chatlab-cli 0.36.1 → 0.36.2

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 (146) hide show
  1. package/dist/{chat-command-XPJ43KSW.mjs → chat-command-SEV6N3AR.mjs} +8 -8
  2. package/dist/{chunk-6QP47LID.mjs → chunk-6E46U4H2.mjs} +2 -2
  3. package/dist/{chunk-NQHZPSW2.mjs → chunk-6EZPD3XJ.mjs} +2 -2
  4. package/dist/{chunk-5MJO4AJB.mjs → chunk-CH5YAZ4Q.mjs} +2 -2
  5. package/dist/{chunk-X2QBH24F.mjs → chunk-HWIXK7SU.mjs} +2 -2
  6. package/dist/{chunk-NFTCEJBJ.mjs → chunk-TJ3NOBVI.mjs} +3 -3
  7. package/dist/{chunk-Q3NEL2KK.mjs → chunk-TRGR3KKJ.mjs} +3 -1
  8. package/dist/chunk-TRGR3KKJ.mjs.map +1 -0
  9. package/dist/{chunk-67HNPYZJ.mjs → chunk-TWH422HC.mjs} +3 -3
  10. package/dist/{chunk-FJOGBUXU.mjs → chunk-VREVDZ4Q.mjs} +4 -4
  11. package/dist/{chunk-JOVL7OTW.mjs → chunk-VUYWUHWW.mjs} +2 -2
  12. package/dist/{chunk-2JPFBIAG.mjs → chunk-WJQOXOMR.mjs} +14 -12
  13. package/dist/chunk-WJQOXOMR.mjs.map +1 -0
  14. package/dist/{chunk-L7TIIVAY.mjs → chunk-WRBFV2GX.mjs} +12 -12
  15. package/dist/{chunk-R73XMAB2.mjs → chunk-YUH3H3QW.mjs} +4 -4
  16. package/dist/cli.mjs +9 -9
  17. package/dist/contacts-worker.mjs +2 -2
  18. package/dist/global-insight-worker.mjs +1 -1
  19. package/dist/{http-5RVY5J5U.mjs → http-237XYNRT.mjs} +12 -12
  20. package/dist/{import-ILTWVHKU.mjs → import-R2E2TFAK.mjs} +7 -7
  21. package/dist/index.mjs +12 -12
  22. package/dist/{mcp-Y2YXOFB4.mjs → mcp-BED4AARV.mjs} +8 -8
  23. package/dist/people-relationships-worker.mjs +2 -2
  24. package/dist/semantic-index-worker.mjs +1 -1
  25. package/dist/{src-OV5ZNE3Z.mjs → src-AYMALWU5.mjs} +6 -6
  26. package/dist/{stream-import-XOUM3Z5W.mjs → stream-import-RXNSOOYH.mjs} +7 -7
  27. package/dist/{worker-runtime-JNGURHDM.mjs → worker-runtime-JGAZU7MC.mjs} +5 -5
  28. package/dist-cli-web/assets/{AISettingsTab-vvjijrc5.js → AISettingsTab-VgI7PiJd.js} +1 -1
  29. package/dist-cli-web/assets/{AboutTab-CxI8zJNz.js → AboutTab-DCM1-glA.js} +1 -1
  30. package/dist-cli-web/assets/ActionToolsPanel-BTGgwXVD.css +1 -0
  31. package/dist-cli-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-a7RMjjve.js +112 -0
  32. package/dist-cli-web/assets/{Alert-_MYcI_E2.js → Alert-D-egBWcb.js} +1 -1
  33. package/dist-cli-web/assets/{ApiSettingsTab-CK7U6dVA.js → ApiSettingsTab-Co3LWf1f.js} +1 -1
  34. package/dist-cli-web/assets/{BatchManageTab-1WnEqqpB.js → BatchManageTab-2LrckmQm.js} +1 -1
  35. package/dist-cli-web/assets/{BufferResource-i64DlwQT.js → BufferResource-BE2_2bZK.js} +1 -1
  36. package/dist-cli-web/assets/{CanvasRenderer-B76mEt9A.js → CanvasRenderer-DDKdvEYQ.js} +1 -1
  37. package/dist-cli-web/assets/{ChatRecordDrawer-Bp6OSCrz.js → ChatRecordDrawer-DRhztqLG.js} +1 -1
  38. package/dist-cli-web/assets/{ChatRecordWorkspace-CyfPIlIy.js → ChatRecordWorkspace-DqUI4QiU.js} +1 -1
  39. package/dist-cli-web/assets/{Checkbox-Ci7IeRw1.js → Checkbox-EfpQmv4A.js} +1 -1
  40. package/dist-cli-web/assets/{DataDirCleanupNotice-Dh63pOLt.js → DataDirCleanupNotice-BYIiR58J.js} +1 -1
  41. package/dist-cli-web/assets/{DatePicker.vue_vue_type_script_setup_true_lang-DqNBNa1D.js → DatePicker.vue_vue_type_script_setup_true_lang-sPDoPzZ9.js} +1 -1
  42. package/dist-cli-web/assets/{DebugToolsPanel-CbNsD9co.js → DebugToolsPanel-BIHA6jw4.js} +1 -1
  43. package/dist-cli-web/assets/{EChart.vue_vue_type_script_setup_true_lang-YeqmodwE.js → EChart.vue_vue_type_script_setup_true_lang-DryMSoCz.js} +1 -1
  44. package/dist-cli-web/assets/{EChartBar.vue_vue_type_script_setup_true_lang-C3pZmq0v.js → EChartBar.vue_vue_type_script_setup_true_lang-BdFW-hvt.js} +1 -1
  45. package/dist-cli-web/assets/{EChartLine.vue_vue_type_script_setup_true_lang-Co6olfwv.js → EChartLine.vue_vue_type_script_setup_true_lang-C69Kdw9X.js} +1 -1
  46. package/dist-cli-web/assets/{EChartWordcloud-rDusZwSq.js → EChartWordcloud-DM7UEHdK.js} +1 -1
  47. package/dist-cli-web/assets/{Filter-yxkeHO78.js → Filter-kO4dIDJ2.js} +1 -1
  48. package/dist-cli-web/assets/{GlobalTaskBar-BlZ-fFiq.js → GlobalTaskBar-BZS_h0zC.js} +1 -1
  49. package/dist-cli-web/assets/{GroupRelationshipGalaxyView-BXQBX0zJ.js → GroupRelationshipGalaxyView--WIaHx_F.js} +1 -1
  50. package/dist-cli-web/assets/{Label-CFAZFBQX.js → Label-CIuDXyeM.js} +1 -1
  51. package/dist-cli-web/assets/{LoadingState.vue_vue_type_script_setup_true_lang-CwgpqtMZ.js → LoadingState.vue_vue_type_script_setup_true_lang-B_7VHxTx.js} +1 -1
  52. package/dist-cli-web/assets/{MessageExportModal-DU71grc7.js → MessageExportModal-BQsIpyxv.js} +1 -1
  53. package/dist-cli-web/assets/{PageHeader-BDPf4NuI.js → PageHeader-DxhQHF_0.js} +1 -1
  54. package/dist-cli-web/assets/{PageTabs.vue_vue_type_script_setup_true_lang-_j82asQU.js → PageTabs.vue_vue_type_script_setup_true_lang-Cgungbjl.js} +1 -1
  55. package/dist-cli-web/assets/{RelationshipGalaxyCanvas-BODk18aA.js → RelationshipGalaxyCanvas-Cod1JX9m.js} +3 -3
  56. package/dist-cli-web/assets/{RelationshipGalaxyThreeCanvas-BJyuRiC-.js → RelationshipGalaxyThreeCanvas-CkefzeFJ.js} +1 -1
  57. package/dist-cli-web/assets/{RenderTargetSystem-CVMvAUSv.js → RenderTargetSystem-SuQ7cbze.js} +1 -1
  58. package/dist-cli-web/assets/{RovingFocusItem-DC_06OmN.js → RovingFocusItem-psoFYxrC.js} +1 -1
  59. package/dist-cli-web/assets/{ScreenCaptureModal-DrBFDOtC.js → ScreenCaptureModal-D4r9ixKh.js} +1 -1
  60. package/dist-cli-web/assets/{SectionTabs.vue_vue_type_script_setup_true_lang-C-Zj2biH.js → SectionTabs.vue_vue_type_script_setup_true_lang-v_7aRBgM.js} +1 -1
  61. package/dist-cli-web/assets/{Select-DLK2LYhO.js → Select-CxurgslB.js} +1 -1
  62. package/dist-cli-web/assets/{SettingsModal-DqaR4Dx5.js → SettingsModal-DBZucuf6.js} +2 -2
  63. package/dist-cli-web/assets/{StorageTab-B0ebN0f8.js → StorageTab-DhSJ-0Ir.js} +1 -1
  64. package/dist-cli-web/assets/{Switch-CokhQWxm.js → Switch-3D81G6uV.js} +1 -1
  65. package/dist-cli-web/assets/{Tabs-N3Q-Mpqi.js → Tabs-Bnm_Q7yW.js} +1 -1
  66. package/dist-cli-web/assets/{Tabs-D1UiZNaZ.js → Tabs-DB603EEu.js} +1 -1
  67. package/dist-cli-web/assets/{ThemeCard.vue_vue_type_script_setup_true_lang-OT-I0mbU.js → ThemeCard.vue_vue_type_script_setup_true_lang-BDTdkH5i.js} +1 -1
  68. package/dist-cli-web/assets/{TimeSelect.vue_vue_type_script_setup_true_lang-Ccunouyf.js → TimeSelect.vue_vue_type_script_setup_true_lang-Cjz8Wpg-.js} +1 -1
  69. package/dist-cli-web/assets/{VisuallyHiddenInput-OAJEt_Y5.js → VisuallyHiddenInput-Bo_XwaLu.js} +1 -1
  70. package/dist-cli-web/assets/{WebGLRenderer-DuUeftYD.js → WebGLRenderer-D1x9WZRj.js} +1 -1
  71. package/dist-cli-web/assets/{WebGPURenderer-DoWQxiWZ.js → WebGPURenderer-37Nw-tLm.js} +1 -1
  72. package/dist-cli-web/assets/aiChat-BCzYQeZq.js +8 -0
  73. package/dist-cli-web/assets/{browserAll-Cb-mtR2y.js → browserAll-CWrz_-4U.js} +1 -1
  74. package/dist-cli-web/assets/{cli-web-BHQCZLLg.js → cli-web-C-8N0CJh.js} +1 -1
  75. package/dist-cli-web/assets/{fetch-BzXuAaT3.js → fetch-6pcVxB9h.js} +1 -1
  76. package/dist-cli-web/assets/{fetch-DEub4tOo.js → fetch-B69OkB6B.js} +1 -1
  77. package/dist-cli-web/assets/{fetch-DLTlYnDB.js → fetch-BGmCCyzz.js} +1 -1
  78. package/dist-cli-web/assets/{fetch-BkA_so1e.js → fetch-CFpLXWTe.js} +1 -1
  79. package/dist-cli-web/assets/{fetch-AvsnJLWJ.js → fetch-CgA1peJD.js} +1 -1
  80. package/dist-cli-web/assets/{fetch-B4PYy5JS.js → fetch-CkXgOxcu.js} +1 -1
  81. package/dist-cli-web/assets/{fetch-B-6tyYWu.js → fetch-DPSWt6yX.js} +1 -1
  82. package/dist-cli-web/assets/{fetch-sYDJ-Zs8.js → fetch-DZ6OF-xW.js} +1 -1
  83. package/dist-cli-web/assets/{fetch-BbcFaCRB.js → fetch-Du-wU0OO.js} +1 -1
  84. package/dist-cli-web/assets/{fetch-CW2fKvGp.js → fetch-Gu4qQjUB.js} +1 -1
  85. package/dist-cli-web/assets/{fetch-Qs38Hx1V.js → fetch-qd2FgBWQ.js} +1 -1
  86. package/dist-cli-web/assets/{fetch-ul8-uQIb.js → fetch-z9M9FcIC.js} +1 -1
  87. package/dist-cli-web/assets/{host-DYIkQqvY.js → host-CWsAWKgy.js} +1 -1
  88. package/dist-cli-web/assets/{host-B6SQ6OGo.js → host-D8zlA62K.js} +1 -1
  89. package/dist-cli-web/assets/{index-C7omDgiJ.js → index-BGd4ZfhO.js} +2 -2
  90. package/dist-cli-web/assets/{index-a8Hw6eD8.js → index-BYZF1ngN.js} +1 -1
  91. package/dist-cli-web/assets/index-BcuwlCin.css +1 -0
  92. package/dist-cli-web/assets/{index-sWxuTsa7.js → index-Bq5q3kSU.js} +4 -4
  93. package/dist-cli-web/assets/index-CPR3jdC2.js +137 -0
  94. package/dist-cli-web/assets/{index-9iaY_EWG.js → index-D3AjvaOX.js} +1 -1
  95. package/dist-cli-web/assets/{index-pkxlF8Ee.js → index-DAitScUA.js} +1 -1
  96. package/dist-cli-web/assets/{index-UpTe1KzQ.js → index-DBSMWAJ0.js} +1 -1
  97. package/dist-cli-web/assets/index-DTn9htw-.js +64 -0
  98. package/dist-cli-web/assets/{index-jwjzZNKm.js → index-DV_rWxcH.js} +1 -1
  99. package/dist-cli-web/assets/index-DxhAGqYM.css +1 -0
  100. package/dist-cli-web/assets/{index-D64XYYts.js → index-Dy0fRMDf.js} +1 -1
  101. package/dist-cli-web/assets/index-I0mIcDpE.css +1 -0
  102. package/dist-cli-web/assets/{index-CShh95fU.js → index-a7CT8DQm.js} +1 -1
  103. package/dist-cli-web/assets/index-onwNShRw.js +2 -0
  104. package/dist-cli-web/assets/{index-C_OS8Y8W.js → index-v6DlL4ue.js} +1 -1
  105. package/dist-cli-web/assets/{people-page-header-0jvXFFnh.js → people-page-header-Czt9e1jv.js} +1 -1
  106. package/dist-cli-web/assets/{prompt-BPYj29Vq.js → prompt-DGazz143.js} +1 -1
  107. package/dist-cli-web/assets/{semantic-index-config-builder-vO37z355.js → semantic-index-config-builder-BkFHzIUy.js} +1 -1
  108. package/dist-cli-web/assets/service-BMqwB74f.js +1 -0
  109. package/dist-cli-web/assets/{service-D29Vftq9.js → service-CAp0YJoS.js} +1 -1
  110. package/dist-cli-web/assets/service-CUQ8iHdS.js +1 -0
  111. package/dist-cli-web/assets/{useFormControl-DVawP2DO.js → useFormControl-DcSMUc2d.js} +1 -1
  112. package/dist-cli-web/assets/{useTable-Bv3R_Hux.js → useTable-Clmq3sge.js} +1 -1
  113. package/dist-cli-web/assets/{useToast-BA0EwImD.js → useToast-YAHDkKDN.js} +1 -1
  114. package/dist-cli-web/assets/{webworkerAll-ZPE_yGnC.js → webworkerAll-CvSp2Y8j.js} +1 -1
  115. package/dist-cli-web/index.html +2 -2
  116. package/package.json +1 -1
  117. package/dist/chunk-2JPFBIAG.mjs.map +0 -1
  118. package/dist/chunk-Q3NEL2KK.mjs.map +0 -1
  119. package/dist-cli-web/assets/ActionToolsPanel-Dp-ojXjO.css +0 -1
  120. package/dist-cli-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-w0hHEodr.js +0 -110
  121. package/dist-cli-web/assets/aiChat-CdADfRnU.js +0 -8
  122. package/dist-cli-web/assets/index--IEkRjKe.js +0 -64
  123. package/dist-cli-web/assets/index-B4J99zv3.css +0 -1
  124. package/dist-cli-web/assets/index-BBeqtL8d.css +0 -1
  125. package/dist-cli-web/assets/index-CHsM84U1.js +0 -2
  126. package/dist-cli-web/assets/index-CL8u01Pf.js +0 -137
  127. package/dist-cli-web/assets/index-DrCc8p_I.css +0 -1
  128. package/dist-cli-web/assets/service-CVoA9yNf.js +0 -1
  129. package/dist-cli-web/assets/service-DMysyLCa.js +0 -1
  130. /package/dist/{chat-command-XPJ43KSW.mjs.map → chat-command-SEV6N3AR.mjs.map} +0 -0
  131. /package/dist/{chunk-6QP47LID.mjs.map → chunk-6E46U4H2.mjs.map} +0 -0
  132. /package/dist/{chunk-NQHZPSW2.mjs.map → chunk-6EZPD3XJ.mjs.map} +0 -0
  133. /package/dist/{chunk-5MJO4AJB.mjs.map → chunk-CH5YAZ4Q.mjs.map} +0 -0
  134. /package/dist/{chunk-X2QBH24F.mjs.map → chunk-HWIXK7SU.mjs.map} +0 -0
  135. /package/dist/{chunk-NFTCEJBJ.mjs.map → chunk-TJ3NOBVI.mjs.map} +0 -0
  136. /package/dist/{chunk-67HNPYZJ.mjs.map → chunk-TWH422HC.mjs.map} +0 -0
  137. /package/dist/{chunk-FJOGBUXU.mjs.map → chunk-VREVDZ4Q.mjs.map} +0 -0
  138. /package/dist/{chunk-JOVL7OTW.mjs.map → chunk-VUYWUHWW.mjs.map} +0 -0
  139. /package/dist/{chunk-L7TIIVAY.mjs.map → chunk-WRBFV2GX.mjs.map} +0 -0
  140. /package/dist/{chunk-R73XMAB2.mjs.map → chunk-YUH3H3QW.mjs.map} +0 -0
  141. /package/dist/{http-5RVY5J5U.mjs.map → http-237XYNRT.mjs.map} +0 -0
  142. /package/dist/{import-ILTWVHKU.mjs.map → import-R2E2TFAK.mjs.map} +0 -0
  143. /package/dist/{mcp-Y2YXOFB4.mjs.map → mcp-BED4AARV.mjs.map} +0 -0
  144. /package/dist/{src-OV5ZNE3Z.mjs.map → src-AYMALWU5.mjs.map} +0 -0
  145. /package/dist/{stream-import-XOUM3Z5W.mjs.map → stream-import-RXNSOOYH.mjs.map} +0 -0
  146. /package/dist/{worker-runtime-JNGURHDM.mjs.map → worker-runtime-JGAZU7MC.mjs.map} +0 -0
@@ -0,0 +1,112 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/service-CAp0YJoS.js","assets/index-Bq5q3kSU.js","assets/vendor-snapdom--nZvo8Sg.js","assets/index-DxhAGqYM.css","assets/EChartWordcloud-DM7UEHdK.js","assets/vendor-echarts-wordcloud-B8CF_NgP.js","assets/vendor-echarts-hTLhTs52.js","assets/vendor-zrender-D8psf1AA.js"])))=>i.map(i=>d[i]);
2
+ import{bl as ia,f as T,e as t,aQ as kt,a as le,aM as Wt,v as Bt,b$ as ln,bv as Fa,aN as It,J as fe,o as l,c as P,w as L,b as $e,l as E,C as Fe,P as tt,ad as Kt,r as A,ck as aa,A as un,ch as cn,cm as dn,cI as hs,z as f,aO as it,aP as Ke,cJ as mn,x as He,y as dt,s as At,m as Pe,u as rt,cK as gn,c7 as pn,cL as fn,G as hn,cM as ts,aq as ma,cN as vn,cO as yn,c8 as vs,cP as xn,h as g,F as ie,j as _e,k as ys,am as mt,cQ as bn,bd as xs,bV as kn,cB as _n,ca as wn,bZ as $n,bY as Cn,b_ as Sn,bW as In,c1 as bs,c2 as Tn,bX as Mn,a_ as Tt,c4 as An,c5 as zn,bm as qn,a6 as ne,p as d,a$ as jt,c9 as Ln,cR as Dn,cS as En,aX as Ze,bC as yt,cT as Ma,aE as Ne,bs as ga,K as at,bR as Bn,i as a,n as W,_ as Fn,E as Rn,ak as Ft,H as Vn,ae as gt,a3 as Ie,a9 as pa,a5 as Xe,a4 as Me,a7 as lt,I as zt,az as _t,bT as Ra,aH as ct,aI as Lt,aD as Mt,cr as On,ar as Va,Z as ra,as as Pn,aR as ks,aS as _s,aW as Nn,aT as Oa,bA as ws,cU as as,cb as Nt,at as la,cc as jn,b0 as Un,ap as Yt,a1 as Ut,au as Pa,bB as Na,cd as ss,ce as Ot,aJ as $s,cf as Cs,av as Dt,cV as Hn,cg as Wn,cE as Kn,aK as ot,bN as Ss,cW as Yn,bg as Rt,bS as Gn,bO as Qn,cu as Et,cX as Xt,aC as Jn,ax as Xn,a8 as ja,af as Ct,br as Is,d as Zn,N as ns,S as eo,t as to,ao,bf as so,$ as no,aL as oo,Y as io,co as ro,ct as os}from"./index-Bq5q3kSU.js";import{L as lo,i as uo,_ as ua,u as co}from"./LoadingState.vue_vue_type_script_setup_true_lang-B_7VHxTx.js";import{_ as Ua}from"./SectionTabs.vue_vue_type_script_setup_true_lang-v_7aRBgM.js";import{_ as Ha}from"./Select-CxurgslB.js";import{_ as Wa}from"./Checkbox-EfpQmv4A.js";import{u as ft}from"./useToast-YAHDkKDN.js";import{a as Ht,M as Ka,_ as mo}from"./index-Dy0fRMDf.js";import{u as fa}from"./prompt-DGazz143.js";import{useCacheService as Ts}from"./service-CAp0YJoS.js";import{u as go,a as Ms,s as po,b as Vt,c as Gt}from"./aiChat-BCzYQeZq.js";import{_ as wt}from"./ThemeCard.vue_vue_type_script_setup_true_lang-BDTdkH5i.js";import{a as fo,s as ho,f as vo}from"./ChatRecordWorkspace-DqUI4QiU.js";import{T as St}from"./Tabs-Bnm_Q7yW.js";import{_ as xt,g as Aa}from"./EChartBar.vue_vue_type_script_setup_true_lang-BdFW-hvt.js";import{_ as za}from"./EChartLine.vue_vue_type_script_setup_true_lang-C69Kdw9X.js";import{C as yo,_ as Ya}from"./EChart.vue_vue_type_script_setup_true_lang-DryMSoCz.js";import"./vendor-echarts-wordcloud-B8CF_NgP.js";import{u as ha,p as As,y as zs,j as Ga,v as qs,i as va,k as ya,m as xo,n as bo,t as ko,z as _o}from"./vendor-echarts-hTLhTs52.js";import{a as Ls}from"./Tabs-DB603EEu.js";import{u as Ds}from"./useFormControl-DcSMUc2d.js";import{V as Es}from"./VisuallyHiddenInput-Bo_XwaLu.js";import{u as Qa,a as wo,i as $o}from"./semantic-index-config-builder-BkFHzIUy.js";import{c as Co,d as is,_ as So}from"./TimeSelect.vue_vue_type_script_setup_true_lang-Cjz8Wpg-.js";import{_ as Io,u as To,a as Mo}from"./useTable-Clmq3sge.js";import{P as Ao}from"./PageHeader-DxhQHF_0.js";import{_ as zo}from"./PageTabs.vue_vue_type_script_setup_true_lang-Cgungbjl.js";import{_ as qo}from"./Alert-D-egBWcb.js";function sa(r,i,e){const s=r.findIndex(c=>ia(c,i)),n=r.findIndex(c=>ia(c,e));if(s===-1||n===-1)return[];const[u,o]=[s,n].sort((c,m)=>c-m);return r.slice(u,o+1)}function Bs(r){const i=T(()=>t(r)),e=T(()=>new Intl.Collator("en",{usage:"search",...i.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 m=0;const h=c.length;for(;m+h<=o.length;m++){const p=o.slice(m,m+h);if(e.value.compare(c,p)===0)return!0}return!1}}}function rs(r){return r?.querySelector("[data-state=checked]")}function Lo(r,i,e){return r===void 0?!1:Array.isArray(r)?r.some(s=>bt(s,i,e)):bt(r,i,e)}function bt(r,i,e){return r===void 0||i===void 0?!1:typeof r=="string"?r===i:typeof e=="function"?e(r,i):typeof e=="string"?r?.[e]===i?.[e]:ia(r,i)}const[Qt,Do]=kt("ListboxRoot");var Eo=le({__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:i,emit:e}){const s=r,n=e,{multiple:u,highlightOnHover:o,orientation:c,disabled:m,selectionBehavior:h,dir:p}=Wt(s),{getItems:_}=Bt({isProvider:!0}),{handleTypeaheadSearch:y}=ln(),{primitiveElement:b,currentElement:x}=Kt(),k=dn(),I=Fa(p),$=Ds(x),w=A(),C=A(!1),v=A(!0),S=It(s,"modelValue",n,{defaultValue:s.defaultValue??(u.value?[]:void 0),passive:s.modelValue===void 0,deep:!0});function V(ce){if(C.value=!0,s.multiple){const X=Array.isArray(S.value)?[...S.value]:[],Q=X.findIndex(xe=>bt(xe,ce,s.by));s.selectionBehavior==="toggle"?(Q===-1?X.push(ce):X.splice(Q,1),S.value=X):(S.value=[ce],w.value=ce)}else s.selectionBehavior==="toggle"&&bt(S.value,ce,s.by)?S.value=void 0:S.value=ce;setTimeout(()=>{C.value=!1},1)}const B=A(null),D=A(null),z=A(!1),M=A(!1),q=aa(),U=aa(),Y=aa();function te(){return _().map(ce=>ce.ref).filter(ce=>ce.dataset.disabled!=="")}function K(ce,X=!0,Q){if(!ce)return;B.value=ce,(Q??v.value)&&B.value.focus(),X&&B.value.scrollIntoView({block:"nearest"});const xe=_().find(Ae=>Ae.ref===ce);n("highlight",xe)}function j(ce){if(z.value)Y.trigger(ce);else{const X=_().find(Q=>bt(Q.value,ce,s.by));X&&(B.value=X.ref,K(X.ref))}}function N(ce){B.value&&B.value.isConnected&&(ce.preventDefault(),ce.stopPropagation(),M.value||B.value.click())}function F(ce){if(v.value){if(C.value=!0,z.value)U.trigger(ce);else{const X=ce.altKey||ce.ctrlKey||ce.metaKey;if(X&&ce.key==="a"&&u.value){const Q=_(),xe=Q.map(ze=>ze.value);S.value=[...xe],ce.preventDefault();const Ae=Q.at(-1);Ae&&K(Ae.ref)}else if(!X){const Q=y(ce.key,_());Q&&K(Q)}}setTimeout(()=>{C.value=!1},1)}}function Z(){M.value=!0}function ue(){Fe(()=>{M.value=!1})}function ve(){Fe(()=>{const ce=new KeyboardEvent("keydown",{key:"PageUp"});H(ce)})}function ae(ce){const X=B.value;X?.isConnected&&(D.value=X),B.value=null,n("leave",ce)}function re(ce){const X=new CustomEvent("listbox.entryFocus",{bubbles:!1,cancelable:!0});if(ce.currentTarget?.dispatchEvent(X),n("entryFocus",X),!X.defaultPrevented)if(D.value)K(D.value);else{const Q=te()?.[0];K(Q)}}function H(ce){const X=un(ce,c.value,I.value);if(!X)return;let Q=te();if(B.value){if(X==="last")Q.reverse();else if(X==="prev"||X==="next"){X==="prev"&&Q.reverse();const xe=Q.indexOf(B.value);Q=Q.slice(xe+1)}be(ce,Q[0])}if(Q.length){const xe=!B.value&&X==="prev"?Q.length-1:0;K(Q[xe])}if(z.value)return U.trigger(ce)}function be(ce,X){if(!(z.value||s.selectionBehavior!=="replace"||!u.value||!Array.isArray(S.value)||(ce.altKey||ce.ctrlKey||ce.metaKey)&&!ce.shiftKey)&&ce.shiftKey){const xe=_().filter(je=>je.ref.dataset.disabled!=="");let Ae=xe.find(je=>je.ref===X)?.value;if(ce.key===k.END?Ae=xe.at(-1)?.value:ce.key===k.HOME&&(Ae=xe[0]?.value),!Ae||!w.value)return;const ze=sa(xe.map(je=>je.value),w.value,Ae);S.value=ze}}async function Te(ce,X=!0){if(cn)if(await Fe(),z.value)q.trigger({event:ce,scroll:X});else{const Q=te(),xe=Q.find(ze=>ze.dataset.state==="checked"),Ae=X?void 0:!1;xe?K(xe,X,Ae):Q.length&&K(Q[0],X,Ae)}}let we=!1;return fe(S,()=>{if(!C.value){const ce=we;we=!0,Fe(()=>{Te(void 0,ce)})}},{immediate:!0,deep:!0}),i({highlightedElement:B,highlightItem:j,highlightFirstItem:ve,highlightSelected:Te,getItems:_}),Do({modelValue:S,onValueChange:V,multiple:u,orientation:c,dir:I,disabled:m,highlightOnHover:o,highlightedElement:B,isVirtual:z,virtualFocusHook:q,virtualKeydownHook:U,virtualHighlightHook:Y,by:s.by,firstValue:w,selectionBehavior:h,focusable:v,onLeave:ae,onEnter:re,changeHighlight:K,onKeydownEnter:N,onKeydownNavigation:H,onKeydownTypeAhead:F,onCompositionStart:Z,onCompositionEnd:ue,highlightFirstItem:ve}),(ce,X)=>(l(),P(t(tt),{ref_key:"primitiveElement",ref:b,as:ce.as,"as-child":ce.asChild,dir:t(I),"data-disabled":t(m)?"":void 0,onPointerleave:ae,onFocusout:X[0]||(X[0]=async Q=>{const xe=Q.relatedTarget||Q.target;await Fe(),B.value&&t(x)&&!t(x).contains(xe)&&ae(Q)})},{default:L(()=>[$e(ce.$slots,"default",{modelValue:t(S)}),t($)&&ce.name?(l(),P(t(Es),{key:0,name:ce.name,value:t(S),disabled:t(m),required:ce.required},null,8,["name","value","disabled","required"])):E("v-if",!0)]),_:3},8,["as","as-child","dir","data-disabled"]))}}),Bo=Eo,Fo=le({__name:"ListboxContent",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(r){const{CollectionSlot:i}=Bt(),e=Qt(),s=hs(!1,10);return(n,u)=>(l(),P(t(i),null,{default:L(()=>[f(t(tt),{role:"listbox",as:n.as,"as-child":n.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]=Ke(o=>s.value=!0,["left"])),onFocus:u[1]||(u[1]=o=>{t(s)||t(e).onEnter(o)}),onKeydown:[u[2]||(u[2]=it(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"])),it(t(e).onKeydownEnter,["enter"]),t(e).onKeydownTypeAhead]},{default:L(()=>[$e(n.$slots,"default")]),_:3},8,["as","as-child","tabindex","aria-orientation","aria-multiselectable","data-orientation","onKeydown"])]),_:3}))}}),Ro=Fo,Vo=le({__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:i}){const e=r,n=It(e,"modelValue",i,{defaultValue:"",passive:e.modelValue===void 0}),u=Qt(),{primitiveElement:o,currentElement:c}=Kt(),m=T(()=>e.disabled||u.disabled.value||!1),h=A();mn(()=>h.value=u.highlightedElement.value?.id),He(()=>{u.focusable.value=!1,setTimeout(()=>{e.autoFocus&&c.value?.focus()},1)}),dt(()=>{u.focusable.value=!0});const{isComposing:p,handleCompositionStart:_,handleCompositionEnd:y}=Qa($=>{n.value=$.target.value,u.onCompositionEnd(),u.highlightFirstItem()});function b(){u.onCompositionStart(),_()}function x($){p.value||(n.value=$.target.value,u.highlightFirstItem())}function k($){p.value||($.preventDefault(),u.onKeydownNavigation($))}function I($){p.value||u.onKeydownEnter($)}return($,w)=>(l(),P(t(tt),{ref_key:"primitiveElement",ref:o,as:$.as,"as-child":$.asChild,value:t(n),disabled:m.value?"":void 0,"data-disabled":m.value?"":void 0,"aria-disabled":m.value??void 0,"aria-activedescendant":h.value,type:"text",onKeydown:[it(k,["down","up","home","end"]),it(I,["enter"])],onInput:x,onCompositionstart:b,onCompositionend:t(y)},{default:L(()=>[$e($.$slots,"default",{modelValue:t(n)})]),_:3},8,["as","as-child","value","disabled","data-disabled","aria-disabled","aria-activedescendant","onCompositionend"]))}}),Oo=Vo;const[B2,Po]=kt("ListboxGroup");var No=le({__name:"ListboxGroup",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(r){const i=r,e=At(void 0,"reka-listbox-group");return Po({id:e}),(s,n)=>(l(),P(t(tt),Pe({role:"group"},i,{"aria-labelledby":t(e)}),{default:L(()=>[$e(s.$slots,"default")]),_:3},16,["aria-labelledby"]))}}),jo=No;const Uo="listbox.select",[Ho,Wo]=kt("ListboxItem");var Ko=le({__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:i}){const e=r,s=i,n=At(void 0,"reka-listbox-item"),{CollectionItem:u}=Bt(),{forwardRef:o,currentElement:c}=rt(),m=Qt(),h=T(()=>c.value!=null&&c.value===m.highlightedElement.value),p=T(()=>Lo(m.modelValue.value,e.value,m.by)),_=T(()=>m.disabled.value||e.disabled);async function y(x){s("select",x),!x?.defaultPrevented&&!_.value&&x&&(m.onValueChange(e.value),m.changeHighlight(c.value))}function b(x){const k={originalEvent:x,value:e.value};pn(Uo,y,k)}return Wo({isSelected:p}),(x,k)=>(l(),P(t(u),{value:x.value},{default:L(()=>[gn([h.value,p.value,_.value,t(m).focusable.value],()=>f(t(tt),Pe({id:t(n)},x.$attrs,{ref:t(o),role:"option",tabindex:t(m).focusable.value?h.value?"0":"-1":-1,"aria-selected":p.value,as:x.as,"as-child":x.asChild,disabled:_.value?"":void 0,"data-disabled":_.value?"":void 0,"data-highlighted":h.value?"":void 0,"data-state":p.value?"checked":"unchecked",onClick:b,onKeydown:it(Ke(b,["prevent"]),["space"]),onPointermove:k[0]||(k[0]=()=>{t(m).highlightedElement.value!==t(c)&&t(m).highlightOnHover.value&&t(m).changeHighlight(t(c),!1,!1)})}),{default:L(()=>[$e(x.$slots,"default")]),_:3},16,["id","tabindex","aria-selected","as","as-child","disabled","data-disabled","data-highlighted","data-state","onKeydown"]),k,1)]),_:3},8,["value"]))}}),Yo=Ko,Go=le({__name:"ListboxItemIndicator",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(r){const i=r;rt();const e=Ho();return(s,n)=>t(e).isSelected.value?(l(),P(t(tt),Pe({key:0,"aria-hidden":"true"},i),{default:L(()=>[$e(s.$slots,"default")]),_:3},16)):E("v-if",!0)}}),Qo=Go;function Jo(r,i,e){const s=new Array(r);return new Proxy(s,{get(n,u,o){if(typeof u=="string"){const c=u.charCodeAt(0);if(c>=48&&c<=57){const m=+u;if(Number.isInteger(m)&&m>=0&&m<r){let h=n[m];if(!h){const p=i[m*2];h=n[m]={index:m,key:e(m),start:p,size:i[m*2+1],end:p+i[m*2+1],lane:0}}return h}}if(u==="length")return r}return Reflect.get(n,u,o)}})}function qt(r,i,e){let s=e.initialDeps??[],n,u=!0;function o(){const c=r();return(c.length!==s.length||c.some((h,p)=>s[p]!==h))&&(s=c,n=i(...c),e?.onChange&&!(u&&e.skipInitialOnChange)&&e.onChange(n),u=!1),n}return o.updateDeps=c=>{s=c},o}function ls(r,i){if(r===void 0)throw new Error("Unexpected undefined");return r}const Xo=(r,i)=>Math.abs(r-i)<1.01,Zo=(r,i,e)=>{let s;return function(...n){r.clearTimeout(s),s=r.setTimeout(()=>i.apply(this,n),e)}};let Pt;const ka=()=>{if(Pt!==void 0)return Pt;if(typeof navigator>"u")return Pt=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Pt=!0;const r=navigator.maxTouchPoints;return Pt=navigator.platform==="MacIntel"&&r!==void 0&&r>0},us=r=>{const{offsetWidth:i,offsetHeight:e}=r;return{width:i,height:e}},ei=r=>r,ti=r=>{const i=Math.max(r.startIndex-r.overscan,0),s=Math.min(r.endIndex+r.overscan,r.count-1)-i+1,n=new Array(s);for(let u=0;u<s;u++)n[u]=i+u;return n},ai=(r,i)=>{const e=r.scrollElement;if(!e)return;const s=r.targetWindow;if(!s)return;const n=o=>{const{width:c,height:m}=o;i({width:Math.round(c),height:Math.round(m)})};if(n(us(e)),!s.ResizeObserver)return()=>{};const u=new s.ResizeObserver(o=>{const c=()=>{const m=o[0];if(m?.borderBoxSize){const h=m.borderBoxSize[0];if(h){n({width:h.inlineSize,height:h.blockSize});return}}n(us(e))};r.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return u.observe(e,{box:"border-box"}),()=>{u.unobserve(e)}},ca={passive:!0},si=typeof window>"u"?!0:"onscrollend"in window,ni=(r,i,e)=>{const s=r.scrollElement;if(!s)return;const n=r.targetWindow;if(!n)return;const u=r.options.useScrollendEvent&&si;let o=0;const c=u?null:Zo(n,()=>i(o,!1),r.options.isScrollingResetDelay),m=_=>()=>{o=e(s),c?.(),i(o,_)},h=m(!0),p=m(!1);return s.addEventListener("scroll",h,ca),u&&s.addEventListener("scrollend",p,ca),()=>{s.removeEventListener("scroll",h),u&&s.removeEventListener("scrollend",p)}},oi=(r,i)=>ni(r,i,e=>{const{horizontal:s,isRtl:n}=r.options;return s?e.scrollLeft*(n&&-1||1):e.scrollTop}),ii=(r,i,e)=>{if(e.options.useCachedMeasurements){const s=e.indexFromElement(r),n=e.options.getItemKey(s);return e.itemSizeCache.get(n)??e.options.estimateSize(s)}if(i?.borderBoxSize){const s=i.borderBoxSize[0];if(s)return Math.round(s[e.options.horizontal?"inlineSize":"blockSize"])}if(!i){const s=e.indexFromElement(r),n=e.options.getItemKey(s),u=e.itemSizeCache.get(n);if(u!==void 0)return u}return r[e.options.horizontal?"offsetWidth":"offsetHeight"]},ri=(r,{adjustments:i=0,behavior:e},s)=>{var n,u;(u=(n=s.scrollElement)==null?void 0:n.scrollTo)==null||u.call(n,{[s.options.horizontal?"left":"top"]:r+i,behavior:e})},li=ri;class ui{constructor(i){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,s,n;return((n=(s=(e=this.targetWindow)==null?void 0:e.performance)==null?void 0:s.now)==null?void 0:n.call(s))??Date.now()},this.observer=(()=>{let e=null;const s=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(n=>{n.forEach(u=>{const o=()=>{const c=u.target,m=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);for(const[h,p]of this.elementsCache)if(p===c){this.elementsCache.delete(h);break}return}this.shouldMeasureDuringScroll(m)&&this.resizeItem(m,this.options.measureElement(c,u,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var n;(n=s())==null||n.disconnect(),e=null},observe:n=>{var u;return(u=s())==null?void 0:u.observe(n,{box:"border-box"})},unobserve:n=>{var u;return(u=s())==null?void 0:u.unobserve(n)}}})(),this.range=null,this.setOptions=e=>{var s,n;const u={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ei,rangeExtractor:ti,onChange:()=>{},measureElement:ii,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 b=e[y];b!==void 0&&(u[y]=b)}const o=this.options;let c=null,m=null,h=!1;if(o!==void 0&&o.enabled&&u.enabled&&u.anchorTo==="end"&&this.scrollElement!==null){const y=o.count,b=u.count,x=this.getMeasurements(),k=y>0?((s=x[0])==null?void 0:s.key)??o.getItemKey(0):null,I=y>0?((n=x[y-1])==null?void 0:n.key)??o.getItemKey(y-1):null;if(b!==y||y>0&&b>0&&(u.getItemKey(0)!==k||u.getItemKey(b-1)!==I)){h=!0;const C=y>0?this.getVirtualItemForOffset(this.getScrollOffset())??x[0]:null;C&&(c=[C.key,this.getScrollOffset()-C.start]);const v=u.followOnAppend===!0?"auto":u.followOnAppend||null;v&&b>y&&this.isAtEnd(o.scrollEndThreshold)&&(y===0||u.getItemKey(b-1)!==I)&&(m=v)}}this.options=u,h&&(this.pendingMin=0,this.itemSizeCacheVersion++);let p=!1,_=0;if(c&&this.scrollOffset!==null){const[y,b]=c,x=this.getMeasurements(),{count:k,getItemKey:I}=this.options;let $=0;for(;$<k&&I($)!==y;)$++;if($<k){const w=x[$];if(w){const C=w.start+b;C!==this.scrollOffset&&(_=C-this.scrollOffset,this.scrollOffset=C,p=!0)}}}(p||m)&&(this.pendingScrollAnchor=[p?c[0]:null,p?c[1]:0,m,_])},this.notify=e=>{var s,n;(n=(s=this.options).onChange)==null||n.call(s,this,e)},this.maybeNotify=qt(()=>(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 s=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==s){if(this.cleanup(),!s){this.maybeNotify();return}if(this.scrollElement=s,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,!(!ka()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};u.addEventListener("touchstart",o,ca),u.addEventListener("touchend",c,ca),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 n=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,n&&this.scrollElement&&this.options.enabled){const[u,o,c,m]=n;u!==null&&!c&&(ka()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?m!==0&&(this._iosDeferredAdjustment+=m):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(),s=this.getMaxScrollOffset();if(e<0||e>s)return;const n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,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=qt(()=>[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,s,n,u,o,c,m,h)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMin=null,{count:e,paddingStart:s,scrollMargin:n,getItemKey:u,enabled:o,lanes:c,laneAssignmentMode:m,gap:h}),{key:!1}),this.getMeasurements=qt(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:s,scrollMargin:n,getItemKey:u,enabled:o,lanes:c,laneAssignmentMode:m,gap:h},p)=>{const _=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(const $ of this.laneAssignments.keys())$>=e&&this.laneAssignments.delete($);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($=>{this.itemSizeCache.set($.key,$.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 $=e*2;let w=this._flatMeasurements;if(!w||w.length<$){const S=new Float64Array($);w&&y>0&&S.set(w.subarray(0,y*2)),w=S,this._flatMeasurements=w}let C;if(y===0)C=s+n;else{const S=y-1;C=w[S*2]+w[S*2+1]+h}for(let S=y;S<e;S++){const V=u(S),B=_.get(V),D=typeof B=="number"?B:this.options.estimateSize(S);w[S*2]=C,w[S*2+1]=D,C+=D+h}const v=Jo(e,w,u);return this.measurementsCache=v,v}const b=this.measurementsCache.slice(0,y),x=new Array(c).fill(void 0),k=new Float64Array(c);let I=0;for(let $=0;$<y;$++){const w=b[$];w&&(x[w.lane]===void 0&&I++,x[w.lane]=$,k[w.lane]=w.end)}for(let $=y;$<e;$++){const w=u($),C=this.laneAssignments.get($);let v,S;const V=m==="estimate"||_.has(w);if(C!==void 0&&this.options.lanes>1){v=C;const M=x[v],q=M!==void 0?b[M]:void 0;S=q?q.end+h:s+n}else if(I===c){let M=0,q=k[0],U=x[0];for(let Y=1;Y<c;Y++){const te=k[Y];(te<q||te===q&&x[Y]<U)&&(M=Y,q=te,U=x[Y])}v=M,S=q+h,V&&this.laneAssignments.set($,v)}else v=$%this.options.lanes,S=s+n,V&&this.laneAssignments.set($,v);const B=_.get(w),D=typeof B=="number"?B:this.options.estimateSize($),z=S+D;b[$]={index:$,start:S,size:D,end:z,key:w,lane:v},x[v]===void 0&&I++,x[v]=$,k[v]=z}return this.measurementsCache=b,b},{key:!1,debug:()=>this.options.debug}),this.calculateRange=qt(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,s,n,u)=>e.length===0||s===0?(this.range=null,null):(this.range=di(e,s,n,u,u===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=qt(()=>{let e=null,s=null;const n=this.calculateRange();return n&&(e=n.startIndex,s=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,s]},(e,s,n,u,o)=>u===null||o===null?[]:e({startIndex:u,endIndex:o,overscan:s,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{const s=this.options.indexAttribute,n=e.getAttribute(s);return n?parseInt(n,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const n=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(n!==void 0&&this.range){const u=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,n-u),c=Math.min(this.options.count-1,n+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 s=this.indexFromElement(e),n=this.options.getItemKey(s),u=this.elementsCache.get(n);u!==e&&(u&&this.observer.unobserve(u),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,s)=>{var n,u;if(e<0||e>=this.options.count)return;let o,c,m;const h=this._flatMeasurements;if(this.options.lanes===1&&h!==null)m=this.options.getItemKey(e),c=h[e*2],o=h[e*2+1];else{const y=this.measurementsCache[e];if(!y)return;m=y.key,c=y.start,o=y.size}const p=this.itemSizeCache.get(m)??o,_=s-p;if(_!==0){const y=this.options.anchorTo==="end"&&((n=this.scrollState)==null?void 0:n.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,b=y?this.getTotalSize():0,x=((u=this.scrollState)==null?void 0:u.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:m,start:c,size:o,end:c+o,lane:0},_,this):c<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(m)||this.scrollDirection!=="backward"));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(m,s),this.itemSizeCacheVersion++,y?this.applyScrollAdjustment(this.getTotalSize()-b):x&&this.applyScrollAdjustment(_),this.notify(!1)}},this.getVirtualItems=qt(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,s)=>{const n=[];for(let u=0,o=e.length;u<o;u++){const c=e[u],m=s[c];n.push(m)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{const s=this.getMeasurements();if(s.length===0)return;const n=this._flatMeasurements,u=this.options.lanes===1&&n!=null,o=Fs(0,s.length-1,u?c=>n[c*2]:c=>ls(s[c]).start,e);return ls(s[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,s,n=0)=>{if(!this.scrollElement)return 0;const u=this.getSize(),o=this.getScrollOffset();s==="auto"&&(s=e>=o+u?"end":"start"),s==="center"?e+=(n-u)/2:s==="end"&&(e-=u);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,e),0)},this.getOffsetForIndex=(e,s="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));const n=this.getSize(),u=this.getScrollOffset(),o=this.measurementsCache[e];if(!o)return;if(s==="auto")if(o.end>=u+n-this.options.scrollPaddingEnd)s="end";else if(o.start<=u+this.options.scrollPaddingStart)s="start";else return[u,s];if(s==="end"&&e===this.options.count-1)return[this.getMaxScrollOffset(),s];const c=s==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,s,o.size),s]},this.scrollToOffset=(e,{align:s="start",behavior:n="auto"}={})=>{const u=this.getOffsetForAlignment(e,s),o=this.now();this.scrollState={index:null,align:s,behavior:n,startedAt:o,lastTargetOffset:u,stableFrames:0},this._scrollToOffset(u,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:s="auto",behavior:n="auto"}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));const u=this.getOffsetForIndex(e,s);if(!u)return;const[o,c]=u,m=this.now();this.scrollState={index:e,align:c,behavior:n,startedAt:m,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:s="auto"}={})=>{const n=this.getScrollOffset()+e,u=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:u,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:s}),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 s=this.getMeasurements();let n;if(s.length===0)n=this.options.paddingStart;else if(this.options.lanes===1){const u=s.length-1,o=this._flatMeasurements;o!=null?n=o[u*2]+o[u*2+1]:n=((e=s[u])==null?void 0:e.end)??0}else{const u=Array(this.options.lanes).fill(null);let o=s.length-1;for(;o>=0&&u.some(c=>c===null);){const c=s[o];u[c.lane]===null&&(u[c.lane]=c.end),o--}n=Math.max(...u.filter(c=>c!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const e=[];if(this.itemSizeCache.size===0)return e;const s=this.getMeasurements();for(const n of s)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:s,behavior:n})=>{this._intendedScrollOffset=e+(s??0),this.options.scrollToFn(e,{behavior:n,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(i)}applyScrollAdjustment(i,e){i!==0&&(ka()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=i:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=i,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 s=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,n=s?s[0]:this.scrollState.lastTargetOffset,u=1,o=n!==this.scrollState.lastTargetOffset;if(!o&&Xo(n,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=u){this.getScrollOffset()!==n&&this._scrollToOffset(n,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const c=this.getSize()||600,m=Math.abs(n-this.getScrollOffset()),h=this.scrollState.behavior==="smooth"&&m>c;this.scrollState.lastTargetOffset=n,h||(this.scrollState.behavior="auto"),this._scrollToOffset(n,{adjustments:void 0,behavior:h?"smooth":"auto"})}this.scheduleScrollReconcile()}}const Fs=(r,i,e,s)=>{for(;r<=i;){const n=(r+i)/2|0,u=e(n);if(u<s)r=n+1;else if(u>s)i=n-1;else return n}return r>0?r-1:0};function ci(r,i,e){let s=0;for(;s<=i;){const n=(s+i)/2|0,u=r[n*2];if(u<e)s=n+1;else if(u>e)i=n-1;else return n}return s>0?s-1:0}function di(r,i,e,s,n){const u=r.length-1;if(r.length<=s)return{startIndex:0,endIndex:u};if(s===1&&n!==null){const h=ci(n,u,e);let p=h;const _=e+i;for(;p<u&&n[p*2]+n[p*2+1]<_;)p++;return{startIndex:h,endIndex:p}}let c=Fs(0,u,h=>r[h].start,e),m=c;if(s===1)for(;m<u&&r[m].end<e+i;)m++;else if(s>1){const h=Array(s).fill(0);for(;m<u&&h.some(_=>_<e+i);){const _=r[m];h[_.lane]=_.end,m++}const p=Array(s).fill(e+i);for(;c>=0&&p.some(_=>_>=e);){const _=r[c];p[_.lane]=_.start,c--}c=Math.max(0,c-c%s),m=Math.min(u,m+(s-1-m%s))}return{startIndex:c,endIndex:m}}function mi(r){const i=new ui(t(r)),e=hn(i),s=i._didMount();return fe(()=>t(r).getScrollElement(),n=>{n&&i._willUpdate()},{immediate:!0}),fe(()=>t(r),n=>{i.setOptions({...n,onChange:(u,o)=>{var c;ts(e),(c=n.onChange)==null||c.call(n,u,o)}}),i._willUpdate(),ts(e)},{immediate:!0}),fn(s),e}function gi(r){return mi(T(()=>({observeElementRect:ai,observeElementOffset:oi,scrollToFn:li,...t(r)})))}var pi=le({__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 i=r,e=ma(),s=Qt(),n=vn(),{getItems:u}=Bt();s.isVirtual.value=!0;const o=T(()=>{const y=n.value;if(y){const b=window.getComputedStyle(y);return{start:Number.parseFloat(b.paddingBlockStart||b.paddingTop),end:Number.parseFloat(b.paddingBlockEnd||b.paddingBottom)}}else return{start:0,end:0}}),c=gi({get scrollPaddingStart(){return o.value.start},get scrollPaddingEnd(){return o.value.end},get count(){return i.options.length},get horizontal(){return s.orientation.value==="horizontal"},estimateSize(y){return typeof i.estimateSize=="function"?i.estimateSize(y):i.estimateSize??28},getScrollElement(){return n.value},overscan:i.overscan??12}),m=T(()=>c.value.getVirtualItems().map(y=>{const b=e.default({option:i.options[y.index],virtualizer:c.value,virtualItem:y})[0],x=b.type===ie&&Array.isArray(b.children)?b.children.find(k=>typeof k.type!="symbol"):b;return{item:y,is:bn(x,{key:`${y.key}`,"data-index":y.index,"aria-setsize":i.options.length,"aria-posinset":y.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${y.start}px)`,overflowAnchor:"none"}})}}));s.virtualFocusHook.on(({event:y,scroll:b})=>{const x=i.options.findIndex(k=>Array.isArray(s.modelValue.value)?bt(k,s.modelValue.value[0],s.by):bt(k,s.modelValue.value,s.by));x!==-1?(y?.preventDefault(),c.value.scrollToIndex(x,{align:"start"}),requestAnimationFrame(()=>{const k=rs(n.value);k&&(s.changeHighlight(k,b,b?void 0:!1),y&&k?.focus())})):b?s.highlightFirstItem():requestAnimationFrame(()=>{const k=u().find(I=>I.ref.dataset.disabled!=="")?.ref;k&&s.changeHighlight(k,!1,!1)})}),s.virtualHighlightHook.on(y=>{const b=i.options.findIndex(x=>bt(x,y,s.by));c.value.scrollToIndex(b,{align:"start"}),requestAnimationFrame(()=>{const x=rs(n.value);x&&s.changeHighlight(x)})});const h=hs("",1e3),p=T(()=>{const y=b=>i.textContent?i.textContent(b):b?.toString().toLowerCase();return i.options.map((b,x)=>({index:x,textContent:y(b)}))});function _(y,b){if(!s.firstValue?.value||!s.multiple.value||!Array.isArray(s.modelValue.value))return;const k=u().filter($=>$.ref.dataset.disabled!=="").find($=>$.ref===s.highlightedElement.value)?.value;if(!k)return;let I=null;switch(b){case"prev":case"next":{I=sa(i.options,s.firstValue.value,k);break}case"first":{I=sa(i.options,s.firstValue.value,i.options?.[0]);break}case"last":{I=sa(i.options,s.firstValue.value,i.options.at(-1));break}}s.modelValue.value=I}return s.virtualKeydownHook.on(y=>{const b=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!b)return;let k=yn[y.key];if(b&&y.key==="a"&&s.multiple.value?(y.preventDefault(),s.modelValue.value=[...i.options],k="last"):y.shiftKey&&k&&_(y,k),["first","last"].includes(k)){y.preventDefault();const I=k==="first"?0:i.options.length-1;c.value.scrollToIndex(I),requestAnimationFrame(()=>{const $=u(),w=k==="first"?$[0]:$.at(-1);w&&s.changeHighlight(w.ref)})}else if(!k&&!b){h.value+=y.key;const I=Number(vs()?.getAttribute("data-index")),$=p.value[I].textContent,w=p.value.map(S=>S.textContent??""),C=xn(w,h.value,$),v=p.value.find(S=>S.textContent===C);v&&(c.value.scrollToIndex(v.index,{align:"start"}),requestAnimationFrame(()=>{const S=n.value.querySelector(`[data-index="${v.index}"]`);S instanceof HTMLElement&&s.changeHighlight(S)}))}}),(y,b)=>(l(),g("div",{"data-reka-virtualizer":"",style:mt({position:"relative",width:"100%",height:`${t(c).getTotalSize()}px`})},[(l(!0),g(ie,null,_e(m.value,({is:x,item:k})=>(l(),P(ys(x),{key:k.index}))),128))],4))}}),fi=pi;const[pt,hi]=kt("ComboboxRoot");var vi=le({__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:i,emit:e}){const s=r,n=e,{primitiveElement:u,currentElement:o}=Kt(),{multiple:c,disabled:m,ignoreFilter:h,resetSearchTermOnSelect:p,openOnFocus:_,openOnClick:y,dir:b,resetModelValueOnClear:x,highlightOnHover:k}=Wt(s),I=Fa(b),$=It(s,"modelValue",n,{defaultValue:s.defaultValue??(c.value?[]:void 0),passive:s.modelValue===void 0,deep:!0}),w=It(s,"open",n,{defaultValue:s.defaultOpen,passive:s.open===void 0});async function C(j){w.value=j,Y.value="",j?(await Fe(),u.value?.highlightSelected(),S.value=!0,B.value?.focus()):(S.value=!1,setTimeout(()=>{!j&&s.resetSearchTermOnBlur&&v.trigger()},1))}const v=aa(),S=A(!1),V=A(!1),B=A(),D=A(),z=T(()=>u.value?.highlightedElement??void 0),M=A(new Map),q=A(new Map),{contains:U}=Bs({sensitivity:"base"}),Y=A(""),te=T(j=>{if(!Y.value||s.ignoreFilter||V.value)return{count:M.value.size,items:j?.items??new Map,groups:j?.groups??new Set(q.value.keys())};let N=0;const F=new Map,Z=new Set;for(const[ue,ve]of M.value){const ae=U(ve,Y.value);F.set(ue,ae?1:0),ae&&N++}for(const[ue,ve]of q.value)for(const ae of ve)if(F.get(ae)>0){Z.add(ue);break}return{count:N,items:F,groups:Z}}),K=_n();return He(()=>{K?.exposed&&(K.exposed.highlightItem=u.value?.highlightItem,K.exposed.highlightFirstItem=u.value?.highlightFirstItem,K.exposed.highlightSelected=u.value?.highlightSelected)}),i({filtered:te,highlightedElement:z,highlightItem:u.value?.highlightItem,highlightFirstItem:u.value?.highlightFirstItem,highlightSelected:u.value?.highlightSelected}),hi({modelValue:$,multiple:c,disabled:m,open:w,onOpenChange:C,contentId:"",isUserInputted:S,isVirtual:V,inputElement:B,highlightedElement:z,onInputElementChange:j=>B.value=j,triggerElement:D,onTriggerElementChange:j=>D.value=j,parentElement:o,resetSearchTermOnSelect:p,onResetSearchTerm:v.on,allItems:M,allGroups:q,filterSearch:Y,filterState:te,ignoreFilter:h,openOnFocus:_,openOnClick:y,resetModelValueOnClear:x}),(j,N)=>(l(),P(t(kn),null,{default:L(()=>[f(t(Bo),Pe({ref_key:"primitiveElement",ref:u},j.$attrs,{modelValue:t($),"onUpdate:modelValue":N[0]||(N[0]=F=>xs($)?$.value=F:null),style:{pointerEvents:t(w)?"auto":void 0},as:j.as,"as-child":j.asChild,dir:t(I),multiple:t(c),name:j.name,required:j.required,disabled:t(m),"highlight-on-hover":t(k),by:s.by,onHighlight:N[1]||(N[1]=F=>n("highlight",F))}),{default:L(()=>[$e(j.$slots,"default",{open:t(w),modelValue:t($)})]),_:3},16,["modelValue","style","as","as-child","dir","multiple","name","required","disabled","highlight-on-hover","by"])]),_:3}))}}),yi=vi,xi=le({__name:"ComboboxAnchor",props:{reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(r){const{forwardRef:i}=rt();return(e,s)=>(l(),P(t(wn),{"as-child":"",reference:e.reference},{default:L(()=>[f(t(tt),Pe({ref:t(i),"as-child":e.asChild,as:e.as},e.$attrs),{default:L(()=>[$e(e.$slots,"default")]),_:3},16,["as-child","as"])]),_:3},8,["reference"]))}}),bi=xi;const[ki,_i]=kt("ComboboxContent");var wi=le({__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:i}){const e=r,s=i,{position:n}=Wt(e),u=pt(),o=T(()=>u.ignoreFilter.value?u.allItems.value.size===0:u.filterState.value.count===0),{forwardRef:c,currentElement:m}=rt();$n(e.bodyLock),Cn(),Sn(u.parentElement);const h=T(()=>e.position==="popper"?e:{}),p=In(h.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)"};_i({position:n});const y=A(!1);He(()=>{u.inputElement.value&&(y.value=m.value.contains(u.inputElement.value),y.value&&u.inputElement.value.focus())}),dt(()=>{const x=vs();y.value&&(!x||x===document.body)&&u.triggerElement.value?.focus()});function b(x){if(u.parentElement.value?.contains(x))return!0;const I=(x instanceof Element?x.closest("label"):null)?.control;return!!I&&!!u.parentElement.value?.contains(I)}return(x,k)=>(l(),P(t(Ro),{"as-child":""},{default:L(()=>[f(t(bs),{"as-child":"",onMountAutoFocus:k[5]||(k[5]=Ke(()=>{},["prevent"])),onUnmountAutoFocus:k[6]||(k[6]=Ke(()=>{},["prevent"]))},{default:L(()=>[f(t(Tn),{"as-child":"","disable-outside-pointer-events":x.disableOutsidePointerEvents,onDismiss:k[0]||(k[0]=I=>t(u).onOpenChange(!1)),onFocusOutside:k[1]||(k[1]=I=>{b(I.target)&&I.preventDefault(),s("focusOutside",I)}),onInteractOutside:k[2]||(k[2]=I=>s("interactOutside",I)),onEscapeKeyDown:k[3]||(k[3]=I=>s("escapeKeyDown",I)),onPointerDownOutside:k[4]||(k[4]=I=>{b(I.target)&&I.preventDefault(),s("pointerDownOutside",I)})},{default:L(()=>[(l(),P(ys(t(n)==="popper"?t(Mn):t(tt)),Pe({...x.$attrs,...t(p)},{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(n)==="popper"?_:{}}}),{default:L(()=>[$e(x.$slots,"default")]),_:3},16,["id","data-state","data-empty","style"]))]),_:3},8,["disable-outside-pointer-events"])]),_:3})]),_:3}))}}),$i=wi,Ci=le({__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 i=r,e=pt(),s=ki();return rt(),(n,u)=>t(e).open.value&&t(s).position.value==="popper"?(l(),P(t(An),Tt(Pe({key:0},i)),{default:L(()=>[$e(n.$slots,"default")]),_:3},16)):E("v-if",!0)}}),Si=Ci,Ii=le({__name:"ComboboxCancel",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(r){const i=r;rt();const e=pt();function s(){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(n,u)=>(l(),P(t(tt),Pe({type:n.as==="button"?"button":void 0},i,{tabindex:"-1",onClick:s}),{default:L(()=>[$e(n.$slots,"default")]),_:3},16,["type"]))}}),Ti=Ii,Mi=le({__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:i}){const n=zn(r,i),{forwardRef:u}=rt(),o=pt();return o.contentId||=At(void 0,"reka-combobox-content"),(c,m)=>(l(),P(t(qn),{present:c.forceMount||t(o).open.value},{default:L(()=>[f($i,Pe({...t(n),...c.$attrs},{ref:t(u)}),{default:L(()=>[$e(c.$slots,"default")]),_:3},16)]),_:3},8,["present"]))}}),Ai=Mi,zi=le({__name:"ComboboxEmpty",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(r){const i=r,e=pt(),s=T(()=>e.ignoreFilter.value?e.allItems.value.size===0:e.filterState.value.count===0);return(n,u)=>s.value?(l(),P(t(tt),Tt(Pe({key:0},i)),{default:L(()=>[$e(n.$slots,"default",{},()=>[u[0]||(u[0]=ne("No options"))])]),_:3},16)):E("v-if",!0)}}),qi=zi;const[Rs,Li]=kt("ComboboxGroup");var Di=le({__name:"ComboboxGroup",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(r){const i=r,e=At(void 0,"reka-combobox-group"),s=pt(),n=T(()=>s.ignoreFilter.value?!0:s.filterSearch.value?s.filterState.value.groups.has(e):!0),u=Li({id:e,labelId:""});return He(()=>{s.allGroups.value.has(e)||s.allGroups.value.set(e,new Set)}),dt(()=>{s.allGroups.value.delete(e)}),(o,c)=>(l(),P(t(jo),Pe({id:t(e),"aria-labelledby":t(u).labelId},i,{hidden:n.value?void 0:!0}),{default:L(()=>[$e(o.$slots,"default")]),_:3},16,["id","aria-labelledby","hidden"]))}}),_a=Di,Ei=le({__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:i}){const e=r,s=i,n=pt(),u=Qt(),{primitiveElement:o,currentElement:c}=Kt(),m=It(e,"modelValue",s,{passive:e.modelValue===void 0});He(()=>{c.value&&n.onInputElementChange(c.value)});const{isComposing:h,handleCompositionStart:p,handleCompositionEnd:_}=Qa(C=>{const v=C.target;v&&b(v.value)});function y(C){h.value||(C.preventDefault(),n.open.value||n.onOpenChange(!0))}function b(C){n.open.value?n.filterSearch.value=C:(n.onOpenChange(!0),Fe(()=>{C&&(n.filterSearch.value=C,u.highlightFirstItem())}))}function x(C){h.value||b(C.target.value)}function k(){n.openOnFocus.value&&!n.open.value&&n.onOpenChange(!0)}function I(C){if(!n.open.value)return;const v=C.relatedTarget;if(!v)return;const S=n.parentElement.value?.contains(v),V=document.getElementById(n.contentId)?.contains(v);!S&&!V&&requestAnimationFrame(()=>{if(!n.open.value)return;const B=document.activeElement;!n.parentElement.value?.contains(B)&&!document.getElementById(n.contentId)?.contains(B)&&n.onOpenChange(!1)})}function $(){n.openOnClick.value&&!n.open.value&&n.onOpenChange(!0)}function w(){const C=n.modelValue.value;e.displayValue?m.value=e.displayValue(C):!n.multiple.value&&C&&!Array.isArray(C)&&typeof C!="object"?m.value=C.toString():m.value="",Fe(()=>{m.value=m.value})}return n.onResetSearchTerm(()=>{w()}),fe(n.modelValue,async()=>{!n.isUserInputted.value&&n.resetSearchTermOnSelect.value&&w()},{immediate:!0,deep:!0}),fe(n.filterState,(C,v)=>{!n.isVirtual.value&&v.count===0&&u.highlightFirstItem()}),(C,v)=>(l(),P(t(Oo),{ref_key:"primitiveElement",ref:o,modelValue:t(m),"onUpdate:modelValue":v[0]||(v[0]=S=>xs(m)?m.value=S:null),as:C.as,"as-child":C.asChild,"auto-focus":C.autoFocus,disabled:C.disabled,"aria-expanded":t(n).open.value,"aria-controls":t(n).contentId,"aria-autocomplete":"list",role:"combobox",autocomplete:"off",onClick:$,onInput:x,onKeydown:it(y,["down","up"]),onFocus:k,onBlur:I,onCompositionstart:t(p),onCompositionend:t(_)},{default:L(()=>[$e(C.$slots,"default")]),_:3},8,["modelValue","as","as-child","auto-focus","disabled","aria-expanded","aria-controls","onCompositionstart","onCompositionend"]))}}),Bi=Ei,Fi=le({__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:i}){const e=r,s=i,n=At(void 0,"reka-combobox-item"),u=pt(),o=Rs(null),{primitiveElement:c,currentElement:m}=Kt();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 h=T(()=>{if(u.isVirtual.value||u.ignoreFilter.value||!u.filterSearch.value)return!0;{const p=u.filterState.value.items.get(n);return p===void 0?!0:p>0}});return He(()=>{u.allItems.value.set(n,e.textValue||m.value.textContent||m.value.innerText);const p=o?.id;p&&(u.allGroups.value.has(p)?u.allGroups.value.get(p)?.add(n):u.allGroups.value.set(p,new Set([n])))}),dt(()=>{u.allItems.value.delete(n)}),(p,_)=>h.value?(l(),P(t(Yo),Pe({key:0},e,{id:t(n),ref_key:"primitiveElement",ref:c,disabled:t(u).disabled.value||p.disabled,onSelect:_[0]||(_[0]=y=>{s("select",y),!y.defaultPrevented&&(!t(u).multiple.value&&!p.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:L(()=>[$e(p.$slots,"default",{},()=>[ne(d(p.value),1)])]),_:3},16,["id","disabled"])):E("v-if",!0)}}),cs=Fi,Ri=le({__name:"ComboboxItemIndicator",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(r){const i=r;return(e,s)=>(l(),P(t(Qo),Tt(jt(i)),{default:L(()=>[$e(e.$slots,"default")]),_:3},16))}}),Vi=Ri,Oi=le({__name:"ComboboxLabel",props:{for:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"div"}},setup(r){const i=r;rt();const e=Rs({id:"",labelId:""});return e.labelId||=At(void 0,"reka-combobox-group-label"),(s,n)=>(l(),P(t(tt),Pe(i,{id:t(e).labelId}),{default:L(()=>[$e(s.$slots,"default")]),_:3},16,["id"]))}}),Pi=Oi,Ni=le({__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 i=r;return(e,s)=>(l(),P(t(Ln),Tt(jt(i)),{default:L(()=>[$e(e.$slots,"default")]),_:3},16))}}),ji=Ni,Ui=le({__name:"ComboboxSeparator",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(r){const i=r;return rt(),(e,s)=>(l(),P(t(tt),Pe(i,{"aria-hidden":"true"}),{default:L(()=>[$e(e.$slots,"default")]),_:3},16))}}),Hi=Ui,Wi=le({__name:"ComboboxTrigger",props:{disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(r){const i=r,{forwardRef:e,currentElement:s}=rt(),n=pt(),u=T(()=>i.disabled||n.disabled.value||!1);return He(()=>{s.value&&n.onTriggerElementChange(s.value)}),(o,c)=>(l(),P(t(tt),Pe(i,{ref:t(e),type:o.as==="button"?"button":void 0,tabindex:"-1","aria-label":"Show popup","aria-haspopup":"listbox","aria-expanded":t(n).open.value,"aria-controls":t(n).contentId,"data-state":t(n).open.value?"open":"closed",disabled:u.value,"data-disabled":u.value?"":void 0,"aria-disabled":u.value??void 0,onClick:c[0]||(c[0]=m=>t(n).onOpenChange(!t(n).open.value))}),{default:L(()=>[$e(o.$slots,"default")]),_:3},16,["type","aria-expanded","aria-controls","data-state","disabled","data-disabled","aria-disabled"]))}}),Ki=Wi,Yi=le({__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 i=r,e=pt();return e.isVirtual.value=!0,(s,n)=>(l(),P(fi,Tt(jt(i)),{default:L(u=>[$e(s.$slots,"default",Tt(jt(u)))]),_:3},16))}}),Gi=Yi;const[Ja,Qi]=kt("TagsInputRoot");var Ji=le({__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:i}){const e=r,s=i,{addOnPaste:n,disabled:u,delimiter:o,max:c,id:m,dir:h,addOnBlur:p,addOnTab:_}=Wt(e),y=Fa(h),b=It(e,"modelValue",s,{defaultValue:e.defaultValue,passive:!0,deep:!0}),{forwardRef:x,currentElement:k}=rt(),{focused:I}=Dn(k),$=Ds(k),{getItems:w,CollectionSlot:C}=Bt({isProvider:!0}),v=A(),S=A(!1),V=T(()=>Array.isArray(b.value)?[...b.value]:[]);function B(D){if(D!==-1){const z=w().filter(M=>M.ref.dataset.disabled!=="");b.value=b.value.filter((M,q)=>q!==D),s("removeTag",z[D].value)}}return Qi({modelValue:b,onAddValue:D=>{const z=[...V.value],M=z.length>0&&typeof z[0]=="object",q=z.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 U=e.convertValue?e.convertValue(D):D;if(z.length>=c.value&&c.value)return s("invalid",U),!1;if(e.duplicate)return b.value=[...z,U],s("addTag",U),!0;if(z.includes(U))S.value=!0;else return b.value=[...z,U],s("addTag",U),!0;return s("invalid",U),!1},onRemoveValue:B,onInputKeydown:D=>{if(D.isComposing)return;const z=D.target,M=w().map(U=>U.ref).filter(U=>U.dataset.disabled!=="");if(!M.length)return;const q=M.at(-1);switch(D.key){case"Delete":case"Backspace":{if(z.selectionStart!==0||z.selectionEnd!==0)break;if(v.value){const U=M.findIndex(Y=>Y===v.value);B(U),v.value=v.value===q?M.at(U-1):M.at(U+1),D.preventDefault()}else D.key==="Backspace"&&(v.value=q,D.preventDefault());break}case"Home":case"End":case"ArrowRight":case"ArrowLeft":{const U=D.key==="ArrowRight"&&y.value==="ltr"||D.key==="ArrowLeft"&&y.value==="rtl",Y=!U;if(z.selectionStart!==0||z.selectionEnd!==0)break;if(Y&&!v.value)v.value=q,D.preventDefault();else if(U&&q&&v.value===q)v.value=void 0,D.preventDefault();else if(v.value){const te=En(D,v.value,void 0,{itemsArray:M,loop:!1,dir:y.value});te&&(v.value=te),D.preventDefault()}break}case"ArrowUp":case"ArrowDown":{v.value&&D.preventDefault();break}default:v.value=void 0}},selectedElement:v,isInvalidInput:S,addOnPaste:n,addOnBlur:p,addOnTab:_,dir:y,disabled:u,delimiter:o,max:c,id:m,displayValue:e.displayValue}),(D,z)=>(l(),P(t(C),null,{default:L(()=>[f(t(tt),{ref:t(x),dir:t(y),as:D.as,"as-child":D.asChild,"data-invalid":S.value?"":void 0,"data-disabled":t(u)?"":void 0,"data-focused":t(I)?"":void 0},{default:L(()=>[$e(D.$slots,"default",{modelValue:t(b)}),t($)&&D.name?(l(),P(t(Es),{key:0,name:D.name,value:t(b),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}))}}),Xi=Ji,Zi=le({__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 i=r,e=Ja(),{forwardRef:s,currentElement:n}=rt();function u(x){if(e.selectedElement.value=void 0,!e.addOnBlur.value)return;const k=x.target,I=x.relatedTarget,$=k.getAttribute("aria-controls");if($&&I?.closest(`#${CSS.escape($)}`)||!k.value)return;e.onAddValue(k.value)&&(k.value="")}function o(x){e.addOnTab.value&&p(x)}const{isComposing:c,handleCompositionStart:m,handleCompositionEnd:h}=Qa();async function p(x){if(c.value||(await Fe(),x.defaultPrevented))return;const k=x.target;if(!k.value)return;e.onAddValue(k.value)&&(k.value=""),x.preventDefault()}function _(x){if(c.value||(e.isInvalidInput.value=!1,x.data===null))return;const k=e.delimiter.value;if(k===x.data||k instanceof RegExp&&k.test(x.data)){const $=x.target;if($.value=$.value.replace(k,""),$.value.trim()===""){$.value="";return}e.onAddValue($.value)&&($.value="")}}function y(x){c.value||e.onInputKeydown(x)}function b(x){if(e.addOnPaste.value){x.preventDefault();const k=x.clipboardData;if(!k)return;const I=k.getData("text");e.delimiter.value?I.split(e.delimiter.value).forEach(w=>{e.onAddValue(w)}):e.onAddValue(I)}}return He(()=>{const x=n.value.nodeName==="INPUT"?n.value:n.value.querySelector("input");x&&setTimeout(()=>{i.autoFocus&&x?.focus()},1)}),(x,k)=>(l(),P(t(tt),{id:t(e).id?.value,ref:t(s),type:"text",autocomplete:"off",autocorrect:"off",autocapitalize:"off",as:x.as,"as-child":x.asChild,maxlength:x.maxLength,placeholder:x.placeholder,disabled:t(e).disabled.value,"data-invalid":t(e).isInvalidInput.value?"":void 0,onInput:_,onKeydown:[it(p,["enter"]),it(o,["tab"]),y],onBlur:u,onCompositionstart:t(m),onCompositionend:t(h),onPaste:b},{default:L(()=>[$e(x.$slots,"default")]),_:3},8,["id","as","as-child","maxlength","placeholder","disabled","data-invalid","onCompositionstart","onCompositionend"]))}}),er=Zi;const[Vs,tr]=kt("TagsInputItem");var ar=le({__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 i=r,{value:e}=Wt(i),s=Ja(),{forwardRef:n,currentElement:u}=rt(),{CollectionItem:o}=Bt(),c=T(()=>s.selectedElement.value===u.value),m=T(()=>i.disabled||s.disabled.value),h=tr({value:e,isSelected:c,disabled:m,textId:"",displayValue:T(()=>s.displayValue(e.value))});return(p,_)=>(l(),P(t(o),{value:t(e)},{default:L(()=>[f(t(tt),{ref:t(n),as:p.as,"as-child":p.asChild,"aria-labelledby":t(h).textId,"aria-current":c.value,"data-disabled":m.value?"":void 0,"data-state":c.value?"active":"inactive"},{default:L(()=>[$e(p.$slots,"default")]),_:3},8,["as","as-child","aria-labelledby","aria-current","data-disabled","data-state"])]),_:3},8,["value"]))}}),sr=ar,nr=le({__name:"TagsInputItemDelete",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(r){const i=r;rt();const e=Ja(),s=Vs(),n=T(()=>s.disabled?.value||e.disabled.value);function u(){if(n.value)return;const o=e.modelValue.value.findIndex(c=>ia(c,s.value.value));e.onRemoveValue(o)}return(o,c)=>(l(),P(t(tt),Pe({tabindex:"-1"},i,{"aria-labelledby":t(s).textId,"aria-current":t(s).isSelected.value,"data-state":t(s).isSelected.value?"active":"inactive","data-disabled":n.value?"":void 0,type:o.as==="button"?"button":void 0,onClick:u}),{default:L(()=>[$e(o.$slots,"default")]),_:3},16,["aria-labelledby","aria-current","data-state","data-disabled","type"]))}}),or=nr,ir=le({__name:"TagsInputItemText",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(r){const i=r,e=Vs();return rt(),e.textId||=At(void 0,"reka-tags-input-item-text"),(s,n)=>(l(),P(t(tt),Pe(i,{id:t(e).textId}),{default:L(()=>[$e(s.$slots,"default",{},()=>[ne(d(t(e).displayValue.value),1)])]),_:3},16,["id"]))}}),rr=ir;const lr={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"]},ds=/^(?!.*-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 ur(r,i){const e=i.toLowerCase(),s=r.toLowerCase();if(e.includes("-non-reasoning")||s==="anthropic")return"none";if(s==="gemini")return/gemini-(?:2\.5|3(?:\.\d+)?-(?:flash|pro)|flash-latest|pro-latest)/i.test(e)?"gemini":"none";if(s==="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(s==="openai"||s==="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)||s==="kimi"&&/thinking/i.test(e)?"kimi":/\bdoubao-.*seed/i.test(e)||s==="doubao"&&/seed/i.test(e)?"doubao":/\bhunyuan-(?:t1|a13b)/i.test(e)?"hunyuan":s==="glm"||/\bglm-?(?:5|4\.[5-7]|z1|zero)/i.test(e)?"qwen":s==="siliconflow"&&/r[1-9]/i.test(e)?"deepseek_v4":s==="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":ds.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":ds.test(e)?"default":"none"}function cr(r,i){const e=ur(r,i);return lr[e]}function dr(r,i,e,s="group",n="zh-CN",u){const o=go(),{chatKey:c,state:m}=o.ensureSessionState({sessionId:r,sessionName:i,timeFilter:e,chatType:s,locale:n}),h=o.resetToSelectorOnEnter(c,u);return o.applySessionAssistantSelection(c),{initialization:h,messages:Ze(m,"messages"),sourceMessages:Ze(m,"sourceMessages"),currentKeywords:Ze(m,"currentKeywords"),isLoadingSource:Ze(m,"isLoadingSource"),isAIThinking:Ze(m,"isAIThinking"),currentAIChatId:Ze(m,"currentAIChatId"),currentToolStatus:Ze(m,"currentToolStatus"),toolsUsedInCurrentRound:Ze(m,"toolsUsedInCurrentRound"),sessionTokenUsage:Ze(m,"sessionTokenUsage"),agentStatus:Ze(m,"agentStatus"),selectedAssistantId:Ze(m,"selectedAssistantId"),sendMessage:(p,_)=>o.sendMessage(c,p,_),editMessageAndRegenerate:(p,_,y)=>o.editMessageAndRegenerate(c,p,_,y),loadAIChat:p=>o.loadAIChat(c,p),startNewAIChat:p=>o.startNewAIChat(c,p),loadMoreSourceMessages:()=>o.loadMoreSourceMessages(),updateMaxMessages:()=>o.updateMaxMessages(),stopGeneration:()=>o.stopGeneration(c),selectAssistantForSession:p=>o.selectAssistantForSession(c,p)}}function mr(){const{contains:r,startsWith:i}=Bs({sensitivity:"base"});function e(o,c){return r(o,c)?r(c,o)?0:i(o,c)?1:2:null}function s(o,c,m){if(typeof o!="object"||o===null)return e(String(o),c);let h=null;for(const p of m){const _=yt(o,p);if(_==null)continue;const y=Array.isArray(_)?_.map(String):[String(_)];for(const b of y){const x=e(b,c);if(x!==null&&(h===null||x<h)&&(h=x),h===0)return 0}}return h}function n(o,c,m){if(!c)return o;const h=[];for(const p of o){const _=s(p,c,m);_!==null&&h.push({item:p,score:_})}return h.sort((p,_)=>p.score-_.score),h.map(({item:p})=>p)}function u(o,c,m){return c?o.map(h=>{const p=[];for(const _ of h){if(_==null)continue;if(m.isStructural?.(_)){p.push({item:_,score:-1});continue}const y=s(_,c,m.fields);y!==null&&p.push({item:_,score:y})}return p.sort((_,y)=>_.score-y.score),p.map(({item:_})=>_)}).filter(h=>h.some(p=>!m.isStructural?.(p))):o}return{score:e,scoreItem:s,filter:n,filterGroups:u}}const wa=new Map;function gr(r,i,e){const{activeTab:s,isInitialLoad:n,currentSessionId:u,onTimeRangeChange:o}=e,c=A(null),m=A(null),h=A([]),p=T(()=>{const x=c.value;if(x)return{startTs:x.startTs,endTs:x.endTs}}),_=T(()=>{const x=c.value;return x?`${x.startTs}-${x.endTs}`:"init"}),y=T(()=>{const x=r.query,k=x.timeMode;return k?{mode:k,recentDays:x.timeDays?Number(x.timeDays):void 0,year:x.timeYear?Number(x.timeYear):void 0,quarterYear:x.timeYear?Number(x.timeYear):void 0,quarter:x.timeQuarter?Number(x.timeQuarter):void 0,customStart:x.timeStart||void 0,customEnd:x.timeEnd||void 0}:u.value&&wa.has(u.value)?wa.get(u.value):{mode:"recent",recentDays:365}});fe([s,c],([x,k])=>{if(n.value||!k)return;const I=k.state,$={tab:x,timeMode:I.mode,timeDays:void 0,timeYear:void 0,timeQuarter:void 0,timeStart:void 0,timeEnd:void 0};I.mode==="recent"&&($.timeDays=I.recentDays),I.mode==="year"&&($.timeYear=I.year),I.mode==="quarter"&&($.timeYear=I.quarterYear,$.timeQuarter=I.quarter),I.mode==="custom"&&($.timeStart=I.customStart,$.timeEnd=I.customEnd),i.replace({query:{...r.query,...$}})}),fe(c,x=>{!x||!u.value||(Ma(),wa.set(u.value,x.state),o?.())},{immediate:!0});function b(){c.value=null,m.value=null,h.value=[]}return{timeRangeValue:c,fullTimeRange:m,availableYears:h,timeFilter:p,timeFilterKey:_,initialTimeState:y,resetTimeRange:b}}function pr(r){return r.content.trim()?r.content:r.contentBlocks?.filter(e=>e.type==="text"&&!!e.text).map(e=>e.text).join("")??""}function qa(r){return r.flatMap(i=>{if(i.role!=="user"&&i.role!=="assistant")return[];const e=pr(i);return e.trim()?[{role:i.role,content:e,timestamp:i.timestamp}]:[]})}function fr(r){return qa(r).length>0}function hr(r,i,e,s){const n=[];n.push(`# ${r}`),n.push(""),n.push(`> ${s.createdAt}: ${Ne(e).format("YYYY-MM-DD HH:mm:ss")}`),n.push(""),n.push("---"),n.push("");for(const u of i){const o=Ne(u.timestamp).format("YYYY-MM-DD HH:mm:ss"),c=u.role==="user"?s.user:s.assistant;n.push(`### ${c}`),n.push(`*${o}*`),n.push(""),n.push(u.content),n.push(""),n.push("---"),n.push("")}return n.join(`
3
+ `)}function vr(r,i,e,s){const n=[];n.push(`${r}`),n.push(`${s.createdAt}: ${Ne(e).format("YYYY-MM-DD HH:mm:ss")}`),n.push(""),n.push("=".repeat(50)),n.push("");for(const u of i){const o=Ne(u.timestamp).format("YYYY-MM-DD HH:mm:ss"),c=u.role==="user"?s.user:s.assistant;n.push(`[${c}] ${o}`),n.push(""),n.push(u.content),n.push(""),n.push("-".repeat(50)),n.push("")}return n.join(`
4
+ `)}function yr(r){return r.replace(/[/\\?%*:|"<>]/g,"_")}async function xr(r,i,e,s,n){if(i.length===0)return{success:!1,error:"No messages to export"};let u,o;const c=Ne(e).format("YYYYMMDD_HHmmss"),m=yr(r);s==="markdown"?(u=hr(r,i,e,n),o=`${m}_${c}.md`):(u=vr(r,i,e,n),o=`${m}_${c}.txt`);const h=`data:text/plain;charset=utf-8,${encodeURIComponent(u)}`,{useCacheService:p}=await ga(async()=>{const{useCacheService:y}=await import("./service-CAp0YJoS.js");return{useCacheService:y}},__vite__mapDeps([0,1,2,3]));return await p().saveToDownloads(o,h)}function br(r){const i=r.columns.join(","),e=r.rows.map(s=>s.map(n=>n===null?"":`"${String(n).replace(/"/g,'""')}"`).join(","));return[i,...e].join(`
5
+ `)}function kr(r){const i=r.rows.map(e=>{const s={};return r.columns.forEach((n,u)=>{s[n]=e[u]}),s});return JSON.stringify(i,null,2)}async function _r(r,i){if(r.rows.length===0)return{success:!1,error:"No data to export"};const s=`sql_result_${Ne().format("YYYYMMDD_HHmmss")}.${i}`;let n,u;i==="json"?(n=kr(r),u="application/json"):(n=br(r),u="text/csv");const o=`data:${u};charset=utf-8,${encodeURIComponent(n)}`,{useCacheService:c}=await ga(async()=>{const{useCacheService:h}=await import("./service-CAp0YJoS.js");return{useCacheService:h}},__vite__mapDeps([0,1,2,3]));return await c().saveToDownloads(s,o)}function F2(r){const{route:i,router:e,currentSessionId:s,selectSession:n,defaultTab:u,validTabIds:o}=r,c=A(!0),m=A(!0),h=A(!0),p=A(null),_=A([]),y=A([]),b=A([]),x=A([]);let k=0,I=0,$=!1,w=!1;function C(){!h.value||!$||(!p.value||w)&&(h.value=!1)}function v(){const F=i.query.tab;return F&&o.includes(F)?F:u}const S=A(v()),V=T(()=>S.value==="insights"),B=T(()=>["insights","ranking"].includes(S.value));fe(S,F=>{const Z={insights:"insights",ranking:"ranking","ai-chat":"ai_chat",lab:"sql_lab"}[F];Z&&Bn("feature_used",{feature_id:Z})},{immediate:!0});const{timeRangeValue:D,fullTimeRange:z,availableYears:M,timeFilter:q,initialTimeState:U,resetTimeRange:Y}=gr(i,e,{activeTab:S,isInitialLoad:m,currentSessionId:s,onTimeRangeChange:()=>K()});function te(){const F=i.params.id;F&&(n(F),s.value!==F&&e.replace("/"))}async function K(){const F=s.value;if(!F)return;const Z=++I;if(!V.value){c.value=!1,w=!0,C();return}h.value&&(w=!1),c.value=!0;try{const ue=q.value,ve=at(),[ae,re,H,be]=await Promise.all([ve.getMemberActivity(F,ue),ve.getHourlyActivity(F,ue),ve.getDailyActivity(F,ue),ve.getMessageTypeDistribution(F,ue)]);if(Z!==I)return;_.value=ae,y.value=re,b.value=H,x.value=be}catch(ue){Z===I&&console.error("加载分析数据失败:",ue)}finally{Z===I&&(c.value=!1,w=!0,C())}}function j(F){F||(D.value=null,K())}async function N(){const F=s.value;if(!F)return;const Z=++k;m.value=!0;try{const ue=await at().getSession(F);if(Z!==k||s.value!==F)return;p.value=ue}catch(ue){Z===k&&s.value===F&&(p.value=null,console.error("加载基础数据失败:",ue))}finally{Z===k&&s.value===F&&(m.value=!1,$=!0,C())}}return fe(S,()=>{if(!V.value){I++,Ma(),c.value=!1,B.value||(w=!0,C());return}c.value=!0,s.value&&D.value&&K()}),fe(()=>i.params.id,()=>{S.value=v(),te()}),fe(()=>i.query.tab,()=>{S.value=v()}),fe(s,()=>{I++,Y(),$=!1,w=!B.value,c.value=V.value,h.value=!0,Ma(),N()},{immediate:!0}),He(()=>{te()}),{activeTab:S,isLoading:c,isInitialLoad:m,isSessionSwitching:h,session:p,memberActivity:_,hourlyActivity:y,dailyActivity:b,messageTypes:x,timeRangeValue:D,fullTimeRange:z,availableYears:M,timeFilter:q,initialTimeState:U,syncSession:te,loadData:N,loadAnalysisData:K,handleTimeRangeInitialized:j}}const wr={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"},$r=le({__name:"CardCaptureOverlay",setup(r){return(i,e)=>(l(),g("div",wr,[f(Ht,{type:"element","target-selector":"[data-capturable-card]",size:"xs"})]))}}),xa=le({__name:"ReportCard",props:{capturable:{type:Boolean,default:!0}},setup(r){return(i,e)=>(l(),P(wt,{"data-capturable-card":"",class:"group/card relative isolate flex flex-col"},{default:L(()=>[f(yo),r.capturable?(l(),P($r,{key:0})):E("",!0),$e(i.$slots,"default")]),_:3}))}}),Cr={class:"flex items-center justify-between"},Sr={class:"font-semibold text-gray-900 dark:text-white whitespace-nowrap"},Ir={key:0,class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},Tr={class:"flex items-center gap-2"},Mr={key:0,class:"pointer-events-none opacity-0 transition-opacity duration-200 group-hover/card:pointer-events-auto group-hover/card:opacity-100"},ut=le({__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 i=r,e=T(()=>{if(i.scrollable)return{maxHeight:`${i.maxHeightVh}vh`,overflowY:"auto"}});return(s,n)=>(l(),P(wt,{class:"group/card","data-section-card":""},{default:L(()=>[a("div",{class:W(["px-5 py-3",{"border-b border-gray-200 dark:border-white/5":r.showDivider&&s.$slots.default}])},[a("div",Cr,[a("div",null,[a("p",Sr,d(r.title),1),r.description?(l(),g("p",Ir,d(r.description),1)):E("",!0)]),a("div",Tr,[$e(s.$slots,"headerRight"),r.capturable?(l(),g("div",Mr,[f(Ht,{type:"element","target-selector":"[data-section-card]",size:"xs"})])):E("",!0)])])],2),r.scrollable?(l(),g("div",{key:0,style:mt(e.value)},[$e(s.$slots,"default")],4)):$e(s.$slots,"default",{key:1}),$e(s.$slots,"footer")]),_:3}))}}),Ar={class:"flex items-start justify-between"},zr={class:"min-w-0 flex-1"},qr={class:"text-sm font-medium text-gray-500 dark:text-gray-400"},Lr={key:1,class:"text-xl"},Dr={key:0,class:"mt-4 flex items-center text-sm"},Er={class:"text-gray-500 dark:text-gray-400"},vt=le({__name:"StatCard",props:{label:{},value:{},valueColor:{},subtext:{},icon:{},iconBg:{}},setup(r){const i={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(s,n)=>(l(),P(wt,{class:"p-5"},{default:L(()=>[a("div",Ar,[a("div",zr,[a("p",qr,d(r.label),1),a("p",{class:W(["mt-2 truncate text-2xl font-bold tracking-tight",r.valueColor?i[r.valueColor]:"text-gray-900 dark:text-white"])},d(r.value),3)]),r.icon?(l(),g("div",{key:0,class:W(["ml-4 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl",e[r.iconBg||"gray"]])},[r.icon.startsWith("i-")?(l(),P(Fn,{key:0,name:r.icon,size:"lg"},null,8,["name"])):(l(),g("span",Lr,d(r.icon),1))],2)):E("",!0)]),r.subtext||s.$slots.subtext?(l(),g("div",Dr,[$e(s.$slots,"subtext",{},()=>[a("span",Er,d(r.subtext),1)])])):E("",!0)]),_:3}))}}),Br={key:0,class:"mb-2 block text-2xl"},R2=le({__name:"EmptyState",props:{text:{},icon:{},padding:{}},setup(r){const i={sm:"px-4 py-4",md:"px-5 py-8",lg:"px-6 py-12"};return(e,s)=>(l(),g("div",{class:W(["text-center text-sm text-gray-400",i[r.padding||"md"]])},[r.icon?(l(),g("span",Br,d(r.icon),1)):E("",!0),ne(" "+d(r.text||"暂无数据"),1)],2))}}),Fr=["aria-busy"],Rr={key:0,class:"insight-view-transition__indicator","aria-hidden":"true"},Vr=["inert","aria-hidden"],Or=["inert","aria-hidden"],Pr=le({__name:"InsightViewTransition",props:{activeKey:{}},setup(r){const i=r,e=A(i.activeKey),s=A(null),n=A("primary"),u=A("idle"),o=A(0),c=Rn("session-switch-loading",null),m=T(()=>n.value==="primary"?e.value:s.value),h=T(()=>n.value==="primary"?"secondary":"primary"),p=T(()=>u.value!=="idle"),_=T(()=>u.value==="waiting"&&!c?.value);Vn(uo,{register:k,suppress:p});let y=0,b=null;function x(){b&&clearTimeout(b),b=null}function k(){const v=y;let S=!0;return o.value++,()=>{S&&(S=!1,v===y&&(o.value=Math.max(0,o.value-1)))}}function I(v,S){v==="primary"?e.value=S:s.value=S}function $(v){const S=v===n.value;return{"insight-view-transition__pane--active":S&&u.value==="idle","insight-view-transition__pane--waiting":S&&u.value==="waiting","insight-view-transition__pane--outgoing":S&&u.value==="revealing","insight-view-transition__pane--pending":!S&&u.value==="waiting","insight-view-transition__pane--incoming":!S&&u.value==="revealing"}}async function w(v){await Fe(),await Fe(),!(v!==y||u.value!=="waiting"||o.value>0)&&(u.value="revealing",b=setTimeout(()=>{if(v!==y)return;const S=n.value;n.value=h.value,I(S,null),u.value="idle",b=null},180))}function C(v){const S=++y;if(x(),o.value=0,v===m.value){I(h.value,null),u.value="idle";return}I(h.value,v),u.value="waiting",w(S)}return fe(()=>i.activeKey,v=>C(v)),fe(o,v=>{v===0&&u.value==="waiting"&&w(y)}),Ft(()=>{y++,x()}),(v,S)=>(l(),g("div",{class:"insight-view-transition","aria-busy":p.value},[_.value?(l(),g("div",Rr,[f(lo)])):E("",!0),e.value?(l(),g("div",{key:1,class:W(["insight-view-transition__pane",$("primary")]),inert:n.value!=="primary"||p.value,"aria-hidden":n.value!=="primary"},[$e(v.$slots,"default",{viewKey:e.value},void 0,!0)],10,Vr)):E("",!0),s.value?(l(),g("div",{key:2,class:W(["insight-view-transition__pane",$("secondary")]),inert:n.value!=="secondary"||p.value,"aria-hidden":n.value!=="secondary"},[$e(v.$slots,"default",{viewKey:s.value},void 0,!0)],10,Or)):E("",!0)],8,Fr))}}),V2=gt(Pr,[["__scopeId","data-v-be8a2c26"]]),La=le({__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 i=r,e=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"],s=T(()=>{const n=i.data.labels.map((y,b)=>({name:y,value:i.data.values[b]})),u=i.data.labels.length,o=i.mode==="compact",c=u>(o?8:14),m=u>(o?6:12),h=o?{type:m?"scroll":"plain",orient:"horizontal",left:8,right:8,bottom:0,height:28,textStyle:{fontSize:11,overflow:"truncate",width:72}}:{type:m?"scroll":"plain",orient:"vertical",right:10,top:24,bottom:24,textStyle:{fontSize:12,overflow:"truncate",width:120}},p=!o&&!c,_=i.showLegend&&!p;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:_?h:void 0,series:[{type:"pie",radius:i.doughnut?[i.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:p,formatter:"{b}",overflow:"truncate",width:110,alignTo:"edge",edgeDistance:12},emphasis:{label:{show:p,fontSize:14,fontWeight:"bold",overflow:"truncate",width:140},itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}},data:n}]}});return(n,u)=>(l(),P(Ya,{option:s.value,height:r.height},null,8,["option","height"]))}}),Da=le({__name:"EChartHeatmap",props:{data:{},height:{default:280},mode:{default:"expanded"},minColor:{default:"#fee5e8"},maxColor:{default:"#ee4567"}},setup(r){const i=r,e=T(()=>{let n=0;for(const[,,u]of i.data.data)u>n&&(n=u);return n||1}),s=T(()=>{const n=i.mode==="compact",u=i.data.xLabels.length,o=i.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 m=i.data.xLabels[c.data[0]],h=i.data.yLabels[c.data[1]],p=c.data[2];return`${h} ${m}<br/>消息数: <strong>${p}</strong>`},backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:n?52:72,right:20,top:n?12:24,bottom:n?52:70,outerBoundsMode:"same"},xAxis:{type:"category",data:i.data.xLabels,splitArea:{show:!0},axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:n?10:11,color:"#6b7280",interval:n&&u>16?"auto":0,hideOverlap:!0}},yAxis:{type:"category",data:i.data.yLabels,splitArea:{show:!0},axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:n?10:11,color:"#6b7280",interval:n&&o>14?"auto":0,hideOverlap:!0}},visualMap:{min:0,max:e.value,calculable:!0,orient:"horizontal",left:"center",bottom:0,itemWidth:n?8:10,itemHeight:n?84:120,inRange:{color:[i.minColor,i.maxColor]},textStyle:{color:"#6b7280",fontSize:11}},series:[{type:"heatmap",data:i.data.data,label:{show:!1},emphasis:{itemStyle:{shadowBlur:10,shadowColor:"rgba(0, 0, 0, 0.5)"}}}]}});return(n,u)=>(l(),P(Ya,{option:s.value,height:r.height},null,8,["option","height"]))}}),Nr=le({__name:"EChartCalendar",props:{data:{},height:{default:180},year:{}},setup(r){ha([As,zs,Ga,qs,va]);const i=r,{t:e,locale:s}=Ie(),n=pa(),u=A(null);let o=null;const c=T(()=>{if(i.year)return i.year;if(i.data.length===0)return new Date().getFullYear();const k=i.data.map(I=>parseInt(I.date.split("-")[0]));return Math.max(...k)}),m=T(()=>i.data.length===0?10:Math.max(...i.data.map(k=>k.value),1)),h=T(()=>i.data.map(k=>[k.date,k.value])),p={light:["#fee5e8","#fbb5c2","#f7758c","#ee4567"],dark:["#3d1f24","#6b2f3a","#a34557","#ee4567"]},_=T(()=>({tooltip:{trigger:"item",formatter:k=>{const I=k.data[0],$=k.data[1];return`${I}<br/>${e("views.message.calendarTooltipMessages")}: ${$}`}},visualMap:{min:0,max:m.value,calculable:!1,orient:"horizontal",left:"center",bottom:0,itemWidth:10,itemHeight:100,text:[`${m.value}`,"0"],inRange:{color:n.value?p.dark:p.light},textStyle:{color:n.value?"#9ca3af":"#6b7280",fontSize:10},show:!0},calendar:{top:30,left:40,cellSize:[13,13],range:String(c.value),itemStyle:{borderWidth:2,borderColor:n.value?"#1f2937":"#ffffff"},yearLabel:{show:!0,position:"top",color:n.value?"#9ca3af":"#6b7280",fontSize:12},monthLabel:{show:!0,color:n.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:n.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:h.value}]}));function y(){u.value&&(o=ya(u.value,n.value?"dark":void 0,{renderer:"canvas"}),o.setOption({backgroundColor:"transparent",..._.value}))}function b(){o&&o.setOption({backgroundColor:"transparent",..._.value},{notMerge:!0})}function x(){o?.resize()}return fe([()=>i.data,n,s],()=>{b()}),fe(()=>i.year,()=>{b()}),He(()=>{y(),window.addEventListener("resize",x)}),dt(()=>{window.removeEventListener("resize",x),o?.dispose()}),(k,I)=>(l(),g("div",{ref_key:"chartRef",ref:u,style:mt({height:`${r.height}px`,width:"100%"})},null,4))}}),jr={"zh-CN":{message:"消息记录",member:"成员",meta:"群信息",member_name_history:"昵称历史"},"en-US":{message:"Messages",member:"Members",meta:"Chat Info",member_name_history:"Nickname History"}},Ea={"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 Ba(r,i="zh-CN"){return jr[Os(i)]?.[r]||r}function Xa(r,i,e="zh-CN"){return Ea[Os(e)]?.[r]?.[i]||i}function Os(r){return r.startsWith("zh")?"zh-CN":"en-US"}const Ur={key:0,class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Hr={key:0,class:"flex-1 overflow-y-auto p-2"},Wr=["onClick"],Kr={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Yr={class:"flex-1 truncate text-right text-xs text-gray-400"},Gr={key:0,class:"ml-4 mt-1 space-y-0.5"},Qr=["title","onDblclick"],Jr={class:"font-mono text-gray-700 dark:text-gray-300"},Xr={class:"flex-1 truncate text-right text-[10px] text-gray-400"},Zr={key:1,class:"flex flex-1 flex-col items-center gap-1 overflow-y-auto px-2 pb-2"},el=["title","onClick"],tl=le({__name:"SchemaPanel",props:{sessionId:{}},emits:["insertColumn"],setup(r,{expose:i,emit:e}){const{t:s,locale:n}=Ie(),u=r,o=e,c=A(!1),m=A([]),h=A(new Set);async function p(){try{m.value=await at().getSchema(u.sessionId),m.value.forEach(x=>h.value.add(x.name))}catch(x){console.error("加载 Schema 失败:",x)}}function _(x){h.value.has(x)?h.value.delete(x):h.value.add(x)}function y(x){c.value=!1,h.value.add(x)}function b(x,k){o("insertColumn",x,k)}return i({loadSchema:p,schema:m}),He(()=>{p()}),(x,k)=>{const I=Me,$=Xe;return l(),g("div",{class:W(["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:W(["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):(l(),g("span",Ur,d(t(s)("ai.sqlLab.schema.tables")),1)),c.value?(l(),g("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:k[1]||(k[1]=w=>c.value=!c.value)},[f(I,{name:"i-lucide-panel-right-open",class:"size-4 scale-x-[-1]"})])):(l(),P($,{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:k[0]||(k[0]=w=>c.value=!c.value)},{default:L(()=>[f(I,{name:"i-lucide-panel-right",class:"size-4 scale-x-[-1] group-hover:hidden"}),f(I,{name:"i-lucide-panel-right-close",class:"size-4 hidden scale-x-[-1] group-hover:block"})]),_:1}))],2),c.value?(l(),g("div",Zr,[(l(!0),g(ie,null,_e(m.value,w=>(l(),g("button",{key:w.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(Ba)(w.name,t(n))} (${w.name})`,onClick:C=>y(w.name)},[f(I,{name:"i-heroicons-table-cells",class:"h-5 w-5"})],8,el))),128))])):(l(),g("div",Hr,[(l(!0),g(ie,null,_e(m.value,w=>(l(),g("div",{key:w.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:C=>_(w.name)},[f(I,{name:h.value.has(w.name)?"i-heroicons-chevron-down":"i-heroicons-chevron-right",class:"h-3 w-3 shrink-0 text-gray-400"},null,8,["name"]),f(I,{name:"i-heroicons-table-cells",class:"h-4 w-4 shrink-0 text-pink-500"}),a("span",Kr,d(w.name),1),a("span",Yr,d(t(Ba)(w.name,t(n))),1)],8,Wr),h.value.has(w.name)?(l(),g("div",Gr,[(l(!0),g(ie,null,_e(w.columns,C=>(l(),g("button",{key:C.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(s)("ai.sqlLab.schema.doubleClickToInsert"),onDblclick:v=>b(w.name,C.name)},[C.pk?(l(),P(I,{key:0,name:"i-heroicons-key",class:"h-3 w-3 shrink-0 text-yellow-500",title:t(s)("ai.sqlLab.schema.primaryKey")},null,8,["title"])):E("",!0),a("span",Jr,d(C.name),1),a("span",Xr,d(t(Xa)(w.name,C.name,t(n))),1)],40,Qr))),128))])):E("",!0)]))),128))]))],2)}}}),al={class:"max-h-[70vh] overflow-hidden p-6"},sl={class:"mb-4 flex items-center gap-2"},nl={class:"text-lg font-semibold text-gray-900 dark:text-white"},ol={key:0,class:"max-h-[50vh] space-y-3 overflow-y-auto pr-2"},il={class:"mb-2 flex items-start justify-between gap-2"},rl={class:"flex-1 text-sm font-medium text-gray-700 dark:text-gray-300"},ll={class:"shrink-0 text-xs text-gray-400"},ul={class:"mb-2 rounded bg-white p-2 dark:bg-gray-800"},cl={class:"whitespace-pre-wrap break-all font-mono text-xs text-gray-600 dark:text-gray-400"},dl={key:0,class:"mb-2 text-xs text-gray-500 dark:text-gray-400"},ml={class:"flex justify-end gap-2"},gl={key:1,class:"py-8 text-center text-gray-500 dark:text-gray-400"},pl={class:"text-sm"},fl={class:"mt-4 flex justify-end"},hl=le({__name:"AIHistoryModal",props:{open:{type:Boolean},history:{}},emits:["update:open","execute","delete"],setup(r,{emit:i}){const{t:e}=Ie(),s=i;function n(u){const o=new Date(u),c=new Date,m=c.getTime()-u;return m<6e4?e("ai.sqlLab.history.justNow"):m<36e5?e("ai.sqlLab.history.minutesAgo",{count:Math.floor(m/6e4)}):m<864e5?e("ai.sqlLab.history.hoursAgo",{count:Math.floor(m/36e5)}):o.toDateString()===c.toDateString()?e("ai.sqlLab.history.today"):`${o.getMonth()+1}/${o.getDate()}`}return(u,o)=>{const c=Me,m=Xe,h=lt;return l(),P(h,{open:r.open,ui:{content:"max-w-5xl"},"onUpdate:open":o[1]||(o[1]=p=>s("update:open",p))},{content:L(()=>[a("div",al,[a("div",sl,[f(c,{name:"i-heroicons-clock",class:"h-5 w-5 text-pink-500"}),a("h3",nl,d(t(e)("ai.sqlLab.history.title")),1)]),r.history.length>0?(l(),g("div",ol,[(l(!0),g(ie,null,_e(r.history,p=>(l(),g("div",{key:p.id,class:"rounded-lg border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-page-dark"},[a("div",il,[a("p",rl,d(p.prompt),1),a("span",ll,d(n(p.timestamp)),1)]),a("div",ul,[a("pre",cl,d(p.sql),1)]),p.explanation?(l(),g("p",dl,d(p.explanation),1)):E("",!0),a("div",ml,[f(m,{variant:"ghost",size:"xs",color:"error",onClick:_=>s("delete",p.id)},{default:L(()=>[f(c,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"})]),_:1},8,["onClick"]),f(m,{size:"xs",onClick:_=>s("execute",p)},{default:L(()=>[f(c,{name:"i-heroicons-play",class:"mr-1 h-3.5 w-3.5"}),ne(" "+d(t(e)("ai.sqlLab.history.execute")),1)]),_:1},8,["onClick"])])]))),128))])):(l(),g("div",gl,[f(c,{name:"i-heroicons-clock",class:"mx-auto mb-2 h-8 w-8 text-gray-300 dark:text-gray-600"}),a("p",pl,d(t(e)("ai.sqlLab.history.empty")),1)])),a("div",fl,[f(m,{variant:"ghost",onClick:o[0]||(o[0]=p=>s("update:open",!1))},{default:L(()=>[ne(d(t(e)("common.close")),1)]),_:1})])])]),_:1},8,["open"])}}}),vl={class:"flex flex-1 flex-col overflow-hidden"},yl={key:0,class:"border-b border-red-200 bg-red-50 p-4 dark:border-red-900 dark:bg-red-950"},xl={class:"flex items-start gap-2"},bl={class:"min-w-0 flex-1"},kl={class:"text-sm font-medium text-red-800 dark:text-red-200"},_l={class:"mt-1 break-all font-mono text-xs text-red-600 dark:text-red-400"},wl={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"},$l={class:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400"},Cl={class:"flex cursor-pointer items-center gap-1.5"},Sl={class:"text-xs"},Il={class:"flex items-center gap-2"},Tl={key:2,class:"flex-1 overflow-auto"},Ml={class:"min-w-full divide-y divide-gray-200 dark:divide-gray-700"},Al={class:"sticky top-0 bg-gray-100 dark:bg-page-dark"},zl=["onClick"],ql={class:"flex items-center gap-1"},Ll={class:"flex flex-col"},Dl={class:"text-gray-700 dark:text-gray-300"},El={key:0,class:"font-mono text-[10px] text-gray-400"},Bl={key:0,class:"sticky right-0 w-12 bg-gray-100 px-2 py-2 dark:bg-page-dark"},Fl={class:"divide-y divide-gray-200 bg-white dark:divide-gray-700 dark:bg-page-dark"},Rl=["title"],Vl={key:0,class:"sticky right-0 w-12 bg-white px-2 py-2 dark:bg-page-dark"},Ol={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"},Pl={class:"flex items-center gap-1"},Nl={class:"mx-2 text-xs text-gray-600 dark:text-gray-400"},jl={class:"flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400"},Ul={key:4,class:"flex flex-1 items-center justify-center text-gray-500 dark:text-gray-400"},Hl={class:"text-center"},Wl={class:"mt-2 text-sm"},Kl={key:5,class:"flex flex-1 items-center justify-center text-gray-500 dark:text-gray-400"},Yl={class:"text-center"},Gl={class:"mt-2 text-sm"},Ql={class:"mt-1 text-xs text-gray-400"},Jl={class:"max-h-[70vh] overflow-hidden p-6"},Xl={class:"mb-4 flex items-center gap-2"},Zl={class:"text-lg font-semibold text-gray-900 dark:text-white"},eu={key:0,class:"flex items-center justify-center py-8"},tu={class:"ml-2 text-sm text-gray-500"},au={key:1,class:"max-h-[50vh] overflow-y-auto"},su=["innerHTML"],nu={key:0,class:"mt-2 flex items-center text-xs text-gray-400"},ou={key:2,class:"rounded-lg bg-red-50 p-4 dark:bg-red-950"},iu={class:"text-sm text-red-600 dark:text-red-400"},ru={class:"mt-4 flex justify-end gap-2"},lu=le({__name:"ResultTable",props:{result:{},error:{},sql:{},prompt:{}},setup(r,{expose:i}){const{t:e,locale:s}=Ie(),n=ft(),u=fa(),o=zt(),{aiGlobalSettings:c}=_t(u),m=[/^ts$/i,/^timestamp$/i,/^time$/i,/_at$/i,/_ts$/i,/_time$/i,/^date$/i];function h(X){return m.some(Q=>Q.test(X))}function p(X){if(typeof X!="number"||!Number.isFinite(X))return!1;const Q=946684800,xe=4102444800,Ae=Q*1e3,ze=xe*1e3;return X>=Q&&X<=xe||X>=Ae&&X<=ze}function _(X){const xe=X>1e10?X:X*1e3;return Ne(xe).format("YYYY-MM-DD HH:mm:ss")}const y=[/^id$/i,/^message_id$/i,/^msg_id$/i,/^msgid$/i];function b(X){return X.findIndex(Q=>y.some(xe=>xe.test(Q)))}function x(X){o.openChatRecordDrawer({scrollToMessageId:X})}const k=new Ka({html:!1,breaks:!0,linkify:!0,typographer:!0}),I=r,$=A(null),w=A("asc"),C=A(1),v=A(100),S=[50,100,200,500],V=A(localStorage.getItem("sql-lab-readable-time")!=="false");function B(){V.value=!V.value,localStorage.setItem("sql-lab-readable-time",String(V.value))}const D=A(!1),z=A(!1),M=A(""),q=A(null),U=A(""),Y=A(!1);function te(X){const Q=X.split("."),xe=Q.length>1?Q[Q.length-1]:X,Ae=Ea[s.value]||Ea["zh-CN"];for(const ze of Object.values(Ae))if(ze[xe])return ze[xe];return null}const K=T(()=>{if(!I.result||!$.value)return I.result?.rows||[];const X=I.result.columns.indexOf($.value);return X===-1?I.result.rows:[...I.result.rows].sort((Q,xe)=>{const Ae=Q[X],ze=xe[X];if(Ae===null)return 1;if(ze===null)return-1;if(typeof Ae=="number"&&typeof ze=="number")return w.value==="asc"?Ae-ze:ze-Ae;const je=String(Ae).localeCompare(String(ze));return w.value==="asc"?je:-je})}),j=T(()=>I.result?Math.ceil(K.value.length/v.value):0),N=T(()=>{const X=(C.value-1)*v.value,Q=X+v.value;return K.value.slice(X,Q)}),F=T(()=>I.result?b(I.result.columns):-1),Z=T(()=>F.value!==-1);function ue(X){$.value===X?w.value=w.value==="asc"?"desc":"asc":($.value=X,w.value="asc"),C.value=1}function ve(X){v.value=X,C.value=1}function ae(X,Q){return X===null?"NULL":typeof X=="object"?JSON.stringify(X):V.value&&Q&&h(Q)&&p(X)?_(X):String(X)}async function re(){if(!(!I.result||Y.value)){Y.value=!0;try{const X=c.value.sqlExportFormat??"csv",Q=await _r({columns:I.result.columns,rows:I.result.rows},X);if(Q.success&&Q.filePath){const xe=Q.filePath.split("/").pop()||Q.filePath;n.add({title:e("common.exportSuccess"),description:xe,color:"primary",actions:[{label:e("common.openFolder"),onClick:()=>{Ts().showInFolder(Q.filePath)}}]})}else n.fail(e("common.exportFailed"),{description:Q.error})}catch(X){console.error("导出失败:",X),n.fail(e("common.exportFailed"),{description:String(X)})}finally{Y.value=!1}}}function H(){$.value=null,w.value="asc",C.value=1}function be(){if(!I.result)return"";const X=50,Q=I.result.rows.slice(0,X),xe=I.result.columns.join(" | "),Ae=I.result.columns.map(()=>"---").join(" | "),ze=Q.map(Je=>Je.map(Re=>Re===null?"NULL":String(Re).slice(0,50)).join(" | "));let je=`| ${xe} |
6
+ | ${Ae} |
7
+ `;return je+=ze.map(Je=>`| ${Je} |`).join(`
8
+ `),I.result.rows.length>X&&(je+=`
9
+
10
+ (仅展示前 ${X} 行,共 ${I.result.rowCount} 行)`),je}async function Te(){D.value=!0,M.value="",q.value=null,U.value="",await we()}async function we(){if(!await Ra().hasConfig()){q.value=e("common.errorNoAIConfig");return}z.value=!0,q.value=null,U.value="";try{const Q=be();let xe="";I.prompt&&(xe=`用户的查询意图:${I.prompt}
11
+
12
+ `),I.sql&&(xe+=`执行的 SQL 语句:
13
+ \`\`\`sql
14
+ ${I.sql}
15
+ \`\`\`
16
+
17
+ `);const Ae=`请分析以下 SQL 查询结果,用简洁的中文总结关键发现和洞察。
18
+
19
+ ${xe}查询结果(共 ${I.result?.rowCount||0} 行):
20
+
21
+ ${Q}
22
+
23
+ 请提供:
24
+ 1. 结果概述(一句话总结)
25
+ 2. 关键发现(2-4 个要点)
26
+ 3. 如有明显的趋势或异常,请指出`,ze=await Ms().chatStream([{role:"system",content:"你是一个数据分析专家,擅长从查询结果中提取关键信息和洞察。请用简洁清晰的中文回答。"},{role:"user",content:Ae}],{temperature:.3,maxTokens:1e3},je=>{je.content&&(U.value+=je.content)});ze.success?M.value=U.value:q.value=ze.error||e("ai.sqlLab.result.errorSummary")}catch(Q){q.value=Q.message||String(Q)}finally{z.value=!1}}function ce(){D.value=!1,M.value="",q.value=null,U.value=""}return i({resetSort:H}),(X,Q)=>{const xe=Me,Ae=Wa,ze=Xe,je=Ha,Je=lt;return l(),g("div",vl,[r.error?(l(),g("div",yl,[a("div",xl,[f(xe,{name:"i-heroicons-exclamation-circle",class:"mt-0.5 h-5 w-5 shrink-0 text-red-500"}),a("div",bl,[a("p",kl,d(t(e)("ai.sqlLab.result.queryError")),1),a("p",_l,d(r.error),1)])])])):E("",!0),r.result?(l(),g("div",wl,[a("div",$l,[a("label",Cl,[f(Ae,{"model-value":V.value,size:"xs","onUpdate:modelValue":B},null,8,["model-value"]),a("span",Sl,d(t(e)("ai.sqlLab.result.readableTime")),1)]),Q[5]||(Q[5]=a("span",{class:"text-gray-300 dark:text-gray-600"},"|",-1)),a("span",null,[f(xe,{name:"i-heroicons-table-cells",class:"mr-1 inline h-4 w-4"}),ne(" "+d(t(e)("ai.sqlLab.result.rows",{count:r.result.rowCount})),1)]),a("span",null,[f(xe,{name:"i-heroicons-clock",class:"mr-1 inline h-4 w-4"}),ne(" "+d(r.result.duration)+" ms ",1)])]),a("div",Il,[f(ze,{variant:"ghost",size:"xs",onClick:Te},{default:L(()=>[f(xe,{name:"i-heroicons-sparkles",class:"mr-1 h-4 w-4"}),ne(" "+d(t(e)("ai.sqlLab.result.summarize")),1)]),_:1}),f(ze,{variant:"ghost",size:"xs",loading:Y.value,onClick:re},{default:L(()=>[f(xe,{name:"i-heroicons-arrow-down-tray",class:"mr-1 h-4 w-4"}),ne(" "+d(t(e)("common.export")),1)]),_:1},8,["loading"])])])):E("",!0),r.result&&r.result.rows.length>0?(l(),g("div",Tl,[a("table",Ml,[a("thead",Al,[a("tr",null,[(l(!0),g(ie,null,_e(r.result.columns,(Re,Qe)=>(l(),g("th",{key:Qe,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:et=>ue(Re)},[a("div",ql,[a("div",Ll,[a("span",Dl,d(te(Re)||Re),1),te(Re)?(l(),g("span",El,d(Re),1)):E("",!0)]),$.value===Re?(l(),P(xe,{key:0,name:w.value==="asc"?"i-heroicons-chevron-up":"i-heroicons-chevron-down",class:"h-3 w-3 text-gray-500"},null,8,["name"])):E("",!0)])],8,zl))),128)),Z.value?(l(),g("th",Bl)):E("",!0)])]),a("tbody",Fl,[(l(!0),g(ie,null,_e(N.value,(Re,Qe)=>(l(),g("tr",{key:Qe,class:"hover:bg-gray-50 dark:hover:bg-gray-800"},[(l(!0),g(ie,null,_e(Re,(et,Ee)=>(l(),g("td",{key:Ee,class:W(["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":et===null}]),title:ae(et,r.result.columns[Ee])},d(ae(et,r.result.columns[Ee])),11,Rl))),128)),Z.value?(l(),g("td",Vl,[f(ze,{icon:"i-heroicons-chat-bubble-left-right",color:"neutral",variant:"ghost",size:"xs",title:t(e)("ai.sqlLab.result.viewChat"),onClick:et=>x(Re[F.value])},null,8,["title","onClick"])])):E("",!0)]))),128))])])])):E("",!0),r.result&&r.result.rows.length>0&&j.value>1?(l(),g("div",Ol,[a("div",Pl,[f(ze,{icon:"i-heroicons-chevron-double-left",variant:"ghost",size:"xs",disabled:C.value===1,onClick:Q[0]||(Q[0]=Re=>C.value=1)},null,8,["disabled"]),f(ze,{icon:"i-heroicons-chevron-left",variant:"ghost",size:"xs",disabled:C.value===1,onClick:Q[1]||(Q[1]=Re=>C.value--)},null,8,["disabled"]),a("span",Nl,d(C.value)+" / "+d(j.value),1),f(ze,{icon:"i-heroicons-chevron-right",variant:"ghost",size:"xs",disabled:C.value>=j.value,onClick:Q[2]||(Q[2]=Re=>C.value++)},null,8,["disabled"]),f(ze,{icon:"i-heroicons-chevron-double-right",variant:"ghost",size:"xs",disabled:C.value>=j.value,onClick:Q[3]||(Q[3]=Re=>C.value=j.value)},null,8,["disabled"])]),a("div",jl,[a("span",null,d(t(e)("ai.sqlLab.result.pageSize")),1),f(je,{"model-value":v.value,items:S.map(Re=>({label:String(Re),value:Re})),size:"xs",class:"w-20","onUpdate:modelValue":ve},null,8,["model-value","items"])])])):E("",!0),r.result&&r.result.rows.length===0?(l(),g("div",Ul,[a("div",Hl,[f(xe,{name:"i-heroicons-inbox",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),a("p",Wl,d(t(e)("ai.sqlLab.result.emptyResult")),1)])])):E("",!0),!r.result&&!r.error?(l(),g("div",Kl,[a("div",Yl,[f(xe,{name:"i-heroicons-command-line",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),a("p",Gl,d(t(e)("ai.sqlLab.result.initialState")),1),a("p",Ql,d(t(e)("ai.sqlLab.result.initialHint")),1)])])):E("",!0),f(Je,{open:D.value,"onUpdate:open":Q[4]||(Q[4]=Re=>D.value=Re)},{content:L(()=>[a("div",Jl,[a("div",Xl,[f(xe,{name:"i-heroicons-sparkles",class:"h-5 w-5 text-pink-500"}),a("h3",Zl,d(t(e)("ai.sqlLab.result.summaryTitle")),1)]),z.value&&!U.value?(l(),g("div",eu,[f(xe,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-pink-500"}),a("span",tu,d(t(e)("ai.sqlLab.result.analyzing")),1)])):U.value||M.value?(l(),g("div",au,[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(k).render(U.value||M.value)},null,8,su),z.value?(l(),g("div",nu,[f(xe,{name:"i-heroicons-arrow-path",class:"mr-1 h-3 w-3 animate-spin"}),ne(" "+d(t(e)("common.generating")),1)])):E("",!0)])):E("",!0),q.value?(l(),g("div",ou,[a("p",iu,d(q.value),1)])):E("",!0),a("div",ru,[!z.value&&M.value?(l(),P(ze,{key:0,variant:"outline",onClick:we},{default:L(()=>[f(xe,{name:"i-heroicons-arrow-path",class:"mr-1 h-4 w-4"}),ne(" "+d(t(e)("common.regenerate")),1)]),_:1})):E("",!0),f(ze,{variant:"ghost",onClick:ce},{default:L(()=>[ne(d(t(e)("common.close")),1)]),_:1})])])]),_:1},8,["open"])])}}}),uu={class:"main-content flex h-full"},cu={class:"flex flex-1 flex-col overflow-hidden"},du={class:"flex flex-col border-b border-gray-200 bg-gray-50 p-4 dark:border-gray-800 dark:bg-page-dark"},mu={class:"mx-auto w-full max-w-3xl"},gu=["placeholder"],pu=["placeholder"],fu={class:"mt-1 flex items-center justify-between"},hu={class:"flex items-center gap-2"},vu={key:0,class:"text-xs text-gray-400"},yu={class:"flex items-center gap-2"},xu={key:0,class:"ml-1 text-xs text-gray-400"},bu={key:0,class:"flex-1 overflow-auto p-4"},ku={class:"mb-2 flex items-center gap-1.5 text-sm font-medium text-gray-600 dark:text-gray-300"},_u={key:0,class:"text-gray-500"},wu={key:1,class:"text-pink-500"},$u=["open"],Cu={class:"cursor-pointer select-none text-xs font-medium text-gray-500 dark:text-gray-400"},Su={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"},Tu=le({__name:"SQLLabTab",props:{sessionId:{},chatType:{}},setup(r){const{t:i,locale:e}=Ie(),s=r,n=A(null),u=A(null);function o(F){return i(F==="group"?"ai.sqlLab.generate.defaultPromptGroup":"ai.sqlLab.generate.defaultPromptPrivate")}const c=A("SELECT * FROM message LIMIT 10"),m=A(o(s.chatType)),h=A("prompt"),p=A(!1),_=A(!1),y=A(null),b=A(null),x=A(""),k=A(""),I=A(""),$=A(!1),w=A(null),C=A(!1),v=A([]);function S(){try{const F=`sql-lab-history-${s.sessionId}`,Z=localStorage.getItem(F);Z&&(v.value=JSON.parse(Z))}catch(F){console.error("加载历史记录失败:",F)}}function V(){try{const F=`sql-lab-history-${s.sessionId}`;localStorage.setItem(F,JSON.stringify(v.value))}catch(F){console.error("保存历史记录失败:",F)}}function B(F,Z,ue){const ve={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,prompt:F,sql:Z,explanation:ue,timestamp:Date.now()};v.value.unshift(ve),v.value.length>50&&(v.value=v.value.slice(0,50)),V()}function D(F){v.value=v.value.filter(Z=>Z.id!==F),V()}async function z(){if(!c.value.trim()){y.value=i("ai.sqlLab.editor.errorEmptySQL");return}p.value=!0,y.value=null,b.value=null,u.value?.resetSort();try{b.value=await at().executeSQL(s.sessionId,c.value)}catch(F){y.value=F.message||String(F)}finally{p.value=!1}}function M(F,Z){(F.ctrlKey||F.metaKey)&&F.key==="Enter"&&(F.preventDefault(),Z==="prompt"?j():z())}function q(F,Z){c.value+=`${F}.${Z}`}function U(){h.value=h.value==="prompt"?"sql":"prompt"}function Y(F){const Z=[];for(const ue of F){Z.push(`### ${ue.name} (${Ba(ue.name,e.value)})`),Z.push("| 列名 | 说明 | 类型 |"),Z.push("|------|------|------|");for(const ve of ue.columns){const ae=ve.pk?" (主键)":"";Z.push(`| ${ve.name} | ${Xa(ue.name,ve.name,e.value)}${ae} | ${ve.type} |`)}Z.push("")}return Z.join(`
27
+ `)}function te(F,Z){return`你是一个 SQLite 数据库专家。用户需要查询聊天记录数据库。
28
+
29
+ ## 数据库结构
30
+
31
+ ${Y(Z)}
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
+ ${F}
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 K(F){let Z=F.trim();Z=Z.replace(/^```json?\n?/i,"").replace(/\n?```$/i,"");try{const ue=JSON.parse(Z);return{sql:(ue.sql||"").trim(),explanation:(ue.explanation||"").trim()}}catch{return Z=Z.replace(/^```sql?\n?/i,"").replace(/\n?```$/i,""),{sql:Z.trim(),explanation:""}}}async function j(){const F=m.value.trim();if(!F){y.value=i("ai.sqlLab.generate.errorEmptyPrompt");return}if(!await Ra().hasConfig()){y.value=i("common.errorNoAIConfig");return}const ue=n.value?.schema||[];if(ue.length===0){y.value=i("common.error.unknown");return}_.value=!0,b.value=null,y.value=null,k.value="",I.value="",$.value=!1;let ve="";try{const ae=te(F,ue),re=await Ms().chatStream([{role:"system",content:"你是一个 SQLite 专家,请以 JSON 格式输出 sql 和 explanation 字段。"},{role:"user",content:ae}],{temperature:.1,maxTokens:4096},be=>{if(be.thinking!==void 0){be.thinkingDone?$.value=!1:($.value=!0,be.thinking&&(I.value+=be.thinking,Fe(()=>{w.value&&(w.value.scrollTop=w.value.scrollHeight)})));return}be.error&&(ve=be.error),be.isFinished&&be.finishReason==="length"&&(ve=i("ai.sqlLab.generate.errorTokenLimit")),be.content&&(k.value+=be.content)});if(!re.success){y.value=re.error||ve||i("ai.sqlLab.generate.errorGenerate");return}if(ve){y.value=ve;return}const H=K(k.value);if(!H.sql){y.value=k.value?`${i("ai.sqlLab.generate.errorGenerate")}: ${k.value.slice(0,200)}`:i("ai.sqlLab.generate.errorGenerate");return}c.value=H.sql,x.value=F,B(F,H.sql,H.explanation),await z()}catch(ae){y.value=ae.message||String(ae)}finally{_.value=!1}}async function N(F){c.value=F.sql,x.value=F.prompt,C.value=!1,await z()}return He(()=>{S()}),fe(()=>s.chatType,F=>{m.value=o(F)}),(F,Z)=>{const ue=Me,ve=Xe;return l(),g("div",uu,[f(t(tl),{ref_key:"schemaPanelRef",ref:n,"session-id":r.sessionId,onInsertColumn:q},null,8,["session-id"]),a("div",cu,[a("div",du,[a("div",mu,[h.value==="prompt"?ct((l(),g("textarea",{key:0,"onUpdate:modelValue":Z[0]||(Z[0]=ae=>m.value=ae),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(i)("ai.sqlLab.generate.placeholder"),spellcheck:"false",onKeydown:Z[1]||(Z[1]=ae=>M(ae,"prompt"))},null,40,gu)),[[Lt,m.value]]):ct((l(),g("textarea",{key:1,"onUpdate:modelValue":Z[2]||(Z[2]=ae=>c.value=ae),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(i)("ai.sqlLab.editor.placeholder"),spellcheck:"false",onKeydown:Z[3]||(Z[3]=ae=>M(ae,"sql"))},null,40,pu)),[[Lt,c.value]]),a("div",fu,[a("div",hu,[f(ve,{variant:"ghost",size:"xs",onClick:U},{default:L(()=>[f(ue,{name:"i-heroicons-arrows-right-left",class:"mr-1 h-3.5 w-3.5"}),ne(" "+d(h.value==="prompt"?t(i)("ai.sqlLab.editor.switchToSQLMode"):t(i)("ai.sqlLab.editor.switchToPromptMode")),1)]),_:1}),h.value==="sql"?(l(),g("span",vu,d(t(i)("ai.sqlLab.editor.tip")),1)):E("",!0)]),a("div",yu,[f(ve,{variant:"ghost",size:"sm",disabled:v.value.length===0,onClick:Z[4]||(Z[4]=ae=>C.value=!0)},{default:L(()=>[f(ue,{name:"i-heroicons-clock",class:"mr-1 h-4 w-4"}),ne(" "+d(t(i)("ai.sqlLab.editor.history"))+" ",1),v.value.length>0?(l(),g("span",xu,"("+d(v.value.length)+")",1)):E("",!0)]),_:1},8,["disabled"]),h.value==="prompt"?(l(),P(ve,{key:0,color:"primary",size:"sm",loading:_.value||p.value,disabled:!m.value.trim(),onClick:j},{default:L(()=>[f(ue,{name:"i-heroicons-sparkles",class:"mr-1 h-4 w-4"}),ne(" "+d(t(i)("ai.sqlLab.editor.generateAndRun")),1)]),_:1},8,["loading","disabled"])):(l(),P(ve,{key:1,color:"primary",size:"sm",loading:p.value,onClick:z},{default:L(()=>[f(ue,{name:"i-heroicons-play",class:"mr-1 h-4 w-4"}),ne(" "+d(t(i)("ai.sqlLab.editor.run")),1)]),_:1},8,["loading"]))])])])]),h.value==="prompt"&&!b.value&&!y.value&&(k.value||I.value||_.value)?(l(),g("div",bu,[f(t(wt),{class:"mx-auto w-full max-w-3xl p-4"},{default:L(()=>[a("p",ku,[f(ue,{name:"i-heroicons-cpu-chip",class:"h-4 w-4"}),ne(" "+d(t(i)("ai.sqlLab.generate.aiOutput"))+" ",1),$.value?(l(),g("span",_u,d(t(i)("ai.sqlLab.generate.thinking")),1)):_.value?(l(),g("span",wu,d(t(i)("common.generating")),1)):E("",!0)]),I.value?(l(),g("details",{key:0,class:"mb-3",open:$.value},[a("summary",Cu,d(t(i)("ai.sqlLab.generate.thinkingProcess")),1),a("pre",{ref_key:"thinkingPreRef",ref:w,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(I.value),513)],8,$u)):E("",!0),k.value?(l(),g("pre",Su,d(k.value),1)):I.value?E("",!0):(l(),g("p",Iu,d(t(i)("ai.sqlLab.generate.waitingAI")),1))]),_:1})])):(l(),P(t(lu),{key:1,ref_key:"resultTableRef",ref:u,result:b.value,error:y.value,sql:c.value,prompt:x.value},null,8,["result","error","sql","prompt"]))]),f(t(hl),{open:C.value,"onUpdate:open":Z[5]||(Z[5]=ae=>C.value=ae),history:v.value,onExecute:N,onDelete:D},null,8,["open","history"])])}}}),Mu={class:"flex h-full flex-col"},Au={class:"min-h-0 flex-1 overflow-hidden"},zu=le({__name:"LabTab",props:{sessionId:{},chatType:{}},setup(r){const i=r,{t:e}=Ie(),s=T(()=>[{id:"sql-lab",label:e("ai.tab.sqlLab"),icon:"i-heroicons-command-line"}]),n=A("sql-lab");return(u,o)=>(l(),g("div",Mu,[f(t(Ua),{modelValue:n.value,"onUpdate:modelValue":o[0]||(o[0]=c=>n.value=c),items:s.value,"persist-key":"labTab"},null,8,["modelValue","items"]),a("div",Au,[f(Mt,{name:"fade",mode:"out-in"},{default:L(()=>[n.value==="sql-lab"?(l(),P(Tu,{key:0,class:"h-full","session-id":i.sessionId,"chat-type":i.chatType},null,8,["session-id","chat-type"])):E("",!0)]),_:1})])]))}}),O2=gt(zu,[["__scopeId","data-v-7fc6fe33"]]),qu={class:"flex h-full min-h-0 flex-col"},Lu={class:"min-h-0 flex-1 overflow-hidden"},P2=le({__name:"MemoryTab",props:{sessionId:{},sessionName:{}},setup(r){const{t:i}=Ie(),e=A("records"),s=T(()=>[{id:"records",label:i("analysis.memory.tabs.records"),icon:"i-heroicons-chat-bubble-left-right"}]);return(n,u)=>(l(),g("div",qu,[f(t(Ua),{modelValue:e.value,"onUpdate:modelValue":u[0]||(u[0]=o=>e.value=o),items:s.value,"persist-key":"memoryTab"},null,8,["modelValue","items"]),a("div",Lu,[e.value==="records"?(l(),P(t(fo),{key:r.sessionId,"session-id":r.sessionId,mode:"page","show-topics":!t(On)},null,8,["session-id","show-topics"])):E("",!0)])]))}});function Du(r,i){if(typeof r!="object"||r===null)return!1;const e=yt(r,i);return e!=null&&e!==""}function ms(r,i){return i?{xs:44,sm:48,md:52,lg:56,xl:60}[r]:{xs:24,sm:28,md:32,lg:36,xl:40}[r]}function Eu(r,i,e,s){const n=ms(i,!0),u=ms(i,!1);return s?()=>n:e?o=>Du(r[o],e)?n:u:()=>u}const Bu={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"}},Za=Object.assign({inheritAttrs:!1},{__name:"SelectMenu",props:Ut({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:Ut(["change","blur","focus","create","clear","highlight","update:modelValue","update:open"],["update:searchTerm"]),setup(r,{expose:i,emit:e}){const s=r,n=e,u=ma(),o=Va("selectMenu",s),c=ra(r,"searchTerm",{type:String,default:""}),{t:m}=Pn(),h=Pa(),{filterGroups:p}=mr(),_=ks(_s(o,"modelValue","defaultValue","open","defaultOpen","required","multiple","resetSearchTermOnBlur","resetSearchTermOnSelect","resetModelValueOnClear","highlightOnHover","by"),n),y=Nn(Ze(()=>o.portal)),b=Ze(()=>Ot(o.content,{side:"bottom",sideOffset:8,collisionPadding:8,position:"popper"})),x=Ze(()=>Ot(o.arrow,{rounded:!0})),k=T(()=>typeof o.clear=="object"?o.clear:{}),I=Ze(()=>o.virtualize?Ot(typeof o.virtualize=="boolean"?{}:o.virtualize,{estimateSize:Eu(X.value,Z.value||"md",o.descriptionKey,!!u["item-description"])}):!1),$=Ze(()=>Ot(o.searchInput,{placeholder:m("selectMenu.search"),variant:"none"})),{emitFormBlur:w,emitFormFocus:C,emitFormInput:v,emitFormChange:S,size:V,color:B,id:D,name:z,highlight:M,disabled:q,ariaAttrs:U}=Oa(s),{orientation:Y,size:te}=ws(s),{isLeading:K,isTrailing:j,leadingIconName:N,trailingIconName:F}=Na(Ze(()=>Ot(o,{trailingIcon:h.ui.icons.chevronDown}))),Z=T(()=>te.value||V.value),[ue,ve]=as(),[ae,re]=as({props:{item:{type:[Object,String,Number,Boolean],required:!0},index:{type:Number,required:!1}}}),H=T(()=>Dt({extend:Dt(Bu),...h.ui?.selectMenu||{}})({color:B.value??o.color,variant:o.variant,size:Z?.value??o.size,loading:o.loading,highlight:M.value??o.highlight,leading:K.value||!!o.avatar||!!u.leading,trailing:j.value||!!u.trailing,fieldGroup:Y.value,virtualize:!!o.virtualize,multiple:o.multiple}));function be(R){if(o.multiple&&Array.isArray(R)){const ee=R.map(J=>ss(we.value,J,{labelKey:o.labelKey,valueKey:o.valueKey,by:o.by})).filter(J=>J!=null&&J!=="");return ee.length>0?ee.join(", "):void 0}return ss(we.value,R,{labelKey:o.labelKey,valueKey:o.valueKey,by:o.by})}const Te=T(()=>o.items?.length?Wn(o.items)?o.items:[o.items]:[]),we=T(()=>Te.value.flatMap(R=>R)),ce=T(()=>{if(o.ignoreFilter||!c.value)return Te.value;const R=Array.isArray(o.filterFields)?o.filterFields:[o.labelKey];return p(Te.value,c.value,{fields:R,isStructural:ee=>Ee(ee)&&!!ee.type&&["label","separator"].includes(ee.type)})}),X=T(()=>ce.value.flatMap(R=>R)),Q=T(()=>{if(!o.createItem||!c.value)return!1;const R=o.valueKey?{[o.valueKey]:c.value}:c.value;return typeof o.createItem=="object"&&o.createItem.when==="always"||o.createItem==="always"?!X.value.find(ee=>Hn(ee,R,o.by??o.valueKey)):!X.value.length}),xe=T(()=>typeof o.createItem=="object"?o.createItem.position:"bottom"),Ae=Nt("triggerRef");function ze(){o.autofocus&&Ae.value?.$el?.focus({focusVisible:!0})}He(()=>{setTimeout(()=>{ze()},o.autofocusDelay)});function je(R){if($s(o.modelValue)===R)return;o.modelModifiers?.trim&&(typeof R=="string"||R===null||R===void 0)&&(R=R?.trim()??null),o.modelModifiers?.number&&(R=Cs(R)),o.modelModifiers?.nullable&&(R??=null),o.modelModifiers?.optional&&!o.modelModifiers?.nullable&&R!==null&&(R??=void 0);const ee=new Event("change",{target:{value:R}});n("change",ee),S(),v(),o.resetSearchTermOnSelect&&(c.value="")}const Je=A(!1);function Re(R){Je.value=R;let ee;if(R){const J=new FocusEvent("focus");n("focus",J),C(),clearTimeout(ee)}else{const J=new FocusEvent("blur");n("blur",J),w(),o.resetSearchTermOnBlur&&(ee=setTimeout(()=>{c.value=""},100))}}function Qe(R){R.preventDefault(),R.stopPropagation(),n("create",c.value)}function et(R,ee){if(Ee(ee)){if(ee.disabled){R.preventDefault();return}ee.onSelect?.(R)}}function Ee(R){return typeof R=="object"&&R!==null}function pe(R){return o.multiple&&Array.isArray(R)?R.length===0:R==null||R===""}function ye(){n("clear")}const oe=Nt("viewportRef"),ge=Nt("comboboxRootRef");return fe(()=>o.items,async()=>{Je.value&&(await Fe(),ge.value?.highlightFirstItem?.())},{flush:"post"}),i({triggerRef:Ze(()=>Ae.value?.$el),viewportRef:Ze(()=>oe.value)}),(R,ee)=>(l(),g(ie,null,[f(t(ue),null,{default:L(()=>[f(t(cs),{"data-slot":"item",class:W(H.value.item({class:t(o).ui?.item})),value:c.value,onSelect:Qe},{default:L(()=>[a("span",{"data-slot":"itemLabel",class:W(H.value.itemLabel({class:t(o).ui?.itemLabel}))},[$e(R.$slots,"create-item-label",{item:c.value},()=>[ne(d(t(m)("selectMenu.create",{label:c.value})),1)])],2)]),_:3},8,["class","value"])]),_:3}),f(t(ae),null,{default:L(({item:J,index:de})=>[Ee(J)&&J.type==="label"?(l(),P(t(Pi),{key:0,"data-slot":"label",class:W(H.value.label({class:[t(o).ui?.label,J.ui?.label,J.class]}))},{default:L(()=>[ne(d(t(yt)(J,t(o).labelKey)),1)]),_:2},1032,["class"])):Ee(J)&&J.type==="separator"?(l(),P(t(Hi),{key:1,"data-slot":"separator",class:W(H.value.separator({class:[t(o).ui?.separator,J.ui?.separator,J.class]}))},null,8,["class"])):(l(),P(t(cs),{key:2,"data-slot":"item",class:W(H.value.item({class:[t(o).ui?.item,Ee(J)&&J.ui?.item,Ee(J)&&J.class]})),disabled:Ee(J)&&J.disabled,value:t(o).valueKey&&Ee(J)?t(yt)(J,t(o).valueKey):J,onSelect:Ce=>et(Ce,J)},{default:L(()=>[$e(R.$slots,"item",{item:J,index:de,ui:H.value},()=>[$e(R.$slots,"item-leading",{item:J,index:de,ui:H.value},()=>[Ee(J)&&J.icon?(l(),P(Me,{key:0,name:J.icon,"data-slot":"itemLeadingIcon",class:W(H.value.itemLeadingIcon({class:[t(o).ui?.itemLeadingIcon,J.ui?.itemLeadingIcon]}))},null,8,["name","class"])):Ee(J)&&J.avatar?(l(),P(la,Pe({key:1,size:J.ui?.itemLeadingAvatarSize||t(o).ui?.itemLeadingAvatarSize||H.value.itemLeadingAvatarSize()},J.avatar,{"data-slot":"itemLeadingAvatar",class:H.value.itemLeadingAvatar({class:[t(o).ui?.itemLeadingAvatar,J.ui?.itemLeadingAvatar]})}),null,16,["size","class"])):Ee(J)&&J.chip?(l(),P(jn,Pe({key:2,size:J.ui?.itemLeadingChipSize||t(o).ui?.itemLeadingChipSize||H.value.itemLeadingChipSize(),inset:"",standalone:""},J.chip,{"data-slot":"itemLeadingChip",class:H.value.itemLeadingChip({class:[t(o).ui?.itemLeadingChip,J.ui?.itemLeadingChip]})}),null,16,["size","class"])):E("",!0)]),a("span",{"data-slot":"itemWrapper",class:W(H.value.itemWrapper({class:[t(o).ui?.itemWrapper,Ee(J)&&J.ui?.itemWrapper]}))},[a("span",{"data-slot":"itemLabel",class:W(H.value.itemLabel({class:[t(o).ui?.itemLabel,Ee(J)&&J.ui?.itemLabel]}))},[$e(R.$slots,"item-label",{item:J,index:de},()=>[ne(d(Ee(J)?t(yt)(J,t(o).labelKey):J),1)])],2),Ee(J)&&(t(yt)(J,t(o).descriptionKey)||u["item-description"])?(l(),g("span",{key:0,"data-slot":"itemDescription",class:W(H.value.itemDescription({class:[t(o).ui?.itemDescription,Ee(J)&&J.ui?.itemDescription]}))},[$e(R.$slots,"item-description",{item:J,index:de},()=>[ne(d(t(yt)(J,t(o).descriptionKey)),1)])],2)):E("",!0)],2),a("span",{"data-slot":"itemTrailing",class:W(H.value.itemTrailing({class:[t(o).ui?.itemTrailing,Ee(J)&&J.ui?.itemTrailing]}))},[$e(R.$slots,"item-trailing",{item:J,index:de,ui:H.value}),f(t(Vi),{"as-child":""},{default:L(()=>[f(Me,{name:t(o).selectedIcon||t(h).ui.icons.check,"data-slot":"itemTrailingIcon",class:W(H.value.itemTrailingIcon({class:[t(o).ui?.itemTrailingIcon,Ee(J)&&J.ui?.itemTrailingIcon]}))},null,8,["name","class"])]),_:2},1024)],2)])]),_:2},1032,["class","disabled","value","onSelect"]))]),_:3}),f(t(yi),Pe({ref_key:"comboboxRootRef",ref:ge},t(_),{"ignore-filter":"","as-child":"",name:t(z),disabled:t(q),"onUpdate:modelValue":je,"onUpdate:open":Re}),{default:L(({modelValue:J,open:de})=>[f(t(bi),{"as-child":""},{default:L(()=>[f(t(Ki),Pe({id:t(D),ref_key:"triggerRef",ref:Ae,"data-slot":"base",class:H.value.base({class:[t(o).ui?.base,t(o).class]}),tabindex:"0"},{...R.$attrs,...t(U)}),{default:L(()=>[t(K)||t(o).avatar||u.leading?(l(),g("span",{key:0,"data-slot":"leading",class:W(H.value.leading({class:t(o).ui?.leading}))},[$e(R.$slots,"leading",{modelValue:J,open:de,ui:H.value},()=>[t(K)&&t(N)?(l(),P(Me,{key:0,name:t(N),"data-slot":"leadingIcon",class:W(H.value.leadingIcon({class:t(o).ui?.leadingIcon}))},null,8,["name","class"])):t(o).avatar?(l(),P(la,Pe({key:1,size:t(o).ui?.itemLeadingAvatarSize||H.value.itemLeadingAvatarSize()},t(o).avatar,{"data-slot":"itemLeadingAvatar",class:H.value.itemLeadingAvatar({class:t(o).ui?.itemLeadingAvatar})}),null,16,["size","class"])):E("",!0)])],2)):E("",!0),$e(R.$slots,"default",{modelValue:J,open:de,ui:H.value},()=>[(l(!0),g(ie,null,_e([be(J)],Ce=>(l(),g(ie,{key:Ce},[Ce!=null?(l(),g("span",{key:0,"data-slot":"value",class:W(H.value.value({class:t(o).ui?.value}))},d(Ce),3)):(l(),g("span",{key:1,"data-slot":"placeholder",class:W(H.value.placeholder({class:t(o).ui?.placeholder}))},d(t(o).placeholder??" "),3))],64))),128))]),t(j)||u.trailing||t(o).clear?(l(),g("span",{key:1,"data-slot":"trailing",class:W(H.value.trailing({class:t(o).ui?.trailing}))},[$e(R.$slots,"trailing",{modelValue:J,open:de,ui:H.value},()=>[t(o).clear&&!pe(J)?(l(),P(t(Ti),{key:0,"as-child":""},{default:L(()=>[f(Xe,Pe({as:"span",icon:t(o).clearIcon||t(h).ui.icons.close,size:Z.value,variant:"link",color:"neutral",tabindex:"-1"},k.value,{"data-slot":"trailingClear",class:H.value.trailingClear({class:t(o).ui?.trailingClear}),onClick:Ke(ye,["stop"])}),null,16,["icon","size","class"])]),_:1})):t(F)?(l(),P(Me,{key:1,name:t(F),"data-slot":"trailingIcon",class:W(H.value.trailingIcon({class:t(o).ui?.trailingIcon}))},null,8,["name","class"])):E("",!0)])],2)):E("",!0)]),_:2},1040,["id","class"])]),_:2},1024),f(t(ji),Tt(jt(t(y))),{default:L(()=>[f(t(Un),null,{default:L(()=>[f(t(Ai),Pe({"data-slot":"content",class:H.value.content({class:t(o).ui?.content})},b.value),{default:L(()=>[f(t(bs),{trapped:"","data-slot":"focusScope",class:W(H.value.focusScope({class:t(o).ui?.focusScope}))},{default:L(()=>[$e(R.$slots,"content-top"),t(o).searchInput?(l(),P(t(Bi),{key:0,modelValue:c.value,"onUpdate:modelValue":ee[1]||(ee[1]=Ce=>c.value=Ce),"display-value":()=>c.value,"as-child":""},{default:L(()=>[f(Yt,Pe({autofocus:"",autocomplete:"off",size:Z.value},$.value,{"model-modifiers":{trim:t(o).modelModifiers?.trim},"data-slot":"input",class:H.value.input({class:t(o).ui?.input}),onChange:ee[0]||(ee[0]=Ke(()=>{},["stop"]))}),null,16,["size","model-modifiers","class"])]),_:1},8,["modelValue","display-value"])):E("",!0),f(t(qi),{"data-slot":"empty",class:W(H.value.empty({class:t(o).ui?.empty}))},{default:L(()=>[$e(R.$slots,"empty",{searchTerm:c.value},()=>[ne(d(c.value?t(m)("selectMenu.noMatch",{searchTerm:c.value}):t(m)("selectMenu.noData")),1)])]),_:3},8,["class"]),a("div",{ref_key:"viewportRef",ref:oe,role:"presentation","data-slot":"viewport",class:W(H.value.viewport({class:t(o).ui?.viewport}))},[t(o).virtualize?(l(),g(ie,{key:0},[Q.value&&xe.value==="top"?(l(),P(t(ve),{key:0})):E("",!0),f(t(Gi),Pe({options:X.value,"text-content":Ce=>Ee(Ce)?t(yt)(Ce,t(o).labelKey):String(Ce)},I.value),{default:L(({option:Ce,virtualItem:Ue})=>[f(t(re),{item:Ce,index:Ue.index},null,8,["item","index"])]),_:1},16,["options","text-content"]),Q.value&&xe.value==="bottom"?(l(),P(t(ve),{key:1})):E("",!0)],64)):(l(),g(ie,{key:1},[Q.value&&xe.value==="top"?(l(),P(t(_a),{key:0,"data-slot":"group",class:W(H.value.group({class:t(o).ui?.group}))},{default:L(()=>[f(t(ve))]),_:1},8,["class"])):E("",!0),(l(!0),g(ie,null,_e(ce.value,(Ce,Ue)=>(l(),P(t(_a),{key:`group-${Ue}`,"data-slot":"group",class:W(H.value.group({class:t(o).ui?.group}))},{default:L(()=>[(l(!0),g(ie,null,_e(Ce,(Ye,Ve)=>(l(),P(t(re),{key:`group-${Ue}-${Ve}`,item:Ye,index:Ve},null,8,["item","index"]))),128))]),_:2},1032,["class"]))),128)),Q.value&&xe.value==="bottom"?(l(),P(t(_a),{key:1,"data-slot":"group",class:W(H.value.group({class:t(o).ui?.group}))},{default:L(()=>[f(t(ve))]),_:1},8,["class"])):E("",!0)],64))],2),$e(R.$slots,"content-bottom")]),_:3},8,["class"]),t(o).arrow?(l(),P(t(Si),Pe({key:0},x.value,{"data-slot":"arrow",class:H.value.arrow({class:t(o).ui?.arrow})}),null,16,["class"])):E("",!0)]),_:3},16,["class"])]),_:3})]),_:3},16)]),_:3},16,["name","disabled"])],64))}}),Fu={class:"h-full p-3"},Ru={class:"relative z-20 flex items-center gap-2 border-b border-gray-200 px-4 py-2 dark:border-gray-700"},Vu={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"},Ou={class:"flex-1 overflow-auto"},Pu={key:0,class:"flex h-full items-center justify-center"},Nu={class:"text-sm text-gray-400"},ju={key:1,class:"w-full border-collapse text-xs"},Uu={class:"sticky top-0 bg-gray-50 dark:bg-page-dark"},Hu={class:"font-mono text-xs font-medium text-gray-700 dark:text-gray-300"},Wu={class:"text-[10px] leading-tight text-gray-400"},Ku={class:"border-b border-r border-gray-100 px-2 py-1.5 text-gray-400 dark:border-gray-800"},Yu=["title"],Gu=["onUpdate:modelValue"],Qu={class:"w-full truncate px-2 py-1.5"},Ju={key:0,class:"italic text-gray-400"},Xu={key:1},Zu={class:"border-b border-gray-100 px-2 py-1.5 text-center dark:border-gray-800"},ec={key:0,class:"flex items-center justify-center gap-1"},tc={key:1,class:"flex items-center justify-center gap-1"},ac={class:"flex items-center justify-between border-t border-gray-200 px-4 py-2 dark:border-gray-700"},sc={class:"text-xs text-gray-500 dark:text-gray-400"},nc={key:0,class:"flex items-center gap-3"},oc={class:"text-xs text-gray-500 dark:text-gray-400"},Zt=100,ic=le({__name:"TableBrowser",props:{sessionId:{}},setup(r){const i=["member","meta","message","message_context","member_name_history"],{t:e,locale:s}=Ie(),n=r,u=A(localStorage.getItem("debug_dbSource")||"chat"),o=A([]),c=A(""),m=A(null),h=A(!1),p=A(null),_=A(1),y=A(0),b=T(()=>Math.max(1,Math.ceil(y.value/Zt))),x=A(null),k=A({}),I=A(!1),$=T(()=>u.value==="ai"),w=A([]),C=A(""),v=T(()=>$.value&&c.value==="ai_message"&&w.value.length>0),S=T(()=>{const ae={label:e("analysis.debug.tableBrowser.allConversations"),value:"__all__"},re=w.value.map(H=>({label:H.title||H.id.slice(0,16),value:H.id}));return[ae,...re]});async function V(){if(!$.value){w.value=[];return}try{const ae=n.sessionId.replace(/'/g,"''"),re=await ot().executeAiSQL(`SELECT id, title FROM ai_chat WHERE session_id = '${ae}' ORDER BY updated_at DESC`);w.value=re.rows.map(H=>({id:String(H[0]),title:H[1]?String(H[1]):null})),C.value="__all__"}catch{w.value=[]}}const B=T(()=>[{label:e("analysis.debug.tableBrowser.chatDb"),value:"chat"},{label:e("analysis.debug.tableBrowser.aiDb"),value:"ai"}]),D=T(()=>{const ae=[...o.value];return ae.sort((re,H)=>{const be=i.indexOf(re.name),Te=i.indexOf(H.name);return be!==-1&&Te!==-1?be-Te:be!==-1?-1:Te!==-1?1:0}),ae}),z=T(()=>D.value.map(ae=>({label:ae.name,value:ae.name})));async function M(ae){return u.value==="ai"?await ot().executeAiSQL(ae):await at().executeSQL(n.sessionId,ae)}async function q(){try{if(u.value==="ai"?o.value=await ot().getAiSchema():o.value=await at().getSchema(n.sessionId),D.value.length>0){const ae=$.value?"ai_message":D.value[0].name;c.value=D.value.some(re=>re.name===ae)?ae:D.value[0].name}else c.value="",m.value=null}catch(ae){console.error("Failed to load schema:",ae)}}function U(){if(!$.value)return"";const ae=n.sessionId.replace(/'/g,"''"),re=c.value;return re==="ai_chat"?` WHERE "session_id" = '${ae}'`:re==="ai_message"?C.value&&C.value!=="__all__"?` WHERE "ai_chat_id" = '${C.value.replace(/'/g,"''")}'`:` WHERE "ai_chat_id" IN (SELECT "id" FROM "ai_chat" WHERE "session_id" = '${ae}')`:""}async function Y(){if(c.value){h.value=!0,p.value=null,x.value=null;try{const ae=U(),re=await M(`SELECT COUNT(*) as cnt FROM "${c.value}"${ae}`);y.value=re?.rows?.[0]?.[0]??0;const H=(_.value-1)*Zt;m.value=await M(`SELECT * FROM "${c.value}"${ae} ORDER BY rowid DESC LIMIT ${Zt} OFFSET ${H}`)}catch(ae){p.value=ae.message||String(ae),m.value=null}finally{h.value=!1}}}function te(ae){if(!m.value)return;x.value=ae;const re=m.value.rows[ae],H={};m.value.columns.forEach((be,Te)=>{H[be]=re[Te]==null?"":String(re[Te])}),k.value=H}function K(){x.value=null,k.value={}}async function j(){if(x.value===null||!m.value)return;const ae=c.value,re=o.value.find(Q=>Q.name===ae);if(!re)return;const H=re.columns.find(Q=>Q.pk);if(!H){p.value="No primary key found for this table";return}const be=m.value.rows[x.value],Te=m.value.columns.indexOf(H.name),we=be[Te],ce=m.value.columns.filter(Q=>Q!==H.name).map(Q=>`"${Q}" = '${k.value[Q].replace(/'/g,"''")}'`).join(", "),X=`UPDATE "${ae}" SET ${ce} WHERE "${H.name}" = '${String(we).replace(/'/g,"''")}'`;try{await M(X),K(),await Y()}catch(Q){p.value=Q.message||String(Q)}}async function N(ae){if(!m.value)return;const re=c.value,H=o.value.find(Q=>Q.name===re);if(!H)return;const be=H.columns.find(Q=>Q.pk);if(!be){p.value="No primary key found for this table";return}const Te=m.value.rows[ae],we=m.value.columns.indexOf(be.name),ce=Te[we],X=`DELETE FROM "${re}" WHERE "${be.name}" = '${String(ce).replace(/'/g,"''")}'`;try{await M(X),await Y()}catch(Q){p.value=Q.message||String(Q)}}function F(ae){confirm(e("analysis.debug.tableBrowser.confirmDelete"))&&N(ae)}async function Z(){if(confirm(e("analysis.debug.tableBrowser.confirmClearDebug"))){I.value=!0;try{(await ot().clearDebugContext()).success&&await Y()}catch(ae){p.value=ae.message||String(ae)}finally{I.value=!1}}}function ue(ae){navigator.clipboard.writeText(ae)}function ve(ae,re,H){if(!m.value)return[];const be=ae==null?"NULL":String(ae),Te=m.value.rows[H],we={};return m.value.columns.forEach((ce,X)=>{we[ce]=Te[X]}),[[{label:e("analysis.debug.tableBrowser.copyCell"),class:"p-2",onSelect:()=>ue(be)},{label:e("analysis.debug.tableBrowser.editRow"),class:"p-2",onSelect:()=>te(H)},{label:e("analysis.debug.tableBrowser.copyRow"),class:"p-2",onSelect:()=>ue(JSON.stringify(we,null,2))},{label:e("analysis.debug.tableBrowser.deleteRow"),class:"p-2 text-red-600 dark:text-red-400",onSelect:()=>N(H)}]]}return fe(u,ae=>{localStorage.setItem("debug_dbSource",ae),c.value="",m.value=null,y.value=0,_.value=1,C.value="",q(),V()}),fe(c,ae=>{ae&&(_.value=1,Y())}),fe(C,()=>{c.value==="ai_message"&&(_.value=1,Y())}),fe(_,()=>{Y()}),He(async()=>{await Promise.all([q(),V()]),c.value&&await Y()}),(ae,re)=>{const H=Za,be=Xe,Te=Kn;return l(),g("div",Fu,[f(t(wt),{shadow:!1,class:"flex h-full min-w-0 flex-col"},{default:L(()=>[a("div",Ru,[f(t(St),{modelValue:u.value,"onUpdate:modelValue":re[0]||(re[0]=we=>u.value=we),items:B.value,size:"xs"},null,8,["modelValue","items"]),re[5]||(re[5]=a("div",{class:"mx-1 h-4 w-px bg-gray-200 dark:bg-gray-700"},null,-1)),a("div",{class:W([$.value?"max-w-[50%]":"flex-1","min-w-0"])},[f(t(St),{modelValue:c.value,"onUpdate:modelValue":re[1]||(re[1]=we=>c.value=we),items:z.value,size:"xs"},null,8,["modelValue","items"])],2),v.value?(l(),P(H,{key:0,modelValue:C.value,"onUpdate:modelValue":re[2]||(re[2]=we=>C.value=we),items:S.value,"value-key":"value",class:"w-48",size:"xs",ui:{content:"z-50"}},null,8,["modelValue","items"])):E("",!0),re[6]||(re[6]=a("div",{class:"flex-1"},null,-1)),$.value&&c.value==="ai_message"?(l(),P(be,{key:1,variant:"ghost",size:"xs",color:"error",icon:"i-heroicons-trash",loading:I.value,onClick:Z},{default:L(()=>[ne(d(t(e)("analysis.debug.tableBrowser.clearDebugContext")),1)]),_:1},8,["loading"])):E("",!0),f(be,{variant:"ghost",size:"xs",icon:"i-heroicons-arrow-path",loading:h.value,onClick:Y},{default:L(()=>[ne(d(t(e)("analysis.debug.tableBrowser.refresh")),1)]),_:1},8,["loading"])]),p.value?(l(),g("div",Vu,d(p.value),1)):E("",!0),a("div",Ou,[!m.value&&!h.value?(l(),g("div",Pu,[a("p",Nu,d(t(e)("analysis.debug.tableBrowser.noData")),1)])):m.value?(l(),g("table",ju,[a("thead",Uu,[a("tr",null,[re[7]||(re[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)),(l(!0),g(ie,null,_e(m.value.columns,we=>(l(),g("th",{key:we,class:"border-b border-r border-gray-200 px-2 py-1.5 text-left dark:border-gray-700"},[a("div",Hu,d(we),1),a("div",Wu,d(t(Xa)(c.value,we,t(s))),1)]))),128)),re[8]||(re[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,[(l(!0),g(ie,null,_e(m.value.rows,(we,ce)=>(l(),g("tr",{key:ce,class:"transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[a("td",Ku,d((_.value-1)*Zt+ce+1),1),(l(!0),g(ie,null,_e(we,(X,Q)=>(l(),g("td",{key:Q,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:X==null?"NULL":String(X)},[x.value===ce?ct((l(),g("input",{key:0,"onUpdate:modelValue":xe=>k.value[m.value.columns[Q]]=xe,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,Gu)),[[Lt,k.value[m.value.columns[Q]]]]):(l(),P(Te,{key:1,items:ve(X,Q,ce)},{default:L(()=>[a("div",Qu,[X==null?(l(),g("span",Ju,"NULL")):(l(),g("span",Xu,d(String(X).slice(0,200)),1))])]),_:2},1032,["items"]))],8,Yu))),128)),a("td",Zu,[x.value===ce?(l(),g("div",ec,[f(be,{size:"xs",color:"primary",variant:"ghost",icon:"i-heroicons-check",onClick:j}),f(be,{size:"xs",color:"neutral",variant:"ghost",icon:"i-heroicons-x-mark",onClick:K})])):(l(),g("div",tc,[f(be,{size:"xs",variant:"ghost",icon:"i-heroicons-pencil-square",onClick:X=>te(ce)},null,8,["onClick"]),f(be,{size:"xs",variant:"ghost",color:"error",icon:"i-heroicons-trash",onClick:X=>F(ce)},null,8,["onClick"])]))])]))),128))])])):E("",!0)]),a("div",ac,[a("span",sc,d(y.value>0?t(e)("analysis.debug.tableBrowser.rowCount",{count:y.value}):""),1),b.value>1?(l(),g("div",nc,[f(be,{size:"xs",variant:"ghost",disabled:_.value<=1,icon:"i-heroicons-chevron-left",onClick:re[3]||(re[3]=we=>_.value--)},null,8,["disabled"]),a("span",oc,d(t(e)("analysis.debug.tableBrowser.page",{current:_.value,total:b.value})),1),f(be,{size:"xs",variant:"ghost",disabled:_.value>=b.value,icon:"i-heroicons-chevron-right",onClick:re[4]||(re[4]=we=>_.value++)},null,8,["disabled"])])):E("",!0)])]),_:1})])}}}),rc={class:"flex h-full"},lc={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"},uc={key:0,class:"py-2"},cc={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},dc=["title","onClick"],mc={class:"truncate text-xs font-medium"},gc={class:"truncate text-[10px] opacity-50"},pc={key:1,class:"border-t border-gray-200 py-2 dark:border-gray-700"},fc={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},hc=["title","onClick"],vc={class:"truncate text-xs font-medium"},yc={class:"truncate text-[10px] opacity-50"},xc={class:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4"},bc={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"},kc={class:"text-sm font-medium text-primary-700 dark:text-primary-300"},_c={class:"mt-1 text-xs text-primary-600/70 dark:text-primary-400/70"},wc={key:1,class:"flex flex-col gap-3"},$c={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Cc={class:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3"},Sc={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},Ic={key:0,class:"text-red-500"},Tc={key:1,class:"ml-1 text-gray-400"},Mc={key:2,class:"ml-1 text-gray-400"},Ac={class:"flex items-center gap-3"},zc={key:3,class:"text-xs text-gray-500 dark:text-gray-400"},qc={key:2,class:"flex-1 min-h-0"},Lc={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},Dc={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"},Ec={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"},Bc={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"},Fc=le({__name:"ToolTestTab",props:{sessionId:{}},setup(r){const{t:i}=Ie(),e=r,s=A([]),n=A(""),u=A({}),o=A(!1),c=A(null),m=A(null),h=A(null),p=A(!1),_=A(null);function y(v){const S=`ai.assistant.builtinToolDesc.${v}`,V=i(S);return V!==S?V:v}const b=T(()=>s.value.filter(v=>v.category==="core")),x=T(()=>s.value.filter(v=>v.category==="analysis")),k=T(()=>s.value.find(v=>v.name===n.value)),I=T(()=>{const v=k.value;if(!v?.parameters)return[];const S=v.parameters;if(!S.properties)return[];const V=new Set(S.required??[]);return Object.entries(S.properties).map(([B,D])=>{const z={name:B,type:D.type??"string",description:D.description??"",required:V.has(B),defaultValue:D.default};if(D.enum&&(z.enumValues=D.enum),D.type==="array"){z.isArray=!0;const M=D.items;z.arrayItemType=M?.type??"string"}return z})});fe(n,()=>{u.value={},m.value=null,h.value=null,_.value=null}),He(async()=>{try{s.value=await ot().getToolCatalog(),s.value.length>0&&(n.value=s.value[0].name)}catch(v){console.error("Failed to load tool catalog:",v)}});function $(){const v={};for(const S of I.value){const V=u.value[S.name];if(!(V===void 0||V===""))if(S.type==="number"){const B=Number(V);isNaN(B)||(v[S.name]=B)}else S.isArray?v[S.name]=V.split(",").map(B=>B.trim()).filter(Boolean):v[S.name]=V}return v}async function w(){if(!n.value||o.value)return;o.value=!0,m.value=null,h.value=null,p.value=!1,_.value=null;const v=`tool_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;c.value=v;try{const S=$(),V=await ot().executeTool(v,n.value,S,e.sessionId);if(V.error==="cancelled")return;V.success?(_.value=V.elapsed??null,p.value=!!V.truncated,m.value=V.truncated?V.details?._preview??"":JSON.stringify(V.details??V.content,null,2)):h.value=V.error??"Unknown error"}catch(S){h.value=String(S)}finally{o.value=!1,c.value=null}}async function C(){c.value&&(await ot().cancelToolTest(c.value),o.value=!1,c.value=null)}return(v,S)=>{const V=Za,B=Yt,D=Xe,z=Me;return l(),g("div",rc,[a("div",lc,[b.value.length>0?(l(),g("div",uc,[a("div",cc,d(t(i)("ai.lab.toolTest.coreTools")),1),(l(!0),g(ie,null,_e(b.value,M=>(l(),g("button",{key:M.name,class:W(["flex w-full flex-col px-3 py-1.5 text-left transition-colors",[n.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=>n.value=M.name},[a("span",mc,d(y(M.name)),1),a("span",gc,d(M.name),1)],10,dc))),128))])):E("",!0),x.value.length>0?(l(),g("div",pc,[a("div",fc,d(t(i)("ai.lab.toolTest.analysisTools")),1),(l(!0),g(ie,null,_e(x.value,M=>(l(),g("button",{key:M.name,class:W(["flex w-full flex-col px-3 py-1.5 text-left transition-colors",[n.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=>n.value=M.name},[a("span",vc,d(y(M.name)),1),a("span",yc,d(M.name),1)],10,hc))),128))])):E("",!0)]),f(t(wt),{class:"my-3 mr-3 flex min-w-0 flex-1 flex-col"},{default:L(()=>[a("div",xc,[k.value?(l(),g("div",bc,[a("div",kc,d(y(k.value.name)),1),a("div",_c,d(k.value.description),1)])):E("",!0),I.value.length>0?(l(),g("div",wc,[a("h3",$c,d(t(i)("ai.lab.toolTest.parameters")),1),a("div",Cc,[(l(!0),g(ie,null,_e(I.value,M=>(l(),g("div",{key:M.name,class:"flex flex-col gap-1"},[a("label",Sc,[ne(d(M.name)+" ",1),M.required?(l(),g("span",Ic,"*")):E("",!0),M.type==="number"?(l(),g("span",Tc,"(number)")):E("",!0),M.isArray?(l(),g("span",Mc,"("+d(M.arrayItemType)+"[])",1)):E("",!0)]),M.enumValues?(l(),P(V,{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"])):(l(),P(B,{key:1,modelValue:u.value[M.name],"onUpdate:modelValue":q=>u.value[M.name]=q,placeholder:M.isArray?t(i)("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",Ac,[o.value?(l(),P(D,{key:1,color:"error",icon:"i-heroicons-stop",onClick:C},{default:L(()=>[ne(d(t(i)("ai.lab.toolTest.cancel")),1)]),_:1})):(l(),P(D,{key:0,color:"primary",disabled:!n.value,icon:"i-heroicons-play",onClick:w},{default:L(()=>[ne(d(t(i)("ai.lab.toolTest.execute")),1)]),_:1},8,["disabled"])),o.value?(l(),P(z,{key:2,name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin text-gray-400"})):E("",!0),_.value!==null?(l(),g("span",zc,d(t(i)("ai.lab.toolTest.elapsed",{ms:_.value})),1)):E("",!0)]),m.value||h.value?(l(),g("div",qc,[a("h3",Lc,d(t(i)("ai.lab.toolTest.result")),1),h.value?(l(),g("div",Dc,d(h.value),1)):(l(),g(ie,{key:1},[p.value?(l(),g("div",Ec,d(t(i)("ai.lab.toolTest.truncated")),1)):E("",!0),a("pre",Bc,d(m.value),1)],64))])):E("",!0)])]),_:1})])}}}),Rc={class:"flex h-full flex-col"},Vc={class:"min-h-0 flex-1 overflow-hidden"},Oc=le({__name:"DebugTab",props:{sessionId:{}},setup(r){const{t:i}=Ie(),e=r,s=[{id:"sql-tables",label:i("analysis.debug.sqlTables"),icon:"i-heroicons-table-cells"},{id:"basic-tools",label:i("analysis.debug.basicTools"),icon:"i-heroicons-wrench-screwdriver"}],n=A("sql-tables");return(u,o)=>(l(),g("div",Rc,[f(t(Ua),{modelValue:n.value,"onUpdate:modelValue":o[0]||(o[0]=c=>n.value=c),items:s,"persist-key":"debugTab"},null,8,["modelValue"]),a("div",Vc,[f(Mt,{name:"fade",mode:"out-in"},{default:L(()=>[n.value==="sql-tables"?(l(),P(ic,{key:0,class:"h-full","session-id":e.sessionId},null,8,["session-id"])):n.value==="basic-tools"?(l(),P(Fc,{key:1,class:"h-full","session-id":e.sessionId},null,8,["session-id"])):E("",!0)]),_:1})])]))}}),N2=gt(Oc,[["__scopeId","data-v-b3b3d1a4"]]),Pc=["disabled"],Nc={key:0,class:"flex-1 overflow-y-auto p-2"},jc={key:0,class:"flex items-center justify-center py-8"},Uc={key:1,class:"flex flex-col items-center justify-center py-12 text-center"},Hc={class:"flex h-12 w-12 items-center justify-center rounded-full bg-gray-50 dark:bg-gray-800"},Wc={class:"mt-3 text-xs text-gray-400"},Kc={key:2,class:"space-y-3"},Yc={class:"px-2 pb-1 pt-1.5 text-[10px] font-medium tracking-wide text-gray-400 dark:text-gray-500"},Gc={class:"space-y-0.5"},Qc=["onClick"],Jc=["placeholder","onBlur","onKeyup"],Xc={key:1,class:"flex items-center"},Zc={class:"line-clamp-1 min-w-0 flex-1 text-sm leading-snug"},ed={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"},td={class:"w-28 p-1"},ad=["disabled","onClick"],sd=["onClick"],nd=["disabled","onClick"],od={key:1,class:"flex flex-1 flex-col items-center gap-1 overflow-y-auto px-2 pb-2"},id=["title","disabled"],rd=["title","onClick"],ld={key:0,class:"absolute -left-2 top-1/2 h-4.5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary-500"},ud=le({__name:"ConversationList",props:{sessionId:{},activeId:{},disabled:{type:Boolean},conversations:{},loading:{type:Boolean},embedded:{type:Boolean},collapsible:{type:Boolean}},emits:["select","create","delete","rename"],setup(r,{expose:i,emit:e}){const{t:s}=Ie(),n=r,u=e,o=A([]),c=A(!1),m=A(null),h=A(""),p=A(!1),_=A(null),y=T(()=>n.conversations!==void 0),b=T(()=>n.conversations??o.value),x=T(()=>y.value?n.loading??!1:c.value),k=T(()=>n.collapsible!==!1),I=T(()=>k.value&&p.value);async function $(){if(!y.value){c.value=!0;try{o.value=await ot().getAIChats(n.sessionId)}catch(M){console.error("加载对话列表失败:",M)}finally{c.value=!1}}}const w=T(()=>{if(b.value.length===0)return[];const M=Ne(),q=M.subtract(7,"day").startOf("day"),U=M.subtract(30,"day").startOf("day"),Y=[],te=[],K=new Map;for(const F of b.value){const Z=Ne(F.updatedAt*1e3);if(Z.isAfter(q))Y.push(F);else if(Z.isAfter(U))te.push(F);else{const ue=Z.format("YYYY-MM");K.has(ue)||K.set(ue,[]),K.get(ue).push(F)}}const j=[];Y.length>0&&j.push({label:s("ai.chat.conversation.group.last7Days"),conversations:Y}),te.length>0&&j.push({label:s("ai.chat.conversation.group.last30Days"),conversations:te});const N=[...K.keys()].sort((F,Z)=>Z.localeCompare(F));for(const F of N){const Z=Ne(F+"-01");j.push({label:Z.format(Z.year()===M.year()?"M月":"YYYY年M月"),conversations:K.get(F)})}return j});function C(M){return M.title||s("ai.chat.conversation.newChat")}function v(M){n.disabled||(m.value=M.id,h.value=M.title||"")}async function S(M){if(!n.disabled){if(h.value.trim()){if(y.value){u("rename",{id:M,title:h.value.trim()}),m.value=null;return}try{await ot().updateAIChatTitle(M,h.value.trim());const q=o.value.find(U=>U.id===M);q&&(q.title=h.value.trim())}catch(q){console.error("更新标题失败:",q)}}m.value=null}}function V(M){_.value=null,v(M)}function B(M){_.value=null,navigator.clipboard.writeText(M)}function D(M){_.value=null,z(M)}async function z(M){if(!n.disabled){if(y.value){u("delete",M);return}try{await ot().deleteAIChat(M),o.value=o.value.filter(q=>q.id!==M),u("delete",M)}catch(q){console.error("删除对话失败:",q)}}}return He(()=>{$()}),fe(()=>n.sessionId,()=>{$()}),i({refresh:$}),(M,q)=>{const U=Me,Y=Xe,te=Ss;return l(),g("div",{class:W(["flex shrink-0 flex-col overflow-hidden bg-white transition-all duration-300 ease-in-out dark:bg-sidebar-dark",[n.embedded?"h-full":"m-3 h-[calc(100%-1.5rem)] rounded-lg",I.value?"w-14":"w-64"]])},[a("div",{class:W(["flex items-center",I.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"])},[I.value?(l(),g("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:q[2]||(q[2]=K=>p.value=!p.value)},[f(U,{name:"i-lucide-panel-right-open",class:"size-4 scale-x-[-1]"})])):(l(),g(ie,{key:0},[a("button",{class:W(["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:q[0]||(q[0]=K=>!r.disabled&&u("create"))},[f(U,{name:"i-heroicons-plus",class:"h-3.5 w-3.5"}),a("span",null,d(t(s)("ai.chat.conversation.newConversation")),1)],10,Pc),k.value?(l(),P(Y,{key:0,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:q[1]||(q[1]=K=>p.value=!p.value)},{default:L(()=>[f(U,{name:"i-lucide-panel-right",class:"size-4 scale-x-[-1] group-hover:hidden"}),f(U,{name:"i-lucide-panel-right-close",class:"size-4 hidden scale-x-[-1] group-hover:block"})]),_:1})):E("",!0)],64))],2),I.value?(l(),g("div",od,[a("button",{class:W(["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(s)("ai.chat.conversation.newConversation"),disabled:r.disabled,onClick:q[7]||(q[7]=K=>!r.disabled&&u("create"))},[f(U,{name:"i-heroicons-plus",class:"h-5 w-5"})],10,id),(l(!0),g(ie,null,_e(b.value,K=>(l(),g("button",{key:K.id,class:W(["relative mx-auto flex h-10 w-10 items-center justify-center rounded-lg transition-all duration-200",[r.activeId===K.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:C(K),onClick:j=>u("select",K.id)},[r.activeId===K.id?(l(),g("span",ld)):E("",!0),f(U,{name:"i-heroicons-chat-bubble-left",class:"h-5 w-5"})],10,rd))),128))])):(l(),g("div",Nc,[x.value?(l(),g("div",jc,[f(U,{name:"i-heroicons-arrow-path",class:"h-5 w-5 animate-spin text-gray-400"})])):b.value.length===0?(l(),g("div",Uc,[a("div",Hc,[f(U,{name:"i-heroicons-chat-bubble-left",class:"h-6 w-6 text-gray-300 dark:text-gray-600"})]),a("p",Wc,d(t(s)("ai.chat.conversation.empty")),1),f(Y,{class:"mt-2",size:"xs",variant:"link",color:"primary",disabled:r.disabled,onClick:q[3]||(q[3]=K=>!r.disabled&&u("create"))},{default:L(()=>[ne(d(t(s)("ai.chat.conversation.startNew")),1)]),_:1},8,["disabled"])])):(l(),g("div",Kc,[(l(!0),g(ie,null,_e(w.value,K=>(l(),g("div",{key:K.label},[a("div",Yc,d(K.label),1),a("div",Gc,[(l(!0),g(ie,null,_e(K.conversations,j=>(l(),g("div",{key:j.id,class:W(["group relative rounded-lg px-3 py-2 transition-all",["cursor-pointer",r.activeId===j.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:N=>u("select",j.id)},[m.value===j.id?ct((l(),g("input",{key:0,"onUpdate:modelValue":q[4]||(q[4]=N=>h.value=N),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(s)("ai.chat.conversation.titlePlaceholder"),autoFocus:"",onBlur:N=>S(j.id),onKeyup:it(N=>S(j.id),["enter"]),onClick:q[5]||(q[5]=Ke(()=>{},["stop"]))},null,40,Jc)),[[Lt,h.value]]):(l(),g("div",Xc,[a("p",Zc,d(C(j)),1),a("div",{class:W(["ml-1 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",{"opacity-100":r.activeId===j.id||_.value===j.id}]),onClick:q[6]||(q[6]=Ke(()=>{},["stop"]))},[f(te,{open:_.value===j.id,ui:{content:"z-50 p-0"},"onUpdate:open":N=>_.value=N?j.id:null},{content:L(()=>[a("div",td,[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:N=>V(j)},[f(U,{name:"i-heroicons-pencil",class:"h-3.5 w-3.5"}),ne(" "+d(t(s)("ai.chat.conversation.rename")),1)],8,ad),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:N=>B(j.id)},[f(U,{name:"i-heroicons-clipboard-document",class:"h-3.5 w-3.5"}),ne(" "+d(t(s)("ai.chat.conversation.copyId")),1)],8,sd),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:N=>D(j.id)},[f(U,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"}),ne(" "+d(t(s)("ai.chat.conversation.delete")),1)],8,nd)])]),default:L(()=>[a("button",ed,[f(U,{name:"i-heroicons-ellipsis-horizontal",class:"h-4 w-4"})])]),_:2},1032,["open","onUpdate:open"])],2)]))],10,Qc))),128))])]))),128))]))]))],2)}}}),cd={class:"writing-vertical text-xs"},dd={class:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800"},md={class:"flex items-center gap-2"},gd={class:"font-medium text-gray-900 dark:text-white"},pd={key:0,class:"border-b border-gray-200 px-4 py-2 dark:border-gray-800"},fd={class:"flex flex-wrap items-center gap-2"},hd={class:"text-xs text-gray-500"},vd={class:"flex-1 overflow-y-auto"},yd={key:0,class:"flex items-center justify-center py-8"},xd={key:1,class:"flex flex-col items-center justify-center py-8 text-center"},bd={class:"mt-2 text-sm text-gray-500"},kd={class:"text-xs text-gray-400"},_d={key:2,class:"divide-y divide-gray-100 dark:divide-gray-800"},wd={class:"mb-1 flex items-center justify-between"},$d={class:"text-sm font-medium text-gray-900 dark:text-white"},Cd={class:"text-xs text-gray-400"},Sd=["innerHTML"],Id={key:1,class:"border-t border-gray-200 px-4 py-2 dark:border-gray-800"},Td={class:"flex items-center justify-between"},Md={class:"text-xs text-gray-500"},Ad={key:2,class:"pointer-events-none absolute inset-0 overflow-hidden rounded-xl opacity-[0.03]"},zd=le({__name:"DataSourcePanel",props:{messages:{},keywords:{},isLoading:{type:Boolean},isCollapsed:{type:Boolean}},emits:["toggle","loadMore"],setup(r,{emit:i}){const{t:e}=Ie(),s=r,n=i;function u(c){return Ne(c).format("MM-DD HH:mm")}function o(c){if(!s.keywords.length)return c;const m=s.keywords.join("|"),h=new RegExp(`(${m})`,"gi");return c.replace(h,'<mark class="bg-yellow-200 dark:bg-yellow-800/50 px-0.5 rounded">$1</mark>')}return(c,m)=>{const h=Me,p=Xe;return l(),g("div",{class:W(["relative flex flex-col rounded-xl bg-white transition-all duration-300 dark:bg-page-dark",[r.isCollapsed?"w-12":"w-full"]])},[r.isCollapsed?(l(),g("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:m[0]||(m[0]=_=>n("toggle"))},[f(h,{name:"i-heroicons-chevron-left",class:"h-5 w-5"}),a("span",cd,d(t(e)("ai.chat.dataSource.title")),1)])):(l(),g(ie,{key:1},[a("div",dd,[a("div",md,[f(h,{name:"i-heroicons-document-magnifying-glass",class:"h-5 w-5 text-gray-500"}),a("span",gd,d(t(e)("ai.chat.dataSource.title")),1)]),f(p,{icon:"i-heroicons-chevron-right",color:"gray",variant:"ghost",size:"xs",onClick:m[1]||(m[1]=_=>n("toggle"))})]),r.keywords.length>0?(l(),g("div",pd,[a("div",fd,[a("span",hd,d(t(e)("ai.chat.dataSource.keywords")),1),(l(!0),g(ie,null,_e(r.keywords,_=>(l(),g("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",vd,[r.isLoading?(l(),g("div",yd,[f(h,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):r.messages.length===0?(l(),g("div",xd,[f(h,{name:"i-heroicons-inbox",class:"h-10 w-10 text-gray-300 dark:text-gray-600"}),a("p",bd,d(t(e)("ai.chat.dataSource.empty")),1),a("p",kd,d(t(e)("ai.chat.dataSource.emptyHint")),1)])):(l(),g("div",_d,[(l(!0),g(ie,null,_e(r.messages,_=>(l(),g("div",{key:_.id,class:"px-4 py-3 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[a("div",wd,[a("span",$d,d(_.senderName),1),a("span",Cd,d(u(_.timestamp)),1)]),a("p",{class:"line-clamp-3 text-sm text-gray-600 dark:text-gray-400",innerHTML:o(_.content)},null,8,Sd)]))),128))]))]),r.messages.length>0?(l(),g("div",Id,[a("div",Td,[a("span",Md,d(t(e)("ai.chat.dataSource.totalRecords",{count:r.messages.length})),1),f(p,{size:"xs",variant:"ghost",onClick:m[2]||(m[2]=_=>n("loadMore"))},{default:L(()=>[ne(d(t(e)("ai.chat.dataSource.loadMore")),1)]),_:1})])])):E("",!0)],64)),r.isCollapsed?E("",!0):(l(),g("div",Ad,[...m[3]||(m[3]=[a("div",{class:"data-flow-bg absolute inset-0"},null,-1)])]))],2)}}}),qd=gt(zd,[["__scopeId","data-v-a9962add"]]),Ld={class:"flex max-h-[80vh] flex-col overflow-hidden"},Dd={class:"shrink-0 border-b border-gray-200 px-6 py-4 dark:border-gray-800"},Ed={class:"flex items-center justify-between"},Bd={class:"flex items-center gap-3"},Fd={class:"flex h-8 w-8 items-center justify-center rounded-lg bg-red-100 dark:bg-red-900/40"},Rd={class:"text-lg font-semibold text-gray-900 dark:text-white"},Vd={class:"flex-1 overflow-y-auto px-6 py-4"},Od={class:"flex flex-col gap-4"},Pd={class:"text-sm font-semibold text-gray-700 dark:text-gray-300"},Nd={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"},jd={class:"m-0 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-red-600 dark:text-red-400"},Ud={key:1,class:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-page-dark"},Hd={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"},Wd={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"},Kd={key:0,class:"py-8 text-center text-sm text-gray-400 dark:text-gray-500"},Yd={class:"shrink-0 border-t border-gray-200 px-6 py-3 dark:border-gray-800"},Gd={class:"flex justify-end"},Qd=le({__name:"ErrorDetailModal",props:Ut({error:{}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:["update:open"],setup(r){const{t:i}=Ie(),e=ft(),s=ra(r,"open"),n=r,u=T(()=>{const m=n.error,h=[];return m.url&&h.push({label:i("ai.chat.error.requestUrl"),value:m.url}),m.statusCode!=null&&h.push({label:i("ai.chat.error.statusCode"),value:String(m.statusCode)}),m.responseBody&&h.push({label:i("ai.chat.error.responseBody"),value:o(m.responseBody),isCode:!0}),m.responseHeaders&&h.push({label:i("ai.chat.error.responseHeaders"),value:JSON.stringify(m.responseHeaders,null,2),isCode:!0}),m.name&&h.push({label:i("ai.chat.error.name"),value:m.name}),m.message&&h.push({label:i("ai.chat.error.message"),value:m.message}),m.stack&&h.push({label:i("ai.chat.error.stack"),value:m.stack,isStack:!0}),m.cause&&h.push({label:i("ai.chat.error.cause"),value:o(m.cause),isCode:!0}),m.provider&&h.push({label:i("ai.chat.error.provider"),value:m.provider}),m.requestBody&&h.push({label:i("ai.chat.error.requestBody"),value:o(m.requestBody),isCode:!0}),h});function o(m){try{return JSON.stringify(JSON.parse(m),null,2)}catch{return m}}function c(){const m=u.value.map(h=>`${h.label}: ${h.value}`).join(`
69
+
70
+ `);navigator.clipboard.writeText(m).then(()=>{e.success(i("ai.chat.error.copied"))})}return(m,h)=>{const p=Me,_=Xe,y=lt;return l(),P(y,{open:s.value,"onUpdate:open":h[1]||(h[1]=b=>s.value=b),ui:{content:"sm:max-w-[700px] z-[100]",overlay:"backdrop-blur-sm z-[99]"}},{content:L(()=>[a("div",Ld,[a("div",Dd,[a("div",Ed,[a("div",Bd,[a("div",Fd,[f(p,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4 text-red-600 dark:text-red-400"})]),a("h2",Rd,d(t(i)("ai.chat.error.detail")),1)]),f(_,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:h[0]||(h[0]=b=>s.value=!1)})])]),a("div",Vd,[a("div",Od,[(l(!0),g(ie,null,_e(u.value,(b,x)=>(l(),g("div",{key:x,class:"flex flex-col gap-1.5"},[a("div",Pd,d(b.label),1),b.isStack?(l(),g("div",Nd,[a("pre",jd,d(b.value),1)])):b.isCode?(l(),g("div",Ud,[a("pre",Hd,d(b.value),1)])):(l(),g("div",Wd,d(b.value),1))]))),128)),u.value.length===0?(l(),g("div",Kd,d(t(i)("ai.chat.error.unknown")),1)):E("",!0)])]),a("div",Yd,[a("div",Gd,[f(_,{icon:"i-heroicons-document-duplicate",variant:"soft",color:"neutral",size:"sm",onClick:c},{default:L(()=>[ne(d(t(i)("ai.chat.error.copyAll")),1)]),_:1})])])])]),_:1},8,["open"])}}}),Jd={class:"min-w-0 flex-1 truncate"},Xd={class:"shrink-0 text-[11px] text-amber-600/80 dark:text-amber-400/80"},Zd={class:"mb-1.5 flex items-center gap-2"},em={class:"flex shrink-0 items-center justify-center text-red-500 dark:text-red-400"},tm={class:"pr-5 text-[13px] font-semibold leading-[1.4] text-red-600 dark:text-red-400"},am={class:"ml-6 line-clamp-3 break-words text-xs leading-normal text-gray-600 dark:text-gray-400"},sm={class:"mt-2.5 ml-6 flex items-center"},nm={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"},om=le({__name:"ErrorBlock",props:{error:{},compact:{type:Boolean}},setup(r){const{t:i}=Ie(),e=r,s=A(!1);function n(u){return u.friendlyMessage||u.message||i("ai.chat.error.unknown")}return(u,o)=>{const c=Me;return l(),g(ie,null,[e.compact?(l(),g("button",{key:0,type:"button",class:"flex w-full min-w-0 items-start gap-2 rounded-md py-1 text-left text-xs text-amber-700 transition-colors hover:bg-amber-50/70 dark:text-amber-300 dark:hover:bg-amber-950/20",onClick:o[0]||(o[0]=m=>s.value=!0)},[f(c,{name:"i-heroicons-exclamation-circle",class:"mt-0.5 h-3.5 w-3.5 shrink-0 text-amber-500"}),a("span",Jd,d(n(r.error)),1),a("span",Xd,d(t(i)("ai.chat.error.viewDetail")),1)])):(l(),g("div",{key:1,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:o[1]||(o[1]=m=>s.value=!0)},[a("div",Zd,[a("div",em,[f(c,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4"})]),a("div",tm,d(t(i)("ai.chat.error.title")),1)]),a("div",am,d(n(r.error)),1),a("div",sm,[a("div",nm,[ne(d(t(i)("ai.chat.error.viewDetail"))+" ",1),f(c,{name:"i-heroicons-chevron-right",class:"h-3.5 w-3.5"})])])])),f(Qd,{open:s.value,"onUpdate:open":o[2]||(o[2]=m=>s.value=m),error:r.error},null,8,["open","error"])],64)}}}),im={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"},rm={class:"border-b border-gray-100 px-3 py-2 dark:border-gray-800"},lm={class:"flex min-w-0 items-start justify-between gap-3"},um={class:"min-w-0"},cm={class:"truncate text-sm font-semibold text-gray-900 dark:text-gray-100"},dm={key:0,class:"mt-0.5 line-clamp-2 text-xs text-gray-500 dark:text-gray-400"},mm={class:"flex shrink-0 items-center gap-1.5"},gm={class:"rounded-md bg-gray-100 px-1.5 py-0.5 text-[10px] uppercase text-gray-500 dark:bg-gray-800"},pm={class:"flex max-h-[92vh] flex-col overflow-hidden bg-white dark:bg-page-dark"},fm={class:"flex items-start justify-between gap-4 border-b border-gray-200 px-5 py-4 dark:border-gray-800"},hm={class:"min-w-0"},vm={class:"truncate text-base font-semibold text-gray-900 dark:text-gray-100"},ym={key:0,class:"mt-1 line-clamp-2 text-xs text-gray-500 dark:text-gray-400"},xm={class:"mt-1 text-[11px] text-gray-400 dark:text-gray-500"},bm={class:"min-h-0 flex-1 overflow-auto p-4"},km={key:0,class:"flex h-64 items-center justify-center text-xs text-gray-400 dark:text-gray-500"},_m={class:"mt-1 text-[11px] text-gray-400 dark:text-gray-500"},wm={class:"px-2 py-3"},$m={key:0,class:"flex h-32 items-center justify-center text-xs text-gray-400 dark:text-gray-500"},Cm=le({__name:"ChartBlockRenderer",props:{chart:{}},setup(r){const{t:i}=Ie(),e=r,s=A(!1),n=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),m=T(()=>{const $=[];return e.chart.spec.unit&&$.push(e.chart.spec.unit),e.chart.truncated&&$.push(i("ai.chat.message.chart.truncated")),$.push(i("ai.chat.message.chart.rows",{count:e.chart.rowCount})),$.join(" · ")}),h=T(()=>e.chart.data),p=T(()=>e.chart.data),_=T(()=>e.chart.data),y=T(()=>e.chart.data),b=T(()=>e.chart.spec.type==="pie"?_.value.labels.length>8:e.chart.spec.type==="line"?p.value.labels.length>28||(p.value.series?.length??0)>4:e.chart.spec.type==="bar"?h.value.labels.length>12:e.chart.spec.type==="heatmap"?y.value.xLabels.length*y.value.yLabels.length>180:!1),x=T(()=>{const $=b.value?320:380;return Math.min(o.value,$)}),k=T(()=>{const $=o.value;if(e.chart.spec.type==="pie")return Math.max($,560);if(e.chart.spec.type==="line")return Math.max($,p.value.labels.length>40?620:540);if(e.chart.spec.type==="bar"){const w=e.chart.spec.display?.horizontal?h.value.labels.length*28+120:520;return Math.min(Math.max($,w),820)}return e.chart.spec.type==="heatmap"?Math.min(Math.max($,y.value.yLabels.length*22+150,560),860):Math.max($,520)}),I=T(()=>e.chart.spec.type==="pie"?"640px":e.chart.spec.type==="bar"?"720px":"780px");return($,w)=>{const C=Xe,v=lt;return l(),g("div",im,[a("div",rm,[a("div",lm,[a("div",um,[a("h3",cm,d(n.value),1),u.value?(l(),g("p",dm,d(u.value),1)):E("",!0)]),a("div",mm,[a("span",gm,d(r.chart.spec.type),1),f(v,{open:s.value,"onUpdate:open":w[2]||(w[2]=S=>s.value=S),ui:{overlay:"z-[10040] backdrop-blur-sm",content:"z-[10050] w-[96vw] max-w-6xl max-h-[92vh] overflow-hidden"}},{content:L(()=>[a("div",pm,[a("div",fm,[a("div",hm,[a("h3",vm,d(n.value),1),u.value?(l(),g("p",ym,d(u.value),1)):E("",!0),a("p",xm,d(m.value),1)]),f(C,{icon:"i-heroicons-x-mark",size:"sm",color:"neutral",variant:"ghost",class:"shrink-0",title:t(i)("common.close"),"aria-label":t(i)("common.close"),onClick:w[1]||(w[1]=S=>s.value=!1)},null,8,["title","aria-label"])]),a("div",bm,[a("div",{class:"mx-auto w-full",style:mt({minWidth:I.value})},[c.value?(l(),g("div",km,d(t(i)("ai.chat.message.chart.empty")),1)):r.chart.spec.type==="bar"?(l(),P(xt,{key:1,data:h.value,height:k.value,mode:"expanded",horizontal:r.chart.spec.display?.horizontal},null,8,["data","height","horizontal"])):r.chart.spec.type==="line"?(l(),P(za,{key:2,data:p.value,height:k.value,mode:"expanded"},null,8,["data","height"])):r.chart.spec.type==="pie"?(l(),P(La,{key:3,data:_.value,height:k.value,mode:"expanded","show-legend":r.chart.spec.display?.showLegend??!0},null,8,["data","height","show-legend"])):r.chart.spec.type==="heatmap"?(l(),P(Da,{key:4,data:y.value,height:k.value,mode:"expanded"},null,8,["data","height"])):E("",!0)],4)])])]),default:L(()=>[f(C,{icon:"i-heroicons-arrows-pointing-out",size:"xs",color:"neutral",variant:"ghost",class:"no-capture",title:t(i)("ai.chat.message.chart.expand"),"aria-label":t(i)("ai.chat.message.chart.expand"),onClick:w[0]||(w[0]=Ke(()=>{},["stop"]))},null,8,["title","aria-label"])]),_:1},8,["open"])])]),a("p",_m,d(m.value),1)]),a("div",wm,[c.value?(l(),g("div",$m,d(t(i)("ai.chat.message.chart.empty")),1)):r.chart.spec.type==="bar"?(l(),P(xt,{key:1,data:h.value,height:x.value,mode:"compact",horizontal:r.chart.spec.display?.horizontal},null,8,["data","height","horizontal"])):r.chart.spec.type==="line"?(l(),P(za,{key:2,data:p.value,height:x.value,mode:"compact"},null,8,["data","height"])):r.chart.spec.type==="pie"?(l(),P(La,{key:3,data:_.value,height:x.value,mode:"compact","show-legend":r.chart.spec.display?.showLegend??!0},null,8,["data","height","show-legend"])):r.chart.spec.type==="heatmap"?(l(),P(Da,{key:4,data:y.value,height:x.value,mode:"compact"},null,8,["data","height"])):E("",!0)])])}}}),Sm=["data-open","aria-hidden","inert"],Im={class:"ai-process-fold-inner"},na=le({__name:"ProcessDisclosure",props:{lazy:{type:Boolean,default:!1}},setup(r){const i=r,e=A(!1),s=A(!1);function n(){e.value||(s.value=!0),e.value=!e.value}return(u,o)=>(l(),g("div",null,[$e(u.$slots,"summary",{open:e.value,toggle:n}),a("div",{class:"ai-process-fold","data-open":e.value||void 0,"aria-hidden":!e.value,inert:e.value?void 0:!0},[a("div",Im,[!i.lazy||s.value?$e(u.$slots,"default",{key:0}):E("",!0)])],8,Sm)]))}}),Tm={class:"relative flex h-4 w-4 shrink-0 items-center justify-center","aria-hidden":"true"},oa=le({__name:"ProcessDisclosureIcon",props:{icon:{},open:{type:Boolean},iconClass:{default:"text-gray-400 dark:text-gray-500"}},setup(r){return(i,e)=>{const s=Me;return l(),g("span",Tm,[r.open?E("",!0):(l(),P(s,{key:0,name:r.icon,class:W(["absolute h-3.5 w-3.5 transition-opacity duration-100 group-hover/process-toggle:opacity-0",r.iconClass])},null,8,["name","class"])),f(s,{name:"i-heroicons-chevron-down",class:W(["absolute h-3.5 w-3.5 text-gray-500 transition-opacity duration-100 dark:text-gray-400",r.open?"opacity-100":"opacity-0 group-hover/process-toggle:opacity-100"])},null,8,["class"])])}}}),Mm=["aria-expanded","onClick"],Am={class:"shrink-0 text-gray-600 dark:text-gray-300"},zm={class:"ml-auto flex min-w-0 items-center gap-2"},qm={key:0,class:"truncate text-[11px] text-gray-400 dark:text-gray-500"},Lm={class:"evidence-details mx-px mt-1 rounded-lg border border-gray-200/60 bg-gray-50/80 px-3 py-2 dark:border-white/5 dark:bg-white/[0.03]"},Dm={class:"mb-2 space-y-0.5 text-xs text-gray-600 dark:text-gray-400"},Em={class:"font-medium"},Bm={key:0},Fm={class:"font-medium"},Rm={key:0,class:"mb-2 space-y-1"},Vm={key:1,class:"py-1.5 text-center text-xs text-gray-400 dark:text-gray-500"},Om={key:2,class:"space-y-2"},Pm={class:"flex items-center gap-2"},Nm={class:"ml-auto shrink-0 text-[11px] text-gray-400 dark:text-gray-500"},jm={key:0,class:"mt-1 text-[11px] text-gray-500 dark:text-gray-400"},Um={class:"mt-1 space-y-0.5"},Hm=["onClick"],Wm={class:"min-w-0 flex-1 text-xs leading-snug text-gray-600 dark:text-gray-300"},Km={key:0,class:"mr-1 text-gray-400 dark:text-gray-500"},Ym={class:"line-clamp-2 break-words align-middle"},Gm={key:3,class:"mt-1.5 text-right text-[11px] text-gray-400 dark:text-gray-500"},Qm=le({__name:"EvidenceBlock",props:{evidence:{}},setup(r){const i=r,{t:e}=Ie(),s=zt(),n=["included","uncertain","excluded"],u=T(()=>[...i.evidence.groups].sort((y,b)=>n.indexOf(y.status)-n.indexOf(b.status))),o=T(()=>i.evidence.groups.reduce((y,b)=>y+b.sources.length,0)),c=T(()=>n.map(y=>({status:y,count:i.evidence.groups.filter(b=>b.status===y).length})).filter(y=>y.count>0)),m=T(()=>i.evidence.warnings??[]),h={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"},p={included:"bg-emerald-500",uncertain:"bg-amber-500",excluded:"bg-gray-400"};function _(y){s.openChatRecordDrawer({scrollToMessageId:y})}return(y,b)=>{const x=Me;return l(),P(na,{lazy:"",class:"w-full text-[13px]"},{summary:L(({open:k,toggle:I})=>[a("button",{type:"button",class:"group/process-toggle flex h-7 w-full items-center gap-2 rounded-md text-left text-sm leading-7 text-gray-500 transition-colors hover:bg-gray-50/80 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800/30 dark:hover:text-gray-300","aria-expanded":k,onClick:I},[f(oa,{icon:"i-heroicons-document-magnifying-glass",open:k},null,8,["open"]),a("span",Am,d(t(e)("ai.chat.evidence.title")),1),a("div",zm,[(l(!0),g(ie,null,_e(c.value,$=>(l(),g("span",{key:$.status,class:"flex shrink-0 items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400"},[a("span",{class:W(["h-1.5 w-1.5 rounded-full",p[$.status]])},null,2),ne(" "+d(t(e)(`ai.chat.evidence.group.${$.status}`))+" "+d($.count),1)]))),128)),c.value.length===0?(l(),g("span",qm,d(t(e)("ai.chat.evidence.empty")),1)):E("",!0)])],8,Mm)]),default:L(()=>[a("div",Lm,[a("div",Dm,[a("div",null,[a("span",Em,d(t(e)("ai.chat.evidence.query"))+":",1),ne(" "+d(r.evidence.query),1)]),r.evidence.criteria?(l(),g("div",Bm,[a("span",Fm,d(t(e)("ai.chat.evidence.criteria"))+":",1),ne(" "+d(r.evidence.criteria),1)])):E("",!0)]),m.value.length>0?(l(),g("div",Rm,[(l(!0),g(ie,null,_e(m.value,k=>(l(),g("div",{key:k,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"},[f(x,{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.${k}`)),1)]))),128))])):E("",!0),u.value.length===0?(l(),g("div",Vm,d(t(e)("ai.chat.evidence.empty")),1)):(l(),g("div",Om,[(l(!0),g(ie,null,_e(u.value,k=>(l(),g("div",{key:k.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",Pm,[a("span",{class:W(["rounded px-1.5 py-0.5 text-[11px] font-medium",h[k.status]])},d(t(e)(`ai.chat.evidence.group.${k.status}`)),3),a("span",Nm,d(k.title),1)]),k.reason?(l(),g("div",jm,d(k.reason),1)):E("",!0),a("ul",Um,[(l(!0),g(ie,null,_e(k.sources,(I,$)=>(l(),g("li",{key:`${k.id}-${$}`,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:w=>_(I.messageId)},[a("div",Wm,[I.senderName?(l(),g("span",Km,d(I.senderName)+": ",1)):E("",!0),a("span",Ym,d(I.snippet),1)]),f(x,{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,Hm))),128))])]))),128))])),u.value.length>0?(l(),g("div",Gm,d(t(e)("ai.chat.evidence.totalSources",{count:o.value})),1)):E("",!0)])]),_:1})}}}),Jm=gt(Qm,[["__scopeId","data-v-812e30c9"]]),Xm=/^\s*!\[[^\]\n]*\]\(\s*(?:(?:https?:\/\/(?:localhost|127\.0\.0\.1)(?::\d+)?)?\/?|\.\/)?chart[\w-]*(?:\.(?:png|jpg|jpeg|webp|svg))?(?:\?[^)\s]*)?\s*(?:"[^"]*")?\s*\)\s*$/gim;function Zm(r){return r&&r.replace(Xm,"").replace(/\n{3,}/g,`
71
+
72
+ `).replace(/^\n+|\n+$/g,"")}const eg=["data-follow-end"],gs=le({__name:"LiveFollowText",props:{text:{},followEnd:{type:Boolean,default:!1}},setup(r){const i=r,e=A(null);let s=null;function n(){const o=e.value;o&&(o.scrollLeft=i.followEnd?Math.max(0,o.scrollWidth-o.clientWidth):0)}function u(){if(s!==null)return;let o=3;const c=()=>{if(o-=1,o>0){s=requestAnimationFrame(c);return}s=null,n()};s=requestAnimationFrame(c)}return fe(()=>[i.text,i.followEnd],async()=>{await Fe(),u()},{flush:"post",immediate:!0}),Ft(()=>{s!==null&&cancelAnimationFrame(s)}),(o,c)=>(l(),g("span",{ref_key:"el",ref:e,class:W(["min-w-0 flex-1 overflow-hidden whitespace-nowrap text-gray-400 dark:text-gray-500",[i.followEnd?"":"text-ellipsis"]]),"data-follow-end":i.followEnd||void 0},d(i.text),11,eg))}});function $a(r){const i=r.indexOf(`
73
+ `);return i===-1?r:r.slice(0,i)}function ps(r){const i=r.trimEnd(),e=i.lastIndexOf(`
74
+ `);return e===-1?i:i.slice(e+1)}function tg(r,i,e){for(let s=i+1;s<r.length;s+=1)if(e(r[s]))return!0;return!1}function ag(r,i){const e=[];let s=[];const n=()=>{s.length!==0&&(e.push({type:"process",blocks:s}),s=[])};for(const u of r){if(i(u)){s.push(u);continue}n(),e.push({type:"visible",block:u})}return n(),e}function sg(r,i,e){const s=r.map((c,m)=>i(c)||e(c)&&tg(r,m,i)),n=r.filter((c,m)=>s[m]),u=s.findIndex(Boolean),o=[];return r.forEach((c,m)=>{if(m===u){o.push({type:"process",blocks:n});return}s[m]||o.push({type:"visible",block:c})}),o}function ng(r,i){return i.mode==="timeline"?ag(r,i.isFoldableProcessBlock):sg(r,i.isFoldableProcessBlock,i.isTextBlock)}function og(r,i,e){return e&&i===r.length-1&&r[i]?.type==="process"}function ig(r){return r.flatMap(i=>i.type==="visible"?[i.block]:[])}function rg(r){for(let i=r.length-1;i>=0;i-=1){const e=r[i];if(e.type==="think"&&e.tag?.toLowerCase()!=="plan_validation"&&e.text?.trim())return e}}function lg(r,i){const e=Math.max(0,Math.round(r/1e3));if(i.startsWith("zh")||i.startsWith("ja")){if(e<60)return`${e}秒`;if(e<3600){const h=Math.floor(e/60),p=e%60;return`${h}分${p.toString().padStart(2,"0")}秒`}const o=Math.floor(e/3600),c=Math.floor(e%3600/60),m=e%60;return`${o}时${c.toString().padStart(2,"0")}分${m.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 s=Math.floor(e/3600),n=Math.floor(e%3600/60),u=e%60;return`${s}h ${n.toString().padStart(2,"0")}m ${u.toString().padStart(2,"0")}s`}function ug(r,i){return r.type!=="process"?0:r.blocks.reduce((e,s)=>e+(i(s)??0),0)}function cg(r){return r.isStreaming?r.liveElapsedMs:r.settledElapsedMs||r.recordedElapsedMs}function dg(r){if(r.isActive&&r.activeToolName)return{type:"tool",name:r.activeToolName,progressPhase:r.activeToolProgressPhase};if(r.isActive&&r.lastFoldable){if(r.lastFoldable.kind==="think")return{type:"think"};if(r.lastFoldable.kind==="skill"&&r.lastFoldable.name)return{type:"skill",name:r.lastFoldable.name};if(r.lastFoldable.kind==="plan"||r.lastFoldable.kind==="plan_draft")return{type:"plan"};if(r.lastFoldable.kind==="tool"&&r.lastFoldable.name)return{type:"tool",name:r.lastFoldable.name}}return{type:"generic"}}const mg={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"},gg={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"},pg={class:"border-t border-gray-200/60 px-3 py-2.5 dark:border-gray-700/40"},fg=["innerHTML"],hg={class:"mt-2 text-[11px] text-gray-400 dark:text-gray-500"},vg={key:0,class:"rounded-2xl bg-gray-100 p-4 text-gray-900 dark:bg-gray-800 dark:text-gray-100"},yg=["onKeydown"],xg={class:"mt-2 flex items-center justify-between"},bg={class:"flex cursor-pointer items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400"},kg={class:"flex gap-2"},_g={key:1,class:"ai-user-bubble w-fit max-w-full rounded-3xl bg-gray-100 text-gray-900 dark:bg-gray-800 dark:text-gray-100"},wg=["innerHTML"],$g=["data-running","aria-expanded","onClick"],Cg={key:0,class:"relative mr-1.5 flex h-4 w-4 shrink-0 items-center justify-center"},Sg={key:0},Ig=["data-open"],Tg=["innerHTML"],Mg={key:0,class:"ml-1 inline-block h-4 w-1.5 animate-pulse rounded-sm bg-gray-800 dark:bg-gray-200"},Ag=["data-running","aria-expanded","onClick"],zg={class:"shrink-0 text-gray-600 dark:text-gray-300"},qg={key:0,class:"mx-2 h-0.5 w-0.5 shrink-0 rounded-full bg-gray-300 dark:bg-gray-600","aria-hidden":"true"},Lg={key:2,class:"ml-3 shrink-0 text-xs text-gray-400 dark:text-gray-500"},Dg={class:"prose prose-sm ai-process-detail-content ai-thought-content dark:prose-invert mt-1 max-w-none pl-[22px]"},Eg={key:0,class:"mb-2 font-medium text-gray-700 dark:text-gray-200"},Bg={class:"not-prose space-y-2 text-xs leading-relaxed"},Fg={class:"font-medium text-gray-800 dark:text-gray-200"},Rg={key:0,class:"mt-1 text-gray-500 dark:text-gray-400"},Vg={class:"mt-0.5 text-gray-500 dark:text-gray-400"},Og={key:1,class:"not-prose mt-2 border-t border-gray-100 pt-2 dark:border-gray-800"},Pg={class:"text-[11px] font-medium text-gray-500 dark:text-gray-400"},Ng={class:"mt-1 list-disc space-y-0.5 pl-4 text-xs leading-relaxed text-gray-600 dark:text-gray-300"},jg=["innerHTML"],Ug=["aria-expanded","onClick"],Hg={class:"min-w-0 truncate text-gray-600 dark:text-gray-300"},Wg={class:"mt-2 pl-[22px] text-sm leading-6"},Kg=["innerHTML"],Yg={key:1,class:"space-y-2"},Gg={class:"font-medium text-gray-800 dark:text-gray-200"},Qg={class:"mt-1 text-gray-500 dark:text-gray-400"},Jg={class:"mt-0.5 text-gray-500 dark:text-gray-400"},Xg={key:2,class:"mt-2 border-t border-gray-100 pt-2 dark:border-gray-800"},Zg={class:"text-[11px] font-medium text-gray-500 dark:text-gray-400"},ep={class:"mt-1 list-disc space-y-0.5 pl-4 text-xs leading-relaxed text-gray-600 dark:text-gray-300"},tp={key:4,class:"py-1 text-sm text-gray-600 dark:text-gray-400"},ap={class:"flex items-center gap-2 text-xs font-medium text-gray-600 dark:text-gray-300"},sp={key:0,class:"text-[11px] font-normal text-gray-400 dark:text-gray-500"},np=["innerHTML"],op=["aria-expanded","onClick"],ip={key:0,class:"min-w-0 truncate text-xs text-gray-400 dark:text-gray-500"},rp={class:"ml-auto shrink-0 text-xs text-gray-400 dark:text-gray-500"},lp={class:"mx-px mt-1 overflow-hidden rounded-lg border border-gray-200/60 bg-gray-50/80 dark:border-white/5 dark:bg-white/[0.03]"},up={class:"flex items-center justify-between gap-2 border-b border-gray-200/60 px-3 py-2 dark:border-white/5"},cp={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},dp={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"},mp={class:"ai-tool-result-scroll whitespace-pre-wrap break-words px-3 py-2.5 text-xs leading-relaxed text-gray-700 dark:text-gray-200"},gp=["data-running"],pp={key:0,class:"min-w-0 truncate text-xs text-gray-400 dark:text-gray-500"},fp={key:1,class:"ml-auto shrink-0 text-xs text-gray-400 dark:text-gray-500"},hp={key:3,class:"py-1 text-gray-900 dark:text-gray-100"},vp=["innerHTML"],yp={key:0,class:"ml-1 inline-block h-4 w-1.5 animate-pulse rounded-sm bg-gray-800 dark:bg-gray-200"},xp={key:4,class:"ai-message-actions mt-1 flex items-center gap-2 px-1"},bp={class:"max-w-0 overflow-hidden text-xs whitespace-nowrap text-gray-400 opacity-0 transition-[max-width,opacity] duration-150 group-hover/message:max-w-[12rem] group-hover/message:opacity-100 group-focus-within/message:max-w-[12rem] group-focus-within/message:opacity-100"},kp=32,Ca=le({__name:"ChatMessage",props:{messageId:{},role:{},content:{},timestamp:{},isStreaming:{type:Boolean},processDurationMs:{},contentBlocks:{},showCaptureButton:{type:Boolean},editable:{type:Boolean},activeTool:{}},emits:["edit","fork"],setup(r,{emit:i}){const{t:e,te:s,locale:n}=Ie(),u=ft(),o=r,c=i,m=T(()=>{const O=Ne(o.timestamp);if(O.isSame(Ne(),"day"))return O.format("HH:mm");const G=n.value.startsWith("zh")||n.value.startsWith("ja");return O.isSame(Ne(),"year")?O.format(G?"M月D日 HH:mm":"M/D HH:mm"):O.format(G?"YYYY年M月D日 HH:mm":"YYYY/M/D HH:mm")}),h=T(()=>o.role==="user"),p=T(()=>o.role==="summary"),_=A(!1),y=A(o.content),b=A(null),x=T(()=>h.value&&o.editable&&!o.isStreaming&&!!o.messageId),k=T(()=>!h.value&&!p.value&&!o.isStreaming&&!!o.messageId),I=A(!1),$=new Ka({html:!1,breaks:!0,linkify:!0,typographer:!0});$.renderer.rules.link_open=(O,G,se,qe,ke)=>(O[G].attrSet("target","_blank"),O[G].attrSet("rel","noopener noreferrer"),ke.renderToken(O,G,se));const w=new Map;function C(O){if(!O)return"";const G=w.get(O);if(G!==void 0)return w.delete(O),w.set(O,G),G;const se=$.render(O);if(w.set(O,se),w.size>kp){const qe=w.keys().next().value;qe!==void 0&&w.delete(qe)}return se}function v(O){const G=O?.toLowerCase()||"think";return G==="analysis"?e("ai.chat.message.think.labels.analysis"):G==="reasoning"?e("ai.chat.message.think.labels.reasoning"):G==="reflection"?e("ai.chat.message.think.labels.reflection"):G==="plan_validation"?e("ai.chat.message.think.labels.planValidation"):G==="think"||G==="thought"||G==="thinking"?e("ai.chat.message.think.labels.think"):e("ai.chat.message.think.labels.other",{tag:O})}function S(O){if(!O)return"";const G=(O/1e3).toFixed(1);return e("ai.chat.message.think.duration",{seconds:G})}const V=T(()=>o.content?$.render(q(o.content)):"");fe(()=>o.content,O=>{_.value||(y.value=O)});function B(){const O=b.value;if(!O)return;O.style.height="auto";const G=384,se=Math.min(O.scrollHeight,G);O.style.height=`${se}px`,O.style.overflowY=O.scrollHeight>G?"auto":"hidden"}async function D(){x.value&&(y.value=o.content,_.value=!0,await Fe(),B(),b.value?.focus())}function z(){_.value=!1,y.value=o.content,I.value=!1}function M(){if(!o.messageId)return;const O=y.value.trim();if(!O||O===o.content.trim()){z();return}_.value=!1,c("edit",{messageId:o.messageId,content:O,overwriteSubsequent:I.value}),I.value=!1}function q(O){return Zm(O)}const U=T(()=>{const O=o.contentBlocks||[];return O.filter((G,se)=>G.type==="text"?q(G.text).trim().length>0:G.type==="think"?G.text.trim().length>0:G.type==="error"?!po(O,se,{isStreaming:o.isStreaming}):!0)});function Y(O){return O.type==="think"||O.type==="tool"||O.type==="skill"||O.type==="plan"||O.type==="plan_draft"||O.type==="error"}function te(O){return O.type==="text"}const K=T(()=>!!o.isStreaming&&o.processDurationMs===void 0),j=T(()=>ng(U.value,{isFoldableProcessBlock:Y,isTextBlock:te,mode:K.value?"timeline":"completed"})),N=T(()=>j.value.reduce((O,G)=>O+ug(G,xe),0)),F=T(()=>cg({isStreaming:K.value,liveElapsedMs:0,settledElapsedMs:o.processDurationMs??0,recordedElapsedMs:N.value})),Z=T(()=>ig(j.value)),ue=A({});function ve(O){return O.type==="process"?O.blocks:[O.block]}function ae(O){return`${o.messageId??o.timestamp}:process:${O}`}function re(O){const G=ae(O),se=ue.value[G];return se!==void 0?se:Q(j.value[O])}function H(O){const G=ae(O);ue.value={...ue.value,[G]:!re(O)}}function be(O){return U.value[U.value.length-1]===O}function Te(O){return og(j.value,O,K.value)}function we(O){return O.type==="process"&&!K.value}function ce(O){return O.type!=="process"?0:O.blocks.filter(Y).length}function X(O){const G=ce(O);return e(G===1?"ai.chat.message.process.step":"ai.chat.message.process.steps",{count:G})}function Q(O){return O?.type!=="process"?!1:O.blocks.some(G=>G.type==="error"||G.type==="tool"&&G.tool.status==="error")}function xe(O){return O.type==="think"?O.durationMs??0:O.type==="tool"?O.tool.durationMs??0:0}function Ae(O){if(O.type==="process")for(let G=O.blocks.length-1;G>=0;G-=1){const se=O.blocks[G];if(Y(se))return se}}function ze(O){return O.type==="process"?rg(O.blocks):void 0}function je(O,G){const se=Ae(O);return dg({isActive:Te(G),activeToolName:o.activeTool?.status==="running"?o.activeTool.name:void 0,activeToolProgressPhase:o.activeTool?.status==="running"?o.activeTool.progress?.phase:void 0,lastFoldable:se?{kind:se.type,name:se.type==="tool"?se.tool.name:se.type==="skill"?se.skillName:void 0}:void 0})}function Je(O,G){if(we(O))return Q(O)?e("ai.chat.message.process.failed"):e("ai.chat.message.process.duration",{duration:lg(F.value,n.value)});if(!Te(G)){const qe=ze(O);return qe?v(qe.tag):e("ai.chat.message.process.label")}const se=je(O,G);if(se.type==="tool"){if(o.activeTool?.status==="running"&&o.activeTool.name===se.name)return ye(o.activeTool);const qe=O.type==="process"?O.blocks.find(ke=>ke.type==="tool"&&ke.tool.name===se.name):void 0;return qe?.type==="tool"?ye(qe.tool):se.name}return se.type==="think"?e("ai.chat.message.think.loading"):se.type==="skill"?e("ai.skill.active.label",{name:se.name}):se.type==="plan"?e("ai.chat.message.process.planning"):e("ai.chat.message.process.working")}function Re(O,G){if(we(O))return"";if(Te(G)){const se=je(O,G);if(se.type==="tool"&&se.progressPhase){const qe=`ai.chat.thinking.toolProgress.${se.progressPhase}`;return s(qe)?e(qe):""}return""}return X(O)}function Qe(O,G){if(O.type!=="process"||we(O))return"";if(!Te(G)){const se=ze(O);return se?$a(se.text):""}if(o.activeTool?.status==="running")return"";for(let se=O.blocks.length-1;se>=0;se-=1){const qe=O.blocks[se];if(qe.type==="think"||qe.type==="plan_draft"||qe.type==="text"){const ke=ps(qe.text);if(ke)return ke}}return""}function et(O,G){if(Q(O))return"i-heroicons-exclamation-circle";if(!Te(G))return ze(O)?"i-heroicons-light-bulb":"i-heroicons-queue-list";const se=je(O,G);return se.type==="tool"?"i-heroicons-wrench-screwdriver":se.type==="think"?"i-heroicons-light-bulb":se.type==="skill"?"i-heroicons-bolt":se.type==="plan"?"i-heroicons-clipboard-document-list":"i-heroicons-sparkles"}function Ee(O){return O.type==="think"&&!!o.isStreaming&&!O.durationMs}const pe=T(()=>o.role==="assistant"&&U.value.length>0);function ye(O){return s(`ai.assistant.builtinToolDesc.${O.name}`)?e(`ai.assistant.builtinToolDesc.${O.name}`):O.displayName}function oe(O){return O==="running"?"running":O==="done"?"done":"error"}function ge(O){return O.displayResult??O.result??""}function R(O){return O.status!=="running"&&ge(O).trim().length>0}function ee(O){return!O.displayResult&&(O.result??"").includes("…[truncated]")}async function J(O){const G=ge(O);if(G.trim())try{await navigator.clipboard.writeText(G),u.success(e("ai.chat.message.toolResult.copySuccess"))}catch(se){u.fail(e("ai.chat.message.toolResult.copyFailed"),{description:String(se)})}}function de(O){return O.length===0?e("ai.chat.message.plan.noTools"):O.join(", ")}function Ce(O){try{const G=JSON.parse(O.trim());if(!G||typeof G!="object")return null;const se=G,qe=Array.isArray(se.steps)?se.steps.filter(ke=>!!ke&&typeof ke=="object").map(ke=>({goal:typeof ke.goal=="string"?ke.goal:"",suggestedTools:Array.isArray(ke.suggestedTools)?ke.suggestedTools.filter(he=>typeof he=="string"):[],evidenceNeeded:typeof ke.evidenceNeeded=="string"?ke.evidenceNeeded:""})).filter(ke=>ke.goal):[];return{title:typeof se.title=="string"?se.title:void 0,steps:qe,successCriteria:Array.isArray(se.successCriteria)?se.successCriteria.filter(ke=>typeof ke=="string"):[]}}catch{return null}}const Ue=new Map;function Ye(O){const G=Ue.get(O);if(G)return G;const se=Ce(O);return se&&Ue.set(O,se),se}function Ve(O){if(O.start_time||O.end_time){const G=O.start_time?String(O.start_time):"",se=O.end_time?String(O.end_time):"";return G&&se?`${G} ~ ${se}`:G||se}if(O.year)if(n.value.startsWith("zh")){let G=`${O.year}年`;return O.month&&(G+=`${O.month}月`,O.day&&(G+=`${O.day}日`,O.hour!==void 0&&(G+=` ${O.hour}点`))),G}else{const G=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];let se="";if(O.month){if(se=G[O.month-1]||String(O.month),O.day&&(se+=` ${O.day}`,O.hour!==void 0)){const qe=O.hour,ke=qe>=12?"pm":"am",he=qe%12||12;se+=`, ${he}${ke}`}se+=`, ${O.year}`}else se=String(O.year);return se}return""}function Oe(O){if(!O.params)return"";const G=O.name,se=O.params;if(G==="search_messages"){const ke=se.keywords,he=[];ke&&ke.length>0&&he.push(`${e("ai.chat.message.toolParams.keywords")}: ${ke.join(", ")}`);const Be=Ve(se);return Be&&he.push(`${e("ai.chat.message.toolParams.time")}: ${Be}`),he.join(" | ")}if(G==="get_recent_messages"){const ke=[];ke.push(e("ai.chat.message.toolParams.getMessages",{count:se.limit||100}));const he=Ve(se);return he&&ke.push(he),ke.join(" | ")}if(G==="get_conversation_between"){const ke=[],he=Ve(se);return he&&ke.push(`${e("ai.chat.message.toolParams.time")}: ${he}`),se.limit&&ke.push(e("ai.chat.message.toolParams.limit",{count:se.limit})),ke.join(" | ")}if(G==="get_message_context"){const ke=se.message_ids,he=se.context_size||20;return ke&&ke.length>0?e("ai.chat.message.toolParams.contextWithMessages",{msgCount:ke.length,contextSize:he}):e("ai.chat.message.toolParams.context",{size:he})}if(G==="get_member_stats")return e("ai.chat.message.toolParams.topMembers",{count:se.top_n||10});if(G==="get_time_stats"){const ke=se.type;return e(`ai.chat.message.toolParams.timeStats.${ke}`)||String(se.type)}if(G==="render_chart"){const ke=se.spec&&typeof se.spec=="object"?se.spec:null;return[ke?.title,ke?.type].filter(Be=>typeof Be=="string"&&Be.length>0).join(" | ")}if(G==="get_members")return se.search?`${e("ai.chat.message.toolParams.search")}: ${se.search}`:e("ai.chat.message.toolParams.getMemberList");if(G==="get_member_name_history")return`${e("ai.chat.message.toolParams.memberId")}: ${se.member_id}`;if(G==="semantic_search_current_chat"){const ke=typeof se.query=="string"?se.query:"";return ke?ke.length>40?`“${ke.slice(0,40)}…”`:`“${ke}”`:""}const qe=[];for(const[ke,he]of Object.entries(se)){if(he==null||he==="")continue;const Be=typeof he=="object"?JSON.stringify(he):String(he),me=Be.length>30?Be.substring(0,30)+"...":Be;if(qe.push(`${ke}: ${me}`),qe.length>=3){qe.push("...");break}}return qe.join(" | ")}const nt=T(()=>!pe.value&&o.content.trim()?q(o.content):pe.value?Z.value.map(G=>{if(G.type==="text")return q(G.text);if(G.type==="think"){const se=v(G.tag),qe=G.text.split(`
75
+ `).map(ke=>`> ${ke}`).join(`
76
+ `);return`> ${se}
77
+ >
78
+ ${qe}`}if(G.type==="skill")return`> ${e("ai.skill.active.label",{name:G.skillName})}`;if(G.type==="chart")return`> Chart: ${G.chart.spec.title}`;if(G.type==="evidence"){const se=`> ${e("ai.chat.evidence.title")}`,qe=G.evidence.groups.map(ke=>{const he=e(`ai.chat.evidence.group.${ke.status}`),Be=ke.sources.map(me=>`> - ${me.snippet}`).join(`
79
+ `);return`> [${he}] ${ke.title}
80
+ ${Be}`});return[se,...qe].join(`
81
+ `)}if(G.type==="plan"){const se=G.plan.steps.map((he,Be)=>`${Be+1}. ${he.goal}
82
+ - ${e("ai.chat.message.plan.evidenceNeeded")}: ${he.evidenceNeeded}
83
+ - ${e("ai.chat.message.plan.suggestedTools")}: ${de(he.suggestedTools)}`).join(`
84
+ `),qe=G.plan.successCriteria.map(he=>`- ${he}`).join(`
85
+ `),ke=G.displayText?`${G.displayText.split(`
86
+ `).map(he=>`> ${he}`).join(`
87
+ `)}
88
+
89
+ `:"";return G.displayText?`> ${e("ai.chat.message.plan.label")}: ${G.plan.title}
90
+
91
+ ${ke.trimEnd()}`:`> ${e("ai.chat.message.plan.label")}: ${G.plan.title}
92
+
93
+ ${se}
94
+
95
+ ${e("ai.chat.message.plan.successCriteria")}:
96
+ ${qe}`}if(G.type==="plan_draft")return`> ${e("ai.chat.message.plan.label")}
97
+ >
98
+ ${G.text.split(`
99
+ `).map(se=>`> ${se}`).join(`
100
+ `)}`;if(G.type==="tool"){const se=ye(G.tool),qe=Oe(G.tool),ke=qe?` (${qe})`:"";return`- [${oe(G.tool.status)}] ${se}${ke}`}return""}).filter(G=>G.trim().length>0).join(`
101
+
102
+ `):""),ht=T(()=>!o.isStreaming&&nt.value.trim().length>0);async function Jt(){if(ht.value)try{await navigator.clipboard.writeText(nt.value),u.success(e("ai.chat.message.copy.success"))}catch(O){u.fail(e("ai.chat.message.copy.failed"),{description:String(O)})}}return(O,G)=>{const se=Me,qe=Xe,ke=Rt;return l(),g("div",{class:W(["flex items-start gap-3",[h.value&&!_.value?"flex-row-reverse":"",p.value?"justify-center":""]])},[a("div",{class:W(["group/message",[h.value&&!_.value?"flex max-w-[85%] min-w-0 flex-col items-end":"w-full min-w-0"]])},[p.value?(l(),g("details",mg,[a("summary",gg,[f(se,{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),f(se,{name:"i-heroicons-chevron-right",class:"ml-auto h-3 w-3 transition-transform [[open]>&]:rotate-90"})]),a("div",pg,[a("div",{class:"prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:V.value},null,8,fg),a("p",hg,d(t(e)("ai.chat.message.summary.info")),1)])])):h.value?(l(),g(ie,{key:1},[_.value?(l(),g("div",vg,[ct(a("textarea",{ref_key:"editTextareaRef",ref:b,"onUpdate:modelValue":G[0]||(G[0]=he=>y.value=he),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:[it(Ke(z,["prevent"]),["esc"]),it(Ke(M,["ctrl","prevent"]),["enter"]),it(Ke(M,["meta","prevent"]),["enter"])]},null,40,yg),[[Lt,y.value]]),a("div",xg,[a("label",bg,[ct(a("input",{"onUpdate:modelValue":G[1]||(G[1]=he=>I.value=he),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),[[Yn,I.value]]),ne(" "+d(t(e)("ai.chat.message.edit.overwriteSubsequent")),1)]),a("div",kg,[f(qe,{size:"xs",variant:"ghost",color:"gray",onClick:z},{default:L(()=>[ne(d(t(e)("common.cancel")),1)]),_:1}),f(qe,{size:"xs",color:"primary",onClick:M},{default:L(()=>[ne(d(t(e)("ai.chat.message.edit.submit")),1)]),_:1})])])])):(l(),g("div",_g,[a("div",{class:"prose prose-sm dark:prose-invert max-w-none",innerHTML:V.value},null,8,wg)]))],64)):pe.value?(l(),g("div",{key:2,class:W(K.value?"space-y-2":"space-y-3")},[(l(!0),g(ie,null,_e(j.value,(he,Be)=>(l(),g("div",{key:Be},[he.type==="process"?(l(),g("button",{key:0,type:"button",class:"ai-live-row group/process flex h-6 w-full min-w-0 max-w-full items-center text-left text-sm leading-6 text-gray-500 transition-colors hover:text-gray-700 focus:outline-none focus-visible:bg-gray-50 dark:text-gray-400 dark:hover:text-gray-200 dark:focus-visible:bg-gray-800/30","data-running":Te(Be)||void 0,"aria-expanded":re(Be),onClick:me=>H(Be)},[!we(he)||Q(he)?(l(),g("span",Cg,[re(Be)?(l(),P(se,{key:0,name:"i-heroicons-chevron-down",class:"h-3.5 w-3.5 text-gray-500 dark:text-gray-400"})):(l(),g(ie,{key:1},[f(se,{name:et(he,Be),class:W(["absolute h-3.5 w-3.5 text-gray-400 transition-opacity duration-100 group-hover/process:opacity-0 dark:text-gray-500",[Q(he)?"text-amber-500 dark:text-amber-400":""]])},null,8,["name","class"]),f(se,{name:"i-heroicons-chevron-down",class:"absolute h-3.5 w-3.5 text-gray-500 opacity-0 transition-opacity duration-100 group-hover/process:opacity-100 dark:text-gray-400"})],64))])):E("",!0),a("span",{class:W(["shrink-0",Q(he)?"text-amber-700 dark:text-amber-300":"text-gray-600 dark:text-gray-300"])},d(Je(he,Be)),3),we(he)&&!Q(he)?(l(),P(se,{key:1,name:re(Be)?"i-heroicons-chevron-down":"i-heroicons-chevron-right",class:"ml-1 h-3.5 w-3.5 shrink-0 text-gray-500 dark:text-gray-400"},null,8,["name"])):E("",!0),!re(Be)&&Qe(he,Be)?(l(),g(ie,{key:2},[G[3]||(G[3]=a("span",{class:"mx-2 h-0.5 w-0.5 shrink-0 rounded-full bg-gray-300 dark:bg-gray-600","aria-hidden":"true"},null,-1)),f(gs,{text:Qe(he,Be),"follow-end":Te(Be)},null,8,["text","follow-end"])],64)):E("",!0),Re(he,Be)?(l(),g("span",{key:3,class:W(["shrink-0 text-xs text-gray-400 dark:text-gray-500",[!re(Be)&&Qe(he,Be)?"ml-3":"ml-1.5"]])},[re(Be)||!Qe(he,Be)?(l(),g("span",Sg," · ")):E("",!0),ne(" "+d(Re(he,Be)),1)],2)):E("",!0)],8,$g)):E("",!0),a("div",{class:W(he.type==="process"?"ai-process-fold":""),"data-open":he.type!=="process"||re(Be)?!0:void 0},[a("div",{class:W(he.type==="process"?"ai-process-fold-inner":"")},[a("div",{class:W([he.type==="process"?["ai-process-fold-content",we(he)?"pt-2.5 space-y-1.5":"ml-1.5 pt-1 space-y-0.5 border-l border-gray-200/80 pl-3 dark:border-white/10"]:""])},[(l(!0),g(ie,null,_e(ve(he),(me,ba)=>(l(),g(ie,{key:`${Be}-${ba}`},[me.type==="text"?(l(),g("div",{key:0,class:W(["text-gray-900 dark:text-gray-100",[he.type==="process"?we(he)?"py-2":"py-1 text-xs text-gray-500 dark:text-gray-400":K.value?"py-1":""]])},[a("div",{class:W(["prose dark:prose-invert max-w-none",[he.type==="process"&&!we(he)?"prose-sm leading-relaxed":"ai-chat-prose"]]),innerHTML:C(q(me.text))},null,10,Tg),r.isStreaming&&be(me)?(l(),g("span",Mg)):E("",!0)],2)):me.type==="think"?(l(),P(na,{key:1,class:"w-full text-sm text-gray-500 dark:text-gray-400"},{summary:L(({open:We,toggle:st})=>[a("button",{type:"button",class:W(["ai-live-row group/process-toggle flex w-full min-w-0 cursor-pointer select-none items-center text-left transition-colors hover:text-gray-700 dark:hover:text-gray-300",[we(he)?"h-7 text-sm leading-7":"h-6 text-sm leading-6"]]),"data-running":Ee(me)||void 0,"aria-expanded":We,onClick:st},[f(oa,{icon:"i-heroicons-light-bulb",open:We,class:"mr-1.5"},null,8,["open"]),a("span",zg,d(v(me.tag)),1),!We&&me.tag?.toLowerCase()!=="plan_validation"&&(t($a)(me.text)||Ee(me))?(l(),g("span",qg)):E("",!0),!We&&me.tag?.toLowerCase()!=="plan_validation"?(l(),P(gs,{key:1,text:Ee(me)?t(ps)(me.text):t($a)(me.text),"follow-end":Ee(me)},null,8,["text","follow-end"])):E("",!0),me.durationMs?(l(),g("span",Lg,d(S(me.durationMs)),1)):E("",!0)],10,Ag)]),default:L(()=>[a("div",Dg,[me.tag==="plan_validation"&&Ye(me.text)?(l(),g(ie,{key:0},[Ye(me.text)?.title?(l(),g("div",Eg,d(Ye(me.text)?.title),1)):E("",!0),a("ol",Bg,[(l(!0),g(ie,null,_e(Ye(me.text)?.steps,(We,st)=>(l(),g("li",{key:st,class:"text-gray-600 dark:text-gray-300"},[a("div",Fg,d(We.goal),1),We.evidenceNeeded?(l(),g("div",Rg,d(t(e)("ai.chat.message.plan.evidenceNeeded"))+": "+d(We.evidenceNeeded),1)):E("",!0),a("div",Vg,d(t(e)("ai.chat.message.plan.suggestedTools"))+": "+d(de(We.suggestedTools)),1)]))),128))]),Ye(me.text)?.successCriteria.length?(l(),g("div",Og,[a("div",Pg,d(t(e)("ai.chat.message.plan.successCriteria")),1),a("ul",Ng,[(l(!0),g(ie,null,_e(Ye(me.text)?.successCriteria,(We,st)=>(l(),g("li",{key:st},d(We),1))),128))])])):E("",!0)],64)):(l(),g("div",{key:1,innerHTML:C(me.text)},null,8,jg))])]),_:2},1024)):me.type==="skill"?(l(),g("div",{key:2,class:W(["flex items-center gap-2 font-medium text-gray-600 dark:text-gray-300",[we(he)?"h-7 text-sm leading-7":"py-1 text-xs"]])},[f(se,{name:"i-heroicons-bolt",class:"h-3.5 w-3.5 shrink-0 text-gray-400"}),a("span",null,d(t(e)("ai.skill.active.label",{name:me.skillName})),1)],2)):me.type==="plan"?(l(),P(na,{key:3,class:"group w-full text-sm text-gray-600 dark:text-gray-400"},{summary:L(({open:We,toggle:st})=>[a("button",{type:"button",class:W(["group/process-toggle flex w-full cursor-pointer select-none items-center gap-2 rounded-md text-left text-gray-500 transition-colors hover:bg-gray-50/80 hover:text-gray-700 dark:hover:bg-gray-800/30 dark:hover:text-gray-300",[we(he)?"h-7 text-sm leading-7":"py-1 text-xs"]]),"aria-expanded":We,onClick:st},[f(oa,{icon:"i-heroicons-clipboard-document-list",open:We},null,8,["open"]),a("span",Hg,d(t(e)("ai.chat.message.plan.label"))+" · "+d(me.plan.title),1)],10,Ug)]),default:L(()=>[a("div",Wg,[me.displayText?(l(),g("div",{key:0,class:"prose prose-sm ai-process-detail-content dark:prose-invert max-w-none text-gray-600 dark:text-gray-300",innerHTML:C(me.displayText)},null,8,Kg)):(l(),g("ol",Yg,[(l(!0),g(ie,null,_e(me.plan.steps,(We,st)=>(l(),g("li",{key:st,class:"text-sm leading-6"},[a("div",Gg,d(st+1)+". "+d(We.goal),1),a("div",Qg,d(t(e)("ai.chat.message.plan.evidenceNeeded"))+": "+d(We.evidenceNeeded),1),a("div",Jg,d(t(e)("ai.chat.message.plan.suggestedTools"))+": "+d(de(We.suggestedTools)),1)]))),128))])),me.displayText?E("",!0):(l(),g("div",Xg,[a("div",Zg,d(t(e)("ai.chat.message.plan.successCriteria")),1),a("ul",ep,[(l(!0),g(ie,null,_e(me.plan.successCriteria,(We,st)=>(l(),g("li",{key:st},d(We),1))),128))])]))])]),_:2},1024)):me.type==="plan_draft"?(l(),g("div",tp,[a("div",ap,[f(se,{name:"i-heroicons-clipboard-document-list",class:"h-3.5 w-3.5 shrink-0 text-gray-400"}),a("span",null,d(t(e)("ai.chat.message.plan.label")),1),r.isStreaming?(l(),g("span",sp,d(t(e)("ai.chat.message.process.planning")),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:C(me.text)},null,8,np)])):me.type==="chart"?(l(),P(Cm,{key:5,chart:me.chart},null,8,["chart"])):me.type==="evidence"?(l(),P(Jm,{key:6,evidence:me.evidence},null,8,["evidence"])):me.type==="tool"&&R(me.tool)?(l(),P(na,{key:7,class:"group w-full max-w-full"},{summary:L(({open:We,toggle:st})=>[a("button",{type:"button",class:W(["group/process-toggle flex w-full cursor-pointer select-none items-center gap-2 rounded-md text-left text-gray-500 transition-colors hover:bg-gray-50/80 dark:text-gray-400 dark:hover:bg-gray-800/30",[we(he)?"h-7 text-sm leading-7":"py-1 text-xs",me.tool.status==="error"?"text-amber-700 dark:text-amber-400":""]]),"aria-expanded":We,onClick:st},[f(oa,{icon:me.tool.status==="error"?"i-heroicons-exclamation-circle":"i-heroicons-wrench-screwdriver",open:We,"icon-class":me.tool.status==="error"?"text-amber-500":"text-gray-400 dark:text-gray-500"},null,8,["icon","open","icon-class"]),a("span",{class:W(["shrink-0",[me.tool.status==="error"?"text-amber-700 dark:text-amber-300":"text-gray-600 dark:text-gray-300"]])},d(ye(me.tool)),3),Oe(me.tool)?(l(),g("span",ip,d(Oe(me.tool)),1)):E("",!0),a("span",rp,d(t(e)("ai.chat.message.toolResult.view")),1)],10,op)]),default:L(()=>[a("div",lp,[a("div",up,[a("span",cp,d(t(e)("ai.chat.message.toolResult.title")),1),f(qe,{size:"xs",variant:"ghost",color:"primary",icon:"i-heroicons-document-duplicate",title:t(e)("ai.chat.message.toolResult.copy"),onClick:Ke(We=>J(me.tool),["stop"])},null,8,["title","onClick"])]),ee(me.tool)?(l(),g("div",dp,d(t(e)("ai.chat.message.toolResult.displayTruncated")),1)):E("",!0),a("pre",mp,d(ge(me.tool)),1)])]),_:2},1024)):me.type==="tool"?(l(),g("div",{key:8,class:W(["ai-live-row flex min-w-0 items-center gap-2",[we(he)?"h-7 text-sm leading-7":"py-1 text-xs",me.tool.status==="error"?"text-amber-700 dark:text-amber-400":"text-gray-500 dark:text-gray-400"]]),"data-running":me.tool.status==="running"||void 0},[f(se,{name:me.tool.status==="running"?"i-heroicons-arrow-path":me.tool.status==="error"?"i-heroicons-exclamation-circle":"i-heroicons-wrench-screwdriver",class:W(["h-3.5 w-3.5 shrink-0",[me.tool.status==="running"?"animate-spin text-primary-500":me.tool.status==="error"?"text-amber-500":"text-gray-400"]])},null,8,["name","class"]),a("span",{class:W(["shrink-0",[me.tool.status==="error"?"text-amber-700 dark:text-amber-300":"text-gray-600 dark:text-gray-300"]])},d(ye(me.tool)),3),Oe(me.tool)?(l(),g("span",pp,d(Oe(me.tool)),1)):E("",!0),me.tool.status==="done"&&me.tool.durationMs?(l(),g("span",fp,d(S(me.tool.durationMs)),1)):E("",!0)],10,gp)):me.type==="error"?(l(),P(om,{key:9,error:me.error,compact:he.type==="process"},null,8,["error","compact"])):E("",!0)],64))),128))],2)],2)],10,Ig)]))),128))],2)):(l(),g("div",hp,[a("div",{class:"prose ai-chat-prose dark:prose-invert max-w-none",innerHTML:V.value},null,8,vp),r.isStreaming?(l(),g("span",yp)):E("",!0)])),!p.value&&!r.isStreaming?(l(),g("div",xp,[f(ke,{text:t(e)("ai.chat.message.copy.tooltip"),class:"no-capture"},{default:L(()=>[f(qe,{icon:"i-heroicons-document-duplicate",variant:"ghost",color:"neutral",size:"xs",disabled:!ht.value,onClick:Jt},null,8,["disabled"])]),_:1},8,["text"]),x.value?(l(),P(ke,{key:0,text:t(e)("ai.chat.message.edit.tooltip"),class:"no-capture"},{default:L(()=>[f(qe,{icon:"i-heroicons-pencil-square",variant:"ghost",color:"neutral",size:"xs",onClick:D})]),_:1},8,["text"])):E("",!0),k.value?(l(),P(ke,{key:1,text:t(e)("ai.chat.message.fork.tooltip"),class:"no-capture"},{default:L(()=>[f(qe,{icon:"i-heroicons-arrow-top-right-on-square",variant:"ghost",color:"neutral",size:"xs",onClick:G[2]||(G[2]=he=>c("fork",r.messageId))})]),_:1},8,["text"])):E("",!0),r.showCaptureButton&&!h.value&&!r.isStreaming?(l(),P(Ht,{key:2,size:"xs",color:"neutral",type:"element","target-selector":".qa-pair","markdown-fix":"","capture-frame":"","progressive-narrowing":!0})):E("",!0),a("span",bp,d(m.value),1)])):E("",!0)],2)],2)}}}),_p={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"},wp={class:"truncate"},$p=["value","disabled","placeholder"],Cp=["disabled","title"],Sp=le({__name:"AIChatComposer",props:{modelValue:{},disabled:{type:Boolean,default:!1},status:{default:"ready"},placeholder:{},sendButtonTitle:{},activeSkillName:{default:null},embedded:{type:Boolean,default:!1}},emits:["update:modelValue","submit","stop","keydown","cursorChange","compositionStart","compositionEnd"],setup(r,{expose:i,emit:e}){const s=r,n=e,u=A(null),o=T(()=>s.modelValue.trim().length>0&&!s.disabled);function c(){const y=u.value;if(!y)return;y.style.height="auto";const b=192;y.style.height=`${Math.min(y.scrollHeight,b)}px`,y.style.overflowY=y.scrollHeight>b?"auto":"hidden"}function m(){u.value?.focus()}function h(){const y=s.modelValue.length;return{start:u.value?.selectionStart??y,end:u.value?.selectionEnd??y}}function p(y,b){u.value?.setSelectionRange(y,b)}function _(y){n("update:modelValue",y.target.value)}return fe(()=>s.modelValue,async()=>{await Fe(),c()}),He(()=>{Fe(c)}),i({focus:m,getSelection:h,setSelectionRange:p,syncHeight:c}),(y,b)=>{const x=Me;return l(),g("div",{class:W(["flex flex-col overflow-hidden transition-all",[r.embedded?"bg-transparent":"rounded-2xl bg-white shadow-[0_2px_14px_rgba(0,0,0,0.04)] ring-1 ring-gray-200/60 dark:bg-page-dark dark:ring-white/5",!r.embedded&&r.disabled?"bg-gray-50/50 dark:bg-page-dark/50":"",!r.embedded&&!r.disabled?"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",{class:W(["px-4 pt-2.5 pb-2.5",{relative:!r.embedded}])},[a("div",{class:W(["flex items-start gap-2",{"pr-10":!r.embedded}])},[r.activeSkillName?(l(),g("div",_p,[a("span",wp,"/"+d(r.activeSkillName),1)])):E("",!0),a("textarea",{ref_key:"textareaRef",ref:u,value:r.modelValue,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:r.disabled,placeholder:r.placeholder,onInput:_,onKeydown:b[0]||(b[0]=k=>n("keydown",k)),onClick:b[1]||(b[1]=k=>n("cursorChange")),onKeyup:b[2]||(b[2]=k=>n("cursorChange")),onSelect:b[3]||(b[3]=k=>n("cursorChange")),onCompositionstart:b[4]||(b[4]=k=>n("compositionStart")),onCompositionend:b[5]||(b[5]=k=>n("compositionEnd"))},null,40,$p)],2),r.status==="streaming"?(l(),g("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:b[6]||(b[6]=k=>n("stop"))},[f(x,{name:"i-heroicons-stop-16-solid",class:"h-3.5 w-3.5"})])):(l(),g("button",{key:1,type:"button",class:W(["absolute right-3 bottom-2 flex h-7 w-7 items-center justify-center rounded-full transition-all duration-200",o.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:!o.value,title:r.sendButtonTitle,onClick:b[7]||(b[7]=k=>n("submit"))},[f(x,{name:"i-heroicons-arrow-up-20-solid",class:"h-4 w-4"})],10,Cp))],2)],2)}}}),Ip={key:0,class:"absolute bottom-full left-0 z-20 mb-1.5 w-[240px] max-w-[calc(100vw-2rem)]"},Tp={class:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-overlay dark:border-gray-700 dark:bg-page-dark"},Mp={class:"flex items-center justify-between border-b border-gray-100 px-2.5 py-1.5 dark:border-gray-800"},Ap={class:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400"},zp=["title"],qp={key:0,class:"px-3 py-4 text-center text-xs text-gray-500 dark:text-gray-400"},Lp=["onMouseenter","onClick"],Dp={class:"min-w-0 flex-1"},Ep={class:"flex items-center gap-1.5"},Bp={class:"truncate text-xs font-medium"},Fp={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"},Vp={class:"text-sm font-medium text-gray-700 dark:text-gray-200"},Op={class:"mt-1 text-xs leading-5 text-gray-500 dark:text-gray-400"},Pp=le({__name:"MemberMentionMenu",props:{visible:{type:Boolean},members:{},highlightIndex:{},loading:{type:Boolean}},emits:["select","close","highlight"],setup(r,{emit:i}){const{t:e}=Ie(),s=r,n=i,u=A(null);return fe(()=>[s.visible,s.highlightIndex,s.members.length],async([o,c])=>{if(!o||!u.value)return;await Fe(),u.value.querySelectorAll("[data-mention-item]")[c]?.scrollIntoView({block:"nearest"})}),(o,c)=>{const m=Me;return l(),P(Mt,{name:"mention-menu"},{default:L(()=>[r.visible?(l(),g("div",Ip,[a("div",Tp,[a("div",Mp,[a("div",Ap,[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]=h=>n("close"))},[f(m,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5"})],8,zp)]),s.loading?(l(),g("div",qp,d(t(e)("common.loading")),1)):s.members.length>0?(l(),g("div",{key:1,ref_key:"listRef",ref:u,class:"max-h-72 overflow-y-auto p-1.5"},[(l(!0),g(ie,null,_e(s.members,(h,p)=>(l(),g("button",{key:`${h.memberId}-${h.insertName}`,type:"button","data-mention-item":"",class:W(["flex w-full items-start justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left transition-colors",p===s.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:_=>n("highlight",p),onClick:_=>n("select",h)},[a("div",Dp,[a("div",Ep,[a("span",Bp,"@"+d(h.insertName),1)]),a("p",Fp,d(h.subtitle),1)])],42,Lp))),128))],512)):(l(),g("div",Rp,[a("p",Vp,d(t(e)("ai.chat.input.mentionEmpty")),1),a("p",Op,d(t(e)("ai.chat.input.mentionEmptyHint")),1)]))])])):E("",!0)]),_:1})}}}),Np=gt(Pp,[["__scopeId","data-v-7bc45150"]]),jp={key:0,class:"absolute bottom-full left-0 z-20 mb-1.5 w-[240px] max-w-[calc(100vw-2rem)]"},Up={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"},Wp={class:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400"},Kp=["title"],Yp=["onMouseenter","onClick"],Gp={class:"min-w-0 flex-1"},Qp={class:"flex items-center gap-1.5"},Jp={class:"truncate text-xs font-medium"},Xp={class:"mt-0.5 line-clamp-1 text-xs leading-4 text-gray-500 dark:text-gray-400"},Zp={key:1,class:"px-3 py-4 text-center"},e0={class:"text-sm font-medium text-gray-700 dark:text-gray-200"},t0={class:"mt-1 text-xs leading-5 text-gray-500 dark:text-gray-400"},a0={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"},s0={class:"border-b border-gray-100 px-3 py-2 dark:border-gray-800"},n0={class:"truncate text-sm font-medium text-gray-900 dark:text-gray-100"},o0={class:"mt-0.5 text-xs leading-5 text-gray-500 dark:text-gray-400"},i0={key:0,class:"mt-1 flex items-start gap-1.5 text-[11px] leading-4"},r0={class:"shrink-0 font-medium text-gray-600 dark:text-gray-300"},l0={class:"line-clamp-1 min-w-0 flex-1 text-gray-500 dark:text-gray-400"},u0={key:1,class:"mt-0.5 flex items-start gap-1.5 text-[11px] leading-4"},c0={class:"shrink-0 font-medium text-gray-600 dark:text-gray-300"},d0={class:"line-clamp-1 min-w-0 flex-1 text-gray-500 dark:text-gray-400"},m0={class:"min-h-0 flex-1 overflow-y-auto px-3 py-2"},g0={key:0,class:"text-xs text-gray-400 dark:text-gray-500"},p0=["innerHTML"],f0={key:2,class:"text-xs leading-relaxed text-gray-400 dark:text-gray-500"},h0=le({__name:"SlashCommandMenu",props:{visible:{type:Boolean},skills:{},highlightIndex:{},activeSkillId:{}},emits:["select","close","manage","highlight"],setup(r,{emit:i}){const{t:e,te:s}=Ie(),n=Vt(),u=r,o=i,c=A({}),m=A(""),h=A(!1),p=A(null),_=new Ka({html:!1,breaks:!0,linkify:!0,typographer:!0}),y=T(()=>{if(u.skills.length===0)return null;const $=Math.min(u.highlightIndex,u.skills.length-1);return u.skills[$]??null}),b=T(()=>m.value?_.render(m.value):"");function x($){const w=`ai.assistant.builtinToolDesc.${$}`;return s(w)?e(w):$}const k=T(()=>y.value?.tags.join(" / ")||""),I=T(()=>y.value?.tools.map($=>x($)).join(" / ")||"");return fe(()=>[u.visible,y.value?.id],async([$,w])=>{if(!$||!w){m.value="",h.value=!1;return}if(c.value[w]){m.value=c.value[w],h.value=!1;return}h.value=!0;const v=(await n.getSkillConfig(w))?.prompt?.trim()||"";c.value={...c.value,[w]:v},y.value?.id===w&&(m.value=v,h.value=!1)},{immediate:!0}),fe(()=>[u.visible,u.highlightIndex,u.skills.length],async([$,w])=>{if(!$||!p.value)return;await Fe(),p.value.querySelectorAll("[data-slash-item]")[w]?.scrollIntoView({block:"nearest"})}),($,w)=>{const C=Me;return l(),P(Mt,{name:"slash-menu"},{default:L(()=>[r.visible?(l(),g("div",jp,[a("div",Up,[a("div",Hp,[a("div",Wp,[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:w[0]||(w[0]=v=>o("close"))},[f(C,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5"})],8,Kp)]),u.skills.length>0?(l(),g("div",{key:0,ref_key:"listRef",ref:p,class:"max-h-72 overflow-y-auto p-1.5"},[(l(!0),g(ie,null,_e(u.skills,(v,S)=>(l(),g("button",{key:v.id,type:"button","data-slash-item":"",class:W(["flex w-full items-start justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left transition-colors",S===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:V=>o("highlight",S),onClick:V=>o("select",v)},[a("div",Gp,[a("div",Qp,[a("span",Jp,d(v.name),1),u.activeSkillId===v.id?(l(),P(C,{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",Xp,d(v.description),1)])],42,Yp))),128))],512)):(l(),g("div",Zp,[a("p",e0,d(t(e)("ai.chat.input.slashEmpty")),1),a("p",t0,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:w[1]||(w[1]=v=>o("manage"))},[a("span",null,d(t(e)("ai.chat.input.manageSkills")),1),f(C,{name:"i-heroicons-arrow-top-right-on-square",class:"h-3.5 w-3.5"})])]),u.skills.length>0&&y.value?(l(),g("div",a0,[a("div",s0,[a("p",n0,d(y.value.name),1),a("p",o0,d(y.value.description),1),k.value?(l(),g("div",i0,[a("span",r0,d(t(e)("ai.chat.input.previewTagsLabel")),1),a("span",l0,d(k.value),1)])):E("",!0),I.value?(l(),g("div",u0,[a("span",c0,d(t(e)("ai.chat.input.previewToolsLabel")),1),a("span",d0,d(I.value),1)])):E("",!0)]),a("div",m0,[h.value?(l(),g("div",g0,d(t(e)("common.loading")),1)):b.value?(l(),g("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:b.value},null,8,p0)):(l(),g("div",f0,d(t(e)("ai.chat.input.previewUnavailable")),1))])])):E("",!0)])):E("",!0)]),_:1})}}}),v0=gt(h0,[["__scopeId","data-v-0f67bc21"]]),y0=le({__name:"AIChatInput",props:{sessionId:{},disabled:{type:Boolean},status:{},chatType:{},embedded:{type:Boolean}},emits:["send","stop","manageSkills","skillActivated"],setup(r,{expose:i,emit:e}){const{t:s}=Ie(),n=r,u=e,o=Vt(),{compatibleSkills:c,activeSkill:m,activeSkillId:h,isLoaded:p}=_t(o),_=A(null),y=A(null),b=A(""),x=A([]),k=A([]),I=A(!1),$=A(!1),w=A(""),C=A(0),v=A(!1),S=A(""),V=A(0),B=A(null),D=A(!1),z=A(null),M=A(null),q=A(!1),U=T(()=>b.value.trim().length>0&&!n.disabled),Y=T(()=>m.value&&b.value.trim().length===0?s("ai.chat.input.placeholderWithActiveSkill",{name:m.value.name}):s("ai.chat.input.placeholderWithSlash")),te=T(()=>n.status==="streaming"?"":U.value?s("ai.chat.input.send"):m.value?s("ai.chat.input.needMoreThanSkill"):s("ai.chat.input.needQuestion")),K=T(()=>{const R=new Map;return x.value.forEach(ee=>{const J=ee.groupNickname||ee.accountName||ee.platformId;R.set(J,(R.get(J)??0)+1)}),x.value.map(ee=>{const J=ee.groupNickname||ee.accountName||ee.platformId,de=(R.get(J)??0)>1?`${J}·${ee.platformId}`:J,Ce=[ee.platformId];return ee.aliases.length>0&&Ce.push(ee.aliases.join(" / ")),{memberId:ee.id,platformId:ee.platformId,displayName:J,aliases:[...ee.aliases],mentionText:`@${de}`,insertName:de,subtitle:Ce.join(" · "),searchText:[J,ee.groupNickname||"",ee.accountName||"",ee.platformId,de,ee.aliases.join(" ")].join(" ").toLocaleLowerCase()}})}),j=T(()=>{const R=w.value.trim().toLocaleLowerCase();return R?c.value.filter(ee=>[ee.name,ee.description,ee.tags.join(" ")].join(" ").toLocaleLowerCase().includes(R)):c.value}),N=T(()=>{const R=S.value.trim().toLocaleLowerCase();return R?K.value.filter(ee=>ee.searchText.includes(R)):K.value});function F(){y.value?.syncHeight()}function Z(){y.value?.focus()}async function ue(){if(!n.sessionId){x.value=[];return}I.value=!0;try{const R=await at().getMembers(n.sessionId);x.value=[...R].sort((ee,J)=>J.messageCount-ee.messageCount)}catch(R){console.error("加载 AI @ 成员列表失败:",R),x.value=[]}finally{I.value=!1}}function ve(){$.value=!1,w.value="",C.value=0}function ae(){v.value=!1,S.value="",V.value=0,B.value=null}function re(){/^\s*\/([^\n]*)$/.test(b.value)&&(z.value=b.value),ve()}function H(){B.value&&(M.value=B.value.rawToken),ae()}function be(R){if(n.disabled){ve();return}z.value&&z.value!==R&&(z.value=null);const ee=R.match(/^\s*\/([^\n]*)$/);if(!ee){ve();return}const J=!$.value||w.value!==ee[1];if(w.value=ee[1],z.value===R){$.value=!1;return}$.value=!0,J&&(C.value=0)}function Te(){return y.value?.getSelection()??{start:b.value.length,end:b.value.length}}function we(R){const{start:ee,end:J}=Te();if(ee!==J)return null;const de=R.slice(0,ee),Ce=de.match(/@([^\s@]*)$/);if(!Ce)return null;const Ue=Ce[1],Ye=de.length-Ue.length-1;return{start:Ye,end:ee,rawToken:de.slice(Ye),query:Ue}}function ce(R){if(n.disabled||$.value){ae();return}const ee=we(R);if(M.value&&M.value!==ee?.rawToken&&(M.value=null),!ee){ae();return}const J=!v.value||S.value!==ee.query||B.value?.rawToken!==ee.rawToken;if(S.value=ee.query,B.value={start:ee.start,end:ee.end,rawToken:ee.rawToken},M.value===ee.rawToken){v.value=!1;return}v.value=!0,J&&(V.value=0)}function X(R){if(be(R),$.value){ae();return}ce(R)}function Q(R){k.value=k.value.filter(ee=>R.includes(ee.mentionText))}function xe(){const{start:R,end:ee}=Te();if(R!==ee||R===0)return!1;const J=[...new Set(k.value.map(de=>de.mentionText))].sort((de,Ce)=>Ce.length-de.length);for(const de of J){let Ce=b.value.indexOf(de);for(;Ce!==-1;){const Ue=Ce,Ye=Ce+de.length,Ve=b.value[Ye]===" "?Ye+1:Ye;if(R>Ue&&R<=Ve)return q.value=!0,b.value=b.value.slice(0,Ue)+b.value.slice(Ve),M.value=null,Fe(()=>{F(),Z(),y.value?.setSelectionRange(Ue,Ue),q.value=!1,X(b.value)}),!0;Ce=b.value.indexOf(de,Ce+de.length)}}return!1}function Ae(){o.activateSkill(null),Fe(Z)}function ze(){n.disabled||(h.value&&o.activateSkill(null),q.value=!0,b.value="/",z.value=null,Fe(()=>{F(),Z(),y.value?.setSelectionRange(1,1),q.value=!1,X(b.value)}))}function je(R){n.disabled||(q.value=!0,b.value=R,z.value=null,Fe(()=>{F(),Z();const ee=b.value.length;y.value?.setSelectionRange(ee,ee),q.value=!1,X(b.value)}))}function Je(R){if(n.disabled||!B.value)return;const ee=b.value.slice(0,B.value.start),J=b.value.slice(B.value.end),de=`@${R.insertName}`,Ce=`${ee}${de} ${J}`;k.value=[...k.value.filter(Ue=>Ue.memberId!==R.memberId),{memberId:R.memberId,platformId:R.platformId,displayName:R.displayName,aliases:[...R.aliases],mentionText:de}],q.value=!0,b.value=Ce,M.value=null,ae(),Fe(()=>{const Ue=ee.length+de.length+1;F(),Z(),y.value?.setSelectionRange(Ue,Ue),q.value=!1,X(b.value)})}function Re(){U.value&&(u("send",{content:b.value.trim(),mentionedMembers:[...k.value]}),b.value="",z.value=null,M.value=null,k.value=[],ae(),h.value&&o.activateSkill(null))}function Qe(R){n.disabled||(o.activateSkill(R.id),u("skillActivated",R),b.value="",z.value=null,ve(),Fe(()=>{Z()}))}function et(){re(),u("manageSkills")}function Ee(R){if(!j.value.length)return;const ee=j.value.length;C.value=(C.value+R+ee)%ee}function pe(R){if(!N.value.length)return;const ee=N.value.length;V.value=(V.value+R+ee)%ee}function ye(R){if(R.key==="Backspace"&&b.value.length===0&&h.value){R.preventDefault(),Ae();return}if(R.key==="Backspace"&&xe()){R.preventDefault();return}if(v.value){if(R.key==="ArrowDown"){R.preventDefault(),pe(1);return}if(R.key==="ArrowUp"){R.preventDefault(),pe(-1);return}if(R.key==="Escape"){R.preventDefault(),H();return}if(R.key==="Enter"&&!R.shiftKey&&!D.value||R.key==="Tab"){R.preventDefault();const ee=N.value[V.value];ee&&Je(ee);return}}if($.value){if(R.key==="ArrowDown"){R.preventDefault(),Ee(1);return}if(R.key==="ArrowUp"){R.preventDefault(),Ee(-1);return}if(R.key==="Escape"){R.preventDefault(),re();return}if(R.key==="Enter"&&!R.shiftKey&&!D.value||R.key==="Tab"){R.preventDefault();const ee=j.value[C.value];ee&&Qe(ee);return}}R.key==="Enter"&&!R.shiftKey&&!D.value&&(R.preventDefault(),Re())}function oe(R){if(!$.value&&!v.value||!_.value)return;const ee=R.target;ee instanceof Node&&!_.value.contains(ee)&&(re(),H())}function ge(){q.value||X(b.value)}return fe(()=>n.chatType,R=>{o.setFilterContext(R)},{immediate:!0}),fe(b,async R=>{Q(R),q.value||X(R),await Fe(),F()}),fe(j,R=>{if(R.length===0){C.value=0;return}C.value>=R.length&&(C.value=R.length-1)},{immediate:!0}),fe(N,R=>{if(R.length===0){V.value=0;return}V.value>=R.length&&(V.value=R.length-1)},{immediate:!0}),fe(()=>n.disabled,R=>{R&&(re(),H())}),fe(()=>n.sessionId,()=>{k.value=[],ae(),ue()},{immediate:!0}),He(async()=>{p.value||await o.loadSkills(),await Fe(),F(),document.addEventListener("mousedown",oe)}),Ft(()=>{document.removeEventListener("mousedown",oe)}),i({fillInput:je,openSkillSelector:ze}),(R,ee)=>(l(),g("div",{class:W(["shrink-0",[n.embedded?"":"pt-2 pb-2"]])},[a("div",{ref_key:"rootRef",ref:_,class:W(["w-full max-w-4xl mx-auto",{relative:!n.embedded}])},[f(v0,{visible:$.value,skills:j.value,"highlight-index":C.value,"active-skill-id":t(h),onSelect:Qe,onClose:re,onManage:et,onHighlight:ee[0]||(ee[0]=J=>C.value=J)},null,8,["visible","skills","highlight-index","active-skill-id"]),f(Np,{visible:v.value,members:N.value,"highlight-index":V.value,loading:I.value,onSelect:Je,onClose:H,onHighlight:ee[1]||(ee[1]=J=>V.value=J)},null,8,["visible","members","highlight-index","loading"]),f(Sp,{ref_key:"composerRef",ref:y,modelValue:b.value,"onUpdate:modelValue":ee[2]||(ee[2]=J=>b.value=J),disabled:n.disabled,status:n.status,placeholder:Y.value,"send-button-title":te.value,"active-skill-name":t(m)?.name,embedded:n.embedded,onSubmit:Re,onStop:ee[3]||(ee[3]=J=>u("stop")),onKeydown:ye,onCursorChange:ge,onCompositionStart:ee[4]||(ee[4]=J=>D.value=!0),onCompositionEnd:ee[5]||(ee[5]=J=>D.value=!1)},null,8,["modelValue","disabled","status","placeholder","send-button-title","active-skill-name","embedded"])],2)],2))}}),x0=["data-running"],b0={class:"min-w-0 truncate"},k0={class:"text-gray-600 dark:text-gray-300"},_0={key:0,class:"text-gray-400 dark:text-gray-500"},w0=le({__name:"AIThinkingIndicator",props:{currentToolStatus:{},agentStatus:{}},setup(r){const{t:i,te:e}=Ie();function s(y,b){const x=`ai.assistant.builtinToolDesc.${y}`;return e(x)?i(x):b||y}function n(y){if(!y)return"";const b=`ai.chat.thinking.toolProgress.${y.phase}`;return e(b)?i(b):""}const u=r,o=T(()=>u.agentStatus?.phase==="compressing"),c=T(()=>!o.value&&!u.currentToolStatus),m=T(()=>o.value?i("ai.chat.thinking.compressing"):u.currentToolStatus?s(u.currentToolStatus.name,u.currentToolStatus.displayName):i("ai.chat.thinking.analyzing")),h=T(()=>o.value||!u.currentToolStatus?"":u.currentToolStatus.status==="running"?n(u.currentToolStatus.progress):u.currentToolStatus.status==="done"?i("ai.chat.thinking.processingResult"):""),p=T(()=>o.value||u.currentToolStatus?.status==="running"?"i-heroicons-arrow-path":u.currentToolStatus?.status==="error"?"i-heroicons-exclamation-circle":u.currentToolStatus?"i-heroicons-wrench-screwdriver":"i-heroicons-sparkles"),_=T(()=>o.value||u.currentToolStatus?.status==="running");return(y,b)=>{const x=Me;return l(),g("div",{class:"ai-live-row flex h-6 min-w-0 items-center gap-1.5 text-sm leading-6 text-gray-500 dark:text-gray-400","data-running":c.value||void 0},[f(x,{name:p.value,class:W(["h-3.5 w-3.5 shrink-0 text-gray-400 dark:text-gray-500",[_.value?"animate-spin text-primary-500 dark:text-primary-400":""]])},null,8,["name","class"]),a("span",b0,[a("span",k0,d(m.value),1),h.value?(l(),g("span",_0,"· "+d(h.value),1)):E("",!0)])],8,x0)}}}),$0={class:"pointer-events-none relative z-20 flex items-center justify-between"},C0={class:"pointer-events-auto flex items-center gap-1"},S0=["disabled"],I0={class:"max-w-[160px] truncate"},T0=["title"],M0={class:"w-40 py-1"},A0={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},z0=["onClick"],q0={class:"pointer-events-auto flex items-center gap-1"},L0=["title"],D0=["aria-label"],E0={viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true"},B0=["stroke-dasharray"],F0={class:"space-y-0.5 whitespace-nowrap text-xs"},R0={key:0},Sa=5.5,V0=le({__name:"ChatStatusBar",props:{sessionTokenUsage:{},agentStatus:{},estimatedContextTokens:{}},setup(r){const{t:i}=Ie(),e=zt(),s=r,n=fa(),u=Gn(),{defaultAssistantConfig:o,isLoading:c}=_t(u),m=T(()=>s.agentStatus?i(`ai.chat.statusBar.agent.phase.${s.agentStatus.phase}`):""),h=T(()=>s.agentStatus?i(`ai.chat.statusBar.agent.phaseShort.${s.agentStatus.phase}`):""),p=T(()=>{const K=s.agentStatus?.phase;return K==="compressing"||K==="preparing"||K==="thinking"||K==="tool_running"||K==="responding"}),_=T(()=>{const K=s.agentStatus?.phase;return p.value||K==="error"});function y(K){return Number.isFinite(K)?new Intl.NumberFormat().format(Math.max(0,Math.round(K))):"0"}function b(K){const j=Math.max(0,Math.round(K));return j>=1e6?`${(j/1e6).toFixed(1).replace(/\.0$/,"")}M`:j>=1e3?`${(j/1e3).toFixed(1).replace(/\.0$/,"")}k`:String(j)}const x=T(()=>y(s.sessionTokenUsage.totalTokens)),k=T(()=>b(s.sessionTokenUsage.totalTokens)),I=T(()=>s.sessionTokenUsage.cacheReadTokens>0),$=T(()=>b(s.sessionTokenUsage.cacheReadTokens)),w=T(()=>s.agentStatus?.contextTokens?s.agentStatus.contextTokens:s.estimatedContextTokens&&s.estimatedContextTokens>0?s.estimatedContextTokens:0),C=T(()=>{const K=o.value,j=u.defaultAssistant?.modelId||K?.model;return!K||!j?128e3:(u.getModelById(K.provider,j)||u.findModelAcrossProviders(j))?.contextWindow??128e3}),v=T(()=>w.value<=0||C.value<=0?0:Math.min(100,Math.round(w.value/C.value*100))),S=2*Math.PI*Sa,V=T(()=>`${S*v.value/100} ${S}`),B=T(()=>s.agentStatus?[`${i("ai.chat.statusBar.agent.label")}: ${m.value}`,`${i("ai.chat.statusBar.agent.contextTokens")}: ${y(s.agentStatus.contextTokens)}`,`${i("ai.chat.statusBar.tokenUsageTitle")}: ${x.value}`].join(`
103
+ `):"");function D(){e.openSettings("ai","defaultModel")}const z=A(!1),M=T(()=>{const K=o.value,j=u.defaultAssistant?.modelId||K?.model;return!K?.provider||!j?[]:cr(K.provider,j)}),q=T(()=>M.value.length>0),U=T(()=>{const K=u.defaultAssistant;return!K?.configId||!K?.modelId?"default":n.getThinkingLevel(K.configId,K.modelId)??"default"});function Y(K){const j=u.defaultAssistant;!j?.configId||!j?.modelId||(n.setThinkingLevel(j.configId,j.modelId,K),z.value=!1)}const te=T(()=>i(`ai.chat.statusBar.thinking.level.${U.value}`));return(K,j)=>{const N=Me,F=Ss,Z=Rt;return l(),g("div",$0,[a("div",C0,[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(c),onClick:D},[f(N,{name:"i-heroicons-cpu-chip",class:"h-3.5 w-3.5"}),a("span",I0,d(t(u).defaultAssistant?.modelId?t(u).getModelById(t(o)?.provider??"",t(u).defaultAssistant.modelId)?.name||t(u).defaultAssistant.modelId:t(i)("ai.chat.statusBar.model.notConfigured")),1)],8,S0),q.value?(l(),P(F,{key:0,open:z.value,"onUpdate:open":j[0]||(j[0]=ue=>z.value=ue),ui:{content:"z-[80] p-0"}},{content:L(()=>[a("div",M0,[a("div",A0,d(t(i)("ai.chat.statusBar.thinking.title")),1),(l(!0),g(ie,null,_e(M.value,ue=>(l(),g("button",{key:ue,class:W(["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",U.value===ue?"text-primary-600 dark:text-primary-400":"text-gray-700 dark:text-gray-300"]),onClick:ve=>Y(ue)},[f(N,{name:U.value===ue?"i-heroicons-check-circle-solid":"i-heroicons-light-bulb",class:W(["h-4 w-4 shrink-0",U.value===ue?"text-primary-500":"text-gray-400"])},null,8,["name","class"]),a("span",null,d(t(i)(`ai.chat.statusBar.thinking.level.${ue}`)),1)],10,z0))),128))])]),default:L(()=>[a("button",{class:W(["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",U.value==="default"||U.value==="off"?"text-gray-400 dark:text-gray-500":"text-primary-500 dark:text-primary-400"]),title:t(i)("ai.chat.statusBar.thinking.tooltip")},[f(N,{name:"i-heroicons-light-bulb",class:"h-3.5 w-3.5"}),a("span",null,d(te.value),1)],10,T0)]),_:1},8,["open"])):E("",!0)]),a("div",q0,[_.value?(l(),g("div",{key:0,class:"hidden shrink-0 items-center gap-1.5 px-1.5 py-1 text-[11px] text-gray-400 lg:flex dark:text-gray-500",title:B.value},[a("span",{class:W(["h-1.5 w-1.5 rounded-full",[r.agentStatus?.phase==="error"?"bg-amber-500":"bg-primary-500 animate-pulse"]])},null,2),a("span",null,d(h.value),1)],8,L0)):E("",!0),w.value>0?(l(),P(Z,{key:1,ui:{content:"h-auto py-1.5"}},{content:L(()=>[a("div",F0,[a("div",null,d(t(i)("ai.chat.statusBar.agent.contextTokens"))+": "+d(b(w.value))+" / "+d(b(C.value)),1),a("div",null,d(t(i)("ai.chat.statusBar.tokenUsageTitle"))+": "+d(k.value),1),I.value?(l(),g("div",R0,d(t(i)("ai.chat.statusBar.cacheHit"))+": "+d($.value),1)):E("",!0)])]),default:L(()=>[a("div",{class:"hidden h-7 w-7 shrink-0 place-items-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 md:grid dark:text-gray-500 dark:hover:bg-gray-800","aria-label":`${t(i)("ai.chat.statusBar.agent.contextTokens")} ${v.value}%`},[(l(),g("svg",E0,[a("circle",{cx:"7",cy:"7",r:Sa,fill:"none",class:"stroke-gray-300 dark:stroke-gray-700","stroke-width":"2"}),a("circle",{cx:"7",cy:"7",r:Sa,fill:"none",class:"stroke-gray-400 transition-[stroke-dasharray] duration-300 dark:stroke-gray-500","stroke-width":"2","stroke-linecap":"round","stroke-dasharray":V.value,transform:"rotate(-90 7 7)"},null,8,B0)]))],8,D0)]),_:1})):E("",!0)])])}}}),O0={class:"flex shrink-0 items-center gap-1"},P0=["title","disabled"],N0=["title","disabled"],j0=le({__name:"ChatHeaderActions",props:{currentAIChatId:{},currentMessages:{},fallbackTitle:{}},setup(r){const i=r,{t:e}=Ie(),s=ft(),n=fa(),{aiGlobalSettings:u}=_t(n),o=A(!1),c=A(!1),m=T(()=>qa(i.currentMessages??[])),h=T(()=>!!i.currentAIChatId||fr(i.currentMessages??[]));function p(){return{createdAt:e("ai.chat.conversation.export.createdAt"),user:e("ai.chat.conversation.export.user"),assistant:e("ai.chat.conversation.export.assistant")}}function _(x){return x.map(k=>({...k,timestamp:k.timestamp*1e3}))}async function y(){if(!(o.value||!h.value)){o.value=!0;try{const x=u.value.exportFormat||"markdown",k=p();let I=i.fallbackTitle||e("ai.chat.conversation.newChat"),$=m.value[0]?.timestamp??Date.now(),w=m.value;if(i.currentAIChatId){const[v,S]=await Promise.all([ot().getAIChat(i.currentAIChatId),ot().getMessages(i.currentAIChatId)]);v&&(I=v.title||I,$=v.createdAt*1e3);const V=qa(_(S));V.length>0&&(w=V)}if(w.length===0){s.warn(e("ai.chat.conversation.export.noMessages"));return}const C=await xr(I,w,$,x,k);if(C.success&&C.filePath){const v=C.filePath.split("/").pop()||C.filePath,S=C.filePath;s.add({title:e("common.exportSuccess"),description:v,color:"primary",actions:[{label:e("common.openFolder"),onClick:()=>{Ts().showInFolder(S)}}]})}else s.fail(e("common.exportFailed"),{description:C.error})}catch(x){console.error("Failed to export AI conversation:",x),s.fail(e("common.exportFailed"),{description:String(x)})}finally{o.value=!1}}}async function b(){if(!c.value){c.value=!0;try{const x=await ot().showAiLogFile();x?.success||s.fail(e("ai.chat.statusBar.log.openFailed"),{description:x?.error||e("ai.chat.statusBar.log.openFailedDesc")})}catch(x){console.error("Failed to open AI log file:",x),s.fail(e("ai.chat.statusBar.log.openFailed"),{description:String(x)})}finally{c.value=!1}}}return(x,k)=>{const I=Me;return l(),g("div",O0,[a("button",{type:"button",class:"flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 disabled:cursor-not-allowed disabled:opacity-60 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",title:t(e)("ai.chat.statusBar.export.title"),disabled:o.value||!h.value,onClick:y},[f(I,{name:"i-heroicons-arrow-down-tray",class:"h-3.5 w-3.5"}),a("span",null,d(t(e)("ai.chat.statusBar.export.label")),1)],8,P0),a("button",{type:"button",class:"flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 disabled:cursor-not-allowed disabled:opacity-60 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",title:t(e)("ai.chat.statusBar.log.title"),disabled:c.value,onClick:b},[f(I,{name:"i-heroicons-document-text",class:"h-3.5 w-3.5"}),a("span",null,d(t(e)("ai.chat.statusBar.log.label")),1)],8,N0)])}}}),U0={class:"assistant-bar-wrapper flex justify-center"},H0=["onClick"],W0={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"},K0={class:"custom-scrollbar max-h-60 space-y-0.5 overflow-y-auto"},Y0=["onClick"],G0={class:"truncate font-medium"},ea=4,Q0=le({__name:"AssistantInlineBar",props:{chatType:{},locale:{},selectedId:{}},emits:["select","market"],setup(r,{emit:i}){const e=r,s=i,n=A(!1),u=A(null);function o(v){s("select",v),n.value=!1}function c(){x.value.length!==0&&(n.value=!n.value)}function m(v){if(!n.value||!u.value)return;const S=v.target;S instanceof Node&&!u.value.contains(S)&&(n.value=!1)}const h=Gt(),{filteredAssistants:p,isLoaded:_}=_t(h),y=T(()=>{const v=Qn(e.locale);return[...p.value].sort((S,V)=>S.id===v?-1:V.id===v?1:0)}),b=T(()=>{const v=y.value;if(v.length<=ea)return v;const S=v.findIndex(V=>V.id===e.selectedId);if(S!==-1&&S>=ea-1){const V=v.slice(0,ea-1),B=v[S];return[...V,B]}return v.slice(0,ea)}),x=T(()=>{const v=new Set(b.value.map(S=>S.id));return y.value.filter(S=>!v.has(S.id))});fe(()=>[e.chatType,e.locale],([v,S])=>{h.setFilterContext(v,S)},{immediate:!0});const k=A([]),I=A(null);let $=null;const w=A({width:"0px",transform:"translateX(0px)",opacity:0}),C=async()=>{await Fe();const v=b.value.findIndex(S=>S.id===e.selectedId);if(v!==-1&&k.value[v]){const S=k.value[v];w.value={width:`${S.offsetWidth+6}px`,transform:`translateX(${S.offsetLeft-3}px)`,opacity:1}}else w.value.opacity=0};return fe(()=>[e.selectedId,b.value],()=>{C()},{deep:!0}),He(async()=>{_.value||await h.loadAssistants(),C(),document.addEventListener("mousedown",m),typeof ResizeObserver<"u"&&I.value&&($=new ResizeObserver(()=>{C()}),$.observe(I.value))}),dt(()=>{document.removeEventListener("mousedown",m),$&&$.disconnect()}),(v,S)=>{const V=Me;return l(),g("div",U0,[a("div",{ref_key:"containerRef",ref:I,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:mt(w.value)},null,4),(l(!0),g(ie,null,_e(b.value,(B,D)=>(l(),g("button",{key:B.id,ref_for:!0,ref:z=>{z&&(k.value[D]=z)},class:W(["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===B.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:z=>s("select",B.id)},d(B.name),11,H0))),128)),x.value.length>0?(l(),g("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},[f(V,{name:"i-heroicons-ellipsis-horizontal",class:"h-5 w-5"})]),n.value?(l(),g("div",W0,[a("div",K0,[S[1]||(S[1]=a("p",{class:"px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500"}," 更多助手 ",-1)),(l(!0),g(ie,null,_e(x.value,B=>(l(),g("button",{key:B.id,type:"button",class:W(["flex w-full items-center justify-between rounded-md px-2.5 py-1.5 text-left text-sm transition-colors",[r.selectedId===B.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(B.id)},[a("span",G0,d(B.name),1),r.selectedId===B.id?(l(),P(V,{key:0,name:"i-heroicons-check",class:"h-4 w-4 shrink-0"})):E("",!0)],10,Y0))),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:S[0]||(S[0]=B=>s("market"))},[f(V,{name:"i-heroicons-plus",class:"h-[18px] w-[18px]"})])],512)])}}}),J0=gt(Q0,[["__scopeId","data-v-169115ce"]]),X0={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"}},Z0=["id","value","name","rows","placeholder","disabled","required"],ef=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:i,emit:e}){const s=r,n=e,u=ma(),o=Va("textarea",s),c=It(o,"modelValue",n,{defaultValue:o.defaultValue}),m=Pa(),{emitFormFocus:h,emitFormBlur:p,emitFormInput:_,emitFormChange:y,size:b,color:x,id:k,name:I,highlight:$,disabled:w,ariaAttrs:C}=Oa(s,{deferInputValidation:!0}),{isLeading:v,isTrailing:S,leadingIconName:V,trailingIconName:B}=Na(o),D=T(()=>Dt({extend:Dt(X0),...m.ui?.textarea||{}})({color:x.value??o.color,variant:o.variant,size:b?.value??o.size,loading:o.loading,highlight:$.value??o.highlight,fixed:o.fixed,autoresize:o.autoresize,leading:v.value||!!o.avatar||!!u.leading,trailing:S.value||!!u.trailing})),z=Nt("textareaRef");function M(j){o.modelModifiers?.trim&&(typeof j=="string"||j===null||j===void 0)&&(j=j?.trim()??null),o.modelModifiers?.number&&(j=Cs(j)),o.modelModifiers?.nullable&&(j||=null),o.modelModifiers?.optional&&!o.modelModifiers?.nullable&&j!==null&&(j||=void 0),c.value=j,_()}function q(j){K(),o.modelModifiers?.lazy||M(j.target.value)}function U(j){const N=j.target.value;o.modelModifiers?.lazy&&M(N),o.modelModifiers?.trim&&(j.target.value=N.trim()),y(),n("change",j)}function Y(j){p(),n("blur",j)}function te(){o.autofocus&&z.value?.focus()}function K(){if(o.autoresize&&z.value){z.value.rows=o.rows;const j=z.value.style.overflow;z.value.style.overflow="hidden";const N=window.getComputedStyle(z.value),F=Number.parseInt(N.paddingTop),Z=Number.parseInt(N.paddingBottom),ue=F+Z,ve=Number.parseInt(N.lineHeight),{scrollHeight:ae}=z.value,re=(ae-ue)/ve;re>o.rows&&(z.value.rows=o.maxrows?Math.min(re,o.maxrows):re),z.value.style.overflow=j}}return fe(c,()=>{Fe(K)}),He(()=>{setTimeout(()=>{te()},o.autofocusDelay),setTimeout(async()=>{await Fe(),K()},o.autoresizeDelay)}),i({textareaRef:z,autoResize:K}),(j,N)=>(l(),P(t(tt),{as:t(o).as,"data-slot":"root",class:W(D.value.root({class:[t(o).ui?.root,t(o).class]}))},{default:L(()=>[a("textarea",Pe({id:t(k),ref_key:"textareaRef",ref:z,value:t(c),name:t(I),rows:t(o).rows,placeholder:t(o).placeholder,"data-slot":"base",class:D.value.base({class:t(o).ui?.base}),disabled:t(w),required:t(o).required},{...j.$attrs,...t(C)},{onInput:q,onBlur:Y,onChange:U,onFocus:N[0]||(N[0]=(...F)=>t(h)&&t(h)(...F))}),null,16,Z0),$e(j.$slots,"default",{ui:D.value}),t(v)||t(o).avatar||u.leading?(l(),g("span",{key:0,"data-slot":"leading",class:W(D.value.leading({class:t(o).ui?.leading}))},[$e(j.$slots,"leading",{ui:D.value},()=>[t(v)&&t(V)?(l(),P(Me,{key:0,name:t(V),"data-slot":"leadingIcon",class:W(D.value.leadingIcon({class:t(o).ui?.leadingIcon}))},null,8,["name","class"])):t(o).avatar?(l(),P(la,Pe({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(S)||u.trailing?(l(),g("span",{key:1,"data-slot":"trailing",class:W(D.value.trailing({class:t(o).ui?.trailing}))},[$e(j.$slots,"trailing",{ui:D.value},()=>[t(B)?(l(),P(Me,{key:0,name:t(B),"data-slot":"trailingIcon",class:W(D.value.trailingIcon({class:t(o).ui?.trailingIcon}))},null,8,["name","class"])):E("",!0)])],2)):E("",!0)]),_:3},8,["as","class"]))}}),tf={class:"p-6"},af={class:"mb-4 flex items-start justify-between gap-3"},sf={class:"min-w-0"},nf={class:"text-lg font-semibold text-gray-900 dark:text-white"},of={key:0,class:"mt-1 text-xs text-amber-600 dark:text-amber-400"},rf={key:0,class:"flex items-center justify-center py-12"},lf={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},uf={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"},cf={class:"max-h-[500px] overflow-y-auto pr-1"},df={class:"space-y-5"},mf={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},gf={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},pf={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},ff={class:"flex flex-wrap gap-2"},hf=["disabled","onClick"],vf={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},yf={class:"flex flex-wrap gap-2"},xf=["disabled","onClick"],bf={class:"mt-1 text-[10px] text-gray-400"},kf={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},_f={class:"space-y-2"},wf={key:0,class:"flex items-center gap-2"},$f={class:"space-y-5"},Cf={class:"mb-1 text-sm font-medium text-gray-700 dark:text-gray-300"},Sf={class:"mb-2.5 text-[10px] text-gray-400"},If={class:"grid grid-cols-2 gap-1.5"},Tf={class:"min-w-0"},Mf={class:"truncate text-xs font-medium text-gray-600 dark:text-gray-400"},Af={class:"truncate text-[10px] text-gray-400 dark:text-gray-500"},zf={class:"mb-1 flex items-center justify-between"},qf={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Lf={key:0,class:"flex gap-2"},Df={class:"mb-2.5 text-[10px] text-gray-400"},Ef={class:"grid grid-cols-2 gap-1.5"},Bf=["checked","disabled","onChange"],Ff={class:"min-w-0"},Rf={class:"truncate text-xs font-medium text-gray-800 dark:text-gray-200"},Vf={class:"truncate text-[10px] text-gray-500 dark:text-gray-400"},Of={class:"mt-6 flex items-center justify-between"},Pf={class:"flex gap-2"},Nf=le({__name:"AssistantConfigModal",props:{open:{type:Boolean},assistantId:{},readonly:{type:Boolean},scrollToSection:{}},emits:["update:open","saved","created"],setup(r,{emit:i}){const{t:e}=Ie(),s=r,n=i,u=ft(),o=Gt(),c=A(!1),m=A(!1),h=A(null),p=A(!1),_=A("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")}]),b=[{value:"zh",label:"简体中文"},{value:"en",label:"English"},{value:"ja",label:"日本語"}],x=T(()=>o.builtinToolCatalog.filter(N=>N.category==="core").map(N=>({name:N.name,description:e(`ai.assistant.builtinToolDesc.${N.name}`)}))),k=T(()=>o.builtinToolCatalog.filter(N=>N.category==="analysis").map(N=>({name:N.name,description:e(`ai.assistant.builtinToolDesc.${N.name}`)}))),I=A({name:"",systemPrompt:"",presetQuestions:[],applicableChatType:"",supportedLocales:[],allowedBuiltinTools:[]}),$=A(""),w=A(null),C=T(()=>I.value.allowedBuiltinTools.length);He(async()=>{o.builtinToolCatalog.length===0&&await o.loadBuiltinToolCatalog()}),fe(()=>[s.open,s.assistantId],async([N,F])=>{N&&(_.value="basic",F?(p.value=!1,await S(F)):s.readonly||(p.value=!0,v()),s.scrollToSection==="presetQuestions"&&(await Fe(),setTimeout(()=>{w.value?.scrollIntoView({behavior:"smooth",block:"center"})},100)))},{immediate:!0});function v(){h.value={id:"",name:"",systemPrompt:"",presetQuestions:[],allowedBuiltinTools:[],applicableChatTypes:[],supportedLocales:[]},I.value={name:"",systemPrompt:"",presetQuestions:[],applicableChatType:"",supportedLocales:[],allowedBuiltinTools:[]},c.value=!1}async function S(N){c.value=!0;try{h.value=await o.getAssistantConfig(N),h.value&&(I.value={name:h.value.name,systemPrompt:h.value.systemPrompt,presetQuestions:[...h.value.presetQuestions],applicableChatType:h.value.applicableChatTypes?.[0]||"",supportedLocales:[...h.value.supportedLocales||[]],allowedBuiltinTools:[...h.value.allowedBuiltinTools||[]]})}catch(F){console.error("[AssistantConfigModal] Failed to load config:",F),u.fail(e("ai.assistant.toast.loadFailed"),{description:String(F)})}finally{c.value=!1}}async function V(){m.value=!0;try{const N={name:I.value.name,systemPrompt:I.value.systemPrompt,presetQuestions:[...I.value.presetQuestions],applicableChatTypes:I.value.applicableChatType?[I.value.applicableChatType]:[],supportedLocales:[...I.value.supportedLocales],allowedBuiltinTools:[...I.value.allowedBuiltinTools]};if(p.value){const F=await o.createAssistant(N);F.success?(u.success(e("ai.assistant.toast.createSuccess")),n("created",F.id),j()):u.fail(e("ai.assistant.toast.createFailed"),{description:F.error||e("ai.assistant.toast.unknownError")})}else{if(!s.assistantId)return;const F=await o.updateAssistant(s.assistantId,N);F.success?(u.success(e("ai.assistant.toast.saveSuccess")),n("saved"),j()):u.fail(e("ai.assistant.toast.saveFailed"),{description:F.error||e("ai.assistant.toast.unknownError")})}}catch(N){console.error("[AssistantConfigModal] Save failed:",N),u.fail(e("ai.assistant.toast.saveFailed"),{description:String(N)})}finally{m.value=!1}}async function B(){if(!(!s.assistantId||!h.value?.builtinId)){m.value=!0;try{const N=await o.resetAssistant(s.assistantId);N.success?(u.success(e("ai.assistant.toast.resetSuccess")),await S(s.assistantId),n("saved")):u.fail(e("ai.assistant.toast.resetFailed"),{description:N.error||e("ai.assistant.toast.unknownError")})}catch(N){u.fail(e("ai.assistant.toast.resetFailed"),{description:String(N)})}finally{m.value=!1}}}function D(){const N=$.value.trim();N&&!I.value.presetQuestions.includes(N)&&(I.value.presetQuestions.push(N),$.value="")}function z(N){I.value.presetQuestions.splice(N,1)}function M(N){const F=I.value.allowedBuiltinTools.indexOf(N);F>=0?I.value.allowedBuiltinTools.splice(F,1):I.value.allowedBuiltinTools.push(N)}function q(N){return I.value.allowedBuiltinTools.includes(N)}function U(){I.value.allowedBuiltinTools=k.value.map(N=>N.name)}function Y(){I.value.allowedBuiltinTools=[]}function te(N){I.value.applicableChatType=N}function K(N){const F=I.value.supportedLocales.indexOf(N);F>=0?I.value.supportedLocales.splice(F,1):I.value.supportedLocales.push(N)}function j(){n("update:open",!1)}return(N,F)=>{const Z=Xe,ue=Me,ve=Yt,ae=ef,re=lt;return l(),P(re,{open:r.open,ui:{content:"sm:max-w-2xl z-100"},"onUpdate:open":F[5]||(F[5]=H=>n("update:open",H))},{content:L(()=>[a("div",tf,[a("div",af,[a("div",sf,[a("h2",nf,d(r.readonly?t(e)("ai.assistant.config.viewTitle"):p.value?t(e)("ai.assistant.config.createTitle"):t(e)("ai.assistant.config.editTitle")),1),r.readonly?E("",!0):(l(),g("p",of,d(t(e)("ai.assistant.config.betaWarning")),1))]),f(Z,{icon:"i-heroicons-x-mark",variant:"ghost",size:"sm",class:"shrink-0",onClick:j})]),c.value?(l(),g("div",rf,[f(ue,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):h.value?(l(),g(ie,{key:1},[a("div",lf,[a("button",{class:W(["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:F[0]||(F[0]=H=>_.value="basic")},d(t(e)("ai.assistant.config.tabs.basic")),3),a("button",{class:W(["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:F[1]||(F[1]=H=>_.value="tools")},[ne(d(t(e)("ai.assistant.config.tabs.tools"))+" ",1),C.value>0?(l(),g("span",uf,d(C.value),1)):E("",!0)],2)]),a("div",cf,[ct(a("div",df,[a("div",null,[a("label",mf,d(t(e)("ai.assistant.config.name")),1),f(ve,{modelValue:I.value.name,"onUpdate:modelValue":F[2]||(F[2]=H=>I.value.name=H),class:"w-full",disabled:r.readonly},null,8,["modelValue","disabled"])]),a("div",null,[a("label",gf,d(t(e)("ai.assistant.config.systemPrompt")),1),f(ae,{modelValue:I.value.systemPrompt,"onUpdate:modelValue":F[3]||(F[3]=H=>I.value.systemPrompt=H),rows:5,autoresize:"",class:"w-full font-mono text-sm",disabled:r.readonly},null,8,["modelValue","disabled"])]),a("div",null,[a("label",pf,d(t(e)("ai.assistant.config.chatType")),1),a("div",ff,[(l(!0),g(ie,null,_e(y.value,H=>(l(),g("button",{key:H.value,type:"button",class:W(["rounded-lg border px-3 py-1.5 text-xs transition-colors",I.value.applicableChatType===H.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:be=>te(H.value)},d(H.label),11,hf))),128))])]),a("div",null,[a("label",vf,d(t(e)("ai.assistant.config.locale")),1),a("div",yf,[(l(),g(ie,null,_e(b,H=>a("button",{key:H.value,type:"button",class:W(["rounded-lg border px-3 py-1.5 text-xs transition-colors",I.value.supportedLocales.includes(H.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:be=>K(H.value)},d(H.label),11,xf)),64))]),a("p",bf,d(t(e)("ai.assistant.config.localeHint")),1)]),a("div",{ref_key:"presetQuestionsRef",ref:w},[a("label",kf,d(t(e)("ai.assistant.config.presetQuestions")),1),a("div",_f,[(l(!0),g(ie,null,_e(I.value.presetQuestions,(H,be)=>(l(),g("div",{key:be,class:"flex items-center gap-2"},[f(ve,{modelValue:I.value.presetQuestions[be],"onUpdate:modelValue":Te=>I.value.presetQuestions[be]=Te,class:"min-w-0 flex-1",size:"sm",disabled:r.readonly},null,8,["modelValue","onUpdate:modelValue","disabled"]),r.readonly?E("",!0):(l(),P(Z,{key:0,color:"error",variant:"ghost",icon:"i-heroicons-trash",size:"xs",class:"shrink-0",onClick:Te=>z(be)},null,8,["onClick"]))]))),128)),r.readonly?E("",!0):(l(),g("div",wf,[f(ve,{modelValue:$.value,"onUpdate:modelValue":F[4]||(F[4]=H=>$.value=H),placeholder:t(e)("ai.assistant.config.addQuestion"),class:"min-w-0 flex-1",size:"sm",onKeyup:it(D,["enter"])},null,8,["modelValue","placeholder"]),f(Z,{color:"primary",variant:"soft",icon:"i-heroicons-plus",size:"xs",class:"shrink-0",onClick:D})]))])],512)],512),[[Et,_.value==="basic"]]),ct(a("div",$f,[a("div",null,[a("h3",Cf,d(t(e)("ai.assistant.config.coreTools")),1),a("p",Sf,d(t(e)("ai.assistant.config.coreToolsHint")),1),a("div",If,[(l(!0),g(ie,null,_e(x.value,H=>(l(),g("label",{key:H.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"},[F[6]||(F[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",Tf,[a("div",Mf,d(H.name),1),a("div",Af,d(H.description),1)])]))),128))])]),a("div",null,[a("div",zf,[a("h3",qf,d(t(e)("ai.assistant.config.analysisTools")),1),r.readonly?E("",!0):(l(),g("div",Lf,[a("button",{class:"text-[10px] text-primary-500 hover:text-primary-600",onClick:U},d(t(e)("ai.assistant.config.selectAll")),1),F[7]||(F[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:Y},d(t(e)("ai.assistant.config.deselectAll")),1)]))]),a("p",Df,d(t(e)("ai.assistant.config.analysisToolsHint")),1),a("div",Ef,[(l(!0),g(ie,null,_e(k.value,H=>(l(),g("label",{key:H.name,class:W(["flex cursor-pointer items-start gap-2 rounded-md border px-2.5 py-2 transition-colors",q(H.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(H.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:be=>M(H.name)},null,40,Bf),a("div",Ff,[a("div",Rf,d(H.name),1),a("div",Vf,d(H.description),1)])],2))),128))])])],512),[[Et,_.value==="tools"]])]),a("div",Of,[a("div",null,[!r.readonly&&!p.value&&h.value?.builtinId?(l(),P(Z,{key:0,variant:"outline",color:"warning",loading:m.value,onClick:B},{default:L(()=>[ne(d(t(e)("ai.assistant.config.resetDefault")),1)]),_:1},8,["loading"])):E("",!0)]),a("div",Pf,[f(Z,{variant:"ghost",onClick:j},{default:L(()=>[ne(d(r.readonly?t(e)("common.close"):t(e)("common.cancel")),1)]),_:1}),r.readonly?E("",!0):(l(),P(Z,{key:0,color:"primary",loading:m.value,onClick:V},{default:L(()=>[ne(d(p.value?t(e)("ai.assistant.config.create"):t(e)("common.save")),1)]),_:1},8,["loading"]))])])],64)):E("",!0)])]),_:1},8,["open"])}}}),jf={class:"p-6"},Uf={class:"mb-4 flex items-center justify-between"},Hf={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},Wf={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},Kf={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"},Yf={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},Gf={class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},Qf={class:"min-w-0 flex-1"},Jf={class:"flex items-center gap-2"},Xf={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Zf={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"},eh={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"},th={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},ah={class:"flex shrink-0 items-center gap-1.5"},sh=["title","onClick"],nh=["title","onClick"],oh=["title","onClick"],ih={key:0,class:"py-12 text-center text-sm text-gray-400"},rh={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},lh={key:0,class:"py-12 text-center text-sm text-gray-400"},uh={key:1,class:"py-12 text-center"},ch={class:"text-sm text-gray-500 dark:text-gray-400"},dh={key:2,class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},mh={class:"min-w-0 flex-1"},gh={class:"flex items-center gap-2"},ph={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},fh={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"},hh={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"},vh={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},yh={class:"flex shrink-0 items-center gap-2"},xh=["disabled","onClick"],bh={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},kh=["disabled","onClick"],_h=["title","onClick"],wh={key:3,class:"py-12 text-center text-sm text-gray-400"},$h=le({__name:"AssistantMarketModal",props:{open:{type:Boolean}},emits:["update:open","configure","view-config","create"],setup(r,{emit:i}){const{t:e,locale:s}=Ie(),n=ft(),u=r,o=i,c=Gt(),{assistants:m,cloudCatalogWithStatus:h,cloudLoading:p,cloudError:_}=_t(c),y=A("local"),b=T(()=>{const z=s.value;return[...m.value].filter(M=>!M.supportedLocales?.length||M.supportedLocales.some(q=>z.startsWith(q))).sort((M,q)=>M.name.localeCompare(q.name))}),x=T(()=>[...h.value].sort((z,M)=>z.name.localeCompare(M.name))),k=A(new Set);fe(()=>[u.open,y.value],([z,M])=>{z&&M==="market"&&c.fetchCloudCatalog(s.value)},{immediate:!0});function I(z){o("configure",z)}async function $(z){Xt(z)||await c.deleteAssistant(z)}async function w(z){await c.duplicateAssistant(z)}function C(){o("create")}async function v(z){if(!k.value.has(z.id)){k.value=new Set([...k.value,z.id]);try{const M=await c.importFromCloud(z);M.success?n.success(e("ai.assistant.market.importSuccess")):n.fail(e("ai.assistant.market.importFailed"),{description:M.error})}finally{const M=new Set(k.value);M.delete(z.id),k.value=M}}}async function S(z){if(!k.value.has(z.id)){k.value=new Set([...k.value,z.id]);try{const M=await c.deleteAssistant(z.id);if(!M.success){n.fail(e("ai.assistant.market.importFailed"),{description:M.error});return}const q=await c.importFromCloud(z);q.success?n.success(e("ai.assistant.market.importSuccess")):n.fail(e("ai.assistant.market.importFailed"),{description:q.error})}finally{const M=new Set(k.value);M.delete(z.id),k.value=M}}}function V(z){o("view-config",z)}function B(){c.fetchCloudCatalog(s.value)}function D(z){return z?.length?z.map(q=>e(q==="group"?"ai.assistant.config.chatTypeGroup":"ai.assistant.config.chatTypePrivate")).join(" / "):null}return(z,M)=>{const q=Me,U=lt;return l(),P(U,{open:r.open,ui:{content:"sm:max-w-xl z-50"},"onUpdate:open":M[3]||(M[3]=Y=>o("update:open",Y))},{content:L(()=>[a("div",jf,[a("div",Uf,[a("h2",Hf,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]=Y=>o("update:open",!1))},[f(q,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),a("div",Wf,[a("button",{class:W(["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]=Y=>y.value="local")},[ne(d(t(e)("ai.assistant.market.tabs.local"))+" ",1),b.value.length?(l(),g("span",Kf,d(b.value.length),1)):E("",!0)],2),a("button",{class:W(["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]=Y=>y.value="market")},d(t(e)("ai.assistant.market.tabs.market")),3)]),ct(a("div",null,[a("p",Yf,d(t(e)("ai.assistant.market.localHint")),1),a("div",Gf,[(l(!0),g(ie,null,_e(b.value,Y=>(l(),g("div",{key:Y.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",Qf,[a("div",Jf,[a("h3",Xf,d(Y.name),1),D(Y.applicableChatTypes)?(l(),g("span",Zf,d(D(Y.applicableChatTypes)),1)):E("",!0),t(Xt)(Y.id)?(l(),g("span",eh,d(t(e)("ai.assistant.market.default")),1)):E("",!0)]),a("p",th,d(Y.systemPrompt),1)]),a("div",ah,[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:Ke(te=>I(Y.id),["stop"])},[f(q,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})],8,sh),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:Ke(te=>w(Y.id),["stop"])},[f(q,{name:"i-heroicons-document-duplicate",class:"h-4 w-4"})],8,nh),t(Xt)(Y.id)?E("",!0):(l(),g("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:Ke(te=>$(Y.id),["stop"])},[f(q,{name:"i-heroicons-trash",class:"h-4 w-4"})],8,oh))])]))),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:C},[f(q,{name:"i-heroicons-plus",class:"h-4 w-4"}),ne(" "+d(t(e)("ai.assistant.market.addAssistant")),1)]),b.value.length===0?(l(),g("div",ih,d(t(e)("ai.assistant.market.noLocal")),1)):E("",!0)],512),[[Et,y.value==="local"]]),ct(a("div",null,[a("p",rh,d(t(e)("ai.assistant.market.marketHint")),1),t(p)?(l(),g("div",lh,d(t(e)("ai.assistant.market.loading")),1)):t(_)?(l(),g("div",uh,[a("p",ch,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:B},d(t(e)("ai.assistant.market.retry")),1)])):(l(),g("div",dh,[(l(!0),g(ie,null,_e(x.value,Y=>(l(),g("div",{key:Y.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",mh,[a("div",gh,[a("h3",ph,d(Y.name),1),D(Y.applicableChatTypes)?(l(),g("span",fh,d(D(Y.applicableChatTypes)),1)):E("",!0),t(Xt)(Y.id)?(l(),g("span",hh,d(t(e)("ai.assistant.market.default")),1)):E("",!0)]),a("p",vh,d(Y.description),1)]),a("div",yh,[Y.imported?(l(),g(ie,{key:1},[a("span",bh,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:k.value.has(Y.id),onClick:te=>S(Y)},d(k.value.has(Y.id)?t(e)("ai.assistant.market.importing"):t(e)("ai.assistant.market.reimport")),9,kh)],64)):(l(),g("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(Y.id),onClick:te=>v(Y)},d(k.value.has(Y.id)?t(e)("ai.assistant.market.importing"):t(e)("ai.assistant.market.import")),9,xh)),Y.imported?(l(),g("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:Ke(te=>V(Y.id),["stop"])},[f(q,{name:"i-heroicons-eye",class:"h-4 w-4"})],8,_h)):E("",!0)])]))),128))])),!t(p)&&!t(_)&&x.value.length===0?(l(),g("div",wh,d(t(e)("ai.assistant.market.noCatalog")),1)):E("",!0)],512),[[Et,y.value==="market"]])])]),_:1},8,["open"])}}}),Ch={class:"p-5"},Sh={class:"flex items-start gap-3"},Ih={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"},Th={class:"min-w-0"},Mh={class:"font-semibold text-gray-900 dark:text-white"},Ah={class:"mt-1.5 text-sm leading-6 text-gray-600 dark:text-gray-400"},zh={class:"mt-4 rounded-lg bg-gray-50 px-3 py-2.5 dark:bg-gray-800/70"},qh={class:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300"},Lh={class:"truncate"},Dh={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},Eh={class:"mt-5 flex justify-end gap-2"},Bh=le({__name:"AssistantUpgradeModal",props:{open:{type:Boolean},backupName:{},upgrading:{type:Boolean},skipping:{type:Boolean}},emits:["skip","confirm"],setup(r,{emit:i}){const e=i,{t:s}=Ie();return(n,u)=>{const o=Me,c=Xe,m=lt;return l(),P(m,{open:r.open,dismissible:!1,ui:{content:"sm:max-w-md z-50",overlay:"z-40"}},{content:L(()=>[a("div",Ch,[a("div",Sh,[a("div",Ih,[f(o,{name:"i-lucide-sparkles",class:"h-5 w-5"})]),a("div",Th,[a("h3",Mh,d(t(s)("ai.assistant.upgrade.title")),1),a("p",Ah,d(t(s)("ai.assistant.upgrade.message",{backupName:r.backupName})),1)])]),a("div",zh,[a("div",qh,[f(o,{name:"i-lucide-copy-check",class:"h-4 w-4 shrink-0 text-gray-400"}),a("span",Lh,d(r.backupName),1)])]),a("p",Dh,d(t(s)("ai.assistant.upgrade.skipHint")),1),a("div",Eh,[f(c,{variant:"soft",loading:r.skipping,disabled:r.upgrading,onClick:u[0]||(u[0]=h=>e("skip"))},{default:L(()=>[ne(d(t(s)("ai.assistant.upgrade.skip")),1)]),_:1},8,["loading","disabled"]),f(c,{color:"primary",loading:r.upgrading,disabled:r.skipping,onClick:u[1]||(u[1]=h=>e("confirm"))},{default:L(()=>[ne(d(t(s)("ai.assistant.upgrade.confirm")),1)]),_:1},8,["loading","disabled"])])])]),_:1},8,["open"])}}}),Fh={class:"p-6"},Rh={class:"mb-4 flex items-center justify-between"},Vh={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},Oh={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},Ph={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"},Nh={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},jh={class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},Uh={class:"min-w-0 flex-1"},Hh={class:"flex items-center gap-2"},Wh={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Kh={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"},Yh={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},Gh={key:0,class:"mt-1.5 flex flex-wrap gap-1"},Qh={class:"flex shrink-0 items-center gap-1.5"},Jh=["title","onClick"],Xh=["title","onClick"],Zh={key:0,class:"py-12 text-center text-sm text-gray-400"},ev={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},tv={key:0,class:"py-12 text-center text-sm text-gray-400"},av={key:1,class:"py-12 text-center"},sv={class:"text-sm text-gray-500 dark:text-gray-400"},nv={key:2,class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},ov={class:"min-w-0 flex-1"},iv={class:"flex items-center gap-2"},rv={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},lv={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"},uv={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},cv={key:0,class:"mt-1.5 flex flex-wrap gap-1"},dv={class:"flex shrink-0 items-center gap-2"},mv=["disabled","onClick"],gv={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},pv=["disabled","onClick"],fv={key:3,class:"py-12 text-center text-sm text-gray-400"},hv=le({__name:"SkillMarketModal",props:{open:{type:Boolean}},emits:["update:open","configure","create"],setup(r,{emit:i}){const{t:e,locale:s}=Ie(),n=ft(),u=r,o=i,c=Vt(),{skills:m,cloudCatalogWithStatus:h,cloudLoading:p,cloudError:_}=_t(c),y=A("local"),b=A(new Set);He(()=>{c.setFilterContext("group",s.value)}),fe(()=>[u.open,y.value],([B,D])=>{B&&D==="market"&&(c.setFilterContext("group",s.value),c.fetchCloudCatalog())},{immediate:!0});const x=T(()=>[...m.value].sort((B,D)=>B.name.localeCompare(D.name))),k=T(()=>[...h.value].sort((B,D)=>B.name.localeCompare(D.name)));function I(B){return e(B==="group"?"ai.skill.config.chatScopeGroup":B==="private"?"ai.skill.config.chatScopePrivate":"ai.skill.config.chatScopeAll")}function $(B){o("configure",B)}async function w(B){await c.deleteSkill(B)}function C(){o("create")}async function v(B){if(!b.value.has(B.id)){b.value=new Set([...b.value,B.id]);try{const D=await c.importFromCloud(B);D.success?n.success(e("ai.skill.market.importSuccess")):n.fail(e("ai.skill.market.importFailed"),{description:D.error})}finally{const D=new Set(b.value);D.delete(B.id),b.value=D}}}async function S(B){if(!b.value.has(B.id)){b.value=new Set([...b.value,B.id]);try{const D=await c.deleteSkill(B.id);if(!D.success){n.fail(e("ai.skill.market.importFailed"),{description:D.error});return}const z=await c.importFromCloud(B);z.success?n.success(e("ai.skill.market.importSuccess")):n.fail(e("ai.skill.market.importFailed"),{description:z.error})}finally{const D=new Set(b.value);D.delete(B.id),b.value=D}}}function V(){c.fetchCloudCatalog()}return(B,D)=>{const z=Me,M=lt;return l(),P(M,{open:r.open,ui:{content:"sm:max-w-xl z-50"},"onUpdate:open":D[3]||(D[3]=q=>o("update:open",q))},{content:L(()=>[a("div",Fh,[a("div",Rh,[a("h2",Vh,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))},[f(z,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),a("div",Oh,[a("button",{class:W(["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")},[ne(d(t(e)("ai.skill.market.tabs.local"))+" ",1),t(m).length?(l(),g("span",Ph,d(t(m).length),1)):E("",!0)],2),a("button",{class:W(["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)]),ct(a("div",null,[a("p",Nh,d(t(e)("ai.skill.market.localHint")),1),a("div",jh,[(l(!0),g(ie,null,_e(x.value,q=>(l(),g("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",Uh,[a("div",Hh,[a("h3",Wh,d(q.name),1),a("span",Kh,d(I(q.chatScope)),1)]),a("p",Yh,d(q.description),1),q.tags.length?(l(),g("div",Gh,[(l(!0),g(ie,null,_e(q.tags,U=>(l(),g("span",{key:U,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(U),1))),128))])):E("",!0)]),a("div",Qh,[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:Ke(U=>$(q.id),["stop"])},[f(z,{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-red-50 hover:text-red-500 dark:hover:bg-red-900/20 dark:hover:text-red-400",title:t(e)("common.delete"),onClick:Ke(U=>w(q.id),["stop"])},[f(z,{name:"i-heroicons-trash",class:"h-4 w-4"})],8,Xh)])]))),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:C},[f(z,{name:"i-heroicons-plus",class:"h-4 w-4"}),ne(" "+d(t(e)("ai.skill.market.addSkill")),1)]),x.value.length===0?(l(),g("div",Zh,d(t(e)("ai.skill.market.noLocal")),1)):E("",!0)],512),[[Et,y.value==="local"]]),ct(a("div",null,[a("p",ev,d(t(e)("ai.skill.market.marketHint")),1),t(p)?(l(),g("div",tv,d(t(e)("ai.skill.market.loading")),1)):t(_)?(l(),g("div",av,[a("p",sv,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:V},d(t(e)("ai.skill.market.retry")),1)])):(l(),g("div",nv,[(l(!0),g(ie,null,_e(k.value,q=>(l(),g("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",ov,[a("div",iv,[a("h3",rv,d(q.name),1),a("span",lv,d(I(q.chatScope)),1)]),a("p",uv,d(q.description),1),q.tags?.length?(l(),g("div",cv,[(l(!0),g(ie,null,_e(q.tags,U=>(l(),g("span",{key:U,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(U),1))),128))])):E("",!0)]),a("div",dv,[q.imported?(l(),g(ie,{key:1},[a("span",gv,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:b.value.has(q.id),onClick:U=>S(q)},d(b.value.has(q.id)?t(e)("ai.skill.market.importing"):t(e)("ai.skill.market.reimport")),9,pv)],64)):(l(),g("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:b.value.has(q.id),onClick:U=>v(q)},d(b.value.has(q.id)?t(e)("ai.skill.market.importing"):t(e)("ai.skill.market.import")),9,mv))])]))),128))])),!t(p)&&!t(_)&&k.value.length===0?(l(),g("div",fv,d(t(e)("ai.skill.market.noCatalog")),1)):E("",!0)],512),[[Et,y.value==="market"]])])]),_:1},8,["open"])}}}),vv={class:"p-6"},yv={class:"mb-4 flex items-center justify-between"},xv={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},bv={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},kv={key:0,class:"flex h-64 items-center justify-center text-gray-400"},_v={class:"mt-4 flex justify-end gap-2"},wv=["disabled"],$v=`---
104
+ name: ""
105
+ description: ""
106
+ tags: []
107
+ chatScope: all
108
+ tools: []
109
+ ---
110
+
111
+ `,Cv=le({__name:"SkillConfigModal",props:{open:{type:Boolean},skillId:{}},emits:["update:open","saved","created"],setup(r,{emit:i}){const{t:e}=Ie(),s=r,n=i,u=Vt(),o=A(""),c=A(!1),m=A(!1),h=A(!1);fe(()=>[s.open,s.skillId],async([_,y])=>{if(_){if(!y){h.value=!0,o.value=$v;return}h.value=!1,c.value=!0;try{const b=await u.getSkillConfig(y);if(b){const x=["---",`name: "${b.name}"`,`description: "${b.description}"`,`tags: [${b.tags.map(k=>`"${k}"`).join(", ")}]`,`chatScope: ${b.chatScope}`,b.tools.length?`tools: [${b.tools.map(k=>`"${k}"`).join(", ")}]`:"tools: []",b.builtinId?`builtinId: ${b.builtinId}`:"","---","",b.prompt].filter(Boolean).join(`
112
+ `);o.value=x}}finally{c.value=!1}}},{immediate:!0});async function p(){if(o.value.trim()){m.value=!0;try{if(h.value){const _=await u.createSkill(o.value);_.success&&_.id&&(n("created",_.id),n("update:open",!1))}else s.skillId&&(await u.updateSkill(s.skillId,o.value)).success&&(n("saved"),n("update:open",!1))}finally{m.value=!1}}}return(_,y)=>{const b=Me,x=lt;return l(),P(x,{open:r.open,ui:{content:"sm:max-w-2xl z-50"},"onUpdate:open":y[3]||(y[3]=k=>n("update:open",k))},{content:L(()=>[a("div",vv,[a("div",yv,[a("h2",xv,d(h.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]=k=>n("update:open",!1))},[f(b,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),a("p",bv,d(t(e)("ai.skill.config.rawEditorHint")),1),c.value?(l(),g("div",kv,[f(b,{name:"i-heroicons-arrow-path",class:"mr-2 h-5 w-5 animate-spin"})])):ct((l(),g("textarea",{key:1,"onUpdate:modelValue":y[1]||(y[1]=k=>o.value=k),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)),[[Lt,o.value]]),a("div",_v,[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]=k=>n("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:m.value||!o.value.trim(),onClick:p},d(h.value?t(e)("ai.skill.config.create"):t(e)("ai.skill.config.save")),9,wv)])])]),_:1},8,["open"])}}}),Sv={key:0,class:"relative"},Iv={class:"relative flex flex-nowrap gap-2"},Tv=["disabled"],Mv=["disabled"],Av={class:"inline-flex items-center gap-1"},zv={key:0,class:"absolute left-0 bottom-full z-20 mb-2 w-[320px] max-w-[calc(100vw-3rem)]"},qv={class:"mb-1.5 flex justify-start"},Lv={class:"flex flex-wrap gap-2"},Dv=["disabled","onClick"],Ia="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",Ev=le({__name:"PresetQuestions",props:{questions:{},disabled:{type:Boolean},leadingActionLabel:{}},emits:["select","leadingAction","editQuestions"],setup(r,{emit:i}){const{t:e}=Ie(),s=r,n=i,u=A(!1);let o=null;function c(_){u.value=!1,n("select",_)}function m(){s.disabled||s.questions.length===0||(o&&(clearTimeout(o),o=null),u.value=!0)}function h(){o=setTimeout(()=>{u.value=!1},150)}function p(){u.value=!1,n("editQuestions")}return Ft(()=>{o&&clearTimeout(o)}),(_,y)=>{const b=Me;return r.leadingActionLabel||r.questions.length>0?(l(),g("div",Sv,[a("div",Iv,[r.leadingActionLabel?(l(),g("button",{key:0,class:W(Ia),disabled:s.disabled,onClick:y[0]||(y[0]=x=>n("leadingAction"))},d(r.leadingActionLabel),9,Tv)):E("",!0),r.questions.length>0?(l(),g("div",{key:1,class:"relative shrink-0",onMouseenter:m,onMouseleave:h},[a("button",{class:W([Ia,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:s.disabled},[a("span",Av,[f(b,{name:"i-heroicons-chat-bubble-left-ellipsis",class:"h-3.5 w-3.5"}),ne(" "+d(t(e)("ai.chat.input.quickAsk")),1)])],10,Mv),f(Mt,{"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:L(()=>[u.value?(l(),g("div",zv,[a("div",qv,[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:p},[f(b,{name:"i-heroicons-pencil-square",class:"h-3 w-3"}),ne(" "+d(t(e)("ai.chat.input.editQuickAsk")),1)])]),a("div",Lv,[(l(!0),g(ie,null,_e(r.questions,(x,k)=>(l(),g("button",{key:k,class:W(Ia),disabled:s.disabled,onClick:I=>c(x)},d(x),9,Dv))),128))])])):E("",!0)]),_:1})],32)):E("",!0)])])):E("",!0)}}}),Bv=30,Fv=100;function Rv(r,i=Fv){let e=null,s=!1;function n(o=!1){s||=o,e===null&&(e=setTimeout(()=>{e=null;const c=s;s=!1,r(c)},i))}function u(){e!==null&&(clearTimeout(e),e=null),s=!1}return{schedule:n,cancel:u}}function Vv(r,i){const e=A(null),s=A(!0),n=A(!1),u=Rv(p=>{e.value&&(p||s.value)&&(e.value.scrollTop=e.value.scrollHeight,s.value=!0,n.value=!1)});function o(p=!1){u.schedule(p)}function c(p){p.deltaY<0&&i.value&&(s.value=!1,n.value=!0)}function m(){if(!e.value)return;const{scrollTop:p,scrollHeight:_,clientHeight:y}=e.value;_-p-y<Bv&&(s.value=!0,n.value=!1)}function h(){o(!0)}return fe(()=>{const p=r.value[r.value.length-1];return[r.value.length,p?.content,p?.contentBlocks?.length]},()=>o()),He(()=>{e.value&&(e.value.addEventListener("scroll",m),e.value.addEventListener("wheel",c,{passive:!0})),r.value.length>0&&o(!0)}),Ft(()=>{u.cancel(),e.value&&(e.value.removeEventListener("scroll",m),e.value.removeEventListener("wheel",c))}),{messagesContainer:e,showScrollToBottom:n,scrollToBottom:o,handleScrollToBottom:h}}const ta=20;function Ov(r,i,e){const s=A(ta),n=T(()=>r.value.slice(-s.value)),u=T(()=>s.value<r.value.length);fe([i,()=>r.value.length],([c,m],[h,p])=>{if(c!==h){s.value=ta;return}m<p?s.value=Math.max(ta,Math.min(s.value,m)):p>0&&s.value>=p&&(s.value=m)});async function o(){if(!u.value)return;const c=e.value,m=c?.scrollHeight??0,h=c?.scrollTop??0;s.value=Math.min(r.value.length,s.value+ta),await Fe(),c&&e.value===c&&(c.scrollTop=h+(c.scrollHeight-m))}return{visiblePairs:n,hasOlderPairs:u,loadOlderPairs:o}}function Pv(){const r=Gt(),i=Vt(),e=A(!1),s=A(null),n=A(!1),u=A(!1),o=A(!1),c=A(!1),m=A(null);function h(S){s.value=S,n.value=!1,e.value=!0}function p(){u.value=!0}function _(S){s.value=S,n.value=!1,e.value=!0}function y(S){s.value=S,n.value=!0,e.value=!0}function b(){s.value=null,n.value=!1,e.value=!0}async function x(S){await r.loadAssistants(),await r.loadBuiltinCatalog()}async function k(){await r.loadAssistants()}function I(){o.value=!0}function $(S){m.value=S,c.value=!0}function w(){m.value=null,c.value=!0}async function C(){await i.loadSkills()}async function v(S){await i.loadSkills(),await i.loadBuiltinCatalog()}return{configModalVisible:e,configModalAssistantId:s,configModalReadonly:n,marketModalVisible:u,handleConfigureAssistant:h,handleOpenMarket:p,handleMarketConfigure:_,handleMarketViewConfig:y,handleCreateAssistant:b,handleAssistantCreated:x,handleAssistantConfigSaved:k,skillMarketModalVisible:o,skillConfigModalVisible:c,skillConfigModalSkillId:m,handleOpenSkillMarket:I,handleSkillMarketConfigure:$,handleCreateSkill:w,handleSkillConfigSaved:C,handleSkillCreated:v}}function Nv(r){const i=[];let e=null;for(const s of r)s.role==="user"?(e&&i.push({user:e,assistant:null,standalone:null,id:e.id}),e=s):s.role==="assistant"?(i.push({user:e,assistant:s,standalone:null,id:e?.id||s.id}),e=null):(e&&(i.push({user:e,assistant:null,standalone:null,id:e.id}),e=null),i.push({user:null,assistant:null,standalone:s,id:s.id}));return e&&i.push({user:e,assistant:null,standalone:null,id:e.id}),i}const jv={class:"main-content flex h-full overflow-hidden"},Uv={class:"flex h-full flex-1 overflow-hidden"},Hv={class:"flex h-full flex-1"},Wv={class:"relative flex min-w-[480px] flex-1 flex-col overflow-hidden"},Kv={key:0,class:"flex items-center justify-between gap-2 px-3 py-1.5"},Yv=["disabled"],Gv={key:0,class:"flex w-full flex-col items-center justify-center animate-fade-in"},Qv={key:0,class:"mb-3 text-center text-2xl font-semibold tracking-tight text-gray-800 dark:text-gray-100"},Jv={class:"text-primary-600 dark:text-primary-400"},Xv={key:1,class:"relative mb-8 w-full max-w-lg"},Zv={class:"flex w-full justify-center"},ey={key:1,class:"flex justify-center pb-2"},ty={key:1,class:"qa-pair space-y-6 pb-4"},ay={key:1,class:"px-4 pb-2"},sy={class:"mx-auto max-w-3xl"},ny={class:"px-4 pb-3"},oy={class:"mx-auto max-w-3xl"},iy={class:"relative overflow-visible rounded-2xl bg-white shadow-[0_2px_14px_rgba(0,0,0,0.04)] ring-1 ring-gray-200/60 transition-all focus-within:ring-primary-500/40 focus-within:shadow-[0_4px_20px_rgba(0,0,0,0.08)] dark:bg-page-dark dark:ring-white/5 dark:focus-within:ring-primary-500/40"},ry={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"},ly=le({__name:"ChatExplorer",props:{sessionId:{},sessionName:{},timeFilter:{},chatType:{}},emits:["restore-loading-change"],setup(r,{expose:i,emit:e}){const{t:s}=Ie(),n=Jn(),u=Xn(),o=ft(),c=ja(),m=Gt(),h=Vt(),p=r,_=e,y=typeof n.query.aiChatId=="string"?n.query.aiChatId:null;y&&_("restore-loading-change",!0);const{initialization:b,messages:x,sourceMessages:k,currentKeywords:I,isLoadingSource:$,isAIThinking:w,currentAIChatId:C,currentToolStatus:v,sessionTokenUsage:S,agentStatus:V,selectedAssistantId:B,sendMessage:D,editMessageAndRegenerate:z,loadAIChat:M,startNewAIChat:q,loadMoreSourceMessages:U,updateMaxMessages:Y,stopGeneration:te,selectAssistantForSession:K}=dr(p.sessionId,p.sessionName,p.timeFilter,p.chatType??"group",c.locale,y);let j=!1;async function N(Se){(typeof n.query.aiChatId=="string"?n.query.aiChatId:null)!==Se&&await u.replace({query:{...n.query,aiChatId:Se||void 0}})}b.finally(()=>{_("restore-loading-change",!1),j=!0,N(C.value)}),dt(()=>_("restore-loading-change",!1)),fe(C,Se=>{j&&N(Se)});const F=Vv(x,w),{showScrollToBottom:Z,scrollToBottom:ue,handleScrollToBottom:ve}=F,{configModalVisible:ae,configModalAssistantId:re,configModalReadonly:H,marketModalVisible:be,skillMarketModalVisible:Te,skillConfigModalVisible:we,skillConfigModalSkillId:ce,handleConfigureAssistant:X,handleOpenMarket:Q,handleMarketConfigure:xe,handleMarketViewConfig:Ae,handleCreateAssistant:ze,handleAssistantCreated:je,handleAssistantConfigSaved:Je,handleOpenSkillMarket:Re,handleSkillMarketConfigure:Qe,handleCreateSkill:et,handleSkillConfigSaved:Ee,handleSkillCreated:pe}=Pv(),ye=fa(),oe=A(0);fe(()=>C.value,async Se=>{if(!Se){oe.value=0;return}try{const Le=await ot().estimateContextTokens(Se);Le.success&&(oe.value=Le.tokens)}catch{oe.value=0}},{immediate:!0});const ge=T(()=>m.selectedAssistant?.presetQuestions??[]),R=T(()=>p.chatType??"group"),ee=A(!1),J=A(!1),de=A(!0),Ce=A(void 0),Ue=A(null),Ye=A(null),Ve=A(null),Oe=A(!1),nt=A(!1),ht=A(!1),Jt=T(()=>{const Se=Ve.value?.name||s("ai.assistant.fallbackName");return s("ai.assistant.upgrade.backupName",{name:Se})}),O=T(()=>Nv(x.value)),G=Ov(O,C,F.messagesContainer),{visiblePairs:se,hasOlderPairs:qe,loadOlderPairs:ke}=G;async function he(){de.value=!0;try{J.value=await Ra().hasConfig()}catch(Se){console.error("检查 LLM 配置失败:",Se),J.value=!1}finally{de.value=!1}}async function Be(){await he(),J.value&&await Y()}i({refreshConfig:Be});const me=T(()=>{const Se=m.selectedAssistant;if(!Se)return{name:"",preview:""};const Le=Se.systemPrompt.replace(/#{1,6}\s+[^\n]*/g,"").replace(/\n+/g," ").replace(/\s+/g," ").trim();return{name:Se.name,preview:Le}}),ba=T(()=>!!B.value&&x.value.length===0&&!w.value);function We(){o.warn(s("ai.chat.backgroundTask.runningTitle"),{description:s("ai.chat.backgroundTask.runningDescription")})}function st(){o.warn(s("ai.chat.backgroundTask.blockedAction"))}function js(Se){if(Se!==B.value){if(!K(Se)){st();return}h.activateSkill(null),q()}}async function Us(Se){const Le=await D(Se);!Le.success&&Le.reason==="busy"&&We()}function Hs(){const Se=m.selectedAssistant?.id;Se&&(Ce.value="presetQuestions",X(Se))}function Ws(Se){ae.value=Se,Se||(Ce.value=void 0)}function Ks(){Ye.value?.openSkillSelector()}function Ys(){ue(!0)}async function es(){const Se=await m.checkDefaultAssistantUpgrade(c.locale);Se&&(Ve.value=Se,Oe.value=!0)}async function Gs(){const Se=Ve.value;if(!(!Se||nt.value||ht.value)){ht.value=!0;try{const Le=await m.skipAssistantUpgrade(Se);if(!Le.success){o.fail(s("ai.assistant.upgrade.skipFailed"),{description:Le.error||s("ai.assistant.toast.unknownError")});return}Oe.value=!1,Ve.value=null}finally{ht.value=!1}}}async function Qs(){const Se=Ve.value;if(!(!Se||nt.value||ht.value)){nt.value=!0;try{const Le=Jt.value,$t=await m.upgradeAssistantWithBackup(Se,Le);if(!$t.success){o.fail(s("ai.assistant.upgrade.failed"),{description:$t.error||s("ai.assistant.toast.unknownError")});return}Oe.value=!1,Ve.value=null,o.success(s("ai.assistant.upgrade.success"),{description:s("ai.assistant.upgrade.successDescription",{name:Le})})}finally{nt.value=!1}}}async function Js(Se){const Le=await D(Se.content,{mentionedMembers:Se.mentionedMembers});if(!Le.success){Le.reason==="busy"&&We();return}ue(!0),Ue.value?.refresh()}async function Xs(Se){const Le=await z(Se.messageId,Se.content,{overwriteSubsequent:Se.overwriteSubsequent});if(!Le.success){Le.reason==="busy"&&We();return}ue(!0),Ue.value?.refresh()}async function Zs(Se){if(C.value)try{const Le=await ot().forkAIChat(C.value,Se);await M(Le.id),Ue.value?.refresh(),ue(!0),o.success(s("ai.chat.fork.success"))}catch(Le){o.fail(s("ai.chat.fork.failed"),{description:String(Le)})}}function en(){ee.value=!ee.value}async function tn(){await U()}async function an(Se){await M(Se),ue(!0)}function sn(){if(w.value){st();return}q()}function nn(Se){C.value===Se&&q()}function on(){te()}return he(),Y(),He(()=>{es()}),fe(()=>c.locale,()=>{es()}),fe(()=>ye.aiConfigVersion,async()=>{await Be()}),(Se,Le)=>{const $t=Me,rn=Rt;return l(),g("div",jv,[f(ud,{ref_key:"conversationListRef",ref:Ue,"session-id":r.sessionId,"active-id":t(C),disabled:t(w),onSelect:an,onCreate:sn,onDelete:nn},null,8,["session-id","active-id","disabled"]),a("div",Uv,[a("div",Hv,[a("div",Wv,[t(x).length>0||t(w)?(l(),g("div",Kv,[a("button",{class:W(["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(w)||!t(m).selectedAssistant?.id}]),disabled:t(w)||!t(m).selectedAssistant?.id,onClick:Le[0]||(Le[0]=De=>t(X)(t(m).selectedAssistant.id))},[f($t,{name:"i-heroicons-sparkles",class:"h-3.5 w-3.5"}),a("span",null,d(t(m).selectedAssistant?.name||t(s)("ai.assistant.fallbackName")),1)],10,Yv),f(j0,{"current-ai-chat-id":t(C),"current-messages":t(x),"fallback-title":r.sessionName},null,8,["current-ai-chat-id","current-messages","fallback-title"])])):E("",!0),a("div",{ref:t(F).messagesContainer,class:W(["relative min-h-0 flex-1 overflow-x-hidden overflow-y-auto p-4",{"p-0!":t(x).length===0&&!t(w)}])},[a("div",{class:W(["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(x).length===0&&!t(w),"px-4":t(x).length>0||t(w)}])},[t(x).length===0&&!t(w)?(l(),g("div",Gv,[me.value.name?(l(),g("h2",Qv,[ne(d(t(s)("ai.assistant.selector.heroTitlePrefix","使用"))+" ",1),a("span",Jv,d(me.value.name),1),ne(" "+d(t(s)("ai.assistant.selector.heroTitleSuffix","开始对话")),1)])):E("",!0),ba.value&&me.value.name?(l(),g("div",Xv,[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:Le[1]||(Le[1]=De=>t(X)(t(m).selectedAssistant.id))},[f(rn,{text:t(s)("ai.assistant.config.systemPrompt","系统设定"),popper:{placement:"top"}},{default:L(()=>[ne(d(me.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:Le[2]||(Le[2]=Ke(De=>t(X)(t(m).selectedAssistant.id),["stop"]))},[f($t,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})])])):E("",!0),a("div",Zv,[f(J0,{"chat-type":R.value,locale:t(c).locale,"selected-id":t(B),onSelect:js,onMarket:t(Q)},null,8,["chat-type","locale","selected-id","onMarket"])])])):E("",!0),t(qe)?(l(),g("div",ey,[a("button",{type:"button",class:"flex h-8 items-center gap-1.5 rounded-full px-3 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-200",onClick:Le[3]||(Le[3]=(...De)=>t(ke)&&t(ke)(...De))},[f($t,{name:"i-heroicons-arrow-up",class:"h-3.5 w-3.5"}),a("span",null,d(t(s)("ai.chat.history.loadEarlier")),1)])])):E("",!0),(l(!0),g(ie,null,_e(t(se),De=>(l(),g(ie,{key:De.id},[De.standalone?(l(),P(Ca,{key:0,role:De.standalone.role,content:De.standalone.content,timestamp:De.standalone.timestamp},null,8,["role","content","timestamp"])):(l(),g("div",ty,[De.user&&(De.user.role==="user"||De.user.content)?(l(),P(Ca,{key:0,role:De.user.role,"message-id":De.user.id,content:De.user.content,timestamp:De.user.timestamp,"is-streaming":De.user.isStreaming,"content-blocks":De.user.contentBlocks,editable:!t(w),onEdit:Xs},null,8,["role","message-id","content","timestamp","is-streaming","content-blocks","editable"])):E("",!0),De.assistant&&(De.assistant.content||De.assistant.contentBlocks&&De.assistant.contentBlocks.length>0)?(l(),P(Ca,{key:1,role:De.assistant.role,"message-id":De.assistant.id,content:De.assistant.content,timestamp:De.assistant.timestamp,"is-streaming":De.assistant.isStreaming,"process-duration-ms":De.assistant.processDurationMs,"content-blocks":De.assistant.contentBlocks,"show-capture-button":!De.assistant.isStreaming,"active-tool":De.assistant.isStreaming?t(v):null,onFork:Zs},null,8,["role","message-id","content","timestamp","is-streaming","process-duration-ms","content-blocks","show-capture-button","active-tool"])):De.assistant?.isStreaming?(l(),P(w0,{key:2,"current-tool-status":t(v),"agent-status":t(V)},null,8,["current-tool-status","agent-status"])):E("",!0)]))],64))),128))],2)],2),f(Mt,{name:"fade-up"},{default:L(()=>[t(Z)?(l(),g("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:Le[4]||(Le[4]=(...De)=>t(ve)&&t(ve)(...De))},[f($t,{name:"i-heroicons-arrow-down",class:"h-3.5 w-3.5"}),a("span",null,d(t(s)("ai.chat.scrollToBottom")),1)])):E("",!0)]),_:1}),t(x).length===0&&!t(w)?(l(),g("div",ay,[a("div",sy,[f(Ev,{questions:ge.value,"leading-action-label":t(s)("ai.chat.input.useSkill"),onSelect:Us,onLeadingAction:Ks,onEditQuestions:Hs},null,8,["questions","leading-action-label"])])])):E("",!0),a("div",ny,[a("div",oy,[a("div",iy,[f(y0,{ref_key:"chatInputRef",ref:Ye,"session-id":r.sessionId,disabled:t(w),status:t(w)?"streaming":"ready","chat-type":R.value,embedded:"",onSend:Js,onStop:on,onManageSkills:t(Re),onSkillActivated:Ys},null,8,["session-id","disabled","status","chat-type","onManageSkills"]),f(V0,{class:"pb-1.5 pl-2 pr-[52px] pt-0.5","session-token-usage":t(S),"agent-status":t(V),"estimated-context-tokens":oe.value},null,8,["session-token-usage","agent-status","estimated-context-tokens"])])])])])]),f(Mt,{name:"slide-fade"},{default:L(()=>[t(k).length>0&&!ee.value?(l(),g("div",ry,[f(qd,{messages:t(k),keywords:t(I),"is-loading":t($),"is-collapsed":ee.value,class:"h-full",onToggle:en,onLoadMore:tn},null,8,["messages","keywords","is-loading","is-collapsed"])])):E("",!0)]),_:1})]),f(Nf,{open:t(ae),"assistant-id":t(re),readonly:t(H),"scroll-to-section":Ce.value,"onUpdate:open":Ws,onSaved:t(Je),onCreated:t(je)},null,8,["open","assistant-id","readonly","scroll-to-section","onSaved","onCreated"]),f(Bh,{open:Oe.value,"backup-name":Jt.value,upgrading:nt.value,skipping:ht.value,onSkip:Gs,onConfirm:Qs},null,8,["open","backup-name","upgrading","skipping"]),f($h,{open:t(be),"onUpdate:open":Le[5]||(Le[5]=De=>be.value=De),onConfigure:t(xe),onViewConfig:t(Ae),onCreate:t(ze)},null,8,["open","onConfigure","onViewConfig","onCreate"]),f(hv,{open:t(Te),"onUpdate:open":Le[6]||(Le[6]=De=>Te.value=De),onConfigure:t(Qe),onCreate:t(et)},null,8,["open","onConfigure","onCreate"]),f(Cv,{open:t(we),"skill-id":t(ce),"onUpdate:open":Le[7]||(Le[7]=De=>we.value=De),onSaved:t(Ee),onCreated:t(pe)},null,8,["open","skill-id","onSaved","onCreated"])])}}}),j2=gt(ly,[["__scopeId","data-v-9fb5a29e"]]),Ta="__ALL__",uy=le({__name:"UserSelect",props:{sessionId:{},modelValue:{}},emits:["update:modelValue"],setup(r,{emit:i}){const{t:e}=Ie(),s=r,n=i,u=A([]),o=A(!1),c=T({get:()=>s.modelValue===null?Ta:String(s.modelValue),set:p=>{n("update:modelValue",p===Ta?null:parseInt(p))}}),m=T(()=>{const p=[{value:Ta,label:e("common.userSelect.allMembers")}];return u.value.forEach(_=>{const y=_.groupNickname||_.accountName||_.platformId;p.push({value:String(_.id),label:`${y} (${_.messageCount})`})}),p});async function h(){if(s.sessionId){o.value=!0;try{const p=await at().getMembers(s.sessionId);u.value=p.sort((_,y)=>y.messageCount-_.messageCount)}catch(p){console.error("加载成员列表失败:",p)}finally{o.value=!1}}}return fe(()=>s.sessionId,()=>{n("update:modelValue",null),h()},{immediate:!0}),(p,_)=>{const y=Za;return l(),P(y,{modelValue:c.value,"onUpdate:modelValue":_[0]||(_[0]=b=>c.value=b),items:m.value,loading:o.value,virtualize:{estimateSize:32,overscan:10},"value-key":"value",class:"w-48"},null,8,["modelValue","items","loading"])}}}),cy={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},dy={class:"flex items-center gap-6 sm:gap-10"},my={class:"min-w-0 flex-1"},gy={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},py={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},fy={class:"mb-4 flex min-w-0 flex-wrap items-baseline gap-2"},hy={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},vy={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},yy={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},xy={key:1,class:"flex min-w-0 max-w-full flex-wrap items-center gap-x-1.5 gap-y-1.5"},by={class:"text-base font-medium text-gray-600 dark:text-gray-300"},ky={class:"font-bold tabular-nums text-pink-500 dark:text-pink-400"},_y={class:"flex shrink-0 flex-col items-center"},wy={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},$y={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Cy={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Sy={class:"min-w-0 flex-1"},Iy={class:"flex items-center justify-between gap-1"},Ty={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},My={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Ay={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"},zy={class:"flex items-center gap-1.5"},qy={class:"text-[9px] font-medium uppercase tracking-widest"},Ly=le({__name:"TypeProfileCard",props:{sessionId:{},messageTypes:{},textStats:{},timeFilter:{}},setup(r){ha([xo,Ga,va]);const{t:i}=Ie(),e=pa(),s=r,n=T(()=>s.messageTypes.reduce((M,q)=>M+q.count,0)),u=T(()=>s.messageTypes.find(M=>M.type===Ct.TEXT)?.count??0),o=T(()=>{if(n.value===0)return 0;const M=n.value-u.value;return Math.round(M/n.value*100)}),c=T(()=>s.textStats.textCount===0?0:Math.round(s.textStats.shortCount/s.textStats.textCount*100)),m=A({first:"",last:""});async function h(){if(s.sessionId)try{const M=await at().getDailyActivity(s.sessionId,s.timeFilter);if(M.length>0){const q=[...M].sort((U,Y)=>U.date.localeCompare(Y.date));m.value={first:Ne(q[0].date).format("YYYY/MM/DD"),last:Ne(q[q.length-1].date).format("YYYY/MM/DD")}}}catch{}}function p(M){return s.messageTypes.find(q=>q.type===M)?.count??0}const _=T(()=>[{label:i("views.message.typeCard.nonTextImage"),count:p(Ct.IMAGE),unit:i("views.message.typeCard.unitImage")},{label:i("views.message.typeCard.nonTextEmoji"),count:p(Ct.EMOJI),unit:i("views.message.typeCard.unitEmoji")},{label:i("views.message.typeCard.nonTextVoice"),count:p(Ct.VOICE),unit:i("views.message.typeCard.unitVoice")},{label:i("views.message.typeCard.nonTextVideo"),count:p(Ct.VIDEO),unit:i("views.message.typeCard.unitVideo")},{label:i("views.message.typeCard.nonTextFile"),count:p(Ct.FILE),unit:i("views.message.typeCard.unitFile")},{label:i("views.message.typeCard.nonTextLink"),count:p(Ct.LINK),unit:i("views.message.typeCard.unitLink")}].filter(M=>M.count>0)),y=A(30),b=A(0),x=A(!1),k=[{label:"20",value:20},{label:"30",value:30},{label:"50",value:50},{label:"80",value:80},{label:"100",value:100}],I=T({get:()=>y.value,set:M=>{y.value!==M&&(y.value=M,$())}});async function $(){if(s.sessionId){x.value=!0;try{b.value=await at().getLongMessageCount(s.sessionId,s.timeFilter,y.value)}catch(M){console.error("[chart-message] Failed to load essay count:",M)}finally{x.value=!1}}}fe(()=>[s.sessionId,s.timeFilter],()=>{$(),h()},{immediate:!0,deep:!0});const w=T(()=>[{icon:"i-heroicons-pencil-square",label:i("views.message.profile.textExpression"),value:i("views.message.profile.avgLengthUnit",{count:s.textStats.avgLength||0}),subtext:s.textStats.maxLength>0?i("views.message.profile.textExpressionDesc",{count:s.textStats.maxLength}):"",colorClass:"text-violet-600 dark:text-violet-400"},{icon:"i-heroicons-chat-bubble-bottom-center-text",label:i("views.message.profile.shortMaster"),value:`${c.value}%`,subtext:i("views.message.profile.shortMasterDesc",{count:s.textStats.shortCount}),colorClass:"text-emerald-600 dark:text-emerald-400"},{icon:"i-heroicons-document-text",label:i("views.message.profile.essayLover"),value:b.value.toLocaleString(),subtext:i("views.message.profile.essayLoverDesc",{threshold:y.value}),colorClass:"text-indigo-600 dark:text-indigo-400",slot:"essay-threshold"},{icon:"i-heroicons-photo",label:i("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"}]),C=A(null);let v=null;const S=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],V=T(()=>[...s.messageTypes].sort((q,U)=>U.count-q.count).slice(0,8).map((q,U)=>({name:Aa(q.type,i),value:q.count,itemStyle:{color:S[U%S.length]}})));function B(){C.value&&(v=ya(C.value,void 0,{renderer:"canvas"}),D())}function D(){v&&v.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:V.value}]},{notMerge:!0})}function z(){v?.resize()}return fe(()=>s.messageTypes,()=>D()),fe(e,()=>{v?.dispose(),B()}),He(()=>{B(),window.addEventListener("resize",z)}),dt(()=>{window.removeEventListener("resize",z),v?.dispose()}),(M,q)=>{const U=Me,Y=Ha;return l(),P(t(xa),null,{default:L(()=>[a("div",cy,[a("div",dy,[a("div",my,[a("div",gy,[m.value.first?(l(),g("p",py,d(m.value.first)+" – "+d(m.value.last),1)):E("",!0),a("div",fy,[a("span",hy,d(t(i)("views.message.profile.heroLine1Prefix")),1),a("span",vy,d(n.value.toLocaleString()),1),a("span",yy,d(t(i)("views.message.profile.heroLine1Suffix")),1)]),_.value.length>0?(l(),g("div",xy,[a("span",by,d(t(i)("views.message.typeCard.nonTextPrefix")),1),(l(!0),g(ie,null,_e(_.value,te=>(l(),g("span",{key:te.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",ky,d(te.count.toLocaleString()),1),a("span",null,d(te.unit),1)]))),128))])):E("",!0)])]),a("div",_y,[a("div",wy,d(t(i)("views.message.profile.typeDistribution")),1),a("div",{ref_key:"donutRef",ref:C,style:{width:"130px",height:"130px"}},null,512)])])]),a("div",$y,[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",Cy,[(l(!0),g(ie,null,_e(w.value,te=>(l(),g("div",{key:te.icon+te.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[f(U,{name:te.icon,class:W(["mt-0.5 h-3.5 w-3.5 shrink-0",te.colorClass])},null,8,["name","class"]),a("div",Sy,[a("div",Iy,[a("div",{class:W(["truncate font-mono text-sm font-black leading-tight tabular-nums",te.colorClass])},d(te.value),3),te.slot==="essay-threshold"?(l(),P(Y,{key:0,modelValue:I.value,"onUpdate:modelValue":q[0]||(q[0]=K=>I.value=K),items:k,"value-key":"value",size:"xs",class:"relative z-120 w-16 shrink-0",ui:{content:"z-[121]"},disabled:x.value},null,8,["modelValue","disabled"])):E("",!0)]),a("div",Ty,d(te.label),1),a("div",My,d(te.subtext),1)])]))),128))])]),a("div",Ay,[a("div",zy,[f(U,{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",qy,d(t(i)("views.message.typeCard.watermark")),1)])]),_:1})}}}),Dy={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-4 sm:p-6"},Ey={class:"p-5"},By={key:0,class:"grid grid-cols-1 gap-6 lg:grid-cols-2 lg:items-center"},Fy={class:"space-y-3"},Ry={class:"min-w-20 shrink-0 text-sm text-gray-700 dark:text-gray-300"},Vy={class:"flex-1"},Oy={class:"h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800"},Py={class:"shrink-0 text-right"},Ny={class:"text-sm font-medium text-gray-900 dark:text-white"},jy={class:"ml-1 text-xs text-gray-400"},Uy={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Hy={class:"p-5"},Wy={class:"mb-5 grid grid-cols-2 gap-3 sm:grid-cols-4"},Ky={class:"p-3"},Yy={class:"font-mono text-xl font-bold text-gray-900 dark:text-white"},Gy={class:"mt-1 text-xs text-gray-500"},Qy={class:"p-3"},Jy={class:"font-mono text-xl font-bold text-indigo-600 dark:text-indigo-400"},Xy={class:"mt-1 text-xs text-gray-500"},Zy={class:"p-3"},ex={class:"font-mono text-xl font-bold text-pink-600 dark:text-pink-400"},tx={class:"mt-1 text-xs text-gray-500"},ax={class:"p-3"},sx={class:"font-mono text-xl font-bold text-emerald-600 dark:text-emerald-400"},nx={class:"mt-1 text-xs text-gray-500"},ox={class:"mb-5 rounded-lg border border-gray-200 p-4 dark:border-gray-700"},ix={class:"mb-2 text-xs font-medium text-gray-500 dark:text-gray-400"},rx={class:"flex items-center gap-4 text-sm"},lx={class:"flex items-center gap-1.5"},ux={class:"font-mono font-medium text-gray-900 dark:text-white"},cx={class:"flex items-center gap-1.5"},dx={class:"font-mono font-medium text-gray-900 dark:text-white"},mx={class:"flex items-center gap-1.5"},gx={class:"font-mono font-medium text-gray-900 dark:text-white"},px={class:"flex items-center gap-1.5"},fx={class:"font-mono font-medium text-gray-900 dark:text-white"},hx={class:"mt-3 grid grid-cols-3 gap-3 text-xs"},vx={class:"text-gray-500"},yx={class:"ml-1 font-medium text-emerald-600 dark:text-emerald-400"},xx={class:"text-gray-400"},bx={class:"text-gray-500"},kx={class:"ml-1 font-medium text-indigo-600 dark:text-indigo-400"},_x={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},wx={class:"text-xs text-gray-400"},$x={class:"p-5"},Cx={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Sx={class:"text-xs text-gray-400"},Ix={class:"p-5"},Tx={key:1,class:"flex h-48 items-center justify-center text-gray-400"},U2=le({__name:"TypeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(r){const i=r,{t:e}=Ie(),s=A(!0),n=A([]),u=A([]),o=A([]),c=A({textCount:0,avgLength:0,maxLength:0,shortCount:0}),m=A({p25:0,p50:0,p75:0,p90:0}),h=A(0),p=T(()=>{const w=[...n.value].sort((C,v)=>v.count-C.count);return{labels:w.map(C=>Aa(C.type,e)),values:w.map(C=>C.count)}}),_=T(()=>{const w=n.value.reduce((v,S)=>v+S.count,0);return[...n.value].sort((v,S)=>S.count-v.count).map(v=>({name:Aa(v.type,e),count:v.count,percentage:w>0?Math.round(v.count/w*100):0}))}),y=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"];function b(w){return y[w%y.length]}const x=T(()=>({labels:u.value.map(w=>String(w.len)),values:u.value.map(w=>w.count)})),k=T(()=>({labels:o.value.map(w=>w.range),values:o.value.map(w=>w.count)})),I=T(()=>c.value.textCount===0?0:Math.round(c.value.shortCount/c.value.textCount*100));async function $(){if(i.sessionId){s.value=!0;try{const w=at(),[C,v,S,V,B]=await Promise.all([w.getMessageTypeDistribution(i.sessionId,i.timeFilter),w.getMessageLengthDistribution(i.sessionId,i.timeFilter),w.getTextStats(i.sessionId,i.timeFilter),w.getTextLengthPercentiles(i.sessionId,i.timeFilter),w.getLongMessageCount(i.sessionId,i.timeFilter,30)]);n.value=C,u.value=v.detail,o.value=v.grouped,c.value=S,m.value=V,h.value=B}catch(w){console.error("[chart-message] Failed to load type analysis data:",w)}finally{s.value=!1}}}return fe(()=>[i.sessionId,i.timeFilter],()=>$(),{immediate:!0,deep:!0}),(w,C)=>(l(),g("div",{class:W(s.value?"h-full":"")},[s.value?(l(),P(t(ua),{key:0,variant:"page",text:t(e)("common.loading")},null,8,["text"])):(l(),g("div",Dy,[n.value.length>0?(l(),P(Ly,{key:0,"session-id":r.sessionId,"message-types":n.value,"text-stats":c.value,"time-filter":r.timeFilter},null,8,["session-id","message-types","text-stats","time-filter"])):E("",!0),f(t(ut),{title:t(e)("views.message.typeDistribution"),"show-divider":!1},{default:L(()=>[a("div",Ey,[p.value.values.length>0?(l(),g("div",By,[a("div",null,[f(t(La),{data:p.value,height:280,"show-legend":!1},null,8,["data"])]),a("div",null,[a("div",Fy,[(l(!0),g(ie,null,_e(_.value,(v,S)=>(l(),g("div",{key:S,class:"flex items-center gap-3"},[a("div",{class:"h-3 w-3 shrink-0 rounded-full",style:mt({backgroundColor:b(S)})},null,4),a("div",Ry,d(v.name),1),a("div",Vy,[a("div",Oy,[a("div",{class:"h-full rounded-full transition-all",style:mt({width:`${v.percentage}%`,backgroundColor:b(S)})},null,4)])]),a("div",Py,[a("span",Ny,d(v.count.toLocaleString()),1),a("span",jy,"("+d(v.percentage)+"%)",1)])]))),128))])])])):(l(),g("div",Uy,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"]),f(t(ut),{title:t(e)("views.message.typeAnalysis.textDepthTitle"),"show-divider":!1},{default:L(()=>[a("div",Hy,[a("div",Wy,[a("div",Ky,[a("div",Yy,d(c.value.textCount.toLocaleString()),1),a("div",Gy,d(t(e)("views.message.typeAnalysis.textTotal")),1)]),a("div",Qy,[a("div",Jy,d(c.value.avgLength||0),1),a("div",Xy,d(t(e)("views.message.typeAnalysis.avgLength")),1)]),a("div",Zy,[a("div",ex,d(m.value.p50),1),a("div",tx,d(t(e)("views.message.typeAnalysis.medianLength")),1)]),a("div",ax,[a("div",sx,d(c.value.maxLength),1),a("div",nx,d(t(e)("views.message.typeAnalysis.maxLength")),1)])]),a("div",ox,[a("div",ix,d(t(e)("views.message.typeAnalysis.percentiles")),1),a("div",rx,[a("div",lx,[C[0]||(C[0]=a("span",{class:"text-gray-500"},"P25",-1)),a("span",ux,d(m.value.p25),1)]),a("div",cx,[C[1]||(C[1]=a("span",{class:"text-gray-500"},"P50",-1)),a("span",dx,d(m.value.p50),1)]),a("div",mx,[C[2]||(C[2]=a("span",{class:"text-gray-500"},"P75",-1)),a("span",gx,d(m.value.p75),1)]),a("div",px,[C[3]||(C[3]=a("span",{class:"text-gray-500"},"P90",-1)),a("span",fx,d(m.value.p90),1)])]),a("div",hx,[a("div",null,[a("span",vx,d(t(e)("views.message.typeAnalysis.shortMessages")),1),a("span",yx,d(I.value)+"%",1),a("span",xx,"("+d(c.value.shortCount)+")",1)]),a("div",null,[a("span",bx,d(t(e)("views.message.typeAnalysis.essayMessages")),1),a("span",kx,d(h.value),1)])])])])]),_:1},8,["title"]),a("div",_x,[f(t(ut),{title:t(e)("views.message.lengthDetailTitle"),"show-divider":!1},{headerRight:L(()=>[a("span",wx,d(t(e)("views.message.lengthDetailHint")),1)]),default:L(()=>[a("div",$x,[x.value.values.some(v=>v>0)?(l(),P(t(xt),{key:0,data:x.value,height:200},null,8,["data"])):(l(),g("div",Cx,d(t(e)("views.message.noTextMessages")),1))])]),_:1},8,["title"]),f(t(ut),{title:t(e)("views.message.lengthGroupedTitle"),"show-divider":!1},{headerRight:L(()=>[a("span",Sx,d(t(e)("views.message.lengthGroupedHint")),1)]),default:L(()=>[a("div",Ix,[k.value.values.some(v=>v>0)?(l(),P(t(xt),{key:0,data:k.value,height:200},null,8,["data"])):(l(),g("div",Tx,d(t(e)("views.message.noTextMessages")),1))])]),_:1},8,["title"])])]))],2))}}),Mx={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Ax={class:"flex items-start gap-6 sm:gap-10"},zx={class:"min-w-0 flex-1"},qx={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},Lx={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},Dx={class:"mb-3 flex items-baseline gap-2"},Ex={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Bx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Fx={class:"font-bold text-3xl text-indigo-500 dark:text-indigo-400"},Rx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Vx={class:"flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},Ox={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Px={class:"font-bold text-xl text-pink-500 dark:text-pink-400"},Nx={class:"text-base font-medium text-gray-600 dark:text-gray-300"},jx={class:"text-base font-medium text-amber-600 dark:text-amber-400"},Ux={class:"flex shrink-0 flex-col items-center"},Hx={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},Wx={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Kx={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Yx={class:"min-w-0 flex-1"},Gx={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"},Jx={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"},Xx={class:"flex items-center gap-1.5"},Zx={class:"text-[9px] font-medium uppercase tracking-widest"},eb=le({__name:"TimeProfileCard",props:{hourlyActivity:{},weekdayActivity:{},dailyActivity:{}},setup(r){ha([bo,ko,va]);const{t:i}=Ie(),e=pa(),s=r,n=T(()=>s.dailyActivity.filter(v=>v.messageCount>0).length),u=T(()=>s.dailyActivity.reduce((v,S)=>v+S.messageCount,0)),o=T(()=>{if(s.dailyActivity.length===0)return{first:"",last:"",days:0};const v=[...s.dailyActivity].sort((B,D)=>B.date.localeCompare(D.date)),S=Ne(v[0].date),V=Ne(v[v.length-1].date);return{first:S.format("YYYY/MM/DD"),last:V.format("YYYY/MM/DD"),days:V.diff(S,"day")+1}}),c=T(()=>n.value===0?0:Math.round(u.value/n.value)),m=T(()=>s.dailyActivity.length===0?null:s.dailyActivity.reduce((v,S)=>S.messageCount>v.messageCount?S:v,s.dailyActivity[0])),h=T(()=>s.hourlyActivity.length===0?[]:[...s.hourlyActivity].sort((v,S)=>S.messageCount-v.messageCount).slice(0,3)),p=T(()=>{if(s.hourlyActivity.length===0&&s.weekdayActivity.length===0)return null;const v=o.value.days>0?n.value/o.value.days:0,S=s.weekdayActivity.filter(N=>N.weekday===6||N.weekday===7),V=s.weekdayActivity.filter(N=>N.weekday>=1&&N.weekday<=5),B=S.reduce((N,F)=>N+F.messageCount,0),D=V.reduce((N,F)=>N+F.messageCount,0),z=B+D,M=z>0?B/z:0,q=s.hourlyActivity.reduce((N,F)=>N+F.messageCount,0),U=s.hourlyActivity.filter(N=>N.hour>=22||N.hour<5).reduce((N,F)=>N+F.messageCount,0),Y=s.hourlyActivity.filter(N=>N.hour>=18&&N.hour<22).reduce((N,F)=>N+F.messageCount,0),te=q>0?U/q:0,K=q>0?Y/q:0;if(v>=.9)return{label:i("views.message.timeCard.personalityEveryday"),icon:"i-heroicons-fire"};if(M>=.55)return{label:i("views.message.timeCard.personalityWeekend"),icon:"i-heroicons-calendar"};if(M<=.2&&z>0)return{label:i("views.message.timeCard.personalityWeekday"),icon:"i-heroicons-briefcase"};if(te>=.3)return{label:i("views.message.timeCard.personalityNightOwl"),icon:"i-heroicons-moon"};if(K>=.4)return{label:i("views.message.timeCard.personalityEveningChat"),icon:"i-heroicons-sparkles"};const j=[...s.hourlyActivity].sort((N,F)=>F.messageCount-N.messageCount)[0];return j?j.hour>=5&&j.hour<9?{label:i("views.message.timeCard.personalityEarlyBird"),icon:"i-heroicons-sun"}:j.hour>=12&&j.hour<14?{label:i("views.message.timeCard.personalityLunchChat"),icon:"i-heroicons-clock"}:{label:i("views.message.timeCard.personalityDaytime"),icon:"i-heroicons-sun"}:null}),_=T(()=>{const v=s.weekdayActivity.filter(z=>z.weekday===6||z.weekday===7),S=s.weekdayActivity.filter(z=>z.weekday>=1&&z.weekday<=5),V=v.reduce((z,M)=>z+M.messageCount,0),B=S.reduce((z,M)=>z+M.messageCount,0),D=V+B;return D===0?0:Math.round(V/D*100)}),y=T(()=>[i("common.weekday.mon"),i("common.weekday.tue"),i("common.weekday.wed"),i("common.weekday.thu"),i("common.weekday.fri"),i("common.weekday.sat"),i("common.weekday.sun")]),b=T(()=>{if(s.weekdayActivity.length===0)return null;const v=[...s.weekdayActivity].sort((S,V)=>V.messageCount-S.messageCount)[0];return{name:y.value[v.weekday-1],count:v.messageCount}}),x=T(()=>[{icon:"i-heroicons-fire",label:i("views.message.timeCard.peakRecord"),value:m.value?Ne(m.value.date).format("MM/DD"):"-",subtext:m.value?i("views.message.timeCard.peakRecordDesc",{count:m.value.messageCount}):"",colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-clock",label:i("views.message.timeCard.topHoursLabel"),value:h.value.length>0?`${h.value[0].hour}:00`:"-",subtext:h.value.length>=2?h.value.map(v=>`${v.hour}:00`).join(" > "):"",colorClass:"text-cyan-600 dark:text-cyan-400"},{icon:"i-heroicons-calendar-days",label:i("views.message.timeCard.peakWeekdayLabel"),value:b.value?.name||"-",subtext:b.value?`${b.value.count.toLocaleString()}`:"",colorClass:"text-violet-600 dark:text-violet-400"},{icon:"i-heroicons-building-office",label:i("views.message.timeCard.weekendRatio"),value:`${_.value}%`,subtext:i("views.message.timeCard.weekendRatioDesc"),colorClass:"text-amber-600 dark:text-amber-400"}]),k=A(null);let I=null;function $(){k.value&&(I=ya(k.value,void 0,{renderer:"canvas"}),w())}function w(){if(!I)return;const v=new Map(s.hourlyActivity.map(D=>[D.hour,D.messageCount])),S=[];for(let D=0;D<24;D++)S.push(v.get(D)||0);const V=Math.max(...S,1),B=S.map(D=>{const z=D/V;return z>.8?e.value?"#f472b6":"#ec4899":z>.5?e.value?"#a78bfa":"#8b5cf6":e.value?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.08)"});I.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,z)=>`${z}`),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:S.map((D,z)=>({value:D,itemStyle:{color:B[z]}})),barWidth:"60%",itemStyle:{borderRadius:[2,2,0,0]}}]},{notMerge:!0})}function C(){I?.resize()}return fe(()=>s.hourlyActivity,()=>w()),fe(e,()=>{I?.dispose(),$()}),He(()=>{$(),window.addEventListener("resize",C)}),dt(()=>{window.removeEventListener("resize",C),I?.dispose()}),(v,S)=>{const V=Me;return l(),P(t(xa),null,{default:L(()=>[a("div",Mx,[a("div",Ax,[a("div",zx,[a("div",qx,[o.value.first?(l(),g("p",Lx,d(o.value.first)+" – "+d(o.value.last),1)):E("",!0),a("div",Dx,[a("span",Ex,d(o.value.days),1),a("span",Bx,d(t(i)("views.message.timeCard.heroDaysIn")),1),a("span",Fx,d(n.value),1),a("span",Rx,d(t(i)("views.message.timeCard.heroDaysActive")),1)]),a("div",Vx,[a("span",Ox,d(t(i)("views.message.timeCard.heroAvgPrefix")),1),a("span",Px,d(c.value),1),a("span",Nx,d(t(i)("views.message.timeCard.heroAvgSuffix")),1),p.value?(l(),g(ie,{key:0},[f(V,{name:p.value.icon,class:"ml-2 h-4 w-4 text-amber-500"},null,8,["name"]),a("span",jx,d(p.value.label),1)],64)):E("",!0)])])]),a("div",Ux,[a("div",Hx,d(t(i)("views.message.timeCard.hourlyDistribution")),1),a("div",{ref_key:"barRef",ref:k,style:{width:"180px",height:"110px"}},null,512)])])]),a("div",Wx,[S[0]||(S[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",Kx,[(l(!0),g(ie,null,_e(x.value,B=>(l(),g("div",{key:B.icon+B.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[f(V,{name:B.icon,class:W(["mt-0.5 h-3.5 w-3.5 shrink-0",B.colorClass])},null,8,["name","class"]),a("div",Yx,[a("div",{class:W(["truncate font-mono text-sm font-black leading-tight tabular-nums",B.colorClass])},d(B.value),3),a("div",Gx,d(B.label),1),a("div",Qx,d(B.subtext),1)])]))),128))])]),a("div",Jx,[a("div",Xx,[f(V,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),S[1]||(S[1]=a("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),a("span",Zx,d(t(i)("views.message.timeCard.watermark")),1)])]),_:1})}}}),tb={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-4 sm:p-6"},ab={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},sb={class:"p-5"},nb={class:"p-5"},ob={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},ib={class:"p-5"},rb={class:"p-5"},lb={key:1,class:"flex h-48 items-center justify-center text-gray-400"},ub={class:"text-xs text-gray-400"},cb={class:"p-5"},db={key:1,class:"flex h-48 items-center justify-center text-gray-400"},mb={class:"text-xs text-gray-400"},gb={class:"p-5"},pb={class:"flex items-center gap-2"},fb={class:"text-xs text-gray-400"},hb={class:"p-5"},vb={key:1,class:"flex h-32 items-center justify-center text-gray-400"},H2=le({__name:"TimeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(r){const i=r,{t:e}=Ie(),s=A(!0),n=A([]),u=A([]),o=A([]),c=A([]),m=A([]),h=A([]),p=A([]),_=["#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")]),b=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")]),x=T(()=>{const z=new Map(u.value.map(U=>[U.hour,U.messageCount])),M=[],q=[];for(let U=0;U<24;U++)M.push(`${U}`),q.push(z.get(U)||0);return{labels:M,values:q}}),k=T(()=>{const z=new Map(o.value.map(q=>[q.weekday,q.messageCount])),M=[];for(let q=1;q<=7;q++)M.push(z.get(q)||0);return{labels:y.value,values:M}}),I=T(()=>{const z=new Map(c.value.map(q=>[q.month,q.messageCount])),M=[];for(let q=1;q<=12;q++)M.push(z.get(q)||0);return{labels:b.value,values:M}}),$=T(()=>{const z=[...m.value].sort((M,q)=>M.year-q.year);return{labels:z.map(M=>String(M.year)),values:z.map(M=>M.messageCount)}}),w=T(()=>{const z=Array.from({length:24},(Y,te)=>`${te}:00`),M=y.value,q=n.value.reduce((Y,te)=>Y+te.count,0)||1,U=[];for(let Y=1;Y<=7;Y++)for(let te=0;te<24;te++){const K=o.value.find(F=>F.weekday===Y)?.messageCount||0,j=u.value.find(F=>F.hour===te)?.messageCount||0,N=Math.round(K*j/q);U.push([te,Y-1,N])}return{xLabels:z,yLabels:M,data:U}}),C=T(()=>h.value.map(z=>({date:z.date,value:z.messageCount}))),v=T(()=>{const z=new Set;return h.value.forEach(M=>{const q=parseInt(M.date.split("-")[0]);isNaN(q)||z.add(q)}),Array.from(z).sort((M,q)=>q-M)}),S=A(new Date().getFullYear()),V=T(()=>{const z=S.value;return C.value.filter(M=>M.date.startsWith(`${z}-`))}),B=T(()=>{if(p.value.length===0)return{};const z=[...new Set(p.value.map(te=>te.month))].sort(),M=new Map;if(p.value.forEach(te=>{const K=M.get(te.memberId);K?K.total+=te.count:M.set(te.memberId,{name:te.memberName,total:te.count})}),M.size<=2){const te=new Map;return p.value.forEach(K=>{te.set(K.month,(te.get(K.month)||0)+K.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:z,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:z.map(K=>te.get(K)||0)}]}}const Y=[...M.entries()].sort((te,K)=>K[1].total-te[1].total).slice(0,10).map(([te,K],j)=>{const N=new Map(p.value.filter(F=>F.memberId===te).map(F=>[F.month,F.count]));return{name:K.name,type:"line",stack:"total",areaStyle:{opacity:.3},smooth:!0,symbol:"none",itemStyle:{color:_[j%_.length]},data:z.map(F=>N.get(F)||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:z,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{type:"dashed",opacity:.3}}},series:Y}});async function D(){if(i.sessionId){s.value=!0;try{const z=at(),[M,q,U,Y,te,K,j]=await Promise.all([z.getMessageTypeDistribution(i.sessionId,i.timeFilter),z.getHourlyActivity(i.sessionId,i.timeFilter),z.getWeekdayActivity(i.sessionId,i.timeFilter),z.getMonthlyActivity(i.sessionId,i.timeFilter),z.getYearlyActivity(i.sessionId,i.timeFilter),z.getDailyActivity(i.sessionId,i.timeFilter),z.getMemberMonthlyTrend(i.sessionId,i.timeFilter)]);n.value=M,u.value=q,o.value=U,c.value=Y,m.value=te,h.value=K,p.value=j,v.value.length>0&&(S.value=v.value[0])}catch(z){console.error("[chart-message] Failed to load time analysis data:",z)}finally{s.value=!1}}}return fe(()=>[i.sessionId,i.timeFilter],()=>D(),{immediate:!0,deep:!0}),(z,M)=>{const q=Ha;return l(),g("div",{class:W(s.value?"h-full":"")},[s.value?(l(),P(t(ua),{key:0,variant:"page",text:t(e)("common.loading")},null,8,["text"])):(l(),g("div",tb,[h.value.length>0?(l(),P(eb,{key:0,"hourly-activity":u.value,"weekday-activity":o.value,"daily-activity":h.value},null,8,["hourly-activity","weekday-activity","daily-activity"])):E("",!0),a("div",ab,[f(t(ut),{title:t(e)("views.message.hourlyDistribution"),"show-divider":!1},{default:L(()=>[a("div",sb,[f(t(xt),{data:x.value,height:200},null,8,["data"])])]),_:1},8,["title"]),f(t(ut),{title:t(e)("views.message.weekdayDistribution"),"show-divider":!1},{default:L(()=>[a("div",nb,[f(t(xt),{data:k.value,height:200},null,8,["data"])])]),_:1},8,["title"])]),a("div",ob,[f(t(ut),{title:t(e)("views.message.monthlyDistribution"),"show-divider":!1},{default:L(()=>[a("div",ib,[f(t(xt),{data:I.value,height:200},null,8,["data"])])]),_:1},8,["title"]),f(t(ut),{title:t(e)("views.message.yearlyDistribution"),"show-divider":!1},{default:L(()=>[a("div",rb,[$.value.values.length>0?(l(),P(t(xt),{key:0,data:$.value,height:200},null,8,["data"])):(l(),g("div",lb,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"])]),f(t(ut),{title:t(e)("views.message.timeAnalysis.memberTrendTitle"),"show-divider":!1},{headerRight:L(()=>[a("span",ub,d(t(e)("views.message.timeAnalysis.memberTrendHint")),1)]),default:L(()=>[a("div",cb,[p.value.length>0?(l(),P(t(Ya),{key:0,option:B.value,height:280},null,8,["option"])):(l(),g("div",db,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"]),f(t(ut),{title:t(e)("views.message.timeHeatmap"),"show-divider":!1},{headerRight:L(()=>[a("span",mb,d(t(e)("views.message.heatmapHint")),1)]),default:L(()=>[a("div",gb,[f(t(Da),{data:w.value,height:320},null,8,["data"])])]),_:1},8,["title"]),f(t(ut),{title:t(e)("views.message.calendarHeatmap"),"show-divider":!1},{headerRight:L(()=>[a("div",pb,[a("span",fb,d(t(e)("views.message.calendarHint")),1),v.value.length>1?(l(),P(q,{key:0,modelValue:S.value,"onUpdate:modelValue":M[0]||(M[0]=U=>S.value=U),items:v.value.map(U=>({value:U,label:String(U)})),size:"xs",class:"w-20"},null,8,["modelValue","items"])):E("",!0)])]),default:L(()=>[a("div",hb,[V.value.length>0?(l(),P(t(Nr),{key:0,data:V.value,year:S.value,height:180},null,8,["data","year"])):(l(),g("div",vb,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"])]))],2)}}}),yb={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},xb={class:"flex items-center gap-6 sm:gap-10"},bb={class:"min-w-0 flex-1"},kb={class:"flex flex-col gap-2 text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},_b={key:0,class:"mb-0 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},wb={class:"flex items-baseline gap-x-1.5"},$b={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Cb={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Sb={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Ib={class:"flex items-baseline gap-x-1.5"},Tb={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Mb={class:"font-black text-3xl text-pink-500 dark:text-pink-400"},Ab={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},zb={key:1,class:"mt-1 flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},qb={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Lb=["onClick"],Db={key:0,class:"text-gray-400"},Eb={key:0,class:"hidden shrink-0 overflow-hidden rounded-lg sm:block"},Bb={class:"relative",style:{width:"360px",height:"220px"}},Fb={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Rb={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Vb={class:"min-w-0 flex-1"},Ob={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},Pb={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Nb={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"},jb={class:"flex items-center gap-1.5"},Ub={class:"text-[9px] font-medium uppercase tracking-widest"},Hb=le({__name:"TopicProfileCard",props:{totalMessages:{},totalWords:{},uniqueWords:{},topWords:{},topicWords:{},posTagStats:{},timeFilter:{}},emits:["wordClick"],setup(r,{emit:i}){const e=Is(()=>ga(()=>import("./EChartWordcloud-DM7UEHdK.js"),__vite__mapDeps([4,5,6,7,1,2,3]))),{t:s}=Ie(),n=r,u=i,o=T(()=>{const{startTs:x,endTs:k}=n.timeFilter??{};return x&&k?`${Ne(x*1e3).format("YYYY/MM/DD")} – ${Ne(k*1e3).format("YYYY/MM/DD")}`:""}),c=T(()=>(n.topicWords?.length?n.topicWords:n.topWords).slice(0,5)),m=T(()=>({words:(n.topicWords?.length?n.topicWords:n.topWords).slice(0,50).map(k=>({word:k.word,count:k.count,percentage:k.percentage}))})),h=T(()=>n.totalWords===0?0:Math.round(n.uniqueWords/n.totalWords*100)),p=T(()=>{if(!n.posTagStats?.length)return{key:"Balanced",label:s("quotes.topicProfile.styleBalanced"),desc:s("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"};const x=new Map(n.posTagStats.map(V=>[V.tag,V.count])),k=(x.get("n")||0)+(x.get("ns")||0)+(x.get("nt")||0)+(x.get("nz")||0),I=(x.get("v")||0)+(x.get("vn")||0)+(x.get("vd")||0),$=(x.get("a")||0)+(x.get("ad")||0)+(x.get("an")||0),w=k+I+$;if(w===0)return{key:"Balanced",label:s("quotes.topicProfile.styleBalanced"),desc:s("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"};const C=k/w,v=I/w,S=$/w;return C>.5?{key:"Encyclopedia",label:s("quotes.topicProfile.styleEncyclopedia"),desc:s("quotes.topicProfile.styleEncyclopediaDesc"),icon:"i-heroicons-book-open-solid",colorClass:"text-indigo-600 dark:text-indigo-400"}:v>.45?{key:"Action",label:s("quotes.topicProfile.styleAction"),desc:s("quotes.topicProfile.styleActionDesc"),icon:"i-heroicons-rocket-launch-solid",colorClass:"text-orange-600 dark:text-orange-400"}:S>.3?{key:"Expressive",label:s("quotes.topicProfile.styleExpressive"),desc:s("quotes.topicProfile.styleExpressiveDesc"),icon:"i-heroicons-paint-brush-solid",colorClass:"text-pink-600 dark:text-pink-400"}:{key:"Balanced",label:s("quotes.topicProfile.styleBalanced"),desc:s("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"}}),_=T(()=>{if(n.topWords.length===0)return{label:s("quotes.topicProfile.expressionMixed"),desc:s("quotes.topicProfile.expressionMixedDesc"),icon:"i-heroicons-chat-bubble-left-right-solid",colorClass:"text-emerald-600 dark:text-emerald-400"};const x=n.topWords.reduce(($,w)=>$+w.word.length*w.count,0),k=n.topWords.reduce(($,w)=>$+w.count,0),I=x/k;return I<2.5?{label:s("quotes.topicProfile.expressionCasual"),desc:s("quotes.topicProfile.expressionCasualDesc"),icon:"i-heroicons-face-smile-solid",colorClass:"text-amber-600 dark:text-amber-400"}:I>3.5?{label:s("quotes.topicProfile.expressionFormal"),desc:s("quotes.topicProfile.expressionFormalDesc"),icon:"i-heroicons-academic-cap-solid",colorClass:"text-violet-600 dark:text-violet-400"}:{label:s("quotes.topicProfile.expressionMixed"),desc:s("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:s("quotes.topicProfile.hotTopic"),value:c.value[0]?.word??"-",subtext:c.value[0]?s("quotes.topicProfile.hotTopicDesc",{count:c.value[0].count}):"",colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-sparkles-solid",label:s("quotes.topicProfile.richness"),value:s("quotes.topicProfile.richnessValue",{value:h.value}),subtext:s("quotes.topicProfile.richnessDesc",{unique:n.uniqueWords.toLocaleString(),total:n.totalWords.toLocaleString()}),colorClass:"text-blue-600 dark:text-blue-400"},{icon:p.value.icon,label:s("quotes.topicProfile.chatStyle"),value:p.value.label,subtext:p.value.desc,colorClass:p.value.colorClass},{icon:_.value.icon,label:s("quotes.topicProfile.expressionStyle"),value:_.value.label,subtext:_.value.desc,colorClass:_.value.colorClass}]),b=["#6366f1","#ec4899","#f97316","#22c55e","#3b82f6","#8b5cf6","#14b8a6","#f43f5e"];return(x,k)=>{const I=Me;return l(),P(t(xa),null,{default:L(()=>[a("div",yb,[a("div",xb,[a("div",bb,[a("div",kb,[o.value?(l(),g("p",_b,d(o.value),1)):E("",!0),a("div",wb,[a("span",$b,d(t(s)("quotes.topicProfile.heroPrefix")),1),a("span",Cb,d(r.totalMessages.toLocaleString()),1),a("span",Sb,d(t(s)("quotes.topicProfile.heroMiddle")),1)]),a("div",Ib,[a("span",Tb,d(t(s)("quotes.topicProfile.heroMiddleSecond")),1),a("span",Mb,d(r.uniqueWords.toLocaleString()),1),a("span",Ab,d(t(s)("quotes.topicProfile.heroSuffix")),1)]),c.value.length>0?(l(),g("div",zb,[a("span",qb,d(t(s)("quotes.topicProfile.topTopicsPrefix")),1),(l(!0),g(ie,null,_e(c.value,($,w)=>(l(),g(ie,{key:$.word},[a("span",{class:"cursor-pointer font-bold text-xl transition-opacity hover:opacity-70",style:mt({color:b[w%b.length]}),onClick:C=>u("wordClick",$.word)},d($.word),13,Lb),w<c.value.length-1?(l(),g("span",Db,"·")):E("",!0)],64))),128))])):E("",!0)])]),m.value.words.length>0?(l(),g("div",Eb,[a("div",Bb,[f(t(e),{data:m.value,height:"100%","max-words":50,"size-scale":.8,"draw-out-of-bound":!0,shape:"rectangle","color-scheme":"default",onWordClick:k[0]||(k[0]=$=>u("wordClick",$))},null,8,["data"])])])):E("",!0)])]),a("div",Fb,[k[1]||(k[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",Rb,[(l(!0),g(ie,null,_e(y.value,$=>(l(),g("div",{key:$.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[f(I,{name:$.icon,class:W(["mt-0.5 h-3.5 w-3.5 shrink-0",$.colorClass])},null,8,["name","class"]),a("div",Vb,[a("div",{class:W(["truncate font-mono text-sm font-black leading-tight tabular-nums",$.colorClass])},d($.value),3),a("div",Ob,d($.label),1),a("div",Pb,d($.subtext),1)])]))),128))])]),a("div",Nb,[a("div",jb,[f(I,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),k[2]||(k[2]=a("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),a("span",Ub,d(t(s)("quotes.topicProfile.watermark")),1)])]),_:1})}}}),Wb={class:"px-5 py-4 sm:px-6"},Kb={class:"mb-4 flex items-center gap-2"},Yb={class:"text-[15px] font-black tracking-tight text-gray-900 dark:text-white"},Gb={class:"flex flex-wrap justify-center gap-2"},Qb=["onClick"],Jb=le({__name:"SharedTopicsCard",props:{sessionId:{},timeFilter:{},dictType:{},excludeWords:{}},emits:["wordClick"],setup(r,{emit:i}){const{t:e}=Ie(),s=ja(),n=r,u=i,o=T(()=>s.locale),c=A([]),m=A([]),h=T(()=>c.value.slice(0,20)),p=["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(n.sessionId)try{m.value.length===0&&(m.value=await at().getMembers(n.sessionId));const y=[...m.value].sort((C,v)=>v.messageCount-C.messageCount).slice(0,2);if(y.length<2){c.value=[];return}const b={locale:o.value,timeFilter:n.timeFilter?{startTs:n.timeFilter.startTs,endTs:n.timeFilter.endTs}:void 0,topN:100,minCount:2,posFilterMode:"meaningful",enableStopwords:!0,dictType:n.dictType??"default",excludeWords:n.excludeWords?.length?[...n.excludeWords]:void 0},x=at(),[k,I]=await Promise.all([x.getWordFrequency(n.sessionId,{...b,memberId:y[0].id}),x.getWordFrequency(n.sessionId,{...b,memberId:y[1].id})]),$=new Map(I.words.map(C=>[C.word,C.count])),w=[];for(const C of k.words){const v=$.get(C.word);v&&w.push({word:C.word,countA:C.count,countB:v})}w.sort((C,v)=>v.countA+v.countB-(C.countA+C.countB)),c.value=w.slice(0,30)}catch(y){console.error("加载共同话题数据失败:",y),c.value=[]}}return fe(()=>n.sessionId,()=>{m.value=[]}),fe(()=>[n.sessionId,n.timeFilter,n.dictType,n.excludeWords],()=>{_()},{immediate:!0,deep:!0}),(y,b)=>{const x=Me;return h.value.length>0?(l(),P(t(wt),{key:0},{default:L(()=>[a("div",Wb,[a("div",Kb,[f(x,{name:"i-heroicons-link",class:"h-4 w-4 text-emerald-500"}),a("span",Yb,d(t(e)("quotes.topicProfile.sharedTopics")),1)]),a("div",Gb,[(l(!0),g(ie,null,_e(h.value,(k,I)=>(l(),g("span",{key:k.word,class:W(["cursor-pointer rounded-full px-3 py-1 text-xs font-bold transition-opacity hover:opacity-80",p[I%p.length]]),onClick:$=>u("wordClick",k.word)},d(k.word),11,Qb))),128))])])]),_:1})):E("",!0)}}}),Ps=Zn("wordFilter",()=>{const r=A([]),i=A(null),e=A({}),s=A(!1);function n(){return`wf_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function u($,w=[]){const C={id:n(),name:$,words:[...w],createdAt:Date.now()};return r.value.push(C),C}function o($,w){const C=r.value.find(v=>v.id===$);C&&(w.name!==void 0&&(C.name=w.name),w.words!==void 0&&(C.words=[...w.words]))}function c($){r.value=r.value.filter(w=>w.id!==$),i.value===$&&(i.value=null);for(const[w,C]of Object.entries(e.value))C===$&&delete e.value[w]}function m($){i.value=$}function h($,w){e.value[$]=w}function p($){delete e.value[$]}function _($){return $ in e.value?e.value[$]:i.value}function y($){const w=_($);return w?r.value.find(v=>v.id===w)?.words??[]:[]}function b($){return r.value.find(w=>w.id===$)}const x=T(()=>r.value.map($=>({label:$.name,value:$.id,isDefault:$.id===i.value,wordCount:$.words.length})));function k(){s.value=!0}function I(){s.value=!1}return{schemes:r,defaultSchemeId:i,sessionSchemeOverrides:e,showWordFilterModal:s,schemeOptions:x,createScheme:u,updateScheme:o,deleteScheme:c,setDefaultScheme:m,setSessionScheme:h,clearSessionScheme:p,getActiveSchemeId:_,getExcludeWords:y,getSchemeById:b,openModal:k,closeModal:I}},{persist:!1,backendPersist:{pick:["schemes","defaultSchemeId","sessionSchemeOverrides"],key:"wordFilter"}}),Xb={class:"flex flex-col",style:{height:"520px"}},Zb={class:"flex items-center justify-between border-b border-gray-200 px-6 py-4 dark:border-white/5"},ek={class:"flex items-center gap-3"},tk={class:"flex h-9 w-9 items-center justify-center rounded-xl bg-linear-to-br from-pink-400 to-pink-600"},ak={class:"text-lg font-semibold text-gray-900 dark:text-white"},sk={class:"flex flex-1 overflow-hidden"},nk={class:"flex w-[200px] shrink-0 flex-col border-r border-gray-200 dark:border-white/5"},ok={class:"flex items-center justify-between px-3 py-2"},ik={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},rk={class:"flex-1 overflow-y-auto px-2 pb-2"},lk=["onClick"],uk={class:"truncate text-sm"},ck={class:"ml-auto text-xs text-gray-400 dark:text-gray-500"},dk={key:0,class:"px-3 py-8 text-center text-xs text-gray-400 dark:text-gray-500"},mk={class:"flex flex-1 flex-col overflow-hidden"},gk={class:"flex-1 space-y-4 overflow-y-auto p-5"},pk={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},fk={class:"flex items-center gap-2"},hk={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},vk={class:"flex gap-2"},yk={class:"mb-1.5 flex items-center justify-between"},xk={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},bk={class:"ml-1 text-gray-400 dark:text-gray-500"},kk={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"},_k={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"},wk={class:"flex shrink-0 justify-end border-t border-gray-200 px-5 py-3 dark:border-white/5"},$k={key:1,class:"flex flex-1 flex-col items-center justify-center gap-3 text-gray-400 dark:text-gray-500"},Ck={class:"text-sm"},Sk=le({__name:"WordFilterModal",setup(r){const{t:i}=Ie(),e=Ps(),s=T({get:()=>e.showWordFilterModal,set:w=>w?e.openModal():e.closeModal()}),n=A(null),u=A(""),o=A(""),c=A(null),m=T(()=>n.value?e.getSchemeById(n.value)??null:null),h=T(()=>n.value===e.defaultSchemeId);fe(s,w=>{w&&(e.schemes.length>0&&!n.value&&(n.value=e.schemes[0].id),p())}),fe(n,()=>{p(),o.value=""});function p(){u.value=m.value?.name??""}function _(){const w=e.createScheme(i("wordFilter.defaultSchemeName"));n.value=w.id,Fe(()=>{c.value?.focus(),c.value?.select()})}function y(){if(!n.value)return;const w=e.schemes.findIndex(C=>C.id===n.value);if(e.deleteScheme(n.value),e.schemes.length>0){const C=Math.min(w,e.schemes.length-1);n.value=e.schemes[C].id}else n.value=null}function b(){!n.value||!u.value.trim()||e.updateScheme(n.value,{name:u.value.trim()})}function x(){n.value&&(h.value?e.setDefaultScheme(null):e.setDefaultScheme(n.value))}function k(){if(!n.value||!o.value.trim())return;const C=o.value.trim().split(/[,,\n\r\t;;|、\s]+/).map(B=>B.trim()).filter(B=>B.length>0);if(C.length===0)return;const v=m.value;if(!v)return;const S=new Set(v.words.map(B=>B.toLowerCase())),V=C.filter(B=>!S.has(B.toLowerCase()));V.length>0&&e.updateScheme(n.value,{words:[...v.words,...V]}),o.value=""}function I(w){if(!n.value)return;const C=m.value;C&&e.updateScheme(n.value,{words:C.words.filter(v=>v!==w)})}function $(){n.value&&e.updateScheme(n.value,{words:[]})}return(w,C)=>{const v=Me,S=Xe,V=Yt,B=Ls,D=lt;return l(),P(D,{open:s.value,"onUpdate:open":C[4]||(C[4]=z=>s.value=z),ui:{content:"max-w-3xl z-50"}},{content:L(()=>[a("div",Xb,[a("div",Zb,[a("div",ek,[a("div",tk,[f(v,{name:"i-heroicons-funnel",class:"h-4.5 w-4.5 text-white"})]),a("h2",ak,d(t(i)("wordFilter.title")),1)]),f(S,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:C[0]||(C[0]=z=>s.value=!1)})]),a("div",sk,[a("div",nk,[a("div",ok,[a("span",ik,d(t(i)("wordFilter.schemeList")),1),f(S,{icon:"i-heroicons-plus",size:"xs",variant:"ghost",color:"primary",onClick:_})]),a("div",rk,[(l(!0),g(ie,null,_e(t(e).schemes,z=>(l(),g("div",{key:z.id,class:W(["group mb-1 flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 transition-colors",n.value===z.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=>n.value=z.id},[z.id===t(e).defaultSchemeId?(l(),P(v,{key:0,name:"i-heroicons-star-solid",class:"h-3.5 w-3.5 shrink-0 text-amber-500"})):E("",!0),a("span",uk,d(z.name),1),a("span",ck,d(z.words.length),1)],10,lk))),128)),t(e).schemes.length===0?(l(),g("div",dk,d(t(i)("wordFilter.emptyScheme")),1)):E("",!0)])]),a("div",mk,[m.value?(l(),g(ie,{key:0},[a("div",gk,[a("div",null,[a("label",pk,d(t(i)("wordFilter.schemeName")),1),f(V,{ref_key:"nameInputRef",ref:c,modelValue:u.value,"onUpdate:modelValue":C[1]||(C[1]=z=>u.value=z),size:"sm",placeholder:t(i)("wordFilter.schemeNamePlaceholder"),onBlur:b,onKeydown:it(b,["enter"])},null,8,["modelValue","placeholder"])]),a("div",fk,[f(S,{size:"xs",variant:h.value?"solid":"soft",color:h.value?"warning":"neutral",icon:h.value?"i-heroicons-star-solid":"i-heroicons-star",onClick:x},{default:L(()=>[ne(d(h.value?t(i)("wordFilter.isDefault"):t(i)("wordFilter.setDefault")),1)]),_:1},8,["variant","color","icon"]),f(S,{size:"xs",variant:"soft",color:"error",icon:"i-heroicons-trash",onClick:y},{default:L(()=>[ne(d(t(i)("wordFilter.deleteScheme")),1)]),_:1})]),a("div",null,[a("label",hk,d(t(i)("wordFilter.addWords")),1),a("div",vk,[f(V,{modelValue:o.value,"onUpdate:modelValue":C[2]||(C[2]=z=>o.value=z),size:"sm",class:"flex-1",placeholder:t(i)("wordFilter.addWordsPlaceholder"),onKeydown:it(k,["enter"])},null,8,["modelValue","placeholder"]),f(S,{size:"sm",color:"primary",icon:"i-heroicons-plus",onClick:k},{default:L(()=>[ne(d(t(i)("wordFilter.add")),1)]),_:1})])]),a("div",null,[a("div",yk,[a("label",xk,[ne(d(t(i)("wordFilter.wordList"))+" ",1),a("span",bk,"("+d(m.value.words.length)+")",1)]),m.value.words.length>0?(l(),P(S,{key:0,size:"xs",variant:"ghost",color:"error",onClick:$},{default:L(()=>[ne(d(t(i)("wordFilter.clearAll")),1)]),_:1})):E("",!0)]),m.value.words.length>0?(l(),g("div",kk,[(l(!0),g(ie,null,_e(m.value.words,z=>(l(),P(B,{key:z,color:"neutral",variant:"subtle",class:"group/badge cursor-default gap-1 pr-1"},{default:L(()=>[ne(d(z)+" ",1),f(v,{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=>I(z)},null,8,["onClick"])]),_:2},1024))),128))])):(l(),g("div",_k,d(t(i)("wordFilter.emptyWords")),1))])]),a("div",wk,[f(S,{color:"primary",variant:"soft",onClick:C[3]||(C[3]=z=>s.value=!1)},{default:L(()=>[ne(d(t(i)("wordFilter.close")),1)]),_:1})])],64)):(l(),g("div",$k,[f(v,{name:"i-heroicons-funnel",class:"h-10 w-10"}),a("p",Ck,d(t(i)("wordFilter.selectOrCreate")),1),f(S,{size:"sm",color:"primary",variant:"soft",icon:"i-heroicons-plus",onClick:_},{default:L(()=>[ne(d(t(i)("wordFilter.createScheme")),1)]),_:1})]))])])])]),_:1},8,["open"])}}}),Ik={class:"main-content mx-auto max-w-[920px] space-y-6 p-4 sm:p-6"},Tk={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"},Mk={class:"flex min-w-0 items-start gap-3"},Ak={class:"min-w-0 text-sm text-primary-700 dark:text-primary-300"},zk={class:"flex shrink-0 flex-wrap gap-2"},qk={key:1,class:"space-y-6"},Lk={class:"flex flex-col gap-6 p-4 sm:p-6 lg:flex-row"},Dk={class:"flex min-w-0 flex-1 flex-col"},Ek={class:"relative w-full",style:{"aspect-ratio":"16 / 9"}},Bk={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"},Fk={class:"text-xs font-medium"},Rk={class:"px-4 text-center text-[11px]"},Vk={key:0,class:"mt-2 text-center text-xs text-gray-500 dark:text-gray-400"},Ok={class:"w-full shrink-0 space-y-4 lg:w-[280px]"},Pk={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Nk={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},jk={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Uk={key:0},Hk={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Wk={class:"space-y-2"},Kk={class:"text-xs text-gray-400 dark:text-gray-500"},Yk={key:1},Gk={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Qk={class:"flex items-center"},Jk={key:2,class:"space-y-2"},Xk={class:"flex items-center justify-between"},Zk={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},e1={class:"flex gap-1"},t1={class:"flex max-h-[360px] flex-wrap gap-1.5 overflow-y-auto"},a1={key:0,class:"ml-1 opacity-60"},s1={class:"mb-2 flex items-center justify-between"},n1={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},o1={key:0,class:"mt-1 text-xs text-gray-400 dark:text-gray-500"},i1={class:"space-y-4"},r1={class:"text-sm text-gray-600 dark:text-gray-300"},l1={class:"flex justify-end gap-2"},u1="default",fs="chatlab_zhTW_dict_prompt_dismissed",W2=le({__name:"WordcloudTab",props:{sessionId:{},timeFilter:{},memberId:{},showSharedTopics:{type:Boolean},enableNodeNlpFeatures:{type:Boolean,default:!0},enableRecordNavigation:{type:Boolean,default:!0}},setup(r){const i=Is(()=>ga(()=>import("./EChartWordcloud-DM7UEHdK.js"),__vite__mapDeps([4,5,6,7,1,2,3]))),{t:e}=Ie(),s=ja(),n=zt(),u=Ps(),o=ft(),c=r,m=A(!0);co(m);const h=A([]),p=A({totalMessages:0,totalWords:0,uniqueWords:0}),_=A(1.25),y=A(150),b=T(()=>{const pe=h.value.slice(0,y.value),ye=pe.reduce((oe,ge)=>oe+ge.count,0);return{words:pe.map(oe=>({word:oe.word,count:oe.count,percentage:ye>0?Math.round(oe.count/ye*1e4)/100:0}))}}),x=A(c.enableNodeNlpFeatures?"meaningful":"all"),k=A(!0),I=A([]),$=A([]),w=A(new Map),C=["n","nr","ns","nt","nz","nw","vn","a","an"],v=A([]),S=T(()=>b.value.words.map(pe=>({word:pe.word,count:pe.count,percentage:pe.percentage??0}))),V=T(()=>[...w.value.entries()].map(([pe,ye])=>({tag:pe,count:ye}))),B=A(null),D=T({get:()=>u.getActiveSchemeId(c.sessionId),set:pe=>u.setSessionScheme(c.sessionId,pe)}),z=T(()=>[{label:e("wordFilter.noFilter"),value:"__none__"},...u.schemeOptions.map(pe=>({label:pe.isDefault?`${pe.label} ★`:pe.label,value:pe.value}))]),M=T({get:()=>D.value??"__none__",set:pe=>{D.value=pe==="__none__"?null:pe}}),q=T(()=>u.getExcludeWords(c.sessionId)),U=A("default"),Y=A([]),te=A(!1),K=A(null),j=A(!1),N=A(!c.enableNodeNlpFeatures),F=T(()=>s.locale),Z=T(()=>s.locale==="zh-TW"),ue=T(()=>F.value.startsWith("zh")),ve=T(()=>Y.value.filter(pe=>pe.downloaded).map(pe=>({label:e(`quotes.wordcloud.dict.${pe.id==="zh-CN"?"zhCN":pe.id==="zh-TW"?"zhTW":pe.id}`),value:pe.id}))),ae=T(()=>Y.value.some(pe=>pe.downloaded)),re=T(()=>!c.enableNodeNlpFeatures||!ue.value||N.value),H=T(()=>Y.value.filter(pe=>!pe.downloaded));async function be(){if(c.enableNodeNlpFeatures)try{Y.value=await ns("/nlp/dicts"),Z.value&&U.value==="default"&&Y.value.find(oe=>oe.id==="zh-TW")?.downloaded&&(U.value="zh-TW"),Y.value.find(ye=>ye.id==="zh-CN")?.downloaded&&U.value==="default"&&(U.value="zh-CN")}catch(pe){console.error("Failed to get dict list:",pe)}finally{N.value=!0}}async function Te(pe){te.value=!0,K.value=pe;try{const ye=await eo(`/nlp/dicts/${pe}/download`);ye.success?(await be(),U.value=pe,o.success(e("quotes.wordcloud.dict.downloadSuccess"))):o.fail(e("quotes.wordcloud.dict.downloadFailed"),{description:ye.error})}catch{o.fail(e("quotes.wordcloud.dict.downloadFailed"))}finally{te.value=!1,K.value=null,j.value=!1}}function we(){j.value=!1,localStorage.setItem(fs,"true")}function ce(){const pe=Y.value.find(ye=>ye.id==="zh-TW");Z.value&&pe&&!pe.downloaded&&!localStorage.getItem(fs)&&(j.value=!0)}const X=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"}]),Q=[{label:"80",value:80},{label:"100",value:100},{label:"150",value:150},{label:"200",value:200},{label:"300",value:300}],xe=Math.max(...Q.map(pe=>pe.value)),Ae=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}]),ze=T(()=>$.value.map(pe=>({label:pe.name,tag:pe.tag,value:pe.tag,count:w.value.get(pe.tag)||0,meaningful:pe.meaningful})));async function je(){if(c.enableNodeNlpFeatures)try{const pe=await ns("/nlp/pos-tags");$.value=pe,I.value=pe.filter(ye=>ye.meaningful).map(ye=>ye.tag)}catch(pe){console.error("加载词性标签失败:",pe)}}let Je=0;async function Re(){if(!c.sessionId||!re.value)return;const pe=++Je;try{const ye=await at().getWordFrequency(c.sessionId,{locale:F.value,timeFilter:c.timeFilter?{startTs:c.timeFilter.startTs,endTs:c.timeFilter.endTs}:void 0,memberId:B.value??void 0,topN:50,minCount:2,posFilterMode:c.enableNodeNlpFeatures?"custom":"all",customPosTags:c.enableNodeNlpFeatures?[...C]:void 0,enableStopwords:!0,dictType:U.value,excludeWords:q.value.length>0?[...q.value]:void 0});if(pe!==Je)return;v.value=ye.words.map(oe=>({word:oe.word,count:oe.count,percentage:oe.percentage}))}catch(ye){if(console.error("加载话题迷你词云数据失败:",ye),pe!==Je)return;v.value=[]}}let Qe=0;async function et(){if(!c.sessionId||!re.value)return;const pe=++Qe;h.value.length===0&&(m.value=!0);try{const ye=await at().getWordFrequency(c.sessionId,{locale:F.value,timeFilter:c.timeFilter?{startTs:c.timeFilter.startTs,endTs:c.timeFilter.endTs}:void 0,memberId:B.value??void 0,topN:xe,minCount:2,posFilterMode:c.enableNodeNlpFeatures?x.value:"all",customPosTags:c.enableNodeNlpFeatures&&x.value==="custom"?[...I.value]:void 0,enableStopwords:k.value,dictType:U.value,excludeWords:q.value.length>0?[...q.value]:void 0});if(pe!==Qe)return;if(h.value=ye.words.map(oe=>({word:oe.word,count:oe.count,percentage:oe.percentage})),p.value={totalMessages:ye.totalMessages,totalWords:ye.totalWords,uniqueWords:ye.uniqueWords},ye.posTagStats){const oe=new Map;for(const ge of ye.posTagStats)oe.set(ge.tag,ge.count);w.value=oe}}catch(ye){if(console.error("加载词频数据失败:",ye),pe!==Qe)return;h.value=[]}finally{pe===Qe&&(m.value=!1)}}fe(()=>c.sessionId,()=>{B.value=null,h.value=[],v.value=[],p.value={totalMessages:0,totalWords:0,uniqueWords:0},w.value=new Map}),fe(()=>[c.sessionId,c.timeFilter,B.value,x.value,k.value,U.value,q.value,re.value],()=>{et()},{immediate:!0,deep:!0}),fe(()=>[c.sessionId,c.timeFilter,B.value,U.value,q.value,re.value],()=>{Re()},{immediate:!0,deep:!0}),fe(I,()=>{x.value==="custom"&&et()},{deep:!0}),fe(F,()=>{et()});function Ee(pe){c.enableRecordNavigation&&n.openChatRecordDrawer({keywords:[pe]})}return He(async()=>{c.enableNodeNlpFeatures&&(je(),await be(),ce())}),(pe,ye)=>{const oe=Me,ge=Xe,R=Wa,ee=Ls,J=lt;return l(),g("div",Ik,[c.enableNodeNlpFeatures&&ue.value&&!ae.value?(l(),g("div",Tk,[a("div",Mk,[f(oe,{name:"i-heroicons-information-circle",class:"mt-0.5 shrink-0 text-xl text-primary-500"}),a("p",Ak,d(t(e)("quotes.wordcloud.dict.needDownload")),1)]),a("div",zk,[(l(!0),g(ie,null,_e(Y.value,de=>(l(),P(ge,{key:de.id,size:"sm",color:"primary",loading:te.value&&K.value===de.id,disabled:te.value&&K.value!==de.id,icon:"i-heroicons-arrow-down-tray",onClick:Ce=>Te(de.id)},{default:L(()=>[ne(d(t(e)(`quotes.wordcloud.dict.download_${de.id}`,de.label)),1)]),_:2},1032,["loading","disabled","onClick"]))),128))])])):E("",!0),re.value?(l(),g("div",qk,[m.value&&S.value.length===0?(l(),P(t(ua),{key:0,text:t(e)("quotes.wordcloud.loading"),class:"py-8"},null,8,["text"])):E("",!0),f(Hb,{"total-messages":p.value.totalMessages,"total-words":p.value.totalWords,"unique-words":p.value.uniqueWords,"top-words":S.value,"topic-words":v.value,"pos-tag-stats":V.value,"time-filter":c.timeFilter,onWordClick:Ee},null,8,["total-messages","total-words","unique-words","top-words","topic-words","pos-tag-stats","time-filter"]),c.showSharedTopics?(l(),P(Jb,{key:1,"session-id":c.sessionId,"time-filter":c.timeFilter,"dict-type":U.value,"exclude-words":q.value,onWordClick:Ee},null,8,["session-id","time-filter","dict-type","exclude-words"])):E("",!0),f(t(ut),{title:t(e)("quotes.wordcloud.stats.wordsLabel"),"show-divider":!1},{default:L(()=>[a("div",Lk,[a("div",Dk,[a("div",Ek,[m.value?(l(),P(t(ua),{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"])):S.value.length===0?(l(),g("div",Bk,[f(oe,{name:"i-heroicons-chat-bubble-bottom-center-text",class:"text-2xl"}),a("p",Fk,d(t(e)("quotes.wordcloud.empty.title")),1),a("p",Rk,d(t(e)("quotes.wordcloud.empty.description")),1)])):(l(),P(t(i),{key:2,data:b.value,height:"100%","max-words":y.value,"color-scheme":u1,"size-scale":_.value,loading:m.value,onWordClick:Ee},null,8,["data","max-words","size-scale","loading"]))]),c.enableRecordNavigation?(l(),g("p",Vk,d(t(e)("quotes.wordcloud.stats.clickHint")),1)):E("",!0)]),a("div",Ok,[a("div",null,[a("h4",Pk,d(t(e)("quotes.wordcloud.config.maxWords")),1),f(t(St),{modelValue:y.value,"onUpdate:modelValue":ye[0]||(ye[0]=de=>y.value=de),size:"xs",items:Q},null,8,["modelValue"])]),a("div",null,[a("h4",Nk,d(t(e)("quotes.wordcloud.config.sizeScale")),1),f(t(St),{modelValue:_.value,"onUpdate:modelValue":ye[1]||(ye[1]=de=>_.value=de),size:"xs",items:Ae.value},null,8,["modelValue","items"])]),a("div",null,[a("h4",jk,d(t(e)("quotes.wordcloud.config.userFilter")),1),f(uy,{modelValue:B.value,"onUpdate:modelValue":ye[2]||(ye[2]=de=>B.value=de),"session-id":c.sessionId,class:"w-full"},null,8,["modelValue","session-id"])]),c.enableNodeNlpFeatures?(l(),g("div",Uk,[a("h4",Hk,d(t(e)("quotes.wordcloud.config.dict")),1),a("div",Wk,[ve.value.length>1?(l(),P(t(St),{key:0,modelValue:U.value,"onUpdate:modelValue":ye[3]||(ye[3]=de=>U.value=de),size:"xs",items:ve.value},null,8,["modelValue","items"])):E("",!0),(l(!0),g(ie,null,_e(H.value,de=>(l(),g("div",{key:de.id,class:"flex items-center gap-2"},[f(ge,{size:"xs",variant:"soft",color:"primary",loading:te.value&&K.value===de.id,disabled:te.value&&K.value!==de.id,icon:"i-heroicons-arrow-down-tray",onClick:Ce=>Te(de.id)},{default:L(()=>[ne(d(t(e)(`quotes.wordcloud.dict.download_${de.id}`,t(e)("quotes.wordcloud.dict.download"))),1)]),_:2},1032,["loading","disabled","onClick"]),a("span",Kk,d(t(e)("quotes.wordcloud.dict.downloadHint")),1)]))),128))])])):E("",!0),c.enableNodeNlpFeatures?(l(),g("div",Yk,[a("h4",Gk,d(t(e)("quotes.wordcloud.config.posFilter")),1),f(t(St),{modelValue:x.value,"onUpdate:modelValue":ye[4]||(ye[4]=de=>x.value=de),size:"xs",items:X.value},null,8,["modelValue","items"])])):E("",!0),a("div",Qk,[f(R,{modelValue:k.value,"onUpdate:modelValue":ye[5]||(ye[5]=de=>k.value=de),label:t(e)("quotes.wordcloud.config.enableStopwords")},null,8,["modelValue","label"])]),c.enableNodeNlpFeatures&&x.value==="custom"?(l(),g("div",Jk,[a("div",Xk,[a("h4",Zk,d(t(e)("quotes.wordcloud.posFilter.customHint")),1),a("div",e1,[f(ge,{size:"xs",variant:"ghost",color:"neutral",onClick:ye[6]||(ye[6]=de=>I.value=$.value.filter(Ce=>Ce.meaningful).map(Ce=>Ce.tag))},{default:L(()=>[ne(d(t(e)("quotes.wordcloud.posFilter.selectMeaningful")),1)]),_:1}),f(ge,{size:"xs",variant:"ghost",color:"neutral",onClick:ye[7]||(ye[7]=de=>I.value=$.value.map(Ce=>Ce.tag))},{default:L(()=>[ne(d(t(e)("quotes.wordcloud.posFilter.selectAll")),1)]),_:1}),f(ge,{size:"xs",variant:"ghost",color:"neutral",onClick:ye[8]||(ye[8]=de=>I.value=[])},{default:L(()=>[ne(d(t(e)("quotes.wordcloud.posFilter.clearAll")),1)]),_:1})])]),a("div",t1,[(l(!0),g(ie,null,_e(ze.value,de=>(l(),P(ee,{key:de.value,color:I.value.includes(de.value)?"primary":"neutral",variant:I.value.includes(de.value)?"solid":"outline",class:"cursor-pointer select-none transition-colors",onClick:()=>{I.value.includes(de.value)?I.value=I.value.filter(Ce=>Ce!==de.value):I.value=[...I.value,de.value]}},{default:L(()=>[ne(d(de.label)+" ",1),de.count>0?(l(),g("span",a1,"("+d(de.count)+")",1)):E("",!0)]),_:2},1032,["color","variant","onClick"]))),128))])])):E("",!0),a("div",null,[a("div",s1,[a("h4",n1,d(t(e)("wordFilter.filterScheme")),1),f(ge,{size:"xs",variant:"ghost",color:"neutral",icon:"i-heroicons-cog-6-tooth","aria-label":t(e)("wordFilter.manage"),onClick:ye[9]||(ye[9]=de=>t(u).openModal())},null,8,["aria-label"])]),f(t(St),{modelValue:M.value,"onUpdate:modelValue":ye[10]||(ye[10]=de=>M.value=de),size:"xs",items:z.value},null,8,["modelValue","items"]),q.value.length>0?(l(),g("p",o1,d(t(e)("wordFilter.activeCount",{count:q.value.length})),1)):E("",!0)])])])]),_:1},8,["title"])])):E("",!0),c.enableNodeNlpFeatures?(l(),P(J,{key:2,open:j.value,"onUpdate:open":ye[12]||(ye[12]=de=>j.value=de),title:t(e)("quotes.wordcloud.dict.promptTitle")},{body:L(()=>[a("div",i1,[a("p",r1,d(t(e)("quotes.wordcloud.dict.promptDescription")),1),a("div",l1,[f(ge,{variant:"ghost",color:"neutral",onClick:we},{default:L(()=>[ne(d(t(e)("quotes.wordcloud.dict.promptLater")),1)]),_:1}),f(ge,{color:"primary",loading:te.value,onClick:ye[11]||(ye[11]=de=>Te("zh-TW"))},{default:L(()=>[ne(d(t(e)("quotes.wordcloud.dict.promptDownload")),1)]),_:1},8,["loading"])])])]),_:1},8,["open","title"])):E("",!0),f(Sk)])}}});function K2(r){const i=T(()=>to(r)),e=T(()=>{const n=i.value;return n.length<2?!1:new Set(n.map(o=>Ne(o.date).year())).size>1}),s=T(()=>{const n=i.value,u=50;if(n.length<=u){const h=e.value?"YYYY/MM/DD":"MM/DD";return{labels:n.map(p=>Ne(p.date).format(h)),values:n.map(p=>p.messageCount)}}const o=Math.ceil(n.length/u),c=[],m=[];for(let h=0;h<n.length;h+=o){const p=n.slice(h,h+o);if(p.length===0)continue;const _=Math.floor(p.length/2),y=p[_].date,b=e.value?"YYYY/MM/DD":"MM/DD";c.push(Ne(y).format(b));const x=p.reduce((I,$)=>I+$.messageCount,0),k=Math.round(x/p.length);m.push(k)}return{labels:c,values:m}});return{isMultiYear:e,dailyChartData:s}}const c1=86400;function da(r){return typeof r=="number"&&Number.isFinite(r)}function d1(r){return da(r?.startTs)&&da(r?.endTs)}function Ns(r,i){const e=i?.startTs??r?.start,s=i?.endTs??r?.end;return!da(e)||!da(s)||s<e?null:{start:e,end:s}}function m1(r,i=0){return!r||r.end<r.start?0:Math.max(Math.ceil((r.end-r.start)/c1),i,1)}function g1(r){return r?[Ne.unix(r.start).format("YYYY-MM-DD"),Ne.unix(r.end).format("YYYY-MM-DD")]:null}function p1(r,i){const{t:e}=Ie(),s=T(()=>Ns(r.timeRange,r.timeFilter)),n=T(()=>d1(r.timeFilter)),u=T(()=>r.dailyActivity.filter(V=>V.messageCount>0).length),o=T(()=>m1(s.value,u.value)),c=T(()=>n.value?r.filteredMessageCount:r.session.messageCount),m=T(()=>n.value?r.filteredMemberCount??r.session.memberCount:r.session.memberCount),h=T(()=>o.value),p=T(()=>h.value===0?0:Math.round(c.value/h.value)),_=T(()=>o.value===0?0:Math.round(c.value/o.value)),y=T(()=>r.messageTypes.find(B=>B.type===1)?.count||0),b=T(()=>r.hourlyActivity.length?r.hourlyActivity.reduce((V,B)=>B.messageCount>V.messageCount?B:V,r.hourlyActivity[0]):null),x=T(()=>i.value.length?i.value.reduce((V,B)=>B.messageCount>V.messageCount?B:V,i.value[0]):null),k=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")]),I=T(()=>{if(!i.value.length)return{weekday:0,weekend:0};const V=i.value.filter(z=>z.weekday>=1&&z.weekday<=5).reduce((z,M)=>z+M.messageCount,0),B=i.value.filter(z=>z.weekday>=6&&z.weekday<=7).reduce((z,M)=>z+M.messageCount,0),D=V+B;return{weekday:D>0?Math.round(V/D*100):0,weekend:D>0?Math.round(B/D*100):0}}),$=T(()=>r.dailyActivity.length?r.dailyActivity.reduce((V,B)=>B.messageCount>V.messageCount?B:V,r.dailyActivity[0]):null),w=T(()=>o.value),C=T(()=>w.value>0?Math.round(u.value/w.value*100):0),v=T(()=>{if(!r.hourlyActivity.length)return{count:0,ratio:0};const V=r.hourlyActivity.reduce((D,z)=>D+z.messageCount,0),B=r.hourlyActivity.filter(D=>D.hour>=0&&D.hour<=4).reduce((D,z)=>D+z.messageCount,0);return{count:B,ratio:V>0?Math.round(B/V*100):0}}),S=T(()=>{if(!r.dailyActivity.length)return 0;const V=[...r.dailyActivity].filter(z=>z.messageCount>0).sort((z,M)=>Ne(z.date).valueOf()-Ne(M.date).valueOf());if(V.length===0)return 0;let B=1,D=1;for(let z=1;z<V.length;z++){const M=Ne(V[z-1].date);Ne(V[z].date).diff(M,"day")===1?D++:(D>B&&(B=D),D=1)}return D>B&&(B=D),B});return{durationDays:o,displayMessageCount:c,displayMemberCount:m,dailyAvgMessages:_,totalDurationDays:h,totalDailyAvgMessages:p,imageCount:y,peakHour:b,peakWeekday:x,weekdayNames:k,weekdayVsWeekend:I,peakDay:$,activeDays:u,totalDays:w,activeRate:C,lateNightChat:v,maxConsecutiveDays:S}}function f1(r){const i=A([]);let e=0;async function s(){const n=++e,u=r.sessionId();if(!u){i.value=[];return}try{const o=await at().getWeekdayActivity(u,r.timeFilter());n===e&&(i.value=o)}catch(o){n===e&&console.error("Failed to load weekday activity:",o)}}return fe([r.sessionId,r.timeFilter],()=>s(),{immediate:!0,deep:!0}),{weekdayActivity:i}}const h1={key:0,class:"relative z-10 px-5 pb-5 pt-2 sm:px-8 sm:pb-6"},v1={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},y1={class:"min-w-0"},x1={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},b1={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},k1={key:1,class:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4"},_1={class:"text-sm text-gray-500"},w1={class:"text-sm text-gray-500"},$1={class:"ml-1 font-semibold text-pink-500"},C1={class:"text-sm text-gray-500"},S1={class:"text-sm text-gray-500"},I1={class:"text-sm text-gray-500"},T1={class:"text-sm text-gray-500"},M1={class:"text-sm text-gray-500"},A1={class:"text-sm text-gray-500"},z1=le({__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:i}=Ie(),e=r,s=T(()=>[{icon:"i-heroicons-chat-bubble-left-right",label:i("analysis.overview.statCards.dailyAvgMessages"),value:i("analysis.overview.statCards.messagesCount",{count:e.dailyAvgMessages}),subtext:i("analysis.overview.statCards.daysCount",{count:e.durationDays}),colorClass:"text-blue-600 dark:text-blue-400"},{icon:"i-heroicons-photo",label:i("analysis.overview.statCards.imageMessages"),value:i("analysis.overview.statCards.imagesCount",{count:e.imageCount}),subtext:`${i("analysis.overview.statCards.peakHour")} ${e.peakHour?.hour||0}:00`,colorClass:"text-pink-600 dark:text-pink-400"},{icon:"i-heroicons-calendar-days",label:i("analysis.overview.statCards.mostActiveWeekday"),value:e.peakWeekday?e.weekdayNames[e.peakWeekday.weekday-1]:"-",subtext:i("analysis.overview.statCards.messagesOnDay",{count:e.peakWeekday?.messageCount??0}),colorClass:"text-amber-600 dark:text-amber-400"},{icon:"i-heroicons-sun",label:i("analysis.overview.statCards.weekendActivity"),value:`${e.weekdayVsWeekend.weekend}%`,subtext:i("analysis.overview.statCards.weekendRatio"),colorClass:"text-green-600 dark:text-green-400"},{icon:"i-heroicons-fire",label:i("analysis.overview.statCards.mostActiveDate"),value:e.peakDay?Ne(e.peakDay.date).format("MM/DD"):"-",subtext:i("analysis.overview.statCards.messagesOnDay",{count:e.peakDay?.messageCount??0}),colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-moon",label:i("analysis.overview.statCards.lateNightChat"),value:i("analysis.overview.statCards.messagesCount",{count:e.lateNightCount}),subtext:i("analysis.overview.statCards.lateNightRatio",{ratio:e.lateNightRatio}),colorClass:"text-indigo-600 dark:text-indigo-400"},{icon:"i-heroicons-bolt",label:i("analysis.overview.statCards.consecutiveStreak"),value:i("analysis.overview.statCards.daysStreak",{count:e.maxConsecutiveDays}),subtext:i("analysis.overview.statCards.longestStreak"),colorClass:"text-amber-600 dark:text-amber-400"},{icon:"i-heroicons-chart-bar",label:i("analysis.overview.statCards.activityRate"),value:`${e.activeRate}%`,subtext:i("analysis.overview.statCards.activeDaysRatio"),colorClass:"text-gray-900 dark:text-white"}]);return(n,u)=>{const o=Me;return r.flat?(l(),g("div",h1,[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",v1,[(l(!0),g(ie,null,_e(s.value,c=>(l(),g("div",{key:c.icon+c.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[f(o,{name:c.icon,class:W(["mt-0.5 h-3.5 w-3.5 shrink-0",c.colorClass])},null,8,["name","class"]),a("div",y1,[a("div",{class:W(["truncate font-mono text-sm font-black leading-tight tabular-nums",c.colorClass])},d(c.value),3),a("div",x1,d(c.label),1),a("div",b1,d(c.subtext),1)])]))),128))])])):(l(),g("div",k1,[f(t(vt),{label:t(i)("analysis.overview.statCards.dailyAvgMessages"),value:t(i)("analysis.overview.statCards.messagesCount",{count:r.dailyAvgMessages}),icon:"i-heroicons-chat-bubble-left-right","icon-bg":"blue"},{subtext:L(()=>[a("span",_1,d(t(i)("analysis.overview.statCards.daysCount",{count:r.durationDays})),1)]),_:1},8,["label","value"]),f(t(vt),{label:t(i)("analysis.overview.statCards.imageMessages"),value:t(i)("analysis.overview.statCards.imagesCount",{count:r.imageCount}),icon:"i-heroicons-photo","icon-bg":"pink"},{subtext:L(()=>[a("span",w1,d(t(i)("analysis.overview.statCards.peakHour")),1),a("span",$1,d(r.peakHour?.hour||0)+":00",1)]),_:1},8,["label","value"]),f(t(vt),{label:t(i)("analysis.overview.statCards.mostActiveWeekday"),value:r.peakWeekday?r.weekdayNames[r.peakWeekday.weekday-1]:"-",icon:"i-heroicons-calendar-days","icon-bg":"amber"},{subtext:L(()=>[a("span",C1,d(t(i)("analysis.overview.statCards.messagesOnDay",{count:r.peakWeekday?.messageCount??0})),1)]),_:1},8,["label","value"]),f(t(vt),{label:t(i)("analysis.overview.statCards.weekendActivity"),value:`${r.weekdayVsWeekend.weekend}%`,icon:"i-heroicons-sun","icon-bg":"green"},{subtext:L(()=>[a("span",S1,d(t(i)("analysis.overview.statCards.weekendRatio")),1)]),_:1},8,["label","value"]),f(t(vt),{label:t(i)("analysis.overview.statCards.mostActiveDate"),value:r.peakDay?t(Ne)(r.peakDay.date).format("MM/DD"):"-",icon:"i-heroicons-fire","icon-bg":"red"},{subtext:L(()=>[a("span",I1,d(t(i)("analysis.overview.statCards.messagesOnDay",{count:r.peakDay?.messageCount??0})),1)]),_:1},8,["label","value"]),f(t(vt),{label:t(i)("analysis.overview.statCards.lateNightChat"),value:t(i)("analysis.overview.statCards.messagesCount",{count:r.lateNightCount}),icon:"i-heroicons-moon","icon-bg":"blue"},{subtext:L(()=>[a("span",T1,d(t(i)("analysis.overview.statCards.lateNightRatio",{ratio:r.lateNightRatio})),1)]),_:1},8,["label","value"]),f(t(vt),{label:t(i)("analysis.overview.statCards.consecutiveStreak"),value:t(i)("analysis.overview.statCards.daysStreak",{count:r.maxConsecutiveDays}),icon:"i-heroicons-bolt","icon-bg":"amber"},{subtext:L(()=>[a("span",M1,d(t(i)("analysis.overview.statCards.longestStreak")),1)]),_:1},8,["label","value"]),f(t(vt),{label:t(i)("analysis.overview.statCards.activityRate"),value:`${r.activeRate}%`,icon:"i-heroicons-chart-bar","icon-bg":"gray"},{subtext:L(()=>[a("span",A1,d(t(i)("analysis.overview.statCards.activeDaysRatio")),1)]),_:1},8,["label","value"])]))}}}),q1={class:"relative z-10 px-5 pt-6 pb-4 sm:px-8 sm:pt-8"},L1={class:"text-2xl font-bold tracking-tight text-gray-900 sm:text-3xl dark:text-gray-100"},D1={class:"mt-4 flex flex-col gap-5 sm:flex-row sm:items-start sm:gap-24"},E1={class:"min-w-0 flex flex-col gap-2 text-sm font-medium text-gray-500 dark:text-gray-400"},B1={class:"flex items-center gap-2"},F1={class:"flex h-6 w-6 shrink-0 items-center justify-center"},R1={class:"whitespace-nowrap"},V1={key:0,class:"flex items-center gap-2"},O1={class:"flex h-6 w-6 shrink-0 items-center justify-center"},P1={class:"font-mono text-xs opacity-90 whitespace-nowrap"},N1={class:"grid grid-cols-2 gap-x-8 gap-y-4 sm:flex sm:shrink-0 sm:gap-6"},j1={class:"flex flex-col gap-1 text-center"},U1={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},H1={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},W1={class:"flex flex-col gap-1 text-center"},K1={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},Y1={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},G1={class:"flex flex-col gap-1 text-center"},Q1={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},J1={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},X1={class:"flex flex-col gap-1 text-center"},Z1={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},e_={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},t_={class:"relative z-10 px-5 pb-2 sm:px-8"},a_={class:"overflow-x-auto overflow-y-hidden scrollbar-hide py-1"},Y2=le({__name:"OverviewIdentityCard",props:{session:{},dailyActivity:{},messageTypes:{},hourlyActivity:{},timeRange:{},filteredMessageCount:{},filteredMemberCount:{},timeFilter:{},capturable:{type:Boolean,default:!0}},setup(r){ha([As,_o,zs,Ga,qs,va]);const{t:i,locale:e}=Ie(),s=pa(),n=r,{weekdayActivity:u}=f1({sessionId:()=>n.session.id,timeFilter:()=>n.timeFilter}),{durationDays:o,displayMessageCount:c,dailyAvgMessages:m,imageCount:h,peakHour:p,peakWeekday:_,weekdayNames:y,weekdayVsWeekend:b,peakDay:x,activeDays:k,totalDays:I,activeRate:$,lateNightChat:w,maxConsecutiveDays:C}=p1(n,u),v=A(null);let S=null;const V=T(()=>Ns(n.timeRange,n.timeFilter)),B=T(()=>V.value?Co(V.value.start,V.value.end,"YYYY/MM/DD"):""),D=T(()=>{const N=g1(V.value);if(N)return N;const ue=(ve=>ve.toISOString().slice(0,10))(new Date);return[ue,ue]}),z=T(()=>{const[N,F]=D.value,Z=new Date(N+"T00:00:00Z"),ue=new Date(F+"T00:00:00Z"),ve=new Map;n.dailyActivity.filter(H=>H.date>=N&&H.date<=F).forEach(H=>ve.set(H.date,H.messageCount));const ae=[],re=new Date(Z);for(;re<=ue;){const H=re.toISOString().slice(0,10),be=ve.get(H)||0;ae.push({value:[H,be],itemStyle:be===0?{color:U.value}:void 0}),re.setUTCDate(re.getUTCDate()+1)}return ae}),M=T(()=>n.dailyActivity.length===0?10:Math.max(...n.dailyActivity.map(N=>N.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)"]},U=T(()=>s.value?"rgba(255, 255, 255, 0.04)":"#ebedf0"),Y=T(()=>({tooltip:{trigger:"item",formatter:N=>{const F=N.value[0],Z=N.value[1];return`${F}<br/>${i("views.message.calendarTooltipMessages")}: ${Z}`}},visualMap:{min:1,max:M.value,calculable:!1,orient:"horizontal",left:"center",bottom:0,itemWidth:10,itemHeight:80,text:[`${M.value}`,"1"],inRange:{color:s.value?q.dark:q.light},textStyle:{color:s.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:s.value?"#8b949e":"#6b7280",fontSize:10,nameMap:[i("common.month.jan"),i("common.month.feb"),i("common.month.mar"),i("common.month.apr"),i("common.month.may"),i("common.month.jun"),i("common.month.jul"),i("common.month.aug"),i("common.month.sep"),i("common.month.oct"),i("common.month.nov"),i("common.month.dec")]},dayLabel:{show:!0,firstDay:1,color:s.value?"#8b949e":"#9ca3af",fontSize:10,nameMap:[i("common.weekday.sun"),i("common.weekday.mon"),i("common.weekday.tue"),i("common.weekday.wed"),i("common.weekday.thu"),i("common.weekday.fri"),i("common.weekday.sat")]},splitLine:{show:!1}},series:[{type:"custom",coordinateSystem:"calendar",data:z.value,renderItem:(N,F)=>{const Z=F.coord(F.value(0)),ue=N.coordSys.cellWidth,ve=N.coordSys.cellHeight,ae=Math.min(ue,ve)-3;return{type:"rect",shape:{x:Z[0]-ae/2,y:Z[1]-ae/2,width:ae,height:ae,r:3},style:{fill:F.visual("color")}}},itemStyle:{borderColor:s.value?"transparent":"rgba(0,0,0,0.02)",borderWidth:1}}]}));function te(){v.value&&(S=ya(v.value,void 0,{renderer:"canvas"}),S.setOption({backgroundColor:"transparent",...Y.value}))}function K(){S&&S.setOption({backgroundColor:"transparent",...Y.value},{notMerge:!0})}function j(){S?.resize()}return fe([()=>n.dailyActivity,e,D],()=>K()),fe(s,()=>{S?.dispose(),te()}),He(()=>{te(),window.addEventListener("resize",j)}),dt(()=>{window.removeEventListener("resize",j),S?.dispose()}),(N,F)=>{const Z=Me;return l(),P(t(xa),{capturable:r.capturable},{default:L(()=>[a("div",q1,[a("h2",L1,d(r.session.name),1),a("div",D1,[a("div",E1,[a("div",B1,[a("div",F1,[r.session.type==="group"?(l(),P(Z,{key:0,name:"i-heroicons-user-group",class:"h-4 w-4 opacity-70"})):(l(),P(Z,{key:1,name:"i-heroicons-user",class:"h-4 w-4 opacity-70"}))]),a("span",R1,d(r.session.platform.toUpperCase())+" · "+d(r.session.type==="private"?t(i)("analysis.overview.identity.privateChat"):t(i)("analysis.overview.identity.groupChat")),1)]),B.value?(l(),g("div",V1,[a("div",O1,[f(Z,{name:"i-heroicons-calendar",class:"h-4 w-4 opacity-70"})]),a("span",P1,d(B.value),1)])):E("",!0)]),a("div",N1,[a("div",j1,[a("span",U1,d(t(c).toLocaleString()),1),a("span",H1,d(t(i)("analysis.overview.identity.totalMessages")),1)]),a("div",W1,[a("span",K1,d(t(o).toLocaleString()),1),a("span",Y1,d(t(i)("analysis.overview.identity.durationDays")),1)]),a("div",G1,[a("span",Q1,d(t(k).toLocaleString()),1),a("span",J1,d(t(i)("analysis.overview.identity.activeDays")),1)]),a("div",X1,[a("span",Z1,d(t(m).toLocaleString()),1),a("span",e_,d(t(i)("analysis.overview.identity.dailyAvgMessages")),1)])])])]),a("div",t_,[F[0]||(F[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",a_,[a("div",{ref_key:"chartRef",ref:v,class:"h-[140px] min-w-[700px] lg:w-full"},null,512)])]),f(z1,{flat:"","daily-avg-messages":t(m),"duration-days":t(o),"image-count":t(h),"peak-hour":t(p),"peak-weekday":t(_),"weekday-names":t(y),"weekday-vs-weekend":t(b),"peak-day":t(x),"active-days":t(k),"total-days":t(I),"active-rate":t($),"late-night-count":t(w).count,"late-night-ratio":t(w).ratio,"max-consecutive-days":t(C)},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"])}}}),s_={class:"p-3 sm:p-5"},G2=le({__name:"DailyTrendCard",props:{dailyActivity:{},dailyChartData:{},capturable:{type:Boolean,default:!0}},setup(r){const{t:i}=Ie();return(e,s)=>r.dailyActivity.length>0?(l(),P(t(ut),{key:0,title:t(i)("analysis.overview.dailyTrend.title"),capturable:r.capturable,"show-divider":!1},{default:L(()=>[a("div",s_,[f(t(za),{data:r.dailyChartData,height:288},null,8,["data"])])]),_:1},8,["title","capturable"])):E("",!0)}}),n_={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"}},o_=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:i,emit:e}){const s=r,n=e,u=ma(),o=Va("inputTags",s),c=Pa(),m=ks(_s(o,"as","addOnPaste","addOnTab","addOnBlur","duplicate","delimiter","max","convertValue","displayValue","required"),n),{emitFormBlur:h,emitFormFocus:p,emitFormChange:_,emitFormInput:y,size:b,color:x,id:k,name:I,highlight:$,disabled:w,ariaAttrs:C}=Oa(s),{orientation:v,size:S}=ws(s),{isLeading:V,isTrailing:B,leadingIconName:D,trailingIconName:z}=Na(o),M=T(()=>S.value||b.value),q=T(()=>Dt({extend:Dt(n_),...c.ui?.inputTags||{}})({color:x.value??o.color,variant:o.variant,size:M?.value??o.size,loading:o.loading,highlight:$.value??o.highlight,fixed:o.fixed,leading:V.value||!!o.avatar||!!u.leading,trailing:B.value||!!u.trailing,fieldGroup:v.value})),U=Nt("inputRef");function Y(){o.autofocus&&U.value?.$el?.focus()}He(()=>{setTimeout(()=>{Y()},o.autofocusDelay)});function te(N){if($s(o.modelValue)===N)return;const F=new Event("change",{target:{value:N}});n("change",F),_(),y()}function K(N){n("blur",N),h()}function j(N){n("focus",N),p()}return i({inputRef:Ze(()=>U.value?.$el)}),(N,F)=>(l(),P(t(Xi),Pe({id:t(k),"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(m),{name:t(I),disabled:t(w),"onUpdate:modelValue":te}),{default:L(({modelValue:Z})=>[(l(!0),g(ie,null,_e(Z,(ue,ve)=>(l(),P(t(sr),{key:ve,value:ue,"data-slot":"item",class:W(q.value.item({class:[t(o).ui?.item]}))},{default:L(()=>[f(t(rr),{"data-slot":"itemText",class:W(q.value.itemText({class:[t(o).ui?.itemText]}))},{default:L(()=>[u["item-text"]?$e(N.$slots,"item-text",{key:0,item:ue,index:ve,ui:q.value}):E("",!0)]),_:2},1032,["class"]),f(t(or),{"data-slot":"itemDelete",class:W(q.value.itemDelete({class:[t(o).ui?.itemDelete]})),disabled:t(w)},{default:L(()=>[$e(N.$slots,"item-delete",{item:ue,index:ve,ui:q.value},()=>[f(Me,{name:t(o).deleteIcon||t(c).ui.icons.close,"data-slot":"itemDeleteIcon",class:W(q.value.itemDeleteIcon({class:[t(o).ui?.itemDeleteIcon]}))},null,8,["name","class"])])]),_:2},1032,["class","disabled"])]),_:2},1032,["value","class"]))),128)),f(t(er),Pe({ref_key:"inputRef",ref:U},{...N.$attrs,...t(C)},{placeholder:t(o).placeholder,"max-length":t(o).maxLength,"data-slot":"input",class:q.value.input({class:t(o).ui?.input}),onBlur:K,onFocus:j}),null,16,["placeholder","max-length","class"]),$e(N.$slots,"default",{ui:q.value}),t(V)||t(o).avatar||u.leading?(l(),g("span",{key:0,"data-slot":"leading",class:W(q.value.leading({class:t(o).ui?.leading}))},[$e(N.$slots,"leading",{ui:q.value},()=>[t(V)&&t(D)?(l(),P(Me,{key:0,name:t(D),"data-slot":"leadingIcon",class:W(q.value.leadingIcon({class:t(o).ui?.leadingIcon}))},null,8,["name","class"])):t(o).avatar?(l(),P(la,Pe({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(B)||u.trailing?(l(),g("span",{key:1,"data-slot":"trailing",class:W(q.value.trailing({class:t(o).ui?.trailing}))},[$e(N.$slots,"trailing",{ui:q.value},()=>[t(z)?(l(),P(Me,{key:0,name:t(z),"data-slot":"trailingIcon",class:W(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"]))}}),i_={class:"flex items-center justify-between gap-3"},r_={class:"flex items-center gap-2"},l_={class:"text-sm font-medium text-gray-900 dark:text-white"},u_={class:"text-xs text-gray-500 dark:text-gray-400"},c_=le({__name:"OwnerEntryCard",props:{sessionId:{},members:{},chatType:{}},setup(r){const{t:i}=Ie(),e=ao(),s=r,n=A(!1);function u(m){return m.groupNickname||m.accountName||m.platformId}const o=T(()=>{const m=e.currentSession?.ownerId;return m&&s.members.find(h=>h.platformId===m)||null}),c=T(()=>o.value?u(o.value):e.currentSession?.ownerId??"");return(m,h)=>{const p=Me,_=Xe;return l(),P(t(wt),{class:"w-150 p-3"},{default:L(()=>[a("div",i_,[a("div",r_,[a("div",{class:W(["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"])},[f(p,{name:"i-heroicons-user",class:"h-4 w-4 text-white"})],2),a("div",null,[a("h3",l_,d(c.value?t(i)("members.ownerPrompt.currentOwner",{name:c.value}):t(i)("members.ownerPrompt.choose")),1),a("p",u_,d(t(i)("members.ownerPrompt.helper")),1)])]),f(_,{size:"sm",variant:c.value?"outline":"solid",color:"primary",onClick:h[0]||(h[0]=y=>n.value=!0)},{default:L(()=>[ne(d(c.value?t(i)("members.ownerPrompt.change"):t(i)("members.ownerPrompt.choose")),1)]),_:1},8,["variant"])]),f(Io,{modelValue:n.value,"onUpdate:modelValue":h[1]||(h[1]=y=>n.value=y),"session-id":r.sessionId,"chat-type":r.chatType},null,8,["modelValue","session-id","chat-type"])]),_:1})}}}),d_={key:0,class:"mb-6"},m_={class:"flex items-center gap-3"},g_={class:"text-xl font-bold text-gray-900 dark:text-white"},p_={class:"text-sm text-gray-500 dark:text-gray-400"},f_={class:"mb-4 flex flex-wrap items-center justify-between gap-3"},h_={key:0,class:"flex items-center gap-2"},v_={class:"text-xs text-gray-500 dark:text-gray-400"},y_={key:0,class:"flex flex-1 items-center justify-center"},x_={key:1,class:"flex flex-1 flex-col items-center justify-center gap-3"},b_={class:"text-sm text-gray-500 dark:text-gray-400"},k_={key:2,class:"flex flex-1 flex-col items-center justify-center"},__={class:"text-gray-500 dark:text-gray-400"},w_={key:3,class:"min-h-0 flex-1 overflow-x-auto overflow-y-hidden"},$_={key:0,"aria-hidden":"true"},C_={class:"flex shrink-0 flex-col leading-none"},S_={class:"flex shrink-0 flex-col leading-none"},I_={class:"flex shrink-0 flex-col leading-none"},T_={class:"inline-flex items-center gap-1.5"},M_={class:"text-right"},A_=["data-index","onClick"],z_={key:0,class:"flex justify-center"},q_={class:"flex min-w-0 items-center gap-2.5"},L_={class:"min-w-0"},D_=["title"],E_=["title"],B_=["title"],F_={class:"text-right font-mono text-sm font-semibold tabular-nums text-gray-900 dark:text-white"},R_=["title"],V_={class:"flex justify-end gap-1"},O_={class:"p-6 text-center"},P_={class:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30"},N_={class:"mb-2 text-lg font-semibold text-gray-900 dark:text-white"},j_={class:"mb-6 text-sm text-gray-500 dark:text-gray-400"},U_={class:"flex justify-center gap-3"},H_={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"},K_={class:"mb-2 text-lg font-semibold text-gray-900 dark:text-white"},Y_={class:"mb-6 text-sm text-gray-500 dark:text-gray-400"},G_={class:"flex justify-center gap-3"},Q_={class:"p-6"},J_={class:"mb-4 flex items-center gap-3"},X_={class:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100 dark:bg-amber-900/30"},Z_={class:"text-lg font-semibold text-gray-900 dark:text-white"},ew={class:"mb-2 text-sm text-gray-600 dark:text-gray-400"},tw={class:"mb-6 text-xs text-amber-700 dark:text-amber-300"},aw={class:"flex justify-end gap-2"},sw=64,nw=le({__name:"MemberList",props:{sessionId:{},showHeader:{type:Boolean,default:!0},chatType:{default:"group"}},emits:["data-changed"],setup(r,{emit:i}){const{t:e}=Ie(),s=at(),n=zt(),u=r,o=i,c=A([]),m=A(!1),h=A(!1),p=A(""),_=T(()=>ho(u.chatType,c.value.length)),y=T(()=>u.chatType==="group"?"":_.value?"member-table-grid--private":"member-table-grid--private-without-selection"),b=A(null),x=A(!1),k=A(!1),I=A(!1),$=A(!1),w=A(!1),{sortState:C,toggleSort:v,resetSort:S,isSortActive:V}=To({initialState:{field:"messageCount",direction:"desc"}}),B=A(new Set);let D=0;function z(oe,ge){const R=ge instanceof Error?ge:new Error(String(ge));console.error(oe,R),io(`${oe} ${R.message}`,R.stack)}function M(oe){return oe.groupNickname||oe.accountName||oe.platformId}function q(oe){return M(oe).slice(0,1)}function U(oe){n.openChatRecordDrawer({sessionId:u.sessionId,memberId:oe.id,memberName:M(oe)})}const Y=T(()=>vo(c.value,p.value,C.value)),{selectedIds:te,setSelection:K,clearSelection:j,handleRowClick:N,handleRowMouseDown:F}=Mo({rows:Y,getRowId:oe=>oe.id}),Z=T(()=>c.value.filter(oe=>te.value.has(oe.id))),ue=T(()=>Z.value.length===2),ve=T(()=>Z.value.reduce((oe,ge)=>oe+ge.messageCount,0));function ae(oe,ge,R){_.value&&N(oe,ge,R)}function re(oe){_.value&&F(oe)}const H=T(()=>{if(Z.value.length!==2)return null;const[oe,ge]=Z.value;return ge.messageCount>oe.messageCount||ge.messageCount===oe.messageCount&&ge.id<oe.id?{primary:ge,secondary:oe}:{primary:oe,secondary:ge}});function be(oe,ge){return V(oe,ge)?"text-primary-500 dark:text-primary-400":"text-gray-300 dark:text-gray-600"}const Te=A(null),we=so(T(()=>({count:Y.value.length,getScrollElement:()=>Te.value,estimateSize:()=>sw,overscan:8,getItemKey:oe=>Y.value[oe]?.id??oe}))),ce=T(()=>we.value.getVirtualItems().map(oe=>({virtualItem:oe,member:Y.value[oe.index]}))),X=T(()=>we.value.getTotalSize());function Q(oe){oe instanceof HTMLElement&&we.value.measureElement(oe)}async function xe(){await Fe(),Te.value?.scrollTo({top:0}),we.value.measure()}async function Ae(){const oe=u.sessionId;if(!oe)return;const ge=++D;m.value=!0,h.value=!1;try{const R=await s.getMembers(oe);if(ge!==D||oe!==u.sessionId)return;c.value=R,await Fe(),we.value.measure()}catch(R){ge===D&&(h.value=!0),z("Failed to load member list:",R)}finally{ge===D&&(m.value=!1)}}function ze(oe,ge){const R=new Set(B.value);ge?R.add(oe):R.delete(oe),B.value=R}async function je(oe,ge){const R=u.sessionId,ee=JSON.parse(JSON.stringify(ge)),J=JSON.stringify(oe.aliases),de=JSON.stringify(ee);if(J!==de){ze(oe.id,!0);try{if(await s.updateMemberAliases(R,oe.id,ee)&&R===u.sessionId){const Ue=c.value.findIndex(Ye=>Ye.id===oe.id);Ue!==-1&&(c.value[Ue]={...c.value[Ue],aliases:ee},await Fe(),we.value.measure())}}catch(Ce){z("Failed to save member aliases:",Ce)}finally{ze(oe.id,!1)}}}function Je(oe){b.value=oe}function Re(){b.value=null}async function Qe(){if(b.value){x.value=!0;try{const oe=b.value.id;if(await s.deleteMember(u.sessionId,oe)){const R=new Set(te.value);R.delete(oe),K(R),await Ae(),o("data-changed")}}catch(oe){z("Failed to delete member:",oe)}finally{x.value=!1,b.value=null}}}function et(){te.value.size!==0&&(k.value=!0)}async function Ee(){const oe=u.sessionId,ge=Array.from(te.value);if(ge.length!==0){I.value=!0;try{await s.deleteMembers(oe,ge)&&oe===u.sessionId&&(k.value=!1,j(),await Ae(),o("data-changed"))}catch(R){z("Failed to delete selected members:",R)}finally{I.value=!1}}}function pe(){ue.value&&($.value=!0)}async function ye(){if(H.value){w.value=!0;try{await s.mergeMembers(u.sessionId,H.value.primary.id,H.value.secondary.id)&&($.value=!1,j(),await Ae(),o("data-changed"))}catch(oe){z("Failed to merge members:",oe)}finally{w.value=!1}}}return fe([p,C],xe),fe(_,oe=>{oe||j()}),fe(()=>u.sessionId,()=>{D+=1,c.value=[],h.value=!1,B.value=new Set,p.value="",S(),j(),xe(),Ae()},{immediate:!0}),dt(()=>{D+=1}),(oe,ge)=>{const R=Xe,ee=Yt,J=Me,de=Rt,Ce=Wa,Ue=o_,Ye=lt;return l(),g("div",{class:W(["main-content",u.showHeader?"max-w-5xl p-6":"flex h-full max-w-none flex-col overflow-hidden p-4"])},[u.showHeader?(l(),g("div",d_,[a("div",m_,[a("div",null,[a("h2",g_,d(t(e)(u.chatType==="private"?"members.private.title":"members.list.title")),1),a("p",p_,d(t(e)(u.chatType==="private"?"members.private.description":"members.list.description",{count:c.value.length})),1)])])])):E("",!0),f(c_,{class:"mb-6","session-id":r.sessionId,members:c.value,"chat-type":u.chatType},null,8,["session-id","members","chat-type"]),a("div",f_,[f(ee,{modelValue:p.value,"onUpdate:modelValue":ge[1]||(ge[1]=Ve=>p.value=Ve),placeholder:t(e)("members.list.searchPlaceholder"),icon:"i-heroicons-magnifying-glass",class:"w-full md:w-100"},no({_:2},[p.value?{name:"trailing",fn:L(()=>[f(R,{icon:"i-heroicons-x-mark",variant:"link",color:"neutral",size:"xs",onClick:ge[0]||(ge[0]=Ve=>p.value="")})]),key:"0"}:void 0]),1032,["modelValue","placeholder"]),_.value?(l(),g("div",h_,[m.value&&c.value.length>0?(l(),P(J,{key:0,name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin text-primary-500"})):E("",!0),a("span",v_,d(t(e)("members.list.selectedCount",{count:t(te).size})),1),f(R,{icon:"i-heroicons-link",size:"sm",color:"primary",disabled:!ue.value,onClick:pe},{default:L(()=>[ne(d(t(e)("members.list.mergeSelected")),1)]),_:1},8,["disabled"]),f(R,{icon:"i-heroicons-trash",size:"sm",color:"error",variant:"outline",disabled:t(te).size===0,onClick:et},{default:L(()=>[ne(d(t(e)("members.list.deleteSelected")),1)]),_:1},8,["disabled"])])):E("",!0)]),a("div",{class:W(["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"])},[m.value&&c.value.length===0?(l(),g("div",y_,[f(J,{name:"i-heroicons-arrow-path",class:"h-8 w-8 animate-spin text-primary-500"})])):h.value&&c.value.length===0?(l(),g("div",x_,[f(J,{name:"i-heroicons-exclamation-circle",class:"h-10 w-10 text-red-400"}),a("p",b_,d(t(e)("members.list.loadError")),1),f(R,{size:"sm",variant:"outline",icon:"i-heroicons-arrow-path",onClick:Ae},{default:L(()=>[ne(d(t(e)("common.retry")),1)]),_:1})])):Y.value.length===0?(l(),g("div",k_,[f(J,{name:"i-heroicons-user-group",class:"mb-3 h-12 w-12 text-gray-300 dark:text-gray-600"}),a("p",__,d(p.value?t(e)("members.list.noMatch"):t(e)("members.list.empty")),1)])):(l(),g("div",w_,[a("div",{class:W(["flex h-full flex-col",u.chatType==="private"?"min-w-[920px]":"min-w-[1120px]"])},[a("div",{class:W(["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?(l(),g("span",$_)):E("",!0),a("span",null,d(t(e)("members.list.table.accountName")),1),u.chatType==="group"?(l(),g("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:ge[2]||(ge[2]=Ve=>t(v)("groupNickname"))},[ne(d(t(e)("members.list.table.groupNickname"))+" ",1),a("span",C_,[f(J,{name:"i-heroicons-chevron-up",class:W(["h-2.5 w-2.5",be("groupNickname","asc")])},null,8,["class"]),f(J,{name:"i-heroicons-chevron-down",class:W(["-mt-0.5 h-2.5 w-2.5",be("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:ge[3]||(ge[3]=Ve=>t(v)("messageCount"))},[ne(d(t(e)("members.list.table.messageCount"))+" ",1),a("span",S_,[f(J,{name:"i-heroicons-chevron-up",class:W(["h-2.5 w-2.5",be("messageCount","asc")])},null,8,["class"]),f(J,{name:"i-heroicons-chevron-down",class:W(["-mt-0.5 h-2.5 w-2.5",be("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:ge[4]||(ge[4]=Ve=>t(v)("lastMessageTs"))},[ne(d(t(e)("members.list.table.lastMessageTime"))+" ",1),a("span",I_,[f(J,{name:"i-heroicons-chevron-up",class:W(["h-2.5 w-2.5",be("lastMessageTs","asc")])},null,8,["class"]),f(J,{name:"i-heroicons-chevron-down",class:W(["-mt-0.5 h-2.5 w-2.5",be("lastMessageTs","desc")])},null,8,["class"])])]),a("span",T_,[a("span",null,d(t(e)("members.list.table.customAlias")),1),f(de,{text:t(e)("members.list.tip"),popper:{placement:"top"}},{default:L(()=>[f(J,{name:"i-heroicons-question-mark-circle",class:"h-4 w-4 text-gray-400 dark:text-gray-500"})]),_:1},8,["text"])]),a("span",M_,d(t(e)("members.list.table.actions")),1)],2),a("div",{ref_key:"listScrollRef",ref:Te,class:"min-h-0 flex-1 overflow-y-auto"},[a("div",{class:"relative",style:mt({height:`${X.value}px`})},[(l(!0),g(ie,null,_e(ce.value,({virtualItem:Ve,member:Oe})=>(l(),g("div",{key:String(Ve.key),ref_for:!0,ref:Q,"data-index":Ve.index,class:W(["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(te).has(Oe.id)?"bg-primary-50/70 dark:bg-primary-950/20":""]]),style:mt({transform:`translateY(${Ve.start}px)`}),onMousedown:re,onClick:nt=>ae(Ve.index,Oe.id,nt)},[_.value?(l(),g("div",z_,[f(Ce,{"model-value":t(te).has(Oe.id),onClick:Ke(nt=>ae(Ve.index,Oe.id,nt),["stop"])},null,8,["model-value","onClick"])])):E("",!0),a("div",q_,[f(oo,{src:Oe.avatar,alt:M(Oe),text:q(Oe),"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",L_,[a("p",{class:"truncate text-sm font-medium text-gray-900 dark:text-white",title:Oe.accountName||"-"},d(Oe.accountName||"-"),9,D_),a("p",{class:"truncate text-xs text-gray-400 dark:text-gray-500",title:Oe.platformId},d(Oe.platformId),9,E_)])]),u.chatType==="group"?(l(),g("p",{key:1,class:W(["truncate text-sm text-gray-700 dark:text-gray-300",Oe.groupNickname?"font-medium":"text-gray-400 dark:text-gray-500"]),title:Oe.groupNickname||"-"},d(Oe.groupNickname||"-"),11,B_)):E("",!0),a("span",F_,d(Oe.messageCount.toLocaleString()),1),a("span",{class:"text-right font-mono text-xs tabular-nums text-gray-600 dark:text-gray-400",title:Oe.lastMessageTs===null?"-":t(is)(Oe.lastMessageTs)},d(Oe.lastMessageTs===null?"-":t(is)(Oe.lastMessageTs)),9,R_),f(Ue,{"model-value":Oe.aliases,placeholder:t(e)("members.list.aliasPlaceholder"),loading:B.value.has(Oe.id),size:"xs",class:"w-full",onClick:ge[5]||(ge[5]=Ke(()=>{},["stop"])),"onUpdate:modelValue":nt=>je(Oe,nt)},null,8,["model-value","placeholder","loading","onUpdate:modelValue"]),a("div",V_,[f(R,{icon:"i-heroicons-chat-bubble-left-ellipsis",size:"xs",color:"neutral",variant:"ghost",title:t(e)("common.viewChatRecords"),onClick:Ke(nt=>U(Oe),["stop"])},null,8,["title","onClick"]),f(R,{icon:"i-heroicons-trash",size:"xs",color:"error",variant:"ghost",title:t(e)("members.list.delete"),onClick:Ke(nt=>Je(Oe),["stop"])},null,8,["title","onClick"])])],46,A_))),128))],4)],512)],2)]))],2),f(Ye,{open:!!b.value,ui:{content:"max-w-sm"},"onUpdate:open":ge[6]||(ge[6]=Ve=>b.value=null)},{content:L(()=>[a("div",O_,[a("div",P_,[f(J,{name:"i-heroicons-exclamation-triangle",class:"h-7 w-7 text-red-500"})]),a("h3",N_,d(t(e)("members.list.modal.title")),1),a("p",j_,d(t(e)("members.list.modal.content",{name:b.value?M(b.value):"",count:b.value?.messageCount.toLocaleString()})),1),a("div",U_,[f(R,{variant:"outline",onClick:Re},{default:L(()=>[ne(d(t(e)("members.list.modal.cancel")),1)]),_:1}),f(R,{color:"error",loading:x.value,onClick:Qe},{default:L(()=>[ne(d(t(e)("members.list.modal.confirm")),1)]),_:1},8,["loading"])])])]),_:1},8,["open"]),f(Ye,{open:k.value,ui:{content:"max-w-sm"},"onUpdate:open":ge[8]||(ge[8]=Ve=>k.value=Ve)},{content:L(()=>[a("div",H_,[a("div",W_,[f(J,{name:"i-heroicons-exclamation-triangle",class:"h-7 w-7 text-red-500"})]),a("h3",K_,d(t(e)("members.list.batchDeleteModal.title")),1),a("p",Y_,d(t(e)("members.list.batchDeleteModal.content",{count:Z.value.length,messageCount:ve.value.toLocaleString()})),1),a("div",G_,[f(R,{variant:"outline",disabled:I.value,onClick:ge[7]||(ge[7]=Ve=>k.value=!1)},{default:L(()=>[ne(d(t(e)("members.list.modal.cancel")),1)]),_:1},8,["disabled"]),f(R,{color:"error",loading:I.value,onClick:Ee},{default:L(()=>[ne(d(t(e)("members.list.modal.confirm")),1)]),_:1},8,["loading"])])])]),_:1},8,["open"]),f(Ye,{open:$.value,ui:{content:"max-w-md"},"onUpdate:open":ge[10]||(ge[10]=Ve=>$.value=Ve)},{content:L(()=>[a("div",Q_,[a("div",J_,[a("div",X_,[f(J,{name:"i-heroicons-link",class:"h-5 w-5 text-amber-600 dark:text-amber-400"})]),a("h3",Z_,d(t(e)("members.list.mergeModal.title")),1)]),a("p",ew,d(t(e)("members.list.mergeModal.content",{source:H.value?M(H.value.secondary):"",sourceCount:H.value?H.value.secondary.messageCount.toLocaleString():"0",target:H.value?M(H.value.primary):"",targetCount:H.value?H.value.primary.messageCount.toLocaleString():"0"})),1),a("p",tw,d(t(e)("members.list.mergeModal.hint")),1),a("div",aw,[f(R,{variant:"outline",disabled:w.value,onClick:ge[9]||(ge[9]=Ve=>$.value=!1)},{default:L(()=>[ne(d(t(e)("members.list.mergeModal.cancel")),1)]),_:1},8,["disabled"]),f(R,{color:"primary",loading:w.value,onClick:ye},{default:L(()=>[ne(d(t(e)("members.list.mergeModal.confirm")),1)]),_:1},8,["loading"])])])]),_:1},8,["open"])],2)}}}),Q2=gt(nw,[["__scopeId","data-v-0754d30f"]]),ow={class:"mt-3 flex flex-col items-stretch gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3"},iw={class:"max-w-full overflow-x-auto scrollbar-hide"},J2=le({__name:"SessionAnalysisHeader",props:Ut({title:{},avatar:{},icon:{},iconClass:{},tabs:{},currentSessionId:{},initialTimeState:{},showSessionActions:{type:Boolean,default:!0}},{activeTab:{required:!0},activeTabModifiers:{},timeRangeValue:{required:!0},timeRangeValueModifiers:{}}),emits:Ut(["openIncrementalImport","openMemberManagement","openChatRecord","update:fullRange","update:availableYears","timeRangeInitialized"],["update:activeTab","update:timeRangeValue"]),setup(r,{emit:i}){const e=ra(r,"activeTab"),s=ra(r,"timeRangeValue"),n=r,u=i,{t:o}=Ie(),c=zt(),m=T(()=>!["ai-chat","memory","lab","debug"].includes(e.value)),h=T(()=>n.tabs.map(p=>({id:p.id,label:o(p.labelKey),icon:p.icon})));return(p,_)=>{const y=Xe,b=Rt;return l(),P(Ao,{title:r.title,avatar:r.avatar,size:"compact",icon:r.icon,"icon-class":r.iconClass},{actions:L(()=>[r.showSessionActions&&t(c).effectiveToolsPanelPosition==="header"?(l(),g(ie,{key:0},[f(b,{text:t(o)("analysis.tooltip.viewChatRecord")},{default:L(()=>[f(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]=x=>u("openChatRecord"))})]),_:1},8,["text"]),f(b,{text:t(o)("analysis.tooltip.incrementalImport")},{default:L(()=>[f(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]=x=>u("openIncrementalImport"))})]),_:1},8,["text"]),f(b,{text:t(o)("analysis.tooltip.memberManagement")},{default:L(()=>[f(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]=x=>u("openMemberManagement"))})]),_:1},8,["text"]),f(Ht,{color:"gray"}),f(b,{text:t(o)("analysis.tooltip.more")},{default:L(()=>[f(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]=x=>t(c).toggleToolsPanelOpen())})]),_:1},8,["text"])],64)):r.showSessionActions?(l(),P(Ht,{key:1,color:"gray"})):E("",!0)]),default:L(()=>[a("div",ow,[f(t(zo),{modelValue:e.value,"onUpdate:modelValue":_[4]||(_[4]=x=>e.value=x),class:"min-w-0 shrink",items:h.value},null,8,["modelValue","items"]),a("div",iw,[m.value?(l(),P(So,{key:0,modelValue:s.value,"onUpdate:modelValue":_[5]||(_[5]=x=>s.value=x),"session-id":r.currentSessionId??void 0,"initial-state":r.initialTimeState,size:"sm","onUpdate:fullRange":_[6]||(_[6]=x=>u("update:fullRange",x)),"onUpdate:availableYears":_[7]||(_[7]=x=>u("update:availableYears",x)),onInitializationComplete:_[8]||(_[8]=x=>u("timeRangeInitialized",x))},null,8,["modelValue","session-id","initial-state"])):E("",!0)])])]),_:1},8,["title","avatar","icon","icon-class"])}}}),rw={class:"space-y-4 p-5"},lw={class:"flex items-center gap-2"},uw={class:"text-base font-semibold text-gray-900 dark:text-white"},cw={key:0,class:"flex items-center gap-2 text-sm text-gray-400"},dw={class:"rounded-lg border border-gray-200 bg-gray-50 p-3 text-sm dark:border-gray-700 dark:bg-gray-800/50"},mw={class:"flex items-center justify-between"},gw={class:"text-gray-500"},pw={class:"font-medium text-gray-800 dark:text-gray-200"},fw={key:0,class:"mt-1 flex items-center justify-between"},hw={class:"text-gray-500"},vw={class:"text-gray-700 dark:text-gray-300"},yw={key:1,class:"mt-2"},xw={class:"flex items-center justify-between text-xs text-gray-500"},bw={class:"mt-1 h-1.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},kw={key:2,class:"mt-1 text-xs text-red-500"},_w={class:"text-sm text-gray-600 dark:text-gray-400"},ww={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"},$w={class:"flex justify-end gap-2"},Cw={class:"text-xs text-gray-400"},Sw={class:"flex flex-wrap justify-end gap-2"},Ge="settings.ai.semanticIndex",X2=le({__name:"SemanticIndexSessionModal",props:{modelValue:{type:Boolean},sessionId:{},messageCount:{}},emits:["update:modelValue"],setup(r,{emit:i}){const e=r,s=i,{t:n}=Ie(),u=wo(),o=T({get:()=>e.modelValue,set:C=>s("update:modelValue",C)}),c=A(null),m=A(!1),h=A(!1),p=A(!1),_=T(()=>{const C=c.value;return!C||!C.enabled?n(`${Ge}.session.notEnabled`):C.needsRebuild?n(`${Ge}.state.needsRebuild`):C.running||C.queued||C.indexStatus==="running"?n(`${Ge}.state.building`):C.indexStatus==="completed"?n(`${Ge}.state.completed`):C.indexStatus==="failed"?n(`${Ge}.state.failed`):C.indexStatus==="paused"?n(`${Ge}.state.paused`):n(`${Ge}.state.pending`)}),y=T(()=>{const C=c.value;return!!C&&(C.running||C.queued||C.indexStatus==="running")}),b=T(()=>c.value&&c.value.totalMessages>0?Math.round(c.value.indexedMessages/c.value.totalMessages*100):0);let x=null;function k(){x&&(clearTimeout(x),x=null)}function I(){k(),x=setTimeout(async()=>{try{c.value=await u.status(e.sessionId)}catch(C){console.error("[semantic-index] poll status failed:",C)}y.value&&e.modelValue?I():k()},1500)}async function $(){h.value=!0;try{const[C,v]=await Promise.all([u.getConfig(),u.status(e.sessionId)]);m.value=C.config.enabled&&C.configured&&(C.config.mode==="local"?!!C.config.local.modelId:!!C.config.api?.baseUrl&&!!C.config.api?.model&&(!$o(C.config.api?.baseUrl)||C.apiKeySet)),c.value=v}catch(C){console.error("[semantic-index] load session status failed:",C)}finally{h.value=!1}y.value&&I()}async function w(C){p.value=!0;try{c.value=await u[C](e.sessionId)}catch(v){console.error(`[semantic-index] ${C} failed:`,v)}finally{p.value=!1}y.value?I():k()}return fe(()=>e.modelValue,C=>{C?$():k()}),dt(k),(C,v)=>{const S=Me,V=Xe,B=lt;return l(),P(B,{open:o.value,"onUpdate:open":v[10]||(v[10]=D=>o.value=D),ui:{content:"z-[101]",overlay:"z-[100]"}},{content:L(()=>[a("div",rw,[a("div",lw,[f(S,{name:"i-heroicons-circle-stack",class:"h-5 w-5 text-blue-500"}),a("h3",uw,d(t(n)(`${Ge}.title`)),1)]),h.value?(l(),g("div",cw,[f(S,{name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin"}),ne(" "+d(t(n)("common.loading")),1)])):(l(),g(ie,{key:1},[a("div",dw,[a("div",mw,[a("span",gw,d(t(n)(`${Ge}.session.statusLabel`)),1),a("span",pw,d(_.value),1)]),c.value?.enabled&&c.value.indexStatus==="completed"?(l(),g("div",fw,[a("span",hw,d(t(n)(`${Ge}.session.coverageLabel`)),1),a("span",vw,d(b.value)+"%",1)])):E("",!0),y.value?(l(),g("div",yw,[a("div",xw,[a("span",null,d(t(n)(`${Ge}.session.progressLabel`)),1),a("span",null,d(c.value?.indexedMessages??0)+" / "+d(c.value?.totalMessages??0)+" ("+d(b.value)+"%) ",1)]),a("div",bw,[a("div",{class:"h-full rounded-full bg-blue-500 transition-all duration-500",style:mt({width:`${b.value}%`})},null,4)])])):E("",!0),c.value?.error?(l(),g("p",kw,d(c.value.error),1)):E("",!0)]),c.value?.enabled?(l(),g(ie,{key:1},[a("p",Cw,d(t(n)(`${Ge}.session.buildVsEnable`)),1),a("div",Sw,[y.value?(l(),g(ie,{key:0},[f(V,{variant:"soft",loading:p.value,onClick:v[2]||(v[2]=D=>w("pause"))},{default:L(()=>[ne(d(t(n)(`${Ge}.action.pause`)),1)]),_:1},8,["loading"]),f(V,{color:"error",variant:"soft",disabled:p.value,onClick:v[3]||(v[3]=D=>w("cancel"))},{default:L(()=>[ne(d(t(n)(`${Ge}.action.cancel`)),1)]),_:1},8,["disabled"])],64)):c.value?.indexStatus==="completed"&&!c.value?.needsRebuild?(l(),P(V,{key:1,variant:"soft",loading:p.value,onClick:v[4]||(v[4]=D=>w("rebuild"))},{default:L(()=>[ne(d(t(n)(`${Ge}.action.rebuild`)),1)]),_:1},8,["loading"])):c.value?.needsRebuild?(l(),P(V,{key:2,color:"primary",loading:p.value,onClick:v[5]||(v[5]=D=>w("rebuild"))},{default:L(()=>[ne(d(t(n)(`${Ge}.action.rebuild`)),1)]),_:1},8,["loading"])):c.value?.indexStatus==="failed"?(l(),P(V,{key:3,color:"primary",loading:p.value,onClick:v[6]||(v[6]=D=>w("build"))},{default:L(()=>[ne(d(t(n)(`${Ge}.session.retry`)),1)]),_:1},8,["loading"])):c.value?.indexStatus==="paused"?(l(),P(V,{key:4,color:"primary",loading:p.value,onClick:v[7]||(v[7]=D=>w("build"))},{default:L(()=>[ne(d(t(n)(`${Ge}.session.continue`)),1)]),_:1},8,["loading"])):(l(),P(V,{key:5,color:"primary",loading:p.value,onClick:v[8]||(v[8]=D=>w("build"))},{default:L(()=>[ne(d(t(n)(`${Ge}.action.build`)),1)]),_:1},8,["loading"])),f(V,{variant:"ghost",color:"neutral",disabled:p.value,onClick:v[9]||(v[9]=D=>w("remove"))},{default:L(()=>[ne(d(t(n)(`${Ge}.action.remove`)),1)]),_:1},8,["disabled"])])],64)):(l(),g(ie,{key:0},[a("p",_w,d(t(n)(`${Ge}.session.enableHint`)),1),m.value?E("",!0):(l(),g("p",ww,d(t(n)(`${Ge}.session.configFirst`)),1)),a("div",$w,[f(V,{variant:"ghost",onClick:v[0]||(v[0]=D=>o.value=!1)},{default:L(()=>[ne(d(t(n)("common.close")),1)]),_:1}),f(V,{color:"primary",loading:p.value,disabled:!m.value,onClick:v[1]||(v[1]=D=>w("enable"))},{default:L(()=>[ne(d(t(n)(`${Ge}.session.enable`)),1)]),_:1},8,["loading","disabled"])])],64))],64))])]),_:1},8,["open"])}}}),Iw={class:"min-h-[200px]"},Tw={key:0,class:"space-y-4"},Mw={class:"text-sm text-gray-600 dark:text-gray-400"},Aw={class:"text-sm text-gray-600 dark:text-gray-400"},zw={key:1,class:"flex flex-col items-center justify-center py-10"},qw={class:"text-gray-600 dark:text-gray-400"},Lw={class:"mt-2 text-sm text-gray-500"},Dw={key:2,class:"space-y-6"},Ew={class:"rounded-lg bg-gray-50 p-4 dark:bg-gray-800"},Bw={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},Fw={class:"grid grid-cols-3 gap-4 text-center"},Rw={class:"text-2xl font-bold text-gray-900 dark:text-white"},Vw={class:"text-xs text-gray-500"},Ow={class:"text-2xl font-bold text-green-600 dark:text-green-400"},Pw={class:"text-xs text-gray-500"},Nw={class:"text-2xl font-bold text-gray-400"},jw={class:"text-xs text-gray-500"},Uw={key:0,class:"text-center text-sm text-amber-600 dark:text-amber-400"},Hw={key:3,class:"flex flex-col items-center justify-center py-10"},Ww={class:"text-gray-600 dark:text-gray-400"},Kw={key:0,class:"mt-4 w-full max-w-xs"},Yw={key:4,class:"flex flex-col items-center justify-center py-10"},Gw={class:"text-lg font-medium text-gray-900 dark:text-white"},Qw={class:"mt-2 text-sm text-gray-600 dark:text-gray-400"},Jw={key:5,class:"flex flex-col items-center justify-center py-10"},Xw={class:"text-lg font-medium text-gray-900 dark:text-white"},Zw={class:"mt-2 text-sm text-red-600 dark:text-red-400"},e2={class:"flex w-full justify-end gap-2"},Z2=le({__name:"IncrementalImportModal",props:{modelValue:{type:Boolean},sessionId:{},sessionName:{}},emits:["update:modelValue","imported"],setup(r,{emit:i}){const e=r,s=i,{t:n}=Ie(),u=A("select"),o=A(null),c=A(null),m=A(null),h=A(null),p=A(null),_=A(null),y=T({get:()=>e.modelValue,set:S=>s("update:modelValue",S)});fe(y,S=>{S||b()});function b(){u.value="select",o.value=null,m.value=null,h.value=null,p.value=null,_.value=null}async function x({files:S,paths:V}){if(S.length>0)o.value={source:S[0],name:S[0].name};else{p.value=n("home.import.cannotReadPath");return}await I()}function k(){c.value?.openFileDialog()}async function I(){if(o.value){u.value="analyzing",p.value=null;try{const S=await os().analyzeIncrementalImport(e.sessionId,o.value.source);if(S.error){u.value="error",p.value=v(S.error);return}m.value={newMessageCount:S.newMessageCount,duplicateCount:S.duplicateCount,totalInFile:S.totalInFile},u.value="preview"}catch(S){u.value="error",p.value=String(S)}}}async function $(){if(o.value){u.value="importing",h.value={stage:"saving",progress:0,message:""};try{const S=await os().incrementalImport(e.sessionId,o.value.source,V=>{h.value=V});S.success?(_.value={newMessageCount:S.newMessageCount},u.value="done"):(u.value="error",p.value=v(S.error||"error.import_failed"))}catch(S){u.value="error",p.value=String(S)}}}function w(){_.value&&s("imported",_.value.newMessageCount),y.value=!1}function C(){u.value="select",o.value=null,m.value=null,p.value=null}function v(S){if(S.startsWith("error.")){const V=`home.import.errors.${S.slice(6)}`,B=n(V);return B!==V?B:S}return S}return(S,V)=>{const B=qo,D=Me,z=ro,M=Xe,q=lt;return l(),P(q,{open:y.value,"onUpdate:open":V[1]||(V[1]=U=>y.value=U),title:t(n)("analysis.incremental.title")},{body:L(()=>[a("div",Iw,[u.value==="select"?(l(),g("div",Tw,[a("p",Mw,d(t(n)("analysis.incremental.description",{name:r.sessionName})),1),f(B,{color:"info",variant:"soft",icon:"i-heroicons-information-circle",description:t(n)("analysis.incremental.homeAutoImportHint")},null,8,["description"]),f(t(mo),{ref_key:"dropZoneRef",ref:c,accept:[".json",".jsonl",".txt"],class:"w-full",onFiles:x},{default:L(({isDragOver:U})=>[a("div",{class:W(["flex cursor-pointer flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 py-10 transition-colors",U?"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:Ke(k,["stop"])},[f(D,{name:"i-heroicons-arrow-up-tray",class:"mb-3 h-10 w-10 text-gray-400"}),a("p",Aw,d(U?t(n)("home.import.dropHint"):t(n)("analysis.incremental.dropHint")),1)],2)]),_:1},512)])):u.value==="analyzing"?(l(),g("div",zw,[f(D,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),a("p",qw,d(t(n)("analysis.incremental.analyzing")),1),a("p",Lw,d(o.value?.name),1)])):u.value==="preview"&&m.value?(l(),g("div",Dw,[a("div",Ew,[a("p",Bw,d(o.value?.name),1),a("div",Fw,[a("div",null,[a("p",Rw,d(m.value.totalInFile.toLocaleString()),1),a("p",Vw,d(t(n)("analysis.incremental.totalInFile")),1)]),a("div",null,[a("p",Ow,d(m.value.newMessageCount.toLocaleString()),1),a("p",Pw,d(t(n)("analysis.incremental.newMessages")),1)]),a("div",null,[a("p",Nw,d(m.value.duplicateCount.toLocaleString()),1),a("p",jw,d(t(n)("analysis.incremental.duplicates")),1)])])]),m.value.newMessageCount===0?(l(),g("p",Uw,[f(D,{name:"i-heroicons-exclamation-triangle",class:"mr-1 inline-block h-4 w-4"}),ne(" "+d(t(n)("analysis.incremental.noNewMessages")),1)])):E("",!0)])):u.value==="importing"?(l(),g("div",Hw,[f(D,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),a("p",Ww,d(t(n)("analysis.incremental.importing")),1),h.value?(l(),g("div",Kw,[f(z,{value:h.value.progress,size:"sm"},null,8,["value"])])):E("",!0)])):u.value==="done"&&_.value?(l(),g("div",Yw,[f(D,{name:"i-heroicons-check-circle",class:"mb-4 h-12 w-12 text-green-500"}),a("p",Gw,d(t(n)("analysis.incremental.success")),1),a("p",Qw,d(t(n)("analysis.incremental.successDetail",{count:_.value.newMessageCount})),1)])):u.value==="error"?(l(),g("div",Jw,[f(D,{name:"i-heroicons-x-circle",class:"mb-4 h-12 w-12 text-red-500"}),a("p",Xw,d(t(n)("analysis.incremental.failed")),1),a("p",Zw,d(p.value),1)])):E("",!0)])]),footer:L(()=>[a("div",e2,[u.value==="select"?(l(),P(M,{key:0,color:"neutral",variant:"ghost",onClick:V[0]||(V[0]=U=>y.value=!1)},{default:L(()=>[ne(d(t(n)("common.cancel")),1)]),_:1})):u.value==="preview"?(l(),g(ie,{key:1},[f(M,{color:"neutral",variant:"ghost",onClick:C},{default:L(()=>[ne(d(t(n)("common.back")),1)]),_:1}),f(M,{color:"primary",disabled:!m.value||m.value.newMessageCount===0,onClick:$},{default:L(()=>[ne(d(t(n)("analysis.incremental.import",{count:m.value?.newMessageCount||0})),1)]),_:1},8,["disabled"])],64)):u.value==="done"||u.value==="error"?(l(),g(ie,{key:2},[u.value==="error"?(l(),P(M,{key:0,color:"neutral",variant:"ghost",onClick:C},{default:L(()=>[ne(d(t(n)("common.retry")),1)]),_:1})):E("",!0),f(M,{color:"primary",onClick:w},{default:L(()=>[ne(d(t(n)("common.done")),1)]),_:1})],64)):E("",!0)])]),_:1},8,["open","title"])}}}),t2={key:0,class:"fixed right-0 top-1/3"},a2={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"},s2=["onClick"],n2={class:"mb-2 flex items-center justify-between"},o2={class:"px-0.5 text-[9px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"},i2={class:"flex flex-col gap-1.5"},r2=["onClick"],l2={class:"whitespace-nowrap"},e$=le({__name:"ActionToolsPanel",emits:["openIncrementalImport","openSemanticIndex","openMemberManagement","openChatRecord","openMessageExport"],setup(r,{emit:i}){const{t:e}=Ie(),s=zt(),{isToolsPanelMini:n,effectiveToolsPanelPosition:u,isToolsPanelOpen:o}=_t(s),c=T(()=>u.value==="header"),m=T(()=>!c.value||o.value),h=A(null),p=i;function _(I){p(I),c.value&&(o.value=!1)}function y(I){if(!c.value||!o.value)return;const $=I.target;$ instanceof Element&&(h.value?.contains($)||$.closest("[data-tools-panel-trigger]")||(o.value=!1))}const b=[{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"}],x=[{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"}],k=T(()=>c.value?x:b);return fe(u,()=>{o.value=!1}),He(()=>{document.addEventListener("mousedown",y)}),Ft(()=>{document.removeEventListener("mousedown",y)}),(I,$)=>{const w=Me,C=Rt;return!c.value&&t(n)?(l(),g("div",t2,[a("div",a2,[(l(),g(ie,null,_e(b,v=>f(C,{key:v.event,text:t(e)(v.labelKey),popper:{placement:"left"}},{default:L(()=>[a("button",{class:W(["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",v.miniHoverBg]),onClick:S=>_(v.event)},[f(w,{name:v.icon,class:"h-3.5 w-3.5"},null,8,["name"])],10,s2)]),_:2},1032,["text"])),64)),$[2]||($[2]=a("div",{class:"my-0.5 h-px w-4 bg-gray-200 dark:bg-gray-700"},null,-1)),f(C,{text:t(e)("analysis.toolsPanel.exitMini"),popper:{placement:"left"}},{default:L(()=>[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:$[0]||($[0]=v=>t(s).toggleToolsPanelMini())},[f(w,{name:"i-heroicons-arrows-pointing-out",class:"h-3 w-3"})])]),_:1},8,["text"])])])):(l(),g("div",{key:1,class:W(["fixed right-0 z-40",c.value?"top-14":"top-1/3"])},[a("div",{class:W(["absolute right-0 top-0 transition-all duration-250 ease-in-out",m.value?"translate-x-0 opacity-100":"pointer-events-none translate-x-full opacity-0"])},[a("div",{ref_key:"panelRef",ref:h,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",n2,[a("span",o2,d(t(e)("analysis.overview.tools")),1),c.value?E("",!0):(l(),P(C,{key:0,text:t(e)("analysis.toolsPanel.miniMode"),popper:{placement:"left"}},{default:L(()=>[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:$[1]||($[1]=v=>t(s).toggleToolsPanelMini())},[f(w,{name:"i-heroicons-arrows-pointing-in",class:"h-3 w-3"})])]),_:1},8,["text"]))]),a("div",i2,[(l(!0),g(ie,null,_e(k.value,v=>(l(),g("button",{key:v.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:S=>_(v.event)},[f(w,{name:v.icon,class:W(["h-3.5 w-3.5 text-gray-400 transition-colors dark:text-gray-500",v.hoverColor])},null,8,["name","class"]),a("span",l2,d(t(e)(v.labelKey)),1)],8,r2))),128))])],512)],2)],2))}}});export{j2 as C,N2 as D,V2 as I,O2 as L,Q2 as M,xa as _,R2 as a,ut as b,Y2 as c,La as d,G2 as e,uy as f,U2 as g,H2 as h,W2 as i,F2 as j,J2 as k,P2 as l,e$ as m,X2 as n,Z2 as o,K2 as u};