chatlab-cli 0.30.2-beta.1 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist/{chat-command-VBDMWOKL.mjs → chat-command-CHV7RLBH.mjs} +9 -8
  2. package/dist/{chat-command-VBDMWOKL.mjs.map → chat-command-CHV7RLBH.mjs.map} +1 -1
  3. package/dist/{chunk-326OCJOT.mjs → chunk-DA5T64RY.mjs} +2 -2
  4. package/dist/{chunk-M2PXDX4G.mjs → chunk-DBBL74RK.mjs} +31 -22
  5. package/dist/chunk-DBBL74RK.mjs.map +1 -0
  6. package/dist/{chunk-KBSAVUFV.mjs → chunk-EXD2SXWL.mjs} +89 -15
  7. package/dist/chunk-EXD2SXWL.mjs.map +1 -0
  8. package/dist/{chunk-D3DPCDII.mjs → chunk-JH5RAJT2.mjs} +83 -34
  9. package/dist/chunk-JH5RAJT2.mjs.map +1 -0
  10. package/dist/{chunk-5EE2EFPE.mjs → chunk-RD335EMA.mjs} +4 -4
  11. package/dist/{chunk-WV5GSRQM.mjs → chunk-RDCUGC24.mjs} +5 -15
  12. package/dist/chunk-RDCUGC24.mjs.map +1 -0
  13. package/dist/{chunk-TEX44HNL.mjs → chunk-SNCXU2QL.mjs} +5 -15
  14. package/dist/chunk-SNCXU2QL.mjs.map +1 -0
  15. package/dist/{chunk-36JGKW6K.mjs → chunk-T64GA5HP.mjs} +1134 -364
  16. package/dist/chunk-T64GA5HP.mjs.map +1 -0
  17. package/dist/{chunk-LVEJHB3X.mjs → chunk-UWWFOEGF.mjs} +494 -97
  18. package/dist/chunk-UWWFOEGF.mjs.map +1 -0
  19. package/dist/{chunk-ULNRUS55.mjs → chunk-WQCY45U2.mjs} +3 -3
  20. package/dist/chunk-YAQLYL52.mjs +14 -0
  21. package/dist/chunk-YAQLYL52.mjs.map +1 -0
  22. package/dist/{chunk-TCZHG3G7.mjs → chunk-YPQ72HMX.mjs} +2 -2
  23. package/dist/cli.mjs +8 -7
  24. package/dist/contacts-worker.mjs +2 -2
  25. package/dist/global-insight-worker.mjs +179 -0
  26. package/dist/global-insight-worker.mjs.map +1 -0
  27. package/dist/{http-L4AMELPZ.mjs → http-3B5ARN7A.mjs} +12 -11
  28. package/dist/{import-WWCSXGVS.mjs → import-2DZGNSEX.mjs} +10 -7
  29. package/dist/index.mjs +12 -11
  30. package/dist/{mcp-A4M3LT5O.mjs → mcp-44I6FUUQ.mjs} +12 -11
  31. package/dist/{mcp-A4M3LT5O.mjs.map → mcp-44I6FUUQ.mjs.map} +1 -1
  32. package/dist/people-relationships-worker.mjs +2 -2
  33. package/dist/semantic-index-worker.mjs +1 -1
  34. package/dist/{src-MPNBTFOE.mjs → src-R3QX6L3L.mjs} +26 -6
  35. package/dist/{stream-import-HIE7PNL4.mjs → stream-import-VUEL2TTU.mjs} +10 -7
  36. package/dist/{worker-runtime-BJXO24XX.mjs → worker-runtime-GJAOIIZW.mjs} +6 -5
  37. package/dist/{worker-runtime-BJXO24XX.mjs.map → worker-runtime-GJAOIIZW.mjs.map} +1 -1
  38. package/dist-web/assets/ActionToolsPanel-fAio70bI.css +1 -0
  39. package/dist-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-CdJT0t2f.js +110 -0
  40. package/dist-web/assets/{BufferResource-CYSOCeE0.js → BufferResource-BPGkshPa.js} +1 -1
  41. package/dist-web/assets/{CanvasRenderer-j7Z_ij_m.js → CanvasRenderer-DTKkZhq4.js} +1 -1
  42. package/dist-web/assets/{EChartWordcloud-Clg60FMo.js → EChartWordcloud-DU3ZYdgz.js} +1 -1
  43. package/dist-web/assets/{Filter-BgGyBeXz.js → Filter-CHXKzS2l.js} +1 -1
  44. package/dist-web/assets/{LoadingState.vue_vue_type_script_setup_true_lang-D_dJuLWJ.js → LoadingState.vue_vue_type_script_setup_true_lang-DACMroOe.js} +1 -1
  45. package/dist-web/assets/MessageExportModal-h-zl0dx1.js +1 -0
  46. package/dist-web/assets/PageHeader-CK0hTsdx.js +1 -0
  47. package/dist-web/assets/PageHeader-XIXMTomn.css +1 -0
  48. package/dist-web/assets/{RelationshipGalaxyCanvas-D2owKyDp.js → RelationshipGalaxyCanvas-Dwdy5flh.js} +3 -3
  49. package/dist-web/assets/{RelationshipGalaxyThreeCanvas-DfJ2x8y9.js → RelationshipGalaxyThreeCanvas-CtY4TGen.js} +1 -1
  50. package/dist-web/assets/{RenderTargetSystem-BQ__RbzR.js → RenderTargetSystem-BE56mKRG.js} +1 -1
  51. package/dist-web/assets/ThemeCard.vue_vue_type_script_setup_true_lang-BoZyssJF.js +1 -0
  52. package/dist-web/assets/TimeSelect.vue_vue_type_script_setup_true_lang-27hMyAUE.js +1 -0
  53. package/dist-web/assets/{WebGLRenderer-DuThUm1R.js → WebGLRenderer-Dm18dxOf.js} +1 -1
  54. package/dist-web/assets/{WebGPURenderer-d8BwTpxP.js → WebGPURenderer-BF6TF-is.js} +1 -1
  55. package/dist-web/assets/annual-summary-time-range-DVLXK1r4.js +1 -0
  56. package/dist-web/assets/base-CFPyD9Gy.js +1 -0
  57. package/dist-web/assets/{browserAll-t_tpJM2L.js → browserAll-Cn_CfkXl.js} +1 -1
  58. package/dist-web/assets/dateFormat-BcqNKTQ1.js +1 -0
  59. package/dist-web/assets/{electron-6T3FvCfK.js → electron-B6xOabTq.js} +1 -1
  60. package/dist-web/assets/electron-hcWiB7Gg.js +1 -0
  61. package/dist-web/assets/fetch-BPkgnY0R.js +1 -0
  62. package/dist-web/assets/{fetch-DFifsv8L.js → fetch-BRXmDI_2.js} +1 -1
  63. package/dist-web/assets/{fetch-BgeRLaoA.js → fetch-BUm1isWe.js} +1 -1
  64. package/dist-web/assets/{fetch-Y-LYZmiT.js → fetch-CBOJwwJp.js} +3 -3
  65. package/dist-web/assets/{fetch-C7rlHKE7.js → fetch-CEhUu1Yu.js} +1 -1
  66. package/dist-web/assets/fetch-C_EfVFJi.js +3 -0
  67. package/dist-web/assets/{fetch-BVM5kQ6-.js → fetch-DL_u25Ui.js} +1 -1
  68. package/dist-web/assets/{fetch-BLTlXcRA.js → fetch-DMLq3xPG.js} +1 -1
  69. package/dist-web/assets/{fetch-BgIWhYDV.js → fetch-DylpNKCR.js} +1 -1
  70. package/dist-web/assets/fetch-etgwVKIw.js +1 -0
  71. package/dist-web/assets/index-0x1QPzKZ.js +1 -0
  72. package/dist-web/assets/index-B5S9FnfP.js +1 -0
  73. package/dist-web/assets/index-BS6loLHW.js +1 -0
  74. package/dist-web/assets/index-BfO_LpDv.css +1 -0
  75. package/dist-web/assets/index-BrTlAl8b.js +1 -0
  76. package/dist-web/assets/index-ByUaiVQK.css +1 -0
  77. package/dist-web/assets/{index-BA87rT8F.js → index-C3TnydSt.js} +1 -1
  78. package/dist-web/assets/index-CAWO10k1.js +2 -0
  79. package/dist-web/assets/index-C_0GHEcb.css +1 -0
  80. package/dist-web/assets/index-Chm17wNe.js +2 -0
  81. package/dist-web/assets/index-DAr_2DlV.js +173 -0
  82. package/dist-web/assets/index-Em6upenM.js +64 -0
  83. package/dist-web/assets/index-FoTy2Cce.js +1 -0
  84. package/dist-web/assets/index-YADL4XIp.js +22 -0
  85. package/dist-web/assets/index-ZsZwPLWy.css +1 -0
  86. package/dist-web/assets/index-_6lck7Bv.css +1 -0
  87. package/dist-web/assets/index-aMIgqj43.js +1 -0
  88. package/dist-web/assets/index-y7cxH1Et.css +1 -0
  89. package/dist-web/assets/index-zZVsV5HB.js +1 -0
  90. package/dist-web/assets/{people-page-header-Mupn-U_b.js → people-page-header-BdKM1qhX.js} +1 -1
  91. package/dist-web/assets/types-CZnACqaB.js +1 -0
  92. package/dist-web/assets/{vendor-echarts-hJVnODyU.js → vendor-echarts-B-i_56Av.js} +1 -1
  93. package/dist-web/assets/{vendor-echarts-wordcloud-k5ih2Jl4.js → vendor-echarts-wordcloud-Ca8n6qS6.js} +1 -1
  94. package/dist-web/assets/{vendor-nuxt-ui-DaLxYaC4.js → vendor-nuxt-ui-CS1uxE9C.js} +2 -2
  95. package/dist-web/assets/{vendor-reka-ui-CzM4kDQ7.js → vendor-reka-ui-Cta6JPvN.js} +1 -1
  96. package/dist-web/assets/web-BUZ-dZy0.js +1 -0
  97. package/dist-web/assets/{webworkerAll-CoXPTsvw.js → webworkerAll-BKGP--A4.js} +1 -1
  98. package/dist-web/index.html +4 -4
  99. package/package.json +1 -1
  100. package/dist/chunk-36JGKW6K.mjs.map +0 -1
  101. package/dist/chunk-D3DPCDII.mjs.map +0 -1
  102. package/dist/chunk-KBSAVUFV.mjs.map +0 -1
  103. package/dist/chunk-LVEJHB3X.mjs.map +0 -1
  104. package/dist/chunk-M2PXDX4G.mjs.map +0 -1
  105. package/dist/chunk-TEX44HNL.mjs.map +0 -1
  106. package/dist/chunk-WV5GSRQM.mjs.map +0 -1
  107. package/dist-web/assets/DebugToolsPanel-D_lFIW6j.css +0 -1
  108. package/dist-web/assets/DebugToolsPanel.vue_vue_type_script_setup_true_lang-Bk9RvIsW.js +0 -110
  109. package/dist-web/assets/MessageExportModal-BkEhC8s3.js +0 -1
  110. package/dist-web/assets/PageHeader-Bbn87QZS.css +0 -1
  111. package/dist-web/assets/PageHeader-CUwv2AFR.js +0 -1
  112. package/dist-web/assets/electron-D9vE5t3H.js +0 -1
  113. package/dist-web/assets/fetch-D0ccqGk_.js +0 -1
  114. package/dist-web/assets/fetch-DdoIAbX4.js +0 -1
  115. package/dist-web/assets/fetch-HpiZrx8C.js +0 -3
  116. package/dist-web/assets/index---rXG1hZ.css +0 -1
  117. package/dist-web/assets/index-B4l3rHie.css +0 -1
  118. package/dist-web/assets/index-B5YKZflT.js +0 -2
  119. package/dist-web/assets/index-C1p9CbmN.css +0 -1
  120. package/dist-web/assets/index-COpza1A4.css +0 -1
  121. package/dist-web/assets/index-CQsrsY5d.js +0 -64
  122. package/dist-web/assets/index-CdsKtFEJ.js +0 -22
  123. package/dist-web/assets/index-DosG7LmJ.css +0 -1
  124. package/dist-web/assets/index-DraLHiEK.js +0 -173
  125. package/dist-web/assets/index-IL5tkxhM.js +0 -2
  126. package/dist-web/assets/index-Tgk7RCvc.js +0 -1
  127. package/dist-web/assets/index-cyh3gOBe.js +0 -1
  128. package/dist-web/assets/index-g8yqhgfj.js +0 -1
  129. package/dist-web/assets/web-DAgXT8gQ.js +0 -1
  130. /package/dist/{chunk-326OCJOT.mjs.map → chunk-DA5T64RY.mjs.map} +0 -0
  131. /package/dist/{chunk-5EE2EFPE.mjs.map → chunk-RD335EMA.mjs.map} +0 -0
  132. /package/dist/{chunk-ULNRUS55.mjs.map → chunk-WQCY45U2.mjs.map} +0 -0
  133. /package/dist/{chunk-TCZHG3G7.mjs.map → chunk-YPQ72HMX.mjs.map} +0 -0
  134. /package/dist/{http-L4AMELPZ.mjs.map → http-3B5ARN7A.mjs.map} +0 -0
  135. /package/dist/{import-WWCSXGVS.mjs.map → import-2DZGNSEX.mjs.map} +0 -0
  136. /package/dist/{src-MPNBTFOE.mjs.map → src-R3QX6L3L.mjs.map} +0 -0
  137. /package/dist/{stream-import-HIE7PNL4.mjs.map → stream-import-VUEL2TTU.mjs.map} +0 -0
@@ -0,0 +1,110 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-YADL4XIp.js","assets/vendor-reka-ui-Cta6JPvN.js","assets/vendor-nuxt-ui-CS1uxE9C.js","assets/vendor-snapdom-XnBoh1gd.js","assets/index-_6lck7Bv.css","assets/EChartWordcloud-DU3ZYdgz.js","assets/vendor-echarts-wordcloud-Ca8n6qS6.js","assets/vendor-echarts-B-i_56Av.js","assets/vendor-zrender-5DcYjSZk.js"])))=>i.map(i=>d[i]);
2
+ import{R as La,S as ta,d as Me,k as Ne,u as fe,q as Fe,m as lt,n as Je,r as ct,U as Da,V as dt,s as et,W as xt,X as Aa,E as aa,Y as gt,y as Nt,Z as Ot,$ as sa,x as bt,a0 as ht,a1 as qa,T as st,g as Jt,b as za,w as oa,M as at,o as Ra,z as Pa,l as Ea,a2 as Ba,a3 as ja,D as Xt}from"./index-YADL4XIp.js";import{t as Ke,w as ge,h as b,b as f,d as je,p as pe,G as n,P as i,L as p,H as Y,K as j,O as We,a5 as e,Q as ne,T as o,U as R,a0 as Qe,R as ee,Z,u as a,a3 as ce,bx as Ve,by as ot,a9 as Be,bz as Ge,J as zt,W as Rt,bF as Ua,bC as nt,n as Ue,bw as rt,z as kt,F as ut,bA as na,k as Fa}from"./vendor-reka-ui-Cta6JPvN.js";import{_ as _t}from"./vendor-snapdom-XnBoh1gd.js";import{_ as we,d as ze,m as ra,g as He,i as pt,b as wt,p as Va,c as la,f as Wt,q as ia,o as Ht,n as Na,r as Yt,e as Oa,l as Wa}from"./vendor-nuxt-ui-CS1uxE9C.js";import{_ as mt}from"./LoadingState.vue_vue_type_script_setup_true_lang-DACMroOe.js";import{_ as tt}from"./ThemeCard.vue_vue_type_script_setup_true_lang-BoZyssJF.js";import{a as it,M as Kt,_ as Ha}from"./index-C3TnydSt.js";import{C as Ya,a as $t,_ as Ze,g as Pt}from"./base-CFPyD9Gy.js";import"./vendor-echarts-wordcloud-Ca8n6qS6.js";import{f as Ka}from"./dateFormat-BcqNKTQ1.js";import{u as Ct,p as ca,z as da,j as Qt,v as ua,i as St,k as Tt,A as Qa,m as Ga,n as Ja,t as Xa}from"./vendor-echarts-B-i_56Av.js";import{_ as Za}from"./TimeSelect.vue_vue_type_script_setup_true_lang-27hMyAUE.js";import{P as es}from"./PageHeader-CK0hTsdx.js";const ts={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"]},Zt=/^(?!.*-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 as(l,s){const t=s.toLowerCase(),c=l.toLowerCase();if(t.includes("-non-reasoning")||c==="anthropic")return"none";if(c==="gemini")return/gemini-(?:2\.5|3(?:\.\d+)?-(?:flash|pro)|flash-latest|pro-latest)/i.test(t)?"gemini":"none";if(c==="qwen"||/\bqwen|qwq/i.test(t))return"qwen";if(/deepseek[_-]v([4-9]|\d{2,})/i.test(t)||/deepseek-ai\/deepseek-r1/i.test(t))return"deepseek_v4";if(/deepseek[_-]chat|deepseek[_-]v3/i.test(t))return"deepseek_hybrid";if(c==="openai"||c==="openai-compatible"){if(/gpt-5\.[2-9]|gpt-5\.[1-9]\d/.test(t))return"gpt5_2plus";if(/gpt-5\.1/.test(t))return"gpt5_1";if(/gpt-5/.test(t))return"gpt5";if(/^o\d/.test(t))return"o_series"}return/^o\d/.test(t)?"o_series":/\bgrok-(?:3-mini|4|4-fast|build)\b/i.test(t)?"grok":/\bkimi-k(?:2-thinking|2\.[5-9]|[3-9])/i.test(t)||c==="kimi"&&/thinking/i.test(t)?"kimi":/\bdoubao-.*seed/i.test(t)||c==="doubao"&&/seed/i.test(t)?"doubao":/\bhunyuan-(?:t1|a13b)/i.test(t)?"hunyuan":c==="glm"||/\bglm-?(?:5|4\.[5-7]|z1|zero)/i.test(t)?"qwen":c==="siliconflow"&&/r[1-9]/i.test(t)?"deepseek_v4":c==="openrouter"?/deepseek.*(v[4-9]|r\d)/i.test(t)?"deepseek_v4":/deepseek[_-]?(chat|v3)/i.test(t)?"deepseek_hybrid":/\bgrok-(?:3-mini|4|4-fast|build)\b/i.test(t)?"grok":/\bkimi-k(?:2-thinking|2\.[5-9]|[3-9])/i.test(t)?"kimi":Zt.test(t)?"default":"none":/\bmimo-v2/i.test(t)||/\bminimax-m[123]/i.test(t)||/\bseed-oss/i.test(t)?"deepseek_hybrid":/\bbaichuan-m[23]/i.test(t)||/\bmagistral/i.test(t)||/\bmistral-small-2603/i.test(t)||/\bstep-(?:3|r1-v-mini)/i.test(t)||/\bgemma-?4/i.test(t)||/\bpangu-pro-moe/i.test(t)||/\bsonar-deep-research/i.test(t)||/\bring-(?:1t|mini|flash)/i.test(t)?"default":/\bqwen|qwq/i.test(t)?"qwen":/deepseek[_-]?r\d|deepseek[_-]?v[4-9]/i.test(t)?"deepseek_v4":/^o\d/i.test(t)?"o_series":Zt.test(t)?"default":"none"}function ss(l,s){const t=as(l,s);return ts[t]}function os(l,s,t,c="group",r="zh-CN"){const g=La(),{chatKey:u,state:d}=g.ensureSessionState({sessionId:l,sessionName:s,timeFilter:t,chatType:c,locale:r});return g.resetToSelectorOnEnter(u),g.applySessionAssistantSelection(u),{messages:Ke(d,"messages"),sourceMessages:Ke(d,"sourceMessages"),currentKeywords:Ke(d,"currentKeywords"),isLoadingSource:Ke(d,"isLoadingSource"),isAIThinking:Ke(d,"isAIThinking"),currentAIChatId:Ke(d,"currentAIChatId"),currentToolStatus:Ke(d,"currentToolStatus"),toolsUsedInCurrentRound:Ke(d,"toolsUsedInCurrentRound"),sessionTokenUsage:Ke(d,"sessionTokenUsage"),agentStatus:Ke(d,"agentStatus"),selectedAssistantId:Ke(d,"selectedAssistantId"),sendMessage:(m,v)=>g.sendMessage(u,m,v),editMessageAndRegenerate:(m,v,y)=>g.editMessageAndRegenerate(u,m,v,y),loadAIChat:m=>g.loadAIChat(u,m),startNewAIChat:m=>g.startNewAIChat(u,m),loadMoreSourceMessages:()=>g.loadMoreSourceMessages(),updateMaxMessages:()=>g.updateMaxMessages(),stopGeneration:()=>g.stopGeneration(u),selectAssistantForSession:m=>g.selectAssistantForSession(u,m)}}const Lt=new Map;function ns(l,s,t){const{activeTab:c,isInitialLoad:r,currentSessionId:g,onTimeRangeChange:u}=t,d=f(null),m=f(null),v=f([]),y=b(()=>{const I=d.value;if(I)return{startTs:I.startTs,endTs:I.endTs}}),M=b(()=>{const I=d.value;return I?`${I.startTs}-${I.endTs}`:"init"}),$=b(()=>{const I=l.query,q=I.timeMode;return q?{mode:q,recentDays:I.timeDays?Number(I.timeDays):void 0,year:I.timeYear?Number(I.timeYear):void 0,quarterYear:I.timeYear?Number(I.timeYear):void 0,quarter:I.timeQuarter?Number(I.timeQuarter):void 0,customStart:I.timeStart||void 0,customEnd:I.timeEnd||void 0}:g.value&&Lt.has(g.value)?Lt.get(g.value):{mode:"recent",recentDays:365}});ge([c,d],([I,q])=>{if(r.value||!q)return;const _=q.state,L={tab:I,timeMode:_.mode,timeDays:void 0,timeYear:void 0,timeQuarter:void 0,timeStart:void 0,timeEnd:void 0};_.mode==="recent"&&(L.timeDays=_.recentDays),_.mode==="year"&&(L.timeYear=_.year),_.mode==="quarter"&&(L.timeYear=_.quarterYear,L.timeQuarter=_.quarter),_.mode==="custom"&&(L.timeStart=_.customStart,L.timeEnd=_.customEnd),s.replace({query:{...l.query,...L}})}),ge(d,I=>{!I||!g.value||(ta(),Lt.set(g.value,I.state),u?.())},{immediate:!0});function D(){d.value=null,m.value=null,v.value=[]}return{timeRangeValue:d,fullTimeRange:m,availableYears:v,timeFilter:y,timeFilterKey:M,initialTimeState:$,resetTimeRange:D}}function rs(l){return l===0?"bg-linear-to-r from-amber-400 to-orange-500 text-white":l===1?"bg-linear-to-r from-gray-300 to-gray-400 text-white":l===2?"bg-linear-to-r from-amber-600 to-amber-700 text-white":"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"}function Fb(l){const s=["from-amber-400 to-orange-500","from-gray-300 to-gray-400","from-amber-600 to-amber-700","from-pink-400 to-pink-600","from-pink-300 to-rose-500","from-cyan-400 to-blue-500","from-green-400 to-emerald-500","from-rose-400 to-pink-500"];return s[l%s.length]}function ls(l){return l.content.trim()?l.content:l.contentBlocks?.filter(t=>t.type==="text"&&!!t.text).map(t=>t.text).join("")??""}function Et(l){return l.flatMap(s=>{if(s.role!=="user"&&s.role!=="assistant")return[];const t=ls(s);return t.trim()?[{role:s.role,content:t,timestamp:s.timestamp}]:[]})}function is(l){return Et(l).length>0}function cs(l,s,t,c){const r=[];r.push(`# ${l}`),r.push(""),r.push(`> ${c.createdAt}: ${Me(t).format("YYYY-MM-DD HH:mm:ss")}`),r.push(""),r.push("---"),r.push("");for(const g of s){const u=Me(g.timestamp).format("YYYY-MM-DD HH:mm:ss"),d=g.role==="user"?c.user:c.assistant;r.push(`### ${d}`),r.push(`*${u}*`),r.push(""),r.push(g.content),r.push(""),r.push("---"),r.push("")}return r.join(`
3
+ `)}function ds(l,s,t,c){const r=[];r.push(`${l}`),r.push(`${c.createdAt}: ${Me(t).format("YYYY-MM-DD HH:mm:ss")}`),r.push(""),r.push("=".repeat(50)),r.push("");for(const g of s){const u=Me(g.timestamp).format("YYYY-MM-DD HH:mm:ss"),d=g.role==="user"?c.user:c.assistant;r.push(`[${d}] ${u}`),r.push(""),r.push(g.content),r.push(""),r.push("-".repeat(50)),r.push("")}return r.join(`
4
+ `)}function us(l){return l.replace(/[/\\?%*:|"<>]/g,"_")}async function ms(l,s,t,c,r){if(s.length===0)return{success:!1,error:"No messages to export"};let g,u;const d=Me(t).format("YYYYMMDD_HHmmss"),m=us(l);c==="markdown"?(g=cs(l,s,t,r),u=`${m}_${d}.md`):(g=ds(l,s,t,r),u=`${m}_${d}.txt`);const v=`data:text/plain;charset=utf-8,${encodeURIComponent(g)}`,{useCacheService:y}=await _t(async()=>{const{useCacheService:$}=await import("./index-YADL4XIp.js").then(D=>D.a5);return{useCacheService:$}},__vite__mapDeps([0,1,2,3,4]));return await y().saveToDownloads(u,v)}function gs(l){const s=l.columns.join(","),t=l.rows.map(c=>c.map(r=>r===null?"":`"${String(r).replace(/"/g,'""')}"`).join(","));return[s,...t].join(`
5
+ `)}function ps(l){const s=l.rows.map(t=>{const c={};return l.columns.forEach((r,g)=>{c[r]=t[g]}),c});return JSON.stringify(s,null,2)}async function vs(l,s){if(l.rows.length===0)return{success:!1,error:"No data to export"};const c=`sql_result_${Me().format("YYYYMMDD_HHmmss")}.${s}`;let r,g;s==="json"?(r=ps(l),g="application/json"):(r=gs(l),g="text/csv");const u=`data:${g};charset=utf-8,${encodeURIComponent(r)}`,{useCacheService:d}=await _t(async()=>{const{useCacheService:v}=await import("./index-YADL4XIp.js").then(y=>y.a5);return{useCacheService:v}},__vite__mapDeps([0,1,2,3,4]));return await d().saveToDownloads(c,u)}function Vb(l){const{route:s,router:t,currentSessionId:c,selectSession:r,defaultTab:g,validTabIds:u}=l,d=f(!0),m=f(!0),v=f(null),y=f([]),M=f([]),$=f([]),D=f([]);function I(){const A=s.query.tab;return A&&u.includes(A)?A:g}const q=f(I()),{timeRangeValue:_,fullTimeRange:L,availableYears:x,timeFilter:C,initialTimeState:h}=ns(s,t,{activeTab:q,isInitialLoad:m,currentSessionId:c,onTimeRangeChange:()=>P()});function k(){const A=s.params.id;A&&(r(A),c.value!==A&&t.replace("/"))}async function S(){if(c.value)try{const A=await Ne().getSession(c.value);v.value=A}catch(A){console.error("加载基础数据失败:",A)}}async function P(){if(c.value){d.value=!0;try{const A=C.value,w=Ne(),[T,H,le,W]=await Promise.all([w.getMemberActivity(c.value,A),w.getHourlyActivity(c.value,A),w.getDailyActivity(c.value,A),w.getMessageTypeDistribution(c.value,A)]);y.value=T,M.value=H,$.value=le,D.value=W}catch(A){console.error("加载分析数据失败:",A)}finally{d.value=!1}}}async function B(){c.value&&(m.value=!0,await S(),m.value=!1)}return ge(()=>s.params.id,()=>{q.value=I(),k()}),ge(()=>s.query.tab,()=>{q.value=I()}),ge(c,()=>{ta(),B()},{immediate:!0}),je(()=>{k()}),{activeTab:q,isLoading:d,isInitialLoad:m,session:v,memberActivity:y,hourlyActivity:M,dailyActivity:$,messageTypes:D,timeRangeValue:_,fullTimeRange:L,availableYears:x,timeFilter:C,initialTimeState:h,syncSession:k,loadData:B,loadAnalysisData:P}}const ys={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"},hs=pe({__name:"CardCaptureOverlay",setup(l){return(s,t)=>(n(),i("div",ys,[p(it,{type:"element","target-selector":"[data-capturable-card]",size:"xs"})]))}}),Mt=pe({__name:"ReportCard",setup(l){return(s,t)=>(n(),Y(tt,{"data-capturable-card":"",class:"group/card relative isolate flex flex-col"},{default:j(()=>[p(Ya),p(hs),We(s.$slots,"default")]),_:3}))}}),fs={class:"flex items-center justify-between"},xs={class:"font-semibold text-gray-900 dark:text-white whitespace-nowrap"},bs={key:0,class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},ks={class:"flex items-center gap-2"},_s={key:0,class:"pointer-events-none opacity-0 transition-opacity duration-200 group-hover/card:pointer-events-auto group-hover/card:opacity-100"},Oe=pe({__name:"SectionCard",props:{title:{},description:{},capturable:{type:Boolean,default:!0},showDivider:{type:Boolean,default:!0},scrollable:{type:Boolean,default:!1},maxHeightVh:{default:60}},setup(l){const s=l,t=b(()=>{if(s.scrollable)return{maxHeight:`${s.maxHeightVh}vh`,overflowY:"auto"}});return(c,r)=>(n(),Y(tt,{class:"group/card","data-section-card":""},{default:j(()=>[e("div",{class:ne(["px-5 py-3",{"border-b border-gray-200 dark:border-white/5":l.showDivider&&c.$slots.default}])},[e("div",fs,[e("div",null,[e("p",xs,o(l.title),1),l.description?(n(),i("p",bs,o(l.description),1)):R("",!0)]),e("div",ks,[We(c.$slots,"headerRight"),l.capturable?(n(),i("div",_s,[p(it,{type:"element","target-selector":"[data-section-card]",size:"xs"})])):R("",!0)])])],2),l.scrollable?(n(),i("div",{key:0,style:Qe(t.value)},[We(c.$slots,"default")],4)):We(c.$slots,"default",{key:1}),We(c.$slots,"footer")]),_:3}))}}),ws={class:"flex items-start justify-between"},$s={class:"min-w-0 flex-1"},Cs={class:"text-sm font-medium text-gray-500 dark:text-gray-400"},Ss={key:1,class:"text-xl"},Ts={key:0,class:"mt-4 flex items-center text-sm"},Ms={class:"text-gray-500 dark:text-gray-400"},Xe=pe({__name:"StatCard",props:{label:{},value:{},valueColor:{},subtext:{},icon:{},iconBg:{}},setup(l){const s={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"},t={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(c,r)=>{const g=we;return n(),Y(tt,{class:"p-5"},{default:j(()=>[e("div",ws,[e("div",$s,[e("p",Cs,o(l.label),1),e("p",{class:ne(["mt-2 truncate text-2xl font-bold tracking-tight",l.valueColor?s[l.valueColor]:"text-gray-900 dark:text-white"])},o(l.value),3)]),l.icon?(n(),i("div",{key:0,class:ne(["ml-4 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl",t[l.iconBg||"gray"]])},[l.icon.startsWith("i-")?(n(),Y(g,{key:0,name:l.icon,class:"h-5 w-5"},null,8,["name"])):(n(),i("span",Ss,o(l.icon),1))],2)):R("",!0)]),l.subtext||c.$slots.subtext?(n(),i("div",Ts,[We(c.$slots,"subtext",{},()=>[e("span",Ms,o(l.subtext),1)])])):R("",!0)]),_:3})}}}),Is={key:0,class:"mb-2 block text-2xl"},Nb=pe({__name:"EmptyState",props:{text:{},icon:{},padding:{}},setup(l){const s={sm:"px-4 py-4",md:"px-5 py-8",lg:"px-6 py-12"};return(t,c)=>(n(),i("div",{class:ne(["text-center text-sm text-gray-400",s[l.padding||"md"]])},[l.icon?(n(),i("span",Is,o(l.icon),1)):R("",!0),ee(" "+o(l.text||"暂无数据"),1)],2))}}),Ls=["disabled"],Ds={key:0,class:"flex-1 overflow-y-auto p-2"},As={key:0,class:"flex items-center justify-center py-8"},qs={key:1,class:"flex flex-col items-center justify-center py-12 text-center"},zs={class:"flex h-12 w-12 items-center justify-center rounded-full bg-gray-50 dark:bg-gray-800"},Rs={class:"mt-3 text-xs text-gray-400"},Ps={key:2,class:"space-y-3"},Es={class:"px-2 pb-1 pt-1.5 text-[10px] font-medium tracking-wide text-gray-400 dark:text-gray-500"},Bs={class:"space-y-0.5"},js=["onClick"],Us=["placeholder","onBlur","onKeyup"],Fs={key:1,class:"flex items-center"},Vs={class:"line-clamp-1 min-w-0 flex-1 text-sm leading-snug"},Ns={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"},Os={class:"w-28 p-1"},Ws=["disabled","onClick"],Hs=["onClick"],Ys=["disabled","onClick"],Ks={key:1,class:"flex flex-1 flex-col items-center gap-1 overflow-y-auto px-2 pb-2"},Qs=["title","disabled"],Gs=["title","onClick"],Js={key:0,class:"absolute -left-2 top-1/2 h-4.5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary-500"},Xs=pe({__name:"ConversationList",props:{sessionId:{},activeId:{},disabled:{type:Boolean}},emits:["select","create","delete"],setup(l,{expose:s,emit:t}){const{t:c}=fe(),r=l,g=t,u=f([]),d=f(!1),m=f(null),v=f(""),y=f(!1),M=f(null);async function $(){d.value=!0;try{u.value=await Fe().getAIChats(r.sessionId)}catch(k){console.error("加载对话列表失败:",k)}finally{d.value=!1}}const D=b(()=>{if(u.value.length===0)return[];const k=Me(),S=k.subtract(7,"day").startOf("day"),P=k.subtract(30,"day").startOf("day"),B=[],A=[],w=new Map;for(const le of u.value){const W=Me(le.updatedAt*1e3);if(W.isAfter(S))B.push(le);else if(W.isAfter(P))A.push(le);else{const ue=W.format("YYYY-MM");w.has(ue)||w.set(ue,[]),w.get(ue).push(le)}}const T=[];B.length>0&&T.push({label:c("ai.chat.conversation.group.last7Days"),conversations:B}),A.length>0&&T.push({label:c("ai.chat.conversation.group.last30Days"),conversations:A});const H=[...w.keys()].sort((le,W)=>W.localeCompare(le));for(const le of H){const W=Me(le+"-01");T.push({label:W.format(W.year()===k.year()?"M月":"YYYY年M月"),conversations:w.get(le)})}return T});function I(k){return k.title||c("ai.chat.conversation.newChat")}function q(k){r.disabled||(m.value=k.id,v.value=k.title||"")}async function _(k){if(!r.disabled){if(v.value.trim())try{await Fe().updateAIChatTitle(k,v.value.trim());const S=u.value.find(P=>P.id===k);S&&(S.title=v.value.trim())}catch(S){console.error("更新标题失败:",S)}m.value=null}}function L(k){M.value=null,q(k)}function x(k){M.value=null,navigator.clipboard.writeText(k)}function C(k){M.value=null,h(k)}async function h(k){if(!r.disabled)try{await Fe().deleteAIChat(k),u.value=u.value.filter(S=>S.id!==k),g("delete",k)}catch(S){console.error("删除对话失败:",S)}}return je(()=>{$()}),ge(()=>r.sessionId,()=>{$()}),s({refresh:$}),(k,S)=>{const P=we,B=ze,A=ra;return n(),i("div",{class:ne(["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",y.value?"w-14":"w-64"])},[e("div",{class:ne(["flex items-center",y.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"])},[y.value?(n(),i("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:S[2]||(S[2]=w=>y.value=!y.value)},[p(P,{name:"i-lucide-panel-right-open",class:"size-4 scale-x-[-1]"})])):(n(),i(Z,{key:0},[e("button",{class:ne(["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":l.disabled}]),disabled:l.disabled,onClick:S[0]||(S[0]=w=>!l.disabled&&g("create"))},[p(P,{name:"i-heroicons-plus",class:"h-3.5 w-3.5"}),e("span",null,o(a(c)("ai.chat.conversation.newConversation")),1)],10,Ls),p(B,{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:S[1]||(S[1]=w=>y.value=!y.value)},{default:j(()=>[p(P,{name:"i-lucide-panel-right",class:"size-4 scale-x-[-1] group-hover:hidden"}),p(P,{name:"i-lucide-panel-right-close",class:"size-4 hidden scale-x-[-1] group-hover:block"})]),_:1})],64))],2),y.value?(n(),i("div",Ks,[e("button",{class:ne(["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":l.disabled}]),title:a(c)("ai.chat.conversation.newConversation"),disabled:l.disabled,onClick:S[7]||(S[7]=w=>!l.disabled&&g("create"))},[p(P,{name:"i-heroicons-plus",class:"h-5 w-5"})],10,Qs),(n(!0),i(Z,null,ce(u.value,w=>(n(),i("button",{key:w.id,class:ne(["relative mx-auto flex h-10 w-10 items-center justify-center rounded-lg transition-all duration-200",[l.activeId===w.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:I(w),onClick:T=>g("select",w.id)},[l.activeId===w.id?(n(),i("span",Js)):R("",!0),p(P,{name:"i-heroicons-chat-bubble-left",class:"h-5 w-5"})],10,Gs))),128))])):(n(),i("div",Ds,[d.value?(n(),i("div",As,[p(P,{name:"i-heroicons-arrow-path",class:"h-5 w-5 animate-spin text-gray-400"})])):u.value.length===0?(n(),i("div",qs,[e("div",zs,[p(P,{name:"i-heroicons-chat-bubble-left",class:"h-6 w-6 text-gray-300 dark:text-gray-600"})]),e("p",Rs,o(a(c)("ai.chat.conversation.empty")),1),p(B,{class:"mt-2",size:"xs",variant:"link",color:"primary",disabled:l.disabled,onClick:S[3]||(S[3]=w=>!l.disabled&&g("create"))},{default:j(()=>[ee(o(a(c)("ai.chat.conversation.startNew")),1)]),_:1},8,["disabled"])])):(n(),i("div",Ps,[(n(!0),i(Z,null,ce(D.value,w=>(n(),i("div",{key:w.label},[e("div",Es,o(w.label),1),e("div",Bs,[(n(!0),i(Z,null,ce(w.conversations,T=>(n(),i("div",{key:T.id,class:ne(["group relative rounded-lg px-3 py-2 transition-all",["cursor-pointer",l.activeId===T.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:H=>g("select",T.id)},[m.value===T.id?Ve((n(),i("input",{key:0,"onUpdate:modelValue":S[4]||(S[4]=H=>v.value=H),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:a(c)("ai.chat.conversation.titlePlaceholder"),autoFocus:"",onBlur:H=>_(T.id),onKeyup:Ge(H=>_(T.id),["enter"]),onClick:S[5]||(S[5]=Be(()=>{},["stop"]))},null,40,Us)),[[ot,v.value]]):(n(),i("div",Fs,[e("p",Vs,o(I(T)),1),e("div",{class:ne(["ml-1 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",{"opacity-100":l.activeId===T.id||M.value===T.id}]),onClick:S[6]||(S[6]=Be(()=>{},["stop"]))},[p(A,{open:M.value===T.id,ui:{content:"z-50 p-0"},"onUpdate:open":H=>M.value=H?T.id:null},{content:j(()=>[e("div",Os,[e("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:l.disabled,onClick:H=>L(T)},[p(P,{name:"i-heroicons-pencil",class:"h-3.5 w-3.5"}),ee(" "+o(a(c)("ai.chat.conversation.rename")),1)],8,Ws),e("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:H=>x(T.id)},[p(P,{name:"i-heroicons-clipboard-document",class:"h-3.5 w-3.5"}),ee(" "+o(a(c)("ai.chat.conversation.copyId")),1)],8,Hs),e("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:l.disabled,onClick:H=>C(T.id)},[p(P,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"}),ee(" "+o(a(c)("ai.chat.conversation.delete")),1)],8,Ys)])]),default:j(()=>[e("button",Ns,[p(P,{name:"i-heroicons-ellipsis-horizontal",class:"h-4 w-4"})])]),_:2},1032,["open","onUpdate:open"])],2)]))],10,js))),128))])]))),128))]))]))],2)}}}),Zs={class:"writing-vertical text-xs"},eo={class:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800"},to={class:"flex items-center gap-2"},ao={class:"font-medium text-gray-900 dark:text-white"},so={key:0,class:"border-b border-gray-200 px-4 py-2 dark:border-gray-800"},oo={class:"flex flex-wrap items-center gap-2"},no={class:"text-xs text-gray-500"},ro={class:"flex-1 overflow-y-auto"},lo={key:0,class:"flex items-center justify-center py-8"},io={key:1,class:"flex flex-col items-center justify-center py-8 text-center"},co={class:"mt-2 text-sm text-gray-500"},uo={class:"text-xs text-gray-400"},mo={key:2,class:"divide-y divide-gray-100 dark:divide-gray-800"},go={class:"mb-1 flex items-center justify-between"},po={class:"text-sm font-medium text-gray-900 dark:text-white"},vo={class:"text-xs text-gray-400"},yo=["innerHTML"],ho={key:1,class:"border-t border-gray-200 px-4 py-2 dark:border-gray-800"},fo={class:"flex items-center justify-between"},xo={class:"text-xs text-gray-500"},bo={key:2,class:"pointer-events-none absolute inset-0 overflow-hidden rounded-xl opacity-[0.03]"},ko=pe({__name:"DataSourcePanel",props:{messages:{},keywords:{},isLoading:{type:Boolean},isCollapsed:{type:Boolean}},emits:["toggle","loadMore"],setup(l,{emit:s}){const{t}=fe(),c=l,r=s;function g(d){return Me(d).format("MM-DD HH:mm")}function u(d){if(!c.keywords.length)return d;const m=c.keywords.join("|"),v=new RegExp(`(${m})`,"gi");return d.replace(v,'<mark class="bg-yellow-200 dark:bg-yellow-800/50 px-0.5 rounded">$1</mark>')}return(d,m)=>{const v=we,y=ze;return n(),i("div",{class:ne(["relative flex flex-col rounded-xl bg-white transition-all duration-300 dark:bg-page-dark",[l.isCollapsed?"w-12":"w-full"]])},[l.isCollapsed?(n(),i("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]=M=>r("toggle"))},[p(v,{name:"i-heroicons-chevron-left",class:"h-5 w-5"}),e("span",Zs,o(a(t)("ai.chat.dataSource.title")),1)])):(n(),i(Z,{key:1},[e("div",eo,[e("div",to,[p(v,{name:"i-heroicons-document-magnifying-glass",class:"h-5 w-5 text-gray-500"}),e("span",ao,o(a(t)("ai.chat.dataSource.title")),1)]),p(y,{icon:"i-heroicons-chevron-right",color:"gray",variant:"ghost",size:"xs",onClick:m[1]||(m[1]=M=>r("toggle"))})]),l.keywords.length>0?(n(),i("div",so,[e("div",oo,[e("span",no,o(a(t)("ai.chat.dataSource.keywords")),1),(n(!0),i(Z,null,ce(l.keywords,M=>(n(),i("span",{key:M,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"},o(M),1))),128))])])):R("",!0),e("div",ro,[l.isLoading?(n(),i("div",lo,[p(v,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):l.messages.length===0?(n(),i("div",io,[p(v,{name:"i-heroicons-inbox",class:"h-10 w-10 text-gray-300 dark:text-gray-600"}),e("p",co,o(a(t)("ai.chat.dataSource.empty")),1),e("p",uo,o(a(t)("ai.chat.dataSource.emptyHint")),1)])):(n(),i("div",mo,[(n(!0),i(Z,null,ce(l.messages,M=>(n(),i("div",{key:M.id,class:"px-4 py-3 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[e("div",go,[e("span",po,o(M.senderName),1),e("span",vo,o(g(M.timestamp)),1)]),e("p",{class:"line-clamp-3 text-sm text-gray-600 dark:text-gray-400",innerHTML:u(M.content)},null,8,yo)]))),128))]))]),l.messages.length>0?(n(),i("div",ho,[e("div",fo,[e("span",xo,o(a(t)("ai.chat.dataSource.totalRecords",{count:l.messages.length})),1),p(y,{size:"xs",variant:"ghost",onClick:m[2]||(m[2]=M=>r("loadMore"))},{default:j(()=>[ee(o(a(t)("ai.chat.dataSource.loadMore")),1)]),_:1})])])):R("",!0)],64)),l.isCollapsed?R("",!0):(n(),i("div",bo,[...m[3]||(m[3]=[e("div",{class:"data-flow-bg absolute inset-0"},null,-1)])]))],2)}}}),_o=lt(ko,[["__scopeId","data-v-a9962add"]]),wo={class:"flex max-h-[80vh] flex-col overflow-hidden"},$o={class:"shrink-0 border-b border-gray-200 px-6 py-4 dark:border-gray-800"},Co={class:"flex items-center justify-between"},So={class:"flex items-center gap-3"},To={class:"flex h-8 w-8 items-center justify-center rounded-lg bg-red-100 dark:bg-red-900/40"},Mo={class:"text-lg font-semibold text-gray-900 dark:text-white"},Io={class:"flex-1 overflow-y-auto px-6 py-4"},Lo={class:"flex flex-col gap-4"},Do={class:"text-sm font-semibold text-gray-700 dark:text-gray-300"},Ao={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"},qo={class:"m-0 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-red-600 dark:text-red-400"},zo={key:1,class:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-page-dark"},Ro={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"},Po={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"},Eo={key:0,class:"py-8 text-center text-sm text-gray-400 dark:text-gray-500"},Bo={class:"shrink-0 border-t border-gray-200 px-6 py-3 dark:border-gray-800"},jo={class:"flex justify-end"},Uo=pe({__name:"ErrorDetailModal",props:Rt({error:{}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:["update:open"],setup(l){const{t:s}=fe(),t=Je(),c=zt(l,"open"),r=l,g=b(()=>{const m=r.error,v=[];return m.url&&v.push({label:s("ai.chat.error.requestUrl"),value:m.url}),m.statusCode!=null&&v.push({label:s("ai.chat.error.statusCode"),value:String(m.statusCode)}),m.responseBody&&v.push({label:s("ai.chat.error.responseBody"),value:u(m.responseBody),isCode:!0}),m.responseHeaders&&v.push({label:s("ai.chat.error.responseHeaders"),value:JSON.stringify(m.responseHeaders,null,2),isCode:!0}),m.name&&v.push({label:s("ai.chat.error.name"),value:m.name}),m.message&&v.push({label:s("ai.chat.error.message"),value:m.message}),m.stack&&v.push({label:s("ai.chat.error.stack"),value:m.stack,isStack:!0}),m.cause&&v.push({label:s("ai.chat.error.cause"),value:u(m.cause),isCode:!0}),m.provider&&v.push({label:s("ai.chat.error.provider"),value:m.provider}),m.requestBody&&v.push({label:s("ai.chat.error.requestBody"),value:u(m.requestBody),isCode:!0}),v});function u(m){try{return JSON.stringify(JSON.parse(m),null,2)}catch{return m}}function d(){const m=g.value.map(v=>`${v.label}: ${v.value}`).join(`
6
+
7
+ `);navigator.clipboard.writeText(m).then(()=>{t.success(s("ai.chat.error.copied"))})}return(m,v)=>{const y=we,M=ze,$=He;return n(),Y($,{open:c.value,"onUpdate:open":v[1]||(v[1]=D=>c.value=D),ui:{content:"sm:max-w-[700px] z-[100]",overlay:"backdrop-blur-sm z-[99]"}},{content:j(()=>[e("div",wo,[e("div",$o,[e("div",Co,[e("div",So,[e("div",To,[p(y,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4 text-red-600 dark:text-red-400"})]),e("h2",Mo,o(a(s)("ai.chat.error.detail")),1)]),p(M,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:v[0]||(v[0]=D=>c.value=!1)})])]),e("div",Io,[e("div",Lo,[(n(!0),i(Z,null,ce(g.value,(D,I)=>(n(),i("div",{key:I,class:"flex flex-col gap-1.5"},[e("div",Do,o(D.label),1),D.isStack?(n(),i("div",Ao,[e("pre",qo,o(D.value),1)])):D.isCode?(n(),i("div",zo,[e("pre",Ro,o(D.value),1)])):(n(),i("div",Po,o(D.value),1))]))),128)),g.value.length===0?(n(),i("div",Eo,o(a(s)("ai.chat.error.unknown")),1)):R("",!0)])]),e("div",Bo,[e("div",jo,[p(M,{icon:"i-heroicons-document-duplicate",variant:"soft",color:"neutral",size:"sm",onClick:d},{default:j(()=>[ee(o(a(s)("ai.chat.error.copyAll")),1)]),_:1})])])])]),_:1},8,["open"])}}}),Fo={class:"mb-1.5 flex items-center gap-2"},Vo={class:"flex shrink-0 items-center justify-center text-red-500 dark:text-red-400"},No={class:"pr-5 text-[13px] font-semibold leading-[1.4] text-red-600 dark:text-red-400"},Oo={class:"ml-6 line-clamp-3 break-words text-xs leading-normal text-gray-600 dark:text-gray-400"},Wo={class:"mt-2.5 ml-6 flex items-center"},Ho={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"},Yo=pe({__name:"ErrorBlock",props:{error:{}},setup(l){const{t:s}=fe(),t=f(!1);function c(r){return r.friendlyMessage||r.message||s("ai.chat.error.unknown")}return(r,g)=>{const u=we;return n(),i(Z,null,[e("div",{class:"group relative my-2 w-full min-w-[320px] cursor-pointer rounded-lg border border-red-200 bg-red-50/60 px-3.5 py-3 text-[13px] transition-all duration-200 hover:border-red-300 hover:bg-red-50 dark:border-red-900/30 dark:bg-red-950/20 dark:hover:border-red-800/50 dark:hover:bg-red-950/30",onClick:g[0]||(g[0]=d=>t.value=!0)},[e("div",Fo,[e("div",Vo,[p(u,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4"})]),e("div",No,o(a(s)("ai.chat.error.title")),1)]),e("div",Oo,o(c(l.error)),1),e("div",Wo,[e("div",Ho,[ee(o(a(s)("ai.chat.error.viewDetail"))+" ",1),p(u,{name:"i-heroicons-chevron-right",class:"h-3.5 w-3.5"})])])]),p(Uo,{open:t.value,"onUpdate:open":g[1]||(g[1]=d=>t.value=d),error:l.error},null,8,["open","error"])],64)}}}),Bt=pe({__name:"EChartHeatmap",props:{data:{},height:{default:280},mode:{default:"expanded"},minColor:{default:"#fee5e8"},maxColor:{default:"#ee4567"}},setup(l){const s=l,t=b(()=>{let r=0;for(const[,,g]of s.data.data)g>r&&(r=g);return r||1}),c=b(()=>{const r=s.mode==="compact",g=s.data.xLabels.length,u=s.data.yLabels.length;return{tooltip:{position:"top",confine:!0,extraCssText:"max-width: min(360px, 70vw); white-space: normal; word-break: break-word;",formatter:d=>{const m=s.data.xLabels[d.data[0]],v=s.data.yLabels[d.data[1]],y=d.data[2];return`${v} ${m}<br/>消息数: <strong>${y}</strong>`},backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:r?52:72,right:20,top:r?12:24,bottom:r?52:70,outerBoundsMode:"same"},xAxis:{type:"category",data:s.data.xLabels,splitArea:{show:!0},axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:r?10:11,color:"#6b7280",interval:r&&g>16?"auto":0,hideOverlap:!0}},yAxis:{type:"category",data:s.data.yLabels,splitArea:{show:!0},axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:r?10:11,color:"#6b7280",interval:r&&u>14?"auto":0,hideOverlap:!0}},visualMap:{min:0,max:t.value,calculable:!0,orient:"horizontal",left:"center",bottom:0,itemWidth:r?8:10,itemHeight:r?84:120,inRange:{color:[s.minColor,s.maxColor]},textStyle:{color:"#6b7280",fontSize:11}},series:[{type:"heatmap",data:s.data.data,label:{show:!1},emphasis:{itemStyle:{shadowBlur:10,shadowColor:"rgba(0, 0, 0, 0.5)"}}}]}});return(r,g)=>(n(),Y($t,{option:c.value,height:l.height},null,8,["option","height"]))}}),jt=pe({__name:"EChartLine",props:{data:{},height:{default:288},mode:{default:"expanded"},showArea:{type:Boolean,default:!0},smooth:{type:Boolean,default:!0}},setup(l){const s=l,t=b(()=>{const c=!!s.data.series?.length,r=s.mode==="compact",g=s.data.series?.length??0,u=s.data.labels.length,d=g>(r?3:8),m=!r&&u>30,v=c?s.data.series.map(y=>({name:y.name,type:"line",data:y.values,smooth:s.smooth,symbol:"circle",symbolSize:4,showSymbol:!r&&u<=80,lineStyle:{width:2},areaStyle:s.showArea?{opacity:.08}:void 0,emphasis:{focus:"series"}})):[{type:"line",data:s.data.values,smooth:s.smooth,symbol:"circle",symbolSize:4,showSymbol:!r&&u<=80,lineStyle:{width:2,color:"#ee4567"},itemStyle:{color:"#ee4567"},areaStyle:s.showArea?{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(238, 69, 103, 0.3)"},{offset:1,color:"rgba(238, 69, 103, 0.05)"}]}}:void 0,emphasis:{focus:"series",itemStyle:{color:"#ee4567",borderColor:"#fff",borderWidth:2}}}];return{tooltip:{trigger:"axis",confine:!0,extraCssText:"max-width: min(420px, 76vw); white-space: normal; word-break: break-word;",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:50,right:20,top:c?r?44:56:20,bottom:m?66:34,outerBoundsMode:"same"},legend:c?{type:d?"scroll":"plain",top:0,left:8,right:8,height:32,textStyle:{color:"#6b7280",fontSize:11}}:void 0,xAxis:{type:"category",data:s.data.labels,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:11,color:"#6b7280",interval:"auto",hideOverlap:!0}},yAxis:{type:"value",axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{type:"dashed",color:"#e5e7eb"}}},dataZoom:m?[{type:"inside",throttle:50},{type:"slider",height:18,bottom:18,showDetail:!1}]:void 0,series:v}});return(c,r)=>(n(),Y($t,{option:t.value,height:l.height},null,8,["option","height"]))}}),Ut=pe({__name:"EChartPie",props:{data:{},height:{default:280},mode:{default:"expanded"},doughnut:{type:Boolean,default:!0},innerRadius:{default:"50%"},showLegend:{type:Boolean,default:!0}},setup(l){const s=l,t=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"],c=b(()=>{const r=s.data.labels.map(($,D)=>({name:$,value:s.data.values[D]})),g=s.data.labels.length,u=s.mode==="compact",d=g>(u?8:14),m=g>(u?6:12),v=u?{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}},y=!u&&!d,M=s.showLegend&&!y;return{color:t,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:M?v:void 0,series:[{type:"pie",radius:s.doughnut?[s.innerRadius,u?"58%":"68%"]:u?"58%":"68%",center:M?u?["50%","42%"]:["38%","50%"]:["50%",u?"46%":"50%"],avoidLabelOverlap:!0,itemStyle:{borderRadius:4,borderColor:"#fff",borderWidth:2},label:{show:y,formatter:"{b}",overflow:"truncate",width:110,alignTo:"edge",edgeDistance:12},emphasis:{label:{show:y,fontSize:14,fontWeight:"bold",overflow:"truncate",width:140},itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}},data:r}]}});return(r,g)=>(n(),Y($t,{option:c.value,height:l.height},null,8,["option","height"]))}}),Ko={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"},Qo={class:"border-b border-gray-100 px-3 py-2 dark:border-gray-800"},Go={class:"flex min-w-0 items-start justify-between gap-3"},Jo={class:"min-w-0"},Xo={class:"truncate text-sm font-semibold text-gray-900 dark:text-gray-100"},Zo={key:0,class:"mt-0.5 line-clamp-2 text-xs text-gray-500 dark:text-gray-400"},en={class:"flex shrink-0 items-center gap-1.5"},tn={class:"rounded-md bg-gray-100 px-1.5 py-0.5 text-[10px] uppercase text-gray-500 dark:bg-gray-800"},an={class:"flex max-h-[92vh] flex-col overflow-hidden bg-white dark:bg-page-dark"},sn={class:"flex items-start justify-between gap-4 border-b border-gray-200 px-5 py-4 dark:border-gray-800"},on={class:"min-w-0"},nn={class:"truncate text-base font-semibold text-gray-900 dark:text-gray-100"},rn={key:0,class:"mt-1 line-clamp-2 text-xs text-gray-500 dark:text-gray-400"},ln={class:"mt-1 text-[11px] text-gray-400 dark:text-gray-500"},cn={class:"min-h-0 flex-1 overflow-auto p-4"},dn={key:0,class:"flex h-64 items-center justify-center text-xs text-gray-400 dark:text-gray-500"},un={class:"mt-1 text-[11px] text-gray-400 dark:text-gray-500"},mn={class:"px-2 py-3"},gn={key:0,class:"flex h-32 items-center justify-center text-xs text-gray-400 dark:text-gray-500"},pn=pe({__name:"ChartBlockRenderer",props:{chart:{}},setup(l){const{t:s}=fe(),t=l,c=f(!1),r=b(()=>t.chart.spec.title),g=b(()=>t.chart.spec.subtitle||t.chart.spec.description||""),u=b(()=>t.chart.spec.display?.height??(t.chart.spec.type==="heatmap"?300:260)),d=b(()=>t.chart.rowCount===0),m=b(()=>{const L=[];return t.chart.spec.unit&&L.push(t.chart.spec.unit),t.chart.truncated&&L.push(s("ai.chat.message.chart.truncated")),L.push(s("ai.chat.message.chart.rows",{count:t.chart.rowCount})),L.join(" · ")}),v=b(()=>t.chart.data),y=b(()=>t.chart.data),M=b(()=>t.chart.data),$=b(()=>t.chart.data),D=b(()=>t.chart.spec.type==="pie"?M.value.labels.length>8:t.chart.spec.type==="line"?y.value.labels.length>28||(y.value.series?.length??0)>4:t.chart.spec.type==="bar"?v.value.labels.length>12:t.chart.spec.type==="heatmap"?$.value.xLabels.length*$.value.yLabels.length>180:!1),I=b(()=>{const L=D.value?320:380;return Math.min(u.value,L)}),q=b(()=>{const L=u.value;if(t.chart.spec.type==="pie")return Math.max(L,560);if(t.chart.spec.type==="line")return Math.max(L,y.value.labels.length>40?620:540);if(t.chart.spec.type==="bar"){const x=t.chart.spec.display?.horizontal?v.value.labels.length*28+120:520;return Math.min(Math.max(L,x),820)}return t.chart.spec.type==="heatmap"?Math.min(Math.max(L,$.value.yLabels.length*22+150,560),860):Math.max(L,520)}),_=b(()=>t.chart.spec.type==="pie"?"640px":t.chart.spec.type==="bar"?"720px":"780px");return(L,x)=>{const C=ze,h=He;return n(),i("div",Ko,[e("div",Qo,[e("div",Go,[e("div",Jo,[e("h3",Xo,o(r.value),1),g.value?(n(),i("p",Zo,o(g.value),1)):R("",!0)]),e("div",en,[e("span",tn,o(l.chart.spec.type),1),p(h,{open:c.value,"onUpdate:open":x[2]||(x[2]=k=>c.value=k),ui:{overlay:"z-[10040] backdrop-blur-sm",content:"z-[10050] w-[96vw] max-w-6xl max-h-[92vh] overflow-hidden"}},{content:j(()=>[e("div",an,[e("div",sn,[e("div",on,[e("h3",nn,o(r.value),1),g.value?(n(),i("p",rn,o(g.value),1)):R("",!0),e("p",ln,o(m.value),1)]),p(C,{icon:"i-heroicons-x-mark",size:"sm",color:"neutral",variant:"ghost",class:"shrink-0",title:a(s)("common.close"),"aria-label":a(s)("common.close"),onClick:x[1]||(x[1]=k=>c.value=!1)},null,8,["title","aria-label"])]),e("div",cn,[e("div",{class:"mx-auto w-full",style:Qe({minWidth:_.value})},[d.value?(n(),i("div",dn,o(a(s)("ai.chat.message.chart.empty")),1)):l.chart.spec.type==="bar"?(n(),Y(Ze,{key:1,data:v.value,height:q.value,mode:"expanded",horizontal:l.chart.spec.display?.horizontal},null,8,["data","height","horizontal"])):l.chart.spec.type==="line"?(n(),Y(jt,{key:2,data:y.value,height:q.value,mode:"expanded"},null,8,["data","height"])):l.chart.spec.type==="pie"?(n(),Y(Ut,{key:3,data:M.value,height:q.value,mode:"expanded","show-legend":l.chart.spec.display?.showLegend??!0},null,8,["data","height","show-legend"])):l.chart.spec.type==="heatmap"?(n(),Y(Bt,{key:4,data:$.value,height:q.value,mode:"expanded"},null,8,["data","height"])):R("",!0)],4)])])]),default:j(()=>[p(C,{icon:"i-heroicons-arrows-pointing-out",size:"xs",color:"neutral",variant:"ghost",class:"no-capture",title:a(s)("ai.chat.message.chart.expand"),"aria-label":a(s)("ai.chat.message.chart.expand"),onClick:x[0]||(x[0]=Be(()=>{},["stop"]))},null,8,["title","aria-label"])]),_:1},8,["open"])])]),e("p",un,o(m.value),1)]),e("div",mn,[d.value?(n(),i("div",gn,o(a(s)("ai.chat.message.chart.empty")),1)):l.chart.spec.type==="bar"?(n(),Y(Ze,{key:1,data:v.value,height:I.value,mode:"compact",horizontal:l.chart.spec.display?.horizontal},null,8,["data","height","horizontal"])):l.chart.spec.type==="line"?(n(),Y(jt,{key:2,data:y.value,height:I.value,mode:"compact"},null,8,["data","height"])):l.chart.spec.type==="pie"?(n(),Y(Ut,{key:3,data:M.value,height:I.value,mode:"compact","show-legend":l.chart.spec.display?.showLegend??!0},null,8,["data","height","show-legend"])):l.chart.spec.type==="heatmap"?(n(),Y(Bt,{key:4,data:$.value,height:I.value,mode:"compact"},null,8,["data","height"])):R("",!0)])])}}}),vn={class:"my-1.5 w-full overflow-hidden rounded-lg border border-gray-200 bg-gray-50/60 text-[13px] dark:border-gray-700/60 dark:bg-gray-800/30"},yn={class:"text-xs font-semibold text-gray-700 dark:text-gray-200"},hn={key:0,class:"flex min-w-0 items-center gap-2"},fn={key:0,class:"truncate text-[11px] text-gray-400 dark:text-gray-500"},xn={class:"ml-auto flex shrink-0 items-center gap-1.5"},bn={class:"text-[11px] text-gray-400 dark:text-gray-500"},kn={key:0,class:"border-t border-gray-200/70 px-3 py-2 dark:border-gray-700/50"},_n={class:"mb-2 space-y-0.5 text-xs text-gray-600 dark:text-gray-400"},wn={class:"font-medium"},$n={key:0},Cn={class:"font-medium"},Sn={key:0,class:"mb-2 space-y-1"},Tn={key:1,class:"py-1.5 text-center text-xs text-gray-400 dark:text-gray-500"},Mn={key:2,class:"space-y-2"},In={class:"flex items-center gap-2"},Ln={class:"ml-auto shrink-0 text-[11px] text-gray-400 dark:text-gray-500"},Dn={key:0,class:"mt-1 text-[11px] text-gray-500 dark:text-gray-400"},An={class:"mt-1 space-y-0.5"},qn=["onClick"],zn={class:"min-w-0 flex-1 text-xs leading-snug text-gray-600 dark:text-gray-300"},Rn={key:0,class:"mr-1 text-gray-400 dark:text-gray-500"},Pn={class:"line-clamp-2 break-words align-middle"},En={key:3,class:"mt-1.5 text-right text-[11px] text-gray-400 dark:text-gray-500"},Bn=pe({__name:"EvidenceBlock",props:{evidence:{}},setup(l){const s=l,{t}=fe(),c=ct(),r=f(!1),g=["included","uncertain","excluded"],u=b(()=>[...s.evidence.groups].sort((D,I)=>g.indexOf(D.status)-g.indexOf(I.status))),d=b(()=>s.evidence.groups.reduce((D,I)=>D+I.sources.length,0)),m=b(()=>g.map(D=>({status:D,count:s.evidence.groups.filter(I=>I.status===D).length})).filter(D=>D.count>0)),v=b(()=>s.evidence.warnings??[]),y={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"},M={included:"bg-emerald-500",uncertain:"bg-amber-500",excluded:"bg-gray-400"};function $(D){c.openChatRecordDrawer({scrollToMessageId:D})}return(D,I)=>{const q=we;return n(),i("div",vn,[e("button",{type:"button",class:"flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-gray-100/60 dark:hover:bg-gray-800/40",onClick:I[0]||(I[0]=_=>r.value=!r.value)},[p(q,{name:"i-heroicons-document-magnifying-glass",class:"h-4 w-4 shrink-0 text-primary-500"}),e("span",yn,o(a(t)("ai.chat.evidence.title")),1),r.value?R("",!0):(n(),i("div",hn,[(n(!0),i(Z,null,ce(m.value,_=>(n(),i("span",{key:_.status,class:"flex shrink-0 items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400"},[e("span",{class:ne(["h-1.5 w-1.5 rounded-full",M[_.status]])},null,2),ee(" "+o(a(t)(`ai.chat.evidence.group.${_.status}`))+" "+o(_.count),1)]))),128)),m.value.length===0?(n(),i("span",fn,o(a(t)("ai.chat.evidence.empty")),1)):R("",!0)])),e("span",xn,[e("span",bn,o(a(t)(`ai.chat.evidence.mode.${l.evidence.mode}`)),1),p(q,{name:r.value?"i-heroicons-chevron-up":"i-heroicons-chevron-down",class:"h-3.5 w-3.5 text-gray-400 dark:text-gray-500"},null,8,["name"])])]),r.value?(n(),i("div",kn,[e("div",_n,[e("div",null,[e("span",wn,o(a(t)("ai.chat.evidence.query"))+":",1),ee(" "+o(l.evidence.query),1)]),l.evidence.criteria?(n(),i("div",$n,[e("span",Cn,o(a(t)("ai.chat.evidence.criteria"))+":",1),ee(" "+o(l.evidence.criteria),1)])):R("",!0)]),v.value.length>0?(n(),i("div",Sn,[(n(!0),i(Z,null,ce(v.value,_=>(n(),i("div",{key:_,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"},[p(q,{name:"i-heroicons-exclamation-triangle",class:"mt-0.5 h-3 w-3 shrink-0"}),e("span",null,o(a(t)(`ai.chat.evidence.warning.${_}`)),1)]))),128))])):R("",!0),u.value.length===0?(n(),i("div",Tn,o(a(t)("ai.chat.evidence.empty")),1)):(n(),i("div",Mn,[(n(!0),i(Z,null,ce(u.value,_=>(n(),i("div",{key:_.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"},[e("div",In,[e("span",{class:ne(["rounded px-1.5 py-0.5 text-[11px] font-medium",y[_.status]])},o(a(t)(`ai.chat.evidence.group.${_.status}`)),3),e("span",Ln,o(_.title),1)]),_.reason?(n(),i("div",Dn,o(_.reason),1)):R("",!0),e("ul",An,[(n(!0),i(Z,null,ce(_.sources,(L,x)=>(n(),i("li",{key:`${_.id}-${x}`,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:C=>$(L.messageId)},[e("div",zn,[L.senderName?(n(),i("span",Rn,o(L.senderName)+": ",1)):R("",!0),e("span",Pn,o(L.snippet),1)]),p(q,{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,qn))),128))])]))),128))])),u.value.length>0?(n(),i("div",En,o(a(t)("ai.chat.evidence.totalSources",{count:d.value})),1)):R("",!0)])):R("",!0)])}}}),jn=/^\s*!\[[^\]\n]*\]\(\s*(?:(?:https?:\/\/(?:localhost|127\.0\.0\.1)(?::\d+)?)?\/?|\.\/)?chart[\w-]*(?:\.(?:png|jpg|jpeg|webp|svg))?(?:\?[^)\s]*)?\s*(?:"[^"]*")?\s*\)\s*$/gim;function Un(l){return l&&l.replace(jn,"").replace(/\n{3,}/g,`
8
+
9
+ `).replace(/^\n+|\n+$/g,"")}function Fn(l,s,t){for(let c=s+1;c<l.length;c+=1)if(t(l[c]))return!0;return!1}function Vn(l,s){const t=[];return l.forEach((c,r)=>{if(!(s.isFoldableProcessBlock(c)||s.isTextBlock(c)&&Fn(l,r,s.isFoldableProcessBlock))){t.push({type:"visible",block:c});return}const u=t[t.length-1];u?.type==="process"?u.blocks.push(c):t.push({type:"process",blocks:[c]})}),t}function Nn(l){return l.flatMap(s=>s.type==="visible"?[s.block]:[])}function On(l,s){const t=Math.max(0,Math.round(l/1e3));if(s.startsWith("zh")||s.startsWith("ja")){if(t<60)return`${t}秒`;if(t<3600){const v=Math.floor(t/60),y=t%60;return`${v}分${y.toString().padStart(2,"0")}秒`}const u=Math.floor(t/3600),d=Math.floor(t%3600/60),m=t%60;return`${u}时${d.toString().padStart(2,"0")}分${m.toString().padStart(2,"0")}秒`}if(t<60)return`${t}s`;if(t<3600){const u=Math.floor(t/60),d=t%60;return`${u}m ${d.toString().padStart(2,"0")}s`}const c=Math.floor(t/3600),r=Math.floor(t%3600/60),g=t%60;return`${c}h ${r.toString().padStart(2,"0")}m ${g.toString().padStart(2,"0")}s`}function Wn(l,s){return l.type!=="process"?0:l.blocks.reduce((t,c)=>t+(s(c)??0),0)}function Hn(l,s){if(s.isProcessing)return s.labels.processing;const t=Wn(l,s.getBlockDurationMs),c=t>0?` ${On(t,s.locale)}`:"";return`${s.labels.processed}${c}`}const Yn={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"},Kn={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"},Qn={class:"border-t border-gray-200/60 px-3 py-2.5 dark:border-gray-700/40"},Gn=["innerHTML"],Jn={class:"mt-2 text-[11px] text-gray-400 dark:text-gray-500"},Xn={key:0,class:"rounded-2xl bg-primary-50 p-4 text-gray-900 dark:bg-primary-500/50 dark:text-gray-100"},Zn=["onKeydown"],er={class:"mt-2 flex items-center justify-between"},tr={class:"flex cursor-pointer items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400"},ar={class:"flex gap-2"},sr={key:1,class:"rounded-3xl bg-primary-50 px-5 py-3 text-gray-900 dark:bg-primary-500/50 dark:text-gray-100"},or=["innerHTML"],nr={key:2,class:"space-y-2"},rr=["aria-expanded","onClick"],lr={class:"truncate"},ir={key:0,class:"py-1 text-gray-900 dark:text-gray-100"},cr=["innerHTML"],dr={key:0,class:"ml-1 inline-block h-4 w-1.5 animate-pulse rounded-sm bg-gray-800 dark:bg-gray-200"},ur={key:1,class:"mb-2 border-l-2 border-gray-200 pl-4 py-1 text-sm text-gray-500 dark:border-gray-700 dark:text-gray-400"},mr={class:"cursor-pointer select-none text-xs font-medium transition-colors hover:text-gray-700 dark:hover:text-gray-300"},gr={key:0,class:"ml-2 text-xs text-gray-400 dark:text-gray-500"},pr={key:1,class:"ml-2 inline-flex items-center gap-1 text-[11px] text-gray-400 dark:text-gray-500"},vr={class:"mt-2 prose prose-sm dark:prose-invert max-w-none leading-relaxed text-xs"},yr={key:0,class:"mb-2 font-medium text-gray-700 dark:text-gray-200"},hr={class:"not-prose space-y-2 text-xs leading-relaxed"},fr={class:"font-medium text-gray-800 dark:text-gray-200"},xr={key:0,class:"mt-1 text-gray-500 dark:text-gray-400"},br={class:"mt-0.5 text-gray-500 dark:text-gray-400"},kr={key:1,class:"not-prose mt-2 border-t border-gray-100 pt-2 dark:border-gray-800"},_r={class:"text-[11px] font-medium text-gray-500 dark:text-gray-400"},wr={class:"mt-1 list-disc space-y-0.5 pl-4 text-xs leading-relaxed text-gray-600 dark:text-gray-300"},$r=["innerHTML"],Cr={key:2,class:"inline-flex items-center gap-1.5 rounded-lg bg-gray-50 px-3 py-1.5 text-xs font-medium text-gray-600 dark:bg-gray-800/50 dark:text-gray-400"},Sr={key:3,open:"",class:"mb-2 border-l-2 border-gray-200 py-1 pl-4 text-sm text-gray-600 dark:border-gray-700 dark:text-gray-400"},Tr={class:"flex cursor-pointer select-none items-center gap-2 text-xs font-medium text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"},Mr={class:"min-w-0 truncate"},Ir={class:"mt-2"},Lr=["innerHTML"],Dr={key:1,class:"space-y-2"},Ar={class:"font-medium text-gray-800 dark:text-gray-200"},qr={class:"mt-1 text-gray-500 dark:text-gray-400"},zr={class:"mt-0.5 text-gray-500 dark:text-gray-400"},Rr={key:2,class:"mt-2 border-t border-gray-100 pt-2 dark:border-gray-800"},Pr={class:"text-[11px] font-medium text-gray-500 dark:text-gray-400"},Er={class:"mt-1 list-disc space-y-0.5 pl-4 text-xs leading-relaxed text-gray-600 dark:text-gray-300"},Br={key:4,class:"mb-2 border-l-2 border-gray-200 py-1 pl-4 text-sm text-gray-600 dark:border-gray-700 dark:text-gray-400"},jr={class:"flex items-center gap-2 text-xs font-medium text-gray-500 dark:text-gray-400"},Ur={key:0,class:"inline-flex items-center gap-1 text-[11px] font-normal text-gray-400 dark:text-gray-500"},Fr=["innerHTML"],Vr={key:7,class:"w-full max-w-full"},Nr={class:"inline-flex cursor-pointer list-none select-none [&::-webkit-details-marker]:hidden"},Or={class:"flex min-w-0 items-baseline gap-1.5 font-medium"},Wr={key:0,class:"max-w-[200px] truncate text-[11px] font-normal opacity-75 sm:max-w-[300px]"},Hr={class:"shrink-0 text-[11px] font-normal opacity-75"},Yr={class:"mt-2 max-w-full rounded-lg border border-gray-200 bg-gray-50/80 dark:border-gray-700/70 dark:bg-page-dark/40"},Kr={class:"flex items-center justify-between gap-2 border-b border-gray-200/70 px-3 py-2 dark:border-gray-700/70"},Qr={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Gr={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"},Jr={class:"max-h-[28rem] overflow-auto whitespace-pre-wrap break-words px-3 py-2.5 text-xs leading-relaxed text-gray-700 dark:text-gray-200"},Xr={class:"flex min-w-0 items-baseline gap-1.5 font-medium"},Zr={key:0,class:"max-w-[200px] truncate text-[11px] font-normal opacity-75 sm:max-w-[300px]"},el={key:1,class:"shrink-0 text-[11px] font-normal opacity-75"},tl={key:0,class:"flex items-center gap-2 px-1 py-2 text-sm text-gray-500 dark:text-gray-400"},al={key:3,class:"py-1 text-gray-900 dark:text-gray-100"},sl=["innerHTML"],ol={key:0,class:"ml-1 inline-block h-4 w-1.5 animate-pulse rounded-sm bg-gray-800 dark:bg-gray-200"},nl={class:"text-xs text-gray-400"},Dt=pe({__name:"ChatMessage",props:{messageId:{},role:{},content:{},timestamp:{},isStreaming:{type:Boolean},contentBlocks:{},showCaptureButton:{type:Boolean},editable:{type:Boolean}},emits:["edit","fork"],setup(l,{emit:s}){const{t,te:c,locale:r}=fe(),g=Je(),u=l,d=s,m=b(()=>Me(u.timestamp).format("HH:mm")),v=b(()=>u.role==="user"),y=b(()=>u.role==="summary"),M=f(!1),$=f(u.content),D=f(null),I=b(()=>v.value&&u.editable&&!u.isStreaming&&!!u.messageId),q=b(()=>!v.value&&!y.value&&!u.isStreaming&&!!u.messageId),_=f(!1),L=new Kt({html:!1,breaks:!0,linkify:!0,typographer:!0});L.renderer.rules.link_open=(z,O,J,N,U)=>(z[O].attrSet("target","_blank"),z[O].attrSet("rel","noopener noreferrer"),U.renderToken(z,O,J));function x(z){return z?L.render(z):""}function C(z){const O=z?.toLowerCase()||"think";return O==="analysis"?t("ai.chat.message.think.labels.analysis"):O==="reasoning"?t("ai.chat.message.think.labels.reasoning"):O==="reflection"?t("ai.chat.message.think.labels.reflection"):O==="plan_validation"?t("ai.chat.message.think.labels.planValidation"):O==="think"||O==="thought"||O==="thinking"?t("ai.chat.message.think.labels.think"):t("ai.chat.message.think.labels.other",{tag:z})}function h(z){if(!z)return"";const O=(z/1e3).toFixed(1);return t("ai.chat.message.think.duration",{seconds:O})}const k=b(()=>u.content?L.render(w(u.content)):"");ge(()=>u.content,z=>{M.value||($.value=z)});function S(){const z=D.value;if(!z)return;z.style.height="auto";const O=384,J=Math.min(z.scrollHeight,O);z.style.height=`${J}px`,z.style.overflowY=z.scrollHeight>O?"auto":"hidden"}async function P(){I.value&&($.value=u.content,M.value=!0,await Ue(),S(),D.value?.focus())}function B(){M.value=!1,$.value=u.content,_.value=!1}function A(){if(!u.messageId)return;const z=$.value.trim();if(!z||z===u.content.trim()){B();return}M.value=!1,d("edit",{messageId:u.messageId,content:z,overwriteSubsequent:_.value}),_.value=!1}function w(z){return Un(z)}const T=b(()=>{const z=u.contentBlocks||[];return z.filter((O,J)=>O.type==="text"?w(O.text).trim().length>0:O.type==="think"?O.text.trim().length>0:O.type==="error"?!Da(z,J,{isStreaming:u.isStreaming}):!0)});function H(z){return z.type==="think"||z.type==="tool"||z.type==="plan"||z.type==="plan_draft"}function le(z){return z.type==="text"}const W=b(()=>Vn(T.value,{isFoldableProcessBlock:H,isTextBlock:le})),ue=b(()=>Nn(W.value)),ve=f({});function G(z){return z.type==="process"?z.blocks:[z.block]}function F(z){return`${u.messageId??u.timestamp}:process:${z}`}function X(z){const O=F(z),J=ve.value[O];return J!==void 0?J:K(z)}function me(z){const O=F(z);ve.value={...ve.value,[O]:!X(z)}}function ye(z){return T.value[T.value.length-1]===z}function K(z){return!!u.isStreaming&&z===W.value.length-1}function E(z){return z.type==="think"?z.durationMs??0:z.type==="tool"?z.tool.durationMs??0:0}function V(z,O){return Hn(z,{getBlockDurationMs:E,isProcessing:K(O),labels:{processed:t("ai.chat.message.process.processed"),processing:t("ai.chat.message.process.processing")},locale:r.value})}const oe=b(()=>u.role==="assistant"&&T.value.length>0);function he(z){return c(`ai.assistant.builtinToolDesc.${z.name}`)?t(`ai.assistant.builtinToolDesc.${z.name}`):z.displayName}function ke(z){return z==="running"?"running":z==="done"?"done":"error"}function be(z){return z.displayResult??z.result??""}function ae(z){return z.status!=="running"&&be(z).trim().length>0}function se(z){return!z.displayResult&&(z.result??"").includes("…[truncated]")}async function xe(z){const O=be(z);if(O.trim())try{await navigator.clipboard.writeText(O),g.success(t("ai.chat.message.toolResult.copySuccess"))}catch(J){g.fail(t("ai.chat.message.toolResult.copyFailed"),{description:String(J)})}}function de(z){return z.length===0?t("ai.chat.message.plan.noTools"):z.join(", ")}function _e(z){try{const O=JSON.parse(z.trim());if(!O||typeof O!="object")return null;const J=O,N=Array.isArray(J.steps)?J.steps.filter(U=>!!U&&typeof U=="object").map(U=>({goal:typeof U.goal=="string"?U.goal:"",suggestedTools:Array.isArray(U.suggestedTools)?U.suggestedTools.filter(re=>typeof re=="string"):[],evidenceNeeded:typeof U.evidenceNeeded=="string"?U.evidenceNeeded:""})).filter(U=>U.goal):[];return{title:typeof J.title=="string"?J.title:void 0,steps:N,successCriteria:Array.isArray(J.successCriteria)?J.successCriteria.filter(U=>typeof U=="string"):[]}}catch{return null}}const Ie=new Map;function Le(z){const O=Ie.get(z);if(O)return O;const J=_e(z);return J&&Ie.set(z,J),J}function Se(z){if(z.start_time||z.end_time){const O=z.start_time?String(z.start_time):"",J=z.end_time?String(z.end_time):"";return O&&J?`${O} ~ ${J}`:O||J}if(z.year)if(r.value.startsWith("zh")){let O=`${z.year}年`;return z.month&&(O+=`${z.month}月`,z.day&&(O+=`${z.day}日`,z.hour!==void 0&&(O+=` ${z.hour}点`))),O}else{const O=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];let J="";if(z.month){if(J=O[z.month-1]||String(z.month),z.day&&(J+=` ${z.day}`,z.hour!==void 0)){const N=z.hour,U=N>=12?"pm":"am",re=N%12||12;J+=`, ${re}${U}`}J+=`, ${z.year}`}else J=String(z.year);return J}return""}function qe(z){if(!z.params)return"";const O=z.name,J=z.params;if(O==="search_messages"){const U=J.keywords,re=[];U&&U.length>0&&re.push(`${t("ai.chat.message.toolParams.keywords")}: ${U.join(", ")}`);const Q=Se(J);return Q&&re.push(`${t("ai.chat.message.toolParams.time")}: ${Q}`),re.join(" | ")}if(O==="get_recent_messages"){const U=[];U.push(t("ai.chat.message.toolParams.getMessages",{count:J.limit||100}));const re=Se(J);return re&&U.push(re),U.join(" | ")}if(O==="get_conversation_between"){const U=[],re=Se(J);return re&&U.push(`${t("ai.chat.message.toolParams.time")}: ${re}`),J.limit&&U.push(t("ai.chat.message.toolParams.limit",{count:J.limit})),U.join(" | ")}if(O==="get_message_context"){const U=J.message_ids,re=J.context_size||20;return U&&U.length>0?t("ai.chat.message.toolParams.contextWithMessages",{msgCount:U.length,contextSize:re}):t("ai.chat.message.toolParams.context",{size:re})}if(O==="get_member_stats")return t("ai.chat.message.toolParams.topMembers",{count:J.top_n||10});if(O==="get_time_stats"){const U=J.type;return t(`ai.chat.message.toolParams.timeStats.${U}`)||String(J.type)}if(O==="render_chart"){const U=J.spec&&typeof J.spec=="object"?J.spec:null;return[U?.title,U?.type].filter(Q=>typeof Q=="string"&&Q.length>0).join(" | ")}if(O==="get_members")return J.search?`${t("ai.chat.message.toolParams.search")}: ${J.search}`:t("ai.chat.message.toolParams.getMemberList");if(O==="get_member_name_history")return`${t("ai.chat.message.toolParams.memberId")}: ${J.member_id}`;if(O==="semantic_search_current_chat"){const U=typeof J.query=="string"?J.query:"";return U?U.length>40?`“${U.slice(0,40)}…”`:`“${U}”`:""}const N=[];for(const[U,re]of Object.entries(J)){if(re==null||re==="")continue;const Q=typeof re=="object"?JSON.stringify(re):String(re),te=Q.length>30?Q.substring(0,30)+"...":Q;if(N.push(`${U}: ${te}`),N.length>=3){N.push("...");break}}return N.join(" | ")}const Re=b(()=>!oe.value&&u.content.trim()?w(u.content):oe.value?ue.value.map(O=>{if(O.type==="text")return w(O.text);if(O.type==="think"){const J=C(O.tag),N=O.text.split(`
10
+ `).map(U=>`> ${U}`).join(`
11
+ `);return`> ${J}
12
+ >
13
+ ${N}`}if(O.type==="skill")return`> ${t("ai.skill.active.label",{name:O.skillName})}`;if(O.type==="chart")return`> Chart: ${O.chart.spec.title}`;if(O.type==="evidence"){const J=`> ${t("ai.chat.evidence.title")}`,N=O.evidence.groups.map(U=>{const re=t(`ai.chat.evidence.group.${U.status}`),Q=U.sources.map(te=>`> - ${te.snippet}`).join(`
14
+ `);return`> [${re}] ${U.title}
15
+ ${Q}`});return[J,...N].join(`
16
+ `)}if(O.type==="plan"){const J=O.plan.steps.map((re,Q)=>`${Q+1}. ${re.goal}
17
+ - ${t("ai.chat.message.plan.evidenceNeeded")}: ${re.evidenceNeeded}
18
+ - ${t("ai.chat.message.plan.suggestedTools")}: ${de(re.suggestedTools)}`).join(`
19
+ `),N=O.plan.successCriteria.map(re=>`- ${re}`).join(`
20
+ `),U=O.displayText?`${O.displayText.split(`
21
+ `).map(re=>`> ${re}`).join(`
22
+ `)}
23
+
24
+ `:"";return O.displayText?`> ${t("ai.chat.message.plan.label")}: ${O.plan.title}
25
+
26
+ ${U.trimEnd()}`:`> ${t("ai.chat.message.plan.label")}: ${O.plan.title}
27
+
28
+ ${J}
29
+
30
+ ${t("ai.chat.message.plan.successCriteria")}:
31
+ ${N}`}if(O.type==="plan_draft")return`> ${t("ai.chat.message.plan.label")}
32
+ >
33
+ ${O.text.split(`
34
+ `).map(J=>`> ${J}`).join(`
35
+ `)}`;if(O.type==="tool"){const J=he(O.tool),N=qe(O.tool),U=N?` (${N})`:"";return`- [${ke(O.tool.status)}] ${J}${U}`}return""}).filter(O=>O.trim().length>0).join(`
36
+
37
+ `):""),Ee=b(()=>!u.isStreaming&&Re.value.trim().length>0);async function ie(){if(Ee.value)try{await navigator.clipboard.writeText(Re.value),g.success(t("ai.chat.message.copy.success"))}catch(z){g.fail(t("ai.chat.message.copy.failed"),{description:String(z)})}}return(z,O)=>{const J=we,N=ze,U=pt;return n(),i("div",{class:ne(["flex items-start gap-3",[v.value&&!M.value?"flex-row-reverse":"",y.value?"justify-center":""]])},[e("div",{class:ne([v.value&&!M.value?"max-w-[85%] min-w-0":"w-full min-w-0"])},[y.value?(n(),i("details",Yn,[e("summary",Kn,[p(J,{name:"i-heroicons-arrow-path",class:"h-3.5 w-3.5 shrink-0"}),e("span",null,o(a(t)("ai.chat.message.summary.label")),1),p(J,{name:"i-heroicons-chevron-right",class:"ml-auto h-3 w-3 transition-transform [[open]>&]:rotate-90"})]),e("div",Qn,[e("div",{class:"prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:k.value},null,8,Gn),e("p",Jn,o(a(t)("ai.chat.message.summary.info")),1)])])):v.value?(n(),i(Z,{key:1},[M.value?(n(),i("div",Xn,[Ve(e("textarea",{ref_key:"editTextareaRef",ref:D,"onUpdate:modelValue":O[0]||(O[0]=re=>$.value=re),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:S,onKeydown:[Ge(Be(B,["prevent"]),["esc"]),Ge(Be(A,["ctrl","prevent"]),["enter"]),Ge(Be(A,["meta","prevent"]),["enter"])]},null,40,Zn),[[ot,$.value]]),e("div",er,[e("label",tr,[Ve(e("input",{"onUpdate:modelValue":O[1]||(O[1]=re=>_.value=re),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),[[Ua,_.value]]),ee(" "+o(a(t)("ai.chat.message.edit.overwriteSubsequent")),1)]),e("div",ar,[p(N,{size:"xs",variant:"ghost",color:"gray",onClick:B},{default:j(()=>[ee(o(a(t)("common.cancel")),1)]),_:1}),p(N,{size:"xs",color:"primary",onClick:A},{default:j(()=>[ee(o(a(t)("ai.chat.message.edit.submit")),1)]),_:1})])])])):(n(),i("div",sr,[e("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:k.value},null,8,or)]))],64)):oe.value?(n(),i("div",nr,[(n(!0),i(Z,null,ce(W.value,(re,Q)=>(n(),i("div",{key:Q,class:ne([re.type==="process"?"py-1":""])},[re.type==="process"?(n(),i("button",{key:0,type:"button",class:"inline-flex max-w-full items-center gap-1.5 text-left text-xs text-gray-400 transition-colors hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300","aria-expanded":X(Q),onClick:te=>me(Q)},[p(J,{name:X(Q)?"i-heroicons-chevron-down":"i-heroicons-chevron-right",class:"h-3 w-3 shrink-0"},null,8,["name"]),e("span",lr,o(V(re,Q)),1),K(Q)?(n(),Y(J,{key:0,name:"i-heroicons-arrow-path",class:"h-3 w-3 shrink-0 animate-spin"})):R("",!0)],8,rr)):R("",!0),Ve(e("div",{class:ne([re.type==="process"?"mt-2 space-y-2 pl-4":""])},[(n(!0),i(Z,null,ce(G(re),(te,Pe)=>(n(),i(Z,{key:`${Q}-${Pe}`},[te.type==="text"?(n(),i("div",ir,[e("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:x(w(te.text))},null,8,cr),l.isStreaming&&ye(te)?(n(),i("span",dr)):R("",!0)])):te.type==="think"?(n(),i("details",ur,[e("summary",mr,[ee(o(C(te.tag))+" ",1),te.durationMs?(n(),i("span",gr,o(h(te.durationMs)),1)):R("",!0),l.isStreaming&&ye(te)?(n(),i("span",pr,[e("span",null,o(a(t)("ai.chat.message.think.loading")),1),O[3]||(O[3]=e("span",{class:"flex gap-0.5"},[e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1))])):R("",!0)]),e("div",vr,[te.tag==="plan_validation"&&Le(te.text)?(n(),i(Z,{key:0},[Le(te.text)?.title?(n(),i("div",yr,o(Le(te.text)?.title),1)):R("",!0),e("ol",hr,[(n(!0),i(Z,null,ce(Le(te.text)?.steps,(De,Ye)=>(n(),i("li",{key:Ye,class:"text-gray-600 dark:text-gray-300"},[e("div",fr,o(De.goal),1),De.evidenceNeeded?(n(),i("div",xr,o(a(t)("ai.chat.message.plan.evidenceNeeded"))+": "+o(De.evidenceNeeded),1)):R("",!0),e("div",br,o(a(t)("ai.chat.message.plan.suggestedTools"))+": "+o(de(De.suggestedTools)),1)]))),128))]),Le(te.text)?.successCriteria.length?(n(),i("div",kr,[e("div",_r,o(a(t)("ai.chat.message.plan.successCriteria")),1),e("ul",wr,[(n(!0),i(Z,null,ce(Le(te.text)?.successCriteria,(De,Ye)=>(n(),i("li",{key:Ye},o(De),1))),128))])])):R("",!0)],64)):(n(),i("div",{key:1,innerHTML:x(te.text)},null,8,$r))])])):te.type==="skill"?(n(),i("div",Cr,[p(J,{name:"i-heroicons-bolt",class:"h-3.5 w-3.5"}),e("span",null,o(a(t)("ai.skill.active.label",{name:te.skillName})),1)])):te.type==="plan"?(n(),i("details",Sr,[e("summary",Tr,[p(J,{name:"i-heroicons-clipboard-document-list",class:"h-3.5 w-3.5 shrink-0"}),e("span",Mr,o(a(t)("ai.chat.message.plan.label"))+" · "+o(te.plan.title),1)]),e("div",Ir,[te.displayText?(n(),i("div",{key:0,class:"prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:x(te.displayText)},null,8,Lr)):(n(),i("ol",Dr,[(n(!0),i(Z,null,ce(te.plan.steps,(De,Ye)=>(n(),i("li",{key:Ye,class:"text-xs leading-relaxed"},[e("div",Ar,o(Ye+1)+". "+o(De.goal),1),e("div",qr,o(a(t)("ai.chat.message.plan.evidenceNeeded"))+": "+o(De.evidenceNeeded),1),e("div",zr,o(a(t)("ai.chat.message.plan.suggestedTools"))+": "+o(de(De.suggestedTools)),1)]))),128))])),te.displayText?R("",!0):(n(),i("div",Rr,[e("div",Pr,o(a(t)("ai.chat.message.plan.successCriteria")),1),e("ul",Er,[(n(!0),i(Z,null,ce(te.plan.successCriteria,(De,Ye)=>(n(),i("li",{key:Ye},o(De),1))),128))])]))])])):te.type==="plan_draft"?(n(),i("div",Br,[e("div",jr,[p(J,{name:"i-heroicons-clipboard-document-list",class:"h-3.5 w-3.5 shrink-0"}),e("span",null,o(a(t)("ai.chat.message.plan.label")),1),l.isStreaming?(n(),i("span",Ur,[...O[4]||(O[4]=[e("span",{class:"flex gap-0.5"},[e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1)])])):R("",!0)]),e("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:x(te.text)},null,8,Fr)])):te.type==="chart"?(n(),Y(pn,{key:5,chart:te.chart},null,8,["chart"])):te.type==="evidence"?(n(),Y(Bn,{key:6,evidence:te.evidence},null,8,["evidence"])):te.type==="tool"&&ae(te.tool)?(n(),i("details",Vr,[e("summary",Nr,[e("div",{class:ne(["flex w-fit items-center gap-1.5 rounded-lg bg-gray-50 px-2.5 py-1 text-xs text-gray-500 transition-colors hover:bg-gray-100 dark:bg-gray-800/30 dark:text-gray-400/80 dark:hover:bg-gray-800/60",[te.tool.status==="error"?"bg-red-50 text-red-600 dark:bg-red-900/20 dark:text-red-400":""]])},[p(J,{name:te.tool.status==="error"?"i-heroicons-exclamation-circle":"i-heroicons-wrench-screwdriver",class:"h-3.5 w-3.5 shrink-0"},null,8,["name"]),e("div",Or,[e("span",null,o(he(te.tool)),1),qe(te.tool)?(n(),i("span",Wr,o(qe(te.tool)),1)):R("",!0),e("span",Hr," · "+o(a(t)("ai.chat.message.toolResult.view")),1)]),p(J,{name:"i-heroicons-chevron-right",class:"h-3 w-3 shrink-0 transition-transform [[open]>&]:rotate-90"})],2)]),e("div",Yr,[e("div",Kr,[e("span",Qr,o(a(t)("ai.chat.message.toolResult.title")),1),p(N,{size:"xs",variant:"ghost",color:"primary",icon:"i-heroicons-document-duplicate",title:a(t)("ai.chat.message.toolResult.copy"),onClick:Be(De=>xe(te.tool),["stop"])},null,8,["title","onClick"])]),se(te.tool)?(n(),i("div",Gr,o(a(t)("ai.chat.message.toolResult.displayTruncated")),1)):R("",!0),e("pre",Jr,o(be(te.tool)),1)])])):te.type==="tool"?(n(),i("div",{key:8,class:ne(["flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs transition-colors",[te.tool.status==="running"?"bg-gray-100 text-gray-600 dark:bg-gray-800/50 dark:text-gray-400":te.tool.status==="done"?"bg-gray-50 text-gray-500 dark:bg-gray-800/30 dark:text-gray-400/80":"bg-red-50 text-red-600 dark:bg-red-900/20 dark:text-red-400"]])},[p(J,{name:te.tool.status==="running"?"i-heroicons-arrow-path":te.tool.status==="done"?"i-heroicons-wrench-screwdriver":"i-heroicons-exclamation-circle",class:ne(["h-3.5 w-3.5 shrink-0",[te.tool.status==="running"?"animate-spin":""]])},null,8,["name","class"]),e("div",Xr,[e("span",null,o(he(te.tool)),1),qe(te.tool)?(n(),i("span",Zr,o(qe(te.tool)),1)):R("",!0),te.tool.status==="done"&&te.tool.durationMs?(n(),i("span",el," · "+o(h(te.tool.durationMs)),1)):R("",!0)])],2)):te.type==="error"?(n(),Y(Yo,{key:9,error:te.error},null,8,["error"])):R("",!0)],64))),128))],2),[[nt,re.type!=="process"||X(Q)]])],2))),128)),l.isStreaming&&T.value.length>0&&T.value[T.value.length-1].type==="tool"?(n(),i("div",tl,[O[5]||(O[5]=e("span",{class:"flex gap-1"},[e("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),e("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),e("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1)),e("span",null,o(a(t)("ai.chat.message.generating")),1)])):R("",!0)])):(n(),i("div",al,[e("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:k.value},null,8,sl),l.isStreaming?(n(),i("span",ol)):R("",!0)])),!y.value&&!l.isStreaming?(n(),i("div",{key:4,class:ne(["mt-1 flex items-center gap-2 px-1",[v.value?"flex-row-reverse":""]])},[e("span",nl,o(m.value),1),p(U,{text:a(t)("ai.chat.message.copy.tooltip"),class:"no-capture"},{default:j(()=>[p(N,{icon:"i-heroicons-document-duplicate",variant:"ghost",color:"primary",size:"xs",disabled:!Ee.value,onClick:ie},null,8,["disabled"])]),_:1},8,["text"]),I.value?(n(),Y(U,{key:0,text:a(t)("ai.chat.message.edit.tooltip"),class:"no-capture"},{default:j(()=>[p(N,{icon:"i-heroicons-pencil-square",variant:"ghost",color:"primary",size:"xs",onClick:P})]),_:1},8,["text"])):R("",!0),q.value?(n(),Y(U,{key:1,text:a(t)("ai.chat.message.fork.tooltip"),class:"no-capture"},{default:j(()=>[p(N,{icon:"i-heroicons-arrow-top-right-on-square",variant:"ghost",color:"primary",size:"xs",onClick:O[2]||(O[2]=re=>d("fork",l.messageId))})]),_:1},8,["text"])):R("",!0),l.showCaptureButton&&!v.value&&!l.isStreaming?(n(),Y(it,{key:2,size:"xs",type:"element","target-selector":".qa-pair","markdown-fix":""})):R("",!0)],2)):R("",!0)],2)],2)}}}),rl={key:0,class:"absolute bottom-full left-0 z-20 mb-1.5 w-[240px] max-w-[calc(100vw-2rem)]"},ll={class:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-overlay dark:border-gray-700 dark:bg-page-dark"},il={class:"flex items-center justify-between border-b border-gray-100 px-2.5 py-1.5 dark:border-gray-800"},cl={class:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400"},dl=["title"],ul={key:0,class:"px-3 py-4 text-center text-xs text-gray-500 dark:text-gray-400"},ml=["onMouseenter","onClick"],gl={class:"min-w-0 flex-1"},pl={class:"flex items-center gap-1.5"},vl={class:"truncate text-xs font-medium"},yl={class:"mt-0.5 line-clamp-2 text-[11px] leading-4 text-gray-500 dark:text-gray-400"},hl={key:2,class:"px-3 py-4 text-center"},fl={class:"text-sm font-medium text-gray-700 dark:text-gray-200"},xl={class:"mt-1 text-xs leading-5 text-gray-500 dark:text-gray-400"},bl=pe({__name:"MemberMentionMenu",props:{visible:{type:Boolean},members:{},highlightIndex:{},loading:{type:Boolean}},emits:["select","close","highlight"],setup(l,{emit:s}){const{t}=fe(),c=l,r=s,g=f(null);return ge(()=>[c.visible,c.highlightIndex,c.members.length],async([u,d])=>{if(!u||!g.value)return;await Ue(),g.value.querySelectorAll("[data-mention-item]")[d]?.scrollIntoView({block:"nearest"})}),(u,d)=>{const m=we;return n(),Y(rt,{name:"mention-menu"},{default:j(()=>[l.visible?(n(),i("div",rl,[e("div",ll,[e("div",il,[e("div",cl,[e("span",null,o(a(t)("ai.chat.input.mentionHint")),1)]),e("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:a(t)("common.close"),onClick:d[0]||(d[0]=v=>r("close"))},[p(m,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5"})],8,dl)]),c.loading?(n(),i("div",ul,o(a(t)("common.loading")),1)):c.members.length>0?(n(),i("div",{key:1,ref_key:"listRef",ref:g,class:"max-h-72 overflow-y-auto p-1.5"},[(n(!0),i(Z,null,ce(c.members,(v,y)=>(n(),i("button",{key:`${v.memberId}-${v.insertName}`,type:"button","data-mention-item":"",class:ne(["flex w-full items-start justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left transition-colors",y===c.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:M=>r("highlight",y),onClick:M=>r("select",v)},[e("div",gl,[e("div",pl,[e("span",vl,"@"+o(v.insertName),1)]),e("p",yl,o(v.subtitle),1)])],42,ml))),128))],512)):(n(),i("div",hl,[e("p",fl,o(a(t)("ai.chat.input.mentionEmpty")),1),e("p",xl,o(a(t)("ai.chat.input.mentionEmptyHint")),1)]))])])):R("",!0)]),_:1})}}}),kl=lt(bl,[["__scopeId","data-v-7bc45150"]]),_l={key:0,class:"absolute bottom-full left-0 z-20 mb-1.5 w-[240px] max-w-[calc(100vw-2rem)]"},wl={class:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-overlay dark:border-gray-700 dark:bg-page-dark"},$l={class:"flex items-center justify-between border-b border-gray-100 px-2.5 py-1.5 dark:border-gray-800"},Cl={class:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400"},Sl=["title"],Tl=["onMouseenter","onClick"],Ml={class:"min-w-0 flex-1"},Il={class:"flex items-center gap-1.5"},Ll={class:"truncate text-xs font-medium"},Dl={class:"mt-0.5 line-clamp-1 text-xs leading-4 text-gray-500 dark:text-gray-400"},Al={key:1,class:"px-3 py-4 text-center"},ql={class:"text-sm font-medium text-gray-700 dark:text-gray-200"},zl={class:"mt-1 text-xs leading-5 text-gray-500 dark:text-gray-400"},Rl={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"},Pl={class:"border-b border-gray-100 px-3 py-2 dark:border-gray-800"},El={class:"truncate text-sm font-medium text-gray-900 dark:text-gray-100"},Bl={class:"mt-0.5 text-xs leading-5 text-gray-500 dark:text-gray-400"},jl={key:0,class:"mt-1 flex items-start gap-1.5 text-[11px] leading-4"},Ul={class:"shrink-0 font-medium text-gray-600 dark:text-gray-300"},Fl={class:"line-clamp-1 min-w-0 flex-1 text-gray-500 dark:text-gray-400"},Vl={key:1,class:"mt-0.5 flex items-start gap-1.5 text-[11px] leading-4"},Nl={class:"shrink-0 font-medium text-gray-600 dark:text-gray-300"},Ol={class:"line-clamp-1 min-w-0 flex-1 text-gray-500 dark:text-gray-400"},Wl={class:"min-h-0 flex-1 overflow-y-auto px-3 py-2"},Hl={key:0,class:"text-xs text-gray-400 dark:text-gray-500"},Yl=["innerHTML"],Kl={key:2,class:"text-xs leading-relaxed text-gray-400 dark:text-gray-500"},Ql=pe({__name:"SlashCommandMenu",props:{visible:{type:Boolean},skills:{},highlightIndex:{},activeSkillId:{}},emits:["select","close","manage","highlight"],setup(l,{emit:s}){const{t,te:c}=fe(),r=dt(),g=l,u=s,d=f({}),m=f(""),v=f(!1),y=f(null),M=new Kt({html:!1,breaks:!0,linkify:!0,typographer:!0}),$=b(()=>{if(g.skills.length===0)return null;const L=Math.min(g.highlightIndex,g.skills.length-1);return g.skills[L]??null}),D=b(()=>m.value?M.render(m.value):"");function I(L){const x=`ai.assistant.builtinToolDesc.${L}`;return c(x)?t(x):L}const q=b(()=>$.value?.tags.join(" / ")||""),_=b(()=>$.value?.tools.map(L=>I(L)).join(" / ")||"");return ge(()=>[g.visible,$.value?.id],async([L,x])=>{if(!L||!x){m.value="",v.value=!1;return}if(d.value[x]){m.value=d.value[x],v.value=!1;return}v.value=!0;const h=(await r.getSkillConfig(x))?.prompt?.trim()||"";d.value={...d.value,[x]:h},$.value?.id===x&&(m.value=h,v.value=!1)},{immediate:!0}),ge(()=>[g.visible,g.highlightIndex,g.skills.length],async([L,x])=>{if(!L||!y.value)return;await Ue(),y.value.querySelectorAll("[data-slash-item]")[x]?.scrollIntoView({block:"nearest"})}),(L,x)=>{const C=we;return n(),Y(rt,{name:"slash-menu"},{default:j(()=>[l.visible?(n(),i("div",_l,[e("div",wl,[e("div",$l,[e("div",Cl,[e("span",null,o(a(t)("ai.chat.input.slashHint")),1)]),e("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:a(t)("common.close"),onClick:x[0]||(x[0]=h=>u("close"))},[p(C,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5"})],8,Sl)]),g.skills.length>0?(n(),i("div",{key:0,ref_key:"listRef",ref:y,class:"max-h-72 overflow-y-auto p-1.5"},[(n(!0),i(Z,null,ce(g.skills,(h,k)=>(n(),i("button",{key:h.id,type:"button","data-slash-item":"",class:ne(["flex w-full items-start justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left transition-colors",k===g.highlightIndex?"bg-primary-50 text-gray-900 dark:bg-primary-950/30 dark:text-gray-100":"text-gray-700 hover:bg-gray-50 dark:text-gray-200 dark:hover:bg-gray-800/80"]),onMouseenter:S=>u("highlight",k),onClick:S=>u("select",h)},[e("div",Ml,[e("div",Il,[e("span",Ll,o(h.name),1),g.activeSkillId===h.id?(n(),Y(C,{key:0,name:"i-heroicons-check-circle-20-solid",class:"h-3.5 w-3.5 shrink-0 text-primary-500"})):R("",!0)]),e("p",Dl,o(h.description),1)])],42,Tl))),128))],512)):(n(),i("div",Al,[e("p",ql,o(a(t)("ai.chat.input.slashEmpty")),1),e("p",zl,o(a(t)("ai.chat.input.slashEmptyHint")),1)])),e("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:x[1]||(x[1]=h=>u("manage"))},[e("span",null,o(a(t)("ai.chat.input.manageSkills")),1),p(C,{name:"i-heroicons-arrow-top-right-on-square",class:"h-3.5 w-3.5"})])]),g.skills.length>0&&$.value?(n(),i("div",Rl,[e("div",Pl,[e("p",El,o($.value.name),1),e("p",Bl,o($.value.description),1),q.value?(n(),i("div",jl,[e("span",Ul,o(a(t)("ai.chat.input.previewTagsLabel")),1),e("span",Fl,o(q.value),1)])):R("",!0),_.value?(n(),i("div",Vl,[e("span",Nl,o(a(t)("ai.chat.input.previewToolsLabel")),1),e("span",Ol,o(_.value),1)])):R("",!0)]),e("div",Wl,[v.value?(n(),i("div",Hl,o(a(t)("common.loading")),1)):D.value?(n(),i("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:D.value},null,8,Yl)):(n(),i("div",Kl,o(a(t)("ai.chat.input.previewUnavailable")),1))])])):R("",!0)])):R("",!0)]),_:1})}}}),Gl=lt(Ql,[["__scopeId","data-v-0f67bc21"]]),Jl={class:"shrink-0 pt-2 pb-2"},Xl={class:"relative px-4 pt-2.5 pb-2.5"},Zl={class:"flex items-start gap-2 pr-10"},ei={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"},ti={class:"truncate"},ai=["disabled","placeholder"],si=["disabled","title"],oi=pe({__name:"AIChatInput",props:{sessionId:{},disabled:{type:Boolean},status:{},chatType:{}},emits:["send","stop","manageSkills","skillActivated"],setup(l,{expose:s,emit:t}){const{t:c}=fe(),r=l,g=t,u=dt(),{compatibleSkills:d,activeSkill:m,activeSkillId:v,isLoaded:y}=et(u),M=f(null),$=f(null),D=f(""),I=f([]),q=f([]),_=f(!1),L=f(!1),x=f(""),C=f(0),h=f(!1),k=f(""),S=f(0),P=f(null),B=f(!1),A=f(null),w=f(null),T=f(!1),H=b(()=>D.value.trim().length>0&&!r.disabled),le=b(()=>m.value&&D.value.trim().length===0?c("ai.chat.input.placeholderWithActiveSkill",{name:m.value.name}):c("ai.chat.input.placeholderWithSlash")),W=b(()=>r.status==="streaming"?"":H.value?c("ai.chat.input.send"):m.value?c("ai.chat.input.needMoreThanSkill"):c("ai.chat.input.needQuestion")),ue=b(()=>{const N=new Map;return I.value.forEach(U=>{const re=U.groupNickname||U.accountName||U.platformId;N.set(re,(N.get(re)??0)+1)}),I.value.map(U=>{const re=U.groupNickname||U.accountName||U.platformId,Q=(N.get(re)??0)>1?`${re}·${U.platformId}`:re,te=[U.platformId];return U.aliases.length>0&&te.push(U.aliases.join(" / ")),{memberId:U.id,platformId:U.platformId,displayName:re,aliases:[...U.aliases],mentionText:`@${Q}`,insertName:Q,subtitle:te.join(" · "),searchText:[re,U.groupNickname||"",U.accountName||"",U.platformId,Q,U.aliases.join(" ")].join(" ").toLocaleLowerCase()}})}),ve=b(()=>{const N=x.value.trim().toLocaleLowerCase();return N?d.value.filter(U=>[U.name,U.description,U.tags.join(" ")].join(" ").toLocaleLowerCase().includes(N)):d.value}),G=b(()=>{const N=k.value.trim().toLocaleLowerCase();return N?ue.value.filter(U=>U.searchText.includes(N)):ue.value});function F(){if(!$.value)return;const N=$.value;N.style.height="auto";const U=192,re=Math.min(N.scrollHeight,U);N.style.height=`${re}px`,N.style.overflowY=N.scrollHeight>U?"auto":"hidden"}function X(){$.value?.focus()}async function me(){if(!r.sessionId){I.value=[];return}_.value=!0;try{const N=await Ne().getMembers(r.sessionId);I.value=[...N].sort((U,re)=>re.messageCount-U.messageCount)}catch(N){console.error("加载 AI @ 成员列表失败:",N),I.value=[]}finally{_.value=!1}}function ye(){L.value=!1,x.value="",C.value=0}function K(){h.value=!1,k.value="",S.value=0,P.value=null}function E(){/^\s*\/([^\n]*)$/.test(D.value)&&(A.value=D.value),ye()}function V(){P.value&&(w.value=P.value.rawToken),K()}function oe(N){if(r.disabled){ye();return}A.value&&A.value!==N&&(A.value=null);const U=N.match(/^\s*\/([^\n]*)$/);if(!U){ye();return}const re=!L.value||x.value!==U[1];if(x.value=U[1],A.value===N){L.value=!1;return}L.value=!0,re&&(C.value=0)}function he(){const N=$.value,U=D.value.length;return{start:N?.selectionStart??U,end:N?.selectionEnd??U}}function ke(N){const{start:U,end:re}=he();if(U!==re)return null;const Q=N.slice(0,U),te=Q.match(/@([^\s@]*)$/);if(!te)return null;const Pe=te[1],De=Q.length-Pe.length-1;return{start:De,end:U,rawToken:Q.slice(De),query:Pe}}function be(N){if(r.disabled||L.value){K();return}const U=ke(N);if(w.value&&w.value!==U?.rawToken&&(w.value=null),!U){K();return}const re=!h.value||k.value!==U.query||P.value?.rawToken!==U.rawToken;if(k.value=U.query,P.value={start:U.start,end:U.end,rawToken:U.rawToken},w.value===U.rawToken){h.value=!1;return}h.value=!0,re&&(S.value=0)}function ae(N){if(oe(N),L.value){K();return}be(N)}function se(N){q.value=q.value.filter(U=>N.includes(U.mentionText))}function xe(){const{start:N,end:U}=he();if(N!==U||N===0)return!1;const re=[...new Set(q.value.map(Q=>Q.mentionText))].sort((Q,te)=>te.length-Q.length);for(const Q of re){let te=D.value.indexOf(Q);for(;te!==-1;){const Pe=te,De=te+Q.length,Ye=D.value[De]===" "?De+1:De;if(N>Pe&&N<=Ye)return T.value=!0,D.value=D.value.slice(0,Pe)+D.value.slice(Ye),w.value=null,Ue(()=>{F(),X(),$.value?.setSelectionRange(Pe,Pe),T.value=!1,ae(D.value)}),!0;te=D.value.indexOf(Q,te+Q.length)}}return!1}function de(){u.activateSkill(null),Ue(X)}function _e(){r.disabled||(v.value&&u.activateSkill(null),T.value=!0,D.value="/",A.value=null,Ue(()=>{F(),X(),$.value?.setSelectionRange(1,1),T.value=!1,ae(D.value)}))}function Ie(N){r.disabled||(T.value=!0,D.value=N,A.value=null,Ue(()=>{F(),X();const U=D.value.length;$.value?.setSelectionRange(U,U),T.value=!1,ae(D.value)}))}function Le(N){if(r.disabled||!P.value)return;const U=D.value.slice(0,P.value.start),re=D.value.slice(P.value.end),Q=`@${N.insertName}`,te=`${U}${Q} ${re}`;q.value=[...q.value.filter(Pe=>Pe.memberId!==N.memberId),{memberId:N.memberId,platformId:N.platformId,displayName:N.displayName,aliases:[...N.aliases],mentionText:Q}],T.value=!0,D.value=te,w.value=null,K(),Ue(()=>{const Pe=U.length+Q.length+1;F(),X(),$.value?.setSelectionRange(Pe,Pe),T.value=!1,ae(D.value)})}function Se(){H.value&&(g("send",{content:D.value.trim(),mentionedMembers:[...q.value]}),D.value="",A.value=null,w.value=null,q.value=[],K(),v.value&&u.activateSkill(null))}function qe(N){r.disabled||(u.activateSkill(N.id),g("skillActivated",N),D.value="",A.value=null,ye(),Ue(()=>{X()}))}function Re(){E(),g("manageSkills")}function Ee(N){if(!ve.value.length)return;const U=ve.value.length;C.value=(C.value+N+U)%U}function ie(N){if(!G.value.length)return;const U=G.value.length;S.value=(S.value+N+U)%U}function z(N){if(N.key==="Backspace"&&D.value.length===0&&v.value){N.preventDefault(),de();return}if(N.key==="Backspace"&&xe()){N.preventDefault();return}if(h.value){if(N.key==="ArrowDown"){N.preventDefault(),ie(1);return}if(N.key==="ArrowUp"){N.preventDefault(),ie(-1);return}if(N.key==="Escape"){N.preventDefault(),V();return}if(N.key==="Enter"&&!N.shiftKey&&!B.value||N.key==="Tab"){N.preventDefault();const U=G.value[S.value];U&&Le(U);return}}if(L.value){if(N.key==="ArrowDown"){N.preventDefault(),Ee(1);return}if(N.key==="ArrowUp"){N.preventDefault(),Ee(-1);return}if(N.key==="Escape"){N.preventDefault(),E();return}if(N.key==="Enter"&&!N.shiftKey&&!B.value||N.key==="Tab"){N.preventDefault();const U=ve.value[C.value];U&&qe(U);return}}N.key==="Enter"&&!N.shiftKey&&!B.value&&(N.preventDefault(),Se())}function O(N){if(!L.value&&!h.value||!M.value)return;const U=N.target;U instanceof Node&&!M.value.contains(U)&&(E(),V())}function J(){T.value||ae(D.value)}return ge(()=>r.chatType,N=>{u.setFilterContext(N)},{immediate:!0}),ge(D,async N=>{se(N),T.value||ae(N),await Ue(),F()}),ge(ve,N=>{if(N.length===0){C.value=0;return}C.value>=N.length&&(C.value=N.length-1)},{immediate:!0}),ge(G,N=>{if(N.length===0){S.value=0;return}S.value>=N.length&&(S.value=N.length-1)},{immediate:!0}),ge(()=>r.disabled,N=>{N&&(E(),V())}),ge(()=>r.sessionId,()=>{q.value=[],K(),me()},{immediate:!0}),je(async()=>{y.value||await u.loadSkills(),await Ue(),F(),document.addEventListener("mousedown",O)}),kt(()=>{document.removeEventListener("mousedown",O)}),s({fillInput:Ie,openSkillSelector:_e}),(N,U)=>{const re=we;return n(),i("div",Jl,[e("div",{ref_key:"rootRef",ref:M,class:"relative w-full max-w-4xl mx-auto"},[p(Gl,{visible:L.value,skills:ve.value,"highlight-index":C.value,"active-skill-id":a(v),onSelect:qe,onClose:E,onManage:Re,onHighlight:U[0]||(U[0]=Q=>C.value=Q)},null,8,["visible","skills","highlight-index","active-skill-id"]),p(kl,{visible:h.value,members:G.value,"highlight-index":S.value,loading:_.value,onSelect:Le,onClose:V,onHighlight:U[1]||(U[1]=Q=>S.value=Q)},null,8,["visible","members","highlight-index","loading"]),e("div",{class:ne(["flex flex-col overflow-hidden rounded-2xl bg-white shadow-[0_2px_14px_rgba(0,0,0,0.04)] ring-1 ring-gray-200/60 transition-all dark:bg-page-dark dark:ring-white/5",r.disabled?"bg-gray-50/50 dark:bg-page-dark/50":"focus-within:ring-primary-500/40 focus-within:shadow-[0_4px_20px_rgba(0,0,0,0.08)] dark:focus-within:ring-primary-500/40"])},[e("div",Xl,[e("div",Zl,[a(m)?(n(),i("div",ei,[e("span",ti,"/"+o(a(m).name),1)])):R("",!0),Ve(e("textarea",{ref_key:"textareaRef",ref:$,"onUpdate:modelValue":U[2]||(U[2]=Q=>D.value=Q),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:le.value,onKeydown:z,onClick:J,onKeyup:J,onSelect:J,onCompositionstart:U[3]||(U[3]=Q=>B.value=!0),onCompositionend:U[4]||(U[4]=Q=>B.value=!1)},null,40,ai),[[ot,D.value]])]),r.status==="streaming"?(n(),i("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:U[5]||(U[5]=Q=>g("stop"))},[p(re,{name:"i-heroicons-stop-16-solid",class:"h-3.5 w-3.5"})])):(n(),i("button",{key:1,type:"button",class:ne(["absolute right-3 bottom-2 flex h-7 w-7 items-center justify-center rounded-full transition-all duration-200",H.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:!H.value,title:W.value,onClick:Se},[p(re,{name:"i-heroicons-arrow-up-20-solid",class:"h-4 w-4"})],10,si))])],2)],512)])}}}),ni={key:0,class:"flex w-fit items-center gap-1.5 rounded-lg bg-gray-100 px-2.5 py-1 text-xs transition-colors dark:bg-gray-800/50"},ri={class:"font-medium text-gray-600 dark:text-gray-400"},li={key:1,class:"flex items-start gap-3"},ii={class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-linear-to-br from-pink-500 to-pink-600"},ci={class:"rounded-2xl rounded-tl-sm bg-gray-100 px-4 py-3 dark:bg-gray-800"},di={key:0,class:"space-y-2"},ui={class:"flex items-center gap-2"},mi={key:0,class:"flex gap-1"},gi={key:1,class:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400"},pi={key:0,class:"flex flex-wrap gap-1"},vi={class:"text-xs text-gray-400"},yi={key:1,class:"flex items-center gap-2"},hi={class:"text-sm text-gray-600 dark:text-gray-400"},fi=pe({__name:"AIThinkingIndicator",props:{currentToolStatus:{},toolsUsed:{},agentStatus:{}},setup(l){const{t:s,te:t}=fe();function c(u,d){const m=`ai.assistant.builtinToolDesc.${u}`;return t(m)?s(m):d||u}const r=l,g=b(()=>r.agentStatus?.phase==="compressing");return(u,d)=>{const m=we;return g.value?(n(),i("div",ni,[p(m,{name:"i-heroicons-arrow-path",class:"h-3.5 w-3.5 shrink-0 animate-spin text-gray-600 dark:text-gray-400"}),e("span",ri,o(a(s)("ai.chat.thinking.compressing")),1)])):(n(),i("div",li,[e("div",ii,[p(m,{name:"i-heroicons-sparkles",class:"h-4 w-4 text-white"})]),e("div",ci,[l.currentToolStatus?(n(),i("div",di,[e("div",ui,[e("span",{class:ne(["inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium",[l.currentToolStatus.status==="running"?"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-300":l.currentToolStatus.status==="done"?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300"]])},[p(m,{name:l.currentToolStatus.status==="running"?"i-heroicons-cog-6-tooth":l.currentToolStatus.status==="done"?"i-heroicons-check-circle":"i-heroicons-x-circle",class:ne(["h-3 w-3",{"animate-spin":l.currentToolStatus.status==="running"}])},null,8,["name","class"]),ee(" "+o(c(l.currentToolStatus.name,l.currentToolStatus.displayName)),1)],2),l.currentToolStatus.status==="running"?(n(),i("span",mi,[...d[0]||(d[0]=[e("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:0ms]"},null,-1),e("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:150ms]"},null,-1),e("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:300ms]"},null,-1)])])):l.currentToolStatus.status==="done"?(n(),i("span",gi,[e("span",null,o(a(s)("ai.chat.thinking.processingResult")),1),d[1]||(d[1]=e("span",{class:"flex gap-1"},[e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1))])):R("",!0)]),l.toolsUsed.length>1?(n(),i("div",pi,[e("span",vi,o(a(s)("ai.chat.thinking.called")),1),(n(!0),i(Z,null,ce(l.toolsUsed.slice(0,-1),v=>(n(),i("span",{key:v,class:"inline-flex items-center gap-1 rounded-full bg-gray-200 px-2 py-0.5 text-xs text-gray-600 dark:bg-gray-700 dark:text-gray-400"},[p(m,{name:"i-heroicons-check",class:"h-3 w-3 text-green-500"}),ee(" "+o(c(v)),1)]))),128))])):R("",!0)])):(n(),i("div",yi,[e("span",hi,o(a(s)("ai.chat.thinking.analyzing")),1),d[2]||(d[2]=e("span",{class:"flex gap-1"},[e("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:0ms]"}),e("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:150ms]"}),e("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:300ms]"})],-1))]))])]))}}}),xi={class:"relative z-20 flex items-center justify-between"},bi={class:"flex items-center gap-1"},ki=["disabled"],_i={class:"max-w-[160px] truncate"},wi=["title"],$i={class:"w-40 py-1"},Ci={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},Si=["onClick"],Ti={class:"flex items-center gap-1"},Mi=["title"],Ii={class:"hidden shrink-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-xs text-gray-400 dark:text-gray-500 md:flex"},Li={class:"h-1.5 w-10 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},Di={class:"text-[10px]"},Ai={class:"space-y-0.5 whitespace-nowrap text-xs"},qi={key:0},zi=["title","disabled"],Ri={class:"hidden xl:inline"},Pi=["title","disabled"],Ei={class:"hidden xl:inline"},Bi=pe({__name:"ChatStatusBar",props:{sessionTokenUsage:{},agentStatus:{},currentAIChatId:{},currentMessages:{},fallbackTitle:{},estimatedContextTokens:{}},setup(l){const{t:s}=fe(),t=Je(),c=ct(),r=l,g=xt(),u=Aa(),{aiGlobalSettings:d}=et(g),{defaultAssistantConfig:m,isLoading:v}=et(u),y=f(!1),M=b(()=>r.agentStatus?s(`ai.chat.statusBar.agent.phase.${r.agentStatus.phase}`):""),$=b(()=>r.agentStatus?s(`ai.chat.statusBar.agent.phaseShort.${r.agentStatus.phase}`):""),D=b(()=>{if(!r.agentStatus)return"text-gray-500 bg-gray-100 dark:bg-gray-800 dark:text-gray-300";switch(r.agentStatus.phase){case"compressing":return"text-purple-600 bg-purple-50 dark:bg-purple-900/30 dark:text-purple-300";case"tool_running":return"text-indigo-600 bg-indigo-50 dark:bg-indigo-900/30 dark:text-indigo-300";case"thinking":return"text-blue-600 bg-blue-50 dark:bg-blue-900/30 dark:text-blue-300";case"responding":return"text-emerald-600 bg-emerald-50 dark:bg-emerald-900/30 dark:text-emerald-300";case"completed":return"text-green-600 bg-green-50 dark:bg-green-900/30 dark:text-green-300";case"aborted":return"text-amber-600 bg-amber-50 dark:bg-amber-900/30 dark:text-amber-300";case"error":return"text-red-600 bg-red-50 dark:bg-red-900/30 dark:text-red-300";default:return"text-gray-500 bg-gray-100 dark:bg-gray-800 dark:text-gray-300"}});function I(E){return Number.isFinite(E)?new Intl.NumberFormat().format(Math.max(0,Math.round(E))):"0"}function q(E){const V=Math.max(0,Math.round(E));return V>=1e6?`${(V/1e6).toFixed(1).replace(/\.0$/,"")}M`:V>=1e3?`${(V/1e3).toFixed(1).replace(/\.0$/,"")}k`:String(V)}const _=b(()=>I(r.sessionTokenUsage.totalTokens)),L=b(()=>q(r.sessionTokenUsage.totalTokens)),x=b(()=>r.sessionTokenUsage.cacheReadTokens>0),C=b(()=>q(r.sessionTokenUsage.cacheReadTokens)),h=b(()=>r.agentStatus?.contextTokens?r.agentStatus.contextTokens:r.estimatedContextTokens&&r.estimatedContextTokens>0?r.estimatedContextTokens:0),k=b(()=>{const E=m.value,V=u.defaultAssistant?.modelId||E?.model;return!E||!V?128e3:(u.getModelById(E.provider,V)||u.findModelAcrossProviders(V))?.contextWindow??128e3}),S=b(()=>h.value<=0||k.value<=0?0:Math.min(100,Math.round(h.value/k.value*100))),P=b(()=>{const E=S.value;return E>=80?"bg-red-500":E>=60?"bg-amber-500":"bg-emerald-500"}),B=b(()=>r.agentStatus?[`${s("ai.chat.statusBar.agent.label")}: ${M.value}`,`${s("ai.chat.statusBar.agent.contextTokens")}: ${I(r.agentStatus.contextTokens)}`,`${s("ai.chat.statusBar.tokenUsageTitle")}: ${_.value}`].join(`
38
+ `):"");function A(){c.openSettings("ai","defaultModel")}const w=f(!1),T=b(()=>Et(r.currentMessages??[])),H=b(()=>!!r.currentAIChatId||is(r.currentMessages??[]));function le(){return{createdAt:s("ai.chat.conversation.export.createdAt"),user:s("ai.chat.conversation.export.user"),assistant:s("ai.chat.conversation.export.assistant")}}function W(E){return E.map(V=>({...V,timestamp:V.timestamp*1e3}))}async function ue(){if(!(w.value||!H.value)){w.value=!0;try{const E=d.value.exportFormat||"markdown",V=le();let oe=r.fallbackTitle||s("ai.chat.conversation.newChat"),he=T.value[0]?.timestamp??Date.now(),ke=T.value;if(r.currentAIChatId){const[ae,se]=await Promise.all([Fe().getAIChat(r.currentAIChatId),Fe().getMessages(r.currentAIChatId)]);ae&&(oe=ae.title||oe,he=ae.createdAt*1e3);const xe=Et(W(se));xe.length>0&&(ke=xe)}if(ke.length===0){t.warn(s("ai.chat.conversation.export.noMessages"));return}const be=await ms(oe,ke,he,E,V);if(be.success&&be.filePath){const ae=be.filePath.split("/").pop()||be.filePath,se=be.filePath;t.add({title:s("common.exportSuccess"),description:ae,color:"primary",actions:[{label:s("common.openFolder"),onClick:()=>{aa().showInFolder(se)}}]})}else t.fail(s("common.exportFailed"),{description:be.error})}catch(E){console.error("导出对话失败:",E),t.fail(s("common.exportFailed"),{description:String(E)})}finally{w.value=!1}}}async function ve(){if(!y.value){y.value=!0;try{const E=await Fe().showAiLogFile();E?.success||t.fail(s("ai.chat.statusBar.log.openFailed"),{description:E?.error||s("ai.chat.statusBar.log.openFailedDesc")})}catch(E){console.error("打开 AI 日志失败:",E),t.fail(s("ai.chat.statusBar.log.openFailed"),{description:String(E)})}finally{y.value=!1}}}const G=f(!1),F=b(()=>{const E=m.value,V=u.defaultAssistant?.modelId||E?.model;return!E?.provider||!V?[]:ss(E.provider,V)}),X=b(()=>F.value.length>0),me=b(()=>{const E=u.defaultAssistant;return!E?.configId||!E?.modelId?"default":g.getThinkingLevel(E.configId,E.modelId)??"default"});function ye(E){const V=u.defaultAssistant;!V?.configId||!V?.modelId||(g.setThinkingLevel(V.configId,V.modelId,E),G.value=!1)}const K=b(()=>s(`ai.chat.statusBar.thinking.level.${me.value}`));return(E,V)=>{const oe=we,he=ra,ke=pt;return n(),i("div",xi,[e("div",bi,[e("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:a(v),onClick:A},[p(oe,{name:"i-heroicons-cpu-chip",class:"h-3.5 w-3.5"}),e("span",_i,o(a(u).defaultAssistant?.modelId?a(u).getModelById(a(m)?.provider??"",a(u).defaultAssistant.modelId)?.name||a(u).defaultAssistant.modelId:a(s)("ai.chat.statusBar.model.notConfigured")),1)],8,ki),X.value?(n(),Y(he,{key:0,open:G.value,"onUpdate:open":V[0]||(V[0]=be=>G.value=be),ui:{content:"z-[80] p-0"}},{content:j(()=>[e("div",$i,[e("div",Ci,o(a(s)("ai.chat.statusBar.thinking.title")),1),(n(!0),i(Z,null,ce(F.value,be=>(n(),i("button",{key:be,class:ne(["flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",me.value===be?"text-primary-600 dark:text-primary-400":"text-gray-700 dark:text-gray-300"]),onClick:ae=>ye(be)},[p(oe,{name:me.value===be?"i-heroicons-check-circle-solid":"i-heroicons-light-bulb",class:ne(["h-4 w-4 shrink-0",me.value===be?"text-primary-500":"text-gray-400"])},null,8,["name","class"]),e("span",null,o(a(s)(`ai.chat.statusBar.thinking.level.${be}`)),1)],10,Si))),128))])]),default:j(()=>[e("button",{class:ne(["flex items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",me.value==="default"||me.value==="off"?"text-gray-400 dark:text-gray-500":"text-primary-500 dark:text-primary-400"]),title:a(s)("ai.chat.statusBar.thinking.tooltip")},[p(oe,{name:"i-heroicons-light-bulb",class:"h-3.5 w-3.5"}),e("span",null,o(K.value),1)],10,wi)]),_:1},8,["open"])):R("",!0)]),e("div",Ti,[l.agentStatus?(n(),i("div",{key:0,class:"hidden shrink-0 items-center gap-1 rounded-lg bg-gray-50/90 px-1.5 py-1 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.35)] dark:bg-gray-800/70 dark:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.04)] lg:flex",title:B.value},[e("span",{class:ne(["rounded px-1 py-0.5 text-[10px] font-medium",D.value])},o($.value),3)],8,Mi)):R("",!0),h.value>0?(n(),Y(ke,{key:1,ui:{content:"h-auto py-1.5"}},{content:j(()=>[e("div",Ai,[e("div",null,o(a(s)("ai.chat.statusBar.agent.contextTokens"))+": "+o(q(h.value))+" / "+o(q(k.value)),1),e("div",null,o(a(s)("ai.chat.statusBar.tokenUsageTitle"))+": "+o(L.value),1),x.value?(n(),i("div",qi,o(a(s)("ai.chat.statusBar.cacheHit"))+": "+o(C.value),1)):R("",!0)])]),default:j(()=>[e("div",Ii,[e("div",Li,[e("div",{class:ne(["h-full rounded-full transition-all duration-300",P.value]),style:Qe({width:`${S.value}%`})},null,6)]),e("span",Di,o(S.value)+"%",1)])]),_:1})):R("",!0),e("button",{class:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:a(s)("ai.chat.statusBar.export.title"),disabled:w.value||!H.value,onClick:ue},[p(oe,{name:"i-heroicons-arrow-down-tray",class:"h-3.5 w-3.5"}),e("span",Ri,o(a(s)("ai.chat.statusBar.export.label")),1)],8,zi),e("button",{class:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:a(s)("ai.chat.statusBar.log.title"),disabled:y.value,onClick:ve},[p(oe,{name:"i-heroicons-document-text",class:"h-3.5 w-3.5"}),e("span",Ei,o(a(s)("ai.chat.statusBar.log.label")),1)],8,Pi)])])}}}),ji={class:"assistant-bar-wrapper flex justify-center"},Ui=["onClick"],Fi={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"},Vi={class:"custom-scrollbar max-h-60 space-y-0.5 overflow-y-auto"},Ni=["onClick"],Oi={class:"truncate font-medium"},vt=4,Wi=pe({__name:"AssistantInlineBar",props:{chatType:{},locale:{},selectedId:{}},emits:["select","market"],setup(l,{emit:s}){const t=l,c=s,r=f(!1),g=f(null);function u(k){c("select",k),r.value=!1}function d(){q.value.length!==0&&(r.value=!r.value)}function m(k){if(!r.value||!g.value)return;const S=k.target;S instanceof Node&&!g.value.contains(S)&&(r.value=!1)}const v=gt(),{filteredAssistants:y,isLoaded:M}=et(v);function $(k){return k.startsWith("ja")?"general_ja":k.startsWith("en")?"general_en":"general_cn"}const D=b(()=>{const k=$(t.locale);return[...y.value].sort((S,P)=>S.id===k?-1:P.id===k?1:0)}),I=b(()=>{const k=D.value;if(k.length<=vt)return k;const S=k.findIndex(P=>P.id===t.selectedId);if(S!==-1&&S>=vt-1){const P=k.slice(0,vt-1),B=k[S];return[...P,B]}return k.slice(0,vt)}),q=b(()=>{const k=new Set(I.value.map(S=>S.id));return D.value.filter(S=>!k.has(S.id))});ge(()=>[t.chatType,t.locale],([k,S])=>{v.setFilterContext(k,S)},{immediate:!0});const _=f([]),L=f(null);let x=null;const C=f({width:"0px",transform:"translateX(0px)",opacity:0}),h=async()=>{await Ue();const k=I.value.findIndex(S=>S.id===t.selectedId);if(k!==-1&&_.value[k]){const S=_.value[k];C.value={width:`${S.offsetWidth+6}px`,transform:`translateX(${S.offsetLeft-3}px)`,opacity:1}}else C.value.opacity=0};return ge(()=>[t.selectedId,I.value],()=>{h()},{deep:!0}),je(async()=>{M.value||await v.loadAssistants(),h(),document.addEventListener("mousedown",m),typeof ResizeObserver<"u"&&L.value&&(x=new ResizeObserver(()=>{h()}),x.observe(L.value))}),ut(()=>{document.removeEventListener("mousedown",m),x&&x.disconnect()}),(k,S)=>{const P=we;return n(),i("div",ji,[e("div",{ref_key:"containerRef",ref:L,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"},[e("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:Qe(C.value)},null,4),(n(!0),i(Z,null,ce(I.value,(B,A)=>(n(),i("button",{key:B.id,ref_for:!0,ref:w=>{w&&(_.value[A]=w)},class:ne(["relative z-10 flex h-[32px] items-center justify-center whitespace-nowrap rounded-full px-4 text-[13px] font-medium transition-colors duration-200",[l.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:w=>c("select",B.id)},o(B.name),11,Ui))),128)),q.value.length>0?(n(),i("div",{key:0,ref_key:"overflowMenuRef",ref:g,class:"relative z-20"},[e("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:d},[p(P,{name:"i-heroicons-ellipsis-horizontal",class:"h-5 w-5"})]),r.value?(n(),i("div",Fi,[e("div",Vi,[S[1]||(S[1]=e("p",{class:"px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500"}," 更多助手 ",-1)),(n(!0),i(Z,null,ce(q.value,B=>(n(),i("button",{key:B.id,type:"button",class:ne(["flex w-full items-center justify-between rounded-md px-2.5 py-1.5 text-left text-sm transition-colors",[l.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:A=>u(B.id)},[e("span",Oi,o(B.name),1),l.selectedId===B.id?(n(),Y(P,{key:0,name:"i-heroicons-check",class:"h-4 w-4 shrink-0"})):R("",!0)],10,Ni))),128))])])):R("",!0)],512)):R("",!0),e("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=>c("market"))},[p(P,{name:"i-heroicons-plus",class:"h-[18px] w-[18px]"})])],512)])}}}),Hi=lt(Wi,[["__scopeId","data-v-ddcf46c0"]]),Yi={class:"p-6"},Ki={class:"mb-4 flex items-start justify-between gap-3"},Qi={class:"min-w-0"},Gi={class:"text-lg font-semibold text-gray-900 dark:text-white"},Ji={key:0,class:"mt-1 text-xs text-amber-600 dark:text-amber-400"},Xi={key:0,class:"flex items-center justify-center py-12"},Zi={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},ec={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"},tc={class:"max-h-[500px] overflow-y-auto pr-1"},ac={class:"space-y-5"},sc={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},oc={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},nc={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},rc={class:"flex flex-wrap gap-2"},lc=["disabled","onClick"],ic={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},cc={class:"flex flex-wrap gap-2"},dc=["disabled","onClick"],uc={class:"mt-1 text-[10px] text-gray-400"},mc={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},gc={class:"space-y-2"},pc={key:0,class:"flex items-center gap-2"},vc={class:"space-y-5"},yc={class:"mb-1 text-sm font-medium text-gray-700 dark:text-gray-300"},hc={class:"mb-2.5 text-[10px] text-gray-400"},fc={class:"grid grid-cols-2 gap-1.5"},xc={class:"min-w-0"},bc={class:"truncate text-xs font-medium text-gray-600 dark:text-gray-400"},kc={class:"truncate text-[10px] text-gray-400 dark:text-gray-500"},_c={class:"mb-1 flex items-center justify-between"},wc={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},$c={key:0,class:"flex gap-2"},Cc={class:"mb-2.5 text-[10px] text-gray-400"},Sc={class:"grid grid-cols-2 gap-1.5"},Tc=["checked","disabled","onChange"],Mc={class:"min-w-0"},Ic={class:"truncate text-xs font-medium text-gray-800 dark:text-gray-200"},Lc={class:"truncate text-[10px] text-gray-500 dark:text-gray-400"},Dc={class:"mt-6 flex items-center justify-between"},Ac={class:"flex gap-2"},qc=pe({__name:"AssistantConfigModal",props:{open:{type:Boolean},assistantId:{},readonly:{type:Boolean},scrollToSection:{}},emits:["update:open","saved","created"],setup(l,{emit:s}){const{t}=fe(),c=l,r=s,g=Je(),u=gt(),d=f(!1),m=f(!1),v=f(null),y=f(!1),M=f("basic"),$=b(()=>[{value:"",label:t("ai.assistant.config.chatTypeAll")},{value:"group",label:t("ai.assistant.config.chatTypeGroup")},{value:"private",label:t("ai.assistant.config.chatTypePrivate")}]),D=[{value:"zh",label:"简体中文"},{value:"en",label:"English"},{value:"ja",label:"日本語"}],I=b(()=>u.builtinToolCatalog.filter(G=>G.category==="core").map(G=>({name:G.name,description:t(`ai.assistant.builtinToolDesc.${G.name}`)}))),q=b(()=>u.builtinToolCatalog.filter(G=>G.category==="analysis").map(G=>({name:G.name,description:t(`ai.assistant.builtinToolDesc.${G.name}`)}))),_=f({name:"",systemPrompt:"",presetQuestions:[],applicableChatType:"",supportedLocales:[],allowedBuiltinTools:[]}),L=f(""),x=f(null),C=b(()=>_.value.allowedBuiltinTools.length);je(async()=>{u.builtinToolCatalog.length===0&&await u.loadBuiltinToolCatalog()}),ge(()=>[c.open,c.assistantId],async([G,F])=>{G&&(M.value="basic",F?(y.value=!1,await k(F)):c.readonly||(y.value=!0,h()),c.scrollToSection==="presetQuestions"&&(await Ue(),setTimeout(()=>{x.value?.scrollIntoView({behavior:"smooth",block:"center"})},100)))},{immediate:!0});function h(){v.value={id:"",name:"",systemPrompt:"",presetQuestions:[],allowedBuiltinTools:[],applicableChatTypes:[],supportedLocales:[]},_.value={name:"",systemPrompt:"",presetQuestions:[],applicableChatType:"",supportedLocales:[],allowedBuiltinTools:[]},d.value=!1}async function k(G){d.value=!0;try{v.value=await u.getAssistantConfig(G),v.value&&(_.value={name:v.value.name,systemPrompt:v.value.systemPrompt,presetQuestions:[...v.value.presetQuestions],applicableChatType:v.value.applicableChatTypes?.[0]||"",supportedLocales:[...v.value.supportedLocales||[]],allowedBuiltinTools:[...v.value.allowedBuiltinTools||[]]})}catch(F){console.error("[AssistantConfigModal] Failed to load config:",F),g.fail(t("ai.assistant.toast.loadFailed"),{description:String(F)})}finally{d.value=!1}}async function S(){m.value=!0;try{const G={name:_.value.name,systemPrompt:_.value.systemPrompt,presetQuestions:[..._.value.presetQuestions],applicableChatTypes:_.value.applicableChatType?[_.value.applicableChatType]:[],supportedLocales:[..._.value.supportedLocales],allowedBuiltinTools:[..._.value.allowedBuiltinTools]};if(y.value){const F=await u.createAssistant(G);F.success?(g.success(t("ai.assistant.toast.createSuccess")),r("created",F.id),ve()):g.fail(t("ai.assistant.toast.createFailed"),{description:F.error||t("ai.assistant.toast.unknownError")})}else{if(!c.assistantId)return;const F=await u.updateAssistant(c.assistantId,G);F.success?(g.success(t("ai.assistant.toast.saveSuccess")),r("saved"),ve()):g.fail(t("ai.assistant.toast.saveFailed"),{description:F.error||t("ai.assistant.toast.unknownError")})}}catch(G){console.error("[AssistantConfigModal] Save failed:",G),g.fail(t("ai.assistant.toast.saveFailed"),{description:String(G)})}finally{m.value=!1}}async function P(){if(!(!c.assistantId||!v.value?.builtinId)){m.value=!0;try{const G=await u.resetAssistant(c.assistantId);G.success?(g.success(t("ai.assistant.toast.resetSuccess")),await k(c.assistantId),r("saved")):g.fail(t("ai.assistant.toast.resetFailed"),{description:G.error||t("ai.assistant.toast.unknownError")})}catch(G){g.fail(t("ai.assistant.toast.resetFailed"),{description:String(G)})}finally{m.value=!1}}}function B(){const G=L.value.trim();G&&!_.value.presetQuestions.includes(G)&&(_.value.presetQuestions.push(G),L.value="")}function A(G){_.value.presetQuestions.splice(G,1)}function w(G){const F=_.value.allowedBuiltinTools.indexOf(G);F>=0?_.value.allowedBuiltinTools.splice(F,1):_.value.allowedBuiltinTools.push(G)}function T(G){return _.value.allowedBuiltinTools.includes(G)}function H(){_.value.allowedBuiltinTools=q.value.map(G=>G.name)}function le(){_.value.allowedBuiltinTools=[]}function W(G){_.value.applicableChatType=G}function ue(G){const F=_.value.supportedLocales.indexOf(G);F>=0?_.value.supportedLocales.splice(F,1):_.value.supportedLocales.push(G)}function ve(){r("update:open",!1)}return(G,F)=>{const X=ze,me=we,ye=wt,K=Va,E=He;return n(),Y(E,{open:l.open,ui:{content:"sm:max-w-2xl z-100"},"onUpdate:open":F[5]||(F[5]=V=>r("update:open",V))},{content:j(()=>[e("div",Yi,[e("div",Ki,[e("div",Qi,[e("h2",Gi,o(l.readonly?a(t)("ai.assistant.config.viewTitle"):y.value?a(t)("ai.assistant.config.createTitle"):a(t)("ai.assistant.config.editTitle")),1),l.readonly?R("",!0):(n(),i("p",Ji,o(a(t)("ai.assistant.config.betaWarning")),1))]),p(X,{icon:"i-heroicons-x-mark",variant:"ghost",size:"sm",class:"shrink-0",onClick:ve})]),d.value?(n(),i("div",Xi,[p(me,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):v.value?(n(),i(Z,{key:1},[e("div",Zi,[e("button",{class:ne(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",M.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]=V=>M.value="basic")},o(a(t)("ai.assistant.config.tabs.basic")),3),e("button",{class:ne(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",M.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]=V=>M.value="tools")},[ee(o(a(t)("ai.assistant.config.tabs.tools"))+" ",1),C.value>0?(n(),i("span",ec,o(C.value),1)):R("",!0)],2)]),e("div",tc,[Ve(e("div",ac,[e("div",null,[e("label",sc,o(a(t)("ai.assistant.config.name")),1),p(ye,{modelValue:_.value.name,"onUpdate:modelValue":F[2]||(F[2]=V=>_.value.name=V),class:"w-full",disabled:l.readonly},null,8,["modelValue","disabled"])]),e("div",null,[e("label",oc,o(a(t)("ai.assistant.config.systemPrompt")),1),p(K,{modelValue:_.value.systemPrompt,"onUpdate:modelValue":F[3]||(F[3]=V=>_.value.systemPrompt=V),rows:5,autoresize:"",class:"w-full font-mono text-sm",disabled:l.readonly},null,8,["modelValue","disabled"])]),e("div",null,[e("label",nc,o(a(t)("ai.assistant.config.chatType")),1),e("div",rc,[(n(!0),i(Z,null,ce($.value,V=>(n(),i("button",{key:V.value,type:"button",class:ne(["rounded-lg border px-3 py-1.5 text-xs transition-colors",_.value.applicableChatType===V.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:l.readonly,onClick:oe=>W(V.value)},o(V.label),11,lc))),128))])]),e("div",null,[e("label",ic,o(a(t)("ai.assistant.config.locale")),1),e("div",cc,[(n(),i(Z,null,ce(D,V=>e("button",{key:V.value,type:"button",class:ne(["rounded-lg border px-3 py-1.5 text-xs transition-colors",_.value.supportedLocales.includes(V.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:l.readonly,onClick:oe=>ue(V.value)},o(V.label),11,dc)),64))]),e("p",uc,o(a(t)("ai.assistant.config.localeHint")),1)]),e("div",{ref_key:"presetQuestionsRef",ref:x},[e("label",mc,o(a(t)("ai.assistant.config.presetQuestions")),1),e("div",gc,[(n(!0),i(Z,null,ce(_.value.presetQuestions,(V,oe)=>(n(),i("div",{key:oe,class:"flex items-center gap-2"},[p(ye,{modelValue:_.value.presetQuestions[oe],"onUpdate:modelValue":he=>_.value.presetQuestions[oe]=he,class:"min-w-0 flex-1",size:"sm",disabled:l.readonly},null,8,["modelValue","onUpdate:modelValue","disabled"]),l.readonly?R("",!0):(n(),Y(X,{key:0,color:"error",variant:"ghost",icon:"i-heroicons-trash",size:"xs",class:"shrink-0",onClick:he=>A(oe)},null,8,["onClick"]))]))),128)),l.readonly?R("",!0):(n(),i("div",pc,[p(ye,{modelValue:L.value,"onUpdate:modelValue":F[4]||(F[4]=V=>L.value=V),placeholder:a(t)("ai.assistant.config.addQuestion"),class:"min-w-0 flex-1",size:"sm",onKeyup:Ge(B,["enter"])},null,8,["modelValue","placeholder"]),p(X,{color:"primary",variant:"soft",icon:"i-heroicons-plus",size:"xs",class:"shrink-0",onClick:B})]))])],512)],512),[[nt,M.value==="basic"]]),Ve(e("div",vc,[e("div",null,[e("h3",yc,o(a(t)("ai.assistant.config.coreTools")),1),e("p",hc,o(a(t)("ai.assistant.config.coreToolsHint")),1),e("div",fc,[(n(!0),i(Z,null,ce(I.value,V=>(n(),i("label",{key:V.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]=e("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)),e("div",xc,[e("div",bc,o(V.name),1),e("div",kc,o(V.description),1)])]))),128))])]),e("div",null,[e("div",_c,[e("h3",wc,o(a(t)("ai.assistant.config.analysisTools")),1),l.readonly?R("",!0):(n(),i("div",$c,[e("button",{class:"text-[10px] text-primary-500 hover:text-primary-600",onClick:H},o(a(t)("ai.assistant.config.selectAll")),1),F[7]||(F[7]=e("span",{class:"text-[10px] text-gray-300 dark:text-gray-600"},"|",-1)),e("button",{class:"text-[10px] text-primary-500 hover:text-primary-600",onClick:le},o(a(t)("ai.assistant.config.deselectAll")),1)]))]),e("p",Cc,o(a(t)("ai.assistant.config.analysisToolsHint")),1),e("div",Sc,[(n(!0),i(Z,null,ce(q.value,V=>(n(),i("label",{key:V.name,class:ne(["flex cursor-pointer items-start gap-2 rounded-md border px-2.5 py-2 transition-colors",T(V.name)?"border-primary-200 bg-primary-50/50 dark:border-primary-800 dark:bg-primary-950/20":"border-gray-200 dark:border-gray-700"])},[e("input",{type:"checkbox",checked:T(V.name),disabled:l.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:oe=>w(V.name)},null,40,Tc),e("div",Mc,[e("div",Ic,o(V.name),1),e("div",Lc,o(V.description),1)])],2))),128))])])],512),[[nt,M.value==="tools"]])]),e("div",Dc,[e("div",null,[!l.readonly&&!y.value&&v.value?.builtinId?(n(),Y(X,{key:0,variant:"outline",color:"warning",loading:m.value,onClick:P},{default:j(()=>[ee(o(a(t)("ai.assistant.config.resetDefault")),1)]),_:1},8,["loading"])):R("",!0)]),e("div",Ac,[p(X,{variant:"ghost",onClick:ve},{default:j(()=>[ee(o(l.readonly?a(t)("common.close"):a(t)("common.cancel")),1)]),_:1}),l.readonly?R("",!0):(n(),Y(X,{key:0,color:"primary",loading:m.value,onClick:S},{default:j(()=>[ee(o(y.value?a(t)("ai.assistant.config.create"):a(t)("common.save")),1)]),_:1},8,["loading"]))])])],64)):R("",!0)])]),_:1},8,["open"])}}}),zc={class:"p-6"},Rc={class:"mb-4 flex items-center justify-between"},Pc={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},Ec={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},Bc={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"},jc={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},Uc={class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},Fc={class:"min-w-0 flex-1"},Vc={class:"flex items-center gap-2"},Nc={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Oc={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"},Wc={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"},Hc={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},Yc={class:"flex shrink-0 items-center gap-1.5"},Kc=["title","onClick"],Qc=["title","onClick"],Gc=["title","onClick"],Jc={key:0,class:"py-12 text-center text-sm text-gray-400"},Xc={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},Zc={key:0,class:"py-12 text-center text-sm text-gray-400"},ed={key:1,class:"py-12 text-center"},td={class:"text-sm text-gray-500 dark:text-gray-400"},ad={key:2,class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},sd={class:"min-w-0 flex-1"},od={class:"flex items-center gap-2"},nd={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},rd={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"},ld={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"},id={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},cd={class:"flex shrink-0 items-center gap-2"},dd=["disabled","onClick"],ud={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},md=["disabled","onClick"],gd=["title","onClick"],pd={key:3,class:"py-12 text-center text-sm text-gray-400"},vd=pe({__name:"AssistantMarketModal",props:{open:{type:Boolean}},emits:["update:open","configure","view-config","create"],setup(l,{emit:s}){const{t,locale:c}=fe(),r=Je(),g=l,u=s,d=gt(),{assistants:m,cloudCatalogWithStatus:v,cloudLoading:y,cloudError:M}=et(d),$=f("local"),D=b(()=>{const w=c.value;return[...m.value].filter(T=>!T.supportedLocales?.length||T.supportedLocales.some(H=>w.startsWith(H))).sort((T,H)=>T.name.localeCompare(H.name))}),I=b(()=>[...v.value].sort((w,T)=>w.name.localeCompare(T.name))),q=f(new Set);ge(()=>[g.open,$.value],([w,T])=>{w&&T==="market"&&d.fetchCloudCatalog(c.value)},{immediate:!0});function _(w){return w==="general_cn"||w==="general_en"||w==="general_ja"}function L(w){u("configure",w)}async function x(w){_(w)||await d.deleteAssistant(w)}async function C(w){await d.duplicateAssistant(w)}function h(){u("create")}async function k(w){if(!q.value.has(w.id)){q.value=new Set([...q.value,w.id]);try{const T=await d.importFromCloud(w);T.success?r.success(t("ai.assistant.market.importSuccess")):r.fail(t("ai.assistant.market.importFailed"),{description:T.error})}finally{const T=new Set(q.value);T.delete(w.id),q.value=T}}}async function S(w){if(!q.value.has(w.id)){q.value=new Set([...q.value,w.id]);try{const T=await d.deleteAssistant(w.id);if(!T.success){r.fail(t("ai.assistant.market.importFailed"),{description:T.error});return}const H=await d.importFromCloud(w);H.success?r.success(t("ai.assistant.market.importSuccess")):r.fail(t("ai.assistant.market.importFailed"),{description:H.error})}finally{const T=new Set(q.value);T.delete(w.id),q.value=T}}}function P(w){u("view-config",w)}function B(){d.fetchCloudCatalog(c.value)}function A(w){return w?.length?w.map(H=>t(H==="group"?"ai.assistant.config.chatTypeGroup":"ai.assistant.config.chatTypePrivate")).join(" / "):null}return(w,T)=>{const H=we,le=He;return n(),Y(le,{open:l.open,ui:{content:"sm:max-w-xl z-50"},"onUpdate:open":T[3]||(T[3]=W=>u("update:open",W))},{content:j(()=>[e("div",zc,[e("div",Rc,[e("h2",Pc,o(a(t)("ai.assistant.market.title")),1),e("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:T[0]||(T[0]=W=>u("update:open",!1))},[p(H,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),e("div",Ec,[e("button",{class:ne(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",$.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:T[1]||(T[1]=W=>$.value="local")},[ee(o(a(t)("ai.assistant.market.tabs.local"))+" ",1),D.value.length?(n(),i("span",Bc,o(D.value.length),1)):R("",!0)],2),e("button",{class:ne(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",$.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:T[2]||(T[2]=W=>$.value="market")},o(a(t)("ai.assistant.market.tabs.market")),3)]),Ve(e("div",null,[e("p",jc,o(a(t)("ai.assistant.market.localHint")),1),e("div",Uc,[(n(!0),i(Z,null,ce(D.value,W=>(n(),i("div",{key:W.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"},[e("div",Fc,[e("div",Vc,[e("h3",Nc,o(W.name),1),A(W.applicableChatTypes)?(n(),i("span",Oc,o(A(W.applicableChatTypes)),1)):R("",!0),_(W.id)?(n(),i("span",Wc,o(a(t)("ai.assistant.market.default")),1)):R("",!0)]),e("p",Hc,o(W.systemPrompt),1)]),e("div",Yc,[e("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:a(t)("common.edit"),onClick:Be(ue=>L(W.id),["stop"])},[p(H,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})],8,Kc),e("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:a(t)("ai.assistant.market.duplicate"),onClick:Be(ue=>C(W.id),["stop"])},[p(H,{name:"i-heroicons-document-duplicate",class:"h-4 w-4"})],8,Qc),_(W.id)?R("",!0):(n(),i("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:a(t)("common.delete"),onClick:Be(ue=>x(W.id),["stop"])},[p(H,{name:"i-heroicons-trash",class:"h-4 w-4"})],8,Gc))])]))),128))]),e("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:h},[p(H,{name:"i-heroicons-plus",class:"h-4 w-4"}),ee(" "+o(a(t)("ai.assistant.market.addAssistant")),1)]),D.value.length===0?(n(),i("div",Jc,o(a(t)("ai.assistant.market.noLocal")),1)):R("",!0)],512),[[nt,$.value==="local"]]),Ve(e("div",null,[e("p",Xc,o(a(t)("ai.assistant.market.marketHint")),1),a(y)?(n(),i("div",Zc,o(a(t)("ai.assistant.market.loading")),1)):a(M)?(n(),i("div",ed,[e("p",td,o(a(t)("ai.assistant.market.loadFailed")),1),e("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},o(a(t)("ai.assistant.market.retry")),1)])):(n(),i("div",ad,[(n(!0),i(Z,null,ce(I.value,W=>(n(),i("div",{key:W.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"},[e("div",sd,[e("div",od,[e("h3",nd,o(W.name),1),A(W.applicableChatTypes)?(n(),i("span",rd,o(A(W.applicableChatTypes)),1)):R("",!0),_(W.id)?(n(),i("span",ld,o(a(t)("ai.assistant.market.default")),1)):R("",!0)]),e("p",id,o(W.description),1)]),e("div",cd,[W.imported?(n(),i(Z,{key:1},[e("span",ud,o(a(t)("ai.assistant.market.imported")),1),e("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:q.value.has(W.id),onClick:ue=>S(W)},o(q.value.has(W.id)?a(t)("ai.assistant.market.importing"):a(t)("ai.assistant.market.reimport")),9,md)],64)):(n(),i("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:q.value.has(W.id),onClick:ue=>k(W)},o(q.value.has(W.id)?a(t)("ai.assistant.market.importing"):a(t)("ai.assistant.market.import")),9,dd)),W.imported?(n(),i("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:a(t)("ai.assistant.market.viewConfig"),onClick:Be(ue=>P(W.id),["stop"])},[p(H,{name:"i-heroicons-eye",class:"h-4 w-4"})],8,gd)):R("",!0)])]))),128))])),!a(y)&&!a(M)&&I.value.length===0?(n(),i("div",pd,o(a(t)("ai.assistant.market.noCatalog")),1)):R("",!0)],512),[[nt,$.value==="market"]])])]),_:1},8,["open"])}}}),yd={class:"p-6"},hd={class:"mb-4 flex items-center justify-between"},fd={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},xd={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},bd={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"},kd={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},_d={class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},wd={class:"min-w-0 flex-1"},$d={class:"flex items-center gap-2"},Cd={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Sd={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"},Td={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},Md={key:0,class:"mt-1.5 flex flex-wrap gap-1"},Id={class:"flex shrink-0 items-center gap-1.5"},Ld=["title","onClick"],Dd=["title","onClick"],Ad={key:0,class:"py-12 text-center text-sm text-gray-400"},qd={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},zd={key:0,class:"py-12 text-center text-sm text-gray-400"},Rd={key:1,class:"py-12 text-center"},Pd={class:"text-sm text-gray-500 dark:text-gray-400"},Ed={key:2,class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},Bd={class:"min-w-0 flex-1"},jd={class:"flex items-center gap-2"},Ud={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Fd={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"},Vd={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},Nd={key:0,class:"mt-1.5 flex flex-wrap gap-1"},Od={class:"flex shrink-0 items-center gap-2"},Wd=["disabled","onClick"],Hd={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},Yd=["disabled","onClick"],Kd={key:3,class:"py-12 text-center text-sm text-gray-400"},Qd=pe({__name:"SkillMarketModal",props:{open:{type:Boolean}},emits:["update:open","configure","create"],setup(l,{emit:s}){const{t,locale:c}=fe(),r=Je(),g=l,u=s,d=dt(),{skills:m,cloudCatalogWithStatus:v,cloudLoading:y,cloudError:M}=et(d),$=f("local"),D=f(new Set);je(()=>{d.setFilterContext("group",c.value)}),ge(()=>[g.open,$.value],([P,B])=>{P&&B==="market"&&(d.setFilterContext("group",c.value),d.fetchCloudCatalog())},{immediate:!0});const I=b(()=>[...m.value].sort((P,B)=>P.name.localeCompare(B.name))),q=b(()=>[...v.value].sort((P,B)=>P.name.localeCompare(B.name)));function _(P){return t(P==="group"?"ai.skill.config.chatScopeGroup":P==="private"?"ai.skill.config.chatScopePrivate":"ai.skill.config.chatScopeAll")}function L(P){u("configure",P)}async function x(P){await d.deleteSkill(P)}function C(){u("create")}async function h(P){if(!D.value.has(P.id)){D.value=new Set([...D.value,P.id]);try{const B=await d.importFromCloud(P);B.success?r.success(t("ai.skill.market.importSuccess")):r.fail(t("ai.skill.market.importFailed"),{description:B.error})}finally{const B=new Set(D.value);B.delete(P.id),D.value=B}}}async function k(P){if(!D.value.has(P.id)){D.value=new Set([...D.value,P.id]);try{const B=await d.deleteSkill(P.id);if(!B.success){r.fail(t("ai.skill.market.importFailed"),{description:B.error});return}const A=await d.importFromCloud(P);A.success?r.success(t("ai.skill.market.importSuccess")):r.fail(t("ai.skill.market.importFailed"),{description:A.error})}finally{const B=new Set(D.value);B.delete(P.id),D.value=B}}}function S(){d.fetchCloudCatalog()}return(P,B)=>{const A=we,w=He;return n(),Y(w,{open:l.open,ui:{content:"sm:max-w-xl z-50"},"onUpdate:open":B[3]||(B[3]=T=>u("update:open",T))},{content:j(()=>[e("div",yd,[e("div",hd,[e("h2",fd,o(a(t)("ai.skill.market.title")),1),e("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:B[0]||(B[0]=T=>u("update:open",!1))},[p(A,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),e("div",xd,[e("button",{class:ne(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",$.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:B[1]||(B[1]=T=>$.value="local")},[ee(o(a(t)("ai.skill.market.tabs.local"))+" ",1),a(m).length?(n(),i("span",bd,o(a(m).length),1)):R("",!0)],2),e("button",{class:ne(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",$.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:B[2]||(B[2]=T=>$.value="market")},o(a(t)("ai.skill.market.tabs.market")),3)]),Ve(e("div",null,[e("p",kd,o(a(t)("ai.skill.market.localHint")),1),e("div",_d,[(n(!0),i(Z,null,ce(I.value,T=>(n(),i("div",{key:T.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"},[e("div",wd,[e("div",$d,[e("h3",Cd,o(T.name),1),e("span",Sd,o(_(T.chatScope)),1)]),e("p",Td,o(T.description),1),T.tags.length?(n(),i("div",Md,[(n(!0),i(Z,null,ce(T.tags,H=>(n(),i("span",{key:H,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"},o(H),1))),128))])):R("",!0)]),e("div",Id,[e("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:a(t)("common.edit"),onClick:Be(H=>L(T.id),["stop"])},[p(A,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})],8,Ld),e("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:a(t)("common.delete"),onClick:Be(H=>x(T.id),["stop"])},[p(A,{name:"i-heroicons-trash",class:"h-4 w-4"})],8,Dd)])]))),128))]),e("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},[p(A,{name:"i-heroicons-plus",class:"h-4 w-4"}),ee(" "+o(a(t)("ai.skill.market.addSkill")),1)]),I.value.length===0?(n(),i("div",Ad,o(a(t)("ai.skill.market.noLocal")),1)):R("",!0)],512),[[nt,$.value==="local"]]),Ve(e("div",null,[e("p",qd,o(a(t)("ai.skill.market.marketHint")),1),a(y)?(n(),i("div",zd,o(a(t)("ai.skill.market.loading")),1)):a(M)?(n(),i("div",Rd,[e("p",Pd,o(a(t)("ai.skill.market.loadFailed")),1),e("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:S},o(a(t)("ai.skill.market.retry")),1)])):(n(),i("div",Ed,[(n(!0),i(Z,null,ce(q.value,T=>(n(),i("div",{key:T.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"},[e("div",Bd,[e("div",jd,[e("h3",Ud,o(T.name),1),e("span",Fd,o(_(T.chatScope)),1)]),e("p",Vd,o(T.description),1),T.tags?.length?(n(),i("div",Nd,[(n(!0),i(Z,null,ce(T.tags,H=>(n(),i("span",{key:H,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"},o(H),1))),128))])):R("",!0)]),e("div",Od,[T.imported?(n(),i(Z,{key:1},[e("span",Hd,o(a(t)("ai.skill.market.imported")),1),e("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:D.value.has(T.id),onClick:H=>k(T)},o(D.value.has(T.id)?a(t)("ai.skill.market.importing"):a(t)("ai.skill.market.reimport")),9,Yd)],64)):(n(),i("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:D.value.has(T.id),onClick:H=>h(T)},o(D.value.has(T.id)?a(t)("ai.skill.market.importing"):a(t)("ai.skill.market.import")),9,Wd))])]))),128))])),!a(y)&&!a(M)&&q.value.length===0?(n(),i("div",Kd,o(a(t)("ai.skill.market.noCatalog")),1)):R("",!0)],512),[[nt,$.value==="market"]])])]),_:1},8,["open"])}}}),Gd={class:"p-6"},Jd={class:"mb-4 flex items-center justify-between"},Xd={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},Zd={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},eu={key:0,class:"flex h-64 items-center justify-center text-gray-400"},tu={class:"mt-4 flex justify-end gap-2"},au=["disabled"],su=`---
39
+ name: ""
40
+ description: ""
41
+ tags: []
42
+ chatScope: all
43
+ tools: []
44
+ ---
45
+
46
+ `,ou=pe({__name:"SkillConfigModal",props:{open:{type:Boolean},skillId:{}},emits:["update:open","saved","created"],setup(l,{emit:s}){const{t}=fe(),c=l,r=s,g=dt(),u=f(""),d=f(!1),m=f(!1),v=f(!1);ge(()=>[c.open,c.skillId],async([M,$])=>{if(M){if(!$){v.value=!0,u.value=su;return}v.value=!1,d.value=!0;try{const D=await g.getSkillConfig($);if(D){const I=["---",`name: "${D.name}"`,`description: "${D.description}"`,`tags: [${D.tags.map(q=>`"${q}"`).join(", ")}]`,`chatScope: ${D.chatScope}`,D.tools.length?`tools: [${D.tools.map(q=>`"${q}"`).join(", ")}]`:"tools: []",D.builtinId?`builtinId: ${D.builtinId}`:"","---","",D.prompt].filter(Boolean).join(`
47
+ `);u.value=I}}finally{d.value=!1}}},{immediate:!0});async function y(){if(u.value.trim()){m.value=!0;try{if(v.value){const M=await g.createSkill(u.value);M.success&&M.id&&(r("created",M.id),r("update:open",!1))}else c.skillId&&(await g.updateSkill(c.skillId,u.value)).success&&(r("saved"),r("update:open",!1))}finally{m.value=!1}}}return(M,$)=>{const D=we,I=He;return n(),Y(I,{open:l.open,ui:{content:"sm:max-w-2xl z-50"},"onUpdate:open":$[3]||($[3]=q=>r("update:open",q))},{content:j(()=>[e("div",Gd,[e("div",Jd,[e("h2",Xd,o(v.value?a(t)("ai.skill.config.createTitle"):a(t)("ai.skill.config.editTitle")),1),e("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:$[0]||($[0]=q=>r("update:open",!1))},[p(D,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),e("p",Zd,o(a(t)("ai.skill.config.rawEditorHint")),1),d.value?(n(),i("div",eu,[p(D,{name:"i-heroicons-arrow-path",class:"mr-2 h-5 w-5 animate-spin"})])):Ve((n(),i("textarea",{key:1,"onUpdate:modelValue":$[1]||($[1]=q=>u.value=q),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)),[[ot,u.value]]),e("div",tu,[e("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:$[2]||($[2]=q=>r("update:open",!1))},o(a(t)("common.cancel")),1),e("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||!u.value.trim(),onClick:y},o(v.value?a(t)("ai.skill.config.create"):a(t)("ai.skill.config.save")),9,au)])])]),_:1},8,["open"])}}}),nu={key:0,class:"relative"},ru={class:"relative flex flex-nowrap gap-2"},lu=["disabled"],iu=["disabled"],cu={class:"inline-flex items-center gap-1"},du={key:0,class:"absolute left-0 bottom-full z-20 mb-2 w-[320px] max-w-[calc(100vw-3rem)]"},uu={class:"mb-1.5 flex justify-start"},mu={class:"flex flex-wrap gap-2"},gu=["disabled","onClick"],At="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",pu=pe({__name:"PresetQuestions",props:{questions:{},disabled:{type:Boolean},leadingActionLabel:{}},emits:["select","leadingAction","editQuestions"],setup(l,{emit:s}){const{t}=fe(),c=l,r=s,g=f(!1);let u=null;function d(M){g.value=!1,r("select",M)}function m(){c.disabled||c.questions.length===0||(u&&(clearTimeout(u),u=null),g.value=!0)}function v(){u=setTimeout(()=>{g.value=!1},150)}function y(){g.value=!1,r("editQuestions")}return kt(()=>{u&&clearTimeout(u)}),(M,$)=>{const D=we;return l.leadingActionLabel||l.questions.length>0?(n(),i("div",nu,[e("div",ru,[l.leadingActionLabel?(n(),i("button",{key:0,class:ne(At),disabled:c.disabled,onClick:$[0]||($[0]=I=>r("leadingAction"))},o(l.leadingActionLabel),9,lu)):R("",!0),l.questions.length>0?(n(),i("div",{key:1,class:"relative shrink-0",onMouseenter:m,onMouseleave:v},[e("button",{class:ne([At,g.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:c.disabled},[e("span",cu,[p(D,{name:"i-heroicons-chat-bubble-left-ellipsis",class:"h-3.5 w-3.5"}),ee(" "+o(a(t)("ai.chat.input.quickAsk")),1)])],10,iu),p(rt,{"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:j(()=>[g.value?(n(),i("div",du,[e("div",uu,[e("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:y},[p(D,{name:"i-heroicons-pencil-square",class:"h-3 w-3"}),ee(" "+o(a(t)("ai.chat.input.editQuickAsk")),1)])]),e("div",mu,[(n(!0),i(Z,null,ce(l.questions,(I,q)=>(n(),i("button",{key:q,class:ne(At),disabled:c.disabled,onClick:_=>d(I)},o(I),9,gu))),128))])])):R("",!0)]),_:1})],32)):R("",!0)])])):R("",!0)}}}),vu=30;function yu(l,s){const t=f(null),c=f(!0),r=f(!1);function g(v=!1){setTimeout(()=>{t.value&&(v||c.value)&&(t.value.scrollTop=t.value.scrollHeight,c.value=!0,r.value=!1)},100)}function u(v){v.deltaY<0&&s.value&&(c.value=!1,r.value=!0)}function d(){if(!t.value)return;const{scrollTop:v,scrollHeight:y,clientHeight:M}=t.value;y-v-M<vu&&(c.value=!0,r.value=!1)}function m(){g(!0)}return ge(()=>{const v=l.value[l.value.length-1];return[l.value.length,v?.content,v?.contentBlocks?.length]},()=>g()),je(()=>{t.value&&(t.value.addEventListener("scroll",d),t.value.addEventListener("wheel",u,{passive:!0})),l.value.length>0&&g(!0)}),kt(()=>{t.value&&(t.value.removeEventListener("scroll",d),t.value.removeEventListener("wheel",u))}),{messagesContainer:t,showScrollToBottom:r,scrollToBottom:g,handleScrollToBottom:m}}function hu(){const l=gt(),s=dt(),t=f(!1),c=f(null),r=f(!1),g=f(!1),u=f(!1),d=f(!1),m=f(null);function v(k){c.value=k,r.value=!1,t.value=!0}function y(){g.value=!0}function M(k){c.value=k,r.value=!1,t.value=!0}function $(k){c.value=k,r.value=!0,t.value=!0}function D(){c.value=null,r.value=!1,t.value=!0}async function I(k){await l.loadAssistants(),await l.loadBuiltinCatalog()}async function q(){await l.loadAssistants()}function _(){u.value=!0}function L(k){m.value=k,d.value=!0}function x(){m.value=null,d.value=!0}async function C(){await s.loadSkills()}async function h(k){await s.loadSkills(),await s.loadBuiltinCatalog()}return{configModalVisible:t,configModalAssistantId:c,configModalReadonly:r,marketModalVisible:g,handleConfigureAssistant:v,handleOpenMarket:y,handleMarketConfigure:M,handleMarketViewConfig:$,handleCreateAssistant:D,handleAssistantCreated:I,handleAssistantConfigSaved:q,skillMarketModalVisible:u,skillConfigModalVisible:d,skillConfigModalSkillId:m,handleOpenSkillMarket:_,handleSkillMarketConfigure:L,handleCreateSkill:x,handleSkillConfigSaved:C,handleSkillCreated:h}}function fu(l){const s=[];let t=null;for(const c of l)c.role==="user"?(t&&s.push({user:t,assistant:null,standalone:null,id:t.id}),t=c):c.role==="assistant"?(s.push({user:t,assistant:c,standalone:null,id:t?.id||c.id}),t=null):(t&&(s.push({user:t,assistant:null,standalone:null,id:t.id}),t=null),s.push({user:null,assistant:null,standalone:c,id:c.id}));return t&&s.push({user:t,assistant:null,standalone:null,id:t.id}),s}const xu={class:"main-content flex h-full overflow-hidden"},bu={class:"flex h-full flex-1 overflow-hidden"},ku={class:"flex h-full flex-1"},_u={class:"relative flex min-w-[480px] flex-1 flex-col overflow-hidden"},wu={key:0,class:"flex items-center gap-1.5 px-3 py-1.5"},$u=["disabled"],Cu={key:0,class:"flex w-full flex-col items-center justify-center animate-fade-in"},Su={key:0,class:"mb-3 text-center text-2xl font-semibold tracking-tight text-gray-800 dark:text-gray-100"},Tu={class:"text-primary-600 dark:text-primary-400"},Mu={key:1,class:"relative mb-8 w-full max-w-lg"},Iu={class:"flex w-full justify-center"},Lu={key:1,class:"qa-pair space-y-6 pb-4"},Du={key:1,class:"px-4 pb-2"},Au={class:"mx-auto max-w-[740px]"},qu={class:"px-4 pb-2"},zu={class:"mx-auto max-w-[740px]"},Ru={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"},Pu=pe({__name:"ChatExplorer",props:{sessionId:{},sessionName:{},timeFilter:{},chatType:{}},setup(l,{expose:s}){const{t}=fe(),c=Je(),r=Nt(),g=gt(),u=dt(),d=l,{messages:m,sourceMessages:v,currentKeywords:y,isLoadingSource:M,isAIThinking:$,currentAIChatId:D,currentToolStatus:I,toolsUsedInCurrentRound:q,sessionTokenUsage:_,agentStatus:L,selectedAssistantId:x,sendMessage:C,editMessageAndRegenerate:h,loadAIChat:k,startNewAIChat:S,loadMoreSourceMessages:P,updateMaxMessages:B,stopGeneration:A,selectAssistantForSession:w}=os(d.sessionId,d.sessionName,d.timeFilter,d.chatType??"group",r.locale),T=yu(m,$),{showScrollToBottom:H,scrollToBottom:le,handleScrollToBottom:W}=T,{configModalVisible:ue,configModalAssistantId:ve,configModalReadonly:G,marketModalVisible:F,skillMarketModalVisible:X,skillConfigModalVisible:me,skillConfigModalSkillId:ye,handleConfigureAssistant:K,handleOpenMarket:E,handleMarketConfigure:V,handleMarketViewConfig:oe,handleCreateAssistant:he,handleAssistantCreated:ke,handleAssistantConfigSaved:be,handleOpenSkillMarket:ae,handleSkillMarketConfigure:se,handleCreateSkill:xe,handleSkillConfigSaved:de,handleSkillCreated:_e}=hu(),Ie=xt(),Le=f(0);ge(()=>D.value,async Ce=>{if(!Ce){Le.value=0;return}try{const Te=await Fe().estimateContextTokens(Ce);Te.success&&(Le.value=Te.tokens)}catch{Le.value=0}},{immediate:!0});const Se=b(()=>g.selectedAssistant?.presetQuestions??[]),qe=b(()=>d.chatType??"group"),Re=f(!1),Ee=f(!1),ie=f(!0),z=f(void 0),O=f(null),J=f(null),N=b(()=>fu(m.value));async function U(){ie.value=!0;try{Ee.value=await Ot().hasConfig()}catch(Ce){console.error("检查 LLM 配置失败:",Ce),Ee.value=!1}finally{ie.value=!1}}async function re(){await U(),Ee.value&&await B()}s({refreshConfig:re});const Q=b(()=>{const Ce=g.selectedAssistant;if(!Ce)return{name:"",preview:""};const Te=Ce.systemPrompt.replace(/#{1,6}\s+[^\n]*/g,"").replace(/\n+/g," ").replace(/\s+/g," ").trim();return{name:Ce.name,preview:Te}}),te=b(()=>!!x.value&&m.value.length===0&&!$.value);function Pe(){c.warn(t("ai.chat.backgroundTask.runningTitle"),{description:t("ai.chat.backgroundTask.runningDescription")})}function De(){c.warn(t("ai.chat.backgroundTask.blockedAction"))}function Ye(Ce){if(Ce!==x.value){if(!w(Ce)){De();return}u.activateSkill(null),S()}}async function va(Ce){const Te=await C(Ce);!Te.success&&Te.reason==="busy"&&Pe()}function ya(){const Ce=g.selectedAssistant?.id;Ce&&(z.value="presetQuestions",K(Ce))}function ha(Ce){ue.value=Ce,Ce||(z.value=void 0)}function fa(){J.value?.openSkillSelector()}function xa(){le(!0)}async function ba(Ce){const Te=await C(Ce.content,{mentionedMembers:Ce.mentionedMembers});if(!Te.success){Te.reason==="busy"&&Pe();return}le(!0),O.value?.refresh()}async function ka(Ce){const Te=await h(Ce.messageId,Ce.content,{overwriteSubsequent:Ce.overwriteSubsequent});if(!Te.success){Te.reason==="busy"&&Pe();return}le(!0),O.value?.refresh()}async function _a(Ce){if(D.value)try{const Te=await Fe().forkAIChat(D.value,Ce);await k(Te.id),O.value?.refresh(),le(!0),c.success(t("ai.chat.fork.success"))}catch(Te){c.fail(t("ai.chat.fork.failed"),{description:String(Te)})}}function wa(){Re.value=!Re.value}async function $a(){await P()}async function Ca(Ce){await k(Ce),le(!0)}function Sa(){if($.value){De();return}S()}function Ta(Ce){D.value===Ce&&S()}function Ma(){A()}return U(),B(),ge(()=>Ie.aiConfigVersion,async()=>{await re()}),(Ce,Te)=>{const It=we,Ia=pt;return n(),i("div",xu,[p(Xs,{ref_key:"conversationListRef",ref:O,"session-id":l.sessionId,"active-id":a(D),disabled:a($),onSelect:Ca,onCreate:Sa,onDelete:Ta},null,8,["session-id","active-id","disabled"]),e("div",bu,[e("div",ku,[e("div",_u,[a(m).length>0||a($)?(n(),i("div",wu,[e("button",{class:ne(["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":a($)||!a(g).selectedAssistant?.id}]),disabled:a($)||!a(g).selectedAssistant?.id,onClick:Te[0]||(Te[0]=$e=>a(K)(a(g).selectedAssistant.id))},[p(It,{name:"i-heroicons-sparkles",class:"h-3.5 w-3.5"}),e("span",null,o(a(g).selectedAssistant?.name||a(t)("ai.assistant.fallbackName")),1)],10,$u)])):R("",!0),e("div",{ref:a(T).messagesContainer,class:ne(["relative min-h-0 flex-1 overflow-x-hidden overflow-y-auto p-4",{"p-0!":a(m).length===0&&!a($)}])},[e("div",{class:ne(["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!":a(m).length===0&&!a($),"px-4":a(m).length>0||a($)}])},[a(m).length===0&&!a($)?(n(),i("div",Cu,[Q.value.name?(n(),i("h2",Su,[ee(o(a(t)("ai.assistant.selector.heroTitlePrefix","使用"))+" ",1),e("span",Tu,o(Q.value.name),1),ee(" "+o(a(t)("ai.assistant.selector.heroTitleSuffix","开始对话")),1)])):R("",!0),te.value&&Q.value.name?(n(),i("div",Mu,[e("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:Te[1]||(Te[1]=$e=>a(K)(a(g).selectedAssistant.id))},[p(Ia,{text:a(t)("ai.assistant.config.systemPrompt","系统设定"),popper:{placement:"top"}},{default:j(()=>[ee(o(Q.value.preview),1)]),_:1},8,["text"])]),e("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:Te[2]||(Te[2]=Be($e=>a(K)(a(g).selectedAssistant.id),["stop"]))},[p(It,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})])])):R("",!0),e("div",Iu,[p(Hi,{"chat-type":qe.value,locale:a(r).locale,"selected-id":a(x),onSelect:Ye,onMarket:a(E)},null,8,["chat-type","locale","selected-id","onMarket"])])])):R("",!0),(n(!0),i(Z,null,ce(N.value,$e=>(n(),i(Z,{key:$e.id},[$e.standalone?(n(),Y(Dt,{key:0,role:$e.standalone.role,content:$e.standalone.content,timestamp:$e.standalone.timestamp},null,8,["role","content","timestamp"])):(n(),i("div",Lu,[$e.user&&($e.user.role==="user"||$e.user.content)?(n(),Y(Dt,{key:0,role:$e.user.role,"message-id":$e.user.id,content:$e.user.content,timestamp:$e.user.timestamp,"is-streaming":$e.user.isStreaming,"content-blocks":$e.user.contentBlocks,editable:!a($),onEdit:ka},null,8,["role","message-id","content","timestamp","is-streaming","content-blocks","editable"])):R("",!0),$e.assistant&&($e.assistant.content||$e.assistant.contentBlocks&&$e.assistant.contentBlocks.length>0)?(n(),Y(Dt,{key:1,role:$e.assistant.role,"message-id":$e.assistant.id,content:$e.assistant.content,timestamp:$e.assistant.timestamp,"is-streaming":$e.assistant.isStreaming,"content-blocks":$e.assistant.contentBlocks,"show-capture-button":!$e.assistant.isStreaming,onFork:_a},null,8,["role","message-id","content","timestamp","is-streaming","content-blocks","show-capture-button"])):R("",!0)]))],64))),128)),a($)&&!a(m)[a(m).length-1]?.content&&!(a(m)[a(m).length-1]?.contentBlocks?.length??0)?(n(),Y(fi,{key:1,"current-tool-status":a(I),"tools-used":a(q),"agent-status":a(L)},null,8,["current-tool-status","tools-used","agent-status"])):R("",!0)],2)],2),p(rt,{name:"fade-up"},{default:j(()=>[a(H)?(n(),i("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:Te[3]||(Te[3]=(...$e)=>a(W)&&a(W)(...$e))},[p(It,{name:"i-heroicons-arrow-down",class:"h-3.5 w-3.5"}),e("span",null,o(a(t)("ai.chat.scrollToBottom")),1)])):R("",!0)]),_:1}),a(m).length===0&&!a($)?(n(),i("div",Du,[e("div",Au,[p(pu,{questions:Se.value,"leading-action-label":a(t)("ai.chat.input.useSkill"),onSelect:va,onLeadingAction:fa,onEditQuestions:ya},null,8,["questions","leading-action-label"])])])):R("",!0),e("div",qu,[e("div",zu,[p(oi,{ref_key:"chatInputRef",ref:J,"session-id":l.sessionId,disabled:a($),status:a($)?"streaming":"ready","chat-type":qe.value,onSend:ba,onStop:Ma,onManageSkills:a(ae),onSkillActivated:xa},null,8,["session-id","disabled","status","chat-type","onManageSkills"]),p(Bi,{"session-token-usage":a(_),"agent-status":a(L),"current-ai-chat-id":a(D),"current-messages":a(m),"fallback-title":l.sessionName,"estimated-context-tokens":Le.value},null,8,["session-token-usage","agent-status","current-ai-chat-id","current-messages","fallback-title","estimated-context-tokens"])])])])]),p(rt,{name:"slide-fade"},{default:j(()=>[a(v).length>0&&!Re.value?(n(),i("div",Ru,[p(_o,{messages:a(v),keywords:a(y),"is-loading":a(M),"is-collapsed":Re.value,class:"h-full",onToggle:wa,onLoadMore:$a},null,8,["messages","keywords","is-loading","is-collapsed"])])):R("",!0)]),_:1})]),p(qc,{open:a(ue),"assistant-id":a(ve),readonly:a(G),"scroll-to-section":z.value,"onUpdate:open":ha,onSaved:a(be),onCreated:a(ke)},null,8,["open","assistant-id","readonly","scroll-to-section","onSaved","onCreated"]),p(vd,{open:a(F),"onUpdate:open":Te[4]||(Te[4]=$e=>F.value=$e),onConfigure:a(V),onViewConfig:a(oe),onCreate:a(he)},null,8,["open","onConfigure","onViewConfig","onCreate"]),p(Qd,{open:a(X),"onUpdate:open":Te[5]||(Te[5]=$e=>X.value=$e),onConfigure:a(se),onCreate:a(xe)},null,8,["open","onConfigure","onCreate"]),p(ou,{open:a(me),"skill-id":a(ye),"onUpdate:open":Te[6]||(Te[6]=$e=>me.value=$e),onSaved:a(de),onCreated:a(_e)},null,8,["open","skill-id","onSaved","onCreated"])])}}}),Eu=lt(Pu,[["__scopeId","data-v-f07ad687"]]),Bu={"zh-CN":{message:"消息记录",member:"成员",meta:"群信息",member_name_history:"昵称历史"},"en-US":{message:"Messages",member:"Members",meta:"Chat Info",member_name_history:"Nickname History"}},Ft={"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 Vt(l,s="zh-CN"){return Bu[ma(s)]?.[l]||l}function Gt(l,s,t="zh-CN"){return Ft[ma(t)]?.[l]?.[s]||s}function ma(l){return l.startsWith("zh")?"zh-CN":"en-US"}const ju={key:0,class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Uu={key:0,class:"flex-1 overflow-y-auto p-2"},Fu=["onClick"],Vu={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Nu={class:"flex-1 truncate text-right text-xs text-gray-400"},Ou={key:0,class:"ml-4 mt-1 space-y-0.5"},Wu=["title","onDblclick"],Hu={class:"font-mono text-gray-700 dark:text-gray-300"},Yu={class:"flex-1 truncate text-right text-[10px] text-gray-400"},Ku={key:1,class:"flex flex-1 flex-col items-center gap-1 overflow-y-auto px-2 pb-2"},Qu=["title","onClick"],Gu=pe({__name:"SchemaPanel",props:{sessionId:{}},emits:["insertColumn"],setup(l,{expose:s,emit:t}){const{t:c,locale:r}=fe(),g=l,u=t,d=f(!1),m=f([]),v=f(new Set);async function y(){try{m.value=await Ne().getSchema(g.sessionId),m.value.forEach(I=>v.value.add(I.name))}catch(I){console.error("加载 Schema 失败:",I)}}function M(I){v.value.has(I)?v.value.delete(I):v.value.add(I)}function $(I){d.value=!1,v.value.add(I)}function D(I,q){u("insertColumn",I,q)}return s({loadSchema:y,schema:m}),je(()=>{y()}),(I,q)=>{const _=we,L=ze;return n(),i("div",{class:ne(["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",d.value?"w-14":"w-56"])},[e("div",{class:ne(["flex items-center",d.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"])},[d.value?R("",!0):(n(),i("span",ju,o(a(c)("ai.sqlLab.schema.tables")),1)),d.value?(n(),i("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:q[1]||(q[1]=x=>d.value=!d.value)},[p(_,{name:"i-lucide-panel-right-open",class:"size-4 scale-x-[-1]"})])):(n(),Y(L,{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:q[0]||(q[0]=x=>d.value=!d.value)},{default:j(()=>[p(_,{name:"i-lucide-panel-right",class:"size-4 scale-x-[-1] group-hover:hidden"}),p(_,{name:"i-lucide-panel-right-close",class:"size-4 hidden scale-x-[-1] group-hover:block"})]),_:1}))],2),d.value?(n(),i("div",Ku,[(n(!0),i(Z,null,ce(m.value,x=>(n(),i("button",{key:x.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:`${a(Vt)(x.name,a(r))} (${x.name})`,onClick:C=>$(x.name)},[p(_,{name:"i-heroicons-table-cells",class:"h-5 w-5"})],8,Qu))),128))])):(n(),i("div",Uu,[(n(!0),i(Z,null,ce(m.value,x=>(n(),i("div",{key:x.name,class:"mb-2"},[e("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=>M(x.name)},[p(_,{name:v.value.has(x.name)?"i-heroicons-chevron-down":"i-heroicons-chevron-right",class:"h-3 w-3 shrink-0 text-gray-400"},null,8,["name"]),p(_,{name:"i-heroicons-table-cells",class:"h-4 w-4 shrink-0 text-pink-500"}),e("span",Vu,o(x.name),1),e("span",Nu,o(a(Vt)(x.name,a(r))),1)],8,Fu),v.value.has(x.name)?(n(),i("div",Ou,[(n(!0),i(Z,null,ce(x.columns,C=>(n(),i("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:a(c)("ai.sqlLab.schema.doubleClickToInsert"),onDblclick:h=>D(x.name,C.name)},[C.pk?(n(),Y(_,{key:0,name:"i-heroicons-key",class:"h-3 w-3 shrink-0 text-yellow-500",title:a(c)("ai.sqlLab.schema.primaryKey")},null,8,["title"])):R("",!0),e("span",Hu,o(C.name),1),e("span",Yu,o(a(Gt)(x.name,C.name,a(r))),1)],40,Wu))),128))])):R("",!0)]))),128))]))],2)}}}),Ju={class:"max-h-[70vh] overflow-hidden p-6"},Xu={class:"mb-4 flex items-center gap-2"},Zu={class:"text-lg font-semibold text-gray-900 dark:text-white"},e0={key:0,class:"max-h-[50vh] space-y-3 overflow-y-auto pr-2"},t0={class:"mb-2 flex items-start justify-between gap-2"},a0={class:"flex-1 text-sm font-medium text-gray-700 dark:text-gray-300"},s0={class:"shrink-0 text-xs text-gray-400"},o0={class:"mb-2 rounded bg-white p-2 dark:bg-gray-800"},n0={class:"whitespace-pre-wrap break-all font-mono text-xs text-gray-600 dark:text-gray-400"},r0={key:0,class:"mb-2 text-xs text-gray-500 dark:text-gray-400"},l0={class:"flex justify-end gap-2"},i0={key:1,class:"py-8 text-center text-gray-500 dark:text-gray-400"},c0={class:"text-sm"},d0={class:"mt-4 flex justify-end"},u0=pe({__name:"AIHistoryModal",props:{open:{type:Boolean},history:{}},emits:["update:open","execute","delete"],setup(l,{emit:s}){const{t}=fe(),c=s;function r(g){const u=new Date(g),d=new Date,m=d.getTime()-g;return m<6e4?t("ai.sqlLab.history.justNow"):m<36e5?t("ai.sqlLab.history.minutesAgo",{count:Math.floor(m/6e4)}):m<864e5?t("ai.sqlLab.history.hoursAgo",{count:Math.floor(m/36e5)}):u.toDateString()===d.toDateString()?t("ai.sqlLab.history.today"):`${u.getMonth()+1}/${u.getDate()}`}return(g,u)=>{const d=we,m=ze,v=He;return n(),Y(v,{open:l.open,ui:{content:"max-w-5xl"},"onUpdate:open":u[1]||(u[1]=y=>c("update:open",y))},{content:j(()=>[e("div",Ju,[e("div",Xu,[p(d,{name:"i-heroicons-clock",class:"h-5 w-5 text-pink-500"}),e("h3",Zu,o(a(t)("ai.sqlLab.history.title")),1)]),l.history.length>0?(n(),i("div",e0,[(n(!0),i(Z,null,ce(l.history,y=>(n(),i("div",{key:y.id,class:"rounded-lg border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-page-dark"},[e("div",t0,[e("p",a0,o(y.prompt),1),e("span",s0,o(r(y.timestamp)),1)]),e("div",o0,[e("pre",n0,o(y.sql),1)]),y.explanation?(n(),i("p",r0,o(y.explanation),1)):R("",!0),e("div",l0,[p(m,{variant:"ghost",size:"xs",color:"error",onClick:M=>c("delete",y.id)},{default:j(()=>[p(d,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"})]),_:1},8,["onClick"]),p(m,{size:"xs",onClick:M=>c("execute",y)},{default:j(()=>[p(d,{name:"i-heroicons-play",class:"mr-1 h-3.5 w-3.5"}),ee(" "+o(a(t)("ai.sqlLab.history.execute")),1)]),_:1},8,["onClick"])])]))),128))])):(n(),i("div",i0,[p(d,{name:"i-heroicons-clock",class:"mx-auto mb-2 h-8 w-8 text-gray-300 dark:text-gray-600"}),e("p",c0,o(a(t)("ai.sqlLab.history.empty")),1)])),e("div",d0,[p(m,{variant:"ghost",onClick:u[0]||(u[0]=y=>c("update:open",!1))},{default:j(()=>[ee(o(a(t)("common.close")),1)]),_:1})])])]),_:1},8,["open"])}}}),m0={class:"flex flex-1 flex-col overflow-hidden"},g0={key:0,class:"border-b border-red-200 bg-red-50 p-4 dark:border-red-900 dark:bg-red-950"},p0={class:"flex items-start gap-2"},v0={class:"min-w-0 flex-1"},y0={class:"text-sm font-medium text-red-800 dark:text-red-200"},h0={class:"mt-1 break-all font-mono text-xs text-red-600 dark:text-red-400"},f0={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"},x0={class:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400"},b0={class:"flex cursor-pointer items-center gap-1.5"},k0={class:"text-xs"},_0={class:"flex items-center gap-2"},w0={key:2,class:"flex-1 overflow-auto"},$0={class:"min-w-full divide-y divide-gray-200 dark:divide-gray-700"},C0={class:"sticky top-0 bg-gray-100 dark:bg-page-dark"},S0=["onClick"],T0={class:"flex items-center gap-1"},M0={class:"flex flex-col"},I0={class:"text-gray-700 dark:text-gray-300"},L0={key:0,class:"font-mono text-[10px] text-gray-400"},D0={key:0,class:"sticky right-0 w-12 bg-gray-100 px-2 py-2 dark:bg-page-dark"},A0={class:"divide-y divide-gray-200 bg-white dark:divide-gray-700 dark:bg-page-dark"},q0=["title"],z0={key:0,class:"sticky right-0 w-12 bg-white px-2 py-2 dark:bg-page-dark"},R0={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"},P0={class:"flex items-center gap-1"},E0={class:"mx-2 text-xs text-gray-600 dark:text-gray-400"},B0={class:"flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400"},j0={key:4,class:"flex flex-1 items-center justify-center text-gray-500 dark:text-gray-400"},U0={class:"text-center"},F0={class:"mt-2 text-sm"},V0={key:5,class:"flex flex-1 items-center justify-center text-gray-500 dark:text-gray-400"},N0={class:"text-center"},O0={class:"mt-2 text-sm"},W0={class:"mt-1 text-xs text-gray-400"},H0={class:"max-h-[70vh] overflow-hidden p-6"},Y0={class:"mb-4 flex items-center gap-2"},K0={class:"text-lg font-semibold text-gray-900 dark:text-white"},Q0={key:0,class:"flex items-center justify-center py-8"},G0={class:"ml-2 text-sm text-gray-500"},J0={key:1,class:"max-h-[50vh] overflow-y-auto"},X0=["innerHTML"],Z0={key:0,class:"mt-2 flex items-center text-xs text-gray-400"},em={key:2,class:"rounded-lg bg-red-50 p-4 dark:bg-red-950"},tm={class:"text-sm text-red-600 dark:text-red-400"},am={class:"mt-4 flex justify-end gap-2"},sm=pe({__name:"ResultTable",props:{result:{},error:{},sql:{},prompt:{}},setup(l,{expose:s}){const{t,locale:c}=fe(),r=Je(),g=xt(),u=ct(),{aiGlobalSettings:d}=et(g),m=[/^ts$/i,/^timestamp$/i,/^time$/i,/_at$/i,/_ts$/i,/_time$/i,/^date$/i];function v(ae){return m.some(se=>se.test(ae))}function y(ae){if(typeof ae!="number"||!Number.isFinite(ae))return!1;const se=946684800,xe=4102444800,de=se*1e3,_e=xe*1e3;return ae>=se&&ae<=xe||ae>=de&&ae<=_e}function M(ae){const xe=ae>1e10?ae:ae*1e3;return Me(xe).format("YYYY-MM-DD HH:mm:ss")}const $=[/^id$/i,/^message_id$/i,/^msg_id$/i,/^msgid$/i];function D(ae){return ae.findIndex(se=>$.some(xe=>xe.test(se)))}function I(ae){u.openChatRecordDrawer({scrollToMessageId:ae})}const q=new Kt({html:!1,breaks:!0,linkify:!0,typographer:!0}),_=l,L=f(null),x=f("asc"),C=f(1),h=f(100),k=[50,100,200,500],S=f(localStorage.getItem("sql-lab-readable-time")!=="false");function P(){S.value=!S.value,localStorage.setItem("sql-lab-readable-time",String(S.value))}const B=f(!1),A=f(!1),w=f(""),T=f(null),H=f(""),le=f(!1);function W(ae){const se=ae.split("."),xe=se.length>1?se[se.length-1]:ae,de=Ft[c.value]||Ft["zh-CN"];for(const _e of Object.values(de))if(_e[xe])return _e[xe];return null}const ue=b(()=>{if(!_.result||!L.value)return _.result?.rows||[];const ae=_.result.columns.indexOf(L.value);return ae===-1?_.result.rows:[..._.result.rows].sort((se,xe)=>{const de=se[ae],_e=xe[ae];if(de===null)return 1;if(_e===null)return-1;if(typeof de=="number"&&typeof _e=="number")return x.value==="asc"?de-_e:_e-de;const Ie=String(de).localeCompare(String(_e));return x.value==="asc"?Ie:-Ie})}),ve=b(()=>_.result?Math.ceil(ue.value.length/h.value):0),G=b(()=>{const ae=(C.value-1)*h.value,se=ae+h.value;return ue.value.slice(ae,se)}),F=b(()=>_.result?D(_.result.columns):-1),X=b(()=>F.value!==-1);function me(ae){L.value===ae?x.value=x.value==="asc"?"desc":"asc":(L.value=ae,x.value="asc"),C.value=1}function ye(ae){h.value=ae,C.value=1}function K(ae,se){return ae===null?"NULL":typeof ae=="object"?JSON.stringify(ae):S.value&&se&&v(se)&&y(ae)?M(ae):String(ae)}async function E(){if(!(!_.result||le.value)){le.value=!0;try{const ae=d.value.sqlExportFormat??"csv",se=await vs({columns:_.result.columns,rows:_.result.rows},ae);if(se.success&&se.filePath){const xe=se.filePath.split("/").pop()||se.filePath;r.add({title:t("common.exportSuccess"),description:xe,color:"primary",actions:[{label:t("common.openFolder"),onClick:()=>{aa().showInFolder(se.filePath)}}]})}else r.fail(t("common.exportFailed"),{description:se.error})}catch(ae){console.error("导出失败:",ae),r.fail(t("common.exportFailed"),{description:String(ae)})}finally{le.value=!1}}}function V(){L.value=null,x.value="asc",C.value=1}function oe(){if(!_.result)return"";const ae=50,se=_.result.rows.slice(0,ae),xe=_.result.columns.join(" | "),de=_.result.columns.map(()=>"---").join(" | "),_e=se.map(Le=>Le.map(Se=>Se===null?"NULL":String(Se).slice(0,50)).join(" | "));let Ie=`| ${xe} |
48
+ | ${de} |
49
+ `;return Ie+=_e.map(Le=>`| ${Le} |`).join(`
50
+ `),_.result.rows.length>ae&&(Ie+=`
51
+
52
+ (仅展示前 ${ae} 行,共 ${_.result.rowCount} 行)`),Ie}async function he(){B.value=!0,w.value="",T.value=null,H.value="",await ke()}async function ke(){if(!await Ot().hasConfig()){T.value=t("common.errorNoAIConfig");return}A.value=!0,T.value=null,H.value="";try{const se=oe();let xe="";_.prompt&&(xe=`用户的查询意图:${_.prompt}
53
+
54
+ `),_.sql&&(xe+=`执行的 SQL 语句:
55
+ \`\`\`sql
56
+ ${_.sql}
57
+ \`\`\`
58
+
59
+ `);const de=`请分析以下 SQL 查询结果,用简洁的中文总结关键发现和洞察。
60
+
61
+ ${xe}查询结果(共 ${_.result?.rowCount||0} 行):
62
+
63
+ ${se}
64
+
65
+ 请提供:
66
+ 1. 结果概述(一句话总结)
67
+ 2. 关键发现(2-4 个要点)
68
+ 3. 如有明显的趋势或异常,请指出`,_e=await sa().chatStream([{role:"system",content:"你是一个数据分析专家,擅长从查询结果中提取关键信息和洞察。请用简洁清晰的中文回答。"},{role:"user",content:de}],{temperature:.3,maxTokens:1e3},Ie=>{Ie.content&&(H.value+=Ie.content)});_e.success?w.value=H.value:T.value=_e.error||t("ai.sqlLab.result.errorSummary")}catch(se){T.value=se.message||String(se)}finally{A.value=!1}}function be(){B.value=!1,w.value="",T.value=null,H.value=""}return s({resetSort:V}),(ae,se)=>{const xe=we,de=la,_e=ze,Ie=Wt,Le=He;return n(),i("div",m0,[l.error?(n(),i("div",g0,[e("div",p0,[p(xe,{name:"i-heroicons-exclamation-circle",class:"mt-0.5 h-5 w-5 shrink-0 text-red-500"}),e("div",v0,[e("p",y0,o(a(t)("ai.sqlLab.result.queryError")),1),e("p",h0,o(l.error),1)])])])):R("",!0),l.result?(n(),i("div",f0,[e("div",x0,[e("label",b0,[p(de,{"model-value":S.value,size:"xs","onUpdate:modelValue":P},null,8,["model-value"]),e("span",k0,o(a(t)("ai.sqlLab.result.readableTime")),1)]),se[5]||(se[5]=e("span",{class:"text-gray-300 dark:text-gray-600"},"|",-1)),e("span",null,[p(xe,{name:"i-heroicons-table-cells",class:"mr-1 inline h-4 w-4"}),ee(" "+o(a(t)("ai.sqlLab.result.rows",{count:l.result.rowCount})),1)]),e("span",null,[p(xe,{name:"i-heroicons-clock",class:"mr-1 inline h-4 w-4"}),ee(" "+o(l.result.duration)+" ms ",1)])]),e("div",_0,[p(_e,{variant:"ghost",size:"xs",onClick:he},{default:j(()=>[p(xe,{name:"i-heroicons-sparkles",class:"mr-1 h-4 w-4"}),ee(" "+o(a(t)("ai.sqlLab.result.summarize")),1)]),_:1}),p(_e,{variant:"ghost",size:"xs",loading:le.value,onClick:E},{default:j(()=>[p(xe,{name:"i-heroicons-arrow-down-tray",class:"mr-1 h-4 w-4"}),ee(" "+o(a(t)("common.export")),1)]),_:1},8,["loading"])])])):R("",!0),l.result&&l.result.rows.length>0?(n(),i("div",w0,[e("table",$0,[e("thead",C0,[e("tr",null,[(n(!0),i(Z,null,ce(l.result.columns,(Se,qe)=>(n(),i("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:Re=>me(Se)},[e("div",T0,[e("div",M0,[e("span",I0,o(W(Se)||Se),1),W(Se)?(n(),i("span",L0,o(Se),1)):R("",!0)]),L.value===Se?(n(),Y(xe,{key:0,name:x.value==="asc"?"i-heroicons-chevron-up":"i-heroicons-chevron-down",class:"h-3 w-3 text-gray-500"},null,8,["name"])):R("",!0)])],8,S0))),128)),X.value?(n(),i("th",D0)):R("",!0)])]),e("tbody",A0,[(n(!0),i(Z,null,ce(G.value,(Se,qe)=>(n(),i("tr",{key:qe,class:"hover:bg-gray-50 dark:hover:bg-gray-800"},[(n(!0),i(Z,null,ce(Se,(Re,Ee)=>(n(),i("td",{key:Ee,class:ne(["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":Re===null}]),title:K(Re,l.result.columns[Ee])},o(K(Re,l.result.columns[Ee])),11,q0))),128)),X.value?(n(),i("td",z0,[p(_e,{icon:"i-heroicons-chat-bubble-left-right",color:"neutral",variant:"ghost",size:"xs",title:a(t)("ai.sqlLab.result.viewChat"),onClick:Re=>I(Se[F.value])},null,8,["title","onClick"])])):R("",!0)]))),128))])])])):R("",!0),l.result&&l.result.rows.length>0&&ve.value>1?(n(),i("div",R0,[e("div",P0,[p(_e,{icon:"i-heroicons-chevron-double-left",variant:"ghost",size:"xs",disabled:C.value===1,onClick:se[0]||(se[0]=Se=>C.value=1)},null,8,["disabled"]),p(_e,{icon:"i-heroicons-chevron-left",variant:"ghost",size:"xs",disabled:C.value===1,onClick:se[1]||(se[1]=Se=>C.value--)},null,8,["disabled"]),e("span",E0,o(C.value)+" / "+o(ve.value),1),p(_e,{icon:"i-heroicons-chevron-right",variant:"ghost",size:"xs",disabled:C.value>=ve.value,onClick:se[2]||(se[2]=Se=>C.value++)},null,8,["disabled"]),p(_e,{icon:"i-heroicons-chevron-double-right",variant:"ghost",size:"xs",disabled:C.value>=ve.value,onClick:se[3]||(se[3]=Se=>C.value=ve.value)},null,8,["disabled"])]),e("div",B0,[e("span",null,o(a(t)("ai.sqlLab.result.pageSize")),1),p(Ie,{"model-value":h.value,items:k.map(Se=>({label:String(Se),value:Se})),size:"xs",class:"w-20","onUpdate:modelValue":ye},null,8,["model-value","items"])])])):R("",!0),l.result&&l.result.rows.length===0?(n(),i("div",j0,[e("div",U0,[p(xe,{name:"i-heroicons-inbox",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),e("p",F0,o(a(t)("ai.sqlLab.result.emptyResult")),1)])])):R("",!0),!l.result&&!l.error?(n(),i("div",V0,[e("div",N0,[p(xe,{name:"i-heroicons-command-line",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),e("p",O0,o(a(t)("ai.sqlLab.result.initialState")),1),e("p",W0,o(a(t)("ai.sqlLab.result.initialHint")),1)])])):R("",!0),p(Le,{open:B.value,"onUpdate:open":se[4]||(se[4]=Se=>B.value=Se)},{content:j(()=>[e("div",H0,[e("div",Y0,[p(xe,{name:"i-heroicons-sparkles",class:"h-5 w-5 text-pink-500"}),e("h3",K0,o(a(t)("ai.sqlLab.result.summaryTitle")),1)]),A.value&&!H.value?(n(),i("div",Q0,[p(xe,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-pink-500"}),e("span",G0,o(a(t)("ai.sqlLab.result.analyzing")),1)])):H.value||w.value?(n(),i("div",J0,[e("div",{class:"prose prose-sm max-w-none rounded-lg bg-gray-50 p-4 dark:prose-invert dark:bg-page-dark",innerHTML:a(q).render(H.value||w.value)},null,8,X0),A.value?(n(),i("div",Z0,[p(xe,{name:"i-heroicons-arrow-path",class:"mr-1 h-3 w-3 animate-spin"}),ee(" "+o(a(t)("common.generating")),1)])):R("",!0)])):R("",!0),T.value?(n(),i("div",em,[e("p",tm,o(T.value),1)])):R("",!0),e("div",am,[!A.value&&w.value?(n(),Y(_e,{key:0,variant:"outline",onClick:ke},{default:j(()=>[p(xe,{name:"i-heroicons-arrow-path",class:"mr-1 h-4 w-4"}),ee(" "+o(a(t)("common.regenerate")),1)]),_:1})):R("",!0),p(_e,{variant:"ghost",onClick:be},{default:j(()=>[ee(o(a(t)("common.close")),1)]),_:1})])])]),_:1},8,["open"])])}}}),om={class:"main-content flex h-full"},nm={class:"flex flex-1 flex-col overflow-hidden"},rm={class:"flex flex-col border-b border-gray-200 bg-gray-50 p-4 dark:border-gray-800 dark:bg-page-dark"},lm={class:"mx-auto w-full max-w-3xl"},im=["placeholder"],cm=["placeholder"],dm={class:"mt-1 flex items-center justify-between"},um={class:"flex items-center gap-2"},mm={key:0,class:"text-xs text-gray-400"},gm={class:"flex items-center gap-2"},pm={key:0,class:"ml-1 text-xs text-gray-400"},vm={key:0,class:"flex-1 overflow-auto p-4"},ym={class:"mb-2 flex items-center gap-1.5 text-sm font-medium text-gray-600 dark:text-gray-300"},hm={key:0,class:"text-gray-500"},fm={key:1,class:"text-pink-500"},xm=["open"],bm={class:"cursor-pointer select-none text-xs font-medium text-gray-500 dark:text-gray-400"},km={key:1,class:"whitespace-pre-wrap break-all font-mono text-xs leading-5 text-gray-600 dark:text-gray-400"},_m={key:2,class:"font-mono text-xs text-gray-400"},wm=pe({__name:"SQLLabTab",props:{sessionId:{},chatType:{}},setup(l){const{t:s,locale:t}=fe(),c=l,r=f(null),g=f(null);function u(F){return s(F==="group"?"ai.sqlLab.generate.defaultPromptGroup":"ai.sqlLab.generate.defaultPromptPrivate")}const d=f("SELECT * FROM message LIMIT 10"),m=f(u(c.chatType)),v=f("prompt"),y=f(!1),M=f(!1),$=f(null),D=f(null),I=f(""),q=f(""),_=f(""),L=f(!1),x=f(null),C=f(!1),h=f([]);function k(){try{const F=`sql-lab-history-${c.sessionId}`,X=localStorage.getItem(F);X&&(h.value=JSON.parse(X))}catch(F){console.error("加载历史记录失败:",F)}}function S(){try{const F=`sql-lab-history-${c.sessionId}`;localStorage.setItem(F,JSON.stringify(h.value))}catch(F){console.error("保存历史记录失败:",F)}}function P(F,X,me){const ye={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,prompt:F,sql:X,explanation:me,timestamp:Date.now()};h.value.unshift(ye),h.value.length>50&&(h.value=h.value.slice(0,50)),S()}function B(F){h.value=h.value.filter(X=>X.id!==F),S()}async function A(){if(!d.value.trim()){$.value=s("ai.sqlLab.editor.errorEmptySQL");return}y.value=!0,$.value=null,D.value=null,g.value?.resetSort();try{D.value=await Ne().executeSQL(c.sessionId,d.value)}catch(F){$.value=F.message||String(F)}finally{y.value=!1}}function w(F,X){(F.ctrlKey||F.metaKey)&&F.key==="Enter"&&(F.preventDefault(),X==="prompt"?ve():A())}function T(F,X){d.value+=`${F}.${X}`}function H(){v.value=v.value==="prompt"?"sql":"prompt"}function le(F){const X=[];for(const me of F){X.push(`### ${me.name} (${Vt(me.name,t.value)})`),X.push("| 列名 | 说明 | 类型 |"),X.push("|------|------|------|");for(const ye of me.columns){const K=ye.pk?" (主键)":"";X.push(`| ${ye.name} | ${Gt(me.name,ye.name,t.value)}${K} | ${ye.type} |`)}X.push("")}return X.join(`
69
+ `)}function W(F,X){return`你是一个 SQLite 数据库专家。用户需要查询聊天记录数据库。
70
+
71
+ ## 数据库结构
72
+
73
+ ${le(X)}
74
+
75
+ ## 重要说明
76
+
77
+ 1. message 表的 ts 字段是 Unix 时间戳(秒),查询日期需要使用 datetime(ts, 'unixepoch') 转换
78
+ 2. message.type 字段:0=文本, 1=图片, 2=语音, 3=视频, 4=文件, 5=表情包, 6=系统消息, 99=其他
79
+ 3. member 和 message 表通过 message.sender_id = member.id 关联
80
+ 4. **人名查询**:当识别到人名/昵称查询时,必须同时在 member 表的 account_name、group_nickname 和 aliases 三个字段中模糊搜索,使用 OR 连接:
81
+ \`\`\`
82
+ WHERE m.account_name LIKE '%人名%'
83
+ OR m.group_nickname LIKE '%人名%'
84
+ OR m.aliases LIKE '%人名%'
85
+ \`\`\`
86
+ 5. 显示成员名称时,使用 COALESCE(m.group_nickname, m.account_name, m.platform_id) 来获取最佳显示名
87
+ 6. **查询具体消息时包含消息 ID**:当用户需要查看具体的聊天记录时,SELECT 应包含 msg.id 作为第一个字段,这样用户可以点击查看完整上下文。注意是 msg.id(消息 ID),不是 m.id(成员 ID)。
88
+ 7. **统计查询不需要消息 ID**:当用户需要统计分析时,不需要返回 msg.id
89
+ 8. **严禁使用不存在的字段**:只能使用上方 Schema 中明确存在的表名和列名,禁止使用如 sender.display_name、member.display_name 等虚构字段
90
+ 9. **成员显示名写法**:如果需要显示成员名称,优先使用 COALESCE(m.group_nickname, m.account_name, m.platform_id);若不联表 member,可使用 COALESCE(msg.sender_group_nickname, msg.sender_account_name, msg.sender_id)
91
+ 10. **单次只做一个分析目标**:一次 SQL 只返回一个语义一致的结果集,不要把多个分析目标用 UNION ALL/UNION 混合到同一结果表
92
+
93
+ ## 用户需求
94
+
95
+ ${F}
96
+
97
+ ## 要求
98
+
99
+ 请以 JSON 格式输出,包含两个字段:
100
+ - sql: SQLite 查询语句(不要用代码块包裹)
101
+ - explanation: 用简洁的中文解释这条 SQL 做了什么
102
+
103
+ 示例格式:
104
+ {"sql": "SELECT ...", "explanation": "这条SQL查询了..."}
105
+
106
+ 注意:
107
+ 1. 仅输出 JSON,不要有任何其他文字
108
+ 2. SQL 中的查询结果限制在合理范围内(建议 LIMIT 100)
109
+ 3. 确保 SQL 语法正确
110
+ 4. 若用户需求包含多个分析目标,仅选择第一个目标生成 SQL`}function ue(F){let X=F.trim();X=X.replace(/^```json?\n?/i,"").replace(/\n?```$/i,"");try{const me=JSON.parse(X);return{sql:(me.sql||"").trim(),explanation:(me.explanation||"").trim()}}catch{return X=X.replace(/^```sql?\n?/i,"").replace(/\n?```$/i,""),{sql:X.trim(),explanation:""}}}async function ve(){const F=m.value.trim();if(!F){$.value=s("ai.sqlLab.generate.errorEmptyPrompt");return}if(!await Ot().hasConfig()){$.value=s("common.errorNoAIConfig");return}const me=r.value?.schema||[];if(me.length===0){$.value=s("common.error.unknown");return}M.value=!0,D.value=null,$.value=null,q.value="",_.value="",L.value=!1;let ye="";try{const K=W(F,me),E=await sa().chatStream([{role:"system",content:"你是一个 SQLite 专家,请以 JSON 格式输出 sql 和 explanation 字段。"},{role:"user",content:K}],{temperature:.1,maxTokens:4096},oe=>{if(oe.thinking!==void 0){oe.thinkingDone?L.value=!1:(L.value=!0,oe.thinking&&(_.value+=oe.thinking,Ue(()=>{x.value&&(x.value.scrollTop=x.value.scrollHeight)})));return}oe.error&&(ye=oe.error),oe.isFinished&&oe.finishReason==="length"&&(ye=s("ai.sqlLab.generate.errorTokenLimit")),oe.content&&(q.value+=oe.content)});if(!E.success){$.value=E.error||ye||s("ai.sqlLab.generate.errorGenerate");return}if(ye){$.value=ye;return}const V=ue(q.value);if(!V.sql){$.value=q.value?`${s("ai.sqlLab.generate.errorGenerate")}: ${q.value.slice(0,200)}`:s("ai.sqlLab.generate.errorGenerate");return}d.value=V.sql,I.value=F,P(F,V.sql,V.explanation),await A()}catch(K){$.value=K.message||String(K)}finally{M.value=!1}}async function G(F){d.value=F.sql,I.value=F.prompt,C.value=!1,await A()}return je(()=>{k()}),ge(()=>c.chatType,F=>{m.value=u(F)}),(F,X)=>{const me=we,ye=ze;return n(),i("div",om,[p(a(Gu),{ref_key:"schemaPanelRef",ref:r,"session-id":l.sessionId,onInsertColumn:T},null,8,["session-id"]),e("div",nm,[e("div",rm,[e("div",lm,[v.value==="prompt"?Ve((n(),i("textarea",{key:0,"onUpdate:modelValue":X[0]||(X[0]=K=>m.value=K),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:a(s)("ai.sqlLab.generate.placeholder"),spellcheck:"false",onKeydown:X[1]||(X[1]=K=>w(K,"prompt"))},null,40,im)),[[ot,m.value]]):Ve((n(),i("textarea",{key:1,"onUpdate:modelValue":X[2]||(X[2]=K=>d.value=K),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:a(s)("ai.sqlLab.editor.placeholder"),spellcheck:"false",onKeydown:X[3]||(X[3]=K=>w(K,"sql"))},null,40,cm)),[[ot,d.value]]),e("div",dm,[e("div",um,[p(ye,{variant:"ghost",size:"xs",onClick:H},{default:j(()=>[p(me,{name:"i-heroicons-arrows-right-left",class:"mr-1 h-3.5 w-3.5"}),ee(" "+o(v.value==="prompt"?a(s)("ai.sqlLab.editor.switchToSQLMode"):a(s)("ai.sqlLab.editor.switchToPromptMode")),1)]),_:1}),v.value==="sql"?(n(),i("span",mm,o(a(s)("ai.sqlLab.editor.tip")),1)):R("",!0)]),e("div",gm,[p(ye,{variant:"ghost",size:"sm",disabled:h.value.length===0,onClick:X[4]||(X[4]=K=>C.value=!0)},{default:j(()=>[p(me,{name:"i-heroicons-clock",class:"mr-1 h-4 w-4"}),ee(" "+o(a(s)("ai.sqlLab.editor.history"))+" ",1),h.value.length>0?(n(),i("span",pm,"("+o(h.value.length)+")",1)):R("",!0)]),_:1},8,["disabled"]),v.value==="prompt"?(n(),Y(ye,{key:0,color:"primary",size:"sm",loading:M.value||y.value,disabled:!m.value.trim(),onClick:ve},{default:j(()=>[p(me,{name:"i-heroicons-sparkles",class:"mr-1 h-4 w-4"}),ee(" "+o(a(s)("ai.sqlLab.editor.generateAndRun")),1)]),_:1},8,["loading","disabled"])):(n(),Y(ye,{key:1,color:"primary",size:"sm",loading:y.value,onClick:A},{default:j(()=>[p(me,{name:"i-heroicons-play",class:"mr-1 h-4 w-4"}),ee(" "+o(a(s)("ai.sqlLab.editor.run")),1)]),_:1},8,["loading"]))])])])]),v.value==="prompt"&&!D.value&&!$.value&&(q.value||_.value||M.value)?(n(),i("div",vm,[p(a(tt),{class:"mx-auto w-full max-w-3xl p-4"},{default:j(()=>[e("p",ym,[p(me,{name:"i-heroicons-cpu-chip",class:"h-4 w-4"}),ee(" "+o(a(s)("ai.sqlLab.generate.aiOutput"))+" ",1),L.value?(n(),i("span",hm,o(a(s)("ai.sqlLab.generate.thinking")),1)):M.value?(n(),i("span",fm,o(a(s)("common.generating")),1)):R("",!0)]),_.value?(n(),i("details",{key:0,class:"mb-3",open:L.value},[e("summary",bm,o(a(s)("ai.sqlLab.generate.thinkingProcess")),1),e("pre",{ref_key:"thinkingPreRef",ref:x,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"},o(_.value),513)],8,xm)):R("",!0),q.value?(n(),i("pre",km,o(q.value),1)):_.value?R("",!0):(n(),i("p",_m,o(a(s)("ai.sqlLab.generate.waitingAI")),1))]),_:1})])):(n(),Y(a(sm),{key:1,ref_key:"resultTableRef",ref:g,result:D.value,error:$.value,sql:d.value,prompt:I.value},null,8,["result","error","sql","prompt"]))]),p(a(u0),{open:C.value,"onUpdate:open":X[5]||(X[5]=K=>C.value=K),history:h.value,onExecute:G,onDelete:B},null,8,["open","history"])])}}}),$m=pe({__name:"EChartCalendar",props:{data:{},height:{default:180},year:{}},setup(l){Ct([ca,da,Qt,ua,St]);const s=l,{t,locale:c}=fe(),r=bt(),g=f(null);let u=null;const d=b(()=>{if(s.year)return s.year;if(s.data.length===0)return new Date().getFullYear();const q=s.data.map(_=>parseInt(_.date.split("-")[0]));return Math.max(...q)}),m=b(()=>s.data.length===0?10:Math.max(...s.data.map(q=>q.value),1)),v=b(()=>s.data.map(q=>[q.date,q.value])),y={light:["#fee5e8","#fbb5c2","#f7758c","#ee4567"],dark:["#3d1f24","#6b2f3a","#a34557","#ee4567"]},M=b(()=>({tooltip:{trigger:"item",formatter:q=>{const _=q.data[0],L=q.data[1];return`${_}<br/>${t("views.message.calendarTooltipMessages")}: ${L}`}},visualMap:{min:0,max:m.value,calculable:!1,orient:"horizontal",left:"center",bottom:0,itemWidth:10,itemHeight:100,text:[`${m.value}`,"0"],inRange:{color:r.value?y.dark:y.light},textStyle:{color:r.value?"#9ca3af":"#6b7280",fontSize:10},show:!0},calendar:{top:30,left:40,cellSize:[13,13],range:String(d.value),itemStyle:{borderWidth:2,borderColor:r.value?"#1f2937":"#ffffff"},yearLabel:{show:!0,position:"top",color:r.value?"#9ca3af":"#6b7280",fontSize:12},monthLabel:{show:!0,color:r.value?"#9ca3af":"#6b7280",fontSize:10,nameMap:[t("common.month.jan"),t("common.month.feb"),t("common.month.mar"),t("common.month.apr"),t("common.month.may"),t("common.month.jun"),t("common.month.jul"),t("common.month.aug"),t("common.month.sep"),t("common.month.oct"),t("common.month.nov"),t("common.month.dec")]},dayLabel:{show:!0,firstDay:1,color:r.value?"#6b7280":"#9ca3af",fontSize:10,nameMap:[t("common.weekday.sun"),t("common.weekday.mon"),t("common.weekday.tue"),t("common.weekday.wed"),t("common.weekday.thu"),t("common.weekday.fri"),t("common.weekday.sat")]},splitLine:{show:!1}},series:[{type:"heatmap",coordinateSystem:"calendar",data:v.value}]}));function $(){g.value&&(u=Tt(g.value,r.value?"dark":void 0,{renderer:"canvas"}),u.setOption({backgroundColor:"transparent",...M.value}))}function D(){u&&u.setOption({backgroundColor:"transparent",...M.value},{notMerge:!0})}function I(){u?.resize()}return ge([()=>s.data,r,c],()=>{D()}),ge(()=>s.year,()=>{D()}),je(()=>{$(),window.addEventListener("resize",I)}),ut(()=>{window.removeEventListener("resize",I),u?.dispose()}),(q,_)=>(n(),i("div",{ref_key:"chartRef",ref:g,style:Qe({height:`${l.height}px`,width:"100%"})},null,4))}}),Cm={class:"no-capture flex items-center gap-2"},Sm={class:"flex w-full items-center justify-between border-b border-gray-200 px-6 py-4 dark:border-gray-700"},Tm={class:"flex items-center gap-2"},Mm={class:"text-lg font-semibold text-gray-900 whitespace-nowrap dark:text-white"},Im={class:"text-sm text-gray-500"},Lm={class:"max-h-[60vh] overflow-y-auto p-4"},Dm=pe({__name:"ExpandableListCard",props:{title:{},description:{},showViewAll:{type:Boolean},viewAllLabel:{},countLabel:{}},setup(l){const s=f(!1),t=f(null);return(c,r)=>{const g=ze,u=He;return n(),Y(a(Oe),{title:l.title,description:l.description},{headerRight:j(()=>[e("div",Cm,[We(c.$slots,"headerRight"),p(u,{open:s.value,"onUpdate:open":r[0]||(r[0]=d=>s.value=d),ui:{content:"md:w-full max-w-3xl"}},{content:j(()=>[e("div",{ref_key:"modalBodyRef",ref:t,class:"section-content flex flex-col"},[e("div",Sm,[e("div",Tm,[e("h3",Mm,o(l.title),1),e("span",Im,"("+o(l.countLabel)+")",1)]),p(it,{size:"xs",type:"element","target-element":t.value},null,8,["target-element"])]),e("div",Lm,[We(c.$slots,"full")])],512)]),default:j(()=>[l.showViewAll?(n(),Y(g,{key:0,icon:"i-heroicons-list-bullet",variant:"ghost"},{default:j(()=>[ee(o(l.viewAllLabel),1)]),_:1})):R("",!0)]),_:3},8,["open"])])]),default:j(()=>[We(c.$slots,"default")]),_:3},8,["title","description"])}}}),Am={class:"divide-y divide-gray-100 dark:divide-gray-800"},qm={class:"divide-y divide-gray-100 dark:divide-gray-800"},zm={key:0},Rm={class:"px-5 py-8 text-center text-sm text-gray-400"},Pm=pe({__name:"ListPro",props:{items:{},title:{},description:{},topN:{default:10},countTemplate:{}},setup(l){const{t:s}=fe(),t=l,c=b(()=>t.items.slice(0,t.topN)),r=b(()=>t.items.length>t.topN),g=b(()=>(t.countTemplate||s("views.charts.listPro.countTemplate")).replace("{count}",String(t.items.length)));return(u,d)=>(n(),Y(Dm,{title:l.title,description:l.description,"show-view-all":r.value,"view-all-label":a(s)("views.charts.listPro.fullRanking"),"count-label":g.value},{headerRight:j(()=>[We(u.$slots,"headerRight")]),full:j(()=>[e("div",Am,[(n(!0),i(Z,null,ce(l.items,(m,v)=>(n(),i("div",{key:v,class:"px-5 py-3"},[We(u.$slots,"item",{item:m,index:v})]))),128))])]),default:j(()=>[We(u.$slots,"config"),e("div",qm,[(n(!0),i(Z,null,ce(c.value,(m,v)=>(n(),i("div",{key:v,class:"px-5 py-3"},[We(u.$slots,"item",{item:m,index:v})]))),128))]),l.items.length===0?(n(),i("div",zm,[We(u.$slots,"empty",{},()=>[e("div",Rm,o(a(s)("views.charts.listPro.empty")),1)])])):R("",!0)]),_:3},8,["title","description","show-view-all","view-all-label","count-label"]))}}),Em={class:"border-b border-gray-100 p-4 dark:border-gray-800"},Bm={class:"mb-3 flex flex-wrap items-center gap-2"},jm={class:"text-xs text-gray-500 dark:text-gray-400"},Um=["onClick"],Fm={class:"p-4"},Vm={class:"mb-3 font-semibold text-gray-900 dark:text-white"},Nm={class:"space-y-3"},Om={class:"mb-1 block text-xs text-gray-500"},Wm={class:"mb-1 block text-xs text-gray-500"},Hm={class:"flex flex-wrap items-center gap-2"},Ym={class:"mt-4 flex justify-end gap-2"},Km={class:"flex flex-wrap items-center gap-2"},Qm={class:"mt-1.5 text-xs text-gray-400"},Gm={key:0,class:"border-b border-gray-100 px-5 py-4 dark:border-gray-800"},Jm={class:"mb-3 flex items-center justify-between"},Xm={class:"text-base font-medium text-gray-700 dark:text-gray-300"},Zm={class:"flex cursor-pointer items-center gap-1.5 text-xs text-gray-500"},eg={class:"flex flex-wrap gap-2"},tg={class:"text-xs text-gray-500"},ag={class:"flex items-center gap-3"},sg={class:"w-32 shrink-0"},og={class:"truncate font-medium text-gray-900 dark:text-white"},ng={class:"flex flex-1 items-center"},rg={class:"flex h-2.5 w-full overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800"},lg=["title"],ig={class:"flex shrink-0 items-baseline gap-2"},cg={class:"text-lg font-bold text-gray-900 dark:text-white"},dg={class:"text-sm text-gray-500"},ug={key:0,class:"flex h-64 flex-col items-center justify-center text-gray-400"},mg={class:"text-sm"},gg={key:1,class:"h-64"},pg=pe({__name:"KeywordAnalysis",props:{sessionId:{},timeFilter:{}},setup(l){const{t:s}=fe(),t=l,c=xt(),r=f(!1),g={bg:"bg-pink-400",text:"text-pink-700",badge:"pink",wrapBg:"bg-pink-50 dark:bg-pink-900/20"},u=[{bg:"bg-amber-400",text:"text-amber-700",badge:"amber",wrapBg:"bg-amber-50 dark:bg-amber-900/20"},{bg:"bg-pink-400",text:"text-pink-700",badge:"pink",wrapBg:"bg-pink-50 dark:bg-pink-900/20"},{bg:"bg-blue-400",text:"text-blue-700",badge:"blue",wrapBg:"bg-blue-50 dark:bg-blue-900/20"},{bg:"bg-green-400",text:"text-green-700",badge:"green",wrapBg:"bg-green-50 dark:bg-green-900/20"},{bg:"bg-purple-400",text:"text-purple-700",badge:"purple",wrapBg:"bg-purple-50 dark:bg-purple-900/20"},{bg:"bg-red-400",text:"text-red-700",badge:"red",wrapBg:"bg-red-50 dark:bg-red-900/20"},{bg:"bg-cyan-400",text:"text-cyan-700",badge:"cyan",wrapBg:"bg-cyan-50 dark:bg-cyan-900/20"},{bg:"bg-orange-400",text:"text-orange-700",badge:"orange",wrapBg:"bg-orange-50 dark:bg-orange-900/20"}];function d(E){if(!r.value)return g;const V=$.value.indexOf(E);return u[V%u.length]}const m=["laugh","sad","praise","slacker","gossip","polite","curious"],v=b(()=>[{id:"laugh",name:s("quotes.keywords.templates.laugh.name"),keywords:s("quotes.keywords.templates.laugh.keywords").split(","),description:s("quotes.keywords.templates.laugh.description")},{id:"sad",name:s("quotes.keywords.templates.sad.name"),keywords:s("quotes.keywords.templates.sad.keywords").split(","),description:s("quotes.keywords.templates.sad.description")},{id:"praise",name:s("quotes.keywords.templates.praise.name"),keywords:s("quotes.keywords.templates.praise.keywords").split(","),description:s("quotes.keywords.templates.praise.description")},{id:"slacker",name:s("quotes.keywords.templates.slacker.name"),keywords:s("quotes.keywords.templates.slacker.keywords").split(","),description:s("quotes.keywords.templates.slacker.description")},{id:"gossip",name:s("quotes.keywords.templates.gossip.name"),keywords:s("quotes.keywords.templates.gossip.keywords").split(","),description:s("quotes.keywords.templates.gossip.description")},{id:"polite",name:s("quotes.keywords.templates.polite.name"),keywords:s("quotes.keywords.templates.polite.keywords").split(","),description:s("quotes.keywords.templates.polite.description")},{id:"curious",name:s("quotes.keywords.templates.curious.name"),keywords:s("quotes.keywords.templates.curious.keywords").split(","),description:s("quotes.keywords.templates.curious.description")}]),y=b(()=>{const E=c.customKeywordTemplates.map(oe=>({...oe,isCustom:!0}));return[...v.value.filter(oe=>!c.deletedPresetTemplateIds.includes(oe.id)),...E]}),M=f("laugh"),$=f([]);ge(v,E=>{E.length>0&&$.value.length===0&&($.value=[...E[0].keywords])},{immediate:!0});const D=b(()=>{const E=y.value.find(V=>V.id===M.value);return E?E.name:""}),I=f(null),q=f(!1),_=f(!1),L=f(null),x=f(""),C=f([]),h=f(""),k=b(()=>L.value!==null),S=b(()=>k.value?s("quotes.keywords.modal.editTitle"):s("quotes.keywords.modal.createTitle"));function P(){L.value=null,x.value="",C.value=[],h.value="",_.value=!0}function B(E){L.value=E.id,x.value=E.name,C.value=[...E.keywords],_.value=!0}function A(){const E=h.value.trim();E&&!C.value.includes(E)&&(C.value=[...C.value,E]),h.value=""}function w(E){C.value=C.value.filter(V=>V!==E)}function T(E){M.value=E.id,$.value=[...E.keywords],I.value=null,X()}function H(){$.value=[],I.value=null,M.value=""}const le=f("");function W(){const E=le.value.trim();E&&!$.value.includes(E)&&($.value=[...$.value,E],X()),le.value=""}function ue(E){$.value=$.value.filter(V=>V!==E),X()}function ve(E){return m.includes(E)}function G(){if(x.value.trim()){if(k.value&&L.value)if(ve(L.value)){const E={id:`custom_${Date.now()}`,name:x.value.trim(),keywords:[...C.value]};c.addCustomKeywordTemplate(E),M.value=E.id,$.value=[...E.keywords],X()}else c.updateCustomKeywordTemplate(L.value,{name:x.value.trim(),keywords:[...C.value]}),M.value===L.value&&($.value=[...C.value],X());else{const E={id:`custom_${Date.now()}`,name:x.value.trim(),keywords:[...C.value]};c.addCustomKeywordTemplate(E),M.value=E.id,$.value=[...E.keywords],X()}_.value=!1}}function F(E){ve(E)?c.addDeletedPresetTemplateId(E):c.removeCustomKeywordTemplate(E),M.value===E&&(y.value.length>0?T(y.value[0]):H())}async function X(){if(!t.sessionId||$.value.length===0){I.value=null;return}q.value=!0;try{I.value=await Ne().getLaughAnalysis(t.sessionId,t.timeFilter,[...$.value])}catch(E){console.error("加载词频分析失败:",E),I.value=null}finally{q.value=!1}}const me=b(()=>I.value?I.value.rankByCount.map(E=>({id:E.memberId.toString(),name:E.name,value:E.laughCount,percentage:E.percentage,keywordDistribution:E.keywordDistribution||[]})):[]);function ye(E){if(me.value.length===0)return 0;const V=me.value[0].value;return V===0?0:Math.round(me.value[E].value/V*100)}function K(E,V){const oe=ye(V);return!E.keywordDistribution||E.keywordDistribution.length===0?[{keyword:"default",width:oe,bg:"bg-amber-400"}]:E.keywordDistribution.map(he=>({keyword:he.keyword,width:he.percentage/100*oe,bg:d(he.keyword).bg}))}return ge(()=>[t.sessionId,t.timeFilter],()=>{X()},{immediate:!0,deep:!0}),(E,V)=>{const oe=ia,he=wt,ke=Ht,be=ze,ae=He,se=Na,xe=we;return n(),Y(a(Pm),{items:me.value,title:a(s)("quotes.keywords.title"),description:a(s)("quotes.keywords.description"),"top-n":10,"count-template":a(s)("quotes.keywords.countTemplate")},{config:j(()=>[e("div",Em,[e("div",Bm,[e("span",jm,o(a(s)("quotes.keywords.templateLabel")),1),(n(!0),i(Z,null,ce(y.value,de=>(n(),Y(oe,{key:de.id,items:[[{label:a(s)("quotes.keywords.contextMenu.edit"),icon:"i-lucide-pencil",disabled:!de.isCustom,onSelect:()=>B(de)},{label:a(s)("quotes.keywords.contextMenu.delete"),icon:"i-lucide-trash",color:"error",onSelect:()=>F(de.id)}]]},{default:j(()=>[e("button",{class:ne(["rounded-md border px-2.5 py-1 text-sm transition-all",M.value===de.id?"border-pink-500 bg-pink-50 text-pink-600 dark:border-pink-400 dark:bg-pink-900/20 dark:text-pink-400":"border-gray-200 text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:text-gray-400 dark:hover:border-gray-600"]),onClick:_e=>T(de)},o(de.name),11,Um)]),_:2},1032,["items"]))),128)),p(ae,{open:_.value,"onUpdate:open":V[3]||(V[3]=de=>_.value=de)},{content:j(()=>[e("div",Fm,[e("h3",Vm,o(S.value),1),e("div",Nm,[e("div",null,[e("label",Om,o(a(s)("quotes.keywords.modal.templateName")),1),p(he,{modelValue:x.value,"onUpdate:modelValue":V[0]||(V[0]=de=>x.value=de),placeholder:a(s)("quotes.keywords.modal.templateNamePlaceholder")},null,8,["modelValue","placeholder"])]),e("div",null,[e("label",Wm,o(a(s)("quotes.keywords.modal.keywords")),1),e("div",Hm,[(n(!0),i(Z,null,ce(C.value,de=>(n(),Y(ke,{key:de,variant:"soft",class:"cursor-pointer",onClick:_e=>w(de)},{default:j(()=>[ee(o(de)+" ",1),V[6]||(V[6]=e("span",{class:"ml-0.5 hover:text-red-500"},"×",-1))]),_:2},1032,["onClick"]))),128)),p(he,{modelValue:h.value,"onUpdate:modelValue":V[1]||(V[1]=de=>h.value=de),placeholder:a(s)("quotes.keywords.modal.keywordPlaceholder"),class:"w-full",onKeydown:Ge(Be(A,["prevent"]),["enter"])},null,8,["modelValue","placeholder","onKeydown"])])])]),e("div",Ym,[p(be,{variant:"soft",onClick:V[2]||(V[2]=de=>_.value=!1)},{default:j(()=>[ee(o(a(s)("common.cancel")),1)]),_:1}),p(be,{color:"primary",disabled:!x.value.trim()||C.value.length===0,onClick:G},{default:j(()=>[ee(o(k.value?a(s)("quotes.keywords.modal.update"):a(s)("common.save")),1)]),_:1},8,["disabled"])])])]),default:j(()=>[e("button",{class:"rounded-md border border-dashed border-gray-300 px-2.5 py-1 text-sm text-gray-500 transition-all hover:border-pink-400 hover:text-pink-500 dark:border-gray-600",onClick:P},o(a(s)("quotes.keywords.newTemplate")),1)]),_:1},8,["open"])]),e("div",Km,[(n(!0),i(Z,null,ce($.value,de=>(n(),Y(ke,{key:de,class:"cursor-pointer",onClick:_e=>ue(de)},{default:j(()=>[ee(o(de)+" ",1),V[7]||(V[7]=e("span",{class:"ml-0.5 hover:text-red-500"},"×",-1))]),_:2},1032,["onClick"]))),128)),p(he,{modelValue:le.value,"onUpdate:modelValue":V[4]||(V[4]=de=>le.value=de),placeholder:a(s)("quotes.keywords.searchPlaceholder"),class:"w-32",onKeydown:Ge(Be(W,["prevent"]),["enter"])},null,8,["modelValue","placeholder","onKeydown"]),$.value.length>0?(n(),i("button",{key:0,class:"text-sm text-pink-500 hover:text-red-500",onClick:H},o(a(s)("quotes.keywords.clear")),1)):R("",!0)]),e("div",Qm,o(a(s)("quotes.keywords.templateHint")),1)]),I.value&&I.value.typeDistribution.length>0?(n(),i("div",Gm,[e("div",Jm,[e("span",Xm,o(D.value?D.value:$.value.length===1?$.value[0]:a(s)("quotes.keywords.keyword"))+o(a(s)("quotes.keywords.ranking")),1),e("label",Zm,[e("span",null,o(a(s)("quotes.keywords.multiColorMode")),1),p(se,{modelValue:r.value,"onUpdate:modelValue":V[5]||(V[5]=de=>r.value=de),size:"md"},null,8,["modelValue"])])]),e("div",eg,[(n(!0),i(Z,null,ce(I.value.typeDistribution,de=>(n(),i("div",{key:de.type,class:ne(["flex items-center gap-2 rounded-lg px-2 py-2 text-xs",d(de.type).wrapBg])},[e("span",{class:ne(["h-2.5 w-2.5 shrink-0 rounded-full",d(de.type).bg])},null,2),e("span",{class:ne(["font-medium",d(de.type).text])},o(de.type),3),e("span",tg,o(a(s)("quotes.keywords.times",{count:de.count})),1),p(ke,{color:d(de.type).badge,variant:"soft",size:"xs"},{default:j(()=>[ee(o(de.percentage)+"%",1)]),_:2},1032,["color"])],2))),128))])])):R("",!0),q.value&&me.value.length===0?(n(),Y(a(mt),{key:1,text:a(s)("quotes.keywords.loading")},null,8,["text"])):R("",!0)]),item:j(({item:de,index:_e})=>[e("div",ag,[e("div",{class:ne(["flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-sm font-bold",a(rs)(_e)])},o(_e+1),3),e("div",sg,[e("p",og,o(de.name),1)]),e("div",ng,[e("div",rg,[(n(!0),i(Z,null,ce(K(de,_e),Ie=>(n(),i("div",{key:Ie.keyword,class:ne(["h-full transition-all first:rounded-l-full last:rounded-r-full",Ie.bg]),style:Qe({width:`${Ie.width}%`}),title:`${Ie.keyword}: ${Ie.width.toFixed(1)}%`},null,14,lg))),128))])]),e("div",ig,[e("span",cg,o(de.value),1),e("span",dg,o(a(s)("quotes.keywords.timesWithPercent",{count:de.value,percent:de.percentage})),1)])])]),empty:j(()=>[q.value?(n(),i("div",gg)):(n(),i("div",ug,[p(xe,{name:"i-heroicons-magnifying-glass",class:"mb-2 h-8 w-8 opacity-50"}),e("p",mg,o(a(s)("quotes.keywords.empty")),1)]))]),_:1},8,["items","title","description","count-template"])}}}),vg={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},yg={class:"flex items-center gap-6 sm:gap-10"},hg={class:"min-w-0 flex-1"},fg={class:"flex flex-col gap-2 text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},xg={key:0,class:"mb-0 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},bg={class:"flex items-baseline gap-x-1.5"},kg={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},_g={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},wg={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},$g={class:"flex items-baseline gap-x-1.5"},Cg={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Sg={class:"font-black text-3xl text-pink-500 dark:text-pink-400"},Tg={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Mg={key:1,class:"mt-1 flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},Ig={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Lg=["onClick"],Dg={key:0,class:"text-gray-400"},Ag={key:0,class:"hidden shrink-0 overflow-hidden rounded-lg sm:block"},qg={class:"relative",style:{width:"360px",height:"220px"}},zg={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Rg={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Pg={class:"min-w-0 flex-1"},Eg={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},Bg={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},jg={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"},Ug={class:"flex items-center gap-1.5"},Fg={class:"text-[9px] font-medium uppercase tracking-widest"},Vg=pe({__name:"TopicProfileCard",props:{totalMessages:{},totalWords:{},uniqueWords:{},topWords:{},topicWords:{},posTagStats:{},timeFilter:{}},emits:["wordClick"],setup(l,{emit:s}){const t=na(()=>_t(()=>import("./EChartWordcloud-DU3ZYdgz.js"),__vite__mapDeps([5,6,7,8,1]))),{t:c}=fe(),r=l,g=s,u=b(()=>{const{startTs:I,endTs:q}=r.timeFilter??{};return I&&q?`${Me(I*1e3).format("YYYY/MM/DD")} – ${Me(q*1e3).format("YYYY/MM/DD")}`:""}),d=b(()=>(r.topicWords?.length?r.topicWords:r.topWords).slice(0,5)),m=b(()=>({words:(r.topicWords?.length?r.topicWords:r.topWords).slice(0,50).map(q=>({word:q.word,count:q.count,percentage:q.percentage}))})),v=b(()=>r.totalWords===0?0:Math.round(r.uniqueWords/r.totalWords*100)),y=b(()=>{if(!r.posTagStats?.length)return{key:"Balanced",label:c("quotes.topicProfile.styleBalanced"),desc:c("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"};const I=new Map(r.posTagStats.map(S=>[S.tag,S.count])),q=(I.get("n")||0)+(I.get("ns")||0)+(I.get("nt")||0)+(I.get("nz")||0),_=(I.get("v")||0)+(I.get("vn")||0)+(I.get("vd")||0),L=(I.get("a")||0)+(I.get("ad")||0)+(I.get("an")||0),x=q+_+L;if(x===0)return{key:"Balanced",label:c("quotes.topicProfile.styleBalanced"),desc:c("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"};const C=q/x,h=_/x,k=L/x;return C>.5?{key:"Encyclopedia",label:c("quotes.topicProfile.styleEncyclopedia"),desc:c("quotes.topicProfile.styleEncyclopediaDesc"),icon:"i-heroicons-book-open-solid",colorClass:"text-indigo-600 dark:text-indigo-400"}:h>.45?{key:"Action",label:c("quotes.topicProfile.styleAction"),desc:c("quotes.topicProfile.styleActionDesc"),icon:"i-heroicons-rocket-launch-solid",colorClass:"text-orange-600 dark:text-orange-400"}:k>.3?{key:"Expressive",label:c("quotes.topicProfile.styleExpressive"),desc:c("quotes.topicProfile.styleExpressiveDesc"),icon:"i-heroicons-paint-brush-solid",colorClass:"text-pink-600 dark:text-pink-400"}:{key:"Balanced",label:c("quotes.topicProfile.styleBalanced"),desc:c("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"}}),M=b(()=>{if(r.topWords.length===0)return{label:c("quotes.topicProfile.expressionMixed"),desc:c("quotes.topicProfile.expressionMixedDesc"),icon:"i-heroicons-chat-bubble-left-right-solid",colorClass:"text-emerald-600 dark:text-emerald-400"};const I=r.topWords.reduce((L,x)=>L+x.word.length*x.count,0),q=r.topWords.reduce((L,x)=>L+x.count,0),_=I/q;return _<2.5?{label:c("quotes.topicProfile.expressionCasual"),desc:c("quotes.topicProfile.expressionCasualDesc"),icon:"i-heroicons-face-smile-solid",colorClass:"text-amber-600 dark:text-amber-400"}:_>3.5?{label:c("quotes.topicProfile.expressionFormal"),desc:c("quotes.topicProfile.expressionFormalDesc"),icon:"i-heroicons-academic-cap-solid",colorClass:"text-violet-600 dark:text-violet-400"}:{label:c("quotes.topicProfile.expressionMixed"),desc:c("quotes.topicProfile.expressionMixedDesc"),icon:"i-heroicons-chat-bubble-left-right-solid",colorClass:"text-emerald-600 dark:text-emerald-400"}}),$=b(()=>[{icon:"i-heroicons-fire-solid",label:c("quotes.topicProfile.hotTopic"),value:d.value[0]?.word??"-",subtext:d.value[0]?c("quotes.topicProfile.hotTopicDesc",{count:d.value[0].count}):"",colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-sparkles-solid",label:c("quotes.topicProfile.richness"),value:c("quotes.topicProfile.richnessValue",{value:v.value}),subtext:c("quotes.topicProfile.richnessDesc",{unique:r.uniqueWords.toLocaleString(),total:r.totalWords.toLocaleString()}),colorClass:"text-blue-600 dark:text-blue-400"},{icon:y.value.icon,label:c("quotes.topicProfile.chatStyle"),value:y.value.label,subtext:y.value.desc,colorClass:y.value.colorClass},{icon:M.value.icon,label:c("quotes.topicProfile.expressionStyle"),value:M.value.label,subtext:M.value.desc,colorClass:M.value.colorClass}]),D=["#6366f1","#ec4899","#f97316","#22c55e","#3b82f6","#8b5cf6","#14b8a6","#f43f5e"];return(I,q)=>{const _=we;return n(),Y(a(Mt),null,{default:j(()=>[e("div",vg,[e("div",yg,[e("div",hg,[e("div",fg,[u.value?(n(),i("p",xg,o(u.value),1)):R("",!0),e("div",bg,[e("span",kg,o(a(c)("quotes.topicProfile.heroPrefix")),1),e("span",_g,o(l.totalMessages.toLocaleString()),1),e("span",wg,o(a(c)("quotes.topicProfile.heroMiddle")),1)]),e("div",$g,[e("span",Cg,o(a(c)("quotes.topicProfile.heroMiddleSecond")),1),e("span",Sg,o(l.uniqueWords.toLocaleString()),1),e("span",Tg,o(a(c)("quotes.topicProfile.heroSuffix")),1)]),d.value.length>0?(n(),i("div",Mg,[e("span",Ig,o(a(c)("quotes.topicProfile.topTopicsPrefix")),1),(n(!0),i(Z,null,ce(d.value,(L,x)=>(n(),i(Z,{key:L.word},[e("span",{class:"cursor-pointer font-bold text-xl transition-opacity hover:opacity-70",style:Qe({color:D[x%D.length]}),onClick:C=>g("wordClick",L.word)},o(L.word),13,Lg),x<d.value.length-1?(n(),i("span",Dg,"·")):R("",!0)],64))),128))])):R("",!0)])]),m.value.words.length>0?(n(),i("div",Ag,[e("div",qg,[p(a(t),{data:m.value,height:"100%","max-words":50,"size-scale":.8,"draw-out-of-bound":!0,shape:"rectangle","color-scheme":"default",onWordClick:q[0]||(q[0]=L=>g("wordClick",L))},null,8,["data"])])])):R("",!0)])]),e("div",zg,[q[1]||(q[1]=e("div",{class:"mb-3 flex items-center justify-between"},[e("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Topic Profile ")],-1)),e("div",Rg,[(n(!0),i(Z,null,ce($.value,L=>(n(),i("div",{key:L.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[p(_,{name:L.icon,class:ne(["mt-0.5 h-3.5 w-3.5 shrink-0",L.colorClass])},null,8,["name","class"]),e("div",Pg,[e("div",{class:ne(["truncate font-mono text-sm font-black leading-tight tabular-nums",L.colorClass])},o(L.value),3),e("div",Eg,o(L.label),1),e("div",Bg,o(L.subtext),1)])]))),128))])]),e("div",jg,[e("div",Ug,[p(_,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),q[2]||(q[2]=e("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),e("span",Fg,o(a(c)("quotes.topicProfile.watermark")),1)])]),_:1})}}}),Ng={class:"px-5 py-4 sm:px-6"},Og={class:"mb-4 flex items-center gap-2"},Wg={class:"text-[15px] font-black tracking-tight text-gray-900 dark:text-white"},Hg={class:"flex flex-wrap justify-center gap-2"},Yg=["onClick"],Kg=pe({__name:"SharedTopicsCard",props:{sessionId:{},timeFilter:{},dictType:{},excludeWords:{}},emits:["wordClick"],setup(l,{emit:s}){const{t}=fe(),c=Nt(),r=l,g=s,u=b(()=>c.locale),d=f([]),m=f([]),v=b(()=>d.value.slice(0,20)),y=["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 M(){if(r.sessionId)try{m.value.length===0&&(m.value=await Ne().getMembers(r.sessionId));const $=[...m.value].sort((x,C)=>C.messageCount-x.messageCount).slice(0,2);if($.length<2){d.value=[];return}const D={sessionId:r.sessionId,locale:u.value,timeFilter:r.timeFilter?{startTs:r.timeFilter.startTs,endTs:r.timeFilter.endTs}:void 0,topN:100,minCount:2,posFilterMode:"meaningful",enableStopwords:!0,dictType:r.dictType??"default",excludeWords:r.excludeWords?.length?[...r.excludeWords]:void 0},[I,q]=await Promise.all([ht("/nlp/word-frequency",{...D,memberId:$[0].id}),ht("/nlp/word-frequency",{...D,memberId:$[1].id})]),_=new Map(q.words.map(x=>[x.word,x.count])),L=[];for(const x of I.words){const C=_.get(x.word);C&&L.push({word:x.word,countA:x.count,countB:C})}L.sort((x,C)=>C.countA+C.countB-(x.countA+x.countB)),d.value=L.slice(0,30)}catch($){console.error("加载共同话题数据失败:",$),d.value=[]}}return ge(()=>r.sessionId,()=>{m.value=[]}),ge(()=>[r.sessionId,r.timeFilter,r.dictType,r.excludeWords],()=>{M()},{immediate:!0,deep:!0}),($,D)=>{const I=we;return v.value.length>0?(n(),Y(a(tt),{key:0},{default:j(()=>[e("div",Ng,[e("div",Og,[p(I,{name:"i-heroicons-link",class:"h-4 w-4 text-emerald-500"}),e("span",Wg,o(a(t)("quotes.topicProfile.sharedTopics")),1)]),e("div",Hg,[(n(!0),i(Z,null,ce(v.value,(q,_)=>(n(),i("span",{key:q.word,class:ne(["cursor-pointer rounded-full px-3 py-1 text-xs font-bold transition-opacity hover:opacity-80",y[_%y.length]]),onClick:L=>g("wordClick",q.word)},o(q.word),11,Yg))),128))])])]),_:1})):R("",!0)}}}),qt="__ALL__",Qg=pe({__name:"UserSelect",props:{sessionId:{},modelValue:{}},emits:["update:modelValue"],setup(l,{emit:s}){const{t}=fe(),c=l,r=s,g=f([]),u=f(!1),d=b({get:()=>c.modelValue===null?qt:String(c.modelValue),set:y=>{r("update:modelValue",y===qt?null:parseInt(y))}}),m=b(()=>{const y=[{value:qt,label:t("common.userSelect.allMembers")}];return g.value.forEach(M=>{const $=M.groupNickname||M.accountName||M.platformId;y.push({value:String(M.id),label:`${$} (${M.messageCount})`})}),y});async function v(){if(c.sessionId){u.value=!0;try{const y=await Ne().getMembers(c.sessionId);g.value=y.sort((M,$)=>$.messageCount-M.messageCount)}catch(y){console.error("加载成员列表失败:",y)}finally{u.value=!1}}}return ge(()=>c.sessionId,()=>{r("update:modelValue",null),v()},{immediate:!0}),(y,M)=>{const $=Yt;return n(),Y($,{modelValue:d.value,"onUpdate:modelValue":M[0]||(M[0]=D=>d.value=D),items:m.value,loading:u.value,virtualize:{estimateSize:32,overscan:10},"value-key":"value",class:"w-48"},null,8,["modelValue","items","loading"])}}}),ga=qa("wordFilter",()=>{const l=f([]),s=f(null),t=f({}),c=f(!1);function r(){return`wf_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function g(L,x=[]){const C={id:r(),name:L,words:[...x],createdAt:Date.now()};return l.value.push(C),C}function u(L,x){const C=l.value.find(h=>h.id===L);C&&(x.name!==void 0&&(C.name=x.name),x.words!==void 0&&(C.words=[...x.words]))}function d(L){l.value=l.value.filter(x=>x.id!==L),s.value===L&&(s.value=null);for(const[x,C]of Object.entries(t.value))C===L&&delete t.value[x]}function m(L){s.value=L}function v(L,x){t.value[L]=x}function y(L){delete t.value[L]}function M(L){return L in t.value?t.value[L]:s.value}function $(L){const x=M(L);return x?l.value.find(h=>h.id===x)?.words??[]:[]}function D(L){return l.value.find(x=>x.id===L)}const I=b(()=>l.value.map(L=>({label:L.name,value:L.id,isDefault:L.id===s.value,wordCount:L.words.length})));function q(){c.value=!0}function _(){c.value=!1}return{schemes:l,defaultSchemeId:s,sessionSchemeOverrides:t,showWordFilterModal:c,schemeOptions:I,createScheme:g,updateScheme:u,deleteScheme:d,setDefaultScheme:m,setSessionScheme:v,clearSessionScheme:y,getActiveSchemeId:M,getExcludeWords:$,getSchemeById:D,openModal:q,closeModal:_}},{persist:!1,backendPersist:{pick:["schemes","defaultSchemeId","sessionSchemeOverrides"],key:"wordFilter"}}),Gg={class:"flex flex-col",style:{height:"520px"}},Jg={class:"flex items-center justify-between border-b border-gray-200 px-6 py-4 dark:border-white/5"},Xg={class:"flex items-center gap-3"},Zg={class:"flex h-9 w-9 items-center justify-center rounded-xl bg-linear-to-br from-pink-400 to-pink-600"},ep={class:"text-lg font-semibold text-gray-900 dark:text-white"},tp={class:"flex flex-1 overflow-hidden"},ap={class:"flex w-[200px] shrink-0 flex-col border-r border-gray-200 dark:border-white/5"},sp={class:"flex items-center justify-between px-3 py-2"},op={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},np={class:"flex-1 overflow-y-auto px-2 pb-2"},rp=["onClick"],lp={class:"truncate text-sm"},ip={class:"ml-auto text-xs text-gray-400 dark:text-gray-500"},cp={key:0,class:"px-3 py-8 text-center text-xs text-gray-400 dark:text-gray-500"},dp={class:"flex flex-1 flex-col overflow-hidden"},up={class:"flex-1 space-y-4 overflow-y-auto p-5"},mp={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},gp={class:"flex items-center gap-2"},pp={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},vp={class:"flex gap-2"},yp={class:"mb-1.5 flex items-center justify-between"},hp={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},fp={class:"ml-1 text-gray-400 dark:text-gray-500"},xp={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"},bp={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"},kp={class:"flex shrink-0 justify-end border-t border-gray-200 px-5 py-3 dark:border-white/5"},_p={key:1,class:"flex flex-1 flex-col items-center justify-center gap-3 text-gray-400 dark:text-gray-500"},wp={class:"text-sm"},$p=pe({__name:"WordFilterModal",setup(l){const{t:s}=fe(),t=ga(),c=b({get:()=>t.showWordFilterModal,set:x=>x?t.openModal():t.closeModal()}),r=f(null),g=f(""),u=f(""),d=f(null),m=b(()=>r.value?t.getSchemeById(r.value)??null:null),v=b(()=>r.value===t.defaultSchemeId);ge(c,x=>{x&&(t.schemes.length>0&&!r.value&&(r.value=t.schemes[0].id),y())}),ge(r,()=>{y(),u.value=""});function y(){g.value=m.value?.name??""}function M(){const x=t.createScheme(s("wordFilter.defaultSchemeName"));r.value=x.id,Ue(()=>{d.value?.focus(),d.value?.select()})}function $(){if(!r.value)return;const x=t.schemes.findIndex(C=>C.id===r.value);if(t.deleteScheme(r.value),t.schemes.length>0){const C=Math.min(x,t.schemes.length-1);r.value=t.schemes[C].id}else r.value=null}function D(){!r.value||!g.value.trim()||t.updateScheme(r.value,{name:g.value.trim()})}function I(){r.value&&(v.value?t.setDefaultScheme(null):t.setDefaultScheme(r.value))}function q(){if(!r.value||!u.value.trim())return;const C=u.value.trim().split(/[,,\n\r\t;;|、\s]+/).map(P=>P.trim()).filter(P=>P.length>0);if(C.length===0)return;const h=m.value;if(!h)return;const k=new Set(h.words.map(P=>P.toLowerCase())),S=C.filter(P=>!k.has(P.toLowerCase()));S.length>0&&t.updateScheme(r.value,{words:[...h.words,...S]}),u.value=""}function _(x){if(!r.value)return;const C=m.value;C&&t.updateScheme(r.value,{words:C.words.filter(h=>h!==x)})}function L(){r.value&&t.updateScheme(r.value,{words:[]})}return(x,C)=>{const h=we,k=ze,S=wt,P=Ht,B=He;return n(),Y(B,{open:c.value,"onUpdate:open":C[4]||(C[4]=A=>c.value=A),ui:{content:"max-w-3xl z-50"}},{content:j(()=>[e("div",Gg,[e("div",Jg,[e("div",Xg,[e("div",Zg,[p(h,{name:"i-heroicons-funnel",class:"h-4.5 w-4.5 text-white"})]),e("h2",ep,o(a(s)("wordFilter.title")),1)]),p(k,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:C[0]||(C[0]=A=>c.value=!1)})]),e("div",tp,[e("div",ap,[e("div",sp,[e("span",op,o(a(s)("wordFilter.schemeList")),1),p(k,{icon:"i-heroicons-plus",size:"xs",variant:"ghost",color:"primary",onClick:M})]),e("div",np,[(n(!0),i(Z,null,ce(a(t).schemes,A=>(n(),i("div",{key:A.id,class:ne(["group mb-1 flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 transition-colors",r.value===A.id?"bg-primary-50 text-primary-700 dark:bg-primary-900/20 dark:text-primary-300":"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-white/5"]),onClick:w=>r.value=A.id},[A.id===a(t).defaultSchemeId?(n(),Y(h,{key:0,name:"i-heroicons-star-solid",class:"h-3.5 w-3.5 shrink-0 text-amber-500"})):R("",!0),e("span",lp,o(A.name),1),e("span",ip,o(A.words.length),1)],10,rp))),128)),a(t).schemes.length===0?(n(),i("div",cp,o(a(s)("wordFilter.emptyScheme")),1)):R("",!0)])]),e("div",dp,[m.value?(n(),i(Z,{key:0},[e("div",up,[e("div",null,[e("label",mp,o(a(s)("wordFilter.schemeName")),1),p(S,{ref_key:"nameInputRef",ref:d,modelValue:g.value,"onUpdate:modelValue":C[1]||(C[1]=A=>g.value=A),size:"sm",placeholder:a(s)("wordFilter.schemeNamePlaceholder"),onBlur:D,onKeydown:Ge(D,["enter"])},null,8,["modelValue","placeholder"])]),e("div",gp,[p(k,{size:"xs",variant:v.value?"solid":"soft",color:v.value?"warning":"neutral",icon:v.value?"i-heroicons-star-solid":"i-heroicons-star",onClick:I},{default:j(()=>[ee(o(v.value?a(s)("wordFilter.isDefault"):a(s)("wordFilter.setDefault")),1)]),_:1},8,["variant","color","icon"]),p(k,{size:"xs",variant:"soft",color:"error",icon:"i-heroicons-trash",onClick:$},{default:j(()=>[ee(o(a(s)("wordFilter.deleteScheme")),1)]),_:1})]),e("div",null,[e("label",pp,o(a(s)("wordFilter.addWords")),1),e("div",vp,[p(S,{modelValue:u.value,"onUpdate:modelValue":C[2]||(C[2]=A=>u.value=A),size:"sm",class:"flex-1",placeholder:a(s)("wordFilter.addWordsPlaceholder"),onKeydown:Ge(q,["enter"])},null,8,["modelValue","placeholder"]),p(k,{size:"sm",color:"primary",icon:"i-heroicons-plus",onClick:q},{default:j(()=>[ee(o(a(s)("wordFilter.add")),1)]),_:1})])]),e("div",null,[e("div",yp,[e("label",hp,[ee(o(a(s)("wordFilter.wordList"))+" ",1),e("span",fp,"("+o(m.value.words.length)+")",1)]),m.value.words.length>0?(n(),Y(k,{key:0,size:"xs",variant:"ghost",color:"error",onClick:L},{default:j(()=>[ee(o(a(s)("wordFilter.clearAll")),1)]),_:1})):R("",!0)]),m.value.words.length>0?(n(),i("div",xp,[(n(!0),i(Z,null,ce(m.value.words,A=>(n(),Y(P,{key:A,color:"neutral",variant:"subtle",class:"group/badge cursor-default gap-1 pr-1"},{default:j(()=>[ee(o(A)+" ",1),p(h,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5 cursor-pointer text-gray-400 transition-colors hover:text-red-500",onClick:w=>_(A)},null,8,["onClick"])]),_:2},1024))),128))])):(n(),i("div",bp,o(a(s)("wordFilter.emptyWords")),1))])]),e("div",kp,[p(k,{color:"primary",variant:"soft",onClick:C[3]||(C[3]=A=>c.value=!1)},{default:j(()=>[ee(o(a(s)("wordFilter.close")),1)]),_:1})])],64)):(n(),i("div",_p,[p(h,{name:"i-heroicons-funnel",class:"h-10 w-10"}),e("p",wp,o(a(s)("wordFilter.selectOrCreate")),1),p(k,{size:"sm",color:"primary",variant:"soft",icon:"i-heroicons-plus",onClick:M},{default:j(()=>[ee(o(a(s)("wordFilter.createScheme")),1)]),_:1})]))])])])]),_:1},8,["open"])}}}),Cp={class:"main-content mx-auto max-w-[920px] space-y-6 p-6"},Sp={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"},Tp={class:"flex min-w-0 items-start gap-3"},Mp={class:"min-w-0 text-sm text-primary-700 dark:text-primary-300"},Ip={class:"flex shrink-0 flex-wrap gap-2"},Lp={key:1,class:"space-y-6"},Dp={class:"flex gap-6 p-4 sm:p-6"},Ap={class:"flex min-w-0 flex-1 flex-col"},qp={class:"relative w-full",style:{"aspect-ratio":"16 / 9"}},zp={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"},Rp={class:"text-xs font-medium"},Pp={class:"px-4 text-center text-[11px]"},Ep={class:"mt-2 text-center text-xs text-gray-500 dark:text-gray-400"},Bp={class:"w-[280px] shrink-0 space-y-4"},jp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Up={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Fp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Vp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Np={class:"space-y-2"},Op={class:"text-xs text-gray-400 dark:text-gray-500"},Wp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Hp={class:"flex items-center"},Yp={key:0,class:"space-y-2"},Kp={class:"flex items-center justify-between"},Qp={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},Gp={class:"flex gap-1"},Jp={class:"flex max-h-[360px] flex-wrap gap-1.5 overflow-y-auto"},Xp={key:0,class:"ml-1 opacity-60"},Zp={class:"mb-2 flex items-center justify-between"},ev={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},tv={key:0,class:"mt-1 text-xs text-gray-400 dark:text-gray-500"},av={class:"space-y-4"},sv={class:"text-sm text-gray-600 dark:text-gray-300"},ov={class:"flex justify-end gap-2"},nv="default",ea="chatlab_zhTW_dict_prompt_dismissed",Ob=pe({__name:"WordcloudTab",props:{sessionId:{},timeFilter:{},memberId:{},showSharedTopics:{type:Boolean}},setup(l){const s=na(()=>_t(()=>import("./EChartWordcloud-DU3ZYdgz.js"),__vite__mapDeps([5,6,7,8,1]))),{t}=fe(),c=Nt(),r=ct(),g=ga(),u=Je(),d=l,m=f(!1),v=f([]),y=f({totalMessages:0,totalWords:0,uniqueWords:0}),M=f(1.25),$=f(150),D=b(()=>{const ie=v.value.slice(0,$.value),z=ie.reduce((O,J)=>O+J.count,0);return{words:ie.map(O=>({word:O.word,count:O.count,percentage:z>0?Math.round(O.count/z*1e4)/100:0}))}}),I=f("meaningful"),q=f(!0),_=f([]),L=f([]),x=f(new Map),C=["n","nr","ns","nt","nz","nw","vn","a","an"],h=f([]),k=b(()=>D.value.words.map(ie=>({word:ie.word,count:ie.count,percentage:ie.percentage??0}))),S=b(()=>[...x.value.entries()].map(([ie,z])=>({tag:ie,count:z}))),P=f(null),B=b({get:()=>g.getActiveSchemeId(d.sessionId),set:ie=>g.setSessionScheme(d.sessionId,ie)}),A=b(()=>[{label:t("wordFilter.noFilter"),value:"__none__"},...g.schemeOptions.map(ie=>({label:ie.isDefault?`${ie.label} ★`:ie.label,value:ie.value}))]),w=b({get:()=>B.value??"__none__",set:ie=>{B.value=ie==="__none__"?null:ie}}),T=b(()=>g.getExcludeWords(d.sessionId)),H=f("default"),le=f([]),W=f(!1),ue=f(null),ve=f(!1),G=f(!1),F=b(()=>c.locale),X=b(()=>c.locale==="zh-TW"),me=b(()=>F.value.startsWith("zh")),ye=b(()=>le.value.filter(ie=>ie.downloaded).map(ie=>({label:t(`quotes.wordcloud.dict.${ie.id==="zh-CN"?"zhCN":ie.id==="zh-TW"?"zhTW":ie.id}`),value:ie.id}))),K=b(()=>le.value.some(ie=>ie.downloaded)),E=b(()=>!me.value||G.value),V=b(()=>le.value.filter(ie=>!ie.downloaded));async function oe(){try{le.value=await Jt("/nlp/dicts"),X.value&&H.value==="default"&&le.value.find(O=>O.id==="zh-TW")?.downloaded&&(H.value="zh-TW"),le.value.find(z=>z.id==="zh-CN")?.downloaded&&H.value==="default"&&(H.value="zh-CN")}catch(ie){console.error("Failed to get dict list:",ie)}finally{G.value=!0}}async function he(ie){W.value=!0,ue.value=ie;try{const z=await za(`/nlp/dicts/${ie}/download`);z.success?(await oe(),H.value=ie,u.success(t("quotes.wordcloud.dict.downloadSuccess"))):u.fail(t("quotes.wordcloud.dict.downloadFailed"),{description:z.error})}catch{u.fail(t("quotes.wordcloud.dict.downloadFailed"))}finally{W.value=!1,ue.value=null,ve.value=!1}}function ke(){ve.value=!1,localStorage.setItem(ea,"true")}function be(){const ie=le.value.find(z=>z.id==="zh-TW");X.value&&ie&&!ie.downloaded&&!localStorage.getItem(ea)&&(ve.value=!0)}const ae=b(()=>[{label:t("quotes.wordcloud.posFilter.all"),value:"all"},{label:t("quotes.wordcloud.posFilter.meaningful"),value:"meaningful"},{label:t("quotes.wordcloud.posFilter.custom"),value:"custom"}]),se=[{label:"80",value:80},{label:"100",value:100},{label:"150",value:150},{label:"200",value:200},{label:"300",value:300}],xe=Math.max(...se.map(ie=>ie.value)),de=b(()=>[{label:t("quotes.wordcloud.size.small"),value:.75},{label:t("quotes.wordcloud.size.medium"),value:1},{label:t("quotes.wordcloud.size.large"),value:1.25},{label:t("quotes.wordcloud.size.xlarge"),value:1.5}]),_e=b(()=>L.value.map(ie=>({label:ie.name,tag:ie.tag,value:ie.tag,count:x.value.get(ie.tag)||0,meaningful:ie.meaningful})));async function Ie(){try{const ie=await Jt("/nlp/pos-tags");L.value=ie,_.value=ie.filter(z=>z.meaningful).map(z=>z.tag)}catch(ie){console.error("加载词性标签失败:",ie)}}let Le=0;async function Se(){if(!d.sessionId||!E.value)return;const ie=++Le;try{const z=await ht("/nlp/word-frequency",{sessionId:d.sessionId,locale:F.value,timeFilter:d.timeFilter?{startTs:d.timeFilter.startTs,endTs:d.timeFilter.endTs}:void 0,memberId:P.value??void 0,topN:50,minCount:2,posFilterMode:"custom",customPosTags:[...C],enableStopwords:!0,dictType:H.value,excludeWords:T.value.length>0?[...T.value]:void 0});if(ie!==Le)return;h.value=z.words.map(O=>({word:O.word,count:O.count,percentage:O.percentage}))}catch(z){if(console.error("加载话题迷你词云数据失败:",z),ie!==Le)return;h.value=[]}}let qe=0;async function Re(){if(!d.sessionId||!E.value)return;const ie=++qe;v.value.length===0&&(m.value=!0);try{const z=await ht("/nlp/word-frequency",{sessionId:d.sessionId,locale:F.value,timeFilter:d.timeFilter?{startTs:d.timeFilter.startTs,endTs:d.timeFilter.endTs}:void 0,memberId:P.value??void 0,topN:xe,minCount:2,posFilterMode:I.value,customPosTags:I.value==="custom"?[..._.value]:void 0,enableStopwords:q.value,dictType:H.value,excludeWords:T.value.length>0?[...T.value]:void 0});if(ie!==qe)return;if(v.value=z.words.map(O=>({word:O.word,count:O.count,percentage:O.percentage})),y.value={totalMessages:z.totalMessages,totalWords:z.totalWords,uniqueWords:z.uniqueWords},z.posTagStats){const O=new Map;for(const J of z.posTagStats)O.set(J.tag,J.count);x.value=O}}catch(z){if(console.error("加载词频数据失败:",z),ie!==qe)return;v.value=[]}finally{ie===qe&&(m.value=!1)}}ge(()=>d.sessionId,()=>{P.value=null,v.value=[],h.value=[],y.value={totalMessages:0,totalWords:0,uniqueWords:0},x.value=new Map}),ge(()=>[d.sessionId,d.timeFilter,P.value,I.value,q.value,H.value,T.value,E.value],()=>{Re()},{immediate:!0,deep:!0}),ge(()=>[d.sessionId,d.timeFilter,P.value,H.value,T.value,E.value],()=>{Se()},{immediate:!0,deep:!0}),ge(_,()=>{I.value==="custom"&&Re()},{deep:!0}),ge(F,()=>{Re()});function Ee(ie){r.openChatRecordDrawer({keywords:[ie]})}return je(async()=>{Ie(),await oe(),be()}),(ie,z)=>{const O=we,J=ze,N=la,U=Ht,re=He;return n(),i("div",Cp,[me.value&&!K.value?(n(),i("div",Sp,[e("div",Tp,[p(O,{name:"i-heroicons-information-circle",class:"mt-0.5 shrink-0 text-xl text-primary-500"}),e("p",Mp,o(a(t)("quotes.wordcloud.dict.needDownload")),1)]),e("div",Ip,[(n(!0),i(Z,null,ce(le.value,Q=>(n(),Y(J,{key:Q.id,size:"sm",color:"primary",loading:W.value&&ue.value===Q.id,disabled:W.value&&ue.value!==Q.id,icon:"i-heroicons-arrow-down-tray",onClick:te=>he(Q.id)},{default:j(()=>[ee(o(a(t)(`quotes.wordcloud.dict.download_${Q.id}`,Q.label)),1)]),_:2},1032,["loading","disabled","onClick"]))),128))])])):R("",!0),E.value?(n(),i("div",Lp,[m.value&&k.value.length===0?(n(),Y(a(mt),{key:0,text:a(t)("quotes.wordcloud.loading"),class:"py-8"},null,8,["text"])):R("",!0),p(Vg,{"total-messages":y.value.totalMessages,"total-words":y.value.totalWords,"unique-words":y.value.uniqueWords,"top-words":k.value,"topic-words":h.value,"pos-tag-stats":S.value,"time-filter":d.timeFilter,onWordClick:Ee},null,8,["total-messages","total-words","unique-words","top-words","topic-words","pos-tag-stats","time-filter"]),d.showSharedTopics?(n(),Y(Kg,{key:1,"session-id":d.sessionId,"time-filter":d.timeFilter,"dict-type":H.value,"exclude-words":T.value,onWordClick:Ee},null,8,["session-id","time-filter","dict-type","exclude-words"])):R("",!0),p(a(Oe),{title:a(t)("quotes.wordcloud.stats.wordsLabel"),"show-divider":!1},{default:j(()=>[e("div",Dp,[e("div",Ap,[e("div",qp,[m.value?(n(),Y(a(mt),{key:0,text:a(t)("quotes.wordcloud.loading"),class:"absolute inset-0 z-10 rounded-lg bg-white/80 dark:bg-page-dark/80"},null,8,["text"])):k.value.length===0?(n(),i("div",zp,[p(O,{name:"i-heroicons-chat-bubble-bottom-center-text",class:"text-2xl"}),e("p",Rp,o(a(t)("quotes.wordcloud.empty.title")),1),e("p",Pp,o(a(t)("quotes.wordcloud.empty.description")),1)])):(n(),Y(a(s),{key:2,data:D.value,height:"100%","max-words":$.value,"color-scheme":nv,"size-scale":M.value,loading:m.value,onWordClick:Ee},null,8,["data","max-words","size-scale","loading"]))]),e("p",Ep,o(a(t)("quotes.wordcloud.stats.clickHint")),1)]),e("div",Bp,[e("div",null,[e("h4",jp,o(a(t)("quotes.wordcloud.config.maxWords")),1),p(a(st),{modelValue:$.value,"onUpdate:modelValue":z[0]||(z[0]=Q=>$.value=Q),size:"xs",items:se},null,8,["modelValue"])]),e("div",null,[e("h4",Up,o(a(t)("quotes.wordcloud.config.sizeScale")),1),p(a(st),{modelValue:M.value,"onUpdate:modelValue":z[1]||(z[1]=Q=>M.value=Q),size:"xs",items:de.value},null,8,["modelValue","items"])]),e("div",null,[e("h4",Fp,o(a(t)("quotes.wordcloud.config.userFilter")),1),p(Qg,{modelValue:P.value,"onUpdate:modelValue":z[2]||(z[2]=Q=>P.value=Q),"session-id":d.sessionId,class:"w-full"},null,8,["modelValue","session-id"])]),e("div",null,[e("h4",Vp,o(a(t)("quotes.wordcloud.config.dict")),1),e("div",Np,[ye.value.length>1?(n(),Y(a(st),{key:0,modelValue:H.value,"onUpdate:modelValue":z[3]||(z[3]=Q=>H.value=Q),size:"xs",items:ye.value},null,8,["modelValue","items"])):R("",!0),(n(!0),i(Z,null,ce(V.value,Q=>(n(),i("div",{key:Q.id,class:"flex items-center gap-2"},[p(J,{size:"xs",variant:"soft",color:"primary",loading:W.value&&ue.value===Q.id,disabled:W.value&&ue.value!==Q.id,icon:"i-heroicons-arrow-down-tray",onClick:te=>he(Q.id)},{default:j(()=>[ee(o(a(t)(`quotes.wordcloud.dict.download_${Q.id}`,a(t)("quotes.wordcloud.dict.download"))),1)]),_:2},1032,["loading","disabled","onClick"]),e("span",Op,o(a(t)("quotes.wordcloud.dict.downloadHint")),1)]))),128))])]),e("div",null,[e("h4",Wp,o(a(t)("quotes.wordcloud.config.posFilter")),1),p(a(st),{modelValue:I.value,"onUpdate:modelValue":z[4]||(z[4]=Q=>I.value=Q),size:"xs",items:ae.value},null,8,["modelValue","items"])]),e("div",Hp,[p(N,{modelValue:q.value,"onUpdate:modelValue":z[5]||(z[5]=Q=>q.value=Q),label:a(t)("quotes.wordcloud.config.enableStopwords")},null,8,["modelValue","label"])]),I.value==="custom"?(n(),i("div",Yp,[e("div",Kp,[e("h4",Qp,o(a(t)("quotes.wordcloud.posFilter.customHint")),1),e("div",Gp,[p(J,{size:"xs",variant:"ghost",color:"neutral",onClick:z[6]||(z[6]=Q=>_.value=L.value.filter(te=>te.meaningful).map(te=>te.tag))},{default:j(()=>[ee(o(a(t)("quotes.wordcloud.posFilter.selectMeaningful")),1)]),_:1}),p(J,{size:"xs",variant:"ghost",color:"neutral",onClick:z[7]||(z[7]=Q=>_.value=L.value.map(te=>te.tag))},{default:j(()=>[ee(o(a(t)("quotes.wordcloud.posFilter.selectAll")),1)]),_:1}),p(J,{size:"xs",variant:"ghost",color:"neutral",onClick:z[8]||(z[8]=Q=>_.value=[])},{default:j(()=>[ee(o(a(t)("quotes.wordcloud.posFilter.clearAll")),1)]),_:1})])]),e("div",Jp,[(n(!0),i(Z,null,ce(_e.value,Q=>(n(),Y(U,{key:Q.value,color:_.value.includes(Q.value)?"primary":"neutral",variant:_.value.includes(Q.value)?"solid":"outline",class:"cursor-pointer select-none transition-colors",onClick:()=>{_.value.includes(Q.value)?_.value=_.value.filter(te=>te!==Q.value):_.value=[..._.value,Q.value]}},{default:j(()=>[ee(o(Q.label)+" ",1),Q.count>0?(n(),i("span",Xp,"("+o(Q.count)+")",1)):R("",!0)]),_:2},1032,["color","variant","onClick"]))),128))])])):R("",!0),e("div",null,[e("div",Zp,[e("h4",ev,o(a(t)("wordFilter.filterScheme")),1),p(J,{size:"xs",variant:"ghost",color:"neutral",icon:"i-heroicons-cog-6-tooth","aria-label":a(t)("wordFilter.manage"),onClick:z[9]||(z[9]=Q=>a(g).openModal())},null,8,["aria-label"])]),p(a(st),{modelValue:w.value,"onUpdate:modelValue":z[10]||(z[10]=Q=>w.value=Q),size:"xs",items:A.value},null,8,["modelValue","items"]),T.value.length>0?(n(),i("p",tv,o(a(t)("wordFilter.activeCount",{count:T.value.length})),1)):R("",!0)])])])]),_:1},8,["title"])])):R("",!0),p(re,{open:ve.value,"onUpdate:open":z[12]||(z[12]=Q=>ve.value=Q),title:a(t)("quotes.wordcloud.dict.promptTitle")},{body:j(()=>[e("div",av,[e("p",sv,o(a(t)("quotes.wordcloud.dict.promptDescription")),1),e("div",ov,[p(J,{variant:"ghost",color:"neutral",onClick:ke},{default:j(()=>[ee(o(a(t)("quotes.wordcloud.dict.promptLater")),1)]),_:1}),p(J,{color:"primary",loading:W.value,onClick:z[11]||(z[11]=Q=>he("zh-TW"))},{default:j(()=>[ee(o(a(t)("quotes.wordcloud.dict.promptDownload")),1)]),_:1},8,["loading"])])])]),_:1},8,["open","title"]),p($p)])}}}),rv={class:"flex h-full flex-col"},lv={class:"flex-1 min-h-0 overflow-hidden"},iv={key:1,class:"h-full overflow-auto"},cv={class:"main-content mx-auto max-w-3xl p-6"},dv=pe({__name:"AITab",props:{sessionId:{},sessionName:{},timeFilter:{},chatType:{},mode:{}},setup(l,{expose:s}){const{t}=fe(),c=Oa(),r=l,g=b(()=>r.mode==="sql-only"?[{id:"sql-lab",label:t("ai.tab.sqlLab"),icon:"i-heroicons-command-line"},{id:"keyword",label:t("analysis.subTabs.quotes.keywordAnalysis"),icon:"i-heroicons-magnifying-glass"}]:[{id:"chat-explorer",label:t("ai.tab.chatExplorer"),icon:"i-heroicons-chat-bubble-left-ellipsis"},{id:"sql-lab",label:t("ai.tab.sqlLab"),icon:"i-heroicons-command-line"}]),u=f(r.mode==="sql-only"?"sql-lab":c.query.aiSubTab||"chat-explorer");ge(()=>c.query.aiSubTab,v=>{if(r.mode==="sql-only"){(v==="keyword"||v==="sql-lab")&&(u.value=v);return}(v==="chat-explorer"||v==="sql-lab")&&(u.value=v)});const d=f(null);function m(){d.value?.refreshConfig()}return s({refreshAIConfig:m}),(v,y)=>(n(),i("div",rv,[p(a(oa),{modelValue:u.value,"onUpdate:modelValue":y[0]||(y[0]=M=>u.value=M),items:g.value,"persist-key":"aiTab"},null,8,["modelValue","items"]),e("div",lv,[p(rt,{name:"fade",mode:"out-in"},{default:j(()=>[u.value==="chat-explorer"?(n(),Y(a(Eu),{key:0,ref_key:"chatExplorerRef",ref:d,class:"h-full","session-id":l.sessionId,"session-name":l.sessionName,"time-filter":l.timeFilter,"chat-type":l.chatType},null,8,["session-id","session-name","time-filter","chat-type"])):u.value==="keyword"?(n(),i("div",iv,[e("div",cv,[p(a(pg),{"session-id":r.sessionId,"time-filter":r.timeFilter},null,8,["session-id","time-filter"])])])):(n(),Y(wm,{key:2,class:"h-full","session-id":r.sessionId,"chat-type":r.chatType},null,8,["session-id","chat-type"]))]),_:1})])]))}}),Wb=lt(dv,[["__scopeId","data-v-e5523cf0"]]),uv={class:"flex h-full items-center justify-center"},mv={class:"max-w-sm text-center"},gv={class:"mt-3 text-sm text-gray-400 dark:text-gray-500"},pv=["href"],Hb=pe({__name:"MemoryTab",props:{sessionId:{},sessionName:{}},setup(l){const{t:s,te:t}=fe(),c=b(()=>t("analysis.memory.joinLink")?s("analysis.memory.joinLink"):"");return(r,g)=>{const u=we;return n(),i("div",uv,[e("div",mv,[p(u,{name:"i-heroicons-light-bulb",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),e("p",gv,o(a(s)("analysis.memory.comingSoon")),1),c.value?(n(),i("a",{key:0,href:c.value,target:"_blank",rel:"noopener noreferrer",class:"mt-2 inline-block text-sm text-primary-500 hover:text-primary-600 dark:text-primary-400 dark:hover:text-primary-300"},o(c.value),9,pv)):R("",!0)])])}}}),vv={class:"h-full p-3"},yv={class:"relative z-20 flex items-center gap-2 border-b border-gray-200 px-4 py-2 dark:border-gray-700"},hv={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"},fv={class:"flex-1 overflow-auto"},xv={key:0,class:"flex h-full items-center justify-center"},bv={class:"text-sm text-gray-400"},kv={key:1,class:"w-full border-collapse text-xs"},_v={class:"sticky top-0 bg-gray-50 dark:bg-page-dark"},wv={class:"font-mono text-xs font-medium text-gray-700 dark:text-gray-300"},$v={class:"text-[10px] leading-tight text-gray-400"},Cv={class:"border-b border-r border-gray-100 px-2 py-1.5 text-gray-400 dark:border-gray-800"},Sv=["title"],Tv=["onUpdate:modelValue"],Mv={class:"w-full truncate px-2 py-1.5"},Iv={key:0,class:"italic text-gray-400"},Lv={key:1},Dv={class:"border-b border-gray-100 px-2 py-1.5 text-center dark:border-gray-800"},Av={key:0,class:"flex items-center justify-center gap-1"},qv={key:1,class:"flex items-center justify-center gap-1"},zv={class:"flex items-center justify-between border-t border-gray-200 px-4 py-2 dark:border-gray-700"},Rv={class:"text-xs text-gray-500 dark:text-gray-400"},Pv={key:0,class:"flex items-center gap-3"},Ev={class:"text-xs text-gray-500 dark:text-gray-400"},yt=100,Bv=pe({__name:"TableBrowser",props:{sessionId:{}},setup(l){const s=["member","meta","message","message_context","member_name_history"],{t,locale:c}=fe(),r=l,g=f(localStorage.getItem("debug_dbSource")||"chat"),u=f([]),d=f(""),m=f(null),v=f(!1),y=f(null),M=f(1),$=f(0),D=b(()=>Math.max(1,Math.ceil($.value/yt))),I=f(null),q=f({}),_=f(!1),L=b(()=>g.value==="ai"),x=f([]),C=f(""),h=b(()=>L.value&&d.value==="ai_message"&&x.value.length>0),k=b(()=>{const K={label:t("analysis.debug.tableBrowser.allConversations"),value:"__all__"},E=x.value.map(V=>({label:V.title||V.id.slice(0,16),value:V.id}));return[K,...E]});async function S(){if(!L.value){x.value=[];return}try{const K=r.sessionId.replace(/'/g,"''"),E=await Fe().executeAiSQL(`SELECT id, title FROM ai_chat WHERE session_id = '${K}' ORDER BY updated_at DESC`);x.value=E.rows.map(V=>({id:String(V[0]),title:V[1]?String(V[1]):null})),C.value="__all__"}catch{x.value=[]}}const P=b(()=>[{label:t("analysis.debug.tableBrowser.chatDb"),value:"chat"},{label:t("analysis.debug.tableBrowser.aiDb"),value:"ai"}]),B=b(()=>{const K=[...u.value];return K.sort((E,V)=>{const oe=s.indexOf(E.name),he=s.indexOf(V.name);return oe!==-1&&he!==-1?oe-he:oe!==-1?-1:he!==-1?1:0}),K}),A=b(()=>B.value.map(K=>({label:K.name,value:K.name})));async function w(K){return g.value==="ai"?await Fe().executeAiSQL(K):await Ne().executeSQL(r.sessionId,K)}async function T(){try{if(g.value==="ai"?u.value=await Fe().getAiSchema():u.value=await Ne().getSchema(r.sessionId),B.value.length>0){const K=L.value?"ai_message":B.value[0].name;d.value=B.value.some(E=>E.name===K)?K:B.value[0].name}else d.value="",m.value=null}catch(K){console.error("Failed to load schema:",K)}}function H(){if(!L.value)return"";const K=r.sessionId.replace(/'/g,"''"),E=d.value;return E==="ai_chat"?` WHERE "session_id" = '${K}'`:E==="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" = '${K}')`:""}async function le(){if(d.value){v.value=!0,y.value=null,I.value=null;try{const K=H(),E=await w(`SELECT COUNT(*) as cnt FROM "${d.value}"${K}`);$.value=E?.rows?.[0]?.[0]??0;const V=(M.value-1)*yt;m.value=await w(`SELECT * FROM "${d.value}"${K} ORDER BY rowid DESC LIMIT ${yt} OFFSET ${V}`)}catch(K){y.value=K.message||String(K),m.value=null}finally{v.value=!1}}}function W(K){if(!m.value)return;I.value=K;const E=m.value.rows[K],V={};m.value.columns.forEach((oe,he)=>{V[oe]=E[he]==null?"":String(E[he])}),q.value=V}function ue(){I.value=null,q.value={}}async function ve(){if(I.value===null||!m.value)return;const K=d.value,E=u.value.find(se=>se.name===K);if(!E)return;const V=E.columns.find(se=>se.pk);if(!V){y.value="No primary key found for this table";return}const oe=m.value.rows[I.value],he=m.value.columns.indexOf(V.name),ke=oe[he],be=m.value.columns.filter(se=>se!==V.name).map(se=>`"${se}" = '${q.value[se].replace(/'/g,"''")}'`).join(", "),ae=`UPDATE "${K}" SET ${be} WHERE "${V.name}" = '${String(ke).replace(/'/g,"''")}'`;try{await w(ae),ue(),await le()}catch(se){y.value=se.message||String(se)}}async function G(K){if(!m.value)return;const E=d.value,V=u.value.find(se=>se.name===E);if(!V)return;const oe=V.columns.find(se=>se.pk);if(!oe){y.value="No primary key found for this table";return}const he=m.value.rows[K],ke=m.value.columns.indexOf(oe.name),be=he[ke],ae=`DELETE FROM "${E}" WHERE "${oe.name}" = '${String(be).replace(/'/g,"''")}'`;try{await w(ae),await le()}catch(se){y.value=se.message||String(se)}}function F(K){confirm(t("analysis.debug.tableBrowser.confirmDelete"))&&G(K)}async function X(){if(confirm(t("analysis.debug.tableBrowser.confirmClearDebug"))){_.value=!0;try{(await Fe().clearDebugContext()).success&&await le()}catch(K){y.value=K.message||String(K)}finally{_.value=!1}}}function me(K){navigator.clipboard.writeText(K)}function ye(K,E,V){if(!m.value)return[];const oe=K==null?"NULL":String(K),he=m.value.rows[V],ke={};return m.value.columns.forEach((be,ae)=>{ke[be]=he[ae]}),[[{label:t("analysis.debug.tableBrowser.copyCell"),class:"p-2",onSelect:()=>me(oe)},{label:t("analysis.debug.tableBrowser.editRow"),class:"p-2",onSelect:()=>W(V)},{label:t("analysis.debug.tableBrowser.copyRow"),class:"p-2",onSelect:()=>me(JSON.stringify(ke,null,2))},{label:t("analysis.debug.tableBrowser.deleteRow"),class:"p-2 text-red-600 dark:text-red-400",onSelect:()=>G(V)}]]}return ge(g,K=>{localStorage.setItem("debug_dbSource",K),d.value="",m.value=null,$.value=0,M.value=1,C.value="",T(),S()}),ge(d,K=>{K&&(M.value=1,le())}),ge(C,()=>{d.value==="ai_message"&&(M.value=1,le())}),ge(M,()=>{le()}),je(async()=>{await Promise.all([T(),S()]),d.value&&await le()}),(K,E)=>{const V=Yt,oe=ze,he=ia;return n(),i("div",vv,[p(a(tt),{shadow:!1,class:"flex h-full min-w-0 flex-col"},{default:j(()=>[e("div",yv,[p(a(st),{modelValue:g.value,"onUpdate:modelValue":E[0]||(E[0]=ke=>g.value=ke),items:P.value,size:"xs"},null,8,["modelValue","items"]),E[5]||(E[5]=e("div",{class:"mx-1 h-4 w-px bg-gray-200 dark:bg-gray-700"},null,-1)),e("div",{class:ne([L.value?"max-w-[50%]":"flex-1","min-w-0"])},[p(a(st),{modelValue:d.value,"onUpdate:modelValue":E[1]||(E[1]=ke=>d.value=ke),items:A.value,size:"xs"},null,8,["modelValue","items"])],2),h.value?(n(),Y(V,{key:0,modelValue:C.value,"onUpdate:modelValue":E[2]||(E[2]=ke=>C.value=ke),items:k.value,"value-key":"value",class:"w-48",size:"xs",ui:{content:"z-50"}},null,8,["modelValue","items"])):R("",!0),E[6]||(E[6]=e("div",{class:"flex-1"},null,-1)),L.value&&d.value==="ai_message"?(n(),Y(oe,{key:1,variant:"ghost",size:"xs",color:"error",icon:"i-heroicons-trash",loading:_.value,onClick:X},{default:j(()=>[ee(o(a(t)("analysis.debug.tableBrowser.clearDebugContext")),1)]),_:1},8,["loading"])):R("",!0),p(oe,{variant:"ghost",size:"xs",icon:"i-heroicons-arrow-path",loading:v.value,onClick:le},{default:j(()=>[ee(o(a(t)("analysis.debug.tableBrowser.refresh")),1)]),_:1},8,["loading"])]),y.value?(n(),i("div",hv,o(y.value),1)):R("",!0),e("div",fv,[!m.value&&!v.value?(n(),i("div",xv,[e("p",bv,o(a(t)("analysis.debug.tableBrowser.noData")),1)])):m.value?(n(),i("table",kv,[e("thead",_v,[e("tr",null,[E[7]||(E[7]=e("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)),(n(!0),i(Z,null,ce(m.value.columns,ke=>(n(),i("th",{key:ke,class:"border-b border-r border-gray-200 px-2 py-1.5 text-left dark:border-gray-700"},[e("div",wv,o(ke),1),e("div",$v,o(a(Gt)(d.value,ke,a(c))),1)]))),128)),E[8]||(E[8]=e("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))])]),e("tbody",null,[(n(!0),i(Z,null,ce(m.value.rows,(ke,be)=>(n(),i("tr",{key:be,class:"transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[e("td",Cv,o((M.value-1)*yt+be+1),1),(n(!0),i(Z,null,ce(ke,(ae,se)=>(n(),i("td",{key:se,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:ae==null?"NULL":String(ae)},[I.value===be?Ve((n(),i("input",{key:0,"onUpdate:modelValue":xe=>q.value[m.value.columns[se]]=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,Tv)),[[ot,q.value[m.value.columns[se]]]]):(n(),Y(he,{key:1,items:ye(ae,se,be)},{default:j(()=>[e("div",Mv,[ae==null?(n(),i("span",Iv,"NULL")):(n(),i("span",Lv,o(String(ae).slice(0,200)),1))])]),_:2},1032,["items"]))],8,Sv))),128)),e("td",Dv,[I.value===be?(n(),i("div",Av,[p(oe,{size:"xs",color:"primary",variant:"ghost",icon:"i-heroicons-check",onClick:ve}),p(oe,{size:"xs",color:"neutral",variant:"ghost",icon:"i-heroicons-x-mark",onClick:ue})])):(n(),i("div",qv,[p(oe,{size:"xs",variant:"ghost",icon:"i-heroicons-pencil-square",onClick:ae=>W(be)},null,8,["onClick"]),p(oe,{size:"xs",variant:"ghost",color:"error",icon:"i-heroicons-trash",onClick:ae=>F(be)},null,8,["onClick"])]))])]))),128))])])):R("",!0)]),e("div",zv,[e("span",Rv,o($.value>0?a(t)("analysis.debug.tableBrowser.rowCount",{count:$.value}):""),1),D.value>1?(n(),i("div",Pv,[p(oe,{size:"xs",variant:"ghost",disabled:M.value<=1,icon:"i-heroicons-chevron-left",onClick:E[3]||(E[3]=ke=>M.value--)},null,8,["disabled"]),e("span",Ev,o(a(t)("analysis.debug.tableBrowser.page",{current:M.value,total:D.value})),1),p(oe,{size:"xs",variant:"ghost",disabled:M.value>=D.value,icon:"i-heroicons-chevron-right",onClick:E[4]||(E[4]=ke=>M.value++)},null,8,["disabled"])])):R("",!0)])]),_:1})])}}}),jv={class:"flex h-full"},Uv={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"},Fv={key:0,class:"py-2"},Vv={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},Nv=["title","onClick"],Ov={class:"truncate text-xs font-medium"},Wv={class:"truncate text-[10px] opacity-50"},Hv={key:1,class:"border-t border-gray-200 py-2 dark:border-gray-700"},Yv={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},Kv=["title","onClick"],Qv={class:"truncate text-xs font-medium"},Gv={class:"truncate text-[10px] opacity-50"},Jv={class:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4"},Xv={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"},Zv={class:"text-sm font-medium text-primary-700 dark:text-primary-300"},ey={class:"mt-1 text-xs text-primary-600/70 dark:text-primary-400/70"},ty={key:1,class:"flex flex-col gap-3"},ay={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},sy={class:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3"},oy={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},ny={key:0,class:"text-red-500"},ry={key:1,class:"ml-1 text-gray-400"},ly={key:2,class:"ml-1 text-gray-400"},iy={class:"flex items-center gap-3"},cy={key:3,class:"text-xs text-gray-500 dark:text-gray-400"},dy={key:2,class:"flex-1 min-h-0"},uy={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},my={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"},gy={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"},py={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"},vy=pe({__name:"ToolTestTab",props:{sessionId:{}},setup(l){const{t:s}=fe(),t=l,c=f([]),r=f(""),g=f({}),u=f(!1),d=f(null),m=f(null),v=f(null),y=f(!1),M=f(null);function $(h){const k=`ai.assistant.builtinToolDesc.${h}`,S=s(k);return S!==k?S:h}const D=b(()=>c.value.filter(h=>h.category==="core")),I=b(()=>c.value.filter(h=>h.category==="analysis")),q=b(()=>c.value.find(h=>h.name===r.value)),_=b(()=>{const h=q.value;if(!h?.parameters)return[];const k=h.parameters;if(!k.properties)return[];const S=new Set(k.required??[]);return Object.entries(k.properties).map(([P,B])=>{const A={name:P,type:B.type??"string",description:B.description??"",required:S.has(P),defaultValue:B.default};if(B.enum&&(A.enumValues=B.enum),B.type==="array"){A.isArray=!0;const w=B.items;A.arrayItemType=w?.type??"string"}return A})});ge(r,()=>{g.value={},m.value=null,v.value=null,M.value=null}),je(async()=>{try{c.value=await Fe().getToolCatalog(),c.value.length>0&&(r.value=c.value[0].name)}catch(h){console.error("Failed to load tool catalog:",h)}});function L(){const h={};for(const k of _.value){const S=g.value[k.name];if(!(S===void 0||S===""))if(k.type==="number"){const P=Number(S);isNaN(P)||(h[k.name]=P)}else k.isArray?h[k.name]=S.split(",").map(P=>P.trim()).filter(Boolean):h[k.name]=S}return h}async function x(){if(!r.value||u.value)return;u.value=!0,m.value=null,v.value=null,y.value=!1,M.value=null;const h=`tool_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;d.value=h;try{const k=L(),S=await Fe().executeTool(h,r.value,k,t.sessionId);if(S.error==="cancelled")return;S.success?(M.value=S.elapsed??null,y.value=!!S.truncated,m.value=S.truncated?S.details?._preview??"":JSON.stringify(S.details??S.content,null,2)):v.value=S.error??"Unknown error"}catch(k){v.value=String(k)}finally{u.value=!1,d.value=null}}async function C(){d.value&&(await Fe().cancelToolTest(d.value),u.value=!1,d.value=null)}return(h,k)=>{const S=Yt,P=wt,B=ze,A=we;return n(),i("div",jv,[e("div",Uv,[D.value.length>0?(n(),i("div",Fv,[e("div",Vv,o(a(s)("ai.lab.toolTest.coreTools")),1),(n(!0),i(Z,null,ce(D.value,w=>(n(),i("button",{key:w.name,class:ne(["flex w-full flex-col px-3 py-1.5 text-left transition-colors",[r.value===w.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:w.description,onClick:T=>r.value=w.name},[e("span",Ov,o($(w.name)),1),e("span",Wv,o(w.name),1)],10,Nv))),128))])):R("",!0),I.value.length>0?(n(),i("div",Hv,[e("div",Yv,o(a(s)("ai.lab.toolTest.analysisTools")),1),(n(!0),i(Z,null,ce(I.value,w=>(n(),i("button",{key:w.name,class:ne(["flex w-full flex-col px-3 py-1.5 text-left transition-colors",[r.value===w.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:w.description,onClick:T=>r.value=w.name},[e("span",Qv,o($(w.name)),1),e("span",Gv,o(w.name),1)],10,Kv))),128))])):R("",!0)]),p(a(tt),{class:"my-3 mr-3 flex min-w-0 flex-1 flex-col"},{default:j(()=>[e("div",Jv,[q.value?(n(),i("div",Xv,[e("div",Zv,o($(q.value.name)),1),e("div",ey,o(q.value.description),1)])):R("",!0),_.value.length>0?(n(),i("div",ty,[e("h3",ay,o(a(s)("ai.lab.toolTest.parameters")),1),e("div",sy,[(n(!0),i(Z,null,ce(_.value,w=>(n(),i("div",{key:w.name,class:"flex flex-col gap-1"},[e("label",oy,[ee(o(w.name)+" ",1),w.required?(n(),i("span",ny,"*")):R("",!0),w.type==="number"?(n(),i("span",ry,"(number)")):R("",!0),w.isArray?(n(),i("span",ly,"("+o(w.arrayItemType)+"[])",1)):R("",!0)]),w.enumValues?(n(),Y(S,{key:0,modelValue:g.value[w.name],"onUpdate:modelValue":T=>g.value[w.name]=T,items:w.enumValues,placeholder:w.description,size:"sm"},null,8,["modelValue","onUpdate:modelValue","items","placeholder"])):(n(),Y(P,{key:1,modelValue:g.value[w.name],"onUpdate:modelValue":T=>g.value[w.name]=T,placeholder:w.isArray?a(s)("ai.lab.toolTest.arrayPlaceholder"):w.defaultValue!==void 0?String(w.defaultValue):w.description,type:w.type==="number"?"number":"text",size:"sm"},null,8,["modelValue","onUpdate:modelValue","placeholder","type"]))]))),128))])])):R("",!0),e("div",iy,[u.value?(n(),Y(B,{key:1,color:"error",icon:"i-heroicons-stop",onClick:C},{default:j(()=>[ee(o(a(s)("ai.lab.toolTest.cancel")),1)]),_:1})):(n(),Y(B,{key:0,color:"primary",disabled:!r.value,icon:"i-heroicons-play",onClick:x},{default:j(()=>[ee(o(a(s)("ai.lab.toolTest.execute")),1)]),_:1},8,["disabled"])),u.value?(n(),Y(A,{key:2,name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin text-gray-400"})):R("",!0),M.value!==null?(n(),i("span",cy,o(a(s)("ai.lab.toolTest.elapsed",{ms:M.value})),1)):R("",!0)]),m.value||v.value?(n(),i("div",dy,[e("h3",uy,o(a(s)("ai.lab.toolTest.result")),1),v.value?(n(),i("div",my,o(v.value),1)):(n(),i(Z,{key:1},[y.value?(n(),i("div",gy,o(a(s)("ai.lab.toolTest.truncated")),1)):R("",!0),e("pre",py,o(m.value),1)],64))])):R("",!0)])]),_:1})])}}}),yy={class:"flex h-full flex-col"},hy={class:"min-h-0 flex-1 overflow-hidden"},fy=pe({__name:"DebugTab",props:{sessionId:{}},setup(l){const{t:s}=fe(),t=l,c=[{id:"sql-tables",label:s("analysis.debug.sqlTables"),icon:"i-heroicons-table-cells"},{id:"basic-tools",label:s("analysis.debug.basicTools"),icon:"i-heroicons-wrench-screwdriver"}],r=f("sql-tables");return(g,u)=>(n(),i("div",yy,[p(a(oa),{modelValue:r.value,"onUpdate:modelValue":u[0]||(u[0]=d=>r.value=d),items:c,"persist-key":"debugTab"},null,8,["modelValue"]),e("div",hy,[p(rt,{name:"fade",mode:"out-in"},{default:j(()=>[r.value==="sql-tables"?(n(),Y(Bv,{key:0,class:"h-full","session-id":t.sessionId},null,8,["session-id"])):r.value==="basic-tools"?(n(),Y(vy,{key:1,class:"h-full","session-id":t.sessionId},null,8,["session-id"])):R("",!0)]),_:1})])]))}}),Yb=lt(fy,[["__scopeId","data-v-b3b3d1a4"]]);function Kb(l){const s=b(()=>Fa(l)),t=b(()=>{const r=s.value;return r.length<2?!1:new Set(r.map(u=>Me(u.date).year())).size>1}),c=b(()=>{const r=s.value,g=50;if(r.length<=g){const v=t.value?"YYYY/MM/DD":"MM/DD";return{labels:r.map(y=>Me(y.date).format(v)),values:r.map(y=>y.messageCount)}}const u=Math.ceil(r.length/g),d=[],m=[];for(let v=0;v<r.length;v+=u){const y=r.slice(v,v+u);if(y.length===0)continue;const M=Math.floor(y.length/2),$=y[M].date,D=t.value?"YYYY/MM/DD":"MM/DD";d.push(Me($).format(D));const I=y.reduce((_,L)=>_+L.messageCount,0),q=Math.round(I/y.length);m.push(q)}return{labels:d,values:m}});return{isMultiYear:t,dailyChartData:c}}const xy=86400;function ft(l){return typeof l=="number"&&Number.isFinite(l)}function by(l){return ft(l?.startTs)&&ft(l?.endTs)}function pa(l,s){const t=s?.startTs??l?.start,c=s?.endTs??l?.end;return!ft(t)||!ft(c)||c<t?null:{start:t,end:c}}function ky(l){return!l||l.end<l.start?0:Math.max(Math.ceil((l.end-l.start)/xy),1)}function _y(l){return l?[Me.unix(l.start).format("YYYY-MM-DD"),Me.unix(l.end).format("YYYY-MM-DD")]:null}function wy(l,s){const{t}=fe(),c=b(()=>pa(l.timeRange,l.timeFilter)),r=b(()=>by(l.timeFilter)),g=b(()=>ky(c.value)),u=b(()=>r.value?l.filteredMessageCount:l.session.messageCount),d=b(()=>r.value?l.filteredMemberCount??l.session.memberCount:l.session.memberCount),m=b(()=>g.value),v=b(()=>m.value===0?0:Math.round(u.value/m.value)),y=b(()=>g.value===0?0:Math.round(u.value/g.value)),M=b(()=>l.messageTypes.find(P=>P.type===1)?.count||0),$=b(()=>l.hourlyActivity.length?l.hourlyActivity.reduce((S,P)=>P.messageCount>S.messageCount?P:S,l.hourlyActivity[0]):null),D=b(()=>s.value.length?s.value.reduce((S,P)=>P.messageCount>S.messageCount?P:S,s.value[0]):null),I=b(()=>[t("common.weekday.mon"),t("common.weekday.tue"),t("common.weekday.wed"),t("common.weekday.thu"),t("common.weekday.fri"),t("common.weekday.sat"),t("common.weekday.sun")]),q=b(()=>{if(!s.value.length)return{weekday:0,weekend:0};const S=s.value.filter(A=>A.weekday>=1&&A.weekday<=5).reduce((A,w)=>A+w.messageCount,0),P=s.value.filter(A=>A.weekday>=6&&A.weekday<=7).reduce((A,w)=>A+w.messageCount,0),B=S+P;return{weekday:B>0?Math.round(S/B*100):0,weekend:B>0?Math.round(P/B*100):0}}),_=b(()=>l.dailyActivity.length?l.dailyActivity.reduce((S,P)=>P.messageCount>S.messageCount?P:S,l.dailyActivity[0]):null),L=b(()=>l.dailyActivity.filter(S=>S.messageCount>0).length),x=b(()=>g.value),C=b(()=>x.value>0?Math.round(L.value/x.value*100):0),h=b(()=>{if(!l.hourlyActivity.length)return{count:0,ratio:0};const S=l.hourlyActivity.reduce((B,A)=>B+A.messageCount,0),P=l.hourlyActivity.filter(B=>B.hour>=0&&B.hour<=4).reduce((B,A)=>B+A.messageCount,0);return{count:P,ratio:S>0?Math.round(P/S*100):0}}),k=b(()=>{if(!l.dailyActivity.length)return 0;const S=[...l.dailyActivity].filter(A=>A.messageCount>0).sort((A,w)=>Me(A.date).valueOf()-Me(w.date).valueOf());if(S.length===0)return 0;let P=1,B=1;for(let A=1;A<S.length;A++){const w=Me(S[A-1].date);Me(S[A].date).diff(w,"day")===1?B++:(B>P&&(P=B),B=1)}return B>P&&(P=B),P});return{durationDays:g,displayMessageCount:u,displayMemberCount:d,dailyAvgMessages:y,totalDurationDays:m,totalDailyAvgMessages:v,imageCount:M,peakHour:$,peakWeekday:D,weekdayNames:I,weekdayVsWeekend:q,peakDay:_,activeDays:L,totalDays:x,activeRate:C,lateNightChat:h,maxConsecutiveDays:k}}const $y={key:0,class:"relative z-10 px-6 pb-6 pt-2 sm:px-8"},Cy={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Sy={class:"min-w-0"},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"},Iy={key:1,class:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4"},Ly={class:"text-sm text-gray-500"},Dy={class:"text-sm text-gray-500"},Ay={class:"ml-1 font-semibold text-pink-500"},qy={class:"text-sm text-gray-500"},zy={class:"text-sm text-gray-500"},Ry={class:"text-sm text-gray-500"},Py={class:"text-sm text-gray-500"},Ey={class:"text-sm text-gray-500"},By={class:"text-sm text-gray-500"},jy=pe({__name:"OverviewStatCards",props:{dailyAvgMessages:{},durationDays:{},imageCount:{},peakHour:{},peakWeekday:{},weekdayNames:{},weekdayVsWeekend:{},peakDay:{},activeDays:{},totalDays:{},activeRate:{},lateNightCount:{},lateNightRatio:{},maxConsecutiveDays:{},flat:{type:Boolean,default:!1}},setup(l){const{t:s}=fe(),t=l,c=b(()=>[{icon:"i-heroicons-chat-bubble-left-right",label:s("analysis.overview.statCards.dailyAvgMessages"),value:s("analysis.overview.statCards.messagesCount",{count:t.dailyAvgMessages}),subtext:s("analysis.overview.statCards.daysCount",{count:t.durationDays}),colorClass:"text-blue-600 dark:text-blue-400"},{icon:"i-heroicons-photo",label:s("analysis.overview.statCards.imageMessages"),value:s("analysis.overview.statCards.imagesCount",{count:t.imageCount}),subtext:`${s("analysis.overview.statCards.peakHour")} ${t.peakHour?.hour||0}:00`,colorClass:"text-pink-600 dark:text-pink-400"},{icon:"i-heroicons-calendar-days",label:s("analysis.overview.statCards.mostActiveWeekday"),value:t.peakWeekday?t.weekdayNames[t.peakWeekday.weekday-1]:"-",subtext:s("analysis.overview.statCards.messagesOnDay",{count:t.peakWeekday?.messageCount??0}),colorClass:"text-amber-600 dark:text-amber-400"},{icon:"i-heroicons-sun",label:s("analysis.overview.statCards.weekendActivity"),value:`${t.weekdayVsWeekend.weekend}%`,subtext:s("analysis.overview.statCards.weekendRatio"),colorClass:"text-green-600 dark:text-green-400"},{icon:"i-heroicons-fire",label:s("analysis.overview.statCards.mostActiveDate"),value:t.peakDay?Me(t.peakDay.date).format("MM/DD"):"-",subtext:s("analysis.overview.statCards.messagesOnDay",{count:t.peakDay?.messageCount??0}),colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-moon",label:s("analysis.overview.statCards.lateNightChat"),value:s("analysis.overview.statCards.messagesCount",{count:t.lateNightCount}),subtext:s("analysis.overview.statCards.lateNightRatio",{ratio:t.lateNightRatio}),colorClass:"text-indigo-600 dark:text-indigo-400"},{icon:"i-heroicons-bolt",label:s("analysis.overview.statCards.consecutiveStreak"),value:s("analysis.overview.statCards.daysStreak",{count:t.maxConsecutiveDays}),subtext:s("analysis.overview.statCards.longestStreak"),colorClass:"text-amber-600 dark:text-amber-400"},{icon:"i-heroicons-chart-bar",label:s("analysis.overview.statCards.activityRate"),value:`${t.activeRate}%`,subtext:s("analysis.overview.statCards.activeDaysRatio"),colorClass:"text-gray-900 dark:text-white"}]);return(r,g)=>{const u=we;return l.flat?(n(),i("div",$y,[g[0]||(g[0]=e("div",{class:"mb-3 flex items-center justify-between"},[e("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"},"Key Metrics")],-1)),e("div",Cy,[(n(!0),i(Z,null,ce(c.value,d=>(n(),i("div",{key:d.icon+d.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[p(u,{name:d.icon,class:ne(["mt-0.5 h-3.5 w-3.5 shrink-0",d.colorClass])},null,8,["name","class"]),e("div",Sy,[e("div",{class:ne(["truncate font-mono text-sm font-black leading-tight tabular-nums",d.colorClass])},o(d.value),3),e("div",Ty,o(d.label),1),e("div",My,o(d.subtext),1)])]))),128))])])):(n(),i("div",Iy,[p(a(Xe),{label:a(s)("analysis.overview.statCards.dailyAvgMessages"),value:a(s)("analysis.overview.statCards.messagesCount",{count:l.dailyAvgMessages}),icon:"i-heroicons-chat-bubble-left-right","icon-bg":"blue"},{subtext:j(()=>[e("span",Ly,o(a(s)("analysis.overview.statCards.daysCount",{count:l.durationDays})),1)]),_:1},8,["label","value"]),p(a(Xe),{label:a(s)("analysis.overview.statCards.imageMessages"),value:a(s)("analysis.overview.statCards.imagesCount",{count:l.imageCount}),icon:"i-heroicons-photo","icon-bg":"pink"},{subtext:j(()=>[e("span",Dy,o(a(s)("analysis.overview.statCards.peakHour")),1),e("span",Ay,o(l.peakHour?.hour||0)+":00",1)]),_:1},8,["label","value"]),p(a(Xe),{label:a(s)("analysis.overview.statCards.mostActiveWeekday"),value:l.peakWeekday?l.weekdayNames[l.peakWeekday.weekday-1]:"-",icon:"i-heroicons-calendar-days","icon-bg":"amber"},{subtext:j(()=>[e("span",qy,o(a(s)("analysis.overview.statCards.messagesOnDay",{count:l.peakWeekday?.messageCount??0})),1)]),_:1},8,["label","value"]),p(a(Xe),{label:a(s)("analysis.overview.statCards.weekendActivity"),value:`${l.weekdayVsWeekend.weekend}%`,icon:"i-heroicons-sun","icon-bg":"green"},{subtext:j(()=>[e("span",zy,o(a(s)("analysis.overview.statCards.weekendRatio")),1)]),_:1},8,["label","value"]),p(a(Xe),{label:a(s)("analysis.overview.statCards.mostActiveDate"),value:l.peakDay?a(Me)(l.peakDay.date).format("MM/DD"):"-",icon:"i-heroicons-fire","icon-bg":"red"},{subtext:j(()=>[e("span",Ry,o(a(s)("analysis.overview.statCards.messagesOnDay",{count:l.peakDay?.messageCount??0})),1)]),_:1},8,["label","value"]),p(a(Xe),{label:a(s)("analysis.overview.statCards.lateNightChat"),value:a(s)("analysis.overview.statCards.messagesCount",{count:l.lateNightCount}),icon:"i-heroicons-moon","icon-bg":"blue"},{subtext:j(()=>[e("span",Py,o(a(s)("analysis.overview.statCards.lateNightRatio",{ratio:l.lateNightRatio})),1)]),_:1},8,["label","value"]),p(a(Xe),{label:a(s)("analysis.overview.statCards.consecutiveStreak"),value:a(s)("analysis.overview.statCards.daysStreak",{count:l.maxConsecutiveDays}),icon:"i-heroicons-bolt","icon-bg":"amber"},{subtext:j(()=>[e("span",Ey,o(a(s)("analysis.overview.statCards.longestStreak")),1)]),_:1},8,["label","value"]),p(a(Xe),{label:a(s)("analysis.overview.statCards.activityRate"),value:`${l.activeRate}%`,icon:"i-heroicons-chart-bar","icon-bg":"gray"},{subtext:j(()=>[e("span",By,o(a(s)("analysis.overview.statCards.activeDaysRatio")),1)]),_:1},8,["label","value"])]))}}}),Uy={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Fy={class:"text-3xl font-bold tracking-tight text-gray-900 dark:text-gray-100"},Vy={class:"mt-4 flex items-start gap-6 sm:gap-24"},Ny={class:"min-w-0 flex flex-col gap-2 text-sm font-medium text-gray-500 dark:text-gray-400"},Oy={class:"flex items-center gap-2"},Wy={class:"flex h-6 w-6 shrink-0 items-center justify-center"},Hy={class:"whitespace-nowrap"},Yy={key:0,class:"flex items-center gap-2"},Ky={class:"flex h-6 w-6 shrink-0 items-center justify-center"},Qy={class:"font-mono text-xs opacity-90 whitespace-nowrap"},Gy={class:"flex shrink-0 gap-6"},Jy={class:"flex flex-col gap-1 text-center"},Xy={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},Zy={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},eh={class:"flex flex-col gap-1 text-center"},th={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},ah={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},sh={class:"flex flex-col gap-1 text-center"},oh={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},nh={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},rh={class:"flex flex-col gap-1 text-center"},lh={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},ih={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},ch={class:"relative z-10 px-6 pb-2 sm:px-8"},dh={class:"overflow-x-auto overflow-y-hidden scrollbar-hide py-1"},Qb=pe({__name:"OverviewIdentityCard",props:{session:{},dailyActivity:{},messageTypes:{},hourlyActivity:{},timeRange:{},filteredMessageCount:{},filteredMemberCount:{},timeFilter:{}},setup(l){Ct([ca,Qa,da,Qt,ua,St]);const{t:s,locale:t}=fe(),c=bt(),r=l,g=f([]);async function u(){if(r.session.id)try{g.value=await Ne().getWeekdayActivity(r.session.id,r.timeFilter)}catch(F){console.error("加载星期活跃度失败:",F)}}ge(()=>[r.session.id,r.timeFilter],()=>u(),{immediate:!0,deep:!0});const{durationDays:d,displayMessageCount:m,dailyAvgMessages:v,imageCount:y,peakHour:M,peakWeekday:$,weekdayNames:D,weekdayVsWeekend:I,peakDay:q,activeDays:_,totalDays:L,activeRate:x,lateNightChat:C,maxConsecutiveDays:h}=wy(r,g),k=f(null);let S=null;const P=b(()=>pa(r.timeRange,r.timeFilter)),B=b(()=>P.value?Ka(P.value.start,P.value.end,"YYYY/MM/DD"):""),A=b(()=>{const F=_y(P.value);if(F)return F;const ye=(K=>K.toISOString().slice(0,10))(new Date);return[ye,ye]}),w=b(()=>{const[F,X]=A.value,me=new Date(F+"T00:00:00Z"),ye=new Date(X+"T00:00:00Z"),K=new Map;r.dailyActivity.filter(oe=>oe.date>=F&&oe.date<=X).forEach(oe=>K.set(oe.date,oe.messageCount));const E=[],V=new Date(me);for(;V<=ye;){const oe=V.toISOString().slice(0,10),he=K.get(oe)||0;E.push({value:[oe,he],itemStyle:he===0?{color:le.value}:void 0}),V.setUTCDate(V.getUTCDate()+1)}return E}),T=b(()=>r.dailyActivity.length===0?10:Math.max(...r.dailyActivity.map(F=>F.messageCount),1)),H={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)"]},le=b(()=>c.value?"rgba(255, 255, 255, 0.04)":"#ebedf0"),W=b(()=>({tooltip:{trigger:"item",formatter:F=>{const X=F.value[0],me=F.value[1];return`${X}<br/>${s("views.message.calendarTooltipMessages")}: ${me}`}},visualMap:{min:1,max:T.value,calculable:!1,orient:"horizontal",left:"center",bottom:0,itemWidth:10,itemHeight:80,text:[`${T.value}`,"1"],inRange:{color:c.value?H.dark:H.light},textStyle:{color:c.value?"#8b949e":"#6b7280",fontSize:10},show:!0},calendar:{top:20,left:30,cellSize:[13,13],range:A.value,itemStyle:{borderWidth:0,color:"transparent"},yearLabel:{show:!1},monthLabel:{show:!0,color:c.value?"#8b949e":"#6b7280",fontSize:10,nameMap:[s("common.month.jan"),s("common.month.feb"),s("common.month.mar"),s("common.month.apr"),s("common.month.may"),s("common.month.jun"),s("common.month.jul"),s("common.month.aug"),s("common.month.sep"),s("common.month.oct"),s("common.month.nov"),s("common.month.dec")]},dayLabel:{show:!0,firstDay:1,color:c.value?"#8b949e":"#9ca3af",fontSize:10,nameMap:[s("common.weekday.sun"),s("common.weekday.mon"),s("common.weekday.tue"),s("common.weekday.wed"),s("common.weekday.thu"),s("common.weekday.fri"),s("common.weekday.sat")]},splitLine:{show:!1}},series:[{type:"custom",coordinateSystem:"calendar",data:w.value,renderItem:(F,X)=>{const me=X.coord(X.value(0)),ye=F.coordSys.cellWidth,K=F.coordSys.cellHeight,E=Math.min(ye,K)-3;return{type:"rect",shape:{x:me[0]-E/2,y:me[1]-E/2,width:E,height:E,r:3},style:{fill:X.visual("color")}}},itemStyle:{borderColor:c.value?"transparent":"rgba(0,0,0,0.02)",borderWidth:1}}]}));function ue(){k.value&&(S=Tt(k.value,void 0,{renderer:"canvas"}),S.setOption({backgroundColor:"transparent",...W.value}))}function ve(){S&&S.setOption({backgroundColor:"transparent",...W.value},{notMerge:!0})}function G(){S?.resize()}return ge([()=>r.dailyActivity,t,A],()=>ve()),ge(c,()=>{S?.dispose(),ue()}),je(()=>{ue(),window.addEventListener("resize",G)}),ut(()=>{window.removeEventListener("resize",G),S?.dispose()}),(F,X)=>{const me=we;return n(),Y(a(Mt),null,{default:j(()=>[e("div",Uy,[e("h2",Fy,o(l.session.name),1),e("div",Vy,[e("div",Ny,[e("div",Oy,[e("div",Wy,[l.session.type==="group"?(n(),Y(me,{key:0,name:"i-heroicons-user-group",class:"h-4 w-4 opacity-70"})):(n(),Y(me,{key:1,name:"i-heroicons-user",class:"h-4 w-4 opacity-70"}))]),e("span",Hy,o(l.session.platform.toUpperCase())+" · "+o(l.session.type==="private"?a(s)("analysis.overview.identity.privateChat"):a(s)("analysis.overview.identity.groupChat")),1)]),B.value?(n(),i("div",Yy,[e("div",Ky,[p(me,{name:"i-heroicons-calendar",class:"h-4 w-4 opacity-70"})]),e("span",Qy,o(B.value),1)])):R("",!0)]),e("div",Gy,[e("div",Jy,[e("span",Xy,o(a(m).toLocaleString()),1),e("span",Zy,o(a(s)("analysis.overview.identity.totalMessages")),1)]),e("div",eh,[e("span",th,o(a(d).toLocaleString()),1),e("span",ah,o(a(s)("analysis.overview.identity.durationDays")),1)]),e("div",sh,[e("span",oh,o(a(_).toLocaleString()),1),e("span",nh,o(a(s)("analysis.overview.identity.activeDays")),1)]),e("div",rh,[e("span",lh,o(a(v).toLocaleString()),1),e("span",ih,o(a(s)("analysis.overview.identity.dailyAvgMessages")),1)])])])]),e("div",ch,[X[0]||(X[0]=e("div",{class:"mb-2 flex items-center justify-between"},[e("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Activity Heatmap ")],-1)),e("div",dh,[e("div",{ref_key:"chartRef",ref:k,class:"h-[140px] min-w-[700px] lg:w-full"},null,512)])]),p(jy,{flat:"","daily-avg-messages":a(v),"duration-days":a(d),"image-count":a(y),"peak-hour":a(M),"peak-weekday":a($),"weekday-names":a(D),"weekday-vs-weekend":a(I),"peak-day":a(q),"active-days":a(_),"total-days":a(L),"active-rate":a(x),"late-night-count":a(C).count,"late-night-ratio":a(C).ratio,"max-consecutive-days":a(h)},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})}}}),uh={class:"p-5"},Gb=pe({__name:"DailyTrendCard",props:{dailyActivity:{},dailyChartData:{}},setup(l){const{t:s}=fe();return(t,c)=>l.dailyActivity.length>0?(n(),Y(a(Oe),{key:0,title:a(s)("analysis.overview.dailyTrend.title"),"show-divider":!1},{default:j(()=>[e("div",uh,[p(a(jt),{data:l.dailyChartData,height:288},null,8,["data"])])]),_:1},8,["title"])):R("",!0)}}),mh={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},gh={class:"flex items-center gap-6 sm:gap-10"},ph={class:"min-w-0 flex-1"},vh={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},yh={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},hh={class:"mb-4 flex min-w-0 flex-wrap items-baseline gap-2"},fh={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},xh={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},bh={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},kh={key:1,class:"flex min-w-0 max-w-full flex-wrap items-center gap-x-1.5 gap-y-1.5"},_h={class:"text-base font-medium text-gray-600 dark:text-gray-300"},wh={class:"font-bold tabular-nums text-pink-500 dark:text-pink-400"},$h={class:"flex shrink-0 flex-col items-center"},Ch={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},Sh={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Th={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Mh={class:"min-w-0 flex-1"},Ih={class:"flex items-center justify-between gap-1"},Lh={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},Dh={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Ah={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"},qh={class:"flex items-center gap-1.5"},zh={class:"text-[9px] font-medium uppercase tracking-widest"},Rh=pe({__name:"TypeProfileCard",props:{sessionId:{},messageTypes:{},textStats:{},timeFilter:{}},setup(l){Ct([Ga,Qt,St]);const{t:s}=fe(),t=bt(),c=l,r=b(()=>c.messageTypes.reduce((w,T)=>w+T.count,0)),g=b(()=>c.messageTypes.find(w=>w.type===at.TEXT)?.count??0),u=b(()=>{if(r.value===0)return 0;const w=r.value-g.value;return Math.round(w/r.value*100)}),d=b(()=>c.textStats.textCount===0?0:Math.round(c.textStats.shortCount/c.textStats.textCount*100)),m=f({first:"",last:""});async function v(){if(c.sessionId)try{const w=await Ne().getDailyActivity(c.sessionId,c.timeFilter);if(w.length>0){const T=[...w].sort((H,le)=>H.date.localeCompare(le.date));m.value={first:Me(T[0].date).format("YYYY/MM/DD"),last:Me(T[T.length-1].date).format("YYYY/MM/DD")}}}catch{}}function y(w){return c.messageTypes.find(T=>T.type===w)?.count??0}const M=b(()=>[{label:s("views.message.typeCard.nonTextImage"),count:y(at.IMAGE),unit:s("views.message.typeCard.unitImage")},{label:s("views.message.typeCard.nonTextEmoji"),count:y(at.EMOJI),unit:s("views.message.typeCard.unitEmoji")},{label:s("views.message.typeCard.nonTextVoice"),count:y(at.VOICE),unit:s("views.message.typeCard.unitVoice")},{label:s("views.message.typeCard.nonTextVideo"),count:y(at.VIDEO),unit:s("views.message.typeCard.unitVideo")},{label:s("views.message.typeCard.nonTextFile"),count:y(at.FILE),unit:s("views.message.typeCard.unitFile")},{label:s("views.message.typeCard.nonTextLink"),count:y(at.LINK),unit:s("views.message.typeCard.unitLink")}].filter(w=>w.count>0)),$=f(30),D=f(0),I=f(!1),q=[{label:"20",value:20},{label:"30",value:30},{label:"50",value:50},{label:"80",value:80},{label:"100",value:100}],_=b({get:()=>$.value,set:w=>{$.value!==w&&($.value=w,L())}});async function L(){if(c.sessionId){I.value=!0;try{D.value=await Ne().getLongMessageCount(c.sessionId,c.timeFilter,$.value)}catch(w){console.error("[chart-message] Failed to load essay count:",w)}finally{I.value=!1}}}ge(()=>[c.sessionId,c.timeFilter],()=>{L(),v()},{immediate:!0,deep:!0});const x=b(()=>[{icon:"i-heroicons-pencil-square",label:s("views.message.profile.textExpression"),value:s("views.message.profile.avgLengthUnit",{count:c.textStats.avgLength||0}),subtext:c.textStats.maxLength>0?s("views.message.profile.textExpressionDesc",{count:c.textStats.maxLength}):"",colorClass:"text-violet-600 dark:text-violet-400"},{icon:"i-heroicons-chat-bubble-bottom-center-text",label:s("views.message.profile.shortMaster"),value:`${d.value}%`,subtext:s("views.message.profile.shortMasterDesc",{count:c.textStats.shortCount}),colorClass:"text-emerald-600 dark:text-emerald-400"},{icon:"i-heroicons-document-text",label:s("views.message.profile.essayLover"),value:D.value.toLocaleString(),subtext:s("views.message.profile.essayLoverDesc",{threshold:$.value}),colorClass:"text-indigo-600 dark:text-indigo-400",slot:"essay-threshold"},{icon:"i-heroicons-photo",label:s("views.message.profile.mediaRichness"),value:`${u.value}%`,subtext:M.value.slice(0,3).map(w=>`${w.label} ${w.count}`).join(" · ")||"-",colorClass:"text-pink-600 dark:text-pink-400"}]),C=f(null);let h=null;const k=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],S=b(()=>[...c.messageTypes].sort((T,H)=>H.count-T.count).slice(0,8).map((T,H)=>({name:Pt(T.type,s),value:T.count,itemStyle:{color:k[H%k.length]}})));function P(){C.value&&(h=Tt(C.value,void 0,{renderer:"canvas"}),B())}function B(){h&&h.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:S.value}]},{notMerge:!0})}function A(){h?.resize()}return ge(()=>c.messageTypes,()=>B()),ge(t,()=>{h?.dispose(),P()}),je(()=>{P(),window.addEventListener("resize",A)}),ut(()=>{window.removeEventListener("resize",A),h?.dispose()}),(w,T)=>{const H=we,le=Wt;return n(),Y(a(Mt),null,{default:j(()=>[e("div",mh,[e("div",gh,[e("div",ph,[e("div",vh,[m.value.first?(n(),i("p",yh,o(m.value.first)+" – "+o(m.value.last),1)):R("",!0),e("div",hh,[e("span",fh,o(a(s)("views.message.profile.heroLine1Prefix")),1),e("span",xh,o(r.value.toLocaleString()),1),e("span",bh,o(a(s)("views.message.profile.heroLine1Suffix")),1)]),M.value.length>0?(n(),i("div",kh,[e("span",_h,o(a(s)("views.message.typeCard.nonTextPrefix")),1),(n(!0),i(Z,null,ce(M.value,W=>(n(),i("span",{key:W.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"},[e("span",wh,o(W.count.toLocaleString()),1),e("span",null,o(W.unit),1)]))),128))])):R("",!0)])]),e("div",$h,[e("div",Ch,o(a(s)("views.message.profile.typeDistribution")),1),e("div",{ref_key:"donutRef",ref:C,style:{width:"130px",height:"130px"}},null,512)])])]),e("div",Sh,[T[1]||(T[1]=e("div",{class:"mb-3 flex items-center justify-between"},[e("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Type Profile ")],-1)),e("div",Th,[(n(!0),i(Z,null,ce(x.value,W=>(n(),i("div",{key:W.icon+W.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[p(H,{name:W.icon,class:ne(["mt-0.5 h-3.5 w-3.5 shrink-0",W.colorClass])},null,8,["name","class"]),e("div",Mh,[e("div",Ih,[e("div",{class:ne(["truncate font-mono text-sm font-black leading-tight tabular-nums",W.colorClass])},o(W.value),3),W.slot==="essay-threshold"?(n(),Y(le,{key:0,modelValue:_.value,"onUpdate:modelValue":T[0]||(T[0]=ue=>_.value=ue),items:q,"value-key":"value",size:"xs",class:"relative z-120 w-16 shrink-0",ui:{content:"z-[121]"},disabled:I.value},null,8,["modelValue","disabled"])):R("",!0)]),e("div",Lh,o(W.label),1),e("div",Dh,o(W.subtext),1)])]))),128))])]),e("div",Ah,[e("div",qh,[p(H,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),T[2]||(T[2]=e("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),e("span",zh,o(a(s)("views.message.typeCard.watermark")),1)])]),_:1})}}}),Ph={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-6"},Eh={class:"p-5"},Bh={key:0,class:"grid grid-cols-1 gap-6 lg:grid-cols-2 lg:items-center"},jh={class:"space-y-3"},Uh={class:"min-w-20 shrink-0 text-sm text-gray-700 dark:text-gray-300"},Fh={class:"flex-1"},Vh={class:"h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800"},Nh={class:"shrink-0 text-right"},Oh={class:"text-sm font-medium text-gray-900 dark:text-white"},Wh={class:"ml-1 text-xs text-gray-400"},Hh={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Yh={class:"p-5"},Kh={class:"mb-5 grid grid-cols-2 gap-3 sm:grid-cols-4"},Qh={class:"p-3"},Gh={class:"font-mono text-xl font-bold text-gray-900 dark:text-white"},Jh={class:"mt-1 text-xs text-gray-500"},Xh={class:"p-3"},Zh={class:"font-mono text-xl font-bold text-indigo-600 dark:text-indigo-400"},ef={class:"mt-1 text-xs text-gray-500"},tf={class:"p-3"},af={class:"font-mono text-xl font-bold text-pink-600 dark:text-pink-400"},sf={class:"mt-1 text-xs text-gray-500"},of={class:"p-3"},nf={class:"font-mono text-xl font-bold text-emerald-600 dark:text-emerald-400"},rf={class:"mt-1 text-xs text-gray-500"},lf={class:"mb-5 rounded-lg border border-gray-200 p-4 dark:border-gray-700"},cf={class:"mb-2 text-xs font-medium text-gray-500 dark:text-gray-400"},df={class:"flex items-center gap-4 text-sm"},uf={class:"flex items-center gap-1.5"},mf={class:"font-mono font-medium text-gray-900 dark:text-white"},gf={class:"flex items-center gap-1.5"},pf={class:"font-mono font-medium text-gray-900 dark:text-white"},vf={class:"flex items-center gap-1.5"},yf={class:"font-mono font-medium text-gray-900 dark:text-white"},hf={class:"flex items-center gap-1.5"},ff={class:"font-mono font-medium text-gray-900 dark:text-white"},xf={class:"mt-3 grid grid-cols-3 gap-3 text-xs"},bf={class:"text-gray-500"},kf={class:"ml-1 font-medium text-emerald-600 dark:text-emerald-400"},_f={class:"text-gray-400"},wf={class:"text-gray-500"},$f={class:"ml-1 font-medium text-indigo-600 dark:text-indigo-400"},Cf={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},Sf={class:"text-xs text-gray-400"},Tf={class:"p-5"},Mf={key:1,class:"flex h-48 items-center justify-center text-gray-400"},If={class:"text-xs text-gray-400"},Lf={class:"p-5"},Df={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Jb=pe({__name:"TypeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(l){const s=l,{t}=fe(),c=f(!0),r=f([]),g=f([]),u=f([]),d=f({textCount:0,avgLength:0,maxLength:0,shortCount:0}),m=f({p25:0,p50:0,p75:0,p90:0}),v=f(0),y=b(()=>{const x=[...r.value].sort((C,h)=>h.count-C.count);return{labels:x.map(C=>Pt(C.type,t)),values:x.map(C=>C.count)}}),M=b(()=>{const x=r.value.reduce((h,k)=>h+k.count,0);return[...r.value].sort((h,k)=>k.count-h.count).map(h=>({name:Pt(h.type,t),count:h.count,percentage:x>0?Math.round(h.count/x*100):0}))}),$=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"];function D(x){return $[x%$.length]}const I=b(()=>({labels:g.value.map(x=>String(x.len)),values:g.value.map(x=>x.count)})),q=b(()=>({labels:u.value.map(x=>x.range),values:u.value.map(x=>x.count)})),_=b(()=>d.value.textCount===0?0:Math.round(d.value.shortCount/d.value.textCount*100));async function L(){if(s.sessionId){c.value=!0;try{const x=Ne(),[C,h,k,S,P]=await Promise.all([x.getMessageTypeDistribution(s.sessionId,s.timeFilter),x.getMessageLengthDistribution(s.sessionId,s.timeFilter),x.getTextStats(s.sessionId,s.timeFilter),x.getTextLengthPercentiles(s.sessionId,s.timeFilter),x.getLongMessageCount(s.sessionId,s.timeFilter,30)]);r.value=C,g.value=h.detail,u.value=h.grouped,d.value=k,m.value=S,v.value=P}catch(x){console.error("[chart-message] Failed to load type analysis data:",x)}finally{c.value=!1}}}return ge(()=>[s.sessionId,s.timeFilter],()=>L(),{immediate:!0,deep:!0}),(x,C)=>(n(),i("div",{class:ne(c.value?"h-full":"")},[c.value?(n(),Y(a(mt),{key:0,variant:"page",text:a(t)("common.loading")},null,8,["text"])):(n(),i("div",Ph,[r.value.length>0?(n(),Y(Rh,{key:0,"session-id":l.sessionId,"message-types":r.value,"text-stats":d.value,"time-filter":l.timeFilter},null,8,["session-id","message-types","text-stats","time-filter"])):R("",!0),p(a(Oe),{title:a(t)("views.message.typeDistribution"),"show-divider":!1},{default:j(()=>[e("div",Eh,[y.value.values.length>0?(n(),i("div",Bh,[e("div",null,[p(a(Ut),{data:y.value,height:280,"show-legend":!1},null,8,["data"])]),e("div",null,[e("div",jh,[(n(!0),i(Z,null,ce(M.value,(h,k)=>(n(),i("div",{key:k,class:"flex items-center gap-3"},[e("div",{class:"h-3 w-3 shrink-0 rounded-full",style:Qe({backgroundColor:D(k)})},null,4),e("div",Uh,o(h.name),1),e("div",Fh,[e("div",Vh,[e("div",{class:"h-full rounded-full transition-all",style:Qe({width:`${h.percentage}%`,backgroundColor:D(k)})},null,4)])]),e("div",Nh,[e("span",Oh,o(h.count.toLocaleString()),1),e("span",Wh,"("+o(h.percentage)+"%)",1)])]))),128))])])])):(n(),i("div",Hh,o(a(t)("views.message.noData")),1))])]),_:1},8,["title"]),p(a(Oe),{title:a(t)("views.message.typeAnalysis.textDepthTitle"),"show-divider":!1},{default:j(()=>[e("div",Yh,[e("div",Kh,[e("div",Qh,[e("div",Gh,o(d.value.textCount.toLocaleString()),1),e("div",Jh,o(a(t)("views.message.typeAnalysis.textTotal")),1)]),e("div",Xh,[e("div",Zh,o(d.value.avgLength||0),1),e("div",ef,o(a(t)("views.message.typeAnalysis.avgLength")),1)]),e("div",tf,[e("div",af,o(m.value.p50),1),e("div",sf,o(a(t)("views.message.typeAnalysis.medianLength")),1)]),e("div",of,[e("div",nf,o(d.value.maxLength),1),e("div",rf,o(a(t)("views.message.typeAnalysis.maxLength")),1)])]),e("div",lf,[e("div",cf,o(a(t)("views.message.typeAnalysis.percentiles")),1),e("div",df,[e("div",uf,[C[0]||(C[0]=e("span",{class:"text-gray-500"},"P25",-1)),e("span",mf,o(m.value.p25),1)]),e("div",gf,[C[1]||(C[1]=e("span",{class:"text-gray-500"},"P50",-1)),e("span",pf,o(m.value.p50),1)]),e("div",vf,[C[2]||(C[2]=e("span",{class:"text-gray-500"},"P75",-1)),e("span",yf,o(m.value.p75),1)]),e("div",hf,[C[3]||(C[3]=e("span",{class:"text-gray-500"},"P90",-1)),e("span",ff,o(m.value.p90),1)])]),e("div",xf,[e("div",null,[e("span",bf,o(a(t)("views.message.typeAnalysis.shortMessages")),1),e("span",kf,o(_.value)+"%",1),e("span",_f,"("+o(d.value.shortCount)+")",1)]),e("div",null,[e("span",wf,o(a(t)("views.message.typeAnalysis.essayMessages")),1),e("span",$f,o(v.value),1)])])])])]),_:1},8,["title"]),e("div",Cf,[p(a(Oe),{title:a(t)("views.message.lengthDetailTitle"),"show-divider":!1},{headerRight:j(()=>[e("span",Sf,o(a(t)("views.message.lengthDetailHint")),1)]),default:j(()=>[e("div",Tf,[I.value.values.some(h=>h>0)?(n(),Y(a(Ze),{key:0,data:I.value,height:200},null,8,["data"])):(n(),i("div",Mf,o(a(t)("views.message.noTextMessages")),1))])]),_:1},8,["title"]),p(a(Oe),{title:a(t)("views.message.lengthGroupedTitle"),"show-divider":!1},{headerRight:j(()=>[e("span",If,o(a(t)("views.message.lengthGroupedHint")),1)]),default:j(()=>[e("div",Lf,[q.value.values.some(h=>h>0)?(n(),Y(a(Ze),{key:0,data:q.value,height:200},null,8,["data"])):(n(),i("div",Df,o(a(t)("views.message.noTextMessages")),1))])]),_:1},8,["title"])])]))],2))}}),Af={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},qf={class:"flex items-start gap-6 sm:gap-10"},zf={class:"min-w-0 flex-1"},Rf={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},Pf={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},Ef={class:"mb-3 flex items-baseline gap-2"},Bf={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},jf={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Uf={class:"font-bold text-3xl text-indigo-500 dark:text-indigo-400"},Ff={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Vf={class:"flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},Nf={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Of={class:"font-bold text-xl text-pink-500 dark:text-pink-400"},Wf={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Hf={class:"text-base font-medium text-amber-600 dark:text-amber-400"},Yf={class:"flex shrink-0 flex-col items-center"},Kf={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},Qf={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Gf={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Jf={class:"min-w-0 flex-1"},Xf={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},Zf={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},ex={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"},tx={class:"flex items-center gap-1.5"},ax={class:"text-[9px] font-medium uppercase tracking-widest"},sx=pe({__name:"TimeProfileCard",props:{hourlyActivity:{},weekdayActivity:{},dailyActivity:{}},setup(l){Ct([Ja,Xa,St]);const{t:s}=fe(),t=bt(),c=l,r=b(()=>c.dailyActivity.filter(h=>h.messageCount>0).length),g=b(()=>c.dailyActivity.reduce((h,k)=>h+k.messageCount,0)),u=b(()=>{if(c.dailyActivity.length===0)return{first:"",last:"",days:0};const h=[...c.dailyActivity].sort((P,B)=>P.date.localeCompare(B.date)),k=Me(h[0].date),S=Me(h[h.length-1].date);return{first:k.format("YYYY/MM/DD"),last:S.format("YYYY/MM/DD"),days:S.diff(k,"day")+1}}),d=b(()=>r.value===0?0:Math.round(g.value/r.value)),m=b(()=>c.dailyActivity.length===0?null:c.dailyActivity.reduce((h,k)=>k.messageCount>h.messageCount?k:h,c.dailyActivity[0])),v=b(()=>c.hourlyActivity.length===0?[]:[...c.hourlyActivity].sort((h,k)=>k.messageCount-h.messageCount).slice(0,3)),y=b(()=>{if(c.hourlyActivity.length===0&&c.weekdayActivity.length===0)return null;const h=u.value.days>0?r.value/u.value.days:0,k=c.weekdayActivity.filter(G=>G.weekday===6||G.weekday===7),S=c.weekdayActivity.filter(G=>G.weekday>=1&&G.weekday<=5),P=k.reduce((G,F)=>G+F.messageCount,0),B=S.reduce((G,F)=>G+F.messageCount,0),A=P+B,w=A>0?P/A:0,T=c.hourlyActivity.reduce((G,F)=>G+F.messageCount,0),H=c.hourlyActivity.filter(G=>G.hour>=22||G.hour<5).reduce((G,F)=>G+F.messageCount,0),le=c.hourlyActivity.filter(G=>G.hour>=18&&G.hour<22).reduce((G,F)=>G+F.messageCount,0),W=T>0?H/T:0,ue=T>0?le/T:0;if(h>=.9)return{label:s("views.message.timeCard.personalityEveryday"),icon:"i-heroicons-fire"};if(w>=.55)return{label:s("views.message.timeCard.personalityWeekend"),icon:"i-heroicons-calendar"};if(w<=.2&&A>0)return{label:s("views.message.timeCard.personalityWeekday"),icon:"i-heroicons-briefcase"};if(W>=.3)return{label:s("views.message.timeCard.personalityNightOwl"),icon:"i-heroicons-moon"};if(ue>=.4)return{label:s("views.message.timeCard.personalityEveningChat"),icon:"i-heroicons-sparkles"};const ve=[...c.hourlyActivity].sort((G,F)=>F.messageCount-G.messageCount)[0];return ve?ve.hour>=5&&ve.hour<9?{label:s("views.message.timeCard.personalityEarlyBird"),icon:"i-heroicons-sun"}:ve.hour>=12&&ve.hour<14?{label:s("views.message.timeCard.personalityLunchChat"),icon:"i-heroicons-clock"}:{label:s("views.message.timeCard.personalityDaytime"),icon:"i-heroicons-sun"}:null}),M=b(()=>{const h=c.weekdayActivity.filter(A=>A.weekday===6||A.weekday===7),k=c.weekdayActivity.filter(A=>A.weekday>=1&&A.weekday<=5),S=h.reduce((A,w)=>A+w.messageCount,0),P=k.reduce((A,w)=>A+w.messageCount,0),B=S+P;return B===0?0:Math.round(S/B*100)}),$=b(()=>[s("common.weekday.mon"),s("common.weekday.tue"),s("common.weekday.wed"),s("common.weekday.thu"),s("common.weekday.fri"),s("common.weekday.sat"),s("common.weekday.sun")]),D=b(()=>{if(c.weekdayActivity.length===0)return null;const h=[...c.weekdayActivity].sort((k,S)=>S.messageCount-k.messageCount)[0];return{name:$.value[h.weekday-1],count:h.messageCount}}),I=b(()=>[{icon:"i-heroicons-fire",label:s("views.message.timeCard.peakRecord"),value:m.value?Me(m.value.date).format("MM/DD"):"-",subtext:m.value?s("views.message.timeCard.peakRecordDesc",{count:m.value.messageCount}):"",colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-clock",label:s("views.message.timeCard.topHoursLabel"),value:v.value.length>0?`${v.value[0].hour}:00`:"-",subtext:v.value.length>=2?v.value.map(h=>`${h.hour}:00`).join(" > "):"",colorClass:"text-cyan-600 dark:text-cyan-400"},{icon:"i-heroicons-calendar-days",label:s("views.message.timeCard.peakWeekdayLabel"),value:D.value?.name||"-",subtext:D.value?`${D.value.count.toLocaleString()}`:"",colorClass:"text-violet-600 dark:text-violet-400"},{icon:"i-heroicons-building-office",label:s("views.message.timeCard.weekendRatio"),value:`${M.value}%`,subtext:s("views.message.timeCard.weekendRatioDesc"),colorClass:"text-amber-600 dark:text-amber-400"}]),q=f(null);let _=null;function L(){q.value&&(_=Tt(q.value,void 0,{renderer:"canvas"}),x())}function x(){if(!_)return;const h=new Map(c.hourlyActivity.map(B=>[B.hour,B.messageCount])),k=[];for(let B=0;B<24;B++)k.push(h.get(B)||0);const S=Math.max(...k,1),P=k.map(B=>{const A=B/S;return A>.8?t.value?"#f472b6":"#ec4899":A>.5?t.value?"#a78bfa":"#8b5cf6":t.value?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.08)"});_.setOption({backgroundColor:"transparent",tooltip:{trigger:"axis",formatter:B=>`${B[0].axisValue}:00 — ${B[0].value}`},grid:{left:0,right:0,top:4,bottom:16},xAxis:{type:"category",data:Array.from({length:24},(B,A)=>`${A}`),axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:9,color:t.value?"#6b7280":"#9ca3af",interval:B=>B%6===0}},yAxis:{type:"value",show:!1},series:[{type:"bar",data:k.map((B,A)=>({value:B,itemStyle:{color:P[A]}})),barWidth:"60%",itemStyle:{borderRadius:[2,2,0,0]}}]},{notMerge:!0})}function C(){_?.resize()}return ge(()=>c.hourlyActivity,()=>x()),ge(t,()=>{_?.dispose(),L()}),je(()=>{L(),window.addEventListener("resize",C)}),ut(()=>{window.removeEventListener("resize",C),_?.dispose()}),(h,k)=>{const S=we;return n(),Y(a(Mt),null,{default:j(()=>[e("div",Af,[e("div",qf,[e("div",zf,[e("div",Rf,[u.value.first?(n(),i("p",Pf,o(u.value.first)+" – "+o(u.value.last),1)):R("",!0),e("div",Ef,[e("span",Bf,o(u.value.days),1),e("span",jf,o(a(s)("views.message.timeCard.heroDaysIn")),1),e("span",Uf,o(r.value),1),e("span",Ff,o(a(s)("views.message.timeCard.heroDaysActive")),1)]),e("div",Vf,[e("span",Nf,o(a(s)("views.message.timeCard.heroAvgPrefix")),1),e("span",Of,o(d.value),1),e("span",Wf,o(a(s)("views.message.timeCard.heroAvgSuffix")),1),y.value?(n(),i(Z,{key:0},[p(S,{name:y.value.icon,class:"ml-2 h-4 w-4 text-amber-500"},null,8,["name"]),e("span",Hf,o(y.value.label),1)],64)):R("",!0)])])]),e("div",Yf,[e("div",Kf,o(a(s)("views.message.timeCard.hourlyDistribution")),1),e("div",{ref_key:"barRef",ref:q,style:{width:"180px",height:"110px"}},null,512)])])]),e("div",Qf,[k[0]||(k[0]=e("div",{class:"mb-3 flex items-center justify-between"},[e("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Time Profile ")],-1)),e("div",Gf,[(n(!0),i(Z,null,ce(I.value,P=>(n(),i("div",{key:P.icon+P.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[p(S,{name:P.icon,class:ne(["mt-0.5 h-3.5 w-3.5 shrink-0",P.colorClass])},null,8,["name","class"]),e("div",Jf,[e("div",{class:ne(["truncate font-mono text-sm font-black leading-tight tabular-nums",P.colorClass])},o(P.value),3),e("div",Xf,o(P.label),1),e("div",Zf,o(P.subtext),1)])]))),128))])]),e("div",ex,[e("div",tx,[p(S,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),k[1]||(k[1]=e("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),e("span",ax,o(a(s)("views.message.timeCard.watermark")),1)])]),_:1})}}}),ox={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-6"},nx={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},rx={class:"p-5"},lx={class:"p-5"},ix={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},cx={class:"p-5"},dx={class:"p-5"},ux={key:1,class:"flex h-48 items-center justify-center text-gray-400"},mx={class:"text-xs text-gray-400"},gx={class:"p-5"},px={key:1,class:"flex h-48 items-center justify-center text-gray-400"},vx={class:"text-xs text-gray-400"},yx={class:"p-5"},hx={class:"flex items-center gap-2"},fx={class:"text-xs text-gray-400"},xx={class:"p-5"},bx={key:1,class:"flex h-32 items-center justify-center text-gray-400"},Xb=pe({__name:"TimeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(l){const s=l,{t}=fe(),c=f(!0),r=f([]),g=f([]),u=f([]),d=f([]),m=f([]),v=f([]),y=f([]),M=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],$=b(()=>[t("common.weekday.mon"),t("common.weekday.tue"),t("common.weekday.wed"),t("common.weekday.thu"),t("common.weekday.fri"),t("common.weekday.sat"),t("common.weekday.sun")]),D=b(()=>[t("common.month.jan"),t("common.month.feb"),t("common.month.mar"),t("common.month.apr"),t("common.month.may"),t("common.month.jun"),t("common.month.jul"),t("common.month.aug"),t("common.month.sep"),t("common.month.oct"),t("common.month.nov"),t("common.month.dec")]),I=b(()=>{const A=new Map(g.value.map(H=>[H.hour,H.messageCount])),w=[],T=[];for(let H=0;H<24;H++)w.push(`${H}`),T.push(A.get(H)||0);return{labels:w,values:T}}),q=b(()=>{const A=new Map(u.value.map(T=>[T.weekday,T.messageCount])),w=[];for(let T=1;T<=7;T++)w.push(A.get(T)||0);return{labels:$.value,values:w}}),_=b(()=>{const A=new Map(d.value.map(T=>[T.month,T.messageCount])),w=[];for(let T=1;T<=12;T++)w.push(A.get(T)||0);return{labels:D.value,values:w}}),L=b(()=>{const A=[...m.value].sort((w,T)=>w.year-T.year);return{labels:A.map(w=>String(w.year)),values:A.map(w=>w.messageCount)}}),x=b(()=>{const A=Array.from({length:24},(le,W)=>`${W}:00`),w=$.value,T=r.value.reduce((le,W)=>le+W.count,0)||1,H=[];for(let le=1;le<=7;le++)for(let W=0;W<24;W++){const ue=u.value.find(F=>F.weekday===le)?.messageCount||0,ve=g.value.find(F=>F.hour===W)?.messageCount||0,G=Math.round(ue*ve/T);H.push([W,le-1,G])}return{xLabels:A,yLabels:w,data:H}}),C=b(()=>v.value.map(A=>({date:A.date,value:A.messageCount}))),h=b(()=>{const A=new Set;return v.value.forEach(w=>{const T=parseInt(w.date.split("-")[0]);isNaN(T)||A.add(T)}),Array.from(A).sort((w,T)=>T-w)}),k=f(new Date().getFullYear()),S=b(()=>{const A=k.value;return C.value.filter(w=>w.date.startsWith(`${A}-`))}),P=b(()=>{if(y.value.length===0)return{};const A=[...new Set(y.value.map(W=>W.month))].sort(),w=new Map;if(y.value.forEach(W=>{const ue=w.get(W.memberId);ue?ue.total+=W.count:w.set(W.memberId,{name:W.memberName,total:W.count})}),w.size<=2){const W=new Map;return y.value.forEach(ue=>{W.set(ue.month,(W.get(ue.month)||0)+ue.count)}),{tooltip:{trigger:"axis",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:50,right:20,top:10,bottom:30},xAxis:{type:"category",data:A,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{type:"dashed",opacity:.3}}},series:[{type:"line",smooth:!0,symbol:"none",areaStyle:{opacity:.2},itemStyle:{color:"#6366f1"},data:A.map(ue=>W.get(ue)||0)}]}}const le=[...w.entries()].sort((W,ue)=>ue[1].total-W[1].total).slice(0,10).map(([W,ue],ve)=>{const G=new Map(y.value.filter(F=>F.memberId===W).map(F=>[F.month,F.count]));return{name:ue.name,type:"line",stack:"total",areaStyle:{opacity:.3},smooth:!0,symbol:"none",itemStyle:{color:M[ve%M.length]},data:A.map(F=>G.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:A,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{type:"dashed",opacity:.3}}},series:le}});async function B(){if(s.sessionId){c.value=!0;try{const A=Ne(),[w,T,H,le,W,ue,ve]=await Promise.all([A.getMessageTypeDistribution(s.sessionId,s.timeFilter),A.getHourlyActivity(s.sessionId,s.timeFilter),A.getWeekdayActivity(s.sessionId,s.timeFilter),A.getMonthlyActivity(s.sessionId,s.timeFilter),A.getYearlyActivity(s.sessionId,s.timeFilter),A.getDailyActivity(s.sessionId,s.timeFilter),A.getMemberMonthlyTrend(s.sessionId,s.timeFilter)]);r.value=w,g.value=T,u.value=H,d.value=le,m.value=W,v.value=ue,y.value=ve,h.value.length>0&&(k.value=h.value[0])}catch(A){console.error("[chart-message] Failed to load time analysis data:",A)}finally{c.value=!1}}}return ge(()=>[s.sessionId,s.timeFilter],()=>B(),{immediate:!0,deep:!0}),(A,w)=>{const T=Wt;return n(),i("div",{class:ne(c.value?"h-full":"")},[c.value?(n(),Y(a(mt),{key:0,variant:"page",text:a(t)("common.loading")},null,8,["text"])):(n(),i("div",ox,[v.value.length>0?(n(),Y(sx,{key:0,"hourly-activity":g.value,"weekday-activity":u.value,"daily-activity":v.value},null,8,["hourly-activity","weekday-activity","daily-activity"])):R("",!0),e("div",nx,[p(a(Oe),{title:a(t)("views.message.hourlyDistribution"),"show-divider":!1},{default:j(()=>[e("div",rx,[p(a(Ze),{data:I.value,height:200},null,8,["data"])])]),_:1},8,["title"]),p(a(Oe),{title:a(t)("views.message.weekdayDistribution"),"show-divider":!1},{default:j(()=>[e("div",lx,[p(a(Ze),{data:q.value,height:200},null,8,["data"])])]),_:1},8,["title"])]),e("div",ix,[p(a(Oe),{title:a(t)("views.message.monthlyDistribution"),"show-divider":!1},{default:j(()=>[e("div",cx,[p(a(Ze),{data:_.value,height:200},null,8,["data"])])]),_:1},8,["title"]),p(a(Oe),{title:a(t)("views.message.yearlyDistribution"),"show-divider":!1},{default:j(()=>[e("div",dx,[L.value.values.length>0?(n(),Y(a(Ze),{key:0,data:L.value,height:200},null,8,["data"])):(n(),i("div",ux,o(a(t)("views.message.noData")),1))])]),_:1},8,["title"])]),p(a(Oe),{title:a(t)("views.message.timeAnalysis.memberTrendTitle"),"show-divider":!1},{headerRight:j(()=>[e("span",mx,o(a(t)("views.message.timeAnalysis.memberTrendHint")),1)]),default:j(()=>[e("div",gx,[y.value.length>0?(n(),Y(a($t),{key:0,option:P.value,height:280},null,8,["option"])):(n(),i("div",px,o(a(t)("views.message.noData")),1))])]),_:1},8,["title"]),p(a(Oe),{title:a(t)("views.message.timeHeatmap"),"show-divider":!1},{headerRight:j(()=>[e("span",vx,o(a(t)("views.message.heatmapHint")),1)]),default:j(()=>[e("div",yx,[p(a(Bt),{data:x.value,height:320},null,8,["data"])])]),_:1},8,["title"]),p(a(Oe),{title:a(t)("views.message.calendarHeatmap"),"show-divider":!1},{headerRight:j(()=>[e("div",hx,[e("span",fx,o(a(t)("views.message.calendarHint")),1),h.value.length>1?(n(),Y(T,{key:0,modelValue:k.value,"onUpdate:modelValue":w[0]||(w[0]=H=>k.value=H),items:h.value.map(H=>({value:H,label:String(H)})),size:"xs",class:"w-20"},null,8,["modelValue","items"])):R("",!0)])]),default:j(()=>[e("div",xx,[S.value.length>0?(n(),Y(a($m),{key:0,data:S.value,year:k.value,height:180},null,8,["data","year"])):(n(),i("div",bx,o(a(t)("views.message.noData")),1))])]),_:1},8,["title"])]))],2)}}}),kx={class:"flex items-center justify-between gap-3"},_x={class:"flex items-center gap-2"},wx={class:"text-sm font-medium text-gray-900 dark:text-white"},$x={class:"text-xs text-gray-500 dark:text-gray-400"},Zb=pe({__name:"OwnerEntryCard",props:{sessionId:{},members:{},chatType:{}},setup(l){const{t:s}=fe(),t=Ra(),c=l,r=f(!1);function g(m){return m.groupNickname||m.accountName||m.platformId}const u=b(()=>{const m=t.currentSession?.ownerId;return m&&c.members.find(v=>v.platformId===m)||null}),d=b(()=>u.value?g(u.value):t.currentSession?.ownerId??"");return(m,v)=>{const y=we,M=ze;return n(),Y(a(tt),{class:"w-150 p-3"},{default:j(()=>[e("div",kx,[e("div",_x,[e("div",{class:ne(["flex h-8 w-8 items-center justify-center rounded-full bg-linear-to-br",l.chatType==="group"?"from-pink-400 to-pink-600":"from-purple-400 to-purple-600"])},[p(y,{name:"i-heroicons-user",class:"h-4 w-4 text-white"})],2),e("div",null,[e("h3",wx,o(d.value?a(s)("members.ownerPrompt.currentOwner",{name:d.value}):a(s)("members.ownerPrompt.choose")),1),e("p",$x,o(a(s)("members.ownerPrompt.helper")),1)])]),p(M,{size:"sm",variant:d.value?"outline":"solid",color:"primary",onClick:v[0]||(v[0]=$=>r.value=!0)},{default:j(()=>[ee(o(d.value?a(s)("members.ownerPrompt.change"):a(s)("members.ownerPrompt.choose")),1)]),_:1},8,["variant"])]),p(Pa,{modelValue:r.value,"onUpdate:modelValue":v[1]||(v[1]=$=>r.value=$),"session-id":l.sessionId,"chat-type":l.chatType},null,8,["modelValue","session-id","chat-type"])]),_:1})}}}),Cx={class:"mt-3 flex items-center justify-between gap-3"},ek=pe({__name:"SessionAnalysisHeader",props:Rt({title:{},avatar:{},icon:{},iconClass:{},tabs:{},currentSessionId:{},initialTimeState:{}},{activeTab:{required:!0},activeTabModifiers:{},timeRangeValue:{required:!0},timeRangeValueModifiers:{}}),emits:Rt(["openIncrementalImport","openMemberManagement","openChatRecord","update:fullRange","update:availableYears"],["update:activeTab","update:timeRangeValue"]),setup(l,{emit:s}){const t=zt(l,"activeTab"),c=zt(l,"timeRangeValue"),r=l,g=s,{t:u}=fe(),d=ct(),m=b(()=>!["ai-chat","memory","lab","debug"].includes(t.value)),v=b(()=>r.tabs.map(y=>({id:y.id,label:u(y.labelKey),icon:y.icon})));return(y,M)=>{const $=ze,D=pt;return n(),Y(es,{title:l.title,avatar:l.avatar,size:"compact",icon:l.icon,"icon-class":l.iconClass},{actions:j(()=>[a(d).toolsPanelPosition==="header"?(n(),i(Z,{key:0},[p(D,{text:a(u)("analysis.tooltip.viewChatRecord")},{default:j(()=>[p($,{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:M[0]||(M[0]=I=>g("openChatRecord"))})]),_:1},8,["text"]),p(D,{text:a(u)("analysis.tooltip.incrementalImport")},{default:j(()=>[p($,{icon:"i-heroicons-plus-circle",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:M[1]||(M[1]=I=>g("openIncrementalImport"))})]),_:1},8,["text"]),p(D,{text:a(u)("analysis.tooltip.memberManagement")},{default:j(()=>[p($,{icon:"i-heroicons-user-group",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:M[2]||(M[2]=I=>g("openMemberManagement"))})]),_:1},8,["text"]),p(it,{color:"gray"}),p(D,{text:a(u)("analysis.tooltip.more")},{default:j(()=>[p($,{"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:M[3]||(M[3]=I=>a(d).toggleToolsPanelOpen())})]),_:1},8,["text"])],64)):(n(),Y(it,{key:1,color:"gray"}))]),default:j(()=>[e("div",Cx,[p(a(Ea),{modelValue:t.value,"onUpdate:modelValue":M[4]||(M[4]=I=>t.value=I),class:"min-w-0 shrink",items:v.value},null,8,["modelValue","items"]),p(Za,{modelValue:c.value,"onUpdate:modelValue":M[5]||(M[5]=I=>c.value=I),"session-id":l.currentSessionId??void 0,visible:m.value,"initial-state":l.initialTimeState,size:"sm","onUpdate:fullRange":M[6]||(M[6]=I=>g("update:fullRange",I)),"onUpdate:availableYears":M[7]||(M[7]=I=>g("update:availableYears",I))},null,8,["modelValue","session-id","visible","initial-state"])])]),_:1},8,["title","avatar","icon","icon-class"])}}}),Sx={class:"space-y-4 p-5"},Tx={class:"flex items-center gap-2"},Mx={class:"text-base font-semibold text-gray-900 dark:text-white"},Ix={key:0,class:"flex items-center gap-2 text-sm text-gray-400"},Lx={class:"rounded-lg border border-gray-200 bg-gray-50 p-3 text-sm dark:border-gray-700 dark:bg-gray-800/50"},Dx={class:"flex items-center justify-between"},Ax={class:"text-gray-500"},qx={class:"font-medium text-gray-800 dark:text-gray-200"},zx={key:0,class:"mt-1 flex items-center justify-between"},Rx={class:"text-gray-500"},Px={class:"text-gray-700 dark:text-gray-300"},Ex={key:1,class:"mt-2"},Bx={class:"flex items-center justify-between text-xs text-gray-500"},jx={class:"mt-1 h-1.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},Ux={key:2,class:"mt-1 text-xs text-red-500"},Fx={class:"text-sm text-gray-600 dark:text-gray-400"},Vx={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"},Nx={class:"flex justify-end gap-2"},Ox={class:"text-xs text-gray-400"},Wx={class:"flex flex-wrap justify-end gap-2"},Ae="settings.ai.semanticIndex",tk=pe({__name:"SemanticIndexSessionModal",props:{modelValue:{type:Boolean},sessionId:{},messageCount:{}},emits:["update:modelValue"],setup(l,{emit:s}){const t=l,c=s,{t:r}=fe(),g=Ba(),u=b({get:()=>t.modelValue,set:C=>c("update:modelValue",C)}),d=f(null),m=f(!1),v=f(!1),y=f(!1),M=b(()=>{const C=d.value;return!C||!C.enabled?r(`${Ae}.session.notEnabled`):C.needsRebuild?r(`${Ae}.state.needsRebuild`):C.running||C.queued||C.indexStatus==="running"?r(`${Ae}.state.building`):C.indexStatus==="completed"?r(`${Ae}.state.completed`):C.indexStatus==="failed"?r(`${Ae}.state.failed`):C.indexStatus==="paused"?r(`${Ae}.state.paused`):r(`${Ae}.state.pending`)}),$=b(()=>{const C=d.value;return!!C&&(C.running||C.queued||C.indexStatus==="running")}),D=b(()=>d.value&&d.value.totalMessages>0?Math.round(d.value.indexedMessages/d.value.totalMessages*100):0);let I=null;function q(){I&&(clearTimeout(I),I=null)}function _(){q(),I=setTimeout(async()=>{try{d.value=await g.status(t.sessionId)}catch(C){console.error("[semantic-index] poll status failed:",C)}$.value&&t.modelValue?_():q()},1500)}async function L(){v.value=!0;try{const[C,h]=await Promise.all([g.getConfig(),g.status(t.sessionId)]);m.value=C.config.enabled&&C.configured&&(C.config.mode==="local"?!!C.config.local.modelId:!!C.config.api?.baseUrl&&!!C.config.api?.model&&(!ja(C.config.api?.baseUrl)||C.apiKeySet)),d.value=h}catch(C){console.error("[semantic-index] load session status failed:",C)}finally{v.value=!1}$.value&&_()}async function x(C){y.value=!0;try{d.value=await g[C](t.sessionId)}catch(h){console.error(`[semantic-index] ${C} failed:`,h)}finally{y.value=!1}$.value?_():q()}return ge(()=>t.modelValue,C=>{C?L():q()}),ut(q),(C,h)=>{const k=we,S=ze,P=He;return n(),Y(P,{open:u.value,"onUpdate:open":h[10]||(h[10]=B=>u.value=B),ui:{content:"z-[101]",overlay:"z-[100]"}},{content:j(()=>[e("div",Sx,[e("div",Tx,[p(k,{name:"i-heroicons-circle-stack",class:"h-5 w-5 text-blue-500"}),e("h3",Mx,o(a(r)(`${Ae}.title`)),1)]),v.value?(n(),i("div",Ix,[p(k,{name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin"}),ee(" "+o(a(r)("common.loading")),1)])):(n(),i(Z,{key:1},[e("div",Lx,[e("div",Dx,[e("span",Ax,o(a(r)(`${Ae}.session.statusLabel`)),1),e("span",qx,o(M.value),1)]),d.value?.enabled&&d.value.indexStatus==="completed"?(n(),i("div",zx,[e("span",Rx,o(a(r)(`${Ae}.session.coverageLabel`)),1),e("span",Px,o(D.value)+"%",1)])):R("",!0),$.value?(n(),i("div",Ex,[e("div",Bx,[e("span",null,o(a(r)(`${Ae}.session.progressLabel`)),1),e("span",null,o(d.value?.indexedMessages??0)+" / "+o(d.value?.totalMessages??0)+" ("+o(D.value)+"%) ",1)]),e("div",jx,[e("div",{class:"h-full rounded-full bg-blue-500 transition-all duration-500",style:Qe({width:`${D.value}%`})},null,4)])])):R("",!0),d.value?.error?(n(),i("p",Ux,o(d.value.error),1)):R("",!0)]),d.value?.enabled?(n(),i(Z,{key:1},[e("p",Ox,o(a(r)(`${Ae}.session.buildVsEnable`)),1),e("div",Wx,[$.value?(n(),i(Z,{key:0},[p(S,{variant:"soft",loading:y.value,onClick:h[2]||(h[2]=B=>x("pause"))},{default:j(()=>[ee(o(a(r)(`${Ae}.action.pause`)),1)]),_:1},8,["loading"]),p(S,{color:"error",variant:"soft",disabled:y.value,onClick:h[3]||(h[3]=B=>x("cancel"))},{default:j(()=>[ee(o(a(r)(`${Ae}.action.cancel`)),1)]),_:1},8,["disabled"])],64)):d.value?.indexStatus==="completed"&&!d.value?.needsRebuild?(n(),Y(S,{key:1,variant:"soft",loading:y.value,onClick:h[4]||(h[4]=B=>x("rebuild"))},{default:j(()=>[ee(o(a(r)(`${Ae}.action.rebuild`)),1)]),_:1},8,["loading"])):d.value?.needsRebuild?(n(),Y(S,{key:2,color:"primary",loading:y.value,onClick:h[5]||(h[5]=B=>x("rebuild"))},{default:j(()=>[ee(o(a(r)(`${Ae}.action.rebuild`)),1)]),_:1},8,["loading"])):d.value?.indexStatus==="failed"?(n(),Y(S,{key:3,color:"primary",loading:y.value,onClick:h[6]||(h[6]=B=>x("build"))},{default:j(()=>[ee(o(a(r)(`${Ae}.session.retry`)),1)]),_:1},8,["loading"])):d.value?.indexStatus==="paused"?(n(),Y(S,{key:4,color:"primary",loading:y.value,onClick:h[7]||(h[7]=B=>x("build"))},{default:j(()=>[ee(o(a(r)(`${Ae}.session.continue`)),1)]),_:1},8,["loading"])):(n(),Y(S,{key:5,color:"primary",loading:y.value,onClick:h[8]||(h[8]=B=>x("build"))},{default:j(()=>[ee(o(a(r)(`${Ae}.action.build`)),1)]),_:1},8,["loading"])),p(S,{variant:"ghost",color:"neutral",disabled:y.value,onClick:h[9]||(h[9]=B=>x("remove"))},{default:j(()=>[ee(o(a(r)(`${Ae}.action.remove`)),1)]),_:1},8,["disabled"])])],64)):(n(),i(Z,{key:0},[e("p",Fx,o(a(r)(`${Ae}.session.enableHint`)),1),m.value?R("",!0):(n(),i("p",Vx,o(a(r)(`${Ae}.session.configFirst`)),1)),e("div",Nx,[p(S,{variant:"ghost",onClick:h[0]||(h[0]=B=>u.value=!1)},{default:j(()=>[ee(o(a(r)("common.close")),1)]),_:1}),p(S,{color:"primary",loading:y.value,disabled:!m.value,onClick:h[1]||(h[1]=B=>x("enable"))},{default:j(()=>[ee(o(a(r)(`${Ae}.session.enable`)),1)]),_:1},8,["loading","disabled"])])],64))],64))])]),_:1},8,["open"])}}}),Hx={class:"min-h-[200px]"},Yx={key:0,class:"space-y-4"},Kx={class:"text-sm text-gray-600 dark:text-gray-400"},Qx={class:"text-sm text-gray-600 dark:text-gray-400"},Gx={key:1,class:"flex flex-col items-center justify-center py-10"},Jx={class:"text-gray-600 dark:text-gray-400"},Xx={class:"mt-2 text-sm text-gray-500"},Zx={key:2,class:"space-y-6"},eb={class:"rounded-lg bg-gray-50 p-4 dark:bg-gray-800"},tb={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},ab={class:"grid grid-cols-3 gap-4 text-center"},sb={class:"text-2xl font-bold text-gray-900 dark:text-white"},ob={class:"text-xs text-gray-500"},nb={class:"text-2xl font-bold text-green-600 dark:text-green-400"},rb={class:"text-xs text-gray-500"},lb={class:"text-2xl font-bold text-gray-400"},ib={class:"text-xs text-gray-500"},cb={key:0,class:"text-center text-sm text-amber-600 dark:text-amber-400"},db={key:3,class:"flex flex-col items-center justify-center py-10"},ub={class:"text-gray-600 dark:text-gray-400"},mb={key:0,class:"mt-4 w-full max-w-xs"},gb={key:4,class:"flex flex-col items-center justify-center py-10"},pb={class:"text-lg font-medium text-gray-900 dark:text-white"},vb={class:"mt-2 text-sm text-gray-600 dark:text-gray-400"},yb={key:5,class:"flex flex-col items-center justify-center py-10"},hb={class:"text-lg font-medium text-gray-900 dark:text-white"},fb={class:"mt-2 text-sm text-red-600 dark:text-red-400"},xb={class:"flex w-full justify-end gap-2"},ak=pe({__name:"IncrementalImportModal",props:{modelValue:{type:Boolean},sessionId:{},sessionName:{}},emits:["update:modelValue","imported"],setup(l,{emit:s}){const t=l,c=s,{t:r}=fe(),g=f("select"),u=f(null),d=f(null),m=f(null),v=f(null),y=f(null),M=f(null),$=b({get:()=>t.modelValue,set:k=>c("update:modelValue",k)});ge($,k=>{k||D()});function D(){g.value="select",u.value=null,m.value=null,v.value=null,y.value=null,M.value=null}async function I({files:k,paths:S}){if(k.length>0)u.value={source:k[0],name:k[0].name};else{y.value=r("home.import.cannotReadPath");return}await _()}function q(){d.value?.openFileDialog()}async function _(){if(u.value){g.value="analyzing",y.value=null;try{const k=await Xt().analyzeIncrementalImport(t.sessionId,u.value.source);if(k.error){g.value="error",y.value=h(k.error);return}m.value={newMessageCount:k.newMessageCount,duplicateCount:k.duplicateCount,totalInFile:k.totalInFile},g.value="preview"}catch(k){g.value="error",y.value=String(k)}}}async function L(){if(u.value){g.value="importing",v.value={stage:"saving",progress:0,message:""};try{const k=await Xt().incrementalImport(t.sessionId,u.value.source,S=>{v.value=S});k.success?(M.value={newMessageCount:k.newMessageCount},g.value="done"):(g.value="error",y.value=h(k.error||"error.import_failed"))}catch(k){g.value="error",y.value=String(k)}}}function x(){M.value&&c("imported",M.value.newMessageCount),$.value=!1}function C(){g.value="select",u.value=null,m.value=null,y.value=null}function h(k){if(k.startsWith("error.")){const S=`home.import.errors.${k.slice(6)}`,P=r(S);return P!==S?P:k}return k}return(k,S)=>{const P=we,B=Wa,A=ze,w=He;return n(),Y(w,{open:$.value,"onUpdate:open":S[1]||(S[1]=T=>$.value=T),title:a(r)("analysis.incremental.title")},{body:j(()=>[e("div",Hx,[g.value==="select"?(n(),i("div",Yx,[e("p",Kx,o(a(r)("analysis.incremental.description",{name:l.sessionName})),1),p(a(Ha),{ref_key:"dropZoneRef",ref:d,accept:[".json",".jsonl",".txt"],class:"w-full",onFiles:I},{default:j(({isDragOver:T})=>[e("div",{class:ne(["flex cursor-pointer flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 py-10 transition-colors",T?"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:Be(q,["stop"])},[p(P,{name:"i-heroicons-arrow-up-tray",class:"mb-3 h-10 w-10 text-gray-400"}),e("p",Qx,o(T?a(r)("home.import.dropHint"):a(r)("analysis.incremental.dropHint")),1)],2)]),_:1},512)])):g.value==="analyzing"?(n(),i("div",Gx,[p(P,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),e("p",Jx,o(a(r)("analysis.incremental.analyzing")),1),e("p",Xx,o(u.value?.name),1)])):g.value==="preview"&&m.value?(n(),i("div",Zx,[e("div",eb,[e("p",tb,o(u.value?.name),1),e("div",ab,[e("div",null,[e("p",sb,o(m.value.totalInFile.toLocaleString()),1),e("p",ob,o(a(r)("analysis.incremental.totalInFile")),1)]),e("div",null,[e("p",nb,o(m.value.newMessageCount.toLocaleString()),1),e("p",rb,o(a(r)("analysis.incremental.newMessages")),1)]),e("div",null,[e("p",lb,o(m.value.duplicateCount.toLocaleString()),1),e("p",ib,o(a(r)("analysis.incremental.duplicates")),1)])])]),m.value.newMessageCount===0?(n(),i("p",cb,[p(P,{name:"i-heroicons-exclamation-triangle",class:"mr-1 inline-block h-4 w-4"}),ee(" "+o(a(r)("analysis.incremental.noNewMessages")),1)])):R("",!0)])):g.value==="importing"?(n(),i("div",db,[p(P,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),e("p",ub,o(a(r)("analysis.incremental.importing")),1),v.value?(n(),i("div",mb,[p(B,{value:v.value.progress,size:"sm"},null,8,["value"])])):R("",!0)])):g.value==="done"&&M.value?(n(),i("div",gb,[p(P,{name:"i-heroicons-check-circle",class:"mb-4 h-12 w-12 text-green-500"}),e("p",pb,o(a(r)("analysis.incremental.success")),1),e("p",vb,o(a(r)("analysis.incremental.successDetail",{count:M.value.newMessageCount})),1)])):g.value==="error"?(n(),i("div",yb,[p(P,{name:"i-heroicons-x-circle",class:"mb-4 h-12 w-12 text-red-500"}),e("p",hb,o(a(r)("analysis.incremental.failed")),1),e("p",fb,o(y.value),1)])):R("",!0)])]),footer:j(()=>[e("div",xb,[g.value==="select"?(n(),Y(A,{key:0,color:"neutral",variant:"ghost",onClick:S[0]||(S[0]=T=>$.value=!1)},{default:j(()=>[ee(o(a(r)("common.cancel")),1)]),_:1})):g.value==="preview"?(n(),i(Z,{key:1},[p(A,{color:"neutral",variant:"ghost",onClick:C},{default:j(()=>[ee(o(a(r)("common.back")),1)]),_:1}),p(A,{color:"primary",disabled:!m.value||m.value.newMessageCount===0,onClick:L},{default:j(()=>[ee(o(a(r)("analysis.incremental.import",{count:m.value?.newMessageCount||0})),1)]),_:1},8,["disabled"])],64)):g.value==="done"||g.value==="error"?(n(),i(Z,{key:2},[g.value==="error"?(n(),Y(A,{key:0,color:"neutral",variant:"ghost",onClick:C},{default:j(()=>[ee(o(a(r)("common.retry")),1)]),_:1})):R("",!0),p(A,{color:"primary",onClick:x},{default:j(()=>[ee(o(a(r)("common.done")),1)]),_:1})],64)):R("",!0)])]),_:1},8,["open","title"])}}}),bb={key:0,class:"fixed right-0 top-1/3"},kb={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"},_b=["onClick"],wb={class:"mb-2 flex items-center justify-between"},$b={class:"px-0.5 text-[9px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"},Cb={class:"flex flex-col gap-1.5"},Sb=["onClick"],Tb={class:"whitespace-nowrap"},sk=pe({__name:"ActionToolsPanel",emits:["openIncrementalImport","openSemanticIndex","openMemberManagement","openChatRecord","openMessageExport"],setup(l,{emit:s}){const{t}=fe(),c=ct(),{isToolsPanelMini:r,toolsPanelPosition:g,isToolsPanelOpen:u}=et(c),d=b(()=>g.value==="header"),m=b(()=>!d.value||u.value),v=f(null),y=s;function M(_){y(_),d.value&&(u.value=!1)}function $(_){if(!d.value||!u.value)return;const L=_.target;L instanceof Element&&(v.value?.contains(L)||L.closest("[data-tools-panel-trigger]")||(u.value=!1))}const D=[{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"}],I=[{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"}],q=b(()=>d.value?I:D);return ge(g,()=>{u.value=!1}),je(()=>{document.addEventListener("mousedown",$)}),kt(()=>{document.removeEventListener("mousedown",$)}),(_,L)=>{const x=we,C=pt;return!d.value&&a(r)?(n(),i("div",bb,[e("div",kb,[(n(),i(Z,null,ce(D,h=>p(C,{key:h.event,text:a(t)(h.labelKey),popper:{placement:"left"}},{default:j(()=>[e("button",{class:ne(["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",h.miniHoverBg]),onClick:k=>M(h.event)},[p(x,{name:h.icon,class:"h-3.5 w-3.5"},null,8,["name"])],10,_b)]),_:2},1032,["text"])),64)),L[2]||(L[2]=e("div",{class:"my-0.5 h-px w-4 bg-gray-200 dark:bg-gray-700"},null,-1)),p(C,{text:a(t)("analysis.toolsPanel.exitMini"),popper:{placement:"left"}},{default:j(()=>[e("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:L[0]||(L[0]=h=>a(c).toggleToolsPanelMini())},[p(x,{name:"i-heroicons-arrows-pointing-out",class:"h-3 w-3"})])]),_:1},8,["text"])])])):(n(),i("div",{key:1,class:ne(["fixed right-0 z-40",d.value?"top-14":"top-1/3"])},[e("div",{class:ne(["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"])},[e("div",{ref_key:"panelRef",ref:v,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"},[e("div",wb,[e("span",$b,o(a(t)("analysis.overview.tools")),1),d.value?R("",!0):(n(),Y(C,{key:0,text:a(t)("analysis.toolsPanel.miniMode"),popper:{placement:"left"}},{default:j(()=>[e("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:L[1]||(L[1]=h=>a(c).toggleToolsPanelMini())},[p(x,{name:"i-heroicons-arrows-pointing-in",class:"h-3 w-3"})])]),_:1},8,["text"]))]),e("div",Cb,[(n(!0),i(Z,null,ce(q.value,h=>(n(),i("button",{key:h.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:k=>M(h.event)},[p(x,{name:h.icon,class:ne(["h-3.5 w-3.5 text-gray-400 transition-colors dark:text-gray-500",h.hoverColor])},null,8,["name","class"]),e("span",Tb,o(a(t)(h.labelKey)),1)],8,Sb))),128))])],512)],2)],2))}}});export{Wb as A,Eu as C,Yb as D,Mt as _,Nb as a,Qb as b,Oe as c,Ut as d,Gb as e,Qg as f,Jb as g,Xb as h,Ob as i,Zb as j,Vb as k,ek as l,sk as m,tk as n,ak as o,Hb as p,rs as q,Fb as r,Dm as s,Pm as t,Kb as u};