chatlab-cli 0.34.3 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/dist/{chat-command-QH7DXCAJ.mjs → chat-command-24RYGJAS.mjs} +8 -8
  2. package/dist/{chunk-2WYXD5ZP.mjs → chunk-22YJOBA3.mjs} +474 -99
  3. package/dist/chunk-22YJOBA3.mjs.map +1 -0
  4. package/dist/{chunk-AWXHYTD5.mjs → chunk-4GWWKHWA.mjs} +42 -14
  5. package/dist/chunk-4GWWKHWA.mjs.map +1 -0
  6. package/dist/{chunk-ZVGDOSGG.mjs → chunk-7IGBPZMI.mjs} +38 -18
  7. package/dist/chunk-7IGBPZMI.mjs.map +1 -0
  8. package/dist/{chunk-WJVE5Q4Y.mjs → chunk-BRZ6YIBR.mjs} +2 -2
  9. package/dist/{chunk-XIWVJAXH.mjs → chunk-DC7IUDNV.mjs} +10 -18
  10. package/dist/chunk-DC7IUDNV.mjs.map +1 -0
  11. package/dist/{chunk-JYBPJWE2.mjs → chunk-DEFEU567.mjs} +10 -18
  12. package/dist/chunk-DEFEU567.mjs.map +1 -0
  13. package/dist/{chunk-C2PD3BS7.mjs → chunk-GQMCDWZQ.mjs} +2 -2
  14. package/dist/{chunk-AWGXYFIC.mjs → chunk-KIMJXKZO.mjs} +2 -2
  15. package/dist/{chunk-SWUTRDGZ.mjs → chunk-KXDJ7N6N.mjs} +2 -2
  16. package/dist/{chunk-3X26JJIP.mjs → chunk-QKEARRFH.mjs} +3 -3
  17. package/dist/{chunk-6U2QZO3N.mjs → chunk-U36TQMAF.mjs} +2 -2
  18. package/dist/{chunk-2Q3HHVTS.mjs → chunk-ZBPPLXM4.mjs} +12 -12
  19. package/dist/cli.mjs +9 -9
  20. package/dist/contacts-worker.mjs +2 -2
  21. package/dist/global-insight-worker.mjs +1 -1
  22. package/dist/{http-D2F4QTQW.mjs → http-3K4YMWDE.mjs} +12 -12
  23. package/dist/{import-H7X2JU2O.mjs → import-D4LV565A.mjs} +7 -7
  24. package/dist/index.mjs +12 -12
  25. package/dist/{mcp-UURXRGDF.mjs → mcp-KL22FKQ2.mjs} +8 -8
  26. package/dist/people-relationships-worker.mjs +2 -2
  27. package/dist/semantic-index-worker.mjs +1 -1
  28. package/dist/{src-MHCO4HYY.mjs → src-COIB6Z4P.mjs} +8 -6
  29. package/dist/{stream-import-BHXACUCA.mjs → stream-import-FSXCFG4M.mjs} +7 -7
  30. package/dist/{worker-runtime-JOUCP2L4.mjs → worker-runtime-DPS2LURI.mjs} +5 -5
  31. package/dist-cli-web/assets/AISettingsTab-rQC2ocFH.js +1 -0
  32. package/dist-cli-web/assets/AboutTab-DMPziKjj.js +1 -0
  33. package/dist-cli-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-CnRLt_1j.js +110 -0
  34. package/dist-cli-web/assets/Alert--bTQXRcZ.js +1 -0
  35. package/dist-cli-web/assets/ApiSettingsTab-CtXl4I28.js +2 -0
  36. package/dist-cli-web/assets/BatchManageTab-1KaCPweN.js +1 -0
  37. package/dist-cli-web/assets/{BufferResource-Dak23r3B.js → BufferResource-BXSJADxx.js} +1 -1
  38. package/dist-cli-web/assets/CanvasRenderer-Cq--8UQ_.js +1 -0
  39. package/dist-cli-web/assets/ChatRecordDrawer-BC0F7ok1.js +11 -0
  40. package/dist-cli-web/assets/ChatRecordDrawer-Tt6UduRC.css +1 -0
  41. package/dist-cli-web/assets/Checkbox-CwajNPGF.js +1 -0
  42. package/dist-cli-web/assets/DataDirCleanupNotice-D0Oruka2.js +1 -0
  43. package/dist-cli-web/assets/DatePicker.vue_vue_type_script_setup_true_lang-C4CsoIlq.js +1 -0
  44. package/dist-cli-web/assets/DebugToolsPanel-DVDwS-wz.js +1 -0
  45. package/dist-cli-web/assets/EChartWordcloud-KV0MdsDE.js +1 -0
  46. package/dist-cli-web/assets/{Filter-CHKZVYB3.js → Filter-DVaqcFmI.js} +1 -1
  47. package/dist-cli-web/assets/GlobalTaskBar-COW_uBX6.css +1 -0
  48. package/dist-cli-web/assets/GlobalTaskBar-DpPMX0jx.js +1 -0
  49. package/dist-cli-web/assets/GroupRelationshipGalaxyView-CLnO3phW.js +1 -0
  50. package/dist-cli-web/assets/Label-Bt2U4lGy.js +1 -0
  51. package/dist-cli-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-Cnshyn0f.js +1 -0
  52. package/dist-cli-web/assets/MessageExportModal-BozaR9UZ.js +1 -0
  53. package/dist-cli-web/assets/PageHeader-CEe0xTl3.js +1 -0
  54. package/dist-cli-web/assets/PageTabs.vue_vue_type_script_setup_true_lang-D2DZrrnv.js +1 -0
  55. package/dist-cli-web/assets/{RelationshipGalaxyCanvas-mJhEPzsY.js → RelationshipGalaxyCanvas-6EamagxG.js} +3 -3
  56. package/dist-cli-web/assets/{RelationshipGalaxyThreeCanvas-Bf76yzmQ.js → RelationshipGalaxyThreeCanvas-B6GB4PWS.js} +166 -166
  57. package/dist-cli-web/assets/{RelationshipGalaxyThreeCanvas-CMuibfiA.css → RelationshipGalaxyThreeCanvas-TYGOUDiv.css} +1 -1
  58. package/dist-cli-web/assets/{RenderTargetSystem-1rM7OF-M.js → RenderTargetSystem-mYuj4uBS.js} +1 -1
  59. package/dist-cli-web/assets/RovingFocusItem-B2y6BG1a.js +1 -0
  60. package/dist-cli-web/assets/ScreenCaptureModal-BvAtSNNR.js +1 -0
  61. package/dist-cli-web/assets/SectionTabs.vue_vue_type_script_setup_true_lang-ueEF4zHE.js +1 -0
  62. package/dist-cli-web/assets/Select-Cm4I8u9n.js +1 -0
  63. package/dist-cli-web/assets/SettingsModal-CjVax3I6.css +1 -0
  64. package/dist-cli-web/assets/SettingsModal-Cwshzj7i.js +2 -0
  65. package/dist-cli-web/assets/StorageTab-D7HzH16Y.js +1 -0
  66. package/dist-cli-web/assets/Switch-BVw4e_19.js +1 -0
  67. package/dist-cli-web/assets/Tabs-Dqwkh3Ea.js +1 -0
  68. package/dist-cli-web/assets/Tabs-OrJkANIA.js +1 -0
  69. package/dist-cli-web/assets/ThemeCard.vue_vue_type_script_setup_true_lang-DPIvbq75.js +1 -0
  70. package/dist-cli-web/assets/TimeSelect.vue_vue_type_script_setup_true_lang-dEdo6CqM.js +1 -0
  71. package/dist-cli-web/assets/VisuallyHiddenInput-BOdkR_GC.js +1 -0
  72. package/dist-cli-web/assets/{WebGLRenderer-Y0jQtBvK.js → WebGLRenderer-BB8ukBI_.js} +2 -2
  73. package/dist-cli-web/assets/{WebGPURenderer-BcUvCPhd.js → WebGPURenderer-DDOzF1Kc.js} +2 -2
  74. package/dist-cli-web/assets/aiChat-CzFSFuOJ.js +8 -0
  75. package/dist-cli-web/assets/annual-summary-time-range-CmrAqcuj.js +1 -0
  76. package/dist-cli-web/assets/base-CawUl6ET.js +1 -0
  77. package/dist-cli-web/assets/{browserAll-BsR1UaCC.js → browserAll-BRqlnNxq.js} +2 -2
  78. package/dist-cli-web/assets/chatlabSiteLocale-CrCNb8QP.js +1 -0
  79. package/dist-cli-web/assets/clamp-jFYhBC76.js +1 -0
  80. package/dist-cli-web/assets/cli-web-ClAJ6Tao.js +1 -0
  81. package/dist-cli-web/assets/{dateFormat-B6JnNCxp.js → dateFormat-DXuDxIye.js} +1 -1
  82. package/dist-cli-web/assets/fetch-3_xX8Yi8.js +1 -0
  83. package/dist-cli-web/assets/{fetch-DGvqctIb.js → fetch-Bcy2T8Fe.js} +1 -1
  84. package/dist-cli-web/assets/{fetch-BAJ_VjWE.js → fetch-CGu53cxT.js} +1 -1
  85. package/dist-cli-web/assets/{fetch-bdY0RMM3.js → fetch-CP1afnT0.js} +1 -1
  86. package/dist-cli-web/assets/{fetch-Clj_RVUD.js → fetch-DWAIk_6_.js} +1 -1
  87. package/dist-cli-web/assets/{fetch-DtnhbqTN.js → fetch-DijSOvop.js} +1 -1
  88. package/dist-cli-web/assets/{fetch-D7vgaLpy.js → fetch-Dy38lkAa.js} +1 -1
  89. package/dist-cli-web/assets/{fetch-bhHY8rO7.js → fetch-DzKlTaLz.js} +1 -1
  90. package/dist-cli-web/assets/{fetch-CPloHijF.js → fetch-LY-yerw1.js} +1 -1
  91. package/dist-cli-web/assets/{fetch-BNcHe2-O.js → fetch-q480XYZQ.js} +1 -1
  92. package/dist-cli-web/assets/index-0dp58uL4.css +1 -0
  93. package/dist-cli-web/assets/index-1X7zdLgJ.css +1 -0
  94. package/dist-cli-web/assets/index-4enwdBcq.css +1 -0
  95. package/dist-cli-web/assets/index-AudHHbMs.js +1 -0
  96. package/dist-cli-web/assets/{index-DMYFpctK.js → index-BRV_D8dv.js} +3 -3
  97. package/dist-cli-web/assets/index-CF4DTbvD.js +1 -0
  98. package/dist-cli-web/assets/index-CMLoht5R.js +1 -0
  99. package/dist-cli-web/assets/index-CMPHZH6B.css +1 -0
  100. package/dist-cli-web/assets/index-CNzv7aBW.js +1 -0
  101. package/dist-cli-web/assets/index-CXUTiy-V.js +1 -0
  102. package/dist-cli-web/assets/index-D5m0P4ss.js +36 -0
  103. package/dist-cli-web/assets/index-Di6FmCdk.js +64 -0
  104. package/dist-cli-web/assets/index-DkOrt7_X.js +2 -0
  105. package/dist-cli-web/assets/index-Dlb6fC68.js +1 -0
  106. package/dist-cli-web/assets/index-IA7YUjQX.js +2 -0
  107. package/dist-cli-web/assets/index-kzU381y1.js +1 -0
  108. package/dist-cli-web/assets/index-z8Vogc-b.js +137 -0
  109. package/dist-cli-web/assets/lazy-overlay-visibility-Bd9ZFOgR.js +1 -0
  110. package/dist-cli-web/assets/member-select-utils-BXZ3oHct.js +1 -0
  111. package/dist-cli-web/assets/people-page-header-Bh3KXD4g.js +1 -0
  112. package/dist-cli-web/assets/prompt-DcAcgQiB.js +1 -0
  113. package/dist-cli-web/assets/relationship-galaxy-connections-Cg4G5yYE.js +1 -0
  114. package/dist-cli-web/assets/semantic-index-config-builder-CK6v64Y1.js +1 -0
  115. package/dist-cli-web/assets/service-YZnJyEMq.js +1 -0
  116. package/dist-cli-web/assets/useFormControl-B-aXrJZN.js +1 -0
  117. package/dist-cli-web/assets/useTable-DPEMaGby.js +1 -0
  118. package/dist-cli-web/assets/useToast-B36MzFFy.js +1 -0
  119. package/dist-cli-web/assets/vendor-echarts-DfAMQxdr.js +11 -0
  120. package/dist-cli-web/assets/{vendor-echarts-wordcloud-Ca8n6qS6.js → vendor-echarts-wordcloud-BsaEJTPY.js} +1 -1
  121. package/dist-cli-web/assets/vendor-zrender-PFmZe1EY.js +8 -0
  122. package/dist-cli-web/assets/{webworkerAll-CfZWlukP.js → webworkerAll-Dwqmy_YO.js} +1 -1
  123. package/dist-cli-web/index.html +2 -2
  124. package/package.json +1 -1
  125. package/dist/chunk-2WYXD5ZP.mjs.map +0 -1
  126. package/dist/chunk-AWXHYTD5.mjs.map +0 -1
  127. package/dist/chunk-JYBPJWE2.mjs.map +0 -1
  128. package/dist/chunk-XIWVJAXH.mjs.map +0 -1
  129. package/dist/chunk-ZVGDOSGG.mjs.map +0 -1
  130. package/dist-cli-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-kN3uxTW8.js +0 -110
  131. package/dist-cli-web/assets/CanvasRenderer-Cmjtvski.js +0 -1
  132. package/dist-cli-web/assets/DataDirCleanupNotice-B5tyDzK-.js +0 -1
  133. package/dist-cli-web/assets/EChartWordcloud-Bd3L3G8I.js +0 -1
  134. package/dist-cli-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-CKf_gC1k.js +0 -1
  135. package/dist-cli-web/assets/MessageExportModal-ODYCcSnk.js +0 -1
  136. package/dist-cli-web/assets/PageHeader-Bn7Jn8JW.js +0 -1
  137. package/dist-cli-web/assets/ThemeCard.vue_vue_type_script_setup_true_lang-CADZpPia.js +0 -1
  138. package/dist-cli-web/assets/TimeSelect.vue_vue_type_script_setup_true_lang-I3FYjhfs.js +0 -1
  139. package/dist-cli-web/assets/annual-summary-time-range-BIADd8qE.js +0 -1
  140. package/dist-cli-web/assets/base-BpxxC5Z5.js +0 -1
  141. package/dist-cli-web/assets/cli-web-BiWUOncc.js +0 -1
  142. package/dist-cli-web/assets/fetch-DSxgaVBO.js +0 -1
  143. package/dist-cli-web/assets/index-B6Gq11lw.css +0 -1
  144. package/dist-cli-web/assets/index-BJ2lywiG.js +0 -1
  145. package/dist-cli-web/assets/index-BT3_fSP6.js +0 -2
  146. package/dist-cli-web/assets/index-BVZhP1J5.js +0 -1
  147. package/dist-cli-web/assets/index-Br8r4pu8.js +0 -1
  148. package/dist-cli-web/assets/index-Byok4VaA.css +0 -1
  149. package/dist-cli-web/assets/index-CKnnxOci.js +0 -1
  150. package/dist-cli-web/assets/index-CXnYfvTv.js +0 -137
  151. package/dist-cli-web/assets/index-CsFLLk3T.css +0 -1
  152. package/dist-cli-web/assets/index-CzoOQ7zg.js +0 -1
  153. package/dist-cli-web/assets/index-D-dTTUGj.js +0 -1
  154. package/dist-cli-web/assets/index-DEbvEKzi.js +0 -2
  155. package/dist-cli-web/assets/index-KO7uPd8W.js +0 -64
  156. package/dist-cli-web/assets/index-lkmJ6dI7.js +0 -1
  157. package/dist-cli-web/assets/index-y7xPDpsW.js +0 -53
  158. package/dist-cli-web/assets/people-page-header-gjTyODWs.js +0 -1
  159. package/dist-cli-web/assets/vendor-echarts-B-i_56Av.js +0 -11
  160. package/dist-cli-web/assets/vendor-zrender-5DcYjSZk.js +0 -8
  161. /package/dist/{chat-command-QH7DXCAJ.mjs.map → chat-command-24RYGJAS.mjs.map} +0 -0
  162. /package/dist/{chunk-WJVE5Q4Y.mjs.map → chunk-BRZ6YIBR.mjs.map} +0 -0
  163. /package/dist/{chunk-C2PD3BS7.mjs.map → chunk-GQMCDWZQ.mjs.map} +0 -0
  164. /package/dist/{chunk-AWGXYFIC.mjs.map → chunk-KIMJXKZO.mjs.map} +0 -0
  165. /package/dist/{chunk-SWUTRDGZ.mjs.map → chunk-KXDJ7N6N.mjs.map} +0 -0
  166. /package/dist/{chunk-3X26JJIP.mjs.map → chunk-QKEARRFH.mjs.map} +0 -0
  167. /package/dist/{chunk-6U2QZO3N.mjs.map → chunk-U36TQMAF.mjs.map} +0 -0
  168. /package/dist/{chunk-2Q3HHVTS.mjs.map → chunk-ZBPPLXM4.mjs.map} +0 -0
  169. /package/dist/{http-D2F4QTQW.mjs.map → http-3K4YMWDE.mjs.map} +0 -0
  170. /package/dist/{import-H7X2JU2O.mjs.map → import-D4LV565A.mjs.map} +0 -0
  171. /package/dist/{mcp-UURXRGDF.mjs.map → mcp-KL22FKQ2.mjs.map} +0 -0
  172. /package/dist/{src-MHCO4HYY.mjs.map → src-COIB6Z4P.mjs.map} +0 -0
  173. /package/dist/{stream-import-BHXACUCA.mjs.map → stream-import-FSXCFG4M.mjs.map} +0 -0
  174. /package/dist/{worker-runtime-JOUCP2L4.mjs.map → worker-runtime-DPS2LURI.mjs.map} +0 -0
@@ -1,110 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-y7xPDpsW.js","assets/vendor-snapdom--nZvo8Sg.js","assets/index-B6Gq11lw.css","assets/EChartWordcloud-Bd3L3G8I.js","assets/vendor-echarts-wordcloud-Ca8n6qS6.js","assets/vendor-echarts-B-i_56Av.js","assets/vendor-zrender-5DcYjSZk.js"])))=>i.map(i=>d[i]);
2
- import{a$ as Wt,a as T,F as t,b0 as dt,d as ce,b1 as Dt,b2 as Ct,b3 as Ns,b4 as ba,b5 as wt,w as fe,o as i,A as W,B as F,r as ye,b6 as Ja,G as E,ao as qe,ae as He,b7 as Et,b8 as Xa,b as z,b9 as Nt,ba as Us,bb as Ws,bc as Hs,bd as Za,D as h,ar as Ge,am as Oe,be as Ks,y as Re,P as tt,bf as ka,bg as xt,a_ as Ae,bh as Je,bi as Ys,bj as Gs,bk as Qs,s as Js,bl as Ra,a8 as Jt,bm as Xs,bn as Zs,bo as es,bp as en,c as m,$ as re,a0 as ve,W as ts,Q as et,bq as tn,U as as,br as an,bs as sn,bt as nn,bu as on,bv as ln,bw as rn,bx as un,by as ss,bz as cn,bA as dn,bB as ht,bC as mn,bD as gn,bE as pn,I as ie,E as d,bF as At,bG as hn,bH as fn,bI as vn,bJ as it,bK as yn,bL as We,bM as ma,e as Ee,av as Xt,N as Ke,bN as xn,C as a,n as J,_ as _e,Z as at,K as Bt,i as bn,p as kn,v as we,H as Ue,J as Xe,a4 as ot,aU as _a,x as bt,aq as ct,al as wa,L as $a,z as ns,bO as Ca,bP as os,a2 as Qe,a3 as ft,ay as ls,V as vt,a9 as Sa,a1 as Ht,bQ as _n,bR as is,bS as rs,bT as wn,bU as Ia,bV as us,bW as Va,bX as zt,bY as Kt,bZ as $n,b_ as Cn,ak as Ft,b$ as qt,ag as Ta,c0 as Ma,c1 as Oa,c2 as Tt,a6 as cs,c3 as ds,af as $t,c4 as Sn,c5 as In,T as pt,aV as Tn,a7 as Ye,aI as ms,c6 as Mn,aL as yt,az as St,c7 as zn,c8 as It,c9 as An,ca as Rt,cb as qn,cc as Ln,cd as Ot,aB as za,aA as Zt,ap as gt,au as gs,ce as Dn,aW as ps,g as Pa,j as En,cf as Bn,a5 as Fn,aC as Rn,cg as Vn,ch as On,ax as Pn,S as jn,as as Nn,u as Un,ci as Wn,cj as Hn,R as Kn,ck as Yn,cl as Gn,aF as Qn,aH as Jn,aG as ja}from"./index-y7xPDpsW.js";import{i as Xn,_ as Yt,u as Zn}from"./LoadingState.vue_vue_type_script_setup_true_lang-CKf_gC1k.js";import{a as Lt,M as Aa,_ as eo}from"./index-DMYFpctK.js";import{_ as mt}from"./ThemeCard.vue_vue_type_script_setup_true_lang-CADZpPia.js";import{C as to,a as ea,_ as rt,g as ga}from"./base-BpxxC5Z5.js";import"./vendor-echarts-wordcloud-Ca8n6qS6.js";import{u as ta,p as hs,z as fs,j as qa,v as vs,i as aa,k as sa,m as ao,n as so,t as no,A as oo}from"./vendor-echarts-B-i_56Av.js";import{f as lo,d as Na}from"./dateFormat-B6JnNCxp.js";import{_ as io}from"./TimeSelect.vue_vue_type_script_setup_true_lang-I3FYjhfs.js";import{P as ro}from"./PageHeader-Bn7Jn8JW.js";function Ut(r,l,e){const n=r.findIndex(c=>Wt(c,l)),s=r.findIndex(c=>Wt(c,e));if(n===-1||s===-1)return[];const[u,o]=[n,s].sort((c,g)=>c-g);return r.slice(u,o+1)}function ys(r){const l=T(()=>t(r)),e=T(()=>new Intl.Collator("en",{usage:"search",...l.value}));return{startsWith:(o,c)=>c.length===0?!0:(o=o.normalize("NFC"),c=c.normalize("NFC"),e.value.compare(o.slice(0,c.length),c)===0),endsWith:(o,c)=>c.length===0?!0:(o=o.normalize("NFC"),c=c.normalize("NFC"),e.value.compare(o.slice(-c.length),c)===0),contains:(o,c)=>{if(c.length===0)return!0;o=o.normalize("NFC"),c=c.normalize("NFC");let g=0;const p=c.length;for(;g+p<=o.length;g++){const v=o.slice(g,g+p);if(e.value.compare(c,v)===0)return!0}return!1}}}function Ua(r){return r?.querySelector("[data-state=checked]")}function uo(r,l,e){return r===void 0?!1:Array.isArray(r)?r.some(n=>ut(n,l,e)):ut(r,l,e)}function ut(r,l,e){return r===void 0||l===void 0?!1:typeof r=="string"?r===l:typeof e=="function"?e(r,l):typeof e=="string"?r?.[e]===l?.[e]:Wt(r,l)}const[Vt,co]=dt("ListboxRoot");var mo=ce({__name:"ListboxRoot",props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},multiple:{type:Boolean,required:!1},orientation:{type:String,required:!1,default:"vertical"},dir:{type:String,required:!1},disabled:{type:Boolean,required:!1},selectionBehavior:{type:String,required:!1,default:"toggle"},highlightOnHover:{type:Boolean,required:!1},by:{type:[String,Function],required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue","highlight","entryFocus","leave"],setup(r,{expose:l,emit:e}){const n=r,s=e,{multiple:u,highlightOnHover:o,orientation:c,disabled:g,selectionBehavior:p,dir:v}=Dt(n),{getItems:_}=Ct({isProvider:!0}),{handleTypeaheadSearch:y}=Ns(),{primitiveElement:k,currentElement:b}=Et(),$=Hs(),C=ba(v),w=Xa(b),S=z(),I=z(!1),f=z(!0),x=wt(n,"modelValue",s,{defaultValue:n.defaultValue??(u.value?[]:void 0),passive:n.modelValue===void 0,deep:!0});function B(le){if(I.value=!0,n.multiple){const Q=Array.isArray(x.value)?[...x.value]:[],X=Q.findIndex(pe=>ut(pe,le,n.by));n.selectionBehavior==="toggle"?(X===-1?Q.push(le):Q.splice(X,1),x.value=Q):(x.value=[le],S.value=le)}else n.selectionBehavior==="toggle"&&ut(x.value,le,n.by)?x.value=void 0:x.value=le;setTimeout(()=>{I.value=!1},1)}const R=z(null),D=z(null),A=z(!1),M=z(!1),q=Nt(),Y=Nt(),G=Nt();function Z(){return _().map(le=>le.ref).filter(le=>le.dataset.disabled!=="")}function ue(le,Q=!0,X){if(!le)return;R.value=le,(X??f.value)&&R.value.focus(),Q&&R.value.scrollIntoView({block:"nearest"});const pe=_().find(ke=>ke.ref===le);s("highlight",pe)}function oe(le){if(A.value)G.trigger(le);else{const Q=_().find(X=>ut(X.value,le,n.by));Q&&(R.value=Q.ref,ue(Q.ref))}}function H(le){R.value&&R.value.isConnected&&(le.preventDefault(),le.stopPropagation(),M.value||R.value.click())}function P(le){if(f.value){if(I.value=!0,A.value)Y.trigger(le);else{const Q=le.altKey||le.ctrlKey||le.metaKey;if(Q&&le.key==="a"&&u.value){const X=_(),pe=X.map($e=>$e.value);x.value=[...pe],le.preventDefault();const ke=X.at(-1);ke&&ue(ke.ref)}else if(!Q){const X=y(le.key,_());X&&ue(X)}}setTimeout(()=>{I.value=!1},1)}}function se(){M.value=!0}function me(){qe(()=>{M.value=!1})}function he(){qe(()=>{const le=new KeyboardEvent("keydown",{key:"PageUp"});N(le)})}function ee(le){const Q=R.value;Q?.isConnected&&(D.value=Q),R.value=null,s("leave",le)}function te(le){const Q=new CustomEvent("listbox.entryFocus",{bubbles:!1,cancelable:!0});if(le.currentTarget?.dispatchEvent(Q),s("entryFocus",Q),!Q.defaultPrevented)if(D.value)ue(D.value);else{const X=Z()?.[0];ue(X)}}function N(le){const Q=Us(le,c.value,C.value);if(!Q)return;let X=Z();if(R.value){if(Q==="last")X.reverse();else if(Q==="prev"||Q==="next"){Q==="prev"&&X.reverse();const pe=X.indexOf(R.value);X=X.slice(pe+1)}de(le,X[0])}if(X.length){const pe=!R.value&&Q==="prev"?X.length-1:0;ue(X[pe])}if(A.value)return Y.trigger(le)}function de(le,Q){if(!(A.value||n.selectionBehavior!=="replace"||!u.value||!Array.isArray(x.value)||(le.altKey||le.ctrlKey||le.metaKey)&&!le.shiftKey)&&le.shiftKey){const pe=_().filter(De=>De.ref.dataset.disabled!=="");let ke=pe.find(De=>De.ref===Q)?.value;if(le.key===$.END?ke=pe.at(-1)?.value:le.key===$.HOME&&(ke=pe[0]?.value),!ke||!S.value)return;const $e=Ut(pe.map(De=>De.value),S.value,ke);x.value=$e}}async function be(le,Q=!0){if(Ws)if(await qe(),A.value)q.trigger({event:le,scroll:Q});else{const X=Z(),pe=X.find($e=>$e.dataset.state==="checked"),ke=Q?void 0:!1;pe?ue(pe,Q,ke):X.length&&ue(X[0],Q,ke)}}let xe=!1;return fe(x,()=>{if(!I.value){const le=xe;xe=!0,qe(()=>{be(void 0,le)})}},{immediate:!0,deep:!0}),l({highlightedElement:R,highlightItem:oe,highlightFirstItem:he,highlightSelected:be,getItems:_}),co({modelValue:x,onValueChange:B,multiple:u,orientation:c,dir:C,disabled:g,highlightOnHover:o,highlightedElement:R,isVirtual:A,virtualFocusHook:q,virtualKeydownHook:Y,virtualHighlightHook:G,by:n.by,firstValue:S,selectionBehavior:p,focusable:f,onLeave:ee,onEnter:te,changeHighlight:ue,onKeydownEnter:H,onKeydownNavigation:N,onKeydownTypeAhead:P,onCompositionStart:se,onCompositionEnd:me,highlightFirstItem:he}),(le,Q)=>(i(),W(t(He),{ref_key:"primitiveElement",ref:k,as:le.as,"as-child":le.asChild,dir:t(C),"data-disabled":t(g)?"":void 0,onPointerleave:ee,onFocusout:Q[0]||(Q[0]=async X=>{const pe=X.relatedTarget||X.target;await qe(),R.value&&t(b)&&!t(b).contains(pe)&&ee(X)})},{default:F(()=>[ye(le.$slots,"default",{modelValue:t(x)}),t(w)&&le.name?(i(),W(t(Ja),{key:0,name:le.name,value:t(x),disabled:t(g),required:le.required},null,8,["name","value","disabled","required"])):E("v-if",!0)]),_:3},8,["as","as-child","dir","data-disabled"]))}}),go=mo,po=ce({__name:"ListboxContent",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(r){const{CollectionSlot:l}=Ct(),e=Vt(),n=Za(!1,10);return(s,u)=>(i(),W(t(l),null,{default:F(()=>[h(t(He),{role:"listbox",as:s.as,"as-child":s.asChild,tabindex:t(e).focusable.value?t(e).highlightedElement.value?"-1":"0":"-1","aria-orientation":t(e).orientation.value,"aria-multiselectable":!!t(e).multiple.value,"data-orientation":t(e).orientation.value,onMousedown:u[0]||(u[0]=Oe(o=>n.value=!0,["left"])),onFocus:u[1]||(u[1]=o=>{t(n)||t(e).onEnter(o)}),onKeydown:[u[2]||(u[2]=Ge(o=>{t(e).orientation.value==="vertical"&&(o.key==="ArrowLeft"||o.key==="ArrowRight")||t(e).orientation.value==="horizontal"&&(o.key==="ArrowUp"||o.key==="ArrowDown")||(o.preventDefault(),t(e).focusable.value&&t(e).onKeydownNavigation(o))},["down","up","left","right","home","end"])),Ge(t(e).onKeydownEnter,["enter"]),t(e).onKeydownTypeAhead]},{default:F(()=>[ye(s.$slots,"default")]),_:3},8,["as","as-child","tabindex","aria-orientation","aria-multiselectable","data-orientation","onKeydown"])]),_:3}))}}),ho=po,fo=ce({__name:"ListboxFilter",props:{modelValue:{type:String,required:!1},autoFocus:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"input"}},emits:["update:modelValue"],setup(r,{emit:l}){const e=r,s=wt(e,"modelValue",l,{defaultValue:"",passive:e.modelValue===void 0}),u=Vt(),{primitiveElement:o,currentElement:c}=Et(),g=T(()=>e.disabled||u.disabled.value||!1),p=z();Ks(()=>p.value=u.highlightedElement.value?.id),Re(()=>{u.focusable.value=!1,setTimeout(()=>{e.autoFocus&&c.value?.focus()},1)}),tt(()=>{u.focusable.value=!0});const{isComposing:v,handleCompositionStart:_,handleCompositionEnd:y}=ka(w=>{s.value=w.target.value,u.onCompositionEnd(),u.highlightFirstItem()});function k(){u.onCompositionStart(),_()}function b(w){v.value||(s.value=w.target.value,u.highlightFirstItem())}function $(w){v.value||(w.preventDefault(),u.onKeydownNavigation(w))}function C(w){v.value||u.onKeydownEnter(w)}return(w,S)=>(i(),W(t(He),{ref_key:"primitiveElement",ref:o,as:w.as,"as-child":w.asChild,value:t(s),disabled:g.value?"":void 0,"data-disabled":g.value?"":void 0,"aria-disabled":g.value??void 0,"aria-activedescendant":p.value,type:"text",onKeydown:[Ge($,["down","up","home","end"]),Ge(C,["enter"])],onInput:b,onCompositionstart:k,onCompositionend:t(y)},{default:F(()=>[ye(w.$slots,"default",{modelValue:t(s)})]),_:3},8,["as","as-child","value","disabled","data-disabled","aria-disabled","aria-activedescendant","onCompositionend"]))}}),vo=fo;const[t2,yo]=dt("ListboxGroup");var xo=ce({__name:"ListboxGroup",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(r){const l=r,e=xt(void 0,"reka-listbox-group");return yo({id:e}),(n,s)=>(i(),W(t(He),Ae({role:"group"},l,{"aria-labelledby":t(e)}),{default:F(()=>[ye(n.$slots,"default")]),_:3},16,["aria-labelledby"]))}}),bo=xo;const ko="listbox.select",[_o,wo]=dt("ListboxItem");var $o=ce({__name:"ListboxItem",props:{value:{type:null,required:!0},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"div"}},emits:["select"],setup(r,{emit:l}){const e=r,n=l,s=xt(void 0,"reka-listbox-item"),{CollectionItem:u}=Ct(),{forwardRef:o,currentElement:c}=Je(),g=Vt(),p=T(()=>c.value!=null&&c.value===g.highlightedElement.value),v=T(()=>uo(g.modelValue.value,e.value,g.by)),_=T(()=>g.disabled.value||e.disabled);async function y(b){n("select",b),!b?.defaultPrevented&&!_.value&&b&&(g.onValueChange(e.value),g.changeHighlight(c.value))}function k(b){const $={originalEvent:b,value:e.value};Gs(ko,y,$)}return wo({isSelected:v}),(b,$)=>(i(),W(t(u),{value:b.value},{default:F(()=>[Ys([p.value,v.value,_.value,t(g).focusable.value],()=>h(t(He),Ae({id:t(s)},b.$attrs,{ref:t(o),role:"option",tabindex:t(g).focusable.value?p.value?"0":"-1":-1,"aria-selected":v.value,as:b.as,"as-child":b.asChild,disabled:_.value?"":void 0,"data-disabled":_.value?"":void 0,"data-highlighted":p.value?"":void 0,"data-state":v.value?"checked":"unchecked",onClick:k,onKeydown:Ge(Oe(k,["prevent"]),["space"]),onPointermove:$[0]||($[0]=()=>{t(g).highlightedElement.value!==t(c)&&t(g).highlightOnHover.value&&t(g).changeHighlight(t(c),!1,!1)})}),{default:F(()=>[ye(b.$slots,"default")]),_:3},16,["id","tabindex","aria-selected","as","as-child","disabled","data-disabled","data-highlighted","data-state","onKeydown"]),$,1)]),_:3},8,["value"]))}}),Co=$o,So=ce({__name:"ListboxItemIndicator",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(r){const l=r;Je();const e=_o();return(n,s)=>t(e).isSelected.value?(i(),W(t(He),Ae({key:0,"aria-hidden":"true"},l),{default:F(()=>[ye(n.$slots,"default")]),_:3},16)):E("v-if",!0)}}),Io=So;function To(r,l,e){const n=new Array(r);return new Proxy(n,{get(s,u,o){if(typeof u=="string"){const c=u.charCodeAt(0);if(c>=48&&c<=57){const g=+u;if(Number.isInteger(g)&&g>=0&&g<r){let p=s[g];if(!p){const v=l[g*2];p=s[g]={index:g,key:e(g),start:v,size:l[g*2+1],end:v+l[g*2+1],lane:0}}return p}}if(u==="length")return r}return Reflect.get(s,u,o)}})}function _t(r,l,e){let n=e.initialDeps??[],s,u=!0;function o(){const c=r();return(c.length!==n.length||c.some((p,v)=>n[v]!==p))&&(n=c,s=l(...c),e?.onChange&&!(u&&e.skipInitialOnChange)&&e.onChange(s),u=!1),s}return o.updateDeps=c=>{n=c},o}function Wa(r,l){if(r===void 0)throw new Error("Unexpected undefined");return r}const Mo=(r,l)=>Math.abs(r-l)<1.01,zo=(r,l,e)=>{let n;return function(...s){r.clearTimeout(n),n=r.setTimeout(()=>l.apply(this,s),e)}};let Mt;const la=()=>{if(Mt!==void 0)return Mt;if(typeof navigator>"u")return Mt=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Mt=!0;const r=navigator.maxTouchPoints;return Mt=navigator.platform==="MacIntel"&&r!==void 0&&r>0},Ha=r=>{const{offsetWidth:l,offsetHeight:e}=r;return{width:l,height:e}},Ao=r=>r,qo=r=>{const l=Math.max(r.startIndex-r.overscan,0),n=Math.min(r.endIndex+r.overscan,r.count-1)-l+1,s=new Array(n);for(let u=0;u<n;u++)s[u]=l+u;return s},Lo=(r,l)=>{const e=r.scrollElement;if(!e)return;const n=r.targetWindow;if(!n)return;const s=o=>{const{width:c,height:g}=o;l({width:Math.round(c),height:Math.round(g)})};if(s(Ha(e)),!n.ResizeObserver)return()=>{};const u=new n.ResizeObserver(o=>{const c=()=>{const g=o[0];if(g?.borderBoxSize){const p=g.borderBoxSize[0];if(p){s({width:p.inlineSize,height:p.blockSize});return}}s(Ha(e))};r.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return u.observe(e,{box:"border-box"}),()=>{u.unobserve(e)}},Gt={passive:!0},Do=typeof window>"u"?!0:"onscrollend"in window,Eo=(r,l,e)=>{const n=r.scrollElement;if(!n)return;const s=r.targetWindow;if(!s)return;const u=r.options.useScrollendEvent&&Do;let o=0;const c=u?null:zo(s,()=>l(o,!1),r.options.isScrollingResetDelay),g=_=>()=>{o=e(n),c?.(),l(o,_)},p=g(!0),v=g(!1);return n.addEventListener("scroll",p,Gt),u&&n.addEventListener("scrollend",v,Gt),()=>{n.removeEventListener("scroll",p),u&&n.removeEventListener("scrollend",v)}},Bo=(r,l)=>Eo(r,l,e=>{const{horizontal:n,isRtl:s}=r.options;return n?e.scrollLeft*(s&&-1||1):e.scrollTop}),Fo=(r,l,e)=>{if(e.options.useCachedMeasurements){const n=e.indexFromElement(r),s=e.options.getItemKey(n);return e.itemSizeCache.get(s)??e.options.estimateSize(n)}if(l?.borderBoxSize){const n=l.borderBoxSize[0];if(n)return Math.round(n[e.options.horizontal?"inlineSize":"blockSize"])}if(!l){const n=e.indexFromElement(r),s=e.options.getItemKey(n),u=e.itemSizeCache.get(s);if(u!==void 0)return u}return r[e.options.horizontal?"offsetWidth":"offsetHeight"]},Ro=(r,{adjustments:l=0,behavior:e},n)=>{var s,u;(u=(s=n.scrollElement)==null?void 0:s.scrollTo)==null||u.call(s,{[n.options.horizontal?"left":"top"]:r+l,behavior:e})},Vo=Ro;class Oo{constructor(l){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e,n,s;return((s=(n=(e=this.targetWindow)==null?void 0:e.performance)==null?void 0:n.now)==null?void 0:s.call(n))??Date.now()},this.observer=(()=>{let e=null;const n=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(s=>{s.forEach(u=>{const o=()=>{const c=u.target,g=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);for(const[p,v]of this.elementsCache)if(v===c){this.elementsCache.delete(p);break}return}this.shouldMeasureDuringScroll(g)&&this.resizeItem(g,this.options.measureElement(c,u,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var s;(s=n())==null||s.disconnect(),e=null},observe:s=>{var u;return(u=n())==null?void 0:u.observe(s,{box:"border-box"})},unobserve:s=>{var u;return(u=n())==null?void 0:u.unobserve(s)}}})(),this.range=null,this.setOptions=e=>{var n,s;const u={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Ao,rangeExtractor:qo,onChange:()=>{},measureElement:Fo,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const y in e){const k=e[y];k!==void 0&&(u[y]=k)}const o=this.options;let c=null,g=null,p=!1;if(o!==void 0&&o.enabled&&u.enabled&&u.anchorTo==="end"&&this.scrollElement!==null){const y=o.count,k=u.count,b=this.getMeasurements(),$=y>0?((n=b[0])==null?void 0:n.key)??o.getItemKey(0):null,C=y>0?((s=b[y-1])==null?void 0:s.key)??o.getItemKey(y-1):null;if(k!==y||y>0&&k>0&&(u.getItemKey(0)!==$||u.getItemKey(k-1)!==C)){p=!0;const I=y>0?this.getVirtualItemForOffset(this.getScrollOffset())??b[0]:null;I&&(c=[I.key,this.getScrollOffset()-I.start]);const f=u.followOnAppend===!0?"auto":u.followOnAppend||null;f&&k>y&&this.isAtEnd(o.scrollEndThreshold)&&(y===0||u.getItemKey(k-1)!==C)&&(g=f)}}this.options=u,p&&(this.pendingMin=0,this.itemSizeCacheVersion++);let v=!1,_=0;if(c&&this.scrollOffset!==null){const[y,k]=c,b=this.getMeasurements(),{count:$,getItemKey:C}=this.options;let w=0;for(;w<$&&C(w)!==y;)w++;if(w<$){const S=b[w];if(S){const I=S.start+k;I!==this.scrollOffset&&(_=I-this.scrollOffset,this.scrollOffset=I,v=!0)}}}(v||g)&&(this.pendingScrollAnchor=[v?c[0]:null,v?c[1]:0,g,_])},this.notify=e=>{var n,s;(s=(n=this.options).onChange)==null||s.call(n,this,e)},this.maybeNotify=_t(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;const n=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==n){if(this.cleanup(),!n){this.maybeNotify();return}if(this.scrollElement=n,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((e=this.scrollElement)==null?void 0:e.window)??null,this.elementsCache.forEach(u=>{this.observer.observe(u)}),this.unsubs.push(this.options.observeElementRect(this,u=>{this.scrollRect=u,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(u,o)=>{if(o&&this._intendedScrollOffset===null&&u===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(u-this._intendedScrollOffset)<1.5&&(u=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const c=this.getScrollOffset();this.scrollDirection=o?c===u?this.scrollDirection:c<u?"forward":"backward":null,this.scrollOffset=u,this.isScrolling=o,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const u=this.scrollElement,o=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},c=()=>{this._iosTouching=!1,!(!la()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};u.addEventListener("touchstart",o,Gt),u.addEventListener("touchend",c,Gt),this.unsubs.push(()=>{u.removeEventListener("touchstart",o),u.removeEventListener("touchend",c),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const s=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,s&&this.scrollElement&&this.options.enabled){const[u,o,c,g]=s;u!==null&&!c&&(la()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?g!==0&&(this._iosDeferredAdjustment+=g):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),c&&this.scrollToEnd({behavior:c})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const e=this.getScrollOffset(),n=this.getMaxScrollOffset();if(e<0||e>n)return;const s=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=s,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=_t(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,n,s,u,o,c,g,p)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMin=null,{count:e,paddingStart:n,scrollMargin:s,getItemKey:u,enabled:o,lanes:c,laneAssignmentMode:g,gap:p}),{key:!1}),this.getMeasurements=_t(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:n,scrollMargin:s,getItemKey:u,enabled:o,lanes:c,laneAssignmentMode:g,gap:p},v)=>{const _=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(const w of this.laneAssignments.keys())w>=e&&this.laneAssignments.delete(w);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(w=>{this.itemSizeCache.set(w.key,w.size)}));const y=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),c===1){const w=e*2;let S=this._flatMeasurements;if(!S||S.length<w){const x=new Float64Array(w);S&&y>0&&x.set(S.subarray(0,y*2)),S=x,this._flatMeasurements=S}let I;if(y===0)I=n+s;else{const x=y-1;I=S[x*2]+S[x*2+1]+p}for(let x=y;x<e;x++){const B=u(x),R=_.get(B),D=typeof R=="number"?R:this.options.estimateSize(x);S[x*2]=I,S[x*2+1]=D,I+=D+p}const f=To(e,S,u);return this.measurementsCache=f,f}const k=this.measurementsCache.slice(0,y),b=new Array(c).fill(void 0),$=new Float64Array(c);let C=0;for(let w=0;w<y;w++){const S=k[w];S&&(b[S.lane]===void 0&&C++,b[S.lane]=w,$[S.lane]=S.end)}for(let w=y;w<e;w++){const S=u(w),I=this.laneAssignments.get(w);let f,x;const B=g==="estimate"||_.has(S);if(I!==void 0&&this.options.lanes>1){f=I;const M=b[f],q=M!==void 0?k[M]:void 0;x=q?q.end+p:n+s}else if(C===c){let M=0,q=$[0],Y=b[0];for(let G=1;G<c;G++){const Z=$[G];(Z<q||Z===q&&b[G]<Y)&&(M=G,q=Z,Y=b[G])}f=M,x=q+p,B&&this.laneAssignments.set(w,f)}else f=w%this.options.lanes,x=n+s,B&&this.laneAssignments.set(w,f);const R=_.get(S),D=typeof R=="number"?R:this.options.estimateSize(w),A=x+D;k[w]={index:w,start:x,size:D,end:A,key:S,lane:f},b[f]===void 0&&C++,b[f]=w,$[f]=A}return this.measurementsCache=k,k},{key:!1,debug:()=>this.options.debug}),this.calculateRange=_t(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,n,s,u)=>e.length===0||n===0?(this.range=null,null):(this.range=jo(e,n,s,u,u===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=_t(()=>{let e=null,n=null;const s=this.calculateRange();return s&&(e=s.startIndex,n=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,n]},(e,n,s,u,o)=>u===null||o===null?[]:e({startIndex:u,endIndex:o,overscan:n,count:s}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{const n=this.options.indexAttribute,s=e.getAttribute(n);return s?parseInt(s,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var n;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const s=this.scrollState.index??((n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index);if(s!==void 0&&this.range){const u=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,s-u),c=Math.min(this.options.count-1,s+u);return e>=o&&e<=c}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((o,c)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(c))});return}const n=this.indexFromElement(e),s=this.options.getItemKey(n),u=this.elementsCache.get(s);u!==e&&(u&&this.observer.unobserve(u),this.observer.observe(e),this.elementsCache.set(s,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,n)=>{var s,u;if(e<0||e>=this.options.count)return;let o,c,g;const p=this._flatMeasurements;if(this.options.lanes===1&&p!==null)g=this.options.getItemKey(e),c=p[e*2],o=p[e*2+1];else{const y=this.measurementsCache[e];if(!y)return;g=y.key,c=y.start,o=y.size}const v=this.itemSizeCache.get(g)??o,_=n-v;if(_!==0){const y=this.options.anchorTo==="end"&&((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,k=y?this.getTotalSize():0,b=((u=this.scrollState)==null?void 0:u.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:g,start:c,size:o,end:c+o,lane:0},_,this):c<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(g)||this.scrollDirection!=="backward"));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(g,n),this.itemSizeCacheVersion++,y?this.applyScrollAdjustment(this.getTotalSize()-k):b&&this.applyScrollAdjustment(_),this.notify(!1)}},this.getVirtualItems=_t(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,n)=>{const s=[];for(let u=0,o=e.length;u<o;u++){const c=e[u],g=n[c];s.push(g)}return s},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{const n=this.getMeasurements();if(n.length===0)return;const s=this._flatMeasurements,u=this.options.lanes===1&&s!=null,o=xs(0,n.length-1,u?c=>s[c*2]:c=>Wa(n[c]).start,e);return Wa(n[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,n,s=0)=>{if(!this.scrollElement)return 0;const u=this.getSize(),o=this.getScrollOffset();n==="auto"&&(n=e>=o+u?"end":"start"),n==="center"?e+=(s-u)/2:n==="end"&&(e-=u);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,e),0)},this.getOffsetForIndex=(e,n="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));const s=this.getSize(),u=this.getScrollOffset(),o=this.measurementsCache[e];if(!o)return;if(n==="auto")if(o.end>=u+s-this.options.scrollPaddingEnd)n="end";else if(o.start<=u+this.options.scrollPaddingStart)n="start";else return[u,n];if(n==="end"&&e===this.options.count-1)return[this.getMaxScrollOffset(),n];const c=n==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,n,o.size),n]},this.scrollToOffset=(e,{align:n="start",behavior:s="auto"}={})=>{const u=this.getOffsetForAlignment(e,n),o=this.now();this.scrollState={index:null,align:n,behavior:s,startedAt:o,lastTargetOffset:u,stableFrames:0},this._scrollToOffset(u,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:n="auto",behavior:s="auto"}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));const u=this.getOffsetForIndex(e,n);if(!u)return;const[o,c]=u,g=this.now();this.scrollState={index:e,align:c,behavior:s,startedAt:g,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:n="auto"}={})=>{const s=this.getScrollOffset()+e,u=this.now();this.scrollState={index:null,align:"start",behavior:n,startedAt:u,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{var e;const n=this.getMeasurements();let s;if(n.length===0)s=this.options.paddingStart;else if(this.options.lanes===1){const u=n.length-1,o=this._flatMeasurements;o!=null?s=o[u*2]+o[u*2+1]:s=((e=n[u])==null?void 0:e.end)??0}else{const u=Array(this.options.lanes).fill(null);let o=n.length-1;for(;o>=0&&u.some(c=>c===null);){const c=n[o];u[c.lane]===null&&(u[c.lane]=c.end),o--}s=Math.max(...u.filter(c=>c!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const e=[];if(this.itemSizeCache.size===0)return e;const n=this.getMeasurements();for(const s of n)s&&this.itemSizeCache.has(s.key)&&e.push({index:s.index,key:s.key,start:s.start,size:s.size,end:s.end,lane:s.lane});return e},this._scrollToOffset=(e,{adjustments:n,behavior:s})=>{this._intendedScrollOffset=e+(n??0),this.options.scrollToFn(e,{behavior:s,adjustments:n},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(l)}applyScrollAdjustment(l,e){l!==0&&(la()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=l:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:e}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const n=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,s=n?n[0]:this.scrollState.lastTargetOffset,u=1,o=s!==this.scrollState.lastTargetOffset;if(!o&&Mo(s,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=u){this.getScrollOffset()!==s&&this._scrollToOffset(s,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const c=this.getSize()||600,g=Math.abs(s-this.getScrollOffset()),p=this.scrollState.behavior==="smooth"&&g>c;this.scrollState.lastTargetOffset=s,p||(this.scrollState.behavior="auto"),this._scrollToOffset(s,{adjustments:void 0,behavior:p?"smooth":"auto"})}this.scheduleScrollReconcile()}}const xs=(r,l,e,n)=>{for(;r<=l;){const s=(r+l)/2|0,u=e(s);if(u<n)r=s+1;else if(u>n)l=s-1;else return s}return r>0?r-1:0};function Po(r,l,e){let n=0;for(;n<=l;){const s=(n+l)/2|0,u=r[s*2];if(u<e)n=s+1;else if(u>e)l=s-1;else return s}return n>0?n-1:0}function jo(r,l,e,n,s){const u=r.length-1;if(r.length<=n)return{startIndex:0,endIndex:u};if(n===1&&s!==null){const p=Po(s,u,e);let v=p;const _=e+l;for(;v<u&&s[v*2]+s[v*2+1]<_;)v++;return{startIndex:p,endIndex:v}}let c=xs(0,u,p=>r[p].start,e),g=c;if(n===1)for(;g<u&&r[g].end<e+l;)g++;else if(n>1){const p=Array(n).fill(0);for(;g<u&&p.some(_=>_<e+l);){const _=r[g];p[_.lane]=_.end,g++}const v=Array(n).fill(e+l);for(;c>=0&&v.some(_=>_>=e);){const _=r[c];v[_.lane]=_.start,c--}c=Math.max(0,c-c%n),g=Math.min(u,g+(n-1-g%n))}return{startIndex:c,endIndex:g}}function No(r){const l=new Oo(t(r)),e=Js(l),n=l._didMount();return fe(()=>t(r).getScrollElement(),s=>{s&&l._willUpdate()},{immediate:!0}),fe(()=>t(r),s=>{l.setOptions({...s,onChange:(u,o)=>{var c;Ra(e),(c=s.onChange)==null||c.call(s,u,o)}}),l._willUpdate(),Ra(e)},{immediate:!0}),Qs(n),e}function Uo(r){return No(T(()=>({observeElementRect:Lo,observeElementOffset:Bo,scrollToFn:Vo,...t(r)})))}var Wo=ce({__name:"ListboxVirtualizer",props:{options:{type:Array,required:!0},overscan:{type:Number,required:!1},estimateSize:{type:[Number,Function],required:!1},textContent:{type:Function,required:!1}},setup(r){const l=r,e=Jt(),n=Vt(),s=Xs(),{getItems:u}=Ct();n.isVirtual.value=!0;const o=T(()=>{const y=s.value;if(y){const k=window.getComputedStyle(y);return{start:Number.parseFloat(k.paddingBlockStart||k.paddingTop),end:Number.parseFloat(k.paddingBlockEnd||k.paddingBottom)}}else return{start:0,end:0}}),c=Uo({get scrollPaddingStart(){return o.value.start},get scrollPaddingEnd(){return o.value.end},get count(){return l.options.length},get horizontal(){return n.orientation.value==="horizontal"},estimateSize(y){return typeof l.estimateSize=="function"?l.estimateSize(y):l.estimateSize??28},getScrollElement(){return s.value},overscan:l.overscan??12}),g=T(()=>c.value.getVirtualItems().map(y=>{const k=e.default({option:l.options[y.index],virtualizer:c.value,virtualItem:y})[0],b=k.type===re&&Array.isArray(k.children)?k.children.find($=>typeof $.type!="symbol"):k;return{item:y,is:tn(b,{key:`${y.key}`,"data-index":y.index,"aria-setsize":l.options.length,"aria-posinset":y.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${y.start}px)`,overflowAnchor:"none"}})}}));n.virtualFocusHook.on(({event:y,scroll:k})=>{const b=l.options.findIndex($=>Array.isArray(n.modelValue.value)?ut($,n.modelValue.value[0],n.by):ut($,n.modelValue.value,n.by));b!==-1?(y?.preventDefault(),c.value.scrollToIndex(b,{align:"start"}),requestAnimationFrame(()=>{const $=Ua(s.value);$&&(n.changeHighlight($,k,k?void 0:!1),y&&$?.focus())})):k?n.highlightFirstItem():requestAnimationFrame(()=>{const $=u().find(C=>C.ref.dataset.disabled!=="")?.ref;$&&n.changeHighlight($,!1,!1)})}),n.virtualHighlightHook.on(y=>{const k=l.options.findIndex(b=>ut(b,y,n.by));c.value.scrollToIndex(k,{align:"start"}),requestAnimationFrame(()=>{const b=Ua(s.value);b&&n.changeHighlight(b)})});const p=Za("",1e3),v=T(()=>{const y=k=>l.textContent?l.textContent(k):k?.toString().toLowerCase();return l.options.map((k,b)=>({index:b,textContent:y(k)}))});function _(y,k){if(!n.firstValue?.value||!n.multiple.value||!Array.isArray(n.modelValue.value))return;const $=u().filter(w=>w.ref.dataset.disabled!=="").find(w=>w.ref===n.highlightedElement.value)?.value;if(!$)return;let C=null;switch(k){case"prev":case"next":{C=Ut(l.options,n.firstValue.value,$);break}case"first":{C=Ut(l.options,n.firstValue.value,l.options?.[0]);break}case"last":{C=Ut(l.options,n.firstValue.value,l.options.at(-1));break}}n.modelValue.value=C}return n.virtualKeydownHook.on(y=>{const k=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!k)return;let $=Zs[y.key];if(k&&y.key==="a"&&n.multiple.value?(y.preventDefault(),n.modelValue.value=[...l.options],$="last"):y.shiftKey&&$&&_(y,$),["first","last"].includes($)){y.preventDefault();const C=$==="first"?0:l.options.length-1;c.value.scrollToIndex(C),requestAnimationFrame(()=>{const w=u(),S=$==="first"?w[0]:w.at(-1);S&&n.changeHighlight(S.ref)})}else if(!$&&!k){p.value+=y.key;const C=Number(es()?.getAttribute("data-index")),w=v.value[C].textContent,S=v.value.map(x=>x.textContent??""),I=en(S,p.value,w),f=v.value.find(x=>x.textContent===I);f&&(c.value.scrollToIndex(f.index,{align:"start"}),requestAnimationFrame(()=>{const x=s.value.querySelector(`[data-index="${f.index}"]`);x instanceof HTMLElement&&n.changeHighlight(x)}))}}),(y,k)=>(i(),m("div",{"data-reka-virtualizer":"",style:et({position:"relative",width:"100%",height:`${t(c).getTotalSize()}px`})},[(i(!0),m(re,null,ve(g.value,({is:b,item:$})=>(i(),W(ts(b),{key:$.index}))),128))],4))}}),Ho=Wo;const[st,Ko]=dt("ComboboxRoot");var Yo=ce({__name:"ComboboxRoot",props:{open:{type:Boolean,required:!1,default:void 0},defaultOpen:{type:Boolean,required:!1},resetSearchTermOnBlur:{type:Boolean,required:!1,default:!0},resetSearchTermOnSelect:{type:Boolean,required:!1,default:!0},openOnFocus:{type:Boolean,required:!1,default:!1},openOnClick:{type:Boolean,required:!1,default:!1},ignoreFilter:{type:Boolean,required:!1},resetModelValueOnClear:{type:Boolean,required:!1,default:!1},modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},multiple:{type:Boolean,required:!1},dir:{type:String,required:!1},disabled:{type:Boolean,required:!1},highlightOnHover:{type:Boolean,required:!1,default:!0},by:{type:[String,Function],required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue","highlight","update:open"],setup(r,{expose:l,emit:e}){const n=r,s=e,{primitiveElement:u,currentElement:o}=Et(),{multiple:c,disabled:g,ignoreFilter:p,resetSearchTermOnSelect:v,openOnFocus:_,openOnClick:y,dir:k,resetModelValueOnClear:b,highlightOnHover:$}=Dt(n),C=ba(k),w=wt(n,"modelValue",s,{defaultValue:n.defaultValue??(c.value?[]:void 0),passive:n.modelValue===void 0,deep:!0}),S=wt(n,"open",s,{defaultValue:n.defaultOpen,passive:n.open===void 0});async function I(oe){S.value=oe,G.value="",oe?(await qe(),u.value?.highlightSelected(),x.value=!0,R.value?.focus()):(x.value=!1,setTimeout(()=>{!oe&&n.resetSearchTermOnBlur&&f.trigger()},1))}const f=Nt(),x=z(!1),B=z(!1),R=z(),D=z(),A=T(()=>u.value?.highlightedElement??void 0),M=z(new Map),q=z(new Map),{contains:Y}=ys({sensitivity:"base"}),G=z(""),Z=T(oe=>{if(!G.value||n.ignoreFilter||B.value)return{count:M.value.size,items:oe?.items??new Map,groups:oe?.groups??new Set(q.value.keys())};let H=0;const P=new Map,se=new Set;for(const[me,he]of M.value){const ee=Y(he,G.value);P.set(me,ee?1:0),ee&&H++}for(const[me,he]of q.value)for(const ee of he)if(P.get(ee)>0){se.add(me);break}return{count:H,items:P,groups:se}}),ue=sn();return Re(()=>{ue?.exposed&&(ue.exposed.highlightItem=u.value?.highlightItem,ue.exposed.highlightFirstItem=u.value?.highlightFirstItem,ue.exposed.highlightSelected=u.value?.highlightSelected)}),l({filtered:Z,highlightedElement:A,highlightItem:u.value?.highlightItem,highlightFirstItem:u.value?.highlightFirstItem,highlightSelected:u.value?.highlightSelected}),Ko({modelValue:w,multiple:c,disabled:g,open:S,onOpenChange:I,contentId:"",isUserInputted:x,isVirtual:B,inputElement:R,highlightedElement:A,onInputElementChange:oe=>R.value=oe,triggerElement:D,onTriggerElementChange:oe=>D.value=oe,parentElement:o,resetSearchTermOnSelect:v,onResetSearchTerm:f.on,allItems:M,allGroups:q,filterSearch:G,filterState:Z,ignoreFilter:p,openOnFocus:_,openOnClick:y,resetModelValueOnClear:b}),(oe,H)=>(i(),W(t(an),null,{default:F(()=>[h(t(go),Ae({ref_key:"primitiveElement",ref:u},oe.$attrs,{modelValue:t(w),"onUpdate:modelValue":H[0]||(H[0]=P=>as(w)?w.value=P:null),style:{pointerEvents:t(S)?"auto":void 0},as:oe.as,"as-child":oe.asChild,dir:t(C),multiple:t(c),name:oe.name,required:oe.required,disabled:t(g),"highlight-on-hover":t($),by:n.by,onHighlight:H[1]||(H[1]=P=>s("highlight",P))}),{default:F(()=>[ye(oe.$slots,"default",{open:t(S),modelValue:t(w)})]),_:3},16,["modelValue","style","as","as-child","dir","multiple","name","required","disabled","highlight-on-hover","by"])]),_:3}))}}),Go=Yo,Qo=ce({__name:"ComboboxAnchor",props:{reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(r){const{forwardRef:l}=Je();return(e,n)=>(i(),W(t(nn),{"as-child":"",reference:e.reference},{default:F(()=>[h(t(He),Ae({ref:t(l),"as-child":e.asChild,as:e.as},e.$attrs),{default:F(()=>[ye(e.$slots,"default")]),_:3},16,["as-child","as"])]),_:3},8,["reference"]))}}),Jo=Qo;const[Xo,Zo]=dt("ComboboxContent");var el=ce({__name:"ComboboxContentImpl",props:{position:{type:String,required:!1,default:"inline"},bodyLock:{type:Boolean,required:!1},hideWhenEmpty:{type:Boolean,required:!1},side:{type:null,required:!1},sideOffset:{type:Number,required:!1},sideFlip:{type:Boolean,required:!1},align:{type:null,required:!1},alignOffset:{type:Number,required:!1},alignFlip:{type:Boolean,required:!1},avoidCollisions:{type:Boolean,required:!1},collisionBoundary:{type:null,required:!1},collisionPadding:{type:[Number,Object],required:!1},arrowPadding:{type:Number,required:!1},hideShiftedArrow:{type:Boolean,required:!1},sticky:{type:String,required:!1},hideWhenDetached:{type:Boolean,required:!1},positionStrategy:{type:String,required:!1},updatePositionStrategy:{type:String,required:!1},disableUpdateOnLayoutShift:{type:Boolean,required:!1},prioritizePosition:{type:Boolean,required:!1},reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},disableOutsidePointerEvents:{type:Boolean,required:!1}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside"],setup(r,{emit:l}){const e=r,n=l,{position:s}=Dt(e),u=st(),o=T(()=>u.ignoreFilter.value?u.allItems.value.size===0:u.filterState.value.count===0),{forwardRef:c,currentElement:g}=Je();on(e.bodyLock),ln(),rn(u.parentElement);const p=T(()=>e.position==="popper"?e:{}),v=un(p.value),_={boxSizing:"border-box","--reka-combobox-content-transform-origin":"var(--reka-popper-transform-origin)","--reka-combobox-content-available-width":"var(--reka-popper-available-width)","--reka-combobox-content-available-height":"var(--reka-popper-available-height)","--reka-combobox-trigger-width":"var(--reka-popper-anchor-width)","--reka-combobox-trigger-height":"var(--reka-popper-anchor-height)"};Zo({position:s});const y=z(!1);Re(()=>{u.inputElement.value&&(y.value=g.value.contains(u.inputElement.value),y.value&&u.inputElement.value.focus())}),tt(()=>{const b=es();y.value&&(!b||b===document.body)&&u.triggerElement.value?.focus()});function k(b){if(u.parentElement.value?.contains(b))return!0;const C=(b instanceof Element?b.closest("label"):null)?.control;return!!C&&!!u.parentElement.value?.contains(C)}return(b,$)=>(i(),W(t(ho),{"as-child":""},{default:F(()=>[h(t(ss),{"as-child":"",onMountAutoFocus:$[5]||($[5]=Oe(()=>{},["prevent"])),onUnmountAutoFocus:$[6]||($[6]=Oe(()=>{},["prevent"]))},{default:F(()=>[h(t(cn),{"as-child":"","disable-outside-pointer-events":b.disableOutsidePointerEvents,onDismiss:$[0]||($[0]=C=>t(u).onOpenChange(!1)),onFocusOutside:$[1]||($[1]=C=>{k(C.target)&&C.preventDefault(),n("focusOutside",C)}),onInteractOutside:$[2]||($[2]=C=>n("interactOutside",C)),onEscapeKeyDown:$[3]||($[3]=C=>n("escapeKeyDown",C)),onPointerDownOutside:$[4]||($[4]=C=>{k(C.target)&&C.preventDefault(),n("pointerDownOutside",C)})},{default:F(()=>[(i(),W(ts(t(s)==="popper"?t(dn):t(He)),Ae({...b.$attrs,...t(v)},{id:t(u).contentId,ref:t(c),"data-state":t(u).open.value?"open":"closed","data-empty":o.value?"":void 0,style:{display:e.hideWhenEmpty&&o.value?"none":"flex",flexDirection:"column",outline:"none",...t(s)==="popper"?_:{}}}),{default:F(()=>[ye(b.$slots,"default")]),_:3},16,["id","data-state","data-empty","style"]))]),_:3},8,["disable-outside-pointer-events"])]),_:3})]),_:3}))}}),tl=el,al=ce({__name:"ComboboxArrow",props:{width:{type:Number,required:!1,default:10},height:{type:Number,required:!1,default:5},rounded:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"svg"}},setup(r){const l=r,e=st(),n=Xo();return Je(),(s,u)=>t(e).open.value&&t(n).position.value==="popper"?(i(),W(t(mn),ht(Ae({key:0},l)),{default:F(()=>[ye(s.$slots,"default")]),_:3},16)):E("v-if",!0)}}),sl=al,nl=ce({__name:"ComboboxCancel",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(r){const l=r;Je();const e=st();function n(){e.filterSearch.value="",e.inputElement.value&&(e.inputElement.value.value="",e.inputElement.value.focus()),e.resetModelValueOnClear?.value&&(e.modelValue.value=e.multiple.value?[]:null)}return(s,u)=>(i(),W(t(He),Ae({type:s.as==="button"?"button":void 0},l,{tabindex:"-1",onClick:n}),{default:F(()=>[ye(s.$slots,"default")]),_:3},16,["type"]))}}),ol=nl,ll=ce({__name:"ComboboxContent",props:{forceMount:{type:Boolean,required:!1},position:{type:String,required:!1},bodyLock:{type:Boolean,required:!1},hideWhenEmpty:{type:Boolean,required:!1},side:{type:null,required:!1},sideOffset:{type:Number,required:!1},sideFlip:{type:Boolean,required:!1},align:{type:null,required:!1},alignOffset:{type:Number,required:!1},alignFlip:{type:Boolean,required:!1},avoidCollisions:{type:Boolean,required:!1},collisionBoundary:{type:null,required:!1},collisionPadding:{type:[Number,Object],required:!1},arrowPadding:{type:Number,required:!1},hideShiftedArrow:{type:Boolean,required:!1},sticky:{type:String,required:!1},hideWhenDetached:{type:Boolean,required:!1},positionStrategy:{type:String,required:!1},updatePositionStrategy:{type:String,required:!1},disableUpdateOnLayoutShift:{type:Boolean,required:!1},prioritizePosition:{type:Boolean,required:!1},reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},disableOutsidePointerEvents:{type:Boolean,required:!1}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside"],setup(r,{emit:l}){const s=gn(r,l),{forwardRef:u}=Je(),o=st();return o.contentId||=xt(void 0,"reka-combobox-content"),(c,g)=>(i(),W(t(pn),{present:c.forceMount||t(o).open.value},{default:F(()=>[h(tl,Ae({...t(s),...c.$attrs},{ref:t(u)}),{default:F(()=>[ye(c.$slots,"default")]),_:3},16)]),_:3},8,["present"]))}}),il=ll,rl=ce({__name:"ComboboxEmpty",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(r){const l=r,e=st(),n=T(()=>e.ignoreFilter.value?e.allItems.value.size===0:e.filterState.value.count===0);return(s,u)=>n.value?(i(),W(t(He),ht(Ae({key:0},l)),{default:F(()=>[ye(s.$slots,"default",{},()=>[u[0]||(u[0]=ie("No options"))])]),_:3},16)):E("v-if",!0)}}),ul=rl;const[bs,cl]=dt("ComboboxGroup");var dl=ce({__name:"ComboboxGroup",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(r){const l=r,e=xt(void 0,"reka-combobox-group"),n=st(),s=T(()=>n.ignoreFilter.value?!0:n.filterSearch.value?n.filterState.value.groups.has(e):!0),u=cl({id:e,labelId:""});return Re(()=>{n.allGroups.value.has(e)||n.allGroups.value.set(e,new Set)}),tt(()=>{n.allGroups.value.delete(e)}),(o,c)=>(i(),W(t(bo),Ae({id:t(e),"aria-labelledby":t(u).labelId},l,{hidden:s.value?void 0:!0}),{default:F(()=>[ye(o.$slots,"default")]),_:3},16,["id","aria-labelledby","hidden"]))}}),ia=dl,ml=ce({__name:"ComboboxInput",props:{displayValue:{type:Function,required:!1},modelValue:{type:String,required:!1},autoFocus:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"input"}},emits:["update:modelValue"],setup(r,{emit:l}){const e=r,n=l,s=st(),u=Vt(),{primitiveElement:o,currentElement:c}=Et(),g=wt(e,"modelValue",n,{passive:e.modelValue===void 0});Re(()=>{c.value&&s.onInputElementChange(c.value)});const{isComposing:p,handleCompositionStart:v,handleCompositionEnd:_}=ka(I=>{const f=I.target;f&&k(f.value)});function y(I){p.value||(I.preventDefault(),s.open.value||s.onOpenChange(!0))}function k(I){s.open.value?s.filterSearch.value=I:(s.onOpenChange(!0),qe(()=>{I&&(s.filterSearch.value=I,u.highlightFirstItem())}))}function b(I){p.value||k(I.target.value)}function $(){s.openOnFocus.value&&!s.open.value&&s.onOpenChange(!0)}function C(I){if(!s.open.value)return;const f=I.relatedTarget;if(!f)return;const x=s.parentElement.value?.contains(f),B=document.getElementById(s.contentId)?.contains(f);!x&&!B&&requestAnimationFrame(()=>{if(!s.open.value)return;const R=document.activeElement;!s.parentElement.value?.contains(R)&&!document.getElementById(s.contentId)?.contains(R)&&s.onOpenChange(!1)})}function w(){s.openOnClick.value&&!s.open.value&&s.onOpenChange(!0)}function S(){const I=s.modelValue.value;e.displayValue?g.value=e.displayValue(I):!s.multiple.value&&I&&!Array.isArray(I)&&typeof I!="object"?g.value=I.toString():g.value="",qe(()=>{g.value=g.value})}return s.onResetSearchTerm(()=>{S()}),fe(s.modelValue,async()=>{!s.isUserInputted.value&&s.resetSearchTermOnSelect.value&&S()},{immediate:!0,deep:!0}),fe(s.filterState,(I,f)=>{!s.isVirtual.value&&f.count===0&&u.highlightFirstItem()}),(I,f)=>(i(),W(t(vo),{ref_key:"primitiveElement",ref:o,modelValue:t(g),"onUpdate:modelValue":f[0]||(f[0]=x=>as(g)?g.value=x:null),as:I.as,"as-child":I.asChild,"auto-focus":I.autoFocus,disabled:I.disabled,"aria-expanded":t(s).open.value,"aria-controls":t(s).contentId,"aria-autocomplete":"list",role:"combobox",autocomplete:"off",onClick:w,onInput:b,onKeydown:Ge(y,["down","up"]),onFocus:$,onBlur:C,onCompositionstart:t(v),onCompositionend:t(_)},{default:F(()=>[ye(I.$slots,"default")]),_:3},8,["modelValue","as","as-child","auto-focus","disabled","aria-expanded","aria-controls","onCompositionstart","onCompositionend"]))}}),gl=ml,pl=ce({__name:"ComboboxItem",props:{textValue:{type:String,required:!1},value:{type:null,required:!0},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["select"],setup(r,{emit:l}){const e=r,n=l,s=xt(void 0,"reka-combobox-item"),u=st(),o=bs(null),{primitiveElement:c,currentElement:g}=Et();if(e.value==="")throw new Error("A <ComboboxItem /> must have a value prop that is not an empty string. This is because the Combobox value can be set to an empty string to clear the selection and show the placeholder.");const p=T(()=>{if(u.isVirtual.value||u.ignoreFilter.value||!u.filterSearch.value)return!0;{const v=u.filterState.value.items.get(s);return v===void 0?!0:v>0}});return Re(()=>{u.allItems.value.set(s,e.textValue||g.value.textContent||g.value.innerText);const v=o?.id;v&&(u.allGroups.value.has(v)?u.allGroups.value.get(v)?.add(s):u.allGroups.value.set(v,new Set([s])))}),tt(()=>{u.allItems.value.delete(s)}),(v,_)=>p.value?(i(),W(t(Co),Ae({key:0},e,{id:t(s),ref_key:"primitiveElement",ref:c,disabled:t(u).disabled.value||v.disabled,onSelect:_[0]||(_[0]=y=>{n("select",y),!y.defaultPrevented&&(!t(u).multiple.value&&!v.disabled&&!t(u).disabled.value?(y.preventDefault(),t(u).onOpenChange(!1),t(u).modelValue.value=e.value):t(u).multiple.value&&t(u).inputElement.value?.focus())})}),{default:F(()=>[ye(v.$slots,"default",{},()=>[ie(d(v.value),1)])]),_:3},16,["id","disabled"])):E("v-if",!0)}}),Ka=pl,hl=ce({__name:"ComboboxItemIndicator",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(r){const l=r;return(e,n)=>(i(),W(t(Io),ht(At(l)),{default:F(()=>[ye(e.$slots,"default")]),_:3},16))}}),fl=hl,vl=ce({__name:"ComboboxLabel",props:{for:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"div"}},setup(r){const l=r;Je();const e=bs({id:"",labelId:""});return e.labelId||=xt(void 0,"reka-combobox-group-label"),(n,s)=>(i(),W(t(He),Ae(l,{id:t(e).labelId}),{default:F(()=>[ye(n.$slots,"default")]),_:3},16,["id"]))}}),yl=vl,xl=ce({__name:"ComboboxPortal",props:{to:{type:null,required:!1},disabled:{type:Boolean,required:!1},defer:{type:Boolean,required:!1},forceMount:{type:Boolean,required:!1}},setup(r){const l=r;return(e,n)=>(i(),W(t(hn),ht(At(l)),{default:F(()=>[ye(e.$slots,"default")]),_:3},16))}}),bl=xl,kl=ce({__name:"ComboboxSeparator",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(r){const l=r;return Je(),(e,n)=>(i(),W(t(He),Ae(l,{"aria-hidden":"true"}),{default:F(()=>[ye(e.$slots,"default")]),_:3},16))}}),_l=kl,wl=ce({__name:"ComboboxTrigger",props:{disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(r){const l=r,{forwardRef:e,currentElement:n}=Je(),s=st(),u=T(()=>l.disabled||s.disabled.value||!1);return Re(()=>{n.value&&s.onTriggerElementChange(n.value)}),(o,c)=>(i(),W(t(He),Ae(l,{ref:t(e),type:o.as==="button"?"button":void 0,tabindex:"-1","aria-label":"Show popup","aria-haspopup":"listbox","aria-expanded":t(s).open.value,"aria-controls":t(s).contentId,"data-state":t(s).open.value?"open":"closed",disabled:u.value,"data-disabled":u.value?"":void 0,"aria-disabled":u.value??void 0,onClick:c[0]||(c[0]=g=>t(s).onOpenChange(!t(s).open.value))}),{default:F(()=>[ye(o.$slots,"default")]),_:3},16,["type","aria-expanded","aria-controls","data-state","disabled","data-disabled","aria-disabled"]))}}),$l=wl,Cl=ce({__name:"ComboboxVirtualizer",props:{options:{type:Array,required:!0},overscan:{type:Number,required:!1},estimateSize:{type:[Number,Function],required:!1},textContent:{type:Function,required:!1}},setup(r){const l=r,e=st();return e.isVirtual.value=!0,(n,s)=>(i(),W(Ho,ht(At(l)),{default:F(u=>[ye(n.$slots,"default",ht(At(u)))]),_:3},16))}}),Sl=Cl;const[La,Il]=dt("TagsInputRoot");var Tl=ce({__name:"TagsInputRoot",props:{modelValue:{type:[Array,null],required:!1},defaultValue:{type:Array,required:!1,default:()=>[]},addOnPaste:{type:Boolean,required:!1},addOnTab:{type:Boolean,required:!1},addOnBlur:{type:Boolean,required:!1},duplicate:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},delimiter:{type:null,required:!1,default:","},dir:{type:String,required:!1},max:{type:Number,required:!1,default:0},id:{type:String,required:!1},convertValue:{type:Function,required:!1},displayValue:{type:Function,required:!1,default:r=>r.toString()},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue","invalid","addTag","removeTag"],setup(r,{emit:l}){const e=r,n=l,{addOnPaste:s,disabled:u,delimiter:o,max:c,id:g,dir:p,addOnBlur:v,addOnTab:_}=Dt(e),y=ba(p),k=wt(e,"modelValue",n,{defaultValue:e.defaultValue,passive:!0,deep:!0}),{forwardRef:b,currentElement:$}=Je(),{focused:C}=fn($),w=Xa($),{getItems:S,CollectionSlot:I}=Ct({isProvider:!0}),f=z(),x=z(!1),B=T(()=>Array.isArray(k.value)?[...k.value]:[]);function R(D){if(D!==-1){const A=S().filter(M=>M.ref.dataset.disabled!=="");k.value=k.value.filter((M,q)=>q!==D),n("removeTag",A[D].value)}}return Il({modelValue:k,onAddValue:D=>{const A=[...B.value],M=A.length>0&&typeof A[0]=="object",q=A.length>0&&typeof e.defaultValue[0]=="object";if((M||q)&&typeof e.convertValue!="function")throw new Error("You must provide a `convertValue` function when using objects as values.");const Y=e.convertValue?e.convertValue(D):D;if(A.length>=c.value&&c.value)return n("invalid",Y),!1;if(e.duplicate)return k.value=[...A,Y],n("addTag",Y),!0;if(A.includes(Y))x.value=!0;else return k.value=[...A,Y],n("addTag",Y),!0;return n("invalid",Y),!1},onRemoveValue:R,onInputKeydown:D=>{if(D.isComposing)return;const A=D.target,M=S().map(Y=>Y.ref).filter(Y=>Y.dataset.disabled!=="");if(!M.length)return;const q=M.at(-1);switch(D.key){case"Delete":case"Backspace":{if(A.selectionStart!==0||A.selectionEnd!==0)break;if(f.value){const Y=M.findIndex(G=>G===f.value);R(Y),f.value=f.value===q?M.at(Y-1):M.at(Y+1),D.preventDefault()}else D.key==="Backspace"&&(f.value=q,D.preventDefault());break}case"Home":case"End":case"ArrowRight":case"ArrowLeft":{const Y=D.key==="ArrowRight"&&y.value==="ltr"||D.key==="ArrowLeft"&&y.value==="rtl",G=!Y;if(A.selectionStart!==0||A.selectionEnd!==0)break;if(G&&!f.value)f.value=q,D.preventDefault();else if(Y&&q&&f.value===q)f.value=void 0,D.preventDefault();else if(f.value){const Z=vn(D,f.value,void 0,{itemsArray:M,loop:!1,dir:y.value});Z&&(f.value=Z),D.preventDefault()}break}case"ArrowUp":case"ArrowDown":{f.value&&D.preventDefault();break}default:f.value=void 0}},selectedElement:f,isInvalidInput:x,addOnPaste:s,addOnBlur:v,addOnTab:_,dir:y,disabled:u,delimiter:o,max:c,id:g,displayValue:e.displayValue}),(D,A)=>(i(),W(t(I),null,{default:F(()=>[h(t(He),{ref:t(b),dir:t(y),as:D.as,"as-child":D.asChild,"data-invalid":x.value?"":void 0,"data-disabled":t(u)?"":void 0,"data-focused":t(C)?"":void 0},{default:F(()=>[ye(D.$slots,"default",{modelValue:t(k)}),t(w)&&D.name?(i(),W(t(Ja),{key:0,name:D.name,value:t(k),required:D.required,disabled:t(u)},null,8,["name","value","required","disabled"])):E("v-if",!0)]),_:3},8,["dir","as","as-child","data-invalid","data-disabled","data-focused"])]),_:3}))}}),Ml=Tl,zl=ce({__name:"TagsInputInput",props:{placeholder:{type:String,required:!1},autoFocus:{type:Boolean,required:!1},maxLength:{type:Number,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"input"}},setup(r){const l=r,e=La(),{forwardRef:n,currentElement:s}=Je();function u(b){if(e.selectedElement.value=void 0,!e.addOnBlur.value)return;const $=b.target,C=b.relatedTarget,w=$.getAttribute("aria-controls");if(w&&C?.closest(`#${CSS.escape(w)}`)||!$.value)return;e.onAddValue($.value)&&($.value="")}function o(b){e.addOnTab.value&&v(b)}const{isComposing:c,handleCompositionStart:g,handleCompositionEnd:p}=ka();async function v(b){if(c.value||(await qe(),b.defaultPrevented))return;const $=b.target;if(!$.value)return;e.onAddValue($.value)&&($.value=""),b.preventDefault()}function _(b){if(c.value||(e.isInvalidInput.value=!1,b.data===null))return;const $=e.delimiter.value;if($===b.data||$ instanceof RegExp&&$.test(b.data)){const w=b.target;if(w.value=w.value.replace($,""),w.value.trim()===""){w.value="";return}e.onAddValue(w.value)&&(w.value="")}}function y(b){c.value||e.onInputKeydown(b)}function k(b){if(e.addOnPaste.value){b.preventDefault();const $=b.clipboardData;if(!$)return;const C=$.getData("text");e.delimiter.value?C.split(e.delimiter.value).forEach(S=>{e.onAddValue(S)}):e.onAddValue(C)}}return Re(()=>{const b=s.value.nodeName==="INPUT"?s.value:s.value.querySelector("input");b&&setTimeout(()=>{l.autoFocus&&b?.focus()},1)}),(b,$)=>(i(),W(t(He),{id:t(e).id?.value,ref:t(n),type:"text",autocomplete:"off",autocorrect:"off",autocapitalize:"off",as:b.as,"as-child":b.asChild,maxlength:b.maxLength,placeholder:b.placeholder,disabled:t(e).disabled.value,"data-invalid":t(e).isInvalidInput.value?"":void 0,onInput:_,onKeydown:[Ge(v,["enter"]),Ge(o,["tab"]),y],onBlur:u,onCompositionstart:t(g),onCompositionend:t(p),onPaste:k},{default:F(()=>[ye(b.$slots,"default")]),_:3},8,["id","as","as-child","maxlength","placeholder","disabled","data-invalid","onCompositionstart","onCompositionend"]))}}),Al=zl;const[ks,ql]=dt("TagsInputItem");var Ll=ce({__name:"TagsInputItem",props:{value:{type:null,required:!0},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(r){const l=r,{value:e}=Dt(l),n=La(),{forwardRef:s,currentElement:u}=Je(),{CollectionItem:o}=Ct(),c=T(()=>n.selectedElement.value===u.value),g=T(()=>l.disabled||n.disabled.value),p=ql({value:e,isSelected:c,disabled:g,textId:"",displayValue:T(()=>n.displayValue(e.value))});return(v,_)=>(i(),W(t(o),{value:t(e)},{default:F(()=>[h(t(He),{ref:t(s),as:v.as,"as-child":v.asChild,"aria-labelledby":t(p).textId,"aria-current":c.value,"data-disabled":g.value?"":void 0,"data-state":c.value?"active":"inactive"},{default:F(()=>[ye(v.$slots,"default")]),_:3},8,["as","as-child","aria-labelledby","aria-current","data-disabled","data-state"])]),_:3},8,["value"]))}}),Dl=Ll,El=ce({__name:"TagsInputItemDelete",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(r){const l=r;Je();const e=La(),n=ks(),s=T(()=>n.disabled?.value||e.disabled.value);function u(){if(s.value)return;const o=e.modelValue.value.findIndex(c=>Wt(c,n.value.value));e.onRemoveValue(o)}return(o,c)=>(i(),W(t(He),Ae({tabindex:"-1"},l,{"aria-labelledby":t(n).textId,"aria-current":t(n).isSelected.value,"data-state":t(n).isSelected.value?"active":"inactive","data-disabled":s.value?"":void 0,type:o.as==="button"?"button":void 0,onClick:u}),{default:F(()=>[ye(o.$slots,"default")]),_:3},16,["aria-labelledby","aria-current","data-state","data-disabled","type"]))}}),Bl=El,Fl=ce({__name:"TagsInputItemText",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(r){const l=r,e=ks();return Je(),e.textId||=xt(void 0,"reka-tags-input-item-text"),(n,s)=>(i(),W(t(He),Ae(l,{id:t(e).textId}),{default:F(()=>[ye(n.$slots,"default",{},()=>[ie(d(t(e).displayValue.value),1)])]),_:3},16,["id"]))}}),Rl=Fl;const Vl={none:[],qwen:["default","off","high"],deepseek_v4:["default","off","high","xhigh"],deepseek_hybrid:["default","off","auto"],o_series:["default","low","medium","high"],gpt5:["default","minimal","low","medium","high"],gpt5_1:["default","off","low","medium","high"],gpt5_2plus:["default","off","minimal","low","medium","high","xhigh"],grok:["default","low","high"],kimi:["default","off","auto","low","medium","high"],doubao:["default","off","auto","high"],hunyuan:["default","off","high"],gemini:["default","off","low","medium","high"],default:["default","off","low","medium","high"]},Ya=/^(?!.*-non-reasoning\b)(o\d+(?:-[\w-]+)?|.*\b(?:reasoning|reasoner|thinking|think)\b.*|.*-[rR]\d+.*|.*\bqwq(?:-[\w-]+)?\b.*|.*\bhunyuan-t1(?:-[\w-]+)?\b.*|.*\bgrok-(?:3-mini|4|4-fast|build)(?:-[\w-]+)?\b.*)$/i;function Ol(r,l){const e=l.toLowerCase(),n=r.toLowerCase();if(e.includes("-non-reasoning")||n==="anthropic")return"none";if(n==="gemini")return/gemini-(?:2\.5|3(?:\.\d+)?-(?:flash|pro)|flash-latest|pro-latest)/i.test(e)?"gemini":"none";if(n==="qwen"||/\bqwen|qwq/i.test(e))return"qwen";if(/deepseek[_-]v([4-9]|\d{2,})/i.test(e)||/deepseek-ai\/deepseek-r1/i.test(e))return"deepseek_v4";if(/deepseek[_-]chat|deepseek[_-]v3/i.test(e))return"deepseek_hybrid";if(n==="openai"||n==="openai-compatible"){if(/gpt-5\.[2-9]|gpt-5\.[1-9]\d/.test(e))return"gpt5_2plus";if(/gpt-5\.1/.test(e))return"gpt5_1";if(/gpt-5/.test(e))return"gpt5";if(/^o\d/.test(e))return"o_series"}return/^o\d/.test(e)?"o_series":/\bgrok-(?:3-mini|4|4-fast|build)\b/i.test(e)?"grok":/\bkimi-k(?:2-thinking|2\.[5-9]|[3-9])/i.test(e)||n==="kimi"&&/thinking/i.test(e)?"kimi":/\bdoubao-.*seed/i.test(e)||n==="doubao"&&/seed/i.test(e)?"doubao":/\bhunyuan-(?:t1|a13b)/i.test(e)?"hunyuan":n==="glm"||/\bglm-?(?:5|4\.[5-7]|z1|zero)/i.test(e)?"qwen":n==="siliconflow"&&/r[1-9]/i.test(e)?"deepseek_v4":n==="openrouter"?/deepseek.*(v[4-9]|r\d)/i.test(e)?"deepseek_v4":/deepseek[_-]?(chat|v3)/i.test(e)?"deepseek_hybrid":/\bgrok-(?:3-mini|4|4-fast|build)\b/i.test(e)?"grok":/\bkimi-k(?:2-thinking|2\.[5-9]|[3-9])/i.test(e)?"kimi":Ya.test(e)?"default":"none":/\bmimo-v2/i.test(e)||/\bminimax-m[123]/i.test(e)||/\bseed-oss/i.test(e)?"deepseek_hybrid":/\bbaichuan-m[23]/i.test(e)||/\bmagistral/i.test(e)||/\bmistral-small-2603/i.test(e)||/\bstep-(?:3|r1-v-mini)/i.test(e)||/\bgemma-?4/i.test(e)||/\bpangu-pro-moe/i.test(e)||/\bsonar-deep-research/i.test(e)||/\bring-(?:1t|mini|flash)/i.test(e)?"default":/\bqwen|qwq/i.test(e)?"qwen":/deepseek[_-]?r\d|deepseek[_-]?v[4-9]/i.test(e)?"deepseek_v4":/^o\d/i.test(e)?"o_series":Ya.test(e)?"default":"none"}function Pl(r,l){const e=Ol(r,l);return Vl[e]}function jl(){const{contains:r,startsWith:l}=ys({sensitivity:"base"});function e(o,c){return r(o,c)?r(c,o)?0:l(o,c)?1:2:null}function n(o,c,g){if(typeof o!="object"||o===null)return e(String(o),c);let p=null;for(const v of g){const _=it(o,v);if(_==null)continue;const y=Array.isArray(_)?_.map(String):[String(_)];for(const k of y){const b=e(k,c);if(b!==null&&(p===null||b<p)&&(p=b),p===0)return 0}}return p}function s(o,c,g){if(!c)return o;const p=[];for(const v of o){const _=n(v,c,g);_!==null&&p.push({item:v,score:_})}return p.sort((v,_)=>v.score-_.score),p.map(({item:v})=>v)}function u(o,c,g){return c?o.map(p=>{const v=[];for(const _ of p){if(_==null)continue;if(g.isStructural?.(_)){v.push({item:_,score:-1});continue}const y=n(_,c,g.fields);y!==null&&v.push({item:_,score:y})}return v.sort((_,y)=>_.score-y.score),v.map(({item:_})=>_)}).filter(p=>p.some(v=>!g.isStructural?.(v))):o}return{score:e,scoreItem:n,filter:s,filterGroups:u}}function Nl(r,l,e,n="group",s="zh-CN"){const u=yn(),{chatKey:o,state:c}=u.ensureSessionState({sessionId:r,sessionName:l,timeFilter:e,chatType:n,locale:s});return u.resetToSelectorOnEnter(o),u.applySessionAssistantSelection(o),{messages:We(c,"messages"),sourceMessages:We(c,"sourceMessages"),currentKeywords:We(c,"currentKeywords"),isLoadingSource:We(c,"isLoadingSource"),isAIThinking:We(c,"isAIThinking"),currentAIChatId:We(c,"currentAIChatId"),currentToolStatus:We(c,"currentToolStatus"),toolsUsedInCurrentRound:We(c,"toolsUsedInCurrentRound"),sessionTokenUsage:We(c,"sessionTokenUsage"),agentStatus:We(c,"agentStatus"),selectedAssistantId:We(c,"selectedAssistantId"),sendMessage:(g,p)=>u.sendMessage(o,g,p),editMessageAndRegenerate:(g,p,v)=>u.editMessageAndRegenerate(o,g,p,v),loadAIChat:g=>u.loadAIChat(o,g),startNewAIChat:g=>u.startNewAIChat(o,g),loadMoreSourceMessages:()=>u.loadMoreSourceMessages(),updateMaxMessages:()=>u.updateMaxMessages(),stopGeneration:()=>u.stopGeneration(o),selectAssistantForSession:g=>u.selectAssistantForSession(o,g)}}const ra=new Map;function Ul(r,l,e){const{activeTab:n,isInitialLoad:s,currentSessionId:u,onTimeRangeChange:o}=e,c=z(null),g=z(null),p=z([]),v=T(()=>{const b=c.value;if(b)return{startTs:b.startTs,endTs:b.endTs}}),_=T(()=>{const b=c.value;return b?`${b.startTs}-${b.endTs}`:"init"}),y=T(()=>{const b=r.query,$=b.timeMode;return $?{mode:$,recentDays:b.timeDays?Number(b.timeDays):void 0,year:b.timeYear?Number(b.timeYear):void 0,quarterYear:b.timeYear?Number(b.timeYear):void 0,quarter:b.timeQuarter?Number(b.timeQuarter):void 0,customStart:b.timeStart||void 0,customEnd:b.timeEnd||void 0}:u.value&&ra.has(u.value)?ra.get(u.value):{mode:"recent",recentDays:365}});fe([n,c],([b,$])=>{if(s.value||!$)return;const C=$.state,w={tab:b,timeMode:C.mode,timeDays:void 0,timeYear:void 0,timeQuarter:void 0,timeStart:void 0,timeEnd:void 0};C.mode==="recent"&&(w.timeDays=C.recentDays),C.mode==="year"&&(w.timeYear=C.year),C.mode==="quarter"&&(w.timeYear=C.quarterYear,w.timeQuarter=C.quarter),C.mode==="custom"&&(w.timeStart=C.customStart,w.timeEnd=C.customEnd),l.replace({query:{...r.query,...w}})}),fe(c,b=>{!b||!u.value||(ma(),ra.set(u.value,b.state),o?.())},{immediate:!0});function k(){c.value=null,g.value=null,p.value=[]}return{timeRangeValue:c,fullTimeRange:g,availableYears:p,timeFilter:v,timeFilterKey:_,initialTimeState:y,resetTimeRange:k}}function Wl(r){return r.content.trim()?r.content:r.contentBlocks?.filter(e=>e.type==="text"&&!!e.text).map(e=>e.text).join("")??""}function pa(r){return r.flatMap(l=>{if(l.role!=="user"&&l.role!=="assistant")return[];const e=Wl(l);return e.trim()?[{role:l.role,content:e,timestamp:l.timestamp}]:[]})}function Hl(r){return pa(r).length>0}function Kl(r,l,e,n){const s=[];s.push(`# ${r}`),s.push(""),s.push(`> ${n.createdAt}: ${Ee(e).format("YYYY-MM-DD HH:mm:ss")}`),s.push(""),s.push("---"),s.push("");for(const u of l){const o=Ee(u.timestamp).format("YYYY-MM-DD HH:mm:ss"),c=u.role==="user"?n.user:n.assistant;s.push(`### ${c}`),s.push(`*${o}*`),s.push(""),s.push(u.content),s.push(""),s.push("---"),s.push("")}return s.join(`
3
- `)}function Yl(r,l,e,n){const s=[];s.push(`${r}`),s.push(`${n.createdAt}: ${Ee(e).format("YYYY-MM-DD HH:mm:ss")}`),s.push(""),s.push("=".repeat(50)),s.push("");for(const u of l){const o=Ee(u.timestamp).format("YYYY-MM-DD HH:mm:ss"),c=u.role==="user"?n.user:n.assistant;s.push(`[${c}] ${o}`),s.push(""),s.push(u.content),s.push(""),s.push("-".repeat(50)),s.push("")}return s.join(`
4
- `)}function Gl(r){return r.replace(/[/\\?%*:|"<>]/g,"_")}async function Ql(r,l,e,n,s){if(l.length===0)return{success:!1,error:"No messages to export"};let u,o;const c=Ee(e).format("YYYYMMDD_HHmmss"),g=Gl(r);n==="markdown"?(u=Kl(r,l,e,s),o=`${g}_${c}.md`):(u=Yl(r,l,e,s),o=`${g}_${c}.txt`);const p=`data:text/plain;charset=utf-8,${encodeURIComponent(u)}`,{useCacheService:v}=await Xt(async()=>{const{useCacheService:y}=await import("./index-y7xPDpsW.js").then(k=>k.cn);return{useCacheService:y}},__vite__mapDeps([0,1,2]));return await v().saveToDownloads(o,p)}function Jl(r){const l=r.columns.join(","),e=r.rows.map(n=>n.map(s=>s===null?"":`"${String(s).replace(/"/g,'""')}"`).join(","));return[l,...e].join(`
5
- `)}function Xl(r){const l=r.rows.map(e=>{const n={};return r.columns.forEach((s,u)=>{n[s]=e[u]}),n});return JSON.stringify(l,null,2)}async function Zl(r,l){if(r.rows.length===0)return{success:!1,error:"No data to export"};const n=`sql_result_${Ee().format("YYYYMMDD_HHmmss")}.${l}`;let s,u;l==="json"?(s=Xl(r),u="application/json"):(s=Jl(r),u="text/csv");const o=`data:${u};charset=utf-8,${encodeURIComponent(s)}`,{useCacheService:c}=await Xt(async()=>{const{useCacheService:p}=await import("./index-y7xPDpsW.js").then(v=>v.cn);return{useCacheService:p}},__vite__mapDeps([0,1,2]));return await c().saveToDownloads(n,o)}function a2(r){const{route:l,router:e,currentSessionId:n,selectSession:s,defaultTab:u,validTabIds:o}=r,c=z(!0),g=z(!0),p=z(!0),v=z(null),_=z([]),y=z([]),k=z([]),b=z([]);let $=0,C=0,w=!1,S=!1;function I(){!p.value||!w||(!v.value||S)&&(p.value=!1)}function f(){const P=l.query.tab;return P&&o.includes(P)?P:u}const x=z(f()),B=T(()=>x.value==="insights"),R=T(()=>["insights","ranking"].includes(x.value));fe(x,P=>{const se={insights:"insights",ranking:"ranking","ai-chat":"ai_chat",lab:"sql_lab"}[P];se&&xn("feature_used",{feature_id:se})},{immediate:!0});const{timeRangeValue:D,fullTimeRange:A,availableYears:M,timeFilter:q,initialTimeState:Y,resetTimeRange:G}=Ul(l,e,{activeTab:x,isInitialLoad:g,currentSessionId:n,onTimeRangeChange:()=>ue()});function Z(){const P=l.params.id;P&&(s(P),n.value!==P&&e.replace("/"))}async function ue(){const P=n.value;if(!P)return;const se=++C;if(!B.value){c.value=!1,S=!0,I();return}p.value&&(S=!1),c.value=!0;try{const me=q.value,he=Ke(),[ee,te,N,de]=await Promise.all([he.getMemberActivity(P,me),he.getHourlyActivity(P,me),he.getDailyActivity(P,me),he.getMessageTypeDistribution(P,me)]);if(se!==C)return;_.value=ee,y.value=te,k.value=N,b.value=de}catch(me){se===C&&console.error("加载分析数据失败:",me)}finally{se===C&&(c.value=!1,S=!0,I())}}function oe(P){P||(D.value=null,ue())}async function H(){const P=n.value;if(!P)return;const se=++$;g.value=!0;try{const me=await Ke().getSession(P);if(se!==$||n.value!==P)return;v.value=me}catch(me){se===$&&n.value===P&&(v.value=null,console.error("加载基础数据失败:",me))}finally{se===$&&n.value===P&&(g.value=!1,w=!0,I())}}return fe(x,()=>{if(!B.value){C++,ma(),c.value=!1,R.value||(S=!0,I());return}c.value=!0,n.value&&D.value&&ue()}),fe(()=>l.params.id,()=>{x.value=f(),Z()}),fe(()=>l.query.tab,()=>{x.value=f()}),fe(n,()=>{C++,G(),w=!1,S=!R.value,c.value=B.value,p.value=!0,ma(),H()},{immediate:!0}),Re(()=>{Z()}),{activeTab:x,isLoading:c,isInitialLoad:g,isSessionSwitching:p,session:v,memberActivity:_,hourlyActivity:y,dailyActivity:k,messageTypes:b,timeRangeValue:D,fullTimeRange:A,availableYears:M,timeFilter:q,initialTimeState:Y,syncSession:Z,loadData:H,loadAnalysisData:ue,handleTimeRangeInitialized:oe}}const ei={class:"pointer-events-none absolute right-3 top-3 z-50 opacity-0 transition-opacity duration-200 group-hover/card:pointer-events-auto group-hover/card:opacity-100"},ti=ce({__name:"CardCaptureOverlay",setup(r){return(l,e)=>(i(),m("div",ei,[h(Lt,{type:"element","target-selector":"[data-capturable-card]",size:"xs"})]))}}),na=ce({__name:"ReportCard",props:{capturable:{type:Boolean,default:!0}},setup(r){return(l,e)=>(i(),W(mt,{"data-capturable-card":"",class:"group/card relative isolate flex flex-col"},{default:F(()=>[h(to),r.capturable?(i(),W(ti,{key:0})):E("",!0),ye(l.$slots,"default")]),_:3}))}}),ai={class:"flex items-center justify-between"},si={class:"font-semibold text-gray-900 dark:text-white whitespace-nowrap"},ni={key:0,class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},oi={class:"flex items-center gap-2"},li={key:0,class:"pointer-events-none opacity-0 transition-opacity duration-200 group-hover/card:pointer-events-auto group-hover/card:opacity-100"},Ze=ce({__name:"SectionCard",props:{title:{},description:{},capturable:{type:Boolean,default:!0},showDivider:{type:Boolean,default:!0},scrollable:{type:Boolean,default:!1},maxHeightVh:{default:60}},setup(r){const l=r,e=T(()=>{if(l.scrollable)return{maxHeight:`${l.maxHeightVh}vh`,overflowY:"auto"}});return(n,s)=>(i(),W(mt,{class:"group/card","data-section-card":""},{default:F(()=>[a("div",{class:J(["px-5 py-3",{"border-b border-gray-200 dark:border-white/5":r.showDivider&&n.$slots.default}])},[a("div",ai,[a("div",null,[a("p",si,d(r.title),1),r.description?(i(),m("p",ni,d(r.description),1)):E("",!0)]),a("div",oi,[ye(n.$slots,"headerRight"),r.capturable?(i(),m("div",li,[h(Lt,{type:"element","target-selector":"[data-section-card]",size:"xs"})])):E("",!0)])])],2),r.scrollable?(i(),m("div",{key:0,style:et(e.value)},[ye(n.$slots,"default")],4)):ye(n.$slots,"default",{key:1}),ye(n.$slots,"footer")]),_:3}))}}),ii={class:"flex items-start justify-between"},ri={class:"min-w-0 flex-1"},ui={class:"text-sm font-medium text-gray-500 dark:text-gray-400"},ci={key:1,class:"text-xl"},di={key:0,class:"mt-4 flex items-center text-sm"},mi={class:"text-gray-500 dark:text-gray-400"},lt=ce({__name:"StatCard",props:{label:{},value:{},valueColor:{},subtext:{},icon:{},iconBg:{}},setup(r){const l={pink:"text-pink-600 dark:text-pink-400",amber:"text-amber-600 dark:text-amber-400",blue:"text-blue-600 dark:text-blue-400",green:"text-green-600 dark:text-green-400",red:"text-red-600 dark:text-red-400",gray:"text-gray-900 dark:text-white"},e={pink:"bg-pink-100 dark:bg-pink-500/10",amber:"bg-amber-100 dark:bg-amber-500/10",blue:"bg-blue-100 dark:bg-blue-500/10",green:"bg-green-100 dark:bg-green-500/10",red:"bg-red-100 dark:bg-red-500/10",gray:"bg-gray-100 dark:bg-white/5"};return(n,s)=>{const u=_e;return i(),W(mt,{class:"p-5"},{default:F(()=>[a("div",ii,[a("div",ri,[a("p",ui,d(r.label),1),a("p",{class:J(["mt-2 truncate text-2xl font-bold tracking-tight",r.valueColor?l[r.valueColor]:"text-gray-900 dark:text-white"])},d(r.value),3)]),r.icon?(i(),m("div",{key:0,class:J(["ml-4 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl",e[r.iconBg||"gray"]])},[r.icon.startsWith("i-")?(i(),W(u,{key:0,name:r.icon,class:"h-5 w-5"},null,8,["name"])):(i(),m("span",ci,d(r.icon),1))],2)):E("",!0)]),r.subtext||n.$slots.subtext?(i(),m("div",di,[ye(n.$slots,"subtext",{},()=>[a("span",mi,d(r.subtext),1)])])):E("",!0)]),_:3})}}}),gi={key:0,class:"mb-2 block text-2xl"},s2=ce({__name:"EmptyState",props:{text:{},icon:{},padding:{}},setup(r){const l={sm:"px-4 py-4",md:"px-5 py-8",lg:"px-6 py-12"};return(e,n)=>(i(),m("div",{class:J(["text-center text-sm text-gray-400",l[r.padding||"md"]])},[r.icon?(i(),m("span",gi,d(r.icon),1)):E("",!0),ie(" "+d(r.text||"暂无数据"),1)],2))}}),pi={},hi={class:"insight-loading-dots",viewBox:"0 0 35 14",width:"35",height:"14","aria-hidden":"true",focusable:"false"};function fi(r,l){return i(),m("svg",hi,[...l[0]||(l[0]=[a("circle",{class:"insight-loading-dots__dot fill-primary-500",cx:"6",cy:"8",r:"2.5"},null,-1),a("circle",{class:"insight-loading-dots__dot fill-primary-500",cx:"17.5",cy:"8",r:"2.5"},null,-1),a("circle",{class:"insight-loading-dots__dot fill-primary-500",cx:"29",cy:"8",r:"2.5"},null,-1)])])}const vi=at(pi,[["render",fi],["__scopeId","data-v-a9203e1d"]]),yi=["aria-busy"],xi={key:0,class:"insight-view-transition__indicator","aria-hidden":"true"},bi=["inert","aria-hidden"],ki=["inert","aria-hidden"],_i=ce({__name:"InsightViewTransition",props:{activeKey:{}},setup(r){const l=r,e=z(l.activeKey),n=z(null),s=z("primary"),u=z("idle"),o=z(0),c=bn("session-switch-loading",null),g=T(()=>s.value==="primary"?e.value:n.value),p=T(()=>s.value==="primary"?"secondary":"primary"),v=T(()=>u.value!=="idle"),_=T(()=>u.value==="waiting"&&!c?.value);kn(Xn,{register:$,suppress:v});let y=0,k=null;function b(){k&&clearTimeout(k),k=null}function $(){const f=y;let x=!0;return o.value++,()=>{x&&(x=!1,f===y&&(o.value=Math.max(0,o.value-1)))}}function C(f,x){f==="primary"?e.value=x:n.value=x}function w(f){const x=f===s.value;return{"insight-view-transition__pane--active":x&&u.value==="idle","insight-view-transition__pane--waiting":x&&u.value==="waiting","insight-view-transition__pane--outgoing":x&&u.value==="revealing","insight-view-transition__pane--pending":!x&&u.value==="waiting","insight-view-transition__pane--incoming":!x&&u.value==="revealing"}}async function S(f){await qe(),await qe(),!(f!==y||u.value!=="waiting"||o.value>0)&&(u.value="revealing",k=setTimeout(()=>{if(f!==y)return;const x=s.value;s.value=p.value,C(x,null),u.value="idle",k=null},180))}function I(f){const x=++y;if(b(),o.value=0,f===g.value){C(p.value,null),u.value="idle";return}C(p.value,f),u.value="waiting",S(x)}return fe(()=>l.activeKey,f=>I(f)),fe(o,f=>{f===0&&u.value==="waiting"&&S(y)}),Bt(()=>{y++,b()}),(f,x)=>(i(),m("div",{class:"insight-view-transition","aria-busy":v.value},[_.value?(i(),m("div",xi,[h(vi)])):E("",!0),e.value?(i(),m("div",{key:1,class:J(["insight-view-transition__pane",w("primary")]),inert:s.value!=="primary"||v.value,"aria-hidden":s.value!=="primary"},[ye(f.$slots,"default",{viewKey:e.value},void 0,!0)],10,bi)):E("",!0),n.value?(i(),m("div",{key:2,class:J(["insight-view-transition__pane",w("secondary")]),inert:s.value!=="secondary"||v.value,"aria-hidden":s.value!=="secondary"},[ye(f.$slots,"default",{viewKey:n.value},void 0,!0)],10,ki)):E("",!0)],8,yi))}}),n2=at(_i,[["__scopeId","data-v-2eb42eb1"]]),wi={"zh-CN":{message:"消息记录",member:"成员",meta:"群信息",member_name_history:"昵称历史"},"en-US":{message:"Messages",member:"Members",meta:"Chat Info",member_name_history:"Nickname History"}},ha={"zh-CN":{message:{id:"消息ID",sender_id:"发送者ID",sender_account_name:"发送时账号名",sender_group_nickname:"发送时群昵称",ts:"时间戳(秒)",type:"消息类型",content:"消息内容"},member:{id:"成员ID",platform_id:"平台ID",account_name:"账号名称",group_nickname:"群昵称",aliases:"自定义别名"},meta:{name:"群名称",platform:"平台",type:"聊天类型",imported_at:"导入时间"},member_name_history:{id:"记录ID",member_id:"成员ID",name_type:"名称类型",name:"昵称值",start_ts:"开始时间",end_ts:"结束时间"}},"en-US":{message:{id:"Message ID",sender_id:"Sender ID",sender_account_name:"Sender Account",sender_group_nickname:"Sender Nickname",ts:"Timestamp (sec)",type:"Message Type",content:"Content"},member:{id:"Member ID",platform_id:"Platform ID",account_name:"Account Name",group_nickname:"Group Nickname",aliases:"Custom Aliases"},meta:{name:"Chat Name",platform:"Platform",type:"Chat Type",imported_at:"Imported At"},member_name_history:{id:"Record ID",member_id:"Member ID",name_type:"Name Type",name:"Nickname",start_ts:"Start Time",end_ts:"End Time"}}};function fa(r,l="zh-CN"){return wi[_s(l)]?.[r]||r}function Da(r,l,e="zh-CN"){return ha[_s(e)]?.[r]?.[l]||l}function _s(r){return r.startsWith("zh")?"zh-CN":"en-US"}const $i={key:0,class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Ci={key:0,class:"flex-1 overflow-y-auto p-2"},Si=["onClick"],Ii={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Ti={class:"flex-1 truncate text-right text-xs text-gray-400"},Mi={key:0,class:"ml-4 mt-1 space-y-0.5"},zi=["title","onDblclick"],Ai={class:"font-mono text-gray-700 dark:text-gray-300"},qi={class:"flex-1 truncate text-right text-[10px] text-gray-400"},Li={key:1,class:"flex flex-1 flex-col items-center gap-1 overflow-y-auto px-2 pb-2"},Di=["title","onClick"],Ei=ce({__name:"SchemaPanel",props:{sessionId:{}},emits:["insertColumn"],setup(r,{expose:l,emit:e}){const{t:n,locale:s}=we(),u=r,o=e,c=z(!1),g=z([]),p=z(new Set);async function v(){try{g.value=await Ke().getSchema(u.sessionId),g.value.forEach(b=>p.value.add(b.name))}catch(b){console.error("加载 Schema 失败:",b)}}function _(b){p.value.has(b)?p.value.delete(b):p.value.add(b)}function y(b){c.value=!1,p.value.add(b)}function k(b,$){o("insertColumn",b,$)}return l({loadSchema:v,schema:g}),Re(()=>{v()}),(b,$)=>{const C=_e,w=Ue;return i(),m("div",{class:J(["m-3 flex h-[calc(100%-1.5rem)] shrink-0 flex-col overflow-hidden rounded-lg bg-white transition-all duration-300 ease-in-out dark:bg-sidebar-dark",c.value?"w-14":"w-56"])},[a("div",{class:J(["flex items-center",c.value?"justify-center px-2 pb-2 pt-5":"justify-between border-b border-gray-200 py-2 pl-3 pr-2 dark:border-gray-800"])},[c.value?E("",!0):(i(),m("span",$i,d(t(n)("ai.sqlLab.schema.tables")),1)),c.value?(i(),m("button",{key:2,type:"button",class:"group relative flex h-9 w-9 cursor-pointer items-center justify-center rounded-full hover:bg-gray-200/60 dark:hover:bg-white/[0.06]",onClick:$[1]||($[1]=S=>c.value=!c.value)},[h(C,{name:"i-lucide-panel-right-open",class:"size-4 scale-x-[-1]"})])):(i(),W(w,{key:1,color:"neutral",variant:"ghost",size:"sm",class:"group flex h-9 w-9 cursor-pointer items-center justify-center rounded-full hover:bg-gray-200/60 dark:hover:bg-white/[0.06]",onClick:$[0]||($[0]=S=>c.value=!c.value)},{default:F(()=>[h(C,{name:"i-lucide-panel-right",class:"size-4 scale-x-[-1] group-hover:hidden"}),h(C,{name:"i-lucide-panel-right-close",class:"size-4 hidden scale-x-[-1] group-hover:block"})]),_:1}))],2),c.value?(i(),m("div",Li,[(i(!0),m(re,null,ve(g.value,S=>(i(),m("button",{key:S.name,class:"flex h-10 w-10 items-center justify-center rounded-lg text-gray-600 transition-colors hover:bg-gray-200/40 hover:text-primary-600 dark:text-gray-300 dark:hover:bg-white/[0.06] dark:hover:text-primary-400",title:`${t(fa)(S.name,t(s))} (${S.name})`,onClick:I=>y(S.name)},[h(C,{name:"i-heroicons-table-cells",class:"h-5 w-5"})],8,Di))),128))])):(i(),m("div",Ci,[(i(!0),m(re,null,ve(g.value,S=>(i(),m("div",{key:S.name,class:"mb-2"},[a("button",{class:"flex w-full items-center gap-1 rounded px-2 py-1.5 text-left transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",onClick:I=>_(S.name)},[h(C,{name:p.value.has(S.name)?"i-heroicons-chevron-down":"i-heroicons-chevron-right",class:"h-3 w-3 shrink-0 text-gray-400"},null,8,["name"]),h(C,{name:"i-heroicons-table-cells",class:"h-4 w-4 shrink-0 text-pink-500"}),a("span",Ii,d(S.name),1),a("span",Ti,d(t(fa)(S.name,t(s))),1)],8,Si),p.value.has(S.name)?(i(),m("div",Mi,[(i(!0),m(re,null,ve(S.columns,I=>(i(),m("button",{key:I.name,class:"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",title:t(n)("ai.sqlLab.schema.doubleClickToInsert"),onDblclick:f=>k(S.name,I.name)},[I.pk?(i(),W(C,{key:0,name:"i-heroicons-key",class:"h-3 w-3 shrink-0 text-yellow-500",title:t(n)("ai.sqlLab.schema.primaryKey")},null,8,["title"])):E("",!0),a("span",Ai,d(I.name),1),a("span",qi,d(t(Da)(S.name,I.name,t(s))),1)],40,zi))),128))])):E("",!0)]))),128))]))],2)}}}),Bi={class:"max-h-[70vh] overflow-hidden p-6"},Fi={class:"mb-4 flex items-center gap-2"},Ri={class:"text-lg font-semibold text-gray-900 dark:text-white"},Vi={key:0,class:"max-h-[50vh] space-y-3 overflow-y-auto pr-2"},Oi={class:"mb-2 flex items-start justify-between gap-2"},Pi={class:"flex-1 text-sm font-medium text-gray-700 dark:text-gray-300"},ji={class:"shrink-0 text-xs text-gray-400"},Ni={class:"mb-2 rounded bg-white p-2 dark:bg-gray-800"},Ui={class:"whitespace-pre-wrap break-all font-mono text-xs text-gray-600 dark:text-gray-400"},Wi={key:0,class:"mb-2 text-xs text-gray-500 dark:text-gray-400"},Hi={class:"flex justify-end gap-2"},Ki={key:1,class:"py-8 text-center text-gray-500 dark:text-gray-400"},Yi={class:"text-sm"},Gi={class:"mt-4 flex justify-end"},Qi=ce({__name:"AIHistoryModal",props:{open:{type:Boolean},history:{}},emits:["update:open","execute","delete"],setup(r,{emit:l}){const{t:e}=we(),n=l;function s(u){const o=new Date(u),c=new Date,g=c.getTime()-u;return g<6e4?e("ai.sqlLab.history.justNow"):g<36e5?e("ai.sqlLab.history.minutesAgo",{count:Math.floor(g/6e4)}):g<864e5?e("ai.sqlLab.history.hoursAgo",{count:Math.floor(g/36e5)}):o.toDateString()===c.toDateString()?e("ai.sqlLab.history.today"):`${o.getMonth()+1}/${o.getDate()}`}return(u,o)=>{const c=_e,g=Ue,p=Xe;return i(),W(p,{open:r.open,ui:{content:"max-w-5xl"},"onUpdate:open":o[1]||(o[1]=v=>n("update:open",v))},{content:F(()=>[a("div",Bi,[a("div",Fi,[h(c,{name:"i-heroicons-clock",class:"h-5 w-5 text-pink-500"}),a("h3",Ri,d(t(e)("ai.sqlLab.history.title")),1)]),r.history.length>0?(i(),m("div",Vi,[(i(!0),m(re,null,ve(r.history,v=>(i(),m("div",{key:v.id,class:"rounded-lg border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-page-dark"},[a("div",Oi,[a("p",Pi,d(v.prompt),1),a("span",ji,d(s(v.timestamp)),1)]),a("div",Ni,[a("pre",Ui,d(v.sql),1)]),v.explanation?(i(),m("p",Wi,d(v.explanation),1)):E("",!0),a("div",Hi,[h(g,{variant:"ghost",size:"xs",color:"error",onClick:_=>n("delete",v.id)},{default:F(()=>[h(c,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"})]),_:1},8,["onClick"]),h(g,{size:"xs",onClick:_=>n("execute",v)},{default:F(()=>[h(c,{name:"i-heroicons-play",class:"mr-1 h-3.5 w-3.5"}),ie(" "+d(t(e)("ai.sqlLab.history.execute")),1)]),_:1},8,["onClick"])])]))),128))])):(i(),m("div",Ki,[h(c,{name:"i-heroicons-clock",class:"mx-auto mb-2 h-8 w-8 text-gray-300 dark:text-gray-600"}),a("p",Yi,d(t(e)("ai.sqlLab.history.empty")),1)])),a("div",Gi,[h(g,{variant:"ghost",onClick:o[0]||(o[0]=v=>n("update:open",!1))},{default:F(()=>[ie(d(t(e)("common.close")),1)]),_:1})])])]),_:1},8,["open"])}}}),Ji={class:"flex flex-1 flex-col overflow-hidden"},Xi={key:0,class:"border-b border-red-200 bg-red-50 p-4 dark:border-red-900 dark:bg-red-950"},Zi={class:"flex items-start gap-2"},er={class:"min-w-0 flex-1"},tr={class:"text-sm font-medium text-red-800 dark:text-red-200"},ar={class:"mt-1 break-all font-mono text-xs text-red-600 dark:text-red-400"},sr={key:1,class:"flex items-center justify-between border-b border-gray-200 bg-gray-50 px-4 py-2 dark:border-gray-800 dark:bg-page-dark"},nr={class:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400"},or={class:"flex cursor-pointer items-center gap-1.5"},lr={class:"text-xs"},ir={class:"flex items-center gap-2"},rr={key:2,class:"flex-1 overflow-auto"},ur={class:"min-w-full divide-y divide-gray-200 dark:divide-gray-700"},cr={class:"sticky top-0 bg-gray-100 dark:bg-page-dark"},dr=["onClick"],mr={class:"flex items-center gap-1"},gr={class:"flex flex-col"},pr={class:"text-gray-700 dark:text-gray-300"},hr={key:0,class:"font-mono text-[10px] text-gray-400"},fr={key:0,class:"sticky right-0 w-12 bg-gray-100 px-2 py-2 dark:bg-page-dark"},vr={class:"divide-y divide-gray-200 bg-white dark:divide-gray-700 dark:bg-page-dark"},yr=["title"],xr={key:0,class:"sticky right-0 w-12 bg-white px-2 py-2 dark:bg-page-dark"},br={key:3,class:"flex shrink-0 items-center gap-4 border-t border-gray-200 bg-gray-50 px-4 py-2 dark:border-gray-800 dark:bg-page-dark"},kr={class:"flex items-center gap-1"},_r={class:"mx-2 text-xs text-gray-600 dark:text-gray-400"},wr={class:"flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400"},$r={key:4,class:"flex flex-1 items-center justify-center text-gray-500 dark:text-gray-400"},Cr={class:"text-center"},Sr={class:"mt-2 text-sm"},Ir={key:5,class:"flex flex-1 items-center justify-center text-gray-500 dark:text-gray-400"},Tr={class:"text-center"},Mr={class:"mt-2 text-sm"},zr={class:"mt-1 text-xs text-gray-400"},Ar={class:"max-h-[70vh] overflow-hidden p-6"},qr={class:"mb-4 flex items-center gap-2"},Lr={class:"text-lg font-semibold text-gray-900 dark:text-white"},Dr={key:0,class:"flex items-center justify-center py-8"},Er={class:"ml-2 text-sm text-gray-500"},Br={key:1,class:"max-h-[50vh] overflow-y-auto"},Fr=["innerHTML"],Rr={key:0,class:"mt-2 flex items-center text-xs text-gray-400"},Vr={key:2,class:"rounded-lg bg-red-50 p-4 dark:bg-red-950"},Or={class:"text-sm text-red-600 dark:text-red-400"},Pr={class:"mt-4 flex justify-end gap-2"},jr=ce({__name:"ResultTable",props:{result:{},error:{},sql:{},prompt:{}},setup(r,{expose:l}){const{t:e,locale:n}=we(),s=ot(),u=_a(),o=bt(),{aiGlobalSettings:c}=ct(u),g=[/^ts$/i,/^timestamp$/i,/^time$/i,/_at$/i,/_ts$/i,/_time$/i,/^date$/i];function p(Q){return g.some(X=>X.test(Q))}function v(Q){if(typeof Q!="number"||!Number.isFinite(Q))return!1;const X=946684800,pe=4102444800,ke=X*1e3,$e=pe*1e3;return Q>=X&&Q<=pe||Q>=ke&&Q<=$e}function _(Q){const pe=Q>1e10?Q:Q*1e3;return Ee(pe).format("YYYY-MM-DD HH:mm:ss")}const y=[/^id$/i,/^message_id$/i,/^msg_id$/i,/^msgid$/i];function k(Q){return Q.findIndex(X=>y.some(pe=>pe.test(X)))}function b(Q){o.openChatRecordDrawer({scrollToMessageId:Q})}const $=new Aa({html:!1,breaks:!0,linkify:!0,typographer:!0}),C=r,w=z(null),S=z("asc"),I=z(1),f=z(100),x=[50,100,200,500],B=z(localStorage.getItem("sql-lab-readable-time")!=="false");function R(){B.value=!B.value,localStorage.setItem("sql-lab-readable-time",String(B.value))}const D=z(!1),A=z(!1),M=z(""),q=z(null),Y=z(""),G=z(!1);function Z(Q){const X=Q.split("."),pe=X.length>1?X[X.length-1]:Q,ke=ha[n.value]||ha["zh-CN"];for(const $e of Object.values(ke))if($e[pe])return $e[pe];return null}const ue=T(()=>{if(!C.result||!w.value)return C.result?.rows||[];const Q=C.result.columns.indexOf(w.value);return Q===-1?C.result.rows:[...C.result.rows].sort((X,pe)=>{const ke=X[Q],$e=pe[Q];if(ke===null)return 1;if($e===null)return-1;if(typeof ke=="number"&&typeof $e=="number")return S.value==="asc"?ke-$e:$e-ke;const De=String(ke).localeCompare(String($e));return S.value==="asc"?De:-De})}),oe=T(()=>C.result?Math.ceil(ue.value.length/f.value):0),H=T(()=>{const Q=(I.value-1)*f.value,X=Q+f.value;return ue.value.slice(Q,X)}),P=T(()=>C.result?k(C.result.columns):-1),se=T(()=>P.value!==-1);function me(Q){w.value===Q?S.value=S.value==="asc"?"desc":"asc":(w.value=Q,S.value="asc"),I.value=1}function he(Q){f.value=Q,I.value=1}function ee(Q,X){return Q===null?"NULL":typeof Q=="object"?JSON.stringify(Q):B.value&&X&&p(X)&&v(Q)?_(Q):String(Q)}async function te(){if(!(!C.result||G.value)){G.value=!0;try{const Q=c.value.sqlExportFormat??"csv",X=await Zl({columns:C.result.columns,rows:C.result.rows},Q);if(X.success&&X.filePath){const pe=X.filePath.split("/").pop()||X.filePath;s.add({title:e("common.exportSuccess"),description:pe,color:"primary",actions:[{label:e("common.openFolder"),onClick:()=>{ns().showInFolder(X.filePath)}}]})}else s.fail(e("common.exportFailed"),{description:X.error})}catch(Q){console.error("导出失败:",Q),s.fail(e("common.exportFailed"),{description:String(Q)})}finally{G.value=!1}}}function N(){w.value=null,S.value="asc",I.value=1}function de(){if(!C.result)return"";const Q=50,X=C.result.rows.slice(0,Q),pe=C.result.columns.join(" | "),ke=C.result.columns.map(()=>"---").join(" | "),$e=X.map(Be=>Be.map(Te=>Te===null?"NULL":String(Te).slice(0,50)).join(" | "));let De=`| ${pe} |
6
- | ${ke} |
7
- `;return De+=$e.map(Be=>`| ${Be} |`).join(`
8
- `),C.result.rows.length>Q&&(De+=`
9
-
10
- (仅展示前 ${Q} 行,共 ${C.result.rowCount} 行)`),De}async function be(){D.value=!0,M.value="",q.value=null,Y.value="",await xe()}async function xe(){if(!await Ca().hasConfig()){q.value=e("common.errorNoAIConfig");return}A.value=!0,q.value=null,Y.value="";try{const X=de();let pe="";C.prompt&&(pe=`用户的查询意图:${C.prompt}
11
-
12
- `),C.sql&&(pe+=`执行的 SQL 语句:
13
- \`\`\`sql
14
- ${C.sql}
15
- \`\`\`
16
-
17
- `);const ke=`请分析以下 SQL 查询结果,用简洁的中文总结关键发现和洞察。
18
-
19
- ${pe}查询结果(共 ${C.result?.rowCount||0} 行):
20
-
21
- ${X}
22
-
23
- 请提供:
24
- 1. 结果概述(一句话总结)
25
- 2. 关键发现(2-4 个要点)
26
- 3. 如有明显的趋势或异常,请指出`,$e=await os().chatStream([{role:"system",content:"你是一个数据分析专家,擅长从查询结果中提取关键信息和洞察。请用简洁清晰的中文回答。"},{role:"user",content:ke}],{temperature:.3,maxTokens:1e3},De=>{De.content&&(Y.value+=De.content)});$e.success?M.value=Y.value:q.value=$e.error||e("ai.sqlLab.result.errorSummary")}catch(X){q.value=X.message||String(X)}finally{A.value=!1}}function le(){D.value=!1,M.value="",q.value=null,Y.value=""}return l({resetSort:N}),(Q,X)=>{const pe=_e,ke=wa,$e=Ue,De=$a,Be=Xe;return i(),m("div",Ji,[r.error?(i(),m("div",Xi,[a("div",Zi,[h(pe,{name:"i-heroicons-exclamation-circle",class:"mt-0.5 h-5 w-5 shrink-0 text-red-500"}),a("div",er,[a("p",tr,d(t(e)("ai.sqlLab.result.queryError")),1),a("p",ar,d(r.error),1)])])])):E("",!0),r.result?(i(),m("div",sr,[a("div",nr,[a("label",or,[h(ke,{"model-value":B.value,size:"xs","onUpdate:modelValue":R},null,8,["model-value"]),a("span",lr,d(t(e)("ai.sqlLab.result.readableTime")),1)]),X[5]||(X[5]=a("span",{class:"text-gray-300 dark:text-gray-600"},"|",-1)),a("span",null,[h(pe,{name:"i-heroicons-table-cells",class:"mr-1 inline h-4 w-4"}),ie(" "+d(t(e)("ai.sqlLab.result.rows",{count:r.result.rowCount})),1)]),a("span",null,[h(pe,{name:"i-heroicons-clock",class:"mr-1 inline h-4 w-4"}),ie(" "+d(r.result.duration)+" ms ",1)])]),a("div",ir,[h($e,{variant:"ghost",size:"xs",onClick:be},{default:F(()=>[h(pe,{name:"i-heroicons-sparkles",class:"mr-1 h-4 w-4"}),ie(" "+d(t(e)("ai.sqlLab.result.summarize")),1)]),_:1}),h($e,{variant:"ghost",size:"xs",loading:G.value,onClick:te},{default:F(()=>[h(pe,{name:"i-heroicons-arrow-down-tray",class:"mr-1 h-4 w-4"}),ie(" "+d(t(e)("common.export")),1)]),_:1},8,["loading"])])])):E("",!0),r.result&&r.result.rows.length>0?(i(),m("div",rr,[a("table",ur,[a("thead",cr,[a("tr",null,[(i(!0),m(re,null,ve(r.result.columns,(Te,Pe)=>(i(),m("th",{key:Pe,class:"cursor-pointer whitespace-nowrap px-4 py-2 text-left text-xs font-medium transition-colors hover:bg-gray-200 dark:hover:bg-gray-700",onClick:je=>me(Te)},[a("div",mr,[a("div",gr,[a("span",pr,d(Z(Te)||Te),1),Z(Te)?(i(),m("span",hr,d(Te),1)):E("",!0)]),w.value===Te?(i(),W(pe,{key:0,name:S.value==="asc"?"i-heroicons-chevron-up":"i-heroicons-chevron-down",class:"h-3 w-3 text-gray-500"},null,8,["name"])):E("",!0)])],8,dr))),128)),se.value?(i(),m("th",fr)):E("",!0)])]),a("tbody",vr,[(i(!0),m(re,null,ve(H.value,(Te,Pe)=>(i(),m("tr",{key:Pe,class:"hover:bg-gray-50 dark:hover:bg-gray-800"},[(i(!0),m(re,null,ve(Te,(je,Se)=>(i(),m("td",{key:Se,class:J(["max-w-xs truncate whitespace-nowrap px-4 py-2 font-mono text-sm text-gray-700 dark:text-gray-300",{"text-gray-400 italic":je===null}]),title:ee(je,r.result.columns[Se])},d(ee(je,r.result.columns[Se])),11,yr))),128)),se.value?(i(),m("td",xr,[h($e,{icon:"i-heroicons-chat-bubble-left-right",color:"neutral",variant:"ghost",size:"xs",title:t(e)("ai.sqlLab.result.viewChat"),onClick:je=>b(Te[P.value])},null,8,["title","onClick"])])):E("",!0)]))),128))])])])):E("",!0),r.result&&r.result.rows.length>0&&oe.value>1?(i(),m("div",br,[a("div",kr,[h($e,{icon:"i-heroicons-chevron-double-left",variant:"ghost",size:"xs",disabled:I.value===1,onClick:X[0]||(X[0]=Te=>I.value=1)},null,8,["disabled"]),h($e,{icon:"i-heroicons-chevron-left",variant:"ghost",size:"xs",disabled:I.value===1,onClick:X[1]||(X[1]=Te=>I.value--)},null,8,["disabled"]),a("span",_r,d(I.value)+" / "+d(oe.value),1),h($e,{icon:"i-heroicons-chevron-right",variant:"ghost",size:"xs",disabled:I.value>=oe.value,onClick:X[2]||(X[2]=Te=>I.value++)},null,8,["disabled"]),h($e,{icon:"i-heroicons-chevron-double-right",variant:"ghost",size:"xs",disabled:I.value>=oe.value,onClick:X[3]||(X[3]=Te=>I.value=oe.value)},null,8,["disabled"])]),a("div",wr,[a("span",null,d(t(e)("ai.sqlLab.result.pageSize")),1),h(De,{"model-value":f.value,items:x.map(Te=>({label:String(Te),value:Te})),size:"xs",class:"w-20","onUpdate:modelValue":he},null,8,["model-value","items"])])])):E("",!0),r.result&&r.result.rows.length===0?(i(),m("div",$r,[a("div",Cr,[h(pe,{name:"i-heroicons-inbox",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),a("p",Sr,d(t(e)("ai.sqlLab.result.emptyResult")),1)])])):E("",!0),!r.result&&!r.error?(i(),m("div",Ir,[a("div",Tr,[h(pe,{name:"i-heroicons-command-line",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),a("p",Mr,d(t(e)("ai.sqlLab.result.initialState")),1),a("p",zr,d(t(e)("ai.sqlLab.result.initialHint")),1)])])):E("",!0),h(Be,{open:D.value,"onUpdate:open":X[4]||(X[4]=Te=>D.value=Te)},{content:F(()=>[a("div",Ar,[a("div",qr,[h(pe,{name:"i-heroicons-sparkles",class:"h-5 w-5 text-pink-500"}),a("h3",Lr,d(t(e)("ai.sqlLab.result.summaryTitle")),1)]),A.value&&!Y.value?(i(),m("div",Dr,[h(pe,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-pink-500"}),a("span",Er,d(t(e)("ai.sqlLab.result.analyzing")),1)])):Y.value||M.value?(i(),m("div",Br,[a("div",{class:"prose prose-sm max-w-none rounded-lg bg-gray-50 p-4 dark:prose-invert dark:bg-page-dark",innerHTML:t($).render(Y.value||M.value)},null,8,Fr),A.value?(i(),m("div",Rr,[h(pe,{name:"i-heroicons-arrow-path",class:"mr-1 h-3 w-3 animate-spin"}),ie(" "+d(t(e)("common.generating")),1)])):E("",!0)])):E("",!0),q.value?(i(),m("div",Vr,[a("p",Or,d(q.value),1)])):E("",!0),a("div",Pr,[!A.value&&M.value?(i(),W($e,{key:0,variant:"outline",onClick:xe},{default:F(()=>[h(pe,{name:"i-heroicons-arrow-path",class:"mr-1 h-4 w-4"}),ie(" "+d(t(e)("common.regenerate")),1)]),_:1})):E("",!0),h($e,{variant:"ghost",onClick:le},{default:F(()=>[ie(d(t(e)("common.close")),1)]),_:1})])])]),_:1},8,["open"])])}}}),Nr={class:"main-content flex h-full"},Ur={class:"flex flex-1 flex-col overflow-hidden"},Wr={class:"flex flex-col border-b border-gray-200 bg-gray-50 p-4 dark:border-gray-800 dark:bg-page-dark"},Hr={class:"mx-auto w-full max-w-3xl"},Kr=["placeholder"],Yr=["placeholder"],Gr={class:"mt-1 flex items-center justify-between"},Qr={class:"flex items-center gap-2"},Jr={key:0,class:"text-xs text-gray-400"},Xr={class:"flex items-center gap-2"},Zr={key:0,class:"ml-1 text-xs text-gray-400"},eu={key:0,class:"flex-1 overflow-auto p-4"},tu={class:"mb-2 flex items-center gap-1.5 text-sm font-medium text-gray-600 dark:text-gray-300"},au={key:0,class:"text-gray-500"},su={key:1,class:"text-pink-500"},nu=["open"],ou={class:"cursor-pointer select-none text-xs font-medium text-gray-500 dark:text-gray-400"},lu={key:1,class:"whitespace-pre-wrap break-all font-mono text-xs leading-5 text-gray-600 dark:text-gray-400"},iu={key:2,class:"font-mono text-xs text-gray-400"},ru=ce({__name:"SQLLabTab",props:{sessionId:{},chatType:{}},setup(r){const{t:l,locale:e}=we(),n=r,s=z(null),u=z(null);function o(P){return l(P==="group"?"ai.sqlLab.generate.defaultPromptGroup":"ai.sqlLab.generate.defaultPromptPrivate")}const c=z("SELECT * FROM message LIMIT 10"),g=z(o(n.chatType)),p=z("prompt"),v=z(!1),_=z(!1),y=z(null),k=z(null),b=z(""),$=z(""),C=z(""),w=z(!1),S=z(null),I=z(!1),f=z([]);function x(){try{const P=`sql-lab-history-${n.sessionId}`,se=localStorage.getItem(P);se&&(f.value=JSON.parse(se))}catch(P){console.error("加载历史记录失败:",P)}}function B(){try{const P=`sql-lab-history-${n.sessionId}`;localStorage.setItem(P,JSON.stringify(f.value))}catch(P){console.error("保存历史记录失败:",P)}}function R(P,se,me){const he={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,prompt:P,sql:se,explanation:me,timestamp:Date.now()};f.value.unshift(he),f.value.length>50&&(f.value=f.value.slice(0,50)),B()}function D(P){f.value=f.value.filter(se=>se.id!==P),B()}async function A(){if(!c.value.trim()){y.value=l("ai.sqlLab.editor.errorEmptySQL");return}v.value=!0,y.value=null,k.value=null,u.value?.resetSort();try{k.value=await Ke().executeSQL(n.sessionId,c.value)}catch(P){y.value=P.message||String(P)}finally{v.value=!1}}function M(P,se){(P.ctrlKey||P.metaKey)&&P.key==="Enter"&&(P.preventDefault(),se==="prompt"?oe():A())}function q(P,se){c.value+=`${P}.${se}`}function Y(){p.value=p.value==="prompt"?"sql":"prompt"}function G(P){const se=[];for(const me of P){se.push(`### ${me.name} (${fa(me.name,e.value)})`),se.push("| 列名 | 说明 | 类型 |"),se.push("|------|------|------|");for(const he of me.columns){const ee=he.pk?" (主键)":"";se.push(`| ${he.name} | ${Da(me.name,he.name,e.value)}${ee} | ${he.type} |`)}se.push("")}return se.join(`
27
- `)}function Z(P,se){return`你是一个 SQLite 数据库专家。用户需要查询聊天记录数据库。
28
-
29
- ## 数据库结构
30
-
31
- ${G(se)}
32
-
33
- ## 重要说明
34
-
35
- 1. message 表的 ts 字段是 Unix 时间戳(秒),查询日期需要使用 datetime(ts, 'unixepoch') 转换
36
- 2. message.type 字段:0=文本, 1=图片, 2=语音, 3=视频, 4=文件, 5=表情包, 6=系统消息, 99=其他
37
- 3. member 和 message 表通过 message.sender_id = member.id 关联
38
- 4. **人名查询**:当识别到人名/昵称查询时,必须同时在 member 表的 account_name、group_nickname 和 aliases 三个字段中模糊搜索,使用 OR 连接:
39
- \`\`\`
40
- WHERE m.account_name LIKE '%人名%'
41
- OR m.group_nickname LIKE '%人名%'
42
- OR m.aliases LIKE '%人名%'
43
- \`\`\`
44
- 5. 显示成员名称时,使用 COALESCE(m.group_nickname, m.account_name, m.platform_id) 来获取最佳显示名
45
- 6. **查询具体消息时包含消息 ID**:当用户需要查看具体的聊天记录时,SELECT 应包含 msg.id 作为第一个字段,这样用户可以点击查看完整上下文。注意是 msg.id(消息 ID),不是 m.id(成员 ID)。
46
- 7. **统计查询不需要消息 ID**:当用户需要统计分析时,不需要返回 msg.id
47
- 8. **严禁使用不存在的字段**:只能使用上方 Schema 中明确存在的表名和列名,禁止使用如 sender.display_name、member.display_name 等虚构字段
48
- 9. **成员显示名写法**:如果需要显示成员名称,优先使用 COALESCE(m.group_nickname, m.account_name, m.platform_id);若不联表 member,可使用 COALESCE(msg.sender_group_nickname, msg.sender_account_name, msg.sender_id)
49
- 10. **单次只做一个分析目标**:一次 SQL 只返回一个语义一致的结果集,不要把多个分析目标用 UNION ALL/UNION 混合到同一结果表
50
-
51
- ## 用户需求
52
-
53
- ${P}
54
-
55
- ## 要求
56
-
57
- 请以 JSON 格式输出,包含两个字段:
58
- - sql: SQLite 查询语句(不要用代码块包裹)
59
- - explanation: 用简洁的中文解释这条 SQL 做了什么
60
-
61
- 示例格式:
62
- {"sql": "SELECT ...", "explanation": "这条SQL查询了..."}
63
-
64
- 注意:
65
- 1. 仅输出 JSON,不要有任何其他文字
66
- 2. SQL 中的查询结果限制在合理范围内(建议 LIMIT 100)
67
- 3. 确保 SQL 语法正确
68
- 4. 若用户需求包含多个分析目标,仅选择第一个目标生成 SQL`}function ue(P){let se=P.trim();se=se.replace(/^```json?\n?/i,"").replace(/\n?```$/i,"");try{const me=JSON.parse(se);return{sql:(me.sql||"").trim(),explanation:(me.explanation||"").trim()}}catch{return se=se.replace(/^```sql?\n?/i,"").replace(/\n?```$/i,""),{sql:se.trim(),explanation:""}}}async function oe(){const P=g.value.trim();if(!P){y.value=l("ai.sqlLab.generate.errorEmptyPrompt");return}if(!await Ca().hasConfig()){y.value=l("common.errorNoAIConfig");return}const me=s.value?.schema||[];if(me.length===0){y.value=l("common.error.unknown");return}_.value=!0,k.value=null,y.value=null,$.value="",C.value="",w.value=!1;let he="";try{const ee=Z(P,me),te=await os().chatStream([{role:"system",content:"你是一个 SQLite 专家,请以 JSON 格式输出 sql 和 explanation 字段。"},{role:"user",content:ee}],{temperature:.1,maxTokens:4096},de=>{if(de.thinking!==void 0){de.thinkingDone?w.value=!1:(w.value=!0,de.thinking&&(C.value+=de.thinking,qe(()=>{S.value&&(S.value.scrollTop=S.value.scrollHeight)})));return}de.error&&(he=de.error),de.isFinished&&de.finishReason==="length"&&(he=l("ai.sqlLab.generate.errorTokenLimit")),de.content&&($.value+=de.content)});if(!te.success){y.value=te.error||he||l("ai.sqlLab.generate.errorGenerate");return}if(he){y.value=he;return}const N=ue($.value);if(!N.sql){y.value=$.value?`${l("ai.sqlLab.generate.errorGenerate")}: ${$.value.slice(0,200)}`:l("ai.sqlLab.generate.errorGenerate");return}c.value=N.sql,b.value=P,R(P,N.sql,N.explanation),await A()}catch(ee){y.value=ee.message||String(ee)}finally{_.value=!1}}async function H(P){c.value=P.sql,b.value=P.prompt,I.value=!1,await A()}return Re(()=>{x()}),fe(()=>n.chatType,P=>{g.value=o(P)}),(P,se)=>{const me=_e,he=Ue;return i(),m("div",Nr,[h(t(Ei),{ref_key:"schemaPanelRef",ref:s,"session-id":r.sessionId,onInsertColumn:q},null,8,["session-id"]),a("div",Ur,[a("div",Wr,[a("div",Hr,[p.value==="prompt"?Qe((i(),m("textarea",{key:0,"onUpdate:modelValue":se[0]||(se[0]=ee=>g.value=ee),class:"h-32 w-full resize-none rounded-2xl border-0 bg-white p-3 text-sm text-gray-800 shadow-[0_2px_14px_rgba(0,0,0,0.04)] outline-none ring-1 ring-gray-200/60 transition-all placeholder:text-gray-400 focus:ring-primary-500/40 focus:shadow-[0_4px_20px_rgba(0,0,0,0.08)] dark:bg-page-dark dark:text-gray-200 dark:ring-white/5 dark:placeholder:text-gray-500 dark:focus:ring-primary-500/40",placeholder:t(l)("ai.sqlLab.generate.placeholder"),spellcheck:"false",onKeydown:se[1]||(se[1]=ee=>M(ee,"prompt"))},null,40,Kr)),[[ft,g.value]]):Qe((i(),m("textarea",{key:1,"onUpdate:modelValue":se[2]||(se[2]=ee=>c.value=ee),class:"h-32 w-full resize-none rounded-2xl border-0 bg-white p-3 font-mono text-sm text-gray-800 shadow-[0_2px_14px_rgba(0,0,0,0.04)] outline-none ring-1 ring-gray-200/60 transition-all placeholder:text-gray-400 focus:ring-primary-500/40 focus:shadow-[0_4px_20px_rgba(0,0,0,0.08)] dark:bg-page-dark dark:text-gray-200 dark:ring-white/5 dark:placeholder:text-gray-500 dark:focus:ring-primary-500/40",placeholder:t(l)("ai.sqlLab.editor.placeholder"),spellcheck:"false",onKeydown:se[3]||(se[3]=ee=>M(ee,"sql"))},null,40,Yr)),[[ft,c.value]]),a("div",Gr,[a("div",Qr,[h(he,{variant:"ghost",size:"xs",onClick:Y},{default:F(()=>[h(me,{name:"i-heroicons-arrows-right-left",class:"mr-1 h-3.5 w-3.5"}),ie(" "+d(p.value==="prompt"?t(l)("ai.sqlLab.editor.switchToSQLMode"):t(l)("ai.sqlLab.editor.switchToPromptMode")),1)]),_:1}),p.value==="sql"?(i(),m("span",Jr,d(t(l)("ai.sqlLab.editor.tip")),1)):E("",!0)]),a("div",Xr,[h(he,{variant:"ghost",size:"sm",disabled:f.value.length===0,onClick:se[4]||(se[4]=ee=>I.value=!0)},{default:F(()=>[h(me,{name:"i-heroicons-clock",class:"mr-1 h-4 w-4"}),ie(" "+d(t(l)("ai.sqlLab.editor.history"))+" ",1),f.value.length>0?(i(),m("span",Zr,"("+d(f.value.length)+")",1)):E("",!0)]),_:1},8,["disabled"]),p.value==="prompt"?(i(),W(he,{key:0,color:"primary",size:"sm",loading:_.value||v.value,disabled:!g.value.trim(),onClick:oe},{default:F(()=>[h(me,{name:"i-heroicons-sparkles",class:"mr-1 h-4 w-4"}),ie(" "+d(t(l)("ai.sqlLab.editor.generateAndRun")),1)]),_:1},8,["loading","disabled"])):(i(),W(he,{key:1,color:"primary",size:"sm",loading:v.value,onClick:A},{default:F(()=>[h(me,{name:"i-heroicons-play",class:"mr-1 h-4 w-4"}),ie(" "+d(t(l)("ai.sqlLab.editor.run")),1)]),_:1},8,["loading"]))])])])]),p.value==="prompt"&&!k.value&&!y.value&&($.value||C.value||_.value)?(i(),m("div",eu,[h(t(mt),{class:"mx-auto w-full max-w-3xl p-4"},{default:F(()=>[a("p",tu,[h(me,{name:"i-heroicons-cpu-chip",class:"h-4 w-4"}),ie(" "+d(t(l)("ai.sqlLab.generate.aiOutput"))+" ",1),w.value?(i(),m("span",au,d(t(l)("ai.sqlLab.generate.thinking")),1)):_.value?(i(),m("span",su,d(t(l)("common.generating")),1)):E("",!0)]),C.value?(i(),m("details",{key:0,class:"mb-3",open:w.value},[a("summary",ou,d(t(l)("ai.sqlLab.generate.thinkingProcess")),1),a("pre",{ref_key:"thinkingPreRef",ref:S,class:"mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-all rounded border border-gray-200 bg-gray-50 p-2 font-mono text-xs leading-5 text-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400"},d(C.value),513)],8,nu)):E("",!0),$.value?(i(),m("pre",lu,d($.value),1)):C.value?E("",!0):(i(),m("p",iu,d(t(l)("ai.sqlLab.generate.waitingAI")),1))]),_:1})])):(i(),W(t(jr),{key:1,ref_key:"resultTableRef",ref:u,result:k.value,error:y.value,sql:c.value,prompt:b.value},null,8,["result","error","sql","prompt"]))]),h(t(Qi),{open:I.value,"onUpdate:open":se[5]||(se[5]=ee=>I.value=ee),history:f.value,onExecute:H,onDelete:D},null,8,["open","history"])])}}}),uu={class:"flex h-full flex-col"},cu={class:"min-h-0 flex-1 overflow-hidden"},du=ce({__name:"LabTab",props:{sessionId:{},chatType:{}},setup(r){const l=r,{t:e}=we(),n=T(()=>[{id:"sql-lab",label:e("ai.tab.sqlLab"),icon:"i-heroicons-command-line"}]),s=z("sql-lab");return(u,o)=>(i(),m("div",uu,[h(t(ls),{modelValue:s.value,"onUpdate:modelValue":o[0]||(o[0]=c=>s.value=c),items:n.value,"persist-key":"labTab"},null,8,["modelValue","items"]),a("div",cu,[h(vt,{name:"fade",mode:"out-in"},{default:F(()=>[s.value==="sql-lab"?(i(),W(ru,{key:0,class:"h-full","session-id":l.sessionId,"chat-type":l.chatType},null,8,["session-id","chat-type"])):E("",!0)]),_:1})])]))}}),o2=at(du,[["__scopeId","data-v-7fc6fe33"]]),mu={class:"flex h-full items-center justify-center"},gu={class:"max-w-sm text-center"},pu={class:"mt-3 text-sm text-gray-400 dark:text-gray-500"},hu=["href"],l2=ce({__name:"MemoryTab",props:{sessionId:{},sessionName:{}},setup(r){const{t:l,te:e}=we(),n=T(()=>e("analysis.memory.joinLink")?l("analysis.memory.joinLink"):"");return(s,u)=>{const o=_e;return i(),m("div",mu,[a("div",gu,[h(o,{name:"i-heroicons-light-bulb",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),a("p",pu,d(t(l)("analysis.memory.comingSoon")),1),n.value?(i(),m("a",{key:0,href:n.value,target:"_blank",rel:"noopener noreferrer",class:"mt-2 inline-block text-sm text-primary-500 hover:text-primary-600 dark:text-primary-400 dark:hover:text-primary-300"},d(n.value),9,hu)):E("",!0)])])}}});function fu(r,l){if(typeof r!="object"||r===null)return!1;const e=it(r,l);return e!=null&&e!==""}function Ga(r,l){return l?{xs:44,sm:48,md:52,lg:56,xl:60}[r]:{xs:24,sm:28,md:32,lg:36,xl:40}[r]}function vu(r,l,e,n){const s=Ga(l,!0),u=Ga(l,!1);return n?()=>s:e?o=>fu(r[o],e)?s:u:()=>u}const yu={slots:{base:["relative group rounded-md inline-flex items-center disabled:cursor-not-allowed disabled:opacity-75","transition-colors"],leading:"absolute inset-y-0 start-0 flex items-center",leadingIcon:"shrink-0 text-dimmed",leadingAvatar:"shrink-0",leadingAvatarSize:"",trailing:"absolute inset-y-0 end-0 flex items-center",trailingIcon:"shrink-0 text-dimmed",value:"truncate pointer-events-none",placeholder:"truncate text-dimmed",arrow:"fill-bg stroke-default",content:["max-h-[min(15rem,var(--reka-select-content-available-height,15rem))] w-(--reka-select-trigger-width) bg-default shadow-lg rounded-md ring ring-default overflow-hidden origin-(--reka-select-content-transform-origin) pointer-events-auto flex flex-col","max-h-[min(15rem,var(--reka-combobox-content-available-height,15rem))] origin-(--reka-combobox-content-transform-origin) w-(--reka-combobox-trigger-width)"],viewport:"relative scroll-py-1 overflow-y-auto flex-1",group:"p-1 isolate",empty:"text-center text-muted",label:"font-semibold text-highlighted",separator:"-mx-1 my-1 h-px bg-border",item:["group relative w-full flex items-start select-none outline-none before:absolute before:z-[-1] before:inset-px before:rounded-md data-disabled:cursor-not-allowed data-disabled:opacity-75 text-default data-highlighted:not-data-disabled:text-highlighted data-highlighted:not-data-disabled:before:bg-elevated/50","transition-colors before:transition-colors"],itemLeadingIcon:["shrink-0 text-dimmed group-data-highlighted:not-group-data-disabled:text-default","transition-colors"],itemLeadingAvatar:"shrink-0",itemLeadingAvatarSize:"",itemLeadingChip:"shrink-0",itemLeadingChipSize:"",itemTrailing:"ms-auto inline-flex gap-1.5 items-center",itemTrailingIcon:"shrink-0",itemWrapper:"flex-1 flex flex-col min-w-0",itemLabel:"truncate",itemDescription:"truncate text-muted",input:"border-b border-default",focusScope:"flex flex-col min-h-0",trailingClear:"p-0"},variants:{fieldGroup:{horizontal:"not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]",vertical:"not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]"},size:{xs:{base:"px-2 py-1 text-xs gap-1",leading:"ps-2",trailing:"pe-2",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4",label:"p-1 text-[10px]/3 gap-1",item:"p-1 text-xs gap-1",itemLeadingIcon:"size-4",itemLeadingAvatarSize:"3xs",itemLeadingChip:"size-4",itemLeadingChipSize:"sm",itemTrailingIcon:"size-4",empty:"p-2 text-xs"},sm:{base:"px-2.5 py-1.5 text-xs gap-1.5",leading:"ps-2.5",trailing:"pe-2.5",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4",label:"p-1.5 text-[10px]/3 gap-1.5",item:"p-1.5 text-xs gap-1.5",itemLeadingIcon:"size-4",itemLeadingAvatarSize:"3xs",itemLeadingChip:"size-4",itemLeadingChipSize:"sm",itemTrailingIcon:"size-4",empty:"p-2.5 text-xs"},md:{base:"px-2.5 py-1.5 text-sm gap-1.5",leading:"ps-2.5",trailing:"pe-2.5",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5",label:"p-1.5 text-xs gap-1.5",item:"p-1.5 text-sm gap-1.5",itemLeadingIcon:"size-5",itemLeadingAvatarSize:"2xs",itemLeadingChip:"size-5",itemLeadingChipSize:"md",itemTrailingIcon:"size-5",empty:"p-2.5 text-sm"},lg:{base:"px-3 py-2 text-sm gap-2",leading:"ps-3",trailing:"pe-3",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5",label:"p-2 text-xs gap-2",item:"p-2 text-sm gap-2",itemLeadingIcon:"size-5",itemLeadingAvatarSize:"2xs",itemLeadingChip:"size-5",itemLeadingChipSize:"md",itemTrailingIcon:"size-5",empty:"p-3 text-sm"},xl:{base:"px-3 py-2 text-base gap-2",leading:"ps-3",trailing:"pe-3",leadingIcon:"size-6",leadingAvatarSize:"xs",trailingIcon:"size-6",label:"p-2 text-sm gap-2",item:"p-2 text-base gap-2",itemLeadingIcon:"size-6",itemLeadingAvatarSize:"xs",itemLeadingChip:"size-6",itemLeadingChipSize:"lg",itemTrailingIcon:"size-6",empty:"p-3 text-base"}},variant:{outline:"text-highlighted bg-default ring ring-inset ring-accented hover:bg-elevated disabled:bg-default",soft:"text-highlighted bg-elevated/50 hover:bg-elevated focus:bg-elevated disabled:bg-elevated/50",subtle:"text-highlighted bg-elevated ring ring-inset ring-accented hover:bg-accented/75 disabled:bg-elevated",ghost:"text-highlighted bg-transparent hover:bg-elevated focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent",none:"text-highlighted bg-transparent focus:outline-none"},color:{primary:"",secondary:"",success:"",info:"",warning:"",error:"",neutral:""},leading:{true:""},trailing:{true:""},loading:{true:""},highlight:{true:""},fixed:{false:""},type:{file:"file:me-1.5 file:font-medium file:text-muted file:outline-none"},position:{popper:{content:"data-[state=open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in]"},"item-aligned":{content:""}},multiple:{true:""},virtualize:{true:{viewport:"p-1 isolate"},false:{viewport:"divide-y divide-default"}}},compoundVariants:[{color:"primary",variant:["outline","subtle"],class:"outline-primary/25 focus-visible:outline-3 focus-visible:ring-primary"},{color:"secondary",variant:["outline","subtle"],class:"outline-secondary/25 focus-visible:outline-3 focus-visible:ring-secondary"},{color:"success",variant:["outline","subtle"],class:"outline-success/25 focus-visible:outline-3 focus-visible:ring-success"},{color:"info",variant:["outline","subtle"],class:"outline-info/25 focus-visible:outline-3 focus-visible:ring-info"},{color:"warning",variant:["outline","subtle"],class:"outline-warning/25 focus-visible:outline-3 focus-visible:ring-warning"},{color:"error",variant:["outline","subtle"],class:"outline-error/25 focus-visible:outline-3 focus-visible:ring-error"},{color:"primary",variant:["soft","ghost"],class:"outline-primary/25 focus-visible:outline-3"},{color:"secondary",variant:["soft","ghost"],class:"outline-secondary/25 focus-visible:outline-3"},{color:"success",variant:["soft","ghost"],class:"outline-success/25 focus-visible:outline-3"},{color:"info",variant:["soft","ghost"],class:"outline-info/25 focus-visible:outline-3"},{color:"warning",variant:["soft","ghost"],class:"outline-warning/25 focus-visible:outline-3"},{color:"error",variant:["soft","ghost"],class:"outline-error/25 focus-visible:outline-3"},{color:"primary",highlight:!0,class:"ring ring-inset ring-primary"},{color:"secondary",highlight:!0,class:"ring ring-inset ring-secondary"},{color:"success",highlight:!0,class:"ring ring-inset ring-success"},{color:"info",highlight:!0,class:"ring ring-inset ring-info"},{color:"warning",highlight:!0,class:"ring ring-inset ring-warning"},{color:"error",highlight:!0,class:"ring ring-inset ring-error"},{color:"neutral",variant:["outline","subtle"],class:"outline-inverted/25 focus-visible:outline-3 focus-visible:ring-inverted"},{color:"neutral",variant:["soft","ghost"],class:"outline-inverted/25 focus-visible:outline-3"},{color:"neutral",highlight:!0,class:"ring ring-inset ring-inverted"},{leading:!0,size:"xs",class:"ps-7"},{leading:!0,size:"sm",class:"ps-8"},{leading:!0,size:"md",class:"ps-9"},{leading:!0,size:"lg",class:"ps-10"},{leading:!0,size:"xl",class:"ps-11"},{trailing:!0,size:"xs",class:"pe-7"},{trailing:!0,size:"sm",class:"pe-8"},{trailing:!0,size:"md",class:"pe-9"},{trailing:!0,size:"lg",class:"pe-10"},{trailing:!0,size:"xl",class:"pe-11"},{loading:!0,leading:!0,class:{leadingIcon:"animate-spin"}},{loading:!0,leading:!1,trailing:!0,class:{trailingIcon:"animate-spin"}},{fixed:!1,size:"xs",class:"md:text-xs"},{fixed:!1,size:"sm",class:"md:text-xs"},{fixed:!1,size:"md",class:"md:text-sm"},{fixed:!1,size:"lg",class:"md:text-sm"}],defaultVariants:{size:"md",color:"primary",variant:"outline",position:"popper"}},Ea=Object.assign({inheritAttrs:!1},{__name:"SelectMenu",props:qt({id:{type:String,required:!1},placeholder:{type:String,required:!1},searchInput:{type:[Boolean,Object],required:!1,default:!0},color:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},required:{type:Boolean,required:!1},trailingIcon:{type:null,required:!1},selectedIcon:{type:null,required:!1},clear:{type:[Boolean,Object],required:!1},clearIcon:{type:null,required:!1},content:{type:Object,required:!1},arrow:{type:[Boolean,Object],required:!1},portal:{type:[Boolean,String],required:!1,skipCheck:!0,default:!0},virtualize:{type:[Boolean,Object],required:!1,default:!1},valueKey:{type:null,required:!1},labelKey:{type:null,required:!1,default:"label"},descriptionKey:{type:null,required:!1,default:"description"},items:{type:null,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1},modelModifiers:{type:null,required:!1},multiple:{type:Boolean,required:!1},highlight:{type:Boolean,required:!1},createItem:{type:[Boolean,String,Object],required:!1},filterFields:{type:Array,required:!1},ignoreFilter:{type:Boolean,required:!1},autofocus:{type:Boolean,required:!1},autofocusDelay:{type:Number,required:!1,default:0},class:{type:null,required:!1},ui:{type:Object,required:!1},open:{type:Boolean,required:!1},defaultOpen:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},name:{type:String,required:!1},resetSearchTermOnBlur:{type:Boolean,required:!1,default:!0},resetSearchTermOnSelect:{type:Boolean,required:!1,default:!0},resetModelValueOnClear:{type:Boolean,required:!1,default:!0},highlightOnHover:{type:Boolean,required:!1},by:{type:[String,Function],required:!1},icon:{type:null,required:!1},avatar:{type:Object,required:!1},leading:{type:Boolean,required:!1},leadingIcon:{type:null,required:!1},trailing:{type:Boolean,required:!1},loading:{type:Boolean,required:!1},loadingIcon:{type:null,required:!1}},{searchTerm:{type:String,default:""},searchTermModifiers:{}}),emits:qt(["change","blur","focus","create","clear","highlight","update:modelValue","update:open"],["update:searchTerm"]),setup(r,{expose:l,emit:e}){const n=r,s=e,u=Jt(),o=Sa("selectMenu",n),c=Ht(r,"searchTerm",{type:String,default:""}),{t:g}=_n(),p=Ta(),{filterGroups:v}=jl(),_=is(rs(o,"modelValue","defaultValue","open","defaultOpen","required","multiple","resetSearchTermOnBlur","resetSearchTermOnSelect","resetModelValueOnClear","highlightOnHover","by"),s),y=wn(We(()=>o.portal)),k=We(()=>Tt(o.content,{side:"bottom",sideOffset:8,collisionPadding:8,position:"popper"})),b=We(()=>Tt(o.arrow,{rounded:!0})),$=T(()=>typeof o.clear=="object"?o.clear:{}),C=We(()=>o.virtualize?Tt(typeof o.virtualize=="boolean"?{}:o.virtualize,{estimateSize:vu(Q.value,se.value||"md",o.descriptionKey,!!u["item-description"])}):!1),w=We(()=>Tt(o.searchInput,{placeholder:g("selectMenu.search"),variant:"none"})),{emitFormBlur:S,emitFormFocus:I,emitFormInput:f,emitFormChange:x,size:B,color:R,id:D,name:A,highlight:M,disabled:q,ariaAttrs:Y}=Ia(n),{orientation:G,size:Z}=us(n),{isLeading:ue,isTrailing:oe,leadingIconName:H,trailingIconName:P}=Ma(We(()=>Tt(o,{trailingIcon:p.ui.icons.chevronDown}))),se=T(()=>Z.value||B.value),[me,he]=Va(),[ee,te]=Va({props:{item:{type:[Object,String,Number,Boolean],required:!0},index:{type:Number,required:!1}}}),N=T(()=>$t({extend:$t(yu),...p.ui?.selectMenu||{}})({color:R.value??o.color,variant:o.variant,size:se?.value??o.size,loading:o.loading,highlight:M.value??o.highlight,leading:ue.value||!!o.avatar||!!u.leading,trailing:oe.value||!!u.trailing,fieldGroup:G.value,virtualize:!!o.virtualize,multiple:o.multiple}));function de(L){if(o.multiple&&Array.isArray(L)){const j=L.map(U=>Oa(xe.value,U,{labelKey:o.labelKey,valueKey:o.valueKey,by:o.by})).filter(U=>U!=null&&U!=="");return j.length>0?j.join(", "):void 0}return Oa(xe.value,L,{labelKey:o.labelKey,valueKey:o.valueKey,by:o.by})}const be=T(()=>o.items?.length?In(o.items)?o.items:[o.items]:[]),xe=T(()=>be.value.flatMap(L=>L)),le=T(()=>{if(o.ignoreFilter||!c.value)return be.value;const L=Array.isArray(o.filterFields)?o.filterFields:[o.labelKey];return v(be.value,c.value,{fields:L,isStructural:j=>Se(j)&&!!j.type&&["label","separator"].includes(j.type)})}),Q=T(()=>le.value.flatMap(L=>L)),X=T(()=>{if(!o.createItem||!c.value)return!1;const L=o.valueKey?{[o.valueKey]:c.value}:c.value;return typeof o.createItem=="object"&&o.createItem.when==="always"||o.createItem==="always"?!Q.value.find(j=>Sn(j,L,o.by??o.valueKey)):!Q.value.length}),pe=T(()=>typeof o.createItem=="object"?o.createItem.position:"bottom"),ke=zt("triggerRef");function $e(){o.autofocus&&ke.value?.$el?.focus({focusVisible:!0})}Re(()=>{setTimeout(()=>{$e()},o.autofocusDelay)});function De(L){if(cs(o.modelValue)===L)return;o.modelModifiers?.trim&&(typeof L=="string"||L===null||L===void 0)&&(L=L?.trim()??null),o.modelModifiers?.number&&(L=ds(L)),o.modelModifiers?.nullable&&(L??=null),o.modelModifiers?.optional&&!o.modelModifiers?.nullable&&L!==null&&(L??=void 0);const j=new Event("change",{target:{value:L}});s("change",j),x(),f(),o.resetSearchTermOnSelect&&(c.value="")}const Be=z(!1);function Te(L){Be.value=L;let j;if(L){const U=new FocusEvent("focus");s("focus",U),I(),clearTimeout(j)}else{const U=new FocusEvent("blur");s("blur",U),S(),o.resetSearchTermOnBlur&&(j=setTimeout(()=>{c.value=""},100))}}function Pe(L){L.preventDefault(),L.stopPropagation(),s("create",c.value)}function je(L,j){if(Se(j)){if(j.disabled){L.preventDefault();return}j.onSelect?.(L)}}function Se(L){return typeof L=="object"&&L!==null}function ge(L){return o.multiple&&Array.isArray(L)?L.length===0:L==null||L===""}function O(){s("clear")}const V=zt("viewportRef"),K=zt("comboboxRootRef");return fe(()=>o.items,async()=>{Be.value&&(await qe(),K.value?.highlightFirstItem?.())},{flush:"post"}),l({triggerRef:We(()=>ke.value?.$el),viewportRef:We(()=>V.value)}),(L,j)=>(i(),m(re,null,[h(t(me),null,{default:F(()=>[h(t(Ka),{"data-slot":"item",class:J(N.value.item({class:t(o).ui?.item})),value:c.value,onSelect:Pe},{default:F(()=>[a("span",{"data-slot":"itemLabel",class:J(N.value.itemLabel({class:t(o).ui?.itemLabel}))},[ye(L.$slots,"create-item-label",{item:c.value},()=>[ie(d(t(g)("selectMenu.create",{label:c.value})),1)])],2)]),_:3},8,["class","value"])]),_:3}),h(t(ee),null,{default:F(({item:U,index:ae})=>[Se(U)&&U.type==="label"?(i(),W(t(yl),{key:0,"data-slot":"label",class:J(N.value.label({class:[t(o).ui?.label,U.ui?.label,U.class]}))},{default:F(()=>[ie(d(t(it)(U,t(o).labelKey)),1)]),_:2},1032,["class"])):Se(U)&&U.type==="separator"?(i(),W(t(_l),{key:1,"data-slot":"separator",class:J(N.value.separator({class:[t(o).ui?.separator,U.ui?.separator,U.class]}))},null,8,["class"])):(i(),W(t(Ka),{key:2,"data-slot":"item",class:J(N.value.item({class:[t(o).ui?.item,Se(U)&&U.ui?.item,Se(U)&&U.class]})),disabled:Se(U)&&U.disabled,value:t(o).valueKey&&Se(U)?t(it)(U,t(o).valueKey):U,onSelect:ne=>je(ne,U)},{default:F(()=>[ye(L.$slots,"item",{item:U,index:ae,ui:N.value},()=>[ye(L.$slots,"item-leading",{item:U,index:ae,ui:N.value},()=>[Se(U)&&U.icon?(i(),W(_e,{key:0,name:U.icon,"data-slot":"itemLeadingIcon",class:J(N.value.itemLeadingIcon({class:[t(o).ui?.itemLeadingIcon,U.ui?.itemLeadingIcon]}))},null,8,["name","class"])):Se(U)&&U.avatar?(i(),W(Kt,Ae({key:1,size:U.ui?.itemLeadingAvatarSize||t(o).ui?.itemLeadingAvatarSize||N.value.itemLeadingAvatarSize()},U.avatar,{"data-slot":"itemLeadingAvatar",class:N.value.itemLeadingAvatar({class:[t(o).ui?.itemLeadingAvatar,U.ui?.itemLeadingAvatar]})}),null,16,["size","class"])):Se(U)&&U.chip?(i(),W($n,Ae({key:2,size:U.ui?.itemLeadingChipSize||t(o).ui?.itemLeadingChipSize||N.value.itemLeadingChipSize(),inset:"",standalone:""},U.chip,{"data-slot":"itemLeadingChip",class:N.value.itemLeadingChip({class:[t(o).ui?.itemLeadingChip,U.ui?.itemLeadingChip]})}),null,16,["size","class"])):E("",!0)]),a("span",{"data-slot":"itemWrapper",class:J(N.value.itemWrapper({class:[t(o).ui?.itemWrapper,Se(U)&&U.ui?.itemWrapper]}))},[a("span",{"data-slot":"itemLabel",class:J(N.value.itemLabel({class:[t(o).ui?.itemLabel,Se(U)&&U.ui?.itemLabel]}))},[ye(L.$slots,"item-label",{item:U,index:ae},()=>[ie(d(Se(U)?t(it)(U,t(o).labelKey):U),1)])],2),Se(U)&&(t(it)(U,t(o).descriptionKey)||u["item-description"])?(i(),m("span",{key:0,"data-slot":"itemDescription",class:J(N.value.itemDescription({class:[t(o).ui?.itemDescription,Se(U)&&U.ui?.itemDescription]}))},[ye(L.$slots,"item-description",{item:U,index:ae},()=>[ie(d(t(it)(U,t(o).descriptionKey)),1)])],2)):E("",!0)],2),a("span",{"data-slot":"itemTrailing",class:J(N.value.itemTrailing({class:[t(o).ui?.itemTrailing,Se(U)&&U.ui?.itemTrailing]}))},[ye(L.$slots,"item-trailing",{item:U,index:ae,ui:N.value}),h(t(fl),{"as-child":""},{default:F(()=>[h(_e,{name:t(o).selectedIcon||t(p).ui.icons.check,"data-slot":"itemTrailingIcon",class:J(N.value.itemTrailingIcon({class:[t(o).ui?.itemTrailingIcon,Se(U)&&U.ui?.itemTrailingIcon]}))},null,8,["name","class"])]),_:2},1024)],2)])]),_:2},1032,["class","disabled","value","onSelect"]))]),_:3}),h(t(Go),Ae({ref_key:"comboboxRootRef",ref:K},t(_),{"ignore-filter":"","as-child":"",name:t(A),disabled:t(q),"onUpdate:modelValue":De,"onUpdate:open":Te}),{default:F(({modelValue:U,open:ae})=>[h(t(Jo),{"as-child":""},{default:F(()=>[h(t($l),Ae({id:t(D),ref_key:"triggerRef",ref:ke,"data-slot":"base",class:N.value.base({class:[t(o).ui?.base,t(o).class]}),tabindex:"0"},{...L.$attrs,...t(Y)}),{default:F(()=>[t(ue)||t(o).avatar||u.leading?(i(),m("span",{key:0,"data-slot":"leading",class:J(N.value.leading({class:t(o).ui?.leading}))},[ye(L.$slots,"leading",{modelValue:U,open:ae,ui:N.value},()=>[t(ue)&&t(H)?(i(),W(_e,{key:0,name:t(H),"data-slot":"leadingIcon",class:J(N.value.leadingIcon({class:t(o).ui?.leadingIcon}))},null,8,["name","class"])):t(o).avatar?(i(),W(Kt,Ae({key:1,size:t(o).ui?.itemLeadingAvatarSize||N.value.itemLeadingAvatarSize()},t(o).avatar,{"data-slot":"itemLeadingAvatar",class:N.value.itemLeadingAvatar({class:t(o).ui?.itemLeadingAvatar})}),null,16,["size","class"])):E("",!0)])],2)):E("",!0),ye(L.$slots,"default",{modelValue:U,open:ae,ui:N.value},()=>[(i(!0),m(re,null,ve([de(U)],ne=>(i(),m(re,{key:ne},[ne!=null?(i(),m("span",{key:0,"data-slot":"value",class:J(N.value.value({class:t(o).ui?.value}))},d(ne),3)):(i(),m("span",{key:1,"data-slot":"placeholder",class:J(N.value.placeholder({class:t(o).ui?.placeholder}))},d(t(o).placeholder??" "),3))],64))),128))]),t(oe)||u.trailing||t(o).clear?(i(),m("span",{key:1,"data-slot":"trailing",class:J(N.value.trailing({class:t(o).ui?.trailing}))},[ye(L.$slots,"trailing",{modelValue:U,open:ae,ui:N.value},()=>[t(o).clear&&!ge(U)?(i(),W(t(ol),{key:0,"as-child":""},{default:F(()=>[h(Ue,Ae({as:"span",icon:t(o).clearIcon||t(p).ui.icons.close,size:se.value,variant:"link",color:"neutral",tabindex:"-1"},$.value,{"data-slot":"trailingClear",class:N.value.trailingClear({class:t(o).ui?.trailingClear}),onClick:Oe(O,["stop"])}),null,16,["icon","size","class"])]),_:1})):t(P)?(i(),W(_e,{key:1,name:t(P),"data-slot":"trailingIcon",class:J(N.value.trailingIcon({class:t(o).ui?.trailingIcon}))},null,8,["name","class"])):E("",!0)])],2)):E("",!0)]),_:2},1040,["id","class"])]),_:2},1024),h(t(bl),ht(At(t(y))),{default:F(()=>[h(t(Cn),null,{default:F(()=>[h(t(il),Ae({"data-slot":"content",class:N.value.content({class:t(o).ui?.content})},k.value),{default:F(()=>[h(t(ss),{trapped:"","data-slot":"focusScope",class:J(N.value.focusScope({class:t(o).ui?.focusScope}))},{default:F(()=>[ye(L.$slots,"content-top"),t(o).searchInput?(i(),W(t(gl),{key:0,modelValue:c.value,"onUpdate:modelValue":j[1]||(j[1]=ne=>c.value=ne),"display-value":()=>c.value,"as-child":""},{default:F(()=>[h(Ft,Ae({autofocus:"",autocomplete:"off",size:se.value},w.value,{"model-modifiers":{trim:t(o).modelModifiers?.trim},"data-slot":"input",class:N.value.input({class:t(o).ui?.input}),onChange:j[0]||(j[0]=Oe(()=>{},["stop"]))}),null,16,["size","model-modifiers","class"])]),_:1},8,["modelValue","display-value"])):E("",!0),h(t(ul),{"data-slot":"empty",class:J(N.value.empty({class:t(o).ui?.empty}))},{default:F(()=>[ye(L.$slots,"empty",{searchTerm:c.value},()=>[ie(d(c.value?t(g)("selectMenu.noMatch",{searchTerm:c.value}):t(g)("selectMenu.noData")),1)])]),_:3},8,["class"]),a("div",{ref_key:"viewportRef",ref:V,role:"presentation","data-slot":"viewport",class:J(N.value.viewport({class:t(o).ui?.viewport}))},[t(o).virtualize?(i(),m(re,{key:0},[X.value&&pe.value==="top"?(i(),W(t(he),{key:0})):E("",!0),h(t(Sl),Ae({options:Q.value,"text-content":ne=>Se(ne)?t(it)(ne,t(o).labelKey):String(ne)},C.value),{default:F(({option:ne,virtualItem:Ve})=>[h(t(te),{item:ne,index:Ve.index},null,8,["item","index"])]),_:1},16,["options","text-content"]),X.value&&pe.value==="bottom"?(i(),W(t(he),{key:1})):E("",!0)],64)):(i(),m(re,{key:1},[X.value&&pe.value==="top"?(i(),W(t(ia),{key:0,"data-slot":"group",class:J(N.value.group({class:t(o).ui?.group}))},{default:F(()=>[h(t(he))]),_:1},8,["class"])):E("",!0),(i(!0),m(re,null,ve(le.value,(ne,Ve)=>(i(),W(t(ia),{key:`group-${Ve}`,"data-slot":"group",class:J(N.value.group({class:t(o).ui?.group}))},{default:F(()=>[(i(!0),m(re,null,ve(ne,(Le,Me)=>(i(),W(t(te),{key:`group-${Ve}-${Me}`,item:Le,index:Me},null,8,["item","index"]))),128))]),_:2},1032,["class"]))),128)),X.value&&pe.value==="bottom"?(i(),W(t(ia),{key:1,"data-slot":"group",class:J(N.value.group({class:t(o).ui?.group}))},{default:F(()=>[h(t(he))]),_:1},8,["class"])):E("",!0)],64))],2),ye(L.$slots,"content-bottom")]),_:3},8,["class"]),t(o).arrow?(i(),W(t(sl),Ae({key:0},b.value,{"data-slot":"arrow",class:N.value.arrow({class:t(o).ui?.arrow})}),null,16,["class"])):E("",!0)]),_:3},16,["class"])]),_:3})]),_:3},16)]),_:3},16,["name","disabled"])],64))}}),xu={class:"h-full p-3"},bu={class:"relative z-20 flex items-center gap-2 border-b border-gray-200 px-4 py-2 dark:border-gray-700"},ku={key:0,class:"mx-4 mt-2 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-400"},_u={class:"flex-1 overflow-auto"},wu={key:0,class:"flex h-full items-center justify-center"},$u={class:"text-sm text-gray-400"},Cu={key:1,class:"w-full border-collapse text-xs"},Su={class:"sticky top-0 bg-gray-50 dark:bg-page-dark"},Iu={class:"font-mono text-xs font-medium text-gray-700 dark:text-gray-300"},Tu={class:"text-[10px] leading-tight text-gray-400"},Mu={class:"border-b border-r border-gray-100 px-2 py-1.5 text-gray-400 dark:border-gray-800"},zu=["title"],Au=["onUpdate:modelValue"],qu={class:"w-full truncate px-2 py-1.5"},Lu={key:0,class:"italic text-gray-400"},Du={key:1},Eu={class:"border-b border-gray-100 px-2 py-1.5 text-center dark:border-gray-800"},Bu={key:0,class:"flex items-center justify-center gap-1"},Fu={key:1,class:"flex items-center justify-center gap-1"},Ru={class:"flex items-center justify-between border-t border-gray-200 px-4 py-2 dark:border-gray-700"},Vu={class:"text-xs text-gray-500 dark:text-gray-400"},Ou={key:0,class:"flex items-center gap-3"},Pu={class:"text-xs text-gray-500 dark:text-gray-400"},Pt=100,ju=ce({__name:"TableBrowser",props:{sessionId:{}},setup(r){const l=["member","meta","message","message_context","member_name_history"],{t:e,locale:n}=we(),s=r,u=z(localStorage.getItem("debug_dbSource")||"chat"),o=z([]),c=z(""),g=z(null),p=z(!1),v=z(null),_=z(1),y=z(0),k=T(()=>Math.max(1,Math.ceil(y.value/Pt))),b=z(null),$=z({}),C=z(!1),w=T(()=>u.value==="ai"),S=z([]),I=z(""),f=T(()=>w.value&&c.value==="ai_message"&&S.value.length>0),x=T(()=>{const ee={label:e("analysis.debug.tableBrowser.allConversations"),value:"__all__"},te=S.value.map(N=>({label:N.title||N.id.slice(0,16),value:N.id}));return[ee,...te]});async function B(){if(!w.value){S.value=[];return}try{const ee=s.sessionId.replace(/'/g,"''"),te=await Ye().executeAiSQL(`SELECT id, title FROM ai_chat WHERE session_id = '${ee}' ORDER BY updated_at DESC`);S.value=te.rows.map(N=>({id:String(N[0]),title:N[1]?String(N[1]):null})),I.value="__all__"}catch{S.value=[]}}const R=T(()=>[{label:e("analysis.debug.tableBrowser.chatDb"),value:"chat"},{label:e("analysis.debug.tableBrowser.aiDb"),value:"ai"}]),D=T(()=>{const ee=[...o.value];return ee.sort((te,N)=>{const de=l.indexOf(te.name),be=l.indexOf(N.name);return de!==-1&&be!==-1?de-be:de!==-1?-1:be!==-1?1:0}),ee}),A=T(()=>D.value.map(ee=>({label:ee.name,value:ee.name})));async function M(ee){return u.value==="ai"?await Ye().executeAiSQL(ee):await Ke().executeSQL(s.sessionId,ee)}async function q(){try{if(u.value==="ai"?o.value=await Ye().getAiSchema():o.value=await Ke().getSchema(s.sessionId),D.value.length>0){const ee=w.value?"ai_message":D.value[0].name;c.value=D.value.some(te=>te.name===ee)?ee:D.value[0].name}else c.value="",g.value=null}catch(ee){console.error("Failed to load schema:",ee)}}function Y(){if(!w.value)return"";const ee=s.sessionId.replace(/'/g,"''"),te=c.value;return te==="ai_chat"?` WHERE "session_id" = '${ee}'`:te==="ai_message"?I.value&&I.value!=="__all__"?` WHERE "ai_chat_id" = '${I.value.replace(/'/g,"''")}'`:` WHERE "ai_chat_id" IN (SELECT "id" FROM "ai_chat" WHERE "session_id" = '${ee}')`:""}async function G(){if(c.value){p.value=!0,v.value=null,b.value=null;try{const ee=Y(),te=await M(`SELECT COUNT(*) as cnt FROM "${c.value}"${ee}`);y.value=te?.rows?.[0]?.[0]??0;const N=(_.value-1)*Pt;g.value=await M(`SELECT * FROM "${c.value}"${ee} ORDER BY rowid DESC LIMIT ${Pt} OFFSET ${N}`)}catch(ee){v.value=ee.message||String(ee),g.value=null}finally{p.value=!1}}}function Z(ee){if(!g.value)return;b.value=ee;const te=g.value.rows[ee],N={};g.value.columns.forEach((de,be)=>{N[de]=te[be]==null?"":String(te[be])}),$.value=N}function ue(){b.value=null,$.value={}}async function oe(){if(b.value===null||!g.value)return;const ee=c.value,te=o.value.find(X=>X.name===ee);if(!te)return;const N=te.columns.find(X=>X.pk);if(!N){v.value="No primary key found for this table";return}const de=g.value.rows[b.value],be=g.value.columns.indexOf(N.name),xe=de[be],le=g.value.columns.filter(X=>X!==N.name).map(X=>`"${X}" = '${$.value[X].replace(/'/g,"''")}'`).join(", "),Q=`UPDATE "${ee}" SET ${le} WHERE "${N.name}" = '${String(xe).replace(/'/g,"''")}'`;try{await M(Q),ue(),await G()}catch(X){v.value=X.message||String(X)}}async function H(ee){if(!g.value)return;const te=c.value,N=o.value.find(X=>X.name===te);if(!N)return;const de=N.columns.find(X=>X.pk);if(!de){v.value="No primary key found for this table";return}const be=g.value.rows[ee],xe=g.value.columns.indexOf(de.name),le=be[xe],Q=`DELETE FROM "${te}" WHERE "${de.name}" = '${String(le).replace(/'/g,"''")}'`;try{await M(Q),await G()}catch(X){v.value=X.message||String(X)}}function P(ee){confirm(e("analysis.debug.tableBrowser.confirmDelete"))&&H(ee)}async function se(){if(confirm(e("analysis.debug.tableBrowser.confirmClearDebug"))){C.value=!0;try{(await Ye().clearDebugContext()).success&&await G()}catch(ee){v.value=ee.message||String(ee)}finally{C.value=!1}}}function me(ee){navigator.clipboard.writeText(ee)}function he(ee,te,N){if(!g.value)return[];const de=ee==null?"NULL":String(ee),be=g.value.rows[N],xe={};return g.value.columns.forEach((le,Q)=>{xe[le]=be[Q]}),[[{label:e("analysis.debug.tableBrowser.copyCell"),class:"p-2",onSelect:()=>me(de)},{label:e("analysis.debug.tableBrowser.editRow"),class:"p-2",onSelect:()=>Z(N)},{label:e("analysis.debug.tableBrowser.copyRow"),class:"p-2",onSelect:()=>me(JSON.stringify(xe,null,2))},{label:e("analysis.debug.tableBrowser.deleteRow"),class:"p-2 text-red-600 dark:text-red-400",onSelect:()=>H(N)}]]}return fe(u,ee=>{localStorage.setItem("debug_dbSource",ee),c.value="",g.value=null,y.value=0,_.value=1,I.value="",q(),B()}),fe(c,ee=>{ee&&(_.value=1,G())}),fe(I,()=>{c.value==="ai_message"&&(_.value=1,G())}),fe(_,()=>{G()}),Re(async()=>{await Promise.all([q(),B()]),c.value&&await G()}),(ee,te)=>{const N=Ea,de=Ue,be=Tn;return i(),m("div",xu,[h(t(mt),{shadow:!1,class:"flex h-full min-w-0 flex-col"},{default:F(()=>[a("div",bu,[h(t(pt),{modelValue:u.value,"onUpdate:modelValue":te[0]||(te[0]=xe=>u.value=xe),items:R.value,size:"xs"},null,8,["modelValue","items"]),te[5]||(te[5]=a("div",{class:"mx-1 h-4 w-px bg-gray-200 dark:bg-gray-700"},null,-1)),a("div",{class:J([w.value?"max-w-[50%]":"flex-1","min-w-0"])},[h(t(pt),{modelValue:c.value,"onUpdate:modelValue":te[1]||(te[1]=xe=>c.value=xe),items:A.value,size:"xs"},null,8,["modelValue","items"])],2),f.value?(i(),W(N,{key:0,modelValue:I.value,"onUpdate:modelValue":te[2]||(te[2]=xe=>I.value=xe),items:x.value,"value-key":"value",class:"w-48",size:"xs",ui:{content:"z-50"}},null,8,["modelValue","items"])):E("",!0),te[6]||(te[6]=a("div",{class:"flex-1"},null,-1)),w.value&&c.value==="ai_message"?(i(),W(de,{key:1,variant:"ghost",size:"xs",color:"error",icon:"i-heroicons-trash",loading:C.value,onClick:se},{default:F(()=>[ie(d(t(e)("analysis.debug.tableBrowser.clearDebugContext")),1)]),_:1},8,["loading"])):E("",!0),h(de,{variant:"ghost",size:"xs",icon:"i-heroicons-arrow-path",loading:p.value,onClick:G},{default:F(()=>[ie(d(t(e)("analysis.debug.tableBrowser.refresh")),1)]),_:1},8,["loading"])]),v.value?(i(),m("div",ku,d(v.value),1)):E("",!0),a("div",_u,[!g.value&&!p.value?(i(),m("div",wu,[a("p",$u,d(t(e)("analysis.debug.tableBrowser.noData")),1)])):g.value?(i(),m("table",Cu,[a("thead",Su,[a("tr",null,[te[7]||(te[7]=a("th",{class:"whitespace-nowrap border-b border-r border-gray-200 px-2 py-1.5 text-left font-medium text-gray-500 dark:border-gray-700 dark:text-gray-400"}," # ",-1)),(i(!0),m(re,null,ve(g.value.columns,xe=>(i(),m("th",{key:xe,class:"border-b border-r border-gray-200 px-2 py-1.5 text-left dark:border-gray-700"},[a("div",Iu,d(xe),1),a("div",Tu,d(t(Da)(c.value,xe,t(n))),1)]))),128)),te[8]||(te[8]=a("th",{class:"whitespace-nowrap border-b border-gray-200 px-2 py-1.5 text-center font-medium text-gray-500 dark:border-gray-700 dark:text-gray-400"}," 操作 ",-1))])]),a("tbody",null,[(i(!0),m(re,null,ve(g.value.rows,(xe,le)=>(i(),m("tr",{key:le,class:"transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[a("td",Mu,d((_.value-1)*Pt+le+1),1),(i(!0),m(re,null,ve(xe,(Q,X)=>(i(),m("td",{key:X,class:"max-w-[300px] border-b border-r border-gray-100 p-0 text-gray-700 dark:border-gray-800 dark:text-gray-300",title:Q==null?"NULL":String(Q)},[b.value===le?Qe((i(),m("input",{key:0,"onUpdate:modelValue":pe=>$.value[g.value.columns[X]]=pe,class:"w-full px-2 py-1.5 rounded border border-gray-300 bg-white text-xs dark:border-gray-600 dark:bg-gray-800"},null,8,Au)),[[ft,$.value[g.value.columns[X]]]]):(i(),W(be,{key:1,items:he(Q,X,le)},{default:F(()=>[a("div",qu,[Q==null?(i(),m("span",Lu,"NULL")):(i(),m("span",Du,d(String(Q).slice(0,200)),1))])]),_:2},1032,["items"]))],8,zu))),128)),a("td",Eu,[b.value===le?(i(),m("div",Bu,[h(de,{size:"xs",color:"primary",variant:"ghost",icon:"i-heroicons-check",onClick:oe}),h(de,{size:"xs",color:"neutral",variant:"ghost",icon:"i-heroicons-x-mark",onClick:ue})])):(i(),m("div",Fu,[h(de,{size:"xs",variant:"ghost",icon:"i-heroicons-pencil-square",onClick:Q=>Z(le)},null,8,["onClick"]),h(de,{size:"xs",variant:"ghost",color:"error",icon:"i-heroicons-trash",onClick:Q=>P(le)},null,8,["onClick"])]))])]))),128))])])):E("",!0)]),a("div",Ru,[a("span",Vu,d(y.value>0?t(e)("analysis.debug.tableBrowser.rowCount",{count:y.value}):""),1),k.value>1?(i(),m("div",Ou,[h(de,{size:"xs",variant:"ghost",disabled:_.value<=1,icon:"i-heroicons-chevron-left",onClick:te[3]||(te[3]=xe=>_.value--)},null,8,["disabled"]),a("span",Pu,d(t(e)("analysis.debug.tableBrowser.page",{current:_.value,total:k.value})),1),h(de,{size:"xs",variant:"ghost",disabled:_.value>=k.value,icon:"i-heroicons-chevron-right",onClick:te[4]||(te[4]=xe=>_.value++)},null,8,["disabled"])])):E("",!0)])]),_:1})])}}}),Nu={class:"flex h-full"},Uu={class:"m-3 h-[calc(100%-1.5rem)] w-56 shrink-0 overflow-y-auto rounded-lg bg-white shadow-elevated dark:bg-sidebar-dark"},Wu={key:0,class:"py-2"},Hu={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},Ku=["title","onClick"],Yu={class:"truncate text-xs font-medium"},Gu={class:"truncate text-[10px] opacity-50"},Qu={key:1,class:"border-t border-gray-200 py-2 dark:border-gray-700"},Ju={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},Xu=["title","onClick"],Zu={class:"truncate text-xs font-medium"},ec={class:"truncate text-[10px] opacity-50"},tc={class:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4"},ac={key:0,class:"rounded-lg border border-primary-200 bg-primary-50/50 px-4 py-3 dark:border-primary-800 dark:bg-primary-900/20"},sc={class:"text-sm font-medium text-primary-700 dark:text-primary-300"},nc={class:"mt-1 text-xs text-primary-600/70 dark:text-primary-400/70"},oc={key:1,class:"flex flex-col gap-3"},lc={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},ic={class:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3"},rc={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},uc={key:0,class:"text-red-500"},cc={key:1,class:"ml-1 text-gray-400"},dc={key:2,class:"ml-1 text-gray-400"},mc={class:"flex items-center gap-3"},gc={key:3,class:"text-xs text-gray-500 dark:text-gray-400"},pc={key:2,class:"flex-1 min-h-0"},hc={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},fc={key:0,class:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-400"},vc={key:0,class:"mb-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-400"},yc={class:"max-h-[60vh] overflow-auto rounded-lg border border-gray-200 bg-gray-50 p-3 text-xs leading-relaxed text-gray-800 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200"},xc=ce({__name:"ToolTestTab",props:{sessionId:{}},setup(r){const{t:l}=we(),e=r,n=z([]),s=z(""),u=z({}),o=z(!1),c=z(null),g=z(null),p=z(null),v=z(!1),_=z(null);function y(f){const x=`ai.assistant.builtinToolDesc.${f}`,B=l(x);return B!==x?B:f}const k=T(()=>n.value.filter(f=>f.category==="core")),b=T(()=>n.value.filter(f=>f.category==="analysis")),$=T(()=>n.value.find(f=>f.name===s.value)),C=T(()=>{const f=$.value;if(!f?.parameters)return[];const x=f.parameters;if(!x.properties)return[];const B=new Set(x.required??[]);return Object.entries(x.properties).map(([R,D])=>{const A={name:R,type:D.type??"string",description:D.description??"",required:B.has(R),defaultValue:D.default};if(D.enum&&(A.enumValues=D.enum),D.type==="array"){A.isArray=!0;const M=D.items;A.arrayItemType=M?.type??"string"}return A})});fe(s,()=>{u.value={},g.value=null,p.value=null,_.value=null}),Re(async()=>{try{n.value=await Ye().getToolCatalog(),n.value.length>0&&(s.value=n.value[0].name)}catch(f){console.error("Failed to load tool catalog:",f)}});function w(){const f={};for(const x of C.value){const B=u.value[x.name];if(!(B===void 0||B===""))if(x.type==="number"){const R=Number(B);isNaN(R)||(f[x.name]=R)}else x.isArray?f[x.name]=B.split(",").map(R=>R.trim()).filter(Boolean):f[x.name]=B}return f}async function S(){if(!s.value||o.value)return;o.value=!0,g.value=null,p.value=null,v.value=!1,_.value=null;const f=`tool_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;c.value=f;try{const x=w(),B=await Ye().executeTool(f,s.value,x,e.sessionId);if(B.error==="cancelled")return;B.success?(_.value=B.elapsed??null,v.value=!!B.truncated,g.value=B.truncated?B.details?._preview??"":JSON.stringify(B.details??B.content,null,2)):p.value=B.error??"Unknown error"}catch(x){p.value=String(x)}finally{o.value=!1,c.value=null}}async function I(){c.value&&(await Ye().cancelToolTest(c.value),o.value=!1,c.value=null)}return(f,x)=>{const B=Ea,R=Ft,D=Ue,A=_e;return i(),m("div",Nu,[a("div",Uu,[k.value.length>0?(i(),m("div",Wu,[a("div",Hu,d(t(l)("ai.lab.toolTest.coreTools")),1),(i(!0),m(re,null,ve(k.value,M=>(i(),m("button",{key:M.name,class:J(["flex w-full flex-col px-3 py-1.5 text-left transition-colors",[s.value===M.name?"bg-primary-50 text-primary-700 dark:bg-primary-900/30 dark:text-primary-300":"text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700/50"]]),title:M.description,onClick:q=>s.value=M.name},[a("span",Yu,d(y(M.name)),1),a("span",Gu,d(M.name),1)],10,Ku))),128))])):E("",!0),b.value.length>0?(i(),m("div",Qu,[a("div",Ju,d(t(l)("ai.lab.toolTest.analysisTools")),1),(i(!0),m(re,null,ve(b.value,M=>(i(),m("button",{key:M.name,class:J(["flex w-full flex-col px-3 py-1.5 text-left transition-colors",[s.value===M.name?"bg-primary-50 text-primary-700 dark:bg-primary-900/30 dark:text-primary-300":"text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700/50"]]),title:M.description,onClick:q=>s.value=M.name},[a("span",Zu,d(y(M.name)),1),a("span",ec,d(M.name),1)],10,Xu))),128))])):E("",!0)]),h(t(mt),{class:"my-3 mr-3 flex min-w-0 flex-1 flex-col"},{default:F(()=>[a("div",tc,[$.value?(i(),m("div",ac,[a("div",sc,d(y($.value.name)),1),a("div",nc,d($.value.description),1)])):E("",!0),C.value.length>0?(i(),m("div",oc,[a("h3",lc,d(t(l)("ai.lab.toolTest.parameters")),1),a("div",ic,[(i(!0),m(re,null,ve(C.value,M=>(i(),m("div",{key:M.name,class:"flex flex-col gap-1"},[a("label",rc,[ie(d(M.name)+" ",1),M.required?(i(),m("span",uc,"*")):E("",!0),M.type==="number"?(i(),m("span",cc,"(number)")):E("",!0),M.isArray?(i(),m("span",dc,"("+d(M.arrayItemType)+"[])",1)):E("",!0)]),M.enumValues?(i(),W(B,{key:0,modelValue:u.value[M.name],"onUpdate:modelValue":q=>u.value[M.name]=q,items:M.enumValues,placeholder:M.description,size:"sm"},null,8,["modelValue","onUpdate:modelValue","items","placeholder"])):(i(),W(R,{key:1,modelValue:u.value[M.name],"onUpdate:modelValue":q=>u.value[M.name]=q,placeholder:M.isArray?t(l)("ai.lab.toolTest.arrayPlaceholder"):M.defaultValue!==void 0?String(M.defaultValue):M.description,type:M.type==="number"?"number":"text",size:"sm"},null,8,["modelValue","onUpdate:modelValue","placeholder","type"]))]))),128))])])):E("",!0),a("div",mc,[o.value?(i(),W(D,{key:1,color:"error",icon:"i-heroicons-stop",onClick:I},{default:F(()=>[ie(d(t(l)("ai.lab.toolTest.cancel")),1)]),_:1})):(i(),W(D,{key:0,color:"primary",disabled:!s.value,icon:"i-heroicons-play",onClick:S},{default:F(()=>[ie(d(t(l)("ai.lab.toolTest.execute")),1)]),_:1},8,["disabled"])),o.value?(i(),W(A,{key:2,name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin text-gray-400"})):E("",!0),_.value!==null?(i(),m("span",gc,d(t(l)("ai.lab.toolTest.elapsed",{ms:_.value})),1)):E("",!0)]),g.value||p.value?(i(),m("div",pc,[a("h3",hc,d(t(l)("ai.lab.toolTest.result")),1),p.value?(i(),m("div",fc,d(p.value),1)):(i(),m(re,{key:1},[v.value?(i(),m("div",vc,d(t(l)("ai.lab.toolTest.truncated")),1)):E("",!0),a("pre",yc,d(g.value),1)],64))])):E("",!0)])]),_:1})])}}}),bc={class:"flex h-full flex-col"},kc={class:"min-h-0 flex-1 overflow-hidden"},_c=ce({__name:"DebugTab",props:{sessionId:{}},setup(r){const{t:l}=we(),e=r,n=[{id:"sql-tables",label:l("analysis.debug.sqlTables"),icon:"i-heroicons-table-cells"},{id:"basic-tools",label:l("analysis.debug.basicTools"),icon:"i-heroicons-wrench-screwdriver"}],s=z("sql-tables");return(u,o)=>(i(),m("div",bc,[h(t(ls),{modelValue:s.value,"onUpdate:modelValue":o[0]||(o[0]=c=>s.value=c),items:n,"persist-key":"debugTab"},null,8,["modelValue"]),a("div",kc,[h(vt,{name:"fade",mode:"out-in"},{default:F(()=>[s.value==="sql-tables"?(i(),W(ju,{key:0,class:"h-full","session-id":e.sessionId},null,8,["session-id"])):s.value==="basic-tools"?(i(),W(xc,{key:1,class:"h-full","session-id":e.sessionId},null,8,["session-id"])):E("",!0)]),_:1})])]))}}),i2=at(_c,[["__scopeId","data-v-b3b3d1a4"]]),wc=["disabled"],$c={key:0,class:"flex-1 overflow-y-auto p-2"},Cc={key:0,class:"flex items-center justify-center py-8"},Sc={key:1,class:"flex flex-col items-center justify-center py-12 text-center"},Ic={class:"flex h-12 w-12 items-center justify-center rounded-full bg-gray-50 dark:bg-gray-800"},Tc={class:"mt-3 text-xs text-gray-400"},Mc={key:2,class:"space-y-3"},zc={class:"px-2 pb-1 pt-1.5 text-[10px] font-medium tracking-wide text-gray-400 dark:text-gray-500"},Ac={class:"space-y-0.5"},qc=["onClick"],Lc=["placeholder","onBlur","onKeyup"],Dc={key:1,class:"flex items-center"},Ec={class:"line-clamp-1 min-w-0 flex-1 text-sm leading-snug"},Bc={class:"rounded p-0.5 text-gray-400 transition-colors hover:bg-gray-200 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300"},Fc={class:"w-28 p-1"},Rc=["disabled","onClick"],Vc=["onClick"],Oc=["disabled","onClick"],Pc={key:1,class:"flex flex-1 flex-col items-center gap-1 overflow-y-auto px-2 pb-2"},jc=["title","disabled"],Nc=["title","onClick"],Uc={key:0,class:"absolute -left-2 top-1/2 h-4.5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary-500"},Wc=ce({__name:"ConversationList",props:{sessionId:{},activeId:{},disabled:{type:Boolean}},emits:["select","create","delete"],setup(r,{expose:l,emit:e}){const{t:n}=we(),s=r,u=e,o=z([]),c=z(!1),g=z(null),p=z(""),v=z(!1),_=z(null);async function y(){c.value=!0;try{o.value=await Ye().getAIChats(s.sessionId)}catch(x){console.error("加载对话列表失败:",x)}finally{c.value=!1}}const k=T(()=>{if(o.value.length===0)return[];const x=Ee(),B=x.subtract(7,"day").startOf("day"),R=x.subtract(30,"day").startOf("day"),D=[],A=[],M=new Map;for(const G of o.value){const Z=Ee(G.updatedAt*1e3);if(Z.isAfter(B))D.push(G);else if(Z.isAfter(R))A.push(G);else{const ue=Z.format("YYYY-MM");M.has(ue)||M.set(ue,[]),M.get(ue).push(G)}}const q=[];D.length>0&&q.push({label:n("ai.chat.conversation.group.last7Days"),conversations:D}),A.length>0&&q.push({label:n("ai.chat.conversation.group.last30Days"),conversations:A});const Y=[...M.keys()].sort((G,Z)=>Z.localeCompare(G));for(const G of Y){const Z=Ee(G+"-01");q.push({label:Z.format(Z.year()===x.year()?"M月":"YYYY年M月"),conversations:M.get(G)})}return q});function b(x){return x.title||n("ai.chat.conversation.newChat")}function $(x){s.disabled||(g.value=x.id,p.value=x.title||"")}async function C(x){if(!s.disabled){if(p.value.trim())try{await Ye().updateAIChatTitle(x,p.value.trim());const B=o.value.find(R=>R.id===x);B&&(B.title=p.value.trim())}catch(B){console.error("更新标题失败:",B)}g.value=null}}function w(x){_.value=null,$(x)}function S(x){_.value=null,navigator.clipboard.writeText(x)}function I(x){_.value=null,f(x)}async function f(x){if(!s.disabled)try{await Ye().deleteAIChat(x),o.value=o.value.filter(B=>B.id!==x),u("delete",x)}catch(B){console.error("删除对话失败:",B)}}return Re(()=>{y()}),fe(()=>s.sessionId,()=>{y()}),l({refresh:y}),(x,B)=>{const R=_e,D=Ue,A=ms;return i(),m("div",{class:J(["m-3 flex h-[calc(100%-1.5rem)] shrink-0 flex-col overflow-hidden rounded-lg bg-white transition-all duration-300 ease-in-out dark:bg-sidebar-dark",v.value?"w-14":"w-64"])},[a("div",{class:J(["flex items-center",v.value?"justify-center px-2 pb-2 pt-5":"justify-between border-b border-gray-200 py-2 pl-3 pr-2 dark:border-gray-800"])},[v.value?(i(),m("button",{key:1,type:"button",class:"group relative flex h-9 w-9 cursor-pointer items-center justify-center rounded-full hover:bg-gray-200/60 dark:hover:bg-white/[0.06]",onClick:B[2]||(B[2]=M=>v.value=!v.value)},[h(R,{name:"i-lucide-panel-right-open",class:"size-4 scale-x-[-1]"})])):(i(),m(re,{key:0},[a("button",{class:J(["flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",{"cursor-not-allowed opacity-50":r.disabled}]),disabled:r.disabled,onClick:B[0]||(B[0]=M=>!r.disabled&&u("create"))},[h(R,{name:"i-heroicons-plus",class:"h-3.5 w-3.5"}),a("span",null,d(t(n)("ai.chat.conversation.newConversation")),1)],10,wc),h(D,{color:"neutral",variant:"ghost",size:"sm",class:"group flex h-9 w-9 cursor-pointer items-center justify-center rounded-full hover:bg-gray-200/60 dark:hover:bg-white/[0.06]",onClick:B[1]||(B[1]=M=>v.value=!v.value)},{default:F(()=>[h(R,{name:"i-lucide-panel-right",class:"size-4 scale-x-[-1] group-hover:hidden"}),h(R,{name:"i-lucide-panel-right-close",class:"size-4 hidden scale-x-[-1] group-hover:block"})]),_:1})],64))],2),v.value?(i(),m("div",Pc,[a("button",{class:J(["flex h-10 w-10 items-center justify-center rounded-lg text-gray-600 transition-colors hover:bg-gray-200/40 hover:text-primary-600 dark:text-gray-300 dark:hover:bg-white/[0.06] dark:hover:text-primary-400",{"cursor-not-allowed opacity-50":r.disabled}]),title:t(n)("ai.chat.conversation.newConversation"),disabled:r.disabled,onClick:B[7]||(B[7]=M=>!r.disabled&&u("create"))},[h(R,{name:"i-heroicons-plus",class:"h-5 w-5"})],10,jc),(i(!0),m(re,null,ve(o.value,M=>(i(),m("button",{key:M.id,class:J(["relative mx-auto flex h-10 w-10 items-center justify-center rounded-lg transition-all duration-200",[r.activeId===M.id?"bg-gray-200/50 text-primary-600 dark:bg-white/[0.07] dark:text-primary-400 dark:ring-1 dark:ring-white/10":"text-gray-600 hover:bg-gray-200/40 dark:text-gray-300 dark:hover:bg-white/[0.06]"]]),title:b(M),onClick:q=>u("select",M.id)},[r.activeId===M.id?(i(),m("span",Uc)):E("",!0),h(R,{name:"i-heroicons-chat-bubble-left",class:"h-5 w-5"})],10,Nc))),128))])):(i(),m("div",$c,[c.value?(i(),m("div",Cc,[h(R,{name:"i-heroicons-arrow-path",class:"h-5 w-5 animate-spin text-gray-400"})])):o.value.length===0?(i(),m("div",Sc,[a("div",Ic,[h(R,{name:"i-heroicons-chat-bubble-left",class:"h-6 w-6 text-gray-300 dark:text-gray-600"})]),a("p",Tc,d(t(n)("ai.chat.conversation.empty")),1),h(D,{class:"mt-2",size:"xs",variant:"link",color:"primary",disabled:r.disabled,onClick:B[3]||(B[3]=M=>!r.disabled&&u("create"))},{default:F(()=>[ie(d(t(n)("ai.chat.conversation.startNew")),1)]),_:1},8,["disabled"])])):(i(),m("div",Mc,[(i(!0),m(re,null,ve(k.value,M=>(i(),m("div",{key:M.label},[a("div",zc,d(M.label),1),a("div",Ac,[(i(!0),m(re,null,ve(M.conversations,q=>(i(),m("div",{key:q.id,class:J(["group relative rounded-lg px-3 py-2 transition-all",["cursor-pointer",r.activeId===q.id?"bg-gray-100 text-gray-900 dark:bg-gray-800 dark:text-white":"text-gray-600 hover:bg-gray-50 dark:text-gray-400 dark:hover:bg-gray-800/50"]]),onClick:Y=>u("select",q.id)},[g.value===q.id?Qe((i(),m("input",{key:0,"onUpdate:modelValue":B[4]||(B[4]=Y=>p.value=Y),class:"w-full rounded border-none bg-white px-2 py-1 text-sm shadow-sm outline-none ring-1 ring-gray-200 focus:ring-2 focus:ring-primary-500 dark:bg-page-dark dark:ring-gray-700",placeholder:t(n)("ai.chat.conversation.titlePlaceholder"),autoFocus:"",onBlur:Y=>C(q.id),onKeyup:Ge(Y=>C(q.id),["enter"]),onClick:B[5]||(B[5]=Oe(()=>{},["stop"]))},null,40,Lc)),[[ft,p.value]]):(i(),m("div",Dc,[a("p",Ec,d(b(q)),1),a("div",{class:J(["ml-1 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",{"opacity-100":r.activeId===q.id||_.value===q.id}]),onClick:B[6]||(B[6]=Oe(()=>{},["stop"]))},[h(A,{open:_.value===q.id,ui:{content:"z-50 p-0"},"onUpdate:open":Y=>_.value=Y?q.id:null},{content:F(()=>[a("div",Fc,[a("button",{class:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-xs text-gray-600 transition-colors hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800",disabled:r.disabled,onClick:Y=>w(q)},[h(R,{name:"i-heroicons-pencil",class:"h-3.5 w-3.5"}),ie(" "+d(t(n)("ai.chat.conversation.rename")),1)],8,Rc),a("button",{class:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-xs text-gray-600 transition-colors hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800",onClick:Y=>S(q.id)},[h(R,{name:"i-heroicons-clipboard-document",class:"h-3.5 w-3.5"}),ie(" "+d(t(n)("ai.chat.conversation.copyId")),1)],8,Vc),a("button",{class:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-xs text-red-500 transition-colors hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/30",disabled:r.disabled,onClick:Y=>I(q.id)},[h(R,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"}),ie(" "+d(t(n)("ai.chat.conversation.delete")),1)],8,Oc)])]),default:F(()=>[a("button",Bc,[h(R,{name:"i-heroicons-ellipsis-horizontal",class:"h-4 w-4"})])]),_:2},1032,["open","onUpdate:open"])],2)]))],10,qc))),128))])]))),128))]))]))],2)}}}),Hc={class:"writing-vertical text-xs"},Kc={class:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800"},Yc={class:"flex items-center gap-2"},Gc={class:"font-medium text-gray-900 dark:text-white"},Qc={key:0,class:"border-b border-gray-200 px-4 py-2 dark:border-gray-800"},Jc={class:"flex flex-wrap items-center gap-2"},Xc={class:"text-xs text-gray-500"},Zc={class:"flex-1 overflow-y-auto"},ed={key:0,class:"flex items-center justify-center py-8"},td={key:1,class:"flex flex-col items-center justify-center py-8 text-center"},ad={class:"mt-2 text-sm text-gray-500"},sd={class:"text-xs text-gray-400"},nd={key:2,class:"divide-y divide-gray-100 dark:divide-gray-800"},od={class:"mb-1 flex items-center justify-between"},ld={class:"text-sm font-medium text-gray-900 dark:text-white"},id={class:"text-xs text-gray-400"},rd=["innerHTML"],ud={key:1,class:"border-t border-gray-200 px-4 py-2 dark:border-gray-800"},cd={class:"flex items-center justify-between"},dd={class:"text-xs text-gray-500"},md={key:2,class:"pointer-events-none absolute inset-0 overflow-hidden rounded-xl opacity-[0.03]"},gd=ce({__name:"DataSourcePanel",props:{messages:{},keywords:{},isLoading:{type:Boolean},isCollapsed:{type:Boolean}},emits:["toggle","loadMore"],setup(r,{emit:l}){const{t:e}=we(),n=r,s=l;function u(c){return Ee(c).format("MM-DD HH:mm")}function o(c){if(!n.keywords.length)return c;const g=n.keywords.join("|"),p=new RegExp(`(${g})`,"gi");return c.replace(p,'<mark class="bg-yellow-200 dark:bg-yellow-800/50 px-0.5 rounded">$1</mark>')}return(c,g)=>{const p=_e,v=Ue;return i(),m("div",{class:J(["relative flex flex-col rounded-xl bg-white transition-all duration-300 dark:bg-page-dark",[r.isCollapsed?"w-12":"w-full"]])},[r.isCollapsed?(i(),m("button",{key:0,class:"flex h-full flex-col items-center justify-center gap-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",onClick:g[0]||(g[0]=_=>s("toggle"))},[h(p,{name:"i-heroicons-chevron-left",class:"h-5 w-5"}),a("span",Hc,d(t(e)("ai.chat.dataSource.title")),1)])):(i(),m(re,{key:1},[a("div",Kc,[a("div",Yc,[h(p,{name:"i-heroicons-document-magnifying-glass",class:"h-5 w-5 text-gray-500"}),a("span",Gc,d(t(e)("ai.chat.dataSource.title")),1)]),h(v,{icon:"i-heroicons-chevron-right",color:"gray",variant:"ghost",size:"xs",onClick:g[1]||(g[1]=_=>s("toggle"))})]),r.keywords.length>0?(i(),m("div",Qc,[a("div",Jc,[a("span",Xc,d(t(e)("ai.chat.dataSource.keywords")),1),(i(!0),m(re,null,ve(r.keywords,_=>(i(),m("span",{key:_,class:"rounded-full bg-violet-100 px-2 py-0.5 text-xs text-violet-700 dark:bg-violet-900/30 dark:text-violet-400"},d(_),1))),128))])])):E("",!0),a("div",Zc,[r.isLoading?(i(),m("div",ed,[h(p,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):r.messages.length===0?(i(),m("div",td,[h(p,{name:"i-heroicons-inbox",class:"h-10 w-10 text-gray-300 dark:text-gray-600"}),a("p",ad,d(t(e)("ai.chat.dataSource.empty")),1),a("p",sd,d(t(e)("ai.chat.dataSource.emptyHint")),1)])):(i(),m("div",nd,[(i(!0),m(re,null,ve(r.messages,_=>(i(),m("div",{key:_.id,class:"px-4 py-3 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[a("div",od,[a("span",ld,d(_.senderName),1),a("span",id,d(u(_.timestamp)),1)]),a("p",{class:"line-clamp-3 text-sm text-gray-600 dark:text-gray-400",innerHTML:o(_.content)},null,8,rd)]))),128))]))]),r.messages.length>0?(i(),m("div",ud,[a("div",cd,[a("span",dd,d(t(e)("ai.chat.dataSource.totalRecords",{count:r.messages.length})),1),h(v,{size:"xs",variant:"ghost",onClick:g[2]||(g[2]=_=>s("loadMore"))},{default:F(()=>[ie(d(t(e)("ai.chat.dataSource.loadMore")),1)]),_:1})])])):E("",!0)],64)),r.isCollapsed?E("",!0):(i(),m("div",md,[...g[3]||(g[3]=[a("div",{class:"data-flow-bg absolute inset-0"},null,-1)])]))],2)}}}),pd=at(gd,[["__scopeId","data-v-a9962add"]]),hd={class:"flex max-h-[80vh] flex-col overflow-hidden"},fd={class:"shrink-0 border-b border-gray-200 px-6 py-4 dark:border-gray-800"},vd={class:"flex items-center justify-between"},yd={class:"flex items-center gap-3"},xd={class:"flex h-8 w-8 items-center justify-center rounded-lg bg-red-100 dark:bg-red-900/40"},bd={class:"text-lg font-semibold text-gray-900 dark:text-white"},kd={class:"flex-1 overflow-y-auto px-6 py-4"},_d={class:"flex flex-col gap-4"},wd={class:"text-sm font-semibold text-gray-700 dark:text-gray-300"},$d={key:0,class:"rounded-md border border-red-200 bg-red-50/50 p-3 dark:border-red-900/40 dark:bg-red-950/20"},Cd={class:"m-0 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-red-600 dark:text-red-400"},Sd={key:1,class:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-page-dark"},Id={class:"m-0 max-h-[300px] overflow-auto whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-gray-700 dark:text-gray-300"},Td={key:2,class:"select-text break-words rounded-md border border-gray-200 bg-gray-50 px-3 py-2 font-mono text-xs text-gray-700 dark:border-gray-700 dark:bg-page-dark dark:text-gray-300"},Md={key:0,class:"py-8 text-center text-sm text-gray-400 dark:text-gray-500"},zd={class:"shrink-0 border-t border-gray-200 px-6 py-3 dark:border-gray-800"},Ad={class:"flex justify-end"},qd=ce({__name:"ErrorDetailModal",props:qt({error:{}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:["update:open"],setup(r){const{t:l}=we(),e=ot(),n=Ht(r,"open"),s=r,u=T(()=>{const g=s.error,p=[];return g.url&&p.push({label:l("ai.chat.error.requestUrl"),value:g.url}),g.statusCode!=null&&p.push({label:l("ai.chat.error.statusCode"),value:String(g.statusCode)}),g.responseBody&&p.push({label:l("ai.chat.error.responseBody"),value:o(g.responseBody),isCode:!0}),g.responseHeaders&&p.push({label:l("ai.chat.error.responseHeaders"),value:JSON.stringify(g.responseHeaders,null,2),isCode:!0}),g.name&&p.push({label:l("ai.chat.error.name"),value:g.name}),g.message&&p.push({label:l("ai.chat.error.message"),value:g.message}),g.stack&&p.push({label:l("ai.chat.error.stack"),value:g.stack,isStack:!0}),g.cause&&p.push({label:l("ai.chat.error.cause"),value:o(g.cause),isCode:!0}),g.provider&&p.push({label:l("ai.chat.error.provider"),value:g.provider}),g.requestBody&&p.push({label:l("ai.chat.error.requestBody"),value:o(g.requestBody),isCode:!0}),p});function o(g){try{return JSON.stringify(JSON.parse(g),null,2)}catch{return g}}function c(){const g=u.value.map(p=>`${p.label}: ${p.value}`).join(`
69
-
70
- `);navigator.clipboard.writeText(g).then(()=>{e.success(l("ai.chat.error.copied"))})}return(g,p)=>{const v=_e,_=Ue,y=Xe;return i(),W(y,{open:n.value,"onUpdate:open":p[1]||(p[1]=k=>n.value=k),ui:{content:"sm:max-w-[700px] z-[100]",overlay:"backdrop-blur-sm z-[99]"}},{content:F(()=>[a("div",hd,[a("div",fd,[a("div",vd,[a("div",yd,[a("div",xd,[h(v,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4 text-red-600 dark:text-red-400"})]),a("h2",bd,d(t(l)("ai.chat.error.detail")),1)]),h(_,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:p[0]||(p[0]=k=>n.value=!1)})])]),a("div",kd,[a("div",_d,[(i(!0),m(re,null,ve(u.value,(k,b)=>(i(),m("div",{key:b,class:"flex flex-col gap-1.5"},[a("div",wd,d(k.label),1),k.isStack?(i(),m("div",$d,[a("pre",Cd,d(k.value),1)])):k.isCode?(i(),m("div",Sd,[a("pre",Id,d(k.value),1)])):(i(),m("div",Td,d(k.value),1))]))),128)),u.value.length===0?(i(),m("div",Md,d(t(l)("ai.chat.error.unknown")),1)):E("",!0)])]),a("div",zd,[a("div",Ad,[h(_,{icon:"i-heroicons-document-duplicate",variant:"soft",color:"neutral",size:"sm",onClick:c},{default:F(()=>[ie(d(t(l)("ai.chat.error.copyAll")),1)]),_:1})])])])]),_:1},8,["open"])}}}),Ld={class:"mb-1.5 flex items-center gap-2"},Dd={class:"flex shrink-0 items-center justify-center text-red-500 dark:text-red-400"},Ed={class:"pr-5 text-[13px] font-semibold leading-[1.4] text-red-600 dark:text-red-400"},Bd={class:"ml-6 line-clamp-3 break-words text-xs leading-normal text-gray-600 dark:text-gray-400"},Fd={class:"mt-2.5 ml-6 flex items-center"},Rd={class:"ml-auto inline-flex items-center gap-0.5 text-xs text-gray-400 transition-colors duration-150 group-hover:text-red-500 dark:text-gray-500 dark:group-hover:text-red-400"},Vd=ce({__name:"ErrorBlock",props:{error:{}},setup(r){const{t:l}=we(),e=z(!1);function n(s){return s.friendlyMessage||s.message||l("ai.chat.error.unknown")}return(s,u)=>{const o=_e;return i(),m(re,null,[a("div",{class:"group relative my-2 w-full min-w-[320px] cursor-pointer rounded-lg border border-red-200 bg-red-50/60 px-3.5 py-3 text-[13px] transition-all duration-200 hover:border-red-300 hover:bg-red-50 dark:border-red-900/30 dark:bg-red-950/20 dark:hover:border-red-800/50 dark:hover:bg-red-950/30",onClick:u[0]||(u[0]=c=>e.value=!0)},[a("div",Ld,[a("div",Dd,[h(o,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4"})]),a("div",Ed,d(t(l)("ai.chat.error.title")),1)]),a("div",Bd,d(n(r.error)),1),a("div",Fd,[a("div",Rd,[ie(d(t(l)("ai.chat.error.viewDetail"))+" ",1),h(o,{name:"i-heroicons-chevron-right",class:"h-3.5 w-3.5"})])])]),h(qd,{open:e.value,"onUpdate:open":u[1]||(u[1]=c=>e.value=c),error:r.error},null,8,["open","error"])],64)}}}),va=ce({__name:"EChartHeatmap",props:{data:{},height:{default:280},mode:{default:"expanded"},minColor:{default:"#fee5e8"},maxColor:{default:"#ee4567"}},setup(r){const l=r,e=T(()=>{let s=0;for(const[,,u]of l.data.data)u>s&&(s=u);return s||1}),n=T(()=>{const s=l.mode==="compact",u=l.data.xLabels.length,o=l.data.yLabels.length;return{tooltip:{position:"top",confine:!0,extraCssText:"max-width: min(360px, 70vw); white-space: normal; word-break: break-word;",formatter:c=>{const g=l.data.xLabels[c.data[0]],p=l.data.yLabels[c.data[1]],v=c.data[2];return`${p} ${g}<br/>消息数: <strong>${v}</strong>`},backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:s?52:72,right:20,top:s?12:24,bottom:s?52:70,outerBoundsMode:"same"},xAxis:{type:"category",data:l.data.xLabels,splitArea:{show:!0},axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:s?10:11,color:"#6b7280",interval:s&&u>16?"auto":0,hideOverlap:!0}},yAxis:{type:"category",data:l.data.yLabels,splitArea:{show:!0},axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:s?10:11,color:"#6b7280",interval:s&&o>14?"auto":0,hideOverlap:!0}},visualMap:{min:0,max:e.value,calculable:!0,orient:"horizontal",left:"center",bottom:0,itemWidth:s?8:10,itemHeight:s?84:120,inRange:{color:[l.minColor,l.maxColor]},textStyle:{color:"#6b7280",fontSize:11}},series:[{type:"heatmap",data:l.data.data,label:{show:!1},emphasis:{itemStyle:{shadowBlur:10,shadowColor:"rgba(0, 0, 0, 0.5)"}}}]}});return(s,u)=>(i(),W(ea,{option:n.value,height:r.height},null,8,["option","height"]))}}),ya=ce({__name:"EChartLine",props:{data:{},height:{default:288},mode:{default:"expanded"},showArea:{type:Boolean,default:!0},smooth:{type:Boolean,default:!0}},setup(r){const l=r,e=T(()=>{const n=!!l.data.series?.length,s=l.mode==="compact",u=l.data.series?.length??0,o=l.data.labels.length,c=u>(s?3:8),g=!s&&o>30,p=n?l.data.series.map(v=>({name:v.name,type:"line",data:v.values,smooth:l.smooth,symbol:"circle",symbolSize:4,showSymbol:!s&&o<=80,lineStyle:{width:2},areaStyle:l.showArea?{opacity:.08}:void 0,emphasis:{focus:"series"}})):[{type:"line",data:l.data.values,smooth:l.smooth,symbol:"circle",symbolSize:4,showSymbol:!s&&o<=80,lineStyle:{width:2,color:"#ee4567"},itemStyle:{color:"#ee4567"},areaStyle:l.showArea?{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(238, 69, 103, 0.3)"},{offset:1,color:"rgba(238, 69, 103, 0.05)"}]}}:void 0,emphasis:{focus:"series",itemStyle:{color:"#ee4567",borderColor:"#fff",borderWidth:2}}}];return{tooltip:{trigger:"axis",confine:!0,extraCssText:"max-width: min(420px, 76vw); white-space: normal; word-break: break-word;",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:50,right:20,top:n?s?44:56:20,bottom:g?66:34,outerBoundsMode:"same"},legend:n?{type:c?"scroll":"plain",top:0,left:8,right:8,height:32,textStyle:{color:"#6b7280",fontSize:11}}:void 0,xAxis:{type:"category",data:l.data.labels,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:11,color:"#6b7280",interval:"auto",hideOverlap:!0}},yAxis:{type:"value",axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{type:"dashed",color:"#e5e7eb"}}},dataZoom:g?[{type:"inside",throttle:50},{type:"slider",height:18,bottom:18,showDetail:!1}]:void 0,series:p}});return(n,s)=>(i(),W(ea,{option:e.value,height:r.height},null,8,["option","height"]))}}),xa=ce({__name:"EChartPie",props:{data:{},height:{default:280},mode:{default:"expanded"},doughnut:{type:Boolean,default:!0},innerRadius:{default:"50%"},showLegend:{type:Boolean,default:!0}},setup(r){const l=r,e=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"],n=T(()=>{const s=l.data.labels.map((y,k)=>({name:y,value:l.data.values[k]})),u=l.data.labels.length,o=l.mode==="compact",c=u>(o?8:14),g=u>(o?6:12),p=o?{type:g?"scroll":"plain",orient:"horizontal",left:8,right:8,bottom:0,height:28,textStyle:{fontSize:11,overflow:"truncate",width:72}}:{type:g?"scroll":"plain",orient:"vertical",right:10,top:24,bottom:24,textStyle:{fontSize:12,overflow:"truncate",width:120}},v=!o&&!c,_=l.showLegend&&!v;return{color:e,tooltip:{trigger:"item",formatter:"{b}: {c} ({d}%)",confine:!0,extraCssText:"max-width: min(360px, 70vw); white-space: normal; word-break: break-word;",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},legend:_?p:void 0,series:[{type:"pie",radius:l.doughnut?[l.innerRadius,o?"58%":"68%"]:o?"58%":"68%",center:_?o?["50%","42%"]:["38%","50%"]:["50%",o?"46%":"50%"],avoidLabelOverlap:!0,itemStyle:{borderRadius:4,borderColor:"#fff",borderWidth:2},label:{show:v,formatter:"{b}",overflow:"truncate",width:110,alignTo:"edge",edgeDistance:12},emphasis:{label:{show:v,fontSize:14,fontWeight:"bold",overflow:"truncate",width:140},itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}},data:s}]}});return(s,u)=>(i(),W(ea,{option:n.value,height:r.height},null,8,["option","height"]))}}),Od={class:"my-2 w-full overflow-hidden rounded-lg border border-gray-200 bg-white/80 dark:border-gray-700/70 dark:bg-page-dark/70"},Pd={class:"border-b border-gray-100 px-3 py-2 dark:border-gray-800"},jd={class:"flex min-w-0 items-start justify-between gap-3"},Nd={class:"min-w-0"},Ud={class:"truncate text-sm font-semibold text-gray-900 dark:text-gray-100"},Wd={key:0,class:"mt-0.5 line-clamp-2 text-xs text-gray-500 dark:text-gray-400"},Hd={class:"flex shrink-0 items-center gap-1.5"},Kd={class:"rounded-md bg-gray-100 px-1.5 py-0.5 text-[10px] uppercase text-gray-500 dark:bg-gray-800"},Yd={class:"flex max-h-[92vh] flex-col overflow-hidden bg-white dark:bg-page-dark"},Gd={class:"flex items-start justify-between gap-4 border-b border-gray-200 px-5 py-4 dark:border-gray-800"},Qd={class:"min-w-0"},Jd={class:"truncate text-base font-semibold text-gray-900 dark:text-gray-100"},Xd={key:0,class:"mt-1 line-clamp-2 text-xs text-gray-500 dark:text-gray-400"},Zd={class:"mt-1 text-[11px] text-gray-400 dark:text-gray-500"},em={class:"min-h-0 flex-1 overflow-auto p-4"},tm={key:0,class:"flex h-64 items-center justify-center text-xs text-gray-400 dark:text-gray-500"},am={class:"mt-1 text-[11px] text-gray-400 dark:text-gray-500"},sm={class:"px-2 py-3"},nm={key:0,class:"flex h-32 items-center justify-center text-xs text-gray-400 dark:text-gray-500"},om=ce({__name:"ChartBlockRenderer",props:{chart:{}},setup(r){const{t:l}=we(),e=r,n=z(!1),s=T(()=>e.chart.spec.title),u=T(()=>e.chart.spec.subtitle||e.chart.spec.description||""),o=T(()=>e.chart.spec.display?.height??(e.chart.spec.type==="heatmap"?300:260)),c=T(()=>e.chart.rowCount===0),g=T(()=>{const w=[];return e.chart.spec.unit&&w.push(e.chart.spec.unit),e.chart.truncated&&w.push(l("ai.chat.message.chart.truncated")),w.push(l("ai.chat.message.chart.rows",{count:e.chart.rowCount})),w.join(" · ")}),p=T(()=>e.chart.data),v=T(()=>e.chart.data),_=T(()=>e.chart.data),y=T(()=>e.chart.data),k=T(()=>e.chart.spec.type==="pie"?_.value.labels.length>8:e.chart.spec.type==="line"?v.value.labels.length>28||(v.value.series?.length??0)>4:e.chart.spec.type==="bar"?p.value.labels.length>12:e.chart.spec.type==="heatmap"?y.value.xLabels.length*y.value.yLabels.length>180:!1),b=T(()=>{const w=k.value?320:380;return Math.min(o.value,w)}),$=T(()=>{const w=o.value;if(e.chart.spec.type==="pie")return Math.max(w,560);if(e.chart.spec.type==="line")return Math.max(w,v.value.labels.length>40?620:540);if(e.chart.spec.type==="bar"){const S=e.chart.spec.display?.horizontal?p.value.labels.length*28+120:520;return Math.min(Math.max(w,S),820)}return e.chart.spec.type==="heatmap"?Math.min(Math.max(w,y.value.yLabels.length*22+150,560),860):Math.max(w,520)}),C=T(()=>e.chart.spec.type==="pie"?"640px":e.chart.spec.type==="bar"?"720px":"780px");return(w,S)=>{const I=Ue,f=Xe;return i(),m("div",Od,[a("div",Pd,[a("div",jd,[a("div",Nd,[a("h3",Ud,d(s.value),1),u.value?(i(),m("p",Wd,d(u.value),1)):E("",!0)]),a("div",Hd,[a("span",Kd,d(r.chart.spec.type),1),h(f,{open:n.value,"onUpdate:open":S[2]||(S[2]=x=>n.value=x),ui:{overlay:"z-[10040] backdrop-blur-sm",content:"z-[10050] w-[96vw] max-w-6xl max-h-[92vh] overflow-hidden"}},{content:F(()=>[a("div",Yd,[a("div",Gd,[a("div",Qd,[a("h3",Jd,d(s.value),1),u.value?(i(),m("p",Xd,d(u.value),1)):E("",!0),a("p",Zd,d(g.value),1)]),h(I,{icon:"i-heroicons-x-mark",size:"sm",color:"neutral",variant:"ghost",class:"shrink-0",title:t(l)("common.close"),"aria-label":t(l)("common.close"),onClick:S[1]||(S[1]=x=>n.value=!1)},null,8,["title","aria-label"])]),a("div",em,[a("div",{class:"mx-auto w-full",style:et({minWidth:C.value})},[c.value?(i(),m("div",tm,d(t(l)("ai.chat.message.chart.empty")),1)):r.chart.spec.type==="bar"?(i(),W(rt,{key:1,data:p.value,height:$.value,mode:"expanded",horizontal:r.chart.spec.display?.horizontal},null,8,["data","height","horizontal"])):r.chart.spec.type==="line"?(i(),W(ya,{key:2,data:v.value,height:$.value,mode:"expanded"},null,8,["data","height"])):r.chart.spec.type==="pie"?(i(),W(xa,{key:3,data:_.value,height:$.value,mode:"expanded","show-legend":r.chart.spec.display?.showLegend??!0},null,8,["data","height","show-legend"])):r.chart.spec.type==="heatmap"?(i(),W(va,{key:4,data:y.value,height:$.value,mode:"expanded"},null,8,["data","height"])):E("",!0)],4)])])]),default:F(()=>[h(I,{icon:"i-heroicons-arrows-pointing-out",size:"xs",color:"neutral",variant:"ghost",class:"no-capture",title:t(l)("ai.chat.message.chart.expand"),"aria-label":t(l)("ai.chat.message.chart.expand"),onClick:S[0]||(S[0]=Oe(()=>{},["stop"]))},null,8,["title","aria-label"])]),_:1},8,["open"])])]),a("p",am,d(g.value),1)]),a("div",sm,[c.value?(i(),m("div",nm,d(t(l)("ai.chat.message.chart.empty")),1)):r.chart.spec.type==="bar"?(i(),W(rt,{key:1,data:p.value,height:b.value,mode:"compact",horizontal:r.chart.spec.display?.horizontal},null,8,["data","height","horizontal"])):r.chart.spec.type==="line"?(i(),W(ya,{key:2,data:v.value,height:b.value,mode:"compact"},null,8,["data","height"])):r.chart.spec.type==="pie"?(i(),W(xa,{key:3,data:_.value,height:b.value,mode:"compact","show-legend":r.chart.spec.display?.showLegend??!0},null,8,["data","height","show-legend"])):r.chart.spec.type==="heatmap"?(i(),W(va,{key:4,data:y.value,height:b.value,mode:"compact"},null,8,["data","height"])):E("",!0)])])}}}),lm={class:"my-1.5 w-full overflow-hidden rounded-lg border border-gray-200 bg-gray-50/60 text-[13px] dark:border-gray-700/60 dark:bg-gray-800/30"},im={class:"text-xs font-semibold text-gray-700 dark:text-gray-200"},rm={key:0,class:"flex min-w-0 items-center gap-2"},um={key:0,class:"truncate text-[11px] text-gray-400 dark:text-gray-500"},cm={class:"ml-auto flex shrink-0 items-center gap-1.5"},dm={class:"text-[11px] text-gray-400 dark:text-gray-500"},mm={key:0,class:"border-t border-gray-200/70 px-3 py-2 dark:border-gray-700/50"},gm={class:"mb-2 space-y-0.5 text-xs text-gray-600 dark:text-gray-400"},pm={class:"font-medium"},hm={key:0},fm={class:"font-medium"},vm={key:0,class:"mb-2 space-y-1"},ym={key:1,class:"py-1.5 text-center text-xs text-gray-400 dark:text-gray-500"},xm={key:2,class:"space-y-2"},bm={class:"flex items-center gap-2"},km={class:"ml-auto shrink-0 text-[11px] text-gray-400 dark:text-gray-500"},_m={key:0,class:"mt-1 text-[11px] text-gray-500 dark:text-gray-400"},wm={class:"mt-1 space-y-0.5"},$m=["onClick"],Cm={class:"min-w-0 flex-1 text-xs leading-snug text-gray-600 dark:text-gray-300"},Sm={key:0,class:"mr-1 text-gray-400 dark:text-gray-500"},Im={class:"line-clamp-2 break-words align-middle"},Tm={key:3,class:"mt-1.5 text-right text-[11px] text-gray-400 dark:text-gray-500"},Mm=ce({__name:"EvidenceBlock",props:{evidence:{}},setup(r){const l=r,{t:e}=we(),n=bt(),s=z(!1),u=["included","uncertain","excluded"],o=T(()=>[...l.evidence.groups].sort((k,b)=>u.indexOf(k.status)-u.indexOf(b.status))),c=T(()=>l.evidence.groups.reduce((k,b)=>k+b.sources.length,0)),g=T(()=>u.map(k=>({status:k,count:l.evidence.groups.filter(b=>b.status===k).length})).filter(k=>k.count>0)),p=T(()=>l.evidence.warnings??[]),v={included:"bg-emerald-50 text-emerald-600 dark:bg-emerald-900/20 dark:text-emerald-400",uncertain:"bg-amber-50 text-amber-600 dark:bg-amber-900/20 dark:text-amber-400",excluded:"bg-gray-100 text-gray-500 dark:bg-gray-800/40 dark:text-gray-400"},_={included:"bg-emerald-500",uncertain:"bg-amber-500",excluded:"bg-gray-400"};function y(k){n.openChatRecordDrawer({scrollToMessageId:k})}return(k,b)=>{const $=_e;return i(),m("div",lm,[a("button",{type:"button",class:"flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-gray-100/60 dark:hover:bg-gray-800/40",onClick:b[0]||(b[0]=C=>s.value=!s.value)},[h($,{name:"i-heroicons-document-magnifying-glass",class:"h-4 w-4 shrink-0 text-primary-500"}),a("span",im,d(t(e)("ai.chat.evidence.title")),1),s.value?E("",!0):(i(),m("div",rm,[(i(!0),m(re,null,ve(g.value,C=>(i(),m("span",{key:C.status,class:"flex shrink-0 items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400"},[a("span",{class:J(["h-1.5 w-1.5 rounded-full",_[C.status]])},null,2),ie(" "+d(t(e)(`ai.chat.evidence.group.${C.status}`))+" "+d(C.count),1)]))),128)),g.value.length===0?(i(),m("span",um,d(t(e)("ai.chat.evidence.empty")),1)):E("",!0)])),a("span",cm,[a("span",dm,d(t(e)(`ai.chat.evidence.mode.${r.evidence.mode}`)),1),h($,{name:s.value?"i-heroicons-chevron-up":"i-heroicons-chevron-down",class:"h-3.5 w-3.5 text-gray-400 dark:text-gray-500"},null,8,["name"])])]),s.value?(i(),m("div",mm,[a("div",gm,[a("div",null,[a("span",pm,d(t(e)("ai.chat.evidence.query"))+":",1),ie(" "+d(r.evidence.query),1)]),r.evidence.criteria?(i(),m("div",hm,[a("span",fm,d(t(e)("ai.chat.evidence.criteria"))+":",1),ie(" "+d(r.evidence.criteria),1)])):E("",!0)]),p.value.length>0?(i(),m("div",vm,[(i(!0),m(re,null,ve(p.value,C=>(i(),m("div",{key:C,class:"flex items-start gap-1.5 rounded bg-amber-50/70 px-2 py-1 text-[11px] text-amber-600 dark:bg-amber-900/15 dark:text-amber-400"},[h($,{name:"i-heroicons-exclamation-triangle",class:"mt-0.5 h-3 w-3 shrink-0"}),a("span",null,d(t(e)(`ai.chat.evidence.warning.${C}`)),1)]))),128))])):E("",!0),o.value.length===0?(i(),m("div",ym,d(t(e)("ai.chat.evidence.empty")),1)):(i(),m("div",xm,[(i(!0),m(re,null,ve(o.value,C=>(i(),m("div",{key:C.id,class:"rounded-md border border-gray-200/80 bg-white px-2.5 py-1.5 dark:border-gray-700/50 dark:bg-page-dark/30"},[a("div",bm,[a("span",{class:J(["rounded px-1.5 py-0.5 text-[11px] font-medium",v[C.status]])},d(t(e)(`ai.chat.evidence.group.${C.status}`)),3),a("span",km,d(C.title),1)]),C.reason?(i(),m("div",_m,d(C.reason),1)):E("",!0),a("ul",wm,[(i(!0),m(re,null,ve(C.sources,(w,S)=>(i(),m("li",{key:`${C.id}-${S}`,class:"group/source flex cursor-pointer items-start gap-1.5 rounded px-1.5 py-1 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/40",onClick:I=>y(w.messageId)},[a("div",Cm,[w.senderName?(i(),m("span",Sm,d(w.senderName)+": ",1)):E("",!0),a("span",Im,d(w.snippet),1)]),h($,{name:"i-heroicons-arrow-top-right-on-square",class:"mt-0.5 h-3 w-3 shrink-0 text-gray-400 opacity-0 transition-opacity group-hover/source:opacity-100 dark:text-gray-500"})],8,$m))),128))])]))),128))])),o.value.length>0?(i(),m("div",Tm,d(t(e)("ai.chat.evidence.totalSources",{count:c.value})),1)):E("",!0)])):E("",!0)])}}}),zm=/^\s*!\[[^\]\n]*\]\(\s*(?:(?:https?:\/\/(?:localhost|127\.0\.0\.1)(?::\d+)?)?\/?|\.\/)?chart[\w-]*(?:\.(?:png|jpg|jpeg|webp|svg))?(?:\?[^)\s]*)?\s*(?:"[^"]*")?\s*\)\s*$/gim;function Am(r){return r&&r.replace(zm,"").replace(/\n{3,}/g,`
71
-
72
- `).replace(/^\n+|\n+$/g,"")}function qm(r,l,e){for(let n=l+1;n<r.length;n+=1)if(e(r[n]))return!0;return!1}function Lm(r,l){const e=[];return r.forEach((n,s)=>{if(!(l.isFoldableProcessBlock(n)||l.isTextBlock(n)&&qm(r,s,l.isFoldableProcessBlock))){e.push({type:"visible",block:n});return}const o=e[e.length-1];o?.type==="process"?o.blocks.push(n):e.push({type:"process",blocks:[n]})}),e}function Dm(r){return r.flatMap(l=>l.type==="visible"?[l.block]:[])}function Em(r,l){const e=Math.max(0,Math.round(r/1e3));if(l.startsWith("zh")||l.startsWith("ja")){if(e<60)return`${e}秒`;if(e<3600){const p=Math.floor(e/60),v=e%60;return`${p}分${v.toString().padStart(2,"0")}秒`}const o=Math.floor(e/3600),c=Math.floor(e%3600/60),g=e%60;return`${o}时${c.toString().padStart(2,"0")}分${g.toString().padStart(2,"0")}秒`}if(e<60)return`${e}s`;if(e<3600){const o=Math.floor(e/60),c=e%60;return`${o}m ${c.toString().padStart(2,"0")}s`}const n=Math.floor(e/3600),s=Math.floor(e%3600/60),u=e%60;return`${n}h ${s.toString().padStart(2,"0")}m ${u.toString().padStart(2,"0")}s`}function Bm(r,l){return r.type!=="process"?0:r.blocks.reduce((e,n)=>e+(l(n)??0),0)}function Fm(r,l){if(l.isProcessing)return l.labels.processing;const e=Bm(r,l.getBlockDurationMs),n=e>0?` ${Em(e,l.locale)}`:"";return`${l.labels.processed}${n}`}const Rm={key:0,class:"w-full rounded-lg border border-gray-200 bg-gray-50/80 dark:border-gray-700/50 dark:bg-gray-800/40"},Vm={class:"flex cursor-pointer select-none items-center gap-2 px-3 py-2 text-xs font-medium text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"},Om={class:"border-t border-gray-200/60 px-3 py-2.5 dark:border-gray-700/40"},Pm=["innerHTML"],jm={class:"mt-2 text-[11px] text-gray-400 dark:text-gray-500"},Nm={key:0,class:"rounded-2xl bg-gray-100 p-4 text-gray-900 dark:bg-gray-800 dark:text-gray-100"},Um=["onKeydown"],Wm={class:"mt-2 flex items-center justify-between"},Hm={class:"flex cursor-pointer items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400"},Km={class:"flex gap-2"},Ym={key:1,class:"rounded-3xl bg-gray-100 px-5 py-3 text-gray-900 dark:bg-gray-800 dark:text-gray-100"},Gm=["innerHTML"],Qm={key:2,class:"space-y-2"},Jm=["aria-expanded","onClick"],Xm={class:"truncate"},Zm={key:0,class:"py-1 text-gray-900 dark:text-gray-100"},eg=["innerHTML"],tg={key:0,class:"ml-1 inline-block h-4 w-1.5 animate-pulse rounded-sm bg-gray-800 dark:bg-gray-200"},ag={key:1,class:"mb-2 border-l-2 border-gray-200 pl-4 py-1 text-sm text-gray-500 dark:border-gray-700 dark:text-gray-400"},sg={class:"cursor-pointer select-none text-xs font-medium transition-colors hover:text-gray-700 dark:hover:text-gray-300"},ng={key:0,class:"ml-2 text-xs text-gray-400 dark:text-gray-500"},og={key:1,class:"ml-2 inline-flex items-center gap-1 text-[11px] text-gray-400 dark:text-gray-500"},lg={class:"mt-2 prose prose-sm dark:prose-invert max-w-none leading-relaxed text-xs"},ig={key:0,class:"mb-2 font-medium text-gray-700 dark:text-gray-200"},rg={class:"not-prose space-y-2 text-xs leading-relaxed"},ug={class:"font-medium text-gray-800 dark:text-gray-200"},cg={key:0,class:"mt-1 text-gray-500 dark:text-gray-400"},dg={class:"mt-0.5 text-gray-500 dark:text-gray-400"},mg={key:1,class:"not-prose mt-2 border-t border-gray-100 pt-2 dark:border-gray-800"},gg={class:"text-[11px] font-medium text-gray-500 dark:text-gray-400"},pg={class:"mt-1 list-disc space-y-0.5 pl-4 text-xs leading-relaxed text-gray-600 dark:text-gray-300"},hg=["innerHTML"],fg={key:2,class:"inline-flex items-center gap-1.5 rounded-lg bg-gray-50 px-3 py-1.5 text-xs font-medium text-gray-600 dark:bg-gray-800/50 dark:text-gray-400"},vg={key:3,open:"",class:"mb-2 border-l-2 border-gray-200 py-1 pl-4 text-sm text-gray-600 dark:border-gray-700 dark:text-gray-400"},yg={class:"flex cursor-pointer select-none items-center gap-2 text-xs font-medium text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"},xg={class:"min-w-0 truncate"},bg={class:"mt-2"},kg=["innerHTML"],_g={key:1,class:"space-y-2"},wg={class:"font-medium text-gray-800 dark:text-gray-200"},$g={class:"mt-1 text-gray-500 dark:text-gray-400"},Cg={class:"mt-0.5 text-gray-500 dark:text-gray-400"},Sg={key:2,class:"mt-2 border-t border-gray-100 pt-2 dark:border-gray-800"},Ig={class:"text-[11px] font-medium text-gray-500 dark:text-gray-400"},Tg={class:"mt-1 list-disc space-y-0.5 pl-4 text-xs leading-relaxed text-gray-600 dark:text-gray-300"},Mg={key:4,class:"mb-2 border-l-2 border-gray-200 py-1 pl-4 text-sm text-gray-600 dark:border-gray-700 dark:text-gray-400"},zg={class:"flex items-center gap-2 text-xs font-medium text-gray-500 dark:text-gray-400"},Ag={key:0,class:"inline-flex items-center gap-1 text-[11px] font-normal text-gray-400 dark:text-gray-500"},qg=["innerHTML"],Lg={key:7,class:"w-full max-w-full"},Dg={class:"inline-flex cursor-pointer list-none select-none [&::-webkit-details-marker]:hidden"},Eg={class:"flex min-w-0 items-baseline gap-1.5 font-medium"},Bg={key:0,class:"max-w-[200px] truncate text-[11px] font-normal opacity-75 sm:max-w-[300px]"},Fg={class:"shrink-0 text-[11px] font-normal opacity-75"},Rg={class:"mt-2 max-w-full rounded-lg border border-gray-200 bg-gray-50/80 dark:border-gray-700/70 dark:bg-page-dark/40"},Vg={class:"flex items-center justify-between gap-2 border-b border-gray-200/70 px-3 py-2 dark:border-gray-700/70"},Og={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Pg={key:0,class:"border-b border-amber-200/70 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-300"},jg={class:"max-h-[28rem] overflow-auto whitespace-pre-wrap break-words px-3 py-2.5 text-xs leading-relaxed text-gray-700 dark:text-gray-200"},Ng={class:"flex min-w-0 items-baseline gap-1.5 font-medium"},Ug={key:0,class:"max-w-[200px] truncate text-[11px] font-normal opacity-75 sm:max-w-[300px]"},Wg={key:1,class:"shrink-0 text-[11px] font-normal opacity-75"},Hg={key:0,class:"flex items-center gap-2 px-1 py-2 text-sm text-gray-500 dark:text-gray-400"},Kg={key:3,class:"py-1 text-gray-900 dark:text-gray-100"},Yg=["innerHTML"],Gg={key:0,class:"ml-1 inline-block h-4 w-1.5 animate-pulse rounded-sm bg-gray-800 dark:bg-gray-200"},Qg={class:"text-xs text-gray-400"},ua=ce({__name:"ChatMessage",props:{messageId:{},role:{},content:{},timestamp:{},isStreaming:{type:Boolean},contentBlocks:{},showCaptureButton:{type:Boolean},editable:{type:Boolean}},emits:["edit","fork"],setup(r,{emit:l}){const{t:e,te:n,locale:s}=we(),u=ot(),o=r,c=l,g=T(()=>Ee(o.timestamp).format("HH:mm")),p=T(()=>o.role==="user"),v=T(()=>o.role==="summary"),_=z(!1),y=z(o.content),k=z(null),b=T(()=>p.value&&o.editable&&!o.isStreaming&&!!o.messageId),$=T(()=>!p.value&&!v.value&&!o.isStreaming&&!!o.messageId),C=z(!1),w=new Aa({html:!1,breaks:!0,linkify:!0,typographer:!0});w.renderer.rules.link_open=(O,V,K,L,j)=>(O[V].attrSet("target","_blank"),O[V].attrSet("rel","noopener noreferrer"),j.renderToken(O,V,K));function S(O){return O?w.render(O):""}function I(O){const V=O?.toLowerCase()||"think";return V==="analysis"?e("ai.chat.message.think.labels.analysis"):V==="reasoning"?e("ai.chat.message.think.labels.reasoning"):V==="reflection"?e("ai.chat.message.think.labels.reflection"):V==="plan_validation"?e("ai.chat.message.think.labels.planValidation"):V==="think"||V==="thought"||V==="thinking"?e("ai.chat.message.think.labels.think"):e("ai.chat.message.think.labels.other",{tag:O})}function f(O){if(!O)return"";const V=(O/1e3).toFixed(1);return e("ai.chat.message.think.duration",{seconds:V})}const x=T(()=>o.content?w.render(M(o.content)):"");fe(()=>o.content,O=>{_.value||(y.value=O)});function B(){const O=k.value;if(!O)return;O.style.height="auto";const V=384,K=Math.min(O.scrollHeight,V);O.style.height=`${K}px`,O.style.overflowY=O.scrollHeight>V?"auto":"hidden"}async function R(){b.value&&(y.value=o.content,_.value=!0,await qe(),B(),k.value?.focus())}function D(){_.value=!1,y.value=o.content,C.value=!1}function A(){if(!o.messageId)return;const O=y.value.trim();if(!O||O===o.content.trim()){D();return}_.value=!1,c("edit",{messageId:o.messageId,content:O,overwriteSubsequent:C.value}),C.value=!1}function M(O){return Am(O)}const q=T(()=>{const O=o.contentBlocks||[];return O.filter((V,K)=>V.type==="text"?M(V.text).trim().length>0:V.type==="think"?V.text.trim().length>0:V.type==="error"?!zn(O,K,{isStreaming:o.isStreaming}):!0)});function Y(O){return O.type==="think"||O.type==="tool"||O.type==="plan"||O.type==="plan_draft"}function G(O){return O.type==="text"}const Z=T(()=>Lm(q.value,{isFoldableProcessBlock:Y,isTextBlock:G})),ue=T(()=>Dm(Z.value)),oe=z({});function H(O){return O.type==="process"?O.blocks:[O.block]}function P(O){return`${o.messageId??o.timestamp}:process:${O}`}function se(O){const V=P(O),K=oe.value[V];return K!==void 0?K:ee(O)}function me(O){const V=P(O);oe.value={...oe.value,[V]:!se(O)}}function he(O){return q.value[q.value.length-1]===O}function ee(O){return!!o.isStreaming&&O===Z.value.length-1}function te(O){return O.type==="think"?O.durationMs??0:O.type==="tool"?O.tool.durationMs??0:0}function N(O,V){return Fm(O,{getBlockDurationMs:te,isProcessing:ee(V),labels:{processed:e("ai.chat.message.process.processed"),processing:e("ai.chat.message.process.processing")},locale:s.value})}const de=T(()=>o.role==="assistant"&&q.value.length>0);function be(O){return n(`ai.assistant.builtinToolDesc.${O.name}`)?e(`ai.assistant.builtinToolDesc.${O.name}`):O.displayName}function xe(O){return O==="running"?"running":O==="done"?"done":"error"}function le(O){return O.displayResult??O.result??""}function Q(O){return O.status!=="running"&&le(O).trim().length>0}function X(O){return!O.displayResult&&(O.result??"").includes("…[truncated]")}async function pe(O){const V=le(O);if(V.trim())try{await navigator.clipboard.writeText(V),u.success(e("ai.chat.message.toolResult.copySuccess"))}catch(K){u.fail(e("ai.chat.message.toolResult.copyFailed"),{description:String(K)})}}function ke(O){return O.length===0?e("ai.chat.message.plan.noTools"):O.join(", ")}function $e(O){try{const V=JSON.parse(O.trim());if(!V||typeof V!="object")return null;const K=V,L=Array.isArray(K.steps)?K.steps.filter(j=>!!j&&typeof j=="object").map(j=>({goal:typeof j.goal=="string"?j.goal:"",suggestedTools:Array.isArray(j.suggestedTools)?j.suggestedTools.filter(U=>typeof U=="string"):[],evidenceNeeded:typeof j.evidenceNeeded=="string"?j.evidenceNeeded:""})).filter(j=>j.goal):[];return{title:typeof K.title=="string"?K.title:void 0,steps:L,successCriteria:Array.isArray(K.successCriteria)?K.successCriteria.filter(j=>typeof j=="string"):[]}}catch{return null}}const De=new Map;function Be(O){const V=De.get(O);if(V)return V;const K=$e(O);return K&&De.set(O,K),K}function Te(O){if(O.start_time||O.end_time){const V=O.start_time?String(O.start_time):"",K=O.end_time?String(O.end_time):"";return V&&K?`${V} ~ ${K}`:V||K}if(O.year)if(s.value.startsWith("zh")){let V=`${O.year}年`;return O.month&&(V+=`${O.month}月`,O.day&&(V+=`${O.day}日`,O.hour!==void 0&&(V+=` ${O.hour}点`))),V}else{const V=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];let K="";if(O.month){if(K=V[O.month-1]||String(O.month),O.day&&(K+=` ${O.day}`,O.hour!==void 0)){const L=O.hour,j=L>=12?"pm":"am",U=L%12||12;K+=`, ${U}${j}`}K+=`, ${O.year}`}else K=String(O.year);return K}return""}function Pe(O){if(!O.params)return"";const V=O.name,K=O.params;if(V==="search_messages"){const j=K.keywords,U=[];j&&j.length>0&&U.push(`${e("ai.chat.message.toolParams.keywords")}: ${j.join(", ")}`);const ae=Te(K);return ae&&U.push(`${e("ai.chat.message.toolParams.time")}: ${ae}`),U.join(" | ")}if(V==="get_recent_messages"){const j=[];j.push(e("ai.chat.message.toolParams.getMessages",{count:K.limit||100}));const U=Te(K);return U&&j.push(U),j.join(" | ")}if(V==="get_conversation_between"){const j=[],U=Te(K);return U&&j.push(`${e("ai.chat.message.toolParams.time")}: ${U}`),K.limit&&j.push(e("ai.chat.message.toolParams.limit",{count:K.limit})),j.join(" | ")}if(V==="get_message_context"){const j=K.message_ids,U=K.context_size||20;return j&&j.length>0?e("ai.chat.message.toolParams.contextWithMessages",{msgCount:j.length,contextSize:U}):e("ai.chat.message.toolParams.context",{size:U})}if(V==="get_member_stats")return e("ai.chat.message.toolParams.topMembers",{count:K.top_n||10});if(V==="get_time_stats"){const j=K.type;return e(`ai.chat.message.toolParams.timeStats.${j}`)||String(K.type)}if(V==="render_chart"){const j=K.spec&&typeof K.spec=="object"?K.spec:null;return[j?.title,j?.type].filter(ae=>typeof ae=="string"&&ae.length>0).join(" | ")}if(V==="get_members")return K.search?`${e("ai.chat.message.toolParams.search")}: ${K.search}`:e("ai.chat.message.toolParams.getMemberList");if(V==="get_member_name_history")return`${e("ai.chat.message.toolParams.memberId")}: ${K.member_id}`;if(V==="semantic_search_current_chat"){const j=typeof K.query=="string"?K.query:"";return j?j.length>40?`“${j.slice(0,40)}…”`:`“${j}”`:""}const L=[];for(const[j,U]of Object.entries(K)){if(U==null||U==="")continue;const ae=typeof U=="object"?JSON.stringify(U):String(U),ne=ae.length>30?ae.substring(0,30)+"...":ae;if(L.push(`${j}: ${ne}`),L.length>=3){L.push("...");break}}return L.join(" | ")}const je=T(()=>!de.value&&o.content.trim()?M(o.content):de.value?ue.value.map(V=>{if(V.type==="text")return M(V.text);if(V.type==="think"){const K=I(V.tag),L=V.text.split(`
73
- `).map(j=>`> ${j}`).join(`
74
- `);return`> ${K}
75
- >
76
- ${L}`}if(V.type==="skill")return`> ${e("ai.skill.active.label",{name:V.skillName})}`;if(V.type==="chart")return`> Chart: ${V.chart.spec.title}`;if(V.type==="evidence"){const K=`> ${e("ai.chat.evidence.title")}`,L=V.evidence.groups.map(j=>{const U=e(`ai.chat.evidence.group.${j.status}`),ae=j.sources.map(ne=>`> - ${ne.snippet}`).join(`
77
- `);return`> [${U}] ${j.title}
78
- ${ae}`});return[K,...L].join(`
79
- `)}if(V.type==="plan"){const K=V.plan.steps.map((U,ae)=>`${ae+1}. ${U.goal}
80
- - ${e("ai.chat.message.plan.evidenceNeeded")}: ${U.evidenceNeeded}
81
- - ${e("ai.chat.message.plan.suggestedTools")}: ${ke(U.suggestedTools)}`).join(`
82
- `),L=V.plan.successCriteria.map(U=>`- ${U}`).join(`
83
- `),j=V.displayText?`${V.displayText.split(`
84
- `).map(U=>`> ${U}`).join(`
85
- `)}
86
-
87
- `:"";return V.displayText?`> ${e("ai.chat.message.plan.label")}: ${V.plan.title}
88
-
89
- ${j.trimEnd()}`:`> ${e("ai.chat.message.plan.label")}: ${V.plan.title}
90
-
91
- ${K}
92
-
93
- ${e("ai.chat.message.plan.successCriteria")}:
94
- ${L}`}if(V.type==="plan_draft")return`> ${e("ai.chat.message.plan.label")}
95
- >
96
- ${V.text.split(`
97
- `).map(K=>`> ${K}`).join(`
98
- `)}`;if(V.type==="tool"){const K=be(V.tool),L=Pe(V.tool),j=L?` (${L})`:"";return`- [${xe(V.tool.status)}] ${K}${j}`}return""}).filter(V=>V.trim().length>0).join(`
99
-
100
- `):""),Se=T(()=>!o.isStreaming&&je.value.trim().length>0);async function ge(){if(Se.value)try{await navigator.clipboard.writeText(je.value),u.success(e("ai.chat.message.copy.success"))}catch(O){u.fail(e("ai.chat.message.copy.failed"),{description:String(O)})}}return(O,V)=>{const K=_e,L=Ue,j=St;return i(),m("div",{class:J(["flex items-start gap-3",[p.value&&!_.value?"flex-row-reverse":"",v.value?"justify-center":""]])},[a("div",{class:J([p.value&&!_.value?"max-w-[85%] min-w-0":"w-full min-w-0"])},[v.value?(i(),m("details",Rm,[a("summary",Vm,[h(K,{name:"i-heroicons-arrow-path",class:"h-3.5 w-3.5 shrink-0"}),a("span",null,d(t(e)("ai.chat.message.summary.label")),1),h(K,{name:"i-heroicons-chevron-right",class:"ml-auto h-3 w-3 transition-transform [[open]>&]:rotate-90"})]),a("div",Om,[a("div",{class:"prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:x.value},null,8,Pm),a("p",jm,d(t(e)("ai.chat.message.summary.info")),1)])])):p.value?(i(),m(re,{key:1},[_.value?(i(),m("div",Nm,[Qe(a("textarea",{ref_key:"editTextareaRef",ref:k,"onUpdate:modelValue":V[0]||(V[0]=U=>y.value=U),rows:"2",class:"w-full resize-none rounded-xl border border-primary-200 bg-white/90 px-4 py-3 text-sm leading-relaxed outline-none focus:border-primary-400 dark:border-primary-400/40 dark:bg-page-dark/70",onInput:B,onKeydown:[Ge(Oe(D,["prevent"]),["esc"]),Ge(Oe(A,["ctrl","prevent"]),["enter"]),Ge(Oe(A,["meta","prevent"]),["enter"])]},null,40,Um),[[ft,y.value]]),a("div",Wm,[a("label",Hm,[Qe(a("input",{"onUpdate:modelValue":V[1]||(V[1]=U=>C.value=U),type:"checkbox",class:"h-3.5 w-3.5 rounded border-gray-300 text-primary-500 focus:ring-primary-500 dark:border-gray-600"},null,512),[[Mn,C.value]]),ie(" "+d(t(e)("ai.chat.message.edit.overwriteSubsequent")),1)]),a("div",Km,[h(L,{size:"xs",variant:"ghost",color:"gray",onClick:D},{default:F(()=>[ie(d(t(e)("common.cancel")),1)]),_:1}),h(L,{size:"xs",color:"primary",onClick:A},{default:F(()=>[ie(d(t(e)("ai.chat.message.edit.submit")),1)]),_:1})])])])):(i(),m("div",Ym,[a("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:x.value},null,8,Gm)]))],64)):de.value?(i(),m("div",Qm,[(i(!0),m(re,null,ve(Z.value,(U,ae)=>(i(),m("div",{key:ae,class:J([U.type==="process"?"py-1":""])},[U.type==="process"?(i(),m("button",{key:0,type:"button",class:"inline-flex max-w-full items-center gap-1.5 text-left text-xs text-gray-400 transition-colors hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300","aria-expanded":se(ae),onClick:ne=>me(ae)},[h(K,{name:se(ae)?"i-heroicons-chevron-down":"i-heroicons-chevron-right",class:"h-3 w-3 shrink-0"},null,8,["name"]),a("span",Xm,d(N(U,ae)),1),ee(ae)?(i(),W(K,{key:0,name:"i-heroicons-arrow-path",class:"h-3 w-3 shrink-0 animate-spin"})):E("",!0)],8,Jm)):E("",!0),Qe(a("div",{class:J([U.type==="process"?"mt-2 space-y-2 pl-4":""])},[(i(!0),m(re,null,ve(H(U),(ne,Ve)=>(i(),m(re,{key:`${ae}-${Ve}`},[ne.type==="text"?(i(),m("div",Zm,[a("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:S(M(ne.text))},null,8,eg),r.isStreaming&&he(ne)?(i(),m("span",tg)):E("",!0)])):ne.type==="think"?(i(),m("details",ag,[a("summary",sg,[ie(d(I(ne.tag))+" ",1),ne.durationMs?(i(),m("span",ng,d(f(ne.durationMs)),1)):E("",!0),r.isStreaming&&he(ne)?(i(),m("span",og,[a("span",null,d(t(e)("ai.chat.message.think.loading")),1),V[3]||(V[3]=a("span",{class:"flex gap-0.5"},[a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1))])):E("",!0)]),a("div",lg,[ne.tag==="plan_validation"&&Be(ne.text)?(i(),m(re,{key:0},[Be(ne.text)?.title?(i(),m("div",ig,d(Be(ne.text)?.title),1)):E("",!0),a("ol",rg,[(i(!0),m(re,null,ve(Be(ne.text)?.steps,(Le,Me)=>(i(),m("li",{key:Me,class:"text-gray-600 dark:text-gray-300"},[a("div",ug,d(Le.goal),1),Le.evidenceNeeded?(i(),m("div",cg,d(t(e)("ai.chat.message.plan.evidenceNeeded"))+": "+d(Le.evidenceNeeded),1)):E("",!0),a("div",dg,d(t(e)("ai.chat.message.plan.suggestedTools"))+": "+d(ke(Le.suggestedTools)),1)]))),128))]),Be(ne.text)?.successCriteria.length?(i(),m("div",mg,[a("div",gg,d(t(e)("ai.chat.message.plan.successCriteria")),1),a("ul",pg,[(i(!0),m(re,null,ve(Be(ne.text)?.successCriteria,(Le,Me)=>(i(),m("li",{key:Me},d(Le),1))),128))])])):E("",!0)],64)):(i(),m("div",{key:1,innerHTML:S(ne.text)},null,8,hg))])])):ne.type==="skill"?(i(),m("div",fg,[h(K,{name:"i-heroicons-bolt",class:"h-3.5 w-3.5"}),a("span",null,d(t(e)("ai.skill.active.label",{name:ne.skillName})),1)])):ne.type==="plan"?(i(),m("details",vg,[a("summary",yg,[h(K,{name:"i-heroicons-clipboard-document-list",class:"h-3.5 w-3.5 shrink-0"}),a("span",xg,d(t(e)("ai.chat.message.plan.label"))+" · "+d(ne.plan.title),1)]),a("div",bg,[ne.displayText?(i(),m("div",{key:0,class:"prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:S(ne.displayText)},null,8,kg)):(i(),m("ol",_g,[(i(!0),m(re,null,ve(ne.plan.steps,(Le,Me)=>(i(),m("li",{key:Me,class:"text-xs leading-relaxed"},[a("div",wg,d(Me+1)+". "+d(Le.goal),1),a("div",$g,d(t(e)("ai.chat.message.plan.evidenceNeeded"))+": "+d(Le.evidenceNeeded),1),a("div",Cg,d(t(e)("ai.chat.message.plan.suggestedTools"))+": "+d(ke(Le.suggestedTools)),1)]))),128))])),ne.displayText?E("",!0):(i(),m("div",Sg,[a("div",Ig,d(t(e)("ai.chat.message.plan.successCriteria")),1),a("ul",Tg,[(i(!0),m(re,null,ve(ne.plan.successCriteria,(Le,Me)=>(i(),m("li",{key:Me},d(Le),1))),128))])]))])])):ne.type==="plan_draft"?(i(),m("div",Mg,[a("div",zg,[h(K,{name:"i-heroicons-clipboard-document-list",class:"h-3.5 w-3.5 shrink-0"}),a("span",null,d(t(e)("ai.chat.message.plan.label")),1),r.isStreaming?(i(),m("span",Ag,[...V[4]||(V[4]=[a("span",{class:"flex gap-0.5"},[a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1)])])):E("",!0)]),a("div",{class:"mt-2 prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:S(ne.text)},null,8,qg)])):ne.type==="chart"?(i(),W(om,{key:5,chart:ne.chart},null,8,["chart"])):ne.type==="evidence"?(i(),W(Mm,{key:6,evidence:ne.evidence},null,8,["evidence"])):ne.type==="tool"&&Q(ne.tool)?(i(),m("details",Lg,[a("summary",Dg,[a("div",{class:J(["flex w-fit items-center gap-1.5 rounded-lg bg-gray-50 px-2.5 py-1 text-xs text-gray-500 transition-colors hover:bg-gray-100 dark:bg-gray-800/30 dark:text-gray-400/80 dark:hover:bg-gray-800/60",[ne.tool.status==="error"?"bg-red-50 text-red-600 dark:bg-red-900/20 dark:text-red-400":""]])},[h(K,{name:ne.tool.status==="error"?"i-heroicons-exclamation-circle":"i-heroicons-wrench-screwdriver",class:"h-3.5 w-3.5 shrink-0"},null,8,["name"]),a("div",Eg,[a("span",null,d(be(ne.tool)),1),Pe(ne.tool)?(i(),m("span",Bg,d(Pe(ne.tool)),1)):E("",!0),a("span",Fg," · "+d(t(e)("ai.chat.message.toolResult.view")),1)]),h(K,{name:"i-heroicons-chevron-right",class:"h-3 w-3 shrink-0 transition-transform [[open]>&]:rotate-90"})],2)]),a("div",Rg,[a("div",Vg,[a("span",Og,d(t(e)("ai.chat.message.toolResult.title")),1),h(L,{size:"xs",variant:"ghost",color:"primary",icon:"i-heroicons-document-duplicate",title:t(e)("ai.chat.message.toolResult.copy"),onClick:Oe(Le=>pe(ne.tool),["stop"])},null,8,["title","onClick"])]),X(ne.tool)?(i(),m("div",Pg,d(t(e)("ai.chat.message.toolResult.displayTruncated")),1)):E("",!0),a("pre",jg,d(le(ne.tool)),1)])])):ne.type==="tool"?(i(),m("div",{key:8,class:J(["flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs transition-colors",[ne.tool.status==="running"?"bg-gray-100 text-gray-600 dark:bg-gray-800/50 dark:text-gray-400":ne.tool.status==="done"?"bg-gray-50 text-gray-500 dark:bg-gray-800/30 dark:text-gray-400/80":"bg-red-50 text-red-600 dark:bg-red-900/20 dark:text-red-400"]])},[h(K,{name:ne.tool.status==="running"?"i-heroicons-arrow-path":ne.tool.status==="done"?"i-heroicons-wrench-screwdriver":"i-heroicons-exclamation-circle",class:J(["h-3.5 w-3.5 shrink-0",[ne.tool.status==="running"?"animate-spin":""]])},null,8,["name","class"]),a("div",Ng,[a("span",null,d(be(ne.tool)),1),Pe(ne.tool)?(i(),m("span",Ug,d(Pe(ne.tool)),1)):E("",!0),ne.tool.status==="done"&&ne.tool.durationMs?(i(),m("span",Wg," · "+d(f(ne.tool.durationMs)),1)):E("",!0)])],2)):ne.type==="error"?(i(),W(Vd,{key:9,error:ne.error},null,8,["error"])):E("",!0)],64))),128))],2),[[yt,U.type!=="process"||se(ae)]])],2))),128)),r.isStreaming&&q.value.length>0&&q.value[q.value.length-1].type==="tool"?(i(),m("div",Hg,[V[5]||(V[5]=a("span",{class:"flex gap-1"},[a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1)),a("span",null,d(t(e)("ai.chat.message.generating")),1)])):E("",!0)])):(i(),m("div",Kg,[a("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:x.value},null,8,Yg),r.isStreaming?(i(),m("span",Gg)):E("",!0)])),!v.value&&!r.isStreaming?(i(),m("div",{key:4,class:J(["mt-1 flex items-center gap-2 px-1",[p.value?"flex-row-reverse":""]])},[a("span",Qg,d(g.value),1),h(j,{text:t(e)("ai.chat.message.copy.tooltip"),class:"no-capture"},{default:F(()=>[h(L,{icon:"i-heroicons-document-duplicate",variant:"ghost",color:"primary",size:"xs",disabled:!Se.value,onClick:ge},null,8,["disabled"])]),_:1},8,["text"]),b.value?(i(),W(j,{key:0,text:t(e)("ai.chat.message.edit.tooltip"),class:"no-capture"},{default:F(()=>[h(L,{icon:"i-heroicons-pencil-square",variant:"ghost",color:"primary",size:"xs",onClick:R})]),_:1},8,["text"])):E("",!0),$.value?(i(),W(j,{key:1,text:t(e)("ai.chat.message.fork.tooltip"),class:"no-capture"},{default:F(()=>[h(L,{icon:"i-heroicons-arrow-top-right-on-square",variant:"ghost",color:"primary",size:"xs",onClick:V[2]||(V[2]=U=>c("fork",r.messageId))})]),_:1},8,["text"])):E("",!0),r.showCaptureButton&&!p.value&&!r.isStreaming?(i(),W(Lt,{key:2,size:"xs",type:"element","target-selector":".qa-pair","markdown-fix":"","capture-frame":"","progressive-narrowing":!0})):E("",!0)],2)):E("",!0)],2)],2)}}}),Jg={key:0,class:"absolute bottom-full left-0 z-20 mb-1.5 w-[240px] max-w-[calc(100vw-2rem)]"},Xg={class:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-overlay dark:border-gray-700 dark:bg-page-dark"},Zg={class:"flex items-center justify-between border-b border-gray-100 px-2.5 py-1.5 dark:border-gray-800"},ep={class:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400"},tp=["title"],ap={key:0,class:"px-3 py-4 text-center text-xs text-gray-500 dark:text-gray-400"},sp=["onMouseenter","onClick"],np={class:"min-w-0 flex-1"},op={class:"flex items-center gap-1.5"},lp={class:"truncate text-xs font-medium"},ip={class:"mt-0.5 line-clamp-2 text-[11px] leading-4 text-gray-500 dark:text-gray-400"},rp={key:2,class:"px-3 py-4 text-center"},up={class:"text-sm font-medium text-gray-700 dark:text-gray-200"},cp={class:"mt-1 text-xs leading-5 text-gray-500 dark:text-gray-400"},dp=ce({__name:"MemberMentionMenu",props:{visible:{type:Boolean},members:{},highlightIndex:{},loading:{type:Boolean}},emits:["select","close","highlight"],setup(r,{emit:l}){const{t:e}=we(),n=r,s=l,u=z(null);return fe(()=>[n.visible,n.highlightIndex,n.members.length],async([o,c])=>{if(!o||!u.value)return;await qe(),u.value.querySelectorAll("[data-mention-item]")[c]?.scrollIntoView({block:"nearest"})}),(o,c)=>{const g=_e;return i(),W(vt,{name:"mention-menu"},{default:F(()=>[r.visible?(i(),m("div",Jg,[a("div",Xg,[a("div",Zg,[a("div",ep,[a("span",null,d(t(e)("ai.chat.input.mentionHint")),1)]),a("button",{type:"button",class:"rounded-md p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:t(e)("common.close"),onClick:c[0]||(c[0]=p=>s("close"))},[h(g,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5"})],8,tp)]),n.loading?(i(),m("div",ap,d(t(e)("common.loading")),1)):n.members.length>0?(i(),m("div",{key:1,ref_key:"listRef",ref:u,class:"max-h-72 overflow-y-auto p-1.5"},[(i(!0),m(re,null,ve(n.members,(p,v)=>(i(),m("button",{key:`${p.memberId}-${p.insertName}`,type:"button","data-mention-item":"",class:J(["flex w-full items-start justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left transition-colors",v===n.highlightIndex?"bg-primary-50 text-gray-900 dark:bg-primary-950/30 dark:text-gray-100":"text-gray-700 hover:bg-gray-50 dark:text-gray-200 dark:hover:bg-gray-800/80"]),onMouseenter:_=>s("highlight",v),onClick:_=>s("select",p)},[a("div",np,[a("div",op,[a("span",lp,"@"+d(p.insertName),1)]),a("p",ip,d(p.subtitle),1)])],42,sp))),128))],512)):(i(),m("div",rp,[a("p",up,d(t(e)("ai.chat.input.mentionEmpty")),1),a("p",cp,d(t(e)("ai.chat.input.mentionEmptyHint")),1)]))])])):E("",!0)]),_:1})}}}),mp=at(dp,[["__scopeId","data-v-7bc45150"]]),gp={key:0,class:"absolute bottom-full left-0 z-20 mb-1.5 w-[240px] max-w-[calc(100vw-2rem)]"},pp={class:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-overlay dark:border-gray-700 dark:bg-page-dark"},hp={class:"flex items-center justify-between border-b border-gray-100 px-2.5 py-1.5 dark:border-gray-800"},fp={class:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400"},vp=["title"],yp=["onMouseenter","onClick"],xp={class:"min-w-0 flex-1"},bp={class:"flex items-center gap-1.5"},kp={class:"truncate text-xs font-medium"},_p={class:"mt-0.5 line-clamp-1 text-xs leading-4 text-gray-500 dark:text-gray-400"},wp={key:1,class:"px-3 py-4 text-center"},$p={class:"text-sm font-medium text-gray-700 dark:text-gray-200"},Cp={class:"mt-1 text-xs leading-5 text-gray-500 dark:text-gray-400"},Sp={key:0,class:"absolute top-1/2 left-full ml-1 flex max-h-[min(348px,calc(100vh-10rem))] w-[300px] -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-overlay dark:border-gray-700 dark:bg-page-dark"},Ip={class:"border-b border-gray-100 px-3 py-2 dark:border-gray-800"},Tp={class:"truncate text-sm font-medium text-gray-900 dark:text-gray-100"},Mp={class:"mt-0.5 text-xs leading-5 text-gray-500 dark:text-gray-400"},zp={key:0,class:"mt-1 flex items-start gap-1.5 text-[11px] leading-4"},Ap={class:"shrink-0 font-medium text-gray-600 dark:text-gray-300"},qp={class:"line-clamp-1 min-w-0 flex-1 text-gray-500 dark:text-gray-400"},Lp={key:1,class:"mt-0.5 flex items-start gap-1.5 text-[11px] leading-4"},Dp={class:"shrink-0 font-medium text-gray-600 dark:text-gray-300"},Ep={class:"line-clamp-1 min-w-0 flex-1 text-gray-500 dark:text-gray-400"},Bp={class:"min-h-0 flex-1 overflow-y-auto px-3 py-2"},Fp={key:0,class:"text-xs text-gray-400 dark:text-gray-500"},Rp=["innerHTML"],Vp={key:2,class:"text-xs leading-relaxed text-gray-400 dark:text-gray-500"},Op=ce({__name:"SlashCommandMenu",props:{visible:{type:Boolean},skills:{},highlightIndex:{},activeSkillId:{}},emits:["select","close","manage","highlight"],setup(r,{emit:l}){const{t:e,te:n}=we(),s=It(),u=r,o=l,c=z({}),g=z(""),p=z(!1),v=z(null),_=new Aa({html:!1,breaks:!0,linkify:!0,typographer:!0}),y=T(()=>{if(u.skills.length===0)return null;const w=Math.min(u.highlightIndex,u.skills.length-1);return u.skills[w]??null}),k=T(()=>g.value?_.render(g.value):"");function b(w){const S=`ai.assistant.builtinToolDesc.${w}`;return n(S)?e(S):w}const $=T(()=>y.value?.tags.join(" / ")||""),C=T(()=>y.value?.tools.map(w=>b(w)).join(" / ")||"");return fe(()=>[u.visible,y.value?.id],async([w,S])=>{if(!w||!S){g.value="",p.value=!1;return}if(c.value[S]){g.value=c.value[S],p.value=!1;return}p.value=!0;const f=(await s.getSkillConfig(S))?.prompt?.trim()||"";c.value={...c.value,[S]:f},y.value?.id===S&&(g.value=f,p.value=!1)},{immediate:!0}),fe(()=>[u.visible,u.highlightIndex,u.skills.length],async([w,S])=>{if(!w||!v.value)return;await qe(),v.value.querySelectorAll("[data-slash-item]")[S]?.scrollIntoView({block:"nearest"})}),(w,S)=>{const I=_e;return i(),W(vt,{name:"slash-menu"},{default:F(()=>[r.visible?(i(),m("div",gp,[a("div",pp,[a("div",hp,[a("div",fp,[a("span",null,d(t(e)("ai.chat.input.slashHint")),1)]),a("button",{type:"button",class:"rounded-md p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:t(e)("common.close"),onClick:S[0]||(S[0]=f=>o("close"))},[h(I,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5"})],8,vp)]),u.skills.length>0?(i(),m("div",{key:0,ref_key:"listRef",ref:v,class:"max-h-72 overflow-y-auto p-1.5"},[(i(!0),m(re,null,ve(u.skills,(f,x)=>(i(),m("button",{key:f.id,type:"button","data-slash-item":"",class:J(["flex w-full items-start justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left transition-colors",x===u.highlightIndex?"bg-primary-50 text-gray-900 dark:bg-primary-950/30 dark:text-gray-100":"text-gray-700 hover:bg-gray-50 dark:text-gray-200 dark:hover:bg-gray-800/80"]),onMouseenter:B=>o("highlight",x),onClick:B=>o("select",f)},[a("div",xp,[a("div",bp,[a("span",kp,d(f.name),1),u.activeSkillId===f.id?(i(),W(I,{key:0,name:"i-heroicons-check-circle-20-solid",class:"h-3.5 w-3.5 shrink-0 text-primary-500"})):E("",!0)]),a("p",_p,d(f.description),1)])],42,yp))),128))],512)):(i(),m("div",wp,[a("p",$p,d(t(e)("ai.chat.input.slashEmpty")),1),a("p",Cp,d(t(e)("ai.chat.input.slashEmptyHint")),1)])),a("button",{type:"button",class:"flex w-full items-center justify-between border-t border-gray-100 px-2.5 py-1.5 text-xs text-gray-600 transition-colors hover:bg-gray-50 hover:text-gray-900 dark:border-gray-800 dark:text-gray-300 dark:hover:bg-gray-800/80 dark:hover:text-gray-100",onClick:S[1]||(S[1]=f=>o("manage"))},[a("span",null,d(t(e)("ai.chat.input.manageSkills")),1),h(I,{name:"i-heroicons-arrow-top-right-on-square",class:"h-3.5 w-3.5"})])]),u.skills.length>0&&y.value?(i(),m("div",Sp,[a("div",Ip,[a("p",Tp,d(y.value.name),1),a("p",Mp,d(y.value.description),1),$.value?(i(),m("div",zp,[a("span",Ap,d(t(e)("ai.chat.input.previewTagsLabel")),1),a("span",qp,d($.value),1)])):E("",!0),C.value?(i(),m("div",Lp,[a("span",Dp,d(t(e)("ai.chat.input.previewToolsLabel")),1),a("span",Ep,d(C.value),1)])):E("",!0)]),a("div",Bp,[p.value?(i(),m("div",Fp,d(t(e)("common.loading")),1)):k.value?(i(),m("div",{key:1,class:"prose prose-sm max-w-none text-xs leading-5 dark:prose-invert prose-headings:mb-1.5 prose-headings:mt-2 prose-p:my-1.5 prose-ul:my-1.5 prose-ol:my-1.5",innerHTML:k.value},null,8,Rp)):(i(),m("div",Vp,d(t(e)("ai.chat.input.previewUnavailable")),1))])])):E("",!0)])):E("",!0)]),_:1})}}}),Pp=at(Op,[["__scopeId","data-v-0f67bc21"]]),jp={class:"shrink-0 pt-2 pb-2"},Np={class:"relative px-4 pt-2.5 pb-2.5"},Up={class:"flex items-start gap-2 pr-10"},Wp={key:0,class:"inline-flex max-w-[180px] shrink-0 items-center rounded-md bg-primary-50 px-2 text-sm leading-6 font-medium text-primary-700 dark:bg-primary-500/10 dark:text-primary-400"},Hp={class:"truncate"},Kp=["disabled","placeholder"],Yp=["disabled","title"],Gp=ce({__name:"AIChatInput",props:{sessionId:{},disabled:{type:Boolean},status:{},chatType:{}},emits:["send","stop","manageSkills","skillActivated"],setup(r,{expose:l,emit:e}){const{t:n}=we(),s=r,u=e,o=It(),{compatibleSkills:c,activeSkill:g,activeSkillId:p,isLoaded:v}=ct(o),_=z(null),y=z(null),k=z(""),b=z([]),$=z([]),C=z(!1),w=z(!1),S=z(""),I=z(0),f=z(!1),x=z(""),B=z(0),R=z(null),D=z(!1),A=z(null),M=z(null),q=z(!1),Y=T(()=>k.value.trim().length>0&&!s.disabled),G=T(()=>g.value&&k.value.trim().length===0?n("ai.chat.input.placeholderWithActiveSkill",{name:g.value.name}):n("ai.chat.input.placeholderWithSlash")),Z=T(()=>s.status==="streaming"?"":Y.value?n("ai.chat.input.send"):g.value?n("ai.chat.input.needMoreThanSkill"):n("ai.chat.input.needQuestion")),ue=T(()=>{const L=new Map;return b.value.forEach(j=>{const U=j.groupNickname||j.accountName||j.platformId;L.set(U,(L.get(U)??0)+1)}),b.value.map(j=>{const U=j.groupNickname||j.accountName||j.platformId,ae=(L.get(U)??0)>1?`${U}·${j.platformId}`:U,ne=[j.platformId];return j.aliases.length>0&&ne.push(j.aliases.join(" / ")),{memberId:j.id,platformId:j.platformId,displayName:U,aliases:[...j.aliases],mentionText:`@${ae}`,insertName:ae,subtitle:ne.join(" · "),searchText:[U,j.groupNickname||"",j.accountName||"",j.platformId,ae,j.aliases.join(" ")].join(" ").toLocaleLowerCase()}})}),oe=T(()=>{const L=S.value.trim().toLocaleLowerCase();return L?c.value.filter(j=>[j.name,j.description,j.tags.join(" ")].join(" ").toLocaleLowerCase().includes(L)):c.value}),H=T(()=>{const L=x.value.trim().toLocaleLowerCase();return L?ue.value.filter(j=>j.searchText.includes(L)):ue.value});function P(){if(!y.value)return;const L=y.value;L.style.height="auto";const j=192,U=Math.min(L.scrollHeight,j);L.style.height=`${U}px`,L.style.overflowY=L.scrollHeight>j?"auto":"hidden"}function se(){y.value?.focus()}async function me(){if(!s.sessionId){b.value=[];return}C.value=!0;try{const L=await Ke().getMembers(s.sessionId);b.value=[...L].sort((j,U)=>U.messageCount-j.messageCount)}catch(L){console.error("加载 AI @ 成员列表失败:",L),b.value=[]}finally{C.value=!1}}function he(){w.value=!1,S.value="",I.value=0}function ee(){f.value=!1,x.value="",B.value=0,R.value=null}function te(){/^\s*\/([^\n]*)$/.test(k.value)&&(A.value=k.value),he()}function N(){R.value&&(M.value=R.value.rawToken),ee()}function de(L){if(s.disabled){he();return}A.value&&A.value!==L&&(A.value=null);const j=L.match(/^\s*\/([^\n]*)$/);if(!j){he();return}const U=!w.value||S.value!==j[1];if(S.value=j[1],A.value===L){w.value=!1;return}w.value=!0,U&&(I.value=0)}function be(){const L=y.value,j=k.value.length;return{start:L?.selectionStart??j,end:L?.selectionEnd??j}}function xe(L){const{start:j,end:U}=be();if(j!==U)return null;const ae=L.slice(0,j),ne=ae.match(/@([^\s@]*)$/);if(!ne)return null;const Ve=ne[1],Le=ae.length-Ve.length-1;return{start:Le,end:j,rawToken:ae.slice(Le),query:Ve}}function le(L){if(s.disabled||w.value){ee();return}const j=xe(L);if(M.value&&M.value!==j?.rawToken&&(M.value=null),!j){ee();return}const U=!f.value||x.value!==j.query||R.value?.rawToken!==j.rawToken;if(x.value=j.query,R.value={start:j.start,end:j.end,rawToken:j.rawToken},M.value===j.rawToken){f.value=!1;return}f.value=!0,U&&(B.value=0)}function Q(L){if(de(L),w.value){ee();return}le(L)}function X(L){$.value=$.value.filter(j=>L.includes(j.mentionText))}function pe(){const{start:L,end:j}=be();if(L!==j||L===0)return!1;const U=[...new Set($.value.map(ae=>ae.mentionText))].sort((ae,ne)=>ne.length-ae.length);for(const ae of U){let ne=k.value.indexOf(ae);for(;ne!==-1;){const Ve=ne,Le=ne+ae.length,Me=k.value[Le]===" "?Le+1:Le;if(L>Ve&&L<=Me)return q.value=!0,k.value=k.value.slice(0,Ve)+k.value.slice(Me),M.value=null,qe(()=>{P(),se(),y.value?.setSelectionRange(Ve,Ve),q.value=!1,Q(k.value)}),!0;ne=k.value.indexOf(ae,ne+ae.length)}}return!1}function ke(){o.activateSkill(null),qe(se)}function $e(){s.disabled||(p.value&&o.activateSkill(null),q.value=!0,k.value="/",A.value=null,qe(()=>{P(),se(),y.value?.setSelectionRange(1,1),q.value=!1,Q(k.value)}))}function De(L){s.disabled||(q.value=!0,k.value=L,A.value=null,qe(()=>{P(),se();const j=k.value.length;y.value?.setSelectionRange(j,j),q.value=!1,Q(k.value)}))}function Be(L){if(s.disabled||!R.value)return;const j=k.value.slice(0,R.value.start),U=k.value.slice(R.value.end),ae=`@${L.insertName}`,ne=`${j}${ae} ${U}`;$.value=[...$.value.filter(Ve=>Ve.memberId!==L.memberId),{memberId:L.memberId,platformId:L.platformId,displayName:L.displayName,aliases:[...L.aliases],mentionText:ae}],q.value=!0,k.value=ne,M.value=null,ee(),qe(()=>{const Ve=j.length+ae.length+1;P(),se(),y.value?.setSelectionRange(Ve,Ve),q.value=!1,Q(k.value)})}function Te(){Y.value&&(u("send",{content:k.value.trim(),mentionedMembers:[...$.value]}),k.value="",A.value=null,M.value=null,$.value=[],ee(),p.value&&o.activateSkill(null))}function Pe(L){s.disabled||(o.activateSkill(L.id),u("skillActivated",L),k.value="",A.value=null,he(),qe(()=>{se()}))}function je(){te(),u("manageSkills")}function Se(L){if(!oe.value.length)return;const j=oe.value.length;I.value=(I.value+L+j)%j}function ge(L){if(!H.value.length)return;const j=H.value.length;B.value=(B.value+L+j)%j}function O(L){if(L.key==="Backspace"&&k.value.length===0&&p.value){L.preventDefault(),ke();return}if(L.key==="Backspace"&&pe()){L.preventDefault();return}if(f.value){if(L.key==="ArrowDown"){L.preventDefault(),ge(1);return}if(L.key==="ArrowUp"){L.preventDefault(),ge(-1);return}if(L.key==="Escape"){L.preventDefault(),N();return}if(L.key==="Enter"&&!L.shiftKey&&!D.value||L.key==="Tab"){L.preventDefault();const j=H.value[B.value];j&&Be(j);return}}if(w.value){if(L.key==="ArrowDown"){L.preventDefault(),Se(1);return}if(L.key==="ArrowUp"){L.preventDefault(),Se(-1);return}if(L.key==="Escape"){L.preventDefault(),te();return}if(L.key==="Enter"&&!L.shiftKey&&!D.value||L.key==="Tab"){L.preventDefault();const j=oe.value[I.value];j&&Pe(j);return}}L.key==="Enter"&&!L.shiftKey&&!D.value&&(L.preventDefault(),Te())}function V(L){if(!w.value&&!f.value||!_.value)return;const j=L.target;j instanceof Node&&!_.value.contains(j)&&(te(),N())}function K(){q.value||Q(k.value)}return fe(()=>s.chatType,L=>{o.setFilterContext(L)},{immediate:!0}),fe(k,async L=>{X(L),q.value||Q(L),await qe(),P()}),fe(oe,L=>{if(L.length===0){I.value=0;return}I.value>=L.length&&(I.value=L.length-1)},{immediate:!0}),fe(H,L=>{if(L.length===0){B.value=0;return}B.value>=L.length&&(B.value=L.length-1)},{immediate:!0}),fe(()=>s.disabled,L=>{L&&(te(),N())}),fe(()=>s.sessionId,()=>{$.value=[],ee(),me()},{immediate:!0}),Re(async()=>{v.value||await o.loadSkills(),await qe(),P(),document.addEventListener("mousedown",V)}),Bt(()=>{document.removeEventListener("mousedown",V)}),l({fillInput:De,openSkillSelector:$e}),(L,j)=>{const U=_e;return i(),m("div",jp,[a("div",{ref_key:"rootRef",ref:_,class:"relative w-full max-w-4xl mx-auto"},[h(Pp,{visible:w.value,skills:oe.value,"highlight-index":I.value,"active-skill-id":t(p),onSelect:Pe,onClose:te,onManage:je,onHighlight:j[0]||(j[0]=ae=>I.value=ae)},null,8,["visible","skills","highlight-index","active-skill-id"]),h(mp,{visible:f.value,members:H.value,"highlight-index":B.value,loading:C.value,onSelect:Be,onClose:N,onHighlight:j[1]||(j[1]=ae=>B.value=ae)},null,8,["visible","members","highlight-index","loading"]),a("div",{class:J(["flex flex-col overflow-hidden rounded-2xl bg-white shadow-[0_2px_14px_rgba(0,0,0,0.04)] ring-1 ring-gray-200/60 transition-all dark:bg-page-dark dark:ring-white/5",s.disabled?"bg-gray-50/50 dark:bg-page-dark/50":"focus-within:ring-primary-500/40 focus-within:shadow-[0_4px_20px_rgba(0,0,0,0.08)] dark:focus-within:ring-primary-500/40"])},[a("div",Np,[a("div",Up,[t(g)?(i(),m("div",Wp,[a("span",Hp,"/"+d(t(g).name),1)])):E("",!0),Qe(a("textarea",{ref_key:"textareaRef",ref:y,"onUpdate:modelValue":j[2]||(j[2]=ae=>k.value=ae),rows:"2",class:"min-h-[48px] min-w-0 flex-1 resize-none border-0 bg-transparent px-0 py-0 text-sm leading-6 text-gray-900 outline-none placeholder:text-gray-400 disabled:cursor-not-allowed disabled:text-gray-400 dark:text-gray-100 dark:placeholder:text-gray-500 dark:disabled:text-gray-500",disabled:s.disabled,placeholder:G.value,onKeydown:O,onClick:K,onKeyup:K,onSelect:K,onCompositionstart:j[3]||(j[3]=ae=>D.value=!0),onCompositionend:j[4]||(j[4]=ae=>D.value=!1)},null,40,Kp),[[ft,k.value]])]),s.status==="streaming"?(i(),m("button",{key:0,type:"button",class:"absolute right-3 bottom-2 flex h-7 w-7 items-center justify-center rounded-full bg-primary-500 text-white shadow-sm transition-colors hover:bg-primary-600",onClick:j[5]||(j[5]=ae=>u("stop"))},[h(U,{name:"i-heroicons-stop-16-solid",class:"h-3.5 w-3.5"})])):(i(),m("button",{key:1,type:"button",class:J(["absolute right-3 bottom-2 flex h-7 w-7 items-center justify-center rounded-full transition-all duration-200",Y.value?"bg-primary-500 text-white hover:bg-primary-600 shadow-sm":"bg-gray-100 text-gray-400 dark:bg-gray-800 dark:text-gray-500"]),disabled:!Y.value,title:Z.value,onClick:Te},[h(U,{name:"i-heroicons-arrow-up-20-solid",class:"h-4 w-4"})],10,Yp))])],2)],512)])}}}),Qp={key:0,class:"flex w-fit items-center gap-1.5 rounded-lg bg-gray-100 px-2.5 py-1 text-xs transition-colors dark:bg-gray-800/50"},Jp={class:"font-medium text-gray-600 dark:text-gray-400"},Xp={key:1,class:"flex items-start gap-3"},Zp={class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-linear-to-br from-pink-500 to-pink-600"},e0={class:"rounded-2xl rounded-tl-sm bg-gray-100 px-4 py-3 dark:bg-gray-800"},t0={key:0,class:"space-y-2"},a0={class:"flex items-center gap-2"},s0={key:0,class:"flex gap-1"},n0={key:1,class:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400"},o0={key:0,class:"flex flex-wrap gap-1"},l0={class:"text-xs text-gray-400"},i0={key:1,class:"flex items-center gap-2"},r0={class:"text-sm text-gray-600 dark:text-gray-400"},u0=ce({__name:"AIThinkingIndicator",props:{currentToolStatus:{},toolsUsed:{},agentStatus:{}},setup(r){const{t:l,te:e}=we();function n(o,c){const g=`ai.assistant.builtinToolDesc.${o}`;return e(g)?l(g):c||o}const s=r,u=T(()=>s.agentStatus?.phase==="compressing");return(o,c)=>{const g=_e;return u.value?(i(),m("div",Qp,[h(g,{name:"i-heroicons-arrow-path",class:"h-3.5 w-3.5 shrink-0 animate-spin text-gray-600 dark:text-gray-400"}),a("span",Jp,d(t(l)("ai.chat.thinking.compressing")),1)])):(i(),m("div",Xp,[a("div",Zp,[h(g,{name:"i-heroicons-sparkles",class:"h-4 w-4 text-white"})]),a("div",e0,[r.currentToolStatus?(i(),m("div",t0,[a("div",a0,[a("span",{class:J(["inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium",[r.currentToolStatus.status==="running"?"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-300":r.currentToolStatus.status==="done"?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300"]])},[h(g,{name:r.currentToolStatus.status==="running"?"i-heroicons-cog-6-tooth":r.currentToolStatus.status==="done"?"i-heroicons-check-circle":"i-heroicons-x-circle",class:J(["h-3 w-3",{"animate-spin":r.currentToolStatus.status==="running"}])},null,8,["name","class"]),ie(" "+d(n(r.currentToolStatus.name,r.currentToolStatus.displayName)),1)],2),r.currentToolStatus.status==="running"?(i(),m("span",s0,[...c[0]||(c[0]=[a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:0ms]"},null,-1),a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:150ms]"},null,-1),a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:300ms]"},null,-1)])])):r.currentToolStatus.status==="done"?(i(),m("span",n0,[a("span",null,d(t(l)("ai.chat.thinking.processingResult")),1),c[1]||(c[1]=a("span",{class:"flex gap-1"},[a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1))])):E("",!0)]),r.toolsUsed.length>1?(i(),m("div",o0,[a("span",l0,d(t(l)("ai.chat.thinking.called")),1),(i(!0),m(re,null,ve(r.toolsUsed.slice(0,-1),p=>(i(),m("span",{key:p,class:"inline-flex items-center gap-1 rounded-full bg-gray-200 px-2 py-0.5 text-xs text-gray-600 dark:bg-gray-700 dark:text-gray-400"},[h(g,{name:"i-heroicons-check",class:"h-3 w-3 text-green-500"}),ie(" "+d(n(p)),1)]))),128))])):E("",!0)])):(i(),m("div",i0,[a("span",r0,d(t(l)("ai.chat.thinking.analyzing")),1),c[2]||(c[2]=a("span",{class:"flex gap-1"},[a("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:0ms]"}),a("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:150ms]"}),a("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:300ms]"})],-1))]))])]))}}}),c0={class:"relative z-20 flex items-center justify-between"},d0={class:"flex items-center gap-1"},m0=["disabled"],g0={class:"max-w-[160px] truncate"},p0=["title"],h0={class:"w-40 py-1"},f0={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},v0=["onClick"],y0={class:"flex items-center gap-1"},x0=["title"],b0={class:"hidden shrink-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-xs text-gray-400 dark:text-gray-500 md:flex"},k0={class:"h-1.5 w-10 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},_0={class:"text-[10px]"},w0={class:"space-y-0.5 whitespace-nowrap text-xs"},$0={key:0},C0=["title","disabled"],S0={class:"hidden xl:inline"},I0=["title","disabled"],T0={class:"hidden xl:inline"},M0=ce({__name:"ChatStatusBar",props:{sessionTokenUsage:{},agentStatus:{},currentAIChatId:{},currentMessages:{},fallbackTitle:{},estimatedContextTokens:{}},setup(r){const{t:l}=we(),e=ot(),n=bt(),s=r,u=_a(),o=An(),{aiGlobalSettings:c}=ct(u),{defaultAssistantConfig:g,isLoading:p}=ct(o),v=z(!1),_=T(()=>s.agentStatus?l(`ai.chat.statusBar.agent.phase.${s.agentStatus.phase}`):""),y=T(()=>s.agentStatus?l(`ai.chat.statusBar.agent.phaseShort.${s.agentStatus.phase}`):""),k=T(()=>{if(!s.agentStatus)return"text-gray-500 bg-gray-100 dark:bg-gray-800 dark:text-gray-300";switch(s.agentStatus.phase){case"compressing":return"text-purple-600 bg-purple-50 dark:bg-purple-900/30 dark:text-purple-300";case"tool_running":return"text-indigo-600 bg-indigo-50 dark:bg-indigo-900/30 dark:text-indigo-300";case"thinking":return"text-blue-600 bg-blue-50 dark:bg-blue-900/30 dark:text-blue-300";case"responding":return"text-emerald-600 bg-emerald-50 dark:bg-emerald-900/30 dark:text-emerald-300";case"completed":return"text-green-600 bg-green-50 dark:bg-green-900/30 dark:text-green-300";case"aborted":return"text-amber-600 bg-amber-50 dark:bg-amber-900/30 dark:text-amber-300";case"error":return"text-red-600 bg-red-50 dark:bg-red-900/30 dark:text-red-300";default:return"text-gray-500 bg-gray-100 dark:bg-gray-800 dark:text-gray-300"}});function b(te){return Number.isFinite(te)?new Intl.NumberFormat().format(Math.max(0,Math.round(te))):"0"}function $(te){const N=Math.max(0,Math.round(te));return N>=1e6?`${(N/1e6).toFixed(1).replace(/\.0$/,"")}M`:N>=1e3?`${(N/1e3).toFixed(1).replace(/\.0$/,"")}k`:String(N)}const C=T(()=>b(s.sessionTokenUsage.totalTokens)),w=T(()=>$(s.sessionTokenUsage.totalTokens)),S=T(()=>s.sessionTokenUsage.cacheReadTokens>0),I=T(()=>$(s.sessionTokenUsage.cacheReadTokens)),f=T(()=>s.agentStatus?.contextTokens?s.agentStatus.contextTokens:s.estimatedContextTokens&&s.estimatedContextTokens>0?s.estimatedContextTokens:0),x=T(()=>{const te=g.value,N=o.defaultAssistant?.modelId||te?.model;return!te||!N?128e3:(o.getModelById(te.provider,N)||o.findModelAcrossProviders(N))?.contextWindow??128e3}),B=T(()=>f.value<=0||x.value<=0?0:Math.min(100,Math.round(f.value/x.value*100))),R=T(()=>{const te=B.value;return te>=80?"bg-red-500":te>=60?"bg-amber-500":"bg-emerald-500"}),D=T(()=>s.agentStatus?[`${l("ai.chat.statusBar.agent.label")}: ${_.value}`,`${l("ai.chat.statusBar.agent.contextTokens")}: ${b(s.agentStatus.contextTokens)}`,`${l("ai.chat.statusBar.tokenUsageTitle")}: ${C.value}`].join(`
101
- `):"");function A(){n.openSettings("ai","defaultModel")}const M=z(!1),q=T(()=>pa(s.currentMessages??[])),Y=T(()=>!!s.currentAIChatId||Hl(s.currentMessages??[]));function G(){return{createdAt:l("ai.chat.conversation.export.createdAt"),user:l("ai.chat.conversation.export.user"),assistant:l("ai.chat.conversation.export.assistant")}}function Z(te){return te.map(N=>({...N,timestamp:N.timestamp*1e3}))}async function ue(){if(!(M.value||!Y.value)){M.value=!0;try{const te=c.value.exportFormat||"markdown",N=G();let de=s.fallbackTitle||l("ai.chat.conversation.newChat"),be=q.value[0]?.timestamp??Date.now(),xe=q.value;if(s.currentAIChatId){const[Q,X]=await Promise.all([Ye().getAIChat(s.currentAIChatId),Ye().getMessages(s.currentAIChatId)]);Q&&(de=Q.title||de,be=Q.createdAt*1e3);const pe=pa(Z(X));pe.length>0&&(xe=pe)}if(xe.length===0){e.warn(l("ai.chat.conversation.export.noMessages"));return}const le=await Ql(de,xe,be,te,N);if(le.success&&le.filePath){const Q=le.filePath.split("/").pop()||le.filePath,X=le.filePath;e.add({title:l("common.exportSuccess"),description:Q,color:"primary",actions:[{label:l("common.openFolder"),onClick:()=>{ns().showInFolder(X)}}]})}else e.fail(l("common.exportFailed"),{description:le.error})}catch(te){console.error("导出对话失败:",te),e.fail(l("common.exportFailed"),{description:String(te)})}finally{M.value=!1}}}async function oe(){if(!v.value){v.value=!0;try{const te=await Ye().showAiLogFile();te?.success||e.fail(l("ai.chat.statusBar.log.openFailed"),{description:te?.error||l("ai.chat.statusBar.log.openFailedDesc")})}catch(te){console.error("打开 AI 日志失败:",te),e.fail(l("ai.chat.statusBar.log.openFailed"),{description:String(te)})}finally{v.value=!1}}}const H=z(!1),P=T(()=>{const te=g.value,N=o.defaultAssistant?.modelId||te?.model;return!te?.provider||!N?[]:Pl(te.provider,N)}),se=T(()=>P.value.length>0),me=T(()=>{const te=o.defaultAssistant;return!te?.configId||!te?.modelId?"default":u.getThinkingLevel(te.configId,te.modelId)??"default"});function he(te){const N=o.defaultAssistant;!N?.configId||!N?.modelId||(u.setThinkingLevel(N.configId,N.modelId,te),H.value=!1)}const ee=T(()=>l(`ai.chat.statusBar.thinking.level.${me.value}`));return(te,N)=>{const de=_e,be=ms,xe=St;return i(),m("div",c0,[a("div",d0,[a("button",{class:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-300",disabled:t(p),onClick:A},[h(de,{name:"i-heroicons-cpu-chip",class:"h-3.5 w-3.5"}),a("span",g0,d(t(o).defaultAssistant?.modelId?t(o).getModelById(t(g)?.provider??"",t(o).defaultAssistant.modelId)?.name||t(o).defaultAssistant.modelId:t(l)("ai.chat.statusBar.model.notConfigured")),1)],8,m0),se.value?(i(),W(be,{key:0,open:H.value,"onUpdate:open":N[0]||(N[0]=le=>H.value=le),ui:{content:"z-[80] p-0"}},{content:F(()=>[a("div",h0,[a("div",f0,d(t(l)("ai.chat.statusBar.thinking.title")),1),(i(!0),m(re,null,ve(P.value,le=>(i(),m("button",{key:le,class:J(["flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",me.value===le?"text-primary-600 dark:text-primary-400":"text-gray-700 dark:text-gray-300"]),onClick:Q=>he(le)},[h(de,{name:me.value===le?"i-heroicons-check-circle-solid":"i-heroicons-light-bulb",class:J(["h-4 w-4 shrink-0",me.value===le?"text-primary-500":"text-gray-400"])},null,8,["name","class"]),a("span",null,d(t(l)(`ai.chat.statusBar.thinking.level.${le}`)),1)],10,v0))),128))])]),default:F(()=>[a("button",{class:J(["flex items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",me.value==="default"||me.value==="off"?"text-gray-400 dark:text-gray-500":"text-primary-500 dark:text-primary-400"]),title:t(l)("ai.chat.statusBar.thinking.tooltip")},[h(de,{name:"i-heroicons-light-bulb",class:"h-3.5 w-3.5"}),a("span",null,d(ee.value),1)],10,p0)]),_:1},8,["open"])):E("",!0)]),a("div",y0,[r.agentStatus?(i(),m("div",{key:0,class:"hidden shrink-0 items-center gap-1 rounded-lg bg-gray-50/90 px-1.5 py-1 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.35)] dark:bg-gray-800/70 dark:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.04)] lg:flex",title:D.value},[a("span",{class:J(["rounded px-1 py-0.5 text-[10px] font-medium",k.value])},d(y.value),3)],8,x0)):E("",!0),f.value>0?(i(),W(xe,{key:1,ui:{content:"h-auto py-1.5"}},{content:F(()=>[a("div",w0,[a("div",null,d(t(l)("ai.chat.statusBar.agent.contextTokens"))+": "+d($(f.value))+" / "+d($(x.value)),1),a("div",null,d(t(l)("ai.chat.statusBar.tokenUsageTitle"))+": "+d(w.value),1),S.value?(i(),m("div",$0,d(t(l)("ai.chat.statusBar.cacheHit"))+": "+d(I.value),1)):E("",!0)])]),default:F(()=>[a("div",b0,[a("div",k0,[a("div",{class:J(["h-full rounded-full transition-all duration-300",R.value]),style:et({width:`${B.value}%`})},null,6)]),a("span",_0,d(B.value)+"%",1)])]),_:1})):E("",!0),a("button",{class:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:t(l)("ai.chat.statusBar.export.title"),disabled:M.value||!Y.value,onClick:ue},[h(de,{name:"i-heroicons-arrow-down-tray",class:"h-3.5 w-3.5"}),a("span",S0,d(t(l)("ai.chat.statusBar.export.label")),1)],8,C0),a("button",{class:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:t(l)("ai.chat.statusBar.log.title"),disabled:v.value,onClick:oe},[h(de,{name:"i-heroicons-document-text",class:"h-3.5 w-3.5"}),a("span",T0,d(t(l)("ai.chat.statusBar.log.label")),1)],8,I0)])])}}}),z0={class:"assistant-bar-wrapper flex justify-center"},A0=["onClick"],q0={key:0,class:"absolute right-0 top-full z-30 mt-2 w-56 overflow-hidden rounded-xl border border-gray-200/80 bg-white/95 p-1 shadow-overlay backdrop-blur-md dark:border-gray-700 dark:bg-page-dark/95"},L0={class:"custom-scrollbar max-h-60 space-y-0.5 overflow-y-auto"},D0=["onClick"],E0={class:"truncate font-medium"},jt=4,B0=ce({__name:"AssistantInlineBar",props:{chatType:{},locale:{},selectedId:{}},emits:["select","market"],setup(r,{emit:l}){const e=r,n=l,s=z(!1),u=z(null);function o(f){n("select",f),s.value=!1}function c(){b.value.length!==0&&(s.value=!s.value)}function g(f){if(!s.value||!u.value)return;const x=f.target;x instanceof Node&&!u.value.contains(x)&&(s.value=!1)}const p=Rt(),{filteredAssistants:v,isLoaded:_}=ct(p),y=T(()=>{const f=qn(e.locale);return[...v.value].sort((x,B)=>x.id===f?-1:B.id===f?1:0)}),k=T(()=>{const f=y.value;if(f.length<=jt)return f;const x=f.findIndex(B=>B.id===e.selectedId);if(x!==-1&&x>=jt-1){const B=f.slice(0,jt-1),R=f[x];return[...B,R]}return f.slice(0,jt)}),b=T(()=>{const f=new Set(k.value.map(x=>x.id));return y.value.filter(x=>!f.has(x.id))});fe(()=>[e.chatType,e.locale],([f,x])=>{p.setFilterContext(f,x)},{immediate:!0});const $=z([]),C=z(null);let w=null;const S=z({width:"0px",transform:"translateX(0px)",opacity:0}),I=async()=>{await qe();const f=k.value.findIndex(x=>x.id===e.selectedId);if(f!==-1&&$.value[f]){const x=$.value[f];S.value={width:`${x.offsetWidth+6}px`,transform:`translateX(${x.offsetLeft-3}px)`,opacity:1}}else S.value.opacity=0};return fe(()=>[e.selectedId,k.value],()=>{I()},{deep:!0}),Re(async()=>{_.value||await p.loadAssistants(),I(),document.addEventListener("mousedown",g),typeof ResizeObserver<"u"&&C.value&&(w=new ResizeObserver(()=>{I()}),w.observe(C.value))}),tt(()=>{document.removeEventListener("mousedown",g),w&&w.disconnect()}),(f,x)=>{const B=_e;return i(),m("div",z0,[a("div",{ref_key:"containerRef",ref:C,class:"assistant-bar-grid relative flex items-center justify-center gap-1.5 rounded-full bg-gray-50/60 p-[3px] shadow-inner ring-1 ring-inset ring-gray-900/5 backdrop-blur-md dark:bg-gray-800/40 dark:ring-white/10 z-0 overflow-hidden sm:overflow-visible"},[a("div",{class:"absolute left-0 inset-y-0 -z-10 rounded-full bg-white ring-[1.5px] ring-primary-500 shadow-sm transition-all duration-350 ease-out dark:bg-primary-700/15 dark:ring-primary-500",style:et(S.value)},null,4),(i(!0),m(re,null,ve(k.value,(R,D)=>(i(),m("button",{key:R.id,ref_for:!0,ref:A=>{A&&($.value[D]=A)},class:J(["relative z-10 flex h-[32px] items-center justify-center whitespace-nowrap rounded-full px-4 text-[13px] font-medium transition-colors duration-200",[r.selectedId===R.id?"text-primary-600 dark:text-primary-400":"text-gray-500 hover:bg-gray-200/50 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-700/50 dark:hover:text-gray-200"]]),onClick:A=>n("select",R.id)},d(R.name),11,A0))),128)),b.value.length>0?(i(),m("div",{key:0,ref_key:"overflowMenuRef",ref:u,class:"relative z-20"},[a("button",{type:"button",class:"relative z-10 flex h-[32px] w-[32px] ml-0.5 items-center justify-center rounded-full text-gray-500 transition-colors duration-200 hover:bg-gray-200/50 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-700/50 dark:hover:text-gray-200",onClick:c},[h(B,{name:"i-heroicons-ellipsis-horizontal",class:"h-5 w-5"})]),s.value?(i(),m("div",q0,[a("div",L0,[x[1]||(x[1]=a("p",{class:"px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500"}," 更多助手 ",-1)),(i(!0),m(re,null,ve(b.value,R=>(i(),m("button",{key:R.id,type:"button",class:J(["flex w-full items-center justify-between rounded-md px-2.5 py-1.5 text-left text-sm transition-colors",[r.selectedId===R.id?"bg-primary-50 text-primary-600 dark:bg-primary-500/10 dark:text-primary-400":"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800"]]),onClick:D=>o(R.id)},[a("span",E0,d(R.name),1),r.selectedId===R.id?(i(),W(B,{key:0,name:"i-heroicons-check",class:"h-4 w-4 shrink-0"})):E("",!0)],10,D0))),128))])])):E("",!0)],512)):E("",!0),a("button",{type:"button",class:"relative z-10 flex h-[32px] w-[32px] items-center justify-center rounded-full text-gray-500 transition-colors duration-200 hover:bg-gray-200/50 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-700/50 dark:hover:text-gray-200",onClick:x[0]||(x[0]=R=>n("market"))},[h(B,{name:"i-heroicons-plus",class:"h-[18px] w-[18px]"})])],512)])}}}),F0=at(B0,[["__scopeId","data-v-169115ce"]]),R0={slots:{root:"relative inline-flex items-center",base:["w-full rounded-md border-0 appearance-none placeholder:text-dimmed disabled:cursor-not-allowed disabled:opacity-75","transition-colors"],leading:"absolute start-0 flex items-start",leadingIcon:"shrink-0 text-dimmed",leadingAvatar:"shrink-0",leadingAvatarSize:"",trailing:"absolute end-0 flex items-start",trailingIcon:"shrink-0 text-dimmed"},variants:{fieldGroup:{horizontal:{root:"group has-focus-visible:z-[1]",base:"group-not-only:group-first:rounded-e-none group-not-only:group-last:rounded-s-none group-not-last:group-not-first:rounded-none"},vertical:{root:"group has-focus-visible:z-[1]",base:"group-not-only:group-first:rounded-b-none group-not-only:group-last:rounded-t-none group-not-last:group-not-first:rounded-none"}},size:{xs:{base:"px-2 py-1 text-sm/4 gap-1",leading:"ps-2 inset-y-1",trailing:"pe-2 inset-y-1",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4"},sm:{base:"px-2.5 py-1.5 text-sm/4 gap-1.5",leading:"ps-2.5 inset-y-1.5",trailing:"pe-2.5 inset-y-1.5",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4"},md:{base:"px-2.5 py-1.5 text-base/5 gap-1.5",leading:"ps-2.5 inset-y-1.5",trailing:"pe-2.5 inset-y-1.5",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5"},lg:{base:"px-3 py-2 text-base/5 gap-2",leading:"ps-3 inset-y-2",trailing:"pe-3 inset-y-2",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5"},xl:{base:"px-3 py-2 text-base gap-2",leading:"ps-3 inset-y-2",trailing:"pe-3 inset-y-2",leadingIcon:"size-6",leadingAvatarSize:"xs",trailingIcon:"size-6"}},variant:{outline:"text-highlighted bg-default ring ring-inset ring-accented",soft:"text-highlighted bg-elevated/50 hover:bg-elevated focus:bg-elevated disabled:bg-elevated/50",subtle:"text-highlighted bg-elevated ring ring-inset ring-accented",ghost:"text-highlighted bg-transparent hover:bg-elevated focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent",none:"text-highlighted bg-transparent focus:outline-none"},color:{primary:"",secondary:"",success:"",info:"",warning:"",error:"",neutral:""},leading:{true:""},trailing:{true:""},loading:{true:""},highlight:{true:""},fixed:{false:""},type:{file:"file:me-1.5 file:font-medium file:text-muted file:outline-none"},autoresize:{true:{base:"resize-none"}}},compoundVariants:[{color:"primary",variant:["outline","subtle"],class:"outline-primary/25 focus-visible:outline-3 focus-visible:ring-primary"},{color:"secondary",variant:["outline","subtle"],class:"outline-secondary/25 focus-visible:outline-3 focus-visible:ring-secondary"},{color:"success",variant:["outline","subtle"],class:"outline-success/25 focus-visible:outline-3 focus-visible:ring-success"},{color:"info",variant:["outline","subtle"],class:"outline-info/25 focus-visible:outline-3 focus-visible:ring-info"},{color:"warning",variant:["outline","subtle"],class:"outline-warning/25 focus-visible:outline-3 focus-visible:ring-warning"},{color:"error",variant:["outline","subtle"],class:"outline-error/25 focus-visible:outline-3 focus-visible:ring-error"},{color:"primary",variant:["soft","ghost"],class:"outline-primary/25 focus-visible:outline-3"},{color:"secondary",variant:["soft","ghost"],class:"outline-secondary/25 focus-visible:outline-3"},{color:"success",variant:["soft","ghost"],class:"outline-success/25 focus-visible:outline-3"},{color:"info",variant:["soft","ghost"],class:"outline-info/25 focus-visible:outline-3"},{color:"warning",variant:["soft","ghost"],class:"outline-warning/25 focus-visible:outline-3"},{color:"error",variant:["soft","ghost"],class:"outline-error/25 focus-visible:outline-3"},{color:"primary",highlight:!0,class:"ring ring-inset ring-primary"},{color:"secondary",highlight:!0,class:"ring ring-inset ring-secondary"},{color:"success",highlight:!0,class:"ring ring-inset ring-success"},{color:"info",highlight:!0,class:"ring ring-inset ring-info"},{color:"warning",highlight:!0,class:"ring ring-inset ring-warning"},{color:"error",highlight:!0,class:"ring ring-inset ring-error"},{color:"neutral",variant:["outline","subtle"],class:"outline-inverted/25 focus-visible:outline-3 focus-visible:ring-inverted"},{color:"neutral",variant:["soft","ghost"],class:"outline-inverted/25 focus-visible:outline-3"},{color:"neutral",highlight:!0,class:"ring ring-inset ring-inverted"},{leading:!0,size:"xs",class:"ps-7"},{leading:!0,size:"sm",class:"ps-8"},{leading:!0,size:"md",class:"ps-9"},{leading:!0,size:"lg",class:"ps-10"},{leading:!0,size:"xl",class:"ps-11"},{trailing:!0,size:"xs",class:"pe-7"},{trailing:!0,size:"sm",class:"pe-8"},{trailing:!0,size:"md",class:"pe-9"},{trailing:!0,size:"lg",class:"pe-10"},{trailing:!0,size:"xl",class:"pe-11"},{loading:!0,leading:!0,class:{leadingIcon:"animate-spin"}},{loading:!0,leading:!1,trailing:!0,class:{trailingIcon:"animate-spin"}},{fixed:!1,size:"xs",class:"md:text-xs"},{fixed:!1,size:"sm",class:"md:text-xs"},{fixed:!1,size:"md",class:"md:text-sm"},{fixed:!1,size:"lg",class:"md:text-sm"}],defaultVariants:{size:"md",color:"primary",variant:"outline"}},V0=["id","value","name","rows","placeholder","disabled","required"],O0=Object.assign({inheritAttrs:!1},{__name:"Textarea",props:{as:{type:null,required:!1},id:{type:String,required:!1},name:{type:String,required:!1},placeholder:{type:String,required:!1},color:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},required:{type:Boolean,required:!1},autofocus:{type:Boolean,required:!1},autofocusDelay:{type:Number,required:!1,default:0},autoresize:{type:Boolean,required:!1},autoresizeDelay:{type:Number,required:!1,default:0},disabled:{type:Boolean,required:!1},rows:{type:Number,required:!1,default:3},maxrows:{type:Number,required:!1,default:0},highlight:{type:Boolean,required:!1},fixed:{type:Boolean,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1},modelModifiers:{type:null,required:!1},class:{type:null,required:!1},ui:{type:Object,required:!1},icon:{type:null,required:!1},avatar:{type:Object,required:!1},leading:{type:Boolean,required:!1},leadingIcon:{type:null,required:!1},trailing:{type:Boolean,required:!1},trailingIcon:{type:null,required:!1},loading:{type:Boolean,required:!1},loadingIcon:{type:null,required:!1}},emits:["update:modelValue","blur","change"],setup(r,{expose:l,emit:e}){const n=r,s=e,u=Jt(),o=Sa("textarea",n),c=Ln(o,"modelValue",s,{defaultValue:o.defaultValue}),g=Ta(),{emitFormFocus:p,emitFormBlur:v,emitFormInput:_,emitFormChange:y,size:k,color:b,id:$,name:C,highlight:w,disabled:S,ariaAttrs:I}=Ia(n,{deferInputValidation:!0}),{isLeading:f,isTrailing:x,leadingIconName:B,trailingIconName:R}=Ma(o),D=T(()=>$t({extend:$t(R0),...g.ui?.textarea||{}})({color:b.value??o.color,variant:o.variant,size:k?.value??o.size,loading:o.loading,highlight:w.value??o.highlight,fixed:o.fixed,autoresize:o.autoresize,leading:f.value||!!o.avatar||!!u.leading,trailing:x.value||!!u.trailing})),A=zt("textareaRef");function M(oe){o.modelModifiers?.trim&&(typeof oe=="string"||oe===null||oe===void 0)&&(oe=oe?.trim()??null),o.modelModifiers?.number&&(oe=ds(oe)),o.modelModifiers?.nullable&&(oe||=null),o.modelModifiers?.optional&&!o.modelModifiers?.nullable&&oe!==null&&(oe||=void 0),c.value=oe,_()}function q(oe){ue(),o.modelModifiers?.lazy||M(oe.target.value)}function Y(oe){const H=oe.target.value;o.modelModifiers?.lazy&&M(H),o.modelModifiers?.trim&&(oe.target.value=H.trim()),y(),s("change",oe)}function G(oe){v(),s("blur",oe)}function Z(){o.autofocus&&A.value?.focus()}function ue(){if(o.autoresize&&A.value){A.value.rows=o.rows;const oe=A.value.style.overflow;A.value.style.overflow="hidden";const H=window.getComputedStyle(A.value),P=Number.parseInt(H.paddingTop),se=Number.parseInt(H.paddingBottom),me=P+se,he=Number.parseInt(H.lineHeight),{scrollHeight:ee}=A.value,te=(ee-me)/he;te>o.rows&&(A.value.rows=o.maxrows?Math.min(te,o.maxrows):te),A.value.style.overflow=oe}}return fe(c,()=>{qe(ue)}),Re(()=>{setTimeout(()=>{Z()},o.autofocusDelay),setTimeout(async()=>{await qe(),ue()},o.autoresizeDelay)}),l({textareaRef:A,autoResize:ue}),(oe,H)=>(i(),W(t(He),{as:t(o).as,"data-slot":"root",class:J(D.value.root({class:[t(o).ui?.root,t(o).class]}))},{default:F(()=>[a("textarea",Ae({id:t($),ref_key:"textareaRef",ref:A,value:t(c),name:t(C),rows:t(o).rows,placeholder:t(o).placeholder,"data-slot":"base",class:D.value.base({class:t(o).ui?.base}),disabled:t(S),required:t(o).required},{...oe.$attrs,...t(I)},{onInput:q,onBlur:G,onChange:Y,onFocus:H[0]||(H[0]=(...P)=>t(p)&&t(p)(...P))}),null,16,V0),ye(oe.$slots,"default",{ui:D.value}),t(f)||t(o).avatar||u.leading?(i(),m("span",{key:0,"data-slot":"leading",class:J(D.value.leading({class:t(o).ui?.leading}))},[ye(oe.$slots,"leading",{ui:D.value},()=>[t(f)&&t(B)?(i(),W(_e,{key:0,name:t(B),"data-slot":"leadingIcon",class:J(D.value.leadingIcon({class:t(o).ui?.leadingIcon}))},null,8,["name","class"])):t(o).avatar?(i(),W(Kt,Ae({key:1,size:t(o).ui?.leadingAvatarSize||D.value.leadingAvatarSize()},t(o).avatar,{"data-slot":"leadingAvatar",class:D.value.leadingAvatar({class:t(o).ui?.leadingAvatar})}),null,16,["size","class"])):E("",!0)])],2)):E("",!0),t(x)||u.trailing?(i(),m("span",{key:1,"data-slot":"trailing",class:J(D.value.trailing({class:t(o).ui?.trailing}))},[ye(oe.$slots,"trailing",{ui:D.value},()=>[t(R)?(i(),W(_e,{key:0,name:t(R),"data-slot":"trailingIcon",class:J(D.value.trailingIcon({class:t(o).ui?.trailingIcon}))},null,8,["name","class"])):E("",!0)])],2)):E("",!0)]),_:3},8,["as","class"]))}}),P0={class:"p-6"},j0={class:"mb-4 flex items-start justify-between gap-3"},N0={class:"min-w-0"},U0={class:"text-lg font-semibold text-gray-900 dark:text-white"},W0={key:0,class:"mt-1 text-xs text-amber-600 dark:text-amber-400"},H0={key:0,class:"flex items-center justify-center py-12"},K0={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},Y0={key:0,class:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary-100 px-1 text-[10px] text-primary-600 dark:bg-primary-900/30 dark:text-primary-400"},G0={class:"max-h-[500px] overflow-y-auto pr-1"},Q0={class:"space-y-5"},J0={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},X0={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},Z0={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},eh={class:"flex flex-wrap gap-2"},th=["disabled","onClick"],ah={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},sh={class:"flex flex-wrap gap-2"},nh=["disabled","onClick"],oh={class:"mt-1 text-[10px] text-gray-400"},lh={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},ih={class:"space-y-2"},rh={key:0,class:"flex items-center gap-2"},uh={class:"space-y-5"},ch={class:"mb-1 text-sm font-medium text-gray-700 dark:text-gray-300"},dh={class:"mb-2.5 text-[10px] text-gray-400"},mh={class:"grid grid-cols-2 gap-1.5"},gh={class:"min-w-0"},ph={class:"truncate text-xs font-medium text-gray-600 dark:text-gray-400"},hh={class:"truncate text-[10px] text-gray-400 dark:text-gray-500"},fh={class:"mb-1 flex items-center justify-between"},vh={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},yh={key:0,class:"flex gap-2"},xh={class:"mb-2.5 text-[10px] text-gray-400"},bh={class:"grid grid-cols-2 gap-1.5"},kh=["checked","disabled","onChange"],_h={class:"min-w-0"},wh={class:"truncate text-xs font-medium text-gray-800 dark:text-gray-200"},$h={class:"truncate text-[10px] text-gray-500 dark:text-gray-400"},Ch={class:"mt-6 flex items-center justify-between"},Sh={class:"flex gap-2"},Ih=ce({__name:"AssistantConfigModal",props:{open:{type:Boolean},assistantId:{},readonly:{type:Boolean},scrollToSection:{}},emits:["update:open","saved","created"],setup(r,{emit:l}){const{t:e}=we(),n=r,s=l,u=ot(),o=Rt(),c=z(!1),g=z(!1),p=z(null),v=z(!1),_=z("basic"),y=T(()=>[{value:"",label:e("ai.assistant.config.chatTypeAll")},{value:"group",label:e("ai.assistant.config.chatTypeGroup")},{value:"private",label:e("ai.assistant.config.chatTypePrivate")}]),k=[{value:"zh",label:"简体中文"},{value:"en",label:"English"},{value:"ja",label:"日本語"}],b=T(()=>o.builtinToolCatalog.filter(H=>H.category==="core").map(H=>({name:H.name,description:e(`ai.assistant.builtinToolDesc.${H.name}`)}))),$=T(()=>o.builtinToolCatalog.filter(H=>H.category==="analysis").map(H=>({name:H.name,description:e(`ai.assistant.builtinToolDesc.${H.name}`)}))),C=z({name:"",systemPrompt:"",presetQuestions:[],applicableChatType:"",supportedLocales:[],allowedBuiltinTools:[]}),w=z(""),S=z(null),I=T(()=>C.value.allowedBuiltinTools.length);Re(async()=>{o.builtinToolCatalog.length===0&&await o.loadBuiltinToolCatalog()}),fe(()=>[n.open,n.assistantId],async([H,P])=>{H&&(_.value="basic",P?(v.value=!1,await x(P)):n.readonly||(v.value=!0,f()),n.scrollToSection==="presetQuestions"&&(await qe(),setTimeout(()=>{S.value?.scrollIntoView({behavior:"smooth",block:"center"})},100)))},{immediate:!0});function f(){p.value={id:"",name:"",systemPrompt:"",presetQuestions:[],allowedBuiltinTools:[],applicableChatTypes:[],supportedLocales:[]},C.value={name:"",systemPrompt:"",presetQuestions:[],applicableChatType:"",supportedLocales:[],allowedBuiltinTools:[]},c.value=!1}async function x(H){c.value=!0;try{p.value=await o.getAssistantConfig(H),p.value&&(C.value={name:p.value.name,systemPrompt:p.value.systemPrompt,presetQuestions:[...p.value.presetQuestions],applicableChatType:p.value.applicableChatTypes?.[0]||"",supportedLocales:[...p.value.supportedLocales||[]],allowedBuiltinTools:[...p.value.allowedBuiltinTools||[]]})}catch(P){console.error("[AssistantConfigModal] Failed to load config:",P),u.fail(e("ai.assistant.toast.loadFailed"),{description:String(P)})}finally{c.value=!1}}async function B(){g.value=!0;try{const H={name:C.value.name,systemPrompt:C.value.systemPrompt,presetQuestions:[...C.value.presetQuestions],applicableChatTypes:C.value.applicableChatType?[C.value.applicableChatType]:[],supportedLocales:[...C.value.supportedLocales],allowedBuiltinTools:[...C.value.allowedBuiltinTools]};if(v.value){const P=await o.createAssistant(H);P.success?(u.success(e("ai.assistant.toast.createSuccess")),s("created",P.id),oe()):u.fail(e("ai.assistant.toast.createFailed"),{description:P.error||e("ai.assistant.toast.unknownError")})}else{if(!n.assistantId)return;const P=await o.updateAssistant(n.assistantId,H);P.success?(u.success(e("ai.assistant.toast.saveSuccess")),s("saved"),oe()):u.fail(e("ai.assistant.toast.saveFailed"),{description:P.error||e("ai.assistant.toast.unknownError")})}}catch(H){console.error("[AssistantConfigModal] Save failed:",H),u.fail(e("ai.assistant.toast.saveFailed"),{description:String(H)})}finally{g.value=!1}}async function R(){if(!(!n.assistantId||!p.value?.builtinId)){g.value=!0;try{const H=await o.resetAssistant(n.assistantId);H.success?(u.success(e("ai.assistant.toast.resetSuccess")),await x(n.assistantId),s("saved")):u.fail(e("ai.assistant.toast.resetFailed"),{description:H.error||e("ai.assistant.toast.unknownError")})}catch(H){u.fail(e("ai.assistant.toast.resetFailed"),{description:String(H)})}finally{g.value=!1}}}function D(){const H=w.value.trim();H&&!C.value.presetQuestions.includes(H)&&(C.value.presetQuestions.push(H),w.value="")}function A(H){C.value.presetQuestions.splice(H,1)}function M(H){const P=C.value.allowedBuiltinTools.indexOf(H);P>=0?C.value.allowedBuiltinTools.splice(P,1):C.value.allowedBuiltinTools.push(H)}function q(H){return C.value.allowedBuiltinTools.includes(H)}function Y(){C.value.allowedBuiltinTools=$.value.map(H=>H.name)}function G(){C.value.allowedBuiltinTools=[]}function Z(H){C.value.applicableChatType=H}function ue(H){const P=C.value.supportedLocales.indexOf(H);P>=0?C.value.supportedLocales.splice(P,1):C.value.supportedLocales.push(H)}function oe(){s("update:open",!1)}return(H,P)=>{const se=Ue,me=_e,he=Ft,ee=O0,te=Xe;return i(),W(te,{open:r.open,ui:{content:"sm:max-w-2xl z-100"},"onUpdate:open":P[5]||(P[5]=N=>s("update:open",N))},{content:F(()=>[a("div",P0,[a("div",j0,[a("div",N0,[a("h2",U0,d(r.readonly?t(e)("ai.assistant.config.viewTitle"):v.value?t(e)("ai.assistant.config.createTitle"):t(e)("ai.assistant.config.editTitle")),1),r.readonly?E("",!0):(i(),m("p",W0,d(t(e)("ai.assistant.config.betaWarning")),1))]),h(se,{icon:"i-heroicons-x-mark",variant:"ghost",size:"sm",class:"shrink-0",onClick:oe})]),c.value?(i(),m("div",H0,[h(me,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):p.value?(i(),m(re,{key:1},[a("div",K0,[a("button",{class:J(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",_.value==="basic"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:P[0]||(P[0]=N=>_.value="basic")},d(t(e)("ai.assistant.config.tabs.basic")),3),a("button",{class:J(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",_.value==="tools"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:P[1]||(P[1]=N=>_.value="tools")},[ie(d(t(e)("ai.assistant.config.tabs.tools"))+" ",1),I.value>0?(i(),m("span",Y0,d(I.value),1)):E("",!0)],2)]),a("div",G0,[Qe(a("div",Q0,[a("div",null,[a("label",J0,d(t(e)("ai.assistant.config.name")),1),h(he,{modelValue:C.value.name,"onUpdate:modelValue":P[2]||(P[2]=N=>C.value.name=N),class:"w-full",disabled:r.readonly},null,8,["modelValue","disabled"])]),a("div",null,[a("label",X0,d(t(e)("ai.assistant.config.systemPrompt")),1),h(ee,{modelValue:C.value.systemPrompt,"onUpdate:modelValue":P[3]||(P[3]=N=>C.value.systemPrompt=N),rows:5,autoresize:"",class:"w-full font-mono text-sm",disabled:r.readonly},null,8,["modelValue","disabled"])]),a("div",null,[a("label",Z0,d(t(e)("ai.assistant.config.chatType")),1),a("div",eh,[(i(!0),m(re,null,ve(y.value,N=>(i(),m("button",{key:N.value,type:"button",class:J(["rounded-lg border px-3 py-1.5 text-xs transition-colors",C.value.applicableChatType===N.value?"border-primary-500 bg-primary-50 text-primary-700 dark:border-primary-400 dark:bg-primary-950/30 dark:text-primary-300":"border-gray-200 text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:text-gray-400"]),disabled:r.readonly,onClick:de=>Z(N.value)},d(N.label),11,th))),128))])]),a("div",null,[a("label",ah,d(t(e)("ai.assistant.config.locale")),1),a("div",sh,[(i(),m(re,null,ve(k,N=>a("button",{key:N.value,type:"button",class:J(["rounded-lg border px-3 py-1.5 text-xs transition-colors",C.value.supportedLocales.includes(N.value)?"border-primary-500 bg-primary-50 text-primary-700 dark:border-primary-400 dark:bg-primary-950/30 dark:text-primary-300":"border-gray-200 text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:text-gray-400"]),disabled:r.readonly,onClick:de=>ue(N.value)},d(N.label),11,nh)),64))]),a("p",oh,d(t(e)("ai.assistant.config.localeHint")),1)]),a("div",{ref_key:"presetQuestionsRef",ref:S},[a("label",lh,d(t(e)("ai.assistant.config.presetQuestions")),1),a("div",ih,[(i(!0),m(re,null,ve(C.value.presetQuestions,(N,de)=>(i(),m("div",{key:de,class:"flex items-center gap-2"},[h(he,{modelValue:C.value.presetQuestions[de],"onUpdate:modelValue":be=>C.value.presetQuestions[de]=be,class:"min-w-0 flex-1",size:"sm",disabled:r.readonly},null,8,["modelValue","onUpdate:modelValue","disabled"]),r.readonly?E("",!0):(i(),W(se,{key:0,color:"error",variant:"ghost",icon:"i-heroicons-trash",size:"xs",class:"shrink-0",onClick:be=>A(de)},null,8,["onClick"]))]))),128)),r.readonly?E("",!0):(i(),m("div",rh,[h(he,{modelValue:w.value,"onUpdate:modelValue":P[4]||(P[4]=N=>w.value=N),placeholder:t(e)("ai.assistant.config.addQuestion"),class:"min-w-0 flex-1",size:"sm",onKeyup:Ge(D,["enter"])},null,8,["modelValue","placeholder"]),h(se,{color:"primary",variant:"soft",icon:"i-heroicons-plus",size:"xs",class:"shrink-0",onClick:D})]))])],512)],512),[[yt,_.value==="basic"]]),Qe(a("div",uh,[a("div",null,[a("h3",ch,d(t(e)("ai.assistant.config.coreTools")),1),a("p",dh,d(t(e)("ai.assistant.config.coreToolsHint")),1),a("div",mh,[(i(!0),m(re,null,ve(b.value,N=>(i(),m("label",{key:N.name,class:"flex items-start gap-2 rounded-md border border-gray-200 bg-gray-50/50 px-2.5 py-2 opacity-70 dark:border-gray-700 dark:bg-gray-800/30"},[P[6]||(P[6]=a("input",{type:"checkbox",checked:"",disabled:"",class:"mt-0.5 h-3.5 w-3.5 shrink-0 rounded border-gray-300 text-gray-400"},null,-1)),a("div",gh,[a("div",ph,d(N.name),1),a("div",hh,d(N.description),1)])]))),128))])]),a("div",null,[a("div",fh,[a("h3",vh,d(t(e)("ai.assistant.config.analysisTools")),1),r.readonly?E("",!0):(i(),m("div",yh,[a("button",{class:"text-[10px] text-primary-500 hover:text-primary-600",onClick:Y},d(t(e)("ai.assistant.config.selectAll")),1),P[7]||(P[7]=a("span",{class:"text-[10px] text-gray-300 dark:text-gray-600"},"|",-1)),a("button",{class:"text-[10px] text-primary-500 hover:text-primary-600",onClick:G},d(t(e)("ai.assistant.config.deselectAll")),1)]))]),a("p",xh,d(t(e)("ai.assistant.config.analysisToolsHint")),1),a("div",bh,[(i(!0),m(re,null,ve($.value,N=>(i(),m("label",{key:N.name,class:J(["flex cursor-pointer items-start gap-2 rounded-md border px-2.5 py-2 transition-colors",q(N.name)?"border-primary-200 bg-primary-50/50 dark:border-primary-800 dark:bg-primary-950/20":"border-gray-200 dark:border-gray-700"])},[a("input",{type:"checkbox",checked:q(N.name),disabled:r.readonly,class:"mt-0.5 h-3.5 w-3.5 shrink-0 rounded border-gray-300 text-primary-600 focus:ring-primary-500",onChange:de=>M(N.name)},null,40,kh),a("div",_h,[a("div",wh,d(N.name),1),a("div",$h,d(N.description),1)])],2))),128))])])],512),[[yt,_.value==="tools"]])]),a("div",Ch,[a("div",null,[!r.readonly&&!v.value&&p.value?.builtinId?(i(),W(se,{key:0,variant:"outline",color:"warning",loading:g.value,onClick:R},{default:F(()=>[ie(d(t(e)("ai.assistant.config.resetDefault")),1)]),_:1},8,["loading"])):E("",!0)]),a("div",Sh,[h(se,{variant:"ghost",onClick:oe},{default:F(()=>[ie(d(r.readonly?t(e)("common.close"):t(e)("common.cancel")),1)]),_:1}),r.readonly?E("",!0):(i(),W(se,{key:0,color:"primary",loading:g.value,onClick:B},{default:F(()=>[ie(d(v.value?t(e)("ai.assistant.config.create"):t(e)("common.save")),1)]),_:1},8,["loading"]))])])],64)):E("",!0)])]),_:1},8,["open"])}}}),Th={class:"p-6"},Mh={class:"mb-4 flex items-center justify-between"},zh={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},Ah={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},qh={key:0,class:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary-100 px-1 text-[10px] text-primary-600 dark:bg-primary-900/30 dark:text-primary-400"},Lh={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},Dh={class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},Eh={class:"min-w-0 flex-1"},Bh={class:"flex items-center gap-2"},Fh={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Rh={key:0,class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},Vh={key:1,class:"inline-flex shrink-0 items-center rounded-full bg-green-100 px-2 py-0.5 text-[10px] font-medium text-green-700 dark:bg-green-900/30 dark:text-green-400"},Oh={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},Ph={class:"flex shrink-0 items-center gap-1.5"},jh=["title","onClick"],Nh=["title","onClick"],Uh=["title","onClick"],Wh={key:0,class:"py-12 text-center text-sm text-gray-400"},Hh={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},Kh={key:0,class:"py-12 text-center text-sm text-gray-400"},Yh={key:1,class:"py-12 text-center"},Gh={class:"text-sm text-gray-500 dark:text-gray-400"},Qh={key:2,class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},Jh={class:"min-w-0 flex-1"},Xh={class:"flex items-center gap-2"},Zh={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},ef={key:0,class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},tf={key:1,class:"inline-flex shrink-0 items-center rounded-full bg-green-100 px-2 py-0.5 text-[10px] font-medium text-green-700 dark:bg-green-900/30 dark:text-green-400"},af={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},sf={class:"flex shrink-0 items-center gap-2"},nf=["disabled","onClick"],of={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},lf=["disabled","onClick"],rf=["title","onClick"],uf={key:3,class:"py-12 text-center text-sm text-gray-400"},cf=ce({__name:"AssistantMarketModal",props:{open:{type:Boolean}},emits:["update:open","configure","view-config","create"],setup(r,{emit:l}){const{t:e,locale:n}=we(),s=ot(),u=r,o=l,c=Rt(),{assistants:g,cloudCatalogWithStatus:p,cloudLoading:v,cloudError:_}=ct(c),y=z("local"),k=T(()=>{const A=n.value;return[...g.value].filter(M=>!M.supportedLocales?.length||M.supportedLocales.some(q=>A.startsWith(q))).sort((M,q)=>M.name.localeCompare(q.name))}),b=T(()=>[...p.value].sort((A,M)=>A.name.localeCompare(M.name))),$=z(new Set);fe(()=>[u.open,y.value],([A,M])=>{A&&M==="market"&&c.fetchCloudCatalog(n.value)},{immediate:!0});function C(A){o("configure",A)}async function w(A){Ot(A)||await c.deleteAssistant(A)}async function S(A){await c.duplicateAssistant(A)}function I(){o("create")}async function f(A){if(!$.value.has(A.id)){$.value=new Set([...$.value,A.id]);try{const M=await c.importFromCloud(A);M.success?s.success(e("ai.assistant.market.importSuccess")):s.fail(e("ai.assistant.market.importFailed"),{description:M.error})}finally{const M=new Set($.value);M.delete(A.id),$.value=M}}}async function x(A){if(!$.value.has(A.id)){$.value=new Set([...$.value,A.id]);try{const M=await c.deleteAssistant(A.id);if(!M.success){s.fail(e("ai.assistant.market.importFailed"),{description:M.error});return}const q=await c.importFromCloud(A);q.success?s.success(e("ai.assistant.market.importSuccess")):s.fail(e("ai.assistant.market.importFailed"),{description:q.error})}finally{const M=new Set($.value);M.delete(A.id),$.value=M}}}function B(A){o("view-config",A)}function R(){c.fetchCloudCatalog(n.value)}function D(A){return A?.length?A.map(q=>e(q==="group"?"ai.assistant.config.chatTypeGroup":"ai.assistant.config.chatTypePrivate")).join(" / "):null}return(A,M)=>{const q=_e,Y=Xe;return i(),W(Y,{open:r.open,ui:{content:"sm:max-w-xl z-50"},"onUpdate:open":M[3]||(M[3]=G=>o("update:open",G))},{content:F(()=>[a("div",Th,[a("div",Mh,[a("h2",zh,d(t(e)("ai.assistant.market.title")),1),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:M[0]||(M[0]=G=>o("update:open",!1))},[h(q,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),a("div",Ah,[a("button",{class:J(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",y.value==="local"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:M[1]||(M[1]=G=>y.value="local")},[ie(d(t(e)("ai.assistant.market.tabs.local"))+" ",1),k.value.length?(i(),m("span",qh,d(k.value.length),1)):E("",!0)],2),a("button",{class:J(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",y.value==="market"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:M[2]||(M[2]=G=>y.value="market")},d(t(e)("ai.assistant.market.tabs.market")),3)]),Qe(a("div",null,[a("p",Lh,d(t(e)("ai.assistant.market.localHint")),1),a("div",Dh,[(i(!0),m(re,null,ve(k.value,G=>(i(),m("div",{key:G.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[a("div",Eh,[a("div",Bh,[a("h3",Fh,d(G.name),1),D(G.applicableChatTypes)?(i(),m("span",Rh,d(D(G.applicableChatTypes)),1)):E("",!0),t(Ot)(G.id)?(i(),m("span",Vh,d(t(e)("ai.assistant.market.default")),1)):E("",!0)]),a("p",Oh,d(G.systemPrompt),1)]),a("div",Ph,[a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:t(e)("common.edit"),onClick:Oe(Z=>C(G.id),["stop"])},[h(q,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})],8,jh),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:t(e)("ai.assistant.market.duplicate"),onClick:Oe(Z=>S(G.id),["stop"])},[h(q,{name:"i-heroicons-document-duplicate",class:"h-4 w-4"})],8,Nh),t(Ot)(G.id)?E("",!0):(i(),m("button",{key:0,class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500 dark:hover:bg-red-900/20 dark:hover:text-red-400",title:t(e)("common.delete"),onClick:Oe(Z=>w(G.id),["stop"])},[h(q,{name:"i-heroicons-trash",class:"h-4 w-4"})],8,Uh))])]))),128))]),a("button",{type:"button",class:"mt-3 flex w-full items-center justify-center gap-1.5 rounded-xl border-2 border-dashed border-gray-300 py-4 text-sm text-gray-500 transition-colors hover:border-primary-400 hover:text-primary-600 dark:border-gray-600 dark:text-gray-400 dark:hover:border-primary-500 dark:hover:text-primary-400",onClick:I},[h(q,{name:"i-heroicons-plus",class:"h-4 w-4"}),ie(" "+d(t(e)("ai.assistant.market.addAssistant")),1)]),k.value.length===0?(i(),m("div",Wh,d(t(e)("ai.assistant.market.noLocal")),1)):E("",!0)],512),[[yt,y.value==="local"]]),Qe(a("div",null,[a("p",Hh,d(t(e)("ai.assistant.market.marketHint")),1),t(v)?(i(),m("div",Kh,d(t(e)("ai.assistant.market.loading")),1)):t(_)?(i(),m("div",Yh,[a("p",Gh,d(t(e)("ai.assistant.market.loadFailed")),1),a("button",{type:"button",class:"mt-3 rounded-lg bg-primary-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-600",onClick:R},d(t(e)("ai.assistant.market.retry")),1)])):(i(),m("div",Qh,[(i(!0),m(re,null,ve(b.value,G=>(i(),m("div",{key:G.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[a("div",Jh,[a("div",Xh,[a("h3",Zh,d(G.name),1),D(G.applicableChatTypes)?(i(),m("span",ef,d(D(G.applicableChatTypes)),1)):E("",!0),t(Ot)(G.id)?(i(),m("span",tf,d(t(e)("ai.assistant.market.default")),1)):E("",!0)]),a("p",af,d(G.description),1)]),a("div",sf,[G.imported?(i(),m(re,{key:1},[a("span",of,d(t(e)("ai.assistant.market.imported")),1),a("button",{class:"rounded-lg px-3 py-1.5 text-xs font-medium text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-300 disabled:opacity-50",disabled:$.value.has(G.id),onClick:Z=>x(G)},d($.value.has(G.id)?t(e)("ai.assistant.market.importing"):t(e)("ai.assistant.market.reimport")),9,lf)],64)):(i(),m("button",{key:0,class:"rounded-lg bg-primary-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50",disabled:$.value.has(G.id),onClick:Z=>f(G)},d($.value.has(G.id)?t(e)("ai.assistant.market.importing"):t(e)("ai.assistant.market.import")),9,nf)),G.imported?(i(),m("button",{key:2,class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:t(e)("ai.assistant.market.viewConfig"),onClick:Oe(Z=>B(G.id),["stop"])},[h(q,{name:"i-heroicons-eye",class:"h-4 w-4"})],8,rf)):E("",!0)])]))),128))])),!t(v)&&!t(_)&&b.value.length===0?(i(),m("div",uf,d(t(e)("ai.assistant.market.noCatalog")),1)):E("",!0)],512),[[yt,y.value==="market"]])])]),_:1},8,["open"])}}}),df={class:"p-5"},mf={class:"flex items-start gap-3"},gf={class:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-primary-50 text-primary-600 dark:bg-primary-950/40 dark:text-primary-400"},pf={class:"min-w-0"},hf={class:"font-semibold text-gray-900 dark:text-white"},ff={class:"mt-1.5 text-sm leading-6 text-gray-600 dark:text-gray-400"},vf={class:"mt-4 rounded-lg bg-gray-50 px-3 py-2.5 dark:bg-gray-800/70"},yf={class:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300"},xf={class:"truncate"},bf={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},kf={class:"mt-5 flex justify-end gap-2"},_f=ce({__name:"AssistantUpgradeModal",props:{open:{type:Boolean},backupName:{},upgrading:{type:Boolean},skipping:{type:Boolean}},emits:["skip","confirm"],setup(r,{emit:l}){const e=l,{t:n}=we();return(s,u)=>{const o=_e,c=Ue,g=Xe;return i(),W(g,{open:r.open,dismissible:!1,ui:{content:"sm:max-w-md z-50",overlay:"z-40"}},{content:F(()=>[a("div",df,[a("div",mf,[a("div",gf,[h(o,{name:"i-lucide-sparkles",class:"h-5 w-5"})]),a("div",pf,[a("h3",hf,d(t(n)("ai.assistant.upgrade.title")),1),a("p",ff,d(t(n)("ai.assistant.upgrade.message",{backupName:r.backupName})),1)])]),a("div",vf,[a("div",yf,[h(o,{name:"i-lucide-copy-check",class:"h-4 w-4 shrink-0 text-gray-400"}),a("span",xf,d(r.backupName),1)])]),a("p",bf,d(t(n)("ai.assistant.upgrade.skipHint")),1),a("div",kf,[h(c,{variant:"soft",loading:r.skipping,disabled:r.upgrading,onClick:u[0]||(u[0]=p=>e("skip"))},{default:F(()=>[ie(d(t(n)("ai.assistant.upgrade.skip")),1)]),_:1},8,["loading","disabled"]),h(c,{color:"primary",loading:r.upgrading,disabled:r.skipping,onClick:u[1]||(u[1]=p=>e("confirm"))},{default:F(()=>[ie(d(t(n)("ai.assistant.upgrade.confirm")),1)]),_:1},8,["loading","disabled"])])])]),_:1},8,["open"])}}}),wf={class:"p-6"},$f={class:"mb-4 flex items-center justify-between"},Cf={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},Sf={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},If={key:0,class:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary-100 px-1 text-[10px] text-primary-600 dark:bg-primary-900/30 dark:text-primary-400"},Tf={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},Mf={class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},zf={class:"min-w-0 flex-1"},Af={class:"flex items-center gap-2"},qf={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Lf={class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},Df={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},Ef={key:0,class:"mt-1.5 flex flex-wrap gap-1"},Bf={class:"flex shrink-0 items-center gap-1.5"},Ff=["title","onClick"],Rf=["title","onClick"],Vf={key:0,class:"py-12 text-center text-sm text-gray-400"},Of={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},Pf={key:0,class:"py-12 text-center text-sm text-gray-400"},jf={key:1,class:"py-12 text-center"},Nf={class:"text-sm text-gray-500 dark:text-gray-400"},Uf={key:2,class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},Wf={class:"min-w-0 flex-1"},Hf={class:"flex items-center gap-2"},Kf={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Yf={class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},Gf={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},Qf={key:0,class:"mt-1.5 flex flex-wrap gap-1"},Jf={class:"flex shrink-0 items-center gap-2"},Xf=["disabled","onClick"],Zf={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},ev=["disabled","onClick"],tv={key:3,class:"py-12 text-center text-sm text-gray-400"},av=ce({__name:"SkillMarketModal",props:{open:{type:Boolean}},emits:["update:open","configure","create"],setup(r,{emit:l}){const{t:e,locale:n}=we(),s=ot(),u=r,o=l,c=It(),{skills:g,cloudCatalogWithStatus:p,cloudLoading:v,cloudError:_}=ct(c),y=z("local"),k=z(new Set);Re(()=>{c.setFilterContext("group",n.value)}),fe(()=>[u.open,y.value],([R,D])=>{R&&D==="market"&&(c.setFilterContext("group",n.value),c.fetchCloudCatalog())},{immediate:!0});const b=T(()=>[...g.value].sort((R,D)=>R.name.localeCompare(D.name))),$=T(()=>[...p.value].sort((R,D)=>R.name.localeCompare(D.name)));function C(R){return e(R==="group"?"ai.skill.config.chatScopeGroup":R==="private"?"ai.skill.config.chatScopePrivate":"ai.skill.config.chatScopeAll")}function w(R){o("configure",R)}async function S(R){await c.deleteSkill(R)}function I(){o("create")}async function f(R){if(!k.value.has(R.id)){k.value=new Set([...k.value,R.id]);try{const D=await c.importFromCloud(R);D.success?s.success(e("ai.skill.market.importSuccess")):s.fail(e("ai.skill.market.importFailed"),{description:D.error})}finally{const D=new Set(k.value);D.delete(R.id),k.value=D}}}async function x(R){if(!k.value.has(R.id)){k.value=new Set([...k.value,R.id]);try{const D=await c.deleteSkill(R.id);if(!D.success){s.fail(e("ai.skill.market.importFailed"),{description:D.error});return}const A=await c.importFromCloud(R);A.success?s.success(e("ai.skill.market.importSuccess")):s.fail(e("ai.skill.market.importFailed"),{description:A.error})}finally{const D=new Set(k.value);D.delete(R.id),k.value=D}}}function B(){c.fetchCloudCatalog()}return(R,D)=>{const A=_e,M=Xe;return i(),W(M,{open:r.open,ui:{content:"sm:max-w-xl z-50"},"onUpdate:open":D[3]||(D[3]=q=>o("update:open",q))},{content:F(()=>[a("div",wf,[a("div",$f,[a("h2",Cf,d(t(e)("ai.skill.market.title")),1),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:D[0]||(D[0]=q=>o("update:open",!1))},[h(A,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),a("div",Sf,[a("button",{class:J(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",y.value==="local"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:D[1]||(D[1]=q=>y.value="local")},[ie(d(t(e)("ai.skill.market.tabs.local"))+" ",1),t(g).length?(i(),m("span",If,d(t(g).length),1)):E("",!0)],2),a("button",{class:J(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",y.value==="market"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:D[2]||(D[2]=q=>y.value="market")},d(t(e)("ai.skill.market.tabs.market")),3)]),Qe(a("div",null,[a("p",Tf,d(t(e)("ai.skill.market.localHint")),1),a("div",Mf,[(i(!0),m(re,null,ve(b.value,q=>(i(),m("div",{key:q.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[a("div",zf,[a("div",Af,[a("h3",qf,d(q.name),1),a("span",Lf,d(C(q.chatScope)),1)]),a("p",Df,d(q.description),1),q.tags.length?(i(),m("div",Ef,[(i(!0),m(re,null,ve(q.tags,Y=>(i(),m("span",{key:Y,class:"rounded-full bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-500 dark:bg-gray-700 dark:text-gray-400"},d(Y),1))),128))])):E("",!0)]),a("div",Bf,[a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:t(e)("common.edit"),onClick:Oe(Y=>w(q.id),["stop"])},[h(A,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})],8,Ff),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500 dark:hover:bg-red-900/20 dark:hover:text-red-400",title:t(e)("common.delete"),onClick:Oe(Y=>S(q.id),["stop"])},[h(A,{name:"i-heroicons-trash",class:"h-4 w-4"})],8,Rf)])]))),128))]),a("button",{type:"button",class:"mt-3 flex w-full items-center justify-center gap-1.5 rounded-xl border-2 border-dashed border-gray-300 py-4 text-sm text-gray-500 transition-colors hover:border-primary-400 hover:text-primary-600 dark:border-gray-600 dark:text-gray-400 dark:hover:border-primary-500 dark:hover:text-primary-400",onClick:I},[h(A,{name:"i-heroicons-plus",class:"h-4 w-4"}),ie(" "+d(t(e)("ai.skill.market.addSkill")),1)]),b.value.length===0?(i(),m("div",Vf,d(t(e)("ai.skill.market.noLocal")),1)):E("",!0)],512),[[yt,y.value==="local"]]),Qe(a("div",null,[a("p",Of,d(t(e)("ai.skill.market.marketHint")),1),t(v)?(i(),m("div",Pf,d(t(e)("ai.skill.market.loading")),1)):t(_)?(i(),m("div",jf,[a("p",Nf,d(t(e)("ai.skill.market.loadFailed")),1),a("button",{type:"button",class:"mt-3 rounded-lg bg-primary-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-600",onClick:B},d(t(e)("ai.skill.market.retry")),1)])):(i(),m("div",Uf,[(i(!0),m(re,null,ve($.value,q=>(i(),m("div",{key:q.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[a("div",Wf,[a("div",Hf,[a("h3",Kf,d(q.name),1),a("span",Yf,d(C(q.chatScope)),1)]),a("p",Gf,d(q.description),1),q.tags?.length?(i(),m("div",Qf,[(i(!0),m(re,null,ve(q.tags,Y=>(i(),m("span",{key:Y,class:"rounded-full bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-500 dark:bg-gray-700 dark:text-gray-400"},d(Y),1))),128))])):E("",!0)]),a("div",Jf,[q.imported?(i(),m(re,{key:1},[a("span",Zf,d(t(e)("ai.skill.market.imported")),1),a("button",{class:"rounded-lg px-3 py-1.5 text-xs font-medium text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-300 disabled:opacity-50",disabled:k.value.has(q.id),onClick:Y=>x(q)},d(k.value.has(q.id)?t(e)("ai.skill.market.importing"):t(e)("ai.skill.market.reimport")),9,ev)],64)):(i(),m("button",{key:0,class:"rounded-lg bg-primary-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50",disabled:k.value.has(q.id),onClick:Y=>f(q)},d(k.value.has(q.id)?t(e)("ai.skill.market.importing"):t(e)("ai.skill.market.import")),9,Xf))])]))),128))])),!t(v)&&!t(_)&&$.value.length===0?(i(),m("div",tv,d(t(e)("ai.skill.market.noCatalog")),1)):E("",!0)],512),[[yt,y.value==="market"]])])]),_:1},8,["open"])}}}),sv={class:"p-6"},nv={class:"mb-4 flex items-center justify-between"},ov={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},lv={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},iv={key:0,class:"flex h-64 items-center justify-center text-gray-400"},rv={class:"mt-4 flex justify-end gap-2"},uv=["disabled"],cv=`---
102
- name: ""
103
- description: ""
104
- tags: []
105
- chatScope: all
106
- tools: []
107
- ---
108
-
109
- `,dv=ce({__name:"SkillConfigModal",props:{open:{type:Boolean},skillId:{}},emits:["update:open","saved","created"],setup(r,{emit:l}){const{t:e}=we(),n=r,s=l,u=It(),o=z(""),c=z(!1),g=z(!1),p=z(!1);fe(()=>[n.open,n.skillId],async([_,y])=>{if(_){if(!y){p.value=!0,o.value=cv;return}p.value=!1,c.value=!0;try{const k=await u.getSkillConfig(y);if(k){const b=["---",`name: "${k.name}"`,`description: "${k.description}"`,`tags: [${k.tags.map($=>`"${$}"`).join(", ")}]`,`chatScope: ${k.chatScope}`,k.tools.length?`tools: [${k.tools.map($=>`"${$}"`).join(", ")}]`:"tools: []",k.builtinId?`builtinId: ${k.builtinId}`:"","---","",k.prompt].filter(Boolean).join(`
110
- `);o.value=b}}finally{c.value=!1}}},{immediate:!0});async function v(){if(o.value.trim()){g.value=!0;try{if(p.value){const _=await u.createSkill(o.value);_.success&&_.id&&(s("created",_.id),s("update:open",!1))}else n.skillId&&(await u.updateSkill(n.skillId,o.value)).success&&(s("saved"),s("update:open",!1))}finally{g.value=!1}}}return(_,y)=>{const k=_e,b=Xe;return i(),W(b,{open:r.open,ui:{content:"sm:max-w-2xl z-50"},"onUpdate:open":y[3]||(y[3]=$=>s("update:open",$))},{content:F(()=>[a("div",sv,[a("div",nv,[a("h2",ov,d(p.value?t(e)("ai.skill.config.createTitle"):t(e)("ai.skill.config.editTitle")),1),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:y[0]||(y[0]=$=>s("update:open",!1))},[h(k,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),a("p",lv,d(t(e)("ai.skill.config.rawEditorHint")),1),c.value?(i(),m("div",iv,[h(k,{name:"i-heroicons-arrow-path",class:"mr-2 h-5 w-5 animate-spin"})])):Qe((i(),m("textarea",{key:1,"onUpdate:modelValue":y[1]||(y[1]=$=>o.value=$),class:"h-[400px] w-full resize-none rounded-lg border border-gray-300 bg-gray-50 p-3 font-mono text-xs text-gray-900 focus:border-primary-500 focus:ring-1 focus:ring-primary-500 dark:border-gray-600 dark:bg-page-dark dark:text-gray-100",spellcheck:"false"},null,512)),[[ft,o.value]]),a("div",rv,[a("button",{class:"rounded-lg px-4 py-2 text-sm text-gray-500 transition-colors hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800",onClick:y[2]||(y[2]=$=>s("update:open",!1))},d(t(e)("common.cancel")),1),a("button",{class:"rounded-lg bg-primary-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50",disabled:g.value||!o.value.trim(),onClick:v},d(p.value?t(e)("ai.skill.config.create"):t(e)("ai.skill.config.save")),9,uv)])])]),_:1},8,["open"])}}}),mv={key:0,class:"relative"},gv={class:"relative flex flex-nowrap gap-2"},pv=["disabled"],hv=["disabled"],fv={class:"inline-flex items-center gap-1"},vv={key:0,class:"absolute left-0 bottom-full z-20 mb-2 w-[320px] max-w-[calc(100vw-3rem)]"},yv={class:"mb-1.5 flex justify-start"},xv={class:"flex flex-wrap gap-2"},bv=["disabled","onClick"],ca="rounded-full ring-1 ring-inset ring-gray-200/80 bg-white/60 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.05)] backdrop-blur-md px-3 py-1.5 text-xs text-gray-600 transition-all duration-300 hover:-translate-y-[1px] hover:ring-primary-300 hover:bg-white/90 hover:text-primary-600 hover:shadow-[0_4px_12px_-2px_rgba(0,0,0,0.08)] disabled:cursor-not-allowed disabled:opacity-50 dark:ring-gray-700/60 dark:bg-gray-800/60 dark:text-gray-300 dark:hover:ring-primary-500/50 dark:hover:bg-gray-800/90 dark:hover:text-primary-400",kv=ce({__name:"PresetQuestions",props:{questions:{},disabled:{type:Boolean},leadingActionLabel:{}},emits:["select","leadingAction","editQuestions"],setup(r,{emit:l}){const{t:e}=we(),n=r,s=l,u=z(!1);let o=null;function c(_){u.value=!1,s("select",_)}function g(){n.disabled||n.questions.length===0||(o&&(clearTimeout(o),o=null),u.value=!0)}function p(){o=setTimeout(()=>{u.value=!1},150)}function v(){u.value=!1,s("editQuestions")}return Bt(()=>{o&&clearTimeout(o)}),(_,y)=>{const k=_e;return r.leadingActionLabel||r.questions.length>0?(i(),m("div",mv,[a("div",gv,[r.leadingActionLabel?(i(),m("button",{key:0,class:J(ca),disabled:n.disabled,onClick:y[0]||(y[0]=b=>s("leadingAction"))},d(r.leadingActionLabel),9,pv)):E("",!0),r.questions.length>0?(i(),m("div",{key:1,class:"relative shrink-0",onMouseenter:g,onMouseleave:p},[a("button",{class:J([ca,u.value?"ring-primary-300 bg-white/90 text-primary-600 dark:ring-primary-500/50 dark:bg-gray-800/90 dark:text-primary-400":""]),disabled:n.disabled},[a("span",fv,[h(k,{name:"i-heroicons-chat-bubble-left-ellipsis",class:"h-3.5 w-3.5"}),ie(" "+d(t(e)("ai.chat.input.quickAsk")),1)])],10,hv),h(vt,{"enter-active-class":"transition duration-200 ease-out","enter-from-class":"opacity-0 translate-y-2","enter-to-class":"opacity-100 translate-y-0","leave-active-class":"transition duration-150 ease-in","leave-from-class":"opacity-100 translate-y-0","leave-to-class":"opacity-0 translate-y-2"},{default:F(()=>[u.value?(i(),m("div",vv,[a("div",yv,[a("button",{class:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] text-gray-400 transition-colors hover:text-primary-500 dark:text-gray-500 dark:hover:text-primary-400",onClick:v},[h(k,{name:"i-heroicons-pencil-square",class:"h-3 w-3"}),ie(" "+d(t(e)("ai.chat.input.editQuickAsk")),1)])]),a("div",xv,[(i(!0),m(re,null,ve(r.questions,(b,$)=>(i(),m("button",{key:$,class:J(ca),disabled:n.disabled,onClick:C=>c(b)},d(b),9,bv))),128))])])):E("",!0)]),_:1})],32)):E("",!0)])])):E("",!0)}}}),_v=30;function wv(r,l){const e=z(null),n=z(!0),s=z(!1);function u(p=!1){setTimeout(()=>{e.value&&(p||n.value)&&(e.value.scrollTop=e.value.scrollHeight,n.value=!0,s.value=!1)},100)}function o(p){p.deltaY<0&&l.value&&(n.value=!1,s.value=!0)}function c(){if(!e.value)return;const{scrollTop:p,scrollHeight:v,clientHeight:_}=e.value;v-p-_<_v&&(n.value=!0,s.value=!1)}function g(){u(!0)}return fe(()=>{const p=r.value[r.value.length-1];return[r.value.length,p?.content,p?.contentBlocks?.length]},()=>u()),Re(()=>{e.value&&(e.value.addEventListener("scroll",c),e.value.addEventListener("wheel",o,{passive:!0})),r.value.length>0&&u(!0)}),Bt(()=>{e.value&&(e.value.removeEventListener("scroll",c),e.value.removeEventListener("wheel",o))}),{messagesContainer:e,showScrollToBottom:s,scrollToBottom:u,handleScrollToBottom:g}}function $v(){const r=Rt(),l=It(),e=z(!1),n=z(null),s=z(!1),u=z(!1),o=z(!1),c=z(!1),g=z(null);function p(x){n.value=x,s.value=!1,e.value=!0}function v(){u.value=!0}function _(x){n.value=x,s.value=!1,e.value=!0}function y(x){n.value=x,s.value=!0,e.value=!0}function k(){n.value=null,s.value=!1,e.value=!0}async function b(x){await r.loadAssistants(),await r.loadBuiltinCatalog()}async function $(){await r.loadAssistants()}function C(){o.value=!0}function w(x){g.value=x,c.value=!0}function S(){g.value=null,c.value=!0}async function I(){await l.loadSkills()}async function f(x){await l.loadSkills(),await l.loadBuiltinCatalog()}return{configModalVisible:e,configModalAssistantId:n,configModalReadonly:s,marketModalVisible:u,handleConfigureAssistant:p,handleOpenMarket:v,handleMarketConfigure:_,handleMarketViewConfig:y,handleCreateAssistant:k,handleAssistantCreated:b,handleAssistantConfigSaved:$,skillMarketModalVisible:o,skillConfigModalVisible:c,skillConfigModalSkillId:g,handleOpenSkillMarket:C,handleSkillMarketConfigure:w,handleCreateSkill:S,handleSkillConfigSaved:I,handleSkillCreated:f}}function Cv(r){const l=[];let e=null;for(const n of r)n.role==="user"?(e&&l.push({user:e,assistant:null,standalone:null,id:e.id}),e=n):n.role==="assistant"?(l.push({user:e,assistant:n,standalone:null,id:e?.id||n.id}),e=null):(e&&(l.push({user:e,assistant:null,standalone:null,id:e.id}),e=null),l.push({user:null,assistant:null,standalone:n,id:n.id}));return e&&l.push({user:e,assistant:null,standalone:null,id:e.id}),l}const Sv={class:"main-content flex h-full overflow-hidden"},Iv={class:"flex h-full flex-1 overflow-hidden"},Tv={class:"flex h-full flex-1"},Mv={class:"relative flex min-w-[480px] flex-1 flex-col overflow-hidden"},zv={key:0,class:"flex items-center gap-1.5 px-3 py-1.5"},Av=["disabled"],qv={key:0,class:"flex w-full flex-col items-center justify-center animate-fade-in"},Lv={key:0,class:"mb-3 text-center text-2xl font-semibold tracking-tight text-gray-800 dark:text-gray-100"},Dv={class:"text-primary-600 dark:text-primary-400"},Ev={key:1,class:"relative mb-8 w-full max-w-lg"},Bv={class:"flex w-full justify-center"},Fv={key:1,class:"qa-pair space-y-6 pb-4"},Rv={key:1,class:"px-4 pb-2"},Vv={class:"mx-auto max-w-[740px]"},Ov={class:"px-4 pb-2"},Pv={class:"mx-auto max-w-[740px]"},jv={key:0,class:"w-80 shrink-0 border-l border-gray-200 bg-gray-50/50 p-4 dark:border-gray-800 dark:bg-page-dark/50"},Nv=ce({__name:"ChatExplorer",props:{sessionId:{},sessionName:{},timeFilter:{},chatType:{}},setup(r,{expose:l}){const{t:e}=we(),n=ot(),s=za(),u=Rt(),o=It(),c=r,{messages:g,sourceMessages:p,currentKeywords:v,isLoadingSource:_,isAIThinking:y,currentAIChatId:k,currentToolStatus:b,toolsUsedInCurrentRound:$,sessionTokenUsage:C,agentStatus:w,selectedAssistantId:S,sendMessage:I,editMessageAndRegenerate:f,loadAIChat:x,startNewAIChat:B,loadMoreSourceMessages:R,updateMaxMessages:D,stopGeneration:A,selectAssistantForSession:M}=Nl(c.sessionId,c.sessionName,c.timeFilter,c.chatType??"group",s.locale),q=wv(g,y),{showScrollToBottom:Y,scrollToBottom:G,handleScrollToBottom:Z}=q,{configModalVisible:ue,configModalAssistantId:oe,configModalReadonly:H,marketModalVisible:P,skillMarketModalVisible:se,skillConfigModalVisible:me,skillConfigModalSkillId:he,handleConfigureAssistant:ee,handleOpenMarket:te,handleMarketConfigure:N,handleMarketViewConfig:de,handleCreateAssistant:be,handleAssistantCreated:xe,handleAssistantConfigSaved:le,handleOpenSkillMarket:Q,handleSkillMarketConfigure:X,handleCreateSkill:pe,handleSkillConfigSaved:ke,handleSkillCreated:$e}=$v(),De=_a(),Be=z(0);fe(()=>k.value,async Ce=>{if(!Ce){Be.value=0;return}try{const Ie=await Ye().estimateContextTokens(Ce);Ie.success&&(Be.value=Ie.tokens)}catch{Be.value=0}},{immediate:!0});const Te=T(()=>u.selectedAssistant?.presetQuestions??[]),Pe=T(()=>c.chatType??"group"),je=z(!1),Se=z(!1),ge=z(!0),O=z(void 0),V=z(null),K=z(null),L=z(null),j=z(!1),U=z(!1),ae=z(!1),ne=T(()=>{const Ce=L.value?.name||e("ai.assistant.fallbackName");return e("ai.assistant.upgrade.backupName",{name:Ce})}),Ve=T(()=>Cv(g.value));async function Le(){ge.value=!0;try{Se.value=await Ca().hasConfig()}catch(Ce){console.error("检查 LLM 配置失败:",Ce),Se.value=!1}finally{ge.value=!1}}async function Me(){await Le(),Se.value&&await D()}l({refreshConfig:Me});const Fe=T(()=>{const Ce=u.selectedAssistant;if(!Ce)return{name:"",preview:""};const Ie=Ce.systemPrompt.replace(/#{1,6}\s+[^\n]*/g,"").replace(/\n+/g," ").replace(/\s+/g," ").trim();return{name:Ce.name,preview:Ie}}),nt=T(()=>!!S.value&&g.value.length===0&&!y.value);function oa(){n.warn(e("ai.chat.backgroundTask.runningTitle"),{description:e("ai.chat.backgroundTask.runningDescription")})}function Ba(){n.warn(e("ai.chat.backgroundTask.blockedAction"))}function Cs(Ce){if(Ce!==S.value){if(!M(Ce)){Ba();return}o.activateSkill(null),B()}}async function Ss(Ce){const Ie=await I(Ce);!Ie.success&&Ie.reason==="busy"&&oa()}function Is(){const Ce=u.selectedAssistant?.id;Ce&&(O.value="presetQuestions",ee(Ce))}function Ts(Ce){ue.value=Ce,Ce||(O.value=void 0)}function Ms(){K.value?.openSkillSelector()}function zs(){G(!0)}async function Fa(){const Ce=await u.checkDefaultAssistantUpgrade(s.locale);Ce&&(L.value=Ce,j.value=!0)}async function As(){const Ce=L.value;if(!(!Ce||U.value||ae.value)){ae.value=!0;try{const Ie=await u.skipAssistantUpgrade(Ce);if(!Ie.success){n.fail(e("ai.assistant.upgrade.skipFailed"),{description:Ie.error||e("ai.assistant.toast.unknownError")});return}j.value=!1,L.value=null}finally{ae.value=!1}}}async function qs(){const Ce=L.value;if(!(!Ce||U.value||ae.value)){U.value=!0;try{const Ie=ne.value,kt=await u.upgradeAssistantWithBackup(Ce,Ie);if(!kt.success){n.fail(e("ai.assistant.upgrade.failed"),{description:kt.error||e("ai.assistant.toast.unknownError")});return}j.value=!1,L.value=null,n.success(e("ai.assistant.upgrade.success"),{description:e("ai.assistant.upgrade.successDescription",{name:Ie})})}finally{U.value=!1}}}async function Ls(Ce){const Ie=await I(Ce.content,{mentionedMembers:Ce.mentionedMembers});if(!Ie.success){Ie.reason==="busy"&&oa();return}G(!0),V.value?.refresh()}async function Ds(Ce){const Ie=await f(Ce.messageId,Ce.content,{overwriteSubsequent:Ce.overwriteSubsequent});if(!Ie.success){Ie.reason==="busy"&&oa();return}G(!0),V.value?.refresh()}async function Es(Ce){if(k.value)try{const Ie=await Ye().forkAIChat(k.value,Ce);await x(Ie.id),V.value?.refresh(),G(!0),n.success(e("ai.chat.fork.success"))}catch(Ie){n.fail(e("ai.chat.fork.failed"),{description:String(Ie)})}}function Bs(){je.value=!je.value}async function Fs(){await R()}async function Rs(Ce){await x(Ce),G(!0)}function Vs(){if(y.value){Ba();return}B()}function Os(Ce){k.value===Ce&&B()}function Ps(){A()}return Le(),D(),Re(()=>{Fa()}),fe(()=>s.locale,()=>{Fa()}),fe(()=>De.aiConfigVersion,async()=>{await Me()}),(Ce,Ie)=>{const kt=_e,js=St;return i(),m("div",Sv,[h(Wc,{ref_key:"conversationListRef",ref:V,"session-id":r.sessionId,"active-id":t(k),disabled:t(y),onSelect:Rs,onCreate:Vs,onDelete:Os},null,8,["session-id","active-id","disabled"]),a("div",Iv,[a("div",Tv,[a("div",Mv,[t(g).length>0||t(y)?(i(),m("div",zv,[a("button",{class:J(["flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",{"cursor-not-allowed opacity-50":t(y)||!t(u).selectedAssistant?.id}]),disabled:t(y)||!t(u).selectedAssistant?.id,onClick:Ie[0]||(Ie[0]=ze=>t(ee)(t(u).selectedAssistant.id))},[h(kt,{name:"i-heroicons-sparkles",class:"h-3.5 w-3.5"}),a("span",null,d(t(u).selectedAssistant?.name||t(e)("ai.assistant.fallbackName")),1)],10,Av)])):E("",!0),a("div",{ref:t(q).messagesContainer,class:J(["relative min-h-0 flex-1 overflow-x-hidden overflow-y-auto p-4",{"p-0!":t(g).length===0&&!t(y)}])},[a("div",{class:J(["mx-auto max-w-3xl space-y-6",{"flex min-h-full flex-col justify-center px-4 pb-32 pt-4 space-y-0!":t(g).length===0&&!t(y),"px-4":t(g).length>0||t(y)}])},[t(g).length===0&&!t(y)?(i(),m("div",qv,[Fe.value.name?(i(),m("h2",Lv,[ie(d(t(e)("ai.assistant.selector.heroTitlePrefix","使用"))+" ",1),a("span",Dv,d(Fe.value.name),1),ie(" "+d(t(e)("ai.assistant.selector.heroTitleSuffix","开始对话")),1)])):E("",!0),nt.value&&Fe.value.name?(i(),m("div",Ev,[a("p",{class:"cursor-pointer pr-7 text-center text-sm leading-relaxed text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300 line-clamp-2",onClick:Ie[1]||(Ie[1]=ze=>t(ee)(t(u).selectedAssistant.id))},[h(js,{text:t(e)("ai.assistant.config.systemPrompt","系统设定"),popper:{placement:"top"}},{default:F(()=>[ie(d(Fe.value.preview),1)]),_:1},8,["text"])]),a("button",{type:"button",class:"absolute bottom-0 right-0 rounded-md p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-200",onClick:Ie[2]||(Ie[2]=Oe(ze=>t(ee)(t(u).selectedAssistant.id),["stop"]))},[h(kt,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})])])):E("",!0),a("div",Bv,[h(F0,{"chat-type":Pe.value,locale:t(s).locale,"selected-id":t(S),onSelect:Cs,onMarket:t(te)},null,8,["chat-type","locale","selected-id","onMarket"])])])):E("",!0),(i(!0),m(re,null,ve(Ve.value,ze=>(i(),m(re,{key:ze.id},[ze.standalone?(i(),W(ua,{key:0,role:ze.standalone.role,content:ze.standalone.content,timestamp:ze.standalone.timestamp},null,8,["role","content","timestamp"])):(i(),m("div",Fv,[ze.user&&(ze.user.role==="user"||ze.user.content)?(i(),W(ua,{key:0,role:ze.user.role,"message-id":ze.user.id,content:ze.user.content,timestamp:ze.user.timestamp,"is-streaming":ze.user.isStreaming,"content-blocks":ze.user.contentBlocks,editable:!t(y),onEdit:Ds},null,8,["role","message-id","content","timestamp","is-streaming","content-blocks","editable"])):E("",!0),ze.assistant&&(ze.assistant.content||ze.assistant.contentBlocks&&ze.assistant.contentBlocks.length>0)?(i(),W(ua,{key:1,role:ze.assistant.role,"message-id":ze.assistant.id,content:ze.assistant.content,timestamp:ze.assistant.timestamp,"is-streaming":ze.assistant.isStreaming,"content-blocks":ze.assistant.contentBlocks,"show-capture-button":!ze.assistant.isStreaming,onFork:Es},null,8,["role","message-id","content","timestamp","is-streaming","content-blocks","show-capture-button"])):E("",!0)]))],64))),128)),t(y)&&!t(g)[t(g).length-1]?.content&&!(t(g)[t(g).length-1]?.contentBlocks?.length??0)?(i(),W(u0,{key:1,"current-tool-status":t(b),"tools-used":t($),"agent-status":t(w)},null,8,["current-tool-status","tools-used","agent-status"])):E("",!0)],2)],2),h(vt,{name:"fade-up"},{default:F(()=>[t(Y)?(i(),m("button",{key:0,class:"absolute bottom-20 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full bg-gray-800/90 px-3 py-1.5 text-xs text-white shadow-lg backdrop-blur-sm transition-all hover:bg-gray-700 dark:bg-gray-700/90 dark:hover:bg-gray-600",onClick:Ie[3]||(Ie[3]=(...ze)=>t(Z)&&t(Z)(...ze))},[h(kt,{name:"i-heroicons-arrow-down",class:"h-3.5 w-3.5"}),a("span",null,d(t(e)("ai.chat.scrollToBottom")),1)])):E("",!0)]),_:1}),t(g).length===0&&!t(y)?(i(),m("div",Rv,[a("div",Vv,[h(kv,{questions:Te.value,"leading-action-label":t(e)("ai.chat.input.useSkill"),onSelect:Ss,onLeadingAction:Ms,onEditQuestions:Is},null,8,["questions","leading-action-label"])])])):E("",!0),a("div",Ov,[a("div",Pv,[h(Gp,{ref_key:"chatInputRef",ref:K,"session-id":r.sessionId,disabled:t(y),status:t(y)?"streaming":"ready","chat-type":Pe.value,onSend:Ls,onStop:Ps,onManageSkills:t(Q),onSkillActivated:zs},null,8,["session-id","disabled","status","chat-type","onManageSkills"]),h(M0,{"session-token-usage":t(C),"agent-status":t(w),"current-ai-chat-id":t(k),"current-messages":t(g),"fallback-title":r.sessionName,"estimated-context-tokens":Be.value},null,8,["session-token-usage","agent-status","current-ai-chat-id","current-messages","fallback-title","estimated-context-tokens"])])])])]),h(vt,{name:"slide-fade"},{default:F(()=>[t(p).length>0&&!je.value?(i(),m("div",jv,[h(pd,{messages:t(p),keywords:t(v),"is-loading":t(_),"is-collapsed":je.value,class:"h-full",onToggle:Bs,onLoadMore:Fs},null,8,["messages","keywords","is-loading","is-collapsed"])])):E("",!0)]),_:1})]),h(Ih,{open:t(ue),"assistant-id":t(oe),readonly:t(H),"scroll-to-section":O.value,"onUpdate:open":Ts,onSaved:t(le),onCreated:t(xe)},null,8,["open","assistant-id","readonly","scroll-to-section","onSaved","onCreated"]),h(_f,{open:j.value,"backup-name":ne.value,upgrading:U.value,skipping:ae.value,onSkip:As,onConfirm:qs},null,8,["open","backup-name","upgrading","skipping"]),h(cf,{open:t(P),"onUpdate:open":Ie[4]||(Ie[4]=ze=>P.value=ze),onConfigure:t(N),onViewConfig:t(de),onCreate:t(be)},null,8,["open","onConfigure","onViewConfig","onCreate"]),h(av,{open:t(se),"onUpdate:open":Ie[5]||(Ie[5]=ze=>se.value=ze),onConfigure:t(X),onCreate:t(pe)},null,8,["open","onConfigure","onCreate"]),h(dv,{open:t(me),"skill-id":t(he),"onUpdate:open":Ie[6]||(Ie[6]=ze=>me.value=ze),onSaved:t(ke),onCreated:t($e)},null,8,["open","skill-id","onSaved","onCreated"])])}}}),r2=at(Nv,[["__scopeId","data-v-3b042ff8"]]),da="__ALL__",Uv=ce({__name:"UserSelect",props:{sessionId:{},modelValue:{}},emits:["update:modelValue"],setup(r,{emit:l}){const{t:e}=we(),n=r,s=l,u=z([]),o=z(!1),c=T({get:()=>n.modelValue===null?da:String(n.modelValue),set:v=>{s("update:modelValue",v===da?null:parseInt(v))}}),g=T(()=>{const v=[{value:da,label:e("common.userSelect.allMembers")}];return u.value.forEach(_=>{const y=_.groupNickname||_.accountName||_.platformId;v.push({value:String(_.id),label:`${y} (${_.messageCount})`})}),v});async function p(){if(n.sessionId){o.value=!0;try{const v=await Ke().getMembers(n.sessionId);u.value=v.sort((_,y)=>y.messageCount-_.messageCount)}catch(v){console.error("加载成员列表失败:",v)}finally{o.value=!1}}}return fe(()=>n.sessionId,()=>{s("update:modelValue",null),p()},{immediate:!0}),(v,_)=>{const y=Ea;return i(),W(y,{modelValue:c.value,"onUpdate:modelValue":_[0]||(_[0]=k=>c.value=k),items:g.value,loading:o.value,virtualize:{estimateSize:32,overscan:10},"value-key":"value",class:"w-48"},null,8,["modelValue","items","loading"])}}}),Wv=ce({__name:"EChartCalendar",props:{data:{},height:{default:180},year:{}},setup(r){ta([hs,fs,qa,vs,aa]);const l=r,{t:e,locale:n}=we(),s=Zt(),u=z(null);let o=null;const c=T(()=>{if(l.year)return l.year;if(l.data.length===0)return new Date().getFullYear();const $=l.data.map(C=>parseInt(C.date.split("-")[0]));return Math.max(...$)}),g=T(()=>l.data.length===0?10:Math.max(...l.data.map($=>$.value),1)),p=T(()=>l.data.map($=>[$.date,$.value])),v={light:["#fee5e8","#fbb5c2","#f7758c","#ee4567"],dark:["#3d1f24","#6b2f3a","#a34557","#ee4567"]},_=T(()=>({tooltip:{trigger:"item",formatter:$=>{const C=$.data[0],w=$.data[1];return`${C}<br/>${e("views.message.calendarTooltipMessages")}: ${w}`}},visualMap:{min:0,max:g.value,calculable:!1,orient:"horizontal",left:"center",bottom:0,itemWidth:10,itemHeight:100,text:[`${g.value}`,"0"],inRange:{color:s.value?v.dark:v.light},textStyle:{color:s.value?"#9ca3af":"#6b7280",fontSize:10},show:!0},calendar:{top:30,left:40,cellSize:[13,13],range:String(c.value),itemStyle:{borderWidth:2,borderColor:s.value?"#1f2937":"#ffffff"},yearLabel:{show:!0,position:"top",color:s.value?"#9ca3af":"#6b7280",fontSize:12},monthLabel:{show:!0,color:s.value?"#9ca3af":"#6b7280",fontSize:10,nameMap:[e("common.month.jan"),e("common.month.feb"),e("common.month.mar"),e("common.month.apr"),e("common.month.may"),e("common.month.jun"),e("common.month.jul"),e("common.month.aug"),e("common.month.sep"),e("common.month.oct"),e("common.month.nov"),e("common.month.dec")]},dayLabel:{show:!0,firstDay:1,color:s.value?"#6b7280":"#9ca3af",fontSize:10,nameMap:[e("common.weekday.sun"),e("common.weekday.mon"),e("common.weekday.tue"),e("common.weekday.wed"),e("common.weekday.thu"),e("common.weekday.fri"),e("common.weekday.sat")]},splitLine:{show:!1}},series:[{type:"heatmap",coordinateSystem:"calendar",data:p.value}]}));function y(){u.value&&(o=sa(u.value,s.value?"dark":void 0,{renderer:"canvas"}),o.setOption({backgroundColor:"transparent",..._.value}))}function k(){o&&o.setOption({backgroundColor:"transparent",..._.value},{notMerge:!0})}function b(){o?.resize()}return fe([()=>l.data,s,n],()=>{k()}),fe(()=>l.year,()=>{k()}),Re(()=>{y(),window.addEventListener("resize",b)}),tt(()=>{window.removeEventListener("resize",b),o?.dispose()}),($,C)=>(i(),m("div",{ref_key:"chartRef",ref:u,style:et({height:`${r.height}px`,width:"100%"})},null,4))}}),Hv={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Kv={class:"flex items-center gap-6 sm:gap-10"},Yv={class:"min-w-0 flex-1"},Gv={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},Qv={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},Jv={class:"mb-4 flex min-w-0 flex-wrap items-baseline gap-2"},Xv={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Zv={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},ey={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},ty={key:1,class:"flex min-w-0 max-w-full flex-wrap items-center gap-x-1.5 gap-y-1.5"},ay={class:"text-base font-medium text-gray-600 dark:text-gray-300"},sy={class:"font-bold tabular-nums text-pink-500 dark:text-pink-400"},ny={class:"flex shrink-0 flex-col items-center"},oy={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},ly={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},iy={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},ry={class:"min-w-0 flex-1"},uy={class:"flex items-center justify-between gap-1"},cy={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},dy={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},my={class:"relative z-10 flex items-center justify-between px-6 pb-4 opacity-40 mix-blend-luminosity dark:opacity-30 sm:px-8 sm:pb-5"},gy={class:"flex items-center gap-1.5"},py={class:"text-[9px] font-medium uppercase tracking-widest"},hy=ce({__name:"TypeProfileCard",props:{sessionId:{},messageTypes:{},textStats:{},timeFilter:{}},setup(r){ta([ao,qa,aa]);const{t:l}=we(),e=Zt(),n=r,s=T(()=>n.messageTypes.reduce((M,q)=>M+q.count,0)),u=T(()=>n.messageTypes.find(M=>M.type===gt.TEXT)?.count??0),o=T(()=>{if(s.value===0)return 0;const M=s.value-u.value;return Math.round(M/s.value*100)}),c=T(()=>n.textStats.textCount===0?0:Math.round(n.textStats.shortCount/n.textStats.textCount*100)),g=z({first:"",last:""});async function p(){if(n.sessionId)try{const M=await Ke().getDailyActivity(n.sessionId,n.timeFilter);if(M.length>0){const q=[...M].sort((Y,G)=>Y.date.localeCompare(G.date));g.value={first:Ee(q[0].date).format("YYYY/MM/DD"),last:Ee(q[q.length-1].date).format("YYYY/MM/DD")}}}catch{}}function v(M){return n.messageTypes.find(q=>q.type===M)?.count??0}const _=T(()=>[{label:l("views.message.typeCard.nonTextImage"),count:v(gt.IMAGE),unit:l("views.message.typeCard.unitImage")},{label:l("views.message.typeCard.nonTextEmoji"),count:v(gt.EMOJI),unit:l("views.message.typeCard.unitEmoji")},{label:l("views.message.typeCard.nonTextVoice"),count:v(gt.VOICE),unit:l("views.message.typeCard.unitVoice")},{label:l("views.message.typeCard.nonTextVideo"),count:v(gt.VIDEO),unit:l("views.message.typeCard.unitVideo")},{label:l("views.message.typeCard.nonTextFile"),count:v(gt.FILE),unit:l("views.message.typeCard.unitFile")},{label:l("views.message.typeCard.nonTextLink"),count:v(gt.LINK),unit:l("views.message.typeCard.unitLink")}].filter(M=>M.count>0)),y=z(30),k=z(0),b=z(!1),$=[{label:"20",value:20},{label:"30",value:30},{label:"50",value:50},{label:"80",value:80},{label:"100",value:100}],C=T({get:()=>y.value,set:M=>{y.value!==M&&(y.value=M,w())}});async function w(){if(n.sessionId){b.value=!0;try{k.value=await Ke().getLongMessageCount(n.sessionId,n.timeFilter,y.value)}catch(M){console.error("[chart-message] Failed to load essay count:",M)}finally{b.value=!1}}}fe(()=>[n.sessionId,n.timeFilter],()=>{w(),p()},{immediate:!0,deep:!0});const S=T(()=>[{icon:"i-heroicons-pencil-square",label:l("views.message.profile.textExpression"),value:l("views.message.profile.avgLengthUnit",{count:n.textStats.avgLength||0}),subtext:n.textStats.maxLength>0?l("views.message.profile.textExpressionDesc",{count:n.textStats.maxLength}):"",colorClass:"text-violet-600 dark:text-violet-400"},{icon:"i-heroicons-chat-bubble-bottom-center-text",label:l("views.message.profile.shortMaster"),value:`${c.value}%`,subtext:l("views.message.profile.shortMasterDesc",{count:n.textStats.shortCount}),colorClass:"text-emerald-600 dark:text-emerald-400"},{icon:"i-heroicons-document-text",label:l("views.message.profile.essayLover"),value:k.value.toLocaleString(),subtext:l("views.message.profile.essayLoverDesc",{threshold:y.value}),colorClass:"text-indigo-600 dark:text-indigo-400",slot:"essay-threshold"},{icon:"i-heroicons-photo",label:l("views.message.profile.mediaRichness"),value:`${o.value}%`,subtext:_.value.slice(0,3).map(M=>`${M.label} ${M.count}`).join(" · ")||"-",colorClass:"text-pink-600 dark:text-pink-400"}]),I=z(null);let f=null;const x=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],B=T(()=>[...n.messageTypes].sort((q,Y)=>Y.count-q.count).slice(0,8).map((q,Y)=>({name:ga(q.type,l),value:q.count,itemStyle:{color:x[Y%x.length]}})));function R(){I.value&&(f=sa(I.value,void 0,{renderer:"canvas"}),D())}function D(){f&&f.setOption({backgroundColor:"transparent",tooltip:{trigger:"item",formatter:"{b}: {c} ({d}%)"},series:[{type:"pie",radius:["50%","78%"],center:["50%","50%"],avoidLabelOverlap:!1,padAngle:2,itemStyle:{borderRadius:4},label:{show:!1},emphasis:{label:{show:!1},scaleSize:4},data:B.value}]},{notMerge:!0})}function A(){f?.resize()}return fe(()=>n.messageTypes,()=>D()),fe(e,()=>{f?.dispose(),R()}),Re(()=>{R(),window.addEventListener("resize",A)}),tt(()=>{window.removeEventListener("resize",A),f?.dispose()}),(M,q)=>{const Y=_e,G=$a;return i(),W(t(na),null,{default:F(()=>[a("div",Hv,[a("div",Kv,[a("div",Yv,[a("div",Gv,[g.value.first?(i(),m("p",Qv,d(g.value.first)+" – "+d(g.value.last),1)):E("",!0),a("div",Jv,[a("span",Xv,d(t(l)("views.message.profile.heroLine1Prefix")),1),a("span",Zv,d(s.value.toLocaleString()),1),a("span",ey,d(t(l)("views.message.profile.heroLine1Suffix")),1)]),_.value.length>0?(i(),m("div",ty,[a("span",ay,d(t(l)("views.message.typeCard.nonTextPrefix")),1),(i(!0),m(re,null,ve(_.value,Z=>(i(),m("span",{key:Z.label,class:"inline-flex items-center gap-1 rounded-full bg-gray-100 px-2.5 py-0.5 text-xs font-semibold text-gray-700 dark:bg-white/10 dark:text-gray-200"},[a("span",sy,d(Z.count.toLocaleString()),1),a("span",null,d(Z.unit),1)]))),128))])):E("",!0)])]),a("div",ny,[a("div",oy,d(t(l)("views.message.profile.typeDistribution")),1),a("div",{ref_key:"donutRef",ref:I,style:{width:"130px",height:"130px"}},null,512)])])]),a("div",ly,[q[1]||(q[1]=a("div",{class:"mb-3 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Type Profile ")],-1)),a("div",iy,[(i(!0),m(re,null,ve(S.value,Z=>(i(),m("div",{key:Z.icon+Z.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[h(Y,{name:Z.icon,class:J(["mt-0.5 h-3.5 w-3.5 shrink-0",Z.colorClass])},null,8,["name","class"]),a("div",ry,[a("div",uy,[a("div",{class:J(["truncate font-mono text-sm font-black leading-tight tabular-nums",Z.colorClass])},d(Z.value),3),Z.slot==="essay-threshold"?(i(),W(G,{key:0,modelValue:C.value,"onUpdate:modelValue":q[0]||(q[0]=ue=>C.value=ue),items:$,"value-key":"value",size:"xs",class:"relative z-120 w-16 shrink-0",ui:{content:"z-[121]"},disabled:b.value},null,8,["modelValue","disabled"])):E("",!0)]),a("div",cy,d(Z.label),1),a("div",dy,d(Z.subtext),1)])]))),128))])]),a("div",my,[a("div",gy,[h(Y,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),q[2]||(q[2]=a("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),a("span",py,d(t(l)("views.message.typeCard.watermark")),1)])]),_:1})}}}),fy={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-4 sm:p-6"},vy={class:"p-5"},yy={key:0,class:"grid grid-cols-1 gap-6 lg:grid-cols-2 lg:items-center"},xy={class:"space-y-3"},by={class:"min-w-20 shrink-0 text-sm text-gray-700 dark:text-gray-300"},ky={class:"flex-1"},_y={class:"h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800"},wy={class:"shrink-0 text-right"},$y={class:"text-sm font-medium text-gray-900 dark:text-white"},Cy={class:"ml-1 text-xs text-gray-400"},Sy={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Iy={class:"p-5"},Ty={class:"mb-5 grid grid-cols-2 gap-3 sm:grid-cols-4"},My={class:"p-3"},zy={class:"font-mono text-xl font-bold text-gray-900 dark:text-white"},Ay={class:"mt-1 text-xs text-gray-500"},qy={class:"p-3"},Ly={class:"font-mono text-xl font-bold text-indigo-600 dark:text-indigo-400"},Dy={class:"mt-1 text-xs text-gray-500"},Ey={class:"p-3"},By={class:"font-mono text-xl font-bold text-pink-600 dark:text-pink-400"},Fy={class:"mt-1 text-xs text-gray-500"},Ry={class:"p-3"},Vy={class:"font-mono text-xl font-bold text-emerald-600 dark:text-emerald-400"},Oy={class:"mt-1 text-xs text-gray-500"},Py={class:"mb-5 rounded-lg border border-gray-200 p-4 dark:border-gray-700"},jy={class:"mb-2 text-xs font-medium text-gray-500 dark:text-gray-400"},Ny={class:"flex items-center gap-4 text-sm"},Uy={class:"flex items-center gap-1.5"},Wy={class:"font-mono font-medium text-gray-900 dark:text-white"},Hy={class:"flex items-center gap-1.5"},Ky={class:"font-mono font-medium text-gray-900 dark:text-white"},Yy={class:"flex items-center gap-1.5"},Gy={class:"font-mono font-medium text-gray-900 dark:text-white"},Qy={class:"flex items-center gap-1.5"},Jy={class:"font-mono font-medium text-gray-900 dark:text-white"},Xy={class:"mt-3 grid grid-cols-3 gap-3 text-xs"},Zy={class:"text-gray-500"},ex={class:"ml-1 font-medium text-emerald-600 dark:text-emerald-400"},tx={class:"text-gray-400"},ax={class:"text-gray-500"},sx={class:"ml-1 font-medium text-indigo-600 dark:text-indigo-400"},nx={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},ox={class:"text-xs text-gray-400"},lx={class:"p-5"},ix={key:1,class:"flex h-48 items-center justify-center text-gray-400"},rx={class:"text-xs text-gray-400"},ux={class:"p-5"},cx={key:1,class:"flex h-48 items-center justify-center text-gray-400"},u2=ce({__name:"TypeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(r){const l=r,{t:e}=we(),n=z(!0),s=z([]),u=z([]),o=z([]),c=z({textCount:0,avgLength:0,maxLength:0,shortCount:0}),g=z({p25:0,p50:0,p75:0,p90:0}),p=z(0),v=T(()=>{const S=[...s.value].sort((I,f)=>f.count-I.count);return{labels:S.map(I=>ga(I.type,e)),values:S.map(I=>I.count)}}),_=T(()=>{const S=s.value.reduce((f,x)=>f+x.count,0);return[...s.value].sort((f,x)=>x.count-f.count).map(f=>({name:ga(f.type,e),count:f.count,percentage:S>0?Math.round(f.count/S*100):0}))}),y=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"];function k(S){return y[S%y.length]}const b=T(()=>({labels:u.value.map(S=>String(S.len)),values:u.value.map(S=>S.count)})),$=T(()=>({labels:o.value.map(S=>S.range),values:o.value.map(S=>S.count)})),C=T(()=>c.value.textCount===0?0:Math.round(c.value.shortCount/c.value.textCount*100));async function w(){if(l.sessionId){n.value=!0;try{const S=Ke(),[I,f,x,B,R]=await Promise.all([S.getMessageTypeDistribution(l.sessionId,l.timeFilter),S.getMessageLengthDistribution(l.sessionId,l.timeFilter),S.getTextStats(l.sessionId,l.timeFilter),S.getTextLengthPercentiles(l.sessionId,l.timeFilter),S.getLongMessageCount(l.sessionId,l.timeFilter,30)]);s.value=I,u.value=f.detail,o.value=f.grouped,c.value=x,g.value=B,p.value=R}catch(S){console.error("[chart-message] Failed to load type analysis data:",S)}finally{n.value=!1}}}return fe(()=>[l.sessionId,l.timeFilter],()=>w(),{immediate:!0,deep:!0}),(S,I)=>(i(),m("div",{class:J(n.value?"h-full":"")},[n.value?(i(),W(t(Yt),{key:0,variant:"page",text:t(e)("common.loading")},null,8,["text"])):(i(),m("div",fy,[s.value.length>0?(i(),W(hy,{key:0,"session-id":r.sessionId,"message-types":s.value,"text-stats":c.value,"time-filter":r.timeFilter},null,8,["session-id","message-types","text-stats","time-filter"])):E("",!0),h(t(Ze),{title:t(e)("views.message.typeDistribution"),"show-divider":!1},{default:F(()=>[a("div",vy,[v.value.values.length>0?(i(),m("div",yy,[a("div",null,[h(t(xa),{data:v.value,height:280,"show-legend":!1},null,8,["data"])]),a("div",null,[a("div",xy,[(i(!0),m(re,null,ve(_.value,(f,x)=>(i(),m("div",{key:x,class:"flex items-center gap-3"},[a("div",{class:"h-3 w-3 shrink-0 rounded-full",style:et({backgroundColor:k(x)})},null,4),a("div",by,d(f.name),1),a("div",ky,[a("div",_y,[a("div",{class:"h-full rounded-full transition-all",style:et({width:`${f.percentage}%`,backgroundColor:k(x)})},null,4)])]),a("div",wy,[a("span",$y,d(f.count.toLocaleString()),1),a("span",Cy,"("+d(f.percentage)+"%)",1)])]))),128))])])])):(i(),m("div",Sy,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"]),h(t(Ze),{title:t(e)("views.message.typeAnalysis.textDepthTitle"),"show-divider":!1},{default:F(()=>[a("div",Iy,[a("div",Ty,[a("div",My,[a("div",zy,d(c.value.textCount.toLocaleString()),1),a("div",Ay,d(t(e)("views.message.typeAnalysis.textTotal")),1)]),a("div",qy,[a("div",Ly,d(c.value.avgLength||0),1),a("div",Dy,d(t(e)("views.message.typeAnalysis.avgLength")),1)]),a("div",Ey,[a("div",By,d(g.value.p50),1),a("div",Fy,d(t(e)("views.message.typeAnalysis.medianLength")),1)]),a("div",Ry,[a("div",Vy,d(c.value.maxLength),1),a("div",Oy,d(t(e)("views.message.typeAnalysis.maxLength")),1)])]),a("div",Py,[a("div",jy,d(t(e)("views.message.typeAnalysis.percentiles")),1),a("div",Ny,[a("div",Uy,[I[0]||(I[0]=a("span",{class:"text-gray-500"},"P25",-1)),a("span",Wy,d(g.value.p25),1)]),a("div",Hy,[I[1]||(I[1]=a("span",{class:"text-gray-500"},"P50",-1)),a("span",Ky,d(g.value.p50),1)]),a("div",Yy,[I[2]||(I[2]=a("span",{class:"text-gray-500"},"P75",-1)),a("span",Gy,d(g.value.p75),1)]),a("div",Qy,[I[3]||(I[3]=a("span",{class:"text-gray-500"},"P90",-1)),a("span",Jy,d(g.value.p90),1)])]),a("div",Xy,[a("div",null,[a("span",Zy,d(t(e)("views.message.typeAnalysis.shortMessages")),1),a("span",ex,d(C.value)+"%",1),a("span",tx,"("+d(c.value.shortCount)+")",1)]),a("div",null,[a("span",ax,d(t(e)("views.message.typeAnalysis.essayMessages")),1),a("span",sx,d(p.value),1)])])])])]),_:1},8,["title"]),a("div",nx,[h(t(Ze),{title:t(e)("views.message.lengthDetailTitle"),"show-divider":!1},{headerRight:F(()=>[a("span",ox,d(t(e)("views.message.lengthDetailHint")),1)]),default:F(()=>[a("div",lx,[b.value.values.some(f=>f>0)?(i(),W(t(rt),{key:0,data:b.value,height:200},null,8,["data"])):(i(),m("div",ix,d(t(e)("views.message.noTextMessages")),1))])]),_:1},8,["title"]),h(t(Ze),{title:t(e)("views.message.lengthGroupedTitle"),"show-divider":!1},{headerRight:F(()=>[a("span",rx,d(t(e)("views.message.lengthGroupedHint")),1)]),default:F(()=>[a("div",ux,[$.value.values.some(f=>f>0)?(i(),W(t(rt),{key:0,data:$.value,height:200},null,8,["data"])):(i(),m("div",cx,d(t(e)("views.message.noTextMessages")),1))])]),_:1},8,["title"])])]))],2))}}),dx={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},mx={class:"flex items-start gap-6 sm:gap-10"},gx={class:"min-w-0 flex-1"},px={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},hx={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},fx={class:"mb-3 flex items-baseline gap-2"},vx={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},yx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},xx={class:"font-bold text-3xl text-indigo-500 dark:text-indigo-400"},bx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},kx={class:"flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},_x={class:"text-base font-medium text-gray-600 dark:text-gray-300"},wx={class:"font-bold text-xl text-pink-500 dark:text-pink-400"},$x={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Cx={class:"text-base font-medium text-amber-600 dark:text-amber-400"},Sx={class:"flex shrink-0 flex-col items-center"},Ix={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},Tx={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Mx={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},zx={class:"min-w-0 flex-1"},Ax={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},qx={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Lx={class:"relative z-10 flex items-center justify-between px-6 pb-4 opacity-40 mix-blend-luminosity dark:opacity-30 sm:px-8 sm:pb-5"},Dx={class:"flex items-center gap-1.5"},Ex={class:"text-[9px] font-medium uppercase tracking-widest"},Bx=ce({__name:"TimeProfileCard",props:{hourlyActivity:{},weekdayActivity:{},dailyActivity:{}},setup(r){ta([so,no,aa]);const{t:l}=we(),e=Zt(),n=r,s=T(()=>n.dailyActivity.filter(f=>f.messageCount>0).length),u=T(()=>n.dailyActivity.reduce((f,x)=>f+x.messageCount,0)),o=T(()=>{if(n.dailyActivity.length===0)return{first:"",last:"",days:0};const f=[...n.dailyActivity].sort((R,D)=>R.date.localeCompare(D.date)),x=Ee(f[0].date),B=Ee(f[f.length-1].date);return{first:x.format("YYYY/MM/DD"),last:B.format("YYYY/MM/DD"),days:B.diff(x,"day")+1}}),c=T(()=>s.value===0?0:Math.round(u.value/s.value)),g=T(()=>n.dailyActivity.length===0?null:n.dailyActivity.reduce((f,x)=>x.messageCount>f.messageCount?x:f,n.dailyActivity[0])),p=T(()=>n.hourlyActivity.length===0?[]:[...n.hourlyActivity].sort((f,x)=>x.messageCount-f.messageCount).slice(0,3)),v=T(()=>{if(n.hourlyActivity.length===0&&n.weekdayActivity.length===0)return null;const f=o.value.days>0?s.value/o.value.days:0,x=n.weekdayActivity.filter(H=>H.weekday===6||H.weekday===7),B=n.weekdayActivity.filter(H=>H.weekday>=1&&H.weekday<=5),R=x.reduce((H,P)=>H+P.messageCount,0),D=B.reduce((H,P)=>H+P.messageCount,0),A=R+D,M=A>0?R/A:0,q=n.hourlyActivity.reduce((H,P)=>H+P.messageCount,0),Y=n.hourlyActivity.filter(H=>H.hour>=22||H.hour<5).reduce((H,P)=>H+P.messageCount,0),G=n.hourlyActivity.filter(H=>H.hour>=18&&H.hour<22).reduce((H,P)=>H+P.messageCount,0),Z=q>0?Y/q:0,ue=q>0?G/q:0;if(f>=.9)return{label:l("views.message.timeCard.personalityEveryday"),icon:"i-heroicons-fire"};if(M>=.55)return{label:l("views.message.timeCard.personalityWeekend"),icon:"i-heroicons-calendar"};if(M<=.2&&A>0)return{label:l("views.message.timeCard.personalityWeekday"),icon:"i-heroicons-briefcase"};if(Z>=.3)return{label:l("views.message.timeCard.personalityNightOwl"),icon:"i-heroicons-moon"};if(ue>=.4)return{label:l("views.message.timeCard.personalityEveningChat"),icon:"i-heroicons-sparkles"};const oe=[...n.hourlyActivity].sort((H,P)=>P.messageCount-H.messageCount)[0];return oe?oe.hour>=5&&oe.hour<9?{label:l("views.message.timeCard.personalityEarlyBird"),icon:"i-heroicons-sun"}:oe.hour>=12&&oe.hour<14?{label:l("views.message.timeCard.personalityLunchChat"),icon:"i-heroicons-clock"}:{label:l("views.message.timeCard.personalityDaytime"),icon:"i-heroicons-sun"}:null}),_=T(()=>{const f=n.weekdayActivity.filter(A=>A.weekday===6||A.weekday===7),x=n.weekdayActivity.filter(A=>A.weekday>=1&&A.weekday<=5),B=f.reduce((A,M)=>A+M.messageCount,0),R=x.reduce((A,M)=>A+M.messageCount,0),D=B+R;return D===0?0:Math.round(B/D*100)}),y=T(()=>[l("common.weekday.mon"),l("common.weekday.tue"),l("common.weekday.wed"),l("common.weekday.thu"),l("common.weekday.fri"),l("common.weekday.sat"),l("common.weekday.sun")]),k=T(()=>{if(n.weekdayActivity.length===0)return null;const f=[...n.weekdayActivity].sort((x,B)=>B.messageCount-x.messageCount)[0];return{name:y.value[f.weekday-1],count:f.messageCount}}),b=T(()=>[{icon:"i-heroicons-fire",label:l("views.message.timeCard.peakRecord"),value:g.value?Ee(g.value.date).format("MM/DD"):"-",subtext:g.value?l("views.message.timeCard.peakRecordDesc",{count:g.value.messageCount}):"",colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-clock",label:l("views.message.timeCard.topHoursLabel"),value:p.value.length>0?`${p.value[0].hour}:00`:"-",subtext:p.value.length>=2?p.value.map(f=>`${f.hour}:00`).join(" > "):"",colorClass:"text-cyan-600 dark:text-cyan-400"},{icon:"i-heroicons-calendar-days",label:l("views.message.timeCard.peakWeekdayLabel"),value:k.value?.name||"-",subtext:k.value?`${k.value.count.toLocaleString()}`:"",colorClass:"text-violet-600 dark:text-violet-400"},{icon:"i-heroicons-building-office",label:l("views.message.timeCard.weekendRatio"),value:`${_.value}%`,subtext:l("views.message.timeCard.weekendRatioDesc"),colorClass:"text-amber-600 dark:text-amber-400"}]),$=z(null);let C=null;function w(){$.value&&(C=sa($.value,void 0,{renderer:"canvas"}),S())}function S(){if(!C)return;const f=new Map(n.hourlyActivity.map(D=>[D.hour,D.messageCount])),x=[];for(let D=0;D<24;D++)x.push(f.get(D)||0);const B=Math.max(...x,1),R=x.map(D=>{const A=D/B;return A>.8?e.value?"#f472b6":"#ec4899":A>.5?e.value?"#a78bfa":"#8b5cf6":e.value?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.08)"});C.setOption({backgroundColor:"transparent",tooltip:{trigger:"axis",formatter:D=>`${D[0].axisValue}:00 — ${D[0].value}`},grid:{left:0,right:0,top:4,bottom:16},xAxis:{type:"category",data:Array.from({length:24},(D,A)=>`${A}`),axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:9,color:e.value?"#6b7280":"#9ca3af",interval:D=>D%6===0}},yAxis:{type:"value",show:!1},series:[{type:"bar",data:x.map((D,A)=>({value:D,itemStyle:{color:R[A]}})),barWidth:"60%",itemStyle:{borderRadius:[2,2,0,0]}}]},{notMerge:!0})}function I(){C?.resize()}return fe(()=>n.hourlyActivity,()=>S()),fe(e,()=>{C?.dispose(),w()}),Re(()=>{w(),window.addEventListener("resize",I)}),tt(()=>{window.removeEventListener("resize",I),C?.dispose()}),(f,x)=>{const B=_e;return i(),W(t(na),null,{default:F(()=>[a("div",dx,[a("div",mx,[a("div",gx,[a("div",px,[o.value.first?(i(),m("p",hx,d(o.value.first)+" – "+d(o.value.last),1)):E("",!0),a("div",fx,[a("span",vx,d(o.value.days),1),a("span",yx,d(t(l)("views.message.timeCard.heroDaysIn")),1),a("span",xx,d(s.value),1),a("span",bx,d(t(l)("views.message.timeCard.heroDaysActive")),1)]),a("div",kx,[a("span",_x,d(t(l)("views.message.timeCard.heroAvgPrefix")),1),a("span",wx,d(c.value),1),a("span",$x,d(t(l)("views.message.timeCard.heroAvgSuffix")),1),v.value?(i(),m(re,{key:0},[h(B,{name:v.value.icon,class:"ml-2 h-4 w-4 text-amber-500"},null,8,["name"]),a("span",Cx,d(v.value.label),1)],64)):E("",!0)])])]),a("div",Sx,[a("div",Ix,d(t(l)("views.message.timeCard.hourlyDistribution")),1),a("div",{ref_key:"barRef",ref:$,style:{width:"180px",height:"110px"}},null,512)])])]),a("div",Tx,[x[0]||(x[0]=a("div",{class:"mb-3 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Time Profile ")],-1)),a("div",Mx,[(i(!0),m(re,null,ve(b.value,R=>(i(),m("div",{key:R.icon+R.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[h(B,{name:R.icon,class:J(["mt-0.5 h-3.5 w-3.5 shrink-0",R.colorClass])},null,8,["name","class"]),a("div",zx,[a("div",{class:J(["truncate font-mono text-sm font-black leading-tight tabular-nums",R.colorClass])},d(R.value),3),a("div",Ax,d(R.label),1),a("div",qx,d(R.subtext),1)])]))),128))])]),a("div",Lx,[a("div",Dx,[h(B,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),x[1]||(x[1]=a("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),a("span",Ex,d(t(l)("views.message.timeCard.watermark")),1)])]),_:1})}}}),Fx={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-4 sm:p-6"},Rx={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},Vx={class:"p-5"},Ox={class:"p-5"},Px={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},jx={class:"p-5"},Nx={class:"p-5"},Ux={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Wx={class:"text-xs text-gray-400"},Hx={class:"p-5"},Kx={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Yx={class:"text-xs text-gray-400"},Gx={class:"p-5"},Qx={class:"flex items-center gap-2"},Jx={class:"text-xs text-gray-400"},Xx={class:"p-5"},Zx={key:1,class:"flex h-32 items-center justify-center text-gray-400"},c2=ce({__name:"TimeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(r){const l=r,{t:e}=we(),n=z(!0),s=z([]),u=z([]),o=z([]),c=z([]),g=z([]),p=z([]),v=z([]),_=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],y=T(()=>[e("common.weekday.mon"),e("common.weekday.tue"),e("common.weekday.wed"),e("common.weekday.thu"),e("common.weekday.fri"),e("common.weekday.sat"),e("common.weekday.sun")]),k=T(()=>[e("common.month.jan"),e("common.month.feb"),e("common.month.mar"),e("common.month.apr"),e("common.month.may"),e("common.month.jun"),e("common.month.jul"),e("common.month.aug"),e("common.month.sep"),e("common.month.oct"),e("common.month.nov"),e("common.month.dec")]),b=T(()=>{const A=new Map(u.value.map(Y=>[Y.hour,Y.messageCount])),M=[],q=[];for(let Y=0;Y<24;Y++)M.push(`${Y}`),q.push(A.get(Y)||0);return{labels:M,values:q}}),$=T(()=>{const A=new Map(o.value.map(q=>[q.weekday,q.messageCount])),M=[];for(let q=1;q<=7;q++)M.push(A.get(q)||0);return{labels:y.value,values:M}}),C=T(()=>{const A=new Map(c.value.map(q=>[q.month,q.messageCount])),M=[];for(let q=1;q<=12;q++)M.push(A.get(q)||0);return{labels:k.value,values:M}}),w=T(()=>{const A=[...g.value].sort((M,q)=>M.year-q.year);return{labels:A.map(M=>String(M.year)),values:A.map(M=>M.messageCount)}}),S=T(()=>{const A=Array.from({length:24},(G,Z)=>`${Z}:00`),M=y.value,q=s.value.reduce((G,Z)=>G+Z.count,0)||1,Y=[];for(let G=1;G<=7;G++)for(let Z=0;Z<24;Z++){const ue=o.value.find(P=>P.weekday===G)?.messageCount||0,oe=u.value.find(P=>P.hour===Z)?.messageCount||0,H=Math.round(ue*oe/q);Y.push([Z,G-1,H])}return{xLabels:A,yLabels:M,data:Y}}),I=T(()=>p.value.map(A=>({date:A.date,value:A.messageCount}))),f=T(()=>{const A=new Set;return p.value.forEach(M=>{const q=parseInt(M.date.split("-")[0]);isNaN(q)||A.add(q)}),Array.from(A).sort((M,q)=>q-M)}),x=z(new Date().getFullYear()),B=T(()=>{const A=x.value;return I.value.filter(M=>M.date.startsWith(`${A}-`))}),R=T(()=>{if(v.value.length===0)return{};const A=[...new Set(v.value.map(Z=>Z.month))].sort(),M=new Map;if(v.value.forEach(Z=>{const ue=M.get(Z.memberId);ue?ue.total+=Z.count:M.set(Z.memberId,{name:Z.memberName,total:Z.count})}),M.size<=2){const Z=new Map;return v.value.forEach(ue=>{Z.set(ue.month,(Z.get(ue.month)||0)+ue.count)}),{tooltip:{trigger:"axis",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:50,right:20,top:10,bottom:30},xAxis:{type:"category",data:A,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{type:"dashed",opacity:.3}}},series:[{type:"line",smooth:!0,symbol:"none",areaStyle:{opacity:.2},itemStyle:{color:"#6366f1"},data:A.map(ue=>Z.get(ue)||0)}]}}const G=[...M.entries()].sort((Z,ue)=>ue[1].total-Z[1].total).slice(0,10).map(([Z,ue],oe)=>{const H=new Map(v.value.filter(P=>P.memberId===Z).map(P=>[P.month,P.count]));return{name:ue.name,type:"line",stack:"total",areaStyle:{opacity:.3},smooth:!0,symbol:"none",itemStyle:{color:_[oe%_.length]},data:A.map(P=>H.get(P)||0)}});return{tooltip:{trigger:"axis",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},legend:{bottom:0,textStyle:{fontSize:11}},grid:{left:50,right:20,top:10,bottom:40},xAxis:{type:"category",data:A,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{type:"dashed",opacity:.3}}},series:G}});async function D(){if(l.sessionId){n.value=!0;try{const A=Ke(),[M,q,Y,G,Z,ue,oe]=await Promise.all([A.getMessageTypeDistribution(l.sessionId,l.timeFilter),A.getHourlyActivity(l.sessionId,l.timeFilter),A.getWeekdayActivity(l.sessionId,l.timeFilter),A.getMonthlyActivity(l.sessionId,l.timeFilter),A.getYearlyActivity(l.sessionId,l.timeFilter),A.getDailyActivity(l.sessionId,l.timeFilter),A.getMemberMonthlyTrend(l.sessionId,l.timeFilter)]);s.value=M,u.value=q,o.value=Y,c.value=G,g.value=Z,p.value=ue,v.value=oe,f.value.length>0&&(x.value=f.value[0])}catch(A){console.error("[chart-message] Failed to load time analysis data:",A)}finally{n.value=!1}}}return fe(()=>[l.sessionId,l.timeFilter],()=>D(),{immediate:!0,deep:!0}),(A,M)=>{const q=$a;return i(),m("div",{class:J(n.value?"h-full":"")},[n.value?(i(),W(t(Yt),{key:0,variant:"page",text:t(e)("common.loading")},null,8,["text"])):(i(),m("div",Fx,[p.value.length>0?(i(),W(Bx,{key:0,"hourly-activity":u.value,"weekday-activity":o.value,"daily-activity":p.value},null,8,["hourly-activity","weekday-activity","daily-activity"])):E("",!0),a("div",Rx,[h(t(Ze),{title:t(e)("views.message.hourlyDistribution"),"show-divider":!1},{default:F(()=>[a("div",Vx,[h(t(rt),{data:b.value,height:200},null,8,["data"])])]),_:1},8,["title"]),h(t(Ze),{title:t(e)("views.message.weekdayDistribution"),"show-divider":!1},{default:F(()=>[a("div",Ox,[h(t(rt),{data:$.value,height:200},null,8,["data"])])]),_:1},8,["title"])]),a("div",Px,[h(t(Ze),{title:t(e)("views.message.monthlyDistribution"),"show-divider":!1},{default:F(()=>[a("div",jx,[h(t(rt),{data:C.value,height:200},null,8,["data"])])]),_:1},8,["title"]),h(t(Ze),{title:t(e)("views.message.yearlyDistribution"),"show-divider":!1},{default:F(()=>[a("div",Nx,[w.value.values.length>0?(i(),W(t(rt),{key:0,data:w.value,height:200},null,8,["data"])):(i(),m("div",Ux,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"])]),h(t(Ze),{title:t(e)("views.message.timeAnalysis.memberTrendTitle"),"show-divider":!1},{headerRight:F(()=>[a("span",Wx,d(t(e)("views.message.timeAnalysis.memberTrendHint")),1)]),default:F(()=>[a("div",Hx,[v.value.length>0?(i(),W(t(ea),{key:0,option:R.value,height:280},null,8,["option"])):(i(),m("div",Kx,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"]),h(t(Ze),{title:t(e)("views.message.timeHeatmap"),"show-divider":!1},{headerRight:F(()=>[a("span",Yx,d(t(e)("views.message.heatmapHint")),1)]),default:F(()=>[a("div",Gx,[h(t(va),{data:S.value,height:320},null,8,["data"])])]),_:1},8,["title"]),h(t(Ze),{title:t(e)("views.message.calendarHeatmap"),"show-divider":!1},{headerRight:F(()=>[a("div",Qx,[a("span",Jx,d(t(e)("views.message.calendarHint")),1),f.value.length>1?(i(),W(q,{key:0,modelValue:x.value,"onUpdate:modelValue":M[0]||(M[0]=Y=>x.value=Y),items:f.value.map(Y=>({value:Y,label:String(Y)})),size:"xs",class:"w-20"},null,8,["modelValue","items"])):E("",!0)])]),default:F(()=>[a("div",Xx,[B.value.length>0?(i(),W(t(Wv),{key:0,data:B.value,year:x.value,height:180},null,8,["data","year"])):(i(),m("div",Zx,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"])]))],2)}}}),eb={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},tb={class:"flex items-center gap-6 sm:gap-10"},ab={class:"min-w-0 flex-1"},sb={class:"flex flex-col gap-2 text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},nb={key:0,class:"mb-0 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},ob={class:"flex items-baseline gap-x-1.5"},lb={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},ib={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},rb={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},ub={class:"flex items-baseline gap-x-1.5"},cb={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},db={class:"font-black text-3xl text-pink-500 dark:text-pink-400"},mb={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},gb={key:1,class:"mt-1 flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},pb={class:"text-base font-medium text-gray-600 dark:text-gray-300"},hb=["onClick"],fb={key:0,class:"text-gray-400"},vb={key:0,class:"hidden shrink-0 overflow-hidden rounded-lg sm:block"},yb={class:"relative",style:{width:"360px",height:"220px"}},xb={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},bb={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},kb={class:"min-w-0 flex-1"},_b={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},wb={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},$b={class:"relative z-10 flex items-center justify-between px-6 pb-4 opacity-40 mix-blend-luminosity dark:opacity-30 sm:px-8 sm:pb-5"},Cb={class:"flex items-center gap-1.5"},Sb={class:"text-[9px] font-medium uppercase tracking-widest"},Ib=ce({__name:"TopicProfileCard",props:{totalMessages:{},totalWords:{},uniqueWords:{},topWords:{},topicWords:{},posTagStats:{},timeFilter:{}},emits:["wordClick"],setup(r,{emit:l}){const e=gs(()=>Xt(()=>import("./EChartWordcloud-Bd3L3G8I.js"),__vite__mapDeps([3,4,5,6,0,1,2]))),{t:n}=we(),s=r,u=l,o=T(()=>{const{startTs:b,endTs:$}=s.timeFilter??{};return b&&$?`${Ee(b*1e3).format("YYYY/MM/DD")} – ${Ee($*1e3).format("YYYY/MM/DD")}`:""}),c=T(()=>(s.topicWords?.length?s.topicWords:s.topWords).slice(0,5)),g=T(()=>({words:(s.topicWords?.length?s.topicWords:s.topWords).slice(0,50).map($=>({word:$.word,count:$.count,percentage:$.percentage}))})),p=T(()=>s.totalWords===0?0:Math.round(s.uniqueWords/s.totalWords*100)),v=T(()=>{if(!s.posTagStats?.length)return{key:"Balanced",label:n("quotes.topicProfile.styleBalanced"),desc:n("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"};const b=new Map(s.posTagStats.map(B=>[B.tag,B.count])),$=(b.get("n")||0)+(b.get("ns")||0)+(b.get("nt")||0)+(b.get("nz")||0),C=(b.get("v")||0)+(b.get("vn")||0)+(b.get("vd")||0),w=(b.get("a")||0)+(b.get("ad")||0)+(b.get("an")||0),S=$+C+w;if(S===0)return{key:"Balanced",label:n("quotes.topicProfile.styleBalanced"),desc:n("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"};const I=$/S,f=C/S,x=w/S;return I>.5?{key:"Encyclopedia",label:n("quotes.topicProfile.styleEncyclopedia"),desc:n("quotes.topicProfile.styleEncyclopediaDesc"),icon:"i-heroicons-book-open-solid",colorClass:"text-indigo-600 dark:text-indigo-400"}:f>.45?{key:"Action",label:n("quotes.topicProfile.styleAction"),desc:n("quotes.topicProfile.styleActionDesc"),icon:"i-heroicons-rocket-launch-solid",colorClass:"text-orange-600 dark:text-orange-400"}:x>.3?{key:"Expressive",label:n("quotes.topicProfile.styleExpressive"),desc:n("quotes.topicProfile.styleExpressiveDesc"),icon:"i-heroicons-paint-brush-solid",colorClass:"text-pink-600 dark:text-pink-400"}:{key:"Balanced",label:n("quotes.topicProfile.styleBalanced"),desc:n("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"}}),_=T(()=>{if(s.topWords.length===0)return{label:n("quotes.topicProfile.expressionMixed"),desc:n("quotes.topicProfile.expressionMixedDesc"),icon:"i-heroicons-chat-bubble-left-right-solid",colorClass:"text-emerald-600 dark:text-emerald-400"};const b=s.topWords.reduce((w,S)=>w+S.word.length*S.count,0),$=s.topWords.reduce((w,S)=>w+S.count,0),C=b/$;return C<2.5?{label:n("quotes.topicProfile.expressionCasual"),desc:n("quotes.topicProfile.expressionCasualDesc"),icon:"i-heroicons-face-smile-solid",colorClass:"text-amber-600 dark:text-amber-400"}:C>3.5?{label:n("quotes.topicProfile.expressionFormal"),desc:n("quotes.topicProfile.expressionFormalDesc"),icon:"i-heroicons-academic-cap-solid",colorClass:"text-violet-600 dark:text-violet-400"}:{label:n("quotes.topicProfile.expressionMixed"),desc:n("quotes.topicProfile.expressionMixedDesc"),icon:"i-heroicons-chat-bubble-left-right-solid",colorClass:"text-emerald-600 dark:text-emerald-400"}}),y=T(()=>[{icon:"i-heroicons-fire-solid",label:n("quotes.topicProfile.hotTopic"),value:c.value[0]?.word??"-",subtext:c.value[0]?n("quotes.topicProfile.hotTopicDesc",{count:c.value[0].count}):"",colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-sparkles-solid",label:n("quotes.topicProfile.richness"),value:n("quotes.topicProfile.richnessValue",{value:p.value}),subtext:n("quotes.topicProfile.richnessDesc",{unique:s.uniqueWords.toLocaleString(),total:s.totalWords.toLocaleString()}),colorClass:"text-blue-600 dark:text-blue-400"},{icon:v.value.icon,label:n("quotes.topicProfile.chatStyle"),value:v.value.label,subtext:v.value.desc,colorClass:v.value.colorClass},{icon:_.value.icon,label:n("quotes.topicProfile.expressionStyle"),value:_.value.label,subtext:_.value.desc,colorClass:_.value.colorClass}]),k=["#6366f1","#ec4899","#f97316","#22c55e","#3b82f6","#8b5cf6","#14b8a6","#f43f5e"];return(b,$)=>{const C=_e;return i(),W(t(na),null,{default:F(()=>[a("div",eb,[a("div",tb,[a("div",ab,[a("div",sb,[o.value?(i(),m("p",nb,d(o.value),1)):E("",!0),a("div",ob,[a("span",lb,d(t(n)("quotes.topicProfile.heroPrefix")),1),a("span",ib,d(r.totalMessages.toLocaleString()),1),a("span",rb,d(t(n)("quotes.topicProfile.heroMiddle")),1)]),a("div",ub,[a("span",cb,d(t(n)("quotes.topicProfile.heroMiddleSecond")),1),a("span",db,d(r.uniqueWords.toLocaleString()),1),a("span",mb,d(t(n)("quotes.topicProfile.heroSuffix")),1)]),c.value.length>0?(i(),m("div",gb,[a("span",pb,d(t(n)("quotes.topicProfile.topTopicsPrefix")),1),(i(!0),m(re,null,ve(c.value,(w,S)=>(i(),m(re,{key:w.word},[a("span",{class:"cursor-pointer font-bold text-xl transition-opacity hover:opacity-70",style:et({color:k[S%k.length]}),onClick:I=>u("wordClick",w.word)},d(w.word),13,hb),S<c.value.length-1?(i(),m("span",fb,"·")):E("",!0)],64))),128))])):E("",!0)])]),g.value.words.length>0?(i(),m("div",vb,[a("div",yb,[h(t(e),{data:g.value,height:"100%","max-words":50,"size-scale":.8,"draw-out-of-bound":!0,shape:"rectangle","color-scheme":"default",onWordClick:$[0]||($[0]=w=>u("wordClick",w))},null,8,["data"])])])):E("",!0)])]),a("div",xb,[$[1]||($[1]=a("div",{class:"mb-3 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Topic Profile ")],-1)),a("div",bb,[(i(!0),m(re,null,ve(y.value,w=>(i(),m("div",{key:w.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[h(C,{name:w.icon,class:J(["mt-0.5 h-3.5 w-3.5 shrink-0",w.colorClass])},null,8,["name","class"]),a("div",kb,[a("div",{class:J(["truncate font-mono text-sm font-black leading-tight tabular-nums",w.colorClass])},d(w.value),3),a("div",_b,d(w.label),1),a("div",wb,d(w.subtext),1)])]))),128))])]),a("div",$b,[a("div",Cb,[h(C,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),$[2]||($[2]=a("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),a("span",Sb,d(t(n)("quotes.topicProfile.watermark")),1)])]),_:1})}}}),Tb={class:"px-5 py-4 sm:px-6"},Mb={class:"mb-4 flex items-center gap-2"},zb={class:"text-[15px] font-black tracking-tight text-gray-900 dark:text-white"},Ab={class:"flex flex-wrap justify-center gap-2"},qb=["onClick"],Lb=ce({__name:"SharedTopicsCard",props:{sessionId:{},timeFilter:{},dictType:{},excludeWords:{}},emits:["wordClick"],setup(r,{emit:l}){const{t:e}=we(),n=za(),s=r,u=l,o=T(()=>n.locale),c=z([]),g=z([]),p=T(()=>c.value.slice(0,20)),v=["bg-indigo-50 text-indigo-600 ring-1 ring-indigo-500/20 dark:bg-indigo-500/10 dark:text-indigo-400 dark:ring-indigo-500/30","bg-pink-50 text-pink-600 ring-1 ring-pink-500/20 dark:bg-pink-500/10 dark:text-pink-400 dark:ring-pink-500/30","bg-orange-50 text-orange-600 ring-1 ring-orange-500/20 dark:bg-orange-500/10 dark:text-orange-400 dark:ring-orange-500/30","bg-green-50 text-green-600 ring-1 ring-green-500/20 dark:bg-green-500/10 dark:text-green-400 dark:ring-green-500/30","bg-blue-50 text-blue-600 ring-1 ring-blue-500/20 dark:bg-blue-500/10 dark:text-blue-400 dark:ring-blue-500/30","bg-violet-50 text-violet-600 ring-1 ring-violet-500/20 dark:bg-violet-500/10 dark:text-violet-400 dark:ring-violet-500/30","bg-teal-50 text-teal-600 ring-1 ring-teal-500/20 dark:bg-teal-500/10 dark:text-teal-400 dark:ring-teal-500/30","bg-rose-50 text-rose-600 ring-1 ring-rose-500/20 dark:bg-rose-500/10 dark:text-rose-400 dark:ring-rose-500/30","bg-yellow-50 text-yellow-600 ring-1 ring-yellow-500/20 dark:bg-yellow-500/10 dark:text-yellow-400 dark:ring-yellow-500/30","bg-cyan-50 text-cyan-600 ring-1 ring-cyan-500/20 dark:bg-cyan-500/10 dark:text-cyan-400 dark:ring-cyan-500/30"];async function _(){if(s.sessionId)try{g.value.length===0&&(g.value=await Ke().getMembers(s.sessionId));const y=[...g.value].sort((I,f)=>f.messageCount-I.messageCount).slice(0,2);if(y.length<2){c.value=[];return}const k={locale:o.value,timeFilter:s.timeFilter?{startTs:s.timeFilter.startTs,endTs:s.timeFilter.endTs}:void 0,topN:100,minCount:2,posFilterMode:"meaningful",enableStopwords:!0,dictType:s.dictType??"default",excludeWords:s.excludeWords?.length?[...s.excludeWords]:void 0},b=Ke(),[$,C]=await Promise.all([b.getWordFrequency(s.sessionId,{...k,memberId:y[0].id}),b.getWordFrequency(s.sessionId,{...k,memberId:y[1].id})]),w=new Map(C.words.map(I=>[I.word,I.count])),S=[];for(const I of $.words){const f=w.get(I.word);f&&S.push({word:I.word,countA:I.count,countB:f})}S.sort((I,f)=>f.countA+f.countB-(I.countA+I.countB)),c.value=S.slice(0,30)}catch(y){console.error("加载共同话题数据失败:",y),c.value=[]}}return fe(()=>s.sessionId,()=>{g.value=[]}),fe(()=>[s.sessionId,s.timeFilter,s.dictType,s.excludeWords],()=>{_()},{immediate:!0,deep:!0}),(y,k)=>{const b=_e;return p.value.length>0?(i(),W(t(mt),{key:0},{default:F(()=>[a("div",Tb,[a("div",Mb,[h(b,{name:"i-heroicons-link",class:"h-4 w-4 text-emerald-500"}),a("span",zb,d(t(e)("quotes.topicProfile.sharedTopics")),1)]),a("div",Ab,[(i(!0),m(re,null,ve(p.value,($,C)=>(i(),m("span",{key:$.word,class:J(["cursor-pointer rounded-full px-3 py-1 text-xs font-bold transition-opacity hover:opacity-80",v[C%v.length]]),onClick:w=>u("wordClick",$.word)},d($.word),11,qb))),128))])])]),_:1})):E("",!0)}}}),ws=Dn("wordFilter",()=>{const r=z([]),l=z(null),e=z({}),n=z(!1);function s(){return`wf_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function u(w,S=[]){const I={id:s(),name:w,words:[...S],createdAt:Date.now()};return r.value.push(I),I}function o(w,S){const I=r.value.find(f=>f.id===w);I&&(S.name!==void 0&&(I.name=S.name),S.words!==void 0&&(I.words=[...S.words]))}function c(w){r.value=r.value.filter(S=>S.id!==w),l.value===w&&(l.value=null);for(const[S,I]of Object.entries(e.value))I===w&&delete e.value[S]}function g(w){l.value=w}function p(w,S){e.value[w]=S}function v(w){delete e.value[w]}function _(w){return w in e.value?e.value[w]:l.value}function y(w){const S=_(w);return S?r.value.find(f=>f.id===S)?.words??[]:[]}function k(w){return r.value.find(S=>S.id===w)}const b=T(()=>r.value.map(w=>({label:w.name,value:w.id,isDefault:w.id===l.value,wordCount:w.words.length})));function $(){n.value=!0}function C(){n.value=!1}return{schemes:r,defaultSchemeId:l,sessionSchemeOverrides:e,showWordFilterModal:n,schemeOptions:b,createScheme:u,updateScheme:o,deleteScheme:c,setDefaultScheme:g,setSessionScheme:p,clearSessionScheme:v,getActiveSchemeId:_,getExcludeWords:y,getSchemeById:k,openModal:$,closeModal:C}},{persist:!1,backendPersist:{pick:["schemes","defaultSchemeId","sessionSchemeOverrides"],key:"wordFilter"}}),Db={class:"flex flex-col",style:{height:"520px"}},Eb={class:"flex items-center justify-between border-b border-gray-200 px-6 py-4 dark:border-white/5"},Bb={class:"flex items-center gap-3"},Fb={class:"flex h-9 w-9 items-center justify-center rounded-xl bg-linear-to-br from-pink-400 to-pink-600"},Rb={class:"text-lg font-semibold text-gray-900 dark:text-white"},Vb={class:"flex flex-1 overflow-hidden"},Ob={class:"flex w-[200px] shrink-0 flex-col border-r border-gray-200 dark:border-white/5"},Pb={class:"flex items-center justify-between px-3 py-2"},jb={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Nb={class:"flex-1 overflow-y-auto px-2 pb-2"},Ub=["onClick"],Wb={class:"truncate text-sm"},Hb={class:"ml-auto text-xs text-gray-400 dark:text-gray-500"},Kb={key:0,class:"px-3 py-8 text-center text-xs text-gray-400 dark:text-gray-500"},Yb={class:"flex flex-1 flex-col overflow-hidden"},Gb={class:"flex-1 space-y-4 overflow-y-auto p-5"},Qb={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},Jb={class:"flex items-center gap-2"},Xb={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},Zb={class:"flex gap-2"},e1={class:"mb-1.5 flex items-center justify-between"},t1={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},a1={class:"ml-1 text-gray-400 dark:text-gray-500"},s1={key:0,class:"flex max-h-[220px] flex-wrap gap-1.5 overflow-y-auto rounded-lg border border-gray-200 p-3 dark:border-white/5"},n1={key:1,class:"rounded-lg border border-dashed border-gray-300 px-4 py-6 text-center text-xs text-gray-400 dark:border-gray-600 dark:text-gray-500"},o1={class:"flex shrink-0 justify-end border-t border-gray-200 px-5 py-3 dark:border-white/5"},l1={key:1,class:"flex flex-1 flex-col items-center justify-center gap-3 text-gray-400 dark:text-gray-500"},i1={class:"text-sm"},r1=ce({__name:"WordFilterModal",setup(r){const{t:l}=we(),e=ws(),n=T({get:()=>e.showWordFilterModal,set:S=>S?e.openModal():e.closeModal()}),s=z(null),u=z(""),o=z(""),c=z(null),g=T(()=>s.value?e.getSchemeById(s.value)??null:null),p=T(()=>s.value===e.defaultSchemeId);fe(n,S=>{S&&(e.schemes.length>0&&!s.value&&(s.value=e.schemes[0].id),v())}),fe(s,()=>{v(),o.value=""});function v(){u.value=g.value?.name??""}function _(){const S=e.createScheme(l("wordFilter.defaultSchemeName"));s.value=S.id,qe(()=>{c.value?.focus(),c.value?.select()})}function y(){if(!s.value)return;const S=e.schemes.findIndex(I=>I.id===s.value);if(e.deleteScheme(s.value),e.schemes.length>0){const I=Math.min(S,e.schemes.length-1);s.value=e.schemes[I].id}else s.value=null}function k(){!s.value||!u.value.trim()||e.updateScheme(s.value,{name:u.value.trim()})}function b(){s.value&&(p.value?e.setDefaultScheme(null):e.setDefaultScheme(s.value))}function $(){if(!s.value||!o.value.trim())return;const I=o.value.trim().split(/[,,\n\r\t;;|、\s]+/).map(R=>R.trim()).filter(R=>R.length>0);if(I.length===0)return;const f=g.value;if(!f)return;const x=new Set(f.words.map(R=>R.toLowerCase())),B=I.filter(R=>!x.has(R.toLowerCase()));B.length>0&&e.updateScheme(s.value,{words:[...f.words,...B]}),o.value=""}function C(S){if(!s.value)return;const I=g.value;I&&e.updateScheme(s.value,{words:I.words.filter(f=>f!==S)})}function w(){s.value&&e.updateScheme(s.value,{words:[]})}return(S,I)=>{const f=_e,x=Ue,B=Ft,R=ps,D=Xe;return i(),W(D,{open:n.value,"onUpdate:open":I[4]||(I[4]=A=>n.value=A),ui:{content:"max-w-3xl z-50"}},{content:F(()=>[a("div",Db,[a("div",Eb,[a("div",Bb,[a("div",Fb,[h(f,{name:"i-heroicons-funnel",class:"h-4.5 w-4.5 text-white"})]),a("h2",Rb,d(t(l)("wordFilter.title")),1)]),h(x,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:I[0]||(I[0]=A=>n.value=!1)})]),a("div",Vb,[a("div",Ob,[a("div",Pb,[a("span",jb,d(t(l)("wordFilter.schemeList")),1),h(x,{icon:"i-heroicons-plus",size:"xs",variant:"ghost",color:"primary",onClick:_})]),a("div",Nb,[(i(!0),m(re,null,ve(t(e).schemes,A=>(i(),m("div",{key:A.id,class:J(["group mb-1 flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 transition-colors",s.value===A.id?"bg-primary-50 text-primary-700 dark:bg-primary-900/20 dark:text-primary-300":"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-white/5"]),onClick:M=>s.value=A.id},[A.id===t(e).defaultSchemeId?(i(),W(f,{key:0,name:"i-heroicons-star-solid",class:"h-3.5 w-3.5 shrink-0 text-amber-500"})):E("",!0),a("span",Wb,d(A.name),1),a("span",Hb,d(A.words.length),1)],10,Ub))),128)),t(e).schemes.length===0?(i(),m("div",Kb,d(t(l)("wordFilter.emptyScheme")),1)):E("",!0)])]),a("div",Yb,[g.value?(i(),m(re,{key:0},[a("div",Gb,[a("div",null,[a("label",Qb,d(t(l)("wordFilter.schemeName")),1),h(B,{ref_key:"nameInputRef",ref:c,modelValue:u.value,"onUpdate:modelValue":I[1]||(I[1]=A=>u.value=A),size:"sm",placeholder:t(l)("wordFilter.schemeNamePlaceholder"),onBlur:k,onKeydown:Ge(k,["enter"])},null,8,["modelValue","placeholder"])]),a("div",Jb,[h(x,{size:"xs",variant:p.value?"solid":"soft",color:p.value?"warning":"neutral",icon:p.value?"i-heroicons-star-solid":"i-heroicons-star",onClick:b},{default:F(()=>[ie(d(p.value?t(l)("wordFilter.isDefault"):t(l)("wordFilter.setDefault")),1)]),_:1},8,["variant","color","icon"]),h(x,{size:"xs",variant:"soft",color:"error",icon:"i-heroicons-trash",onClick:y},{default:F(()=>[ie(d(t(l)("wordFilter.deleteScheme")),1)]),_:1})]),a("div",null,[a("label",Xb,d(t(l)("wordFilter.addWords")),1),a("div",Zb,[h(B,{modelValue:o.value,"onUpdate:modelValue":I[2]||(I[2]=A=>o.value=A),size:"sm",class:"flex-1",placeholder:t(l)("wordFilter.addWordsPlaceholder"),onKeydown:Ge($,["enter"])},null,8,["modelValue","placeholder"]),h(x,{size:"sm",color:"primary",icon:"i-heroicons-plus",onClick:$},{default:F(()=>[ie(d(t(l)("wordFilter.add")),1)]),_:1})])]),a("div",null,[a("div",e1,[a("label",t1,[ie(d(t(l)("wordFilter.wordList"))+" ",1),a("span",a1,"("+d(g.value.words.length)+")",1)]),g.value.words.length>0?(i(),W(x,{key:0,size:"xs",variant:"ghost",color:"error",onClick:w},{default:F(()=>[ie(d(t(l)("wordFilter.clearAll")),1)]),_:1})):E("",!0)]),g.value.words.length>0?(i(),m("div",s1,[(i(!0),m(re,null,ve(g.value.words,A=>(i(),W(R,{key:A,color:"neutral",variant:"subtle",class:"group/badge cursor-default gap-1 pr-1"},{default:F(()=>[ie(d(A)+" ",1),h(f,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5 cursor-pointer text-gray-400 transition-colors hover:text-red-500",onClick:M=>C(A)},null,8,["onClick"])]),_:2},1024))),128))])):(i(),m("div",n1,d(t(l)("wordFilter.emptyWords")),1))])]),a("div",o1,[h(x,{color:"primary",variant:"soft",onClick:I[3]||(I[3]=A=>n.value=!1)},{default:F(()=>[ie(d(t(l)("wordFilter.close")),1)]),_:1})])],64)):(i(),m("div",l1,[h(f,{name:"i-heroicons-funnel",class:"h-10 w-10"}),a("p",i1,d(t(l)("wordFilter.selectOrCreate")),1),h(x,{size:"sm",color:"primary",variant:"soft",icon:"i-heroicons-plus",onClick:_},{default:F(()=>[ie(d(t(l)("wordFilter.createScheme")),1)]),_:1})]))])])])]),_:1},8,["open"])}}}),u1={class:"main-content mx-auto max-w-[920px] space-y-6 p-4 sm:p-6"},c1={key:0,class:"flex flex-col gap-3 rounded-lg border border-primary-200 bg-primary-50/70 p-4 dark:border-primary-800 dark:bg-primary-950/30 sm:flex-row sm:items-center sm:justify-between"},d1={class:"flex min-w-0 items-start gap-3"},m1={class:"min-w-0 text-sm text-primary-700 dark:text-primary-300"},g1={class:"flex shrink-0 flex-wrap gap-2"},p1={key:1,class:"space-y-6"},h1={class:"flex flex-col gap-6 p-4 sm:p-6 lg:flex-row"},f1={class:"flex min-w-0 flex-1 flex-col"},v1={class:"relative w-full",style:{"aspect-ratio":"16 / 9"}},y1={key:1,class:"absolute inset-0 flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-gray-200 bg-gray-50/40 text-gray-500 dark:border-gray-700 dark:bg-gray-800/30 dark:text-gray-400"},x1={class:"text-xs font-medium"},b1={class:"px-4 text-center text-[11px]"},k1={key:0,class:"mt-2 text-center text-xs text-gray-500 dark:text-gray-400"},_1={class:"w-full shrink-0 space-y-4 lg:w-[280px]"},w1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},$1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},C1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},S1={key:0},I1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},T1={class:"space-y-2"},M1={class:"text-xs text-gray-400 dark:text-gray-500"},z1={key:1},A1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},q1={class:"flex items-center"},L1={key:2,class:"space-y-2"},D1={class:"flex items-center justify-between"},E1={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},B1={class:"flex gap-1"},F1={class:"flex max-h-[360px] flex-wrap gap-1.5 overflow-y-auto"},R1={key:0,class:"ml-1 opacity-60"},V1={class:"mb-2 flex items-center justify-between"},O1={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},P1={key:0,class:"mt-1 text-xs text-gray-400 dark:text-gray-500"},j1={class:"space-y-4"},N1={class:"text-sm text-gray-600 dark:text-gray-300"},U1={class:"flex justify-end gap-2"},W1="default",Qa="chatlab_zhTW_dict_prompt_dismissed",d2=ce({__name:"WordcloudTab",props:{sessionId:{},timeFilter:{},memberId:{},showSharedTopics:{type:Boolean},enableNodeNlpFeatures:{type:Boolean,default:!0},enableRecordNavigation:{type:Boolean,default:!0}},setup(r){const l=gs(()=>Xt(()=>import("./EChartWordcloud-Bd3L3G8I.js"),__vite__mapDeps([3,4,5,6,0,1,2]))),{t:e}=we(),n=za(),s=bt(),u=ws(),o=ot(),c=r,g=z(!0);Zn(g);const p=z([]),v=z({totalMessages:0,totalWords:0,uniqueWords:0}),_=z(1.25),y=z(150),k=T(()=>{const ge=p.value.slice(0,y.value),O=ge.reduce((V,K)=>V+K.count,0);return{words:ge.map(V=>({word:V.word,count:V.count,percentage:O>0?Math.round(V.count/O*1e4)/100:0}))}}),b=z(c.enableNodeNlpFeatures?"meaningful":"all"),$=z(!0),C=z([]),w=z([]),S=z(new Map),I=["n","nr","ns","nt","nz","nw","vn","a","an"],f=z([]),x=T(()=>k.value.words.map(ge=>({word:ge.word,count:ge.count,percentage:ge.percentage??0}))),B=T(()=>[...S.value.entries()].map(([ge,O])=>({tag:ge,count:O}))),R=z(null),D=T({get:()=>u.getActiveSchemeId(c.sessionId),set:ge=>u.setSessionScheme(c.sessionId,ge)}),A=T(()=>[{label:e("wordFilter.noFilter"),value:"__none__"},...u.schemeOptions.map(ge=>({label:ge.isDefault?`${ge.label} ★`:ge.label,value:ge.value}))]),M=T({get:()=>D.value??"__none__",set:ge=>{D.value=ge==="__none__"?null:ge}}),q=T(()=>u.getExcludeWords(c.sessionId)),Y=z("default"),G=z([]),Z=z(!1),ue=z(null),oe=z(!1),H=z(!c.enableNodeNlpFeatures),P=T(()=>n.locale),se=T(()=>n.locale==="zh-TW"),me=T(()=>P.value.startsWith("zh")),he=T(()=>G.value.filter(ge=>ge.downloaded).map(ge=>({label:e(`quotes.wordcloud.dict.${ge.id==="zh-CN"?"zhCN":ge.id==="zh-TW"?"zhTW":ge.id}`),value:ge.id}))),ee=T(()=>G.value.some(ge=>ge.downloaded)),te=T(()=>!c.enableNodeNlpFeatures||!me.value||H.value),N=T(()=>G.value.filter(ge=>!ge.downloaded));async function de(){if(c.enableNodeNlpFeatures)try{G.value=await Pa("/nlp/dicts"),se.value&&Y.value==="default"&&G.value.find(V=>V.id==="zh-TW")?.downloaded&&(Y.value="zh-TW"),G.value.find(O=>O.id==="zh-CN")?.downloaded&&Y.value==="default"&&(Y.value="zh-CN")}catch(ge){console.error("Failed to get dict list:",ge)}finally{H.value=!0}}async function be(ge){Z.value=!0,ue.value=ge;try{const O=await En(`/nlp/dicts/${ge}/download`);O.success?(await de(),Y.value=ge,o.success(e("quotes.wordcloud.dict.downloadSuccess"))):o.fail(e("quotes.wordcloud.dict.downloadFailed"),{description:O.error})}catch{o.fail(e("quotes.wordcloud.dict.downloadFailed"))}finally{Z.value=!1,ue.value=null,oe.value=!1}}function xe(){oe.value=!1,localStorage.setItem(Qa,"true")}function le(){const ge=G.value.find(O=>O.id==="zh-TW");se.value&&ge&&!ge.downloaded&&!localStorage.getItem(Qa)&&(oe.value=!0)}const Q=T(()=>[{label:e("quotes.wordcloud.posFilter.all"),value:"all"},{label:e("quotes.wordcloud.posFilter.meaningful"),value:"meaningful"},{label:e("quotes.wordcloud.posFilter.custom"),value:"custom"}]),X=[{label:"80",value:80},{label:"100",value:100},{label:"150",value:150},{label:"200",value:200},{label:"300",value:300}],pe=Math.max(...X.map(ge=>ge.value)),ke=T(()=>[{label:e("quotes.wordcloud.size.small"),value:.75},{label:e("quotes.wordcloud.size.medium"),value:1},{label:e("quotes.wordcloud.size.large"),value:1.25},{label:e("quotes.wordcloud.size.xlarge"),value:1.5}]),$e=T(()=>w.value.map(ge=>({label:ge.name,tag:ge.tag,value:ge.tag,count:S.value.get(ge.tag)||0,meaningful:ge.meaningful})));async function De(){if(c.enableNodeNlpFeatures)try{const ge=await Pa("/nlp/pos-tags");w.value=ge,C.value=ge.filter(O=>O.meaningful).map(O=>O.tag)}catch(ge){console.error("加载词性标签失败:",ge)}}let Be=0;async function Te(){if(!c.sessionId||!te.value)return;const ge=++Be;try{const O=await Ke().getWordFrequency(c.sessionId,{locale:P.value,timeFilter:c.timeFilter?{startTs:c.timeFilter.startTs,endTs:c.timeFilter.endTs}:void 0,memberId:R.value??void 0,topN:50,minCount:2,posFilterMode:c.enableNodeNlpFeatures?"custom":"all",customPosTags:c.enableNodeNlpFeatures?[...I]:void 0,enableStopwords:!0,dictType:Y.value,excludeWords:q.value.length>0?[...q.value]:void 0});if(ge!==Be)return;f.value=O.words.map(V=>({word:V.word,count:V.count,percentage:V.percentage}))}catch(O){if(console.error("加载话题迷你词云数据失败:",O),ge!==Be)return;f.value=[]}}let Pe=0;async function je(){if(!c.sessionId||!te.value)return;const ge=++Pe;p.value.length===0&&(g.value=!0);try{const O=await Ke().getWordFrequency(c.sessionId,{locale:P.value,timeFilter:c.timeFilter?{startTs:c.timeFilter.startTs,endTs:c.timeFilter.endTs}:void 0,memberId:R.value??void 0,topN:pe,minCount:2,posFilterMode:c.enableNodeNlpFeatures?b.value:"all",customPosTags:c.enableNodeNlpFeatures&&b.value==="custom"?[...C.value]:void 0,enableStopwords:$.value,dictType:Y.value,excludeWords:q.value.length>0?[...q.value]:void 0});if(ge!==Pe)return;if(p.value=O.words.map(V=>({word:V.word,count:V.count,percentage:V.percentage})),v.value={totalMessages:O.totalMessages,totalWords:O.totalWords,uniqueWords:O.uniqueWords},O.posTagStats){const V=new Map;for(const K of O.posTagStats)V.set(K.tag,K.count);S.value=V}}catch(O){if(console.error("加载词频数据失败:",O),ge!==Pe)return;p.value=[]}finally{ge===Pe&&(g.value=!1)}}fe(()=>c.sessionId,()=>{R.value=null,p.value=[],f.value=[],v.value={totalMessages:0,totalWords:0,uniqueWords:0},S.value=new Map}),fe(()=>[c.sessionId,c.timeFilter,R.value,b.value,$.value,Y.value,q.value,te.value],()=>{je()},{immediate:!0,deep:!0}),fe(()=>[c.sessionId,c.timeFilter,R.value,Y.value,q.value,te.value],()=>{Te()},{immediate:!0,deep:!0}),fe(C,()=>{b.value==="custom"&&je()},{deep:!0}),fe(P,()=>{je()});function Se(ge){c.enableRecordNavigation&&s.openChatRecordDrawer({keywords:[ge]})}return Re(async()=>{c.enableNodeNlpFeatures&&(De(),await de(),le())}),(ge,O)=>{const V=_e,K=Ue,L=wa,j=ps,U=Xe;return i(),m("div",u1,[c.enableNodeNlpFeatures&&me.value&&!ee.value?(i(),m("div",c1,[a("div",d1,[h(V,{name:"i-heroicons-information-circle",class:"mt-0.5 shrink-0 text-xl text-primary-500"}),a("p",m1,d(t(e)("quotes.wordcloud.dict.needDownload")),1)]),a("div",g1,[(i(!0),m(re,null,ve(G.value,ae=>(i(),W(K,{key:ae.id,size:"sm",color:"primary",loading:Z.value&&ue.value===ae.id,disabled:Z.value&&ue.value!==ae.id,icon:"i-heroicons-arrow-down-tray",onClick:ne=>be(ae.id)},{default:F(()=>[ie(d(t(e)(`quotes.wordcloud.dict.download_${ae.id}`,ae.label)),1)]),_:2},1032,["loading","disabled","onClick"]))),128))])])):E("",!0),te.value?(i(),m("div",p1,[g.value&&x.value.length===0?(i(),W(t(Yt),{key:0,text:t(e)("quotes.wordcloud.loading"),class:"py-8"},null,8,["text"])):E("",!0),h(Ib,{"total-messages":v.value.totalMessages,"total-words":v.value.totalWords,"unique-words":v.value.uniqueWords,"top-words":x.value,"topic-words":f.value,"pos-tag-stats":B.value,"time-filter":c.timeFilter,onWordClick:Se},null,8,["total-messages","total-words","unique-words","top-words","topic-words","pos-tag-stats","time-filter"]),c.showSharedTopics?(i(),W(Lb,{key:1,"session-id":c.sessionId,"time-filter":c.timeFilter,"dict-type":Y.value,"exclude-words":q.value,onWordClick:Se},null,8,["session-id","time-filter","dict-type","exclude-words"])):E("",!0),h(t(Ze),{title:t(e)("quotes.wordcloud.stats.wordsLabel"),"show-divider":!1},{default:F(()=>[a("div",h1,[a("div",f1,[a("div",v1,[g.value?(i(),W(t(Yt),{key:0,text:t(e)("quotes.wordcloud.loading"),class:"absolute inset-0 z-10 rounded-lg bg-white/80 dark:bg-page-dark/80"},null,8,["text"])):x.value.length===0?(i(),m("div",y1,[h(V,{name:"i-heroicons-chat-bubble-bottom-center-text",class:"text-2xl"}),a("p",x1,d(t(e)("quotes.wordcloud.empty.title")),1),a("p",b1,d(t(e)("quotes.wordcloud.empty.description")),1)])):(i(),W(t(l),{key:2,data:k.value,height:"100%","max-words":y.value,"color-scheme":W1,"size-scale":_.value,loading:g.value,onWordClick:Se},null,8,["data","max-words","size-scale","loading"]))]),c.enableRecordNavigation?(i(),m("p",k1,d(t(e)("quotes.wordcloud.stats.clickHint")),1)):E("",!0)]),a("div",_1,[a("div",null,[a("h4",w1,d(t(e)("quotes.wordcloud.config.maxWords")),1),h(t(pt),{modelValue:y.value,"onUpdate:modelValue":O[0]||(O[0]=ae=>y.value=ae),size:"xs",items:X},null,8,["modelValue"])]),a("div",null,[a("h4",$1,d(t(e)("quotes.wordcloud.config.sizeScale")),1),h(t(pt),{modelValue:_.value,"onUpdate:modelValue":O[1]||(O[1]=ae=>_.value=ae),size:"xs",items:ke.value},null,8,["modelValue","items"])]),a("div",null,[a("h4",C1,d(t(e)("quotes.wordcloud.config.userFilter")),1),h(Uv,{modelValue:R.value,"onUpdate:modelValue":O[2]||(O[2]=ae=>R.value=ae),"session-id":c.sessionId,class:"w-full"},null,8,["modelValue","session-id"])]),c.enableNodeNlpFeatures?(i(),m("div",S1,[a("h4",I1,d(t(e)("quotes.wordcloud.config.dict")),1),a("div",T1,[he.value.length>1?(i(),W(t(pt),{key:0,modelValue:Y.value,"onUpdate:modelValue":O[3]||(O[3]=ae=>Y.value=ae),size:"xs",items:he.value},null,8,["modelValue","items"])):E("",!0),(i(!0),m(re,null,ve(N.value,ae=>(i(),m("div",{key:ae.id,class:"flex items-center gap-2"},[h(K,{size:"xs",variant:"soft",color:"primary",loading:Z.value&&ue.value===ae.id,disabled:Z.value&&ue.value!==ae.id,icon:"i-heroicons-arrow-down-tray",onClick:ne=>be(ae.id)},{default:F(()=>[ie(d(t(e)(`quotes.wordcloud.dict.download_${ae.id}`,t(e)("quotes.wordcloud.dict.download"))),1)]),_:2},1032,["loading","disabled","onClick"]),a("span",M1,d(t(e)("quotes.wordcloud.dict.downloadHint")),1)]))),128))])])):E("",!0),c.enableNodeNlpFeatures?(i(),m("div",z1,[a("h4",A1,d(t(e)("quotes.wordcloud.config.posFilter")),1),h(t(pt),{modelValue:b.value,"onUpdate:modelValue":O[4]||(O[4]=ae=>b.value=ae),size:"xs",items:Q.value},null,8,["modelValue","items"])])):E("",!0),a("div",q1,[h(L,{modelValue:$.value,"onUpdate:modelValue":O[5]||(O[5]=ae=>$.value=ae),label:t(e)("quotes.wordcloud.config.enableStopwords")},null,8,["modelValue","label"])]),c.enableNodeNlpFeatures&&b.value==="custom"?(i(),m("div",L1,[a("div",D1,[a("h4",E1,d(t(e)("quotes.wordcloud.posFilter.customHint")),1),a("div",B1,[h(K,{size:"xs",variant:"ghost",color:"neutral",onClick:O[6]||(O[6]=ae=>C.value=w.value.filter(ne=>ne.meaningful).map(ne=>ne.tag))},{default:F(()=>[ie(d(t(e)("quotes.wordcloud.posFilter.selectMeaningful")),1)]),_:1}),h(K,{size:"xs",variant:"ghost",color:"neutral",onClick:O[7]||(O[7]=ae=>C.value=w.value.map(ne=>ne.tag))},{default:F(()=>[ie(d(t(e)("quotes.wordcloud.posFilter.selectAll")),1)]),_:1}),h(K,{size:"xs",variant:"ghost",color:"neutral",onClick:O[8]||(O[8]=ae=>C.value=[])},{default:F(()=>[ie(d(t(e)("quotes.wordcloud.posFilter.clearAll")),1)]),_:1})])]),a("div",F1,[(i(!0),m(re,null,ve($e.value,ae=>(i(),W(j,{key:ae.value,color:C.value.includes(ae.value)?"primary":"neutral",variant:C.value.includes(ae.value)?"solid":"outline",class:"cursor-pointer select-none transition-colors",onClick:()=>{C.value.includes(ae.value)?C.value=C.value.filter(ne=>ne!==ae.value):C.value=[...C.value,ae.value]}},{default:F(()=>[ie(d(ae.label)+" ",1),ae.count>0?(i(),m("span",R1,"("+d(ae.count)+")",1)):E("",!0)]),_:2},1032,["color","variant","onClick"]))),128))])])):E("",!0),a("div",null,[a("div",V1,[a("h4",O1,d(t(e)("wordFilter.filterScheme")),1),h(K,{size:"xs",variant:"ghost",color:"neutral",icon:"i-heroicons-cog-6-tooth","aria-label":t(e)("wordFilter.manage"),onClick:O[9]||(O[9]=ae=>t(u).openModal())},null,8,["aria-label"])]),h(t(pt),{modelValue:M.value,"onUpdate:modelValue":O[10]||(O[10]=ae=>M.value=ae),size:"xs",items:A.value},null,8,["modelValue","items"]),q.value.length>0?(i(),m("p",P1,d(t(e)("wordFilter.activeCount",{count:q.value.length})),1)):E("",!0)])])])]),_:1},8,["title"])])):E("",!0),c.enableNodeNlpFeatures?(i(),W(U,{key:2,open:oe.value,"onUpdate:open":O[12]||(O[12]=ae=>oe.value=ae),title:t(e)("quotes.wordcloud.dict.promptTitle")},{body:F(()=>[a("div",j1,[a("p",N1,d(t(e)("quotes.wordcloud.dict.promptDescription")),1),a("div",U1,[h(K,{variant:"ghost",color:"neutral",onClick:xe},{default:F(()=>[ie(d(t(e)("quotes.wordcloud.dict.promptLater")),1)]),_:1}),h(K,{color:"primary",loading:Z.value,onClick:O[11]||(O[11]=ae=>be("zh-TW"))},{default:F(()=>[ie(d(t(e)("quotes.wordcloud.dict.promptDownload")),1)]),_:1},8,["loading"])])])]),_:1},8,["open","title"])):E("",!0),h(r1)])}}});function m2(r){const l=T(()=>Bn(r)),e=T(()=>{const s=l.value;return s.length<2?!1:new Set(s.map(o=>Ee(o.date).year())).size>1}),n=T(()=>{const s=l.value,u=50;if(s.length<=u){const p=e.value?"YYYY/MM/DD":"MM/DD";return{labels:s.map(v=>Ee(v.date).format(p)),values:s.map(v=>v.messageCount)}}const o=Math.ceil(s.length/u),c=[],g=[];for(let p=0;p<s.length;p+=o){const v=s.slice(p,p+o);if(v.length===0)continue;const _=Math.floor(v.length/2),y=v[_].date,k=e.value?"YYYY/MM/DD":"MM/DD";c.push(Ee(y).format(k));const b=v.reduce((C,w)=>C+w.messageCount,0),$=Math.round(b/v.length);g.push($)}return{labels:c,values:g}});return{isMultiYear:e,dailyChartData:n}}const H1=86400;function Qt(r){return typeof r=="number"&&Number.isFinite(r)}function K1(r){return Qt(r?.startTs)&&Qt(r?.endTs)}function $s(r,l){const e=l?.startTs??r?.start,n=l?.endTs??r?.end;return!Qt(e)||!Qt(n)||n<e?null:{start:e,end:n}}function Y1(r,l=0){return!r||r.end<r.start?0:Math.max(Math.ceil((r.end-r.start)/H1),l,1)}function G1(r){return r?[Ee.unix(r.start).format("YYYY-MM-DD"),Ee.unix(r.end).format("YYYY-MM-DD")]:null}function Q1(r,l){const{t:e}=we(),n=T(()=>$s(r.timeRange,r.timeFilter)),s=T(()=>K1(r.timeFilter)),u=T(()=>r.dailyActivity.filter(B=>B.messageCount>0).length),o=T(()=>Y1(n.value,u.value)),c=T(()=>s.value?r.filteredMessageCount:r.session.messageCount),g=T(()=>s.value?r.filteredMemberCount??r.session.memberCount:r.session.memberCount),p=T(()=>o.value),v=T(()=>p.value===0?0:Math.round(c.value/p.value)),_=T(()=>o.value===0?0:Math.round(c.value/o.value)),y=T(()=>r.messageTypes.find(R=>R.type===1)?.count||0),k=T(()=>r.hourlyActivity.length?r.hourlyActivity.reduce((B,R)=>R.messageCount>B.messageCount?R:B,r.hourlyActivity[0]):null),b=T(()=>l.value.length?l.value.reduce((B,R)=>R.messageCount>B.messageCount?R:B,l.value[0]):null),$=T(()=>[e("common.weekday.mon"),e("common.weekday.tue"),e("common.weekday.wed"),e("common.weekday.thu"),e("common.weekday.fri"),e("common.weekday.sat"),e("common.weekday.sun")]),C=T(()=>{if(!l.value.length)return{weekday:0,weekend:0};const B=l.value.filter(A=>A.weekday>=1&&A.weekday<=5).reduce((A,M)=>A+M.messageCount,0),R=l.value.filter(A=>A.weekday>=6&&A.weekday<=7).reduce((A,M)=>A+M.messageCount,0),D=B+R;return{weekday:D>0?Math.round(B/D*100):0,weekend:D>0?Math.round(R/D*100):0}}),w=T(()=>r.dailyActivity.length?r.dailyActivity.reduce((B,R)=>R.messageCount>B.messageCount?R:B,r.dailyActivity[0]):null),S=T(()=>o.value),I=T(()=>S.value>0?Math.round(u.value/S.value*100):0),f=T(()=>{if(!r.hourlyActivity.length)return{count:0,ratio:0};const B=r.hourlyActivity.reduce((D,A)=>D+A.messageCount,0),R=r.hourlyActivity.filter(D=>D.hour>=0&&D.hour<=4).reduce((D,A)=>D+A.messageCount,0);return{count:R,ratio:B>0?Math.round(R/B*100):0}}),x=T(()=>{if(!r.dailyActivity.length)return 0;const B=[...r.dailyActivity].filter(A=>A.messageCount>0).sort((A,M)=>Ee(A.date).valueOf()-Ee(M.date).valueOf());if(B.length===0)return 0;let R=1,D=1;for(let A=1;A<B.length;A++){const M=Ee(B[A-1].date);Ee(B[A].date).diff(M,"day")===1?D++:(D>R&&(R=D),D=1)}return D>R&&(R=D),R});return{durationDays:o,displayMessageCount:c,displayMemberCount:g,dailyAvgMessages:_,totalDurationDays:p,totalDailyAvgMessages:v,imageCount:y,peakHour:k,peakWeekday:b,weekdayNames:$,weekdayVsWeekend:C,peakDay:w,activeDays:u,totalDays:S,activeRate:I,lateNightChat:f,maxConsecutiveDays:x}}function J1(r){const l=z([]);let e=0;async function n(){const s=++e,u=r.sessionId();if(!u){l.value=[];return}try{const o=await Ke().getWeekdayActivity(u,r.timeFilter());s===e&&(l.value=o)}catch(o){s===e&&console.error("Failed to load weekday activity:",o)}}return fe([r.sessionId,r.timeFilter],()=>n(),{immediate:!0,deep:!0}),{weekdayActivity:l}}const X1={key:0,class:"relative z-10 px-5 pb-5 pt-2 sm:px-8 sm:pb-6"},Z1={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},ek={class:"min-w-0"},tk={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},ak={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},sk={key:1,class:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4"},nk={class:"text-sm text-gray-500"},ok={class:"text-sm text-gray-500"},lk={class:"ml-1 font-semibold text-pink-500"},ik={class:"text-sm text-gray-500"},rk={class:"text-sm text-gray-500"},uk={class:"text-sm text-gray-500"},ck={class:"text-sm text-gray-500"},dk={class:"text-sm text-gray-500"},mk={class:"text-sm text-gray-500"},gk=ce({__name:"OverviewStatCards",props:{dailyAvgMessages:{},durationDays:{},imageCount:{},peakHour:{},peakWeekday:{},weekdayNames:{},weekdayVsWeekend:{},peakDay:{},activeDays:{},totalDays:{},activeRate:{},lateNightCount:{},lateNightRatio:{},maxConsecutiveDays:{},flat:{type:Boolean,default:!1}},setup(r){const{t:l}=we(),e=r,n=T(()=>[{icon:"i-heroicons-chat-bubble-left-right",label:l("analysis.overview.statCards.dailyAvgMessages"),value:l("analysis.overview.statCards.messagesCount",{count:e.dailyAvgMessages}),subtext:l("analysis.overview.statCards.daysCount",{count:e.durationDays}),colorClass:"text-blue-600 dark:text-blue-400"},{icon:"i-heroicons-photo",label:l("analysis.overview.statCards.imageMessages"),value:l("analysis.overview.statCards.imagesCount",{count:e.imageCount}),subtext:`${l("analysis.overview.statCards.peakHour")} ${e.peakHour?.hour||0}:00`,colorClass:"text-pink-600 dark:text-pink-400"},{icon:"i-heroicons-calendar-days",label:l("analysis.overview.statCards.mostActiveWeekday"),value:e.peakWeekday?e.weekdayNames[e.peakWeekday.weekday-1]:"-",subtext:l("analysis.overview.statCards.messagesOnDay",{count:e.peakWeekday?.messageCount??0}),colorClass:"text-amber-600 dark:text-amber-400"},{icon:"i-heroicons-sun",label:l("analysis.overview.statCards.weekendActivity"),value:`${e.weekdayVsWeekend.weekend}%`,subtext:l("analysis.overview.statCards.weekendRatio"),colorClass:"text-green-600 dark:text-green-400"},{icon:"i-heroicons-fire",label:l("analysis.overview.statCards.mostActiveDate"),value:e.peakDay?Ee(e.peakDay.date).format("MM/DD"):"-",subtext:l("analysis.overview.statCards.messagesOnDay",{count:e.peakDay?.messageCount??0}),colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-moon",label:l("analysis.overview.statCards.lateNightChat"),value:l("analysis.overview.statCards.messagesCount",{count:e.lateNightCount}),subtext:l("analysis.overview.statCards.lateNightRatio",{ratio:e.lateNightRatio}),colorClass:"text-indigo-600 dark:text-indigo-400"},{icon:"i-heroicons-bolt",label:l("analysis.overview.statCards.consecutiveStreak"),value:l("analysis.overview.statCards.daysStreak",{count:e.maxConsecutiveDays}),subtext:l("analysis.overview.statCards.longestStreak"),colorClass:"text-amber-600 dark:text-amber-400"},{icon:"i-heroicons-chart-bar",label:l("analysis.overview.statCards.activityRate"),value:`${e.activeRate}%`,subtext:l("analysis.overview.statCards.activeDaysRatio"),colorClass:"text-gray-900 dark:text-white"}]);return(s,u)=>{const o=_e;return r.flat?(i(),m("div",X1,[u[0]||(u[0]=a("div",{class:"mb-3 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"},"Key Metrics")],-1)),a("div",Z1,[(i(!0),m(re,null,ve(n.value,c=>(i(),m("div",{key:c.icon+c.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[h(o,{name:c.icon,class:J(["mt-0.5 h-3.5 w-3.5 shrink-0",c.colorClass])},null,8,["name","class"]),a("div",ek,[a("div",{class:J(["truncate font-mono text-sm font-black leading-tight tabular-nums",c.colorClass])},d(c.value),3),a("div",tk,d(c.label),1),a("div",ak,d(c.subtext),1)])]))),128))])])):(i(),m("div",sk,[h(t(lt),{label:t(l)("analysis.overview.statCards.dailyAvgMessages"),value:t(l)("analysis.overview.statCards.messagesCount",{count:r.dailyAvgMessages}),icon:"i-heroicons-chat-bubble-left-right","icon-bg":"blue"},{subtext:F(()=>[a("span",nk,d(t(l)("analysis.overview.statCards.daysCount",{count:r.durationDays})),1)]),_:1},8,["label","value"]),h(t(lt),{label:t(l)("analysis.overview.statCards.imageMessages"),value:t(l)("analysis.overview.statCards.imagesCount",{count:r.imageCount}),icon:"i-heroicons-photo","icon-bg":"pink"},{subtext:F(()=>[a("span",ok,d(t(l)("analysis.overview.statCards.peakHour")),1),a("span",lk,d(r.peakHour?.hour||0)+":00",1)]),_:1},8,["label","value"]),h(t(lt),{label:t(l)("analysis.overview.statCards.mostActiveWeekday"),value:r.peakWeekday?r.weekdayNames[r.peakWeekday.weekday-1]:"-",icon:"i-heroicons-calendar-days","icon-bg":"amber"},{subtext:F(()=>[a("span",ik,d(t(l)("analysis.overview.statCards.messagesOnDay",{count:r.peakWeekday?.messageCount??0})),1)]),_:1},8,["label","value"]),h(t(lt),{label:t(l)("analysis.overview.statCards.weekendActivity"),value:`${r.weekdayVsWeekend.weekend}%`,icon:"i-heroicons-sun","icon-bg":"green"},{subtext:F(()=>[a("span",rk,d(t(l)("analysis.overview.statCards.weekendRatio")),1)]),_:1},8,["label","value"]),h(t(lt),{label:t(l)("analysis.overview.statCards.mostActiveDate"),value:r.peakDay?t(Ee)(r.peakDay.date).format("MM/DD"):"-",icon:"i-heroicons-fire","icon-bg":"red"},{subtext:F(()=>[a("span",uk,d(t(l)("analysis.overview.statCards.messagesOnDay",{count:r.peakDay?.messageCount??0})),1)]),_:1},8,["label","value"]),h(t(lt),{label:t(l)("analysis.overview.statCards.lateNightChat"),value:t(l)("analysis.overview.statCards.messagesCount",{count:r.lateNightCount}),icon:"i-heroicons-moon","icon-bg":"blue"},{subtext:F(()=>[a("span",ck,d(t(l)("analysis.overview.statCards.lateNightRatio",{ratio:r.lateNightRatio})),1)]),_:1},8,["label","value"]),h(t(lt),{label:t(l)("analysis.overview.statCards.consecutiveStreak"),value:t(l)("analysis.overview.statCards.daysStreak",{count:r.maxConsecutiveDays}),icon:"i-heroicons-bolt","icon-bg":"amber"},{subtext:F(()=>[a("span",dk,d(t(l)("analysis.overview.statCards.longestStreak")),1)]),_:1},8,["label","value"]),h(t(lt),{label:t(l)("analysis.overview.statCards.activityRate"),value:`${r.activeRate}%`,icon:"i-heroicons-chart-bar","icon-bg":"gray"},{subtext:F(()=>[a("span",mk,d(t(l)("analysis.overview.statCards.activeDaysRatio")),1)]),_:1},8,["label","value"])]))}}}),pk={class:"relative z-10 px-5 pt-6 pb-4 sm:px-8 sm:pt-8"},hk={class:"text-2xl font-bold tracking-tight text-gray-900 sm:text-3xl dark:text-gray-100"},fk={class:"mt-4 flex flex-col gap-5 sm:flex-row sm:items-start sm:gap-24"},vk={class:"min-w-0 flex flex-col gap-2 text-sm font-medium text-gray-500 dark:text-gray-400"},yk={class:"flex items-center gap-2"},xk={class:"flex h-6 w-6 shrink-0 items-center justify-center"},bk={class:"whitespace-nowrap"},kk={key:0,class:"flex items-center gap-2"},_k={class:"flex h-6 w-6 shrink-0 items-center justify-center"},wk={class:"font-mono text-xs opacity-90 whitespace-nowrap"},$k={class:"grid grid-cols-2 gap-x-8 gap-y-4 sm:flex sm:shrink-0 sm:gap-6"},Ck={class:"flex flex-col gap-1 text-center"},Sk={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},Ik={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Tk={class:"flex flex-col gap-1 text-center"},Mk={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},zk={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Ak={class:"flex flex-col gap-1 text-center"},qk={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},Lk={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Dk={class:"flex flex-col gap-1 text-center"},Ek={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},Bk={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Fk={class:"relative z-10 px-5 pb-2 sm:px-8"},Rk={class:"overflow-x-auto overflow-y-hidden scrollbar-hide py-1"},g2=ce({__name:"OverviewIdentityCard",props:{session:{},dailyActivity:{},messageTypes:{},hourlyActivity:{},timeRange:{},filteredMessageCount:{},filteredMemberCount:{},timeFilter:{},capturable:{type:Boolean,default:!0}},setup(r){ta([hs,oo,fs,qa,vs,aa]);const{t:l,locale:e}=we(),n=Zt(),s=r,{weekdayActivity:u}=J1({sessionId:()=>s.session.id,timeFilter:()=>s.timeFilter}),{durationDays:o,displayMessageCount:c,dailyAvgMessages:g,imageCount:p,peakHour:v,peakWeekday:_,weekdayNames:y,weekdayVsWeekend:k,peakDay:b,activeDays:$,totalDays:C,activeRate:w,lateNightChat:S,maxConsecutiveDays:I}=Q1(s,u),f=z(null);let x=null;const B=T(()=>$s(s.timeRange,s.timeFilter)),R=T(()=>B.value?lo(B.value.start,B.value.end,"YYYY/MM/DD"):""),D=T(()=>{const H=G1(B.value);if(H)return H;const me=(he=>he.toISOString().slice(0,10))(new Date);return[me,me]}),A=T(()=>{const[H,P]=D.value,se=new Date(H+"T00:00:00Z"),me=new Date(P+"T00:00:00Z"),he=new Map;s.dailyActivity.filter(N=>N.date>=H&&N.date<=P).forEach(N=>he.set(N.date,N.messageCount));const ee=[],te=new Date(se);for(;te<=me;){const N=te.toISOString().slice(0,10),de=he.get(N)||0;ee.push({value:[N,de],itemStyle:de===0?{color:Y.value}:void 0}),te.setUTCDate(te.getUTCDate()+1)}return ee}),M=T(()=>s.dailyActivity.length===0?10:Math.max(...s.dailyActivity.map(H=>H.messageCount),1)),q={light:["#fce4ec","#f8a4b8","#f06292","#e91e63"],dark:["rgba(238, 69, 103, 0.15)","rgba(238, 69, 103, 0.45)","rgba(238, 69, 103, 0.75)","rgba(238, 69, 103, 1)"]},Y=T(()=>n.value?"rgba(255, 255, 255, 0.04)":"#ebedf0"),G=T(()=>({tooltip:{trigger:"item",formatter:H=>{const P=H.value[0],se=H.value[1];return`${P}<br/>${l("views.message.calendarTooltipMessages")}: ${se}`}},visualMap:{min:1,max:M.value,calculable:!1,orient:"horizontal",left:"center",bottom:0,itemWidth:10,itemHeight:80,text:[`${M.value}`,"1"],inRange:{color:n.value?q.dark:q.light},textStyle:{color:n.value?"#8b949e":"#6b7280",fontSize:10},show:!0},calendar:{top:20,left:30,cellSize:[13,13],range:D.value,itemStyle:{borderWidth:0,color:"transparent"},yearLabel:{show:!1},monthLabel:{show:!0,color:n.value?"#8b949e":"#6b7280",fontSize:10,nameMap:[l("common.month.jan"),l("common.month.feb"),l("common.month.mar"),l("common.month.apr"),l("common.month.may"),l("common.month.jun"),l("common.month.jul"),l("common.month.aug"),l("common.month.sep"),l("common.month.oct"),l("common.month.nov"),l("common.month.dec")]},dayLabel:{show:!0,firstDay:1,color:n.value?"#8b949e":"#9ca3af",fontSize:10,nameMap:[l("common.weekday.sun"),l("common.weekday.mon"),l("common.weekday.tue"),l("common.weekday.wed"),l("common.weekday.thu"),l("common.weekday.fri"),l("common.weekday.sat")]},splitLine:{show:!1}},series:[{type:"custom",coordinateSystem:"calendar",data:A.value,renderItem:(H,P)=>{const se=P.coord(P.value(0)),me=H.coordSys.cellWidth,he=H.coordSys.cellHeight,ee=Math.min(me,he)-3;return{type:"rect",shape:{x:se[0]-ee/2,y:se[1]-ee/2,width:ee,height:ee,r:3},style:{fill:P.visual("color")}}},itemStyle:{borderColor:n.value?"transparent":"rgba(0,0,0,0.02)",borderWidth:1}}]}));function Z(){f.value&&(x=sa(f.value,void 0,{renderer:"canvas"}),x.setOption({backgroundColor:"transparent",...G.value}))}function ue(){x&&x.setOption({backgroundColor:"transparent",...G.value},{notMerge:!0})}function oe(){x?.resize()}return fe([()=>s.dailyActivity,e,D],()=>ue()),fe(n,()=>{x?.dispose(),Z()}),Re(()=>{Z(),window.addEventListener("resize",oe)}),tt(()=>{window.removeEventListener("resize",oe),x?.dispose()}),(H,P)=>{const se=_e;return i(),W(t(na),{capturable:r.capturable},{default:F(()=>[a("div",pk,[a("h2",hk,d(r.session.name),1),a("div",fk,[a("div",vk,[a("div",yk,[a("div",xk,[r.session.type==="group"?(i(),W(se,{key:0,name:"i-heroicons-user-group",class:"h-4 w-4 opacity-70"})):(i(),W(se,{key:1,name:"i-heroicons-user",class:"h-4 w-4 opacity-70"}))]),a("span",bk,d(r.session.platform.toUpperCase())+" · "+d(r.session.type==="private"?t(l)("analysis.overview.identity.privateChat"):t(l)("analysis.overview.identity.groupChat")),1)]),R.value?(i(),m("div",kk,[a("div",_k,[h(se,{name:"i-heroicons-calendar",class:"h-4 w-4 opacity-70"})]),a("span",wk,d(R.value),1)])):E("",!0)]),a("div",$k,[a("div",Ck,[a("span",Sk,d(t(c).toLocaleString()),1),a("span",Ik,d(t(l)("analysis.overview.identity.totalMessages")),1)]),a("div",Tk,[a("span",Mk,d(t(o).toLocaleString()),1),a("span",zk,d(t(l)("analysis.overview.identity.durationDays")),1)]),a("div",Ak,[a("span",qk,d(t($).toLocaleString()),1),a("span",Lk,d(t(l)("analysis.overview.identity.activeDays")),1)]),a("div",Dk,[a("span",Ek,d(t(g).toLocaleString()),1),a("span",Bk,d(t(l)("analysis.overview.identity.dailyAvgMessages")),1)])])])]),a("div",Fk,[P[0]||(P[0]=a("div",{class:"mb-2 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Activity Heatmap ")],-1)),a("div",Rk,[a("div",{ref_key:"chartRef",ref:f,class:"h-[140px] min-w-[700px] lg:w-full"},null,512)])]),h(gk,{flat:"","daily-avg-messages":t(g),"duration-days":t(o),"image-count":t(p),"peak-hour":t(v),"peak-weekday":t(_),"weekday-names":t(y),"weekday-vs-weekend":t(k),"peak-day":t(b),"active-days":t($),"total-days":t(C),"active-rate":t(w),"late-night-count":t(S).count,"late-night-ratio":t(S).ratio,"max-consecutive-days":t(I)},null,8,["daily-avg-messages","duration-days","image-count","peak-hour","peak-weekday","weekday-names","weekday-vs-weekend","peak-day","active-days","total-days","active-rate","late-night-count","late-night-ratio","max-consecutive-days"])]),_:1},8,["capturable"])}}}),Vk={class:"p-3 sm:p-5"},p2=ce({__name:"DailyTrendCard",props:{dailyActivity:{},dailyChartData:{},capturable:{type:Boolean,default:!0}},setup(r){const{t:l}=we();return(e,n)=>r.dailyActivity.length>0?(i(),W(t(Ze),{key:0,title:t(l)("analysis.overview.dailyTrend.title"),capturable:r.capturable,"show-divider":!1},{default:F(()=>[a("div",Vk,[h(t(ya),{data:r.dailyChartData,height:288},null,8,["data"])])]),_:1},8,["title","capturable"])):E("",!0)}}),Ok={slots:{root:["relative inline-flex items-center","flex-wrap"],base:["rounded-md","transition-colors"],leading:"absolute inset-y-0 start-0 flex items-center",leadingIcon:"shrink-0 text-dimmed",leadingAvatar:"shrink-0",leadingAvatarSize:"",trailing:"absolute inset-y-0 end-0 flex items-center",trailingIcon:"shrink-0 text-dimmed",item:'px-1.5 py-0.5 rounded-sm font-medium inline-flex items-center gap-0.5 ring ring-inset ring-accented bg-elevated text-default data-disabled:cursor-not-allowed data-disabled:opacity-75 wrap-anywhere data-[state="active"]:bg-accented',itemText:"",itemDelete:["inline-flex items-center rounded-xs text-dimmed hover:text-default hover:bg-accented/75 disabled:pointer-events-none","transition-colors"],itemDeleteIcon:"shrink-0",input:"flex-1 border-0 bg-transparent placeholder:text-dimmed focus:outline-none disabled:cursor-not-allowed disabled:opacity-75"},variants:{fieldGroup:{horizontal:"not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]",vertical:"not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]"},size:{xs:{base:"px-2 py-1 text-sm/4 gap-1",leading:"ps-2",trailing:"pe-2",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4",item:"text-[10px]/3",itemDeleteIcon:"size-3"},sm:{base:"px-2.5 py-1.5 text-sm/4 gap-1.5",leading:"ps-2.5",trailing:"pe-2.5",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4",item:"text-[10px]/3",itemDeleteIcon:"size-3"},md:{base:"px-2.5 py-1.5 text-base/5 gap-1.5",leading:"ps-2.5",trailing:"pe-2.5",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5",item:"text-xs",itemDeleteIcon:"size-3.5"},lg:{base:"px-3 py-2 text-base/5 gap-2",leading:"ps-3",trailing:"pe-3",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5",item:"text-xs",itemDeleteIcon:"size-3.5"},xl:{base:"px-3 py-2 text-base gap-2",leading:"ps-3",trailing:"pe-3",leadingIcon:"size-6",leadingAvatarSize:"xs",trailingIcon:"size-6",item:"text-sm",itemDeleteIcon:"size-4"}},variant:{outline:"text-highlighted bg-default ring ring-inset ring-accented",soft:"text-highlighted bg-elevated/50 hover:bg-elevated has-focus:bg-elevated disabled:bg-elevated/50",subtle:"text-highlighted bg-elevated ring ring-inset ring-accented",ghost:"text-highlighted bg-transparent hover:bg-elevated has-focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent",none:"text-highlighted bg-transparent has-focus:outline-none"},color:{primary:"",secondary:"",success:"",info:"",warning:"",error:"",neutral:""},leading:{true:""},trailing:{true:""},loading:{true:""},highlight:{true:""},fixed:{false:""},type:{file:"file:me-1.5 file:font-medium file:text-muted file:outline-none"}},compoundVariants:[{color:"primary",variant:["outline","subtle"],class:"outline-primary/25 has-focus-visible:outline-3 has-focus-visible:ring-primary"},{color:"secondary",variant:["outline","subtle"],class:"outline-secondary/25 has-focus-visible:outline-3 has-focus-visible:ring-secondary"},{color:"success",variant:["outline","subtle"],class:"outline-success/25 has-focus-visible:outline-3 has-focus-visible:ring-success"},{color:"info",variant:["outline","subtle"],class:"outline-info/25 has-focus-visible:outline-3 has-focus-visible:ring-info"},{color:"warning",variant:["outline","subtle"],class:"outline-warning/25 has-focus-visible:outline-3 has-focus-visible:ring-warning"},{color:"error",variant:["outline","subtle"],class:"outline-error/25 has-focus-visible:outline-3 has-focus-visible:ring-error"},{color:"primary",variant:["soft","ghost"],class:"outline-primary/25 has-focus-visible:outline-3"},{color:"secondary",variant:["soft","ghost"],class:"outline-secondary/25 has-focus-visible:outline-3"},{color:"success",variant:["soft","ghost"],class:"outline-success/25 has-focus-visible:outline-3"},{color:"info",variant:["soft","ghost"],class:"outline-info/25 has-focus-visible:outline-3"},{color:"warning",variant:["soft","ghost"],class:"outline-warning/25 has-focus-visible:outline-3"},{color:"error",variant:["soft","ghost"],class:"outline-error/25 has-focus-visible:outline-3"},{color:"primary",highlight:!0,class:"ring ring-inset ring-primary"},{color:"secondary",highlight:!0,class:"ring ring-inset ring-secondary"},{color:"success",highlight:!0,class:"ring ring-inset ring-success"},{color:"info",highlight:!0,class:"ring ring-inset ring-info"},{color:"warning",highlight:!0,class:"ring ring-inset ring-warning"},{color:"error",highlight:!0,class:"ring ring-inset ring-error"},{color:"neutral",variant:["outline","subtle"],class:"outline-inverted/25 has-focus-visible:outline-3 has-focus-visible:ring-inverted"},{color:"neutral",variant:["soft","ghost"],class:"outline-inverted/25 has-focus-visible:outline-3"},{color:"neutral",highlight:!0,class:"ring ring-inset ring-inverted"},{leading:!0,size:"xs",class:"ps-7"},{leading:!0,size:"sm",class:"ps-8"},{leading:!0,size:"md",class:"ps-9"},{leading:!0,size:"lg",class:"ps-10"},{leading:!0,size:"xl",class:"ps-11"},{trailing:!0,size:"xs",class:"pe-7"},{trailing:!0,size:"sm",class:"pe-8"},{trailing:!0,size:"md",class:"pe-9"},{trailing:!0,size:"lg",class:"pe-10"},{trailing:!0,size:"xl",class:"pe-11"},{loading:!0,leading:!0,class:{leadingIcon:"animate-spin"}},{loading:!0,leading:!1,trailing:!0,class:{trailingIcon:"animate-spin"}},{fixed:!1,size:"xs",class:"md:text-xs"},{fixed:!1,size:"sm",class:"md:text-xs"},{fixed:!1,size:"md",class:"md:text-sm"},{fixed:!1,size:"lg",class:"md:text-sm"}],defaultVariants:{size:"md",color:"primary",variant:"outline"}},Pk=Object.assign({inheritAttrs:!1},{__name:"InputTags",props:{as:{type:null,required:!1},placeholder:{type:String,required:!1},maxLength:{type:Number,required:!1},color:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},autofocus:{type:Boolean,required:!1},autofocusDelay:{type:Number,required:!1,default:0},deleteIcon:{type:null,required:!1},highlight:{type:Boolean,required:!1},fixed:{type:Boolean,required:!1},class:{type:null,required:!1},ui:{type:Object,required:!1},modelValue:{type:[Array,null],required:!1},defaultValue:{type:Array,required:!1},addOnPaste:{type:Boolean,required:!1},addOnTab:{type:Boolean,required:!1},addOnBlur:{type:Boolean,required:!1},duplicate:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},delimiter:{type:null,required:!1},max:{type:Number,required:!1},id:{type:String,required:!1},convertValue:{type:Function,required:!1},displayValue:{type:Function,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1},icon:{type:null,required:!1},avatar:{type:Object,required:!1},leading:{type:Boolean,required:!1},leadingIcon:{type:null,required:!1},trailing:{type:Boolean,required:!1},trailingIcon:{type:null,required:!1},loading:{type:Boolean,required:!1},loadingIcon:{type:null,required:!1}},emits:["change","blur","focus","update:modelValue","invalid","addTag","removeTag"],setup(r,{expose:l,emit:e}){const n=r,s=e,u=Jt(),o=Sa("inputTags",n),c=Ta(),g=is(rs(o,"as","addOnPaste","addOnTab","addOnBlur","duplicate","delimiter","max","convertValue","displayValue","required"),s),{emitFormBlur:p,emitFormFocus:v,emitFormChange:_,emitFormInput:y,size:k,color:b,id:$,name:C,highlight:w,disabled:S,ariaAttrs:I}=Ia(n),{orientation:f,size:x}=us(n),{isLeading:B,isTrailing:R,leadingIconName:D,trailingIconName:A}=Ma(o),M=T(()=>x.value||k.value),q=T(()=>$t({extend:$t(Ok),...c.ui?.inputTags||{}})({color:b.value??o.color,variant:o.variant,size:M?.value??o.size,loading:o.loading,highlight:w.value??o.highlight,fixed:o.fixed,leading:B.value||!!o.avatar||!!u.leading,trailing:R.value||!!u.trailing,fieldGroup:f.value})),Y=zt("inputRef");function G(){o.autofocus&&Y.value?.$el?.focus()}Re(()=>{setTimeout(()=>{G()},o.autofocusDelay)});function Z(H){if(cs(o.modelValue)===H)return;const P=new Event("change",{target:{value:H}});s("change",P),_(),y()}function ue(H){s("blur",H),p()}function oe(H){s("focus",H),v()}return l({inputRef:We(()=>Y.value?.$el)}),(H,P)=>(i(),W(t(Ml),Ae({id:t($),"model-value":t(o).modelValue,"default-value":t(o).defaultValue,"data-slot":"root",class:q.value.root({class:[q.value.base({class:t(o).ui?.base}),t(o).ui?.root,t(o).class]})},t(g),{name:t(C),disabled:t(S),"onUpdate:modelValue":Z}),{default:F(({modelValue:se})=>[(i(!0),m(re,null,ve(se,(me,he)=>(i(),W(t(Dl),{key:he,value:me,"data-slot":"item",class:J(q.value.item({class:[t(o).ui?.item]}))},{default:F(()=>[h(t(Rl),{"data-slot":"itemText",class:J(q.value.itemText({class:[t(o).ui?.itemText]}))},{default:F(()=>[u["item-text"]?ye(H.$slots,"item-text",{key:0,item:me,index:he,ui:q.value}):E("",!0)]),_:2},1032,["class"]),h(t(Bl),{"data-slot":"itemDelete",class:J(q.value.itemDelete({class:[t(o).ui?.itemDelete]})),disabled:t(S)},{default:F(()=>[ye(H.$slots,"item-delete",{item:me,index:he,ui:q.value},()=>[h(_e,{name:t(o).deleteIcon||t(c).ui.icons.close,"data-slot":"itemDeleteIcon",class:J(q.value.itemDeleteIcon({class:[t(o).ui?.itemDeleteIcon]}))},null,8,["name","class"])])]),_:2},1032,["class","disabled"])]),_:2},1032,["value","class"]))),128)),h(t(Al),Ae({ref_key:"inputRef",ref:Y},{...H.$attrs,...t(I)},{placeholder:t(o).placeholder,"max-length":t(o).maxLength,"data-slot":"input",class:q.value.input({class:t(o).ui?.input}),onBlur:ue,onFocus:oe}),null,16,["placeholder","max-length","class"]),ye(H.$slots,"default",{ui:q.value}),t(B)||t(o).avatar||u.leading?(i(),m("span",{key:0,"data-slot":"leading",class:J(q.value.leading({class:t(o).ui?.leading}))},[ye(H.$slots,"leading",{ui:q.value},()=>[t(B)&&t(D)?(i(),W(_e,{key:0,name:t(D),"data-slot":"leadingIcon",class:J(q.value.leadingIcon({class:t(o).ui?.leadingIcon}))},null,8,["name","class"])):t(o).avatar?(i(),W(Kt,Ae({key:1,size:t(o).ui?.leadingAvatarSize||q.value.leadingAvatarSize()},t(o).avatar,{"data-slot":"leadingAvatar",class:q.value.leadingAvatar({class:t(o).ui?.leadingAvatar})}),null,16,["size","class"])):E("",!0)])],2)):E("",!0),t(R)||u.trailing?(i(),m("span",{key:1,"data-slot":"trailing",class:J(q.value.trailing({class:t(o).ui?.trailing}))},[ye(H.$slots,"trailing",{ui:q.value},()=>[t(A)?(i(),W(_e,{key:0,name:t(A),"data-slot":"trailingIcon",class:J(q.value.trailingIcon({class:t(o).ui?.trailingIcon}))},null,8,["name","class"])):E("",!0)])],2)):E("",!0)]),_:3},16,["id","model-value","default-value","class","name","disabled"]))}}),jk={class:"flex items-center justify-between gap-3"},Nk={class:"flex items-center gap-2"},Uk={class:"text-sm font-medium text-gray-900 dark:text-white"},Wk={class:"text-xs text-gray-500 dark:text-gray-400"},Hk=ce({__name:"OwnerEntryCard",props:{sessionId:{},members:{},chatType:{}},setup(r){const{t:l}=we(),e=Fn(),n=r,s=z(!1);function u(g){return g.groupNickname||g.accountName||g.platformId}const o=T(()=>{const g=e.currentSession?.ownerId;return g&&n.members.find(p=>p.platformId===g)||null}),c=T(()=>o.value?u(o.value):e.currentSession?.ownerId??"");return(g,p)=>{const v=_e,_=Ue;return i(),W(t(mt),{class:"w-150 p-3"},{default:F(()=>[a("div",jk,[a("div",Nk,[a("div",{class:J(["flex h-8 w-8 items-center justify-center rounded-full bg-linear-to-br",r.chatType==="group"?"from-pink-400 to-pink-600":"from-purple-400 to-purple-600"])},[h(v,{name:"i-heroicons-user",class:"h-4 w-4 text-white"})],2),a("div",null,[a("h3",Uk,d(c.value?t(l)("members.ownerPrompt.currentOwner",{name:c.value}):t(l)("members.ownerPrompt.choose")),1),a("p",Wk,d(t(l)("members.ownerPrompt.helper")),1)])]),h(_,{size:"sm",variant:c.value?"outline":"solid",color:"primary",onClick:p[0]||(p[0]=y=>s.value=!0)},{default:F(()=>[ie(d(c.value?t(l)("members.ownerPrompt.change"):t(l)("members.ownerPrompt.choose")),1)]),_:1},8,["variant"])]),h(Rn,{modelValue:s.value,"onUpdate:modelValue":p[1]||(p[1]=y=>s.value=y),"session-id":r.sessionId,"chat-type":r.chatType},null,8,["modelValue","session-id","chat-type"])]),_:1})}}}),Kk={key:0,class:"mb-6"},Yk={class:"flex items-center gap-3"},Gk={class:"text-xl font-bold text-gray-900 dark:text-white"},Qk={class:"text-sm text-gray-500 dark:text-gray-400"},Jk={class:"mb-4 flex flex-wrap items-center justify-between gap-3"},Xk={key:0,class:"flex items-center gap-2"},Zk={class:"text-xs text-gray-500 dark:text-gray-400"},e_={key:0,class:"flex flex-1 items-center justify-center"},t_={key:1,class:"flex flex-1 flex-col items-center justify-center gap-3"},a_={class:"text-sm text-gray-500 dark:text-gray-400"},s_={key:2,class:"flex flex-1 flex-col items-center justify-center"},n_={class:"text-gray-500 dark:text-gray-400"},o_={key:3,class:"min-h-0 flex-1 overflow-x-auto overflow-y-hidden"},l_={key:0,"aria-hidden":"true"},i_={class:"flex shrink-0 flex-col leading-none"},r_={class:"flex shrink-0 flex-col leading-none"},u_={class:"flex shrink-0 flex-col leading-none"},c_={class:"inline-flex items-center gap-1.5"},d_={class:"text-right"},m_=["data-index","onClick"],g_={key:0,class:"flex justify-center"},p_={class:"flex min-w-0 items-center gap-2.5"},h_={class:"min-w-0"},f_=["title"],v_=["title"],y_=["title"],x_={class:"text-right font-mono text-sm font-semibold tabular-nums text-gray-900 dark:text-white"},b_=["title"],k_={class:"flex justify-end gap-1"},__={class:"p-6 text-center"},w_={class:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30"},$_={class:"mb-2 text-lg font-semibold text-gray-900 dark:text-white"},C_={class:"mb-6 text-sm text-gray-500 dark:text-gray-400"},S_={class:"flex justify-center gap-3"},I_={class:"p-6 text-center"},T_={class:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30"},M_={class:"mb-2 text-lg font-semibold text-gray-900 dark:text-white"},z_={class:"mb-6 text-sm text-gray-500 dark:text-gray-400"},A_={class:"flex justify-center gap-3"},q_={class:"p-6"},L_={class:"mb-4 flex items-center gap-3"},D_={class:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100 dark:bg-amber-900/30"},E_={class:"text-lg font-semibold text-gray-900 dark:text-white"},B_={class:"mb-2 text-sm text-gray-600 dark:text-gray-400"},F_={class:"mb-6 text-xs text-amber-700 dark:text-amber-300"},R_={class:"flex justify-end gap-2"},V_=64,O_=ce({__name:"MemberList",props:{sessionId:{},showHeader:{type:Boolean,default:!0},chatType:{default:"group"}},emits:["data-changed"],setup(r,{emit:l}){const{t:e}=we(),n=Ke(),s=bt(),u=r,o=l,c=z([]),g=z(!1),p=z(!1),v=z(""),_=T(()=>Wn(u.chatType,c.value.length)),y=T(()=>u.chatType==="group"?"":_.value?"member-table-grid--private":"member-table-grid--private-without-selection"),k=z(null),b=z(!1),$=z(!1),C=z(!1),w=z(!1),S=z(!1),{sortState:I,toggleSort:f,resetSort:x,isSortActive:B}=Vn({initialState:{field:"messageCount",direction:"desc"}}),R=z(new Set);let D=0;function A(V,K){const L=K instanceof Error?K:new Error(String(K));console.error(V,L),Un(`${V} ${L.message}`,L.stack)}function M(V){return V.groupNickname||V.accountName||V.platformId}function q(V){return M(V).slice(0,1)}function Y(V){s.openChatRecordDrawer({sessionId:u.sessionId,memberId:V.id,memberName:M(V)})}const G=T(()=>Hn(c.value,v.value,I.value)),{selectedIds:Z,setSelection:ue,clearSelection:oe,handleRowClick:H,handleRowMouseDown:P}=On({rows:G,getRowId:V=>V.id}),se=T(()=>c.value.filter(V=>Z.value.has(V.id))),me=T(()=>se.value.length===2),he=T(()=>se.value.reduce((V,K)=>V+K.messageCount,0));function ee(V,K,L){_.value&&H(V,K,L)}function te(V){_.value&&P(V)}const N=T(()=>{if(se.value.length!==2)return null;const[V,K]=se.value;return K.messageCount>V.messageCount||K.messageCount===V.messageCount&&K.id<V.id?{primary:K,secondary:V}:{primary:V,secondary:K}});function de(V,K){return B(V,K)?"text-primary-500 dark:text-primary-400":"text-gray-300 dark:text-gray-600"}const be=z(null),xe=Pn(T(()=>({count:G.value.length,getScrollElement:()=>be.value,estimateSize:()=>V_,overscan:8,getItemKey:V=>G.value[V]?.id??V}))),le=T(()=>xe.value.getVirtualItems().map(V=>({virtualItem:V,member:G.value[V.index]}))),Q=T(()=>xe.value.getTotalSize());function X(V){V instanceof HTMLElement&&xe.value.measureElement(V)}async function pe(){await qe(),be.value?.scrollTo({top:0}),xe.value.measure()}async function ke(){const V=u.sessionId;if(!V)return;const K=++D;g.value=!0,p.value=!1;try{const L=await n.getMembers(V);if(K!==D||V!==u.sessionId)return;c.value=L,await qe(),xe.value.measure()}catch(L){K===D&&(p.value=!0),A("Failed to load member list:",L)}finally{K===D&&(g.value=!1)}}function $e(V,K){const L=new Set(R.value);K?L.add(V):L.delete(V),R.value=L}async function De(V,K){const L=u.sessionId,j=JSON.parse(JSON.stringify(K)),U=JSON.stringify(V.aliases),ae=JSON.stringify(j);if(U!==ae){$e(V.id,!0);try{if(await n.updateMemberAliases(L,V.id,j)&&L===u.sessionId){const Ve=c.value.findIndex(Le=>Le.id===V.id);Ve!==-1&&(c.value[Ve]={...c.value[Ve],aliases:j},await qe(),xe.value.measure())}}catch(ne){A("Failed to save member aliases:",ne)}finally{$e(V.id,!1)}}}function Be(V){k.value=V}function Te(){k.value=null}async function Pe(){if(k.value){b.value=!0;try{const V=k.value.id;if(await n.deleteMember(u.sessionId,V)){const L=new Set(Z.value);L.delete(V),ue(L),await ke(),o("data-changed")}}catch(V){A("Failed to delete member:",V)}finally{b.value=!1,k.value=null}}}function je(){Z.value.size!==0&&($.value=!0)}async function Se(){const V=u.sessionId,K=Array.from(Z.value);if(K.length!==0){C.value=!0;try{await n.deleteMembers(V,K)&&V===u.sessionId&&($.value=!1,oe(),await ke(),o("data-changed"))}catch(L){A("Failed to delete selected members:",L)}finally{C.value=!1}}}function ge(){me.value&&(w.value=!0)}async function O(){if(N.value){S.value=!0;try{await n.mergeMembers(u.sessionId,N.value.primary.id,N.value.secondary.id)&&(w.value=!1,oe(),await ke(),o("data-changed"))}catch(V){A("Failed to merge members:",V)}finally{S.value=!1}}}return fe([v,I],pe),fe(_,V=>{V||oe()}),fe(()=>u.sessionId,()=>{D+=1,c.value=[],p.value=!1,R.value=new Set,v.value="",x(),oe(),pe(),ke()},{immediate:!0}),tt(()=>{D+=1}),(V,K)=>{const L=Ue,j=Ft,U=_e,ae=St,ne=wa,Ve=Pk,Le=Xe;return i(),m("div",{class:J(["main-content",u.showHeader?"max-w-5xl p-6":"flex h-full max-w-none flex-col overflow-hidden p-4"])},[u.showHeader?(i(),m("div",Kk,[a("div",Yk,[a("div",null,[a("h2",Gk,d(t(e)(u.chatType==="private"?"members.private.title":"members.list.title")),1),a("p",Qk,d(t(e)(u.chatType==="private"?"members.private.description":"members.list.description",{count:c.value.length})),1)])])])):E("",!0),h(Hk,{class:"mb-6","session-id":r.sessionId,members:c.value,"chat-type":u.chatType},null,8,["session-id","members","chat-type"]),a("div",Jk,[h(j,{modelValue:v.value,"onUpdate:modelValue":K[1]||(K[1]=Me=>v.value=Me),placeholder:t(e)("members.list.searchPlaceholder"),icon:"i-heroicons-magnifying-glass",class:"w-full md:w-100"},jn({_:2},[v.value?{name:"trailing",fn:F(()=>[h(L,{icon:"i-heroicons-x-mark",variant:"link",color:"neutral",size:"xs",onClick:K[0]||(K[0]=Me=>v.value="")})]),key:"0"}:void 0]),1032,["modelValue","placeholder"]),_.value?(i(),m("div",Xk,[g.value&&c.value.length>0?(i(),W(U,{key:0,name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin text-primary-500"})):E("",!0),a("span",Zk,d(t(e)("members.list.selectedCount",{count:t(Z).size})),1),h(L,{icon:"i-heroicons-link",size:"sm",color:"primary",disabled:!me.value,onClick:ge},{default:F(()=>[ie(d(t(e)("members.list.mergeSelected")),1)]),_:1},8,["disabled"]),h(L,{icon:"i-heroicons-trash",size:"sm",color:"error",variant:"outline",disabled:t(Z).size===0,onClick:je},{default:F(()=>[ie(d(t(e)("members.list.deleteSelected")),1)]),_:1},8,["disabled"])])):E("",!0)]),a("div",{class:J(["flex min-h-[240px] flex-col overflow-hidden rounded-lg border border-gray-200/60 bg-card-bg dark:border-white/5 dark:bg-card-dark",u.showHeader?"h-[500px]":"min-h-0 flex-1"])},[g.value&&c.value.length===0?(i(),m("div",e_,[h(U,{name:"i-heroicons-arrow-path",class:"h-8 w-8 animate-spin text-primary-500"})])):p.value&&c.value.length===0?(i(),m("div",t_,[h(U,{name:"i-heroicons-exclamation-circle",class:"h-10 w-10 text-red-400"}),a("p",a_,d(t(e)("members.list.loadError")),1),h(L,{size:"sm",variant:"outline",icon:"i-heroicons-arrow-path",onClick:ke},{default:F(()=>[ie(d(t(e)("common.retry")),1)]),_:1})])):G.value.length===0?(i(),m("div",s_,[h(U,{name:"i-heroicons-user-group",class:"mb-3 h-12 w-12 text-gray-300 dark:text-gray-600"}),a("p",n_,d(v.value?t(e)("members.list.noMatch"):t(e)("members.list.empty")),1)])):(i(),m("div",o_,[a("div",{class:J(["flex h-full flex-col",u.chatType==="private"?"min-w-[920px]":"min-w-[1120px]"])},[a("div",{class:J(["member-table-grid shrink-0 border-b border-gray-200 bg-gray-50 px-3 py-2 text-xs font-medium text-gray-500 dark:border-white/5 dark:bg-page-dark/80 dark:text-gray-400",y.value])},[_.value?(i(),m("span",l_)):E("",!0),a("span",null,d(t(e)("members.list.table.accountName")),1),u.chatType==="group"?(i(),m("button",{key:1,type:"button",class:"flex items-center justify-start gap-1.5 text-left transition-colors hover:text-gray-700 dark:hover:text-gray-200",onClick:K[2]||(K[2]=Me=>t(f)("groupNickname"))},[ie(d(t(e)("members.list.table.groupNickname"))+" ",1),a("span",i_,[h(U,{name:"i-heroicons-chevron-up",class:J(["h-2.5 w-2.5",de("groupNickname","asc")])},null,8,["class"]),h(U,{name:"i-heroicons-chevron-down",class:J(["-mt-0.5 h-2.5 w-2.5",de("groupNickname","desc")])},null,8,["class"])])])):E("",!0),a("button",{type:"button",class:"flex items-center justify-end gap-1.5 text-right transition-colors hover:text-gray-700 dark:hover:text-gray-200",onClick:K[3]||(K[3]=Me=>t(f)("messageCount"))},[ie(d(t(e)("members.list.table.messageCount"))+" ",1),a("span",r_,[h(U,{name:"i-heroicons-chevron-up",class:J(["h-2.5 w-2.5",de("messageCount","asc")])},null,8,["class"]),h(U,{name:"i-heroicons-chevron-down",class:J(["-mt-0.5 h-2.5 w-2.5",de("messageCount","desc")])},null,8,["class"])])]),a("button",{type:"button",class:"flex items-center justify-end gap-1.5 text-right transition-colors hover:text-gray-700 dark:hover:text-gray-200",onClick:K[4]||(K[4]=Me=>t(f)("lastMessageTs"))},[ie(d(t(e)("members.list.table.lastMessageTime"))+" ",1),a("span",u_,[h(U,{name:"i-heroicons-chevron-up",class:J(["h-2.5 w-2.5",de("lastMessageTs","asc")])},null,8,["class"]),h(U,{name:"i-heroicons-chevron-down",class:J(["-mt-0.5 h-2.5 w-2.5",de("lastMessageTs","desc")])},null,8,["class"])])]),a("span",c_,[a("span",null,d(t(e)("members.list.table.customAlias")),1),h(ae,{text:t(e)("members.list.tip"),popper:{placement:"top"}},{default:F(()=>[h(U,{name:"i-heroicons-question-mark-circle",class:"h-4 w-4 text-gray-400 dark:text-gray-500"})]),_:1},8,["text"])]),a("span",d_,d(t(e)("members.list.table.actions")),1)],2),a("div",{ref_key:"listScrollRef",ref:be,class:"min-h-0 flex-1 overflow-y-auto"},[a("div",{class:"relative",style:et({height:`${Q.value}px`})},[(i(!0),m(re,null,ve(le.value,({virtualItem:Me,member:Fe})=>(i(),m("div",{key:String(Me.key),ref_for:!0,ref:X,"data-index":Me.index,class:J(["member-table-grid absolute left-0 top-0 w-full min-h-16 border-b border-gray-100/80 px-3 py-2 transition-colors hover:bg-gray-50 dark:border-white/5 dark:hover:bg-gray-800/30",[y.value,_.value?"cursor-pointer":"",_.value&&t(Z).has(Fe.id)?"bg-primary-50/70 dark:bg-primary-950/20":""]]),style:et({transform:`translateY(${Me.start}px)`}),onMousedown:te,onClick:nt=>ee(Me.index,Fe.id,nt)},[_.value?(i(),m("div",g_,[h(ne,{"model-value":t(Z).has(Fe.id),onClick:Oe(nt=>ee(Me.index,Fe.id,nt),["stop"])},null,8,["model-value","onClick"])])):E("",!0),a("div",p_,[h(Nn,{src:Fe.avatar,alt:M(Fe),text:q(Fe),"fallback-class":["flex h-8 w-8 items-center justify-center rounded-full text-[10px] font-bold","bg-primary-500 text-white"]},null,8,["src","alt","text"]),a("div",h_,[a("p",{class:"truncate text-sm font-medium text-gray-900 dark:text-white",title:Fe.accountName||"-"},d(Fe.accountName||"-"),9,f_),a("p",{class:"truncate text-xs text-gray-400 dark:text-gray-500",title:Fe.platformId},d(Fe.platformId),9,v_)])]),u.chatType==="group"?(i(),m("p",{key:1,class:J(["truncate text-sm text-gray-700 dark:text-gray-300",Fe.groupNickname?"font-medium":"text-gray-400 dark:text-gray-500"]),title:Fe.groupNickname||"-"},d(Fe.groupNickname||"-"),11,y_)):E("",!0),a("span",x_,d(Fe.messageCount.toLocaleString()),1),a("span",{class:"text-right font-mono text-xs tabular-nums text-gray-600 dark:text-gray-400",title:Fe.lastMessageTs===null?"-":t(Na)(Fe.lastMessageTs)},d(Fe.lastMessageTs===null?"-":t(Na)(Fe.lastMessageTs)),9,b_),h(Ve,{"model-value":Fe.aliases,placeholder:t(e)("members.list.aliasPlaceholder"),loading:R.value.has(Fe.id),size:"xs",class:"w-full",onClick:K[5]||(K[5]=Oe(()=>{},["stop"])),"onUpdate:modelValue":nt=>De(Fe,nt)},null,8,["model-value","placeholder","loading","onUpdate:modelValue"]),a("div",k_,[h(L,{icon:"i-heroicons-chat-bubble-left-ellipsis",size:"xs",color:"neutral",variant:"ghost",title:t(e)("common.viewChatRecords"),onClick:Oe(nt=>Y(Fe),["stop"])},null,8,["title","onClick"]),h(L,{icon:"i-heroicons-trash",size:"xs",color:"error",variant:"ghost",title:t(e)("members.list.delete"),onClick:Oe(nt=>Be(Fe),["stop"])},null,8,["title","onClick"])])],46,m_))),128))],4)],512)],2)]))],2),h(Le,{open:!!k.value,ui:{content:"max-w-sm"},"onUpdate:open":K[6]||(K[6]=Me=>k.value=null)},{content:F(()=>[a("div",__,[a("div",w_,[h(U,{name:"i-heroicons-exclamation-triangle",class:"h-7 w-7 text-red-500"})]),a("h3",$_,d(t(e)("members.list.modal.title")),1),a("p",C_,d(t(e)("members.list.modal.content",{name:k.value?M(k.value):"",count:k.value?.messageCount.toLocaleString()})),1),a("div",S_,[h(L,{variant:"outline",onClick:Te},{default:F(()=>[ie(d(t(e)("members.list.modal.cancel")),1)]),_:1}),h(L,{color:"error",loading:b.value,onClick:Pe},{default:F(()=>[ie(d(t(e)("members.list.modal.confirm")),1)]),_:1},8,["loading"])])])]),_:1},8,["open"]),h(Le,{open:$.value,ui:{content:"max-w-sm"},"onUpdate:open":K[8]||(K[8]=Me=>$.value=Me)},{content:F(()=>[a("div",I_,[a("div",T_,[h(U,{name:"i-heroicons-exclamation-triangle",class:"h-7 w-7 text-red-500"})]),a("h3",M_,d(t(e)("members.list.batchDeleteModal.title")),1),a("p",z_,d(t(e)("members.list.batchDeleteModal.content",{count:se.value.length,messageCount:he.value.toLocaleString()})),1),a("div",A_,[h(L,{variant:"outline",disabled:C.value,onClick:K[7]||(K[7]=Me=>$.value=!1)},{default:F(()=>[ie(d(t(e)("members.list.modal.cancel")),1)]),_:1},8,["disabled"]),h(L,{color:"error",loading:C.value,onClick:Se},{default:F(()=>[ie(d(t(e)("members.list.modal.confirm")),1)]),_:1},8,["loading"])])])]),_:1},8,["open"]),h(Le,{open:w.value,ui:{content:"max-w-md"},"onUpdate:open":K[10]||(K[10]=Me=>w.value=Me)},{content:F(()=>[a("div",q_,[a("div",L_,[a("div",D_,[h(U,{name:"i-heroicons-link",class:"h-5 w-5 text-amber-600 dark:text-amber-400"})]),a("h3",E_,d(t(e)("members.list.mergeModal.title")),1)]),a("p",B_,d(t(e)("members.list.mergeModal.content",{source:N.value?M(N.value.secondary):"",sourceCount:N.value?N.value.secondary.messageCount.toLocaleString():"0",target:N.value?M(N.value.primary):"",targetCount:N.value?N.value.primary.messageCount.toLocaleString():"0"})),1),a("p",F_,d(t(e)("members.list.mergeModal.hint")),1),a("div",R_,[h(L,{variant:"outline",disabled:S.value,onClick:K[9]||(K[9]=Me=>w.value=!1)},{default:F(()=>[ie(d(t(e)("members.list.mergeModal.cancel")),1)]),_:1},8,["disabled"]),h(L,{color:"primary",loading:S.value,onClick:O},{default:F(()=>[ie(d(t(e)("members.list.mergeModal.confirm")),1)]),_:1},8,["loading"])])])]),_:1},8,["open"])],2)}}}),h2=at(O_,[["__scopeId","data-v-0754d30f"]]),P_={class:"mt-3 flex flex-col items-stretch gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3"},j_={class:"max-w-full overflow-x-auto scrollbar-hide"},f2=ce({__name:"SessionAnalysisHeader",props:qt({title:{},avatar:{},icon:{},iconClass:{},tabs:{},currentSessionId:{},initialTimeState:{},showSessionActions:{type:Boolean,default:!0}},{activeTab:{required:!0},activeTabModifiers:{},timeRangeValue:{required:!0},timeRangeValueModifiers:{}}),emits:qt(["openIncrementalImport","openMemberManagement","openChatRecord","update:fullRange","update:availableYears","timeRangeInitialized"],["update:activeTab","update:timeRangeValue"]),setup(r,{emit:l}){const e=Ht(r,"activeTab"),n=Ht(r,"timeRangeValue"),s=r,u=l,{t:o}=we(),c=bt(),g=T(()=>!["ai-chat","memory","lab","debug"].includes(e.value)),p=T(()=>s.tabs.map(v=>({id:v.id,label:o(v.labelKey),icon:v.icon})));return(v,_)=>{const y=Ue,k=St;return i(),W(ro,{title:r.title,avatar:r.avatar,size:"compact",icon:r.icon,"icon-class":r.iconClass},{actions:F(()=>[r.showSessionActions&&t(c).toolsPanelPosition==="header"?(i(),m(re,{key:0},[h(k,{text:t(o)("analysis.tooltip.viewChatRecord")},{default:F(()=>[h(y,{icon:"i-heroicons-chat-bubble-bottom-center-text",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:_[0]||(_[0]=b=>u("openChatRecord"))})]),_:1},8,["text"]),h(k,{text:t(o)("analysis.tooltip.incrementalImport")},{default:F(()=>[h(y,{icon:"i-heroicons-plus-circle",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:_[1]||(_[1]=b=>u("openIncrementalImport"))})]),_:1},8,["text"]),h(k,{text:t(o)("analysis.tooltip.memberManagement")},{default:F(()=>[h(y,{icon:"i-heroicons-user-group",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:_[2]||(_[2]=b=>u("openMemberManagement"))})]),_:1},8,["text"]),h(Lt,{color:"gray"}),h(k,{text:t(o)("analysis.tooltip.more")},{default:F(()=>[h(y,{"data-tools-panel-trigger":"",icon:"i-heroicons-ellipsis-horizontal",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:_[3]||(_[3]=b=>t(c).toggleToolsPanelOpen())})]),_:1},8,["text"])],64)):r.showSessionActions?(i(),W(Lt,{key:1,color:"gray"})):E("",!0)]),default:F(()=>[a("div",P_,[h(t(Kn),{modelValue:e.value,"onUpdate:modelValue":_[4]||(_[4]=b=>e.value=b),class:"min-w-0 shrink",items:p.value},null,8,["modelValue","items"]),a("div",j_,[g.value?(i(),W(io,{key:0,modelValue:n.value,"onUpdate:modelValue":_[5]||(_[5]=b=>n.value=b),"session-id":r.currentSessionId??void 0,"initial-state":r.initialTimeState,size:"sm","onUpdate:fullRange":_[6]||(_[6]=b=>u("update:fullRange",b)),"onUpdate:availableYears":_[7]||(_[7]=b=>u("update:availableYears",b)),onInitializationComplete:_[8]||(_[8]=b=>u("timeRangeInitialized",b))},null,8,["modelValue","session-id","initial-state"])):E("",!0)])])]),_:1},8,["title","avatar","icon","icon-class"])}}}),N_={class:"space-y-4 p-5"},U_={class:"flex items-center gap-2"},W_={class:"text-base font-semibold text-gray-900 dark:text-white"},H_={key:0,class:"flex items-center gap-2 text-sm text-gray-400"},K_={class:"rounded-lg border border-gray-200 bg-gray-50 p-3 text-sm dark:border-gray-700 dark:bg-gray-800/50"},Y_={class:"flex items-center justify-between"},G_={class:"text-gray-500"},Q_={class:"font-medium text-gray-800 dark:text-gray-200"},J_={key:0,class:"mt-1 flex items-center justify-between"},X_={class:"text-gray-500"},Z_={class:"text-gray-700 dark:text-gray-300"},ew={key:1,class:"mt-2"},tw={class:"flex items-center justify-between text-xs text-gray-500"},aw={class:"mt-1 h-1.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},sw={key:2,class:"mt-1 text-xs text-red-500"},nw={class:"text-sm text-gray-600 dark:text-gray-400"},ow={key:0,class:"rounded border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-700 dark:border-amber-800/50 dark:bg-amber-900/20 dark:text-amber-400"},lw={class:"flex justify-end gap-2"},iw={class:"text-xs text-gray-400"},rw={class:"flex flex-wrap justify-end gap-2"},Ne="settings.ai.semanticIndex",v2=ce({__name:"SemanticIndexSessionModal",props:{modelValue:{type:Boolean},sessionId:{},messageCount:{}},emits:["update:modelValue"],setup(r,{emit:l}){const e=r,n=l,{t:s}=we(),u=Yn(),o=T({get:()=>e.modelValue,set:I=>n("update:modelValue",I)}),c=z(null),g=z(!1),p=z(!1),v=z(!1),_=T(()=>{const I=c.value;return!I||!I.enabled?s(`${Ne}.session.notEnabled`):I.needsRebuild?s(`${Ne}.state.needsRebuild`):I.running||I.queued||I.indexStatus==="running"?s(`${Ne}.state.building`):I.indexStatus==="completed"?s(`${Ne}.state.completed`):I.indexStatus==="failed"?s(`${Ne}.state.failed`):I.indexStatus==="paused"?s(`${Ne}.state.paused`):s(`${Ne}.state.pending`)}),y=T(()=>{const I=c.value;return!!I&&(I.running||I.queued||I.indexStatus==="running")}),k=T(()=>c.value&&c.value.totalMessages>0?Math.round(c.value.indexedMessages/c.value.totalMessages*100):0);let b=null;function $(){b&&(clearTimeout(b),b=null)}function C(){$(),b=setTimeout(async()=>{try{c.value=await u.status(e.sessionId)}catch(I){console.error("[semantic-index] poll status failed:",I)}y.value&&e.modelValue?C():$()},1500)}async function w(){p.value=!0;try{const[I,f]=await Promise.all([u.getConfig(),u.status(e.sessionId)]);g.value=I.config.enabled&&I.configured&&(I.config.mode==="local"?!!I.config.local.modelId:!!I.config.api?.baseUrl&&!!I.config.api?.model&&(!Gn(I.config.api?.baseUrl)||I.apiKeySet)),c.value=f}catch(I){console.error("[semantic-index] load session status failed:",I)}finally{p.value=!1}y.value&&C()}async function S(I){v.value=!0;try{c.value=await u[I](e.sessionId)}catch(f){console.error(`[semantic-index] ${I} failed:`,f)}finally{v.value=!1}y.value?C():$()}return fe(()=>e.modelValue,I=>{I?w():$()}),tt($),(I,f)=>{const x=_e,B=Ue,R=Xe;return i(),W(R,{open:o.value,"onUpdate:open":f[10]||(f[10]=D=>o.value=D),ui:{content:"z-[101]",overlay:"z-[100]"}},{content:F(()=>[a("div",N_,[a("div",U_,[h(x,{name:"i-heroicons-circle-stack",class:"h-5 w-5 text-blue-500"}),a("h3",W_,d(t(s)(`${Ne}.title`)),1)]),p.value?(i(),m("div",H_,[h(x,{name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin"}),ie(" "+d(t(s)("common.loading")),1)])):(i(),m(re,{key:1},[a("div",K_,[a("div",Y_,[a("span",G_,d(t(s)(`${Ne}.session.statusLabel`)),1),a("span",Q_,d(_.value),1)]),c.value?.enabled&&c.value.indexStatus==="completed"?(i(),m("div",J_,[a("span",X_,d(t(s)(`${Ne}.session.coverageLabel`)),1),a("span",Z_,d(k.value)+"%",1)])):E("",!0),y.value?(i(),m("div",ew,[a("div",tw,[a("span",null,d(t(s)(`${Ne}.session.progressLabel`)),1),a("span",null,d(c.value?.indexedMessages??0)+" / "+d(c.value?.totalMessages??0)+" ("+d(k.value)+"%) ",1)]),a("div",aw,[a("div",{class:"h-full rounded-full bg-blue-500 transition-all duration-500",style:et({width:`${k.value}%`})},null,4)])])):E("",!0),c.value?.error?(i(),m("p",sw,d(c.value.error),1)):E("",!0)]),c.value?.enabled?(i(),m(re,{key:1},[a("p",iw,d(t(s)(`${Ne}.session.buildVsEnable`)),1),a("div",rw,[y.value?(i(),m(re,{key:0},[h(B,{variant:"soft",loading:v.value,onClick:f[2]||(f[2]=D=>S("pause"))},{default:F(()=>[ie(d(t(s)(`${Ne}.action.pause`)),1)]),_:1},8,["loading"]),h(B,{color:"error",variant:"soft",disabled:v.value,onClick:f[3]||(f[3]=D=>S("cancel"))},{default:F(()=>[ie(d(t(s)(`${Ne}.action.cancel`)),1)]),_:1},8,["disabled"])],64)):c.value?.indexStatus==="completed"&&!c.value?.needsRebuild?(i(),W(B,{key:1,variant:"soft",loading:v.value,onClick:f[4]||(f[4]=D=>S("rebuild"))},{default:F(()=>[ie(d(t(s)(`${Ne}.action.rebuild`)),1)]),_:1},8,["loading"])):c.value?.needsRebuild?(i(),W(B,{key:2,color:"primary",loading:v.value,onClick:f[5]||(f[5]=D=>S("rebuild"))},{default:F(()=>[ie(d(t(s)(`${Ne}.action.rebuild`)),1)]),_:1},8,["loading"])):c.value?.indexStatus==="failed"?(i(),W(B,{key:3,color:"primary",loading:v.value,onClick:f[6]||(f[6]=D=>S("build"))},{default:F(()=>[ie(d(t(s)(`${Ne}.session.retry`)),1)]),_:1},8,["loading"])):c.value?.indexStatus==="paused"?(i(),W(B,{key:4,color:"primary",loading:v.value,onClick:f[7]||(f[7]=D=>S("build"))},{default:F(()=>[ie(d(t(s)(`${Ne}.session.continue`)),1)]),_:1},8,["loading"])):(i(),W(B,{key:5,color:"primary",loading:v.value,onClick:f[8]||(f[8]=D=>S("build"))},{default:F(()=>[ie(d(t(s)(`${Ne}.action.build`)),1)]),_:1},8,["loading"])),h(B,{variant:"ghost",color:"neutral",disabled:v.value,onClick:f[9]||(f[9]=D=>S("remove"))},{default:F(()=>[ie(d(t(s)(`${Ne}.action.remove`)),1)]),_:1},8,["disabled"])])],64)):(i(),m(re,{key:0},[a("p",nw,d(t(s)(`${Ne}.session.enableHint`)),1),g.value?E("",!0):(i(),m("p",ow,d(t(s)(`${Ne}.session.configFirst`)),1)),a("div",lw,[h(B,{variant:"ghost",onClick:f[0]||(f[0]=D=>o.value=!1)},{default:F(()=>[ie(d(t(s)("common.close")),1)]),_:1}),h(B,{color:"primary",loading:v.value,disabled:!g.value,onClick:f[1]||(f[1]=D=>S("enable"))},{default:F(()=>[ie(d(t(s)(`${Ne}.session.enable`)),1)]),_:1},8,["loading","disabled"])])],64))],64))])]),_:1},8,["open"])}}}),uw={class:"min-h-[200px]"},cw={key:0,class:"space-y-4"},dw={class:"text-sm text-gray-600 dark:text-gray-400"},mw={class:"text-sm text-gray-600 dark:text-gray-400"},gw={key:1,class:"flex flex-col items-center justify-center py-10"},pw={class:"text-gray-600 dark:text-gray-400"},hw={class:"mt-2 text-sm text-gray-500"},fw={key:2,class:"space-y-6"},vw={class:"rounded-lg bg-gray-50 p-4 dark:bg-gray-800"},yw={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},xw={class:"grid grid-cols-3 gap-4 text-center"},bw={class:"text-2xl font-bold text-gray-900 dark:text-white"},kw={class:"text-xs text-gray-500"},_w={class:"text-2xl font-bold text-green-600 dark:text-green-400"},ww={class:"text-xs text-gray-500"},$w={class:"text-2xl font-bold text-gray-400"},Cw={class:"text-xs text-gray-500"},Sw={key:0,class:"text-center text-sm text-amber-600 dark:text-amber-400"},Iw={key:3,class:"flex flex-col items-center justify-center py-10"},Tw={class:"text-gray-600 dark:text-gray-400"},Mw={key:0,class:"mt-4 w-full max-w-xs"},zw={key:4,class:"flex flex-col items-center justify-center py-10"},Aw={class:"text-lg font-medium text-gray-900 dark:text-white"},qw={class:"mt-2 text-sm text-gray-600 dark:text-gray-400"},Lw={key:5,class:"flex flex-col items-center justify-center py-10"},Dw={class:"text-lg font-medium text-gray-900 dark:text-white"},Ew={class:"mt-2 text-sm text-red-600 dark:text-red-400"},Bw={class:"flex w-full justify-end gap-2"},y2=ce({__name:"IncrementalImportModal",props:{modelValue:{type:Boolean},sessionId:{},sessionName:{}},emits:["update:modelValue","imported"],setup(r,{emit:l}){const e=r,n=l,{t:s}=we(),u=z("select"),o=z(null),c=z(null),g=z(null),p=z(null),v=z(null),_=z(null),y=T({get:()=>e.modelValue,set:x=>n("update:modelValue",x)});fe(y,x=>{x||k()});function k(){u.value="select",o.value=null,g.value=null,p.value=null,v.value=null,_.value=null}async function b({files:x,paths:B}){if(x.length>0)o.value={source:x[0],name:x[0].name};else{v.value=s("home.import.cannotReadPath");return}await C()}function $(){c.value?.openFileDialog()}async function C(){if(o.value){u.value="analyzing",v.value=null;try{const x=await ja().analyzeIncrementalImport(e.sessionId,o.value.source);if(x.error){u.value="error",v.value=f(x.error);return}g.value={newMessageCount:x.newMessageCount,duplicateCount:x.duplicateCount,totalInFile:x.totalInFile},u.value="preview"}catch(x){u.value="error",v.value=String(x)}}}async function w(){if(o.value){u.value="importing",p.value={stage:"saving",progress:0,message:""};try{const x=await ja().incrementalImport(e.sessionId,o.value.source,B=>{p.value=B});x.success?(_.value={newMessageCount:x.newMessageCount},u.value="done"):(u.value="error",v.value=f(x.error||"error.import_failed"))}catch(x){u.value="error",v.value=String(x)}}}function S(){_.value&&n("imported",_.value.newMessageCount),y.value=!1}function I(){u.value="select",o.value=null,g.value=null,v.value=null}function f(x){if(x.startsWith("error.")){const B=`home.import.errors.${x.slice(6)}`,R=s(B);return R!==B?R:x}return x}return(x,B)=>{const R=Qn,D=_e,A=Jn,M=Ue,q=Xe;return i(),W(q,{open:y.value,"onUpdate:open":B[1]||(B[1]=Y=>y.value=Y),title:t(s)("analysis.incremental.title")},{body:F(()=>[a("div",uw,[u.value==="select"?(i(),m("div",cw,[a("p",dw,d(t(s)("analysis.incremental.description",{name:r.sessionName})),1),h(R,{color:"info",variant:"soft",icon:"i-heroicons-information-circle",description:t(s)("analysis.incremental.homeAutoImportHint")},null,8,["description"]),h(t(eo),{ref_key:"dropZoneRef",ref:c,accept:[".json",".jsonl",".txt"],class:"w-full",onFiles:b},{default:F(({isDragOver:Y})=>[a("div",{class:J(["flex cursor-pointer flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 py-10 transition-colors",Y?"border-pink-500 bg-pink-50/50 dark:border-pink-400 dark:bg-pink-500/10":"border-gray-300 hover:border-pink-400 dark:border-gray-600 dark:hover:border-pink-500"]),onClick:Oe($,["stop"])},[h(D,{name:"i-heroicons-arrow-up-tray",class:"mb-3 h-10 w-10 text-gray-400"}),a("p",mw,d(Y?t(s)("home.import.dropHint"):t(s)("analysis.incremental.dropHint")),1)],2)]),_:1},512)])):u.value==="analyzing"?(i(),m("div",gw,[h(D,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),a("p",pw,d(t(s)("analysis.incremental.analyzing")),1),a("p",hw,d(o.value?.name),1)])):u.value==="preview"&&g.value?(i(),m("div",fw,[a("div",vw,[a("p",yw,d(o.value?.name),1),a("div",xw,[a("div",null,[a("p",bw,d(g.value.totalInFile.toLocaleString()),1),a("p",kw,d(t(s)("analysis.incremental.totalInFile")),1)]),a("div",null,[a("p",_w,d(g.value.newMessageCount.toLocaleString()),1),a("p",ww,d(t(s)("analysis.incremental.newMessages")),1)]),a("div",null,[a("p",$w,d(g.value.duplicateCount.toLocaleString()),1),a("p",Cw,d(t(s)("analysis.incremental.duplicates")),1)])])]),g.value.newMessageCount===0?(i(),m("p",Sw,[h(D,{name:"i-heroicons-exclamation-triangle",class:"mr-1 inline-block h-4 w-4"}),ie(" "+d(t(s)("analysis.incremental.noNewMessages")),1)])):E("",!0)])):u.value==="importing"?(i(),m("div",Iw,[h(D,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),a("p",Tw,d(t(s)("analysis.incremental.importing")),1),p.value?(i(),m("div",Mw,[h(A,{value:p.value.progress,size:"sm"},null,8,["value"])])):E("",!0)])):u.value==="done"&&_.value?(i(),m("div",zw,[h(D,{name:"i-heroicons-check-circle",class:"mb-4 h-12 w-12 text-green-500"}),a("p",Aw,d(t(s)("analysis.incremental.success")),1),a("p",qw,d(t(s)("analysis.incremental.successDetail",{count:_.value.newMessageCount})),1)])):u.value==="error"?(i(),m("div",Lw,[h(D,{name:"i-heroicons-x-circle",class:"mb-4 h-12 w-12 text-red-500"}),a("p",Dw,d(t(s)("analysis.incremental.failed")),1),a("p",Ew,d(v.value),1)])):E("",!0)])]),footer:F(()=>[a("div",Bw,[u.value==="select"?(i(),W(M,{key:0,color:"neutral",variant:"ghost",onClick:B[0]||(B[0]=Y=>y.value=!1)},{default:F(()=>[ie(d(t(s)("common.cancel")),1)]),_:1})):u.value==="preview"?(i(),m(re,{key:1},[h(M,{color:"neutral",variant:"ghost",onClick:I},{default:F(()=>[ie(d(t(s)("common.back")),1)]),_:1}),h(M,{color:"primary",disabled:!g.value||g.value.newMessageCount===0,onClick:w},{default:F(()=>[ie(d(t(s)("analysis.incremental.import",{count:g.value?.newMessageCount||0})),1)]),_:1},8,["disabled"])],64)):u.value==="done"||u.value==="error"?(i(),m(re,{key:2},[u.value==="error"?(i(),W(M,{key:0,color:"neutral",variant:"ghost",onClick:I},{default:F(()=>[ie(d(t(s)("common.retry")),1)]),_:1})):E("",!0),h(M,{color:"primary",onClick:S},{default:F(()=>[ie(d(t(s)("common.done")),1)]),_:1})],64)):E("",!0)])]),_:1},8,["open","title"])}}}),Fw={key:0,class:"fixed right-0 top-1/3"},Rw={class:"no-capture flex flex-col items-center gap-0.5 rounded-l-lg border border-r-0 border-gray-200/60 bg-white py-1.5 shadow-sm dark:border-white/5 dark:bg-page-dark"},Vw=["onClick"],Ow={class:"mb-2 flex items-center justify-between"},Pw={class:"px-0.5 text-[9px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"},jw={class:"flex flex-col gap-1.5"},Nw=["onClick"],Uw={class:"whitespace-nowrap"},x2=ce({__name:"ActionToolsPanel",emits:["openIncrementalImport","openSemanticIndex","openMemberManagement","openChatRecord","openMessageExport"],setup(r,{emit:l}){const{t:e}=we(),n=bt(),{isToolsPanelMini:s,toolsPanelPosition:u,isToolsPanelOpen:o}=ct(n),c=T(()=>u.value==="header"),g=T(()=>!c.value||o.value),p=z(null),v=l;function _(C){v(C),c.value&&(o.value=!1)}function y(C){if(!c.value||!o.value)return;const w=C.target;w instanceof Element&&(p.value?.contains(w)||w.closest("[data-tools-panel-trigger]")||(o.value=!1))}const k=[{event:"openIncrementalImport",icon:"i-heroicons-plus-circle",hoverColor:"group-hover:text-pink-500",miniHoverBg:"hover:text-pink-500",labelKey:"analysis.tooltip.incrementalImport"},{event:"openSemanticIndex",icon:"i-heroicons-circle-stack",hoverColor:"group-hover:text-indigo-500",miniHoverBg:"hover:text-indigo-500",labelKey:"analysis.tooltip.semanticIndex"},{event:"openMemberManagement",icon:"i-heroicons-user-group",hoverColor:"group-hover:text-purple-500",miniHoverBg:"hover:text-purple-500",labelKey:"analysis.tooltip.memberManagement"},{event:"openChatRecord",icon:"i-heroicons-chat-bubble-bottom-center-text",hoverColor:"group-hover:text-cyan-500",miniHoverBg:"hover:text-cyan-500",labelKey:"analysis.tooltip.viewChatRecord"},{event:"openMessageExport",icon:"i-heroicons-document-arrow-down",hoverColor:"group-hover:text-green-500",miniHoverBg:"hover:text-green-500",labelKey:"analysis.messageExport.title"}],b=[{event:"openSemanticIndex",icon:"i-heroicons-circle-stack",hoverColor:"group-hover:text-indigo-500",miniHoverBg:"hover:text-indigo-500",labelKey:"analysis.tooltip.semanticIndex"},{event:"openMessageExport",icon:"i-heroicons-document-arrow-down",hoverColor:"group-hover:text-green-500",miniHoverBg:"hover:text-green-500",labelKey:"analysis.messageExport.title"}],$=T(()=>c.value?b:k);return fe(u,()=>{o.value=!1}),Re(()=>{document.addEventListener("mousedown",y)}),Bt(()=>{document.removeEventListener("mousedown",y)}),(C,w)=>{const S=_e,I=St;return!c.value&&t(s)?(i(),m("div",Fw,[a("div",Rw,[(i(),m(re,null,ve(k,f=>h(I,{key:f.event,text:t(e)(f.labelKey),popper:{placement:"left"}},{default:F(()=>[a("button",{class:J(["flex h-7 w-7 items-center justify-center rounded-md text-gray-400 transition-colors hover:bg-gray-100 dark:text-gray-500 dark:hover:bg-white/5",f.miniHoverBg]),onClick:x=>_(f.event)},[h(S,{name:f.icon,class:"h-3.5 w-3.5"},null,8,["name"])],10,Vw)]),_:2},1032,["text"])),64)),w[2]||(w[2]=a("div",{class:"my-0.5 h-px w-4 bg-gray-200 dark:bg-gray-700"},null,-1)),h(I,{text:t(e)("analysis.toolsPanel.exitMini"),popper:{placement:"left"}},{default:F(()=>[a("button",{class:"flex h-7 w-7 items-center justify-center rounded-md text-gray-300 transition-colors hover:bg-gray-100 hover:text-gray-500 dark:text-gray-600 dark:hover:bg-white/5 dark:hover:text-gray-400",onClick:w[0]||(w[0]=f=>t(n).toggleToolsPanelMini())},[h(S,{name:"i-heroicons-arrows-pointing-out",class:"h-3 w-3"})])]),_:1},8,["text"])])])):(i(),m("div",{key:1,class:J(["fixed right-0 z-40",c.value?"top-14":"top-1/3"])},[a("div",{class:J(["absolute right-0 top-0 transition-all duration-250 ease-in-out",g.value?"translate-x-0 opacity-100":"pointer-events-none translate-x-full opacity-0"])},[a("div",{ref_key:"panelRef",ref:p,class:"no-capture flex w-40 flex-col rounded-l-xl border border-r-0 border-gray-200/60 bg-white p-3 shadow-overlay dark:border-white/5 dark:bg-page-dark"},[a("div",Ow,[a("span",Pw,d(t(e)("analysis.overview.tools")),1),c.value?E("",!0):(i(),W(I,{key:0,text:t(e)("analysis.toolsPanel.miniMode"),popper:{placement:"left"}},{default:F(()=>[a("button",{class:"flex h-5 w-5 items-center justify-center rounded text-gray-300 transition-colors hover:text-gray-500 dark:text-gray-600 dark:hover:text-gray-400",onClick:w[1]||(w[1]=f=>t(n).toggleToolsPanelMini())},[h(S,{name:"i-heroicons-arrows-pointing-in",class:"h-3 w-3"})])]),_:1},8,["text"]))]),a("div",jw,[(i(!0),m(re,null,ve($.value,f=>(i(),m("button",{key:f.event,class:"group flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs font-medium text-gray-600 transition-all hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-white/5 dark:hover:text-white",onClick:x=>_(f.event)},[h(S,{name:f.icon,class:J(["h-3.5 w-3.5 text-gray-400 transition-colors dark:text-gray-500",f.hoverColor])},null,8,["name","class"]),a("span",Uw,d(t(e)(f.labelKey)),1)],8,Nw))),128))])],512)],2)],2))}}});export{r2 as C,i2 as D,n2 as I,o2 as L,h2 as M,na as _,s2 as a,Ze as b,g2 as c,xa as d,p2 as e,Uv as f,u2 as g,c2 as h,d2 as i,a2 as j,f2 as k,x2 as l,v2 as m,y2 as n,l2 as o,vi as p,m2 as u};