chatlab-cli 0.27.1 → 0.28.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.
- package/README.md +1 -1
- package/dist/{chat-command-B7POB3C3.mjs → chat-command-7WL5NMZ6.mjs} +5 -5
- package/dist/{chunk-I7BHOZPX.mjs → chunk-55WR6WKW.mjs} +84 -19
- package/dist/{chunk-I7BHOZPX.mjs.map → chunk-55WR6WKW.mjs.map} +1 -1
- package/dist/{chunk-3FUF3PEY.mjs → chunk-GFRG7TZQ.mjs} +27 -12
- package/dist/chunk-GFRG7TZQ.mjs.map +1 -0
- package/dist/{chunk-N3G43SCQ.mjs → chunk-GPF34WXV.mjs} +2560 -324
- package/dist/chunk-GPF34WXV.mjs.map +1 -0
- package/dist/{chunk-WQMKKUSD.mjs → chunk-VASK54KT.mjs} +2 -2
- package/dist/{chunk-3JNVGW62.mjs → chunk-WGS33EWH.mjs} +2 -2
- package/dist/{chunk-RJ4D4QWK.mjs → chunk-XNU5X7EV.mjs} +3 -3
- package/dist/{chunk-SIVERPF5.mjs → chunk-YQ2FJGBT.mjs} +172 -18
- package/dist/chunk-YQ2FJGBT.mjs.map +1 -0
- package/dist/{chunk-YUFYTDRH.mjs → chunk-YZDEZ6UI.mjs} +3 -3
- package/dist/{chunk-SAE2H2LN.mjs → chunk-ZSFVX6FM.mjs} +3 -3
- package/dist/cli.mjs +4 -4
- package/dist/{http-A54ZBBAY.mjs → http-C2FBHNZG.mjs} +9 -9
- package/dist/{import-EA3TB3S2.mjs → import-ED6JCPSJ.mjs} +5 -5
- package/dist/index.mjs +9 -9
- package/dist/{mcp-DJDOWHH3.mjs → mcp-5JIBER4M.mjs} +5 -5
- package/dist/semantic-index-worker.mjs +1 -1
- package/dist/{src-EKPMJRG6.mjs → src-WBNM42SL.mjs} +21 -3
- package/dist/{stream-import-FQFNRQ2B.mjs → stream-import-37U3SROO.mjs} +4 -4
- package/dist/{worker-runtime-UH2OBO3T.mjs → worker-runtime-6DGYL4TF.mjs} +2 -2
- package/dist-web/assets/{DebugToolsPanel.vue_vue_type_script_setup_true_lang-NL1sTF6i.js → DebugToolsPanel.vue_vue_type_script_setup_true_lang-CCz0Syxo.js} +5 -5
- package/dist-web/assets/{MessageExportModal-B60rvfCh.js → MessageExportModal-Dd6R-cX_.js} +1 -1
- package/dist-web/assets/electron-D9vE5t3H.js +1 -0
- package/dist-web/assets/electron-DGxVMsvC.js +1 -0
- package/dist-web/assets/{electron-BRUg9LnY.js → electron-DjminAKK.js} +1 -1
- package/dist-web/assets/{fetch-DSN-QYZE.js → fetch-B_kLRm6-.js} +1 -1
- package/dist-web/assets/{fetch-DLAp7h55.js → fetch-CURbMNJV.js} +1 -1
- package/dist-web/assets/fetch-Cle6QKmL.js +3 -0
- package/dist-web/assets/{fetch-BIpjJHxj.js → fetch-DFCYOQe5.js} +1 -1
- package/dist-web/assets/{fetch-DNSaxRnL.js → fetch-DOhCQ5J8.js} +1 -1
- package/dist-web/assets/{fetch-DE8gj5Ke.js → fetch-DV8A1dGB.js} +1 -1
- package/dist-web/assets/{fetch-C-m3IysH.js → fetch-Wad5mWVH.js} +1 -1
- package/dist-web/assets/{fetch-BRsMdFcn.js → fetch-r83wdzHy.js} +1 -1
- package/dist-web/assets/{fetch-Cma-mZjd.js → fetch-srCJzcWc.js} +1 -1
- package/dist-web/assets/{fetch-woAa3H2L.js → fetch-uM3erGZm.js} +1 -1
- package/dist-web/assets/index-7E5GSvR2.css +1 -0
- package/dist-web/assets/index-BCRHSc1k.js +173 -0
- package/dist-web/assets/{index-r_zHR2t9.js → index-BIvLzdwg.js} +1 -1
- package/dist-web/assets/{index-o6veAyTB.js → index-BpszRZ8V.js} +3 -3
- package/dist-web/assets/index-D5UgZUpS.js +12 -0
- package/dist-web/assets/{index-iwqJDVMJ.js → index-hOsKRsp6.js} +2 -2
- package/dist-web/assets/{index-B9I-Y3fR.js → index-tkbEq8av.js} +1 -1
- package/dist-web/assets/web-D27K6zSX.js +1 -0
- package/dist-web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-3FUF3PEY.mjs.map +0 -1
- package/dist/chunk-N3G43SCQ.mjs.map +0 -1
- package/dist/chunk-SIVERPF5.mjs.map +0 -1
- package/dist-web/assets/electron-2m4Vdk2z.js +0 -1
- package/dist-web/assets/electron-CRSL7qPM.js +0 -1
- package/dist-web/assets/fetch-DOEbyLSD.js +0 -3
- package/dist-web/assets/index-B3mDjury.js +0 -11
- package/dist-web/assets/index-GAU7LI1r.js +0 -173
- package/dist-web/assets/index-YmzTgkb2.css +0 -1
- package/dist-web/assets/web-C2UtGskd.js +0 -1
- /package/dist/{chat-command-B7POB3C3.mjs.map → chat-command-7WL5NMZ6.mjs.map} +0 -0
- /package/dist/{chunk-WQMKKUSD.mjs.map → chunk-VASK54KT.mjs.map} +0 -0
- /package/dist/{chunk-3JNVGW62.mjs.map → chunk-WGS33EWH.mjs.map} +0 -0
- /package/dist/{chunk-RJ4D4QWK.mjs.map → chunk-XNU5X7EV.mjs.map} +0 -0
- /package/dist/{chunk-YUFYTDRH.mjs.map → chunk-YZDEZ6UI.mjs.map} +0 -0
- /package/dist/{chunk-SAE2H2LN.mjs.map → chunk-ZSFVX6FM.mjs.map} +0 -0
- /package/dist/{http-A54ZBBAY.mjs.map → http-C2FBHNZG.mjs.map} +0 -0
- /package/dist/{import-EA3TB3S2.mjs.map → import-ED6JCPSJ.mjs.map} +0 -0
- /package/dist/{mcp-DJDOWHH3.mjs.map → mcp-5JIBER4M.mjs.map} +0 -0
- /package/dist/{src-EKPMJRG6.mjs.map → src-WBNM42SL.mjs.map} +0 -0
- /package/dist/{stream-import-FQFNRQ2B.mjs.map → stream-import-37U3SROO.mjs.map} +0 -0
- /package/dist/{worker-runtime-UH2OBO3T.mjs.map → worker-runtime-6DGYL4TF.mjs.map} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{v as Ea,w as na,x as $e,j as Ue,u as ke,y as Ne,_ as st,z as Je,k as dt,A as za,B as ut,s as at,D as $t,E as Pa,g as ra,F as gt,b as Ct,G as Yt,H as la,p as pt,J as wt,K as Ba,T as et,L as Zt,M as ja,r as ia,e as ca,N as ea,i as Dt,h as Fa,O as Ua,P as Va,f as ta,d as Oa,Q as Na}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-D5UgZUpS.js","assets/vendor-reka-ui-mMvma1EP.js","assets/vendor-nuxt-ui-Zy8txNdC.js","assets/vendor-snapdom-XnBoh1gd.js","assets/index-7E5GSvR2.css","assets/EChartWordcloud-B_YisOW5.js","assets/vendor-echarts-wordcloud-B1kQMklB.js","assets/vendor-echarts-CITQeskI.js","assets/vendor-zrender-DFl4U2Oe.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{v as Ea,w as na,x as $e,j as Ue,u as ke,y as Ne,_ as st,z as Je,k as dt,A as za,B as ut,s as at,D as $t,E as Pa,g as ra,F as gt,b as Ct,G as Yt,H as la,p as pt,J as wt,K as Ba,T as et,L as Zt,M as ja,r as ia,e as ca,N as ea,i as Dt,h as Fa,O as Ua,P as Va,f as ta,d as Oa,Q as Na}from"./index-D5UgZUpS.js";import{t as Qe,w as ge,h as k,b as x,d as Ee,p as he,G as n,P as i,Q as oe,a5 as e,U as R,L as p,O as Ke,H as K,K as U,T as o,a0 as Ge,R as ee,Z as ne,u as a,a3 as de,bA as He,bB as ot,a9 as Fe,bz as Xe,J as zt,W as Pt,n as Ve,F as lt,bK as Ha,bH as nt,bD as rt,z as St,bI as da,k as Ya}from"./vendor-reka-ui-mMvma1EP.js";import{_ as Tt}from"./vendor-snapdom-XnBoh1gd.js";import{a as _e,b as Re,c as ua,g as Oe,_ as vt,e as ht,E as Wa,n as ma,k as It,f as ga,j as Wt,l as Ka,F as Kt,u as Qa,o as Ga,h as Ja}from"./vendor-nuxt-ui-Zy8txNdC.js";import{a as ct,M as Qt,_ as Xa}from"./index-tkbEq8av.js";import"./vendor-echarts-wordcloud-B1kQMklB.js";import{u as yt,m as ft,v as pa,t as va,w as Za,o as Gt,x as es,j as Mt,k as ts,p as ha,q as Jt,y as as,n as xt,z as ya,A as ss}from"./vendor-echarts-CITQeskI.js";const os={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"]},aa=/^(?!.*-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 ns(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":aa.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":aa.test(t)?"default":"none"}function rs(l,s){const t=ns(l,s);return os[t]}function ls(l,s,t,c="group",r="zh-CN"){const m=Ea(),{chatKey:u,state:d}=m.ensureSessionState({sessionId:l,sessionName:s,timeFilter:t,chatType:c,locale:r});return m.resetToSelectorOnEnter(u),m.applySessionAssistantSelection(u),{messages:Qe(d,"messages"),sourceMessages:Qe(d,"sourceMessages"),currentKeywords:Qe(d,"currentKeywords"),isLoadingSource:Qe(d,"isLoadingSource"),isAIThinking:Qe(d,"isAIThinking"),currentAIChatId:Qe(d,"currentAIChatId"),currentToolStatus:Qe(d,"currentToolStatus"),toolsUsedInCurrentRound:Qe(d,"toolsUsedInCurrentRound"),sessionTokenUsage:Qe(d,"sessionTokenUsage"),agentStatus:Qe(d,"agentStatus"),selectedAssistantId:Qe(d,"selectedAssistantId"),sendMessage:(g,v)=>m.sendMessage(u,g,v),editMessageAndRegenerate:(g,v,h)=>m.editMessageAndRegenerate(u,g,v,h),loadAIChat:g=>m.loadAIChat(u,g),startNewAIChat:g=>m.startNewAIChat(u,g),loadMoreSourceMessages:()=>m.loadMoreSourceMessages(),updateMaxMessages:()=>m.updateMaxMessages(),stopGeneration:()=>m.stopGeneration(u),selectAssistantForSession:g=>m.selectAssistantForSession(u,g)}}const At=new Map;function is(l,s,t){const{activeTab:c,isInitialLoad:r,currentSessionId:m,onTimeRangeChange:u}=t,d=x(null),g=x(null),v=x([]),h=k(()=>{const T=d.value;if(T)return{startTs:T.startTs,endTs:T.endTs}}),S=k(()=>{const T=d.value;return T?`${T.startTs}-${T.endTs}`:"init"}),b=k(()=>{const T=d.value;return!T||T.isFullRange?null:new Date(T.startTs*1e3).getFullYear()}),w=k(()=>{const T=l.query,I=T.timeMode;return I?{mode:I,recentDays:T.timeDays?Number(T.timeDays):void 0,year:T.timeYear?Number(T.timeYear):void 0,quarterYear:T.timeYear?Number(T.timeYear):void 0,quarter:T.timeQuarter?Number(T.timeQuarter):void 0,customStart:T.timeStart||void 0,customEnd:T.timeEnd||void 0}:m.value&&At.has(m.value)?At.get(m.value):{mode:"recent",recentDays:365}});ge([c,d],([T,I])=>{if(r.value||!I)return;const _=I.state,C={tab:T,timeMode:_.mode,timeDays:void 0,timeYear:void 0,timeQuarter:void 0,timeStart:void 0,timeEnd:void 0};_.mode==="recent"&&(C.timeDays=_.recentDays),_.mode==="year"&&(C.timeYear=_.year),_.mode==="quarter"&&(C.timeYear=_.quarterYear,C.timeQuarter=_.quarter),_.mode==="custom"&&(C.timeStart=_.customStart,C.timeEnd=_.customEnd),s.replace({query:{...l.query,...C}})}),ge(d,T=>{!T||!m.value||(na(),At.set(m.value,T.state),u?.())},{immediate:!0});function q(){d.value=null,g.value=null,v.value=[]}return{timeRangeValue:d,fullTimeRange:g,availableYears:v,timeFilter:h,timeFilterKey:S,selectedYearForOverview:b,initialTimeState:w,resetTimeRange:q}}function sa(l){const s=new Date(l*1e3),t=s.getFullYear(),c=String(s.getMonth()+1).padStart(2,"0"),r=String(s.getDate()).padStart(2,"0");return`${t}-${c}-${r}`}function Xk(l){return $e.unix(l).format("YYYY-MM-DD HH:mm:ss")}function Zk(l,s){const t=sa(l);if(s===null)return`${t} ~ 至今`;const c=sa(s);return t===c?t:`${t} ~ ${c}`}function Bt(l,s,t="YYYY/MM/DD",c=" - "){const r=$e.unix(l).format(t),m=$e.unix(s).format(t);return r===m?r:`${r}${c}${m}`}function cs(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 e1(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 ds(l){return l.content.trim()?l.content:l.contentBlocks?.filter(t=>t.type==="text"&&!!t.text).map(t=>t.text).join("")??""}function jt(l){return l.flatMap(s=>{if(s.role!=="user"&&s.role!=="assistant")return[];const t=ds(s);return t.trim()?[{role:s.role,content:t,timestamp:s.timestamp}]:[]})}function us(l){return jt(l).length>0}function ms(l,s,t,c){const r=[];r.push(`# ${l}`),r.push(""),r.push(`> ${c.createdAt}: ${$e(t).format("YYYY-MM-DD HH:mm:ss")}`),r.push(""),r.push("---"),r.push("");for(const m of s){const u=$e(m.timestamp).format("YYYY-MM-DD HH:mm:ss"),d=m.role==="user"?c.user:c.assistant;r.push(`### ${d}`),r.push(`*${u}*`),r.push(""),r.push(m.content),r.push(""),r.push("---"),r.push("")}return r.join(`
|
|
3
3
|
`)}function gs(l,s,t,c){const r=[];r.push(`${l}`),r.push(`${c.createdAt}: ${$e(t).format("YYYY-MM-DD HH:mm:ss")}`),r.push(""),r.push("=".repeat(50)),r.push("");for(const m of s){const u=$e(m.timestamp).format("YYYY-MM-DD HH:mm:ss"),d=m.role==="user"?c.user:c.assistant;r.push(`[${d}] ${u}`),r.push(""),r.push(m.content),r.push(""),r.push("-".repeat(50)),r.push("")}return r.join(`
|
|
4
|
-
`)}function ps(l){return l.replace(/[/\\?%*:|"<>]/g,"_")}async function vs(l,s,t,c,r){if(s.length===0)return{success:!1,error:"No messages to export"};let m,u;const d=$e(t).format("YYYYMMDD_HHmmss"),g=ps(l);c==="markdown"?(m=ms(l,s,t,r),u=`${g}_${d}.md`):(m=gs(l,s,t,r),u=`${g}_${d}.txt`);const v=`data:text/plain;charset=utf-8,${encodeURIComponent(m)}`,{useCacheService:h}=await Tt(async()=>{const{useCacheService:b}=await import("./index-
|
|
5
|
-
`)}function ys(l){const s=l.rows.map(t=>{const c={};return l.columns.forEach((r,m)=>{c[r]=t[m]}),c});return JSON.stringify(s,null,2)}async function fs(l,s){if(l.rows.length===0)return{success:!1,error:"No data to export"};const c=`sql_result_${$e().format("YYYYMMDD_HHmmss")}.${s}`;let r,m;s==="json"?(r=ys(l),m="application/json"):(r=hs(l),m="text/csv");const u=`data:${m};charset=utf-8,${encodeURIComponent(r)}`,{useCacheService:d}=await Tt(async()=>{const{useCacheService:v}=await import("./index-B3mDjury.js").then(h=>h.$);return{useCacheService:v}},__vite__mapDeps([0,1,2,3,4]));return await d().saveToDownloads(c,u)}function t1(l){const{route:s,router:t,currentSessionId:c,selectSession:r,defaultTab:m,validTabIds:u}=l,d=x(!0),g=x(!0),v=x(null),h=x([]),S=x([]),b=x([]),w=x([]);function q(){const $=s.query.tab;return $&&u.includes($)?$:m}const T=x(q()),{timeRangeValue:I,fullTimeRange:_,availableYears:C,timeFilter:M,selectedYearForOverview:y,initialTimeState:f}=is(s,t,{activeTab:T,isInitialLoad:g,currentSessionId:c,onTimeRangeChange:()=>P()});function D(){const $=s.params.id;$&&(r($),c.value!==$&&t.replace("/"))}async function A(){if(c.value)try{const $=await Ue().getSession(c.value);v.value=$}catch($){console.error("加载基础数据失败:",$)}}async function P(){if(c.value){d.value=!0;try{const $=M.value,L=Ue(),[W,ae,Y,pe]=await Promise.all([L.getMemberActivity(c.value,$),L.getHourlyActivity(c.value,$),L.getDailyActivity(c.value,$),L.getMessageTypeDistribution(c.value,$)]);h.value=W,S.value=ae,b.value=Y,w.value=pe}catch($){console.error("加载分析数据失败:",$)}finally{d.value=!1}}}async function z(){c.value&&(g.value=!0,await A(),g.value=!1)}return ge(()=>s.params.id,()=>{T.value=q(),D()}),ge(()=>s.query.tab,()=>{T.value=q()}),ge(c,()=>{na(),z()},{immediate:!0}),Ee(()=>{D()}),{activeTab:T,isLoading:d,isInitialLoad:g,session:v,memberActivity:h,hourlyActivity:S,dailyActivity:b,messageTypes:w,timeRangeValue:I,fullTimeRange:_,availableYears:C,timeFilter:M,selectedYearForOverview:y,initialTimeState:f,syncSession:D,loadData:z,loadAnalysisData:P}}const xs=["data-theme-card"],bs={key:0,class:"pointer-events-none absolute inset-0 overflow-hidden"},ks={key:1,class:"absolute right-3 top-3 z-50 opacity-0 transition-opacity duration-200 group-hover/card:opacity-100"},it=he({__name:"ThemeCard",props:{variant:{default:"section"},decorative:{type:Boolean,default:!1},capturable:{type:Boolean,default:!0}},setup(l){const s=l,t={section:"rounded-xl border border-gray-200 bg-card-bg shadow-sm dark:border-white/5 dark:bg-card-dark",card:"rounded-[20px] border border-gray-200/60 bg-card-bg shadow-sm transition-all hover:shadow-md dark:border-white/5 dark:bg-card-dark",elevated:"rounded-[24px] bg-card-bg shadow-xl ring-1 ring-gray-900/5 dark:bg-card-dark dark:ring-white/10"},c=k(()=>{const m=`relative isolate overflow-hidden ${t[s.variant]}`;return s.capturable?`group/card ${m}`:m}),r=k(()=>s.decorative&&s.variant==="elevated");return(m,u)=>(n(),i("div",{class:oe(c.value),"data-theme-card":l.capturable?"":void 0},[r.value?(n(),i("div",bs,[...u[0]||(u[0]=[e("div",{class:"absolute -left-[20%] -top-[20%] h-[70%] w-[70%] rounded-full bg-blue-400/10 blur-[80px] dark:bg-blue-500/20"},null,-1),e("div",{class:"absolute -right-[20%] top-[10%] h-[70%] w-[70%] rounded-full bg-pink-400/10 blur-[80px] dark:bg-pink-500/20"},null,-1)])])):R("",!0),l.capturable?(n(),i("div",ks,[p(ct,{type:"element","target-selector":"[data-theme-card]",size:"xs"})])):R("",!0),Ke(m.$slots,"default")],10,xs))}}),_s={class:"flex items-center justify-between"},ws={class:"font-semibold text-gray-900 dark:text-white whitespace-nowrap"},$s={key:0,class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},We=he({__name:"SectionCard",props:{title:{},description:{},showDivider:{type:Boolean,default:!0},scrollable:{type:Boolean,default:!1},maxHeightVh:{default:60}},setup(l){const s=l,t=k(()=>{if(s.scrollable)return{maxHeight:`${s.maxHeightVh}vh`,overflowY:"auto"}});return(c,r)=>(n(),K(it,{variant:"section"},{default:U(()=>[e("div",{class:oe(["px-5 py-3",{"border-b border-gray-200 dark:border-white/5":l.showDivider&&c.$slots.default}])},[e("div",_s,[e("div",null,[e("p",ws,o(l.title),1),l.description?(n(),i("p",$s,o(l.description),1)):R("",!0)]),Ke(c.$slots,"headerRight")])],2),l.scrollable?(n(),i("div",{key:0,style:Ge(t.value)},[Ke(c.$slots,"default")],4)):Ke(c.$slots,"default",{key:1}),Ke(c.$slots,"footer")]),_:3}))}}),Cs={class:"flex items-start justify-between"},Ss={class:"min-w-0 flex-1"},Ts={class:"text-sm font-medium text-gray-500 dark:text-gray-400"},Is={key:1,class:"text-xl"},Ms={key:0,class:"mt-4 flex items-center text-sm"},Ls={class:"text-gray-500 dark:text-gray-400"},Ze=he({__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 m=_e;return n(),K(it,{variant:"card",class:"p-5"},{default:U(()=>[e("div",Cs,[e("div",Ss,[e("p",Ts,o(l.label),1),e("p",{class:oe(["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:oe(["ml-4 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl",t[l.iconBg||"gray"]])},[l.icon.startsWith("i-")?(n(),K(m,{key:0,name:l.icon,class:"h-5 w-5"},null,8,["name"])):(n(),i("span",Is,o(l.icon),1))],2)):R("",!0)]),l.subtext||c.$slots.subtext?(n(),i("div",Ms,[Ke(c.$slots,"subtext",{},()=>[e("span",Ls,o(l.subtext),1)])])):R("",!0)]),_:3})}}}),Ds={key:0,class:"mb-2 block text-2xl"},a1=he({__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:oe(["text-center text-sm text-gray-400",s[l.padding||"md"]])},[l.icon?(n(),i("span",Ds,o(l.icon),1)):R("",!0),ee(" "+o(l.text||"暂无数据"),1)],2))}}),As={class:"flex flex-col items-center justify-center text-center"},qs={key:0,class:"mt-2 text-sm text-gray-500"},mt=he({__name:"LoadingState",props:{text:{},height:{},variant:{default:"inline"}},setup(l){const s=l,t=k(()=>{const c="flex items-center justify-center";switch(s.variant){case"page":return`${c} h-full w-full`;case"overlay":return`${c} absolute inset-0 z-10 bg-white/50 backdrop-blur-sm dark:bg-gray-950/50`;default:return`${c} ${s.height||"py-8"}`}});return(c,r)=>{const m=_e;return n(),i("div",{class:oe(t.value)},[e("div",As,[p(m,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-pink-500"}),l.text?(n(),i("p",qs,o(l.text),1)):R("",!0)])],2)}}}),Rs=["disabled"],Es={key:0,class:"flex-1 overflow-y-auto p-2"},zs={key:0,class:"flex items-center justify-center py-8"},Ps={key:1,class:"flex flex-col items-center justify-center py-12 text-center"},Bs={class:"flex h-12 w-12 items-center justify-center rounded-full bg-gray-50 dark:bg-gray-800"},js={class:"mt-3 text-xs text-gray-400"},Fs={key:2,class:"space-y-3"},Us={class:"px-2 pb-1 pt-1.5 text-[10px] font-medium tracking-wide text-gray-400 dark:text-gray-500"},Vs={class:"space-y-0.5"},Os=["onClick"],Ns=["placeholder","onBlur","onKeyup"],Hs={key:1,class:"flex items-center"},Ys={class:"line-clamp-1 min-w-0 flex-1 text-sm leading-snug"},Ws={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"},Ks={class:"w-28 p-1"},Qs=["disabled","onClick"],Gs=["onClick"],Js=["disabled","onClick"],Xs={key:1,class:"flex flex-1 flex-col items-center gap-2 overflow-y-auto py-2"},Zs=["title","disabled"],eo=["title","onClick"],to=he({__name:"ConversationList",props:{sessionId:{},activeId:{},disabled:{type:Boolean}},emits:["select","create","delete"],setup(l,{expose:s,emit:t}){const{t:c}=ke(),r=l,m=t,u=x([]),d=x(!1),g=x(null),v=x(""),h=x(!1),S=x(null);async function b(){d.value=!0;try{u.value=await Ne().getAIChats(r.sessionId)}catch(f){console.error("加载对话列表失败:",f)}finally{d.value=!1}}const w=k(()=>{if(u.value.length===0)return[];const f=$e(),D=f.subtract(7,"day").startOf("day"),A=f.subtract(30,"day").startOf("day"),P=[],z=[],$=new Map;for(const ae of u.value){const Y=$e(ae.updatedAt*1e3);if(Y.isAfter(D))P.push(ae);else if(Y.isAfter(A))z.push(ae);else{const pe=Y.format("YYYY-MM");$.has(pe)||$.set(pe,[]),$.get(pe).push(ae)}}const L=[];P.length>0&&L.push({label:c("ai.chat.conversation.group.last7Days"),conversations:P}),z.length>0&&L.push({label:c("ai.chat.conversation.group.last30Days"),conversations:z});const W=[...$.keys()].sort((ae,Y)=>Y.localeCompare(ae));for(const ae of W){const Y=$e(ae+"-01");L.push({label:Y.format(Y.year()===f.year()?"M月":"YYYY年M月"),conversations:$.get(ae)})}return L});function q(f){return f.title||c("ai.chat.conversation.newChat")}function T(f){r.disabled||(g.value=f.id,v.value=f.title||"")}async function I(f){if(!r.disabled){if(v.value.trim())try{await Ne().updateAIChatTitle(f,v.value.trim());const D=u.value.find(A=>A.id===f);D&&(D.title=v.value.trim())}catch(D){console.error("更新标题失败:",D)}g.value=null}}function _(f){S.value=null,T(f)}function C(f){S.value=null,navigator.clipboard.writeText(f)}function M(f){S.value=null,y(f)}async function y(f){if(!r.disabled)try{await Ne().deleteAIChat(f),u.value=u.value.filter(D=>D.id!==f),m("delete",f)}catch(D){console.error("删除对话失败:",D)}}return Ee(()=>{b()}),ge(()=>r.sessionId,()=>{b()}),s({refresh:b}),(f,D)=>{const A=_e,P=Re,z=ua;return n(),i("div",{class:oe(["flex flex-col border-r border-gray-200 bg-white transition-all dark:border-gray-800 dark:bg-gray-900",h.value?"w-10":"w-64"])},[e("div",{class:oe(["flex items-center border-b border-gray-200 dark:border-gray-800",h.value?"justify-center px-0 py-2":"justify-between pl-3 pr-2 py-2"])},[h.value?(n(),i("button",{key:1,class:"rounded p-1 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:D[2]||(D[2]=$=>h.value=!h.value)},[p(A,{name:"i-heroicons-chevron-right",class:"h-4 w-4"})])):(n(),i(ne,{key:0},[e("button",{class:oe(["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:D[0]||(D[0]=$=>!l.disabled&&m("create"))},[p(A,{name:"i-heroicons-plus",class:"h-3.5 w-3.5"}),e("span",null,o(a(c)("ai.chat.conversation.newConversation")),1)],10,Rs),e("button",{class:"rounded p-1 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:D[1]||(D[1]=$=>h.value=!h.value)},[p(A,{name:"i-heroicons-chevron-left",class:"h-4 w-4"})])],64))],2),h.value?(n(),i("div",Xs,[e("button",{class:oe(["rounded p-1 text-gray-400 transition-colors hover:bg-gray-100 hover:text-pink-500 dark:hover:bg-gray-800",{"cursor-not-allowed opacity-50":l.disabled}]),title:a(c)("ai.chat.conversation.newConversation"),disabled:l.disabled,onClick:D[7]||(D[7]=$=>!l.disabled&&m("create"))},[p(A,{name:"i-heroicons-plus",class:"h-4 w-4"})],10,Zs),D[8]||(D[8]=e("div",{class:"h-px w-6 bg-gray-200 dark:bg-gray-800"},null,-1)),(n(!0),i(ne,null,de(u.value,$=>(n(),i("button",{key:$.id,class:oe(["rounded p-1 transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",[l.activeId===$.id?"text-pink-500":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"]]),title:q($),onClick:L=>m("select",$.id)},[p(A,{name:"i-heroicons-chat-bubble-left",class:"h-4 w-4"})],10,eo))),128))])):(n(),i("div",Es,[d.value?(n(),i("div",zs,[p(A,{name:"i-heroicons-arrow-path",class:"h-5 w-5 animate-spin text-gray-400"})])):u.value.length===0?(n(),i("div",Ps,[e("div",Bs,[p(A,{name:"i-heroicons-chat-bubble-left",class:"h-6 w-6 text-gray-300 dark:text-gray-600"})]),e("p",js,o(a(c)("ai.chat.conversation.empty")),1),p(P,{class:"mt-2",size:"xs",variant:"link",color:"primary",disabled:l.disabled,onClick:D[3]||(D[3]=$=>!l.disabled&&m("create"))},{default:U(()=>[ee(o(a(c)("ai.chat.conversation.startNew")),1)]),_:1},8,["disabled"])])):(n(),i("div",Fs,[(n(!0),i(ne,null,de(w.value,$=>(n(),i("div",{key:$.label},[e("div",Us,o($.label),1),e("div",Vs,[(n(!0),i(ne,null,de($.conversations,L=>(n(),i("div",{key:L.id,class:oe(["group relative rounded-lg px-3 py-2 transition-all",["cursor-pointer",l.activeId===L.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:W=>m("select",L.id)},[g.value===L.id?He((n(),i("input",{key:0,"onUpdate:modelValue":D[4]||(D[4]=W=>v.value=W),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-gray-900 dark:ring-gray-700",placeholder:a(c)("ai.chat.conversation.titlePlaceholder"),autoFocus:"",onBlur:W=>I(L.id),onKeyup:Xe(W=>I(L.id),["enter"]),onClick:D[5]||(D[5]=Fe(()=>{},["stop"]))},null,40,Ns)),[[ot,v.value]]):(n(),i("div",Hs,[e("p",Ys,o(q(L)),1),e("div",{class:oe(["ml-1 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",{"opacity-100":l.activeId===L.id||S.value===L.id}]),onClick:D[6]||(D[6]=Fe(()=>{},["stop"]))},[p(z,{open:S.value===L.id,ui:{content:"z-50 p-0"},"onUpdate:open":W=>S.value=W?L.id:null},{content:U(()=>[e("div",Ks,[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:W=>_(L)},[p(A,{name:"i-heroicons-pencil",class:"h-3.5 w-3.5"}),ee(" "+o(a(c)("ai.chat.conversation.rename")),1)],8,Qs),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:W=>C(L.id)},[p(A,{name:"i-heroicons-clipboard-document",class:"h-3.5 w-3.5"}),ee(" "+o(a(c)("ai.chat.conversation.copyId")),1)],8,Gs),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:W=>M(L.id)},[p(A,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"}),ee(" "+o(a(c)("ai.chat.conversation.delete")),1)],8,Js)])]),default:U(()=>[e("button",Ws,[p(A,{name:"i-heroicons-ellipsis-horizontal",class:"h-4 w-4"})])]),_:2},1032,["open","onUpdate:open"])],2)]))],10,Os))),128))])]))),128))]))]))],2)}}}),ao={class:"writing-vertical text-xs"},so={class:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800"},oo={class:"flex items-center gap-2"},no={class:"font-medium text-gray-900 dark:text-white"},ro={key:0,class:"border-b border-gray-200 px-4 py-2 dark:border-gray-800"},lo={class:"flex flex-wrap items-center gap-2"},io={class:"text-xs text-gray-500"},co={class:"flex-1 overflow-y-auto"},uo={key:0,class:"flex items-center justify-center py-8"},mo={key:1,class:"flex flex-col items-center justify-center py-8 text-center"},go={class:"mt-2 text-sm text-gray-500"},po={class:"text-xs text-gray-400"},vo={key:2,class:"divide-y divide-gray-100 dark:divide-gray-800"},ho={class:"mb-1 flex items-center justify-between"},yo={class:"text-sm font-medium text-gray-900 dark:text-white"},fo={class:"text-xs text-gray-400"},xo=["innerHTML"],bo={key:1,class:"border-t border-gray-200 px-4 py-2 dark:border-gray-800"},ko={class:"flex items-center justify-between"},_o={class:"text-xs text-gray-500"},wo={key:2,class:"pointer-events-none absolute inset-0 overflow-hidden rounded-xl opacity-[0.03]"},$o=he({__name:"DataSourcePanel",props:{messages:{},keywords:{},isLoading:{type:Boolean},isCollapsed:{type:Boolean}},emits:["toggle","loadMore"],setup(l,{emit:s}){const{t}=ke(),c=l,r=s;function m(d){return $e(d).format("MM-DD HH:mm")}function u(d){if(!c.keywords.length)return d;const g=c.keywords.join("|"),v=new RegExp(`(${g})`,"gi");return d.replace(v,'<mark class="bg-yellow-200 dark:bg-yellow-800/50 px-0.5 rounded">$1</mark>')}return(d,g)=>{const v=_e,h=Re;return n(),i("div",{class:oe(["relative flex flex-col rounded-xl bg-white shadow-sm transition-all duration-300 dark:bg-gray-900",[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:g[0]||(g[0]=S=>r("toggle"))},[p(v,{name:"i-heroicons-chevron-left",class:"h-5 w-5"}),e("span",ao,o(a(t)("ai.chat.dataSource.title")),1)])):(n(),i(ne,{key:1},[e("div",so,[e("div",oo,[p(v,{name:"i-heroicons-document-magnifying-glass",class:"h-5 w-5 text-gray-500"}),e("span",no,o(a(t)("ai.chat.dataSource.title")),1)]),p(h,{icon:"i-heroicons-chevron-right",color:"gray",variant:"ghost",size:"xs",onClick:g[1]||(g[1]=S=>r("toggle"))})]),l.keywords.length>0?(n(),i("div",ro,[e("div",lo,[e("span",io,o(a(t)("ai.chat.dataSource.keywords")),1),(n(!0),i(ne,null,de(l.keywords,S=>(n(),i("span",{key:S,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(S),1))),128))])])):R("",!0),e("div",co,[l.isLoading?(n(),i("div",uo,[p(v,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):l.messages.length===0?(n(),i("div",mo,[p(v,{name:"i-heroicons-inbox",class:"h-10 w-10 text-gray-300 dark:text-gray-600"}),e("p",go,o(a(t)("ai.chat.dataSource.empty")),1),e("p",po,o(a(t)("ai.chat.dataSource.emptyHint")),1)])):(n(),i("div",vo,[(n(!0),i(ne,null,de(l.messages,S=>(n(),i("div",{key:S.id,class:"px-4 py-3 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[e("div",ho,[e("span",yo,o(S.senderName),1),e("span",fo,o(m(S.timestamp)),1)]),e("p",{class:"line-clamp-3 text-sm text-gray-600 dark:text-gray-400",innerHTML:u(S.content)},null,8,xo)]))),128))]))]),l.messages.length>0?(n(),i("div",bo,[e("div",ko,[e("span",_o,o(a(t)("ai.chat.dataSource.totalRecords",{count:l.messages.length})),1),p(h,{size:"xs",variant:"ghost",onClick:g[2]||(g[2]=S=>r("loadMore"))},{default:U(()=>[ee(o(a(t)("ai.chat.dataSource.loadMore")),1)]),_:1})])])):R("",!0)],64)),l.isCollapsed?R("",!0):(n(),i("div",wo,[...g[3]||(g[3]=[e("div",{class:"data-flow-bg absolute inset-0"},null,-1)])]))],2)}}}),Co=st($o,[["__scopeId","data-v-19a25590"]]),So={class:"flex max-h-[80vh] flex-col overflow-hidden"},To={class:"shrink-0 border-b border-gray-200 px-6 py-4 dark:border-gray-800"},Io={class:"flex items-center justify-between"},Mo={class:"flex items-center gap-3"},Lo={class:"flex h-8 w-8 items-center justify-center rounded-lg bg-red-100 dark:bg-red-900/40"},Do={class:"text-lg font-semibold text-gray-900 dark:text-white"},Ao={class:"flex-1 overflow-y-auto px-6 py-4"},qo={class:"flex flex-col gap-4"},Ro={class:"text-sm font-semibold text-gray-700 dark:text-gray-300"},Eo={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"},zo={class:"m-0 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-red-600 dark:text-red-400"},Po={key:1,class:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-gray-900"},Bo={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"},jo={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-gray-900 dark:text-gray-300"},Fo={key:0,class:"py-8 text-center text-sm text-gray-400 dark:text-gray-500"},Uo={class:"shrink-0 border-t border-gray-200 px-6 py-3 dark:border-gray-800"},Vo={class:"flex justify-end"},Oo=he({__name:"ErrorDetailModal",props:Pt({error:{}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:["update:open"],setup(l){const{t:s}=ke(),t=Je(),c=zt(l,"open"),r=l,m=k(()=>{const g=r.error,v=[];return g.url&&v.push({label:s("ai.chat.error.requestUrl"),value:g.url}),g.statusCode!=null&&v.push({label:s("ai.chat.error.statusCode"),value:String(g.statusCode)}),g.responseBody&&v.push({label:s("ai.chat.error.responseBody"),value:u(g.responseBody),isCode:!0}),g.responseHeaders&&v.push({label:s("ai.chat.error.responseHeaders"),value:JSON.stringify(g.responseHeaders,null,2),isCode:!0}),g.name&&v.push({label:s("ai.chat.error.name"),value:g.name}),g.message&&v.push({label:s("ai.chat.error.message"),value:g.message}),g.stack&&v.push({label:s("ai.chat.error.stack"),value:g.stack,isStack:!0}),g.cause&&v.push({label:s("ai.chat.error.cause"),value:u(g.cause),isCode:!0}),g.provider&&v.push({label:s("ai.chat.error.provider"),value:g.provider}),g.requestBody&&v.push({label:s("ai.chat.error.requestBody"),value:u(g.requestBody),isCode:!0}),v});function u(g){try{return JSON.stringify(JSON.parse(g),null,2)}catch{return g}}function d(){const g=m.value.map(v=>`${v.label}: ${v.value}`).join(`
|
|
4
|
+
`)}function ps(l){return l.replace(/[/\\?%*:|"<>]/g,"_")}async function vs(l,s,t,c,r){if(s.length===0)return{success:!1,error:"No messages to export"};let m,u;const d=$e(t).format("YYYYMMDD_HHmmss"),g=ps(l);c==="markdown"?(m=ms(l,s,t,r),u=`${g}_${d}.md`):(m=gs(l,s,t,r),u=`${g}_${d}.txt`);const v=`data:text/plain;charset=utf-8,${encodeURIComponent(m)}`,{useCacheService:h}=await Tt(async()=>{const{useCacheService:b}=await import("./index-D5UgZUpS.js").then(w=>w.$);return{useCacheService:b}},__vite__mapDeps([0,1,2,3,4]));return await h().saveToDownloads(u,v)}function hs(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 ys(l){const s=l.rows.map(t=>{const c={};return l.columns.forEach((r,m)=>{c[r]=t[m]}),c});return JSON.stringify(s,null,2)}async function fs(l,s){if(l.rows.length===0)return{success:!1,error:"No data to export"};const c=`sql_result_${$e().format("YYYYMMDD_HHmmss")}.${s}`;let r,m;s==="json"?(r=ys(l),m="application/json"):(r=hs(l),m="text/csv");const u=`data:${m};charset=utf-8,${encodeURIComponent(r)}`,{useCacheService:d}=await Tt(async()=>{const{useCacheService:v}=await import("./index-D5UgZUpS.js").then(h=>h.$);return{useCacheService:v}},__vite__mapDeps([0,1,2,3,4]));return await d().saveToDownloads(c,u)}function t1(l){const{route:s,router:t,currentSessionId:c,selectSession:r,defaultTab:m,validTabIds:u}=l,d=x(!0),g=x(!0),v=x(null),h=x([]),S=x([]),b=x([]),w=x([]);function q(){const $=s.query.tab;return $&&u.includes($)?$:m}const T=x(q()),{timeRangeValue:I,fullTimeRange:_,availableYears:C,timeFilter:M,selectedYearForOverview:y,initialTimeState:f}=is(s,t,{activeTab:T,isInitialLoad:g,currentSessionId:c,onTimeRangeChange:()=>P()});function D(){const $=s.params.id;$&&(r($),c.value!==$&&t.replace("/"))}async function A(){if(c.value)try{const $=await Ue().getSession(c.value);v.value=$}catch($){console.error("加载基础数据失败:",$)}}async function P(){if(c.value){d.value=!0;try{const $=M.value,L=Ue(),[W,ae,Y,pe]=await Promise.all([L.getMemberActivity(c.value,$),L.getHourlyActivity(c.value,$),L.getDailyActivity(c.value,$),L.getMessageTypeDistribution(c.value,$)]);h.value=W,S.value=ae,b.value=Y,w.value=pe}catch($){console.error("加载分析数据失败:",$)}finally{d.value=!1}}}async function z(){c.value&&(g.value=!0,await A(),g.value=!1)}return ge(()=>s.params.id,()=>{T.value=q(),D()}),ge(()=>s.query.tab,()=>{T.value=q()}),ge(c,()=>{na(),z()},{immediate:!0}),Ee(()=>{D()}),{activeTab:T,isLoading:d,isInitialLoad:g,session:v,memberActivity:h,hourlyActivity:S,dailyActivity:b,messageTypes:w,timeRangeValue:I,fullTimeRange:_,availableYears:C,timeFilter:M,selectedYearForOverview:y,initialTimeState:f,syncSession:D,loadData:z,loadAnalysisData:P}}const xs=["data-theme-card"],bs={key:0,class:"pointer-events-none absolute inset-0 overflow-hidden"},ks={key:1,class:"absolute right-3 top-3 z-50 opacity-0 transition-opacity duration-200 group-hover/card:opacity-100"},it=he({__name:"ThemeCard",props:{variant:{default:"section"},decorative:{type:Boolean,default:!1},capturable:{type:Boolean,default:!0}},setup(l){const s=l,t={section:"rounded-xl border border-gray-200 bg-card-bg shadow-sm dark:border-white/5 dark:bg-card-dark",card:"rounded-[20px] border border-gray-200/60 bg-card-bg shadow-sm transition-all hover:shadow-md dark:border-white/5 dark:bg-card-dark",elevated:"rounded-[24px] bg-card-bg shadow-xl ring-1 ring-gray-900/5 dark:bg-card-dark dark:ring-white/10"},c=k(()=>{const m=`relative isolate overflow-hidden ${t[s.variant]}`;return s.capturable?`group/card ${m}`:m}),r=k(()=>s.decorative&&s.variant==="elevated");return(m,u)=>(n(),i("div",{class:oe(c.value),"data-theme-card":l.capturable?"":void 0},[r.value?(n(),i("div",bs,[...u[0]||(u[0]=[e("div",{class:"absolute -left-[20%] -top-[20%] h-[70%] w-[70%] rounded-full bg-blue-400/10 blur-[80px] dark:bg-blue-500/20"},null,-1),e("div",{class:"absolute -right-[20%] top-[10%] h-[70%] w-[70%] rounded-full bg-pink-400/10 blur-[80px] dark:bg-pink-500/20"},null,-1)])])):R("",!0),l.capturable?(n(),i("div",ks,[p(ct,{type:"element","target-selector":"[data-theme-card]",size:"xs"})])):R("",!0),Ke(m.$slots,"default")],10,xs))}}),_s={class:"flex items-center justify-between"},ws={class:"font-semibold text-gray-900 dark:text-white whitespace-nowrap"},$s={key:0,class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},We=he({__name:"SectionCard",props:{title:{},description:{},showDivider:{type:Boolean,default:!0},scrollable:{type:Boolean,default:!1},maxHeightVh:{default:60}},setup(l){const s=l,t=k(()=>{if(s.scrollable)return{maxHeight:`${s.maxHeightVh}vh`,overflowY:"auto"}});return(c,r)=>(n(),K(it,{variant:"section"},{default:U(()=>[e("div",{class:oe(["px-5 py-3",{"border-b border-gray-200 dark:border-white/5":l.showDivider&&c.$slots.default}])},[e("div",_s,[e("div",null,[e("p",ws,o(l.title),1),l.description?(n(),i("p",$s,o(l.description),1)):R("",!0)]),Ke(c.$slots,"headerRight")])],2),l.scrollable?(n(),i("div",{key:0,style:Ge(t.value)},[Ke(c.$slots,"default")],4)):Ke(c.$slots,"default",{key:1}),Ke(c.$slots,"footer")]),_:3}))}}),Cs={class:"flex items-start justify-between"},Ss={class:"min-w-0 flex-1"},Ts={class:"text-sm font-medium text-gray-500 dark:text-gray-400"},Is={key:1,class:"text-xl"},Ms={key:0,class:"mt-4 flex items-center text-sm"},Ls={class:"text-gray-500 dark:text-gray-400"},Ze=he({__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 m=_e;return n(),K(it,{variant:"card",class:"p-5"},{default:U(()=>[e("div",Cs,[e("div",Ss,[e("p",Ts,o(l.label),1),e("p",{class:oe(["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:oe(["ml-4 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl",t[l.iconBg||"gray"]])},[l.icon.startsWith("i-")?(n(),K(m,{key:0,name:l.icon,class:"h-5 w-5"},null,8,["name"])):(n(),i("span",Is,o(l.icon),1))],2)):R("",!0)]),l.subtext||c.$slots.subtext?(n(),i("div",Ms,[Ke(c.$slots,"subtext",{},()=>[e("span",Ls,o(l.subtext),1)])])):R("",!0)]),_:3})}}}),Ds={key:0,class:"mb-2 block text-2xl"},a1=he({__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:oe(["text-center text-sm text-gray-400",s[l.padding||"md"]])},[l.icon?(n(),i("span",Ds,o(l.icon),1)):R("",!0),ee(" "+o(l.text||"暂无数据"),1)],2))}}),As={class:"flex flex-col items-center justify-center text-center"},qs={key:0,class:"mt-2 text-sm text-gray-500"},mt=he({__name:"LoadingState",props:{text:{},height:{},variant:{default:"inline"}},setup(l){const s=l,t=k(()=>{const c="flex items-center justify-center";switch(s.variant){case"page":return`${c} h-full w-full`;case"overlay":return`${c} absolute inset-0 z-10 bg-white/50 backdrop-blur-sm dark:bg-gray-950/50`;default:return`${c} ${s.height||"py-8"}`}});return(c,r)=>{const m=_e;return n(),i("div",{class:oe(t.value)},[e("div",As,[p(m,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-pink-500"}),l.text?(n(),i("p",qs,o(l.text),1)):R("",!0)])],2)}}}),Rs=["disabled"],Es={key:0,class:"flex-1 overflow-y-auto p-2"},zs={key:0,class:"flex items-center justify-center py-8"},Ps={key:1,class:"flex flex-col items-center justify-center py-12 text-center"},Bs={class:"flex h-12 w-12 items-center justify-center rounded-full bg-gray-50 dark:bg-gray-800"},js={class:"mt-3 text-xs text-gray-400"},Fs={key:2,class:"space-y-3"},Us={class:"px-2 pb-1 pt-1.5 text-[10px] font-medium tracking-wide text-gray-400 dark:text-gray-500"},Vs={class:"space-y-0.5"},Os=["onClick"],Ns=["placeholder","onBlur","onKeyup"],Hs={key:1,class:"flex items-center"},Ys={class:"line-clamp-1 min-w-0 flex-1 text-sm leading-snug"},Ws={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"},Ks={class:"w-28 p-1"},Qs=["disabled","onClick"],Gs=["onClick"],Js=["disabled","onClick"],Xs={key:1,class:"flex flex-1 flex-col items-center gap-2 overflow-y-auto py-2"},Zs=["title","disabled"],eo=["title","onClick"],to=he({__name:"ConversationList",props:{sessionId:{},activeId:{},disabled:{type:Boolean}},emits:["select","create","delete"],setup(l,{expose:s,emit:t}){const{t:c}=ke(),r=l,m=t,u=x([]),d=x(!1),g=x(null),v=x(""),h=x(!1),S=x(null);async function b(){d.value=!0;try{u.value=await Ne().getAIChats(r.sessionId)}catch(f){console.error("加载对话列表失败:",f)}finally{d.value=!1}}const w=k(()=>{if(u.value.length===0)return[];const f=$e(),D=f.subtract(7,"day").startOf("day"),A=f.subtract(30,"day").startOf("day"),P=[],z=[],$=new Map;for(const ae of u.value){const Y=$e(ae.updatedAt*1e3);if(Y.isAfter(D))P.push(ae);else if(Y.isAfter(A))z.push(ae);else{const pe=Y.format("YYYY-MM");$.has(pe)||$.set(pe,[]),$.get(pe).push(ae)}}const L=[];P.length>0&&L.push({label:c("ai.chat.conversation.group.last7Days"),conversations:P}),z.length>0&&L.push({label:c("ai.chat.conversation.group.last30Days"),conversations:z});const W=[...$.keys()].sort((ae,Y)=>Y.localeCompare(ae));for(const ae of W){const Y=$e(ae+"-01");L.push({label:Y.format(Y.year()===f.year()?"M月":"YYYY年M月"),conversations:$.get(ae)})}return L});function q(f){return f.title||c("ai.chat.conversation.newChat")}function T(f){r.disabled||(g.value=f.id,v.value=f.title||"")}async function I(f){if(!r.disabled){if(v.value.trim())try{await Ne().updateAIChatTitle(f,v.value.trim());const D=u.value.find(A=>A.id===f);D&&(D.title=v.value.trim())}catch(D){console.error("更新标题失败:",D)}g.value=null}}function _(f){S.value=null,T(f)}function C(f){S.value=null,navigator.clipboard.writeText(f)}function M(f){S.value=null,y(f)}async function y(f){if(!r.disabled)try{await Ne().deleteAIChat(f),u.value=u.value.filter(D=>D.id!==f),m("delete",f)}catch(D){console.error("删除对话失败:",D)}}return Ee(()=>{b()}),ge(()=>r.sessionId,()=>{b()}),s({refresh:b}),(f,D)=>{const A=_e,P=Re,z=ua;return n(),i("div",{class:oe(["flex flex-col border-r border-gray-200 bg-white transition-all dark:border-gray-800 dark:bg-gray-900",h.value?"w-10":"w-64"])},[e("div",{class:oe(["flex items-center border-b border-gray-200 dark:border-gray-800",h.value?"justify-center px-0 py-2":"justify-between pl-3 pr-2 py-2"])},[h.value?(n(),i("button",{key:1,class:"rounded p-1 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:D[2]||(D[2]=$=>h.value=!h.value)},[p(A,{name:"i-heroicons-chevron-right",class:"h-4 w-4"})])):(n(),i(ne,{key:0},[e("button",{class:oe(["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:D[0]||(D[0]=$=>!l.disabled&&m("create"))},[p(A,{name:"i-heroicons-plus",class:"h-3.5 w-3.5"}),e("span",null,o(a(c)("ai.chat.conversation.newConversation")),1)],10,Rs),e("button",{class:"rounded p-1 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:D[1]||(D[1]=$=>h.value=!h.value)},[p(A,{name:"i-heroicons-chevron-left",class:"h-4 w-4"})])],64))],2),h.value?(n(),i("div",Xs,[e("button",{class:oe(["rounded p-1 text-gray-400 transition-colors hover:bg-gray-100 hover:text-pink-500 dark:hover:bg-gray-800",{"cursor-not-allowed opacity-50":l.disabled}]),title:a(c)("ai.chat.conversation.newConversation"),disabled:l.disabled,onClick:D[7]||(D[7]=$=>!l.disabled&&m("create"))},[p(A,{name:"i-heroicons-plus",class:"h-4 w-4"})],10,Zs),D[8]||(D[8]=e("div",{class:"h-px w-6 bg-gray-200 dark:bg-gray-800"},null,-1)),(n(!0),i(ne,null,de(u.value,$=>(n(),i("button",{key:$.id,class:oe(["rounded p-1 transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",[l.activeId===$.id?"text-pink-500":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"]]),title:q($),onClick:L=>m("select",$.id)},[p(A,{name:"i-heroicons-chat-bubble-left",class:"h-4 w-4"})],10,eo))),128))])):(n(),i("div",Es,[d.value?(n(),i("div",zs,[p(A,{name:"i-heroicons-arrow-path",class:"h-5 w-5 animate-spin text-gray-400"})])):u.value.length===0?(n(),i("div",Ps,[e("div",Bs,[p(A,{name:"i-heroicons-chat-bubble-left",class:"h-6 w-6 text-gray-300 dark:text-gray-600"})]),e("p",js,o(a(c)("ai.chat.conversation.empty")),1),p(P,{class:"mt-2",size:"xs",variant:"link",color:"primary",disabled:l.disabled,onClick:D[3]||(D[3]=$=>!l.disabled&&m("create"))},{default:U(()=>[ee(o(a(c)("ai.chat.conversation.startNew")),1)]),_:1},8,["disabled"])])):(n(),i("div",Fs,[(n(!0),i(ne,null,de(w.value,$=>(n(),i("div",{key:$.label},[e("div",Us,o($.label),1),e("div",Vs,[(n(!0),i(ne,null,de($.conversations,L=>(n(),i("div",{key:L.id,class:oe(["group relative rounded-lg px-3 py-2 transition-all",["cursor-pointer",l.activeId===L.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:W=>m("select",L.id)},[g.value===L.id?He((n(),i("input",{key:0,"onUpdate:modelValue":D[4]||(D[4]=W=>v.value=W),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-gray-900 dark:ring-gray-700",placeholder:a(c)("ai.chat.conversation.titlePlaceholder"),autoFocus:"",onBlur:W=>I(L.id),onKeyup:Xe(W=>I(L.id),["enter"]),onClick:D[5]||(D[5]=Fe(()=>{},["stop"]))},null,40,Ns)),[[ot,v.value]]):(n(),i("div",Hs,[e("p",Ys,o(q(L)),1),e("div",{class:oe(["ml-1 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",{"opacity-100":l.activeId===L.id||S.value===L.id}]),onClick:D[6]||(D[6]=Fe(()=>{},["stop"]))},[p(z,{open:S.value===L.id,ui:{content:"z-50 p-0"},"onUpdate:open":W=>S.value=W?L.id:null},{content:U(()=>[e("div",Ks,[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:W=>_(L)},[p(A,{name:"i-heroicons-pencil",class:"h-3.5 w-3.5"}),ee(" "+o(a(c)("ai.chat.conversation.rename")),1)],8,Qs),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:W=>C(L.id)},[p(A,{name:"i-heroicons-clipboard-document",class:"h-3.5 w-3.5"}),ee(" "+o(a(c)("ai.chat.conversation.copyId")),1)],8,Gs),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:W=>M(L.id)},[p(A,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"}),ee(" "+o(a(c)("ai.chat.conversation.delete")),1)],8,Js)])]),default:U(()=>[e("button",Ws,[p(A,{name:"i-heroicons-ellipsis-horizontal",class:"h-4 w-4"})])]),_:2},1032,["open","onUpdate:open"])],2)]))],10,Os))),128))])]))),128))]))]))],2)}}}),ao={class:"writing-vertical text-xs"},so={class:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800"},oo={class:"flex items-center gap-2"},no={class:"font-medium text-gray-900 dark:text-white"},ro={key:0,class:"border-b border-gray-200 px-4 py-2 dark:border-gray-800"},lo={class:"flex flex-wrap items-center gap-2"},io={class:"text-xs text-gray-500"},co={class:"flex-1 overflow-y-auto"},uo={key:0,class:"flex items-center justify-center py-8"},mo={key:1,class:"flex flex-col items-center justify-center py-8 text-center"},go={class:"mt-2 text-sm text-gray-500"},po={class:"text-xs text-gray-400"},vo={key:2,class:"divide-y divide-gray-100 dark:divide-gray-800"},ho={class:"mb-1 flex items-center justify-between"},yo={class:"text-sm font-medium text-gray-900 dark:text-white"},fo={class:"text-xs text-gray-400"},xo=["innerHTML"],bo={key:1,class:"border-t border-gray-200 px-4 py-2 dark:border-gray-800"},ko={class:"flex items-center justify-between"},_o={class:"text-xs text-gray-500"},wo={key:2,class:"pointer-events-none absolute inset-0 overflow-hidden rounded-xl opacity-[0.03]"},$o=he({__name:"DataSourcePanel",props:{messages:{},keywords:{},isLoading:{type:Boolean},isCollapsed:{type:Boolean}},emits:["toggle","loadMore"],setup(l,{emit:s}){const{t}=ke(),c=l,r=s;function m(d){return $e(d).format("MM-DD HH:mm")}function u(d){if(!c.keywords.length)return d;const g=c.keywords.join("|"),v=new RegExp(`(${g})`,"gi");return d.replace(v,'<mark class="bg-yellow-200 dark:bg-yellow-800/50 px-0.5 rounded">$1</mark>')}return(d,g)=>{const v=_e,h=Re;return n(),i("div",{class:oe(["relative flex flex-col rounded-xl bg-white shadow-sm transition-all duration-300 dark:bg-gray-900",[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:g[0]||(g[0]=S=>r("toggle"))},[p(v,{name:"i-heroicons-chevron-left",class:"h-5 w-5"}),e("span",ao,o(a(t)("ai.chat.dataSource.title")),1)])):(n(),i(ne,{key:1},[e("div",so,[e("div",oo,[p(v,{name:"i-heroicons-document-magnifying-glass",class:"h-5 w-5 text-gray-500"}),e("span",no,o(a(t)("ai.chat.dataSource.title")),1)]),p(h,{icon:"i-heroicons-chevron-right",color:"gray",variant:"ghost",size:"xs",onClick:g[1]||(g[1]=S=>r("toggle"))})]),l.keywords.length>0?(n(),i("div",ro,[e("div",lo,[e("span",io,o(a(t)("ai.chat.dataSource.keywords")),1),(n(!0),i(ne,null,de(l.keywords,S=>(n(),i("span",{key:S,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(S),1))),128))])])):R("",!0),e("div",co,[l.isLoading?(n(),i("div",uo,[p(v,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):l.messages.length===0?(n(),i("div",mo,[p(v,{name:"i-heroicons-inbox",class:"h-10 w-10 text-gray-300 dark:text-gray-600"}),e("p",go,o(a(t)("ai.chat.dataSource.empty")),1),e("p",po,o(a(t)("ai.chat.dataSource.emptyHint")),1)])):(n(),i("div",vo,[(n(!0),i(ne,null,de(l.messages,S=>(n(),i("div",{key:S.id,class:"px-4 py-3 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[e("div",ho,[e("span",yo,o(S.senderName),1),e("span",fo,o(m(S.timestamp)),1)]),e("p",{class:"line-clamp-3 text-sm text-gray-600 dark:text-gray-400",innerHTML:u(S.content)},null,8,xo)]))),128))]))]),l.messages.length>0?(n(),i("div",bo,[e("div",ko,[e("span",_o,o(a(t)("ai.chat.dataSource.totalRecords",{count:l.messages.length})),1),p(h,{size:"xs",variant:"ghost",onClick:g[2]||(g[2]=S=>r("loadMore"))},{default:U(()=>[ee(o(a(t)("ai.chat.dataSource.loadMore")),1)]),_:1})])])):R("",!0)],64)),l.isCollapsed?R("",!0):(n(),i("div",wo,[...g[3]||(g[3]=[e("div",{class:"data-flow-bg absolute inset-0"},null,-1)])]))],2)}}}),Co=st($o,[["__scopeId","data-v-19a25590"]]),So={class:"flex max-h-[80vh] flex-col overflow-hidden"},To={class:"shrink-0 border-b border-gray-200 px-6 py-4 dark:border-gray-800"},Io={class:"flex items-center justify-between"},Mo={class:"flex items-center gap-3"},Lo={class:"flex h-8 w-8 items-center justify-center rounded-lg bg-red-100 dark:bg-red-900/40"},Do={class:"text-lg font-semibold text-gray-900 dark:text-white"},Ao={class:"flex-1 overflow-y-auto px-6 py-4"},qo={class:"flex flex-col gap-4"},Ro={class:"text-sm font-semibold text-gray-700 dark:text-gray-300"},Eo={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"},zo={class:"m-0 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-red-600 dark:text-red-400"},Po={key:1,class:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-gray-900"},Bo={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"},jo={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-gray-900 dark:text-gray-300"},Fo={key:0,class:"py-8 text-center text-sm text-gray-400 dark:text-gray-500"},Uo={class:"shrink-0 border-t border-gray-200 px-6 py-3 dark:border-gray-800"},Vo={class:"flex justify-end"},Oo=he({__name:"ErrorDetailModal",props:Pt({error:{}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:["update:open"],setup(l){const{t:s}=ke(),t=Je(),c=zt(l,"open"),r=l,m=k(()=>{const g=r.error,v=[];return g.url&&v.push({label:s("ai.chat.error.requestUrl"),value:g.url}),g.statusCode!=null&&v.push({label:s("ai.chat.error.statusCode"),value:String(g.statusCode)}),g.responseBody&&v.push({label:s("ai.chat.error.responseBody"),value:u(g.responseBody),isCode:!0}),g.responseHeaders&&v.push({label:s("ai.chat.error.responseHeaders"),value:JSON.stringify(g.responseHeaders,null,2),isCode:!0}),g.name&&v.push({label:s("ai.chat.error.name"),value:g.name}),g.message&&v.push({label:s("ai.chat.error.message"),value:g.message}),g.stack&&v.push({label:s("ai.chat.error.stack"),value:g.stack,isStack:!0}),g.cause&&v.push({label:s("ai.chat.error.cause"),value:u(g.cause),isCode:!0}),g.provider&&v.push({label:s("ai.chat.error.provider"),value:g.provider}),g.requestBody&&v.push({label:s("ai.chat.error.requestBody"),value:u(g.requestBody),isCode:!0}),v});function u(g){try{return JSON.stringify(JSON.parse(g),null,2)}catch{return g}}function d(){const g=m.value.map(v=>`${v.label}: ${v.value}`).join(`
|
|
6
6
|
|
|
7
7
|
`);navigator.clipboard.writeText(g).then(()=>{t.success(s("ai.chat.error.copied"))})}return(g,v)=>{const h=_e,S=Re,b=Oe;return n(),K(b,{open:c.value,"onUpdate:open":v[1]||(v[1]=w=>c.value=w),ui:{content:"sm:max-w-[700px] z-[100]",overlay:"backdrop-blur-sm z-[99]"}},{content:U(()=>[e("div",So,[e("div",To,[e("div",Io,[e("div",Mo,[e("div",Lo,[p(h,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4 text-red-600 dark:text-red-400"})]),e("h2",Do,o(a(s)("ai.chat.error.detail")),1)]),p(S,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:v[0]||(v[0]=w=>c.value=!1)})])]),e("div",Ao,[e("div",qo,[(n(!0),i(ne,null,de(m.value,(w,q)=>(n(),i("div",{key:q,class:"flex flex-col gap-1.5"},[e("div",Ro,o(w.label),1),w.isStack?(n(),i("div",Eo,[e("pre",zo,o(w.value),1)])):w.isCode?(n(),i("div",Po,[e("pre",Bo,o(w.value),1)])):(n(),i("div",jo,o(w.value),1))]))),128)),m.value.length===0?(n(),i("div",Fo,o(a(s)("ai.chat.error.unknown")),1)):R("",!0)])]),e("div",Uo,[e("div",Vo,[p(S,{icon:"i-heroicons-document-duplicate",variant:"soft",color:"neutral",size:"sm",onClick:d},{default:U(()=>[ee(o(a(s)("ai.chat.error.copyAll")),1)]),_:1})])])])]),_:1},8,["open"])}}}),No={class:"mb-1.5 flex items-center gap-2"},Ho={class:"flex shrink-0 items-center justify-center text-red-500 dark:text-red-400"},Yo={class:"pr-5 text-[13px] font-semibold leading-[1.4] text-red-600 dark:text-red-400"},Wo={class:"ml-6 line-clamp-3 break-words text-xs leading-normal text-gray-600 dark:text-gray-400"},Ko={class:"mt-2.5 ml-6 flex items-center"},Qo={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"},Go=he({__name:"ErrorBlock",props:{error:{}},setup(l){const{t:s}=ke(),t=x(!1);function c(r){return r.friendlyMessage||r.message||s("ai.chat.error.unknown")}return(r,m)=>{const u=_e;return n(),i(ne,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:m[0]||(m[0]=d=>t.value=!0)},[e("div",No,[e("div",Ho,[p(u,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4"})]),e("div",Yo,o(a(s)("ai.chat.error.title")),1)]),e("div",Wo,o(c(l.error)),1),e("div",Ko,[e("div",Qo,[ee(o(a(s)("ai.chat.error.viewDetail"))+" ",1),p(u,{name:"i-heroicons-chevron-right",class:"h-3.5 w-3.5"})])])]),p(Oo,{open:t.value,"onUpdate:open":m[1]||(m[1]=d=>t.value=d),error:l.error},null,8,["open","error"])],64)}}}),bt=he({__name:"EChart",props:{option:{},height:{default:300},loading:{type:Boolean,default:!1},theme:{default:"auto"}},setup(l,{expose:s}){yt([ft,pa,va,Za,Gt,es,Mt,ts,ha,Jt,as]);const t=l,c=x();let r=null,m=null;const u=k(()=>typeof t.height=="number"?`${t.height}px`:t.height),d=k(()=>t.theme==="auto"?document.documentElement.classList.contains("dark"):t.theme==="dark");function g(){c.value&&(r&&r.dispose(),r=xt(c.value,d.value?"dark":void 0),r.setOption({backgroundColor:"transparent",...t.option}))}function v(){if(!r){g();return}r.setOption({backgroundColor:"transparent",...t.option},{notMerge:!0})}function h(){r?.resize()}ge(()=>t.option,v,{deep:!0}),ge(()=>t.height,()=>{setTimeout(()=>{r?.resize()},0)}),ge(d,()=>{g()}),ge(()=>t.loading,b=>{b?r?.showLoading("default",{text:"",spinnerRadius:12,lineWidth:2}):r?.hideLoading()});let S=null;return Ee(()=>{Ve(()=>{g()}),window.addEventListener("resize",h),c.value&&(m=new ResizeObserver(()=>h()),m.observe(c.value)),S=new MutationObserver(()=>{t.theme==="auto"&&g()}),S.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})}),lt(()=>{window.removeEventListener("resize",h),m?.disconnect(),S?.disconnect(),r?.dispose(),r=null}),s({getInstance:()=>r,resize:h}),(b,w)=>(n(),i("div",{ref_key:"chartRef",ref:c,style:Ge({height:u.value,width:"100%"})},null,4))}}),tt=he({__name:"EChartBar",props:{data:{},height:{default:200},mode:{default:"expanded"},horizontal:{type:Boolean,default:!1},gradient:{type:Boolean,default:!0},borderRadius:{default:4}},setup(l){const s=l,t={type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"#ee4567"},{offset:1,color:"#f7758c"}]},c=k(()=>{const r=s.horizontal,m=s.mode==="compact",u=s.data.labels.length;return{tooltip:{trigger:"axis",confine:!0,extraCssText:"max-width: min(360px, 70vw); white-space: normal; word-break: break-word;",axisPointer:{type:"shadow"},backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:r?m?72:96:36,right:16,top:20,bottom:r?20:u>8?48:30,outerBoundsMode:"same"},xAxis:r?{type:"value",axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{type:"dashed",color:"#e5e7eb"}}}:{type:"category",data:s.data.labels,axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:11,color:"#6b7280",interval:"auto",rotate:!r&&u>8?28:0,hideOverlap:!0}},yAxis:r?{type:"category",data:s.data.labels,axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:11,color:"#6b7280",overflow:"truncate",width:m?70:110}}:{type:"value",axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{type:"dashed",color:"#e5e7eb"}}},series:[{type:"bar",data:s.data.values,itemStyle:{color:s.gradient?t:"#ee4567",borderRadius:s.borderRadius},barMaxWidth:40,emphasis:{itemStyle:{color:s.gradient?{...t,colorStops:[{offset:0,color:"#de335e"},{offset:1,color:"#ee4567"}]}:"#de335e"}}}]}});return(r,m)=>(n(),K(bt,{option:c.value,height:l.height},null,8,["option","height"]))}}),Ft=he({__name:"EChartHeatmap",props:{data:{},height:{default:280},mode:{default:"expanded"},minColor:{default:"#fee5e8"},maxColor:{default:"#ee4567"}},setup(l){const s=l,t=k(()=>{let r=0;for(const[,,m]of s.data.data)m>r&&(r=m);return r||1}),c=k(()=>{const r=s.mode==="compact",m=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 g=s.data.xLabels[d.data[0]],v=s.data.yLabels[d.data[1]],h=d.data[2];return`${v} ${g}<br/>消息数: <strong>${h}</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&&m>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,m)=>(n(),K(bt,{option:c.value,height:l.height},null,8,["option","height"]))}}),Ut=he({__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=k(()=>{const c=!!s.data.series?.length,r=s.mode==="compact",m=s.data.series?.length??0,u=s.data.labels.length,d=m>(r?3:8),g=!r&&u>30,v=c?s.data.series.map(h=>({name:h.name,type:"line",data:h.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:g?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:g?[{type:"inside",throttle:50},{type:"slider",height:18,bottom:18,showDetail:!1}]:void 0,series:v}});return(c,r)=>(n(),K(bt,{option:t.value,height:l.height},null,8,["option","height"]))}}),Vt=he({__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=k(()=>{const r=s.data.labels.map((b,w)=>({name:b,value:s.data.values[w]})),m=s.data.labels.length,u=s.mode==="compact",d=m>(u?8:14),g=m>(u?6:12),v=u?{type:g?"scroll":"plain",orient:"horizontal",left:8,right:8,bottom:0,height:28,textStyle:{fontSize:11,overflow:"truncate",width:72}}:{type:g?"scroll":"plain",orient:"vertical",right:10,top:24,bottom:24,textStyle:{fontSize:12,overflow:"truncate",width:120}},h=!u&&!d,S=s.showLegend&&!h;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:S?v:void 0,series:[{type:"pie",radius:s.doughnut?[s.innerRadius,u?"58%":"68%"]:u?"58%":"68%",center:S?u?["50%","42%"]:["38%","50%"]:["50%",u?"46%":"50%"],avoidLabelOverlap:!0,itemStyle:{borderRadius:4,borderColor:"#fff",borderWidth:2},label:{show:h,formatter:"{b}",overflow:"truncate",width:110,alignTo:"edge",edgeDistance:12},emphasis:{label:{show:h,fontSize:14,fontWeight:"bold",overflow:"truncate",width:140},itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}},data:r}]}});return(r,m)=>(n(),K(bt,{option:c.value,height:l.height},null,8,["option","height"]))}}),Jo={class:"my-2 w-full overflow-hidden rounded-lg border border-gray-200 bg-white/80 shadow-sm dark:border-gray-700/70 dark:bg-gray-900/70"},Xo={class:"border-b border-gray-100 px-3 py-2 dark:border-gray-800"},Zo={class:"flex min-w-0 items-start justify-between gap-3"},en={class:"min-w-0"},tn={class:"truncate text-sm font-semibold text-gray-900 dark:text-gray-100"},an={key:0,class:"mt-0.5 line-clamp-2 text-xs text-gray-500 dark:text-gray-400"},sn={class:"flex shrink-0 items-center gap-1.5"},on={class:"rounded-md bg-gray-100 px-1.5 py-0.5 text-[10px] uppercase text-gray-500 dark:bg-gray-800"},nn={class:"flex max-h-[92vh] flex-col overflow-hidden bg-white dark:bg-gray-950"},rn={class:"flex items-start justify-between gap-4 border-b border-gray-200 px-5 py-4 dark:border-gray-800"},ln={class:"min-w-0"},cn={class:"truncate text-base font-semibold text-gray-900 dark:text-gray-100"},dn={key:0,class:"mt-1 line-clamp-2 text-xs text-gray-500 dark:text-gray-400"},un={class:"mt-1 text-[11px] text-gray-400 dark:text-gray-500"},mn={class:"min-h-0 flex-1 overflow-auto p-4"},gn={key:0,class:"flex h-64 items-center justify-center text-xs text-gray-400 dark:text-gray-500"},pn={class:"mt-1 text-[11px] text-gray-400 dark:text-gray-500"},vn={class:"px-2 py-3"},hn={key:0,class:"flex h-32 items-center justify-center text-xs text-gray-400 dark:text-gray-500"},yn=he({__name:"ChartBlockRenderer",props:{chart:{}},setup(l){const{t:s}=ke(),t=l,c=x(!1),r=k(()=>t.chart.spec.title),m=k(()=>t.chart.spec.subtitle||t.chart.spec.description||""),u=k(()=>t.chart.spec.display?.height??(t.chart.spec.type==="heatmap"?300:260)),d=k(()=>t.chart.rowCount===0),g=k(()=>{const _=[];return t.chart.spec.unit&&_.push(t.chart.spec.unit),t.chart.truncated&&_.push(s("ai.chat.message.chart.truncated")),_.push(s("ai.chat.message.chart.rows",{count:t.chart.rowCount})),_.join(" · ")}),v=k(()=>t.chart.data),h=k(()=>t.chart.data),S=k(()=>t.chart.data),b=k(()=>t.chart.data),w=k(()=>t.chart.spec.type==="pie"?S.value.labels.length>8:t.chart.spec.type==="line"?h.value.labels.length>28||(h.value.series?.length??0)>4:t.chart.spec.type==="bar"?v.value.labels.length>12:t.chart.spec.type==="heatmap"?b.value.xLabels.length*b.value.yLabels.length>180:!1),q=k(()=>{const _=w.value?320:380;return Math.min(u.value,_)}),T=k(()=>{const _=u.value;if(t.chart.spec.type==="pie")return Math.max(_,560);if(t.chart.spec.type==="line")return Math.max(_,h.value.labels.length>40?620:540);if(t.chart.spec.type==="bar"){const C=t.chart.spec.display?.horizontal?v.value.labels.length*28+120:520;return Math.min(Math.max(_,C),820)}return t.chart.spec.type==="heatmap"?Math.min(Math.max(_,b.value.yLabels.length*22+150,560),860):Math.max(_,520)}),I=k(()=>t.chart.spec.type==="pie"?"640px":t.chart.spec.type==="bar"?"720px":"780px");return(_,C)=>{const M=Re,y=Oe;return n(),i("div",Jo,[e("div",Xo,[e("div",Zo,[e("div",en,[e("h3",tn,o(r.value),1),m.value?(n(),i("p",an,o(m.value),1)):R("",!0)]),e("div",sn,[e("span",on,o(l.chart.spec.type),1),p(y,{open:c.value,"onUpdate:open":C[2]||(C[2]=f=>c.value=f),ui:{overlay:"z-[10040] backdrop-blur-sm",content:"z-[10050] w-[96vw] max-w-6xl max-h-[92vh] overflow-hidden"}},{content:U(()=>[e("div",nn,[e("div",rn,[e("div",ln,[e("h3",cn,o(r.value),1),m.value?(n(),i("p",dn,o(m.value),1)):R("",!0),e("p",un,o(g.value),1)]),p(M,{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:C[1]||(C[1]=f=>c.value=!1)},null,8,["title","aria-label"])]),e("div",mn,[e("div",{class:"mx-auto w-full",style:Ge({minWidth:I.value})},[d.value?(n(),i("div",gn,o(a(s)("ai.chat.message.chart.empty")),1)):l.chart.spec.type==="bar"?(n(),K(tt,{key:1,data:v.value,height:T.value,mode:"expanded",horizontal:l.chart.spec.display?.horizontal},null,8,["data","height","horizontal"])):l.chart.spec.type==="line"?(n(),K(Ut,{key:2,data:h.value,height:T.value,mode:"expanded"},null,8,["data","height"])):l.chart.spec.type==="pie"?(n(),K(Vt,{key:3,data:S.value,height:T.value,mode:"expanded","show-legend":l.chart.spec.display?.showLegend??!0},null,8,["data","height","show-legend"])):l.chart.spec.type==="heatmap"?(n(),K(Ft,{key:4,data:b.value,height:T.value,mode:"expanded"},null,8,["data","height"])):R("",!0)],4)])])]),default:U(()=>[p(M,{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:C[0]||(C[0]=Fe(()=>{},["stop"]))},null,8,["title","aria-label"])]),_:1},8,["open"])])]),e("p",pn,o(g.value),1)]),e("div",vn,[d.value?(n(),i("div",hn,o(a(s)("ai.chat.message.chart.empty")),1)):l.chart.spec.type==="bar"?(n(),K(tt,{key:1,data:v.value,height:q.value,mode:"compact",horizontal:l.chart.spec.display?.horizontal},null,8,["data","height","horizontal"])):l.chart.spec.type==="line"?(n(),K(Ut,{key:2,data:h.value,height:q.value,mode:"compact"},null,8,["data","height"])):l.chart.spec.type==="pie"?(n(),K(Vt,{key:3,data:S.value,height:q.value,mode:"compact","show-legend":l.chart.spec.display?.showLegend??!0},null,8,["data","height","show-legend"])):l.chart.spec.type==="heatmap"?(n(),K(Ft,{key:4,data:b.value,height:q.value,mode:"compact"},null,8,["data","height"])):R("",!0)])])}}}),fn={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"},xn={class:"text-xs font-semibold text-gray-700 dark:text-gray-200"},bn={key:0,class:"flex min-w-0 items-center gap-2"},kn={key:0,class:"truncate text-[11px] text-gray-400 dark:text-gray-500"},_n={class:"ml-auto flex shrink-0 items-center gap-1.5"},wn={class:"text-[11px] text-gray-400 dark:text-gray-500"},$n={key:0,class:"border-t border-gray-200/70 px-3 py-2 dark:border-gray-700/50"},Cn={class:"mb-2 space-y-0.5 text-xs text-gray-600 dark:text-gray-400"},Sn={class:"font-medium"},Tn={key:0},In={class:"font-medium"},Mn={key:0,class:"mb-2 space-y-1"},Ln={key:1,class:"py-1.5 text-center text-xs text-gray-400 dark:text-gray-500"},Dn={key:2,class:"space-y-2"},An={class:"flex items-center gap-2"},qn={class:"ml-auto shrink-0 text-[11px] text-gray-400 dark:text-gray-500"},Rn={key:0,class:"mt-1 text-[11px] text-gray-500 dark:text-gray-400"},En={class:"mt-1 space-y-0.5"},zn=["onClick"],Pn={class:"min-w-0 flex-1 text-xs leading-snug text-gray-600 dark:text-gray-300"},Bn={key:0,class:"mr-1 text-gray-400 dark:text-gray-500"},jn={class:"line-clamp-2 break-words align-middle"},Fn={key:3,class:"mt-1.5 text-right text-[11px] text-gray-400 dark:text-gray-500"},Un=he({__name:"EvidenceBlock",props:{evidence:{}},setup(l){const s=l,{t}=ke(),c=dt(),r=x(!1),m=["included","uncertain","excluded"],u=k(()=>[...s.evidence.groups].sort((w,q)=>m.indexOf(w.status)-m.indexOf(q.status))),d=k(()=>s.evidence.groups.reduce((w,q)=>w+q.sources.length,0)),g=k(()=>m.map(w=>({status:w,count:s.evidence.groups.filter(q=>q.status===w).length})).filter(w=>w.count>0)),v=k(()=>s.evidence.warnings??[]),h={included:"bg-emerald-50 text-emerald-600 dark:bg-emerald-900/20 dark:text-emerald-400",uncertain:"bg-amber-50 text-amber-600 dark:bg-amber-900/20 dark:text-amber-400",excluded:"bg-gray-100 text-gray-500 dark:bg-gray-800/40 dark:text-gray-400"},S={included:"bg-emerald-500",uncertain:"bg-amber-500",excluded:"bg-gray-400"};function b(w){c.openChatRecordDrawer({scrollToMessageId:w})}return(w,q)=>{const T=_e;return n(),i("div",fn,[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:q[0]||(q[0]=I=>r.value=!r.value)},[p(T,{name:"i-heroicons-document-magnifying-glass",class:"h-4 w-4 shrink-0 text-primary-500"}),e("span",xn,o(a(t)("ai.chat.evidence.title")),1),r.value?R("",!0):(n(),i("div",bn,[(n(!0),i(ne,null,de(g.value,I=>(n(),i("span",{key:I.status,class:"flex shrink-0 items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400"},[e("span",{class:oe(["h-1.5 w-1.5 rounded-full",S[I.status]])},null,2),ee(" "+o(a(t)(`ai.chat.evidence.group.${I.status}`))+" "+o(I.count),1)]))),128)),g.value.length===0?(n(),i("span",kn,o(a(t)("ai.chat.evidence.empty")),1)):R("",!0)])),e("span",_n,[e("span",wn,o(a(t)(`ai.chat.evidence.mode.${l.evidence.mode}`)),1),p(T,{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",$n,[e("div",Cn,[e("div",null,[e("span",Sn,o(a(t)("ai.chat.evidence.query"))+":",1),ee(" "+o(l.evidence.query),1)]),l.evidence.criteria?(n(),i("div",Tn,[e("span",In,o(a(t)("ai.chat.evidence.criteria"))+":",1),ee(" "+o(l.evidence.criteria),1)])):R("",!0)]),v.value.length>0?(n(),i("div",Mn,[(n(!0),i(ne,null,de(v.value,I=>(n(),i("div",{key:I,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(T,{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.${I}`)),1)]))),128))])):R("",!0),u.value.length===0?(n(),i("div",Ln,o(a(t)("ai.chat.evidence.empty")),1)):(n(),i("div",Dn,[(n(!0),i(ne,null,de(u.value,I=>(n(),i("div",{key:I.id,class:"rounded-md border border-gray-200/80 bg-white px-2.5 py-1.5 dark:border-gray-700/50 dark:bg-gray-900/30"},[e("div",An,[e("span",{class:oe(["rounded px-1.5 py-0.5 text-[11px] font-medium",h[I.status]])},o(a(t)(`ai.chat.evidence.group.${I.status}`)),3),e("span",qn,o(I.title),1)]),I.reason?(n(),i("div",Rn,o(I.reason),1)):R("",!0),e("ul",En,[(n(!0),i(ne,null,de(I.sources,(_,C)=>(n(),i("li",{key:`${I.id}-${C}`,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:M=>b(_.messageId)},[e("div",Pn,[_.senderName?(n(),i("span",Bn,o(_.senderName)+": ",1)):R("",!0),e("span",jn,o(_.snippet),1)]),p(T,{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,zn))),128))])]))),128))])),u.value.length>0?(n(),i("div",Fn,o(a(t)("ai.chat.evidence.totalSources",{count:d.value})),1)):R("",!0)])):R("",!0)])}}}),Vn=/^\s*!\[[^\]\n]*\]\(\s*(?:(?:https?:\/\/(?:localhost|127\.0\.0\.1)(?::\d+)?)?\/?|\.\/)?chart[\w-]*(?:\.(?:png|jpg|jpeg|webp|svg))?(?:\?[^)\s]*)?\s*(?:"[^"]*")?\s*\)\s*$/gim;function On(l){return l&&l.replace(Vn,"").replace(/\n{3,}/g,`
|
|
8
8
|
|
|
@@ -107,4 +107,4 @@ ${V}
|
|
|
107
107
|
1. 仅输出 JSON,不要有任何其他文字
|
|
108
108
|
2. SQL 中的查询结果限制在合理范围内(建议 LIMIT 100)
|
|
109
109
|
3. 确保 SQL 语法正确
|
|
110
|
-
4. 若用户需求包含多个分析目标,仅选择第一个目标生成 SQL`}function pe(V){let te=V.trim();te=te.replace(/^```json?\n?/i,"").replace(/\n?```$/i,"");try{const xe=JSON.parse(te);return{sql:(xe.sql||"").trim(),explanation:(xe.explanation||"").trim()}}catch{return te=te.replace(/^```sql?\n?/i,"").replace(/\n?```$/i,""),{sql:te.trim(),explanation:""}}}async function ye(){const V=g.value.trim();if(!V){b.value=s("ai.sqlLab.generate.errorEmptyPrompt");return}if(!await Yt().hasConfig()){b.value=s("common.errorNoAIConfig");return}const xe=r.value?.schema||[];if(xe.length===0){b.value=s("common.error.unknown");return}S.value=!0,w.value=null,b.value=null,T.value="",I.value="",_.value=!1;let fe="";try{const X=Y(V,xe),O=await la().chatStream([{role:"system",content:"你是一个 SQLite 专家,请以 JSON 格式输出 sql 和 explanation 字段。"},{role:"user",content:X}],{temperature:.1,maxTokens:4096},F=>{if(F.thinking!==void 0){F.thinkingDone?_.value=!1:(_.value=!0,F.thinking&&(I.value+=F.thinking,Ve(()=>{C.value&&(C.value.scrollTop=C.value.scrollHeight)})));return}F.error&&(fe=F.error),F.isFinished&&F.finishReason==="length"&&(fe=s("ai.sqlLab.generate.errorTokenLimit")),F.content&&(T.value+=F.content)});if(!O.success){b.value=O.error||fe||s("ai.sqlLab.generate.errorGenerate");return}if(fe){b.value=fe;return}const B=pe(T.value);if(!B.sql){b.value=T.value?`${s("ai.sqlLab.generate.errorGenerate")}: ${T.value.slice(0,200)}`:s("ai.sqlLab.generate.errorGenerate");return}d.value=B.sql,q.value=V,A(V,B.sql,B.explanation),await z()}catch(X){b.value=X.message||String(X)}finally{S.value=!1}}async function Q(V){d.value=V.sql,q.value=V.prompt,M.value=!1,await z()}return Ee(()=>{f()}),ge(()=>c.chatType,V=>{g.value=u(V)}),(V,te)=>{const xe=_e,fe=Re;return n(),i("div",dm,[p(a(a0),{ref_key:"schemaPanelRef",ref:r,"session-id":l.sessionId,onInsertColumn:L},null,8,["session-id"]),e("div",um,[e("div",mm,[e("div",gm,[v.value==="prompt"?He((n(),i("textarea",{key:0,"onUpdate:modelValue":te[0]||(te[0]=X=>g.value=X),class:"h-32 w-full resize-none rounded-lg border border-gray-300 bg-white p-3 text-sm text-gray-800 focus:border-pink-500 focus:outline-none focus:ring-1 focus:ring-pink-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200",placeholder:a(s)("ai.sqlLab.generate.placeholder"),spellcheck:"false",onKeydown:te[1]||(te[1]=X=>$(X,"prompt"))},null,40,pm)),[[ot,g.value]]):He((n(),i("textarea",{key:1,"onUpdate:modelValue":te[2]||(te[2]=X=>d.value=X),class:"h-32 w-full resize-none rounded-lg border border-gray-300 bg-white p-3 font-mono text-sm text-gray-800 focus:border-pink-500 focus:outline-none focus:ring-1 focus:ring-pink-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200",placeholder:a(s)("ai.sqlLab.editor.placeholder"),spellcheck:"false",onKeydown:te[3]||(te[3]=X=>$(X,"sql"))},null,40,vm)),[[ot,d.value]]),e("div",hm,[e("div",ym,[p(fe,{variant:"ghost",size:"xs",onClick:W},{default:U(()=>[p(xe,{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",fm,o(a(s)("ai.sqlLab.editor.tip")),1)):R("",!0)]),e("div",xm,[p(fe,{variant:"ghost",size:"sm",disabled:y.value.length===0,onClick:te[4]||(te[4]=X=>M.value=!0)},{default:U(()=>[p(xe,{name:"i-heroicons-clock",class:"mr-1 h-4 w-4"}),ee(" "+o(a(s)("ai.sqlLab.editor.history"))+" ",1),y.value.length>0?(n(),i("span",bm,"("+o(y.value.length)+")",1)):R("",!0)]),_:1},8,["disabled"]),v.value==="prompt"?(n(),K(fe,{key:0,color:"primary",size:"sm",loading:S.value||h.value,disabled:!g.value.trim(),onClick:ye},{default:U(()=>[p(xe,{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(),K(fe,{key:1,color:"primary",size:"sm",loading:h.value,onClick:z},{default:U(()=>[p(xe,{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"&&!w.value&&!b.value&&(T.value||I.value||S.value)?(n(),i("div",km,[e("div",_m,[e("p",wm,[p(xe,{name:"i-heroicons-cpu-chip",class:"h-4 w-4"}),ee(" "+o(a(s)("ai.sqlLab.generate.aiOutput"))+" ",1),_.value?(n(),i("span",$m,o(a(s)("ai.sqlLab.generate.thinking")),1)):S.value?(n(),i("span",Cm,o(a(s)("common.generating")),1)):R("",!0)]),I.value?(n(),i("details",{key:0,class:"mb-3",open:_.value},[e("summary",Tm,o(a(s)("ai.sqlLab.generate.thinkingProcess")),1),e("pre",{ref_key:"thinkingPreRef",ref:C,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(I.value),513)],8,Sm)):R("",!0),T.value?(n(),i("pre",Im,o(T.value),1)):I.value?R("",!0):(n(),i("p",Mm,o(a(s)("ai.sqlLab.generate.waitingAI")),1))])])):(n(),K(a(cm),{key:1,ref_key:"resultTableRef",ref:m,result:w.value,error:b.value,sql:d.value,prompt:q.value},null,8,["result","error","sql","prompt"]))]),p(a(y0),{open:M.value,"onUpdate:open":te[5]||(te[5]=X=>M.value=X),history:y.value,onExecute:Q,onDelete:P},null,8,["open","history"])])}}}),Dm=he({__name:"EChartCalendar",props:{data:{},height:{default:180},year:{}},setup(l){yt([Gt,ya,Mt,Jt,ft]);const s=l,{t,locale:c}=ke(),r=pt(),m=x(null);let u=null;const d=k(()=>{if(s.year)return s.year;if(s.data.length===0)return new Date().getFullYear();const T=s.data.map(I=>parseInt(I.date.split("-")[0]));return Math.max(...T)}),g=k(()=>s.data.length===0?10:Math.max(...s.data.map(T=>T.value),1)),v=k(()=>s.data.map(T=>[T.date,T.value])),h={light:["#fee5e8","#fbb5c2","#f7758c","#ee4567"],dark:["#3d1f24","#6b2f3a","#a34557","#ee4567"]},S=k(()=>({tooltip:{trigger:"item",formatter:T=>{const I=T.data[0],_=T.data[1];return`${I}<br/>${t("views.message.calendarTooltipMessages")}: ${_}`}},visualMap:{min:0,max:g.value,calculable:!1,orient:"horizontal",left:"center",bottom:0,itemWidth:10,itemHeight:100,text:[`${g.value}`,"0"],inRange:{color:r.value?h.dark:h.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 b(){m.value&&(u=xt(m.value,r.value?"dark":void 0,{renderer:"canvas"}),u.setOption({backgroundColor:"transparent",...S.value}))}function w(){u&&u.setOption({backgroundColor:"transparent",...S.value},{notMerge:!0})}function q(){u?.resize()}return ge([()=>s.data,r,c],()=>{w()}),ge(()=>s.year,()=>{w()}),Ee(()=>{b(),window.addEventListener("resize",q)}),lt(()=>{window.removeEventListener("resize",q),u?.dispose()}),(T,I)=>(n(),i("div",{ref_key:"chartRef",ref:m,style:Ge({height:`${l.height}px`,width:"100%"})},null,4))}}),Am={class:"flex items-center justify-between border-b border-gray-200 px-5 py-3 dark:border-gray-800"},qm={class:"font-semibold text-gray-900 whitespace-nowrap dark:text-white"},Rm={key:0,class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},Em={class:"no-capture flex items-center gap-2"},zm={class:"flex w-full items-center justify-between border-b border-gray-200 px-6 py-4 dark:border-gray-700"},Pm={class:"flex items-center gap-2"},Bm={class:"text-lg font-semibold text-gray-900 whitespace-nowrap dark:text-white"},jm={class:"text-sm text-gray-500"},Fm={class:"max-h-[60vh] p-4 divide-y divide-gray-100 overflow-y-auto dark:divide-gray-800"},Um={class:"divide-y divide-gray-100 dark:divide-gray-800"},Vm={key:0},Om={class:"px-5 py-8 text-center text-sm text-gray-400"},Nm=he({__name:"ListPro",props:{items:{},title:{},description:{},topN:{default:10},countTemplate:{}},setup(l){const{t:s}=ke(),t=l,c=x(!1),r=x(null),m=x(null),u=k(()=>t.items.slice(0,t.topN)),d=k(()=>t.items.length>t.topN),g=k(()=>(t.countTemplate||s("views.charts.listPro.countTemplate")).replace("{count}",String(t.items.length)));return(v,h)=>{const S=Re,b=Oe;return n(),i("div",{ref_key:"cardRef",ref:r,class:"rounded-xl border border-gray-200 bg-white shadow-sm dark:border-gray-800 dark:bg-gray-900"},[e("div",Am,[e("div",null,[e("h3",qm,o(l.title),1),l.description?(n(),i("p",Rm,o(l.description),1)):R("",!0)]),e("div",Em,[Ke(v.$slots,"headerRight"),p(ct,{size:"xs",type:"element","target-element":r.value},null,8,["target-element"]),p(b,{open:c.value,"onUpdate:open":h[0]||(h[0]=w=>c.value=w),ui:{content:"md:w-full max-w-3xl"}},{content:U(()=>[e("div",{ref_key:"modalBodyRef",ref:m,class:"section-content flex flex-col"},[e("div",zm,[e("div",Pm,[e("h3",Bm,o(l.title),1),e("span",jm,"("+o(g.value)+")",1)]),p(ct,{size:"xs",type:"element","target-element":m.value},null,8,["target-element"])]),e("div",Fm,[(n(!0),i(ne,null,de(l.items,(w,q)=>(n(),i("div",{key:q,class:"px-5 py-3"},[Ke(v.$slots,"item",{item:w,index:q})]))),128))])],512)]),default:U(()=>[d.value?(n(),K(S,{key:0,icon:"i-heroicons-list-bullet",variant:"ghost"},{default:U(()=>[ee(o(a(s)("views.charts.listPro.fullRanking")),1)]),_:1})):R("",!0)]),_:3},8,["open"])])]),Ke(v.$slots,"config"),e("div",Um,[(n(!0),i(ne,null,de(u.value,(w,q)=>(n(),i("div",{key:q,class:"px-5 py-3"},[Ke(v.$slots,"item",{item:w,index:q})]))),128))]),l.items.length===0?(n(),i("div",Vm,[Ke(v.$slots,"empty",{},()=>[e("div",Om,o(a(s)("views.charts.listPro.empty")),1)])])):R("",!0)],512)}}}),Hm={class:"border-b border-gray-100 p-4 dark:border-gray-800"},Ym={class:"mb-3 flex flex-wrap items-center gap-2"},Wm={class:"text-xs text-gray-500 dark:text-gray-400"},Km=["onClick"],Qm={class:"p-4"},Gm={class:"mb-3 font-semibold text-gray-900 dark:text-white"},Jm={class:"space-y-3"},Xm={class:"mb-1 block text-xs text-gray-500"},Zm={class:"mb-1 block text-xs text-gray-500"},eg={class:"flex flex-wrap items-center gap-2"},tg={class:"mt-4 flex justify-end gap-2"},ag={class:"flex flex-wrap items-center gap-2"},sg={class:"mt-1.5 text-xs text-gray-400"},og={key:0,class:"border-b border-gray-100 px-5 py-4 dark:border-gray-800"},ng={class:"mb-3 flex items-center justify-between"},rg={class:"text-base font-medium text-gray-700 dark:text-gray-300"},lg={class:"flex cursor-pointer items-center gap-1.5 text-xs text-gray-500"},ig={class:"flex flex-wrap gap-2"},cg={class:"text-xs text-gray-500"},dg={class:"flex items-center gap-3"},ug={class:"w-32 shrink-0"},mg={class:"truncate font-medium text-gray-900 dark:text-white"},gg={class:"flex flex-1 items-center"},pg={class:"flex h-2.5 w-full overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800"},vg=["title"],hg={class:"flex shrink-0 items-baseline gap-2"},yg={class:"text-lg font-bold text-gray-900 dark:text-white"},fg={class:"text-sm text-gray-500"},xg={key:0,class:"flex h-64 flex-col items-center justify-center text-gray-400"},bg={class:"text-sm"},kg={key:1,class:"h-64"},_g=he({__name:"KeywordAnalysis",props:{sessionId:{},timeFilter:{}},setup(l){const{t:s}=ke(),t=l,c=$t(),r=x(!1),m={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(O){if(!r.value)return m;const B=b.value.indexOf(O);return u[B%u.length]}const g=["laugh","sad","praise","slacker","gossip","polite","curious"],v=k(()=>[{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")}]),h=k(()=>{const O=c.customKeywordTemplates.map(F=>({...F,isCustom:!0}));return[...v.value.filter(F=>!c.deletedPresetTemplateIds.includes(F.id)),...O]}),S=x("laugh"),b=x([]);ge(v,O=>{O.length>0&&b.value.length===0&&(b.value=[...O[0].keywords])},{immediate:!0});const w=k(()=>{const O=h.value.find(B=>B.id===S.value);return O?O.name:""}),q=x(null),T=x(!1),I=x(!1),_=x(null),C=x(""),M=x([]),y=x(""),f=k(()=>_.value!==null),D=k(()=>f.value?s("quotes.keywords.modal.editTitle"):s("quotes.keywords.modal.createTitle"));function A(){_.value=null,C.value="",M.value=[],y.value="",I.value=!0}function P(O){_.value=O.id,C.value=O.name,M.value=[...O.keywords],I.value=!0}function z(){const O=y.value.trim();O&&!M.value.includes(O)&&(M.value=[...M.value,O]),y.value=""}function $(O){M.value=M.value.filter(B=>B!==O)}function L(O){S.value=O.id,b.value=[...O.keywords],q.value=null,te()}function W(){b.value=[],q.value=null,S.value=""}const ae=x("");function Y(){const O=ae.value.trim();O&&!b.value.includes(O)&&(b.value=[...b.value,O],te()),ae.value=""}function pe(O){b.value=b.value.filter(B=>B!==O),te()}function ye(O){return g.includes(O)}function Q(){if(C.value.trim()){if(f.value&&_.value)if(ye(_.value)){const O={id:`custom_${Date.now()}`,name:C.value.trim(),keywords:[...M.value]};c.addCustomKeywordTemplate(O),S.value=O.id,b.value=[...O.keywords],te()}else c.updateCustomKeywordTemplate(_.value,{name:C.value.trim(),keywords:[...M.value]}),S.value===_.value&&(b.value=[...M.value],te());else{const O={id:`custom_${Date.now()}`,name:C.value.trim(),keywords:[...M.value]};c.addCustomKeywordTemplate(O),S.value=O.id,b.value=[...O.keywords],te()}I.value=!1}}function V(O){ye(O)?c.addDeletedPresetTemplateId(O):c.removeCustomKeywordTemplate(O),S.value===O&&(h.value.length>0?L(h.value[0]):W())}async function te(){if(!t.sessionId||b.value.length===0){q.value=null;return}T.value=!0;try{q.value=await Ue().getLaughAnalysis(t.sessionId,t.timeFilter,[...b.value])}catch(O){console.error("加载词频分析失败:",O),q.value=null}finally{T.value=!1}}const xe=k(()=>q.value?q.value.rankByCount.map(O=>({id:O.memberId.toString(),name:O.name,value:O.laughCount,percentage:O.percentage,keywordDistribution:O.keywordDistribution||[]})):[]);function fe(O){if(xe.value.length===0)return 0;const B=xe.value[0].value;return B===0?0:Math.round(xe.value[O].value/B*100)}function X(O,B){const F=fe(B);return!O.keywordDistribution||O.keywordDistribution.length===0?[{keyword:"default",width:F,bg:"bg-amber-400"}]:O.keywordDistribution.map(J=>({keyword:J.keyword,width:J.percentage/100*F,bg:d(J.keyword).bg}))}return ge(()=>[t.sessionId,t.timeFilter],()=>{te()},{immediate:!0,deep:!0}),(O,B)=>{const F=ga,J=ht,ce=Wt,ve=Re,G=Oe,re=Ka,be=_e;return n(),K(a(Nm),{items:xe.value,title:a(s)("quotes.keywords.title"),description:a(s)("quotes.keywords.description"),"top-n":10,"count-template":a(s)("quotes.keywords.countTemplate")},{config:U(()=>[e("div",Hm,[e("div",Ym,[e("span",Wm,o(a(s)("quotes.keywords.templateLabel")),1),(n(!0),i(ne,null,de(h.value,ue=>(n(),K(F,{key:ue.id,items:[[{label:a(s)("quotes.keywords.contextMenu.edit"),icon:"i-lucide-pencil",disabled:!ue.isCustom,onSelect:()=>P(ue)},{label:a(s)("quotes.keywords.contextMenu.delete"),icon:"i-lucide-trash",color:"error",onSelect:()=>V(ue.id)}]]},{default:U(()=>[e("button",{class:oe(["rounded-md border px-2.5 py-1 text-sm transition-all",S.value===ue.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:we=>L(ue)},o(ue.name),11,Km)]),_:2},1032,["items"]))),128)),p(G,{open:I.value,"onUpdate:open":B[3]||(B[3]=ue=>I.value=ue)},{content:U(()=>[e("div",Qm,[e("h3",Gm,o(D.value),1),e("div",Jm,[e("div",null,[e("label",Xm,o(a(s)("quotes.keywords.modal.templateName")),1),p(J,{modelValue:C.value,"onUpdate:modelValue":B[0]||(B[0]=ue=>C.value=ue),placeholder:a(s)("quotes.keywords.modal.templateNamePlaceholder")},null,8,["modelValue","placeholder"])]),e("div",null,[e("label",Zm,o(a(s)("quotes.keywords.modal.keywords")),1),e("div",eg,[(n(!0),i(ne,null,de(M.value,ue=>(n(),K(ce,{key:ue,variant:"soft",class:"cursor-pointer",onClick:we=>$(ue)},{default:U(()=>[ee(o(ue)+" ",1),B[6]||(B[6]=e("span",{class:"ml-0.5 hover:text-red-500"},"×",-1))]),_:2},1032,["onClick"]))),128)),p(J,{modelValue:y.value,"onUpdate:modelValue":B[1]||(B[1]=ue=>y.value=ue),placeholder:a(s)("quotes.keywords.modal.keywordPlaceholder"),class:"w-full",onKeydown:Xe(Fe(z,["prevent"]),["enter"])},null,8,["modelValue","placeholder","onKeydown"])])])]),e("div",tg,[p(ve,{variant:"soft",onClick:B[2]||(B[2]=ue=>I.value=!1)},{default:U(()=>[ee(o(a(s)("common.cancel")),1)]),_:1}),p(ve,{color:"primary",disabled:!C.value.trim()||M.value.length===0,onClick:Q},{default:U(()=>[ee(o(f.value?a(s)("quotes.keywords.modal.update"):a(s)("common.save")),1)]),_:1},8,["disabled"])])])]),default:U(()=>[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:A},o(a(s)("quotes.keywords.newTemplate")),1)]),_:1},8,["open"])]),e("div",ag,[(n(!0),i(ne,null,de(b.value,ue=>(n(),K(ce,{key:ue,class:"cursor-pointer",onClick:we=>pe(ue)},{default:U(()=>[ee(o(ue)+" ",1),B[7]||(B[7]=e("span",{class:"ml-0.5 hover:text-red-500"},"×",-1))]),_:2},1032,["onClick"]))),128)),p(J,{modelValue:ae.value,"onUpdate:modelValue":B[4]||(B[4]=ue=>ae.value=ue),placeholder:a(s)("quotes.keywords.searchPlaceholder"),class:"w-32",onKeydown:Xe(Fe(Y,["prevent"]),["enter"])},null,8,["modelValue","placeholder","onKeydown"]),b.value.length>0?(n(),i("button",{key:0,class:"text-sm text-pink-500 hover:text-red-500",onClick:W},o(a(s)("quotes.keywords.clear")),1)):R("",!0)]),e("div",sg,o(a(s)("quotes.keywords.templateHint")),1)]),q.value&&q.value.typeDistribution.length>0?(n(),i("div",og,[e("div",ng,[e("span",rg,o(w.value?w.value:b.value.length===1?b.value[0]:a(s)("quotes.keywords.keyword"))+o(a(s)("quotes.keywords.ranking")),1),e("label",lg,[e("span",null,o(a(s)("quotes.keywords.multiColorMode")),1),p(re,{modelValue:r.value,"onUpdate:modelValue":B[5]||(B[5]=ue=>r.value=ue),size:"md"},null,8,["modelValue"])])]),e("div",ig,[(n(!0),i(ne,null,de(q.value.typeDistribution,ue=>(n(),i("div",{key:ue.type,class:oe(["flex items-center gap-2 rounded-lg px-2 py-2 text-xs",d(ue.type).wrapBg])},[e("span",{class:oe(["h-2.5 w-2.5 shrink-0 rounded-full",d(ue.type).bg])},null,2),e("span",{class:oe(["font-medium",d(ue.type).text])},o(ue.type),3),e("span",cg,o(a(s)("quotes.keywords.times",{count:ue.count})),1),p(ce,{color:d(ue.type).badge,variant:"soft",size:"xs"},{default:U(()=>[ee(o(ue.percentage)+"%",1)]),_:2},1032,["color"])],2))),128))])])):R("",!0),T.value&&xe.value.length===0?(n(),K(a(mt),{key:1,text:a(s)("quotes.keywords.loading")},null,8,["text"])):R("",!0)]),item:U(({item:ue,index:we})=>[e("div",dg,[e("div",{class:oe(["flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-sm font-bold",a(cs)(we)])},o(we+1),3),e("div",ug,[e("p",mg,o(ue.name),1)]),e("div",gg,[e("div",pg,[(n(!0),i(ne,null,de(X(ue,we),Le=>(n(),i("div",{key:Le.keyword,class:oe(["h-full transition-all first:rounded-l-full last:rounded-r-full",Le.bg]),style:Ge({width:`${Le.width}%`}),title:`${Le.keyword}: ${Le.width.toFixed(1)}%`},null,14,vg))),128))])]),e("div",hg,[e("span",yg,o(ue.value),1),e("span",fg,o(a(s)("quotes.keywords.timesWithPercent",{count:ue.value,percent:ue.percentage})),1)])])]),empty:U(()=>[T.value?(n(),i("div",kg)):(n(),i("div",xg,[p(be,{name:"i-heroicons-magnifying-glass",class:"mb-2 h-8 w-8 opacity-50"}),e("p",bg,o(a(s)("quotes.keywords.empty")),1)]))]),_:1},8,["items","title","description","count-template"])}}}),wg={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},$g={class:"flex items-center gap-6 sm:gap-10"},Cg={class:"min-w-0 flex-1"},Sg={class:"flex flex-col gap-2 text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},Tg={key:0,class:"mb-0 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},Ig={class:"flex items-baseline gap-x-1.5"},Mg={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Lg={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Dg={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Ag={class:"flex items-baseline gap-x-1.5"},qg={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Rg={class:"font-black text-3xl text-pink-500 dark:text-pink-400"},Eg={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},zg={key:1,class:"mt-1 flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},Pg={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Bg=["onClick"],jg={key:0,class:"text-gray-400"},Fg={key:0,class:"hidden shrink-0 overflow-hidden rounded-lg sm:block"},Ug={class:"relative",style:{width:"360px",height:"220px"}},Vg={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Og={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Ng={class:"min-w-0 flex-1"},Hg={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},Yg={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Wg={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"},Kg={class:"flex items-center gap-1.5"},Qg={class:"text-[9px] font-medium uppercase tracking-widest"},Gg=he({__name:"TopicProfileCard",props:{totalMessages:{},totalWords:{},uniqueWords:{},topWords:{},topicWords:{},posTagStats:{},timeFilter:{}},emits:["wordClick"],setup(l,{emit:s}){const t=da(()=>Tt(()=>import("./EChartWordcloud-B_YisOW5.js"),__vite__mapDeps([5,6,7,8,1]))),{t:c}=ke(),r=l,m=s,u=k(()=>{const{startTs:q,endTs:T}=r.timeFilter??{};return q&&T?`${$e(q*1e3).format("YYYY/MM/DD")} – ${$e(T*1e3).format("YYYY/MM/DD")}`:""}),d=k(()=>(r.topicWords?.length?r.topicWords:r.topWords).slice(0,5)),g=k(()=>({words:(r.topicWords?.length?r.topicWords:r.topWords).slice(0,50).map(T=>({word:T.word,count:T.count,percentage:T.percentage}))})),v=k(()=>r.totalWords===0?0:Math.round(r.uniqueWords/r.totalWords*100)),h=k(()=>{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 q=new Map(r.posTagStats.map(D=>[D.tag,D.count])),T=(q.get("n")||0)+(q.get("ns")||0)+(q.get("nt")||0)+(q.get("nz")||0),I=(q.get("v")||0)+(q.get("vn")||0)+(q.get("vd")||0),_=(q.get("a")||0)+(q.get("ad")||0)+(q.get("an")||0),C=T+I+_;if(C===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 M=T/C,y=I/C,f=_/C;return M>.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"}:y>.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"}:f>.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"}}),S=k(()=>{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 q=r.topWords.reduce((_,C)=>_+C.word.length*C.count,0),T=r.topWords.reduce((_,C)=>_+C.count,0),I=q/T;return I<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"}:I>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=k(()=>[{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:h.value.icon,label:c("quotes.topicProfile.chatStyle"),value:h.value.label,subtext:h.value.desc,colorClass:h.value.colorClass},{icon:S.value.icon,label:c("quotes.topicProfile.expressionStyle"),value:S.value.label,subtext:S.value.desc,colorClass:S.value.colorClass}]),w=["#6366f1","#ec4899","#f97316","#22c55e","#3b82f6","#8b5cf6","#14b8a6","#f43f5e"];return(q,T)=>{const I=_e;return n(),K(a(it),{variant:"elevated",decorative:"",class:"flex flex-col"},{default:U(()=>[e("div",wg,[e("div",$g,[e("div",Cg,[e("div",Sg,[u.value?(n(),i("p",Tg,o(u.value),1)):R("",!0),e("div",Ig,[e("span",Mg,o(a(c)("quotes.topicProfile.heroPrefix")),1),e("span",Lg,o(l.totalMessages.toLocaleString()),1),e("span",Dg,o(a(c)("quotes.topicProfile.heroMiddle")),1)]),e("div",Ag,[e("span",qg,o(a(c)("quotes.topicProfile.heroMiddleSecond")),1),e("span",Rg,o(l.uniqueWords.toLocaleString()),1),e("span",Eg,o(a(c)("quotes.topicProfile.heroSuffix")),1)]),d.value.length>0?(n(),i("div",zg,[e("span",Pg,o(a(c)("quotes.topicProfile.topTopicsPrefix")),1),(n(!0),i(ne,null,de(d.value,(_,C)=>(n(),i(ne,{key:_.word},[e("span",{class:"cursor-pointer font-bold text-xl transition-opacity hover:opacity-70",style:Ge({color:w[C%w.length]}),onClick:M=>m("wordClick",_.word)},o(_.word),13,Bg),C<d.value.length-1?(n(),i("span",jg,"·")):R("",!0)],64))),128))])):R("",!0)])]),g.value.words.length>0?(n(),i("div",Fg,[e("div",Ug,[p(a(t),{data:g.value,height:"100%","max-words":50,"size-scale":.8,"draw-out-of-bound":!0,shape:"rectangle","color-scheme":"default",onWordClick:T[0]||(T[0]=_=>m("wordClick",_))},null,8,["data"])])])):R("",!0)])]),e("div",Vg,[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"}," Topic Profile ")],-1)),e("div",Og,[(n(!0),i(ne,null,de(b.value,_=>(n(),i("div",{key:_.label,class:"flex items-start gap-2 rounded-lg bg-white/60 p-2.5 ring-1 ring-gray-900/5 dark:bg-white/5 dark:ring-white/10"},[p(I,{name:_.icon,class:oe(["mt-0.5 h-3.5 w-3.5 shrink-0",_.colorClass])},null,8,["name","class"]),e("div",Ng,[e("div",{class:oe(["truncate font-mono text-sm font-black leading-tight tabular-nums",_.colorClass])},o(_.value),3),e("div",Hg,o(_.label),1),e("div",Yg,o(_.subtext),1)])]))),128))])]),e("div",Wg,[e("div",Kg,[p(I,{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",Qg,o(a(c)("quotes.topicProfile.watermark")),1)])]),_:1})}}}),Jg={class:"px-5 py-4 sm:px-6"},Xg={class:"mb-4 flex items-center gap-2"},Zg={class:"text-[15px] font-black tracking-tight text-gray-900 dark:text-white"},ep={class:"flex flex-wrap justify-center gap-2"},tp=["onClick"],ap=he({__name:"SharedTopicsCard",props:{sessionId:{},timeFilter:{},dictType:{},excludeWords:{}},emits:["wordClick"],setup(l,{emit:s}){const{t}=ke(),c=Ct(),r=l,m=s,u=k(()=>c.locale),d=x([]),g=x([]),v=k(()=>d.value.slice(0,20)),h=["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 S(){if(r.sessionId)try{g.value.length===0&&(g.value=await Ue().getMembers(r.sessionId));const b=[...g.value].sort((C,M)=>M.messageCount-C.messageCount).slice(0,2);if(b.length<2){d.value=[];return}const w={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},[q,T]=await Promise.all([wt("/nlp/word-frequency",{...w,memberId:b[0].id}),wt("/nlp/word-frequency",{...w,memberId:b[1].id})]),I=new Map(T.words.map(C=>[C.word,C.count])),_=[];for(const C of q.words){const M=I.get(C.word);M&&_.push({word:C.word,countA:C.count,countB:M})}_.sort((C,M)=>M.countA+M.countB-(C.countA+C.countB)),d.value=_.slice(0,30)}catch(b){console.error("加载共同话题数据失败:",b),d.value=[]}}return ge(()=>r.sessionId,()=>{g.value=[]}),ge(()=>[r.sessionId,r.timeFilter,r.dictType,r.excludeWords],()=>{S()},{immediate:!0,deep:!0}),(b,w)=>{const q=_e;return v.value.length>0?(n(),K(a(it),{key:0,variant:"section"},{default:U(()=>[e("div",Jg,[e("div",Xg,[p(q,{name:"i-heroicons-link",class:"h-4 w-4 text-emerald-500"}),e("span",Zg,o(a(t)("quotes.topicProfile.sharedTopics")),1)]),e("div",ep,[(n(!0),i(ne,null,de(v.value,(T,I)=>(n(),i("span",{key:T.word,class:oe(["cursor-pointer rounded-full px-3 py-1 text-xs font-bold transition-opacity hover:opacity-80",h[I%h.length]]),onClick:_=>m("wordClick",T.word)},o(T.word),11,tp))),128))])])]),_:1})):R("",!0)}}}),Et="__ALL__",sp=he({__name:"UserSelect",props:{sessionId:{},modelValue:{}},emits:["update:modelValue"],setup(l,{emit:s}){const{t}=ke(),c=l,r=s,m=x([]),u=x(!1),d=k({get:()=>c.modelValue===null?Et:String(c.modelValue),set:h=>{r("update:modelValue",h===Et?null:parseInt(h))}}),g=k(()=>{const h=[{value:Et,label:t("common.userSelect.allMembers")}];return m.value.forEach(S=>{const b=S.groupNickname||S.accountName||S.platformId;h.push({value:String(S.id),label:`${b} (${S.messageCount})`})}),h});async function v(){if(c.sessionId){u.value=!0;try{const h=await Ue().getMembers(c.sessionId);m.value=h.sort((S,b)=>b.messageCount-S.messageCount)}catch(h){console.error("加载成员列表失败:",h)}finally{u.value=!1}}}return ge(()=>c.sessionId,()=>{r("update:modelValue",null),v()},{immediate:!0}),(h,S)=>{const b=Kt;return n(),K(b,{modelValue:d.value,"onUpdate:modelValue":S[0]||(S[0]=w=>d.value=w),items:g.value,loading:u.value,virtualize:{estimateSize:32,overscan:10},"value-key":"value",class:"w-48"},null,8,["modelValue","items","loading"])}}}),xa=Ba("wordFilter",()=>{const l=x([]),s=x(null),t=x({}),c=x(!1);function r(){return`wf_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function m(_,C=[]){const M={id:r(),name:_,words:[...C],createdAt:Date.now()};return l.value.push(M),M}function u(_,C){const M=l.value.find(y=>y.id===_);M&&(C.name!==void 0&&(M.name=C.name),C.words!==void 0&&(M.words=[...C.words]))}function d(_){l.value=l.value.filter(C=>C.id!==_),s.value===_&&(s.value=null);for(const[C,M]of Object.entries(t.value))M===_&&delete t.value[C]}function g(_){s.value=_}function v(_,C){t.value[_]=C}function h(_){delete t.value[_]}function S(_){return _ in t.value?t.value[_]:s.value}function b(_){const C=S(_);return C?l.value.find(y=>y.id===C)?.words??[]:[]}function w(_){return l.value.find(C=>C.id===_)}const q=k(()=>l.value.map(_=>({label:_.name,value:_.id,isDefault:_.id===s.value,wordCount:_.words.length})));function T(){c.value=!0}function I(){c.value=!1}return{schemes:l,defaultSchemeId:s,sessionSchemeOverrides:t,showWordFilterModal:c,schemeOptions:q,createScheme:m,updateScheme:u,deleteScheme:d,setDefaultScheme:g,setSessionScheme:v,clearSessionScheme:h,getActiveSchemeId:S,getExcludeWords:b,getSchemeById:w,openModal:T,closeModal:I}},{persist:!1,backendPersist:{pick:["schemes","defaultSchemeId","sessionSchemeOverrides"],key:"wordFilter"}}),op={class:"flex flex-col",style:{height:"520px"}},np={class:"flex items-center justify-between border-b border-gray-200 px-6 py-4 dark:border-white/5"},rp={class:"flex items-center gap-3"},lp={class:"flex h-9 w-9 items-center justify-center rounded-xl bg-linear-to-br from-pink-400 to-pink-600"},ip={class:"text-lg font-semibold text-gray-900 dark:text-white"},cp={class:"flex flex-1 overflow-hidden"},dp={class:"flex w-[200px] shrink-0 flex-col border-r border-gray-200 dark:border-white/5"},up={class:"flex items-center justify-between px-3 py-2"},mp={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},gp={class:"flex-1 overflow-y-auto px-2 pb-2"},pp=["onClick"],vp={class:"truncate text-sm"},hp={class:"ml-auto text-xs text-gray-400 dark:text-gray-500"},yp={key:0,class:"px-3 py-8 text-center text-xs text-gray-400 dark:text-gray-500"},fp={class:"flex flex-1 flex-col overflow-hidden"},xp={class:"flex-1 space-y-4 overflow-y-auto p-5"},bp={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},kp={class:"flex items-center gap-2"},_p={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},wp={class:"flex gap-2"},$p={class:"mb-1.5 flex items-center justify-between"},Cp={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},Sp={class:"ml-1 text-gray-400 dark:text-gray-500"},Tp={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"},Ip={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"},Mp={class:"flex shrink-0 justify-end border-t border-gray-200 px-5 py-3 dark:border-white/5"},Lp={key:1,class:"flex flex-1 flex-col items-center justify-center gap-3 text-gray-400 dark:text-gray-500"},Dp={class:"text-sm"},Ap=he({__name:"WordFilterModal",setup(l){const{t:s}=ke(),t=xa(),c=k({get:()=>t.showWordFilterModal,set:C=>C?t.openModal():t.closeModal()}),r=x(null),m=x(""),u=x(""),d=x(null),g=k(()=>r.value?t.getSchemeById(r.value)??null:null),v=k(()=>r.value===t.defaultSchemeId);ge(c,C=>{C&&(t.schemes.length>0&&!r.value&&(r.value=t.schemes[0].id),h())}),ge(r,()=>{h(),u.value=""});function h(){m.value=g.value?.name??""}function S(){const C=t.createScheme(s("wordFilter.defaultSchemeName"));r.value=C.id,Ve(()=>{d.value?.focus(),d.value?.select()})}function b(){if(!r.value)return;const C=t.schemes.findIndex(M=>M.id===r.value);if(t.deleteScheme(r.value),t.schemes.length>0){const M=Math.min(C,t.schemes.length-1);r.value=t.schemes[M].id}else r.value=null}function w(){!r.value||!m.value.trim()||t.updateScheme(r.value,{name:m.value.trim()})}function q(){r.value&&(v.value?t.setDefaultScheme(null):t.setDefaultScheme(r.value))}function T(){if(!r.value||!u.value.trim())return;const M=u.value.trim().split(/[,,\n\r\t;;|、\s]+/).map(A=>A.trim()).filter(A=>A.length>0);if(M.length===0)return;const y=g.value;if(!y)return;const f=new Set(y.words.map(A=>A.toLowerCase())),D=M.filter(A=>!f.has(A.toLowerCase()));D.length>0&&t.updateScheme(r.value,{words:[...y.words,...D]}),u.value=""}function I(C){if(!r.value)return;const M=g.value;M&&t.updateScheme(r.value,{words:M.words.filter(y=>y!==C)})}function _(){r.value&&t.updateScheme(r.value,{words:[]})}return(C,M)=>{const y=_e,f=Re,D=ht,A=Wt,P=Oe;return n(),K(P,{open:c.value,"onUpdate:open":M[4]||(M[4]=z=>c.value=z),ui:{content:"max-w-3xl z-50"}},{content:U(()=>[e("div",op,[e("div",np,[e("div",rp,[e("div",lp,[p(y,{name:"i-heroicons-funnel",class:"h-4.5 w-4.5 text-white"})]),e("h2",ip,o(a(s)("wordFilter.title")),1)]),p(f,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:M[0]||(M[0]=z=>c.value=!1)})]),e("div",cp,[e("div",dp,[e("div",up,[e("span",mp,o(a(s)("wordFilter.schemeList")),1),p(f,{icon:"i-heroicons-plus",size:"xs",variant:"ghost",color:"primary",onClick:S})]),e("div",gp,[(n(!0),i(ne,null,de(a(t).schemes,z=>(n(),i("div",{key:z.id,class:oe(["group mb-1 flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 transition-colors",r.value===z.id?"bg-primary-50 text-primary-700 dark:bg-primary-900/20 dark:text-primary-300":"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-white/5"]),onClick:$=>r.value=z.id},[z.id===a(t).defaultSchemeId?(n(),K(y,{key:0,name:"i-heroicons-star-solid",class:"h-3.5 w-3.5 shrink-0 text-amber-500"})):R("",!0),e("span",vp,o(z.name),1),e("span",hp,o(z.words.length),1)],10,pp))),128)),a(t).schemes.length===0?(n(),i("div",yp,o(a(s)("wordFilter.emptyScheme")),1)):R("",!0)])]),e("div",fp,[g.value?(n(),i(ne,{key:0},[e("div",xp,[e("div",null,[e("label",bp,o(a(s)("wordFilter.schemeName")),1),p(D,{ref_key:"nameInputRef",ref:d,modelValue:m.value,"onUpdate:modelValue":M[1]||(M[1]=z=>m.value=z),size:"sm",placeholder:a(s)("wordFilter.schemeNamePlaceholder"),onBlur:w,onKeydown:Xe(w,["enter"])},null,8,["modelValue","placeholder"])]),e("div",kp,[p(f,{size:"xs",variant:v.value?"solid":"soft",color:v.value?"warning":"neutral",icon:v.value?"i-heroicons-star-solid":"i-heroicons-star",onClick:q},{default:U(()=>[ee(o(v.value?a(s)("wordFilter.isDefault"):a(s)("wordFilter.setDefault")),1)]),_:1},8,["variant","color","icon"]),p(f,{size:"xs",variant:"soft",color:"error",icon:"i-heroicons-trash",onClick:b},{default:U(()=>[ee(o(a(s)("wordFilter.deleteScheme")),1)]),_:1})]),e("div",null,[e("label",_p,o(a(s)("wordFilter.addWords")),1),e("div",wp,[p(D,{modelValue:u.value,"onUpdate:modelValue":M[2]||(M[2]=z=>u.value=z),size:"sm",class:"flex-1",placeholder:a(s)("wordFilter.addWordsPlaceholder"),onKeydown:Xe(T,["enter"])},null,8,["modelValue","placeholder"]),p(f,{size:"sm",color:"primary",icon:"i-heroicons-plus",onClick:T},{default:U(()=>[ee(o(a(s)("wordFilter.add")),1)]),_:1})])]),e("div",null,[e("div",$p,[e("label",Cp,[ee(o(a(s)("wordFilter.wordList"))+" ",1),e("span",Sp,"("+o(g.value.words.length)+")",1)]),g.value.words.length>0?(n(),K(f,{key:0,size:"xs",variant:"ghost",color:"error",onClick:_},{default:U(()=>[ee(o(a(s)("wordFilter.clearAll")),1)]),_:1})):R("",!0)]),g.value.words.length>0?(n(),i("div",Tp,[(n(!0),i(ne,null,de(g.value.words,z=>(n(),K(A,{key:z,color:"neutral",variant:"subtle",class:"group/badge cursor-default gap-1 pr-1"},{default:U(()=>[ee(o(z)+" ",1),p(y,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5 cursor-pointer text-gray-400 transition-colors hover:text-red-500",onClick:$=>I(z)},null,8,["onClick"])]),_:2},1024))),128))])):(n(),i("div",Ip,o(a(s)("wordFilter.emptyWords")),1))])]),e("div",Mp,[p(f,{color:"primary",variant:"soft",onClick:M[3]||(M[3]=z=>c.value=!1)},{default:U(()=>[ee(o(a(s)("wordFilter.close")),1)]),_:1})])],64)):(n(),i("div",Lp,[p(y,{name:"i-heroicons-funnel",class:"h-10 w-10"}),e("p",Dp,o(a(s)("wordFilter.selectOrCreate")),1),p(f,{size:"sm",color:"primary",variant:"soft",icon:"i-heroicons-plus",onClick:S},{default:U(()=>[ee(o(a(s)("wordFilter.createScheme")),1)]),_:1})]))])])])]),_:1},8,["open"])}}}),qp={class:"main-content mx-auto max-w-[920px] space-y-6 p-6"},Rp={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"},Ep={class:"flex min-w-0 items-start gap-3"},zp={class:"min-w-0 text-sm text-primary-700 dark:text-primary-300"},Pp={class:"flex shrink-0 flex-wrap gap-2"},Bp={key:1,class:"space-y-6"},jp={class:"flex gap-6 p-4 sm:p-6"},Fp={class:"flex min-w-0 flex-1 flex-col"},Up={class:"relative w-full",style:{"aspect-ratio":"16 / 9"}},Vp={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"},Op={class:"text-xs font-medium"},Np={class:"px-4 text-center text-[11px]"},Hp={class:"mt-2 text-center text-xs text-gray-500 dark:text-gray-400"},Yp={class:"w-[280px] shrink-0 space-y-4"},Wp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Kp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Qp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Gp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Jp={class:"space-y-2"},Xp={class:"text-xs text-gray-400 dark:text-gray-500"},Zp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},ev={class:"flex items-center"},tv={key:0,class:"space-y-2"},av={class:"flex items-center justify-between"},sv={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},ov={class:"flex gap-1"},nv={class:"flex max-h-[360px] flex-wrap gap-1.5 overflow-y-auto"},rv={key:0,class:"ml-1 opacity-60"},lv={class:"mb-2 flex items-center justify-between"},iv={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},cv={key:0,class:"mt-1 text-xs text-gray-400 dark:text-gray-500"},dv={class:"space-y-4"},uv={class:"text-sm text-gray-600 dark:text-gray-300"},mv={class:"flex justify-end gap-2"},gv="default",oa="chatlab_zhTW_dict_prompt_dismissed",s1=he({__name:"WordcloudTab",props:{sessionId:{},timeFilter:{},memberId:{},showSharedTopics:{type:Boolean}},setup(l){const s=da(()=>Tt(()=>import("./EChartWordcloud-B_YisOW5.js"),__vite__mapDeps([5,6,7,8,1]))),{t}=ke(),c=Ct(),r=dt(),m=xa(),u=Je(),d=l,g=x(!1),v=x([]),h=x({totalMessages:0,totalWords:0,uniqueWords:0}),S=x(1.25),b=x(150),w=k(()=>{const me=v.value.slice(0,b.value),E=me.reduce((H,se)=>H+se.count,0);return{words:me.map(H=>({word:H.word,count:H.count,percentage:E>0?Math.round(H.count/E*1e4)/100:0}))}}),q=x("meaningful"),T=x(!0),I=x([]),_=x([]),C=x(new Map),M=["n","nr","ns","nt","nz","nw","vn","a","an"],y=x([]),f=k(()=>w.value.words.map(me=>({word:me.word,count:me.count,percentage:me.percentage??0}))),D=k(()=>[...C.value.entries()].map(([me,E])=>({tag:me,count:E}))),A=x(null),P=k({get:()=>m.getActiveSchemeId(d.sessionId),set:me=>m.setSessionScheme(d.sessionId,me)}),z=k(()=>[{label:t("wordFilter.noFilter"),value:"__none__"},...m.schemeOptions.map(me=>({label:me.isDefault?`${me.label} ★`:me.label,value:me.value}))]),$=k({get:()=>P.value??"__none__",set:me=>{P.value=me==="__none__"?null:me}}),L=k(()=>m.getExcludeWords(d.sessionId)),W=x("default"),ae=x([]),Y=x(!1),pe=x(null),ye=x(!1),Q=x(!1),V=k(()=>c.locale),te=k(()=>c.locale==="zh-TW"),xe=k(()=>V.value.startsWith("zh")),fe=k(()=>ae.value.filter(me=>me.downloaded).map(me=>({label:t(`quotes.wordcloud.dict.${me.id==="zh-CN"?"zhCN":me.id==="zh-TW"?"zhTW":me.id}`),value:me.id}))),X=k(()=>ae.value.some(me=>me.downloaded)),O=k(()=>!xe.value||Q.value),B=k(()=>ae.value.filter(me=>!me.downloaded));async function F(){try{ae.value=await Zt("/nlp/dicts"),te.value&&W.value==="default"&&ae.value.find(H=>H.id==="zh-TW")?.downloaded&&(W.value="zh-TW"),ae.value.find(E=>E.id==="zh-CN")?.downloaded&&W.value==="default"&&(W.value="zh-CN")}catch(me){console.error("Failed to get dict list:",me)}finally{Q.value=!0}}async function J(me){Y.value=!0,pe.value=me;try{const E=await ja(`/nlp/dicts/${me}/download`);E.success?(await F(),W.value=me,u.success(t("quotes.wordcloud.dict.downloadSuccess"))):u.fail(t("quotes.wordcloud.dict.downloadFailed"),{description:E.error})}catch{u.fail(t("quotes.wordcloud.dict.downloadFailed"))}finally{Y.value=!1,pe.value=null,ye.value=!1}}function ce(){ye.value=!1,localStorage.setItem(oa,"true")}function ve(){const me=ae.value.find(E=>E.id==="zh-TW");te.value&&me&&!me.downloaded&&!localStorage.getItem(oa)&&(ye.value=!0)}const G=k(()=>[{label:t("quotes.wordcloud.posFilter.all"),value:"all"},{label:t("quotes.wordcloud.posFilter.meaningful"),value:"meaningful"},{label:t("quotes.wordcloud.posFilter.custom"),value:"custom"}]),re=[{label:"80",value:80},{label:"100",value:100},{label:"150",value:150},{label:"200",value:200},{label:"300",value:300}],be=Math.max(...re.map(me=>me.value)),ue=k(()=>[{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}]),we=k(()=>_.value.map(me=>({label:me.name,tag:me.tag,value:me.tag,count:C.value.get(me.tag)||0,meaningful:me.meaningful})));async function Le(){try{const me=await Zt("/nlp/pos-tags");_.value=me,I.value=me.filter(E=>E.meaningful).map(E=>E.tag)}catch(me){console.error("加载词性标签失败:",me)}}let De=0;async function Te(){if(!d.sessionId||!O.value)return;const me=++De;try{const E=await wt("/nlp/word-frequency",{sessionId:d.sessionId,locale:V.value,timeFilter:d.timeFilter?{startTs:d.timeFilter.startTs,endTs:d.timeFilter.endTs}:void 0,memberId:A.value??void 0,topN:50,minCount:2,posFilterMode:"custom",customPosTags:[...M],enableStopwords:!0,dictType:W.value,excludeWords:L.value.length>0?[...L.value]:void 0});if(me!==De)return;y.value=E.words.map(H=>({word:H.word,count:H.count,percentage:H.percentage}))}catch(E){if(console.error("加载话题迷你词云数据失败:",E),me!==De)return;y.value=[]}}let ze=0;async function Pe(){if(!d.sessionId||!O.value)return;const me=++ze;v.value.length===0&&(g.value=!0);try{const E=await wt("/nlp/word-frequency",{sessionId:d.sessionId,locale:V.value,timeFilter:d.timeFilter?{startTs:d.timeFilter.startTs,endTs:d.timeFilter.endTs}:void 0,memberId:A.value??void 0,topN:be,minCount:2,posFilterMode:q.value,customPosTags:q.value==="custom"?[...I.value]:void 0,enableStopwords:T.value,dictType:W.value,excludeWords:L.value.length>0?[...L.value]:void 0});if(me!==ze)return;if(v.value=E.words.map(H=>({word:H.word,count:H.count,percentage:H.percentage})),h.value={totalMessages:E.totalMessages,totalWords:E.totalWords,uniqueWords:E.uniqueWords},E.posTagStats){const H=new Map;for(const se of E.posTagStats)H.set(se.tag,se.count);C.value=H}}catch(E){if(console.error("加载词频数据失败:",E),me!==ze)return;v.value=[]}finally{me===ze&&(g.value=!1)}}ge(()=>d.sessionId,()=>{A.value=null,v.value=[],y.value=[],h.value={totalMessages:0,totalWords:0,uniqueWords:0},C.value=new Map}),ge(()=>[d.sessionId,d.timeFilter,A.value,q.value,T.value,W.value,L.value,O.value],()=>{Pe()},{immediate:!0,deep:!0}),ge(()=>[d.sessionId,d.timeFilter,A.value,W.value,L.value,O.value],()=>{Te()},{immediate:!0,deep:!0}),ge(I,()=>{q.value==="custom"&&Pe()},{deep:!0}),ge(V,()=>{Pe()});function je(me){r.openChatRecordDrawer({keywords:[me]})}return Ee(async()=>{Le(),await F(),ve()}),(me,E)=>{const H=_e,se=Re,N=ma,j=Wt,ie=Oe;return n(),i("div",qp,[xe.value&&!X.value?(n(),i("div",Rp,[e("div",Ep,[p(H,{name:"i-heroicons-information-circle",class:"mt-0.5 shrink-0 text-xl text-primary-500"}),e("p",zp,o(a(t)("quotes.wordcloud.dict.needDownload")),1)]),e("div",Pp,[(n(!0),i(ne,null,de(ae.value,Z=>(n(),K(se,{key:Z.id,size:"sm",color:"primary",loading:Y.value&&pe.value===Z.id,disabled:Y.value&&pe.value!==Z.id,icon:"i-heroicons-arrow-down-tray",onClick:le=>J(Z.id)},{default:U(()=>[ee(o(a(t)(`quotes.wordcloud.dict.download_${Z.id}`,Z.label)),1)]),_:2},1032,["loading","disabled","onClick"]))),128))])])):R("",!0),O.value?(n(),i("div",Bp,[g.value&&f.value.length===0?(n(),K(a(mt),{key:0,text:a(t)("quotes.wordcloud.loading"),class:"py-8"},null,8,["text"])):R("",!0),p(Gg,{"total-messages":h.value.totalMessages,"total-words":h.value.totalWords,"unique-words":h.value.uniqueWords,"top-words":f.value,"topic-words":y.value,"pos-tag-stats":D.value,"time-filter":d.timeFilter,onWordClick:je},null,8,["total-messages","total-words","unique-words","top-words","topic-words","pos-tag-stats","time-filter"]),d.showSharedTopics?(n(),K(ap,{key:1,"session-id":d.sessionId,"time-filter":d.timeFilter,"dict-type":W.value,"exclude-words":L.value,onWordClick:je},null,8,["session-id","time-filter","dict-type","exclude-words"])):R("",!0),p(a(We),{title:a(t)("quotes.wordcloud.stats.wordsLabel"),"show-divider":!1},{default:U(()=>[e("div",jp,[e("div",Fp,[e("div",Up,[g.value?(n(),K(a(mt),{key:0,text:a(t)("quotes.wordcloud.loading"),class:"absolute inset-0 z-10 rounded-lg bg-white/80 dark:bg-gray-900/80"},null,8,["text"])):f.value.length===0?(n(),i("div",Vp,[p(H,{name:"i-heroicons-chat-bubble-bottom-center-text",class:"text-2xl"}),e("p",Op,o(a(t)("quotes.wordcloud.empty.title")),1),e("p",Np,o(a(t)("quotes.wordcloud.empty.description")),1)])):(n(),K(a(s),{key:2,data:w.value,height:"100%","max-words":b.value,"color-scheme":gv,"size-scale":S.value,loading:g.value,onWordClick:je},null,8,["data","max-words","size-scale","loading"]))]),e("p",Hp,o(a(t)("quotes.wordcloud.stats.clickHint")),1)]),e("div",Yp,[e("div",null,[e("h4",Wp,o(a(t)("quotes.wordcloud.config.maxWords")),1),p(a(et),{modelValue:b.value,"onUpdate:modelValue":E[0]||(E[0]=Z=>b.value=Z),size:"xs",items:re},null,8,["modelValue"])]),e("div",null,[e("h4",Kp,o(a(t)("quotes.wordcloud.config.sizeScale")),1),p(a(et),{modelValue:S.value,"onUpdate:modelValue":E[1]||(E[1]=Z=>S.value=Z),size:"xs",items:ue.value},null,8,["modelValue","items"])]),e("div",null,[e("h4",Qp,o(a(t)("quotes.wordcloud.config.userFilter")),1),p(sp,{modelValue:A.value,"onUpdate:modelValue":E[2]||(E[2]=Z=>A.value=Z),"session-id":d.sessionId,class:"w-full"},null,8,["modelValue","session-id"])]),e("div",null,[e("h4",Gp,o(a(t)("quotes.wordcloud.config.dict")),1),e("div",Jp,[fe.value.length>1?(n(),K(a(et),{key:0,modelValue:W.value,"onUpdate:modelValue":E[3]||(E[3]=Z=>W.value=Z),size:"xs",items:fe.value},null,8,["modelValue","items"])):R("",!0),(n(!0),i(ne,null,de(B.value,Z=>(n(),i("div",{key:Z.id,class:"flex items-center gap-2"},[p(se,{size:"xs",variant:"soft",color:"primary",loading:Y.value&&pe.value===Z.id,disabled:Y.value&&pe.value!==Z.id,icon:"i-heroicons-arrow-down-tray",onClick:le=>J(Z.id)},{default:U(()=>[ee(o(a(t)(`quotes.wordcloud.dict.download_${Z.id}`,a(t)("quotes.wordcloud.dict.download"))),1)]),_:2},1032,["loading","disabled","onClick"]),e("span",Xp,o(a(t)("quotes.wordcloud.dict.downloadHint")),1)]))),128))])]),e("div",null,[e("h4",Zp,o(a(t)("quotes.wordcloud.config.posFilter")),1),p(a(et),{modelValue:q.value,"onUpdate:modelValue":E[4]||(E[4]=Z=>q.value=Z),size:"xs",items:G.value},null,8,["modelValue","items"])]),e("div",ev,[p(N,{modelValue:T.value,"onUpdate:modelValue":E[5]||(E[5]=Z=>T.value=Z),label:a(t)("quotes.wordcloud.config.enableStopwords")},null,8,["modelValue","label"])]),q.value==="custom"?(n(),i("div",tv,[e("div",av,[e("h4",sv,o(a(t)("quotes.wordcloud.posFilter.customHint")),1),e("div",ov,[p(se,{size:"xs",variant:"ghost",color:"neutral",onClick:E[6]||(E[6]=Z=>I.value=_.value.filter(le=>le.meaningful).map(le=>le.tag))},{default:U(()=>[ee(o(a(t)("quotes.wordcloud.posFilter.selectMeaningful")),1)]),_:1}),p(se,{size:"xs",variant:"ghost",color:"neutral",onClick:E[7]||(E[7]=Z=>I.value=_.value.map(le=>le.tag))},{default:U(()=>[ee(o(a(t)("quotes.wordcloud.posFilter.selectAll")),1)]),_:1}),p(se,{size:"xs",variant:"ghost",color:"neutral",onClick:E[8]||(E[8]=Z=>I.value=[])},{default:U(()=>[ee(o(a(t)("quotes.wordcloud.posFilter.clearAll")),1)]),_:1})])]),e("div",nv,[(n(!0),i(ne,null,de(we.value,Z=>(n(),K(j,{key:Z.value,color:I.value.includes(Z.value)?"primary":"neutral",variant:I.value.includes(Z.value)?"solid":"outline",class:"cursor-pointer select-none transition-colors",onClick:()=>{I.value.includes(Z.value)?I.value=I.value.filter(le=>le!==Z.value):I.value=[...I.value,Z.value]}},{default:U(()=>[ee(o(Z.label)+" ",1),Z.count>0?(n(),i("span",rv,"("+o(Z.count)+")",1)):R("",!0)]),_:2},1032,["color","variant","onClick"]))),128))])])):R("",!0),e("div",null,[e("div",lv,[e("h4",iv,o(a(t)("wordFilter.filterScheme")),1),p(se,{size:"xs",variant:"ghost",color:"neutral",icon:"i-heroicons-cog-6-tooth","aria-label":a(t)("wordFilter.manage"),onClick:E[9]||(E[9]=Z=>a(m).openModal())},null,8,["aria-label"])]),p(a(et),{modelValue:$.value,"onUpdate:modelValue":E[10]||(E[10]=Z=>$.value=Z),size:"xs",items:z.value},null,8,["modelValue","items"]),L.value.length>0?(n(),i("p",cv,o(a(t)("wordFilter.activeCount",{count:L.value.length})),1)):R("",!0)])])])]),_:1},8,["title"])])):R("",!0),p(ie,{open:ye.value,"onUpdate:open":E[12]||(E[12]=Z=>ye.value=Z),title:a(t)("quotes.wordcloud.dict.promptTitle")},{body:U(()=>[e("div",dv,[e("p",uv,o(a(t)("quotes.wordcloud.dict.promptDescription")),1),e("div",mv,[p(se,{variant:"ghost",color:"neutral",onClick:ce},{default:U(()=>[ee(o(a(t)("quotes.wordcloud.dict.promptLater")),1)]),_:1}),p(se,{color:"primary",loading:Y.value,onClick:E[11]||(E[11]=Z=>J("zh-TW"))},{default:U(()=>[ee(o(a(t)("quotes.wordcloud.dict.promptDownload")),1)]),_:1},8,["loading"])])])]),_:1},8,["open","title"]),p(Ap)])}}}),pv={class:"flex h-full flex-col"},vv={class:"flex-1 min-h-0 overflow-hidden"},hv={key:1,class:"h-full overflow-auto"},yv={class:"main-content mx-auto max-w-3xl p-6"},fv=he({__name:"AITab",props:{sessionId:{},sessionName:{},timeFilter:{},chatType:{},mode:{}},setup(l,{expose:s}){const{t}=ke(),c=Qa(),r=l,m=k(()=>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=x(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=x(null);function g(){d.value?.refreshConfig()}return s({refreshAIConfig:g}),(v,h)=>(n(),i("div",pv,[p(a(ia),{modelValue:u.value,"onUpdate:modelValue":h[0]||(h[0]=S=>u.value=S),items:m.value,"persist-key":"aiTab"},null,8,["modelValue","items"]),e("div",vv,[p(rt,{name:"fade",mode:"out-in"},{default:U(()=>[u.value==="chat-explorer"?(n(),K(a(Vu),{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",hv,[e("div",yv,[p(a(_g),{"session-id":r.sessionId,"time-filter":r.timeFilter},null,8,["session-id","time-filter"])])])):(n(),K(Lm,{key:2,class:"h-full","session-id":r.sessionId,"chat-type":r.chatType},null,8,["session-id","chat-type"]))]),_:1})])]))}}),o1=st(fv,[["__scopeId","data-v-0df46b7b"]]),xv={class:"flex h-full items-center justify-center"},bv={class:"max-w-sm text-center"},kv={class:"mt-3 text-sm text-gray-400 dark:text-gray-500"},_v=["href"],n1=he({__name:"MemoryTab",props:{sessionId:{},sessionName:{}},setup(l){const{t:s,te:t}=ke(),c=k(()=>t("analysis.memory.joinLink")?s("analysis.memory.joinLink"):"");return(r,m)=>{const u=_e;return n(),i("div",xv,[e("div",bv,[p(u,{name:"i-heroicons-light-bulb",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),e("p",kv,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,_v)):R("",!0)])])}}}),wv={class:"flex h-full flex-col"},$v={class:"relative z-20 flex items-center gap-2 border-b border-gray-200 px-4 py-2 dark:border-gray-700"},Cv={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"},Sv={class:"flex-1 overflow-auto"},Tv={key:0,class:"flex h-full items-center justify-center"},Iv={class:"text-sm text-gray-400"},Mv={key:1,class:"w-full border-collapse text-xs"},Lv={class:"sticky top-0 bg-gray-50 dark:bg-gray-800"},Dv={class:"font-mono text-xs font-medium text-gray-700 dark:text-gray-300"},Av={class:"text-[10px] leading-tight text-gray-400"},qv={class:"border-b border-r border-gray-100 px-2 py-1.5 text-gray-400 dark:border-gray-800"},Rv=["title"],Ev=["onUpdate:modelValue"],zv={class:"w-full truncate px-2 py-1.5"},Pv={key:0,class:"italic text-gray-400"},Bv={key:1},jv={class:"border-b border-gray-100 px-2 py-1.5 text-center dark:border-gray-800"},Fv={key:0,class:"flex items-center justify-center gap-1"},Uv={key:1,class:"flex items-center justify-center gap-1"},Vv={class:"flex items-center justify-between border-t border-gray-200 px-4 py-2 dark:border-gray-700"},Ov={class:"text-xs text-gray-500 dark:text-gray-400"},Nv={key:0,class:"flex items-center gap-3"},Hv={class:"text-xs text-gray-500 dark:text-gray-400"},_t=100,Yv=he({__name:"TableBrowser",props:{sessionId:{}},setup(l){const s=["member","meta","message","message_context","member_name_history"],{t,locale:c}=ke(),r=l,m=x(localStorage.getItem("debug_dbSource")||"chat"),u=x([]),d=x(""),g=x(null),v=x(!1),h=x(null),S=x(1),b=x(0),w=k(()=>Math.max(1,Math.ceil(b.value/_t))),q=x(null),T=x({}),I=x(!1),_=k(()=>m.value==="ai"),C=x([]),M=x(""),y=k(()=>_.value&&d.value==="ai_message"&&C.value.length>0),f=k(()=>{const X={label:t("analysis.debug.tableBrowser.allConversations"),value:"__all__"},O=C.value.map(B=>({label:B.title||B.id.slice(0,16),value:B.id}));return[X,...O]});async function D(){if(!_.value){C.value=[];return}try{const X=r.sessionId.replace(/'/g,"''"),O=await Ne().executeAiSQL(`SELECT id, title FROM ai_chat WHERE session_id = '${X}' ORDER BY updated_at DESC`);C.value=O.rows.map(B=>({id:String(B[0]),title:B[1]?String(B[1]):null})),M.value="__all__"}catch{C.value=[]}}const A=k(()=>[{label:t("analysis.debug.tableBrowser.chatDb"),value:"chat"},{label:t("analysis.debug.tableBrowser.aiDb"),value:"ai"}]),P=k(()=>{const X=[...u.value];return X.sort((O,B)=>{const F=s.indexOf(O.name),J=s.indexOf(B.name);return F!==-1&&J!==-1?F-J:F!==-1?-1:J!==-1?1:0}),X}),z=k(()=>P.value.map(X=>({label:X.name,value:X.name})));async function $(X){return m.value==="ai"?await Ne().executeAiSQL(X):await Ue().executeSQL(r.sessionId,X)}async function L(){try{if(m.value==="ai"?u.value=await Ne().getAiSchema():u.value=await Ue().getSchema(r.sessionId),P.value.length>0){const X=_.value?"ai_message":P.value[0].name;d.value=P.value.some(O=>O.name===X)?X:P.value[0].name}else d.value="",g.value=null}catch(X){console.error("Failed to load schema:",X)}}function W(){if(!_.value)return"";const X=r.sessionId.replace(/'/g,"''"),O=d.value;return O==="ai_chat"?` WHERE "session_id" = '${X}'`:O==="ai_message"?M.value&&M.value!=="__all__"?` WHERE "ai_chat_id" = '${M.value.replace(/'/g,"''")}'`:` WHERE "ai_chat_id" IN (SELECT "id" FROM "ai_chat" WHERE "session_id" = '${X}')`:""}async function ae(){if(d.value){v.value=!0,h.value=null,q.value=null;try{const X=W(),O=await $(`SELECT COUNT(*) as cnt FROM "${d.value}"${X}`);b.value=O?.rows?.[0]?.[0]??0;const B=(S.value-1)*_t;g.value=await $(`SELECT * FROM "${d.value}"${X} ORDER BY rowid DESC LIMIT ${_t} OFFSET ${B}`)}catch(X){h.value=X.message||String(X),g.value=null}finally{v.value=!1}}}function Y(X){if(!g.value)return;q.value=X;const O=g.value.rows[X],B={};g.value.columns.forEach((F,J)=>{B[F]=O[J]==null?"":String(O[J])}),T.value=B}function pe(){q.value=null,T.value={}}async function ye(){if(q.value===null||!g.value)return;const X=d.value,O=u.value.find(re=>re.name===X);if(!O)return;const B=O.columns.find(re=>re.pk);if(!B){h.value="No primary key found for this table";return}const F=g.value.rows[q.value],J=g.value.columns.indexOf(B.name),ce=F[J],ve=g.value.columns.filter(re=>re!==B.name).map(re=>`"${re}" = '${T.value[re].replace(/'/g,"''")}'`).join(", "),G=`UPDATE "${X}" SET ${ve} WHERE "${B.name}" = '${String(ce).replace(/'/g,"''")}'`;try{await $(G),pe(),await ae()}catch(re){h.value=re.message||String(re)}}async function Q(X){if(!g.value)return;const O=d.value,B=u.value.find(re=>re.name===O);if(!B)return;const F=B.columns.find(re=>re.pk);if(!F){h.value="No primary key found for this table";return}const J=g.value.rows[X],ce=g.value.columns.indexOf(F.name),ve=J[ce],G=`DELETE FROM "${O}" WHERE "${F.name}" = '${String(ve).replace(/'/g,"''")}'`;try{await $(G),await ae()}catch(re){h.value=re.message||String(re)}}function V(X){confirm(t("analysis.debug.tableBrowser.confirmDelete"))&&Q(X)}async function te(){if(confirm(t("analysis.debug.tableBrowser.confirmClearDebug"))){I.value=!0;try{(await Ne().clearDebugContext()).success&&await ae()}catch(X){h.value=X.message||String(X)}finally{I.value=!1}}}function xe(X){navigator.clipboard.writeText(X)}function fe(X,O,B){if(!g.value)return[];const F=X==null?"NULL":String(X),J=g.value.rows[B],ce={};return g.value.columns.forEach((ve,G)=>{ce[ve]=J[G]}),[[{label:t("analysis.debug.tableBrowser.copyCell"),class:"p-2",onSelect:()=>xe(F)},{label:t("analysis.debug.tableBrowser.editRow"),class:"p-2",onSelect:()=>Y(B)},{label:t("analysis.debug.tableBrowser.copyRow"),class:"p-2",onSelect:()=>xe(JSON.stringify(ce,null,2))},{label:t("analysis.debug.tableBrowser.deleteRow"),class:"p-2 text-red-600 dark:text-red-400",onSelect:()=>Q(B)}]]}return ge(m,X=>{localStorage.setItem("debug_dbSource",X),d.value="",g.value=null,b.value=0,S.value=1,M.value="",L(),D()}),ge(d,X=>{X&&(S.value=1,ae())}),ge(M,()=>{d.value==="ai_message"&&(S.value=1,ae())}),ge(S,()=>{ae()}),Ee(async()=>{await Promise.all([L(),D()]),d.value&&await ae()}),(X,O)=>{const B=Kt,F=Re,J=ga;return n(),i("div",wv,[e("div",$v,[p(a(et),{modelValue:m.value,"onUpdate:modelValue":O[0]||(O[0]=ce=>m.value=ce),items:A.value,size:"xs"},null,8,["modelValue","items"]),O[5]||(O[5]=e("div",{class:"mx-1 h-4 w-px bg-gray-200 dark:bg-gray-700"},null,-1)),e("div",{class:oe([_.value?"max-w-[50%]":"flex-1","min-w-0"])},[p(a(et),{modelValue:d.value,"onUpdate:modelValue":O[1]||(O[1]=ce=>d.value=ce),items:z.value,size:"xs"},null,8,["modelValue","items"])],2),y.value?(n(),K(B,{key:0,modelValue:M.value,"onUpdate:modelValue":O[2]||(O[2]=ce=>M.value=ce),items:f.value,"value-key":"value",class:"w-48",size:"xs",ui:{content:"z-50"}},null,8,["modelValue","items"])):R("",!0),O[6]||(O[6]=e("div",{class:"flex-1"},null,-1)),_.value&&d.value==="ai_message"?(n(),K(F,{key:1,variant:"ghost",size:"xs",color:"error",icon:"i-heroicons-trash",loading:I.value,onClick:te},{default:U(()=>[ee(o(a(t)("analysis.debug.tableBrowser.clearDebugContext")),1)]),_:1},8,["loading"])):R("",!0),p(F,{variant:"ghost",size:"xs",icon:"i-heroicons-arrow-path",loading:v.value,onClick:ae},{default:U(()=>[ee(o(a(t)("analysis.debug.tableBrowser.refresh")),1)]),_:1},8,["loading"])]),h.value?(n(),i("div",Cv,o(h.value),1)):R("",!0),e("div",Sv,[!g.value&&!v.value?(n(),i("div",Tv,[e("p",Iv,o(a(t)("analysis.debug.tableBrowser.noData")),1)])):g.value?(n(),i("table",Mv,[e("thead",Lv,[e("tr",null,[O[7]||(O[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(ne,null,de(g.value.columns,ce=>(n(),i("th",{key:ce,class:"border-b border-r border-gray-200 px-2 py-1.5 text-left dark:border-gray-700"},[e("div",Dv,o(ce),1),e("div",Av,o(a(Xt)(d.value,ce,a(c))),1)]))),128)),O[8]||(O[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(ne,null,de(g.value.rows,(ce,ve)=>(n(),i("tr",{key:ve,class:"transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[e("td",qv,o((S.value-1)*_t+ve+1),1),(n(!0),i(ne,null,de(ce,(G,re)=>(n(),i("td",{key:re,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:G==null?"NULL":String(G)},[q.value===ve?He((n(),i("input",{key:0,"onUpdate:modelValue":be=>T.value[g.value.columns[re]]=be,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,Ev)),[[ot,T.value[g.value.columns[re]]]]):(n(),K(J,{key:1,items:fe(G,re,ve)},{default:U(()=>[e("div",zv,[G==null?(n(),i("span",Pv,"NULL")):(n(),i("span",Bv,o(String(G).slice(0,200)),1))])]),_:2},1032,["items"]))],8,Rv))),128)),e("td",jv,[q.value===ve?(n(),i("div",Fv,[p(F,{size:"xs",color:"primary",variant:"ghost",icon:"i-heroicons-check",onClick:ye}),p(F,{size:"xs",color:"neutral",variant:"ghost",icon:"i-heroicons-x-mark",onClick:pe})])):(n(),i("div",Uv,[p(F,{size:"xs",variant:"ghost",icon:"i-heroicons-pencil-square",onClick:G=>Y(ve)},null,8,["onClick"]),p(F,{size:"xs",variant:"ghost",color:"error",icon:"i-heroicons-trash",onClick:G=>V(ve)},null,8,["onClick"])]))])]))),128))])])):R("",!0)]),e("div",Vv,[e("span",Ov,o(b.value>0?a(t)("analysis.debug.tableBrowser.rowCount",{count:b.value}):""),1),w.value>1?(n(),i("div",Nv,[p(F,{size:"xs",variant:"ghost",disabled:S.value<=1,icon:"i-heroicons-chevron-left",onClick:O[3]||(O[3]=ce=>S.value--)},null,8,["disabled"]),e("span",Hv,o(a(t)("analysis.debug.tableBrowser.page",{current:S.value,total:w.value})),1),p(F,{size:"xs",variant:"ghost",disabled:S.value>=w.value,icon:"i-heroicons-chevron-right",onClick:O[4]||(O[4]=ce=>S.value++)},null,8,["disabled"])])):R("",!0)])])}}}),Wv={class:"flex h-full"},Kv={class:"w-56 shrink-0 overflow-y-auto border-r border-gray-200 bg-gray-50/50 dark:border-gray-700 dark:bg-gray-800/50"},Qv={key:0,class:"py-2"},Gv={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},Jv=["title","onClick"],Xv={class:"truncate text-xs font-medium"},Zv={class:"truncate text-[10px] opacity-50"},eh={key:1,class:"border-t border-gray-200 py-2 dark:border-gray-700"},th={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},ah=["title","onClick"],sh={class:"truncate text-xs font-medium"},oh={class:"truncate text-[10px] opacity-50"},nh={class:"flex flex-1 flex-col gap-4 overflow-y-auto p-4"},rh={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"},lh={class:"text-sm font-medium text-primary-700 dark:text-primary-300"},ih={class:"mt-1 text-xs text-primary-600/70 dark:text-primary-400/70"},ch={key:1,class:"flex flex-col gap-3"},dh={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},uh={class:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3"},mh={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},gh={key:0,class:"text-red-500"},ph={key:1,class:"ml-1 text-gray-400"},vh={key:2,class:"ml-1 text-gray-400"},hh={class:"flex items-center gap-3"},yh={key:3,class:"text-xs text-gray-500 dark:text-gray-400"},fh={key:2,class:"flex-1 min-h-0"},xh={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},bh={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"},kh={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"},_h={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"},wh=he({__name:"ToolTestTab",props:{sessionId:{}},setup(l){const{t:s}=ke(),t=l,c=x([]),r=x(""),m=x({}),u=x(!1),d=x(null),g=x(null),v=x(null),h=x(!1),S=x(null);function b(y){const f=`ai.assistant.builtinToolDesc.${y}`,D=s(f);return D!==f?D:y}const w=k(()=>c.value.filter(y=>y.category==="core")),q=k(()=>c.value.filter(y=>y.category==="analysis")),T=k(()=>c.value.find(y=>y.name===r.value)),I=k(()=>{const y=T.value;if(!y?.parameters)return[];const f=y.parameters;if(!f.properties)return[];const D=new Set(f.required??[]);return Object.entries(f.properties).map(([A,P])=>{const z={name:A,type:P.type??"string",description:P.description??"",required:D.has(A),defaultValue:P.default};if(P.enum&&(z.enumValues=P.enum),P.type==="array"){z.isArray=!0;const $=P.items;z.arrayItemType=$?.type??"string"}return z})});ge(r,()=>{m.value={},g.value=null,v.value=null,S.value=null}),Ee(async()=>{try{c.value=await Ne().getToolCatalog(),c.value.length>0&&(r.value=c.value[0].name)}catch(y){console.error("Failed to load tool catalog:",y)}});function _(){const y={};for(const f of I.value){const D=m.value[f.name];if(!(D===void 0||D===""))if(f.type==="number"){const A=Number(D);isNaN(A)||(y[f.name]=A)}else f.isArray?y[f.name]=D.split(",").map(A=>A.trim()).filter(Boolean):y[f.name]=D}return y}async function C(){if(!r.value||u.value)return;u.value=!0,g.value=null,v.value=null,h.value=!1,S.value=null;const y=`tool_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;d.value=y;try{const f=_(),D=await Ne().executeTool(y,r.value,f,t.sessionId);if(D.error==="cancelled")return;D.success?(S.value=D.elapsed??null,h.value=!!D.truncated,g.value=D.truncated?D.details?._preview??"":JSON.stringify(D.details??D.content,null,2)):v.value=D.error??"Unknown error"}catch(f){v.value=String(f)}finally{u.value=!1,d.value=null}}async function M(){d.value&&(await Ne().cancelToolTest(d.value),u.value=!1,d.value=null)}return(y,f)=>{const D=Kt,A=ht,P=Re,z=_e;return n(),i("div",Wv,[e("div",Kv,[w.value.length>0?(n(),i("div",Qv,[e("div",Gv,o(a(s)("ai.lab.toolTest.coreTools")),1),(n(!0),i(ne,null,de(w.value,$=>(n(),i("button",{key:$.name,class:oe(["flex w-full flex-col px-3 py-1.5 text-left transition-colors",[r.value===$.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:$.description,onClick:L=>r.value=$.name},[e("span",Xv,o(b($.name)),1),e("span",Zv,o($.name),1)],10,Jv))),128))])):R("",!0),q.value.length>0?(n(),i("div",eh,[e("div",th,o(a(s)("ai.lab.toolTest.analysisTools")),1),(n(!0),i(ne,null,de(q.value,$=>(n(),i("button",{key:$.name,class:oe(["flex w-full flex-col px-3 py-1.5 text-left transition-colors",[r.value===$.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:$.description,onClick:L=>r.value=$.name},[e("span",sh,o(b($.name)),1),e("span",oh,o($.name),1)],10,ah))),128))])):R("",!0)]),e("div",nh,[T.value?(n(),i("div",rh,[e("div",lh,o(b(T.value.name)),1),e("div",ih,o(T.value.description),1)])):R("",!0),I.value.length>0?(n(),i("div",ch,[e("h3",dh,o(a(s)("ai.lab.toolTest.parameters")),1),e("div",uh,[(n(!0),i(ne,null,de(I.value,$=>(n(),i("div",{key:$.name,class:"flex flex-col gap-1"},[e("label",mh,[ee(o($.name)+" ",1),$.required?(n(),i("span",gh,"*")):R("",!0),$.type==="number"?(n(),i("span",ph,"(number)")):R("",!0),$.isArray?(n(),i("span",vh,"("+o($.arrayItemType)+"[])",1)):R("",!0)]),$.enumValues?(n(),K(D,{key:0,modelValue:m.value[$.name],"onUpdate:modelValue":L=>m.value[$.name]=L,items:$.enumValues,placeholder:$.description,size:"sm"},null,8,["modelValue","onUpdate:modelValue","items","placeholder"])):(n(),K(A,{key:1,modelValue:m.value[$.name],"onUpdate:modelValue":L=>m.value[$.name]=L,placeholder:$.isArray?a(s)("ai.lab.toolTest.arrayPlaceholder"):$.defaultValue!==void 0?String($.defaultValue):$.description,type:$.type==="number"?"number":"text",size:"sm"},null,8,["modelValue","onUpdate:modelValue","placeholder","type"]))]))),128))])])):R("",!0),e("div",hh,[u.value?(n(),K(P,{key:1,color:"error",icon:"i-heroicons-stop",onClick:M},{default:U(()=>[ee(o(a(s)("ai.lab.toolTest.cancel")),1)]),_:1})):(n(),K(P,{key:0,color:"primary",disabled:!r.value,icon:"i-heroicons-play",onClick:C},{default:U(()=>[ee(o(a(s)("ai.lab.toolTest.execute")),1)]),_:1},8,["disabled"])),u.value?(n(),K(z,{key:2,name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin text-gray-400"})):R("",!0),S.value!==null?(n(),i("span",yh,o(a(s)("ai.lab.toolTest.elapsed",{ms:S.value})),1)):R("",!0)]),g.value||v.value?(n(),i("div",fh,[e("h3",xh,o(a(s)("ai.lab.toolTest.result")),1),v.value?(n(),i("div",bh,o(v.value),1)):(n(),i(ne,{key:1},[h.value?(n(),i("div",kh,o(a(s)("ai.lab.toolTest.truncated")),1)):R("",!0),e("pre",_h,o(g.value),1)],64))])):R("",!0)])])}}}),$h={class:"flex h-full flex-col"},Ch={class:"min-h-0 flex-1 overflow-hidden"},Sh=he({__name:"DebugTab",props:{sessionId:{}},setup(l){const{t:s}=ke(),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=x("sql-tables");return(m,u)=>(n(),i("div",$h,[p(a(ia),{modelValue:r.value,"onUpdate:modelValue":u[0]||(u[0]=d=>r.value=d),items:c,"persist-key":"debugTab"},null,8,["modelValue"]),e("div",Ch,[p(rt,{name:"fade",mode:"out-in"},{default:U(()=>[r.value==="sql-tables"?(n(),K(Yv,{key:0,class:"h-full","session-id":t.sessionId},null,8,["session-id"])):r.value==="basic-tools"?(n(),K(wh,{key:1,class:"h-full","session-id":t.sessionId},null,8,["session-id"])):R("",!0)]),_:1})])]))}}),r1=st(Sh,[["__scopeId","data-v-d712cb76"]]);var Me=(l=>(l[l.TEXT=0]="TEXT",l[l.IMAGE=1]="IMAGE",l[l.VOICE=2]="VOICE",l[l.VIDEO=3]="VIDEO",l[l.FILE=4]="FILE",l[l.EMOJI=5]="EMOJI",l[l.LINK=7]="LINK",l[l.LOCATION=8]="LOCATION",l[l.RED_PACKET=20]="RED_PACKET",l[l.TRANSFER=21]="TRANSFER",l[l.POKE=22]="POKE",l[l.CALL=23]="CALL",l[l.SHARE=24]="SHARE",l[l.REPLY=25]="REPLY",l[l.FORWARD=26]="FORWARD",l[l.CONTACT=27]="CONTACT",l[l.SYSTEM=80]="SYSTEM",l[l.RECALL=81]="RECALL",l[l.OTHER=99]="OTHER",l))(Me||{});const Th={[Me.TEXT]:"text",[Me.IMAGE]:"image",[Me.VOICE]:"voice",[Me.VIDEO]:"video",[Me.FILE]:"file",[Me.EMOJI]:"emoji",[Me.LINK]:"link",[Me.LOCATION]:"location",[Me.RED_PACKET]:"redPacket",[Me.TRANSFER]:"transfer",[Me.POKE]:"poke",[Me.CALL]:"call",[Me.SHARE]:"share",[Me.REPLY]:"reply",[Me.FORWARD]:"forward",[Me.CONTACT]:"contact",[Me.SYSTEM]:"system",[Me.RECALL]:"recall",[Me.OTHER]:"other"};function Ht(l,s){const t=Th[l];return s&&t?s(`common.messageType.${t}`):s?s("common.messageType.unknown"):"未知"}function l1(l){const s=k(()=>Ya(l)),t=k(()=>{const r=s.value;return r.length<2?!1:new Set(r.map(u=>$e(u.date).year())).size>1}),c=k(()=>{const r=s.value,m=50;if(r.length<=m){const v=t.value?"YYYY/MM/DD":"MM/DD";return{labels:r.map(h=>$e(h.date).format(v)),values:r.map(h=>h.messageCount)}}const u=Math.ceil(r.length/m),d=[],g=[];for(let v=0;v<r.length;v+=u){const h=r.slice(v,v+u);if(h.length===0)continue;const S=Math.floor(h.length/2),b=h[S].date,w=t.value?"YYYY/MM/DD":"MM/DD";d.push($e(b).format(w));const q=h.reduce((I,_)=>I+_.messageCount,0),T=Math.round(q/h.length);g.push(T)}return{labels:d,values:g}});return{isMultiYear:t,dailyChartData:c}}function Ih(l,s){const{t}=ke(),c=k(()=>l.selectedYear?l.selectedYear%4===0&&l.selectedYear%100!==0||l.selectedYear%400===0?366:365:l.timeRange?Math.ceil((l.timeRange.end-l.timeRange.start)/86400):0),r=k(()=>l.selectedYear?l.filteredMessageCount:l.session.messageCount),m=k(()=>l.selectedYear?l.filteredMemberCount??l.session.memberCount:l.session.memberCount),u=k(()=>l.timeRange?Math.ceil((l.timeRange.end-l.timeRange.start)/86400):0),d=k(()=>u.value===0?0:Math.round(l.session.messageCount/u.value)),g=k(()=>c.value===0?0:Math.round(r.value/c.value)),v=k(()=>l.messageTypes.find(f=>f.type===1)?.count||0),h=k(()=>l.hourlyActivity.length?l.hourlyActivity.reduce((y,f)=>f.messageCount>y.messageCount?f:y,l.hourlyActivity[0]):null),S=k(()=>s.value.length?s.value.reduce((y,f)=>f.messageCount>y.messageCount?f:y,s.value[0]):null),b=k(()=>[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")]),w=k(()=>{if(!s.value.length)return{weekday:0,weekend:0};const y=s.value.filter(A=>A.weekday>=1&&A.weekday<=5).reduce((A,P)=>A+P.messageCount,0),f=s.value.filter(A=>A.weekday>=6&&A.weekday<=7).reduce((A,P)=>A+P.messageCount,0),D=y+f;return{weekday:D>0?Math.round(y/D*100):0,weekend:D>0?Math.round(f/D*100):0}}),q=k(()=>l.dailyActivity.length?l.dailyActivity.reduce((y,f)=>f.messageCount>y.messageCount?f:y,l.dailyActivity[0]):null),T=k(()=>l.dailyActivity.filter(y=>y.messageCount>0).length),I=k(()=>{if(!l.timeRange)return 0;const y=$e.unix(l.timeRange.start);return $e.unix(l.timeRange.end).diff(y,"day")+1}),_=k(()=>I.value>0?Math.round(T.value/I.value*100):0),C=k(()=>{if(!l.hourlyActivity.length)return{count:0,ratio:0};const y=l.hourlyActivity.reduce((D,A)=>D+A.messageCount,0),f=l.hourlyActivity.filter(D=>D.hour>=0&&D.hour<=4).reduce((D,A)=>D+A.messageCount,0);return{count:f,ratio:y>0?Math.round(f/y*100):0}}),M=k(()=>{if(!l.dailyActivity.length)return 0;const y=[...l.dailyActivity].filter(A=>A.messageCount>0).sort((A,P)=>$e(A.date).valueOf()-$e(P.date).valueOf());if(y.length===0)return 0;let f=1,D=1;for(let A=1;A<y.length;A++){const P=$e(y[A-1].date);$e(y[A].date).diff(P,"day")===1?D++:(D>f&&(f=D),D=1)}return D>f&&(f=D),f});return{durationDays:c,displayMessageCount:r,displayMemberCount:m,dailyAvgMessages:g,totalDurationDays:u,totalDailyAvgMessages:d,imageCount:v,peakHour:h,peakWeekday:S,weekdayNames:b,weekdayVsWeekend:w,peakDay:q,activeDays:T,totalDays:I,activeRate:_,lateNightChat:C,maxConsecutiveDays:M}}const Mh={key:0,class:"relative z-10 px-6 pb-6 pt-2 sm:px-8"},Lh={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Dh={class:"min-w-0"},Ah={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},qh={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Rh={key:1,class:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4"},Eh={class:"text-sm text-gray-500"},zh={class:"text-sm text-gray-500"},Ph={class:"ml-1 font-semibold text-pink-500"},Bh={class:"text-sm text-gray-500"},jh={class:"text-sm text-gray-500"},Fh={class:"text-sm text-gray-500"},Uh={class:"text-sm text-gray-500"},Vh={class:"text-sm text-gray-500"},Oh={class:"text-sm text-gray-500"},Nh=he({__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}=ke(),t=l,c=k(()=>[{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?$e(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,m)=>{const u=_e;return l.flat?(n(),i("div",Mh,[m[0]||(m[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",Lh,[(n(!0),i(ne,null,de(c.value,d=>(n(),i("div",{key:d.icon+d.label,class:"flex items-start gap-2 rounded-lg bg-white/60 p-2.5 ring-1 ring-gray-900/5 dark:bg-white/5 dark:ring-white/10"},[p(u,{name:d.icon,class:oe(["mt-0.5 h-3.5 w-3.5 shrink-0",d.colorClass])},null,8,["name","class"]),e("div",Dh,[e("div",{class:oe(["truncate font-mono text-sm font-black leading-tight tabular-nums",d.colorClass])},o(d.value),3),e("div",Ah,o(d.label),1),e("div",qh,o(d.subtext),1)])]))),128))])])):(n(),i("div",Rh,[p(a(Ze),{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:U(()=>[e("span",Eh,o(a(s)("analysis.overview.statCards.daysCount",{count:l.durationDays})),1)]),_:1},8,["label","value"]),p(a(Ze),{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:U(()=>[e("span",zh,o(a(s)("analysis.overview.statCards.peakHour")),1),e("span",Ph,o(l.peakHour?.hour||0)+":00",1)]),_:1},8,["label","value"]),p(a(Ze),{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:U(()=>[e("span",Bh,o(a(s)("analysis.overview.statCards.messagesOnDay",{count:l.peakWeekday?.messageCount??0})),1)]),_:1},8,["label","value"]),p(a(Ze),{label:a(s)("analysis.overview.statCards.weekendActivity"),value:`${l.weekdayVsWeekend.weekend}%`,icon:"i-heroicons-sun","icon-bg":"green"},{subtext:U(()=>[e("span",jh,o(a(s)("analysis.overview.statCards.weekendRatio")),1)]),_:1},8,["label","value"]),p(a(Ze),{label:a(s)("analysis.overview.statCards.mostActiveDate"),value:l.peakDay?a($e)(l.peakDay.date).format("MM/DD"):"-",icon:"i-heroicons-fire","icon-bg":"red"},{subtext:U(()=>[e("span",Fh,o(a(s)("analysis.overview.statCards.messagesOnDay",{count:l.peakDay?.messageCount??0})),1)]),_:1},8,["label","value"]),p(a(Ze),{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:U(()=>[e("span",Uh,o(a(s)("analysis.overview.statCards.lateNightRatio",{ratio:l.lateNightRatio})),1)]),_:1},8,["label","value"]),p(a(Ze),{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:U(()=>[e("span",Vh,o(a(s)("analysis.overview.statCards.longestStreak")),1)]),_:1},8,["label","value"]),p(a(Ze),{label:a(s)("analysis.overview.statCards.activityRate"),value:`${l.activeRate}%`,icon:"i-heroicons-chart-bar","icon-bg":"gray"},{subtext:U(()=>[e("span",Oh,o(a(s)("analysis.overview.statCards.activeDaysRatio")),1)]),_:1},8,["label","value"])]))}}}),Hh={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Yh={class:"text-3xl font-bold tracking-tight text-gray-900 dark:text-gray-100"},Wh={class:"mt-4 flex items-start gap-6 sm:gap-24"},Kh={class:"min-w-0 flex flex-col gap-2 text-sm font-medium text-gray-500 dark:text-gray-400"},Qh={class:"flex items-center gap-2"},Gh={class:"flex h-6 w-6 shrink-0 items-center justify-center"},Jh={class:"whitespace-nowrap"},Xh={key:0,class:"flex items-center gap-2"},Zh={class:"flex h-6 w-6 shrink-0 items-center justify-center"},ey={class:"font-mono text-xs opacity-90 whitespace-nowrap"},ty={class:"flex shrink-0 gap-6"},ay={class:"flex flex-col gap-1 text-center"},sy={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},oy={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},ny={class:"flex flex-col gap-1 text-center"},ry={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},ly={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},iy={class:"flex flex-col gap-1 text-center"},cy={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},dy={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},uy={class:"flex flex-col gap-1 text-center"},my={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},gy={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},py={class:"relative z-10 px-6 pb-2 sm:px-8"},vy={class:"overflow-x-auto overflow-y-hidden scrollbar-hide py-1"},i1=he({__name:"OverviewIdentityCard",props:{session:{},dailyActivity:{},messageTypes:{},hourlyActivity:{},timeRange:{},selectedYear:{},filteredMessageCount:{},timeFilter:{}},setup(l){yt([Gt,ss,ya,Mt,Jt,ft]);const{t:s,locale:t}=ke(),c=pt(),r=l,m=x([]);async function u(){if(r.session.id)try{m.value=await Ue().getWeekdayActivity(r.session.id,r.timeFilter)}catch(Q){console.error("加载星期活跃度失败:",Q)}}ge(()=>[r.session.id,r.timeFilter],()=>u(),{immediate:!0,deep:!0});const{durationDays:d,displayMessageCount:g,dailyAvgMessages:v,imageCount:h,peakHour:S,peakWeekday:b,weekdayNames:w,weekdayVsWeekend:q,peakDay:T,activeDays:I,totalDays:_,activeRate:C,lateNightChat:M,maxConsecutiveDays:y}=Ih(r,m),f=x(null);let D=null;const A=k(()=>r.timeRange?Bt(r.timeRange.start,r.timeRange.end,"YYYY/MM/DD"):""),P=k(()=>{const Q=new Date,V=new Date(Q);V.setFullYear(V.getFullYear()-1),V.setDate(V.getDate()+1);const te=xe=>xe.toISOString().slice(0,10);return[te(V),te(Q)]}),z=k(()=>{const[Q,V]=P.value,te=new Date(Q+"T00:00:00Z"),xe=new Date(V+"T00:00:00Z"),fe=new Map;r.dailyActivity.filter(B=>B.date>=Q&&B.date<=V).forEach(B=>fe.set(B.date,B.messageCount));const X=[],O=new Date(te);for(;O<=xe;){const B=O.toISOString().slice(0,10),F=fe.get(B)||0;X.push({value:[B,F],itemStyle:F===0?{color:W.value}:void 0}),O.setUTCDate(O.getUTCDate()+1)}return X}),$=k(()=>r.dailyActivity.length===0?10:Math.max(...r.dailyActivity.map(Q=>Q.messageCount),1)),L={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)"]},W=k(()=>c.value?"rgba(255, 255, 255, 0.04)":"#ebedf0"),ae=k(()=>({tooltip:{trigger:"item",formatter:Q=>{const V=Q.value[0],te=Q.value[1];return`${V}<br/>${s("views.message.calendarTooltipMessages")}: ${te}`}},visualMap:{min:1,max:$.value,calculable:!1,orient:"horizontal",left:"center",bottom:0,itemWidth:10,itemHeight:80,text:[`${$.value}`,"1"],inRange:{color:c.value?L.dark:L.light},textStyle:{color:c.value?"#8b949e":"#6b7280",fontSize:10},show:!0},calendar:{top:20,left:30,cellSize:[13,13],range:P.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:z.value,renderItem:(Q,V)=>{const te=V.coord(V.value(0)),xe=Q.coordSys.cellWidth,fe=Q.coordSys.cellHeight,X=Math.min(xe,fe)-3;return{type:"rect",shape:{x:te[0]-X/2,y:te[1]-X/2,width:X,height:X,r:3},style:{fill:V.visual("color")}}},itemStyle:{borderColor:c.value?"transparent":"rgba(0,0,0,0.02)",borderWidth:1}}]}));function Y(){f.value&&(D=xt(f.value,void 0,{renderer:"canvas"}),D.setOption({backgroundColor:"transparent",...ae.value}))}function pe(){D&&D.setOption({backgroundColor:"transparent",...ae.value},{notMerge:!0})}function ye(){D?.resize()}return ge([()=>r.dailyActivity,t],()=>pe()),ge(c,()=>{D?.dispose(),Y()}),Ee(()=>{Y(),window.addEventListener("resize",ye)}),lt(()=>{window.removeEventListener("resize",ye),D?.dispose()}),(Q,V)=>{const te=_e;return n(),K(a(it),{variant:"elevated",decorative:"",class:"flex flex-col"},{default:U(()=>[e("div",Hh,[e("h2",Yh,o(l.session.name),1),e("div",Wh,[e("div",Kh,[e("div",Qh,[e("div",Gh,[l.session.type==="group"?(n(),K(te,{key:0,name:"i-heroicons-user-group",class:"h-4 w-4 opacity-70"})):(n(),K(te,{key:1,name:"i-heroicons-user",class:"h-4 w-4 opacity-70"}))]),e("span",Jh,o(l.session.platform.toUpperCase())+" · "+o(l.session.type==="private"?a(s)("analysis.overview.identity.privateChat"):a(s)("analysis.overview.identity.groupChat")),1)]),A.value?(n(),i("div",Xh,[e("div",Zh,[p(te,{name:"i-heroicons-calendar",class:"h-4 w-4 opacity-70"})]),e("span",ey,o(A.value),1)])):R("",!0)]),e("div",ty,[e("div",ay,[e("span",sy,o(a(g).toLocaleString()),1),e("span",oy,o(a(s)("analysis.overview.identity.totalMessages")),1)]),e("div",ny,[e("span",ry,o(a(d).toLocaleString()),1),e("span",ly,o(a(s)("analysis.overview.identity.durationDays")),1)]),e("div",iy,[e("span",cy,o(a(I).toLocaleString()),1),e("span",dy,o(a(s)("analysis.overview.identity.activeDays")),1)]),e("div",uy,[e("span",my,o(a(v).toLocaleString()),1),e("span",gy,o(a(s)("analysis.overview.identity.dailyAvgMessages")),1)])])])]),e("div",py,[V[0]||(V[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",vy,[e("div",{ref_key:"chartRef",ref:f,class:"h-[140px] min-w-[700px] lg:w-full"},null,512)])]),p(Nh,{flat:"","daily-avg-messages":a(v),"duration-days":a(d),"image-count":a(h),"peak-hour":a(S),"peak-weekday":a(b),"weekday-names":a(w),"weekday-vs-weekend":a(q),"peak-day":a(T),"active-days":a(I),"total-days":a(_),"active-rate":a(C),"late-night-count":a(M).count,"late-night-ratio":a(M).ratio,"max-consecutive-days":a(y)},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})}}}),hy={class:"p-5"},c1=he({__name:"DailyTrendCard",props:{dailyActivity:{},dailyChartData:{}},setup(l){const{t:s}=ke();return(t,c)=>l.dailyActivity.length>0?(n(),K(a(We),{key:0,title:a(s)("analysis.overview.dailyTrend.title"),"show-divider":!1},{default:U(()=>[e("div",hy,[p(a(Ut),{data:l.dailyChartData,height:288},null,8,["data"])])]),_:1},8,["title"])):R("",!0)}}),yy={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},fy={class:"flex items-center gap-6 sm:gap-10"},xy={class:"min-w-0 flex-1"},by={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},ky={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},_y={class:"mb-4 flex min-w-0 flex-wrap items-baseline gap-2"},wy={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},$y={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Cy={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Sy={key:1,class:"flex min-w-0 max-w-full flex-wrap items-center gap-x-1.5 gap-y-1.5"},Ty={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Iy={class:"font-bold tabular-nums text-pink-500 dark:text-pink-400"},My={class:"flex shrink-0 flex-col items-center"},Ly={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},Dy={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Ay={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},qy={class:"min-w-0 flex-1"},Ry={class:"flex items-center justify-between gap-1"},Ey={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},zy={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Py={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"},By={class:"flex items-center gap-1.5"},jy={class:"text-[9px] font-medium uppercase tracking-widest"},Fy=he({__name:"TypeProfileCard",props:{sessionId:{},messageTypes:{},textStats:{},timeFilter:{}},setup(l){yt([pa,Mt,ft]);const{t:s}=ke(),t=pt(),c=l,r=k(()=>c.messageTypes.reduce(($,L)=>$+L.count,0)),m=k(()=>c.messageTypes.find($=>$.type===Me.TEXT)?.count??0),u=k(()=>{if(r.value===0)return 0;const $=r.value-m.value;return Math.round($/r.value*100)}),d=k(()=>c.textStats.textCount===0?0:Math.round(c.textStats.shortCount/c.textStats.textCount*100)),g=x({first:"",last:""});async function v(){if(c.sessionId)try{const $=await Ue().getDailyActivity(c.sessionId,c.timeFilter);if($.length>0){const L=[...$].sort((W,ae)=>W.date.localeCompare(ae.date));g.value={first:$e(L[0].date).format("YYYY/MM/DD"),last:$e(L[L.length-1].date).format("YYYY/MM/DD")}}}catch{}}function h($){return c.messageTypes.find(L=>L.type===$)?.count??0}const S=k(()=>[{label:s("views.message.typeCard.nonTextImage"),count:h(Me.IMAGE),unit:s("views.message.typeCard.unitImage")},{label:s("views.message.typeCard.nonTextEmoji"),count:h(Me.EMOJI),unit:s("views.message.typeCard.unitEmoji")},{label:s("views.message.typeCard.nonTextVoice"),count:h(Me.VOICE),unit:s("views.message.typeCard.unitVoice")},{label:s("views.message.typeCard.nonTextVideo"),count:h(Me.VIDEO),unit:s("views.message.typeCard.unitVideo")},{label:s("views.message.typeCard.nonTextFile"),count:h(Me.FILE),unit:s("views.message.typeCard.unitFile")},{label:s("views.message.typeCard.nonTextLink"),count:h(Me.LINK),unit:s("views.message.typeCard.unitLink")}].filter($=>$.count>0)),b=x(30),w=x(0),q=x(!1),T=[{label:"20",value:20},{label:"30",value:30},{label:"50",value:50},{label:"80",value:80},{label:"100",value:100}],I=k({get:()=>b.value,set:$=>{b.value!==$&&(b.value=$,_())}});async function _(){if(c.sessionId){q.value=!0;try{w.value=await Ue().getLongMessageCount(c.sessionId,c.timeFilter,b.value)}catch($){console.error("[chart-message] Failed to load essay count:",$)}finally{q.value=!1}}}ge(()=>[c.sessionId,c.timeFilter],()=>{_(),v()},{immediate:!0,deep:!0});const C=k(()=>[{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:w.value.toLocaleString(),subtext:s("views.message.profile.essayLoverDesc",{threshold:b.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:S.value.slice(0,3).map($=>`${$.label} ${$.count}`).join(" · ")||"-",colorClass:"text-pink-600 dark:text-pink-400"}]),M=x(null);let y=null;const f=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],D=k(()=>[...c.messageTypes].sort((L,W)=>W.count-L.count).slice(0,8).map((L,W)=>({name:Ht(L.type,s),value:L.count,itemStyle:{color:f[W%f.length]}})));function A(){M.value&&(y=xt(M.value,void 0,{renderer:"canvas"}),P())}function P(){y&&y.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:D.value}]},{notMerge:!0})}function z(){y?.resize()}return ge(()=>c.messageTypes,()=>P()),ge(t,()=>{y?.dispose(),A()}),Ee(()=>{A(),window.addEventListener("resize",z)}),lt(()=>{window.removeEventListener("resize",z),y?.dispose()}),($,L)=>{const W=_e,ae=It;return n(),K(a(it),{variant:"elevated",decorative:"",class:"flex flex-col"},{default:U(()=>[e("div",yy,[e("div",fy,[e("div",xy,[e("div",by,[g.value.first?(n(),i("p",ky,o(g.value.first)+" – "+o(g.value.last),1)):R("",!0),e("div",_y,[e("span",wy,o(a(s)("views.message.profile.heroLine1Prefix")),1),e("span",$y,o(r.value.toLocaleString()),1),e("span",Cy,o(a(s)("views.message.profile.heroLine1Suffix")),1)]),S.value.length>0?(n(),i("div",Sy,[e("span",Ty,o(a(s)("views.message.typeCard.nonTextPrefix")),1),(n(!0),i(ne,null,de(S.value,Y=>(n(),i("span",{key:Y.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",Iy,o(Y.count.toLocaleString()),1),e("span",null,o(Y.unit),1)]))),128))])):R("",!0)])]),e("div",My,[e("div",Ly,o(a(s)("views.message.profile.typeDistribution")),1),e("div",{ref_key:"donutRef",ref:M,style:{width:"130px",height:"130px"}},null,512)])])]),e("div",Dy,[L[1]||(L[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",Ay,[(n(!0),i(ne,null,de(C.value,Y=>(n(),i("div",{key:Y.icon+Y.label,class:"flex items-start gap-2 rounded-lg bg-white/60 p-2.5 ring-1 ring-gray-900/5 dark:bg-white/5 dark:ring-white/10"},[p(W,{name:Y.icon,class:oe(["mt-0.5 h-3.5 w-3.5 shrink-0",Y.colorClass])},null,8,["name","class"]),e("div",qy,[e("div",Ry,[e("div",{class:oe(["truncate font-mono text-sm font-black leading-tight tabular-nums",Y.colorClass])},o(Y.value),3),Y.slot==="essay-threshold"?(n(),K(ae,{key:0,modelValue:I.value,"onUpdate:modelValue":L[0]||(L[0]=pe=>I.value=pe),items:T,"value-key":"value",size:"xs",class:"relative z-120 w-16 shrink-0",ui:{content:"z-[121]"},disabled:q.value},null,8,["modelValue","disabled"])):R("",!0)]),e("div",Ey,o(Y.label),1),e("div",zy,o(Y.subtext),1)])]))),128))])]),e("div",Py,[e("div",By,[p(W,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),L[2]||(L[2]=e("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),e("span",jy,o(a(s)("views.message.typeCard.watermark")),1)])]),_:1})}}}),Uy={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-6"},Vy={class:"p-5"},Oy={key:0,class:"grid grid-cols-1 gap-6 lg:grid-cols-2 lg:items-center"},Ny={class:"space-y-3"},Hy={class:"min-w-20 shrink-0 text-sm text-gray-700 dark:text-gray-300"},Yy={class:"flex-1"},Wy={class:"h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800"},Ky={class:"shrink-0 text-right"},Qy={class:"text-sm font-medium text-gray-900 dark:text-white"},Gy={class:"ml-1 text-xs text-gray-400"},Jy={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Xy={class:"p-5"},Zy={class:"mb-5 grid grid-cols-2 gap-3 sm:grid-cols-4"},ef={class:"rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50"},tf={class:"font-mono text-xl font-bold text-gray-900 dark:text-white"},af={class:"mt-1 text-xs text-gray-500"},sf={class:"rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50"},of={class:"font-mono text-xl font-bold text-indigo-600 dark:text-indigo-400"},nf={class:"mt-1 text-xs text-gray-500"},rf={class:"rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50"},lf={class:"font-mono text-xl font-bold text-pink-600 dark:text-pink-400"},cf={class:"mt-1 text-xs text-gray-500"},df={class:"rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50"},uf={class:"font-mono text-xl font-bold text-emerald-600 dark:text-emerald-400"},mf={class:"mt-1 text-xs text-gray-500"},gf={class:"mb-5 rounded-lg border border-gray-200 p-4 dark:border-gray-700"},pf={class:"mb-2 text-xs font-medium text-gray-500 dark:text-gray-400"},vf={class:"flex items-center gap-4 text-sm"},hf={class:"flex items-center gap-1.5"},yf={class:"font-mono font-medium text-gray-900 dark:text-white"},ff={class:"flex items-center gap-1.5"},xf={class:"font-mono font-medium text-gray-900 dark:text-white"},bf={class:"flex items-center gap-1.5"},kf={class:"font-mono font-medium text-gray-900 dark:text-white"},_f={class:"flex items-center gap-1.5"},wf={class:"font-mono font-medium text-gray-900 dark:text-white"},$f={class:"mt-3 grid grid-cols-3 gap-3 text-xs"},Cf={class:"text-gray-500"},Sf={class:"ml-1 font-medium text-emerald-600 dark:text-emerald-400"},Tf={class:"text-gray-400"},If={class:"text-gray-500"},Mf={class:"ml-1 font-medium text-indigo-600 dark:text-indigo-400"},Lf={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},Df={class:"text-xs text-gray-400"},Af={class:"p-5"},qf={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Rf={class:"text-xs text-gray-400"},Ef={class:"p-5"},zf={key:1,class:"flex h-48 items-center justify-center text-gray-400"},d1=he({__name:"TypeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(l){const s=l,{t}=ke(),c=x(!0),r=x([]),m=x([]),u=x([]),d=x({textCount:0,avgLength:0,maxLength:0,shortCount:0}),g=x({p25:0,p50:0,p75:0,p90:0}),v=x(0),h=k(()=>{const C=[...r.value].sort((M,y)=>y.count-M.count);return{labels:C.map(M=>Ht(M.type,t)),values:C.map(M=>M.count)}}),S=k(()=>{const C=r.value.reduce((y,f)=>y+f.count,0);return[...r.value].sort((y,f)=>f.count-y.count).map(y=>({name:Ht(y.type,t),count:y.count,percentage:C>0?Math.round(y.count/C*100):0}))}),b=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"];function w(C){return b[C%b.length]}const q=k(()=>({labels:m.value.map(C=>String(C.len)),values:m.value.map(C=>C.count)})),T=k(()=>({labels:u.value.map(C=>C.range),values:u.value.map(C=>C.count)})),I=k(()=>d.value.textCount===0?0:Math.round(d.value.shortCount/d.value.textCount*100));async function _(){if(s.sessionId){c.value=!0;try{const C=Ue(),[M,y,f,D,A]=await Promise.all([C.getMessageTypeDistribution(s.sessionId,s.timeFilter),C.getMessageLengthDistribution(s.sessionId,s.timeFilter),C.getTextStats(s.sessionId,s.timeFilter),C.getTextLengthPercentiles(s.sessionId,s.timeFilter),C.getLongMessageCount(s.sessionId,s.timeFilter,30)]);r.value=M,m.value=y.detail,u.value=y.grouped,d.value=f,g.value=D,v.value=A}catch(C){console.error("[chart-message] Failed to load type analysis data:",C)}finally{c.value=!1}}}return ge(()=>[s.sessionId,s.timeFilter],()=>_(),{immediate:!0,deep:!0}),(C,M)=>(n(),i("div",{class:oe(c.value?"h-full":"")},[c.value?(n(),K(a(mt),{key:0,variant:"page",text:a(t)("common.loading")},null,8,["text"])):(n(),i("div",Uy,[r.value.length>0?(n(),K(Fy,{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(We),{title:a(t)("views.message.typeDistribution"),"show-divider":!1},{default:U(()=>[e("div",Vy,[h.value.values.length>0?(n(),i("div",Oy,[e("div",null,[p(a(Vt),{data:h.value,height:280,"show-legend":!1},null,8,["data"])]),e("div",null,[e("div",Ny,[(n(!0),i(ne,null,de(S.value,(y,f)=>(n(),i("div",{key:f,class:"flex items-center gap-3"},[e("div",{class:"h-3 w-3 shrink-0 rounded-full",style:Ge({backgroundColor:w(f)})},null,4),e("div",Hy,o(y.name),1),e("div",Yy,[e("div",Wy,[e("div",{class:"h-full rounded-full transition-all",style:Ge({width:`${y.percentage}%`,backgroundColor:w(f)})},null,4)])]),e("div",Ky,[e("span",Qy,o(y.count.toLocaleString()),1),e("span",Gy,"("+o(y.percentage)+"%)",1)])]))),128))])])])):(n(),i("div",Jy,o(a(t)("views.message.noData")),1))])]),_:1},8,["title"]),p(a(We),{title:a(t)("views.message.typeAnalysis.textDepthTitle"),"show-divider":!1},{default:U(()=>[e("div",Xy,[e("div",Zy,[e("div",ef,[e("div",tf,o(d.value.textCount.toLocaleString()),1),e("div",af,o(a(t)("views.message.typeAnalysis.textTotal")),1)]),e("div",sf,[e("div",of,o(d.value.avgLength||0),1),e("div",nf,o(a(t)("views.message.typeAnalysis.avgLength")),1)]),e("div",rf,[e("div",lf,o(g.value.p50),1),e("div",cf,o(a(t)("views.message.typeAnalysis.medianLength")),1)]),e("div",df,[e("div",uf,o(d.value.maxLength),1),e("div",mf,o(a(t)("views.message.typeAnalysis.maxLength")),1)])]),e("div",gf,[e("div",pf,o(a(t)("views.message.typeAnalysis.percentiles")),1),e("div",vf,[e("div",hf,[M[0]||(M[0]=e("span",{class:"text-gray-500"},"P25",-1)),e("span",yf,o(g.value.p25),1)]),e("div",ff,[M[1]||(M[1]=e("span",{class:"text-gray-500"},"P50",-1)),e("span",xf,o(g.value.p50),1)]),e("div",bf,[M[2]||(M[2]=e("span",{class:"text-gray-500"},"P75",-1)),e("span",kf,o(g.value.p75),1)]),e("div",_f,[M[3]||(M[3]=e("span",{class:"text-gray-500"},"P90",-1)),e("span",wf,o(g.value.p90),1)])]),e("div",$f,[e("div",null,[e("span",Cf,o(a(t)("views.message.typeAnalysis.shortMessages")),1),e("span",Sf,o(I.value)+"%",1),e("span",Tf,"("+o(d.value.shortCount)+")",1)]),e("div",null,[e("span",If,o(a(t)("views.message.typeAnalysis.essayMessages")),1),e("span",Mf,o(v.value),1)])])])])]),_:1},8,["title"]),e("div",Lf,[p(a(We),{title:a(t)("views.message.lengthDetailTitle"),"show-divider":!1},{headerRight:U(()=>[e("span",Df,o(a(t)("views.message.lengthDetailHint")),1)]),default:U(()=>[e("div",Af,[q.value.values.some(y=>y>0)?(n(),K(a(tt),{key:0,data:q.value,height:200},null,8,["data"])):(n(),i("div",qf,o(a(t)("views.message.noTextMessages")),1))])]),_:1},8,["title"]),p(a(We),{title:a(t)("views.message.lengthGroupedTitle"),"show-divider":!1},{headerRight:U(()=>[e("span",Rf,o(a(t)("views.message.lengthGroupedHint")),1)]),default:U(()=>[e("div",Ef,[T.value.values.some(y=>y>0)?(n(),K(a(tt),{key:0,data:T.value,height:200},null,8,["data"])):(n(),i("div",zf,o(a(t)("views.message.noTextMessages")),1))])]),_:1},8,["title"])])]))],2))}}),Pf={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Bf={class:"flex items-start gap-6 sm:gap-10"},jf={class:"min-w-0 flex-1"},Ff={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},Uf={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},Vf={class:"mb-3 flex items-baseline gap-2"},Of={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Nf={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Hf={class:"font-bold text-3xl text-indigo-500 dark:text-indigo-400"},Yf={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Wf={class:"flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},Kf={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Qf={class:"font-bold text-xl text-pink-500 dark:text-pink-400"},Gf={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Jf={class:"text-base font-medium text-amber-600 dark:text-amber-400"},Xf={class:"flex shrink-0 flex-col items-center"},Zf={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},ex={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},tx={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},ax={class:"min-w-0 flex-1"},sx={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},ox={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},nx={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"},rx={class:"flex items-center gap-1.5"},lx={class:"text-[9px] font-medium uppercase tracking-widest"},ix=he({__name:"TimeProfileCard",props:{hourlyActivity:{},weekdayActivity:{},dailyActivity:{}},setup(l){yt([va,ha,ft]);const{t:s}=ke(),t=pt(),c=l,r=k(()=>c.dailyActivity.filter(y=>y.messageCount>0).length),m=k(()=>c.dailyActivity.reduce((y,f)=>y+f.messageCount,0)),u=k(()=>{if(c.dailyActivity.length===0)return{first:"",last:"",days:0};const y=[...c.dailyActivity].sort((A,P)=>A.date.localeCompare(P.date)),f=$e(y[0].date),D=$e(y[y.length-1].date);return{first:f.format("YYYY/MM/DD"),last:D.format("YYYY/MM/DD"),days:D.diff(f,"day")+1}}),d=k(()=>r.value===0?0:Math.round(m.value/r.value)),g=k(()=>c.dailyActivity.length===0?null:c.dailyActivity.reduce((y,f)=>f.messageCount>y.messageCount?f:y,c.dailyActivity[0])),v=k(()=>c.hourlyActivity.length===0?[]:[...c.hourlyActivity].sort((y,f)=>f.messageCount-y.messageCount).slice(0,3)),h=k(()=>{if(c.hourlyActivity.length===0&&c.weekdayActivity.length===0)return null;const y=u.value.days>0?r.value/u.value.days:0,f=c.weekdayActivity.filter(Q=>Q.weekday===6||Q.weekday===7),D=c.weekdayActivity.filter(Q=>Q.weekday>=1&&Q.weekday<=5),A=f.reduce((Q,V)=>Q+V.messageCount,0),P=D.reduce((Q,V)=>Q+V.messageCount,0),z=A+P,$=z>0?A/z:0,L=c.hourlyActivity.reduce((Q,V)=>Q+V.messageCount,0),W=c.hourlyActivity.filter(Q=>Q.hour>=22||Q.hour<5).reduce((Q,V)=>Q+V.messageCount,0),ae=c.hourlyActivity.filter(Q=>Q.hour>=18&&Q.hour<22).reduce((Q,V)=>Q+V.messageCount,0),Y=L>0?W/L:0,pe=L>0?ae/L:0;if(y>=.9)return{label:s("views.message.timeCard.personalityEveryday"),icon:"i-heroicons-fire"};if($>=.55)return{label:s("views.message.timeCard.personalityWeekend"),icon:"i-heroicons-calendar"};if($<=.2&&z>0)return{label:s("views.message.timeCard.personalityWeekday"),icon:"i-heroicons-briefcase"};if(Y>=.3)return{label:s("views.message.timeCard.personalityNightOwl"),icon:"i-heroicons-moon"};if(pe>=.4)return{label:s("views.message.timeCard.personalityEveningChat"),icon:"i-heroicons-sparkles"};const ye=[...c.hourlyActivity].sort((Q,V)=>V.messageCount-Q.messageCount)[0];return ye?ye.hour>=5&&ye.hour<9?{label:s("views.message.timeCard.personalityEarlyBird"),icon:"i-heroicons-sun"}:ye.hour>=12&&ye.hour<14?{label:s("views.message.timeCard.personalityLunchChat"),icon:"i-heroicons-clock"}:{label:s("views.message.timeCard.personalityDaytime"),icon:"i-heroicons-sun"}:null}),S=k(()=>{const y=c.weekdayActivity.filter(z=>z.weekday===6||z.weekday===7),f=c.weekdayActivity.filter(z=>z.weekday>=1&&z.weekday<=5),D=y.reduce((z,$)=>z+$.messageCount,0),A=f.reduce((z,$)=>z+$.messageCount,0),P=D+A;return P===0?0:Math.round(D/P*100)}),b=k(()=>[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")]),w=k(()=>{if(c.weekdayActivity.length===0)return null;const y=[...c.weekdayActivity].sort((f,D)=>D.messageCount-f.messageCount)[0];return{name:b.value[y.weekday-1],count:y.messageCount}}),q=k(()=>[{icon:"i-heroicons-fire",label:s("views.message.timeCard.peakRecord"),value:g.value?$e(g.value.date).format("MM/DD"):"-",subtext:g.value?s("views.message.timeCard.peakRecordDesc",{count:g.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(y=>`${y.hour}:00`).join(" > "):"",colorClass:"text-cyan-600 dark:text-cyan-400"},{icon:"i-heroicons-calendar-days",label:s("views.message.timeCard.peakWeekdayLabel"),value:w.value?.name||"-",subtext:w.value?`${w.value.count.toLocaleString()}`:"",colorClass:"text-violet-600 dark:text-violet-400"},{icon:"i-heroicons-building-office",label:s("views.message.timeCard.weekendRatio"),value:`${S.value}%`,subtext:s("views.message.timeCard.weekendRatioDesc"),colorClass:"text-amber-600 dark:text-amber-400"}]),T=x(null);let I=null;function _(){T.value&&(I=xt(T.value,void 0,{renderer:"canvas"}),C())}function C(){if(!I)return;const y=new Map(c.hourlyActivity.map(P=>[P.hour,P.messageCount])),f=[];for(let P=0;P<24;P++)f.push(y.get(P)||0);const D=Math.max(...f,1),A=f.map(P=>{const z=P/D;return z>.8?t.value?"#f472b6":"#ec4899":z>.5?t.value?"#a78bfa":"#8b5cf6":t.value?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.08)"});I.setOption({backgroundColor:"transparent",tooltip:{trigger:"axis",formatter:P=>`${P[0].axisValue}:00 — ${P[0].value}`},grid:{left:0,right:0,top:4,bottom:16},xAxis:{type:"category",data:Array.from({length:24},(P,z)=>`${z}`),axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:9,color:t.value?"#6b7280":"#9ca3af",interval:P=>P%6===0}},yAxis:{type:"value",show:!1},series:[{type:"bar",data:f.map((P,z)=>({value:P,itemStyle:{color:A[z]}})),barWidth:"60%",itemStyle:{borderRadius:[2,2,0,0]}}]},{notMerge:!0})}function M(){I?.resize()}return ge(()=>c.hourlyActivity,()=>C()),ge(t,()=>{I?.dispose(),_()}),Ee(()=>{_(),window.addEventListener("resize",M)}),lt(()=>{window.removeEventListener("resize",M),I?.dispose()}),(y,f)=>{const D=_e;return n(),K(a(it),{variant:"elevated",decorative:"",class:"flex flex-col"},{default:U(()=>[e("div",Pf,[e("div",Bf,[e("div",jf,[e("div",Ff,[u.value.first?(n(),i("p",Uf,o(u.value.first)+" – "+o(u.value.last),1)):R("",!0),e("div",Vf,[e("span",Of,o(u.value.days),1),e("span",Nf,o(a(s)("views.message.timeCard.heroDaysIn")),1),e("span",Hf,o(r.value),1),e("span",Yf,o(a(s)("views.message.timeCard.heroDaysActive")),1)]),e("div",Wf,[e("span",Kf,o(a(s)("views.message.timeCard.heroAvgPrefix")),1),e("span",Qf,o(d.value),1),e("span",Gf,o(a(s)("views.message.timeCard.heroAvgSuffix")),1),h.value?(n(),i(ne,{key:0},[p(D,{name:h.value.icon,class:"ml-2 h-4 w-4 text-amber-500"},null,8,["name"]),e("span",Jf,o(h.value.label),1)],64)):R("",!0)])])]),e("div",Xf,[e("div",Zf,o(a(s)("views.message.timeCard.hourlyDistribution")),1),e("div",{ref_key:"barRef",ref:T,style:{width:"180px",height:"110px"}},null,512)])])]),e("div",ex,[f[0]||(f[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",tx,[(n(!0),i(ne,null,de(q.value,A=>(n(),i("div",{key:A.icon+A.label,class:"flex items-start gap-2 rounded-lg bg-white/60 p-2.5 ring-1 ring-gray-900/5 dark:bg-white/5 dark:ring-white/10"},[p(D,{name:A.icon,class:oe(["mt-0.5 h-3.5 w-3.5 shrink-0",A.colorClass])},null,8,["name","class"]),e("div",ax,[e("div",{class:oe(["truncate font-mono text-sm font-black leading-tight tabular-nums",A.colorClass])},o(A.value),3),e("div",sx,o(A.label),1),e("div",ox,o(A.subtext),1)])]))),128))])]),e("div",nx,[e("div",rx,[p(D,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),f[1]||(f[1]=e("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),e("span",lx,o(a(s)("views.message.timeCard.watermark")),1)])]),_:1})}}}),cx={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-6"},dx={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},ux={class:"p-5"},mx={class:"p-5"},gx={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},px={class:"p-5"},vx={class:"p-5"},hx={key:1,class:"flex h-48 items-center justify-center text-gray-400"},yx={class:"text-xs text-gray-400"},fx={class:"p-5"},xx={key:1,class:"flex h-48 items-center justify-center text-gray-400"},bx={class:"text-xs text-gray-400"},kx={class:"p-5"},_x={class:"flex items-center gap-2"},wx={class:"text-xs text-gray-400"},$x={class:"p-5"},Cx={key:1,class:"flex h-32 items-center justify-center text-gray-400"},u1=he({__name:"TimeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(l){const s=l,{t}=ke(),c=x(!0),r=x([]),m=x([]),u=x([]),d=x([]),g=x([]),v=x([]),h=x([]),S=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],b=k(()=>[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")]),w=k(()=>[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")]),q=k(()=>{const z=new Map(m.value.map(W=>[W.hour,W.messageCount])),$=[],L=[];for(let W=0;W<24;W++)$.push(`${W}`),L.push(z.get(W)||0);return{labels:$,values:L}}),T=k(()=>{const z=new Map(u.value.map(L=>[L.weekday,L.messageCount])),$=[];for(let L=1;L<=7;L++)$.push(z.get(L)||0);return{labels:b.value,values:$}}),I=k(()=>{const z=new Map(d.value.map(L=>[L.month,L.messageCount])),$=[];for(let L=1;L<=12;L++)$.push(z.get(L)||0);return{labels:w.value,values:$}}),_=k(()=>{const z=[...g.value].sort(($,L)=>$.year-L.year);return{labels:z.map($=>String($.year)),values:z.map($=>$.messageCount)}}),C=k(()=>{const z=Array.from({length:24},(ae,Y)=>`${Y}:00`),$=b.value,L=r.value.reduce((ae,Y)=>ae+Y.count,0)||1,W=[];for(let ae=1;ae<=7;ae++)for(let Y=0;Y<24;Y++){const pe=u.value.find(V=>V.weekday===ae)?.messageCount||0,ye=m.value.find(V=>V.hour===Y)?.messageCount||0,Q=Math.round(pe*ye/L);W.push([Y,ae-1,Q])}return{xLabels:z,yLabels:$,data:W}}),M=k(()=>v.value.map(z=>({date:z.date,value:z.messageCount}))),y=k(()=>{const z=new Set;return v.value.forEach($=>{const L=parseInt($.date.split("-")[0]);isNaN(L)||z.add(L)}),Array.from(z).sort(($,L)=>L-$)}),f=x(new Date().getFullYear()),D=k(()=>{const z=f.value;return M.value.filter($=>$.date.startsWith(`${z}-`))}),A=k(()=>{if(h.value.length===0)return{};const z=[...new Set(h.value.map(Y=>Y.month))].sort(),$=new Map;if(h.value.forEach(Y=>{const pe=$.get(Y.memberId);pe?pe.total+=Y.count:$.set(Y.memberId,{name:Y.memberName,total:Y.count})}),$.size<=2){const Y=new Map;return h.value.forEach(pe=>{Y.set(pe.month,(Y.get(pe.month)||0)+pe.count)}),{tooltip:{trigger:"axis",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:50,right:20,top:10,bottom:30},xAxis:{type:"category",data:z,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{type:"dashed",opacity:.3}}},series:[{type:"line",smooth:!0,symbol:"none",areaStyle:{opacity:.2},itemStyle:{color:"#6366f1"},data:z.map(pe=>Y.get(pe)||0)}]}}const ae=[...$.entries()].sort((Y,pe)=>pe[1].total-Y[1].total).slice(0,10).map(([Y,pe],ye)=>{const Q=new Map(h.value.filter(V=>V.memberId===Y).map(V=>[V.month,V.count]));return{name:pe.name,type:"line",stack:"total",areaStyle:{opacity:.3},smooth:!0,symbol:"none",itemStyle:{color:S[ye%S.length]},data:z.map(V=>Q.get(V)||0)}});return{tooltip:{trigger:"axis",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},legend:{bottom:0,textStyle:{fontSize:11}},grid:{left:50,right:20,top:10,bottom:40},xAxis:{type:"category",data:z,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{type:"dashed",opacity:.3}}},series:ae}});async function P(){if(s.sessionId){c.value=!0;try{const z=Ue(),[$,L,W,ae,Y,pe,ye]=await Promise.all([z.getMessageTypeDistribution(s.sessionId,s.timeFilter),z.getHourlyActivity(s.sessionId,s.timeFilter),z.getWeekdayActivity(s.sessionId,s.timeFilter),z.getMonthlyActivity(s.sessionId,s.timeFilter),z.getYearlyActivity(s.sessionId,s.timeFilter),z.getDailyActivity(s.sessionId,s.timeFilter),z.getMemberMonthlyTrend(s.sessionId,s.timeFilter)]);r.value=$,m.value=L,u.value=W,d.value=ae,g.value=Y,v.value=pe,h.value=ye,y.value.length>0&&(f.value=y.value[0])}catch(z){console.error("[chart-message] Failed to load time analysis data:",z)}finally{c.value=!1}}}return ge(()=>[s.sessionId,s.timeFilter],()=>P(),{immediate:!0,deep:!0}),(z,$)=>{const L=It;return n(),i("div",{class:oe(c.value?"h-full":"")},[c.value?(n(),K(a(mt),{key:0,variant:"page",text:a(t)("common.loading")},null,8,["text"])):(n(),i("div",cx,[v.value.length>0?(n(),K(ix,{key:0,"hourly-activity":m.value,"weekday-activity":u.value,"daily-activity":v.value},null,8,["hourly-activity","weekday-activity","daily-activity"])):R("",!0),e("div",dx,[p(a(We),{title:a(t)("views.message.hourlyDistribution"),"show-divider":!1},{default:U(()=>[e("div",ux,[p(a(tt),{data:q.value,height:200},null,8,["data"])])]),_:1},8,["title"]),p(a(We),{title:a(t)("views.message.weekdayDistribution"),"show-divider":!1},{default:U(()=>[e("div",mx,[p(a(tt),{data:T.value,height:200},null,8,["data"])])]),_:1},8,["title"])]),e("div",gx,[p(a(We),{title:a(t)("views.message.monthlyDistribution"),"show-divider":!1},{default:U(()=>[e("div",px,[p(a(tt),{data:I.value,height:200},null,8,["data"])])]),_:1},8,["title"]),p(a(We),{title:a(t)("views.message.yearlyDistribution"),"show-divider":!1},{default:U(()=>[e("div",vx,[_.value.values.length>0?(n(),K(a(tt),{key:0,data:_.value,height:200},null,8,["data"])):(n(),i("div",hx,o(a(t)("views.message.noData")),1))])]),_:1},8,["title"])]),p(a(We),{title:a(t)("views.message.timeAnalysis.memberTrendTitle"),"show-divider":!1},{headerRight:U(()=>[e("span",yx,o(a(t)("views.message.timeAnalysis.memberTrendHint")),1)]),default:U(()=>[e("div",fx,[h.value.length>0?(n(),K(a(bt),{key:0,option:A.value,height:280},null,8,["option"])):(n(),i("div",xx,o(a(t)("views.message.noData")),1))])]),_:1},8,["title"]),p(a(We),{title:a(t)("views.message.timeHeatmap"),"show-divider":!1},{headerRight:U(()=>[e("span",bx,o(a(t)("views.message.heatmapHint")),1)]),default:U(()=>[e("div",kx,[p(a(Ft),{data:C.value,height:320},null,8,["data"])])]),_:1},8,["title"]),p(a(We),{title:a(t)("views.message.calendarHeatmap"),"show-divider":!1},{headerRight:U(()=>[e("div",_x,[e("span",wx,o(a(t)("views.message.calendarHint")),1),y.value.length>1?(n(),K(L,{key:0,modelValue:f.value,"onUpdate:modelValue":$[0]||($[0]=W=>f.value=W),items:y.value.map(W=>({value:W,label:String(W)})),size:"xs",class:"w-20"},null,8,["modelValue","items"])):R("",!0)])]),default:U(()=>[e("div",$x,[D.value.length>0?(n(),K(a(Dm),{key:0,data:D.value,year:f.value,height:180},null,8,["data","year"])):(n(),i("div",Cx,o(a(t)("views.message.noData")),1))])]),_:1},8,["title"])]))],2)}}}),Sx={class:"p-6"},Tx={class:"mb-4 flex items-center justify-between"},Ix={class:"flex items-center gap-3"},Mx={class:"text-lg font-semibold text-gray-900 dark:text-white"},Lx={class:"text-sm text-gray-500 dark:text-gray-400"},Dx={class:"h-56 overflow-y-auto rounded-lg border border-gray-200 dark:border-gray-700"},Ax={key:0,class:"flex h-full items-center justify-center"},qx={key:1,class:"flex h-full items-center justify-center"},Rx={class:"text-sm text-gray-500 dark:text-gray-400"},Ex={key:2,class:"divide-y divide-gray-100 dark:divide-gray-800"},zx=["onClick"],Px=["src","alt"],Bx={key:1,class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-linear-to-br from-gray-300 to-gray-400 text-xs font-medium text-white dark:from-gray-600 dark:to-gray-700"},jx={class:"min-w-0 flex-1"},Fx={class:"truncate text-sm font-medium text-gray-900 dark:text-white"},Ux={class:"truncate text-xs text-gray-500 dark:text-gray-400"},Vx={class:"mt-3 text-xs text-gray-500 dark:text-gray-400"},Ox={key:0,class:"mt-2"},Nx={class:"mt-5 flex items-center justify-between gap-2"},Hx={key:1},Yx={class:"flex gap-2"},Wx=he({__name:"OwnerPromptModal",props:{sessionId:{},modelValue:{type:Boolean,default:!1},chatType:{default:"group"},autoCheck:{type:Boolean,default:!1}},emits:["update:modelValue","saved","cleared"],setup(l,{emit:s}){const t=l,c=s,{t:r}=ke(),m=Je(),u=ca(),d=k({get:()=>t.modelValue,set:A=>c("update:modelValue",A)}),g=x([]),v=x(!1),h=x(!1),S=x(!1),b=x(""),w=x(null),q=k(()=>u.currentSession?.ownerId??null);function T(A){return A.groupNickname||A.accountName||A.platformId}const I=k(()=>{const A=b.value.trim().toLowerCase(),P=g.value.filter(z=>z.platformId&&z.platformId.trim()!=="");return A?P.filter(z=>[z.platformId,z.accountName??"",z.groupNickname??"",...z.aliases].some($=>$.toLowerCase().includes(A))):P});async function _(){if(t.sessionId){v.value=!0;try{g.value=await Ue().getMembers(t.sessionId)}catch(A){console.error("加载成员列表失败:",A)}finally{v.value=!1}}}async function C(){if(!(!t.sessionId||!t.autoCheck)&&!q.value)try{const A=await u.tryApplyOwnerProfile(t.sessionId);if(A.applied||A.reason==="already_set"||A.reason==="missing_session"||A.dismissed)return;d.value=!0}catch(A){console.error("检查会话 owner 失败:",A)}}async function M(){if(!(!w.value||!t.sessionId)){h.value=!0;try{const A=await u.setOwnerAndApplyProfile(t.sessionId,w.value);A.updatedSessionIds.length>0?m.success(r("members.ownerPrompt.saved"),{description:r("members.ownerPrompt.appliedToOthers",{count:A.updatedSessionIds.length})}):m.success(r("members.ownerPrompt.saved")),c("saved",A.ownerId),d.value=!1}catch(A){console.error("设置会话 owner 失败:",A),m.fail(r("members.ownerPrompt.saveFailed"))}finally{h.value=!1}}}async function y(){if(!(!t.sessionId||!q.value)){h.value=!0;try{await u.updateSessionOwnerId(t.sessionId,null)&&(w.value=null,c("cleared"),d.value=!1)}catch(A){console.error("清除会话 owner 失败:",A)}finally{h.value=!1}}}async function f(){if(t.sessionId){S.value=!0;try{await u.dismissOwnerPrompt(t.sessionId),d.value=!1}catch(A){console.error("忽略 owner 提醒失败:",A)}finally{S.value=!1}}}function D(){d.value=!1}return ge(d,A=>{A&&(b.value="",w.value=q.value,_())}),ge(()=>t.sessionId,()=>{C()}),Ee(()=>{C()}),(A,P)=>{const z=_e,$=Re,L=ht,W=Oe;return n(),K(W,{open:d.value,"onUpdate:open":P[1]||(P[1]=ae=>d.value=ae),ui:{content:"max-w-md"}},{content:U(()=>[e("div",Sx,[e("div",Tx,[e("div",Ix,[e("div",{class:oe(["flex h-10 w-10 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(z,{name:"i-heroicons-user",class:"h-5 w-5 text-white"})],2),e("div",null,[e("h3",Mx,o(a(r)("members.ownerPrompt.title")),1),e("p",Lx,o(a(r)("members.ownerPrompt.subtitle")),1)])]),p($,{icon:"i-heroicons-x-mark",color:"neutral",variant:"ghost",size:"sm",onClick:D})]),p(L,{modelValue:b.value,"onUpdate:modelValue":P[0]||(P[0]=ae=>b.value=ae),placeholder:a(r)("members.ownerPrompt.searchPlaceholder"),icon:"i-heroicons-magnifying-glass",class:"mb-3 w-full"},null,8,["modelValue","placeholder"]),e("div",Dx,[v.value?(n(),i("div",Ax,[p(z,{name:"i-heroicons-arrow-path",class:"h-5 w-5 animate-spin text-gray-400"})])):I.value.length===0?(n(),i("div",qx,[e("p",Rx,o(b.value?a(r)("members.ownerPrompt.noMatch"):a(r)("members.ownerPrompt.empty")),1)])):(n(),i("ul",Ex,[(n(!0),i(ne,null,de(I.value,ae=>(n(),i("li",{key:ae.id},[e("button",{type:"button",class:oe(["flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-gray-50 dark:hover:bg-gray-800/50",w.value===ae.platformId?"bg-primary-50 dark:bg-primary-900/20":""]),onClick:Y=>w.value=ae.platformId},[ae.avatar?(n(),i("img",{key:0,src:ae.avatar,alt:T(ae),class:"h-8 w-8 shrink-0 rounded-full object-cover"},null,8,Px)):(n(),i("div",Bx,o(T(ae).slice(0,1)),1)),e("div",jx,[e("p",Fx,o(T(ae)),1),e("p",Ux,o(ae.platformId),1)]),w.value===ae.platformId?(n(),K(z,{key:2,name:"i-heroicons-check-circle-solid",class:"h-5 w-5 shrink-0 text-primary-500"})):R("",!0)],10,zx)]))),128))]))]),e("p",Vx,o(a(r)("members.ownerPrompt.description")),1),q.value?(n(),i("div",Ox,[p($,{variant:"link",color:"neutral",size:"xs",disabled:h.value,onClick:y},{default:U(()=>[ee(o(a(r)("members.ownerPrompt.clear")),1)]),_:1},8,["disabled"])])):R("",!0),e("div",Nx,[q.value?(n(),i("span",Hx)):(n(),K($,{key:0,variant:"ghost",color:"neutral",size:"sm",loading:S.value,onClick:f},{default:U(()=>[ee(o(a(r)("members.ownerPrompt.dontRemind")),1)]),_:1},8,["loading"])),e("div",Yx,[p($,{variant:"ghost",color:"neutral",onClick:D},{default:U(()=>[ee(o(a(r)("members.ownerPrompt.later")),1)]),_:1}),p($,{color:"primary",loading:h.value,disabled:!w.value,onClick:M},{default:U(()=>[ee(o(a(r)("members.ownerPrompt.save")),1)]),_:1},8,["loading","disabled"])])])])]),_:1},8,["open"])}}}),Kx={class:"w-150 rounded-lg border border-gray-200 bg-white p-3 shadow-sm dark:border-gray-700 dark:bg-gray-900"},Qx={class:"flex items-center justify-between gap-3"},Gx={class:"flex items-center gap-2"},Jx={class:"text-sm font-medium text-gray-900 dark:text-white"},Xx={class:"text-xs text-gray-500 dark:text-gray-400"},m1=he({__name:"OwnerEntryCard",props:{sessionId:{},members:{},chatType:{}},setup(l){const{t:s}=ke(),t=ca(),c=l,r=x(!1);function m(g){return g.groupNickname||g.accountName||g.platformId}const u=k(()=>{const g=t.currentSession?.ownerId;return g&&c.members.find(v=>v.platformId===g)||null}),d=k(()=>u.value?m(u.value):t.currentSession?.ownerId??"");return(g,v)=>{const h=_e,S=Re;return n(),i("div",Kx,[e("div",Qx,[e("div",Gx,[e("div",{class:oe(["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(h,{name:"i-heroicons-user",class:"h-4 w-4 text-white"})],2),e("div",null,[e("h3",Jx,o(d.value?a(s)("members.ownerPrompt.currentOwner",{name:d.value}):a(s)("members.ownerPrompt.choose")),1),e("p",Xx,o(a(s)("members.ownerPrompt.helper")),1)])]),p(S,{size:"sm",variant:d.value?"outline":"solid",color:"primary",onClick:v[0]||(v[0]=b=>r.value=!0)},{default:U(()=>[ee(o(d.value?a(s)("members.ownerPrompt.change"):a(s)("members.ownerPrompt.choose")),1)]),_:1},8,["variant"])]),p(Wx,{modelValue:r.value,"onUpdate:modelValue":v[1]||(v[1]=b=>r.value=b),"session-id":l.sessionId,"chat-type":l.chatType},null,8,["modelValue","session-id","chat-type"])])}}}),Zx={key:1,class:"flex items-center"},eb={class:"whitespace-nowrap px-0.5 text-sm font-medium text-gray-700 dark:text-gray-300"},tb={key:2,class:"flex items-center"},ab={class:"whitespace-nowrap px-0.5 text-sm font-medium text-gray-700 dark:text-gray-300"},sb={key:3,class:"flex items-center gap-1"},ob=he({__name:"TimeSelect",props:{sessionId:{},modelValue:{},visible:{type:Boolean,default:!0},initialState:{}},emits:["update:modelValue","update:fullRange","update:availableYears"],setup(l,{emit:s}){const t=l,c=s,{t:r}=ke(),m=x(!1),u=x([]),d=x(null),g=x("recent"),v=x(365),h=x(0),S=x(0),b=x(1),w=x(""),q=x(""),T=x(!1);function I(F){const J=new Date(F*1e3);return{year:J.getFullYear(),quarter:Math.floor(J.getMonth()/3)+1}}function _(F,J){const ce=(J-1)*3,ve=new Date(F,ce,1,0,0,0),G=new Date(F,ce+3,0,23,59,59);return{startTs:Math.floor(ve.getTime()/1e3),endTs:Math.floor(G.getTime()/1e3)}}function C(F){const J=new Date(F,0,1,0,0,0),ce=new Date(F,11,31,23,59,59);return{startTs:Math.floor(J.getTime()/1e3),endTs:Math.floor(ce.getTime()/1e3)}}const M=k(()=>[{label:r("common.timeSelect.mode.recent"),value:"recent"},{label:r("common.timeSelect.mode.quarter"),value:"quarter"},{label:r("common.timeSelect.mode.year"),value:"year"},{label:r("common.timeSelect.mode.custom"),value:"custom"}]),y=k(()=>[{label:r("common.timeSelect.recent.oneYear"),value:365},{label:r("common.timeSelect.recent.twoYears"),value:730},{label:r("common.timeSelect.recent.fiveYears"),value:1825},{label:r("common.timeSelect.recent.all"),value:0}]),f=k(()=>d.value?I(d.value.start):{year:0,quarter:1}),D=k(()=>d.value?I(d.value.end):{year:0,quarter:1}),A=k(()=>{const F=f.value;return S.value>F.year||S.value===F.year&&b.value>F.quarter}),P=k(()=>{const F=D.value;return S.value<F.year||S.value===F.year&&b.value<F.quarter}),z=k(()=>u.value.length===0?!1:u.value.indexOf(h.value)<u.value.length-1),$=k(()=>u.value.length===0?!1:u.value.indexOf(h.value)>0),L=k(()=>r("common.timeSelect.quarter.label",{year:S.value,quarter:b.value})),W=k(()=>r("common.timeSelect.year.label",{year:h.value}));function ae(F){return{365:r("common.timeSelect.display.recent365"),730:r("common.timeSelect.display.recent730"),1825:r("common.timeSelect.display.recent1825")}[F]||""}function Y(F){return[365,730,1825,0].includes(F)?F:365}function pe(){if(!d.value)return null;const F={mode:g.value};switch(g.value){case"recent":{if(F.recentDays=v.value,v.value===0)return{startTs:d.value.start,endTs:d.value.end,displayLabel:Bt(d.value.start,d.value.end),isFullRange:!0,state:F};const J=d.value.end;return{startTs:Math.max(J-v.value*86400,d.value.start),endTs:J,displayLabel:ae(v.value),isFullRange:!1,state:F}}case"quarter":return F.quarterYear=S.value,F.quarter=b.value,{..._(S.value,b.value),displayLabel:L.value,isFullRange:!1,state:F};case"year":return F.year=h.value,{...C(h.value),displayLabel:W.value,isFullRange:!1,state:F};case"custom":{if(F.customStart=w.value,F.customEnd=q.value,!w.value||!q.value)return null;let J=$e(w.value).startOf("day").unix(),ce=$e(q.value).endOf("day").unix();return J>ce&&([J,ce]=[ce,J]),{startTs:J,endTs:ce,displayLabel:Bt(J,ce),isFullRange:!1,state:F}}}}function ye(){const F=pe();F&&c("update:modelValue",F)}function Q(F){let J=S.value,ce=b.value+F;ce>4&&(J++,ce=1),ce<1&&(J--,ce=4);const ve=f.value,G=D.value;J<ve.year||J===ve.year&&ce<ve.quarter||J>G.year||J===G.year&&ce>G.quarter||(S.value=J,b.value=ce,ye())}function V(F){const J=u.value,ve=J.indexOf(h.value)-F;ve>=0&&ve<J.length&&(h.value=J[ve],ye())}function te(F){if(d.value)switch(F){case"recent":v.value=Y(v.value);break;case"quarter":{const{year:J,quarter:ce}=I(d.value.end);S.value=J,b.value=ce;break}case"year":{h.value=u.value[0]||new Date(d.value.end*1e3).getFullYear();break}case"custom":{const J=d.value.end,ce=Math.max(J-30*86400,d.value.start);w.value=$e.unix(ce).format("YYYY-MM-DD"),q.value=$e.unix(J).format("YYYY-MM-DD");break}}}const xe=k({get:()=>g.value,set:F=>{g.value=F,T.value=!0,te(F),T.value=!1,ye()}}),fe=k({get:()=>v.value,set:F=>{v.value=F,ye()}}),X=k({get:()=>w.value,set:F=>{w.value=F,q.value&&ye()}}),O=k({get:()=>q.value,set:F=>{q.value=F,w.value&&ye()}});async function B(){if(!t.sessionId){u.value=[],d.value=null,c("update:fullRange",null),c("update:availableYears",[]),m.value=!0;return}try{const F=Ue(),[J,ce]=await Promise.all([F.getAvailableYears(t.sessionId),F.getTimeRange(t.sessionId)]);u.value=J,d.value=ce,c("update:fullRange",ce),c("update:availableYears",J);const ve=t.initialState,G=ve?.mode??"recent";switch(g.value=G,T.value=!0,G){case"recent":v.value=Y(ve?.recentDays??365);break;case"quarter":{if(ve?.quarterYear&&ve?.quarter)S.value=ve.quarterYear,b.value=ve.quarter;else if(ce){const{year:re,quarter:be}=I(ce.end);S.value=re,b.value=be}break}case"year":{ve?.year&&J.includes(ve.year)?h.value=ve.year:h.value=J[0]||0;break}case"custom":{if(ve?.customStart&&ve?.customEnd)w.value=ve.customStart,q.value=ve.customEnd;else if(ce){const re=ce.end,be=Math.max(re-30*86400,ce.start);w.value=$e.unix(be).format("YYYY-MM-DD"),q.value=$e.unix(re).format("YYYY-MM-DD")}break}}T.value=!1,ye()}catch(F){console.error("TimeSelect 加载数据失败:",F),u.value=[],d.value=null,c("update:fullRange",null),c("update:availableYears",[])}finally{m.value=!0}}return Ee(()=>B()),ge(()=>t.sessionId,()=>{m.value=!1,B()}),(F,J)=>{const ce=It,ve=Re;return m.value?(n(),i("div",{key:0,class:oe(["flex items-center gap-2",{invisible:!l.visible}])},[p(ce,{modelValue:xe.value,"onUpdate:modelValue":J[0]||(J[0]=G=>xe.value=G),items:M.value,size:"md",class:"w-28 shrink-0"},null,8,["modelValue","items"]),g.value==="recent"?(n(),K(et,{key:0,modelValue:fe.value,"onUpdate:modelValue":J[1]||(J[1]=G=>fe.value=G),items:y.value,size:"sm",class:"min-w-0 shrink"},null,8,["modelValue","items"])):g.value==="quarter"?(n(),i("div",Zx,[p(ve,{icon:"i-heroicons-chevron-left",size:"sm",variant:"ghost",color:"neutral",disabled:!A.value,onClick:J[2]||(J[2]=G=>Q(-1))},null,8,["disabled"]),e("span",eb,o(L.value),1),p(ve,{icon:"i-heroicons-chevron-right",size:"sm",variant:"ghost",color:"neutral",disabled:!P.value,onClick:J[3]||(J[3]=G=>Q(1))},null,8,["disabled"])])):g.value==="year"?(n(),i("div",tb,[p(ve,{icon:"i-heroicons-chevron-left",size:"sm",variant:"ghost",color:"neutral",disabled:!z.value,onClick:J[4]||(J[4]=G=>V(-1))},null,8,["disabled"]),e("span",ab,o(W.value),1),p(ve,{icon:"i-heroicons-chevron-right",size:"sm",variant:"ghost",color:"neutral",disabled:!$.value,onClick:J[5]||(J[5]=G=>V(1))},null,8,["disabled"])])):g.value==="custom"?(n(),i("div",sb,[p(ea,{modelValue:X.value,"onUpdate:modelValue":J[6]||(J[6]=G=>X.value=G),"width-class":"w-28",clearable:!1},null,8,["modelValue"]),J[8]||(J[8]=e("span",{class:"text-xs text-gray-400"},"-",-1)),p(ea,{modelValue:O.value,"onUpdate:modelValue":J[7]||(J[7]=G=>O.value=G),"width-class":"w-28",clearable:!1},null,8,["modelValue"])])):R("",!0)],2)):R("",!0)}}}),nb={class:"flex items-center justify-between"},rb=["src","alt"],lb={class:"group/title flex items-baseline gap-2"},ib={class:"header-actions relative z-[40] flex items-center gap-2"},cb=he({__name:"PageHeader",props:{title:{},description:{},icon:{},iconClass:{},avatar:{},size:{default:"default"}},setup(l){const s=l;return(t,c)=>{const r=_e;return n(),i("div",{class:oe(["relative border-b border-gray-200/50 dark:border-gray-800/50",s.size==="compact"?"px-5 pb-1.5":"px-6 pb-2"])},[c[1]||(c[1]=e("div",{class:"titlebar-drag-cover"},null,-1)),e("div",nb,[e("div",{class:oe(["flex items-center",s.size==="compact"?"gap-2.5":"gap-3"])},[l.avatar?(n(),i("img",{key:0,src:l.avatar,alt:l.title,class:oe(["object-cover",s.size==="compact"?"h-6 w-6 rounded-md":"h-10 w-10 rounded-xl"])},null,10,rb)):l.icon?(n(),i("div",{key:1,class:oe(["flex items-center justify-center",[l.iconClass,s.size==="compact"?"h-6 w-6 rounded-md":"h-10 w-10 rounded-xl"]])},[p(r,{name:l.icon,class:oe(["text-white",s.size==="compact"?"h-3 w-3":"h-5 w-5"])},null,8,["name","class"])],2)):R("",!0),e("div",lb,[e("h1",{class:oe(["font-semibold text-gray-900 dark:text-white",s.size==="compact"?"text-base":"text-lg"])},o(l.title),3),l.description?(n(),i("p",{key:0,class:oe(["pointer-events-none whitespace-nowrap text-gray-500 opacity-0 transition-opacity duration-200 group-hover/title:opacity-100 dark:text-gray-400",s.size==="compact"?"text-[11px]":"text-xs"])},o(l.description),3)):R("",!0)])],2),c[0]||(c[0]=e("div",{class:"flex-1 self-stretch mx-4",style:{"-webkit-app-region":"drag"}},null,-1)),e("div",ib,[Ke(t.$slots,"actions",{},void 0,!0)])]),Ke(t.$slots,"default",{},void 0,!0)],2)}}}),db=st(cb,[["__scopeId","data-v-b3e18446"]]),ub={class:"mt-3 flex items-center justify-between gap-3"},mb={class:"flex shrink-0 items-center gap-0.5 overflow-x-auto scrollbar-hide"},gb=["onClick"],pb={class:"whitespace-nowrap"},g1=he({__name:"SessionAnalysisHeader",props:Pt({title:{},avatar:{},icon:{},iconClass:{},tabs:{},currentSessionId:{},initialTimeState:{}},{activeTab:{required:!0},activeTabModifiers:{},timeRangeValue:{required:!0},timeRangeValueModifiers:{}}),emits:Pt(["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=s,{t:m}=ke(),u=dt(),d=k(()=>!["ai-chat","memory","lab","debug"].includes(t.value));return(g,v)=>{const h=Re,S=vt,b=_e;return n(),K(db,{title:l.title,avatar:l.avatar,size:"compact",icon:l.icon,"icon-class":l.iconClass},{actions:U(()=>[a(u).toolsPanelPosition==="header"?(n(),i(ne,{key:0},[p(S,{text:a(m)("analysis.tooltip.incrementalImport")},{default:U(()=>[p(h,{icon:"i-heroicons-plus-circle",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:v[0]||(v[0]=w=>r("openIncrementalImport"))})]),_:1},8,["text"]),p(S,{text:a(m)("analysis.tooltip.memberManagement")},{default:U(()=>[p(h,{icon:"i-heroicons-user-group",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:v[1]||(v[1]=w=>r("openMemberManagement"))})]),_:1},8,["text"]),p(S,{text:a(m)("analysis.tooltip.viewChatRecord")},{default:U(()=>[p(h,{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:v[2]||(v[2]=w=>r("openChatRecord"))})]),_:1},8,["text"]),p(ct,{color:"gray"}),p(S,{text:a(m)("analysis.tooltip.more")},{default:U(()=>[p(h,{"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:v[3]||(v[3]=w=>a(u).toggleToolsPanelOpen())})]),_:1},8,["text"])],64)):(n(),K(ct,{key:1,color:"gray"}))]),default:U(()=>[e("div",ub,[e("div",mb,[(n(!0),i(ne,null,de(l.tabs,w=>(n(),i("button",{key:w.id,class:oe(["flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm font-medium transition-all",[t.value===w.id?"bg-pink-500 text-white dark:bg-pink-900/30 dark:text-pink-300":"text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"]]),onClick:q=>t.value=w.id},[p(b,{name:w.icon,class:"h-4 w-4"},null,8,["name"]),e("span",pb,o(a(m)(w.labelKey)),1)],10,gb))),128))]),p(ob,{modelValue:c.value,"onUpdate:modelValue":v[4]||(v[4]=w=>c.value=w),"session-id":l.currentSessionId??void 0,visible:d.value,"initial-state":l.initialTimeState,"onUpdate:fullRange":v[5]||(v[5]=w=>r("update:fullRange",w)),"onUpdate:availableYears":v[6]||(v[6]=w=>r("update:availableYears",w))},null,8,["modelValue","session-id","visible","initial-state"])])]),_:1},8,["title","avatar","icon","icon-class"])}}}),vb={class:"p-6"},hb={class:"mb-4 flex items-center justify-between"},yb={class:"flex items-center gap-2"},fb={class:"flex h-10 w-10 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/30"},xb={class:"text-lg font-semibold text-gray-900 dark:text-white"},bb={class:"text-sm text-gray-500 dark:text-gray-400"},kb={key:0,class:"flex items-center justify-center py-8"},_b={key:0,class:"space-y-4"},wb={class:"rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-800/50 dark:bg-amber-900/20"},$b={class:"flex gap-3"},Cb={class:"text-sm font-medium text-amber-800 dark:text-amber-200"},Sb={class:"mt-1 text-sm text-amber-700 dark:text-amber-300"},Tb={class:"rounded-lg bg-gray-50 p-4 dark:bg-gray-800/50"},Ib={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},Mb={class:"space-y-1 text-sm text-gray-600 dark:text-gray-400"},Lb={class:"flex items-start gap-2"},Db={class:"flex items-start gap-2"},Ab={class:"flex items-start gap-2"},qb={key:1,class:"space-y-4"},Rb={class:"rounded-lg border border-green-200 bg-green-50 p-4 dark:border-green-800/50 dark:bg-green-900/20"},Eb={class:"flex gap-3"},zb={class:"text-sm font-medium text-green-800 dark:text-green-200"},Pb={class:"mt-1 text-sm text-green-700 dark:text-green-300"},Bb={class:"text-sm text-gray-500 dark:text-gray-400"},jb={class:"mt-6 flex justify-end gap-2"},p1=he({__name:"SessionIndexModal",props:{sessionId:{},modelValue:{type:Boolean},messageCount:{}},emits:["update:modelValue","generated"],setup(l,{emit:s}){const t=l,c=s,{t:r}=ke(),m=x(!1),u=x(0),d=x(!1),g=x(!0),v=x(!1),h=k({get:()=>t.modelValue??!1,set:_=>c("update:modelValue",_)}),S=k(()=>!v.value);async function b(){if(t.sessionId&&t.messageCount!==0){g.value=!0;try{const _=await Dt().getStats(t.sessionId);m.value=_.hasIndex,u.value=_.sessionCount,m.value||(v.value=!0,h.value=!0)}catch(_){console.error("检查会话索引失败:",_)}finally{g.value=!1}}}async function w(){if(t.sessionId){g.value=!0;try{const _=await Dt().getStats(t.sessionId);m.value=_.hasIndex,u.value=_.sessionCount}catch(_){console.error("检查会话索引失败:",_)}finally{g.value=!1}}}async function q(){if(t.sessionId){d.value=!0;try{const _=Fa(),C=await Dt().generate(t.sessionId,_);m.value=!0,u.value=C,c("generated",C),v.value=!1,h.value=!1}catch(_){console.error("生成会话索引失败:",_)}finally{d.value=!1}}}function T(){S.value&&(h.value=!1)}function I(_){!_&&!S.value||(h.value=_,_&&!v.value&&w())}return ge(()=>t.sessionId,()=>{b()}),Ee(()=>{b()}),(_,C)=>{const M=_e,y=Re,f=Oe;return n(),K(f,{open:h.value,dismissible:S.value,"onUpdate:open":I},{content:U(()=>[e("div",vb,[e("div",hb,[e("div",yb,[e("div",fb,[p(M,{name:"i-heroicons-clock",class:"h-5 w-5 text-blue-600 dark:text-blue-400"})]),e("div",null,[e("h3",xb,o(a(r)("records.sessionIndex.title")),1),e("p",bb,o(a(r)("records.sessionIndex.subtitle")),1)])]),S.value?(n(),K(y,{key:0,icon:"i-heroicons-x-mark",color:"neutral",variant:"ghost",size:"sm",onClick:T})):R("",!0)]),g.value?(n(),i("div",kb,[p(M,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):(n(),i(ne,{key:1},[m.value?(n(),i("div",qb,[e("div",Rb,[e("div",Eb,[p(M,{name:"i-heroicons-check-circle",class:"h-5 w-5 shrink-0 text-green-500"}),e("div",null,[e("p",zb,o(a(r)("records.sessionIndex.generated")),1),e("p",Pb,o(a(r)("records.sessionIndex.sessionCount",{count:u.value})),1)])])]),e("p",Bb,o(a(r)("records.sessionIndex.regenerateHint")),1)])):(n(),i("div",_b,[e("div",wb,[e("div",$b,[p(M,{name:"i-heroicons-exclamation-triangle",class:"h-5 w-5 shrink-0 text-amber-500"}),e("div",null,[e("p",Cb,o(a(r)("records.sessionIndex.notGenerated")),1),e("p",Sb,o(a(r)("records.sessionIndex.notGeneratedHint")),1)])])]),e("div",Tb,[e("h4",Ib,o(a(r)("records.sessionIndex.whatIsIt")),1),e("ul",Mb,[e("li",Lb,[p(M,{name:"i-heroicons-check",class:"mt-0.5 h-4 w-4 shrink-0 text-green-500"}),ee(" "+o(a(r)("records.sessionIndex.benefit1")),1)]),e("li",Db,[p(M,{name:"i-heroicons-check",class:"mt-0.5 h-4 w-4 shrink-0 text-green-500"}),ee(" "+o(a(r)("records.sessionIndex.benefit2")),1)]),e("li",Ab,[p(M,{name:"i-heroicons-check",class:"mt-0.5 h-4 w-4 shrink-0 text-green-500"}),ee(" "+o(a(r)("records.sessionIndex.benefit3")),1)])])])]))],64)),e("div",jb,[S.value?(n(),K(y,{key:0,variant:"ghost",onClick:T},{default:U(()=>[ee(o(a(r)("records.sessionIndex.cancel")),1)]),_:1})):R("",!0),p(y,{color:"primary",loading:d.value,onClick:q},{default:U(()=>[d.value?R("",!0):(n(),K(M,{key:0,name:m.value?"i-heroicons-arrow-path":"i-heroicons-sparkles",class:"mr-1 h-4 w-4"},null,8,["name"])),ee(" "+o(d.value?a(r)("records.sessionIndex.generating"):m.value?a(r)("records.sessionIndex.regenerate"):a(r)("records.sessionIndex.generate")),1)]),_:1},8,["loading"])])])]),_:1},8,["open","dismissible"])}}}),Fb={class:"space-y-4 p-5"},Ub={class:"flex items-center gap-2"},Vb={class:"text-base font-semibold text-gray-900 dark:text-white"},Ob={key:0,class:"flex items-center gap-2 text-sm text-gray-400"},Nb={class:"rounded-lg border border-gray-200 bg-gray-50 p-3 text-sm dark:border-gray-700 dark:bg-gray-800/50"},Hb={class:"flex items-center justify-between"},Yb={class:"text-gray-500"},Wb={class:"font-medium text-gray-800 dark:text-gray-200"},Kb={key:0,class:"mt-1 flex items-center justify-between"},Qb={class:"text-gray-500"},Gb={class:"text-gray-700 dark:text-gray-300"},Jb={key:1,class:"mt-2"},Xb={class:"flex items-center justify-between text-xs text-gray-500"},Zb={class:"mt-1 h-1.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},ek={key:2,class:"mt-1 text-xs text-red-500"},tk={class:"text-sm text-gray-600 dark:text-gray-400"},ak={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"},sk={class:"flex justify-end gap-2"},ok={class:"text-xs text-gray-400"},nk={class:"flex flex-wrap justify-end gap-2"},qe="settings.ai.semanticIndex",v1=he({__name:"SemanticIndexSessionModal",props:{modelValue:{type:Boolean},sessionId:{},messageCount:{}},emits:["update:modelValue"],setup(l,{emit:s}){const t=l,c=s,{t:r}=ke(),m=Ua(),u=k({get:()=>t.modelValue,set:M=>c("update:modelValue",M)}),d=x(null),g=x(!1),v=x(!1),h=x(!1),S=k(()=>{const M=d.value;return!M||!M.enabled?r(`${qe}.session.notEnabled`):M.needsRebuild?r(`${qe}.state.needsRebuild`):M.running||M.queued||M.indexStatus==="running"?r(`${qe}.state.building`):M.indexStatus==="completed"?r(`${qe}.state.completed`):M.indexStatus==="failed"?r(`${qe}.state.failed`):M.indexStatus==="paused"?r(`${qe}.state.paused`):r(`${qe}.state.pending`)}),b=k(()=>{const M=d.value;return!!M&&(M.running||M.queued||M.indexStatus==="running")}),w=k(()=>d.value&&d.value.totalMessages>0?Math.round(d.value.indexedMessages/d.value.totalMessages*100):0);let q=null;function T(){q&&(clearTimeout(q),q=null)}function I(){T(),q=setTimeout(async()=>{try{d.value=await m.status(t.sessionId)}catch(M){console.error("[semantic-index] poll status failed:",M)}b.value&&t.modelValue?I():T()},1500)}async function _(){v.value=!0;try{const[M,y]=await Promise.all([m.getConfig(),m.status(t.sessionId)]);g.value=M.config.enabled&&M.configured&&(M.config.mode==="local"?!!M.config.local.modelId:!!M.config.api?.baseUrl&&!!M.config.api?.model&&(!Va(M.config.api?.baseUrl)||M.apiKeySet)),d.value=y}catch(M){console.error("[semantic-index] load session status failed:",M)}finally{v.value=!1}b.value&&I()}async function C(M){h.value=!0;try{d.value=await m[M](t.sessionId)}catch(y){console.error(`[semantic-index] ${M} failed:`,y)}finally{h.value=!1}b.value?I():T()}return ge(()=>t.modelValue,M=>{M?_():T()}),lt(T),(M,y)=>{const f=_e,D=Re,A=Oe;return n(),K(A,{open:u.value,"onUpdate:open":y[10]||(y[10]=P=>u.value=P),ui:{content:"z-[101]",overlay:"z-[100]"}},{content:U(()=>[e("div",Fb,[e("div",Ub,[p(f,{name:"i-heroicons-circle-stack",class:"h-5 w-5 text-blue-500"}),e("h3",Vb,o(a(r)(`${qe}.title`)),1)]),v.value?(n(),i("div",Ob,[p(f,{name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin"}),ee(" "+o(a(r)("common.loading")),1)])):(n(),i(ne,{key:1},[e("div",Nb,[e("div",Hb,[e("span",Yb,o(a(r)(`${qe}.session.statusLabel`)),1),e("span",Wb,o(S.value),1)]),d.value?.enabled&&d.value.indexStatus==="completed"?(n(),i("div",Kb,[e("span",Qb,o(a(r)(`${qe}.session.coverageLabel`)),1),e("span",Gb,o(w.value)+"%",1)])):R("",!0),b.value?(n(),i("div",Jb,[e("div",Xb,[e("span",null,o(a(r)(`${qe}.session.progressLabel`)),1),e("span",null,o(d.value?.indexedMessages??0)+" / "+o(d.value?.totalMessages??0)+" ("+o(w.value)+"%) ",1)]),e("div",Zb,[e("div",{class:"h-full rounded-full bg-blue-500 transition-all duration-500",style:Ge({width:`${w.value}%`})},null,4)])])):R("",!0),d.value?.error?(n(),i("p",ek,o(d.value.error),1)):R("",!0)]),d.value?.enabled?(n(),i(ne,{key:1},[e("p",ok,o(a(r)(`${qe}.session.buildVsEnable`)),1),e("div",nk,[b.value?(n(),i(ne,{key:0},[p(D,{variant:"soft",loading:h.value,onClick:y[2]||(y[2]=P=>C("pause"))},{default:U(()=>[ee(o(a(r)(`${qe}.action.pause`)),1)]),_:1},8,["loading"]),p(D,{color:"error",variant:"soft",disabled:h.value,onClick:y[3]||(y[3]=P=>C("cancel"))},{default:U(()=>[ee(o(a(r)(`${qe}.action.cancel`)),1)]),_:1},8,["disabled"])],64)):d.value?.indexStatus==="completed"&&!d.value?.needsRebuild?(n(),K(D,{key:1,variant:"soft",loading:h.value,onClick:y[4]||(y[4]=P=>C("rebuild"))},{default:U(()=>[ee(o(a(r)(`${qe}.action.rebuild`)),1)]),_:1},8,["loading"])):d.value?.needsRebuild?(n(),K(D,{key:2,color:"primary",loading:h.value,onClick:y[5]||(y[5]=P=>C("rebuild"))},{default:U(()=>[ee(o(a(r)(`${qe}.action.rebuild`)),1)]),_:1},8,["loading"])):d.value?.indexStatus==="failed"?(n(),K(D,{key:3,color:"primary",loading:h.value,onClick:y[6]||(y[6]=P=>C("build"))},{default:U(()=>[ee(o(a(r)(`${qe}.session.retry`)),1)]),_:1},8,["loading"])):d.value?.indexStatus==="paused"?(n(),K(D,{key:4,color:"primary",loading:h.value,onClick:y[7]||(y[7]=P=>C("build"))},{default:U(()=>[ee(o(a(r)(`${qe}.session.continue`)),1)]),_:1},8,["loading"])):(n(),K(D,{key:5,color:"primary",loading:h.value,onClick:y[8]||(y[8]=P=>C("build"))},{default:U(()=>[ee(o(a(r)(`${qe}.action.build`)),1)]),_:1},8,["loading"])),p(D,{variant:"ghost",color:"neutral",disabled:h.value,onClick:y[9]||(y[9]=P=>C("disable"))},{default:U(()=>[ee(o(a(r)(`${qe}.action.disable`)),1)]),_:1},8,["disabled"])])],64)):(n(),i(ne,{key:0},[e("p",tk,o(a(r)(`${qe}.session.enableHint`)),1),g.value?R("",!0):(n(),i("p",ak,o(a(r)(`${qe}.session.configFirst`)),1)),e("div",sk,[p(D,{variant:"ghost",onClick:y[0]||(y[0]=P=>u.value=!1)},{default:U(()=>[ee(o(a(r)("common.close")),1)]),_:1}),p(D,{color:"primary",loading:h.value,disabled:!g.value,onClick:y[1]||(y[1]=P=>C("enable"))},{default:U(()=>[ee(o(a(r)(`${qe}.session.enable`)),1)]),_:1},8,["loading","disabled"])])],64))],64))])]),_:1},8,["open"])}}}),rk={class:"min-h-[200px]"},lk={key:0,class:"space-y-4"},ik={class:"text-sm text-gray-600 dark:text-gray-400"},ck={class:"text-sm text-gray-600 dark:text-gray-400"},dk={key:1,class:"flex flex-col items-center justify-center py-10"},uk={class:"text-gray-600 dark:text-gray-400"},mk={class:"mt-2 text-sm text-gray-500"},gk={key:2,class:"space-y-6"},pk={class:"rounded-lg bg-gray-50 p-4 dark:bg-gray-800"},vk={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},hk={class:"grid grid-cols-3 gap-4 text-center"},yk={class:"text-2xl font-bold text-gray-900 dark:text-white"},fk={class:"text-xs text-gray-500"},xk={class:"text-2xl font-bold text-green-600 dark:text-green-400"},bk={class:"text-xs text-gray-500"},kk={class:"text-2xl font-bold text-gray-400"},_k={class:"text-xs text-gray-500"},wk={key:0,class:"text-center text-sm text-amber-600 dark:text-amber-400"},$k={key:3,class:"flex flex-col items-center justify-center py-10"},Ck={class:"text-gray-600 dark:text-gray-400"},Sk={key:0,class:"mt-4 w-full max-w-xs"},Tk={key:4,class:"flex flex-col items-center justify-center py-10"},Ik={class:"text-lg font-medium text-gray-900 dark:text-white"},Mk={class:"mt-2 text-sm text-gray-600 dark:text-gray-400"},Lk={key:5,class:"flex flex-col items-center justify-center py-10"},Dk={class:"text-lg font-medium text-gray-900 dark:text-white"},Ak={class:"mt-2 text-sm text-red-600 dark:text-red-400"},qk={class:"flex w-full justify-end gap-2"},h1=he({__name:"IncrementalImportModal",props:{modelValue:{type:Boolean},sessionId:{},sessionName:{}},emits:["update:modelValue","imported"],setup(l,{emit:s}){const t=l,c=s,{t:r}=ke(),m=x("select"),u=x(null),d=x(null),g=x(null),v=x(null),h=x(null),S=x(null),b=k({get:()=>t.modelValue,set:f=>c("update:modelValue",f)});ge(b,f=>{f||w()});function w(){m.value="select",u.value=null,g.value=null,v.value=null,h.value=null,S.value=null}async function q({files:f,paths:D}){if(f.length>0)u.value={source:f[0],name:f[0].name};else{h.value=r("home.import.cannotReadPath");return}await I()}function T(){d.value?.openFileDialog()}async function I(){if(u.value){m.value="analyzing",h.value=null;try{const f=await ta().analyzeIncrementalImport(t.sessionId,u.value.source);if(f.error){m.value="error",h.value=y(f.error);return}g.value={newMessageCount:f.newMessageCount,duplicateCount:f.duplicateCount,totalInFile:f.totalInFile},m.value="preview"}catch(f){m.value="error",h.value=String(f)}}}async function _(){if(u.value){m.value="importing",v.value={stage:"saving",progress:0,message:""};try{const f=await ta().incrementalImport(t.sessionId,u.value.source,D=>{v.value=D});f.success?(S.value={newMessageCount:f.newMessageCount},m.value="done"):(m.value="error",h.value=y(f.error||"error.import_failed"))}catch(f){m.value="error",h.value=String(f)}}}function C(){S.value&&c("imported",S.value.newMessageCount),b.value=!1}function M(){m.value="select",u.value=null,g.value=null,h.value=null}function y(f){if(f.startsWith("error.")){const D=`home.import.errors.${f.slice(6)}`,A=r(D);return A!==D?A:f}return f}return(f,D)=>{const A=_e,P=Ga,z=Re,$=Oe;return n(),K($,{open:b.value,"onUpdate:open":D[1]||(D[1]=L=>b.value=L),title:a(r)("analysis.incremental.title")},{body:U(()=>[e("div",rk,[m.value==="select"?(n(),i("div",lk,[e("p",ik,o(a(r)("analysis.incremental.description",{name:l.sessionName})),1),p(a(Xa),{ref_key:"dropZoneRef",ref:d,accept:[".json",".jsonl",".txt"],class:"w-full",onFiles:q},{default:U(({isDragOver:L})=>[e("div",{class:oe(["flex cursor-pointer flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 py-10 transition-colors",L?"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:Fe(T,["stop"])},[p(A,{name:"i-heroicons-arrow-up-tray",class:"mb-3 h-10 w-10 text-gray-400"}),e("p",ck,o(L?a(r)("home.import.dropHint"):a(r)("analysis.incremental.dropHint")),1)],2)]),_:1},512)])):m.value==="analyzing"?(n(),i("div",dk,[p(A,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),e("p",uk,o(a(r)("analysis.incremental.analyzing")),1),e("p",mk,o(u.value?.name),1)])):m.value==="preview"&&g.value?(n(),i("div",gk,[e("div",pk,[e("p",vk,o(u.value?.name),1),e("div",hk,[e("div",null,[e("p",yk,o(g.value.totalInFile.toLocaleString()),1),e("p",fk,o(a(r)("analysis.incremental.totalInFile")),1)]),e("div",null,[e("p",xk,o(g.value.newMessageCount.toLocaleString()),1),e("p",bk,o(a(r)("analysis.incremental.newMessages")),1)]),e("div",null,[e("p",kk,o(g.value.duplicateCount.toLocaleString()),1),e("p",_k,o(a(r)("analysis.incremental.duplicates")),1)])])]),g.value.newMessageCount===0?(n(),i("p",wk,[p(A,{name:"i-heroicons-exclamation-triangle",class:"mr-1 inline-block h-4 w-4"}),ee(" "+o(a(r)("analysis.incremental.noNewMessages")),1)])):R("",!0)])):m.value==="importing"?(n(),i("div",$k,[p(A,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),e("p",Ck,o(a(r)("analysis.incremental.importing")),1),v.value?(n(),i("div",Sk,[p(P,{value:v.value.progress,size:"sm"},null,8,["value"])])):R("",!0)])):m.value==="done"&&S.value?(n(),i("div",Tk,[p(A,{name:"i-heroicons-check-circle",class:"mb-4 h-12 w-12 text-green-500"}),e("p",Ik,o(a(r)("analysis.incremental.success")),1),e("p",Mk,o(a(r)("analysis.incremental.successDetail",{count:S.value.newMessageCount})),1)])):m.value==="error"?(n(),i("div",Lk,[p(A,{name:"i-heroicons-x-circle",class:"mb-4 h-12 w-12 text-red-500"}),e("p",Dk,o(a(r)("analysis.incremental.failed")),1),e("p",Ak,o(h.value),1)])):R("",!0)])]),footer:U(()=>[e("div",qk,[m.value==="select"?(n(),K(z,{key:0,color:"neutral",variant:"ghost",onClick:D[0]||(D[0]=L=>b.value=!1)},{default:U(()=>[ee(o(a(r)("common.cancel")),1)]),_:1})):m.value==="preview"?(n(),i(ne,{key:1},[p(z,{color:"neutral",variant:"ghost",onClick:M},{default:U(()=>[ee(o(a(r)("common.back")),1)]),_:1}),p(z,{color:"primary",disabled:!g.value||g.value.newMessageCount===0,onClick:_},{default:U(()=>[ee(o(a(r)("analysis.incremental.import",{count:g.value?.newMessageCount||0})),1)]),_:1},8,["disabled"])],64)):m.value==="done"||m.value==="error"?(n(),i(ne,{key:2},[m.value==="error"?(n(),K(z,{key:0,color:"neutral",variant:"ghost",onClick:M},{default:U(()=>[ee(o(a(r)("common.retry")),1)]),_:1})):R("",!0),p(z,{color:"primary",onClick:C},{default:U(()=>[ee(o(a(r)("common.done")),1)]),_:1})],64)):R("",!0)])]),_:1},8,["open","title"])}}}),Rk={key:0,class:"fixed right-0 top-1/3"},Ek={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-gray-900"},zk=["onClick"],Pk={class:"mb-2 flex items-center justify-between"},Bk={class:"px-0.5 text-[9px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"},jk={class:"flex flex-col gap-1.5"},Fk=["onClick"],Uk={class:"whitespace-nowrap"},y1=he({__name:"ActionToolsPanel",emits:["openIncrementalImport","openSessionIndex","openSemanticIndex","openMemberManagement","openChatRecord","openMessageExport"],setup(l,{emit:s}){const{t}=ke(),c=dt(),{isToolsPanelMini:r,toolsPanelPosition:m,isToolsPanelOpen:u}=at(c),d=k(()=>m.value==="header"),g=k(()=>!d.value||u.value),v=x(null),h=s;function S(I){h(I),d.value&&(u.value=!1)}function b(I){if(!d.value||!u.value)return;const _=I.target;_ instanceof Element&&(v.value?.contains(_)||_.closest("[data-tools-panel-trigger]")||(u.value=!1))}const w=[{event:"openIncrementalImport",icon:"i-heroicons-plus-circle",hoverColor:"group-hover:text-pink-500",miniHoverBg:"hover:text-pink-500",labelKey:"analysis.tooltip.incrementalImport"},{event:"openSessionIndex",icon:"i-heroicons-clock",hoverColor:"group-hover:text-blue-500",miniHoverBg:"hover:text-blue-500",labelKey:"analysis.tooltip.sessionIndex"},{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"}],q=[{event:"openSessionIndex",icon:"i-heroicons-clock",hoverColor:"group-hover:text-blue-500",miniHoverBg:"hover:text-blue-500",labelKey:"analysis.tooltip.sessionIndex"},{event:"openSemanticIndex",icon:"i-heroicons-circle-stack",hoverColor:"group-hover:text-indigo-500",miniHoverBg:"hover:text-indigo-500",labelKey:"analysis.tooltip.semanticIndex"},{event:"openMessageExport",icon:"i-heroicons-document-arrow-down",hoverColor:"group-hover:text-green-500",miniHoverBg:"hover:text-green-500",labelKey:"analysis.messageExport.title"}],T=k(()=>d.value?q:w);return ge(m,()=>{u.value=!1}),Ee(()=>{document.addEventListener("mousedown",b)}),St(()=>{document.removeEventListener("mousedown",b)}),(I,_)=>{const C=_e,M=vt;return!d.value&&a(r)?(n(),i("div",Rk,[e("div",Ek,[(n(),i(ne,null,de(w,y=>p(M,{key:y.event,text:a(t)(y.labelKey),popper:{placement:"left"}},{default:U(()=>[e("button",{class:oe(["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",y.miniHoverBg]),onClick:f=>S(y.event)},[p(C,{name:y.icon,class:"h-3.5 w-3.5"},null,8,["name"])],10,zk)]),_:2},1032,["text"])),64)),_[2]||(_[2]=e("div",{class:"my-0.5 h-px w-4 bg-gray-200 dark:bg-gray-700"},null,-1)),p(M,{text:a(t)("analysis.toolsPanel.exitMini"),popper:{placement:"left"}},{default:U(()=>[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:_[0]||(_[0]=y=>a(c).toggleToolsPanelMini())},[p(C,{name:"i-heroicons-arrows-pointing-out",class:"h-3 w-3"})])]),_:1},8,["text"])])])):(n(),i("div",{key:1,class:oe(["fixed right-0 z-40",d.value?"top-14":"top-1/3"])},[e("div",{class:oe(["absolute right-0 top-0 transition-all duration-250 ease-in-out",g.value?"translate-x-0 opacity-100":"pointer-events-none translate-x-full opacity-0"])},[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-lg dark:border-white/5 dark:bg-gray-900"},[e("div",Pk,[e("span",Bk,o(a(t)("analysis.overview.tools")),1),d.value?R("",!0):(n(),K(M,{key:0,text:a(t)("analysis.toolsPanel.miniMode"),popper:{placement:"left"}},{default:U(()=>[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:_[1]||(_[1]=y=>a(c).toggleToolsPanelMini())},[p(C,{name:"i-heroicons-arrows-pointing-in",class:"h-3 w-3"})])]),_:1},8,["text"]))]),e("div",jk,[(n(!0),i(ne,null,de(T.value,y=>(n(),i("button",{key:y.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:f=>S(y.event)},[p(C,{name:y.icon,class:oe(["h-3.5 w-3.5 text-gray-400 transition-colors dark:text-gray-500",y.hoverColor])},null,8,["name","class"]),e("span",Uk,o(a(t)(y.labelKey)),1)],8,Fk))),128))])],512)],2)],2))}}}),Vk={class:"no-capture flex w-28 flex-col items-center rounded-l-xl border border-r-0 border-amber-200/60 bg-white p-3 shadow-lg dark:border-amber-500/10 dark:bg-gray-900"},Ok={class:"flex w-full flex-col items-center gap-3"},Nk={class:"whitespace-nowrap"},f1=he({__name:"DebugToolsPanel",setup(l){const s=Ct(),t=pt(),c=Na(t),r=x(!1);let m=null;const u=k(()=>r.value);function d(){m&&(clearTimeout(m),m=null),r.value=!0}function g(){m=setTimeout(()=>{r.value=!1},200)}const v=k({get:()=>s.locale,set:S=>s.setLocale(S)}),h=Oa.map(S=>({label:S.nativeName,value:S.code}));return(S,b)=>{const w=_e,q=Ja;return n(),i("div",{class:"fixed right-0 top-[70%] z-40",onMouseenter:d,onMouseleave:g},[e("div",{class:oe(["h-10 w-6 cursor-pointer items-center justify-center rounded-l-lg border border-r-0 border-amber-300/50 bg-amber-50 text-amber-500 shadow-sm transition-opacity duration-200 hover:bg-amber-100 dark:border-amber-500/30 dark:bg-amber-950 dark:text-amber-400 dark:hover:bg-amber-900",u.value?"pointer-events-none flex opacity-0":"flex opacity-100"])},[p(w,{name:"i-heroicons-bug-ant",class:"h-3.5 w-3.5"})],2),e("div",{class:oe(["absolute right-0 top-0 transition-all duration-250 ease-in-out",u.value?"translate-x-0 opacity-100":"pointer-events-none translate-x-full opacity-0"])},[e("div",Vk,[b[2]||(b[2]=e("div",{class:"mb-2"},[e("span",{class:"px-0.5 text-[9px] font-bold uppercase tracking-widest text-amber-500 dark:text-amber-400"}," Debug ")],-1)),e("div",Ok,[e("button",{class:"group flex items-center gap-1.5 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:b[0]||(b[0]=T=>a(c)())},[p(w,{name:a(t)?"i-heroicons-moon-solid":"i-heroicons-sun-solid",class:oe(["h-3.5 w-3.5 transition-colors",a(t)?"text-indigo-400":"text-amber-400"])},null,8,["name","class"]),e("span",Nk,o(a(t)?"Dark":"Light"),1)]),p(q,{modelValue:v.value,"onUpdate:modelValue":b[1]||(b[1]=T=>v.value=T),items:a(h),content:!1,orientation:"vertical",size:"xs"},null,8,["modelValue","items"])])])],2)],32)}}});export{h1 as A,n1 as B,Vu as C,o1 as D,r1 as E,f1 as F,it as G,bt as _,We as a,e1 as b,mt as c,a1 as d,Nm as e,sa as f,cs as g,i1 as h,Vt as i,c1 as j,Ht as k,Xk as l,tt as m,sp as n,d1 as o,u1 as p,s1 as q,m1 as r,Zk as s,t1 as t,l1 as u,g1 as v,y1 as w,p1 as x,v1 as y,Wx as z};
|
|
110
|
+
4. 若用户需求包含多个分析目标,仅选择第一个目标生成 SQL`}function pe(V){let te=V.trim();te=te.replace(/^```json?\n?/i,"").replace(/\n?```$/i,"");try{const xe=JSON.parse(te);return{sql:(xe.sql||"").trim(),explanation:(xe.explanation||"").trim()}}catch{return te=te.replace(/^```sql?\n?/i,"").replace(/\n?```$/i,""),{sql:te.trim(),explanation:""}}}async function ye(){const V=g.value.trim();if(!V){b.value=s("ai.sqlLab.generate.errorEmptyPrompt");return}if(!await Yt().hasConfig()){b.value=s("common.errorNoAIConfig");return}const xe=r.value?.schema||[];if(xe.length===0){b.value=s("common.error.unknown");return}S.value=!0,w.value=null,b.value=null,T.value="",I.value="",_.value=!1;let fe="";try{const X=Y(V,xe),O=await la().chatStream([{role:"system",content:"你是一个 SQLite 专家,请以 JSON 格式输出 sql 和 explanation 字段。"},{role:"user",content:X}],{temperature:.1,maxTokens:4096},F=>{if(F.thinking!==void 0){F.thinkingDone?_.value=!1:(_.value=!0,F.thinking&&(I.value+=F.thinking,Ve(()=>{C.value&&(C.value.scrollTop=C.value.scrollHeight)})));return}F.error&&(fe=F.error),F.isFinished&&F.finishReason==="length"&&(fe=s("ai.sqlLab.generate.errorTokenLimit")),F.content&&(T.value+=F.content)});if(!O.success){b.value=O.error||fe||s("ai.sqlLab.generate.errorGenerate");return}if(fe){b.value=fe;return}const B=pe(T.value);if(!B.sql){b.value=T.value?`${s("ai.sqlLab.generate.errorGenerate")}: ${T.value.slice(0,200)}`:s("ai.sqlLab.generate.errorGenerate");return}d.value=B.sql,q.value=V,A(V,B.sql,B.explanation),await z()}catch(X){b.value=X.message||String(X)}finally{S.value=!1}}async function Q(V){d.value=V.sql,q.value=V.prompt,M.value=!1,await z()}return Ee(()=>{f()}),ge(()=>c.chatType,V=>{g.value=u(V)}),(V,te)=>{const xe=_e,fe=Re;return n(),i("div",dm,[p(a(a0),{ref_key:"schemaPanelRef",ref:r,"session-id":l.sessionId,onInsertColumn:L},null,8,["session-id"]),e("div",um,[e("div",mm,[e("div",gm,[v.value==="prompt"?He((n(),i("textarea",{key:0,"onUpdate:modelValue":te[0]||(te[0]=X=>g.value=X),class:"h-32 w-full resize-none rounded-lg border border-gray-300 bg-white p-3 text-sm text-gray-800 focus:border-pink-500 focus:outline-none focus:ring-1 focus:ring-pink-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200",placeholder:a(s)("ai.sqlLab.generate.placeholder"),spellcheck:"false",onKeydown:te[1]||(te[1]=X=>$(X,"prompt"))},null,40,pm)),[[ot,g.value]]):He((n(),i("textarea",{key:1,"onUpdate:modelValue":te[2]||(te[2]=X=>d.value=X),class:"h-32 w-full resize-none rounded-lg border border-gray-300 bg-white p-3 font-mono text-sm text-gray-800 focus:border-pink-500 focus:outline-none focus:ring-1 focus:ring-pink-500 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200",placeholder:a(s)("ai.sqlLab.editor.placeholder"),spellcheck:"false",onKeydown:te[3]||(te[3]=X=>$(X,"sql"))},null,40,vm)),[[ot,d.value]]),e("div",hm,[e("div",ym,[p(fe,{variant:"ghost",size:"xs",onClick:W},{default:U(()=>[p(xe,{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",fm,o(a(s)("ai.sqlLab.editor.tip")),1)):R("",!0)]),e("div",xm,[p(fe,{variant:"ghost",size:"sm",disabled:y.value.length===0,onClick:te[4]||(te[4]=X=>M.value=!0)},{default:U(()=>[p(xe,{name:"i-heroicons-clock",class:"mr-1 h-4 w-4"}),ee(" "+o(a(s)("ai.sqlLab.editor.history"))+" ",1),y.value.length>0?(n(),i("span",bm,"("+o(y.value.length)+")",1)):R("",!0)]),_:1},8,["disabled"]),v.value==="prompt"?(n(),K(fe,{key:0,color:"primary",size:"sm",loading:S.value||h.value,disabled:!g.value.trim(),onClick:ye},{default:U(()=>[p(xe,{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(),K(fe,{key:1,color:"primary",size:"sm",loading:h.value,onClick:z},{default:U(()=>[p(xe,{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"&&!w.value&&!b.value&&(T.value||I.value||S.value)?(n(),i("div",km,[e("div",_m,[e("p",wm,[p(xe,{name:"i-heroicons-cpu-chip",class:"h-4 w-4"}),ee(" "+o(a(s)("ai.sqlLab.generate.aiOutput"))+" ",1),_.value?(n(),i("span",$m,o(a(s)("ai.sqlLab.generate.thinking")),1)):S.value?(n(),i("span",Cm,o(a(s)("common.generating")),1)):R("",!0)]),I.value?(n(),i("details",{key:0,class:"mb-3",open:_.value},[e("summary",Tm,o(a(s)("ai.sqlLab.generate.thinkingProcess")),1),e("pre",{ref_key:"thinkingPreRef",ref:C,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(I.value),513)],8,Sm)):R("",!0),T.value?(n(),i("pre",Im,o(T.value),1)):I.value?R("",!0):(n(),i("p",Mm,o(a(s)("ai.sqlLab.generate.waitingAI")),1))])])):(n(),K(a(cm),{key:1,ref_key:"resultTableRef",ref:m,result:w.value,error:b.value,sql:d.value,prompt:q.value},null,8,["result","error","sql","prompt"]))]),p(a(y0),{open:M.value,"onUpdate:open":te[5]||(te[5]=X=>M.value=X),history:y.value,onExecute:Q,onDelete:P},null,8,["open","history"])])}}}),Dm=he({__name:"EChartCalendar",props:{data:{},height:{default:180},year:{}},setup(l){yt([Gt,ya,Mt,Jt,ft]);const s=l,{t,locale:c}=ke(),r=pt(),m=x(null);let u=null;const d=k(()=>{if(s.year)return s.year;if(s.data.length===0)return new Date().getFullYear();const T=s.data.map(I=>parseInt(I.date.split("-")[0]));return Math.max(...T)}),g=k(()=>s.data.length===0?10:Math.max(...s.data.map(T=>T.value),1)),v=k(()=>s.data.map(T=>[T.date,T.value])),h={light:["#fee5e8","#fbb5c2","#f7758c","#ee4567"],dark:["#3d1f24","#6b2f3a","#a34557","#ee4567"]},S=k(()=>({tooltip:{trigger:"item",formatter:T=>{const I=T.data[0],_=T.data[1];return`${I}<br/>${t("views.message.calendarTooltipMessages")}: ${_}`}},visualMap:{min:0,max:g.value,calculable:!1,orient:"horizontal",left:"center",bottom:0,itemWidth:10,itemHeight:100,text:[`${g.value}`,"0"],inRange:{color:r.value?h.dark:h.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 b(){m.value&&(u=xt(m.value,r.value?"dark":void 0,{renderer:"canvas"}),u.setOption({backgroundColor:"transparent",...S.value}))}function w(){u&&u.setOption({backgroundColor:"transparent",...S.value},{notMerge:!0})}function q(){u?.resize()}return ge([()=>s.data,r,c],()=>{w()}),ge(()=>s.year,()=>{w()}),Ee(()=>{b(),window.addEventListener("resize",q)}),lt(()=>{window.removeEventListener("resize",q),u?.dispose()}),(T,I)=>(n(),i("div",{ref_key:"chartRef",ref:m,style:Ge({height:`${l.height}px`,width:"100%"})},null,4))}}),Am={class:"flex items-center justify-between border-b border-gray-200 px-5 py-3 dark:border-gray-800"},qm={class:"font-semibold text-gray-900 whitespace-nowrap dark:text-white"},Rm={key:0,class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},Em={class:"no-capture flex items-center gap-2"},zm={class:"flex w-full items-center justify-between border-b border-gray-200 px-6 py-4 dark:border-gray-700"},Pm={class:"flex items-center gap-2"},Bm={class:"text-lg font-semibold text-gray-900 whitespace-nowrap dark:text-white"},jm={class:"text-sm text-gray-500"},Fm={class:"max-h-[60vh] p-4 divide-y divide-gray-100 overflow-y-auto dark:divide-gray-800"},Um={class:"divide-y divide-gray-100 dark:divide-gray-800"},Vm={key:0},Om={class:"px-5 py-8 text-center text-sm text-gray-400"},Nm=he({__name:"ListPro",props:{items:{},title:{},description:{},topN:{default:10},countTemplate:{}},setup(l){const{t:s}=ke(),t=l,c=x(!1),r=x(null),m=x(null),u=k(()=>t.items.slice(0,t.topN)),d=k(()=>t.items.length>t.topN),g=k(()=>(t.countTemplate||s("views.charts.listPro.countTemplate")).replace("{count}",String(t.items.length)));return(v,h)=>{const S=Re,b=Oe;return n(),i("div",{ref_key:"cardRef",ref:r,class:"rounded-xl border border-gray-200 bg-white shadow-sm dark:border-gray-800 dark:bg-gray-900"},[e("div",Am,[e("div",null,[e("h3",qm,o(l.title),1),l.description?(n(),i("p",Rm,o(l.description),1)):R("",!0)]),e("div",Em,[Ke(v.$slots,"headerRight"),p(ct,{size:"xs",type:"element","target-element":r.value},null,8,["target-element"]),p(b,{open:c.value,"onUpdate:open":h[0]||(h[0]=w=>c.value=w),ui:{content:"md:w-full max-w-3xl"}},{content:U(()=>[e("div",{ref_key:"modalBodyRef",ref:m,class:"section-content flex flex-col"},[e("div",zm,[e("div",Pm,[e("h3",Bm,o(l.title),1),e("span",jm,"("+o(g.value)+")",1)]),p(ct,{size:"xs",type:"element","target-element":m.value},null,8,["target-element"])]),e("div",Fm,[(n(!0),i(ne,null,de(l.items,(w,q)=>(n(),i("div",{key:q,class:"px-5 py-3"},[Ke(v.$slots,"item",{item:w,index:q})]))),128))])],512)]),default:U(()=>[d.value?(n(),K(S,{key:0,icon:"i-heroicons-list-bullet",variant:"ghost"},{default:U(()=>[ee(o(a(s)("views.charts.listPro.fullRanking")),1)]),_:1})):R("",!0)]),_:3},8,["open"])])]),Ke(v.$slots,"config"),e("div",Um,[(n(!0),i(ne,null,de(u.value,(w,q)=>(n(),i("div",{key:q,class:"px-5 py-3"},[Ke(v.$slots,"item",{item:w,index:q})]))),128))]),l.items.length===0?(n(),i("div",Vm,[Ke(v.$slots,"empty",{},()=>[e("div",Om,o(a(s)("views.charts.listPro.empty")),1)])])):R("",!0)],512)}}}),Hm={class:"border-b border-gray-100 p-4 dark:border-gray-800"},Ym={class:"mb-3 flex flex-wrap items-center gap-2"},Wm={class:"text-xs text-gray-500 dark:text-gray-400"},Km=["onClick"],Qm={class:"p-4"},Gm={class:"mb-3 font-semibold text-gray-900 dark:text-white"},Jm={class:"space-y-3"},Xm={class:"mb-1 block text-xs text-gray-500"},Zm={class:"mb-1 block text-xs text-gray-500"},eg={class:"flex flex-wrap items-center gap-2"},tg={class:"mt-4 flex justify-end gap-2"},ag={class:"flex flex-wrap items-center gap-2"},sg={class:"mt-1.5 text-xs text-gray-400"},og={key:0,class:"border-b border-gray-100 px-5 py-4 dark:border-gray-800"},ng={class:"mb-3 flex items-center justify-between"},rg={class:"text-base font-medium text-gray-700 dark:text-gray-300"},lg={class:"flex cursor-pointer items-center gap-1.5 text-xs text-gray-500"},ig={class:"flex flex-wrap gap-2"},cg={class:"text-xs text-gray-500"},dg={class:"flex items-center gap-3"},ug={class:"w-32 shrink-0"},mg={class:"truncate font-medium text-gray-900 dark:text-white"},gg={class:"flex flex-1 items-center"},pg={class:"flex h-2.5 w-full overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800"},vg=["title"],hg={class:"flex shrink-0 items-baseline gap-2"},yg={class:"text-lg font-bold text-gray-900 dark:text-white"},fg={class:"text-sm text-gray-500"},xg={key:0,class:"flex h-64 flex-col items-center justify-center text-gray-400"},bg={class:"text-sm"},kg={key:1,class:"h-64"},_g=he({__name:"KeywordAnalysis",props:{sessionId:{},timeFilter:{}},setup(l){const{t:s}=ke(),t=l,c=$t(),r=x(!1),m={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(O){if(!r.value)return m;const B=b.value.indexOf(O);return u[B%u.length]}const g=["laugh","sad","praise","slacker","gossip","polite","curious"],v=k(()=>[{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")}]),h=k(()=>{const O=c.customKeywordTemplates.map(F=>({...F,isCustom:!0}));return[...v.value.filter(F=>!c.deletedPresetTemplateIds.includes(F.id)),...O]}),S=x("laugh"),b=x([]);ge(v,O=>{O.length>0&&b.value.length===0&&(b.value=[...O[0].keywords])},{immediate:!0});const w=k(()=>{const O=h.value.find(B=>B.id===S.value);return O?O.name:""}),q=x(null),T=x(!1),I=x(!1),_=x(null),C=x(""),M=x([]),y=x(""),f=k(()=>_.value!==null),D=k(()=>f.value?s("quotes.keywords.modal.editTitle"):s("quotes.keywords.modal.createTitle"));function A(){_.value=null,C.value="",M.value=[],y.value="",I.value=!0}function P(O){_.value=O.id,C.value=O.name,M.value=[...O.keywords],I.value=!0}function z(){const O=y.value.trim();O&&!M.value.includes(O)&&(M.value=[...M.value,O]),y.value=""}function $(O){M.value=M.value.filter(B=>B!==O)}function L(O){S.value=O.id,b.value=[...O.keywords],q.value=null,te()}function W(){b.value=[],q.value=null,S.value=""}const ae=x("");function Y(){const O=ae.value.trim();O&&!b.value.includes(O)&&(b.value=[...b.value,O],te()),ae.value=""}function pe(O){b.value=b.value.filter(B=>B!==O),te()}function ye(O){return g.includes(O)}function Q(){if(C.value.trim()){if(f.value&&_.value)if(ye(_.value)){const O={id:`custom_${Date.now()}`,name:C.value.trim(),keywords:[...M.value]};c.addCustomKeywordTemplate(O),S.value=O.id,b.value=[...O.keywords],te()}else c.updateCustomKeywordTemplate(_.value,{name:C.value.trim(),keywords:[...M.value]}),S.value===_.value&&(b.value=[...M.value],te());else{const O={id:`custom_${Date.now()}`,name:C.value.trim(),keywords:[...M.value]};c.addCustomKeywordTemplate(O),S.value=O.id,b.value=[...O.keywords],te()}I.value=!1}}function V(O){ye(O)?c.addDeletedPresetTemplateId(O):c.removeCustomKeywordTemplate(O),S.value===O&&(h.value.length>0?L(h.value[0]):W())}async function te(){if(!t.sessionId||b.value.length===0){q.value=null;return}T.value=!0;try{q.value=await Ue().getLaughAnalysis(t.sessionId,t.timeFilter,[...b.value])}catch(O){console.error("加载词频分析失败:",O),q.value=null}finally{T.value=!1}}const xe=k(()=>q.value?q.value.rankByCount.map(O=>({id:O.memberId.toString(),name:O.name,value:O.laughCount,percentage:O.percentage,keywordDistribution:O.keywordDistribution||[]})):[]);function fe(O){if(xe.value.length===0)return 0;const B=xe.value[0].value;return B===0?0:Math.round(xe.value[O].value/B*100)}function X(O,B){const F=fe(B);return!O.keywordDistribution||O.keywordDistribution.length===0?[{keyword:"default",width:F,bg:"bg-amber-400"}]:O.keywordDistribution.map(J=>({keyword:J.keyword,width:J.percentage/100*F,bg:d(J.keyword).bg}))}return ge(()=>[t.sessionId,t.timeFilter],()=>{te()},{immediate:!0,deep:!0}),(O,B)=>{const F=ga,J=ht,ce=Wt,ve=Re,G=Oe,re=Ka,be=_e;return n(),K(a(Nm),{items:xe.value,title:a(s)("quotes.keywords.title"),description:a(s)("quotes.keywords.description"),"top-n":10,"count-template":a(s)("quotes.keywords.countTemplate")},{config:U(()=>[e("div",Hm,[e("div",Ym,[e("span",Wm,o(a(s)("quotes.keywords.templateLabel")),1),(n(!0),i(ne,null,de(h.value,ue=>(n(),K(F,{key:ue.id,items:[[{label:a(s)("quotes.keywords.contextMenu.edit"),icon:"i-lucide-pencil",disabled:!ue.isCustom,onSelect:()=>P(ue)},{label:a(s)("quotes.keywords.contextMenu.delete"),icon:"i-lucide-trash",color:"error",onSelect:()=>V(ue.id)}]]},{default:U(()=>[e("button",{class:oe(["rounded-md border px-2.5 py-1 text-sm transition-all",S.value===ue.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:we=>L(ue)},o(ue.name),11,Km)]),_:2},1032,["items"]))),128)),p(G,{open:I.value,"onUpdate:open":B[3]||(B[3]=ue=>I.value=ue)},{content:U(()=>[e("div",Qm,[e("h3",Gm,o(D.value),1),e("div",Jm,[e("div",null,[e("label",Xm,o(a(s)("quotes.keywords.modal.templateName")),1),p(J,{modelValue:C.value,"onUpdate:modelValue":B[0]||(B[0]=ue=>C.value=ue),placeholder:a(s)("quotes.keywords.modal.templateNamePlaceholder")},null,8,["modelValue","placeholder"])]),e("div",null,[e("label",Zm,o(a(s)("quotes.keywords.modal.keywords")),1),e("div",eg,[(n(!0),i(ne,null,de(M.value,ue=>(n(),K(ce,{key:ue,variant:"soft",class:"cursor-pointer",onClick:we=>$(ue)},{default:U(()=>[ee(o(ue)+" ",1),B[6]||(B[6]=e("span",{class:"ml-0.5 hover:text-red-500"},"×",-1))]),_:2},1032,["onClick"]))),128)),p(J,{modelValue:y.value,"onUpdate:modelValue":B[1]||(B[1]=ue=>y.value=ue),placeholder:a(s)("quotes.keywords.modal.keywordPlaceholder"),class:"w-full",onKeydown:Xe(Fe(z,["prevent"]),["enter"])},null,8,["modelValue","placeholder","onKeydown"])])])]),e("div",tg,[p(ve,{variant:"soft",onClick:B[2]||(B[2]=ue=>I.value=!1)},{default:U(()=>[ee(o(a(s)("common.cancel")),1)]),_:1}),p(ve,{color:"primary",disabled:!C.value.trim()||M.value.length===0,onClick:Q},{default:U(()=>[ee(o(f.value?a(s)("quotes.keywords.modal.update"):a(s)("common.save")),1)]),_:1},8,["disabled"])])])]),default:U(()=>[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:A},o(a(s)("quotes.keywords.newTemplate")),1)]),_:1},8,["open"])]),e("div",ag,[(n(!0),i(ne,null,de(b.value,ue=>(n(),K(ce,{key:ue,class:"cursor-pointer",onClick:we=>pe(ue)},{default:U(()=>[ee(o(ue)+" ",1),B[7]||(B[7]=e("span",{class:"ml-0.5 hover:text-red-500"},"×",-1))]),_:2},1032,["onClick"]))),128)),p(J,{modelValue:ae.value,"onUpdate:modelValue":B[4]||(B[4]=ue=>ae.value=ue),placeholder:a(s)("quotes.keywords.searchPlaceholder"),class:"w-32",onKeydown:Xe(Fe(Y,["prevent"]),["enter"])},null,8,["modelValue","placeholder","onKeydown"]),b.value.length>0?(n(),i("button",{key:0,class:"text-sm text-pink-500 hover:text-red-500",onClick:W},o(a(s)("quotes.keywords.clear")),1)):R("",!0)]),e("div",sg,o(a(s)("quotes.keywords.templateHint")),1)]),q.value&&q.value.typeDistribution.length>0?(n(),i("div",og,[e("div",ng,[e("span",rg,o(w.value?w.value:b.value.length===1?b.value[0]:a(s)("quotes.keywords.keyword"))+o(a(s)("quotes.keywords.ranking")),1),e("label",lg,[e("span",null,o(a(s)("quotes.keywords.multiColorMode")),1),p(re,{modelValue:r.value,"onUpdate:modelValue":B[5]||(B[5]=ue=>r.value=ue),size:"md"},null,8,["modelValue"])])]),e("div",ig,[(n(!0),i(ne,null,de(q.value.typeDistribution,ue=>(n(),i("div",{key:ue.type,class:oe(["flex items-center gap-2 rounded-lg px-2 py-2 text-xs",d(ue.type).wrapBg])},[e("span",{class:oe(["h-2.5 w-2.5 shrink-0 rounded-full",d(ue.type).bg])},null,2),e("span",{class:oe(["font-medium",d(ue.type).text])},o(ue.type),3),e("span",cg,o(a(s)("quotes.keywords.times",{count:ue.count})),1),p(ce,{color:d(ue.type).badge,variant:"soft",size:"xs"},{default:U(()=>[ee(o(ue.percentage)+"%",1)]),_:2},1032,["color"])],2))),128))])])):R("",!0),T.value&&xe.value.length===0?(n(),K(a(mt),{key:1,text:a(s)("quotes.keywords.loading")},null,8,["text"])):R("",!0)]),item:U(({item:ue,index:we})=>[e("div",dg,[e("div",{class:oe(["flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-sm font-bold",a(cs)(we)])},o(we+1),3),e("div",ug,[e("p",mg,o(ue.name),1)]),e("div",gg,[e("div",pg,[(n(!0),i(ne,null,de(X(ue,we),Le=>(n(),i("div",{key:Le.keyword,class:oe(["h-full transition-all first:rounded-l-full last:rounded-r-full",Le.bg]),style:Ge({width:`${Le.width}%`}),title:`${Le.keyword}: ${Le.width.toFixed(1)}%`},null,14,vg))),128))])]),e("div",hg,[e("span",yg,o(ue.value),1),e("span",fg,o(a(s)("quotes.keywords.timesWithPercent",{count:ue.value,percent:ue.percentage})),1)])])]),empty:U(()=>[T.value?(n(),i("div",kg)):(n(),i("div",xg,[p(be,{name:"i-heroicons-magnifying-glass",class:"mb-2 h-8 w-8 opacity-50"}),e("p",bg,o(a(s)("quotes.keywords.empty")),1)]))]),_:1},8,["items","title","description","count-template"])}}}),wg={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},$g={class:"flex items-center gap-6 sm:gap-10"},Cg={class:"min-w-0 flex-1"},Sg={class:"flex flex-col gap-2 text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},Tg={key:0,class:"mb-0 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},Ig={class:"flex items-baseline gap-x-1.5"},Mg={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Lg={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Dg={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Ag={class:"flex items-baseline gap-x-1.5"},qg={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Rg={class:"font-black text-3xl text-pink-500 dark:text-pink-400"},Eg={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},zg={key:1,class:"mt-1 flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},Pg={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Bg=["onClick"],jg={key:0,class:"text-gray-400"},Fg={key:0,class:"hidden shrink-0 overflow-hidden rounded-lg sm:block"},Ug={class:"relative",style:{width:"360px",height:"220px"}},Vg={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Og={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Ng={class:"min-w-0 flex-1"},Hg={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},Yg={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Wg={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"},Kg={class:"flex items-center gap-1.5"},Qg={class:"text-[9px] font-medium uppercase tracking-widest"},Gg=he({__name:"TopicProfileCard",props:{totalMessages:{},totalWords:{},uniqueWords:{},topWords:{},topicWords:{},posTagStats:{},timeFilter:{}},emits:["wordClick"],setup(l,{emit:s}){const t=da(()=>Tt(()=>import("./EChartWordcloud-B_YisOW5.js"),__vite__mapDeps([5,6,7,8,1]))),{t:c}=ke(),r=l,m=s,u=k(()=>{const{startTs:q,endTs:T}=r.timeFilter??{};return q&&T?`${$e(q*1e3).format("YYYY/MM/DD")} – ${$e(T*1e3).format("YYYY/MM/DD")}`:""}),d=k(()=>(r.topicWords?.length?r.topicWords:r.topWords).slice(0,5)),g=k(()=>({words:(r.topicWords?.length?r.topicWords:r.topWords).slice(0,50).map(T=>({word:T.word,count:T.count,percentage:T.percentage}))})),v=k(()=>r.totalWords===0?0:Math.round(r.uniqueWords/r.totalWords*100)),h=k(()=>{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 q=new Map(r.posTagStats.map(D=>[D.tag,D.count])),T=(q.get("n")||0)+(q.get("ns")||0)+(q.get("nt")||0)+(q.get("nz")||0),I=(q.get("v")||0)+(q.get("vn")||0)+(q.get("vd")||0),_=(q.get("a")||0)+(q.get("ad")||0)+(q.get("an")||0),C=T+I+_;if(C===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 M=T/C,y=I/C,f=_/C;return M>.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"}:y>.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"}:f>.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"}}),S=k(()=>{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 q=r.topWords.reduce((_,C)=>_+C.word.length*C.count,0),T=r.topWords.reduce((_,C)=>_+C.count,0),I=q/T;return I<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"}:I>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=k(()=>[{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:h.value.icon,label:c("quotes.topicProfile.chatStyle"),value:h.value.label,subtext:h.value.desc,colorClass:h.value.colorClass},{icon:S.value.icon,label:c("quotes.topicProfile.expressionStyle"),value:S.value.label,subtext:S.value.desc,colorClass:S.value.colorClass}]),w=["#6366f1","#ec4899","#f97316","#22c55e","#3b82f6","#8b5cf6","#14b8a6","#f43f5e"];return(q,T)=>{const I=_e;return n(),K(a(it),{variant:"elevated",decorative:"",class:"flex flex-col"},{default:U(()=>[e("div",wg,[e("div",$g,[e("div",Cg,[e("div",Sg,[u.value?(n(),i("p",Tg,o(u.value),1)):R("",!0),e("div",Ig,[e("span",Mg,o(a(c)("quotes.topicProfile.heroPrefix")),1),e("span",Lg,o(l.totalMessages.toLocaleString()),1),e("span",Dg,o(a(c)("quotes.topicProfile.heroMiddle")),1)]),e("div",Ag,[e("span",qg,o(a(c)("quotes.topicProfile.heroMiddleSecond")),1),e("span",Rg,o(l.uniqueWords.toLocaleString()),1),e("span",Eg,o(a(c)("quotes.topicProfile.heroSuffix")),1)]),d.value.length>0?(n(),i("div",zg,[e("span",Pg,o(a(c)("quotes.topicProfile.topTopicsPrefix")),1),(n(!0),i(ne,null,de(d.value,(_,C)=>(n(),i(ne,{key:_.word},[e("span",{class:"cursor-pointer font-bold text-xl transition-opacity hover:opacity-70",style:Ge({color:w[C%w.length]}),onClick:M=>m("wordClick",_.word)},o(_.word),13,Bg),C<d.value.length-1?(n(),i("span",jg,"·")):R("",!0)],64))),128))])):R("",!0)])]),g.value.words.length>0?(n(),i("div",Fg,[e("div",Ug,[p(a(t),{data:g.value,height:"100%","max-words":50,"size-scale":.8,"draw-out-of-bound":!0,shape:"rectangle","color-scheme":"default",onWordClick:T[0]||(T[0]=_=>m("wordClick",_))},null,8,["data"])])])):R("",!0)])]),e("div",Vg,[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"}," Topic Profile ")],-1)),e("div",Og,[(n(!0),i(ne,null,de(b.value,_=>(n(),i("div",{key:_.label,class:"flex items-start gap-2 rounded-lg bg-white/60 p-2.5 ring-1 ring-gray-900/5 dark:bg-white/5 dark:ring-white/10"},[p(I,{name:_.icon,class:oe(["mt-0.5 h-3.5 w-3.5 shrink-0",_.colorClass])},null,8,["name","class"]),e("div",Ng,[e("div",{class:oe(["truncate font-mono text-sm font-black leading-tight tabular-nums",_.colorClass])},o(_.value),3),e("div",Hg,o(_.label),1),e("div",Yg,o(_.subtext),1)])]))),128))])]),e("div",Wg,[e("div",Kg,[p(I,{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",Qg,o(a(c)("quotes.topicProfile.watermark")),1)])]),_:1})}}}),Jg={class:"px-5 py-4 sm:px-6"},Xg={class:"mb-4 flex items-center gap-2"},Zg={class:"text-[15px] font-black tracking-tight text-gray-900 dark:text-white"},ep={class:"flex flex-wrap justify-center gap-2"},tp=["onClick"],ap=he({__name:"SharedTopicsCard",props:{sessionId:{},timeFilter:{},dictType:{},excludeWords:{}},emits:["wordClick"],setup(l,{emit:s}){const{t}=ke(),c=Ct(),r=l,m=s,u=k(()=>c.locale),d=x([]),g=x([]),v=k(()=>d.value.slice(0,20)),h=["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 S(){if(r.sessionId)try{g.value.length===0&&(g.value=await Ue().getMembers(r.sessionId));const b=[...g.value].sort((C,M)=>M.messageCount-C.messageCount).slice(0,2);if(b.length<2){d.value=[];return}const w={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},[q,T]=await Promise.all([wt("/nlp/word-frequency",{...w,memberId:b[0].id}),wt("/nlp/word-frequency",{...w,memberId:b[1].id})]),I=new Map(T.words.map(C=>[C.word,C.count])),_=[];for(const C of q.words){const M=I.get(C.word);M&&_.push({word:C.word,countA:C.count,countB:M})}_.sort((C,M)=>M.countA+M.countB-(C.countA+C.countB)),d.value=_.slice(0,30)}catch(b){console.error("加载共同话题数据失败:",b),d.value=[]}}return ge(()=>r.sessionId,()=>{g.value=[]}),ge(()=>[r.sessionId,r.timeFilter,r.dictType,r.excludeWords],()=>{S()},{immediate:!0,deep:!0}),(b,w)=>{const q=_e;return v.value.length>0?(n(),K(a(it),{key:0,variant:"section"},{default:U(()=>[e("div",Jg,[e("div",Xg,[p(q,{name:"i-heroicons-link",class:"h-4 w-4 text-emerald-500"}),e("span",Zg,o(a(t)("quotes.topicProfile.sharedTopics")),1)]),e("div",ep,[(n(!0),i(ne,null,de(v.value,(T,I)=>(n(),i("span",{key:T.word,class:oe(["cursor-pointer rounded-full px-3 py-1 text-xs font-bold transition-opacity hover:opacity-80",h[I%h.length]]),onClick:_=>m("wordClick",T.word)},o(T.word),11,tp))),128))])])]),_:1})):R("",!0)}}}),Et="__ALL__",sp=he({__name:"UserSelect",props:{sessionId:{},modelValue:{}},emits:["update:modelValue"],setup(l,{emit:s}){const{t}=ke(),c=l,r=s,m=x([]),u=x(!1),d=k({get:()=>c.modelValue===null?Et:String(c.modelValue),set:h=>{r("update:modelValue",h===Et?null:parseInt(h))}}),g=k(()=>{const h=[{value:Et,label:t("common.userSelect.allMembers")}];return m.value.forEach(S=>{const b=S.groupNickname||S.accountName||S.platformId;h.push({value:String(S.id),label:`${b} (${S.messageCount})`})}),h});async function v(){if(c.sessionId){u.value=!0;try{const h=await Ue().getMembers(c.sessionId);m.value=h.sort((S,b)=>b.messageCount-S.messageCount)}catch(h){console.error("加载成员列表失败:",h)}finally{u.value=!1}}}return ge(()=>c.sessionId,()=>{r("update:modelValue",null),v()},{immediate:!0}),(h,S)=>{const b=Kt;return n(),K(b,{modelValue:d.value,"onUpdate:modelValue":S[0]||(S[0]=w=>d.value=w),items:g.value,loading:u.value,virtualize:{estimateSize:32,overscan:10},"value-key":"value",class:"w-48"},null,8,["modelValue","items","loading"])}}}),xa=Ba("wordFilter",()=>{const l=x([]),s=x(null),t=x({}),c=x(!1);function r(){return`wf_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function m(_,C=[]){const M={id:r(),name:_,words:[...C],createdAt:Date.now()};return l.value.push(M),M}function u(_,C){const M=l.value.find(y=>y.id===_);M&&(C.name!==void 0&&(M.name=C.name),C.words!==void 0&&(M.words=[...C.words]))}function d(_){l.value=l.value.filter(C=>C.id!==_),s.value===_&&(s.value=null);for(const[C,M]of Object.entries(t.value))M===_&&delete t.value[C]}function g(_){s.value=_}function v(_,C){t.value[_]=C}function h(_){delete t.value[_]}function S(_){return _ in t.value?t.value[_]:s.value}function b(_){const C=S(_);return C?l.value.find(y=>y.id===C)?.words??[]:[]}function w(_){return l.value.find(C=>C.id===_)}const q=k(()=>l.value.map(_=>({label:_.name,value:_.id,isDefault:_.id===s.value,wordCount:_.words.length})));function T(){c.value=!0}function I(){c.value=!1}return{schemes:l,defaultSchemeId:s,sessionSchemeOverrides:t,showWordFilterModal:c,schemeOptions:q,createScheme:m,updateScheme:u,deleteScheme:d,setDefaultScheme:g,setSessionScheme:v,clearSessionScheme:h,getActiveSchemeId:S,getExcludeWords:b,getSchemeById:w,openModal:T,closeModal:I}},{persist:!1,backendPersist:{pick:["schemes","defaultSchemeId","sessionSchemeOverrides"],key:"wordFilter"}}),op={class:"flex flex-col",style:{height:"520px"}},np={class:"flex items-center justify-between border-b border-gray-200 px-6 py-4 dark:border-white/5"},rp={class:"flex items-center gap-3"},lp={class:"flex h-9 w-9 items-center justify-center rounded-xl bg-linear-to-br from-pink-400 to-pink-600"},ip={class:"text-lg font-semibold text-gray-900 dark:text-white"},cp={class:"flex flex-1 overflow-hidden"},dp={class:"flex w-[200px] shrink-0 flex-col border-r border-gray-200 dark:border-white/5"},up={class:"flex items-center justify-between px-3 py-2"},mp={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},gp={class:"flex-1 overflow-y-auto px-2 pb-2"},pp=["onClick"],vp={class:"truncate text-sm"},hp={class:"ml-auto text-xs text-gray-400 dark:text-gray-500"},yp={key:0,class:"px-3 py-8 text-center text-xs text-gray-400 dark:text-gray-500"},fp={class:"flex flex-1 flex-col overflow-hidden"},xp={class:"flex-1 space-y-4 overflow-y-auto p-5"},bp={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},kp={class:"flex items-center gap-2"},_p={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},wp={class:"flex gap-2"},$p={class:"mb-1.5 flex items-center justify-between"},Cp={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},Sp={class:"ml-1 text-gray-400 dark:text-gray-500"},Tp={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"},Ip={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"},Mp={class:"flex shrink-0 justify-end border-t border-gray-200 px-5 py-3 dark:border-white/5"},Lp={key:1,class:"flex flex-1 flex-col items-center justify-center gap-3 text-gray-400 dark:text-gray-500"},Dp={class:"text-sm"},Ap=he({__name:"WordFilterModal",setup(l){const{t:s}=ke(),t=xa(),c=k({get:()=>t.showWordFilterModal,set:C=>C?t.openModal():t.closeModal()}),r=x(null),m=x(""),u=x(""),d=x(null),g=k(()=>r.value?t.getSchemeById(r.value)??null:null),v=k(()=>r.value===t.defaultSchemeId);ge(c,C=>{C&&(t.schemes.length>0&&!r.value&&(r.value=t.schemes[0].id),h())}),ge(r,()=>{h(),u.value=""});function h(){m.value=g.value?.name??""}function S(){const C=t.createScheme(s("wordFilter.defaultSchemeName"));r.value=C.id,Ve(()=>{d.value?.focus(),d.value?.select()})}function b(){if(!r.value)return;const C=t.schemes.findIndex(M=>M.id===r.value);if(t.deleteScheme(r.value),t.schemes.length>0){const M=Math.min(C,t.schemes.length-1);r.value=t.schemes[M].id}else r.value=null}function w(){!r.value||!m.value.trim()||t.updateScheme(r.value,{name:m.value.trim()})}function q(){r.value&&(v.value?t.setDefaultScheme(null):t.setDefaultScheme(r.value))}function T(){if(!r.value||!u.value.trim())return;const M=u.value.trim().split(/[,,\n\r\t;;|、\s]+/).map(A=>A.trim()).filter(A=>A.length>0);if(M.length===0)return;const y=g.value;if(!y)return;const f=new Set(y.words.map(A=>A.toLowerCase())),D=M.filter(A=>!f.has(A.toLowerCase()));D.length>0&&t.updateScheme(r.value,{words:[...y.words,...D]}),u.value=""}function I(C){if(!r.value)return;const M=g.value;M&&t.updateScheme(r.value,{words:M.words.filter(y=>y!==C)})}function _(){r.value&&t.updateScheme(r.value,{words:[]})}return(C,M)=>{const y=_e,f=Re,D=ht,A=Wt,P=Oe;return n(),K(P,{open:c.value,"onUpdate:open":M[4]||(M[4]=z=>c.value=z),ui:{content:"max-w-3xl z-50"}},{content:U(()=>[e("div",op,[e("div",np,[e("div",rp,[e("div",lp,[p(y,{name:"i-heroicons-funnel",class:"h-4.5 w-4.5 text-white"})]),e("h2",ip,o(a(s)("wordFilter.title")),1)]),p(f,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:M[0]||(M[0]=z=>c.value=!1)})]),e("div",cp,[e("div",dp,[e("div",up,[e("span",mp,o(a(s)("wordFilter.schemeList")),1),p(f,{icon:"i-heroicons-plus",size:"xs",variant:"ghost",color:"primary",onClick:S})]),e("div",gp,[(n(!0),i(ne,null,de(a(t).schemes,z=>(n(),i("div",{key:z.id,class:oe(["group mb-1 flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 transition-colors",r.value===z.id?"bg-primary-50 text-primary-700 dark:bg-primary-900/20 dark:text-primary-300":"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-white/5"]),onClick:$=>r.value=z.id},[z.id===a(t).defaultSchemeId?(n(),K(y,{key:0,name:"i-heroicons-star-solid",class:"h-3.5 w-3.5 shrink-0 text-amber-500"})):R("",!0),e("span",vp,o(z.name),1),e("span",hp,o(z.words.length),1)],10,pp))),128)),a(t).schemes.length===0?(n(),i("div",yp,o(a(s)("wordFilter.emptyScheme")),1)):R("",!0)])]),e("div",fp,[g.value?(n(),i(ne,{key:0},[e("div",xp,[e("div",null,[e("label",bp,o(a(s)("wordFilter.schemeName")),1),p(D,{ref_key:"nameInputRef",ref:d,modelValue:m.value,"onUpdate:modelValue":M[1]||(M[1]=z=>m.value=z),size:"sm",placeholder:a(s)("wordFilter.schemeNamePlaceholder"),onBlur:w,onKeydown:Xe(w,["enter"])},null,8,["modelValue","placeholder"])]),e("div",kp,[p(f,{size:"xs",variant:v.value?"solid":"soft",color:v.value?"warning":"neutral",icon:v.value?"i-heroicons-star-solid":"i-heroicons-star",onClick:q},{default:U(()=>[ee(o(v.value?a(s)("wordFilter.isDefault"):a(s)("wordFilter.setDefault")),1)]),_:1},8,["variant","color","icon"]),p(f,{size:"xs",variant:"soft",color:"error",icon:"i-heroicons-trash",onClick:b},{default:U(()=>[ee(o(a(s)("wordFilter.deleteScheme")),1)]),_:1})]),e("div",null,[e("label",_p,o(a(s)("wordFilter.addWords")),1),e("div",wp,[p(D,{modelValue:u.value,"onUpdate:modelValue":M[2]||(M[2]=z=>u.value=z),size:"sm",class:"flex-1",placeholder:a(s)("wordFilter.addWordsPlaceholder"),onKeydown:Xe(T,["enter"])},null,8,["modelValue","placeholder"]),p(f,{size:"sm",color:"primary",icon:"i-heroicons-plus",onClick:T},{default:U(()=>[ee(o(a(s)("wordFilter.add")),1)]),_:1})])]),e("div",null,[e("div",$p,[e("label",Cp,[ee(o(a(s)("wordFilter.wordList"))+" ",1),e("span",Sp,"("+o(g.value.words.length)+")",1)]),g.value.words.length>0?(n(),K(f,{key:0,size:"xs",variant:"ghost",color:"error",onClick:_},{default:U(()=>[ee(o(a(s)("wordFilter.clearAll")),1)]),_:1})):R("",!0)]),g.value.words.length>0?(n(),i("div",Tp,[(n(!0),i(ne,null,de(g.value.words,z=>(n(),K(A,{key:z,color:"neutral",variant:"subtle",class:"group/badge cursor-default gap-1 pr-1"},{default:U(()=>[ee(o(z)+" ",1),p(y,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5 cursor-pointer text-gray-400 transition-colors hover:text-red-500",onClick:$=>I(z)},null,8,["onClick"])]),_:2},1024))),128))])):(n(),i("div",Ip,o(a(s)("wordFilter.emptyWords")),1))])]),e("div",Mp,[p(f,{color:"primary",variant:"soft",onClick:M[3]||(M[3]=z=>c.value=!1)},{default:U(()=>[ee(o(a(s)("wordFilter.close")),1)]),_:1})])],64)):(n(),i("div",Lp,[p(y,{name:"i-heroicons-funnel",class:"h-10 w-10"}),e("p",Dp,o(a(s)("wordFilter.selectOrCreate")),1),p(f,{size:"sm",color:"primary",variant:"soft",icon:"i-heroicons-plus",onClick:S},{default:U(()=>[ee(o(a(s)("wordFilter.createScheme")),1)]),_:1})]))])])])]),_:1},8,["open"])}}}),qp={class:"main-content mx-auto max-w-[920px] space-y-6 p-6"},Rp={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"},Ep={class:"flex min-w-0 items-start gap-3"},zp={class:"min-w-0 text-sm text-primary-700 dark:text-primary-300"},Pp={class:"flex shrink-0 flex-wrap gap-2"},Bp={key:1,class:"space-y-6"},jp={class:"flex gap-6 p-4 sm:p-6"},Fp={class:"flex min-w-0 flex-1 flex-col"},Up={class:"relative w-full",style:{"aspect-ratio":"16 / 9"}},Vp={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"},Op={class:"text-xs font-medium"},Np={class:"px-4 text-center text-[11px]"},Hp={class:"mt-2 text-center text-xs text-gray-500 dark:text-gray-400"},Yp={class:"w-[280px] shrink-0 space-y-4"},Wp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Kp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Qp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Gp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Jp={class:"space-y-2"},Xp={class:"text-xs text-gray-400 dark:text-gray-500"},Zp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},ev={class:"flex items-center"},tv={key:0,class:"space-y-2"},av={class:"flex items-center justify-between"},sv={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},ov={class:"flex gap-1"},nv={class:"flex max-h-[360px] flex-wrap gap-1.5 overflow-y-auto"},rv={key:0,class:"ml-1 opacity-60"},lv={class:"mb-2 flex items-center justify-between"},iv={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},cv={key:0,class:"mt-1 text-xs text-gray-400 dark:text-gray-500"},dv={class:"space-y-4"},uv={class:"text-sm text-gray-600 dark:text-gray-300"},mv={class:"flex justify-end gap-2"},gv="default",oa="chatlab_zhTW_dict_prompt_dismissed",s1=he({__name:"WordcloudTab",props:{sessionId:{},timeFilter:{},memberId:{},showSharedTopics:{type:Boolean}},setup(l){const s=da(()=>Tt(()=>import("./EChartWordcloud-B_YisOW5.js"),__vite__mapDeps([5,6,7,8,1]))),{t}=ke(),c=Ct(),r=dt(),m=xa(),u=Je(),d=l,g=x(!1),v=x([]),h=x({totalMessages:0,totalWords:0,uniqueWords:0}),S=x(1.25),b=x(150),w=k(()=>{const me=v.value.slice(0,b.value),E=me.reduce((H,se)=>H+se.count,0);return{words:me.map(H=>({word:H.word,count:H.count,percentage:E>0?Math.round(H.count/E*1e4)/100:0}))}}),q=x("meaningful"),T=x(!0),I=x([]),_=x([]),C=x(new Map),M=["n","nr","ns","nt","nz","nw","vn","a","an"],y=x([]),f=k(()=>w.value.words.map(me=>({word:me.word,count:me.count,percentage:me.percentage??0}))),D=k(()=>[...C.value.entries()].map(([me,E])=>({tag:me,count:E}))),A=x(null),P=k({get:()=>m.getActiveSchemeId(d.sessionId),set:me=>m.setSessionScheme(d.sessionId,me)}),z=k(()=>[{label:t("wordFilter.noFilter"),value:"__none__"},...m.schemeOptions.map(me=>({label:me.isDefault?`${me.label} ★`:me.label,value:me.value}))]),$=k({get:()=>P.value??"__none__",set:me=>{P.value=me==="__none__"?null:me}}),L=k(()=>m.getExcludeWords(d.sessionId)),W=x("default"),ae=x([]),Y=x(!1),pe=x(null),ye=x(!1),Q=x(!1),V=k(()=>c.locale),te=k(()=>c.locale==="zh-TW"),xe=k(()=>V.value.startsWith("zh")),fe=k(()=>ae.value.filter(me=>me.downloaded).map(me=>({label:t(`quotes.wordcloud.dict.${me.id==="zh-CN"?"zhCN":me.id==="zh-TW"?"zhTW":me.id}`),value:me.id}))),X=k(()=>ae.value.some(me=>me.downloaded)),O=k(()=>!xe.value||Q.value),B=k(()=>ae.value.filter(me=>!me.downloaded));async function F(){try{ae.value=await Zt("/nlp/dicts"),te.value&&W.value==="default"&&ae.value.find(H=>H.id==="zh-TW")?.downloaded&&(W.value="zh-TW"),ae.value.find(E=>E.id==="zh-CN")?.downloaded&&W.value==="default"&&(W.value="zh-CN")}catch(me){console.error("Failed to get dict list:",me)}finally{Q.value=!0}}async function J(me){Y.value=!0,pe.value=me;try{const E=await ja(`/nlp/dicts/${me}/download`);E.success?(await F(),W.value=me,u.success(t("quotes.wordcloud.dict.downloadSuccess"))):u.fail(t("quotes.wordcloud.dict.downloadFailed"),{description:E.error})}catch{u.fail(t("quotes.wordcloud.dict.downloadFailed"))}finally{Y.value=!1,pe.value=null,ye.value=!1}}function ce(){ye.value=!1,localStorage.setItem(oa,"true")}function ve(){const me=ae.value.find(E=>E.id==="zh-TW");te.value&&me&&!me.downloaded&&!localStorage.getItem(oa)&&(ye.value=!0)}const G=k(()=>[{label:t("quotes.wordcloud.posFilter.all"),value:"all"},{label:t("quotes.wordcloud.posFilter.meaningful"),value:"meaningful"},{label:t("quotes.wordcloud.posFilter.custom"),value:"custom"}]),re=[{label:"80",value:80},{label:"100",value:100},{label:"150",value:150},{label:"200",value:200},{label:"300",value:300}],be=Math.max(...re.map(me=>me.value)),ue=k(()=>[{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}]),we=k(()=>_.value.map(me=>({label:me.name,tag:me.tag,value:me.tag,count:C.value.get(me.tag)||0,meaningful:me.meaningful})));async function Le(){try{const me=await Zt("/nlp/pos-tags");_.value=me,I.value=me.filter(E=>E.meaningful).map(E=>E.tag)}catch(me){console.error("加载词性标签失败:",me)}}let De=0;async function Te(){if(!d.sessionId||!O.value)return;const me=++De;try{const E=await wt("/nlp/word-frequency",{sessionId:d.sessionId,locale:V.value,timeFilter:d.timeFilter?{startTs:d.timeFilter.startTs,endTs:d.timeFilter.endTs}:void 0,memberId:A.value??void 0,topN:50,minCount:2,posFilterMode:"custom",customPosTags:[...M],enableStopwords:!0,dictType:W.value,excludeWords:L.value.length>0?[...L.value]:void 0});if(me!==De)return;y.value=E.words.map(H=>({word:H.word,count:H.count,percentage:H.percentage}))}catch(E){if(console.error("加载话题迷你词云数据失败:",E),me!==De)return;y.value=[]}}let ze=0;async function Pe(){if(!d.sessionId||!O.value)return;const me=++ze;v.value.length===0&&(g.value=!0);try{const E=await wt("/nlp/word-frequency",{sessionId:d.sessionId,locale:V.value,timeFilter:d.timeFilter?{startTs:d.timeFilter.startTs,endTs:d.timeFilter.endTs}:void 0,memberId:A.value??void 0,topN:be,minCount:2,posFilterMode:q.value,customPosTags:q.value==="custom"?[...I.value]:void 0,enableStopwords:T.value,dictType:W.value,excludeWords:L.value.length>0?[...L.value]:void 0});if(me!==ze)return;if(v.value=E.words.map(H=>({word:H.word,count:H.count,percentage:H.percentage})),h.value={totalMessages:E.totalMessages,totalWords:E.totalWords,uniqueWords:E.uniqueWords},E.posTagStats){const H=new Map;for(const se of E.posTagStats)H.set(se.tag,se.count);C.value=H}}catch(E){if(console.error("加载词频数据失败:",E),me!==ze)return;v.value=[]}finally{me===ze&&(g.value=!1)}}ge(()=>d.sessionId,()=>{A.value=null,v.value=[],y.value=[],h.value={totalMessages:0,totalWords:0,uniqueWords:0},C.value=new Map}),ge(()=>[d.sessionId,d.timeFilter,A.value,q.value,T.value,W.value,L.value,O.value],()=>{Pe()},{immediate:!0,deep:!0}),ge(()=>[d.sessionId,d.timeFilter,A.value,W.value,L.value,O.value],()=>{Te()},{immediate:!0,deep:!0}),ge(I,()=>{q.value==="custom"&&Pe()},{deep:!0}),ge(V,()=>{Pe()});function je(me){r.openChatRecordDrawer({keywords:[me]})}return Ee(async()=>{Le(),await F(),ve()}),(me,E)=>{const H=_e,se=Re,N=ma,j=Wt,ie=Oe;return n(),i("div",qp,[xe.value&&!X.value?(n(),i("div",Rp,[e("div",Ep,[p(H,{name:"i-heroicons-information-circle",class:"mt-0.5 shrink-0 text-xl text-primary-500"}),e("p",zp,o(a(t)("quotes.wordcloud.dict.needDownload")),1)]),e("div",Pp,[(n(!0),i(ne,null,de(ae.value,Z=>(n(),K(se,{key:Z.id,size:"sm",color:"primary",loading:Y.value&&pe.value===Z.id,disabled:Y.value&&pe.value!==Z.id,icon:"i-heroicons-arrow-down-tray",onClick:le=>J(Z.id)},{default:U(()=>[ee(o(a(t)(`quotes.wordcloud.dict.download_${Z.id}`,Z.label)),1)]),_:2},1032,["loading","disabled","onClick"]))),128))])])):R("",!0),O.value?(n(),i("div",Bp,[g.value&&f.value.length===0?(n(),K(a(mt),{key:0,text:a(t)("quotes.wordcloud.loading"),class:"py-8"},null,8,["text"])):R("",!0),p(Gg,{"total-messages":h.value.totalMessages,"total-words":h.value.totalWords,"unique-words":h.value.uniqueWords,"top-words":f.value,"topic-words":y.value,"pos-tag-stats":D.value,"time-filter":d.timeFilter,onWordClick:je},null,8,["total-messages","total-words","unique-words","top-words","topic-words","pos-tag-stats","time-filter"]),d.showSharedTopics?(n(),K(ap,{key:1,"session-id":d.sessionId,"time-filter":d.timeFilter,"dict-type":W.value,"exclude-words":L.value,onWordClick:je},null,8,["session-id","time-filter","dict-type","exclude-words"])):R("",!0),p(a(We),{title:a(t)("quotes.wordcloud.stats.wordsLabel"),"show-divider":!1},{default:U(()=>[e("div",jp,[e("div",Fp,[e("div",Up,[g.value?(n(),K(a(mt),{key:0,text:a(t)("quotes.wordcloud.loading"),class:"absolute inset-0 z-10 rounded-lg bg-white/80 dark:bg-gray-900/80"},null,8,["text"])):f.value.length===0?(n(),i("div",Vp,[p(H,{name:"i-heroicons-chat-bubble-bottom-center-text",class:"text-2xl"}),e("p",Op,o(a(t)("quotes.wordcloud.empty.title")),1),e("p",Np,o(a(t)("quotes.wordcloud.empty.description")),1)])):(n(),K(a(s),{key:2,data:w.value,height:"100%","max-words":b.value,"color-scheme":gv,"size-scale":S.value,loading:g.value,onWordClick:je},null,8,["data","max-words","size-scale","loading"]))]),e("p",Hp,o(a(t)("quotes.wordcloud.stats.clickHint")),1)]),e("div",Yp,[e("div",null,[e("h4",Wp,o(a(t)("quotes.wordcloud.config.maxWords")),1),p(a(et),{modelValue:b.value,"onUpdate:modelValue":E[0]||(E[0]=Z=>b.value=Z),size:"xs",items:re},null,8,["modelValue"])]),e("div",null,[e("h4",Kp,o(a(t)("quotes.wordcloud.config.sizeScale")),1),p(a(et),{modelValue:S.value,"onUpdate:modelValue":E[1]||(E[1]=Z=>S.value=Z),size:"xs",items:ue.value},null,8,["modelValue","items"])]),e("div",null,[e("h4",Qp,o(a(t)("quotes.wordcloud.config.userFilter")),1),p(sp,{modelValue:A.value,"onUpdate:modelValue":E[2]||(E[2]=Z=>A.value=Z),"session-id":d.sessionId,class:"w-full"},null,8,["modelValue","session-id"])]),e("div",null,[e("h4",Gp,o(a(t)("quotes.wordcloud.config.dict")),1),e("div",Jp,[fe.value.length>1?(n(),K(a(et),{key:0,modelValue:W.value,"onUpdate:modelValue":E[3]||(E[3]=Z=>W.value=Z),size:"xs",items:fe.value},null,8,["modelValue","items"])):R("",!0),(n(!0),i(ne,null,de(B.value,Z=>(n(),i("div",{key:Z.id,class:"flex items-center gap-2"},[p(se,{size:"xs",variant:"soft",color:"primary",loading:Y.value&&pe.value===Z.id,disabled:Y.value&&pe.value!==Z.id,icon:"i-heroicons-arrow-down-tray",onClick:le=>J(Z.id)},{default:U(()=>[ee(o(a(t)(`quotes.wordcloud.dict.download_${Z.id}`,a(t)("quotes.wordcloud.dict.download"))),1)]),_:2},1032,["loading","disabled","onClick"]),e("span",Xp,o(a(t)("quotes.wordcloud.dict.downloadHint")),1)]))),128))])]),e("div",null,[e("h4",Zp,o(a(t)("quotes.wordcloud.config.posFilter")),1),p(a(et),{modelValue:q.value,"onUpdate:modelValue":E[4]||(E[4]=Z=>q.value=Z),size:"xs",items:G.value},null,8,["modelValue","items"])]),e("div",ev,[p(N,{modelValue:T.value,"onUpdate:modelValue":E[5]||(E[5]=Z=>T.value=Z),label:a(t)("quotes.wordcloud.config.enableStopwords")},null,8,["modelValue","label"])]),q.value==="custom"?(n(),i("div",tv,[e("div",av,[e("h4",sv,o(a(t)("quotes.wordcloud.posFilter.customHint")),1),e("div",ov,[p(se,{size:"xs",variant:"ghost",color:"neutral",onClick:E[6]||(E[6]=Z=>I.value=_.value.filter(le=>le.meaningful).map(le=>le.tag))},{default:U(()=>[ee(o(a(t)("quotes.wordcloud.posFilter.selectMeaningful")),1)]),_:1}),p(se,{size:"xs",variant:"ghost",color:"neutral",onClick:E[7]||(E[7]=Z=>I.value=_.value.map(le=>le.tag))},{default:U(()=>[ee(o(a(t)("quotes.wordcloud.posFilter.selectAll")),1)]),_:1}),p(se,{size:"xs",variant:"ghost",color:"neutral",onClick:E[8]||(E[8]=Z=>I.value=[])},{default:U(()=>[ee(o(a(t)("quotes.wordcloud.posFilter.clearAll")),1)]),_:1})])]),e("div",nv,[(n(!0),i(ne,null,de(we.value,Z=>(n(),K(j,{key:Z.value,color:I.value.includes(Z.value)?"primary":"neutral",variant:I.value.includes(Z.value)?"solid":"outline",class:"cursor-pointer select-none transition-colors",onClick:()=>{I.value.includes(Z.value)?I.value=I.value.filter(le=>le!==Z.value):I.value=[...I.value,Z.value]}},{default:U(()=>[ee(o(Z.label)+" ",1),Z.count>0?(n(),i("span",rv,"("+o(Z.count)+")",1)):R("",!0)]),_:2},1032,["color","variant","onClick"]))),128))])])):R("",!0),e("div",null,[e("div",lv,[e("h4",iv,o(a(t)("wordFilter.filterScheme")),1),p(se,{size:"xs",variant:"ghost",color:"neutral",icon:"i-heroicons-cog-6-tooth","aria-label":a(t)("wordFilter.manage"),onClick:E[9]||(E[9]=Z=>a(m).openModal())},null,8,["aria-label"])]),p(a(et),{modelValue:$.value,"onUpdate:modelValue":E[10]||(E[10]=Z=>$.value=Z),size:"xs",items:z.value},null,8,["modelValue","items"]),L.value.length>0?(n(),i("p",cv,o(a(t)("wordFilter.activeCount",{count:L.value.length})),1)):R("",!0)])])])]),_:1},8,["title"])])):R("",!0),p(ie,{open:ye.value,"onUpdate:open":E[12]||(E[12]=Z=>ye.value=Z),title:a(t)("quotes.wordcloud.dict.promptTitle")},{body:U(()=>[e("div",dv,[e("p",uv,o(a(t)("quotes.wordcloud.dict.promptDescription")),1),e("div",mv,[p(se,{variant:"ghost",color:"neutral",onClick:ce},{default:U(()=>[ee(o(a(t)("quotes.wordcloud.dict.promptLater")),1)]),_:1}),p(se,{color:"primary",loading:Y.value,onClick:E[11]||(E[11]=Z=>J("zh-TW"))},{default:U(()=>[ee(o(a(t)("quotes.wordcloud.dict.promptDownload")),1)]),_:1},8,["loading"])])])]),_:1},8,["open","title"]),p(Ap)])}}}),pv={class:"flex h-full flex-col"},vv={class:"flex-1 min-h-0 overflow-hidden"},hv={key:1,class:"h-full overflow-auto"},yv={class:"main-content mx-auto max-w-3xl p-6"},fv=he({__name:"AITab",props:{sessionId:{},sessionName:{},timeFilter:{},chatType:{},mode:{}},setup(l,{expose:s}){const{t}=ke(),c=Qa(),r=l,m=k(()=>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=x(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=x(null);function g(){d.value?.refreshConfig()}return s({refreshAIConfig:g}),(v,h)=>(n(),i("div",pv,[p(a(ia),{modelValue:u.value,"onUpdate:modelValue":h[0]||(h[0]=S=>u.value=S),items:m.value,"persist-key":"aiTab"},null,8,["modelValue","items"]),e("div",vv,[p(rt,{name:"fade",mode:"out-in"},{default:U(()=>[u.value==="chat-explorer"?(n(),K(a(Vu),{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",hv,[e("div",yv,[p(a(_g),{"session-id":r.sessionId,"time-filter":r.timeFilter},null,8,["session-id","time-filter"])])])):(n(),K(Lm,{key:2,class:"h-full","session-id":r.sessionId,"chat-type":r.chatType},null,8,["session-id","chat-type"]))]),_:1})])]))}}),o1=st(fv,[["__scopeId","data-v-0df46b7b"]]),xv={class:"flex h-full items-center justify-center"},bv={class:"max-w-sm text-center"},kv={class:"mt-3 text-sm text-gray-400 dark:text-gray-500"},_v=["href"],n1=he({__name:"MemoryTab",props:{sessionId:{},sessionName:{}},setup(l){const{t:s,te:t}=ke(),c=k(()=>t("analysis.memory.joinLink")?s("analysis.memory.joinLink"):"");return(r,m)=>{const u=_e;return n(),i("div",xv,[e("div",bv,[p(u,{name:"i-heroicons-light-bulb",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),e("p",kv,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,_v)):R("",!0)])])}}}),wv={class:"flex h-full flex-col"},$v={class:"relative z-20 flex items-center gap-2 border-b border-gray-200 px-4 py-2 dark:border-gray-700"},Cv={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"},Sv={class:"flex-1 overflow-auto"},Tv={key:0,class:"flex h-full items-center justify-center"},Iv={class:"text-sm text-gray-400"},Mv={key:1,class:"w-full border-collapse text-xs"},Lv={class:"sticky top-0 bg-gray-50 dark:bg-gray-800"},Dv={class:"font-mono text-xs font-medium text-gray-700 dark:text-gray-300"},Av={class:"text-[10px] leading-tight text-gray-400"},qv={class:"border-b border-r border-gray-100 px-2 py-1.5 text-gray-400 dark:border-gray-800"},Rv=["title"],Ev=["onUpdate:modelValue"],zv={class:"w-full truncate px-2 py-1.5"},Pv={key:0,class:"italic text-gray-400"},Bv={key:1},jv={class:"border-b border-gray-100 px-2 py-1.5 text-center dark:border-gray-800"},Fv={key:0,class:"flex items-center justify-center gap-1"},Uv={key:1,class:"flex items-center justify-center gap-1"},Vv={class:"flex items-center justify-between border-t border-gray-200 px-4 py-2 dark:border-gray-700"},Ov={class:"text-xs text-gray-500 dark:text-gray-400"},Nv={key:0,class:"flex items-center gap-3"},Hv={class:"text-xs text-gray-500 dark:text-gray-400"},_t=100,Yv=he({__name:"TableBrowser",props:{sessionId:{}},setup(l){const s=["member","meta","message","message_context","member_name_history"],{t,locale:c}=ke(),r=l,m=x(localStorage.getItem("debug_dbSource")||"chat"),u=x([]),d=x(""),g=x(null),v=x(!1),h=x(null),S=x(1),b=x(0),w=k(()=>Math.max(1,Math.ceil(b.value/_t))),q=x(null),T=x({}),I=x(!1),_=k(()=>m.value==="ai"),C=x([]),M=x(""),y=k(()=>_.value&&d.value==="ai_message"&&C.value.length>0),f=k(()=>{const X={label:t("analysis.debug.tableBrowser.allConversations"),value:"__all__"},O=C.value.map(B=>({label:B.title||B.id.slice(0,16),value:B.id}));return[X,...O]});async function D(){if(!_.value){C.value=[];return}try{const X=r.sessionId.replace(/'/g,"''"),O=await Ne().executeAiSQL(`SELECT id, title FROM ai_chat WHERE session_id = '${X}' ORDER BY updated_at DESC`);C.value=O.rows.map(B=>({id:String(B[0]),title:B[1]?String(B[1]):null})),M.value="__all__"}catch{C.value=[]}}const A=k(()=>[{label:t("analysis.debug.tableBrowser.chatDb"),value:"chat"},{label:t("analysis.debug.tableBrowser.aiDb"),value:"ai"}]),P=k(()=>{const X=[...u.value];return X.sort((O,B)=>{const F=s.indexOf(O.name),J=s.indexOf(B.name);return F!==-1&&J!==-1?F-J:F!==-1?-1:J!==-1?1:0}),X}),z=k(()=>P.value.map(X=>({label:X.name,value:X.name})));async function $(X){return m.value==="ai"?await Ne().executeAiSQL(X):await Ue().executeSQL(r.sessionId,X)}async function L(){try{if(m.value==="ai"?u.value=await Ne().getAiSchema():u.value=await Ue().getSchema(r.sessionId),P.value.length>0){const X=_.value?"ai_message":P.value[0].name;d.value=P.value.some(O=>O.name===X)?X:P.value[0].name}else d.value="",g.value=null}catch(X){console.error("Failed to load schema:",X)}}function W(){if(!_.value)return"";const X=r.sessionId.replace(/'/g,"''"),O=d.value;return O==="ai_chat"?` WHERE "session_id" = '${X}'`:O==="ai_message"?M.value&&M.value!=="__all__"?` WHERE "ai_chat_id" = '${M.value.replace(/'/g,"''")}'`:` WHERE "ai_chat_id" IN (SELECT "id" FROM "ai_chat" WHERE "session_id" = '${X}')`:""}async function ae(){if(d.value){v.value=!0,h.value=null,q.value=null;try{const X=W(),O=await $(`SELECT COUNT(*) as cnt FROM "${d.value}"${X}`);b.value=O?.rows?.[0]?.[0]??0;const B=(S.value-1)*_t;g.value=await $(`SELECT * FROM "${d.value}"${X} ORDER BY rowid DESC LIMIT ${_t} OFFSET ${B}`)}catch(X){h.value=X.message||String(X),g.value=null}finally{v.value=!1}}}function Y(X){if(!g.value)return;q.value=X;const O=g.value.rows[X],B={};g.value.columns.forEach((F,J)=>{B[F]=O[J]==null?"":String(O[J])}),T.value=B}function pe(){q.value=null,T.value={}}async function ye(){if(q.value===null||!g.value)return;const X=d.value,O=u.value.find(re=>re.name===X);if(!O)return;const B=O.columns.find(re=>re.pk);if(!B){h.value="No primary key found for this table";return}const F=g.value.rows[q.value],J=g.value.columns.indexOf(B.name),ce=F[J],ve=g.value.columns.filter(re=>re!==B.name).map(re=>`"${re}" = '${T.value[re].replace(/'/g,"''")}'`).join(", "),G=`UPDATE "${X}" SET ${ve} WHERE "${B.name}" = '${String(ce).replace(/'/g,"''")}'`;try{await $(G),pe(),await ae()}catch(re){h.value=re.message||String(re)}}async function Q(X){if(!g.value)return;const O=d.value,B=u.value.find(re=>re.name===O);if(!B)return;const F=B.columns.find(re=>re.pk);if(!F){h.value="No primary key found for this table";return}const J=g.value.rows[X],ce=g.value.columns.indexOf(F.name),ve=J[ce],G=`DELETE FROM "${O}" WHERE "${F.name}" = '${String(ve).replace(/'/g,"''")}'`;try{await $(G),await ae()}catch(re){h.value=re.message||String(re)}}function V(X){confirm(t("analysis.debug.tableBrowser.confirmDelete"))&&Q(X)}async function te(){if(confirm(t("analysis.debug.tableBrowser.confirmClearDebug"))){I.value=!0;try{(await Ne().clearDebugContext()).success&&await ae()}catch(X){h.value=X.message||String(X)}finally{I.value=!1}}}function xe(X){navigator.clipboard.writeText(X)}function fe(X,O,B){if(!g.value)return[];const F=X==null?"NULL":String(X),J=g.value.rows[B],ce={};return g.value.columns.forEach((ve,G)=>{ce[ve]=J[G]}),[[{label:t("analysis.debug.tableBrowser.copyCell"),class:"p-2",onSelect:()=>xe(F)},{label:t("analysis.debug.tableBrowser.editRow"),class:"p-2",onSelect:()=>Y(B)},{label:t("analysis.debug.tableBrowser.copyRow"),class:"p-2",onSelect:()=>xe(JSON.stringify(ce,null,2))},{label:t("analysis.debug.tableBrowser.deleteRow"),class:"p-2 text-red-600 dark:text-red-400",onSelect:()=>Q(B)}]]}return ge(m,X=>{localStorage.setItem("debug_dbSource",X),d.value="",g.value=null,b.value=0,S.value=1,M.value="",L(),D()}),ge(d,X=>{X&&(S.value=1,ae())}),ge(M,()=>{d.value==="ai_message"&&(S.value=1,ae())}),ge(S,()=>{ae()}),Ee(async()=>{await Promise.all([L(),D()]),d.value&&await ae()}),(X,O)=>{const B=Kt,F=Re,J=ga;return n(),i("div",wv,[e("div",$v,[p(a(et),{modelValue:m.value,"onUpdate:modelValue":O[0]||(O[0]=ce=>m.value=ce),items:A.value,size:"xs"},null,8,["modelValue","items"]),O[5]||(O[5]=e("div",{class:"mx-1 h-4 w-px bg-gray-200 dark:bg-gray-700"},null,-1)),e("div",{class:oe([_.value?"max-w-[50%]":"flex-1","min-w-0"])},[p(a(et),{modelValue:d.value,"onUpdate:modelValue":O[1]||(O[1]=ce=>d.value=ce),items:z.value,size:"xs"},null,8,["modelValue","items"])],2),y.value?(n(),K(B,{key:0,modelValue:M.value,"onUpdate:modelValue":O[2]||(O[2]=ce=>M.value=ce),items:f.value,"value-key":"value",class:"w-48",size:"xs",ui:{content:"z-50"}},null,8,["modelValue","items"])):R("",!0),O[6]||(O[6]=e("div",{class:"flex-1"},null,-1)),_.value&&d.value==="ai_message"?(n(),K(F,{key:1,variant:"ghost",size:"xs",color:"error",icon:"i-heroicons-trash",loading:I.value,onClick:te},{default:U(()=>[ee(o(a(t)("analysis.debug.tableBrowser.clearDebugContext")),1)]),_:1},8,["loading"])):R("",!0),p(F,{variant:"ghost",size:"xs",icon:"i-heroicons-arrow-path",loading:v.value,onClick:ae},{default:U(()=>[ee(o(a(t)("analysis.debug.tableBrowser.refresh")),1)]),_:1},8,["loading"])]),h.value?(n(),i("div",Cv,o(h.value),1)):R("",!0),e("div",Sv,[!g.value&&!v.value?(n(),i("div",Tv,[e("p",Iv,o(a(t)("analysis.debug.tableBrowser.noData")),1)])):g.value?(n(),i("table",Mv,[e("thead",Lv,[e("tr",null,[O[7]||(O[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(ne,null,de(g.value.columns,ce=>(n(),i("th",{key:ce,class:"border-b border-r border-gray-200 px-2 py-1.5 text-left dark:border-gray-700"},[e("div",Dv,o(ce),1),e("div",Av,o(a(Xt)(d.value,ce,a(c))),1)]))),128)),O[8]||(O[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(ne,null,de(g.value.rows,(ce,ve)=>(n(),i("tr",{key:ve,class:"transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[e("td",qv,o((S.value-1)*_t+ve+1),1),(n(!0),i(ne,null,de(ce,(G,re)=>(n(),i("td",{key:re,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:G==null?"NULL":String(G)},[q.value===ve?He((n(),i("input",{key:0,"onUpdate:modelValue":be=>T.value[g.value.columns[re]]=be,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,Ev)),[[ot,T.value[g.value.columns[re]]]]):(n(),K(J,{key:1,items:fe(G,re,ve)},{default:U(()=>[e("div",zv,[G==null?(n(),i("span",Pv,"NULL")):(n(),i("span",Bv,o(String(G).slice(0,200)),1))])]),_:2},1032,["items"]))],8,Rv))),128)),e("td",jv,[q.value===ve?(n(),i("div",Fv,[p(F,{size:"xs",color:"primary",variant:"ghost",icon:"i-heroicons-check",onClick:ye}),p(F,{size:"xs",color:"neutral",variant:"ghost",icon:"i-heroicons-x-mark",onClick:pe})])):(n(),i("div",Uv,[p(F,{size:"xs",variant:"ghost",icon:"i-heroicons-pencil-square",onClick:G=>Y(ve)},null,8,["onClick"]),p(F,{size:"xs",variant:"ghost",color:"error",icon:"i-heroicons-trash",onClick:G=>V(ve)},null,8,["onClick"])]))])]))),128))])])):R("",!0)]),e("div",Vv,[e("span",Ov,o(b.value>0?a(t)("analysis.debug.tableBrowser.rowCount",{count:b.value}):""),1),w.value>1?(n(),i("div",Nv,[p(F,{size:"xs",variant:"ghost",disabled:S.value<=1,icon:"i-heroicons-chevron-left",onClick:O[3]||(O[3]=ce=>S.value--)},null,8,["disabled"]),e("span",Hv,o(a(t)("analysis.debug.tableBrowser.page",{current:S.value,total:w.value})),1),p(F,{size:"xs",variant:"ghost",disabled:S.value>=w.value,icon:"i-heroicons-chevron-right",onClick:O[4]||(O[4]=ce=>S.value++)},null,8,["disabled"])])):R("",!0)])])}}}),Wv={class:"flex h-full"},Kv={class:"w-56 shrink-0 overflow-y-auto border-r border-gray-200 bg-gray-50/50 dark:border-gray-700 dark:bg-gray-800/50"},Qv={key:0,class:"py-2"},Gv={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},Jv=["title","onClick"],Xv={class:"truncate text-xs font-medium"},Zv={class:"truncate text-[10px] opacity-50"},eh={key:1,class:"border-t border-gray-200 py-2 dark:border-gray-700"},th={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},ah=["title","onClick"],sh={class:"truncate text-xs font-medium"},oh={class:"truncate text-[10px] opacity-50"},nh={class:"flex flex-1 flex-col gap-4 overflow-y-auto p-4"},rh={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"},lh={class:"text-sm font-medium text-primary-700 dark:text-primary-300"},ih={class:"mt-1 text-xs text-primary-600/70 dark:text-primary-400/70"},ch={key:1,class:"flex flex-col gap-3"},dh={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},uh={class:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3"},mh={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},gh={key:0,class:"text-red-500"},ph={key:1,class:"ml-1 text-gray-400"},vh={key:2,class:"ml-1 text-gray-400"},hh={class:"flex items-center gap-3"},yh={key:3,class:"text-xs text-gray-500 dark:text-gray-400"},fh={key:2,class:"flex-1 min-h-0"},xh={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},bh={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"},kh={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"},_h={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"},wh=he({__name:"ToolTestTab",props:{sessionId:{}},setup(l){const{t:s}=ke(),t=l,c=x([]),r=x(""),m=x({}),u=x(!1),d=x(null),g=x(null),v=x(null),h=x(!1),S=x(null);function b(y){const f=`ai.assistant.builtinToolDesc.${y}`,D=s(f);return D!==f?D:y}const w=k(()=>c.value.filter(y=>y.category==="core")),q=k(()=>c.value.filter(y=>y.category==="analysis")),T=k(()=>c.value.find(y=>y.name===r.value)),I=k(()=>{const y=T.value;if(!y?.parameters)return[];const f=y.parameters;if(!f.properties)return[];const D=new Set(f.required??[]);return Object.entries(f.properties).map(([A,P])=>{const z={name:A,type:P.type??"string",description:P.description??"",required:D.has(A),defaultValue:P.default};if(P.enum&&(z.enumValues=P.enum),P.type==="array"){z.isArray=!0;const $=P.items;z.arrayItemType=$?.type??"string"}return z})});ge(r,()=>{m.value={},g.value=null,v.value=null,S.value=null}),Ee(async()=>{try{c.value=await Ne().getToolCatalog(),c.value.length>0&&(r.value=c.value[0].name)}catch(y){console.error("Failed to load tool catalog:",y)}});function _(){const y={};for(const f of I.value){const D=m.value[f.name];if(!(D===void 0||D===""))if(f.type==="number"){const A=Number(D);isNaN(A)||(y[f.name]=A)}else f.isArray?y[f.name]=D.split(",").map(A=>A.trim()).filter(Boolean):y[f.name]=D}return y}async function C(){if(!r.value||u.value)return;u.value=!0,g.value=null,v.value=null,h.value=!1,S.value=null;const y=`tool_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;d.value=y;try{const f=_(),D=await Ne().executeTool(y,r.value,f,t.sessionId);if(D.error==="cancelled")return;D.success?(S.value=D.elapsed??null,h.value=!!D.truncated,g.value=D.truncated?D.details?._preview??"":JSON.stringify(D.details??D.content,null,2)):v.value=D.error??"Unknown error"}catch(f){v.value=String(f)}finally{u.value=!1,d.value=null}}async function M(){d.value&&(await Ne().cancelToolTest(d.value),u.value=!1,d.value=null)}return(y,f)=>{const D=Kt,A=ht,P=Re,z=_e;return n(),i("div",Wv,[e("div",Kv,[w.value.length>0?(n(),i("div",Qv,[e("div",Gv,o(a(s)("ai.lab.toolTest.coreTools")),1),(n(!0),i(ne,null,de(w.value,$=>(n(),i("button",{key:$.name,class:oe(["flex w-full flex-col px-3 py-1.5 text-left transition-colors",[r.value===$.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:$.description,onClick:L=>r.value=$.name},[e("span",Xv,o(b($.name)),1),e("span",Zv,o($.name),1)],10,Jv))),128))])):R("",!0),q.value.length>0?(n(),i("div",eh,[e("div",th,o(a(s)("ai.lab.toolTest.analysisTools")),1),(n(!0),i(ne,null,de(q.value,$=>(n(),i("button",{key:$.name,class:oe(["flex w-full flex-col px-3 py-1.5 text-left transition-colors",[r.value===$.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:$.description,onClick:L=>r.value=$.name},[e("span",sh,o(b($.name)),1),e("span",oh,o($.name),1)],10,ah))),128))])):R("",!0)]),e("div",nh,[T.value?(n(),i("div",rh,[e("div",lh,o(b(T.value.name)),1),e("div",ih,o(T.value.description),1)])):R("",!0),I.value.length>0?(n(),i("div",ch,[e("h3",dh,o(a(s)("ai.lab.toolTest.parameters")),1),e("div",uh,[(n(!0),i(ne,null,de(I.value,$=>(n(),i("div",{key:$.name,class:"flex flex-col gap-1"},[e("label",mh,[ee(o($.name)+" ",1),$.required?(n(),i("span",gh,"*")):R("",!0),$.type==="number"?(n(),i("span",ph,"(number)")):R("",!0),$.isArray?(n(),i("span",vh,"("+o($.arrayItemType)+"[])",1)):R("",!0)]),$.enumValues?(n(),K(D,{key:0,modelValue:m.value[$.name],"onUpdate:modelValue":L=>m.value[$.name]=L,items:$.enumValues,placeholder:$.description,size:"sm"},null,8,["modelValue","onUpdate:modelValue","items","placeholder"])):(n(),K(A,{key:1,modelValue:m.value[$.name],"onUpdate:modelValue":L=>m.value[$.name]=L,placeholder:$.isArray?a(s)("ai.lab.toolTest.arrayPlaceholder"):$.defaultValue!==void 0?String($.defaultValue):$.description,type:$.type==="number"?"number":"text",size:"sm"},null,8,["modelValue","onUpdate:modelValue","placeholder","type"]))]))),128))])])):R("",!0),e("div",hh,[u.value?(n(),K(P,{key:1,color:"error",icon:"i-heroicons-stop",onClick:M},{default:U(()=>[ee(o(a(s)("ai.lab.toolTest.cancel")),1)]),_:1})):(n(),K(P,{key:0,color:"primary",disabled:!r.value,icon:"i-heroicons-play",onClick:C},{default:U(()=>[ee(o(a(s)("ai.lab.toolTest.execute")),1)]),_:1},8,["disabled"])),u.value?(n(),K(z,{key:2,name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin text-gray-400"})):R("",!0),S.value!==null?(n(),i("span",yh,o(a(s)("ai.lab.toolTest.elapsed",{ms:S.value})),1)):R("",!0)]),g.value||v.value?(n(),i("div",fh,[e("h3",xh,o(a(s)("ai.lab.toolTest.result")),1),v.value?(n(),i("div",bh,o(v.value),1)):(n(),i(ne,{key:1},[h.value?(n(),i("div",kh,o(a(s)("ai.lab.toolTest.truncated")),1)):R("",!0),e("pre",_h,o(g.value),1)],64))])):R("",!0)])])}}}),$h={class:"flex h-full flex-col"},Ch={class:"min-h-0 flex-1 overflow-hidden"},Sh=he({__name:"DebugTab",props:{sessionId:{}},setup(l){const{t:s}=ke(),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=x("sql-tables");return(m,u)=>(n(),i("div",$h,[p(a(ia),{modelValue:r.value,"onUpdate:modelValue":u[0]||(u[0]=d=>r.value=d),items:c,"persist-key":"debugTab"},null,8,["modelValue"]),e("div",Ch,[p(rt,{name:"fade",mode:"out-in"},{default:U(()=>[r.value==="sql-tables"?(n(),K(Yv,{key:0,class:"h-full","session-id":t.sessionId},null,8,["session-id"])):r.value==="basic-tools"?(n(),K(wh,{key:1,class:"h-full","session-id":t.sessionId},null,8,["session-id"])):R("",!0)]),_:1})])]))}}),r1=st(Sh,[["__scopeId","data-v-d712cb76"]]);var Me=(l=>(l[l.TEXT=0]="TEXT",l[l.IMAGE=1]="IMAGE",l[l.VOICE=2]="VOICE",l[l.VIDEO=3]="VIDEO",l[l.FILE=4]="FILE",l[l.EMOJI=5]="EMOJI",l[l.LINK=7]="LINK",l[l.LOCATION=8]="LOCATION",l[l.RED_PACKET=20]="RED_PACKET",l[l.TRANSFER=21]="TRANSFER",l[l.POKE=22]="POKE",l[l.CALL=23]="CALL",l[l.SHARE=24]="SHARE",l[l.REPLY=25]="REPLY",l[l.FORWARD=26]="FORWARD",l[l.CONTACT=27]="CONTACT",l[l.SYSTEM=80]="SYSTEM",l[l.RECALL=81]="RECALL",l[l.OTHER=99]="OTHER",l))(Me||{});const Th={[Me.TEXT]:"text",[Me.IMAGE]:"image",[Me.VOICE]:"voice",[Me.VIDEO]:"video",[Me.FILE]:"file",[Me.EMOJI]:"emoji",[Me.LINK]:"link",[Me.LOCATION]:"location",[Me.RED_PACKET]:"redPacket",[Me.TRANSFER]:"transfer",[Me.POKE]:"poke",[Me.CALL]:"call",[Me.SHARE]:"share",[Me.REPLY]:"reply",[Me.FORWARD]:"forward",[Me.CONTACT]:"contact",[Me.SYSTEM]:"system",[Me.RECALL]:"recall",[Me.OTHER]:"other"};function Ht(l,s){const t=Th[l];return s&&t?s(`common.messageType.${t}`):s?s("common.messageType.unknown"):"未知"}function l1(l){const s=k(()=>Ya(l)),t=k(()=>{const r=s.value;return r.length<2?!1:new Set(r.map(u=>$e(u.date).year())).size>1}),c=k(()=>{const r=s.value,m=50;if(r.length<=m){const v=t.value?"YYYY/MM/DD":"MM/DD";return{labels:r.map(h=>$e(h.date).format(v)),values:r.map(h=>h.messageCount)}}const u=Math.ceil(r.length/m),d=[],g=[];for(let v=0;v<r.length;v+=u){const h=r.slice(v,v+u);if(h.length===0)continue;const S=Math.floor(h.length/2),b=h[S].date,w=t.value?"YYYY/MM/DD":"MM/DD";d.push($e(b).format(w));const q=h.reduce((I,_)=>I+_.messageCount,0),T=Math.round(q/h.length);g.push(T)}return{labels:d,values:g}});return{isMultiYear:t,dailyChartData:c}}function Ih(l,s){const{t}=ke(),c=k(()=>l.selectedYear?l.selectedYear%4===0&&l.selectedYear%100!==0||l.selectedYear%400===0?366:365:l.timeRange?Math.ceil((l.timeRange.end-l.timeRange.start)/86400):0),r=k(()=>l.selectedYear?l.filteredMessageCount:l.session.messageCount),m=k(()=>l.selectedYear?l.filteredMemberCount??l.session.memberCount:l.session.memberCount),u=k(()=>l.timeRange?Math.ceil((l.timeRange.end-l.timeRange.start)/86400):0),d=k(()=>u.value===0?0:Math.round(l.session.messageCount/u.value)),g=k(()=>c.value===0?0:Math.round(r.value/c.value)),v=k(()=>l.messageTypes.find(f=>f.type===1)?.count||0),h=k(()=>l.hourlyActivity.length?l.hourlyActivity.reduce((y,f)=>f.messageCount>y.messageCount?f:y,l.hourlyActivity[0]):null),S=k(()=>s.value.length?s.value.reduce((y,f)=>f.messageCount>y.messageCount?f:y,s.value[0]):null),b=k(()=>[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")]),w=k(()=>{if(!s.value.length)return{weekday:0,weekend:0};const y=s.value.filter(A=>A.weekday>=1&&A.weekday<=5).reduce((A,P)=>A+P.messageCount,0),f=s.value.filter(A=>A.weekday>=6&&A.weekday<=7).reduce((A,P)=>A+P.messageCount,0),D=y+f;return{weekday:D>0?Math.round(y/D*100):0,weekend:D>0?Math.round(f/D*100):0}}),q=k(()=>l.dailyActivity.length?l.dailyActivity.reduce((y,f)=>f.messageCount>y.messageCount?f:y,l.dailyActivity[0]):null),T=k(()=>l.dailyActivity.filter(y=>y.messageCount>0).length),I=k(()=>{if(!l.timeRange)return 0;const y=$e.unix(l.timeRange.start);return $e.unix(l.timeRange.end).diff(y,"day")+1}),_=k(()=>I.value>0?Math.round(T.value/I.value*100):0),C=k(()=>{if(!l.hourlyActivity.length)return{count:0,ratio:0};const y=l.hourlyActivity.reduce((D,A)=>D+A.messageCount,0),f=l.hourlyActivity.filter(D=>D.hour>=0&&D.hour<=4).reduce((D,A)=>D+A.messageCount,0);return{count:f,ratio:y>0?Math.round(f/y*100):0}}),M=k(()=>{if(!l.dailyActivity.length)return 0;const y=[...l.dailyActivity].filter(A=>A.messageCount>0).sort((A,P)=>$e(A.date).valueOf()-$e(P.date).valueOf());if(y.length===0)return 0;let f=1,D=1;for(let A=1;A<y.length;A++){const P=$e(y[A-1].date);$e(y[A].date).diff(P,"day")===1?D++:(D>f&&(f=D),D=1)}return D>f&&(f=D),f});return{durationDays:c,displayMessageCount:r,displayMemberCount:m,dailyAvgMessages:g,totalDurationDays:u,totalDailyAvgMessages:d,imageCount:v,peakHour:h,peakWeekday:S,weekdayNames:b,weekdayVsWeekend:w,peakDay:q,activeDays:T,totalDays:I,activeRate:_,lateNightChat:C,maxConsecutiveDays:M}}const Mh={key:0,class:"relative z-10 px-6 pb-6 pt-2 sm:px-8"},Lh={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Dh={class:"min-w-0"},Ah={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},qh={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Rh={key:1,class:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4"},Eh={class:"text-sm text-gray-500"},zh={class:"text-sm text-gray-500"},Ph={class:"ml-1 font-semibold text-pink-500"},Bh={class:"text-sm text-gray-500"},jh={class:"text-sm text-gray-500"},Fh={class:"text-sm text-gray-500"},Uh={class:"text-sm text-gray-500"},Vh={class:"text-sm text-gray-500"},Oh={class:"text-sm text-gray-500"},Nh=he({__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}=ke(),t=l,c=k(()=>[{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?$e(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,m)=>{const u=_e;return l.flat?(n(),i("div",Mh,[m[0]||(m[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",Lh,[(n(!0),i(ne,null,de(c.value,d=>(n(),i("div",{key:d.icon+d.label,class:"flex items-start gap-2 rounded-lg bg-white/60 p-2.5 ring-1 ring-gray-900/5 dark:bg-white/5 dark:ring-white/10"},[p(u,{name:d.icon,class:oe(["mt-0.5 h-3.5 w-3.5 shrink-0",d.colorClass])},null,8,["name","class"]),e("div",Dh,[e("div",{class:oe(["truncate font-mono text-sm font-black leading-tight tabular-nums",d.colorClass])},o(d.value),3),e("div",Ah,o(d.label),1),e("div",qh,o(d.subtext),1)])]))),128))])])):(n(),i("div",Rh,[p(a(Ze),{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:U(()=>[e("span",Eh,o(a(s)("analysis.overview.statCards.daysCount",{count:l.durationDays})),1)]),_:1},8,["label","value"]),p(a(Ze),{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:U(()=>[e("span",zh,o(a(s)("analysis.overview.statCards.peakHour")),1),e("span",Ph,o(l.peakHour?.hour||0)+":00",1)]),_:1},8,["label","value"]),p(a(Ze),{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:U(()=>[e("span",Bh,o(a(s)("analysis.overview.statCards.messagesOnDay",{count:l.peakWeekday?.messageCount??0})),1)]),_:1},8,["label","value"]),p(a(Ze),{label:a(s)("analysis.overview.statCards.weekendActivity"),value:`${l.weekdayVsWeekend.weekend}%`,icon:"i-heroicons-sun","icon-bg":"green"},{subtext:U(()=>[e("span",jh,o(a(s)("analysis.overview.statCards.weekendRatio")),1)]),_:1},8,["label","value"]),p(a(Ze),{label:a(s)("analysis.overview.statCards.mostActiveDate"),value:l.peakDay?a($e)(l.peakDay.date).format("MM/DD"):"-",icon:"i-heroicons-fire","icon-bg":"red"},{subtext:U(()=>[e("span",Fh,o(a(s)("analysis.overview.statCards.messagesOnDay",{count:l.peakDay?.messageCount??0})),1)]),_:1},8,["label","value"]),p(a(Ze),{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:U(()=>[e("span",Uh,o(a(s)("analysis.overview.statCards.lateNightRatio",{ratio:l.lateNightRatio})),1)]),_:1},8,["label","value"]),p(a(Ze),{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:U(()=>[e("span",Vh,o(a(s)("analysis.overview.statCards.longestStreak")),1)]),_:1},8,["label","value"]),p(a(Ze),{label:a(s)("analysis.overview.statCards.activityRate"),value:`${l.activeRate}%`,icon:"i-heroicons-chart-bar","icon-bg":"gray"},{subtext:U(()=>[e("span",Oh,o(a(s)("analysis.overview.statCards.activeDaysRatio")),1)]),_:1},8,["label","value"])]))}}}),Hh={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Yh={class:"text-3xl font-bold tracking-tight text-gray-900 dark:text-gray-100"},Wh={class:"mt-4 flex items-start gap-6 sm:gap-24"},Kh={class:"min-w-0 flex flex-col gap-2 text-sm font-medium text-gray-500 dark:text-gray-400"},Qh={class:"flex items-center gap-2"},Gh={class:"flex h-6 w-6 shrink-0 items-center justify-center"},Jh={class:"whitespace-nowrap"},Xh={key:0,class:"flex items-center gap-2"},Zh={class:"flex h-6 w-6 shrink-0 items-center justify-center"},ey={class:"font-mono text-xs opacity-90 whitespace-nowrap"},ty={class:"flex shrink-0 gap-6"},ay={class:"flex flex-col gap-1 text-center"},sy={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},oy={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},ny={class:"flex flex-col gap-1 text-center"},ry={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},ly={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},iy={class:"flex flex-col gap-1 text-center"},cy={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},dy={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},uy={class:"flex flex-col gap-1 text-center"},my={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},gy={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},py={class:"relative z-10 px-6 pb-2 sm:px-8"},vy={class:"overflow-x-auto overflow-y-hidden scrollbar-hide py-1"},i1=he({__name:"OverviewIdentityCard",props:{session:{},dailyActivity:{},messageTypes:{},hourlyActivity:{},timeRange:{},selectedYear:{},filteredMessageCount:{},timeFilter:{}},setup(l){yt([Gt,ss,ya,Mt,Jt,ft]);const{t:s,locale:t}=ke(),c=pt(),r=l,m=x([]);async function u(){if(r.session.id)try{m.value=await Ue().getWeekdayActivity(r.session.id,r.timeFilter)}catch(Q){console.error("加载星期活跃度失败:",Q)}}ge(()=>[r.session.id,r.timeFilter],()=>u(),{immediate:!0,deep:!0});const{durationDays:d,displayMessageCount:g,dailyAvgMessages:v,imageCount:h,peakHour:S,peakWeekday:b,weekdayNames:w,weekdayVsWeekend:q,peakDay:T,activeDays:I,totalDays:_,activeRate:C,lateNightChat:M,maxConsecutiveDays:y}=Ih(r,m),f=x(null);let D=null;const A=k(()=>r.timeRange?Bt(r.timeRange.start,r.timeRange.end,"YYYY/MM/DD"):""),P=k(()=>{const Q=new Date,V=new Date(Q);V.setFullYear(V.getFullYear()-1),V.setDate(V.getDate()+1);const te=xe=>xe.toISOString().slice(0,10);return[te(V),te(Q)]}),z=k(()=>{const[Q,V]=P.value,te=new Date(Q+"T00:00:00Z"),xe=new Date(V+"T00:00:00Z"),fe=new Map;r.dailyActivity.filter(B=>B.date>=Q&&B.date<=V).forEach(B=>fe.set(B.date,B.messageCount));const X=[],O=new Date(te);for(;O<=xe;){const B=O.toISOString().slice(0,10),F=fe.get(B)||0;X.push({value:[B,F],itemStyle:F===0?{color:W.value}:void 0}),O.setUTCDate(O.getUTCDate()+1)}return X}),$=k(()=>r.dailyActivity.length===0?10:Math.max(...r.dailyActivity.map(Q=>Q.messageCount),1)),L={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)"]},W=k(()=>c.value?"rgba(255, 255, 255, 0.04)":"#ebedf0"),ae=k(()=>({tooltip:{trigger:"item",formatter:Q=>{const V=Q.value[0],te=Q.value[1];return`${V}<br/>${s("views.message.calendarTooltipMessages")}: ${te}`}},visualMap:{min:1,max:$.value,calculable:!1,orient:"horizontal",left:"center",bottom:0,itemWidth:10,itemHeight:80,text:[`${$.value}`,"1"],inRange:{color:c.value?L.dark:L.light},textStyle:{color:c.value?"#8b949e":"#6b7280",fontSize:10},show:!0},calendar:{top:20,left:30,cellSize:[13,13],range:P.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:z.value,renderItem:(Q,V)=>{const te=V.coord(V.value(0)),xe=Q.coordSys.cellWidth,fe=Q.coordSys.cellHeight,X=Math.min(xe,fe)-3;return{type:"rect",shape:{x:te[0]-X/2,y:te[1]-X/2,width:X,height:X,r:3},style:{fill:V.visual("color")}}},itemStyle:{borderColor:c.value?"transparent":"rgba(0,0,0,0.02)",borderWidth:1}}]}));function Y(){f.value&&(D=xt(f.value,void 0,{renderer:"canvas"}),D.setOption({backgroundColor:"transparent",...ae.value}))}function pe(){D&&D.setOption({backgroundColor:"transparent",...ae.value},{notMerge:!0})}function ye(){D?.resize()}return ge([()=>r.dailyActivity,t],()=>pe()),ge(c,()=>{D?.dispose(),Y()}),Ee(()=>{Y(),window.addEventListener("resize",ye)}),lt(()=>{window.removeEventListener("resize",ye),D?.dispose()}),(Q,V)=>{const te=_e;return n(),K(a(it),{variant:"elevated",decorative:"",class:"flex flex-col"},{default:U(()=>[e("div",Hh,[e("h2",Yh,o(l.session.name),1),e("div",Wh,[e("div",Kh,[e("div",Qh,[e("div",Gh,[l.session.type==="group"?(n(),K(te,{key:0,name:"i-heroicons-user-group",class:"h-4 w-4 opacity-70"})):(n(),K(te,{key:1,name:"i-heroicons-user",class:"h-4 w-4 opacity-70"}))]),e("span",Jh,o(l.session.platform.toUpperCase())+" · "+o(l.session.type==="private"?a(s)("analysis.overview.identity.privateChat"):a(s)("analysis.overview.identity.groupChat")),1)]),A.value?(n(),i("div",Xh,[e("div",Zh,[p(te,{name:"i-heroicons-calendar",class:"h-4 w-4 opacity-70"})]),e("span",ey,o(A.value),1)])):R("",!0)]),e("div",ty,[e("div",ay,[e("span",sy,o(a(g).toLocaleString()),1),e("span",oy,o(a(s)("analysis.overview.identity.totalMessages")),1)]),e("div",ny,[e("span",ry,o(a(d).toLocaleString()),1),e("span",ly,o(a(s)("analysis.overview.identity.durationDays")),1)]),e("div",iy,[e("span",cy,o(a(I).toLocaleString()),1),e("span",dy,o(a(s)("analysis.overview.identity.activeDays")),1)]),e("div",uy,[e("span",my,o(a(v).toLocaleString()),1),e("span",gy,o(a(s)("analysis.overview.identity.dailyAvgMessages")),1)])])])]),e("div",py,[V[0]||(V[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",vy,[e("div",{ref_key:"chartRef",ref:f,class:"h-[140px] min-w-[700px] lg:w-full"},null,512)])]),p(Nh,{flat:"","daily-avg-messages":a(v),"duration-days":a(d),"image-count":a(h),"peak-hour":a(S),"peak-weekday":a(b),"weekday-names":a(w),"weekday-vs-weekend":a(q),"peak-day":a(T),"active-days":a(I),"total-days":a(_),"active-rate":a(C),"late-night-count":a(M).count,"late-night-ratio":a(M).ratio,"max-consecutive-days":a(y)},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})}}}),hy={class:"p-5"},c1=he({__name:"DailyTrendCard",props:{dailyActivity:{},dailyChartData:{}},setup(l){const{t:s}=ke();return(t,c)=>l.dailyActivity.length>0?(n(),K(a(We),{key:0,title:a(s)("analysis.overview.dailyTrend.title"),"show-divider":!1},{default:U(()=>[e("div",hy,[p(a(Ut),{data:l.dailyChartData,height:288},null,8,["data"])])]),_:1},8,["title"])):R("",!0)}}),yy={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},fy={class:"flex items-center gap-6 sm:gap-10"},xy={class:"min-w-0 flex-1"},by={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},ky={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},_y={class:"mb-4 flex min-w-0 flex-wrap items-baseline gap-2"},wy={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},$y={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Cy={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Sy={key:1,class:"flex min-w-0 max-w-full flex-wrap items-center gap-x-1.5 gap-y-1.5"},Ty={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Iy={class:"font-bold tabular-nums text-pink-500 dark:text-pink-400"},My={class:"flex shrink-0 flex-col items-center"},Ly={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},Dy={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Ay={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},qy={class:"min-w-0 flex-1"},Ry={class:"flex items-center justify-between gap-1"},Ey={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},zy={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Py={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"},By={class:"flex items-center gap-1.5"},jy={class:"text-[9px] font-medium uppercase tracking-widest"},Fy=he({__name:"TypeProfileCard",props:{sessionId:{},messageTypes:{},textStats:{},timeFilter:{}},setup(l){yt([pa,Mt,ft]);const{t:s}=ke(),t=pt(),c=l,r=k(()=>c.messageTypes.reduce(($,L)=>$+L.count,0)),m=k(()=>c.messageTypes.find($=>$.type===Me.TEXT)?.count??0),u=k(()=>{if(r.value===0)return 0;const $=r.value-m.value;return Math.round($/r.value*100)}),d=k(()=>c.textStats.textCount===0?0:Math.round(c.textStats.shortCount/c.textStats.textCount*100)),g=x({first:"",last:""});async function v(){if(c.sessionId)try{const $=await Ue().getDailyActivity(c.sessionId,c.timeFilter);if($.length>0){const L=[...$].sort((W,ae)=>W.date.localeCompare(ae.date));g.value={first:$e(L[0].date).format("YYYY/MM/DD"),last:$e(L[L.length-1].date).format("YYYY/MM/DD")}}}catch{}}function h($){return c.messageTypes.find(L=>L.type===$)?.count??0}const S=k(()=>[{label:s("views.message.typeCard.nonTextImage"),count:h(Me.IMAGE),unit:s("views.message.typeCard.unitImage")},{label:s("views.message.typeCard.nonTextEmoji"),count:h(Me.EMOJI),unit:s("views.message.typeCard.unitEmoji")},{label:s("views.message.typeCard.nonTextVoice"),count:h(Me.VOICE),unit:s("views.message.typeCard.unitVoice")},{label:s("views.message.typeCard.nonTextVideo"),count:h(Me.VIDEO),unit:s("views.message.typeCard.unitVideo")},{label:s("views.message.typeCard.nonTextFile"),count:h(Me.FILE),unit:s("views.message.typeCard.unitFile")},{label:s("views.message.typeCard.nonTextLink"),count:h(Me.LINK),unit:s("views.message.typeCard.unitLink")}].filter($=>$.count>0)),b=x(30),w=x(0),q=x(!1),T=[{label:"20",value:20},{label:"30",value:30},{label:"50",value:50},{label:"80",value:80},{label:"100",value:100}],I=k({get:()=>b.value,set:$=>{b.value!==$&&(b.value=$,_())}});async function _(){if(c.sessionId){q.value=!0;try{w.value=await Ue().getLongMessageCount(c.sessionId,c.timeFilter,b.value)}catch($){console.error("[chart-message] Failed to load essay count:",$)}finally{q.value=!1}}}ge(()=>[c.sessionId,c.timeFilter],()=>{_(),v()},{immediate:!0,deep:!0});const C=k(()=>[{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:w.value.toLocaleString(),subtext:s("views.message.profile.essayLoverDesc",{threshold:b.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:S.value.slice(0,3).map($=>`${$.label} ${$.count}`).join(" · ")||"-",colorClass:"text-pink-600 dark:text-pink-400"}]),M=x(null);let y=null;const f=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],D=k(()=>[...c.messageTypes].sort((L,W)=>W.count-L.count).slice(0,8).map((L,W)=>({name:Ht(L.type,s),value:L.count,itemStyle:{color:f[W%f.length]}})));function A(){M.value&&(y=xt(M.value,void 0,{renderer:"canvas"}),P())}function P(){y&&y.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:D.value}]},{notMerge:!0})}function z(){y?.resize()}return ge(()=>c.messageTypes,()=>P()),ge(t,()=>{y?.dispose(),A()}),Ee(()=>{A(),window.addEventListener("resize",z)}),lt(()=>{window.removeEventListener("resize",z),y?.dispose()}),($,L)=>{const W=_e,ae=It;return n(),K(a(it),{variant:"elevated",decorative:"",class:"flex flex-col"},{default:U(()=>[e("div",yy,[e("div",fy,[e("div",xy,[e("div",by,[g.value.first?(n(),i("p",ky,o(g.value.first)+" – "+o(g.value.last),1)):R("",!0),e("div",_y,[e("span",wy,o(a(s)("views.message.profile.heroLine1Prefix")),1),e("span",$y,o(r.value.toLocaleString()),1),e("span",Cy,o(a(s)("views.message.profile.heroLine1Suffix")),1)]),S.value.length>0?(n(),i("div",Sy,[e("span",Ty,o(a(s)("views.message.typeCard.nonTextPrefix")),1),(n(!0),i(ne,null,de(S.value,Y=>(n(),i("span",{key:Y.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",Iy,o(Y.count.toLocaleString()),1),e("span",null,o(Y.unit),1)]))),128))])):R("",!0)])]),e("div",My,[e("div",Ly,o(a(s)("views.message.profile.typeDistribution")),1),e("div",{ref_key:"donutRef",ref:M,style:{width:"130px",height:"130px"}},null,512)])])]),e("div",Dy,[L[1]||(L[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",Ay,[(n(!0),i(ne,null,de(C.value,Y=>(n(),i("div",{key:Y.icon+Y.label,class:"flex items-start gap-2 rounded-lg bg-white/60 p-2.5 ring-1 ring-gray-900/5 dark:bg-white/5 dark:ring-white/10"},[p(W,{name:Y.icon,class:oe(["mt-0.5 h-3.5 w-3.5 shrink-0",Y.colorClass])},null,8,["name","class"]),e("div",qy,[e("div",Ry,[e("div",{class:oe(["truncate font-mono text-sm font-black leading-tight tabular-nums",Y.colorClass])},o(Y.value),3),Y.slot==="essay-threshold"?(n(),K(ae,{key:0,modelValue:I.value,"onUpdate:modelValue":L[0]||(L[0]=pe=>I.value=pe),items:T,"value-key":"value",size:"xs",class:"relative z-120 w-16 shrink-0",ui:{content:"z-[121]"},disabled:q.value},null,8,["modelValue","disabled"])):R("",!0)]),e("div",Ey,o(Y.label),1),e("div",zy,o(Y.subtext),1)])]))),128))])]),e("div",Py,[e("div",By,[p(W,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),L[2]||(L[2]=e("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),e("span",jy,o(a(s)("views.message.typeCard.watermark")),1)])]),_:1})}}}),Uy={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-6"},Vy={class:"p-5"},Oy={key:0,class:"grid grid-cols-1 gap-6 lg:grid-cols-2 lg:items-center"},Ny={class:"space-y-3"},Hy={class:"min-w-20 shrink-0 text-sm text-gray-700 dark:text-gray-300"},Yy={class:"flex-1"},Wy={class:"h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800"},Ky={class:"shrink-0 text-right"},Qy={class:"text-sm font-medium text-gray-900 dark:text-white"},Gy={class:"ml-1 text-xs text-gray-400"},Jy={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Xy={class:"p-5"},Zy={class:"mb-5 grid grid-cols-2 gap-3 sm:grid-cols-4"},ef={class:"rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50"},tf={class:"font-mono text-xl font-bold text-gray-900 dark:text-white"},af={class:"mt-1 text-xs text-gray-500"},sf={class:"rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50"},of={class:"font-mono text-xl font-bold text-indigo-600 dark:text-indigo-400"},nf={class:"mt-1 text-xs text-gray-500"},rf={class:"rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50"},lf={class:"font-mono text-xl font-bold text-pink-600 dark:text-pink-400"},cf={class:"mt-1 text-xs text-gray-500"},df={class:"rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50"},uf={class:"font-mono text-xl font-bold text-emerald-600 dark:text-emerald-400"},mf={class:"mt-1 text-xs text-gray-500"},gf={class:"mb-5 rounded-lg border border-gray-200 p-4 dark:border-gray-700"},pf={class:"mb-2 text-xs font-medium text-gray-500 dark:text-gray-400"},vf={class:"flex items-center gap-4 text-sm"},hf={class:"flex items-center gap-1.5"},yf={class:"font-mono font-medium text-gray-900 dark:text-white"},ff={class:"flex items-center gap-1.5"},xf={class:"font-mono font-medium text-gray-900 dark:text-white"},bf={class:"flex items-center gap-1.5"},kf={class:"font-mono font-medium text-gray-900 dark:text-white"},_f={class:"flex items-center gap-1.5"},wf={class:"font-mono font-medium text-gray-900 dark:text-white"},$f={class:"mt-3 grid grid-cols-3 gap-3 text-xs"},Cf={class:"text-gray-500"},Sf={class:"ml-1 font-medium text-emerald-600 dark:text-emerald-400"},Tf={class:"text-gray-400"},If={class:"text-gray-500"},Mf={class:"ml-1 font-medium text-indigo-600 dark:text-indigo-400"},Lf={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},Df={class:"text-xs text-gray-400"},Af={class:"p-5"},qf={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Rf={class:"text-xs text-gray-400"},Ef={class:"p-5"},zf={key:1,class:"flex h-48 items-center justify-center text-gray-400"},d1=he({__name:"TypeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(l){const s=l,{t}=ke(),c=x(!0),r=x([]),m=x([]),u=x([]),d=x({textCount:0,avgLength:0,maxLength:0,shortCount:0}),g=x({p25:0,p50:0,p75:0,p90:0}),v=x(0),h=k(()=>{const C=[...r.value].sort((M,y)=>y.count-M.count);return{labels:C.map(M=>Ht(M.type,t)),values:C.map(M=>M.count)}}),S=k(()=>{const C=r.value.reduce((y,f)=>y+f.count,0);return[...r.value].sort((y,f)=>f.count-y.count).map(y=>({name:Ht(y.type,t),count:y.count,percentage:C>0?Math.round(y.count/C*100):0}))}),b=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"];function w(C){return b[C%b.length]}const q=k(()=>({labels:m.value.map(C=>String(C.len)),values:m.value.map(C=>C.count)})),T=k(()=>({labels:u.value.map(C=>C.range),values:u.value.map(C=>C.count)})),I=k(()=>d.value.textCount===0?0:Math.round(d.value.shortCount/d.value.textCount*100));async function _(){if(s.sessionId){c.value=!0;try{const C=Ue(),[M,y,f,D,A]=await Promise.all([C.getMessageTypeDistribution(s.sessionId,s.timeFilter),C.getMessageLengthDistribution(s.sessionId,s.timeFilter),C.getTextStats(s.sessionId,s.timeFilter),C.getTextLengthPercentiles(s.sessionId,s.timeFilter),C.getLongMessageCount(s.sessionId,s.timeFilter,30)]);r.value=M,m.value=y.detail,u.value=y.grouped,d.value=f,g.value=D,v.value=A}catch(C){console.error("[chart-message] Failed to load type analysis data:",C)}finally{c.value=!1}}}return ge(()=>[s.sessionId,s.timeFilter],()=>_(),{immediate:!0,deep:!0}),(C,M)=>(n(),i("div",{class:oe(c.value?"h-full":"")},[c.value?(n(),K(a(mt),{key:0,variant:"page",text:a(t)("common.loading")},null,8,["text"])):(n(),i("div",Uy,[r.value.length>0?(n(),K(Fy,{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(We),{title:a(t)("views.message.typeDistribution"),"show-divider":!1},{default:U(()=>[e("div",Vy,[h.value.values.length>0?(n(),i("div",Oy,[e("div",null,[p(a(Vt),{data:h.value,height:280,"show-legend":!1},null,8,["data"])]),e("div",null,[e("div",Ny,[(n(!0),i(ne,null,de(S.value,(y,f)=>(n(),i("div",{key:f,class:"flex items-center gap-3"},[e("div",{class:"h-3 w-3 shrink-0 rounded-full",style:Ge({backgroundColor:w(f)})},null,4),e("div",Hy,o(y.name),1),e("div",Yy,[e("div",Wy,[e("div",{class:"h-full rounded-full transition-all",style:Ge({width:`${y.percentage}%`,backgroundColor:w(f)})},null,4)])]),e("div",Ky,[e("span",Qy,o(y.count.toLocaleString()),1),e("span",Gy,"("+o(y.percentage)+"%)",1)])]))),128))])])])):(n(),i("div",Jy,o(a(t)("views.message.noData")),1))])]),_:1},8,["title"]),p(a(We),{title:a(t)("views.message.typeAnalysis.textDepthTitle"),"show-divider":!1},{default:U(()=>[e("div",Xy,[e("div",Zy,[e("div",ef,[e("div",tf,o(d.value.textCount.toLocaleString()),1),e("div",af,o(a(t)("views.message.typeAnalysis.textTotal")),1)]),e("div",sf,[e("div",of,o(d.value.avgLength||0),1),e("div",nf,o(a(t)("views.message.typeAnalysis.avgLength")),1)]),e("div",rf,[e("div",lf,o(g.value.p50),1),e("div",cf,o(a(t)("views.message.typeAnalysis.medianLength")),1)]),e("div",df,[e("div",uf,o(d.value.maxLength),1),e("div",mf,o(a(t)("views.message.typeAnalysis.maxLength")),1)])]),e("div",gf,[e("div",pf,o(a(t)("views.message.typeAnalysis.percentiles")),1),e("div",vf,[e("div",hf,[M[0]||(M[0]=e("span",{class:"text-gray-500"},"P25",-1)),e("span",yf,o(g.value.p25),1)]),e("div",ff,[M[1]||(M[1]=e("span",{class:"text-gray-500"},"P50",-1)),e("span",xf,o(g.value.p50),1)]),e("div",bf,[M[2]||(M[2]=e("span",{class:"text-gray-500"},"P75",-1)),e("span",kf,o(g.value.p75),1)]),e("div",_f,[M[3]||(M[3]=e("span",{class:"text-gray-500"},"P90",-1)),e("span",wf,o(g.value.p90),1)])]),e("div",$f,[e("div",null,[e("span",Cf,o(a(t)("views.message.typeAnalysis.shortMessages")),1),e("span",Sf,o(I.value)+"%",1),e("span",Tf,"("+o(d.value.shortCount)+")",1)]),e("div",null,[e("span",If,o(a(t)("views.message.typeAnalysis.essayMessages")),1),e("span",Mf,o(v.value),1)])])])])]),_:1},8,["title"]),e("div",Lf,[p(a(We),{title:a(t)("views.message.lengthDetailTitle"),"show-divider":!1},{headerRight:U(()=>[e("span",Df,o(a(t)("views.message.lengthDetailHint")),1)]),default:U(()=>[e("div",Af,[q.value.values.some(y=>y>0)?(n(),K(a(tt),{key:0,data:q.value,height:200},null,8,["data"])):(n(),i("div",qf,o(a(t)("views.message.noTextMessages")),1))])]),_:1},8,["title"]),p(a(We),{title:a(t)("views.message.lengthGroupedTitle"),"show-divider":!1},{headerRight:U(()=>[e("span",Rf,o(a(t)("views.message.lengthGroupedHint")),1)]),default:U(()=>[e("div",Ef,[T.value.values.some(y=>y>0)?(n(),K(a(tt),{key:0,data:T.value,height:200},null,8,["data"])):(n(),i("div",zf,o(a(t)("views.message.noTextMessages")),1))])]),_:1},8,["title"])])]))],2))}}),Pf={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Bf={class:"flex items-start gap-6 sm:gap-10"},jf={class:"min-w-0 flex-1"},Ff={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},Uf={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},Vf={class:"mb-3 flex items-baseline gap-2"},Of={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Nf={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Hf={class:"font-bold text-3xl text-indigo-500 dark:text-indigo-400"},Yf={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Wf={class:"flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},Kf={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Qf={class:"font-bold text-xl text-pink-500 dark:text-pink-400"},Gf={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Jf={class:"text-base font-medium text-amber-600 dark:text-amber-400"},Xf={class:"flex shrink-0 flex-col items-center"},Zf={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},ex={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},tx={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},ax={class:"min-w-0 flex-1"},sx={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},ox={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},nx={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"},rx={class:"flex items-center gap-1.5"},lx={class:"text-[9px] font-medium uppercase tracking-widest"},ix=he({__name:"TimeProfileCard",props:{hourlyActivity:{},weekdayActivity:{},dailyActivity:{}},setup(l){yt([va,ha,ft]);const{t:s}=ke(),t=pt(),c=l,r=k(()=>c.dailyActivity.filter(y=>y.messageCount>0).length),m=k(()=>c.dailyActivity.reduce((y,f)=>y+f.messageCount,0)),u=k(()=>{if(c.dailyActivity.length===0)return{first:"",last:"",days:0};const y=[...c.dailyActivity].sort((A,P)=>A.date.localeCompare(P.date)),f=$e(y[0].date),D=$e(y[y.length-1].date);return{first:f.format("YYYY/MM/DD"),last:D.format("YYYY/MM/DD"),days:D.diff(f,"day")+1}}),d=k(()=>r.value===0?0:Math.round(m.value/r.value)),g=k(()=>c.dailyActivity.length===0?null:c.dailyActivity.reduce((y,f)=>f.messageCount>y.messageCount?f:y,c.dailyActivity[0])),v=k(()=>c.hourlyActivity.length===0?[]:[...c.hourlyActivity].sort((y,f)=>f.messageCount-y.messageCount).slice(0,3)),h=k(()=>{if(c.hourlyActivity.length===0&&c.weekdayActivity.length===0)return null;const y=u.value.days>0?r.value/u.value.days:0,f=c.weekdayActivity.filter(Q=>Q.weekday===6||Q.weekday===7),D=c.weekdayActivity.filter(Q=>Q.weekday>=1&&Q.weekday<=5),A=f.reduce((Q,V)=>Q+V.messageCount,0),P=D.reduce((Q,V)=>Q+V.messageCount,0),z=A+P,$=z>0?A/z:0,L=c.hourlyActivity.reduce((Q,V)=>Q+V.messageCount,0),W=c.hourlyActivity.filter(Q=>Q.hour>=22||Q.hour<5).reduce((Q,V)=>Q+V.messageCount,0),ae=c.hourlyActivity.filter(Q=>Q.hour>=18&&Q.hour<22).reduce((Q,V)=>Q+V.messageCount,0),Y=L>0?W/L:0,pe=L>0?ae/L:0;if(y>=.9)return{label:s("views.message.timeCard.personalityEveryday"),icon:"i-heroicons-fire"};if($>=.55)return{label:s("views.message.timeCard.personalityWeekend"),icon:"i-heroicons-calendar"};if($<=.2&&z>0)return{label:s("views.message.timeCard.personalityWeekday"),icon:"i-heroicons-briefcase"};if(Y>=.3)return{label:s("views.message.timeCard.personalityNightOwl"),icon:"i-heroicons-moon"};if(pe>=.4)return{label:s("views.message.timeCard.personalityEveningChat"),icon:"i-heroicons-sparkles"};const ye=[...c.hourlyActivity].sort((Q,V)=>V.messageCount-Q.messageCount)[0];return ye?ye.hour>=5&&ye.hour<9?{label:s("views.message.timeCard.personalityEarlyBird"),icon:"i-heroicons-sun"}:ye.hour>=12&&ye.hour<14?{label:s("views.message.timeCard.personalityLunchChat"),icon:"i-heroicons-clock"}:{label:s("views.message.timeCard.personalityDaytime"),icon:"i-heroicons-sun"}:null}),S=k(()=>{const y=c.weekdayActivity.filter(z=>z.weekday===6||z.weekday===7),f=c.weekdayActivity.filter(z=>z.weekday>=1&&z.weekday<=5),D=y.reduce((z,$)=>z+$.messageCount,0),A=f.reduce((z,$)=>z+$.messageCount,0),P=D+A;return P===0?0:Math.round(D/P*100)}),b=k(()=>[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")]),w=k(()=>{if(c.weekdayActivity.length===0)return null;const y=[...c.weekdayActivity].sort((f,D)=>D.messageCount-f.messageCount)[0];return{name:b.value[y.weekday-1],count:y.messageCount}}),q=k(()=>[{icon:"i-heroicons-fire",label:s("views.message.timeCard.peakRecord"),value:g.value?$e(g.value.date).format("MM/DD"):"-",subtext:g.value?s("views.message.timeCard.peakRecordDesc",{count:g.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(y=>`${y.hour}:00`).join(" > "):"",colorClass:"text-cyan-600 dark:text-cyan-400"},{icon:"i-heroicons-calendar-days",label:s("views.message.timeCard.peakWeekdayLabel"),value:w.value?.name||"-",subtext:w.value?`${w.value.count.toLocaleString()}`:"",colorClass:"text-violet-600 dark:text-violet-400"},{icon:"i-heroicons-building-office",label:s("views.message.timeCard.weekendRatio"),value:`${S.value}%`,subtext:s("views.message.timeCard.weekendRatioDesc"),colorClass:"text-amber-600 dark:text-amber-400"}]),T=x(null);let I=null;function _(){T.value&&(I=xt(T.value,void 0,{renderer:"canvas"}),C())}function C(){if(!I)return;const y=new Map(c.hourlyActivity.map(P=>[P.hour,P.messageCount])),f=[];for(let P=0;P<24;P++)f.push(y.get(P)||0);const D=Math.max(...f,1),A=f.map(P=>{const z=P/D;return z>.8?t.value?"#f472b6":"#ec4899":z>.5?t.value?"#a78bfa":"#8b5cf6":t.value?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.08)"});I.setOption({backgroundColor:"transparent",tooltip:{trigger:"axis",formatter:P=>`${P[0].axisValue}:00 — ${P[0].value}`},grid:{left:0,right:0,top:4,bottom:16},xAxis:{type:"category",data:Array.from({length:24},(P,z)=>`${z}`),axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:9,color:t.value?"#6b7280":"#9ca3af",interval:P=>P%6===0}},yAxis:{type:"value",show:!1},series:[{type:"bar",data:f.map((P,z)=>({value:P,itemStyle:{color:A[z]}})),barWidth:"60%",itemStyle:{borderRadius:[2,2,0,0]}}]},{notMerge:!0})}function M(){I?.resize()}return ge(()=>c.hourlyActivity,()=>C()),ge(t,()=>{I?.dispose(),_()}),Ee(()=>{_(),window.addEventListener("resize",M)}),lt(()=>{window.removeEventListener("resize",M),I?.dispose()}),(y,f)=>{const D=_e;return n(),K(a(it),{variant:"elevated",decorative:"",class:"flex flex-col"},{default:U(()=>[e("div",Pf,[e("div",Bf,[e("div",jf,[e("div",Ff,[u.value.first?(n(),i("p",Uf,o(u.value.first)+" – "+o(u.value.last),1)):R("",!0),e("div",Vf,[e("span",Of,o(u.value.days),1),e("span",Nf,o(a(s)("views.message.timeCard.heroDaysIn")),1),e("span",Hf,o(r.value),1),e("span",Yf,o(a(s)("views.message.timeCard.heroDaysActive")),1)]),e("div",Wf,[e("span",Kf,o(a(s)("views.message.timeCard.heroAvgPrefix")),1),e("span",Qf,o(d.value),1),e("span",Gf,o(a(s)("views.message.timeCard.heroAvgSuffix")),1),h.value?(n(),i(ne,{key:0},[p(D,{name:h.value.icon,class:"ml-2 h-4 w-4 text-amber-500"},null,8,["name"]),e("span",Jf,o(h.value.label),1)],64)):R("",!0)])])]),e("div",Xf,[e("div",Zf,o(a(s)("views.message.timeCard.hourlyDistribution")),1),e("div",{ref_key:"barRef",ref:T,style:{width:"180px",height:"110px"}},null,512)])])]),e("div",ex,[f[0]||(f[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",tx,[(n(!0),i(ne,null,de(q.value,A=>(n(),i("div",{key:A.icon+A.label,class:"flex items-start gap-2 rounded-lg bg-white/60 p-2.5 ring-1 ring-gray-900/5 dark:bg-white/5 dark:ring-white/10"},[p(D,{name:A.icon,class:oe(["mt-0.5 h-3.5 w-3.5 shrink-0",A.colorClass])},null,8,["name","class"]),e("div",ax,[e("div",{class:oe(["truncate font-mono text-sm font-black leading-tight tabular-nums",A.colorClass])},o(A.value),3),e("div",sx,o(A.label),1),e("div",ox,o(A.subtext),1)])]))),128))])]),e("div",nx,[e("div",rx,[p(D,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),f[1]||(f[1]=e("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),e("span",lx,o(a(s)("views.message.timeCard.watermark")),1)])]),_:1})}}}),cx={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-6"},dx={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},ux={class:"p-5"},mx={class:"p-5"},gx={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},px={class:"p-5"},vx={class:"p-5"},hx={key:1,class:"flex h-48 items-center justify-center text-gray-400"},yx={class:"text-xs text-gray-400"},fx={class:"p-5"},xx={key:1,class:"flex h-48 items-center justify-center text-gray-400"},bx={class:"text-xs text-gray-400"},kx={class:"p-5"},_x={class:"flex items-center gap-2"},wx={class:"text-xs text-gray-400"},$x={class:"p-5"},Cx={key:1,class:"flex h-32 items-center justify-center text-gray-400"},u1=he({__name:"TimeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(l){const s=l,{t}=ke(),c=x(!0),r=x([]),m=x([]),u=x([]),d=x([]),g=x([]),v=x([]),h=x([]),S=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],b=k(()=>[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")]),w=k(()=>[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")]),q=k(()=>{const z=new Map(m.value.map(W=>[W.hour,W.messageCount])),$=[],L=[];for(let W=0;W<24;W++)$.push(`${W}`),L.push(z.get(W)||0);return{labels:$,values:L}}),T=k(()=>{const z=new Map(u.value.map(L=>[L.weekday,L.messageCount])),$=[];for(let L=1;L<=7;L++)$.push(z.get(L)||0);return{labels:b.value,values:$}}),I=k(()=>{const z=new Map(d.value.map(L=>[L.month,L.messageCount])),$=[];for(let L=1;L<=12;L++)$.push(z.get(L)||0);return{labels:w.value,values:$}}),_=k(()=>{const z=[...g.value].sort(($,L)=>$.year-L.year);return{labels:z.map($=>String($.year)),values:z.map($=>$.messageCount)}}),C=k(()=>{const z=Array.from({length:24},(ae,Y)=>`${Y}:00`),$=b.value,L=r.value.reduce((ae,Y)=>ae+Y.count,0)||1,W=[];for(let ae=1;ae<=7;ae++)for(let Y=0;Y<24;Y++){const pe=u.value.find(V=>V.weekday===ae)?.messageCount||0,ye=m.value.find(V=>V.hour===Y)?.messageCount||0,Q=Math.round(pe*ye/L);W.push([Y,ae-1,Q])}return{xLabels:z,yLabels:$,data:W}}),M=k(()=>v.value.map(z=>({date:z.date,value:z.messageCount}))),y=k(()=>{const z=new Set;return v.value.forEach($=>{const L=parseInt($.date.split("-")[0]);isNaN(L)||z.add(L)}),Array.from(z).sort(($,L)=>L-$)}),f=x(new Date().getFullYear()),D=k(()=>{const z=f.value;return M.value.filter($=>$.date.startsWith(`${z}-`))}),A=k(()=>{if(h.value.length===0)return{};const z=[...new Set(h.value.map(Y=>Y.month))].sort(),$=new Map;if(h.value.forEach(Y=>{const pe=$.get(Y.memberId);pe?pe.total+=Y.count:$.set(Y.memberId,{name:Y.memberName,total:Y.count})}),$.size<=2){const Y=new Map;return h.value.forEach(pe=>{Y.set(pe.month,(Y.get(pe.month)||0)+pe.count)}),{tooltip:{trigger:"axis",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:50,right:20,top:10,bottom:30},xAxis:{type:"category",data:z,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{type:"dashed",opacity:.3}}},series:[{type:"line",smooth:!0,symbol:"none",areaStyle:{opacity:.2},itemStyle:{color:"#6366f1"},data:z.map(pe=>Y.get(pe)||0)}]}}const ae=[...$.entries()].sort((Y,pe)=>pe[1].total-Y[1].total).slice(0,10).map(([Y,pe],ye)=>{const Q=new Map(h.value.filter(V=>V.memberId===Y).map(V=>[V.month,V.count]));return{name:pe.name,type:"line",stack:"total",areaStyle:{opacity:.3},smooth:!0,symbol:"none",itemStyle:{color:S[ye%S.length]},data:z.map(V=>Q.get(V)||0)}});return{tooltip:{trigger:"axis",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},legend:{bottom:0,textStyle:{fontSize:11}},grid:{left:50,right:20,top:10,bottom:40},xAxis:{type:"category",data:z,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{type:"dashed",opacity:.3}}},series:ae}});async function P(){if(s.sessionId){c.value=!0;try{const z=Ue(),[$,L,W,ae,Y,pe,ye]=await Promise.all([z.getMessageTypeDistribution(s.sessionId,s.timeFilter),z.getHourlyActivity(s.sessionId,s.timeFilter),z.getWeekdayActivity(s.sessionId,s.timeFilter),z.getMonthlyActivity(s.sessionId,s.timeFilter),z.getYearlyActivity(s.sessionId,s.timeFilter),z.getDailyActivity(s.sessionId,s.timeFilter),z.getMemberMonthlyTrend(s.sessionId,s.timeFilter)]);r.value=$,m.value=L,u.value=W,d.value=ae,g.value=Y,v.value=pe,h.value=ye,y.value.length>0&&(f.value=y.value[0])}catch(z){console.error("[chart-message] Failed to load time analysis data:",z)}finally{c.value=!1}}}return ge(()=>[s.sessionId,s.timeFilter],()=>P(),{immediate:!0,deep:!0}),(z,$)=>{const L=It;return n(),i("div",{class:oe(c.value?"h-full":"")},[c.value?(n(),K(a(mt),{key:0,variant:"page",text:a(t)("common.loading")},null,8,["text"])):(n(),i("div",cx,[v.value.length>0?(n(),K(ix,{key:0,"hourly-activity":m.value,"weekday-activity":u.value,"daily-activity":v.value},null,8,["hourly-activity","weekday-activity","daily-activity"])):R("",!0),e("div",dx,[p(a(We),{title:a(t)("views.message.hourlyDistribution"),"show-divider":!1},{default:U(()=>[e("div",ux,[p(a(tt),{data:q.value,height:200},null,8,["data"])])]),_:1},8,["title"]),p(a(We),{title:a(t)("views.message.weekdayDistribution"),"show-divider":!1},{default:U(()=>[e("div",mx,[p(a(tt),{data:T.value,height:200},null,8,["data"])])]),_:1},8,["title"])]),e("div",gx,[p(a(We),{title:a(t)("views.message.monthlyDistribution"),"show-divider":!1},{default:U(()=>[e("div",px,[p(a(tt),{data:I.value,height:200},null,8,["data"])])]),_:1},8,["title"]),p(a(We),{title:a(t)("views.message.yearlyDistribution"),"show-divider":!1},{default:U(()=>[e("div",vx,[_.value.values.length>0?(n(),K(a(tt),{key:0,data:_.value,height:200},null,8,["data"])):(n(),i("div",hx,o(a(t)("views.message.noData")),1))])]),_:1},8,["title"])]),p(a(We),{title:a(t)("views.message.timeAnalysis.memberTrendTitle"),"show-divider":!1},{headerRight:U(()=>[e("span",yx,o(a(t)("views.message.timeAnalysis.memberTrendHint")),1)]),default:U(()=>[e("div",fx,[h.value.length>0?(n(),K(a(bt),{key:0,option:A.value,height:280},null,8,["option"])):(n(),i("div",xx,o(a(t)("views.message.noData")),1))])]),_:1},8,["title"]),p(a(We),{title:a(t)("views.message.timeHeatmap"),"show-divider":!1},{headerRight:U(()=>[e("span",bx,o(a(t)("views.message.heatmapHint")),1)]),default:U(()=>[e("div",kx,[p(a(Ft),{data:C.value,height:320},null,8,["data"])])]),_:1},8,["title"]),p(a(We),{title:a(t)("views.message.calendarHeatmap"),"show-divider":!1},{headerRight:U(()=>[e("div",_x,[e("span",wx,o(a(t)("views.message.calendarHint")),1),y.value.length>1?(n(),K(L,{key:0,modelValue:f.value,"onUpdate:modelValue":$[0]||($[0]=W=>f.value=W),items:y.value.map(W=>({value:W,label:String(W)})),size:"xs",class:"w-20"},null,8,["modelValue","items"])):R("",!0)])]),default:U(()=>[e("div",$x,[D.value.length>0?(n(),K(a(Dm),{key:0,data:D.value,year:f.value,height:180},null,8,["data","year"])):(n(),i("div",Cx,o(a(t)("views.message.noData")),1))])]),_:1},8,["title"])]))],2)}}}),Sx={class:"p-6"},Tx={class:"mb-4 flex items-center justify-between"},Ix={class:"flex items-center gap-3"},Mx={class:"text-lg font-semibold text-gray-900 dark:text-white"},Lx={class:"text-sm text-gray-500 dark:text-gray-400"},Dx={class:"h-56 overflow-y-auto rounded-lg border border-gray-200 dark:border-gray-700"},Ax={key:0,class:"flex h-full items-center justify-center"},qx={key:1,class:"flex h-full items-center justify-center"},Rx={class:"text-sm text-gray-500 dark:text-gray-400"},Ex={key:2,class:"divide-y divide-gray-100 dark:divide-gray-800"},zx=["onClick"],Px=["src","alt"],Bx={key:1,class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-linear-to-br from-gray-300 to-gray-400 text-xs font-medium text-white dark:from-gray-600 dark:to-gray-700"},jx={class:"min-w-0 flex-1"},Fx={class:"truncate text-sm font-medium text-gray-900 dark:text-white"},Ux={class:"truncate text-xs text-gray-500 dark:text-gray-400"},Vx={class:"mt-3 text-xs text-gray-500 dark:text-gray-400"},Ox={key:0,class:"mt-2"},Nx={class:"mt-5 flex items-center justify-between gap-2"},Hx={key:1},Yx={class:"flex gap-2"},Wx=he({__name:"OwnerPromptModal",props:{sessionId:{},modelValue:{type:Boolean,default:!1},chatType:{default:"group"},autoCheck:{type:Boolean,default:!1}},emits:["update:modelValue","saved","cleared"],setup(l,{emit:s}){const t=l,c=s,{t:r}=ke(),m=Je(),u=ca(),d=k({get:()=>t.modelValue,set:A=>c("update:modelValue",A)}),g=x([]),v=x(!1),h=x(!1),S=x(!1),b=x(""),w=x(null),q=k(()=>u.currentSession?.ownerId??null);function T(A){return A.groupNickname||A.accountName||A.platformId}const I=k(()=>{const A=b.value.trim().toLowerCase(),P=g.value.filter(z=>z.platformId&&z.platformId.trim()!=="");return A?P.filter(z=>[z.platformId,z.accountName??"",z.groupNickname??"",...z.aliases].some($=>$.toLowerCase().includes(A))):P});async function _(){if(t.sessionId){v.value=!0;try{g.value=await Ue().getMembers(t.sessionId)}catch(A){console.error("加载成员列表失败:",A)}finally{v.value=!1}}}async function C(){if(!(!t.sessionId||!t.autoCheck)&&!q.value)try{const A=await u.tryApplyOwnerProfile(t.sessionId);if(A.applied||A.reason==="already_set"||A.reason==="missing_session"||A.dismissed)return;d.value=!0}catch(A){console.error("检查会话 owner 失败:",A)}}async function M(){if(!(!w.value||!t.sessionId)){h.value=!0;try{const A=await u.setOwnerAndApplyProfile(t.sessionId,w.value);A.updatedSessionIds.length>0?m.success(r("members.ownerPrompt.saved"),{description:r("members.ownerPrompt.appliedToOthers",{count:A.updatedSessionIds.length})}):m.success(r("members.ownerPrompt.saved")),c("saved",A.ownerId),d.value=!1}catch(A){console.error("设置会话 owner 失败:",A),m.fail(r("members.ownerPrompt.saveFailed"))}finally{h.value=!1}}}async function y(){if(!(!t.sessionId||!q.value)){h.value=!0;try{await u.updateSessionOwnerId(t.sessionId,null)&&(w.value=null,c("cleared"),d.value=!1)}catch(A){console.error("清除会话 owner 失败:",A)}finally{h.value=!1}}}async function f(){if(t.sessionId){S.value=!0;try{await u.dismissOwnerPrompt(t.sessionId),d.value=!1}catch(A){console.error("忽略 owner 提醒失败:",A)}finally{S.value=!1}}}function D(){d.value=!1}return ge(d,A=>{A&&(b.value="",w.value=q.value,_())}),ge(()=>t.sessionId,()=>{C()}),Ee(()=>{C()}),(A,P)=>{const z=_e,$=Re,L=ht,W=Oe;return n(),K(W,{open:d.value,"onUpdate:open":P[1]||(P[1]=ae=>d.value=ae),ui:{content:"max-w-md"}},{content:U(()=>[e("div",Sx,[e("div",Tx,[e("div",Ix,[e("div",{class:oe(["flex h-10 w-10 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(z,{name:"i-heroicons-user",class:"h-5 w-5 text-white"})],2),e("div",null,[e("h3",Mx,o(a(r)("members.ownerPrompt.title")),1),e("p",Lx,o(a(r)("members.ownerPrompt.subtitle")),1)])]),p($,{icon:"i-heroicons-x-mark",color:"neutral",variant:"ghost",size:"sm",onClick:D})]),p(L,{modelValue:b.value,"onUpdate:modelValue":P[0]||(P[0]=ae=>b.value=ae),placeholder:a(r)("members.ownerPrompt.searchPlaceholder"),icon:"i-heroicons-magnifying-glass",class:"mb-3 w-full"},null,8,["modelValue","placeholder"]),e("div",Dx,[v.value?(n(),i("div",Ax,[p(z,{name:"i-heroicons-arrow-path",class:"h-5 w-5 animate-spin text-gray-400"})])):I.value.length===0?(n(),i("div",qx,[e("p",Rx,o(b.value?a(r)("members.ownerPrompt.noMatch"):a(r)("members.ownerPrompt.empty")),1)])):(n(),i("ul",Ex,[(n(!0),i(ne,null,de(I.value,ae=>(n(),i("li",{key:ae.id},[e("button",{type:"button",class:oe(["flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-gray-50 dark:hover:bg-gray-800/50",w.value===ae.platformId?"bg-primary-50 dark:bg-primary-900/20":""]),onClick:Y=>w.value=ae.platformId},[ae.avatar?(n(),i("img",{key:0,src:ae.avatar,alt:T(ae),class:"h-8 w-8 shrink-0 rounded-full object-cover"},null,8,Px)):(n(),i("div",Bx,o(T(ae).slice(0,1)),1)),e("div",jx,[e("p",Fx,o(T(ae)),1),e("p",Ux,o(ae.platformId),1)]),w.value===ae.platformId?(n(),K(z,{key:2,name:"i-heroicons-check-circle-solid",class:"h-5 w-5 shrink-0 text-primary-500"})):R("",!0)],10,zx)]))),128))]))]),e("p",Vx,o(a(r)("members.ownerPrompt.description")),1),q.value?(n(),i("div",Ox,[p($,{variant:"link",color:"neutral",size:"xs",disabled:h.value,onClick:y},{default:U(()=>[ee(o(a(r)("members.ownerPrompt.clear")),1)]),_:1},8,["disabled"])])):R("",!0),e("div",Nx,[q.value?(n(),i("span",Hx)):(n(),K($,{key:0,variant:"ghost",color:"neutral",size:"sm",loading:S.value,onClick:f},{default:U(()=>[ee(o(a(r)("members.ownerPrompt.dontRemind")),1)]),_:1},8,["loading"])),e("div",Yx,[p($,{variant:"ghost",color:"neutral",onClick:D},{default:U(()=>[ee(o(a(r)("members.ownerPrompt.later")),1)]),_:1}),p($,{color:"primary",loading:h.value,disabled:!w.value,onClick:M},{default:U(()=>[ee(o(a(r)("members.ownerPrompt.save")),1)]),_:1},8,["loading","disabled"])])])])]),_:1},8,["open"])}}}),Kx={class:"w-150 rounded-lg border border-gray-200 bg-white p-3 shadow-sm dark:border-gray-700 dark:bg-gray-900"},Qx={class:"flex items-center justify-between gap-3"},Gx={class:"flex items-center gap-2"},Jx={class:"text-sm font-medium text-gray-900 dark:text-white"},Xx={class:"text-xs text-gray-500 dark:text-gray-400"},m1=he({__name:"OwnerEntryCard",props:{sessionId:{},members:{},chatType:{}},setup(l){const{t:s}=ke(),t=ca(),c=l,r=x(!1);function m(g){return g.groupNickname||g.accountName||g.platformId}const u=k(()=>{const g=t.currentSession?.ownerId;return g&&c.members.find(v=>v.platformId===g)||null}),d=k(()=>u.value?m(u.value):t.currentSession?.ownerId??"");return(g,v)=>{const h=_e,S=Re;return n(),i("div",Kx,[e("div",Qx,[e("div",Gx,[e("div",{class:oe(["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(h,{name:"i-heroicons-user",class:"h-4 w-4 text-white"})],2),e("div",null,[e("h3",Jx,o(d.value?a(s)("members.ownerPrompt.currentOwner",{name:d.value}):a(s)("members.ownerPrompt.choose")),1),e("p",Xx,o(a(s)("members.ownerPrompt.helper")),1)])]),p(S,{size:"sm",variant:d.value?"outline":"solid",color:"primary",onClick:v[0]||(v[0]=b=>r.value=!0)},{default:U(()=>[ee(o(d.value?a(s)("members.ownerPrompt.change"):a(s)("members.ownerPrompt.choose")),1)]),_:1},8,["variant"])]),p(Wx,{modelValue:r.value,"onUpdate:modelValue":v[1]||(v[1]=b=>r.value=b),"session-id":l.sessionId,"chat-type":l.chatType},null,8,["modelValue","session-id","chat-type"])])}}}),Zx={key:1,class:"flex items-center"},eb={class:"whitespace-nowrap px-0.5 text-sm font-medium text-gray-700 dark:text-gray-300"},tb={key:2,class:"flex items-center"},ab={class:"whitespace-nowrap px-0.5 text-sm font-medium text-gray-700 dark:text-gray-300"},sb={key:3,class:"flex items-center gap-1"},ob=he({__name:"TimeSelect",props:{sessionId:{},modelValue:{},visible:{type:Boolean,default:!0},initialState:{}},emits:["update:modelValue","update:fullRange","update:availableYears"],setup(l,{emit:s}){const t=l,c=s,{t:r}=ke(),m=x(!1),u=x([]),d=x(null),g=x("recent"),v=x(365),h=x(0),S=x(0),b=x(1),w=x(""),q=x(""),T=x(!1);function I(F){const J=new Date(F*1e3);return{year:J.getFullYear(),quarter:Math.floor(J.getMonth()/3)+1}}function _(F,J){const ce=(J-1)*3,ve=new Date(F,ce,1,0,0,0),G=new Date(F,ce+3,0,23,59,59);return{startTs:Math.floor(ve.getTime()/1e3),endTs:Math.floor(G.getTime()/1e3)}}function C(F){const J=new Date(F,0,1,0,0,0),ce=new Date(F,11,31,23,59,59);return{startTs:Math.floor(J.getTime()/1e3),endTs:Math.floor(ce.getTime()/1e3)}}const M=k(()=>[{label:r("common.timeSelect.mode.recent"),value:"recent"},{label:r("common.timeSelect.mode.quarter"),value:"quarter"},{label:r("common.timeSelect.mode.year"),value:"year"},{label:r("common.timeSelect.mode.custom"),value:"custom"}]),y=k(()=>[{label:r("common.timeSelect.recent.oneYear"),value:365},{label:r("common.timeSelect.recent.twoYears"),value:730},{label:r("common.timeSelect.recent.fiveYears"),value:1825},{label:r("common.timeSelect.recent.all"),value:0}]),f=k(()=>d.value?I(d.value.start):{year:0,quarter:1}),D=k(()=>d.value?I(d.value.end):{year:0,quarter:1}),A=k(()=>{const F=f.value;return S.value>F.year||S.value===F.year&&b.value>F.quarter}),P=k(()=>{const F=D.value;return S.value<F.year||S.value===F.year&&b.value<F.quarter}),z=k(()=>u.value.length===0?!1:u.value.indexOf(h.value)<u.value.length-1),$=k(()=>u.value.length===0?!1:u.value.indexOf(h.value)>0),L=k(()=>r("common.timeSelect.quarter.label",{year:S.value,quarter:b.value})),W=k(()=>r("common.timeSelect.year.label",{year:h.value}));function ae(F){return{365:r("common.timeSelect.display.recent365"),730:r("common.timeSelect.display.recent730"),1825:r("common.timeSelect.display.recent1825")}[F]||""}function Y(F){return[365,730,1825,0].includes(F)?F:365}function pe(){if(!d.value)return null;const F={mode:g.value};switch(g.value){case"recent":{if(F.recentDays=v.value,v.value===0)return{startTs:d.value.start,endTs:d.value.end,displayLabel:Bt(d.value.start,d.value.end),isFullRange:!0,state:F};const J=d.value.end;return{startTs:Math.max(J-v.value*86400,d.value.start),endTs:J,displayLabel:ae(v.value),isFullRange:!1,state:F}}case"quarter":return F.quarterYear=S.value,F.quarter=b.value,{..._(S.value,b.value),displayLabel:L.value,isFullRange:!1,state:F};case"year":return F.year=h.value,{...C(h.value),displayLabel:W.value,isFullRange:!1,state:F};case"custom":{if(F.customStart=w.value,F.customEnd=q.value,!w.value||!q.value)return null;let J=$e(w.value).startOf("day").unix(),ce=$e(q.value).endOf("day").unix();return J>ce&&([J,ce]=[ce,J]),{startTs:J,endTs:ce,displayLabel:Bt(J,ce),isFullRange:!1,state:F}}}}function ye(){const F=pe();F&&c("update:modelValue",F)}function Q(F){let J=S.value,ce=b.value+F;ce>4&&(J++,ce=1),ce<1&&(J--,ce=4);const ve=f.value,G=D.value;J<ve.year||J===ve.year&&ce<ve.quarter||J>G.year||J===G.year&&ce>G.quarter||(S.value=J,b.value=ce,ye())}function V(F){const J=u.value,ve=J.indexOf(h.value)-F;ve>=0&&ve<J.length&&(h.value=J[ve],ye())}function te(F){if(d.value)switch(F){case"recent":v.value=Y(v.value);break;case"quarter":{const{year:J,quarter:ce}=I(d.value.end);S.value=J,b.value=ce;break}case"year":{h.value=u.value[0]||new Date(d.value.end*1e3).getFullYear();break}case"custom":{const J=d.value.end,ce=Math.max(J-30*86400,d.value.start);w.value=$e.unix(ce).format("YYYY-MM-DD"),q.value=$e.unix(J).format("YYYY-MM-DD");break}}}const xe=k({get:()=>g.value,set:F=>{g.value=F,T.value=!0,te(F),T.value=!1,ye()}}),fe=k({get:()=>v.value,set:F=>{v.value=F,ye()}}),X=k({get:()=>w.value,set:F=>{w.value=F,q.value&&ye()}}),O=k({get:()=>q.value,set:F=>{q.value=F,w.value&&ye()}});async function B(){if(!t.sessionId){u.value=[],d.value=null,c("update:fullRange",null),c("update:availableYears",[]),m.value=!0;return}try{const F=Ue(),[J,ce]=await Promise.all([F.getAvailableYears(t.sessionId),F.getTimeRange(t.sessionId)]);u.value=J,d.value=ce,c("update:fullRange",ce),c("update:availableYears",J);const ve=t.initialState,G=ve?.mode??"recent";switch(g.value=G,T.value=!0,G){case"recent":v.value=Y(ve?.recentDays??365);break;case"quarter":{if(ve?.quarterYear&&ve?.quarter)S.value=ve.quarterYear,b.value=ve.quarter;else if(ce){const{year:re,quarter:be}=I(ce.end);S.value=re,b.value=be}break}case"year":{ve?.year&&J.includes(ve.year)?h.value=ve.year:h.value=J[0]||0;break}case"custom":{if(ve?.customStart&&ve?.customEnd)w.value=ve.customStart,q.value=ve.customEnd;else if(ce){const re=ce.end,be=Math.max(re-30*86400,ce.start);w.value=$e.unix(be).format("YYYY-MM-DD"),q.value=$e.unix(re).format("YYYY-MM-DD")}break}}T.value=!1,ye()}catch(F){console.error("TimeSelect 加载数据失败:",F),u.value=[],d.value=null,c("update:fullRange",null),c("update:availableYears",[])}finally{m.value=!0}}return Ee(()=>B()),ge(()=>t.sessionId,()=>{m.value=!1,B()}),(F,J)=>{const ce=It,ve=Re;return m.value?(n(),i("div",{key:0,class:oe(["flex items-center gap-2",{invisible:!l.visible}])},[p(ce,{modelValue:xe.value,"onUpdate:modelValue":J[0]||(J[0]=G=>xe.value=G),items:M.value,size:"md",class:"w-28 shrink-0"},null,8,["modelValue","items"]),g.value==="recent"?(n(),K(et,{key:0,modelValue:fe.value,"onUpdate:modelValue":J[1]||(J[1]=G=>fe.value=G),items:y.value,size:"sm",class:"min-w-0 shrink"},null,8,["modelValue","items"])):g.value==="quarter"?(n(),i("div",Zx,[p(ve,{icon:"i-heroicons-chevron-left",size:"sm",variant:"ghost",color:"neutral",disabled:!A.value,onClick:J[2]||(J[2]=G=>Q(-1))},null,8,["disabled"]),e("span",eb,o(L.value),1),p(ve,{icon:"i-heroicons-chevron-right",size:"sm",variant:"ghost",color:"neutral",disabled:!P.value,onClick:J[3]||(J[3]=G=>Q(1))},null,8,["disabled"])])):g.value==="year"?(n(),i("div",tb,[p(ve,{icon:"i-heroicons-chevron-left",size:"sm",variant:"ghost",color:"neutral",disabled:!z.value,onClick:J[4]||(J[4]=G=>V(-1))},null,8,["disabled"]),e("span",ab,o(W.value),1),p(ve,{icon:"i-heroicons-chevron-right",size:"sm",variant:"ghost",color:"neutral",disabled:!$.value,onClick:J[5]||(J[5]=G=>V(1))},null,8,["disabled"])])):g.value==="custom"?(n(),i("div",sb,[p(ea,{modelValue:X.value,"onUpdate:modelValue":J[6]||(J[6]=G=>X.value=G),"width-class":"w-28",clearable:!1},null,8,["modelValue"]),J[8]||(J[8]=e("span",{class:"text-xs text-gray-400"},"-",-1)),p(ea,{modelValue:O.value,"onUpdate:modelValue":J[7]||(J[7]=G=>O.value=G),"width-class":"w-28",clearable:!1},null,8,["modelValue"])])):R("",!0)],2)):R("",!0)}}}),nb={class:"flex items-center justify-between"},rb=["src","alt"],lb={class:"group/title flex items-baseline gap-2"},ib={class:"header-actions relative z-[40] flex items-center gap-2"},cb=he({__name:"PageHeader",props:{title:{},description:{},icon:{},iconClass:{},avatar:{},size:{default:"default"}},setup(l){const s=l;return(t,c)=>{const r=_e;return n(),i("div",{class:oe(["relative border-b border-gray-200/50 dark:border-gray-800/50",s.size==="compact"?"px-5 pb-1.5":"px-6 pb-2"])},[c[1]||(c[1]=e("div",{class:"titlebar-drag-cover"},null,-1)),e("div",nb,[e("div",{class:oe(["flex items-center",s.size==="compact"?"gap-2.5":"gap-3"])},[l.avatar?(n(),i("img",{key:0,src:l.avatar,alt:l.title,class:oe(["object-cover",s.size==="compact"?"h-6 w-6 rounded-md":"h-10 w-10 rounded-xl"])},null,10,rb)):l.icon?(n(),i("div",{key:1,class:oe(["flex items-center justify-center",[l.iconClass,s.size==="compact"?"h-6 w-6 rounded-md":"h-10 w-10 rounded-xl"]])},[p(r,{name:l.icon,class:oe(["text-white",s.size==="compact"?"h-3 w-3":"h-5 w-5"])},null,8,["name","class"])],2)):R("",!0),e("div",lb,[e("h1",{class:oe(["font-semibold text-gray-900 dark:text-white",s.size==="compact"?"text-base":"text-lg"])},o(l.title),3),l.description?(n(),i("p",{key:0,class:oe(["pointer-events-none whitespace-nowrap text-gray-500 opacity-0 transition-opacity duration-200 group-hover/title:opacity-100 dark:text-gray-400",s.size==="compact"?"text-[11px]":"text-xs"])},o(l.description),3)):R("",!0)])],2),c[0]||(c[0]=e("div",{class:"flex-1 self-stretch mx-4",style:{"-webkit-app-region":"drag"}},null,-1)),e("div",ib,[Ke(t.$slots,"actions",{},void 0,!0)])]),Ke(t.$slots,"default",{},void 0,!0)],2)}}}),db=st(cb,[["__scopeId","data-v-b3e18446"]]),ub={class:"mt-3 flex items-center justify-between gap-3"},mb={class:"flex shrink-0 items-center gap-0.5 overflow-x-auto scrollbar-hide"},gb=["onClick"],pb={class:"whitespace-nowrap"},g1=he({__name:"SessionAnalysisHeader",props:Pt({title:{},avatar:{},icon:{},iconClass:{},tabs:{},currentSessionId:{},initialTimeState:{}},{activeTab:{required:!0},activeTabModifiers:{},timeRangeValue:{required:!0},timeRangeValueModifiers:{}}),emits:Pt(["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=s,{t:m}=ke(),u=dt(),d=k(()=>!["ai-chat","memory","lab","debug"].includes(t.value));return(g,v)=>{const h=Re,S=vt,b=_e;return n(),K(db,{title:l.title,avatar:l.avatar,size:"compact",icon:l.icon,"icon-class":l.iconClass},{actions:U(()=>[a(u).toolsPanelPosition==="header"?(n(),i(ne,{key:0},[p(S,{text:a(m)("analysis.tooltip.incrementalImport")},{default:U(()=>[p(h,{icon:"i-heroicons-plus-circle",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:v[0]||(v[0]=w=>r("openIncrementalImport"))})]),_:1},8,["text"]),p(S,{text:a(m)("analysis.tooltip.memberManagement")},{default:U(()=>[p(h,{icon:"i-heroicons-user-group",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:v[1]||(v[1]=w=>r("openMemberManagement"))})]),_:1},8,["text"]),p(S,{text:a(m)("analysis.tooltip.viewChatRecord")},{default:U(()=>[p(h,{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:v[2]||(v[2]=w=>r("openChatRecord"))})]),_:1},8,["text"]),p(ct,{color:"gray"}),p(S,{text:a(m)("analysis.tooltip.more")},{default:U(()=>[p(h,{"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:v[3]||(v[3]=w=>a(u).toggleToolsPanelOpen())})]),_:1},8,["text"])],64)):(n(),K(ct,{key:1,color:"gray"}))]),default:U(()=>[e("div",ub,[e("div",mb,[(n(!0),i(ne,null,de(l.tabs,w=>(n(),i("button",{key:w.id,class:oe(["flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm font-medium transition-all",[t.value===w.id?"bg-pink-500 text-white dark:bg-pink-900/30 dark:text-pink-300":"text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"]]),onClick:q=>t.value=w.id},[p(b,{name:w.icon,class:"h-4 w-4"},null,8,["name"]),e("span",pb,o(a(m)(w.labelKey)),1)],10,gb))),128))]),p(ob,{modelValue:c.value,"onUpdate:modelValue":v[4]||(v[4]=w=>c.value=w),"session-id":l.currentSessionId??void 0,visible:d.value,"initial-state":l.initialTimeState,"onUpdate:fullRange":v[5]||(v[5]=w=>r("update:fullRange",w)),"onUpdate:availableYears":v[6]||(v[6]=w=>r("update:availableYears",w))},null,8,["modelValue","session-id","visible","initial-state"])])]),_:1},8,["title","avatar","icon","icon-class"])}}}),vb={class:"p-6"},hb={class:"mb-4 flex items-center justify-between"},yb={class:"flex items-center gap-2"},fb={class:"flex h-10 w-10 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/30"},xb={class:"text-lg font-semibold text-gray-900 dark:text-white"},bb={class:"text-sm text-gray-500 dark:text-gray-400"},kb={key:0,class:"flex items-center justify-center py-8"},_b={key:0,class:"space-y-4"},wb={class:"rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-800/50 dark:bg-amber-900/20"},$b={class:"flex gap-3"},Cb={class:"text-sm font-medium text-amber-800 dark:text-amber-200"},Sb={class:"mt-1 text-sm text-amber-700 dark:text-amber-300"},Tb={class:"rounded-lg bg-gray-50 p-4 dark:bg-gray-800/50"},Ib={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},Mb={class:"space-y-1 text-sm text-gray-600 dark:text-gray-400"},Lb={class:"flex items-start gap-2"},Db={class:"flex items-start gap-2"},Ab={class:"flex items-start gap-2"},qb={key:1,class:"space-y-4"},Rb={class:"rounded-lg border border-green-200 bg-green-50 p-4 dark:border-green-800/50 dark:bg-green-900/20"},Eb={class:"flex gap-3"},zb={class:"text-sm font-medium text-green-800 dark:text-green-200"},Pb={class:"mt-1 text-sm text-green-700 dark:text-green-300"},Bb={class:"text-sm text-gray-500 dark:text-gray-400"},jb={class:"mt-6 flex justify-end gap-2"},p1=he({__name:"SessionIndexModal",props:{sessionId:{},modelValue:{type:Boolean},messageCount:{}},emits:["update:modelValue","generated"],setup(l,{emit:s}){const t=l,c=s,{t:r}=ke(),m=x(!1),u=x(0),d=x(!1),g=x(!0),v=x(!1),h=k({get:()=>t.modelValue??!1,set:_=>c("update:modelValue",_)}),S=k(()=>!v.value);async function b(){if(t.sessionId&&t.messageCount!==0){g.value=!0;try{const _=await Dt().getStats(t.sessionId);m.value=_.hasIndex,u.value=_.sessionCount,m.value||(v.value=!0,h.value=!0)}catch(_){console.error("检查会话索引失败:",_)}finally{g.value=!1}}}async function w(){if(t.sessionId){g.value=!0;try{const _=await Dt().getStats(t.sessionId);m.value=_.hasIndex,u.value=_.sessionCount}catch(_){console.error("检查会话索引失败:",_)}finally{g.value=!1}}}async function q(){if(t.sessionId){d.value=!0;try{const _=Fa(),C=await Dt().generate(t.sessionId,_);m.value=!0,u.value=C,c("generated",C),v.value=!1,h.value=!1}catch(_){console.error("生成会话索引失败:",_)}finally{d.value=!1}}}function T(){S.value&&(h.value=!1)}function I(_){!_&&!S.value||(h.value=_,_&&!v.value&&w())}return ge(()=>t.sessionId,()=>{b()}),Ee(()=>{b()}),(_,C)=>{const M=_e,y=Re,f=Oe;return n(),K(f,{open:h.value,dismissible:S.value,"onUpdate:open":I},{content:U(()=>[e("div",vb,[e("div",hb,[e("div",yb,[e("div",fb,[p(M,{name:"i-heroicons-clock",class:"h-5 w-5 text-blue-600 dark:text-blue-400"})]),e("div",null,[e("h3",xb,o(a(r)("records.sessionIndex.title")),1),e("p",bb,o(a(r)("records.sessionIndex.subtitle")),1)])]),S.value?(n(),K(y,{key:0,icon:"i-heroicons-x-mark",color:"neutral",variant:"ghost",size:"sm",onClick:T})):R("",!0)]),g.value?(n(),i("div",kb,[p(M,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):(n(),i(ne,{key:1},[m.value?(n(),i("div",qb,[e("div",Rb,[e("div",Eb,[p(M,{name:"i-heroicons-check-circle",class:"h-5 w-5 shrink-0 text-green-500"}),e("div",null,[e("p",zb,o(a(r)("records.sessionIndex.generated")),1),e("p",Pb,o(a(r)("records.sessionIndex.sessionCount",{count:u.value})),1)])])]),e("p",Bb,o(a(r)("records.sessionIndex.regenerateHint")),1)])):(n(),i("div",_b,[e("div",wb,[e("div",$b,[p(M,{name:"i-heroicons-exclamation-triangle",class:"h-5 w-5 shrink-0 text-amber-500"}),e("div",null,[e("p",Cb,o(a(r)("records.sessionIndex.notGenerated")),1),e("p",Sb,o(a(r)("records.sessionIndex.notGeneratedHint")),1)])])]),e("div",Tb,[e("h4",Ib,o(a(r)("records.sessionIndex.whatIsIt")),1),e("ul",Mb,[e("li",Lb,[p(M,{name:"i-heroicons-check",class:"mt-0.5 h-4 w-4 shrink-0 text-green-500"}),ee(" "+o(a(r)("records.sessionIndex.benefit1")),1)]),e("li",Db,[p(M,{name:"i-heroicons-check",class:"mt-0.5 h-4 w-4 shrink-0 text-green-500"}),ee(" "+o(a(r)("records.sessionIndex.benefit2")),1)]),e("li",Ab,[p(M,{name:"i-heroicons-check",class:"mt-0.5 h-4 w-4 shrink-0 text-green-500"}),ee(" "+o(a(r)("records.sessionIndex.benefit3")),1)])])])]))],64)),e("div",jb,[S.value?(n(),K(y,{key:0,variant:"ghost",onClick:T},{default:U(()=>[ee(o(a(r)("records.sessionIndex.cancel")),1)]),_:1})):R("",!0),p(y,{color:"primary",loading:d.value,onClick:q},{default:U(()=>[d.value?R("",!0):(n(),K(M,{key:0,name:m.value?"i-heroicons-arrow-path":"i-heroicons-sparkles",class:"mr-1 h-4 w-4"},null,8,["name"])),ee(" "+o(d.value?a(r)("records.sessionIndex.generating"):m.value?a(r)("records.sessionIndex.regenerate"):a(r)("records.sessionIndex.generate")),1)]),_:1},8,["loading"])])])]),_:1},8,["open","dismissible"])}}}),Fb={class:"space-y-4 p-5"},Ub={class:"flex items-center gap-2"},Vb={class:"text-base font-semibold text-gray-900 dark:text-white"},Ob={key:0,class:"flex items-center gap-2 text-sm text-gray-400"},Nb={class:"rounded-lg border border-gray-200 bg-gray-50 p-3 text-sm dark:border-gray-700 dark:bg-gray-800/50"},Hb={class:"flex items-center justify-between"},Yb={class:"text-gray-500"},Wb={class:"font-medium text-gray-800 dark:text-gray-200"},Kb={key:0,class:"mt-1 flex items-center justify-between"},Qb={class:"text-gray-500"},Gb={class:"text-gray-700 dark:text-gray-300"},Jb={key:1,class:"mt-2"},Xb={class:"flex items-center justify-between text-xs text-gray-500"},Zb={class:"mt-1 h-1.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},ek={key:2,class:"mt-1 text-xs text-red-500"},tk={class:"text-sm text-gray-600 dark:text-gray-400"},ak={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"},sk={class:"flex justify-end gap-2"},ok={class:"text-xs text-gray-400"},nk={class:"flex flex-wrap justify-end gap-2"},qe="settings.ai.semanticIndex",v1=he({__name:"SemanticIndexSessionModal",props:{modelValue:{type:Boolean},sessionId:{},messageCount:{}},emits:["update:modelValue"],setup(l,{emit:s}){const t=l,c=s,{t:r}=ke(),m=Ua(),u=k({get:()=>t.modelValue,set:M=>c("update:modelValue",M)}),d=x(null),g=x(!1),v=x(!1),h=x(!1),S=k(()=>{const M=d.value;return!M||!M.enabled?r(`${qe}.session.notEnabled`):M.needsRebuild?r(`${qe}.state.needsRebuild`):M.running||M.queued||M.indexStatus==="running"?r(`${qe}.state.building`):M.indexStatus==="completed"?r(`${qe}.state.completed`):M.indexStatus==="failed"?r(`${qe}.state.failed`):M.indexStatus==="paused"?r(`${qe}.state.paused`):r(`${qe}.state.pending`)}),b=k(()=>{const M=d.value;return!!M&&(M.running||M.queued||M.indexStatus==="running")}),w=k(()=>d.value&&d.value.totalMessages>0?Math.round(d.value.indexedMessages/d.value.totalMessages*100):0);let q=null;function T(){q&&(clearTimeout(q),q=null)}function I(){T(),q=setTimeout(async()=>{try{d.value=await m.status(t.sessionId)}catch(M){console.error("[semantic-index] poll status failed:",M)}b.value&&t.modelValue?I():T()},1500)}async function _(){v.value=!0;try{const[M,y]=await Promise.all([m.getConfig(),m.status(t.sessionId)]);g.value=M.config.enabled&&M.configured&&(M.config.mode==="local"?!!M.config.local.modelId:!!M.config.api?.baseUrl&&!!M.config.api?.model&&(!Va(M.config.api?.baseUrl)||M.apiKeySet)),d.value=y}catch(M){console.error("[semantic-index] load session status failed:",M)}finally{v.value=!1}b.value&&I()}async function C(M){h.value=!0;try{d.value=await m[M](t.sessionId)}catch(y){console.error(`[semantic-index] ${M} failed:`,y)}finally{h.value=!1}b.value?I():T()}return ge(()=>t.modelValue,M=>{M?_():T()}),lt(T),(M,y)=>{const f=_e,D=Re,A=Oe;return n(),K(A,{open:u.value,"onUpdate:open":y[10]||(y[10]=P=>u.value=P),ui:{content:"z-[101]",overlay:"z-[100]"}},{content:U(()=>[e("div",Fb,[e("div",Ub,[p(f,{name:"i-heroicons-circle-stack",class:"h-5 w-5 text-blue-500"}),e("h3",Vb,o(a(r)(`${qe}.title`)),1)]),v.value?(n(),i("div",Ob,[p(f,{name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin"}),ee(" "+o(a(r)("common.loading")),1)])):(n(),i(ne,{key:1},[e("div",Nb,[e("div",Hb,[e("span",Yb,o(a(r)(`${qe}.session.statusLabel`)),1),e("span",Wb,o(S.value),1)]),d.value?.enabled&&d.value.indexStatus==="completed"?(n(),i("div",Kb,[e("span",Qb,o(a(r)(`${qe}.session.coverageLabel`)),1),e("span",Gb,o(w.value)+"%",1)])):R("",!0),b.value?(n(),i("div",Jb,[e("div",Xb,[e("span",null,o(a(r)(`${qe}.session.progressLabel`)),1),e("span",null,o(d.value?.indexedMessages??0)+" / "+o(d.value?.totalMessages??0)+" ("+o(w.value)+"%) ",1)]),e("div",Zb,[e("div",{class:"h-full rounded-full bg-blue-500 transition-all duration-500",style:Ge({width:`${w.value}%`})},null,4)])])):R("",!0),d.value?.error?(n(),i("p",ek,o(d.value.error),1)):R("",!0)]),d.value?.enabled?(n(),i(ne,{key:1},[e("p",ok,o(a(r)(`${qe}.session.buildVsEnable`)),1),e("div",nk,[b.value?(n(),i(ne,{key:0},[p(D,{variant:"soft",loading:h.value,onClick:y[2]||(y[2]=P=>C("pause"))},{default:U(()=>[ee(o(a(r)(`${qe}.action.pause`)),1)]),_:1},8,["loading"]),p(D,{color:"error",variant:"soft",disabled:h.value,onClick:y[3]||(y[3]=P=>C("cancel"))},{default:U(()=>[ee(o(a(r)(`${qe}.action.cancel`)),1)]),_:1},8,["disabled"])],64)):d.value?.indexStatus==="completed"&&!d.value?.needsRebuild?(n(),K(D,{key:1,variant:"soft",loading:h.value,onClick:y[4]||(y[4]=P=>C("rebuild"))},{default:U(()=>[ee(o(a(r)(`${qe}.action.rebuild`)),1)]),_:1},8,["loading"])):d.value?.needsRebuild?(n(),K(D,{key:2,color:"primary",loading:h.value,onClick:y[5]||(y[5]=P=>C("rebuild"))},{default:U(()=>[ee(o(a(r)(`${qe}.action.rebuild`)),1)]),_:1},8,["loading"])):d.value?.indexStatus==="failed"?(n(),K(D,{key:3,color:"primary",loading:h.value,onClick:y[6]||(y[6]=P=>C("build"))},{default:U(()=>[ee(o(a(r)(`${qe}.session.retry`)),1)]),_:1},8,["loading"])):d.value?.indexStatus==="paused"?(n(),K(D,{key:4,color:"primary",loading:h.value,onClick:y[7]||(y[7]=P=>C("build"))},{default:U(()=>[ee(o(a(r)(`${qe}.session.continue`)),1)]),_:1},8,["loading"])):(n(),K(D,{key:5,color:"primary",loading:h.value,onClick:y[8]||(y[8]=P=>C("build"))},{default:U(()=>[ee(o(a(r)(`${qe}.action.build`)),1)]),_:1},8,["loading"])),p(D,{variant:"ghost",color:"neutral",disabled:h.value,onClick:y[9]||(y[9]=P=>C("remove"))},{default:U(()=>[ee(o(a(r)(`${qe}.action.remove`)),1)]),_:1},8,["disabled"])])],64)):(n(),i(ne,{key:0},[e("p",tk,o(a(r)(`${qe}.session.enableHint`)),1),g.value?R("",!0):(n(),i("p",ak,o(a(r)(`${qe}.session.configFirst`)),1)),e("div",sk,[p(D,{variant:"ghost",onClick:y[0]||(y[0]=P=>u.value=!1)},{default:U(()=>[ee(o(a(r)("common.close")),1)]),_:1}),p(D,{color:"primary",loading:h.value,disabled:!g.value,onClick:y[1]||(y[1]=P=>C("enable"))},{default:U(()=>[ee(o(a(r)(`${qe}.session.enable`)),1)]),_:1},8,["loading","disabled"])])],64))],64))])]),_:1},8,["open"])}}}),rk={class:"min-h-[200px]"},lk={key:0,class:"space-y-4"},ik={class:"text-sm text-gray-600 dark:text-gray-400"},ck={class:"text-sm text-gray-600 dark:text-gray-400"},dk={key:1,class:"flex flex-col items-center justify-center py-10"},uk={class:"text-gray-600 dark:text-gray-400"},mk={class:"mt-2 text-sm text-gray-500"},gk={key:2,class:"space-y-6"},pk={class:"rounded-lg bg-gray-50 p-4 dark:bg-gray-800"},vk={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},hk={class:"grid grid-cols-3 gap-4 text-center"},yk={class:"text-2xl font-bold text-gray-900 dark:text-white"},fk={class:"text-xs text-gray-500"},xk={class:"text-2xl font-bold text-green-600 dark:text-green-400"},bk={class:"text-xs text-gray-500"},kk={class:"text-2xl font-bold text-gray-400"},_k={class:"text-xs text-gray-500"},wk={key:0,class:"text-center text-sm text-amber-600 dark:text-amber-400"},$k={key:3,class:"flex flex-col items-center justify-center py-10"},Ck={class:"text-gray-600 dark:text-gray-400"},Sk={key:0,class:"mt-4 w-full max-w-xs"},Tk={key:4,class:"flex flex-col items-center justify-center py-10"},Ik={class:"text-lg font-medium text-gray-900 dark:text-white"},Mk={class:"mt-2 text-sm text-gray-600 dark:text-gray-400"},Lk={key:5,class:"flex flex-col items-center justify-center py-10"},Dk={class:"text-lg font-medium text-gray-900 dark:text-white"},Ak={class:"mt-2 text-sm text-red-600 dark:text-red-400"},qk={class:"flex w-full justify-end gap-2"},h1=he({__name:"IncrementalImportModal",props:{modelValue:{type:Boolean},sessionId:{},sessionName:{}},emits:["update:modelValue","imported"],setup(l,{emit:s}){const t=l,c=s,{t:r}=ke(),m=x("select"),u=x(null),d=x(null),g=x(null),v=x(null),h=x(null),S=x(null),b=k({get:()=>t.modelValue,set:f=>c("update:modelValue",f)});ge(b,f=>{f||w()});function w(){m.value="select",u.value=null,g.value=null,v.value=null,h.value=null,S.value=null}async function q({files:f,paths:D}){if(f.length>0)u.value={source:f[0],name:f[0].name};else{h.value=r("home.import.cannotReadPath");return}await I()}function T(){d.value?.openFileDialog()}async function I(){if(u.value){m.value="analyzing",h.value=null;try{const f=await ta().analyzeIncrementalImport(t.sessionId,u.value.source);if(f.error){m.value="error",h.value=y(f.error);return}g.value={newMessageCount:f.newMessageCount,duplicateCount:f.duplicateCount,totalInFile:f.totalInFile},m.value="preview"}catch(f){m.value="error",h.value=String(f)}}}async function _(){if(u.value){m.value="importing",v.value={stage:"saving",progress:0,message:""};try{const f=await ta().incrementalImport(t.sessionId,u.value.source,D=>{v.value=D});f.success?(S.value={newMessageCount:f.newMessageCount},m.value="done"):(m.value="error",h.value=y(f.error||"error.import_failed"))}catch(f){m.value="error",h.value=String(f)}}}function C(){S.value&&c("imported",S.value.newMessageCount),b.value=!1}function M(){m.value="select",u.value=null,g.value=null,h.value=null}function y(f){if(f.startsWith("error.")){const D=`home.import.errors.${f.slice(6)}`,A=r(D);return A!==D?A:f}return f}return(f,D)=>{const A=_e,P=Ga,z=Re,$=Oe;return n(),K($,{open:b.value,"onUpdate:open":D[1]||(D[1]=L=>b.value=L),title:a(r)("analysis.incremental.title")},{body:U(()=>[e("div",rk,[m.value==="select"?(n(),i("div",lk,[e("p",ik,o(a(r)("analysis.incremental.description",{name:l.sessionName})),1),p(a(Xa),{ref_key:"dropZoneRef",ref:d,accept:[".json",".jsonl",".txt"],class:"w-full",onFiles:q},{default:U(({isDragOver:L})=>[e("div",{class:oe(["flex cursor-pointer flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 py-10 transition-colors",L?"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:Fe(T,["stop"])},[p(A,{name:"i-heroicons-arrow-up-tray",class:"mb-3 h-10 w-10 text-gray-400"}),e("p",ck,o(L?a(r)("home.import.dropHint"):a(r)("analysis.incremental.dropHint")),1)],2)]),_:1},512)])):m.value==="analyzing"?(n(),i("div",dk,[p(A,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),e("p",uk,o(a(r)("analysis.incremental.analyzing")),1),e("p",mk,o(u.value?.name),1)])):m.value==="preview"&&g.value?(n(),i("div",gk,[e("div",pk,[e("p",vk,o(u.value?.name),1),e("div",hk,[e("div",null,[e("p",yk,o(g.value.totalInFile.toLocaleString()),1),e("p",fk,o(a(r)("analysis.incremental.totalInFile")),1)]),e("div",null,[e("p",xk,o(g.value.newMessageCount.toLocaleString()),1),e("p",bk,o(a(r)("analysis.incremental.newMessages")),1)]),e("div",null,[e("p",kk,o(g.value.duplicateCount.toLocaleString()),1),e("p",_k,o(a(r)("analysis.incremental.duplicates")),1)])])]),g.value.newMessageCount===0?(n(),i("p",wk,[p(A,{name:"i-heroicons-exclamation-triangle",class:"mr-1 inline-block h-4 w-4"}),ee(" "+o(a(r)("analysis.incremental.noNewMessages")),1)])):R("",!0)])):m.value==="importing"?(n(),i("div",$k,[p(A,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),e("p",Ck,o(a(r)("analysis.incremental.importing")),1),v.value?(n(),i("div",Sk,[p(P,{value:v.value.progress,size:"sm"},null,8,["value"])])):R("",!0)])):m.value==="done"&&S.value?(n(),i("div",Tk,[p(A,{name:"i-heroicons-check-circle",class:"mb-4 h-12 w-12 text-green-500"}),e("p",Ik,o(a(r)("analysis.incremental.success")),1),e("p",Mk,o(a(r)("analysis.incremental.successDetail",{count:S.value.newMessageCount})),1)])):m.value==="error"?(n(),i("div",Lk,[p(A,{name:"i-heroicons-x-circle",class:"mb-4 h-12 w-12 text-red-500"}),e("p",Dk,o(a(r)("analysis.incremental.failed")),1),e("p",Ak,o(h.value),1)])):R("",!0)])]),footer:U(()=>[e("div",qk,[m.value==="select"?(n(),K(z,{key:0,color:"neutral",variant:"ghost",onClick:D[0]||(D[0]=L=>b.value=!1)},{default:U(()=>[ee(o(a(r)("common.cancel")),1)]),_:1})):m.value==="preview"?(n(),i(ne,{key:1},[p(z,{color:"neutral",variant:"ghost",onClick:M},{default:U(()=>[ee(o(a(r)("common.back")),1)]),_:1}),p(z,{color:"primary",disabled:!g.value||g.value.newMessageCount===0,onClick:_},{default:U(()=>[ee(o(a(r)("analysis.incremental.import",{count:g.value?.newMessageCount||0})),1)]),_:1},8,["disabled"])],64)):m.value==="done"||m.value==="error"?(n(),i(ne,{key:2},[m.value==="error"?(n(),K(z,{key:0,color:"neutral",variant:"ghost",onClick:M},{default:U(()=>[ee(o(a(r)("common.retry")),1)]),_:1})):R("",!0),p(z,{color:"primary",onClick:C},{default:U(()=>[ee(o(a(r)("common.done")),1)]),_:1})],64)):R("",!0)])]),_:1},8,["open","title"])}}}),Rk={key:0,class:"fixed right-0 top-1/3"},Ek={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-gray-900"},zk=["onClick"],Pk={class:"mb-2 flex items-center justify-between"},Bk={class:"px-0.5 text-[9px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"},jk={class:"flex flex-col gap-1.5"},Fk=["onClick"],Uk={class:"whitespace-nowrap"},y1=he({__name:"ActionToolsPanel",emits:["openIncrementalImport","openSessionIndex","openSemanticIndex","openMemberManagement","openChatRecord","openMessageExport"],setup(l,{emit:s}){const{t}=ke(),c=dt(),{isToolsPanelMini:r,toolsPanelPosition:m,isToolsPanelOpen:u}=at(c),d=k(()=>m.value==="header"),g=k(()=>!d.value||u.value),v=x(null),h=s;function S(I){h(I),d.value&&(u.value=!1)}function b(I){if(!d.value||!u.value)return;const _=I.target;_ instanceof Element&&(v.value?.contains(_)||_.closest("[data-tools-panel-trigger]")||(u.value=!1))}const w=[{event:"openIncrementalImport",icon:"i-heroicons-plus-circle",hoverColor:"group-hover:text-pink-500",miniHoverBg:"hover:text-pink-500",labelKey:"analysis.tooltip.incrementalImport"},{event:"openSessionIndex",icon:"i-heroicons-clock",hoverColor:"group-hover:text-blue-500",miniHoverBg:"hover:text-blue-500",labelKey:"analysis.tooltip.sessionIndex"},{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"}],q=[{event:"openSessionIndex",icon:"i-heroicons-clock",hoverColor:"group-hover:text-blue-500",miniHoverBg:"hover:text-blue-500",labelKey:"analysis.tooltip.sessionIndex"},{event:"openSemanticIndex",icon:"i-heroicons-circle-stack",hoverColor:"group-hover:text-indigo-500",miniHoverBg:"hover:text-indigo-500",labelKey:"analysis.tooltip.semanticIndex"},{event:"openMessageExport",icon:"i-heroicons-document-arrow-down",hoverColor:"group-hover:text-green-500",miniHoverBg:"hover:text-green-500",labelKey:"analysis.messageExport.title"}],T=k(()=>d.value?q:w);return ge(m,()=>{u.value=!1}),Ee(()=>{document.addEventListener("mousedown",b)}),St(()=>{document.removeEventListener("mousedown",b)}),(I,_)=>{const C=_e,M=vt;return!d.value&&a(r)?(n(),i("div",Rk,[e("div",Ek,[(n(),i(ne,null,de(w,y=>p(M,{key:y.event,text:a(t)(y.labelKey),popper:{placement:"left"}},{default:U(()=>[e("button",{class:oe(["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",y.miniHoverBg]),onClick:f=>S(y.event)},[p(C,{name:y.icon,class:"h-3.5 w-3.5"},null,8,["name"])],10,zk)]),_:2},1032,["text"])),64)),_[2]||(_[2]=e("div",{class:"my-0.5 h-px w-4 bg-gray-200 dark:bg-gray-700"},null,-1)),p(M,{text:a(t)("analysis.toolsPanel.exitMini"),popper:{placement:"left"}},{default:U(()=>[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:_[0]||(_[0]=y=>a(c).toggleToolsPanelMini())},[p(C,{name:"i-heroicons-arrows-pointing-out",class:"h-3 w-3"})])]),_:1},8,["text"])])])):(n(),i("div",{key:1,class:oe(["fixed right-0 z-40",d.value?"top-14":"top-1/3"])},[e("div",{class:oe(["absolute right-0 top-0 transition-all duration-250 ease-in-out",g.value?"translate-x-0 opacity-100":"pointer-events-none translate-x-full opacity-0"])},[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-lg dark:border-white/5 dark:bg-gray-900"},[e("div",Pk,[e("span",Bk,o(a(t)("analysis.overview.tools")),1),d.value?R("",!0):(n(),K(M,{key:0,text:a(t)("analysis.toolsPanel.miniMode"),popper:{placement:"left"}},{default:U(()=>[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:_[1]||(_[1]=y=>a(c).toggleToolsPanelMini())},[p(C,{name:"i-heroicons-arrows-pointing-in",class:"h-3 w-3"})])]),_:1},8,["text"]))]),e("div",jk,[(n(!0),i(ne,null,de(T.value,y=>(n(),i("button",{key:y.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:f=>S(y.event)},[p(C,{name:y.icon,class:oe(["h-3.5 w-3.5 text-gray-400 transition-colors dark:text-gray-500",y.hoverColor])},null,8,["name","class"]),e("span",Uk,o(a(t)(y.labelKey)),1)],8,Fk))),128))])],512)],2)],2))}}}),Vk={class:"no-capture flex w-28 flex-col items-center rounded-l-xl border border-r-0 border-amber-200/60 bg-white p-3 shadow-lg dark:border-amber-500/10 dark:bg-gray-900"},Ok={class:"flex w-full flex-col items-center gap-3"},Nk={class:"whitespace-nowrap"},f1=he({__name:"DebugToolsPanel",setup(l){const s=Ct(),t=pt(),c=Na(t),r=x(!1);let m=null;const u=k(()=>r.value);function d(){m&&(clearTimeout(m),m=null),r.value=!0}function g(){m=setTimeout(()=>{r.value=!1},200)}const v=k({get:()=>s.locale,set:S=>s.setLocale(S)}),h=Oa.map(S=>({label:S.nativeName,value:S.code}));return(S,b)=>{const w=_e,q=Ja;return n(),i("div",{class:"fixed right-0 top-[70%] z-40",onMouseenter:d,onMouseleave:g},[e("div",{class:oe(["h-10 w-6 cursor-pointer items-center justify-center rounded-l-lg border border-r-0 border-amber-300/50 bg-amber-50 text-amber-500 shadow-sm transition-opacity duration-200 hover:bg-amber-100 dark:border-amber-500/30 dark:bg-amber-950 dark:text-amber-400 dark:hover:bg-amber-900",u.value?"pointer-events-none flex opacity-0":"flex opacity-100"])},[p(w,{name:"i-heroicons-bug-ant",class:"h-3.5 w-3.5"})],2),e("div",{class:oe(["absolute right-0 top-0 transition-all duration-250 ease-in-out",u.value?"translate-x-0 opacity-100":"pointer-events-none translate-x-full opacity-0"])},[e("div",Vk,[b[2]||(b[2]=e("div",{class:"mb-2"},[e("span",{class:"px-0.5 text-[9px] font-bold uppercase tracking-widest text-amber-500 dark:text-amber-400"}," Debug ")],-1)),e("div",Ok,[e("button",{class:"group flex items-center gap-1.5 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:b[0]||(b[0]=T=>a(c)())},[p(w,{name:a(t)?"i-heroicons-moon-solid":"i-heroicons-sun-solid",class:oe(["h-3.5 w-3.5 transition-colors",a(t)?"text-indigo-400":"text-amber-400"])},null,8,["name","class"]),e("span",Nk,o(a(t)?"Dark":"Light"),1)]),p(q,{modelValue:v.value,"onUpdate:modelValue":b[1]||(b[1]=T=>v.value=T),items:a(h),content:!1,orientation:"vertical",size:"xs"},null,8,["modelValue","items"])])])],2)],32)}}});export{h1 as A,n1 as B,Vu as C,o1 as D,r1 as E,f1 as F,it as G,bt as _,We as a,e1 as b,mt as c,a1 as d,Nm as e,sa as f,cs as g,i1 as h,Vt as i,c1 as j,Ht as k,Xk as l,tt as m,sp as n,d1 as o,u1 as p,s1 as q,m1 as r,Zk as s,t1 as t,l1 as u,g1 as v,y1 as w,p1 as x,v1 as y,Wx as z};
|