chatlab-cli 0.26.3 → 0.27.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 +10 -4
- package/dist/{chat-command-D37MMEJ7.mjs → chat-command-SKGPS3PG.mjs} +5 -5
- package/dist/{chunk-QMXNJRTT.mjs → chunk-3HOTLLFC.mjs} +112 -21
- package/dist/chunk-3HOTLLFC.mjs.map +1 -0
- package/dist/{chunk-VCN64OD6.mjs → chunk-6FXGC6HE.mjs} +2 -2
- package/dist/{chunk-GNGZHBKM.mjs → chunk-7LPVQR77.mjs} +42 -7
- package/dist/chunk-7LPVQR77.mjs.map +1 -0
- package/dist/{chunk-742TAKEP.mjs → chunk-FHLPXRDL.mjs} +2 -2
- package/dist/{chunk-VSOWNKPA.mjs → chunk-GFHSSCCR.mjs} +11 -1
- package/dist/{chunk-YPTJVTVJ.mjs → chunk-KCFVHVO4.mjs} +5102 -4217
- package/dist/chunk-KCFVHVO4.mjs.map +1 -0
- package/dist/{chunk-RMITK4IC.mjs → chunk-M6ABWESL.mjs} +466 -116
- package/dist/chunk-M6ABWESL.mjs.map +1 -0
- package/dist/{chunk-K5SGXTVJ.mjs → chunk-MJITS5CE.mjs} +16 -16
- package/dist/{chunk-D5MWER7N.mjs → chunk-UBJHT3BU.mjs} +2 -2
- package/dist/cli.mjs +4 -4
- package/dist/{http-6F6TYWCI.mjs → http-CPFUTIUB.mjs} +9 -9
- package/dist/{import-VYPOMSSA.mjs → import-UJXKIKYN.mjs} +5 -5
- package/dist/index.mjs +9 -9
- package/dist/{mcp-AR7L5FA3.mjs → mcp-SW4DTCWJ.mjs} +8 -8
- package/dist/onnxruntime_binding-6Q6HXASN.node +0 -0
- package/dist/onnxruntime_binding-EKZT2NRK.node +0 -0
- package/dist/onnxruntime_binding-P6S7V3CI.node +0 -0
- package/dist/onnxruntime_binding-PJNNIIUO.node +0 -0
- package/dist/onnxruntime_binding-UN6SPTQK.node +0 -0
- package/dist/{service-KZTHBDQ5.mjs → service-KGL3RAIA.mjs} +2 -2
- package/dist/{src-6S7JPKHX.mjs → src-M3MO3LEL.mjs} +11 -71
- package/dist/{stream-import-KZFC3XT2.mjs → stream-import-4VDJZHMY.mjs} +4 -4
- package/dist/transformers.node-PUMHAODN.mjs +42889 -0
- package/dist/transformers.node-PUMHAODN.mjs.map +1 -0
- package/dist/{update-checker-3N7HQEP2.mjs → update-checker-LGMTEKMT.mjs} +2 -2
- package/dist-web/assets/DebugToolsPanel.vue_vue_type_script_setup_true_lang-C8mwzxDa.js +110 -0
- package/dist-web/assets/{MessageExportModal-CF6yaor7.js → MessageExportModal-DCB-mzf2.js} +1 -1
- package/dist-web/assets/{electron-DKVw61Ww.js → electron-DDUv0ohD.js} +1 -1
- package/dist-web/assets/{fetch-BC8jyJ_U.js → fetch-B3gsbY_U.js} +1 -1
- package/dist-web/assets/{fetch-BvVfWR-P.js → fetch-B9Oy0bcD.js} +1 -1
- package/dist-web/assets/{fetch-D2jNBqs8.js → fetch-Bry8iJpq.js} +1 -1
- package/dist-web/assets/{fetch-CUw-PUYP.js → fetch-C1aC5Fd1.js} +1 -1
- package/dist-web/assets/{fetch-DqEMAea3.js → fetch-C69hj3wS.js} +1 -1
- package/dist-web/assets/{fetch-CpYSD089.js → fetch-Ck4rGxkO.js} +1 -1
- package/dist-web/assets/{fetch-CPeSfqsU.js → fetch-Ckang-F8.js} +1 -1
- package/dist-web/assets/{fetch-BQlEQsqi.js → fetch-CwHncc6x.js} +1 -1
- package/dist-web/assets/{fetch-BMdgfBVS.js → fetch-D8Ng59an.js} +1 -1
- package/dist-web/assets/{fetch-Bh6HC-IR.js → fetch-DOtBAxUS.js} +1 -1
- package/dist-web/assets/index-B40SKtW8.js +173 -0
- package/dist-web/assets/{index-DqybGdJH.css → index-BX3tqfLz.css} +1 -1
- package/dist-web/assets/{index-BHQnAj6l.js → index-Bd9j73nw.js} +1 -1
- package/dist-web/assets/index-BfFj8Evo.js +64 -0
- package/dist-web/assets/index-C16V6EoP.js +11 -0
- package/dist-web/assets/{index-Qh0XLt3R.js → index-D-J8dY7w.js} +1 -1
- package/dist-web/assets/index-I3SWZjnW.css +1 -0
- package/dist-web/assets/index-YmzTgkb2.css +1 -0
- package/dist-web/assets/index-zAi37ZQ4.js +2 -0
- package/dist-web/assets/{web-Bx2TiHDk.js → web-DKFeBb_F.js} +1 -1
- package/dist-web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-GNGZHBKM.mjs.map +0 -1
- package/dist/chunk-QMXNJRTT.mjs.map +0 -1
- package/dist/chunk-RMITK4IC.mjs.map +0 -1
- package/dist/chunk-YPTJVTVJ.mjs.map +0 -1
- package/dist-web/assets/DebugToolsPanel.vue_vue_type_script_setup_true_lang-BTdqmm0y.js +0 -107
- package/dist-web/assets/index-BwzuCu5R.js +0 -2
- package/dist-web/assets/index-CG746E15.js +0 -64
- package/dist-web/assets/index-CXoQ_U22.js +0 -173
- package/dist-web/assets/index-HgIuP1Td.css +0 -1
- package/dist-web/assets/index-R82N2_0b.css +0 -1
- package/dist-web/assets/index-wPAmuQZY.js +0 -11
- /package/dist/{chat-command-D37MMEJ7.mjs.map → chat-command-SKGPS3PG.mjs.map} +0 -0
- /package/dist/{chunk-VCN64OD6.mjs.map → chunk-6FXGC6HE.mjs.map} +0 -0
- /package/dist/{chunk-742TAKEP.mjs.map → chunk-FHLPXRDL.mjs.map} +0 -0
- /package/dist/{chunk-VSOWNKPA.mjs.map → chunk-GFHSSCCR.mjs.map} +0 -0
- /package/dist/{chunk-K5SGXTVJ.mjs.map → chunk-MJITS5CE.mjs.map} +0 -0
- /package/dist/{chunk-D5MWER7N.mjs.map → chunk-UBJHT3BU.mjs.map} +0 -0
- /package/dist/{http-6F6TYWCI.mjs.map → http-CPFUTIUB.mjs.map} +0 -0
- /package/dist/{import-VYPOMSSA.mjs.map → import-UJXKIKYN.mjs.map} +0 -0
- /package/dist/{mcp-AR7L5FA3.mjs.map → mcp-SW4DTCWJ.mjs.map} +0 -0
- /package/dist/{service-KZTHBDQ5.mjs.map → service-KGL3RAIA.mjs.map} +0 -0
- /package/dist/{src-6S7JPKHX.mjs.map → src-M3MO3LEL.mjs.map} +0 -0
- /package/dist/{stream-import-KZFC3XT2.mjs.map → stream-import-4VDJZHMY.mjs.map} +0 -0
- /package/dist/{update-checker-3N7HQEP2.mjs.map → update-checker-LGMTEKMT.mjs.map} +0 -0
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-wPAmuQZY.js","assets/vendor-reka-ui-mMvma1EP.js","assets/vendor-nuxt-ui-Zy8txNdC.js","assets/vendor-snapdom-XnBoh1gd.js","assets/index-HgIuP1Td.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 qa,w as sa,x as fe,j as qe,u as he,y as je,_ as et,z as Ye,A as Ra,B as lt,s as Ze,k as dt,D as wt,E as Ea,g as oa,F as ut,b as $t,G as Nt,H as na,p as mt,J as _t,K as za,T as Je,L as Jt,M as Pa,r as ra,e as la,N as Xt,i as Lt,h as ja,f as Zt,d as Fa,O as Ba}from"./index-wPAmuQZY.js";import{t as Oe,w as me,h as k,b as f,d as Me,p as pe,G as o,P as i,Q as ae,a5 as e,U as P,L as p,O as Ve,H as Q,K as O,T as n,a0 as Ne,R as ne,Z as oe,u as a,a3 as ue,bA as Be,bB as at,a9 as Pe,bz as Ke,J as Et,W as zt,n as ze,F as it,bK as Ua,bD as st,z as Ct,bH as nt,bI as ia,k as Va}from"./vendor-reka-ui-mMvma1EP.js";import{_ as St}from"./vendor-snapdom-XnBoh1gd.js";import{a as ye,b as Le,c as ca,g as Fe,_ as gt,e as pt,E as Oa,n as da,k as Tt,f as ua,j as Yt,l as Na,F as Ht,u as Ya,o as Ha,h as Wa}from"./vendor-nuxt-ui-Zy8txNdC.js";import{a as rt,M as Wt,_ as Ka}from"./index-Qh0XLt3R.js";import"./vendor-echarts-wordcloud-B1kQMklB.js";import{u as vt,m as ht,v as ma,t as ga,w as Qa,o as Kt,x as Ga,j as It,k as Ja,p as pa,q as Qt,y as Xa,n as yt,z as va,A as Za}from"./vendor-echarts-CITQeskI.js";const es={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"]},ea=/^(?!.*-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 ts(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":ea.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":ea.test(t)?"default":"none"}function as(l,s){const t=ts(l,s);return es[t]}function ss(l,s,t,c="group",r="zh-CN"){const m=qa(),{chatKey:u,state:d}=m.ensureSessionState({sessionId:l,sessionName:s,timeFilter:t,chatType:c,locale:r});return m.resetToSelectorOnEnter(u),m.applySessionAssistantSelection(u),{messages:Oe(d,"messages"),sourceMessages:Oe(d,"sourceMessages"),currentKeywords:Oe(d,"currentKeywords"),isLoadingSource:Oe(d,"isLoadingSource"),isAIThinking:Oe(d,"isAIThinking"),currentAIChatId:Oe(d,"currentAIChatId"),currentToolStatus:Oe(d,"currentToolStatus"),toolsUsedInCurrentRound:Oe(d,"toolsUsedInCurrentRound"),sessionTokenUsage:Oe(d,"sessionTokenUsage"),agentStatus:Oe(d,"agentStatus"),selectedAssistantId:Oe(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 Dt=new Map;function os(l,s,t){const{activeTab:c,isInitialLoad:r,currentSessionId:m,onTimeRangeChange:u}=t,d=f(null),g=f(null),v=f([]),h=k(()=>{const M=d.value;if(M)return{startTs:M.startTs,endTs:M.endTs}}),$=k(()=>{const M=d.value;return M?`${M.startTs}-${M.endTs}`:"init"}),x=k(()=>{const M=d.value;return!M||M.isFullRange?null:new Date(M.startTs*1e3).getFullYear()}),S=k(()=>{const M=l.query,L=M.timeMode;return L?{mode:L,recentDays:M.timeDays?Number(M.timeDays):void 0,year:M.timeYear?Number(M.timeYear):void 0,quarterYear:M.timeYear?Number(M.timeYear):void 0,quarter:M.timeQuarter?Number(M.timeQuarter):void 0,customStart:M.timeStart||void 0,customEnd:M.timeEnd||void 0}:m.value&&Dt.has(m.value)?Dt.get(m.value):{mode:"recent",recentDays:365}});me([c,d],([M,L])=>{if(r.value||!L)return;const b=L.state,I={tab:M,timeMode:b.mode,timeDays:void 0,timeYear:void 0,timeQuarter:void 0,timeStart:void 0,timeEnd:void 0};b.mode==="recent"&&(I.timeDays=b.recentDays),b.mode==="year"&&(I.timeYear=b.year),b.mode==="quarter"&&(I.timeYear=b.quarterYear,I.timeQuarter=b.quarter),b.mode==="custom"&&(I.timeStart=b.customStart,I.timeEnd=b.customEnd),s.replace({query:{...l.query,...I}})}),me(d,M=>{!M||!m.value||(sa(),Dt.set(m.value,M.state),u?.())},{immediate:!0});function E(){d.value=null,g.value=null,v.value=[]}return{timeRangeValue:d,fullTimeRange:g,availableYears:v,timeFilter:h,timeFilterKey:$,selectedYearForOverview:x,initialTimeState:S,resetTimeRange:E}}function ta(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 Pb(l){return fe.unix(l).format("YYYY-MM-DD HH:mm:ss")}function jb(l,s){const t=ta(l);if(s===null)return`${t} ~ 至今`;const c=ta(s);return t===c?t:`${t} ~ ${c}`}function Pt(l,s,t="YYYY/MM/DD",c=" - "){const r=fe.unix(l).format(t),m=fe.unix(s).format(t);return r===m?r:`${r}${c}${m}`}function ns(l){return l===0?"bg-linear-to-r from-amber-400 to-orange-500 text-white":l===1?"bg-linear-to-r from-gray-300 to-gray-400 text-white":l===2?"bg-linear-to-r from-amber-600 to-amber-700 text-white":"bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"}function Fb(l){const s=["from-amber-400 to-orange-500","from-gray-300 to-gray-400","from-amber-600 to-amber-700","from-pink-400 to-pink-600","from-pink-300 to-rose-500","from-cyan-400 to-blue-500","from-green-400 to-emerald-500","from-rose-400 to-pink-500"];return s[l%s.length]}function rs(l,s,t,c){const r=[];r.push(`# ${l}`),r.push(""),r.push(`> ${c.createdAt}: ${fe(t).format("YYYY-MM-DD HH:mm:ss")}`),r.push(""),r.push("---"),r.push("");for(const m of s){const u=fe(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
|
-
`)}function ls(l,s,t,c){const r=[];r.push(`${l}`),r.push(`${c.createdAt}: ${fe(t).format("YYYY-MM-DD HH:mm:ss")}`),r.push(""),r.push("=".repeat(50)),r.push("");for(const m of s){const u=fe(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 is(l){return l.replace(/[/\\?%*:|"<>]/g,"_")}async function cs(l,s,t,c,r){if(s.length===0)return{success:!1,error:"No messages to export"};let m,u;const d=fe(t).format("YYYYMMDD_HHmmss"),g=is(l);c==="markdown"?(m=rs(l,s,t,r),u=`${g}_${d}.md`):(m=ls(l,s,t,r),u=`${g}_${d}.txt`);const v=`data:text/plain;charset=utf-8,${encodeURIComponent(m)}`,{useCacheService:h}=await St(async()=>{const{useCacheService:x}=await import("./index-wPAmuQZY.js").then(S=>S.Y);return{useCacheService:x}},__vite__mapDeps([0,1,2,3,4]));return await h().saveToDownloads(u,v)}function ds(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 us(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 ms(l,s){if(l.rows.length===0)return{success:!1,error:"No data to export"};const c=`sql_result_${fe().format("YYYYMMDD_HHmmss")}.${s}`;let r,m;s==="json"?(r=us(l),m="application/json"):(r=ds(l),m="text/csv");const u=`data:${m};charset=utf-8,${encodeURIComponent(r)}`,{useCacheService:d}=await St(async()=>{const{useCacheService:v}=await import("./index-wPAmuQZY.js").then(h=>h.Y);return{useCacheService:v}},__vite__mapDeps([0,1,2,3,4]));return await d().saveToDownloads(c,u)}function Bb(l){const{route:s,router:t,currentSessionId:c,selectSession:r,defaultTab:m,validTabIds:u}=l,d=f(!0),g=f(!0),v=f(null),h=f([]),$=f([]),x=f([]),S=f([]);function E(){const _=s.query.tab;return _&&u.includes(_)?_:m}const M=f(E()),{timeRangeValue:L,fullTimeRange:b,availableYears:I,timeFilter:R,selectedYearForOverview:w,initialTimeState:y}=os(s,t,{activeTab:M,isInitialLoad:g,currentSessionId:c,onTimeRangeChange:()=>B()});function A(){const _=s.params.id;_&&(r(_),c.value!==_&&t.replace("/"))}async function q(){if(c.value)try{const _=await qe().getSession(c.value);v.value=_}catch(_){console.error("加载基础数据失败:",_)}}async function B(){if(c.value){d.value=!0;try{const _=R.value,T=qe(),[W,ee,Y,ce]=await Promise.all([T.getMemberActivity(c.value,_),T.getHourlyActivity(c.value,_),T.getDailyActivity(c.value,_),T.getMessageTypeDistribution(c.value,_)]);h.value=W,$.value=ee,x.value=Y,S.value=ce}catch(_){console.error("加载分析数据失败:",_)}finally{d.value=!1}}}async function j(){c.value&&(g.value=!0,await q(),g.value=!1)}return me(()=>s.params.id,()=>{M.value=E(),A()}),me(()=>s.query.tab,()=>{M.value=E()}),me(c,()=>{sa(),j()},{immediate:!0}),Me(()=>{A()}),{activeTab:M,isLoading:d,isInitialLoad:g,session:v,memberActivity:h,hourlyActivity:$,dailyActivity:x,messageTypes:S,timeRangeValue:L,fullTimeRange:b,availableYears:I,timeFilter:R,selectedYearForOverview:w,initialTimeState:y,syncSession:A,loadData:j,loadAnalysisData:B}}const gs=["data-theme-card"],ps={key:0,class:"pointer-events-none absolute inset-0 overflow-hidden"},vs={key:1,class:"absolute right-3 top-3 z-50 opacity-0 transition-opacity duration-200 group-hover/card:opacity-100"},ot=pe({__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)=>(o(),i("div",{class:ae(c.value),"data-theme-card":l.capturable?"":void 0},[r.value?(o(),i("div",ps,[...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)])])):P("",!0),l.capturable?(o(),i("div",vs,[p(rt,{type:"element","target-selector":"[data-theme-card]",size:"xs"})])):P("",!0),Ve(m.$slots,"default")],10,gs))}}),hs={class:"flex items-center justify-between"},ys={class:"font-semibold text-gray-900 dark:text-white whitespace-nowrap"},fs={key:0,class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},Ue=pe({__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)=>(o(),Q(ot,{variant:"section"},{default:O(()=>[e("div",{class:ae(["px-5 py-3",{"border-b border-gray-200 dark:border-white/5":l.showDivider&&c.$slots.default}])},[e("div",hs,[e("div",null,[e("p",ys,n(l.title),1),l.description?(o(),i("p",fs,n(l.description),1)):P("",!0)]),Ve(c.$slots,"headerRight")])],2),l.scrollable?(o(),i("div",{key:0,style:Ne(t.value)},[Ve(c.$slots,"default")],4)):Ve(c.$slots,"default",{key:1}),Ve(c.$slots,"footer")]),_:3}))}}),xs={class:"flex items-start justify-between"},bs={class:"min-w-0 flex-1"},ks={class:"text-sm font-medium text-gray-500 dark:text-gray-400"},_s={key:1,class:"text-xl"},ws={key:0,class:"mt-4 flex items-center text-sm"},$s={class:"text-gray-500 dark:text-gray-400"},Ge=pe({__name:"StatCard",props:{label:{},value:{},valueColor:{},subtext:{},icon:{},iconBg:{}},setup(l){const s={pink:"text-pink-600 dark:text-pink-400",amber:"text-amber-600 dark:text-amber-400",blue:"text-blue-600 dark:text-blue-400",green:"text-green-600 dark:text-green-400",red:"text-red-600 dark:text-red-400",gray:"text-gray-900 dark:text-white"},t={pink:"bg-pink-100 dark:bg-pink-500/10",amber:"bg-amber-100 dark:bg-amber-500/10",blue:"bg-blue-100 dark:bg-blue-500/10",green:"bg-green-100 dark:bg-green-500/10",red:"bg-red-100 dark:bg-red-500/10",gray:"bg-gray-100 dark:bg-white/5"};return(c,r)=>{const m=ye;return o(),Q(ot,{variant:"card",class:"p-5"},{default:O(()=>[e("div",xs,[e("div",bs,[e("p",ks,n(l.label),1),e("p",{class:ae(["mt-2 truncate text-2xl font-bold tracking-tight",l.valueColor?s[l.valueColor]:"text-gray-900 dark:text-white"])},n(l.value),3)]),l.icon?(o(),i("div",{key:0,class:ae(["ml-4 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl",t[l.iconBg||"gray"]])},[l.icon.startsWith("i-")?(o(),Q(m,{key:0,name:l.icon,class:"h-5 w-5"},null,8,["name"])):(o(),i("span",_s,n(l.icon),1))],2)):P("",!0)]),l.subtext||c.$slots.subtext?(o(),i("div",ws,[Ve(c.$slots,"subtext",{},()=>[e("span",$s,n(l.subtext),1)])])):P("",!0)]),_:3})}}}),Cs={key:0,class:"mb-2 block text-2xl"},Ub=pe({__name:"EmptyState",props:{text:{},icon:{},padding:{}},setup(l){const s={sm:"px-4 py-4",md:"px-5 py-8",lg:"px-6 py-12"};return(t,c)=>(o(),i("div",{class:ae(["text-center text-sm text-gray-400",s[l.padding||"md"]])},[l.icon?(o(),i("span",Cs,n(l.icon),1)):P("",!0),ne(" "+n(l.text||"暂无数据"),1)],2))}}),Ss={class:"flex flex-col items-center justify-center text-center"},Ts={key:0,class:"mt-2 text-sm text-gray-500"},ct=pe({__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=ye;return o(),i("div",{class:ae(t.value)},[e("div",Ss,[p(m,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-pink-500"}),l.text?(o(),i("p",Ts,n(l.text),1)):P("",!0)])],2)}}}),Is=["disabled"],Ms={key:0,class:"flex-1 overflow-y-auto p-2"},Ls={key:0,class:"flex items-center justify-center py-8"},Ds={key:1,class:"flex flex-col items-center justify-center py-12 text-center"},As={class:"flex h-12 w-12 items-center justify-center rounded-full bg-gray-50 dark:bg-gray-800"},qs={class:"mt-3 text-xs text-gray-400"},Rs={key:2,class:"space-y-3"},Es={class:"px-2 pb-1 pt-1.5 text-[10px] font-medium tracking-wide text-gray-400 dark:text-gray-500"},zs={class:"space-y-0.5"},Ps=["onClick"],js=["placeholder","onBlur","onKeyup"],Fs={key:1,class:"flex items-center"},Bs={class:"line-clamp-1 min-w-0 flex-1 text-sm leading-snug"},Us={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"},Vs={class:"w-28 p-1"},Os=["disabled","onClick"],Ns=["onClick"],Ys=["disabled","onClick"],Hs={key:1,class:"flex flex-1 flex-col items-center gap-2 overflow-y-auto py-2"},Ws=["title","disabled"],Ks=["title","onClick"],Qs=pe({__name:"ConversationList",props:{sessionId:{},activeId:{},disabled:{type:Boolean}},emits:["select","create","delete"],setup(l,{expose:s,emit:t}){const{t:c}=he(),r=l,m=t,u=f([]),d=f(!1),g=f(null),v=f(""),h=f(!1),$=f(null);async function x(){d.value=!0;try{u.value=await je().getAIChats(r.sessionId)}catch(y){console.error("加载对话列表失败:",y)}finally{d.value=!1}}const S=k(()=>{if(u.value.length===0)return[];const y=fe(),A=y.subtract(7,"day").startOf("day"),q=y.subtract(30,"day").startOf("day"),B=[],j=[],_=new Map;for(const ee of u.value){const Y=fe(ee.updatedAt*1e3);if(Y.isAfter(A))B.push(ee);else if(Y.isAfter(q))j.push(ee);else{const ce=Y.format("YYYY-MM");_.has(ce)||_.set(ce,[]),_.get(ce).push(ee)}}const T=[];B.length>0&&T.push({label:c("ai.chat.conversation.group.last7Days"),conversations:B}),j.length>0&&T.push({label:c("ai.chat.conversation.group.last30Days"),conversations:j});const W=[..._.keys()].sort((ee,Y)=>Y.localeCompare(ee));for(const ee of W){const Y=fe(ee+"-01");T.push({label:Y.format(Y.year()===y.year()?"M月":"YYYY年M月"),conversations:_.get(ee)})}return T});function E(y){return y.title||c("ai.chat.conversation.newChat")}function M(y){r.disabled||(g.value=y.id,v.value=y.title||"")}async function L(y){if(!r.disabled){if(v.value.trim())try{await je().updateAIChatTitle(y,v.value.trim());const A=u.value.find(q=>q.id===y);A&&(A.title=v.value.trim())}catch(A){console.error("更新标题失败:",A)}g.value=null}}function b(y){$.value=null,M(y)}function I(y){$.value=null,navigator.clipboard.writeText(y)}function R(y){$.value=null,w(y)}async function w(y){if(!r.disabled)try{await je().deleteAIChat(y),u.value=u.value.filter(A=>A.id!==y),m("delete",y)}catch(A){console.error("删除对话失败:",A)}}return Me(()=>{x()}),me(()=>r.sessionId,()=>{x()}),s({refresh:x}),(y,A)=>{const q=ye,B=Le,j=ca;return o(),i("div",{class:ae(["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:ae(["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?(o(),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:A[2]||(A[2]=_=>h.value=!h.value)},[p(q,{name:"i-heroicons-chevron-right",class:"h-4 w-4"})])):(o(),i(oe,{key:0},[e("button",{class:ae(["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:A[0]||(A[0]=_=>!l.disabled&&m("create"))},[p(q,{name:"i-heroicons-plus",class:"h-3.5 w-3.5"}),e("span",null,n(a(c)("ai.chat.conversation.newConversation")),1)],10,Is),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:A[1]||(A[1]=_=>h.value=!h.value)},[p(q,{name:"i-heroicons-chevron-left",class:"h-4 w-4"})])],64))],2),h.value?(o(),i("div",Hs,[e("button",{class:ae(["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:A[7]||(A[7]=_=>!l.disabled&&m("create"))},[p(q,{name:"i-heroicons-plus",class:"h-4 w-4"})],10,Ws),A[8]||(A[8]=e("div",{class:"h-px w-6 bg-gray-200 dark:bg-gray-800"},null,-1)),(o(!0),i(oe,null,ue(u.value,_=>(o(),i("button",{key:_.id,class:ae(["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:E(_),onClick:T=>m("select",_.id)},[p(q,{name:"i-heroicons-chat-bubble-left",class:"h-4 w-4"})],10,Ks))),128))])):(o(),i("div",Ms,[d.value?(o(),i("div",Ls,[p(q,{name:"i-heroicons-arrow-path",class:"h-5 w-5 animate-spin text-gray-400"})])):u.value.length===0?(o(),i("div",Ds,[e("div",As,[p(q,{name:"i-heroicons-chat-bubble-left",class:"h-6 w-6 text-gray-300 dark:text-gray-600"})]),e("p",qs,n(a(c)("ai.chat.conversation.empty")),1),p(B,{class:"mt-2",size:"xs",variant:"link",color:"primary",disabled:l.disabled,onClick:A[3]||(A[3]=_=>!l.disabled&&m("create"))},{default:O(()=>[ne(n(a(c)("ai.chat.conversation.startNew")),1)]),_:1},8,["disabled"])])):(o(),i("div",Rs,[(o(!0),i(oe,null,ue(S.value,_=>(o(),i("div",{key:_.label},[e("div",Es,n(_.label),1),e("div",zs,[(o(!0),i(oe,null,ue(_.conversations,T=>(o(),i("div",{key:T.id,class:ae(["group relative rounded-lg px-3 py-2 transition-all",["cursor-pointer",l.activeId===T.id?"bg-gray-100 text-gray-900 dark:bg-gray-800 dark:text-white":"text-gray-600 hover:bg-gray-50 dark:text-gray-400 dark:hover:bg-gray-800/50"]]),onClick:W=>m("select",T.id)},[g.value===T.id?Be((o(),i("input",{key:0,"onUpdate:modelValue":A[4]||(A[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=>L(T.id),onKeyup:Ke(W=>L(T.id),["enter"]),onClick:A[5]||(A[5]=Pe(()=>{},["stop"]))},null,40,js)),[[at,v.value]]):(o(),i("div",Fs,[e("p",Bs,n(E(T)),1),e("div",{class:ae(["ml-1 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",{"opacity-100":l.activeId===T.id||$.value===T.id}]),onClick:A[6]||(A[6]=Pe(()=>{},["stop"]))},[p(j,{open:$.value===T.id,ui:{content:"z-50 p-0"},"onUpdate:open":W=>$.value=W?T.id:null},{content:O(()=>[e("div",Vs,[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=>b(T)},[p(q,{name:"i-heroicons-pencil",class:"h-3.5 w-3.5"}),ne(" "+n(a(c)("ai.chat.conversation.rename")),1)],8,Os),e("button",{class:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-xs text-gray-600 transition-colors hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800",onClick:W=>I(T.id)},[p(q,{name:"i-heroicons-clipboard-document",class:"h-3.5 w-3.5"}),ne(" "+n(a(c)("ai.chat.conversation.copyId")),1)],8,Ns),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=>R(T.id)},[p(q,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"}),ne(" "+n(a(c)("ai.chat.conversation.delete")),1)],8,Ys)])]),default:O(()=>[e("button",Us,[p(q,{name:"i-heroicons-ellipsis-horizontal",class:"h-4 w-4"})])]),_:2},1032,["open","onUpdate:open"])],2)]))],10,Ps))),128))])]))),128))]))]))],2)}}}),Gs={class:"writing-vertical text-xs"},Js={class:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800"},Xs={class:"flex items-center gap-2"},Zs={class:"font-medium text-gray-900 dark:text-white"},eo={key:0,class:"border-b border-gray-200 px-4 py-2 dark:border-gray-800"},to={class:"flex flex-wrap items-center gap-2"},ao={class:"text-xs text-gray-500"},so={class:"flex-1 overflow-y-auto"},oo={key:0,class:"flex items-center justify-center py-8"},no={key:1,class:"flex flex-col items-center justify-center py-8 text-center"},ro={class:"mt-2 text-sm text-gray-500"},lo={class:"text-xs text-gray-400"},io={key:2,class:"divide-y divide-gray-100 dark:divide-gray-800"},co={class:"mb-1 flex items-center justify-between"},uo={class:"text-sm font-medium text-gray-900 dark:text-white"},mo={class:"text-xs text-gray-400"},go=["innerHTML"],po={key:1,class:"border-t border-gray-200 px-4 py-2 dark:border-gray-800"},vo={class:"flex items-center justify-between"},ho={class:"text-xs text-gray-500"},yo={key:2,class:"pointer-events-none absolute inset-0 overflow-hidden rounded-xl opacity-[0.03]"},fo=pe({__name:"DataSourcePanel",props:{messages:{},keywords:{},isLoading:{type:Boolean},isCollapsed:{type:Boolean}},emits:["toggle","loadMore"],setup(l,{emit:s}){const{t}=he(),c=l,r=s;function m(d){return fe(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=ye,h=Le;return o(),i("div",{class:ae(["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?(o(),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]=$=>r("toggle"))},[p(v,{name:"i-heroicons-chevron-left",class:"h-5 w-5"}),e("span",Gs,n(a(t)("ai.chat.dataSource.title")),1)])):(o(),i(oe,{key:1},[e("div",Js,[e("div",Xs,[p(v,{name:"i-heroicons-document-magnifying-glass",class:"h-5 w-5 text-gray-500"}),e("span",Zs,n(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]=$=>r("toggle"))})]),l.keywords.length>0?(o(),i("div",eo,[e("div",to,[e("span",ao,n(a(t)("ai.chat.dataSource.keywords")),1),(o(!0),i(oe,null,ue(l.keywords,$=>(o(),i("span",{key:$,class:"rounded-full bg-violet-100 px-2 py-0.5 text-xs text-violet-700 dark:bg-violet-900/30 dark:text-violet-400"},n($),1))),128))])])):P("",!0),e("div",so,[l.isLoading?(o(),i("div",oo,[p(v,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):l.messages.length===0?(o(),i("div",no,[p(v,{name:"i-heroicons-inbox",class:"h-10 w-10 text-gray-300 dark:text-gray-600"}),e("p",ro,n(a(t)("ai.chat.dataSource.empty")),1),e("p",lo,n(a(t)("ai.chat.dataSource.emptyHint")),1)])):(o(),i("div",io,[(o(!0),i(oe,null,ue(l.messages,$=>(o(),i("div",{key:$.id,class:"px-4 py-3 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[e("div",co,[e("span",uo,n($.senderName),1),e("span",mo,n(m($.timestamp)),1)]),e("p",{class:"line-clamp-3 text-sm text-gray-600 dark:text-gray-400",innerHTML:u($.content)},null,8,go)]))),128))]))]),l.messages.length>0?(o(),i("div",po,[e("div",vo,[e("span",ho,n(a(t)("ai.chat.dataSource.totalRecords",{count:l.messages.length})),1),p(h,{size:"xs",variant:"ghost",onClick:g[2]||(g[2]=$=>r("loadMore"))},{default:O(()=>[ne(n(a(t)("ai.chat.dataSource.loadMore")),1)]),_:1})])])):P("",!0)],64)),l.isCollapsed?P("",!0):(o(),i("div",yo,[...g[3]||(g[3]=[e("div",{class:"data-flow-bg absolute inset-0"},null,-1)])]))],2)}}}),xo=et(fo,[["__scopeId","data-v-19a25590"]]),bo={class:"flex max-h-[80vh] flex-col overflow-hidden"},ko={class:"shrink-0 border-b border-gray-200 px-6 py-4 dark:border-gray-800"},_o={class:"flex items-center justify-between"},wo={class:"flex items-center gap-3"},$o={class:"flex h-8 w-8 items-center justify-center rounded-lg bg-red-100 dark:bg-red-900/40"},Co={class:"text-lg font-semibold text-gray-900 dark:text-white"},So={class:"flex-1 overflow-y-auto px-6 py-4"},To={class:"flex flex-col gap-4"},Io={class:"text-sm font-semibold text-gray-700 dark:text-gray-300"},Mo={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"},Lo={class:"m-0 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-red-600 dark:text-red-400"},Do={key:1,class:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-gray-900"},Ao={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"},qo={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"},Ro={key:0,class:"py-8 text-center text-sm text-gray-400 dark:text-gray-500"},Eo={class:"shrink-0 border-t border-gray-200 px-6 py-3 dark:border-gray-800"},zo={class:"flex justify-end"},Po=pe({__name:"ErrorDetailModal",props:zt({error:{}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:["update:open"],setup(l){const{t:s}=he(),t=Ye(),c=Et(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
|
-
|
|
7
|
-
`);navigator.clipboard.writeText(g).then(()=>{t.success(s("ai.chat.error.copied"))})}return(g,v)=>{const h=ye,$=Le,x=Fe;return o(),Q(x,{open:c.value,"onUpdate:open":v[1]||(v[1]=S=>c.value=S),ui:{content:"sm:max-w-[700px] z-[100]",overlay:"backdrop-blur-sm z-[99]"}},{content:O(()=>[e("div",bo,[e("div",ko,[e("div",_o,[e("div",wo,[e("div",$o,[p(h,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4 text-red-600 dark:text-red-400"})]),e("h2",Co,n(a(s)("ai.chat.error.detail")),1)]),p($,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:v[0]||(v[0]=S=>c.value=!1)})])]),e("div",So,[e("div",To,[(o(!0),i(oe,null,ue(m.value,(S,E)=>(o(),i("div",{key:E,class:"flex flex-col gap-1.5"},[e("div",Io,n(S.label),1),S.isStack?(o(),i("div",Mo,[e("pre",Lo,n(S.value),1)])):S.isCode?(o(),i("div",Do,[e("pre",Ao,n(S.value),1)])):(o(),i("div",qo,n(S.value),1))]))),128)),m.value.length===0?(o(),i("div",Ro,n(a(s)("ai.chat.error.unknown")),1)):P("",!0)])]),e("div",Eo,[e("div",zo,[p($,{icon:"i-heroicons-document-duplicate",variant:"soft",color:"neutral",size:"sm",onClick:d},{default:O(()=>[ne(n(a(s)("ai.chat.error.copyAll")),1)]),_:1})])])])]),_:1},8,["open"])}}}),jo={class:"mb-1.5 flex items-center gap-2"},Fo={class:"flex shrink-0 items-center justify-center text-red-500 dark:text-red-400"},Bo={class:"pr-5 text-[13px] font-semibold leading-[1.4] text-red-600 dark:text-red-400"},Uo={class:"ml-6 line-clamp-3 break-words text-xs leading-normal text-gray-600 dark:text-gray-400"},Vo={class:"mt-2.5 ml-6 flex items-center"},Oo={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"},No=pe({__name:"ErrorBlock",props:{error:{}},setup(l){const{t:s}=he(),t=f(!1);function c(r){return r.friendlyMessage||r.message||s("ai.chat.error.unknown")}return(r,m)=>{const u=ye;return o(),i(oe,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",jo,[e("div",Fo,[p(u,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4"})]),e("div",Bo,n(a(s)("ai.chat.error.title")),1)]),e("div",Uo,n(c(l.error)),1),e("div",Vo,[e("div",Oo,[ne(n(a(s)("ai.chat.error.viewDetail"))+" ",1),p(u,{name:"i-heroicons-chevron-right",class:"h-3.5 w-3.5"})])])]),p(Po,{open:t.value,"onUpdate:open":m[1]||(m[1]=d=>t.value=d),error:l.error},null,8,["open","error"])],64)}}}),ft=pe({__name:"EChart",props:{option:{},height:{default:300},loading:{type:Boolean,default:!1},theme:{default:"auto"}},setup(l,{expose:s}){vt([ht,ma,ga,Qa,Kt,Ga,It,Ja,pa,Qt,Xa]);const t=l,c=f();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=yt(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()}me(()=>t.option,v,{deep:!0}),me(()=>t.height,()=>{setTimeout(()=>{r?.resize()},0)}),me(d,()=>{g()}),me(()=>t.loading,x=>{x?r?.showLoading("default",{text:"",spinnerRadius:12,lineWidth:2}):r?.hideLoading()});let $=null;return Me(()=>{ze(()=>{g()}),window.addEventListener("resize",h),c.value&&(m=new ResizeObserver(()=>h()),m.observe(c.value)),$=new MutationObserver(()=>{t.theme==="auto"&&g()}),$.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})}),it(()=>{window.removeEventListener("resize",h),m?.disconnect(),$?.disconnect(),r?.dispose(),r=null}),s({getInstance:()=>r,resize:h}),(x,S)=>(o(),i("div",{ref_key:"chartRef",ref:c,style:Ne({height:u.value,width:"100%"})},null,4))}}),Xe=pe({__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)=>(o(),Q(ft,{option:c.value,height:l.height},null,8,["option","height"]))}}),jt=pe({__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)=>(o(),Q(ft,{option:c.value,height:l.height},null,8,["option","height"]))}}),Ft=pe({__name:"EChartLine",props:{data:{},height:{default:288},mode:{default:"expanded"},showArea:{type:Boolean,default:!0},smooth:{type:Boolean,default:!0}},setup(l){const s=l,t=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)=>(o(),Q(ft,{option:t.value,height:l.height},null,8,["option","height"]))}}),Bt=pe({__name:"EChartPie",props:{data:{},height:{default:280},mode:{default:"expanded"},doughnut:{type:Boolean,default:!0},innerRadius:{default:"50%"},showLegend:{type:Boolean,default:!0}},setup(l){const s=l,t=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"],c=k(()=>{const r=s.data.labels.map((x,S)=>({name:x,value:s.data.values[S]})),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.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:$?v:void 0,series:[{type:"pie",radius:s.doughnut?[s.innerRadius,u?"58%":"68%"]:u?"58%":"68%",center:$?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)=>(o(),Q(ft,{option:c.value,height:l.height},null,8,["option","height"]))}}),Yo={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"},Ho={class:"border-b border-gray-100 px-3 py-2 dark:border-gray-800"},Wo={class:"flex min-w-0 items-start justify-between gap-3"},Ko={class:"min-w-0"},Qo={class:"truncate text-sm font-semibold text-gray-900 dark:text-gray-100"},Go={key:0,class:"mt-0.5 line-clamp-2 text-xs text-gray-500 dark:text-gray-400"},Jo={class:"flex shrink-0 items-center gap-1.5"},Xo={class:"rounded-md bg-gray-100 px-1.5 py-0.5 text-[10px] uppercase text-gray-500 dark:bg-gray-800"},Zo={class:"flex max-h-[92vh] flex-col overflow-hidden bg-white dark:bg-gray-950"},en={class:"flex items-start justify-between gap-4 border-b border-gray-200 px-5 py-4 dark:border-gray-800"},tn={class:"min-w-0"},an={class:"truncate text-base font-semibold text-gray-900 dark:text-gray-100"},sn={key:0,class:"mt-1 line-clamp-2 text-xs text-gray-500 dark:text-gray-400"},on={class:"mt-1 text-[11px] text-gray-400 dark:text-gray-500"},nn={class:"min-h-0 flex-1 overflow-auto p-4"},rn={key:0,class:"flex h-64 items-center justify-center text-xs text-gray-400 dark:text-gray-500"},ln={class:"mt-1 text-[11px] text-gray-400 dark:text-gray-500"},cn={class:"px-2 py-3"},dn={key:0,class:"flex h-32 items-center justify-center text-xs text-gray-400 dark:text-gray-500"},un=pe({__name:"ChartBlockRenderer",props:{chart:{}},setup(l){const{t:s}=he(),t=l,c=f(!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 b=[];return t.chart.spec.unit&&b.push(t.chart.spec.unit),t.chart.truncated&&b.push(s("ai.chat.message.chart.truncated")),b.push(s("ai.chat.message.chart.rows",{count:t.chart.rowCount})),b.join(" · ")}),v=k(()=>t.chart.data),h=k(()=>t.chart.data),$=k(()=>t.chart.data),x=k(()=>t.chart.data),S=k(()=>t.chart.spec.type==="pie"?$.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"?x.value.xLabels.length*x.value.yLabels.length>180:!1),E=k(()=>{const b=S.value?320:380;return Math.min(u.value,b)}),M=k(()=>{const b=u.value;if(t.chart.spec.type==="pie")return Math.max(b,560);if(t.chart.spec.type==="line")return Math.max(b,h.value.labels.length>40?620:540);if(t.chart.spec.type==="bar"){const I=t.chart.spec.display?.horizontal?v.value.labels.length*28+120:520;return Math.min(Math.max(b,I),820)}return t.chart.spec.type==="heatmap"?Math.min(Math.max(b,x.value.yLabels.length*22+150,560),860):Math.max(b,520)}),L=k(()=>t.chart.spec.type==="pie"?"640px":t.chart.spec.type==="bar"?"720px":"780px");return(b,I)=>{const R=Le,w=Fe;return o(),i("div",Yo,[e("div",Ho,[e("div",Wo,[e("div",Ko,[e("h3",Qo,n(r.value),1),m.value?(o(),i("p",Go,n(m.value),1)):P("",!0)]),e("div",Jo,[e("span",Xo,n(l.chart.spec.type),1),p(w,{open:c.value,"onUpdate:open":I[2]||(I[2]=y=>c.value=y),ui:{overlay:"z-[10040] backdrop-blur-sm",content:"z-[10050] w-[96vw] max-w-6xl max-h-[92vh] overflow-hidden"}},{content:O(()=>[e("div",Zo,[e("div",en,[e("div",tn,[e("h3",an,n(r.value),1),m.value?(o(),i("p",sn,n(m.value),1)):P("",!0),e("p",on,n(g.value),1)]),p(R,{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:I[1]||(I[1]=y=>c.value=!1)},null,8,["title","aria-label"])]),e("div",nn,[e("div",{class:"mx-auto w-full",style:Ne({minWidth:L.value})},[d.value?(o(),i("div",rn,n(a(s)("ai.chat.message.chart.empty")),1)):l.chart.spec.type==="bar"?(o(),Q(Xe,{key:1,data:v.value,height:M.value,mode:"expanded",horizontal:l.chart.spec.display?.horizontal},null,8,["data","height","horizontal"])):l.chart.spec.type==="line"?(o(),Q(Ft,{key:2,data:h.value,height:M.value,mode:"expanded"},null,8,["data","height"])):l.chart.spec.type==="pie"?(o(),Q(Bt,{key:3,data:$.value,height:M.value,mode:"expanded","show-legend":l.chart.spec.display?.showLegend??!0},null,8,["data","height","show-legend"])):l.chart.spec.type==="heatmap"?(o(),Q(jt,{key:4,data:x.value,height:M.value,mode:"expanded"},null,8,["data","height"])):P("",!0)],4)])])]),default:O(()=>[p(R,{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:I[0]||(I[0]=Pe(()=>{},["stop"]))},null,8,["title","aria-label"])]),_:1},8,["open"])])]),e("p",ln,n(g.value),1)]),e("div",cn,[d.value?(o(),i("div",dn,n(a(s)("ai.chat.message.chart.empty")),1)):l.chart.spec.type==="bar"?(o(),Q(Xe,{key:1,data:v.value,height:E.value,mode:"compact",horizontal:l.chart.spec.display?.horizontal},null,8,["data","height","horizontal"])):l.chart.spec.type==="line"?(o(),Q(Ft,{key:2,data:h.value,height:E.value,mode:"compact"},null,8,["data","height"])):l.chart.spec.type==="pie"?(o(),Q(Bt,{key:3,data:$.value,height:E.value,mode:"compact","show-legend":l.chart.spec.display?.showLegend??!0},null,8,["data","height","show-legend"])):l.chart.spec.type==="heatmap"?(o(),Q(jt,{key:4,data:x.value,height:E.value,mode:"compact"},null,8,["data","height"])):P("",!0)])])}}}),mn=/^\s*!\[[^\]\n]*\]\(\s*(?:(?:https?:\/\/(?:localhost|127\.0\.0\.1)(?::\d+)?)?\/?|\.\/)?chart[\w-]*(?:\.(?:png|jpg|jpeg|webp|svg))?(?:\?[^)\s]*)?\s*(?:"[^"]*")?\s*\)\s*$/gim;function gn(l){return l&&l.replace(mn,"").replace(/\n{3,}/g,`
|
|
8
|
-
|
|
9
|
-
`).replace(/^\n+|\n+$/g,"")}const pn={key:0,class:"w-full rounded-lg border border-gray-200 bg-gray-50/80 dark:border-gray-700/50 dark:bg-gray-800/40"},vn={class:"flex cursor-pointer select-none items-center gap-2 px-3 py-2 text-xs font-medium text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"},hn={class:"border-t border-gray-200/60 px-3 py-2.5 dark:border-gray-700/40"},yn=["innerHTML"],fn={class:"mt-2 text-[11px] text-gray-400 dark:text-gray-500"},xn={key:0,class:"rounded-2xl bg-primary-50 p-4 text-gray-900 dark:bg-primary-500/50 dark:text-gray-100"},bn=["onKeydown"],kn={class:"mt-2 flex items-center justify-between"},_n={class:"flex cursor-pointer items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400"},wn={class:"flex gap-2"},$n={key:1,class:"rounded-3xl bg-primary-50 px-5 py-3 text-gray-900 dark:bg-primary-500/50 dark:text-gray-100"},Cn=["innerHTML"],Sn={key:2,class:"space-y-2"},Tn={key:0,class:"py-1 text-gray-900 dark:text-gray-100"},In=["innerHTML"],Mn={key:0,class:"ml-1 inline-block h-4 w-1.5 animate-pulse rounded-sm bg-gray-800 dark:bg-gray-200"},Ln={key:1,class:"mb-2 border-l-2 border-gray-200 pl-4 py-1 text-sm text-gray-500 dark:border-gray-700 dark:text-gray-400"},Dn={class:"cursor-pointer select-none text-xs font-medium transition-colors hover:text-gray-700 dark:hover:text-gray-300"},An={key:0,class:"ml-2 text-xs text-gray-400 dark:text-gray-500"},qn={key:1,class:"ml-2 inline-flex items-center gap-1 text-[11px] text-gray-400 dark:text-gray-500"},Rn={class:"mt-2 prose prose-sm dark:prose-invert max-w-none leading-relaxed text-xs"},En={key:0,class:"mb-2 font-medium text-gray-700 dark:text-gray-200"},zn={class:"not-prose space-y-2 text-xs leading-relaxed"},Pn={class:"font-medium text-gray-800 dark:text-gray-200"},jn={key:0,class:"mt-1 text-gray-500 dark:text-gray-400"},Fn={class:"mt-0.5 text-gray-500 dark:text-gray-400"},Bn={key:1,class:"not-prose mt-2 border-t border-gray-100 pt-2 dark:border-gray-800"},Un={class:"text-[11px] font-medium text-gray-500 dark:text-gray-400"},Vn={class:"mt-1 list-disc space-y-0.5 pl-4 text-xs leading-relaxed text-gray-600 dark:text-gray-300"},On=["innerHTML"],Nn={key:2,class:"inline-flex items-center gap-1.5 rounded-lg bg-gray-50 px-3 py-1.5 text-xs font-medium text-gray-600 dark:bg-gray-800/50 dark:text-gray-400"},Yn={key:3,open:"",class:"mb-2 border-l-2 border-gray-200 py-1 pl-4 text-sm text-gray-600 dark:border-gray-700 dark:text-gray-400"},Hn={class:"flex cursor-pointer select-none items-center gap-2 text-xs font-medium text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"},Wn={class:"min-w-0 truncate"},Kn={class:"mt-2"},Qn=["innerHTML"],Gn={key:1,class:"space-y-2"},Jn={class:"font-medium text-gray-800 dark:text-gray-200"},Xn={class:"mt-1 text-gray-500 dark:text-gray-400"},Zn={class:"mt-0.5 text-gray-500 dark:text-gray-400"},er={key:2,class:"mt-2 border-t border-gray-100 pt-2 dark:border-gray-800"},tr={class:"text-[11px] font-medium text-gray-500 dark:text-gray-400"},ar={class:"mt-1 list-disc space-y-0.5 pl-4 text-xs leading-relaxed text-gray-600 dark:text-gray-300"},sr={key:4,class:"mb-2 border-l-2 border-gray-200 py-1 pl-4 text-sm text-gray-600 dark:border-gray-700 dark:text-gray-400"},or={class:"flex items-center gap-2 text-xs font-medium text-gray-500 dark:text-gray-400"},nr={key:0,class:"inline-flex items-center gap-1 text-[11px] font-normal text-gray-400 dark:text-gray-500"},rr=["innerHTML"],lr={class:"flex min-w-0 items-baseline gap-1.5 font-medium"},ir={key:0,class:"truncate font-normal text-[11px] opacity-75 max-w-[200px] sm:max-w-[300px]"},cr={key:1,class:"shrink-0 font-normal text-[11px] opacity-75"},dr={key:0,class:"flex items-center gap-2 px-1 py-2 text-sm text-gray-500 dark:text-gray-400"},ur={key:3,class:"py-1 text-gray-900 dark:text-gray-100"},mr=["innerHTML"],gr={key:0,class:"ml-1 inline-block h-4 w-1.5 animate-pulse rounded-sm bg-gray-800 dark:bg-gray-200"},pr={class:"text-xs text-gray-400"},At=pe({__name:"ChatMessage",props:{messageId:{},role:{},content:{},timestamp:{},isStreaming:{type:Boolean},contentBlocks:{},showCaptureButton:{type:Boolean},editable:{type:Boolean}},emits:["edit","fork"],setup(l,{emit:s}){const{t,te:c,locale:r}=he(),m=Ye(),u=l,d=s,g=k(()=>fe(u.timestamp).format("HH:mm")),v=k(()=>u.role==="user"),h=k(()=>u.role==="summary"),$=f(!1),x=f(u.content),S=f(null),E=k(()=>v.value&&u.editable&&!u.isStreaming&&!!u.messageId),M=k(()=>!v.value&&!h.value&&!u.isStreaming&&!!u.messageId),L=f(!1),b=new Wt({html:!1,breaks:!0,linkify:!0,typographer:!0});b.renderer.rules.link_open=(D,C,F,J,G)=>(D[C].attrSet("target","_blank"),D[C].attrSet("rel","noopener noreferrer"),G.renderToken(D,C,F));function I(D){return D?b.render(D):""}function R(D){const C=D?.toLowerCase()||"think";return C==="analysis"?t("ai.chat.message.think.labels.analysis"):C==="reasoning"?t("ai.chat.message.think.labels.reasoning"):C==="reflection"?t("ai.chat.message.think.labels.reflection"):C==="plan_validation"?t("ai.chat.message.think.labels.planValidation"):C==="think"||C==="thought"||C==="thinking"?t("ai.chat.message.think.labels.think"):t("ai.chat.message.think.labels.other",{tag:D})}function w(D){if(!D)return"";const C=(D/1e3).toFixed(1);return t("ai.chat.message.think.duration",{seconds:C})}const y=k(()=>u.content?b.render(_(u.content)):"");me(()=>u.content,D=>{$.value||(x.value=D)});function A(){const D=S.value;if(!D)return;D.style.height="auto";const C=384,F=Math.min(D.scrollHeight,C);D.style.height=`${F}px`,D.style.overflowY=D.scrollHeight>C?"auto":"hidden"}async function q(){E.value&&(x.value=u.content,$.value=!0,await ze(),A(),S.value?.focus())}function B(){$.value=!1,x.value=u.content,L.value=!1}function j(){if(!u.messageId)return;const D=x.value.trim();if(!D||D===u.content.trim()){B();return}$.value=!1,d("edit",{messageId:u.messageId,content:D,overwriteSubsequent:L.value}),L.value=!1}function _(D){return gn(D)}const T=k(()=>{const D=u.contentBlocks||[];return D.filter((C,F)=>C.type==="text"?_(C.text).trim().length>0:C.type==="think"?C.text.trim().length>0:C.type==="error"?!Ra(D,F,{isStreaming:u.isStreaming}):!0)}),W=k(()=>u.role==="assistant"&&T.value.length>0);function ee(D){return c(`ai.chat.message.tools.${D.name}`)?t(`ai.chat.message.tools.${D.name}`):D.displayName}function Y(D){return D==="running"?"running":D==="done"?"done":"error"}function ce(D){return D.length===0?t("ai.chat.message.plan.noTools"):D.join(", ")}function ve(D){try{const C=JSON.parse(D.trim());if(!C||typeof C!="object")return null;const F=C,J=Array.isArray(F.steps)?F.steps.filter(G=>!!G&&typeof G=="object").map(G=>({goal:typeof G.goal=="string"?G.goal:"",suggestedTools:Array.isArray(G.suggestedTools)?G.suggestedTools.filter(z=>typeof z=="string"):[],evidenceNeeded:typeof G.evidenceNeeded=="string"?G.evidenceNeeded:""})).filter(G=>G.goal):[];return{title:typeof F.title=="string"?F.title:void 0,steps:J,successCriteria:Array.isArray(F.successCriteria)?F.successCriteria.filter(G=>typeof G=="string"):[]}}catch{return null}}const H=new Map;function U(D){const C=H.get(D);if(C)return C;const F=ve(D);return F&&H.set(D,F),F}function te(D){if(D.start_time||D.end_time){const C=D.start_time?String(D.start_time):"",F=D.end_time?String(D.end_time):"";return C&&F?`${C} ~ ${F}`:C||F}if(D.year)if(r.value.startsWith("zh")){let C=`${D.year}年`;return D.month&&(C+=`${D.month}月`,D.day&&(C+=`${D.day}日`,D.hour!==void 0&&(C+=` ${D.hour}点`))),C}else{const C=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];let F="";if(D.month){if(F=C[D.month-1]||String(D.month),D.day&&(F+=` ${D.day}`,D.hour!==void 0)){const J=D.hour,G=J>=12?"pm":"am",z=J%12||12;F+=`, ${z}${G}`}F+=`, ${D.year}`}else F=String(D.year);return F}return""}function se(D){if(!D.params)return"";const C=D.name,F=D.params;if(C==="search_messages"){const G=F.keywords,z=[];G&&G.length>0&&z.push(`${t("ai.chat.message.toolParams.keywords")}: ${G.join(", ")}`);const Z=te(F);return Z&&z.push(`${t("ai.chat.message.toolParams.time")}: ${Z}`),z.join(" | ")}if(C==="get_recent_messages"){const G=[];G.push(t("ai.chat.message.toolParams.getMessages",{count:F.limit||100}));const z=te(F);return z&&G.push(z),G.join(" | ")}if(C==="get_conversation_between"){const G=[],z=te(F);return z&&G.push(`${t("ai.chat.message.toolParams.time")}: ${z}`),F.limit&&G.push(t("ai.chat.message.toolParams.limit",{count:F.limit})),G.join(" | ")}if(C==="get_message_context"){const G=F.message_ids,z=F.context_size||20;return G&&G.length>0?t("ai.chat.message.toolParams.contextWithMessages",{msgCount:G.length,contextSize:z}):t("ai.chat.message.toolParams.context",{size:z})}if(C==="get_member_stats")return t("ai.chat.message.toolParams.topMembers",{count:F.top_n||10});if(C==="get_time_stats"){const G=F.type;return t(`ai.chat.message.toolParams.timeStats.${G}`)||String(F.type)}if(C==="render_chart"){const G=F.spec&&typeof F.spec=="object"?F.spec:null;return[G?.title,G?.type].filter(Z=>typeof Z=="string"&&Z.length>0).join(" | ")}if(C==="get_members")return F.search?`${t("ai.chat.message.toolParams.search")}: ${F.search}`:t("ai.chat.message.toolParams.getMemberList");if(C==="get_member_name_history")return`${t("ai.chat.message.toolParams.memberId")}: ${F.member_id}`;const J=[];for(const[G,z]of Object.entries(F)){if(z==null||z==="")continue;const Z=typeof z=="object"?JSON.stringify(z):String(z),ge=Z.length>30?Z.substring(0,30)+"...":Z;if(J.push(`${G}: ${ge}`),J.length>=3){J.push("...");break}}return J.join(" | ")}const le=k(()=>!W.value&&u.content.trim()?_(u.content):W.value?T.value.map(C=>{if(C.type==="text")return _(C.text);if(C.type==="think"){const F=R(C.tag),J=C.text.split(`
|
|
10
|
-
`).map(G=>`> ${G}`).join(`
|
|
11
|
-
`);return`> ${F}
|
|
12
|
-
>
|
|
13
|
-
${J}`}if(C.type==="skill")return`> ${t("ai.skill.active.label",{name:C.skillName})}`;if(C.type==="chart")return`> Chart: ${C.chart.spec.title}`;if(C.type==="plan"){const F=C.plan.steps.map((z,Z)=>`${Z+1}. ${z.goal}
|
|
14
|
-
- ${t("ai.chat.message.plan.evidenceNeeded")}: ${z.evidenceNeeded}
|
|
15
|
-
- ${t("ai.chat.message.plan.suggestedTools")}: ${ce(z.suggestedTools)}`).join(`
|
|
16
|
-
`),J=C.plan.successCriteria.map(z=>`- ${z}`).join(`
|
|
17
|
-
`),G=C.displayText?`${C.displayText.split(`
|
|
18
|
-
`).map(z=>`> ${z}`).join(`
|
|
19
|
-
`)}
|
|
20
|
-
|
|
21
|
-
`:"";return C.displayText?`> ${t("ai.chat.message.plan.label")}: ${C.plan.title}
|
|
22
|
-
|
|
23
|
-
${G.trimEnd()}`:`> ${t("ai.chat.message.plan.label")}: ${C.plan.title}
|
|
24
|
-
|
|
25
|
-
${F}
|
|
26
|
-
|
|
27
|
-
${t("ai.chat.message.plan.successCriteria")}:
|
|
28
|
-
${J}`}if(C.type==="plan_draft")return`> ${t("ai.chat.message.plan.label")}
|
|
29
|
-
>
|
|
30
|
-
${C.text.split(`
|
|
31
|
-
`).map(F=>`> ${F}`).join(`
|
|
32
|
-
`)}`;if(C.type==="tool"){const F=ee(C.tool),J=se(C.tool),G=J?` (${J})`:"";return`- [${Y(C.tool.status)}] ${F}${G}`}return""}).filter(C=>C.trim().length>0).join(`
|
|
33
|
-
|
|
34
|
-
`):""),K=k(()=>!u.isStreaming&&le.value.trim().length>0);async function N(){if(K.value)try{await navigator.clipboard.writeText(le.value),m.success(t("ai.chat.message.copy.success"))}catch(D){m.fail(t("ai.chat.message.copy.failed"),{description:String(D)})}}return(D,C)=>{const F=ye,J=Le,G=gt;return o(),i("div",{class:ae(["flex items-start gap-3",[v.value&&!$.value?"flex-row-reverse":"",h.value?"justify-center":""]])},[e("div",{class:ae([v.value&&!$.value?"max-w-[85%] min-w-0":"w-full min-w-0"])},[h.value?(o(),i("details",pn,[e("summary",vn,[p(F,{name:"i-heroicons-arrow-path",class:"h-3.5 w-3.5 shrink-0"}),e("span",null,n(a(t)("ai.chat.message.summary.label")),1),p(F,{name:"i-heroicons-chevron-right",class:"ml-auto h-3 w-3 transition-transform [[open]>&]:rotate-90"})]),e("div",hn,[e("div",{class:"prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:y.value},null,8,yn),e("p",fn,n(a(t)("ai.chat.message.summary.info")),1)])])):v.value?(o(),i(oe,{key:1},[$.value?(o(),i("div",xn,[Be(e("textarea",{ref_key:"editTextareaRef",ref:S,"onUpdate:modelValue":C[0]||(C[0]=z=>x.value=z),rows:"2",class:"w-full resize-none rounded-xl border border-primary-200 bg-white/90 px-4 py-3 text-sm leading-relaxed outline-none focus:border-primary-400 dark:border-primary-400/40 dark:bg-gray-900/70",onInput:A,onKeydown:[Ke(Pe(B,["prevent"]),["esc"]),Ke(Pe(j,["ctrl","prevent"]),["enter"]),Ke(Pe(j,["meta","prevent"]),["enter"])]},null,40,bn),[[at,x.value]]),e("div",kn,[e("label",_n,[Be(e("input",{"onUpdate:modelValue":C[1]||(C[1]=z=>L.value=z),type:"checkbox",class:"h-3.5 w-3.5 rounded border-gray-300 text-primary-500 focus:ring-primary-500 dark:border-gray-600"},null,512),[[Ua,L.value]]),ne(" "+n(a(t)("ai.chat.message.edit.overwriteSubsequent")),1)]),e("div",wn,[p(J,{size:"xs",variant:"ghost",color:"gray",onClick:B},{default:O(()=>[ne(n(a(t)("common.cancel")),1)]),_:1}),p(J,{size:"xs",color:"primary",onClick:j},{default:O(()=>[ne(n(a(t)("ai.chat.message.edit.submit")),1)]),_:1})])])])):(o(),i("div",$n,[e("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:y.value},null,8,Cn)]))],64)):W.value?(o(),i("div",Sn,[(o(!0),i(oe,null,ue(T.value,(z,Z)=>(o(),i(oe,{key:Z},[z.type==="text"?(o(),i("div",Tn,[e("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:I(_(z.text))},null,8,In),l.isStreaming&&Z===T.value.length-1?(o(),i("span",Mn)):P("",!0)])):z.type==="think"?(o(),i("details",Ln,[e("summary",Dn,[ne(n(R(z.tag))+" ",1),z.durationMs?(o(),i("span",An,n(w(z.durationMs)),1)):P("",!0),l.isStreaming&&Z===T.value.length-1?(o(),i("span",qn,[e("span",null,n(a(t)("ai.chat.message.think.loading")),1),C[3]||(C[3]=e("span",{class:"flex gap-0.5"},[e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1))])):P("",!0)]),e("div",Rn,[z.tag==="plan_validation"&&U(z.text)?(o(),i(oe,{key:0},[U(z.text)?.title?(o(),i("div",En,n(U(z.text)?.title),1)):P("",!0),e("ol",zn,[(o(!0),i(oe,null,ue(U(z.text)?.steps,(ge,ie)=>(o(),i("li",{key:ie,class:"text-gray-600 dark:text-gray-300"},[e("div",Pn,n(ge.goal),1),ge.evidenceNeeded?(o(),i("div",jn,n(a(t)("ai.chat.message.plan.evidenceNeeded"))+": "+n(ge.evidenceNeeded),1)):P("",!0),e("div",Fn,n(a(t)("ai.chat.message.plan.suggestedTools"))+": "+n(ce(ge.suggestedTools)),1)]))),128))]),U(z.text)?.successCriteria.length?(o(),i("div",Bn,[e("div",Un,n(a(t)("ai.chat.message.plan.successCriteria")),1),e("ul",Vn,[(o(!0),i(oe,null,ue(U(z.text)?.successCriteria,(ge,ie)=>(o(),i("li",{key:ie},n(ge),1))),128))])])):P("",!0)],64)):(o(),i("div",{key:1,innerHTML:I(z.text)},null,8,On))])])):z.type==="skill"?(o(),i("div",Nn,[p(F,{name:"i-heroicons-bolt",class:"h-3.5 w-3.5"}),e("span",null,n(a(t)("ai.skill.active.label",{name:z.skillName})),1)])):z.type==="plan"?(o(),i("details",Yn,[e("summary",Hn,[p(F,{name:"i-heroicons-clipboard-document-list",class:"h-3.5 w-3.5 shrink-0"}),e("span",Wn,n(a(t)("ai.chat.message.plan.label"))+" · "+n(z.plan.title),1)]),e("div",Kn,[z.displayText?(o(),i("div",{key:0,class:"prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:I(z.displayText)},null,8,Qn)):(o(),i("ol",Gn,[(o(!0),i(oe,null,ue(z.plan.steps,(ge,ie)=>(o(),i("li",{key:ie,class:"text-xs leading-relaxed"},[e("div",Jn,n(ie+1)+". "+n(ge.goal),1),e("div",Xn,n(a(t)("ai.chat.message.plan.evidenceNeeded"))+": "+n(ge.evidenceNeeded),1),e("div",Zn,n(a(t)("ai.chat.message.plan.suggestedTools"))+": "+n(ce(ge.suggestedTools)),1)]))),128))])),z.displayText?P("",!0):(o(),i("div",er,[e("div",tr,n(a(t)("ai.chat.message.plan.successCriteria")),1),e("ul",ar,[(o(!0),i(oe,null,ue(z.plan.successCriteria,(ge,ie)=>(o(),i("li",{key:ie},n(ge),1))),128))])]))])])):z.type==="plan_draft"?(o(),i("div",sr,[e("div",or,[p(F,{name:"i-heroicons-clipboard-document-list",class:"h-3.5 w-3.5 shrink-0"}),e("span",null,n(a(t)("ai.chat.message.plan.label")),1),l.isStreaming?(o(),i("span",nr,[...C[4]||(C[4]=[e("span",{class:"flex gap-0.5"},[e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1)])])):P("",!0)]),e("div",{class:"mt-2 prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:I(z.text)},null,8,rr)])):z.type==="chart"?(o(),Q(un,{key:5,chart:z.chart},null,8,["chart"])):z.type==="tool"?(o(),i("div",{key:6,class:ae(["flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs transition-colors",[z.tool.status==="running"?"bg-gray-100 text-gray-600 dark:bg-gray-800/50 dark:text-gray-400":z.tool.status==="done"?"bg-gray-50 text-gray-500 dark:bg-gray-800/30 dark:text-gray-400/80":"bg-red-50 text-red-600 dark:bg-red-900/20 dark:text-red-400"]])},[p(F,{name:z.tool.status==="running"?"i-heroicons-arrow-path":z.tool.status==="done"?"i-heroicons-wrench-screwdriver":"i-heroicons-exclamation-circle",class:ae(["h-3.5 w-3.5 shrink-0",[z.tool.status==="running"?"animate-spin":""]])},null,8,["name","class"]),e("div",lr,[e("span",null,n(ee(z.tool)),1),se(z.tool)?(o(),i("span",ir,n(se(z.tool)),1)):P("",!0),z.tool.status==="done"&&z.tool.durationMs?(o(),i("span",cr," · "+n(w(z.tool.durationMs)),1)):P("",!0)])],2)):z.type==="error"?(o(),Q(No,{key:7,error:z.error},null,8,["error"])):P("",!0)],64))),128)),l.isStreaming&&T.value.length>0&&T.value[T.value.length-1].type==="tool"?(o(),i("div",dr,[C[5]||(C[5]=e("span",{class:"flex gap-1"},[e("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),e("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),e("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1)),e("span",null,n(a(t)("ai.chat.message.generating")),1)])):P("",!0)])):(o(),i("div",ur,[e("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:y.value},null,8,mr),l.isStreaming?(o(),i("span",gr)):P("",!0)])),!h.value&&!l.isStreaming?(o(),i("div",{key:4,class:ae(["mt-1 flex items-center gap-2 px-1",[v.value?"flex-row-reverse":""]])},[e("span",pr,n(g.value),1),p(G,{text:a(t)("ai.chat.message.copy.tooltip"),class:"no-capture"},{default:O(()=>[p(J,{icon:"i-heroicons-document-duplicate",variant:"ghost",color:"primary",size:"xs",disabled:!K.value,onClick:N},null,8,["disabled"])]),_:1},8,["text"]),E.value?(o(),Q(G,{key:0,text:a(t)("ai.chat.message.edit.tooltip"),class:"no-capture"},{default:O(()=>[p(J,{icon:"i-heroicons-pencil-square",variant:"ghost",color:"primary",size:"xs",onClick:q})]),_:1},8,["text"])):P("",!0),M.value?(o(),Q(G,{key:1,text:a(t)("ai.chat.message.fork.tooltip"),class:"no-capture"},{default:O(()=>[p(J,{icon:"i-heroicons-arrow-top-right-on-square",variant:"ghost",color:"primary",size:"xs",onClick:C[2]||(C[2]=z=>d("fork",l.messageId))})]),_:1},8,["text"])):P("",!0),l.showCaptureButton&&!v.value&&!l.isStreaming?(o(),Q(rt,{key:2,size:"xs",type:"element","target-selector":".qa-pair","markdown-fix":""})):P("",!0)],2)):P("",!0)],2)],2)}}}),vr={key:0,class:"absolute bottom-full left-0 z-20 mb-1.5 w-[240px] max-w-[calc(100vw-2rem)]"},hr={class:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-2xl shadow-gray-900/10 dark:border-gray-700 dark:bg-gray-900"},yr={class:"flex items-center justify-between border-b border-gray-100 px-2.5 py-1.5 dark:border-gray-800"},fr={class:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400"},xr=["title"],br={key:0,class:"px-3 py-4 text-center text-xs text-gray-500 dark:text-gray-400"},kr=["onMouseenter","onClick"],_r={class:"min-w-0 flex-1"},wr={class:"flex items-center gap-1.5"},$r={class:"truncate text-xs font-medium"},Cr={class:"mt-0.5 line-clamp-2 text-[11px] leading-4 text-gray-500 dark:text-gray-400"},Sr={key:2,class:"px-3 py-4 text-center"},Tr={class:"text-sm font-medium text-gray-700 dark:text-gray-200"},Ir={class:"mt-1 text-xs leading-5 text-gray-500 dark:text-gray-400"},Mr=pe({__name:"MemberMentionMenu",props:{visible:{type:Boolean},members:{},highlightIndex:{},loading:{type:Boolean}},emits:["select","close","highlight"],setup(l,{emit:s}){const{t}=he(),c=l,r=s,m=f(null);return me(()=>[c.visible,c.highlightIndex,c.members.length],async([u,d])=>{if(!u||!m.value)return;await ze(),m.value.querySelectorAll("[data-mention-item]")[d]?.scrollIntoView({block:"nearest"})}),(u,d)=>{const g=ye;return o(),Q(st,{name:"mention-menu"},{default:O(()=>[l.visible?(o(),i("div",vr,[e("div",hr,[e("div",yr,[e("div",fr,[e("span",null,n(a(t)("ai.chat.input.mentionHint")),1)]),e("button",{type:"button",class:"rounded-md p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:a(t)("common.close"),onClick:d[0]||(d[0]=v=>r("close"))},[p(g,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5"})],8,xr)]),c.loading?(o(),i("div",br,n(a(t)("common.loading")),1)):c.members.length>0?(o(),i("div",{key:1,ref_key:"listRef",ref:m,class:"max-h-72 overflow-y-auto p-1.5"},[(o(!0),i(oe,null,ue(c.members,(v,h)=>(o(),i("button",{key:`${v.memberId}-${v.insertName}`,type:"button","data-mention-item":"",class:ae(["flex w-full items-start justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left transition-colors",h===c.highlightIndex?"bg-primary-50 text-gray-900 dark:bg-primary-950/30 dark:text-gray-100":"text-gray-700 hover:bg-gray-50 dark:text-gray-200 dark:hover:bg-gray-800/80"]),onMouseenter:$=>r("highlight",h),onClick:$=>r("select",v)},[e("div",_r,[e("div",wr,[e("span",$r,"@"+n(v.insertName),1)]),e("p",Cr,n(v.subtitle),1)])],42,kr))),128))],512)):(o(),i("div",Sr,[e("p",Tr,n(a(t)("ai.chat.input.mentionEmpty")),1),e("p",Ir,n(a(t)("ai.chat.input.mentionEmptyHint")),1)]))])])):P("",!0)]),_:1})}}}),Lr=et(Mr,[["__scopeId","data-v-0262c6da"]]),Dr={key:0,class:"absolute bottom-full left-0 z-20 mb-1.5 w-[240px] max-w-[calc(100vw-2rem)]"},Ar={class:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-2xl shadow-gray-900/10 dark:border-gray-700 dark:bg-gray-900"},qr={class:"flex items-center justify-between border-b border-gray-100 px-2.5 py-1.5 dark:border-gray-800"},Rr={class:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400"},Er=["title"],zr=["onMouseenter","onClick"],Pr={class:"min-w-0 flex-1"},jr={class:"flex items-center gap-1.5"},Fr={class:"truncate text-xs font-medium"},Br={class:"mt-0.5 line-clamp-1 text-xs leading-4 text-gray-500 dark:text-gray-400"},Ur={key:1,class:"px-3 py-4 text-center"},Vr={class:"text-sm font-medium text-gray-700 dark:text-gray-200"},Or={class:"mt-1 text-xs leading-5 text-gray-500 dark:text-gray-400"},Nr={key:0,class:"absolute top-1/2 left-full ml-1 flex max-h-[min(348px,calc(100vh-10rem))] w-[300px] -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-2xl shadow-gray-900/10 dark:border-gray-700 dark:bg-gray-900"},Yr={class:"border-b border-gray-100 px-3 py-2 dark:border-gray-800"},Hr={class:"truncate text-sm font-medium text-gray-900 dark:text-gray-100"},Wr={class:"mt-0.5 text-xs leading-5 text-gray-500 dark:text-gray-400"},Kr={key:0,class:"mt-1 flex items-start gap-1.5 text-[11px] leading-4"},Qr={class:"shrink-0 font-medium text-gray-600 dark:text-gray-300"},Gr={class:"line-clamp-1 min-w-0 flex-1 text-gray-500 dark:text-gray-400"},Jr={key:1,class:"mt-0.5 flex items-start gap-1.5 text-[11px] leading-4"},Xr={class:"shrink-0 font-medium text-gray-600 dark:text-gray-300"},Zr={class:"line-clamp-1 min-w-0 flex-1 text-gray-500 dark:text-gray-400"},el={class:"min-h-0 flex-1 overflow-y-auto px-3 py-2"},tl={key:0,class:"text-xs text-gray-400 dark:text-gray-500"},al=["innerHTML"],sl={key:2,class:"text-xs leading-relaxed text-gray-400 dark:text-gray-500"},ol=pe({__name:"SlashCommandMenu",props:{visible:{type:Boolean},skills:{},highlightIndex:{},activeSkillId:{}},emits:["select","close","manage","highlight"],setup(l,{emit:s}){const{t,te:c}=he(),r=lt(),m=l,u=s,d=f({}),g=f(""),v=f(!1),h=f(null),$=new Wt({html:!1,breaks:!0,linkify:!0,typographer:!0}),x=k(()=>{if(m.skills.length===0)return null;const b=Math.min(m.highlightIndex,m.skills.length-1);return m.skills[b]??null}),S=k(()=>g.value?$.render(g.value):"");function E(b){const I=`ai.assistant.builtinToolDesc.${b}`;return c(I)?t(I):b}const M=k(()=>x.value?.tags.join(" / ")||""),L=k(()=>x.value?.tools.map(b=>E(b)).join(" / ")||"");return me(()=>[m.visible,x.value?.id],async([b,I])=>{if(!b||!I){g.value="",v.value=!1;return}if(d.value[I]){g.value=d.value[I],v.value=!1;return}v.value=!0;const w=(await r.getSkillConfig(I))?.prompt?.trim()||"";d.value={...d.value,[I]:w},x.value?.id===I&&(g.value=w,v.value=!1)},{immediate:!0}),me(()=>[m.visible,m.highlightIndex,m.skills.length],async([b,I])=>{if(!b||!h.value)return;await ze(),h.value.querySelectorAll("[data-slash-item]")[I]?.scrollIntoView({block:"nearest"})}),(b,I)=>{const R=ye;return o(),Q(st,{name:"slash-menu"},{default:O(()=>[l.visible?(o(),i("div",Dr,[e("div",Ar,[e("div",qr,[e("div",Rr,[e("span",null,n(a(t)("ai.chat.input.slashHint")),1)]),e("button",{type:"button",class:"rounded-md p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:a(t)("common.close"),onClick:I[0]||(I[0]=w=>u("close"))},[p(R,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5"})],8,Er)]),m.skills.length>0?(o(),i("div",{key:0,ref_key:"listRef",ref:h,class:"max-h-72 overflow-y-auto p-1.5"},[(o(!0),i(oe,null,ue(m.skills,(w,y)=>(o(),i("button",{key:w.id,type:"button","data-slash-item":"",class:ae(["flex w-full items-start justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left transition-colors",y===m.highlightIndex?"bg-primary-50 text-gray-900 dark:bg-primary-950/30 dark:text-gray-100":"text-gray-700 hover:bg-gray-50 dark:text-gray-200 dark:hover:bg-gray-800/80"]),onMouseenter:A=>u("highlight",y),onClick:A=>u("select",w)},[e("div",Pr,[e("div",jr,[e("span",Fr,n(w.name),1),m.activeSkillId===w.id?(o(),Q(R,{key:0,name:"i-heroicons-check-circle-20-solid",class:"h-3.5 w-3.5 shrink-0 text-primary-500"})):P("",!0)]),e("p",Br,n(w.description),1)])],42,zr))),128))],512)):(o(),i("div",Ur,[e("p",Vr,n(a(t)("ai.chat.input.slashEmpty")),1),e("p",Or,n(a(t)("ai.chat.input.slashEmptyHint")),1)])),e("button",{type:"button",class:"flex w-full items-center justify-between border-t border-gray-100 px-2.5 py-1.5 text-xs text-gray-600 transition-colors hover:bg-gray-50 hover:text-gray-900 dark:border-gray-800 dark:text-gray-300 dark:hover:bg-gray-800/80 dark:hover:text-gray-100",onClick:I[1]||(I[1]=w=>u("manage"))},[e("span",null,n(a(t)("ai.chat.input.manageSkills")),1),p(R,{name:"i-heroicons-arrow-top-right-on-square",class:"h-3.5 w-3.5"})])]),m.skills.length>0&&x.value?(o(),i("div",Nr,[e("div",Yr,[e("p",Hr,n(x.value.name),1),e("p",Wr,n(x.value.description),1),M.value?(o(),i("div",Kr,[e("span",Qr,n(a(t)("ai.chat.input.previewTagsLabel")),1),e("span",Gr,n(M.value),1)])):P("",!0),L.value?(o(),i("div",Jr,[e("span",Xr,n(a(t)("ai.chat.input.previewToolsLabel")),1),e("span",Zr,n(L.value),1)])):P("",!0)]),e("div",el,[v.value?(o(),i("div",tl,n(a(t)("common.loading")),1)):S.value?(o(),i("div",{key:1,class:"prose prose-sm max-w-none text-xs leading-5 dark:prose-invert prose-headings:mb-1.5 prose-headings:mt-2 prose-p:my-1.5 prose-ul:my-1.5 prose-ol:my-1.5",innerHTML:S.value},null,8,al)):(o(),i("div",sl,n(a(t)("ai.chat.input.previewUnavailable")),1))])])):P("",!0)])):P("",!0)]),_:1})}}}),nl=et(ol,[["__scopeId","data-v-0853b251"]]),rl={class:"shrink-0 pt-2 pb-2"},ll={class:"relative px-4 pt-2.5 pb-2.5"},il={class:"flex items-start gap-2 pr-10"},cl={key:0,class:"inline-flex max-w-[180px] shrink-0 items-center rounded-md bg-primary-50 px-2 text-sm leading-6 font-medium text-primary-700 dark:bg-primary-500/10 dark:text-primary-400"},dl={class:"truncate"},ul=["disabled","placeholder"],ml=["disabled","title"],gl=pe({__name:"AIChatInput",props:{sessionId:{},disabled:{type:Boolean},status:{},chatType:{}},emits:["send","stop","manageSkills","skillActivated"],setup(l,{expose:s,emit:t}){const{t:c}=he(),r=l,m=t,u=lt(),{compatibleSkills:d,activeSkill:g,activeSkillId:v,isLoaded:h}=Ze(u),$=f(null),x=f(null),S=f(""),E=f([]),M=f([]),L=f(!1),b=f(!1),I=f(""),R=f(0),w=f(!1),y=f(""),A=f(0),q=f(null),B=f(!1),j=f(null),_=f(null),T=f(!1),W=k(()=>S.value.trim().length>0&&!r.disabled),ee=k(()=>g.value&&S.value.trim().length===0?c("ai.chat.input.placeholderWithActiveSkill",{name:g.value.name}):c("ai.chat.input.placeholderWithSlash")),Y=k(()=>r.status==="streaming"?"":W.value?c("ai.chat.input.send"):g.value?c("ai.chat.input.needMoreThanSkill"):c("ai.chat.input.needQuestion")),ce=k(()=>{const V=new Map;return E.value.forEach(X=>{const Ce=X.groupNickname||X.accountName||X.platformId;V.set(Ce,(V.get(Ce)??0)+1)}),E.value.map(X=>{const Ce=X.groupNickname||X.accountName||X.platformId,ke=(V.get(Ce)??0)>1?`${Ce}·${X.platformId}`:Ce,Ae=[X.platformId];return X.aliases.length>0&&Ae.push(X.aliases.join(" / ")),{memberId:X.id,platformId:X.platformId,displayName:Ce,aliases:[...X.aliases],mentionText:`@${ke}`,insertName:ke,subtitle:Ae.join(" · "),searchText:[Ce,X.groupNickname||"",X.accountName||"",X.platformId,ke,X.aliases.join(" ")].join(" ").toLocaleLowerCase()}})}),ve=k(()=>{const V=I.value.trim().toLocaleLowerCase();return V?d.value.filter(X=>[X.name,X.description,X.tags.join(" ")].join(" ").toLocaleLowerCase().includes(V)):d.value}),H=k(()=>{const V=y.value.trim().toLocaleLowerCase();return V?ce.value.filter(X=>X.searchText.includes(V)):ce.value});function U(){if(!x.value)return;const V=x.value;V.style.height="auto";const X=192,Ce=Math.min(V.scrollHeight,X);V.style.height=`${Ce}px`,V.style.overflowY=V.scrollHeight>X?"auto":"hidden"}function te(){x.value?.focus()}async function se(){if(!r.sessionId){E.value=[];return}L.value=!0;try{const V=await qe().getMembers(r.sessionId);E.value=[...V].sort((X,Ce)=>Ce.messageCount-X.messageCount)}catch(V){console.error("加载 AI @ 成员列表失败:",V),E.value=[]}finally{L.value=!1}}function le(){b.value=!1,I.value="",R.value=0}function K(){w.value=!1,y.value="",A.value=0,q.value=null}function N(){/^\s*\/([^\n]*)$/.test(S.value)&&(j.value=S.value),le()}function D(){q.value&&(_.value=q.value.rawToken),K()}function C(V){if(r.disabled){le();return}j.value&&j.value!==V&&(j.value=null);const X=V.match(/^\s*\/([^\n]*)$/);if(!X){le();return}const Ce=!b.value||I.value!==X[1];if(I.value=X[1],j.value===V){b.value=!1;return}b.value=!0,Ce&&(R.value=0)}function F(){const V=x.value,X=S.value.length;return{start:V?.selectionStart??X,end:V?.selectionEnd??X}}function J(V){const{start:X,end:Ce}=F();if(X!==Ce)return null;const ke=V.slice(0,X),Ae=ke.match(/@([^\s@]*)$/);if(!Ae)return null;const Ee=Ae[1],We=ke.length-Ee.length-1;return{start:We,end:X,rawToken:ke.slice(We),query:Ee}}function G(V){if(r.disabled||b.value){K();return}const X=J(V);if(_.value&&_.value!==X?.rawToken&&(_.value=null),!X){K();return}const Ce=!w.value||y.value!==X.query||q.value?.rawToken!==X.rawToken;if(y.value=X.query,q.value={start:X.start,end:X.end,rawToken:X.rawToken},_.value===X.rawToken){w.value=!1;return}w.value=!0,Ce&&(A.value=0)}function z(V){if(C(V),b.value){K();return}G(V)}function Z(V){M.value=M.value.filter(X=>V.includes(X.mentionText))}function ge(){const{start:V,end:X}=F();if(V!==X||V===0)return!1;const Ce=[...new Set(M.value.map(ke=>ke.mentionText))].sort((ke,Ae)=>Ae.length-ke.length);for(const ke of Ce){let Ae=S.value.indexOf(ke);for(;Ae!==-1;){const Ee=Ae,We=Ae+ke.length,xt=S.value[We]===" "?We+1:We;if(V>Ee&&V<=xt)return T.value=!0,S.value=S.value.slice(0,Ee)+S.value.slice(xt),_.value=null,ze(()=>{U(),te(),x.value?.setSelectionRange(Ee,Ee),T.value=!1,z(S.value)}),!0;Ae=S.value.indexOf(ke,Ae+ke.length)}}return!1}function ie(){u.activateSkill(null),ze(te)}function xe(){r.disabled||(v.value&&u.activateSkill(null),T.value=!0,S.value="/",j.value=null,ze(()=>{U(),te(),x.value?.setSelectionRange(1,1),T.value=!1,z(S.value)}))}function Ie(V){r.disabled||(T.value=!0,S.value=V,j.value=null,ze(()=>{U(),te();const X=S.value.length;x.value?.setSelectionRange(X,X),T.value=!1,z(S.value)}))}function De(V){if(r.disabled||!q.value)return;const X=S.value.slice(0,q.value.start),Ce=S.value.slice(q.value.end),ke=`@${V.insertName}`,Ae=`${X}${ke} ${Ce}`;M.value=[...M.value.filter(Ee=>Ee.memberId!==V.memberId),{memberId:V.memberId,platformId:V.platformId,displayName:V.displayName,aliases:[...V.aliases],mentionText:ke}],T.value=!0,S.value=Ae,_.value=null,K(),ze(()=>{const Ee=X.length+ke.length+1;U(),te(),x.value?.setSelectionRange(Ee,Ee),T.value=!1,z(S.value)})}function $e(){W.value&&(m("send",{content:S.value.trim(),mentionedMembers:[...M.value]}),S.value="",j.value=null,_.value=null,M.value=[],K(),v.value&&u.activateSkill(null))}function re(V){r.disabled||(u.activateSkill(V.id),m("skillActivated",V),S.value="",j.value=null,le(),ze(()=>{te()}))}function de(){N(),m("manageSkills")}function Te(V){if(!ve.value.length)return;const X=ve.value.length;R.value=(R.value+V+X)%X}function Re(V){if(!H.value.length)return;const X=H.value.length;A.value=(A.value+V+X)%X}function tt(V){if(V.key==="Backspace"&&S.value.length===0&&v.value){V.preventDefault(),ie();return}if(V.key==="Backspace"&&ge()){V.preventDefault();return}if(w.value){if(V.key==="ArrowDown"){V.preventDefault(),Re(1);return}if(V.key==="ArrowUp"){V.preventDefault(),Re(-1);return}if(V.key==="Escape"){V.preventDefault(),D();return}if(V.key==="Enter"&&!V.shiftKey&&!B.value||V.key==="Tab"){V.preventDefault();const X=H.value[A.value];X&&De(X);return}}if(b.value){if(V.key==="ArrowDown"){V.preventDefault(),Te(1);return}if(V.key==="ArrowUp"){V.preventDefault(),Te(-1);return}if(V.key==="Escape"){V.preventDefault(),N();return}if(V.key==="Enter"&&!V.shiftKey&&!B.value||V.key==="Tab"){V.preventDefault();const X=ve.value[R.value];X&&re(X);return}}V.key==="Enter"&&!V.shiftKey&&!B.value&&(V.preventDefault(),$e())}function He(V){if(!b.value&&!w.value||!$.value)return;const X=V.target;X instanceof Node&&!$.value.contains(X)&&(N(),D())}function Qe(){T.value||z(S.value)}return me(()=>r.chatType,V=>{u.setFilterContext(V)},{immediate:!0}),me(S,async V=>{Z(V),T.value||z(V),await ze(),U()}),me(ve,V=>{if(V.length===0){R.value=0;return}R.value>=V.length&&(R.value=V.length-1)},{immediate:!0}),me(H,V=>{if(V.length===0){A.value=0;return}A.value>=V.length&&(A.value=V.length-1)},{immediate:!0}),me(()=>r.disabled,V=>{V&&(N(),D())}),me(()=>r.sessionId,()=>{M.value=[],K(),se()},{immediate:!0}),Me(async()=>{h.value||await u.loadSkills(),await ze(),U(),document.addEventListener("mousedown",He)}),Ct(()=>{document.removeEventListener("mousedown",He)}),s({fillInput:Ie,openSkillSelector:xe}),(V,X)=>{const Ce=ye;return o(),i("div",rl,[e("div",{ref_key:"rootRef",ref:$,class:"relative w-full max-w-4xl mx-auto"},[p(nl,{visible:b.value,skills:ve.value,"highlight-index":R.value,"active-skill-id":a(v),onSelect:re,onClose:N,onManage:de,onHighlight:X[0]||(X[0]=ke=>R.value=ke)},null,8,["visible","skills","highlight-index","active-skill-id"]),p(Lr,{visible:w.value,members:H.value,"highlight-index":A.value,loading:L.value,onSelect:De,onClose:D,onHighlight:X[1]||(X[1]=ke=>A.value=ke)},null,8,["visible","members","highlight-index","loading"]),e("div",{class:ae(["flex flex-col overflow-hidden rounded-2xl bg-white shadow-[0_2px_14px_rgba(0,0,0,0.04)] ring-1 ring-gray-200 transition-all dark:bg-gray-900 dark:ring-gray-800",r.disabled?"bg-gray-50/50 dark:bg-gray-900/50":"focus-within:ring-primary-500/50 focus-within:shadow-[0_4px_20px_rgba(0,0,0,0.08)] dark:focus-within:ring-primary-500/50"])},[e("div",ll,[e("div",il,[a(g)?(o(),i("div",cl,[e("span",dl,"/"+n(a(g).name),1)])):P("",!0),Be(e("textarea",{ref_key:"textareaRef",ref:x,"onUpdate:modelValue":X[2]||(X[2]=ke=>S.value=ke),rows:"2",class:"min-h-[48px] min-w-0 flex-1 resize-none border-0 bg-transparent px-0 py-0 text-sm leading-6 text-gray-900 outline-none placeholder:text-gray-400 disabled:cursor-not-allowed disabled:text-gray-400 dark:text-gray-100 dark:placeholder:text-gray-500 dark:disabled:text-gray-500",disabled:r.disabled,placeholder:ee.value,onKeydown:tt,onClick:Qe,onKeyup:Qe,onSelect:Qe,onCompositionstart:X[3]||(X[3]=ke=>B.value=!0),onCompositionend:X[4]||(X[4]=ke=>B.value=!1)},null,40,ul),[[at,S.value]])]),r.status==="streaming"?(o(),i("button",{key:0,type:"button",class:"absolute right-3 bottom-2 flex h-7 w-7 items-center justify-center rounded-full bg-primary-500 text-white shadow-sm transition-colors hover:bg-primary-600",onClick:X[5]||(X[5]=ke=>m("stop"))},[p(Ce,{name:"i-heroicons-stop-16-solid",class:"h-3.5 w-3.5"})])):(o(),i("button",{key:1,type:"button",class:ae(["absolute right-3 bottom-2 flex h-7 w-7 items-center justify-center rounded-full transition-all duration-200",W.value?"bg-primary-500 text-white hover:bg-primary-600 shadow-sm":"bg-gray-100 text-gray-400 dark:bg-gray-800 dark:text-gray-500"]),disabled:!W.value,title:Y.value,onClick:$e},[p(Ce,{name:"i-heroicons-arrow-up-20-solid",class:"h-4 w-4"})],10,ml))])],2)],512)])}}}),pl={key:0,class:"flex w-fit items-center gap-1.5 rounded-lg bg-gray-100 px-2.5 py-1 text-xs transition-colors dark:bg-gray-800/50"},vl={class:"font-medium text-gray-600 dark:text-gray-400"},hl={key:1,class:"flex items-start gap-3"},yl={class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-linear-to-br from-pink-500 to-pink-600"},fl={class:"rounded-2xl rounded-tl-sm bg-gray-100 px-4 py-3 dark:bg-gray-800"},xl={key:0,class:"space-y-2"},bl={class:"flex items-center gap-2"},kl={key:0,class:"flex gap-1"},_l={key:1,class:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400"},wl={key:0,class:"flex flex-wrap gap-1"},$l={class:"text-xs text-gray-400"},Cl={key:1,class:"flex items-center gap-2"},Sl={class:"text-sm text-gray-600 dark:text-gray-400"},Tl=pe({__name:"AIThinkingIndicator",props:{currentToolStatus:{},toolsUsed:{},agentStatus:{}},setup(l){const{t:s,te:t}=he();function c(u,d){const g=`ai.chat.message.tools.${u}`;return t(g)?s(g):d||u}const r=l,m=k(()=>r.agentStatus?.phase==="compressing");return(u,d)=>{const g=ye;return m.value?(o(),i("div",pl,[p(g,{name:"i-heroicons-arrow-path",class:"h-3.5 w-3.5 shrink-0 animate-spin text-gray-600 dark:text-gray-400"}),e("span",vl,n(a(s)("ai.chat.thinking.compressing")),1)])):(o(),i("div",hl,[e("div",yl,[p(g,{name:"i-heroicons-sparkles",class:"h-4 w-4 text-white"})]),e("div",fl,[l.currentToolStatus?(o(),i("div",xl,[e("div",bl,[e("span",{class:ae(["inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium",[l.currentToolStatus.status==="running"?"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-300":l.currentToolStatus.status==="done"?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300"]])},[p(g,{name:l.currentToolStatus.status==="running"?"i-heroicons-cog-6-tooth":l.currentToolStatus.status==="done"?"i-heroicons-check-circle":"i-heroicons-x-circle",class:ae(["h-3 w-3",{"animate-spin":l.currentToolStatus.status==="running"}])},null,8,["name","class"]),ne(" "+n(c(l.currentToolStatus.name,l.currentToolStatus.displayName)),1)],2),l.currentToolStatus.status==="running"?(o(),i("span",kl,[...d[0]||(d[0]=[e("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:0ms]"},null,-1),e("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:150ms]"},null,-1),e("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:300ms]"},null,-1)])])):l.currentToolStatus.status==="done"?(o(),i("span",_l,[e("span",null,n(a(s)("ai.chat.thinking.processingResult")),1),d[1]||(d[1]=e("span",{class:"flex gap-1"},[e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),e("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1))])):P("",!0)]),l.toolsUsed.length>1?(o(),i("div",wl,[e("span",$l,n(a(s)("ai.chat.thinking.called")),1),(o(!0),i(oe,null,ue(l.toolsUsed.slice(0,-1),v=>(o(),i("span",{key:v,class:"inline-flex items-center gap-1 rounded-full bg-gray-200 px-2 py-0.5 text-xs text-gray-600 dark:bg-gray-700 dark:text-gray-400"},[p(g,{name:"i-heroicons-check",class:"h-3 w-3 text-green-500"}),ne(" "+n(c(v)),1)]))),128))])):P("",!0)])):(o(),i("div",Cl,[e("span",Sl,n(a(s)("ai.chat.thinking.analyzing")),1),d[2]||(d[2]=e("span",{class:"flex gap-1"},[e("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:0ms]"}),e("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:150ms]"}),e("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:300ms]"})],-1))]))])]))}}}),Il={class:"relative z-20 flex items-center justify-between"},Ml={class:"flex items-center gap-1"},Ll=["disabled"],Dl={class:"max-w-[160px] truncate"},Al=["title"],ql={class:"w-40 py-1"},Rl={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},El=["onClick"],zl={class:"flex items-center gap-1"},Pl=["title"],jl={class:"hidden shrink-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-xs text-gray-400 dark:text-gray-500 md:flex"},Fl={class:"h-1.5 w-10 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},Bl={class:"text-[10px]"},Ul={class:"space-y-0.5 whitespace-nowrap text-xs"},Vl={key:0},Ol=["title"],Nl={class:"hidden lg:inline"},Yl=["title","disabled"],Hl={class:"hidden xl:inline"},Wl=["title","disabled"],Kl={class:"hidden xl:inline"},Ql=pe({__name:"ChatStatusBar",props:{sessionTokenUsage:{},agentStatus:{},currentAIChatId:{},estimatedContextTokens:{}},setup(l){const{t:s}=he(),t=Ye(),c=dt(),r=l,m=wt(),u=Ea(),{aiGlobalSettings:d}=Ze(m),{defaultAssistantConfig:g,isLoading:v}=Ze(u),h=f(!1),$=k(()=>r.agentStatus?s(`ai.chat.statusBar.agent.phase.${r.agentStatus.phase}`):""),x=k(()=>r.agentStatus?s(`ai.chat.statusBar.agent.phaseShort.${r.agentStatus.phase}`):""),S=k(()=>{if(!r.agentStatus)return"text-gray-500 bg-gray-100 dark:bg-gray-800 dark:text-gray-300";switch(r.agentStatus.phase){case"compressing":return"text-purple-600 bg-purple-50 dark:bg-purple-900/30 dark:text-purple-300";case"tool_running":return"text-indigo-600 bg-indigo-50 dark:bg-indigo-900/30 dark:text-indigo-300";case"thinking":return"text-blue-600 bg-blue-50 dark:bg-blue-900/30 dark:text-blue-300";case"responding":return"text-emerald-600 bg-emerald-50 dark:bg-emerald-900/30 dark:text-emerald-300";case"completed":return"text-green-600 bg-green-50 dark:bg-green-900/30 dark:text-green-300";case"aborted":return"text-amber-600 bg-amber-50 dark:bg-amber-900/30 dark:text-amber-300";case"error":return"text-red-600 bg-red-50 dark:bg-red-900/30 dark:text-red-300";default:return"text-gray-500 bg-gray-100 dark:bg-gray-800 dark:text-gray-300"}});function E(se){return Number.isFinite(se)?new Intl.NumberFormat().format(Math.max(0,Math.round(se))):"0"}function M(se){const le=Math.max(0,Math.round(se));return le>=1e6?`${(le/1e6).toFixed(1).replace(/\.0$/,"")}M`:le>=1e3?`${(le/1e3).toFixed(1).replace(/\.0$/,"")}k`:String(le)}const L=k(()=>E(r.sessionTokenUsage.totalTokens)),b=k(()=>M(r.sessionTokenUsage.totalTokens)),I=k(()=>r.sessionTokenUsage.cacheReadTokens>0),R=k(()=>M(r.sessionTokenUsage.cacheReadTokens)),w=k(()=>r.agentStatus?.contextTokens?r.agentStatus.contextTokens:r.estimatedContextTokens&&r.estimatedContextTokens>0?r.estimatedContextTokens:0),y=k(()=>{const se=g.value,le=u.defaultAssistant?.modelId||se?.model;return!se||!le?128e3:(u.getModelById(se.provider,le)||u.findModelAcrossProviders(le))?.contextWindow??128e3}),A=k(()=>w.value<=0||y.value<=0?0:Math.min(100,Math.round(w.value/y.value*100))),q=k(()=>{const se=A.value;return se>=80?"bg-red-500":se>=60?"bg-amber-500":"bg-emerald-500"}),B=k(()=>r.agentStatus?[`${s("ai.chat.statusBar.agent.label")}: ${$.value}`,`${s("ai.chat.statusBar.agent.contextTokens")}: ${E(r.agentStatus.contextTokens)}`,`${s("ai.chat.statusBar.tokenUsageTitle")}: ${L.value}`].join(`
|
|
35
|
-
`):"");function j(){c.openSettings("ai","chat")}function _(){c.openSettings("ai","defaultModel")}const T=f(!1);async function W(){if(!(T.value||!r.currentAIChatId)){T.value=!0;try{const[se,le]=await Promise.all([je().getAIChat(r.currentAIChatId),je().getMessages(r.currentAIChatId)]);if(!se||le.length===0){t.warn(s("ai.chat.conversation.export.noMessages"));return}const K=d.value.exportFormat||"markdown",N=se.title||s("ai.chat.conversation.newChat"),D={createdAt:s("ai.chat.conversation.export.createdAt"),user:s("ai.chat.conversation.export.user"),assistant:s("ai.chat.conversation.export.assistant")},C=le.filter(J=>J.role==="user"||J.role==="assistant").map(J=>({role:J.role,content:J.content,timestamp:J.timestamp*1e3})),F=await cs(N,C,se.createdAt*1e3,K,D);if(F.success&&F.filePath){const J=F.filePath.split("/").pop()||F.filePath,G=F.filePath;t.add({title:s("common.exportSuccess"),description:J,color:"primary",actions:[{label:s("common.openFolder"),onClick:()=>{oa().showInFolder(G)}}]})}else t.fail(s("common.exportFailed"),{description:F.error})}catch(se){console.error("导出对话失败:",se),t.fail(s("common.exportFailed"),{description:String(se)})}finally{T.value=!1}}}async function ee(){if(!h.value){h.value=!0;try{const se=await je().showAiLogFile();se?.success||t.fail(s("ai.chat.statusBar.log.openFailed"),{description:se?.error||s("ai.chat.statusBar.log.openFailedDesc")})}catch(se){console.error("打开 AI 日志失败:",se),t.fail(s("ai.chat.statusBar.log.openFailed"),{description:String(se)})}finally{h.value=!1}}}const Y=f(!1),ce=k(()=>{const se=g.value,le=u.defaultAssistant?.modelId||se?.model;return!se?.provider||!le?[]:as(se.provider,le)}),ve=k(()=>ce.value.length>0),H=k(()=>{const se=u.defaultAssistant;return!se?.configId||!se?.modelId?"default":m.getThinkingLevel(se.configId,se.modelId)??"default"});function U(se){const le=u.defaultAssistant;!le?.configId||!le?.modelId||(m.setThinkingLevel(le.configId,le.modelId,se),Y.value=!1)}const te=k(()=>s(`ai.chat.statusBar.thinking.level.${H.value}`));return(se,le)=>{const K=ye,N=ca,D=gt;return o(),i("div",Il,[e("div",Ml,[e("button",{class:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-300",disabled:a(v),onClick:_},[p(K,{name:"i-heroicons-cpu-chip",class:"h-3.5 w-3.5"}),e("span",Dl,n(a(u).defaultAssistant?.modelId?a(u).getModelById(a(g)?.provider??"",a(u).defaultAssistant.modelId)?.name||a(u).defaultAssistant.modelId:a(s)("ai.chat.statusBar.model.notConfigured")),1)],8,Ll),ve.value?(o(),Q(N,{key:0,open:Y.value,"onUpdate:open":le[0]||(le[0]=C=>Y.value=C),ui:{content:"z-[80] p-0"}},{content:O(()=>[e("div",ql,[e("div",Rl,n(a(s)("ai.chat.statusBar.thinking.title")),1),(o(!0),i(oe,null,ue(ce.value,C=>(o(),i("button",{key:C,class:ae(["flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",H.value===C?"text-primary-600 dark:text-primary-400":"text-gray-700 dark:text-gray-300"]),onClick:F=>U(C)},[p(K,{name:H.value===C?"i-heroicons-check-circle-solid":"i-heroicons-light-bulb",class:ae(["h-4 w-4 shrink-0",H.value===C?"text-primary-500":"text-gray-400"])},null,8,["name","class"]),e("span",null,n(a(s)(`ai.chat.statusBar.thinking.level.${C}`)),1)],10,El))),128))])]),default:O(()=>[e("button",{class:ae(["flex items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",H.value==="default"||H.value==="off"?"text-gray-400 dark:text-gray-500":"text-primary-500 dark:text-primary-400"]),title:a(s)("ai.chat.statusBar.thinking.tooltip")},[p(K,{name:"i-heroicons-light-bulb",class:"h-3.5 w-3.5"}),e("span",null,n(te.value),1)],10,Al)]),_:1},8,["open"])):P("",!0)]),e("div",zl,[l.agentStatus?(o(),i("div",{key:0,class:"hidden shrink-0 items-center gap-1 rounded-lg bg-gray-50/90 px-1.5 py-1 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.35)] dark:bg-gray-800/70 dark:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.04)] lg:flex",title:B.value},[e("span",{class:ae(["rounded px-1 py-0.5 text-[10px] font-medium",S.value])},n(x.value),3)],8,Pl)):P("",!0),w.value>0?(o(),Q(D,{key:1,ui:{content:"h-auto py-1.5"}},{content:O(()=>[e("div",Ul,[e("div",null,n(a(s)("ai.chat.statusBar.agent.contextTokens"))+": "+n(M(w.value))+" / "+n(M(y.value)),1),e("div",null,n(a(s)("ai.chat.statusBar.tokenUsageTitle"))+": "+n(b.value),1),I.value?(o(),i("div",Vl,n(a(s)("ai.chat.statusBar.cacheHit"))+": "+n(R.value),1)):P("",!0)])]),default:O(()=>[e("div",jl,[e("div",Fl,[e("div",{class:ae(["h-full rounded-full transition-all duration-300",q.value]),style:Ne({width:`${A.value}%`})},null,6)]),e("span",Bl,n(A.value)+"%",1)])]),_:1})):P("",!0),e("button",{class:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:a(s)("ai.chat.statusBar.messageLimit.title"),onClick:j},[p(K,{name:"i-heroicons-adjustments-horizontal",class:"h-3.5 w-3.5"}),e("span",Nl,n(a(s)("ai.chat.statusBar.messageLimit.label")),1),e("span",null,n(a(d).maxMessagesPerRequest),1)],8,Ol),e("button",{class:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:a(s)("ai.chat.statusBar.export.title"),disabled:T.value||!l.currentAIChatId,onClick:W},[p(K,{name:"i-heroicons-arrow-down-tray",class:"h-3.5 w-3.5"}),e("span",Hl,n(a(s)("ai.chat.statusBar.export.label")),1)],8,Yl),e("button",{class:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:a(s)("ai.chat.statusBar.log.title"),disabled:h.value,onClick:ee},[p(K,{name:"i-heroicons-document-text",class:"h-3.5 w-3.5"}),e("span",Kl,n(a(s)("ai.chat.statusBar.log.label")),1)],8,Wl)])])}}}),Gl={class:"assistant-bar-wrapper flex justify-center"},Jl=["onClick"],Xl={key:0,class:"absolute right-0 top-full z-30 mt-2 w-56 overflow-hidden rounded-xl border border-gray-200/80 bg-white/95 p-1 shadow-lg backdrop-blur-md dark:border-gray-700 dark:bg-gray-900/95"},Zl={class:"custom-scrollbar max-h-60 space-y-0.5 overflow-y-auto"},ei=["onClick"],ti={class:"truncate font-medium"},bt=4,ai=pe({__name:"AssistantInlineBar",props:{chatType:{},locale:{},selectedId:{}},emits:["select","market"],setup(l,{emit:s}){const t=l,c=s,r=f(!1),m=f(null);function u(y){c("select",y),r.value=!1}function d(){M.value.length!==0&&(r.value=!r.value)}function g(y){if(!r.value||!m.value)return;const A=y.target;A instanceof Node&&!m.value.contains(A)&&(r.value=!1)}const v=ut(),{filteredAssistants:h,isLoaded:$}=Ze(v);function x(y){return y.startsWith("ja")?"general_ja":y.startsWith("en")?"general_en":"general_cn"}const S=k(()=>{const y=x(t.locale);return[...h.value].sort((A,q)=>A.id===y?-1:q.id===y?1:0)}),E=k(()=>{const y=S.value;if(y.length<=bt)return y;const A=y.findIndex(q=>q.id===t.selectedId);if(A!==-1&&A>=bt-1){const q=y.slice(0,bt-1),B=y[A];return[...q,B]}return y.slice(0,bt)}),M=k(()=>{const y=new Set(E.value.map(A=>A.id));return S.value.filter(A=>!y.has(A.id))});me(()=>[t.chatType,t.locale],([y,A])=>{v.setFilterContext(y,A)},{immediate:!0});const L=f([]),b=f(null);let I=null;const R=f({width:"0px",transform:"translateX(0px)",opacity:0}),w=async()=>{await ze();const y=E.value.findIndex(A=>A.id===t.selectedId);if(y!==-1&&L.value[y]){const A=L.value[y];R.value={width:`${A.offsetWidth+6}px`,transform:`translateX(${A.offsetLeft-3}px)`,opacity:1}}else R.value.opacity=0};return me(()=>[t.selectedId,E.value],()=>{w()},{deep:!0}),Me(async()=>{$.value||await v.loadAssistants(),w(),document.addEventListener("mousedown",g),typeof ResizeObserver<"u"&&b.value&&(I=new ResizeObserver(()=>{w()}),I.observe(b.value))}),it(()=>{document.removeEventListener("mousedown",g),I&&I.disconnect()}),(y,A)=>{const q=ye;return o(),i("div",Gl,[e("div",{ref_key:"containerRef",ref:b,class:"assistant-bar-grid relative flex items-center justify-center gap-1.5 rounded-full bg-gray-50/60 p-[3px] shadow-inner ring-1 ring-inset ring-gray-900/5 backdrop-blur-md dark:bg-gray-800/40 dark:ring-white/10 z-0 overflow-hidden sm:overflow-visible"},[e("div",{class:"absolute left-0 inset-y-0 -z-10 rounded-full bg-white ring-[1.5px] ring-primary-500 shadow-sm transition-all duration-350 ease-out dark:bg-primary-700/15 dark:ring-primary-500",style:Ne(R.value)},null,4),(o(!0),i(oe,null,ue(E.value,(B,j)=>(o(),i("button",{key:B.id,ref_for:!0,ref:_=>{_&&(L.value[j]=_)},class:ae(["relative z-10 flex h-[32px] items-center justify-center whitespace-nowrap rounded-full px-4 text-[13px] font-medium transition-colors duration-200",[l.selectedId===B.id?"text-primary-600 dark:text-primary-400":"text-gray-500 hover:bg-gray-200/50 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-700/50 dark:hover:text-gray-200"]]),onClick:_=>c("select",B.id)},n(B.name),11,Jl))),128)),M.value.length>0?(o(),i("div",{key:0,ref_key:"overflowMenuRef",ref:m,class:"relative z-20"},[e("button",{type:"button",class:"relative z-10 flex h-[32px] w-[32px] ml-0.5 items-center justify-center rounded-full text-gray-500 transition-colors duration-200 hover:bg-gray-200/50 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-700/50 dark:hover:text-gray-200",onClick:d},[p(q,{name:"i-heroicons-ellipsis-horizontal",class:"h-5 w-5"})]),r.value?(o(),i("div",Xl,[e("div",Zl,[A[1]||(A[1]=e("p",{class:"px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500"}," 更多助手 ",-1)),(o(!0),i(oe,null,ue(M.value,B=>(o(),i("button",{key:B.id,type:"button",class:ae(["flex w-full items-center justify-between rounded-md px-2.5 py-1.5 text-left text-sm transition-colors",[l.selectedId===B.id?"bg-primary-50 text-primary-600 dark:bg-primary-500/10 dark:text-primary-400":"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800"]]),onClick:j=>u(B.id)},[e("span",ti,n(B.name),1),l.selectedId===B.id?(o(),Q(q,{key:0,name:"i-heroicons-check",class:"h-4 w-4 shrink-0"})):P("",!0)],10,ei))),128))])])):P("",!0)],512)):P("",!0),e("button",{type:"button",class:"relative z-10 flex h-[32px] w-[32px] items-center justify-center rounded-full text-gray-500 transition-colors duration-200 hover:bg-gray-200/50 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-700/50 dark:hover:text-gray-200",onClick:A[0]||(A[0]=B=>c("market"))},[p(q,{name:"i-heroicons-plus",class:"h-[18px] w-[18px]"})])],512)])}}}),si=et(ai,[["__scopeId","data-v-94ffe515"]]),oi={class:"p-6"},ni={class:"mb-4 flex items-start justify-between gap-3"},ri={class:"min-w-0"},li={class:"text-lg font-semibold text-gray-900 dark:text-white"},ii={key:0,class:"mt-1 text-xs text-amber-600 dark:text-amber-400"},ci={key:0,class:"flex items-center justify-center py-12"},di={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},ui={key:0,class:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary-100 px-1 text-[10px] text-primary-600 dark:bg-primary-900/30 dark:text-primary-400"},mi={class:"max-h-[500px] overflow-y-auto pr-1"},gi={class:"space-y-5"},pi={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},vi={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},hi={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},yi={class:"flex flex-wrap gap-2"},fi=["disabled","onClick"],xi={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},bi={class:"flex flex-wrap gap-2"},ki=["disabled","onClick"],_i={class:"mt-1 text-[10px] text-gray-400"},wi={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},$i={class:"space-y-2"},Ci={key:0,class:"flex items-center gap-2"},Si={class:"space-y-5"},Ti={class:"mb-1 text-sm font-medium text-gray-700 dark:text-gray-300"},Ii={class:"mb-2.5 text-[10px] text-gray-400"},Mi={class:"grid grid-cols-2 gap-1.5"},Li={class:"min-w-0"},Di={class:"truncate text-xs font-medium text-gray-600 dark:text-gray-400"},Ai={class:"truncate text-[10px] text-gray-400 dark:text-gray-500"},qi={class:"mb-1 flex items-center justify-between"},Ri={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Ei={key:0,class:"flex gap-2"},zi={class:"mb-2.5 text-[10px] text-gray-400"},Pi={class:"grid grid-cols-2 gap-1.5"},ji=["checked","disabled","onChange"],Fi={class:"min-w-0"},Bi={class:"truncate text-xs font-medium text-gray-800 dark:text-gray-200"},Ui={class:"truncate text-[10px] text-gray-500 dark:text-gray-400"},Vi={class:"mt-6 flex items-center justify-between"},Oi={class:"flex gap-2"},Ni=pe({__name:"AssistantConfigModal",props:{open:{type:Boolean},assistantId:{},readonly:{type:Boolean},scrollToSection:{}},emits:["update:open","saved","created"],setup(l,{emit:s}){const{t}=he(),c=l,r=s,m=Ye(),u=ut(),d=f(!1),g=f(!1),v=f(null),h=f(!1),$=f("basic"),x=k(()=>[{value:"",label:t("ai.assistant.config.chatTypeAll")},{value:"group",label:t("ai.assistant.config.chatTypeGroup")},{value:"private",label:t("ai.assistant.config.chatTypePrivate")}]),S=[{value:"zh",label:"简体中文"},{value:"en",label:"English"},{value:"ja",label:"日本語"}],E=k(()=>u.builtinToolCatalog.filter(H=>H.category==="core").map(H=>({name:H.name,description:t(`ai.assistant.builtinToolDesc.${H.name}`)}))),M=k(()=>u.builtinToolCatalog.filter(H=>H.category==="analysis").map(H=>({name:H.name,description:t(`ai.assistant.builtinToolDesc.${H.name}`)}))),L=f({name:"",systemPrompt:"",presetQuestions:[],applicableChatType:"",supportedLocales:[],allowedBuiltinTools:[]}),b=f(""),I=f(null),R=k(()=>L.value.allowedBuiltinTools.length);Me(async()=>{u.builtinToolCatalog.length===0&&await u.loadBuiltinToolCatalog()}),me(()=>[c.open,c.assistantId],async([H,U])=>{H&&($.value="basic",U?(h.value=!1,await y(U)):c.readonly||(h.value=!0,w()),c.scrollToSection==="presetQuestions"&&(await ze(),setTimeout(()=>{I.value?.scrollIntoView({behavior:"smooth",block:"center"})},100)))},{immediate:!0});function w(){v.value={id:"",name:"",systemPrompt:"",presetQuestions:[],allowedBuiltinTools:[],applicableChatTypes:[],supportedLocales:[]},L.value={name:"",systemPrompt:"",presetQuestions:[],applicableChatType:"",supportedLocales:[],allowedBuiltinTools:[]},d.value=!1}async function y(H){d.value=!0;try{v.value=await u.getAssistantConfig(H),v.value&&(L.value={name:v.value.name,systemPrompt:v.value.systemPrompt,presetQuestions:[...v.value.presetQuestions],applicableChatType:v.value.applicableChatTypes?.[0]||"",supportedLocales:[...v.value.supportedLocales||[]],allowedBuiltinTools:[...v.value.allowedBuiltinTools||[]]})}catch(U){console.error("[AssistantConfigModal] Failed to load config:",U),m.fail(t("ai.assistant.toast.loadFailed"),{description:String(U)})}finally{d.value=!1}}async function A(){g.value=!0;try{const H={name:L.value.name,systemPrompt:L.value.systemPrompt,presetQuestions:[...L.value.presetQuestions],applicableChatTypes:L.value.applicableChatType?[L.value.applicableChatType]:[],supportedLocales:[...L.value.supportedLocales],allowedBuiltinTools:[...L.value.allowedBuiltinTools]};if(h.value){const U=await u.createAssistant(H);U.success?(m.success(t("ai.assistant.toast.createSuccess")),r("created",U.id),ve()):m.fail(t("ai.assistant.toast.createFailed"),{description:U.error||t("ai.assistant.toast.unknownError")})}else{if(!c.assistantId)return;const U=await u.updateAssistant(c.assistantId,H);U.success?(m.success(t("ai.assistant.toast.saveSuccess")),r("saved"),ve()):m.fail(t("ai.assistant.toast.saveFailed"),{description:U.error||t("ai.assistant.toast.unknownError")})}}catch(H){console.error("[AssistantConfigModal] Save failed:",H),m.fail(t("ai.assistant.toast.saveFailed"),{description:String(H)})}finally{g.value=!1}}async function q(){if(!(!c.assistantId||!v.value?.builtinId)){g.value=!0;try{const H=await u.resetAssistant(c.assistantId);H.success?(m.success(t("ai.assistant.toast.resetSuccess")),await y(c.assistantId),r("saved")):m.fail(t("ai.assistant.toast.resetFailed"),{description:H.error||t("ai.assistant.toast.unknownError")})}catch(H){m.fail(t("ai.assistant.toast.resetFailed"),{description:String(H)})}finally{g.value=!1}}}function B(){const H=b.value.trim();H&&!L.value.presetQuestions.includes(H)&&(L.value.presetQuestions.push(H),b.value="")}function j(H){L.value.presetQuestions.splice(H,1)}function _(H){const U=L.value.allowedBuiltinTools.indexOf(H);U>=0?L.value.allowedBuiltinTools.splice(U,1):L.value.allowedBuiltinTools.push(H)}function T(H){return L.value.allowedBuiltinTools.includes(H)}function W(){L.value.allowedBuiltinTools=M.value.map(H=>H.name)}function ee(){L.value.allowedBuiltinTools=[]}function Y(H){L.value.applicableChatType=H}function ce(H){const U=L.value.supportedLocales.indexOf(H);U>=0?L.value.supportedLocales.splice(U,1):L.value.supportedLocales.push(H)}function ve(){r("update:open",!1)}return(H,U)=>{const te=Le,se=ye,le=pt,K=Oa,N=Fe;return o(),Q(N,{open:l.open,ui:{content:"sm:max-w-2xl z-100"},"onUpdate:open":U[5]||(U[5]=D=>r("update:open",D))},{content:O(()=>[e("div",oi,[e("div",ni,[e("div",ri,[e("h2",li,n(l.readonly?a(t)("ai.assistant.config.viewTitle"):h.value?a(t)("ai.assistant.config.createTitle"):a(t)("ai.assistant.config.editTitle")),1),l.readonly?P("",!0):(o(),i("p",ii,n(a(t)("ai.assistant.config.betaWarning")),1))]),p(te,{icon:"i-heroicons-x-mark",variant:"ghost",size:"sm",class:"shrink-0",onClick:ve})]),d.value?(o(),i("div",ci,[p(se,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):v.value?(o(),i(oe,{key:1},[e("div",di,[e("button",{class:ae(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",$.value==="basic"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:U[0]||(U[0]=D=>$.value="basic")},n(a(t)("ai.assistant.config.tabs.basic")),3),e("button",{class:ae(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",$.value==="tools"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:U[1]||(U[1]=D=>$.value="tools")},[ne(n(a(t)("ai.assistant.config.tabs.tools"))+" ",1),R.value>0?(o(),i("span",ui,n(R.value),1)):P("",!0)],2)]),e("div",mi,[Be(e("div",gi,[e("div",null,[e("label",pi,n(a(t)("ai.assistant.config.name")),1),p(le,{modelValue:L.value.name,"onUpdate:modelValue":U[2]||(U[2]=D=>L.value.name=D),class:"w-full",disabled:l.readonly},null,8,["modelValue","disabled"])]),e("div",null,[e("label",vi,n(a(t)("ai.assistant.config.systemPrompt")),1),p(K,{modelValue:L.value.systemPrompt,"onUpdate:modelValue":U[3]||(U[3]=D=>L.value.systemPrompt=D),rows:5,autoresize:"",class:"w-full font-mono text-sm",disabled:l.readonly},null,8,["modelValue","disabled"])]),e("div",null,[e("label",hi,n(a(t)("ai.assistant.config.chatType")),1),e("div",yi,[(o(!0),i(oe,null,ue(x.value,D=>(o(),i("button",{key:D.value,type:"button",class:ae(["rounded-lg border px-3 py-1.5 text-xs transition-colors",L.value.applicableChatType===D.value?"border-primary-500 bg-primary-50 text-primary-700 dark:border-primary-400 dark:bg-primary-950/30 dark:text-primary-300":"border-gray-200 text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:text-gray-400"]),disabled:l.readonly,onClick:C=>Y(D.value)},n(D.label),11,fi))),128))])]),e("div",null,[e("label",xi,n(a(t)("ai.assistant.config.locale")),1),e("div",bi,[(o(),i(oe,null,ue(S,D=>e("button",{key:D.value,type:"button",class:ae(["rounded-lg border px-3 py-1.5 text-xs transition-colors",L.value.supportedLocales.includes(D.value)?"border-primary-500 bg-primary-50 text-primary-700 dark:border-primary-400 dark:bg-primary-950/30 dark:text-primary-300":"border-gray-200 text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:text-gray-400"]),disabled:l.readonly,onClick:C=>ce(D.value)},n(D.label),11,ki)),64))]),e("p",_i,n(a(t)("ai.assistant.config.localeHint")),1)]),e("div",{ref_key:"presetQuestionsRef",ref:I},[e("label",wi,n(a(t)("ai.assistant.config.presetQuestions")),1),e("div",$i,[(o(!0),i(oe,null,ue(L.value.presetQuestions,(D,C)=>(o(),i("div",{key:C,class:"flex items-center gap-2"},[p(le,{modelValue:L.value.presetQuestions[C],"onUpdate:modelValue":F=>L.value.presetQuestions[C]=F,class:"min-w-0 flex-1",size:"sm",disabled:l.readonly},null,8,["modelValue","onUpdate:modelValue","disabled"]),l.readonly?P("",!0):(o(),Q(te,{key:0,color:"error",variant:"ghost",icon:"i-heroicons-trash",size:"xs",class:"shrink-0",onClick:F=>j(C)},null,8,["onClick"]))]))),128)),l.readonly?P("",!0):(o(),i("div",Ci,[p(le,{modelValue:b.value,"onUpdate:modelValue":U[4]||(U[4]=D=>b.value=D),placeholder:a(t)("ai.assistant.config.addQuestion"),class:"min-w-0 flex-1",size:"sm",onKeyup:Ke(B,["enter"])},null,8,["modelValue","placeholder"]),p(te,{color:"primary",variant:"soft",icon:"i-heroicons-plus",size:"xs",class:"shrink-0",onClick:B})]))])],512)],512),[[nt,$.value==="basic"]]),Be(e("div",Si,[e("div",null,[e("h3",Ti,n(a(t)("ai.assistant.config.coreTools")),1),e("p",Ii,n(a(t)("ai.assistant.config.coreToolsHint")),1),e("div",Mi,[(o(!0),i(oe,null,ue(E.value,D=>(o(),i("label",{key:D.name,class:"flex items-start gap-2 rounded-md border border-gray-200 bg-gray-50/50 px-2.5 py-2 opacity-70 dark:border-gray-700 dark:bg-gray-800/30"},[U[6]||(U[6]=e("input",{type:"checkbox",checked:"",disabled:"",class:"mt-0.5 h-3.5 w-3.5 shrink-0 rounded border-gray-300 text-gray-400"},null,-1)),e("div",Li,[e("div",Di,n(D.name),1),e("div",Ai,n(D.description),1)])]))),128))])]),e("div",null,[e("div",qi,[e("h3",Ri,n(a(t)("ai.assistant.config.analysisTools")),1),l.readonly?P("",!0):(o(),i("div",Ei,[e("button",{class:"text-[10px] text-primary-500 hover:text-primary-600",onClick:W},n(a(t)("ai.assistant.config.selectAll")),1),U[7]||(U[7]=e("span",{class:"text-[10px] text-gray-300 dark:text-gray-600"},"|",-1)),e("button",{class:"text-[10px] text-primary-500 hover:text-primary-600",onClick:ee},n(a(t)("ai.assistant.config.deselectAll")),1)]))]),e("p",zi,n(a(t)("ai.assistant.config.analysisToolsHint")),1),e("div",Pi,[(o(!0),i(oe,null,ue(M.value,D=>(o(),i("label",{key:D.name,class:ae(["flex cursor-pointer items-start gap-2 rounded-md border px-2.5 py-2 transition-colors",T(D.name)?"border-primary-200 bg-primary-50/50 dark:border-primary-800 dark:bg-primary-950/20":"border-gray-200 dark:border-gray-700"])},[e("input",{type:"checkbox",checked:T(D.name),disabled:l.readonly,class:"mt-0.5 h-3.5 w-3.5 shrink-0 rounded border-gray-300 text-primary-600 focus:ring-primary-500",onChange:C=>_(D.name)},null,40,ji),e("div",Fi,[e("div",Bi,n(D.name),1),e("div",Ui,n(D.description),1)])],2))),128))])])],512),[[nt,$.value==="tools"]])]),e("div",Vi,[e("div",null,[!l.readonly&&!h.value&&v.value?.builtinId?(o(),Q(te,{key:0,variant:"outline",color:"warning",loading:g.value,onClick:q},{default:O(()=>[ne(n(a(t)("ai.assistant.config.resetDefault")),1)]),_:1},8,["loading"])):P("",!0)]),e("div",Oi,[p(te,{variant:"ghost",onClick:ve},{default:O(()=>[ne(n(l.readonly?a(t)("common.close"):a(t)("common.cancel")),1)]),_:1}),l.readonly?P("",!0):(o(),Q(te,{key:0,color:"primary",loading:g.value,onClick:A},{default:O(()=>[ne(n(h.value?a(t)("ai.assistant.config.create"):a(t)("common.save")),1)]),_:1},8,["loading"]))])])],64)):P("",!0)])]),_:1},8,["open"])}}}),Yi={class:"p-6"},Hi={class:"mb-4 flex items-center justify-between"},Wi={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},Ki={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},Qi={key:0,class:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary-100 px-1 text-[10px] text-primary-600 dark:bg-primary-900/30 dark:text-primary-400"},Gi={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},Ji={class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},Xi={class:"min-w-0 flex-1"},Zi={class:"flex items-center gap-2"},ec={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},tc={key:0,class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},ac={key:1,class:"inline-flex shrink-0 items-center rounded-full bg-green-100 px-2 py-0.5 text-[10px] font-medium text-green-700 dark:bg-green-900/30 dark:text-green-400"},sc={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},oc={class:"flex shrink-0 items-center gap-1.5"},nc=["title","onClick"],rc=["title","onClick"],lc=["title","onClick"],ic={key:0,class:"py-12 text-center text-sm text-gray-400"},cc={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},dc={key:0,class:"py-12 text-center text-sm text-gray-400"},uc={key:1,class:"py-12 text-center"},mc={class:"text-sm text-gray-500 dark:text-gray-400"},gc={key:2,class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},pc={class:"min-w-0 flex-1"},vc={class:"flex items-center gap-2"},hc={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},yc={key:0,class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},fc={key:1,class:"inline-flex shrink-0 items-center rounded-full bg-green-100 px-2 py-0.5 text-[10px] font-medium text-green-700 dark:bg-green-900/30 dark:text-green-400"},xc={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},bc={class:"flex shrink-0 items-center gap-2"},kc=["disabled","onClick"],_c={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},wc=["disabled","onClick"],$c=["title","onClick"],Cc={key:3,class:"py-12 text-center text-sm text-gray-400"},Sc=pe({__name:"AssistantMarketModal",props:{open:{type:Boolean}},emits:["update:open","configure","view-config","create"],setup(l,{emit:s}){const{t,locale:c}=he(),r=Ye(),m=l,u=s,d=ut(),{assistants:g,cloudCatalogWithStatus:v,cloudLoading:h,cloudError:$}=Ze(d),x=f("local"),S=k(()=>{const _=c.value;return[...g.value].filter(T=>!T.supportedLocales?.length||T.supportedLocales.some(W=>_.startsWith(W))).sort((T,W)=>T.name.localeCompare(W.name))}),E=k(()=>[...v.value].sort((_,T)=>_.name.localeCompare(T.name))),M=f(new Set);me(()=>[m.open,x.value],([_,T])=>{_&&T==="market"&&d.fetchCloudCatalog(c.value)},{immediate:!0});function L(_){return _==="general_cn"||_==="general_en"||_==="general_ja"}function b(_){u("configure",_)}async function I(_){L(_)||await d.deleteAssistant(_)}async function R(_){await d.duplicateAssistant(_)}function w(){u("create")}async function y(_){if(!M.value.has(_.id)){M.value=new Set([...M.value,_.id]);try{const T=await d.importFromCloud(_);T.success?r.success(t("ai.assistant.market.importSuccess")):r.fail(t("ai.assistant.market.importFailed"),{description:T.error})}finally{const T=new Set(M.value);T.delete(_.id),M.value=T}}}async function A(_){if(!M.value.has(_.id)){M.value=new Set([...M.value,_.id]);try{const T=await d.deleteAssistant(_.id);if(!T.success){r.fail(t("ai.assistant.market.importFailed"),{description:T.error});return}const W=await d.importFromCloud(_);W.success?r.success(t("ai.assistant.market.importSuccess")):r.fail(t("ai.assistant.market.importFailed"),{description:W.error})}finally{const T=new Set(M.value);T.delete(_.id),M.value=T}}}function q(_){u("view-config",_)}function B(){d.fetchCloudCatalog(c.value)}function j(_){return _?.length?_.map(W=>t(W==="group"?"ai.assistant.config.chatTypeGroup":"ai.assistant.config.chatTypePrivate")).join(" / "):null}return(_,T)=>{const W=ye,ee=Fe;return o(),Q(ee,{open:l.open,ui:{content:"sm:max-w-xl z-50"},"onUpdate:open":T[3]||(T[3]=Y=>u("update:open",Y))},{content:O(()=>[e("div",Yi,[e("div",Hi,[e("h2",Wi,n(a(t)("ai.assistant.market.title")),1),e("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:T[0]||(T[0]=Y=>u("update:open",!1))},[p(W,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),e("div",Ki,[e("button",{class:ae(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",x.value==="local"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:T[1]||(T[1]=Y=>x.value="local")},[ne(n(a(t)("ai.assistant.market.tabs.local"))+" ",1),S.value.length?(o(),i("span",Qi,n(S.value.length),1)):P("",!0)],2),e("button",{class:ae(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",x.value==="market"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:T[2]||(T[2]=Y=>x.value="market")},n(a(t)("ai.assistant.market.tabs.market")),3)]),Be(e("div",null,[e("p",Gi,n(a(t)("ai.assistant.market.localHint")),1),e("div",Ji,[(o(!0),i(oe,null,ue(S.value,Y=>(o(),i("div",{key:Y.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[e("div",Xi,[e("div",Zi,[e("h3",ec,n(Y.name),1),j(Y.applicableChatTypes)?(o(),i("span",tc,n(j(Y.applicableChatTypes)),1)):P("",!0),L(Y.id)?(o(),i("span",ac,n(a(t)("ai.assistant.market.default")),1)):P("",!0)]),e("p",sc,n(Y.systemPrompt),1)]),e("div",oc,[e("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:a(t)("common.edit"),onClick:Pe(ce=>b(Y.id),["stop"])},[p(W,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})],8,nc),e("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:a(t)("ai.assistant.market.duplicate"),onClick:Pe(ce=>R(Y.id),["stop"])},[p(W,{name:"i-heroicons-document-duplicate",class:"h-4 w-4"})],8,rc),L(Y.id)?P("",!0):(o(),i("button",{key:0,class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500 dark:hover:bg-red-900/20 dark:hover:text-red-400",title:a(t)("common.delete"),onClick:Pe(ce=>I(Y.id),["stop"])},[p(W,{name:"i-heroicons-trash",class:"h-4 w-4"})],8,lc))])]))),128))]),e("button",{type:"button",class:"mt-3 flex w-full items-center justify-center gap-1.5 rounded-xl border-2 border-dashed border-gray-300 py-4 text-sm text-gray-500 transition-colors hover:border-primary-400 hover:text-primary-600 dark:border-gray-600 dark:text-gray-400 dark:hover:border-primary-500 dark:hover:text-primary-400",onClick:w},[p(W,{name:"i-heroicons-plus",class:"h-4 w-4"}),ne(" "+n(a(t)("ai.assistant.market.addAssistant")),1)]),S.value.length===0?(o(),i("div",ic,n(a(t)("ai.assistant.market.noLocal")),1)):P("",!0)],512),[[nt,x.value==="local"]]),Be(e("div",null,[e("p",cc,n(a(t)("ai.assistant.market.marketHint")),1),a(h)?(o(),i("div",dc,n(a(t)("ai.assistant.market.loading")),1)):a($)?(o(),i("div",uc,[e("p",mc,n(a(t)("ai.assistant.market.loadFailed")),1),e("button",{type:"button",class:"mt-3 rounded-lg bg-primary-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-600",onClick:B},n(a(t)("ai.assistant.market.retry")),1)])):(o(),i("div",gc,[(o(!0),i(oe,null,ue(E.value,Y=>(o(),i("div",{key:Y.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[e("div",pc,[e("div",vc,[e("h3",hc,n(Y.name),1),j(Y.applicableChatTypes)?(o(),i("span",yc,n(j(Y.applicableChatTypes)),1)):P("",!0),L(Y.id)?(o(),i("span",fc,n(a(t)("ai.assistant.market.default")),1)):P("",!0)]),e("p",xc,n(Y.description),1)]),e("div",bc,[Y.imported?(o(),i(oe,{key:1},[e("span",_c,n(a(t)("ai.assistant.market.imported")),1),e("button",{class:"rounded-lg px-3 py-1.5 text-xs font-medium text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-300 disabled:opacity-50",disabled:M.value.has(Y.id),onClick:ce=>A(Y)},n(M.value.has(Y.id)?a(t)("ai.assistant.market.importing"):a(t)("ai.assistant.market.reimport")),9,wc)],64)):(o(),i("button",{key:0,class:"rounded-lg bg-primary-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50",disabled:M.value.has(Y.id),onClick:ce=>y(Y)},n(M.value.has(Y.id)?a(t)("ai.assistant.market.importing"):a(t)("ai.assistant.market.import")),9,kc)),Y.imported?(o(),i("button",{key:2,class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:a(t)("ai.assistant.market.viewConfig"),onClick:Pe(ce=>q(Y.id),["stop"])},[p(W,{name:"i-heroicons-eye",class:"h-4 w-4"})],8,$c)):P("",!0)])]))),128))])),!a(h)&&!a($)&&E.value.length===0?(o(),i("div",Cc,n(a(t)("ai.assistant.market.noCatalog")),1)):P("",!0)],512),[[nt,x.value==="market"]])])]),_:1},8,["open"])}}}),Tc={class:"p-6"},Ic={class:"mb-4 flex items-center justify-between"},Mc={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},Lc={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},Dc={key:0,class:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary-100 px-1 text-[10px] text-primary-600 dark:bg-primary-900/30 dark:text-primary-400"},Ac={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},qc={class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},Rc={class:"min-w-0 flex-1"},Ec={class:"flex items-center gap-2"},zc={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Pc={class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},jc={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},Fc={key:0,class:"mt-1.5 flex flex-wrap gap-1"},Bc={class:"flex shrink-0 items-center gap-1.5"},Uc=["title","onClick"],Vc=["title","onClick"],Oc={key:0,class:"py-12 text-center text-sm text-gray-400"},Nc={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},Yc={key:0,class:"py-12 text-center text-sm text-gray-400"},Hc={key:1,class:"py-12 text-center"},Wc={class:"text-sm text-gray-500 dark:text-gray-400"},Kc={key:2,class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},Qc={class:"min-w-0 flex-1"},Gc={class:"flex items-center gap-2"},Jc={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Xc={class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},Zc={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},ed={key:0,class:"mt-1.5 flex flex-wrap gap-1"},td={class:"flex shrink-0 items-center gap-2"},ad=["disabled","onClick"],sd={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},od=["disabled","onClick"],nd={key:3,class:"py-12 text-center text-sm text-gray-400"},rd=pe({__name:"SkillMarketModal",props:{open:{type:Boolean}},emits:["update:open","configure","create"],setup(l,{emit:s}){const{t,locale:c}=he(),r=Ye(),m=l,u=s,d=lt(),{skills:g,cloudCatalogWithStatus:v,cloudLoading:h,cloudError:$}=Ze(d),x=f("local"),S=f(new Set);Me(()=>{d.setFilterContext("group",c.value)}),me(()=>[m.open,x.value],([q,B])=>{q&&B==="market"&&(d.setFilterContext("group",c.value),d.fetchCloudCatalog())},{immediate:!0});const E=k(()=>[...g.value].sort((q,B)=>q.name.localeCompare(B.name))),M=k(()=>[...v.value].sort((q,B)=>q.name.localeCompare(B.name)));function L(q){return t(q==="group"?"ai.skill.config.chatScopeGroup":q==="private"?"ai.skill.config.chatScopePrivate":"ai.skill.config.chatScopeAll")}function b(q){u("configure",q)}async function I(q){await d.deleteSkill(q)}function R(){u("create")}async function w(q){if(!S.value.has(q.id)){S.value=new Set([...S.value,q.id]);try{const B=await d.importFromCloud(q);B.success?r.success(t("ai.skill.market.importSuccess")):r.fail(t("ai.skill.market.importFailed"),{description:B.error})}finally{const B=new Set(S.value);B.delete(q.id),S.value=B}}}async function y(q){if(!S.value.has(q.id)){S.value=new Set([...S.value,q.id]);try{const B=await d.deleteSkill(q.id);if(!B.success){r.fail(t("ai.skill.market.importFailed"),{description:B.error});return}const j=await d.importFromCloud(q);j.success?r.success(t("ai.skill.market.importSuccess")):r.fail(t("ai.skill.market.importFailed"),{description:j.error})}finally{const B=new Set(S.value);B.delete(q.id),S.value=B}}}function A(){d.fetchCloudCatalog()}return(q,B)=>{const j=ye,_=Fe;return o(),Q(_,{open:l.open,ui:{content:"sm:max-w-xl z-50"},"onUpdate:open":B[3]||(B[3]=T=>u("update:open",T))},{content:O(()=>[e("div",Tc,[e("div",Ic,[e("h2",Mc,n(a(t)("ai.skill.market.title")),1),e("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:B[0]||(B[0]=T=>u("update:open",!1))},[p(j,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),e("div",Lc,[e("button",{class:ae(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",x.value==="local"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:B[1]||(B[1]=T=>x.value="local")},[ne(n(a(t)("ai.skill.market.tabs.local"))+" ",1),a(g).length?(o(),i("span",Dc,n(a(g).length),1)):P("",!0)],2),e("button",{class:ae(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",x.value==="market"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:B[2]||(B[2]=T=>x.value="market")},n(a(t)("ai.skill.market.tabs.market")),3)]),Be(e("div",null,[e("p",Ac,n(a(t)("ai.skill.market.localHint")),1),e("div",qc,[(o(!0),i(oe,null,ue(E.value,T=>(o(),i("div",{key:T.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[e("div",Rc,[e("div",Ec,[e("h3",zc,n(T.name),1),e("span",Pc,n(L(T.chatScope)),1)]),e("p",jc,n(T.description),1),T.tags.length?(o(),i("div",Fc,[(o(!0),i(oe,null,ue(T.tags,W=>(o(),i("span",{key:W,class:"rounded-full bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-500 dark:bg-gray-700 dark:text-gray-400"},n(W),1))),128))])):P("",!0)]),e("div",Bc,[e("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:a(t)("common.edit"),onClick:Pe(W=>b(T.id),["stop"])},[p(j,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})],8,Uc),e("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500 dark:hover:bg-red-900/20 dark:hover:text-red-400",title:a(t)("common.delete"),onClick:Pe(W=>I(T.id),["stop"])},[p(j,{name:"i-heroicons-trash",class:"h-4 w-4"})],8,Vc)])]))),128))]),e("button",{type:"button",class:"mt-3 flex w-full items-center justify-center gap-1.5 rounded-xl border-2 border-dashed border-gray-300 py-4 text-sm text-gray-500 transition-colors hover:border-primary-400 hover:text-primary-600 dark:border-gray-600 dark:text-gray-400 dark:hover:border-primary-500 dark:hover:text-primary-400",onClick:R},[p(j,{name:"i-heroicons-plus",class:"h-4 w-4"}),ne(" "+n(a(t)("ai.skill.market.addSkill")),1)]),E.value.length===0?(o(),i("div",Oc,n(a(t)("ai.skill.market.noLocal")),1)):P("",!0)],512),[[nt,x.value==="local"]]),Be(e("div",null,[e("p",Nc,n(a(t)("ai.skill.market.marketHint")),1),a(h)?(o(),i("div",Yc,n(a(t)("ai.skill.market.loading")),1)):a($)?(o(),i("div",Hc,[e("p",Wc,n(a(t)("ai.skill.market.loadFailed")),1),e("button",{type:"button",class:"mt-3 rounded-lg bg-primary-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-600",onClick:A},n(a(t)("ai.skill.market.retry")),1)])):(o(),i("div",Kc,[(o(!0),i(oe,null,ue(M.value,T=>(o(),i("div",{key:T.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[e("div",Qc,[e("div",Gc,[e("h3",Jc,n(T.name),1),e("span",Xc,n(L(T.chatScope)),1)]),e("p",Zc,n(T.description),1),T.tags?.length?(o(),i("div",ed,[(o(!0),i(oe,null,ue(T.tags,W=>(o(),i("span",{key:W,class:"rounded-full bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-500 dark:bg-gray-700 dark:text-gray-400"},n(W),1))),128))])):P("",!0)]),e("div",td,[T.imported?(o(),i(oe,{key:1},[e("span",sd,n(a(t)("ai.skill.market.imported")),1),e("button",{class:"rounded-lg px-3 py-1.5 text-xs font-medium text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-300 disabled:opacity-50",disabled:S.value.has(T.id),onClick:W=>y(T)},n(S.value.has(T.id)?a(t)("ai.skill.market.importing"):a(t)("ai.skill.market.reimport")),9,od)],64)):(o(),i("button",{key:0,class:"rounded-lg bg-primary-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50",disabled:S.value.has(T.id),onClick:W=>w(T)},n(S.value.has(T.id)?a(t)("ai.skill.market.importing"):a(t)("ai.skill.market.import")),9,ad))])]))),128))])),!a(h)&&!a($)&&M.value.length===0?(o(),i("div",nd,n(a(t)("ai.skill.market.noCatalog")),1)):P("",!0)],512),[[nt,x.value==="market"]])])]),_:1},8,["open"])}}}),ld={class:"p-6"},id={class:"mb-4 flex items-center justify-between"},cd={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},dd={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},ud={key:0,class:"flex h-64 items-center justify-center text-gray-400"},md={class:"mt-4 flex justify-end gap-2"},gd=["disabled"],pd=`---
|
|
36
|
-
name: ""
|
|
37
|
-
description: ""
|
|
38
|
-
tags: []
|
|
39
|
-
chatScope: all
|
|
40
|
-
tools: []
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
`,vd=pe({__name:"SkillConfigModal",props:{open:{type:Boolean},skillId:{}},emits:["update:open","saved","created"],setup(l,{emit:s}){const{t}=he(),c=l,r=s,m=lt(),u=f(""),d=f(!1),g=f(!1),v=f(!1);me(()=>[c.open,c.skillId],async([$,x])=>{if($){if(!x){v.value=!0,u.value=pd;return}v.value=!1,d.value=!0;try{const S=await m.getSkillConfig(x);if(S){const E=["---",`name: "${S.name}"`,`description: "${S.description}"`,`tags: [${S.tags.map(M=>`"${M}"`).join(", ")}]`,`chatScope: ${S.chatScope}`,S.tools.length?`tools: [${S.tools.map(M=>`"${M}"`).join(", ")}]`:"tools: []",S.builtinId?`builtinId: ${S.builtinId}`:"","---","",S.prompt].filter(Boolean).join(`
|
|
44
|
-
`);u.value=E}}finally{d.value=!1}}},{immediate:!0});async function h(){if(u.value.trim()){g.value=!0;try{if(v.value){const $=await m.createSkill(u.value);$.success&&$.id&&(r("created",$.id),r("update:open",!1))}else c.skillId&&(await m.updateSkill(c.skillId,u.value)).success&&(r("saved"),r("update:open",!1))}finally{g.value=!1}}}return($,x)=>{const S=ye,E=Fe;return o(),Q(E,{open:l.open,ui:{content:"sm:max-w-2xl z-50"},"onUpdate:open":x[3]||(x[3]=M=>r("update:open",M))},{content:O(()=>[e("div",ld,[e("div",id,[e("h2",cd,n(v.value?a(t)("ai.skill.config.createTitle"):a(t)("ai.skill.config.editTitle")),1),e("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:x[0]||(x[0]=M=>r("update:open",!1))},[p(S,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),e("p",dd,n(a(t)("ai.skill.config.rawEditorHint")),1),d.value?(o(),i("div",ud,[p(S,{name:"i-heroicons-arrow-path",class:"mr-2 h-5 w-5 animate-spin"})])):Be((o(),i("textarea",{key:1,"onUpdate:modelValue":x[1]||(x[1]=M=>u.value=M),class:"h-[400px] w-full resize-none rounded-lg border border-gray-300 bg-gray-50 p-3 font-mono text-xs text-gray-900 focus:border-primary-500 focus:ring-1 focus:ring-primary-500 dark:border-gray-600 dark:bg-gray-900 dark:text-gray-100",spellcheck:"false"},null,512)),[[at,u.value]]),e("div",md,[e("button",{class:"rounded-lg px-4 py-2 text-sm text-gray-500 transition-colors hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800",onClick:x[2]||(x[2]=M=>r("update:open",!1))},n(a(t)("common.cancel")),1),e("button",{class:"rounded-lg bg-primary-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50",disabled:g.value||!u.value.trim(),onClick:h},n(v.value?a(t)("ai.skill.config.create"):a(t)("ai.skill.config.save")),9,gd)])])]),_:1},8,["open"])}}}),hd={key:0,class:"relative"},yd={class:"relative flex flex-nowrap gap-2"},fd=["disabled"],xd=["disabled"],bd={class:"inline-flex items-center gap-1"},kd={key:0,class:"absolute left-0 bottom-full z-20 mb-2 w-[320px] max-w-[calc(100vw-3rem)]"},_d={class:"mb-1.5 flex justify-start"},wd={class:"flex flex-wrap gap-2"},$d=["disabled","onClick"],qt="rounded-full ring-1 ring-inset ring-gray-200/80 bg-white/60 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.05)] backdrop-blur-md px-3 py-1.5 text-xs text-gray-600 transition-all duration-300 hover:-translate-y-[1px] hover:ring-primary-300 hover:bg-white/90 hover:text-primary-600 hover:shadow-[0_4px_12px_-2px_rgba(0,0,0,0.08)] disabled:cursor-not-allowed disabled:opacity-50 dark:ring-gray-700/60 dark:bg-gray-800/60 dark:text-gray-300 dark:hover:ring-primary-500/50 dark:hover:bg-gray-800/90 dark:hover:text-primary-400",Cd=pe({__name:"PresetQuestions",props:{questions:{},disabled:{type:Boolean},leadingActionLabel:{}},emits:["select","leadingAction","editQuestions"],setup(l,{emit:s}){const{t}=he(),c=l,r=s,m=f(!1);let u=null;function d($){m.value=!1,r("select",$)}function g(){c.disabled||c.questions.length===0||(u&&(clearTimeout(u),u=null),m.value=!0)}function v(){u=setTimeout(()=>{m.value=!1},150)}function h(){m.value=!1,r("editQuestions")}return Ct(()=>{u&&clearTimeout(u)}),($,x)=>{const S=ye;return l.leadingActionLabel||l.questions.length>0?(o(),i("div",hd,[e("div",yd,[l.leadingActionLabel?(o(),i("button",{key:0,class:ae(qt),disabled:c.disabled,onClick:x[0]||(x[0]=E=>r("leadingAction"))},n(l.leadingActionLabel),9,fd)):P("",!0),l.questions.length>0?(o(),i("div",{key:1,class:"relative shrink-0",onMouseenter:g,onMouseleave:v},[e("button",{class:ae([qt,m.value?"ring-primary-300 bg-white/90 text-primary-600 dark:ring-primary-500/50 dark:bg-gray-800/90 dark:text-primary-400":""]),disabled:c.disabled},[e("span",bd,[p(S,{name:"i-heroicons-chat-bubble-left-ellipsis",class:"h-3.5 w-3.5"}),ne(" "+n(a(t)("ai.chat.input.quickAsk")),1)])],10,xd),p(st,{"enter-active-class":"transition duration-200 ease-out","enter-from-class":"opacity-0 translate-y-2","enter-to-class":"opacity-100 translate-y-0","leave-active-class":"transition duration-150 ease-in","leave-from-class":"opacity-100 translate-y-0","leave-to-class":"opacity-0 translate-y-2"},{default:O(()=>[m.value?(o(),i("div",kd,[e("div",_d,[e("button",{class:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] text-gray-400 transition-colors hover:text-primary-500 dark:text-gray-500 dark:hover:text-primary-400",onClick:h},[p(S,{name:"i-heroicons-pencil-square",class:"h-3 w-3"}),ne(" "+n(a(t)("ai.chat.input.editQuickAsk")),1)])]),e("div",wd,[(o(!0),i(oe,null,ue(l.questions,(E,M)=>(o(),i("button",{key:M,class:ae(qt),disabled:c.disabled,onClick:L=>d(E)},n(E),9,$d))),128))])])):P("",!0)]),_:1})],32)):P("",!0)])])):P("",!0)}}}),Sd=30;function Td(l,s){const t=f(null),c=f(!0),r=f(!1);function m(v=!1){setTimeout(()=>{t.value&&(v||c.value)&&(t.value.scrollTop=t.value.scrollHeight,c.value=!0,r.value=!1)},100)}function u(v){v.deltaY<0&&s.value&&(c.value=!1,r.value=!0)}function d(){if(!t.value)return;const{scrollTop:v,scrollHeight:h,clientHeight:$}=t.value;h-v-$<Sd&&(c.value=!0,r.value=!1)}function g(){m(!0)}return me(()=>{const v=l.value[l.value.length-1];return[l.value.length,v?.content,v?.contentBlocks?.length]},()=>m()),Me(()=>{t.value&&(t.value.addEventListener("scroll",d),t.value.addEventListener("wheel",u,{passive:!0})),l.value.length>0&&m(!0)}),Ct(()=>{t.value&&(t.value.removeEventListener("scroll",d),t.value.removeEventListener("wheel",u))}),{messagesContainer:t,showScrollToBottom:r,scrollToBottom:m,handleScrollToBottom:g}}function Id(){const l=ut(),s=lt(),t=f(!1),c=f(null),r=f(!1),m=f(!1),u=f(!1),d=f(!1),g=f(null);function v(y){c.value=y,r.value=!1,t.value=!0}function h(){m.value=!0}function $(y){c.value=y,r.value=!1,t.value=!0}function x(y){c.value=y,r.value=!0,t.value=!0}function S(){c.value=null,r.value=!1,t.value=!0}async function E(y){await l.loadAssistants(),await l.loadBuiltinCatalog()}async function M(){await l.loadAssistants()}function L(){u.value=!0}function b(y){g.value=y,d.value=!0}function I(){g.value=null,d.value=!0}async function R(){await s.loadSkills()}async function w(y){await s.loadSkills(),await s.loadBuiltinCatalog()}return{configModalVisible:t,configModalAssistantId:c,configModalReadonly:r,marketModalVisible:m,handleConfigureAssistant:v,handleOpenMarket:h,handleMarketConfigure:$,handleMarketViewConfig:x,handleCreateAssistant:S,handleAssistantCreated:E,handleAssistantConfigSaved:M,skillMarketModalVisible:u,skillConfigModalVisible:d,skillConfigModalSkillId:g,handleOpenSkillMarket:L,handleSkillMarketConfigure:b,handleCreateSkill:I,handleSkillConfigSaved:R,handleSkillCreated:w}}function Md(l){const s=[];let t=null;for(const c of l)c.role==="user"?(t&&s.push({user:t,assistant:null,standalone:null,id:t.id}),t=c):c.role==="assistant"?(s.push({user:t,assistant:c,standalone:null,id:t?.id||c.id}),t=null):(t&&(s.push({user:t,assistant:null,standalone:null,id:t.id}),t=null),s.push({user:null,assistant:null,standalone:c,id:c.id}));return t&&s.push({user:t,assistant:null,standalone:null,id:t.id}),s}const Ld={class:"main-content flex h-full overflow-hidden"},Dd={class:"flex h-full flex-1 overflow-hidden"},Ad={class:"flex h-full flex-1"},qd={class:"relative flex min-w-[480px] flex-1 flex-col overflow-hidden"},Rd={key:0,class:"flex items-center gap-1.5 px-3 py-1.5"},Ed=["disabled"],zd={key:0,class:"flex w-full flex-col items-center justify-center animate-fade-in"},Pd={key:0,class:"mb-3 text-center text-2xl font-semibold tracking-tight text-gray-800 dark:text-gray-100"},jd={class:"text-primary-600 dark:text-primary-400"},Fd={key:1,class:"relative mb-8 w-full max-w-lg"},Bd={class:"flex w-full justify-center"},Ud={key:1,class:"qa-pair space-y-6 pb-4"},Vd={key:1,class:"px-4 pb-2"},Od={class:"mx-auto max-w-3xl"},Nd={class:"px-4 pb-2"},Yd={class:"mx-auto max-w-[740px]"},Hd={key:0,class:"w-80 shrink-0 border-l border-gray-200 bg-gray-50/50 p-4 dark:border-gray-800 dark:bg-gray-900/50"},Wd=pe({__name:"ChatExplorer",props:{sessionId:{},sessionName:{},timeFilter:{},chatType:{}},setup(l,{expose:s}){const{t}=he(),c=Ye(),r=$t(),m=ut(),u=lt(),d=l,{messages:g,sourceMessages:v,currentKeywords:h,isLoadingSource:$,isAIThinking:x,currentAIChatId:S,currentToolStatus:E,toolsUsedInCurrentRound:M,sessionTokenUsage:L,agentStatus:b,selectedAssistantId:I,sendMessage:R,editMessageAndRegenerate:w,loadAIChat:y,startNewAIChat:A,loadMoreSourceMessages:q,updateMaxMessages:B,stopGeneration:j,selectAssistantForSession:_}=ss(d.sessionId,d.sessionName,d.timeFilter,d.chatType??"group",r.locale),T=Td(g,x),{showScrollToBottom:W,scrollToBottom:ee,handleScrollToBottom:Y}=T,{configModalVisible:ce,configModalAssistantId:ve,configModalReadonly:H,marketModalVisible:U,skillMarketModalVisible:te,skillConfigModalVisible:se,skillConfigModalSkillId:le,handleConfigureAssistant:K,handleOpenMarket:N,handleMarketConfigure:D,handleMarketViewConfig:C,handleCreateAssistant:F,handleAssistantCreated:J,handleAssistantConfigSaved:G,handleOpenSkillMarket:z,handleSkillMarketConfigure:Z,handleCreateSkill:ge,handleSkillConfigSaved:ie,handleSkillCreated:xe}=Id(),Ie=wt(),De=f(0);me(()=>S.value,async _e=>{if(!_e){De.value=0;return}try{const we=await je().estimateContextTokens(_e);we.success&&(De.value=we.tokens)}catch{De.value=0}},{immediate:!0});const $e=k(()=>m.selectedAssistant?.presetQuestions??[]),re=k(()=>d.chatType??"group"),de=f(!1),Te=f(!1),Re=f(!0),tt=f(void 0),He=f(null),Qe=f(null),V=k(()=>Md(g.value));async function X(){Re.value=!0;try{Te.value=await Nt().hasConfig()}catch(_e){console.error("检查 LLM 配置失败:",_e),Te.value=!1}finally{Re.value=!1}}async function Ce(){await X(),Te.value&&await B()}s({refreshConfig:Ce});const ke=k(()=>{const _e=m.selectedAssistant;if(!_e)return{name:"",preview:""};const we=_e.systemPrompt.replace(/#{1,6}\s+[^\n]*/g,"").replace(/\n+/g," ").replace(/\s+/g," ").trim();return{name:_e.name,preview:we}}),Ae=k(()=>!!I.value&&g.value.length===0&&!x.value);function Ee(){c.warn(t("ai.chat.backgroundTask.runningTitle"),{description:t("ai.chat.backgroundTask.runningDescription")})}function We(){c.warn(t("ai.chat.backgroundTask.blockedAction"))}function xt(_e){if(_e!==I.value){if(!_(_e)){We();return}u.activateSkill(null),A()}}async function fa(_e){const we=await R(_e);!we.success&&we.reason==="busy"&&Ee()}function xa(){const _e=m.selectedAssistant?.id;_e&&(tt.value="presetQuestions",K(_e))}function ba(_e){ce.value=_e,_e||(tt.value=void 0)}function ka(){Qe.value?.openSkillSelector()}function _a(){ee(!0)}async function wa(_e){const we=await R(_e.content,{mentionedMembers:_e.mentionedMembers});if(!we.success){we.reason==="busy"&&Ee();return}ee(!0),He.value?.refresh()}async function $a(_e){const we=await w(_e.messageId,_e.content,{overwriteSubsequent:_e.overwriteSubsequent});if(!we.success){we.reason==="busy"&&Ee();return}ee(!0),He.value?.refresh()}async function Ca(_e){if(S.value)try{const we=await je().forkAIChat(S.value,_e);await y(we.id),He.value?.refresh(),ee(!0),c.success(t("ai.chat.fork.success"))}catch(we){c.fail(t("ai.chat.fork.failed"),{description:String(we)})}}function Sa(){de.value=!de.value}async function Ta(){await q()}async function Ia(_e){await y(_e),ee(!0)}function Ma(){if(x.value){We();return}A()}function La(_e){S.value===_e&&A()}function Da(){j()}return X(),B(),me(()=>Ie.aiConfigVersion,async()=>{await Ce()}),(_e,we)=>{const Mt=ye,Aa=gt;return o(),i("div",Ld,[p(Qs,{ref_key:"conversationListRef",ref:He,"session-id":l.sessionId,"active-id":a(S),disabled:a(x),class:"h-full shrink-0",onSelect:Ia,onCreate:Ma,onDelete:La},null,8,["session-id","active-id","disabled"]),e("div",Dd,[e("div",Ad,[e("div",qd,[a(g).length>0||a(x)?(o(),i("div",Rd,[e("button",{class:ae(["flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",{"cursor-not-allowed opacity-50":a(x)||!a(m).selectedAssistant?.id}]),disabled:a(x)||!a(m).selectedAssistant?.id,onClick:we[0]||(we[0]=be=>a(K)(a(m).selectedAssistant.id))},[p(Mt,{name:"i-heroicons-sparkles",class:"h-3.5 w-3.5"}),e("span",null,n(a(m).selectedAssistant?.name||a(t)("ai.assistant.fallbackName")),1)],10,Ed)])):P("",!0),e("div",{ref:a(T).messagesContainer,class:ae(["relative min-h-0 flex-1 overflow-x-hidden overflow-y-auto p-4",{"p-0!":a(g).length===0&&!a(x)}])},[e("div",{class:ae(["mx-auto max-w-3xl space-y-6",{"flex min-h-full flex-col justify-center px-4 pb-32 pt-4 space-y-0!":a(g).length===0&&!a(x),"px-4":a(g).length>0||a(x)}])},[a(g).length===0&&!a(x)?(o(),i("div",zd,[ke.value.name?(o(),i("h2",Pd,[ne(n(a(t)("ai.assistant.selector.heroTitlePrefix","使用"))+" ",1),e("span",jd,n(ke.value.name),1),ne(" "+n(a(t)("ai.assistant.selector.heroTitleSuffix","开始对话")),1)])):P("",!0),Ae.value&&ke.value.name?(o(),i("div",Fd,[e("p",{class:"cursor-pointer pr-7 text-center text-sm leading-relaxed text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300 line-clamp-2",onClick:we[1]||(we[1]=be=>a(K)(a(m).selectedAssistant.id))},[p(Aa,{text:a(t)("ai.assistant.config.systemPrompt","系统设定"),popper:{placement:"top"}},{default:O(()=>[ne(n(ke.value.preview),1)]),_:1},8,["text"])]),e("button",{type:"button",class:"absolute bottom-0 right-0 rounded-md p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-200",onClick:we[2]||(we[2]=Pe(be=>a(K)(a(m).selectedAssistant.id),["stop"]))},[p(Mt,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})])])):P("",!0),e("div",Bd,[p(si,{"chat-type":re.value,locale:a(r).locale,"selected-id":a(I),onSelect:xt,onMarket:a(N)},null,8,["chat-type","locale","selected-id","onMarket"])])])):P("",!0),(o(!0),i(oe,null,ue(V.value,be=>(o(),i(oe,{key:be.id},[be.standalone?(o(),Q(At,{key:0,role:be.standalone.role,content:be.standalone.content,timestamp:be.standalone.timestamp},null,8,["role","content","timestamp"])):(o(),i("div",Ud,[be.user&&(be.user.role==="user"||be.user.content)?(o(),Q(At,{key:0,role:be.user.role,"message-id":be.user.id,content:be.user.content,timestamp:be.user.timestamp,"is-streaming":be.user.isStreaming,"content-blocks":be.user.contentBlocks,editable:!a(x),onEdit:$a},null,8,["role","message-id","content","timestamp","is-streaming","content-blocks","editable"])):P("",!0),be.assistant&&(be.assistant.content||be.assistant.contentBlocks&&be.assistant.contentBlocks.length>0)?(o(),Q(At,{key:1,role:be.assistant.role,"message-id":be.assistant.id,content:be.assistant.content,timestamp:be.assistant.timestamp,"is-streaming":be.assistant.isStreaming,"content-blocks":be.assistant.contentBlocks,"show-capture-button":!be.assistant.isStreaming,onFork:Ca},null,8,["role","message-id","content","timestamp","is-streaming","content-blocks","show-capture-button"])):P("",!0)]))],64))),128)),a(x)&&!a(g)[a(g).length-1]?.content&&!(a(g)[a(g).length-1]?.contentBlocks?.length??0)?(o(),Q(Tl,{key:1,"current-tool-status":a(E),"tools-used":a(M),"agent-status":a(b)},null,8,["current-tool-status","tools-used","agent-status"])):P("",!0)],2)],2),p(st,{name:"fade-up"},{default:O(()=>[a(W)?(o(),i("button",{key:0,class:"absolute bottom-20 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full bg-gray-800/90 px-3 py-1.5 text-xs text-white shadow-lg backdrop-blur-sm transition-all hover:bg-gray-700 dark:bg-gray-700/90 dark:hover:bg-gray-600",onClick:we[3]||(we[3]=(...be)=>a(Y)&&a(Y)(...be))},[p(Mt,{name:"i-heroicons-arrow-down",class:"h-3.5 w-3.5"}),e("span",null,n(a(t)("ai.chat.scrollToBottom")),1)])):P("",!0)]),_:1}),a(g).length===0&&!a(x)?(o(),i("div",Vd,[e("div",Od,[p(Cd,{questions:$e.value,"leading-action-label":a(t)("ai.chat.input.useSkill"),onSelect:fa,onLeadingAction:ka,onEditQuestions:xa},null,8,["questions","leading-action-label"])])])):P("",!0),e("div",Nd,[e("div",Yd,[p(gl,{ref_key:"chatInputRef",ref:Qe,"session-id":l.sessionId,disabled:a(x),status:a(x)?"streaming":"ready","chat-type":re.value,onSend:wa,onStop:Da,onManageSkills:a(z),onSkillActivated:_a},null,8,["session-id","disabled","status","chat-type","onManageSkills"]),p(Ql,{"session-token-usage":a(L),"agent-status":a(b),"current-ai-chat-id":a(S),"estimated-context-tokens":De.value},null,8,["session-token-usage","agent-status","current-ai-chat-id","estimated-context-tokens"])])])])]),p(st,{name:"slide-fade"},{default:O(()=>[a(v).length>0&&!de.value?(o(),i("div",Hd,[p(xo,{messages:a(v),keywords:a(h),"is-loading":a($),"is-collapsed":de.value,class:"h-full",onToggle:Sa,onLoadMore:Ta},null,8,["messages","keywords","is-loading","is-collapsed"])])):P("",!0)]),_:1})]),p(Ni,{open:a(ce),"assistant-id":a(ve),readonly:a(H),"scroll-to-section":tt.value,"onUpdate:open":ba,onSaved:a(G),onCreated:a(J)},null,8,["open","assistant-id","readonly","scroll-to-section","onSaved","onCreated"]),p(Sc,{open:a(U),"onUpdate:open":we[4]||(we[4]=be=>U.value=be),onConfigure:a(D),onViewConfig:a(C),onCreate:a(F)},null,8,["open","onConfigure","onViewConfig","onCreate"]),p(rd,{open:a(te),"onUpdate:open":we[5]||(we[5]=be=>te.value=be),onConfigure:a(Z),onCreate:a(ge)},null,8,["open","onConfigure","onCreate"]),p(vd,{open:a(se),"skill-id":a(le),"onUpdate:open":we[6]||(we[6]=be=>se.value=be),onSaved:a(ie),onCreated:a(xe)},null,8,["open","skill-id","onSaved","onCreated"])])}}}),Kd=et(Wd,[["__scopeId","data-v-9798e70f"]]),Qd={"zh-CN":{message:"消息记录",member:"成员",meta:"群信息",member_name_history:"昵称历史"},"en-US":{message:"Messages",member:"Members",meta:"Chat Info",member_name_history:"Nickname History"}},Ut={"zh-CN":{message:{id:"消息ID",sender_id:"发送者ID",sender_account_name:"发送时账号名",sender_group_nickname:"发送时群昵称",ts:"时间戳(秒)",type:"消息类型",content:"消息内容"},member:{id:"成员ID",platform_id:"平台ID",account_name:"账号名称",group_nickname:"群昵称",aliases:"自定义别名"},meta:{name:"群名称",platform:"平台",type:"聊天类型",imported_at:"导入时间"},member_name_history:{id:"记录ID",member_id:"成员ID",name_type:"名称类型",name:"昵称值",start_ts:"开始时间",end_ts:"结束时间"}},"en-US":{message:{id:"Message ID",sender_id:"Sender ID",sender_account_name:"Sender Account",sender_group_nickname:"Sender Nickname",ts:"Timestamp (sec)",type:"Message Type",content:"Content"},member:{id:"Member ID",platform_id:"Platform ID",account_name:"Account Name",group_nickname:"Group Nickname",aliases:"Custom Aliases"},meta:{name:"Chat Name",platform:"Platform",type:"Chat Type",imported_at:"Imported At"},member_name_history:{id:"Record ID",member_id:"Member ID",name_type:"Name Type",name:"Nickname",start_ts:"Start Time",end_ts:"End Time"}}};function Vt(l,s="zh-CN"){return Qd[ha(s)]?.[l]||l}function Gt(l,s,t="zh-CN"){return Ut[ha(t)]?.[l]?.[s]||s}function ha(l){return l.startsWith("zh")?"zh-CN":"en-US"}const Gd={class:"flex items-center justify-between border-b border-gray-200 p-2 dark:border-gray-800"},Jd={key:0,class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Xd={key:0,class:"flex-1 overflow-y-auto p-2"},Zd=["onClick"],eu={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},tu={class:"flex-1 truncate text-right text-xs text-gray-400"},au={key:0,class:"ml-4 mt-1 space-y-0.5"},su=["title","onDblclick"],ou={class:"font-mono text-gray-700 dark:text-gray-300"},nu={class:"flex-1 truncate text-right text-[10px] text-gray-400"},ru={key:1,class:"flex flex-1 flex-col items-center gap-2 overflow-y-auto py-2"},lu=["title","onClick"],iu=pe({__name:"SchemaPanel",props:{sessionId:{}},emits:["insertColumn"],setup(l,{expose:s,emit:t}){const{t:c,locale:r}=he(),m=l,u=t,d=f(!1),g=f([]),v=f(new Set);async function h(){try{g.value=await qe().getSchema(m.sessionId),g.value.forEach(E=>v.value.add(E.name))}catch(E){console.error("加载 Schema 失败:",E)}}function $(E){v.value.has(E)?v.value.delete(E):v.value.add(E)}function x(E){d.value=!1,v.value.add(E)}function S(E,M){u("insertColumn",E,M)}return s({loadSchema:h,schema:g}),Me(()=>{h()}),(E,M)=>{const L=ye;return o(),i("div",{class:ae(["flex flex-col border-r border-gray-200 bg-white transition-all dark:border-gray-800 dark:bg-gray-900",d.value?"w-10":"w-56"])},[e("div",Gd,[d.value?P("",!0):(o(),i("span",Jd,n(a(c)("ai.sqlLab.schema.tables")),1)),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:M[0]||(M[0]=b=>d.value=!d.value)},[p(L,{name:d.value?"i-heroicons-chevron-right":"i-heroicons-chevron-left",class:"h-4 w-4"},null,8,["name"])])]),d.value?(o(),i("div",ru,[(o(!0),i(oe,null,ue(g.value,b=>(o(),i("button",{key:b.name,class:"rounded p-1 text-gray-400 transition-colors hover:bg-gray-100 hover:text-pink-500 dark:hover:bg-gray-800",title:`${a(Vt)(b.name,a(r))} (${b.name})`,onClick:I=>x(b.name)},[p(L,{name:"i-heroicons-table-cells",class:"h-4 w-4"})],8,lu))),128))])):(o(),i("div",Xd,[(o(!0),i(oe,null,ue(g.value,b=>(o(),i("div",{key:b.name,class:"mb-2"},[e("button",{class:"flex w-full items-center gap-1 rounded px-2 py-1.5 text-left transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",onClick:I=>$(b.name)},[p(L,{name:v.value.has(b.name)?"i-heroicons-chevron-down":"i-heroicons-chevron-right",class:"h-3 w-3 shrink-0 text-gray-400"},null,8,["name"]),p(L,{name:"i-heroicons-table-cells",class:"h-4 w-4 shrink-0 text-pink-500"}),e("span",eu,n(b.name),1),e("span",tu,n(a(Vt)(b.name,a(r))),1)],8,Zd),v.value.has(b.name)?(o(),i("div",au,[(o(!0),i(oe,null,ue(b.columns,I=>(o(),i("button",{key:I.name,class:"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",title:a(c)("ai.sqlLab.schema.doubleClickToInsert"),onDblclick:R=>S(b.name,I.name)},[I.pk?(o(),Q(L,{key:0,name:"i-heroicons-key",class:"h-3 w-3 shrink-0 text-yellow-500",title:a(c)("ai.sqlLab.schema.primaryKey")},null,8,["title"])):P("",!0),e("span",ou,n(I.name),1),e("span",nu,n(a(Gt)(b.name,I.name,a(r))),1)],40,su))),128))])):P("",!0)]))),128))]))],2)}}}),cu={class:"max-h-[70vh] overflow-hidden p-6"},du={class:"mb-4 flex items-center gap-2"},uu={class:"text-lg font-semibold text-gray-900 dark:text-white"},mu={key:0,class:"max-h-[50vh] space-y-3 overflow-y-auto pr-2"},gu={class:"mb-2 flex items-start justify-between gap-2"},pu={class:"flex-1 text-sm font-medium text-gray-700 dark:text-gray-300"},vu={class:"shrink-0 text-xs text-gray-400"},hu={class:"mb-2 rounded bg-white p-2 dark:bg-gray-800"},yu={class:"whitespace-pre-wrap break-all font-mono text-xs text-gray-600 dark:text-gray-400"},fu={key:0,class:"mb-2 text-xs text-gray-500 dark:text-gray-400"},xu={class:"flex justify-end gap-2"},bu={key:1,class:"py-8 text-center text-gray-500 dark:text-gray-400"},ku={class:"text-sm"},_u={class:"mt-4 flex justify-end"},wu=pe({__name:"AIHistoryModal",props:{open:{type:Boolean},history:{}},emits:["update:open","execute","delete"],setup(l,{emit:s}){const{t}=he(),c=s;function r(m){const u=new Date(m),d=new Date,g=d.getTime()-m;return g<6e4?t("ai.sqlLab.history.justNow"):g<36e5?t("ai.sqlLab.history.minutesAgo",{count:Math.floor(g/6e4)}):g<864e5?t("ai.sqlLab.history.hoursAgo",{count:Math.floor(g/36e5)}):u.toDateString()===d.toDateString()?t("ai.sqlLab.history.today"):`${u.getMonth()+1}/${u.getDate()}`}return(m,u)=>{const d=ye,g=Le,v=Fe;return o(),Q(v,{open:l.open,ui:{content:"max-w-5xl"},"onUpdate:open":u[1]||(u[1]=h=>c("update:open",h))},{content:O(()=>[e("div",cu,[e("div",du,[p(d,{name:"i-heroicons-clock",class:"h-5 w-5 text-pink-500"}),e("h3",uu,n(a(t)("ai.sqlLab.history.title")),1)]),l.history.length>0?(o(),i("div",mu,[(o(!0),i(oe,null,ue(l.history,h=>(o(),i("div",{key:h.id,class:"rounded-lg border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-gray-900"},[e("div",gu,[e("p",pu,n(h.prompt),1),e("span",vu,n(r(h.timestamp)),1)]),e("div",hu,[e("pre",yu,n(h.sql),1)]),h.explanation?(o(),i("p",fu,n(h.explanation),1)):P("",!0),e("div",xu,[p(g,{variant:"ghost",size:"xs",color:"error",onClick:$=>c("delete",h.id)},{default:O(()=>[p(d,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"})]),_:1},8,["onClick"]),p(g,{size:"xs",onClick:$=>c("execute",h)},{default:O(()=>[p(d,{name:"i-heroicons-play",class:"mr-1 h-3.5 w-3.5"}),ne(" "+n(a(t)("ai.sqlLab.history.execute")),1)]),_:1},8,["onClick"])])]))),128))])):(o(),i("div",bu,[p(d,{name:"i-heroicons-clock",class:"mx-auto mb-2 h-8 w-8 text-gray-300 dark:text-gray-600"}),e("p",ku,n(a(t)("ai.sqlLab.history.empty")),1)])),e("div",_u,[p(g,{variant:"ghost",onClick:u[0]||(u[0]=h=>c("update:open",!1))},{default:O(()=>[ne(n(a(t)("common.close")),1)]),_:1})])])]),_:1},8,["open"])}}}),$u={class:"flex flex-1 flex-col overflow-hidden"},Cu={key:0,class:"border-b border-red-200 bg-red-50 p-4 dark:border-red-900 dark:bg-red-950"},Su={class:"flex items-start gap-2"},Tu={class:"min-w-0 flex-1"},Iu={class:"text-sm font-medium text-red-800 dark:text-red-200"},Mu={class:"mt-1 break-all font-mono text-xs text-red-600 dark:text-red-400"},Lu={key:1,class:"flex items-center justify-between border-b border-gray-200 bg-gray-50 px-4 py-2 dark:border-gray-800 dark:bg-gray-900"},Du={class:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400"},Au={class:"flex cursor-pointer items-center gap-1.5"},qu={class:"text-xs"},Ru={class:"flex items-center gap-2"},Eu={key:2,class:"flex-1 overflow-auto"},zu={class:"min-w-full divide-y divide-gray-200 dark:divide-gray-700"},Pu={class:"sticky top-0 bg-gray-100 dark:bg-gray-800"},ju=["onClick"],Fu={class:"flex items-center gap-1"},Bu={class:"flex flex-col"},Uu={class:"text-gray-700 dark:text-gray-300"},Vu={key:0,class:"font-mono text-[10px] text-gray-400"},Ou={key:0,class:"sticky right-0 w-12 bg-gray-100 px-2 py-2 dark:bg-gray-800"},Nu={class:"divide-y divide-gray-200 bg-white dark:divide-gray-700 dark:bg-gray-900"},Yu=["title"],Hu={key:0,class:"sticky right-0 w-12 bg-white px-2 py-2 dark:bg-gray-900"},Wu={key:3,class:"flex shrink-0 items-center gap-4 border-t border-gray-200 bg-gray-50 px-4 py-2 dark:border-gray-800 dark:bg-gray-900"},Ku={class:"flex items-center gap-1"},Qu={class:"mx-2 text-xs text-gray-600 dark:text-gray-400"},Gu={class:"flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400"},Ju={key:4,class:"flex flex-1 items-center justify-center text-gray-500 dark:text-gray-400"},Xu={class:"text-center"},Zu={class:"mt-2 text-sm"},e0={key:5,class:"flex flex-1 items-center justify-center text-gray-500 dark:text-gray-400"},t0={class:"text-center"},a0={class:"mt-2 text-sm"},s0={class:"mt-1 text-xs text-gray-400"},o0={class:"max-h-[70vh] overflow-hidden p-6"},n0={class:"mb-4 flex items-center gap-2"},r0={class:"text-lg font-semibold text-gray-900 dark:text-white"},l0={key:0,class:"flex items-center justify-center py-8"},i0={class:"ml-2 text-sm text-gray-500"},c0={key:1,class:"max-h-[50vh] overflow-y-auto"},d0=["innerHTML"],u0={key:0,class:"mt-2 flex items-center text-xs text-gray-400"},m0={key:2,class:"rounded-lg bg-red-50 p-4 dark:bg-red-950"},g0={class:"text-sm text-red-600 dark:text-red-400"},p0={class:"mt-4 flex justify-end gap-2"},v0=pe({__name:"ResultTable",props:{result:{},error:{},sql:{},prompt:{}},setup(l,{expose:s}){const{t,locale:c}=he(),r=Ye(),m=wt(),u=dt(),{aiGlobalSettings:d}=Ze(m),g=[/^ts$/i,/^timestamp$/i,/^time$/i,/_at$/i,/_ts$/i,/_time$/i,/^date$/i];function v(z){return g.some(Z=>Z.test(z))}function h(z){if(typeof z!="number"||!Number.isFinite(z))return!1;const Z=946684800,ge=4102444800,ie=Z*1e3,xe=ge*1e3;return z>=Z&&z<=ge||z>=ie&&z<=xe}function $(z){const ge=z>1e10?z:z*1e3;return fe(ge).format("YYYY-MM-DD HH:mm:ss")}const x=[/^id$/i,/^message_id$/i,/^msg_id$/i,/^msgid$/i];function S(z){return z.findIndex(Z=>x.some(ge=>ge.test(Z)))}function E(z){u.openChatRecordDrawer({scrollToMessageId:z})}const M=new Wt({html:!1,breaks:!0,linkify:!0,typographer:!0}),L=l,b=f(null),I=f("asc"),R=f(1),w=f(100),y=[50,100,200,500],A=f(localStorage.getItem("sql-lab-readable-time")!=="false");function q(){A.value=!A.value,localStorage.setItem("sql-lab-readable-time",String(A.value))}const B=f(!1),j=f(!1),_=f(""),T=f(null),W=f(""),ee=f(!1);function Y(z){const Z=z.split("."),ge=Z.length>1?Z[Z.length-1]:z,ie=Ut[c.value]||Ut["zh-CN"];for(const xe of Object.values(ie))if(xe[ge])return xe[ge];return null}const ce=k(()=>{if(!L.result||!b.value)return L.result?.rows||[];const z=L.result.columns.indexOf(b.value);return z===-1?L.result.rows:[...L.result.rows].sort((Z,ge)=>{const ie=Z[z],xe=ge[z];if(ie===null)return 1;if(xe===null)return-1;if(typeof ie=="number"&&typeof xe=="number")return I.value==="asc"?ie-xe:xe-ie;const Ie=String(ie).localeCompare(String(xe));return I.value==="asc"?Ie:-Ie})}),ve=k(()=>L.result?Math.ceil(ce.value.length/w.value):0),H=k(()=>{const z=(R.value-1)*w.value,Z=z+w.value;return ce.value.slice(z,Z)}),U=k(()=>L.result?S(L.result.columns):-1),te=k(()=>U.value!==-1);function se(z){b.value===z?I.value=I.value==="asc"?"desc":"asc":(b.value=z,I.value="asc"),R.value=1}function le(z){w.value=z,R.value=1}function K(z,Z){return z===null?"NULL":typeof z=="object"?JSON.stringify(z):A.value&&Z&&v(Z)&&h(z)?$(z):String(z)}async function N(){if(!(!L.result||ee.value)){ee.value=!0;try{const z=d.value.sqlExportFormat??"csv",Z=await ms({columns:L.result.columns,rows:L.result.rows},z);if(Z.success&&Z.filePath){const ge=Z.filePath.split("/").pop()||Z.filePath;r.add({title:t("common.exportSuccess"),description:ge,color:"primary",actions:[{label:t("common.openFolder"),onClick:()=>{oa().showInFolder(Z.filePath)}}]})}else r.fail(t("common.exportFailed"),{description:Z.error})}catch(z){console.error("导出失败:",z),r.fail(t("common.exportFailed"),{description:String(z)})}finally{ee.value=!1}}}function D(){b.value=null,I.value="asc",R.value=1}function C(){if(!L.result)return"";const z=50,Z=L.result.rows.slice(0,z),ge=L.result.columns.join(" | "),ie=L.result.columns.map(()=>"---").join(" | "),xe=Z.map(De=>De.map($e=>$e===null?"NULL":String($e).slice(0,50)).join(" | "));let Ie=`| ${ge} |
|
|
45
|
-
| ${ie} |
|
|
46
|
-
`;return Ie+=xe.map(De=>`| ${De} |`).join(`
|
|
47
|
-
`),L.result.rows.length>z&&(Ie+=`
|
|
48
|
-
|
|
49
|
-
(仅展示前 ${z} 行,共 ${L.result.rowCount} 行)`),Ie}async function F(){B.value=!0,_.value="",T.value=null,W.value="",await J()}async function J(){if(!await Nt().hasConfig()){T.value=t("common.errorNoAIConfig");return}j.value=!0,T.value=null,W.value="";try{const Z=C();let ge="";L.prompt&&(ge=`用户的查询意图:${L.prompt}
|
|
50
|
-
|
|
51
|
-
`),L.sql&&(ge+=`执行的 SQL 语句:
|
|
52
|
-
\`\`\`sql
|
|
53
|
-
${L.sql}
|
|
54
|
-
\`\`\`
|
|
55
|
-
|
|
56
|
-
`);const ie=`请分析以下 SQL 查询结果,用简洁的中文总结关键发现和洞察。
|
|
57
|
-
|
|
58
|
-
${ge}查询结果(共 ${L.result?.rowCount||0} 行):
|
|
59
|
-
|
|
60
|
-
${Z}
|
|
61
|
-
|
|
62
|
-
请提供:
|
|
63
|
-
1. 结果概述(一句话总结)
|
|
64
|
-
2. 关键发现(2-4 个要点)
|
|
65
|
-
3. 如有明显的趋势或异常,请指出`,xe=await na().chatStream([{role:"system",content:"你是一个数据分析专家,擅长从查询结果中提取关键信息和洞察。请用简洁清晰的中文回答。"},{role:"user",content:ie}],{temperature:.3,maxTokens:1e3},Ie=>{Ie.content&&(W.value+=Ie.content)});xe.success?_.value=W.value:T.value=xe.error||t("ai.sqlLab.result.errorSummary")}catch(Z){T.value=Z.message||String(Z)}finally{j.value=!1}}function G(){B.value=!1,_.value="",T.value=null,W.value=""}return s({resetSort:D}),(z,Z)=>{const ge=ye,ie=da,xe=Le,Ie=Tt,De=Fe;return o(),i("div",$u,[l.error?(o(),i("div",Cu,[e("div",Su,[p(ge,{name:"i-heroicons-exclamation-circle",class:"mt-0.5 h-5 w-5 shrink-0 text-red-500"}),e("div",Tu,[e("p",Iu,n(a(t)("ai.sqlLab.result.queryError")),1),e("p",Mu,n(l.error),1)])])])):P("",!0),l.result?(o(),i("div",Lu,[e("div",Du,[e("label",Au,[p(ie,{"model-value":A.value,size:"xs","onUpdate:modelValue":q},null,8,["model-value"]),e("span",qu,n(a(t)("ai.sqlLab.result.readableTime")),1)]),Z[5]||(Z[5]=e("span",{class:"text-gray-300 dark:text-gray-600"},"|",-1)),e("span",null,[p(ge,{name:"i-heroicons-table-cells",class:"mr-1 inline h-4 w-4"}),ne(" "+n(a(t)("ai.sqlLab.result.rows",{count:l.result.rowCount})),1)]),e("span",null,[p(ge,{name:"i-heroicons-clock",class:"mr-1 inline h-4 w-4"}),ne(" "+n(l.result.duration)+" ms ",1)])]),e("div",Ru,[p(xe,{variant:"ghost",size:"xs",onClick:F},{default:O(()=>[p(ge,{name:"i-heroicons-sparkles",class:"mr-1 h-4 w-4"}),ne(" "+n(a(t)("ai.sqlLab.result.summarize")),1)]),_:1}),p(xe,{variant:"ghost",size:"xs",loading:ee.value,onClick:N},{default:O(()=>[p(ge,{name:"i-heroicons-arrow-down-tray",class:"mr-1 h-4 w-4"}),ne(" "+n(a(t)("common.export")),1)]),_:1},8,["loading"])])])):P("",!0),l.result&&l.result.rows.length>0?(o(),i("div",Eu,[e("table",zu,[e("thead",Pu,[e("tr",null,[(o(!0),i(oe,null,ue(l.result.columns,($e,re)=>(o(),i("th",{key:re,class:"cursor-pointer whitespace-nowrap px-4 py-2 text-left text-xs font-medium transition-colors hover:bg-gray-200 dark:hover:bg-gray-700",onClick:de=>se($e)},[e("div",Fu,[e("div",Bu,[e("span",Uu,n(Y($e)||$e),1),Y($e)?(o(),i("span",Vu,n($e),1)):P("",!0)]),b.value===$e?(o(),Q(ge,{key:0,name:I.value==="asc"?"i-heroicons-chevron-up":"i-heroicons-chevron-down",class:"h-3 w-3 text-gray-500"},null,8,["name"])):P("",!0)])],8,ju))),128)),te.value?(o(),i("th",Ou)):P("",!0)])]),e("tbody",Nu,[(o(!0),i(oe,null,ue(H.value,($e,re)=>(o(),i("tr",{key:re,class:"hover:bg-gray-50 dark:hover:bg-gray-800"},[(o(!0),i(oe,null,ue($e,(de,Te)=>(o(),i("td",{key:Te,class:ae(["max-w-xs truncate whitespace-nowrap px-4 py-2 font-mono text-sm text-gray-700 dark:text-gray-300",{"text-gray-400 italic":de===null}]),title:K(de,l.result.columns[Te])},n(K(de,l.result.columns[Te])),11,Yu))),128)),te.value?(o(),i("td",Hu,[p(xe,{icon:"i-heroicons-chat-bubble-left-right",color:"neutral",variant:"ghost",size:"xs",title:a(t)("ai.sqlLab.result.viewChat"),onClick:de=>E($e[U.value])},null,8,["title","onClick"])])):P("",!0)]))),128))])])])):P("",!0),l.result&&l.result.rows.length>0&&ve.value>1?(o(),i("div",Wu,[e("div",Ku,[p(xe,{icon:"i-heroicons-chevron-double-left",variant:"ghost",size:"xs",disabled:R.value===1,onClick:Z[0]||(Z[0]=$e=>R.value=1)},null,8,["disabled"]),p(xe,{icon:"i-heroicons-chevron-left",variant:"ghost",size:"xs",disabled:R.value===1,onClick:Z[1]||(Z[1]=$e=>R.value--)},null,8,["disabled"]),e("span",Qu,n(R.value)+" / "+n(ve.value),1),p(xe,{icon:"i-heroicons-chevron-right",variant:"ghost",size:"xs",disabled:R.value>=ve.value,onClick:Z[2]||(Z[2]=$e=>R.value++)},null,8,["disabled"]),p(xe,{icon:"i-heroicons-chevron-double-right",variant:"ghost",size:"xs",disabled:R.value>=ve.value,onClick:Z[3]||(Z[3]=$e=>R.value=ve.value)},null,8,["disabled"])]),e("div",Gu,[e("span",null,n(a(t)("ai.sqlLab.result.pageSize")),1),p(Ie,{"model-value":w.value,items:y.map($e=>({label:String($e),value:$e})),size:"xs",class:"w-20","onUpdate:modelValue":le},null,8,["model-value","items"])])])):P("",!0),l.result&&l.result.rows.length===0?(o(),i("div",Ju,[e("div",Xu,[p(ge,{name:"i-heroicons-inbox",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),e("p",Zu,n(a(t)("ai.sqlLab.result.emptyResult")),1)])])):P("",!0),!l.result&&!l.error?(o(),i("div",e0,[e("div",t0,[p(ge,{name:"i-heroicons-command-line",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),e("p",a0,n(a(t)("ai.sqlLab.result.initialState")),1),e("p",s0,n(a(t)("ai.sqlLab.result.initialHint")),1)])])):P("",!0),p(De,{open:B.value,"onUpdate:open":Z[4]||(Z[4]=$e=>B.value=$e)},{content:O(()=>[e("div",o0,[e("div",n0,[p(ge,{name:"i-heroicons-sparkles",class:"h-5 w-5 text-pink-500"}),e("h3",r0,n(a(t)("ai.sqlLab.result.summaryTitle")),1)]),j.value&&!W.value?(o(),i("div",l0,[p(ge,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-pink-500"}),e("span",i0,n(a(t)("ai.sqlLab.result.analyzing")),1)])):W.value||_.value?(o(),i("div",c0,[e("div",{class:"prose prose-sm max-w-none rounded-lg bg-gray-50 p-4 dark:prose-invert dark:bg-gray-900",innerHTML:a(M).render(W.value||_.value)},null,8,d0),j.value?(o(),i("div",u0,[p(ge,{name:"i-heroicons-arrow-path",class:"mr-1 h-3 w-3 animate-spin"}),ne(" "+n(a(t)("common.generating")),1)])):P("",!0)])):P("",!0),T.value?(o(),i("div",m0,[e("p",g0,n(T.value),1)])):P("",!0),e("div",p0,[!j.value&&_.value?(o(),Q(xe,{key:0,variant:"outline",onClick:J},{default:O(()=>[p(ge,{name:"i-heroicons-arrow-path",class:"mr-1 h-4 w-4"}),ne(" "+n(a(t)("common.regenerate")),1)]),_:1})):P("",!0),p(xe,{variant:"ghost",onClick:G},{default:O(()=>[ne(n(a(t)("common.close")),1)]),_:1})])])]),_:1},8,["open"])])}}}),h0={class:"main-content flex h-full"},y0={class:"flex flex-1 flex-col overflow-hidden"},f0={class:"flex flex-col border-b border-gray-200 bg-gray-50 p-4 dark:border-gray-800 dark:bg-gray-950"},x0={class:"mx-auto w-full max-w-3xl"},b0=["placeholder"],k0=["placeholder"],_0={class:"mt-1 flex items-center justify-between"},w0={class:"flex items-center gap-2"},$0={key:0,class:"text-xs text-gray-400"},C0={class:"flex items-center gap-2"},S0={key:0,class:"ml-1 text-xs text-gray-400"},T0={key:0,class:"flex-1 overflow-auto p-4"},I0={class:"mx-auto w-full max-w-3xl rounded-lg border border-gray-200 bg-white p-4 dark:border-gray-800 dark:bg-gray-900"},M0={class:"mb-2 flex items-center gap-1.5 text-sm font-medium text-gray-600 dark:text-gray-300"},L0={key:0,class:"text-gray-500"},D0={key:1,class:"text-pink-500"},A0=["open"],q0={class:"cursor-pointer select-none text-xs font-medium text-gray-500 dark:text-gray-400"},R0={key:1,class:"whitespace-pre-wrap break-all font-mono text-xs leading-5 text-gray-600 dark:text-gray-400"},E0={key:2,class:"font-mono text-xs text-gray-400"},z0=pe({__name:"SQLLabTab",props:{sessionId:{},chatType:{}},setup(l){const{t:s,locale:t}=he(),c=l,r=f(null),m=f(null);function u(U){return s(U==="group"?"ai.sqlLab.generate.defaultPromptGroup":"ai.sqlLab.generate.defaultPromptPrivate")}const d=f("SELECT * FROM message LIMIT 10"),g=f(u(c.chatType)),v=f("prompt"),h=f(!1),$=f(!1),x=f(null),S=f(null),E=f(""),M=f(""),L=f(""),b=f(!1),I=f(null),R=f(!1),w=f([]);function y(){try{const U=`sql-lab-history-${c.sessionId}`,te=localStorage.getItem(U);te&&(w.value=JSON.parse(te))}catch(U){console.error("加载历史记录失败:",U)}}function A(){try{const U=`sql-lab-history-${c.sessionId}`;localStorage.setItem(U,JSON.stringify(w.value))}catch(U){console.error("保存历史记录失败:",U)}}function q(U,te,se){const le={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,prompt:U,sql:te,explanation:se,timestamp:Date.now()};w.value.unshift(le),w.value.length>50&&(w.value=w.value.slice(0,50)),A()}function B(U){w.value=w.value.filter(te=>te.id!==U),A()}async function j(){if(!d.value.trim()){x.value=s("ai.sqlLab.editor.errorEmptySQL");return}h.value=!0,x.value=null,S.value=null,m.value?.resetSort();try{S.value=await qe().executeSQL(c.sessionId,d.value)}catch(U){x.value=U.message||String(U)}finally{h.value=!1}}function _(U,te){(U.ctrlKey||U.metaKey)&&U.key==="Enter"&&(U.preventDefault(),te==="prompt"?ve():j())}function T(U,te){d.value+=`${U}.${te}`}function W(){v.value=v.value==="prompt"?"sql":"prompt"}function ee(U){const te=[];for(const se of U){te.push(`### ${se.name} (${Vt(se.name,t.value)})`),te.push("| 列名 | 说明 | 类型 |"),te.push("|------|------|------|");for(const le of se.columns){const K=le.pk?" (主键)":"";te.push(`| ${le.name} | ${Gt(se.name,le.name,t.value)}${K} | ${le.type} |`)}te.push("")}return te.join(`
|
|
66
|
-
`)}function Y(U,te){return`你是一个 SQLite 数据库专家。用户需要查询聊天记录数据库。
|
|
67
|
-
|
|
68
|
-
## 数据库结构
|
|
69
|
-
|
|
70
|
-
${ee(te)}
|
|
71
|
-
|
|
72
|
-
## 重要说明
|
|
73
|
-
|
|
74
|
-
1. message 表的 ts 字段是 Unix 时间戳(秒),查询日期需要使用 datetime(ts, 'unixepoch') 转换
|
|
75
|
-
2. message.type 字段:0=文本, 1=图片, 2=语音, 3=视频, 4=文件, 5=表情包, 6=系统消息, 99=其他
|
|
76
|
-
3. member 和 message 表通过 message.sender_id = member.id 关联
|
|
77
|
-
4. **人名查询**:当识别到人名/昵称查询时,必须同时在 member 表的 account_name、group_nickname 和 aliases 三个字段中模糊搜索,使用 OR 连接:
|
|
78
|
-
\`\`\`
|
|
79
|
-
WHERE m.account_name LIKE '%人名%'
|
|
80
|
-
OR m.group_nickname LIKE '%人名%'
|
|
81
|
-
OR m.aliases LIKE '%人名%'
|
|
82
|
-
\`\`\`
|
|
83
|
-
5. 显示成员名称时,使用 COALESCE(m.group_nickname, m.account_name, m.platform_id) 来获取最佳显示名
|
|
84
|
-
6. **查询具体消息时包含消息 ID**:当用户需要查看具体的聊天记录时,SELECT 应包含 msg.id 作为第一个字段,这样用户可以点击查看完整上下文。注意是 msg.id(消息 ID),不是 m.id(成员 ID)。
|
|
85
|
-
7. **统计查询不需要消息 ID**:当用户需要统计分析时,不需要返回 msg.id
|
|
86
|
-
8. **严禁使用不存在的字段**:只能使用上方 Schema 中明确存在的表名和列名,禁止使用如 sender.display_name、member.display_name 等虚构字段
|
|
87
|
-
9. **成员显示名写法**:如果需要显示成员名称,优先使用 COALESCE(m.group_nickname, m.account_name, m.platform_id);若不联表 member,可使用 COALESCE(msg.sender_group_nickname, msg.sender_account_name, msg.sender_id)
|
|
88
|
-
10. **单次只做一个分析目标**:一次 SQL 只返回一个语义一致的结果集,不要把多个分析目标用 UNION ALL/UNION 混合到同一结果表
|
|
89
|
-
|
|
90
|
-
## 用户需求
|
|
91
|
-
|
|
92
|
-
${U}
|
|
93
|
-
|
|
94
|
-
## 要求
|
|
95
|
-
|
|
96
|
-
请以 JSON 格式输出,包含两个字段:
|
|
97
|
-
- sql: SQLite 查询语句(不要用代码块包裹)
|
|
98
|
-
- explanation: 用简洁的中文解释这条 SQL 做了什么
|
|
99
|
-
|
|
100
|
-
示例格式:
|
|
101
|
-
{"sql": "SELECT ...", "explanation": "这条SQL查询了..."}
|
|
102
|
-
|
|
103
|
-
注意:
|
|
104
|
-
1. 仅输出 JSON,不要有任何其他文字
|
|
105
|
-
2. SQL 中的查询结果限制在合理范围内(建议 LIMIT 100)
|
|
106
|
-
3. 确保 SQL 语法正确
|
|
107
|
-
4. 若用户需求包含多个分析目标,仅选择第一个目标生成 SQL`}function ce(U){let te=U.trim();te=te.replace(/^```json?\n?/i,"").replace(/\n?```$/i,"");try{const se=JSON.parse(te);return{sql:(se.sql||"").trim(),explanation:(se.explanation||"").trim()}}catch{return te=te.replace(/^```sql?\n?/i,"").replace(/\n?```$/i,""),{sql:te.trim(),explanation:""}}}async function ve(){const U=g.value.trim();if(!U){x.value=s("ai.sqlLab.generate.errorEmptyPrompt");return}if(!await Nt().hasConfig()){x.value=s("common.errorNoAIConfig");return}const se=r.value?.schema||[];if(se.length===0){x.value=s("common.error.unknown");return}$.value=!0,S.value=null,x.value=null,M.value="",L.value="",b.value=!1;let le="";try{const K=Y(U,se),N=await na().chatStream([{role:"system",content:"你是一个 SQLite 专家,请以 JSON 格式输出 sql 和 explanation 字段。"},{role:"user",content:K}],{temperature:.1,maxTokens:4096},C=>{if(C.thinking!==void 0){C.thinkingDone?b.value=!1:(b.value=!0,C.thinking&&(L.value+=C.thinking,ze(()=>{I.value&&(I.value.scrollTop=I.value.scrollHeight)})));return}C.error&&(le=C.error),C.isFinished&&C.finishReason==="length"&&(le=s("ai.sqlLab.generate.errorTokenLimit")),C.content&&(M.value+=C.content)});if(!N.success){x.value=N.error||le||s("ai.sqlLab.generate.errorGenerate");return}if(le){x.value=le;return}const D=ce(M.value);if(!D.sql){x.value=M.value?`${s("ai.sqlLab.generate.errorGenerate")}: ${M.value.slice(0,200)}`:s("ai.sqlLab.generate.errorGenerate");return}d.value=D.sql,E.value=U,q(U,D.sql,D.explanation),await j()}catch(K){x.value=K.message||String(K)}finally{$.value=!1}}async function H(U){d.value=U.sql,E.value=U.prompt,R.value=!1,await j()}return Me(()=>{y()}),me(()=>c.chatType,U=>{g.value=u(U)}),(U,te)=>{const se=ye,le=Le;return o(),i("div",h0,[p(a(iu),{ref_key:"schemaPanelRef",ref:r,"session-id":l.sessionId,onInsertColumn:T},null,8,["session-id"]),e("div",y0,[e("div",f0,[e("div",x0,[v.value==="prompt"?Be((o(),i("textarea",{key:0,"onUpdate:modelValue":te[0]||(te[0]=K=>g.value=K),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]=K=>_(K,"prompt"))},null,40,b0)),[[at,g.value]]):Be((o(),i("textarea",{key:1,"onUpdate:modelValue":te[2]||(te[2]=K=>d.value=K),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]=K=>_(K,"sql"))},null,40,k0)),[[at,d.value]]),e("div",_0,[e("div",w0,[p(le,{variant:"ghost",size:"xs",onClick:W},{default:O(()=>[p(se,{name:"i-heroicons-arrows-right-left",class:"mr-1 h-3.5 w-3.5"}),ne(" "+n(v.value==="prompt"?a(s)("ai.sqlLab.editor.switchToSQLMode"):a(s)("ai.sqlLab.editor.switchToPromptMode")),1)]),_:1}),v.value==="sql"?(o(),i("span",$0,n(a(s)("ai.sqlLab.editor.tip")),1)):P("",!0)]),e("div",C0,[p(le,{variant:"ghost",size:"sm",disabled:w.value.length===0,onClick:te[4]||(te[4]=K=>R.value=!0)},{default:O(()=>[p(se,{name:"i-heroicons-clock",class:"mr-1 h-4 w-4"}),ne(" "+n(a(s)("ai.sqlLab.editor.history"))+" ",1),w.value.length>0?(o(),i("span",S0,"("+n(w.value.length)+")",1)):P("",!0)]),_:1},8,["disabled"]),v.value==="prompt"?(o(),Q(le,{key:0,color:"primary",size:"sm",loading:$.value||h.value,disabled:!g.value.trim(),onClick:ve},{default:O(()=>[p(se,{name:"i-heroicons-sparkles",class:"mr-1 h-4 w-4"}),ne(" "+n(a(s)("ai.sqlLab.editor.generateAndRun")),1)]),_:1},8,["loading","disabled"])):(o(),Q(le,{key:1,color:"primary",size:"sm",loading:h.value,onClick:j},{default:O(()=>[p(se,{name:"i-heroicons-play",class:"mr-1 h-4 w-4"}),ne(" "+n(a(s)("ai.sqlLab.editor.run")),1)]),_:1},8,["loading"]))])])])]),v.value==="prompt"&&!S.value&&!x.value&&(M.value||L.value||$.value)?(o(),i("div",T0,[e("div",I0,[e("p",M0,[p(se,{name:"i-heroicons-cpu-chip",class:"h-4 w-4"}),ne(" "+n(a(s)("ai.sqlLab.generate.aiOutput"))+" ",1),b.value?(o(),i("span",L0,n(a(s)("ai.sqlLab.generate.thinking")),1)):$.value?(o(),i("span",D0,n(a(s)("common.generating")),1)):P("",!0)]),L.value?(o(),i("details",{key:0,class:"mb-3",open:b.value},[e("summary",q0,n(a(s)("ai.sqlLab.generate.thinkingProcess")),1),e("pre",{ref_key:"thinkingPreRef",ref:I,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"},n(L.value),513)],8,A0)):P("",!0),M.value?(o(),i("pre",R0,n(M.value),1)):L.value?P("",!0):(o(),i("p",E0,n(a(s)("ai.sqlLab.generate.waitingAI")),1))])])):(o(),Q(a(v0),{key:1,ref_key:"resultTableRef",ref:m,result:S.value,error:x.value,sql:d.value,prompt:E.value},null,8,["result","error","sql","prompt"]))]),p(a(wu),{open:R.value,"onUpdate:open":te[5]||(te[5]=K=>R.value=K),history:w.value,onExecute:H,onDelete:B},null,8,["open","history"])])}}}),P0=pe({__name:"EChartCalendar",props:{data:{},height:{default:180},year:{}},setup(l){vt([Kt,va,It,Qt,ht]);const s=l,{t,locale:c}=he(),r=mt(),m=f(null);let u=null;const d=k(()=>{if(s.year)return s.year;if(s.data.length===0)return new Date().getFullYear();const M=s.data.map(L=>parseInt(L.date.split("-")[0]));return Math.max(...M)}),g=k(()=>s.data.length===0?10:Math.max(...s.data.map(M=>M.value),1)),v=k(()=>s.data.map(M=>[M.date,M.value])),h={light:["#fee5e8","#fbb5c2","#f7758c","#ee4567"],dark:["#3d1f24","#6b2f3a","#a34557","#ee4567"]},$=k(()=>({tooltip:{trigger:"item",formatter:M=>{const L=M.data[0],b=M.data[1];return`${L}<br/>${t("views.message.calendarTooltipMessages")}: ${b}`}},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 x(){m.value&&(u=yt(m.value,r.value?"dark":void 0,{renderer:"canvas"}),u.setOption({backgroundColor:"transparent",...$.value}))}function S(){u&&u.setOption({backgroundColor:"transparent",...$.value},{notMerge:!0})}function E(){u?.resize()}return me([()=>s.data,r,c],()=>{S()}),me(()=>s.year,()=>{S()}),Me(()=>{x(),window.addEventListener("resize",E)}),it(()=>{window.removeEventListener("resize",E),u?.dispose()}),(M,L)=>(o(),i("div",{ref_key:"chartRef",ref:m,style:Ne({height:`${l.height}px`,width:"100%"})},null,4))}}),j0={class:"flex items-center justify-between border-b border-gray-200 px-5 py-3 dark:border-gray-800"},F0={class:"font-semibold text-gray-900 whitespace-nowrap dark:text-white"},B0={key:0,class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},U0={class:"no-capture flex items-center gap-2"},V0={class:"flex w-full items-center justify-between border-b border-gray-200 px-6 py-4 dark:border-gray-700"},O0={class:"flex items-center gap-2"},N0={class:"text-lg font-semibold text-gray-900 whitespace-nowrap dark:text-white"},Y0={class:"text-sm text-gray-500"},H0={class:"max-h-[60vh] p-4 divide-y divide-gray-100 overflow-y-auto dark:divide-gray-800"},W0={class:"divide-y divide-gray-100 dark:divide-gray-800"},K0={key:0},Q0={class:"px-5 py-8 text-center text-sm text-gray-400"},G0=pe({__name:"ListPro",props:{items:{},title:{},description:{},topN:{default:10},countTemplate:{}},setup(l){const{t:s}=he(),t=l,c=f(!1),r=f(null),m=f(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 $=Le,x=Fe;return o(),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",j0,[e("div",null,[e("h3",F0,n(l.title),1),l.description?(o(),i("p",B0,n(l.description),1)):P("",!0)]),e("div",U0,[Ve(v.$slots,"headerRight"),p(rt,{size:"xs",type:"element","target-element":r.value},null,8,["target-element"]),p(x,{open:c.value,"onUpdate:open":h[0]||(h[0]=S=>c.value=S),ui:{content:"md:w-full max-w-3xl"}},{content:O(()=>[e("div",{ref_key:"modalBodyRef",ref:m,class:"section-content flex flex-col"},[e("div",V0,[e("div",O0,[e("h3",N0,n(l.title),1),e("span",Y0,"("+n(g.value)+")",1)]),p(rt,{size:"xs",type:"element","target-element":m.value},null,8,["target-element"])]),e("div",H0,[(o(!0),i(oe,null,ue(l.items,(S,E)=>(o(),i("div",{key:E,class:"px-5 py-3"},[Ve(v.$slots,"item",{item:S,index:E})]))),128))])],512)]),default:O(()=>[d.value?(o(),Q($,{key:0,icon:"i-heroicons-list-bullet",variant:"ghost"},{default:O(()=>[ne(n(a(s)("views.charts.listPro.fullRanking")),1)]),_:1})):P("",!0)]),_:3},8,["open"])])]),Ve(v.$slots,"config"),e("div",W0,[(o(!0),i(oe,null,ue(u.value,(S,E)=>(o(),i("div",{key:E,class:"px-5 py-3"},[Ve(v.$slots,"item",{item:S,index:E})]))),128))]),l.items.length===0?(o(),i("div",K0,[Ve(v.$slots,"empty",{},()=>[e("div",Q0,n(a(s)("views.charts.listPro.empty")),1)])])):P("",!0)],512)}}}),J0={class:"border-b border-gray-100 p-4 dark:border-gray-800"},X0={class:"mb-3 flex flex-wrap items-center gap-2"},Z0={class:"text-xs text-gray-500 dark:text-gray-400"},em=["onClick"],tm={class:"p-4"},am={class:"mb-3 font-semibold text-gray-900 dark:text-white"},sm={class:"space-y-3"},om={class:"mb-1 block text-xs text-gray-500"},nm={class:"mb-1 block text-xs text-gray-500"},rm={class:"flex flex-wrap items-center gap-2"},lm={class:"mt-4 flex justify-end gap-2"},im={class:"flex flex-wrap items-center gap-2"},cm={class:"mt-1.5 text-xs text-gray-400"},dm={key:0,class:"border-b border-gray-100 px-5 py-4 dark:border-gray-800"},um={class:"mb-3 flex items-center justify-between"},mm={class:"text-base font-medium text-gray-700 dark:text-gray-300"},gm={class:"flex cursor-pointer items-center gap-1.5 text-xs text-gray-500"},pm={class:"flex flex-wrap gap-2"},vm={class:"text-xs text-gray-500"},hm={class:"flex items-center gap-3"},ym={class:"w-32 shrink-0"},fm={class:"truncate font-medium text-gray-900 dark:text-white"},xm={class:"flex flex-1 items-center"},bm={class:"flex h-2.5 w-full overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800"},km=["title"],_m={class:"flex shrink-0 items-baseline gap-2"},wm={class:"text-lg font-bold text-gray-900 dark:text-white"},$m={class:"text-sm text-gray-500"},Cm={key:0,class:"flex h-64 flex-col items-center justify-center text-gray-400"},Sm={class:"text-sm"},Tm={key:1,class:"h-64"},Im=pe({__name:"KeywordAnalysis",props:{sessionId:{},timeFilter:{}},setup(l){const{t:s}=he(),t=l,c=wt(),r=f(!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(N){if(!r.value)return m;const D=x.value.indexOf(N);return u[D%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 N=c.customKeywordTemplates.map(C=>({...C,isCustom:!0}));return[...v.value.filter(C=>!c.deletedPresetTemplateIds.includes(C.id)),...N]}),$=f("laugh"),x=f([]);me(v,N=>{N.length>0&&x.value.length===0&&(x.value=[...N[0].keywords])},{immediate:!0});const S=k(()=>{const N=h.value.find(D=>D.id===$.value);return N?N.name:""}),E=f(null),M=f(!1),L=f(!1),b=f(null),I=f(""),R=f([]),w=f(""),y=k(()=>b.value!==null),A=k(()=>y.value?s("quotes.keywords.modal.editTitle"):s("quotes.keywords.modal.createTitle"));function q(){b.value=null,I.value="",R.value=[],w.value="",L.value=!0}function B(N){b.value=N.id,I.value=N.name,R.value=[...N.keywords],L.value=!0}function j(){const N=w.value.trim();N&&!R.value.includes(N)&&(R.value=[...R.value,N]),w.value=""}function _(N){R.value=R.value.filter(D=>D!==N)}function T(N){$.value=N.id,x.value=[...N.keywords],E.value=null,te()}function W(){x.value=[],E.value=null,$.value=""}const ee=f("");function Y(){const N=ee.value.trim();N&&!x.value.includes(N)&&(x.value=[...x.value,N],te()),ee.value=""}function ce(N){x.value=x.value.filter(D=>D!==N),te()}function ve(N){return g.includes(N)}function H(){if(I.value.trim()){if(y.value&&b.value)if(ve(b.value)){const N={id:`custom_${Date.now()}`,name:I.value.trim(),keywords:[...R.value]};c.addCustomKeywordTemplate(N),$.value=N.id,x.value=[...N.keywords],te()}else c.updateCustomKeywordTemplate(b.value,{name:I.value.trim(),keywords:[...R.value]}),$.value===b.value&&(x.value=[...R.value],te());else{const N={id:`custom_${Date.now()}`,name:I.value.trim(),keywords:[...R.value]};c.addCustomKeywordTemplate(N),$.value=N.id,x.value=[...N.keywords],te()}L.value=!1}}function U(N){ve(N)?c.addDeletedPresetTemplateId(N):c.removeCustomKeywordTemplate(N),$.value===N&&(h.value.length>0?T(h.value[0]):W())}async function te(){if(!t.sessionId||x.value.length===0){E.value=null;return}M.value=!0;try{E.value=await qe().getLaughAnalysis(t.sessionId,t.timeFilter,[...x.value])}catch(N){console.error("加载词频分析失败:",N),E.value=null}finally{M.value=!1}}const se=k(()=>E.value?E.value.rankByCount.map(N=>({id:N.memberId.toString(),name:N.name,value:N.laughCount,percentage:N.percentage,keywordDistribution:N.keywordDistribution||[]})):[]);function le(N){if(se.value.length===0)return 0;const D=se.value[0].value;return D===0?0:Math.round(se.value[N].value/D*100)}function K(N,D){const C=le(D);return!N.keywordDistribution||N.keywordDistribution.length===0?[{keyword:"default",width:C,bg:"bg-amber-400"}]:N.keywordDistribution.map(F=>({keyword:F.keyword,width:F.percentage/100*C,bg:d(F.keyword).bg}))}return me(()=>[t.sessionId,t.timeFilter],()=>{te()},{immediate:!0,deep:!0}),(N,D)=>{const C=ua,F=pt,J=Yt,G=Le,z=Fe,Z=Na,ge=ye;return o(),Q(a(G0),{items:se.value,title:a(s)("quotes.keywords.title"),description:a(s)("quotes.keywords.description"),"top-n":10,"count-template":a(s)("quotes.keywords.countTemplate")},{config:O(()=>[e("div",J0,[e("div",X0,[e("span",Z0,n(a(s)("quotes.keywords.templateLabel")),1),(o(!0),i(oe,null,ue(h.value,ie=>(o(),Q(C,{key:ie.id,items:[[{label:a(s)("quotes.keywords.contextMenu.edit"),icon:"i-lucide-pencil",disabled:!ie.isCustom,onSelect:()=>B(ie)},{label:a(s)("quotes.keywords.contextMenu.delete"),icon:"i-lucide-trash",color:"error",onSelect:()=>U(ie.id)}]]},{default:O(()=>[e("button",{class:ae(["rounded-md border px-2.5 py-1 text-sm transition-all",$.value===ie.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:xe=>T(ie)},n(ie.name),11,em)]),_:2},1032,["items"]))),128)),p(z,{open:L.value,"onUpdate:open":D[3]||(D[3]=ie=>L.value=ie)},{content:O(()=>[e("div",tm,[e("h3",am,n(A.value),1),e("div",sm,[e("div",null,[e("label",om,n(a(s)("quotes.keywords.modal.templateName")),1),p(F,{modelValue:I.value,"onUpdate:modelValue":D[0]||(D[0]=ie=>I.value=ie),placeholder:a(s)("quotes.keywords.modal.templateNamePlaceholder")},null,8,["modelValue","placeholder"])]),e("div",null,[e("label",nm,n(a(s)("quotes.keywords.modal.keywords")),1),e("div",rm,[(o(!0),i(oe,null,ue(R.value,ie=>(o(),Q(J,{key:ie,variant:"soft",class:"cursor-pointer",onClick:xe=>_(ie)},{default:O(()=>[ne(n(ie)+" ",1),D[6]||(D[6]=e("span",{class:"ml-0.5 hover:text-red-500"},"×",-1))]),_:2},1032,["onClick"]))),128)),p(F,{modelValue:w.value,"onUpdate:modelValue":D[1]||(D[1]=ie=>w.value=ie),placeholder:a(s)("quotes.keywords.modal.keywordPlaceholder"),class:"w-full",onKeydown:Ke(Pe(j,["prevent"]),["enter"])},null,8,["modelValue","placeholder","onKeydown"])])])]),e("div",lm,[p(G,{variant:"soft",onClick:D[2]||(D[2]=ie=>L.value=!1)},{default:O(()=>[ne(n(a(s)("common.cancel")),1)]),_:1}),p(G,{color:"primary",disabled:!I.value.trim()||R.value.length===0,onClick:H},{default:O(()=>[ne(n(y.value?a(s)("quotes.keywords.modal.update"):a(s)("common.save")),1)]),_:1},8,["disabled"])])])]),default:O(()=>[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:q},n(a(s)("quotes.keywords.newTemplate")),1)]),_:1},8,["open"])]),e("div",im,[(o(!0),i(oe,null,ue(x.value,ie=>(o(),Q(J,{key:ie,class:"cursor-pointer",onClick:xe=>ce(ie)},{default:O(()=>[ne(n(ie)+" ",1),D[7]||(D[7]=e("span",{class:"ml-0.5 hover:text-red-500"},"×",-1))]),_:2},1032,["onClick"]))),128)),p(F,{modelValue:ee.value,"onUpdate:modelValue":D[4]||(D[4]=ie=>ee.value=ie),placeholder:a(s)("quotes.keywords.searchPlaceholder"),class:"w-32",onKeydown:Ke(Pe(Y,["prevent"]),["enter"])},null,8,["modelValue","placeholder","onKeydown"]),x.value.length>0?(o(),i("button",{key:0,class:"text-sm text-pink-500 hover:text-red-500",onClick:W},n(a(s)("quotes.keywords.clear")),1)):P("",!0)]),e("div",cm,n(a(s)("quotes.keywords.templateHint")),1)]),E.value&&E.value.typeDistribution.length>0?(o(),i("div",dm,[e("div",um,[e("span",mm,n(S.value?S.value:x.value.length===1?x.value[0]:a(s)("quotes.keywords.keyword"))+n(a(s)("quotes.keywords.ranking")),1),e("label",gm,[e("span",null,n(a(s)("quotes.keywords.multiColorMode")),1),p(Z,{modelValue:r.value,"onUpdate:modelValue":D[5]||(D[5]=ie=>r.value=ie),size:"md"},null,8,["modelValue"])])]),e("div",pm,[(o(!0),i(oe,null,ue(E.value.typeDistribution,ie=>(o(),i("div",{key:ie.type,class:ae(["flex items-center gap-2 rounded-lg px-2 py-2 text-xs",d(ie.type).wrapBg])},[e("span",{class:ae(["h-2.5 w-2.5 shrink-0 rounded-full",d(ie.type).bg])},null,2),e("span",{class:ae(["font-medium",d(ie.type).text])},n(ie.type),3),e("span",vm,n(a(s)("quotes.keywords.times",{count:ie.count})),1),p(J,{color:d(ie.type).badge,variant:"soft",size:"xs"},{default:O(()=>[ne(n(ie.percentage)+"%",1)]),_:2},1032,["color"])],2))),128))])])):P("",!0),M.value&&se.value.length===0?(o(),Q(a(ct),{key:1,text:a(s)("quotes.keywords.loading")},null,8,["text"])):P("",!0)]),item:O(({item:ie,index:xe})=>[e("div",hm,[e("div",{class:ae(["flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-sm font-bold",a(ns)(xe)])},n(xe+1),3),e("div",ym,[e("p",fm,n(ie.name),1)]),e("div",xm,[e("div",bm,[(o(!0),i(oe,null,ue(K(ie,xe),Ie=>(o(),i("div",{key:Ie.keyword,class:ae(["h-full transition-all first:rounded-l-full last:rounded-r-full",Ie.bg]),style:Ne({width:`${Ie.width}%`}),title:`${Ie.keyword}: ${Ie.width.toFixed(1)}%`},null,14,km))),128))])]),e("div",_m,[e("span",wm,n(ie.value),1),e("span",$m,n(a(s)("quotes.keywords.timesWithPercent",{count:ie.value,percent:ie.percentage})),1)])])]),empty:O(()=>[M.value?(o(),i("div",Tm)):(o(),i("div",Cm,[p(ge,{name:"i-heroicons-magnifying-glass",class:"mb-2 h-8 w-8 opacity-50"}),e("p",Sm,n(a(s)("quotes.keywords.empty")),1)]))]),_:1},8,["items","title","description","count-template"])}}}),Mm={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Lm={class:"flex items-center gap-6 sm:gap-10"},Dm={class:"min-w-0 flex-1"},Am={class:"flex flex-col gap-2 text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},qm={key:0,class:"mb-0 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},Rm={class:"flex items-baseline gap-x-1.5"},Em={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},zm={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Pm={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},jm={class:"flex items-baseline gap-x-1.5"},Fm={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Bm={class:"font-black text-3xl text-pink-500 dark:text-pink-400"},Um={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Vm={key:1,class:"mt-1 flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},Om={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Nm=["onClick"],Ym={key:0,class:"text-gray-400"},Hm={key:0,class:"hidden shrink-0 overflow-hidden rounded-lg sm:block"},Wm={class:"relative",style:{width:"360px",height:"220px"}},Km={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Qm={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Gm={class:"min-w-0 flex-1"},Jm={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},Xm={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Zm={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"},eg={class:"flex items-center gap-1.5"},tg={class:"text-[9px] font-medium uppercase tracking-widest"},ag=pe({__name:"TopicProfileCard",props:{totalMessages:{},totalWords:{},uniqueWords:{},topWords:{},topicWords:{},posTagStats:{},timeFilter:{}},emits:["wordClick"],setup(l,{emit:s}){const t=ia(()=>St(()=>import("./EChartWordcloud-B_YisOW5.js"),__vite__mapDeps([5,6,7,8,1]))),{t:c}=he(),r=l,m=s,u=k(()=>{const{startTs:E,endTs:M}=r.timeFilter??{};return E&&M?`${fe(E*1e3).format("YYYY/MM/DD")} – ${fe(M*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(M=>({word:M.word,count:M.count,percentage:M.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 E=new Map(r.posTagStats.map(A=>[A.tag,A.count])),M=(E.get("n")||0)+(E.get("ns")||0)+(E.get("nt")||0)+(E.get("nz")||0),L=(E.get("v")||0)+(E.get("vn")||0)+(E.get("vd")||0),b=(E.get("a")||0)+(E.get("ad")||0)+(E.get("an")||0),I=M+L+b;if(I===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 R=M/I,w=L/I,y=b/I;return R>.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"}:w>.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"}:y>.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"}}),$=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 E=r.topWords.reduce((b,I)=>b+I.word.length*I.count,0),M=r.topWords.reduce((b,I)=>b+I.count,0),L=E/M;return L<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"}:L>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"}}),x=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:$.value.icon,label:c("quotes.topicProfile.expressionStyle"),value:$.value.label,subtext:$.value.desc,colorClass:$.value.colorClass}]),S=["#6366f1","#ec4899","#f97316","#22c55e","#3b82f6","#8b5cf6","#14b8a6","#f43f5e"];return(E,M)=>{const L=ye;return o(),Q(a(ot),{variant:"elevated",decorative:"",class:"flex flex-col"},{default:O(()=>[e("div",Mm,[e("div",Lm,[e("div",Dm,[e("div",Am,[u.value?(o(),i("p",qm,n(u.value),1)):P("",!0),e("div",Rm,[e("span",Em,n(a(c)("quotes.topicProfile.heroPrefix")),1),e("span",zm,n(l.totalMessages.toLocaleString()),1),e("span",Pm,n(a(c)("quotes.topicProfile.heroMiddle")),1)]),e("div",jm,[e("span",Fm,n(a(c)("quotes.topicProfile.heroMiddleSecond")),1),e("span",Bm,n(l.uniqueWords.toLocaleString()),1),e("span",Um,n(a(c)("quotes.topicProfile.heroSuffix")),1)]),d.value.length>0?(o(),i("div",Vm,[e("span",Om,n(a(c)("quotes.topicProfile.topTopicsPrefix")),1),(o(!0),i(oe,null,ue(d.value,(b,I)=>(o(),i(oe,{key:b.word},[e("span",{class:"cursor-pointer font-bold text-xl transition-opacity hover:opacity-70",style:Ne({color:S[I%S.length]}),onClick:R=>m("wordClick",b.word)},n(b.word),13,Nm),I<d.value.length-1?(o(),i("span",Ym,"·")):P("",!0)],64))),128))])):P("",!0)])]),g.value.words.length>0?(o(),i("div",Hm,[e("div",Wm,[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:M[0]||(M[0]=b=>m("wordClick",b))},null,8,["data"])])])):P("",!0)])]),e("div",Km,[M[1]||(M[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",Qm,[(o(!0),i(oe,null,ue(x.value,b=>(o(),i("div",{key:b.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(L,{name:b.icon,class:ae(["mt-0.5 h-3.5 w-3.5 shrink-0",b.colorClass])},null,8,["name","class"]),e("div",Gm,[e("div",{class:ae(["truncate font-mono text-sm font-black leading-tight tabular-nums",b.colorClass])},n(b.value),3),e("div",Jm,n(b.label),1),e("div",Xm,n(b.subtext),1)])]))),128))])]),e("div",Zm,[e("div",eg,[p(L,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),M[2]||(M[2]=e("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),e("span",tg,n(a(c)("quotes.topicProfile.watermark")),1)])]),_:1})}}}),sg={class:"px-5 py-4 sm:px-6"},og={class:"mb-4 flex items-center gap-2"},ng={class:"text-[15px] font-black tracking-tight text-gray-900 dark:text-white"},rg={class:"flex flex-wrap justify-center gap-2"},lg=["onClick"],ig=pe({__name:"SharedTopicsCard",props:{sessionId:{},timeFilter:{},dictType:{},excludeWords:{}},emits:["wordClick"],setup(l,{emit:s}){const{t}=he(),c=$t(),r=l,m=s,u=k(()=>c.locale),d=f([]),g=f([]),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 $(){if(r.sessionId)try{g.value.length===0&&(g.value=await qe().getMembers(r.sessionId));const x=[...g.value].sort((I,R)=>R.messageCount-I.messageCount).slice(0,2);if(x.length<2){d.value=[];return}const S={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},[E,M]=await Promise.all([_t("/nlp/word-frequency",{...S,memberId:x[0].id}),_t("/nlp/word-frequency",{...S,memberId:x[1].id})]),L=new Map(M.words.map(I=>[I.word,I.count])),b=[];for(const I of E.words){const R=L.get(I.word);R&&b.push({word:I.word,countA:I.count,countB:R})}b.sort((I,R)=>R.countA+R.countB-(I.countA+I.countB)),d.value=b.slice(0,30)}catch(x){console.error("加载共同话题数据失败:",x),d.value=[]}}return me(()=>r.sessionId,()=>{g.value=[]}),me(()=>[r.sessionId,r.timeFilter,r.dictType,r.excludeWords],()=>{$()},{immediate:!0,deep:!0}),(x,S)=>{const E=ye;return v.value.length>0?(o(),Q(a(ot),{key:0,variant:"section"},{default:O(()=>[e("div",sg,[e("div",og,[p(E,{name:"i-heroicons-link",class:"h-4 w-4 text-emerald-500"}),e("span",ng,n(a(t)("quotes.topicProfile.sharedTopics")),1)]),e("div",rg,[(o(!0),i(oe,null,ue(v.value,(M,L)=>(o(),i("span",{key:M.word,class:ae(["cursor-pointer rounded-full px-3 py-1 text-xs font-bold transition-opacity hover:opacity-80",h[L%h.length]]),onClick:b=>m("wordClick",M.word)},n(M.word),11,lg))),128))])])]),_:1})):P("",!0)}}}),Rt="__ALL__",cg=pe({__name:"UserSelect",props:{sessionId:{},modelValue:{}},emits:["update:modelValue"],setup(l,{emit:s}){const{t}=he(),c=l,r=s,m=f([]),u=f(!1),d=k({get:()=>c.modelValue===null?Rt:String(c.modelValue),set:h=>{r("update:modelValue",h===Rt?null:parseInt(h))}}),g=k(()=>{const h=[{value:Rt,label:t("common.userSelect.allMembers")}];return m.value.forEach($=>{const x=$.groupNickname||$.accountName||$.platformId;h.push({value:String($.id),label:`${x} (${$.messageCount})`})}),h});async function v(){if(c.sessionId){u.value=!0;try{const h=await qe().getMembers(c.sessionId);m.value=h.sort(($,x)=>x.messageCount-$.messageCount)}catch(h){console.error("加载成员列表失败:",h)}finally{u.value=!1}}}return me(()=>c.sessionId,()=>{r("update:modelValue",null),v()},{immediate:!0}),(h,$)=>{const x=Ht;return o(),Q(x,{modelValue:d.value,"onUpdate:modelValue":$[0]||($[0]=S=>d.value=S),items:g.value,loading:u.value,virtualize:{estimateSize:32,overscan:10},"value-key":"value",class:"w-48"},null,8,["modelValue","items","loading"])}}}),ya=za("wordFilter",()=>{const l=f([]),s=f(null),t=f({}),c=f(!1);function r(){return`wf_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function m(b,I=[]){const R={id:r(),name:b,words:[...I],createdAt:Date.now()};return l.value.push(R),R}function u(b,I){const R=l.value.find(w=>w.id===b);R&&(I.name!==void 0&&(R.name=I.name),I.words!==void 0&&(R.words=[...I.words]))}function d(b){l.value=l.value.filter(I=>I.id!==b),s.value===b&&(s.value=null);for(const[I,R]of Object.entries(t.value))R===b&&delete t.value[I]}function g(b){s.value=b}function v(b,I){t.value[b]=I}function h(b){delete t.value[b]}function $(b){return b in t.value?t.value[b]:s.value}function x(b){const I=$(b);return I?l.value.find(w=>w.id===I)?.words??[]:[]}function S(b){return l.value.find(I=>I.id===b)}const E=k(()=>l.value.map(b=>({label:b.name,value:b.id,isDefault:b.id===s.value,wordCount:b.words.length})));function M(){c.value=!0}function L(){c.value=!1}return{schemes:l,defaultSchemeId:s,sessionSchemeOverrides:t,showWordFilterModal:c,schemeOptions:E,createScheme:m,updateScheme:u,deleteScheme:d,setDefaultScheme:g,setSessionScheme:v,clearSessionScheme:h,getActiveSchemeId:$,getExcludeWords:x,getSchemeById:S,openModal:M,closeModal:L}},{persist:!1,backendPersist:{pick:["schemes","defaultSchemeId","sessionSchemeOverrides"],key:"wordFilter"}}),dg={class:"flex flex-col",style:{height:"520px"}},ug={class:"flex items-center justify-between border-b border-gray-200 px-6 py-4 dark:border-white/5"},mg={class:"flex items-center gap-3"},gg={class:"flex h-9 w-9 items-center justify-center rounded-xl bg-linear-to-br from-pink-400 to-pink-600"},pg={class:"text-lg font-semibold text-gray-900 dark:text-white"},vg={class:"flex flex-1 overflow-hidden"},hg={class:"flex w-[200px] shrink-0 flex-col border-r border-gray-200 dark:border-white/5"},yg={class:"flex items-center justify-between px-3 py-2"},fg={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},xg={class:"flex-1 overflow-y-auto px-2 pb-2"},bg=["onClick"],kg={class:"truncate text-sm"},_g={class:"ml-auto text-xs text-gray-400 dark:text-gray-500"},wg={key:0,class:"px-3 py-8 text-center text-xs text-gray-400 dark:text-gray-500"},$g={class:"flex flex-1 flex-col overflow-hidden"},Cg={class:"flex-1 space-y-4 overflow-y-auto p-5"},Sg={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},Tg={class:"flex items-center gap-2"},Ig={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},Mg={class:"flex gap-2"},Lg={class:"mb-1.5 flex items-center justify-between"},Dg={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},Ag={class:"ml-1 text-gray-400 dark:text-gray-500"},qg={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"},Rg={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"},Eg={class:"flex shrink-0 justify-end border-t border-gray-200 px-5 py-3 dark:border-white/5"},zg={key:1,class:"flex flex-1 flex-col items-center justify-center gap-3 text-gray-400 dark:text-gray-500"},Pg={class:"text-sm"},jg=pe({__name:"WordFilterModal",setup(l){const{t:s}=he(),t=ya(),c=k({get:()=>t.showWordFilterModal,set:I=>I?t.openModal():t.closeModal()}),r=f(null),m=f(""),u=f(""),d=f(null),g=k(()=>r.value?t.getSchemeById(r.value)??null:null),v=k(()=>r.value===t.defaultSchemeId);me(c,I=>{I&&(t.schemes.length>0&&!r.value&&(r.value=t.schemes[0].id),h())}),me(r,()=>{h(),u.value=""});function h(){m.value=g.value?.name??""}function $(){const I=t.createScheme(s("wordFilter.defaultSchemeName"));r.value=I.id,ze(()=>{d.value?.focus(),d.value?.select()})}function x(){if(!r.value)return;const I=t.schemes.findIndex(R=>R.id===r.value);if(t.deleteScheme(r.value),t.schemes.length>0){const R=Math.min(I,t.schemes.length-1);r.value=t.schemes[R].id}else r.value=null}function S(){!r.value||!m.value.trim()||t.updateScheme(r.value,{name:m.value.trim()})}function E(){r.value&&(v.value?t.setDefaultScheme(null):t.setDefaultScheme(r.value))}function M(){if(!r.value||!u.value.trim())return;const R=u.value.trim().split(/[,,\n\r\t;;|、\s]+/).map(q=>q.trim()).filter(q=>q.length>0);if(R.length===0)return;const w=g.value;if(!w)return;const y=new Set(w.words.map(q=>q.toLowerCase())),A=R.filter(q=>!y.has(q.toLowerCase()));A.length>0&&t.updateScheme(r.value,{words:[...w.words,...A]}),u.value=""}function L(I){if(!r.value)return;const R=g.value;R&&t.updateScheme(r.value,{words:R.words.filter(w=>w!==I)})}function b(){r.value&&t.updateScheme(r.value,{words:[]})}return(I,R)=>{const w=ye,y=Le,A=pt,q=Yt,B=Fe;return o(),Q(B,{open:c.value,"onUpdate:open":R[4]||(R[4]=j=>c.value=j),ui:{content:"max-w-3xl z-50"}},{content:O(()=>[e("div",dg,[e("div",ug,[e("div",mg,[e("div",gg,[p(w,{name:"i-heroicons-funnel",class:"h-4.5 w-4.5 text-white"})]),e("h2",pg,n(a(s)("wordFilter.title")),1)]),p(y,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:R[0]||(R[0]=j=>c.value=!1)})]),e("div",vg,[e("div",hg,[e("div",yg,[e("span",fg,n(a(s)("wordFilter.schemeList")),1),p(y,{icon:"i-heroicons-plus",size:"xs",variant:"ghost",color:"primary",onClick:$})]),e("div",xg,[(o(!0),i(oe,null,ue(a(t).schemes,j=>(o(),i("div",{key:j.id,class:ae(["group mb-1 flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 transition-colors",r.value===j.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=j.id},[j.id===a(t).defaultSchemeId?(o(),Q(w,{key:0,name:"i-heroicons-star-solid",class:"h-3.5 w-3.5 shrink-0 text-amber-500"})):P("",!0),e("span",kg,n(j.name),1),e("span",_g,n(j.words.length),1)],10,bg))),128)),a(t).schemes.length===0?(o(),i("div",wg,n(a(s)("wordFilter.emptyScheme")),1)):P("",!0)])]),e("div",$g,[g.value?(o(),i(oe,{key:0},[e("div",Cg,[e("div",null,[e("label",Sg,n(a(s)("wordFilter.schemeName")),1),p(A,{ref_key:"nameInputRef",ref:d,modelValue:m.value,"onUpdate:modelValue":R[1]||(R[1]=j=>m.value=j),size:"sm",placeholder:a(s)("wordFilter.schemeNamePlaceholder"),onBlur:S,onKeydown:Ke(S,["enter"])},null,8,["modelValue","placeholder"])]),e("div",Tg,[p(y,{size:"xs",variant:v.value?"solid":"soft",color:v.value?"warning":"neutral",icon:v.value?"i-heroicons-star-solid":"i-heroicons-star",onClick:E},{default:O(()=>[ne(n(v.value?a(s)("wordFilter.isDefault"):a(s)("wordFilter.setDefault")),1)]),_:1},8,["variant","color","icon"]),p(y,{size:"xs",variant:"soft",color:"error",icon:"i-heroicons-trash",onClick:x},{default:O(()=>[ne(n(a(s)("wordFilter.deleteScheme")),1)]),_:1})]),e("div",null,[e("label",Ig,n(a(s)("wordFilter.addWords")),1),e("div",Mg,[p(A,{modelValue:u.value,"onUpdate:modelValue":R[2]||(R[2]=j=>u.value=j),size:"sm",class:"flex-1",placeholder:a(s)("wordFilter.addWordsPlaceholder"),onKeydown:Ke(M,["enter"])},null,8,["modelValue","placeholder"]),p(y,{size:"sm",color:"primary",icon:"i-heroicons-plus",onClick:M},{default:O(()=>[ne(n(a(s)("wordFilter.add")),1)]),_:1})])]),e("div",null,[e("div",Lg,[e("label",Dg,[ne(n(a(s)("wordFilter.wordList"))+" ",1),e("span",Ag,"("+n(g.value.words.length)+")",1)]),g.value.words.length>0?(o(),Q(y,{key:0,size:"xs",variant:"ghost",color:"error",onClick:b},{default:O(()=>[ne(n(a(s)("wordFilter.clearAll")),1)]),_:1})):P("",!0)]),g.value.words.length>0?(o(),i("div",qg,[(o(!0),i(oe,null,ue(g.value.words,j=>(o(),Q(q,{key:j,color:"neutral",variant:"subtle",class:"group/badge cursor-default gap-1 pr-1"},{default:O(()=>[ne(n(j)+" ",1),p(w,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5 cursor-pointer text-gray-400 transition-colors hover:text-red-500",onClick:_=>L(j)},null,8,["onClick"])]),_:2},1024))),128))])):(o(),i("div",Rg,n(a(s)("wordFilter.emptyWords")),1))])]),e("div",Eg,[p(y,{color:"primary",variant:"soft",onClick:R[3]||(R[3]=j=>c.value=!1)},{default:O(()=>[ne(n(a(s)("wordFilter.close")),1)]),_:1})])],64)):(o(),i("div",zg,[p(w,{name:"i-heroicons-funnel",class:"h-10 w-10"}),e("p",Pg,n(a(s)("wordFilter.selectOrCreate")),1),p(y,{size:"sm",color:"primary",variant:"soft",icon:"i-heroicons-plus",onClick:$},{default:O(()=>[ne(n(a(s)("wordFilter.createScheme")),1)]),_:1})]))])])])]),_:1},8,["open"])}}}),Fg={class:"main-content mx-auto max-w-[920px] space-y-6 p-6"},Bg={key:0,class:"flex h-64 flex-col items-center justify-center gap-4 rounded-lg border border-dashed border-gray-300 dark:border-gray-600"},Ug={class:"text-sm text-gray-500 dark:text-gray-400"},Vg={class:"flex gap-2"},Og={key:1,class:"space-y-6"},Ng={class:"flex gap-6 p-4 sm:p-6"},Yg={class:"flex min-w-0 flex-1 flex-col"},Hg={class:"relative w-full",style:{"aspect-ratio":"16 / 9"}},Wg={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"},Kg={class:"text-xs font-medium"},Qg={class:"px-4 text-center text-[11px]"},Gg={class:"mt-2 text-center text-xs text-gray-500 dark:text-gray-400"},Jg={class:"w-[280px] shrink-0 space-y-4"},Xg={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},Zg={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},ep={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},tp={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},ap={class:"space-y-2"},sp={class:"text-xs text-gray-400 dark:text-gray-500"},op={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},np={class:"flex items-center"},rp={key:0,class:"space-y-2"},lp={class:"flex items-center justify-between"},ip={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},cp={class:"flex gap-1"},dp={class:"flex max-h-[360px] flex-wrap gap-1.5 overflow-y-auto"},up={key:0,class:"ml-1 opacity-60"},mp={class:"mb-2 flex items-center justify-between"},gp={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},pp={key:0,class:"mt-1 text-xs text-gray-400 dark:text-gray-500"},vp={class:"space-y-4"},hp={class:"text-sm text-gray-600 dark:text-gray-300"},yp={class:"flex justify-end gap-2"},fp="default",aa="chatlab_zhTW_dict_prompt_dismissed",Vb=pe({__name:"WordcloudTab",props:{sessionId:{},timeFilter:{},memberId:{},showSharedTopics:{type:Boolean}},setup(l){const s=ia(()=>St(()=>import("./EChartWordcloud-B_YisOW5.js"),__vite__mapDeps([5,6,7,8,1]))),{t}=he(),c=$t(),r=dt(),m=ya(),u=Ye(),d=l,g=f(!1),v=f([]),h=f({totalMessages:0,totalWords:0,uniqueWords:0}),$=f(1.25),x=f(150),S=k(()=>{const re=v.value.slice(0,x.value),de=re.reduce((Te,Re)=>Te+Re.count,0);return{words:re.map(Te=>({word:Te.word,count:Te.count,percentage:de>0?Math.round(Te.count/de*1e4)/100:0}))}}),E=f("meaningful"),M=f(!0),L=f([]),b=f([]),I=f(new Map),R=["n","nr","ns","nt","nz","nw","vn","a","an"],w=f([]),y=k(()=>S.value.words.map(re=>({word:re.word,count:re.count,percentage:re.percentage??0}))),A=k(()=>[...I.value.entries()].map(([re,de])=>({tag:re,count:de}))),q=f(null),B=k({get:()=>m.getActiveSchemeId(d.sessionId),set:re=>m.setSessionScheme(d.sessionId,re)}),j=k(()=>[{label:t("wordFilter.noFilter"),value:"__none__"},...m.schemeOptions.map(re=>({label:re.isDefault?`${re.label} ★`:re.label,value:re.value}))]),_=k({get:()=>B.value??"__none__",set:re=>{B.value=re==="__none__"?null:re}}),T=k(()=>m.getExcludeWords(d.sessionId)),W=f("default"),ee=f([]),Y=f(!1),ce=f(null),ve=f(!1),H=k(()=>c.locale),U=k(()=>c.locale==="zh-TW"),te=k(()=>H.value.startsWith("zh")),se=k(()=>ee.value.filter(re=>re.downloaded).map(re=>({label:t(`quotes.wordcloud.dict.${re.id==="zh-CN"?"zhCN":re.id==="zh-TW"?"zhTW":re.id}`),value:re.id}))),le=k(()=>ee.value.some(re=>re.downloaded)),K=k(()=>!te.value||le.value),N=k(()=>ee.value.filter(re=>!re.downloaded));async function D(){try{ee.value=await Jt("/nlp/dicts"),U.value&&W.value==="default"&&ee.value.find(Te=>Te.id==="zh-TW")?.downloaded&&(W.value="zh-TW"),ee.value.find(de=>de.id==="zh-CN")?.downloaded&&W.value==="default"&&(W.value="zh-CN")}catch(re){console.error("Failed to get dict list:",re)}}async function C(re){Y.value=!0,ce.value=re;try{const de=await Pa(`/nlp/dicts/${re}/download`);de.success?(await D(),W.value=re,u.success(t("quotes.wordcloud.dict.downloadSuccess"))):u.fail(t("quotes.wordcloud.dict.downloadFailed"),{description:de.error})}catch{u.fail(t("quotes.wordcloud.dict.downloadFailed"))}finally{Y.value=!1,ce.value=null,ve.value=!1}}function F(){ve.value=!1,localStorage.setItem(aa,"true")}function J(){const re=ee.value.find(de=>de.id==="zh-TW");U.value&&re&&!re.downloaded&&!localStorage.getItem(aa)&&(ve.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"}]),z=[{label:"80",value:80},{label:"100",value:100},{label:"150",value:150},{label:"200",value:200},{label:"300",value:300}],Z=Math.max(...z.map(re=>re.value)),ge=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}]),ie=k(()=>b.value.map(re=>({label:re.name,tag:re.tag,value:re.tag,count:I.value.get(re.tag)||0,meaningful:re.meaningful})));async function xe(){try{const re=await Jt("/nlp/pos-tags");b.value=re,L.value=re.filter(de=>de.meaningful).map(de=>de.tag)}catch(re){console.error("加载词性标签失败:",re)}}async function Ie(){if(!(!d.sessionId||!K.value))try{const re=await _t("/nlp/word-frequency",{sessionId:d.sessionId,locale:H.value,timeFilter:d.timeFilter?{startTs:d.timeFilter.startTs,endTs:d.timeFilter.endTs}:void 0,memberId:q.value??void 0,topN:50,minCount:2,posFilterMode:"custom",customPosTags:[...R],enableStopwords:!0,dictType:W.value,excludeWords:T.value.length>0?[...T.value]:void 0});w.value=re.words.map(de=>({word:de.word,count:de.count,percentage:de.percentage}))}catch(re){console.error("加载话题迷你词云数据失败:",re),w.value=[]}}async function De(){if(!(!d.sessionId||!K.value)){g.value=!0;try{const re=await _t("/nlp/word-frequency",{sessionId:d.sessionId,locale:H.value,timeFilter:d.timeFilter?{startTs:d.timeFilter.startTs,endTs:d.timeFilter.endTs}:void 0,memberId:q.value??void 0,topN:Z,minCount:2,posFilterMode:E.value,customPosTags:E.value==="custom"?[...L.value]:void 0,enableStopwords:M.value,dictType:W.value,excludeWords:T.value.length>0?[...T.value]:void 0});if(v.value=re.words.map(de=>({word:de.word,count:de.count,percentage:de.percentage})),h.value={totalMessages:re.totalMessages,totalWords:re.totalWords,uniqueWords:re.uniqueWords},re.posTagStats){const de=new Map;for(const Te of re.posTagStats)de.set(Te.tag,Te.count);I.value=de}}catch(re){console.error("加载词频数据失败:",re),v.value=[]}finally{g.value=!1}}}me(()=>d.sessionId,()=>{q.value=null}),me(()=>[d.sessionId,d.timeFilter,q.value,E.value,M.value,W.value,T.value],()=>{De()},{immediate:!0,deep:!0}),me(()=>[d.sessionId,d.timeFilter,q.value,W.value,T.value],()=>{Ie()},{immediate:!0,deep:!0}),me(L,()=>{E.value==="custom"&&De()},{deep:!0}),me(H,()=>{De()});function $e(re){r.openChatRecordDrawer({keywords:[re]})}return Me(async()=>{xe(),await D(),J()}),(re,de)=>{const Te=ye,Re=Le,tt=da,He=Yt,Qe=Fe;return o(),i("div",Fg,[te.value&&!le.value?(o(),i("div",Bg,[p(Te,{name:"i-heroicons-arrow-down-tray",class:"text-4xl text-gray-400"}),e("p",Ug,n(a(t)("quotes.wordcloud.dict.needDownload")),1),e("div",Vg,[(o(!0),i(oe,null,ue(ee.value,V=>(o(),Q(Re,{key:V.id,size:"sm",color:"primary",loading:Y.value&&ce.value===V.id,disabled:Y.value&&ce.value!==V.id,icon:"i-heroicons-arrow-down-tray",onClick:X=>C(V.id)},{default:O(()=>[ne(n(a(t)(`quotes.wordcloud.dict.download_${V.id}`,V.label)),1)]),_:2},1032,["loading","disabled","onClick"]))),128))])])):(o(),i("div",Og,[g.value&&y.value.length===0?(o(),Q(a(ct),{key:0,text:a(t)("quotes.wordcloud.loading"),class:"py-8"},null,8,["text"])):P("",!0),p(ag,{"total-messages":h.value.totalMessages,"total-words":h.value.totalWords,"unique-words":h.value.uniqueWords,"top-words":y.value,"topic-words":w.value,"pos-tag-stats":A.value,"time-filter":d.timeFilter,onWordClick:$e},null,8,["total-messages","total-words","unique-words","top-words","topic-words","pos-tag-stats","time-filter"]),d.showSharedTopics?(o(),Q(ig,{key:1,"session-id":d.sessionId,"time-filter":d.timeFilter,"dict-type":W.value,"exclude-words":T.value,onWordClick:$e},null,8,["session-id","time-filter","dict-type","exclude-words"])):P("",!0),p(a(Ue),{title:a(t)("quotes.wordcloud.stats.wordsLabel"),"show-divider":!1},{default:O(()=>[e("div",Ng,[e("div",Yg,[e("div",Hg,[g.value?(o(),Q(a(ct),{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"])):y.value.length===0?(o(),i("div",Wg,[p(Te,{name:"i-heroicons-chat-bubble-bottom-center-text",class:"text-2xl"}),e("p",Kg,n(a(t)("quotes.wordcloud.empty.title")),1),e("p",Qg,n(a(t)("quotes.wordcloud.empty.description")),1)])):(o(),Q(a(s),{key:2,data:S.value,height:"100%","max-words":x.value,"color-scheme":fp,"size-scale":$.value,loading:g.value,onWordClick:$e},null,8,["data","max-words","size-scale","loading"]))]),e("p",Gg,n(a(t)("quotes.wordcloud.stats.clickHint")),1)]),e("div",Jg,[e("div",null,[e("h4",Xg,n(a(t)("quotes.wordcloud.config.maxWords")),1),p(a(Je),{modelValue:x.value,"onUpdate:modelValue":de[0]||(de[0]=V=>x.value=V),size:"xs",items:z},null,8,["modelValue"])]),e("div",null,[e("h4",Zg,n(a(t)("quotes.wordcloud.config.sizeScale")),1),p(a(Je),{modelValue:$.value,"onUpdate:modelValue":de[1]||(de[1]=V=>$.value=V),size:"xs",items:ge.value},null,8,["modelValue","items"])]),e("div",null,[e("h4",ep,n(a(t)("quotes.wordcloud.config.userFilter")),1),p(cg,{modelValue:q.value,"onUpdate:modelValue":de[2]||(de[2]=V=>q.value=V),"session-id":d.sessionId,class:"w-full"},null,8,["modelValue","session-id"])]),e("div",null,[e("h4",tp,n(a(t)("quotes.wordcloud.config.dict")),1),e("div",ap,[se.value.length>1?(o(),Q(a(Je),{key:0,modelValue:W.value,"onUpdate:modelValue":de[3]||(de[3]=V=>W.value=V),size:"xs",items:se.value},null,8,["modelValue","items"])):P("",!0),(o(!0),i(oe,null,ue(N.value,V=>(o(),i("div",{key:V.id,class:"flex items-center gap-2"},[p(Re,{size:"xs",variant:"soft",color:"primary",loading:Y.value&&ce.value===V.id,disabled:Y.value&&ce.value!==V.id,icon:"i-heroicons-arrow-down-tray",onClick:X=>C(V.id)},{default:O(()=>[ne(n(a(t)(`quotes.wordcloud.dict.download_${V.id}`,a(t)("quotes.wordcloud.dict.download"))),1)]),_:2},1032,["loading","disabled","onClick"]),e("span",sp,n(a(t)("quotes.wordcloud.dict.downloadHint")),1)]))),128))])]),e("div",null,[e("h4",op,n(a(t)("quotes.wordcloud.config.posFilter")),1),p(a(Je),{modelValue:E.value,"onUpdate:modelValue":de[4]||(de[4]=V=>E.value=V),size:"xs",items:G.value},null,8,["modelValue","items"])]),e("div",np,[p(tt,{modelValue:M.value,"onUpdate:modelValue":de[5]||(de[5]=V=>M.value=V),label:a(t)("quotes.wordcloud.config.enableStopwords")},null,8,["modelValue","label"])]),E.value==="custom"?(o(),i("div",rp,[e("div",lp,[e("h4",ip,n(a(t)("quotes.wordcloud.posFilter.customHint")),1),e("div",cp,[p(Re,{size:"xs",variant:"ghost",color:"neutral",onClick:de[6]||(de[6]=V=>L.value=b.value.filter(X=>X.meaningful).map(X=>X.tag))},{default:O(()=>[ne(n(a(t)("quotes.wordcloud.posFilter.selectMeaningful")),1)]),_:1}),p(Re,{size:"xs",variant:"ghost",color:"neutral",onClick:de[7]||(de[7]=V=>L.value=b.value.map(X=>X.tag))},{default:O(()=>[ne(n(a(t)("quotes.wordcloud.posFilter.selectAll")),1)]),_:1}),p(Re,{size:"xs",variant:"ghost",color:"neutral",onClick:de[8]||(de[8]=V=>L.value=[])},{default:O(()=>[ne(n(a(t)("quotes.wordcloud.posFilter.clearAll")),1)]),_:1})])]),e("div",dp,[(o(!0),i(oe,null,ue(ie.value,V=>(o(),Q(He,{key:V.value,color:L.value.includes(V.value)?"primary":"neutral",variant:L.value.includes(V.value)?"solid":"outline",class:"cursor-pointer select-none transition-colors",onClick:()=>{L.value.includes(V.value)?L.value=L.value.filter(X=>X!==V.value):L.value=[...L.value,V.value]}},{default:O(()=>[ne(n(V.label)+" ",1),V.count>0?(o(),i("span",up,"("+n(V.count)+")",1)):P("",!0)]),_:2},1032,["color","variant","onClick"]))),128))])])):P("",!0),e("div",null,[e("div",mp,[e("h4",gp,n(a(t)("wordFilter.filterScheme")),1),p(Re,{size:"xs",variant:"ghost",color:"neutral",icon:"i-heroicons-cog-6-tooth","aria-label":a(t)("wordFilter.manage"),onClick:de[9]||(de[9]=V=>a(m).openModal())},null,8,["aria-label"])]),p(a(Je),{modelValue:_.value,"onUpdate:modelValue":de[10]||(de[10]=V=>_.value=V),size:"xs",items:j.value},null,8,["modelValue","items"]),T.value.length>0?(o(),i("p",pp,n(a(t)("wordFilter.activeCount",{count:T.value.length})),1)):P("",!0)])])])]),_:1},8,["title"])])),p(Qe,{open:ve.value,"onUpdate:open":de[12]||(de[12]=V=>ve.value=V),title:a(t)("quotes.wordcloud.dict.promptTitle")},{body:O(()=>[e("div",vp,[e("p",hp,n(a(t)("quotes.wordcloud.dict.promptDescription")),1),e("div",yp,[p(Re,{variant:"ghost",color:"neutral",onClick:F},{default:O(()=>[ne(n(a(t)("quotes.wordcloud.dict.promptLater")),1)]),_:1}),p(Re,{color:"primary",loading:Y.value,onClick:de[11]||(de[11]=V=>C("zh-TW"))},{default:O(()=>[ne(n(a(t)("quotes.wordcloud.dict.promptDownload")),1)]),_:1},8,["loading"])])])]),_:1},8,["open","title"]),p(jg)])}}}),xp={class:"flex h-full flex-col"},bp={class:"flex-1 min-h-0 overflow-hidden"},kp={key:1,class:"h-full overflow-auto"},_p={class:"main-content mx-auto max-w-3xl p-6"},wp=pe({__name:"AITab",props:{sessionId:{},sessionName:{},timeFilter:{},chatType:{},mode:{}},setup(l,{expose:s}){const{t}=he(),c=Ya(),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=f(r.mode==="sql-only"?"sql-lab":c.query.aiSubTab||"chat-explorer");me(()=>c.query.aiSubTab,v=>{if(r.mode==="sql-only"){(v==="keyword"||v==="sql-lab")&&(u.value=v);return}(v==="chat-explorer"||v==="sql-lab")&&(u.value=v)});const d=f(null);function g(){d.value?.refreshConfig()}return s({refreshAIConfig:g}),(v,h)=>(o(),i("div",xp,[p(a(ra),{modelValue:u.value,"onUpdate:modelValue":h[0]||(h[0]=$=>u.value=$),items:m.value,"persist-key":"aiTab"},null,8,["modelValue","items"]),e("div",bp,[p(st,{name:"fade",mode:"out-in"},{default:O(()=>[u.value==="chat-explorer"?(o(),Q(a(Kd),{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"?(o(),i("div",kp,[e("div",_p,[p(a(Im),{"session-id":r.sessionId,"time-filter":r.timeFilter},null,8,["session-id","time-filter"])])])):(o(),Q(z0,{key:2,class:"h-full","session-id":r.sessionId,"chat-type":r.chatType},null,8,["session-id","chat-type"]))]),_:1})])]))}}),Ob=et(wp,[["__scopeId","data-v-0df46b7b"]]),$p={class:"flex h-full items-center justify-center"},Cp={class:"max-w-sm text-center"},Sp={class:"mt-3 text-sm text-gray-400 dark:text-gray-500"},Tp=["href"],Nb=pe({__name:"MemoryTab",props:{sessionId:{},sessionName:{}},setup(l){const{t:s,te:t}=he(),c=k(()=>t("analysis.memory.joinLink")?s("analysis.memory.joinLink"):"");return(r,m)=>{const u=ye;return o(),i("div",$p,[e("div",Cp,[p(u,{name:"i-heroicons-light-bulb",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),e("p",Sp,n(a(s)("analysis.memory.comingSoon")),1),c.value?(o(),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"},n(c.value),9,Tp)):P("",!0)])])}}}),Ip={class:"flex h-full flex-col"},Mp={class:"relative z-20 flex items-center gap-2 border-b border-gray-200 px-4 py-2 dark:border-gray-700"},Lp={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"},Dp={class:"flex-1 overflow-auto"},Ap={key:0,class:"flex h-full items-center justify-center"},qp={class:"text-sm text-gray-400"},Rp={key:1,class:"w-full border-collapse text-xs"},Ep={class:"sticky top-0 bg-gray-50 dark:bg-gray-800"},zp={class:"font-mono text-xs font-medium text-gray-700 dark:text-gray-300"},Pp={class:"text-[10px] leading-tight text-gray-400"},jp={class:"border-b border-r border-gray-100 px-2 py-1.5 text-gray-400 dark:border-gray-800"},Fp=["title"],Bp=["onUpdate:modelValue"],Up={class:"w-full truncate px-2 py-1.5"},Vp={key:0,class:"italic text-gray-400"},Op={key:1},Np={class:"border-b border-gray-100 px-2 py-1.5 text-center dark:border-gray-800"},Yp={key:0,class:"flex items-center justify-center gap-1"},Hp={key:1,class:"flex items-center justify-center gap-1"},Wp={class:"flex items-center justify-between border-t border-gray-200 px-4 py-2 dark:border-gray-700"},Kp={class:"text-xs text-gray-500 dark:text-gray-400"},Qp={key:0,class:"flex items-center gap-3"},Gp={class:"text-xs text-gray-500 dark:text-gray-400"},kt=100,Jp=pe({__name:"TableBrowser",props:{sessionId:{}},setup(l){const s=["member","meta","message","message_context","member_name_history"],{t,locale:c}=he(),r=l,m=f(localStorage.getItem("debug_dbSource")||"chat"),u=f([]),d=f(""),g=f(null),v=f(!1),h=f(null),$=f(1),x=f(0),S=k(()=>Math.max(1,Math.ceil(x.value/kt))),E=f(null),M=f({}),L=f(!1),b=k(()=>m.value==="ai"),I=f([]),R=f(""),w=k(()=>b.value&&d.value==="ai_message"&&I.value.length>0),y=k(()=>{const K={label:t("analysis.debug.tableBrowser.allConversations"),value:"__all__"},N=I.value.map(D=>({label:D.title||D.id.slice(0,16),value:D.id}));return[K,...N]});async function A(){if(!b.value){I.value=[];return}try{const K=r.sessionId.replace(/'/g,"''"),N=await je().executeAiSQL(`SELECT id, title FROM ai_chat WHERE session_id = '${K}' ORDER BY updated_at DESC`);I.value=N.rows.map(D=>({id:String(D[0]),title:D[1]?String(D[1]):null})),R.value="__all__"}catch{I.value=[]}}const q=k(()=>[{label:t("analysis.debug.tableBrowser.chatDb"),value:"chat"},{label:t("analysis.debug.tableBrowser.aiDb"),value:"ai"}]),B=k(()=>{const K=[...u.value];return K.sort((N,D)=>{const C=s.indexOf(N.name),F=s.indexOf(D.name);return C!==-1&&F!==-1?C-F:C!==-1?-1:F!==-1?1:0}),K}),j=k(()=>B.value.map(K=>({label:K.name,value:K.name})));async function _(K){return m.value==="ai"?await je().executeAiSQL(K):await qe().executeSQL(r.sessionId,K)}async function T(){try{if(m.value==="ai"?u.value=await je().getAiSchema():u.value=await qe().getSchema(r.sessionId),B.value.length>0){const K=b.value?"ai_message":B.value[0].name;d.value=B.value.some(N=>N.name===K)?K:B.value[0].name}else d.value="",g.value=null}catch(K){console.error("Failed to load schema:",K)}}function W(){if(!b.value)return"";const K=r.sessionId.replace(/'/g,"''"),N=d.value;return N==="ai_chat"?` WHERE "session_id" = '${K}'`:N==="ai_message"?R.value&&R.value!=="__all__"?` WHERE "ai_chat_id" = '${R.value.replace(/'/g,"''")}'`:` WHERE "ai_chat_id" IN (SELECT "id" FROM "ai_chat" WHERE "session_id" = '${K}')`:""}async function ee(){if(d.value){v.value=!0,h.value=null,E.value=null;try{const K=W(),N=await _(`SELECT COUNT(*) as cnt FROM "${d.value}"${K}`);x.value=N?.rows?.[0]?.[0]??0;const D=($.value-1)*kt;g.value=await _(`SELECT * FROM "${d.value}"${K} ORDER BY rowid DESC LIMIT ${kt} OFFSET ${D}`)}catch(K){h.value=K.message||String(K),g.value=null}finally{v.value=!1}}}function Y(K){if(!g.value)return;E.value=K;const N=g.value.rows[K],D={};g.value.columns.forEach((C,F)=>{D[C]=N[F]==null?"":String(N[F])}),M.value=D}function ce(){E.value=null,M.value={}}async function ve(){if(E.value===null||!g.value)return;const K=d.value,N=u.value.find(Z=>Z.name===K);if(!N)return;const D=N.columns.find(Z=>Z.pk);if(!D){h.value="No primary key found for this table";return}const C=g.value.rows[E.value],F=g.value.columns.indexOf(D.name),J=C[F],G=g.value.columns.filter(Z=>Z!==D.name).map(Z=>`"${Z}" = '${M.value[Z].replace(/'/g,"''")}'`).join(", "),z=`UPDATE "${K}" SET ${G} WHERE "${D.name}" = '${String(J).replace(/'/g,"''")}'`;try{await _(z),ce(),await ee()}catch(Z){h.value=Z.message||String(Z)}}async function H(K){if(!g.value)return;const N=d.value,D=u.value.find(Z=>Z.name===N);if(!D)return;const C=D.columns.find(Z=>Z.pk);if(!C){h.value="No primary key found for this table";return}const F=g.value.rows[K],J=g.value.columns.indexOf(C.name),G=F[J],z=`DELETE FROM "${N}" WHERE "${C.name}" = '${String(G).replace(/'/g,"''")}'`;try{await _(z),await ee()}catch(Z){h.value=Z.message||String(Z)}}function U(K){confirm(t("analysis.debug.tableBrowser.confirmDelete"))&&H(K)}async function te(){if(confirm(t("analysis.debug.tableBrowser.confirmClearDebug"))){L.value=!0;try{(await je().clearDebugContext()).success&&await ee()}catch(K){h.value=K.message||String(K)}finally{L.value=!1}}}function se(K){navigator.clipboard.writeText(K)}function le(K,N,D){if(!g.value)return[];const C=K==null?"NULL":String(K),F=g.value.rows[D],J={};return g.value.columns.forEach((G,z)=>{J[G]=F[z]}),[[{label:t("analysis.debug.tableBrowser.copyCell"),class:"p-2",onSelect:()=>se(C)},{label:t("analysis.debug.tableBrowser.editRow"),class:"p-2",onSelect:()=>Y(D)},{label:t("analysis.debug.tableBrowser.copyRow"),class:"p-2",onSelect:()=>se(JSON.stringify(J,null,2))},{label:t("analysis.debug.tableBrowser.deleteRow"),class:"p-2 text-red-600 dark:text-red-400",onSelect:()=>H(D)}]]}return me(m,K=>{localStorage.setItem("debug_dbSource",K),d.value="",g.value=null,x.value=0,$.value=1,R.value="",T(),A()}),me(d,K=>{K&&($.value=1,ee())}),me(R,()=>{d.value==="ai_message"&&($.value=1,ee())}),me($,()=>{ee()}),Me(async()=>{await Promise.all([T(),A()]),d.value&&await ee()}),(K,N)=>{const D=Ht,C=Le,F=ua;return o(),i("div",Ip,[e("div",Mp,[p(a(Je),{modelValue:m.value,"onUpdate:modelValue":N[0]||(N[0]=J=>m.value=J),items:q.value,size:"xs"},null,8,["modelValue","items"]),N[5]||(N[5]=e("div",{class:"mx-1 h-4 w-px bg-gray-200 dark:bg-gray-700"},null,-1)),e("div",{class:ae([b.value?"max-w-[50%]":"flex-1","min-w-0"])},[p(a(Je),{modelValue:d.value,"onUpdate:modelValue":N[1]||(N[1]=J=>d.value=J),items:j.value,size:"xs"},null,8,["modelValue","items"])],2),w.value?(o(),Q(D,{key:0,modelValue:R.value,"onUpdate:modelValue":N[2]||(N[2]=J=>R.value=J),items:y.value,"value-key":"value",class:"w-48",size:"xs",ui:{content:"z-50"}},null,8,["modelValue","items"])):P("",!0),N[6]||(N[6]=e("div",{class:"flex-1"},null,-1)),b.value&&d.value==="ai_message"?(o(),Q(C,{key:1,variant:"ghost",size:"xs",color:"error",icon:"i-heroicons-trash",loading:L.value,onClick:te},{default:O(()=>[ne(n(a(t)("analysis.debug.tableBrowser.clearDebugContext")),1)]),_:1},8,["loading"])):P("",!0),p(C,{variant:"ghost",size:"xs",icon:"i-heroicons-arrow-path",loading:v.value,onClick:ee},{default:O(()=>[ne(n(a(t)("analysis.debug.tableBrowser.refresh")),1)]),_:1},8,["loading"])]),h.value?(o(),i("div",Lp,n(h.value),1)):P("",!0),e("div",Dp,[!g.value&&!v.value?(o(),i("div",Ap,[e("p",qp,n(a(t)("analysis.debug.tableBrowser.noData")),1)])):g.value?(o(),i("table",Rp,[e("thead",Ep,[e("tr",null,[N[7]||(N[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)),(o(!0),i(oe,null,ue(g.value.columns,J=>(o(),i("th",{key:J,class:"border-b border-r border-gray-200 px-2 py-1.5 text-left dark:border-gray-700"},[e("div",zp,n(J),1),e("div",Pp,n(a(Gt)(d.value,J,a(c))),1)]))),128)),N[8]||(N[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,[(o(!0),i(oe,null,ue(g.value.rows,(J,G)=>(o(),i("tr",{key:G,class:"transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[e("td",jp,n(($.value-1)*kt+G+1),1),(o(!0),i(oe,null,ue(J,(z,Z)=>(o(),i("td",{key:Z,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:z==null?"NULL":String(z)},[E.value===G?Be((o(),i("input",{key:0,"onUpdate:modelValue":ge=>M.value[g.value.columns[Z]]=ge,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,Bp)),[[at,M.value[g.value.columns[Z]]]]):(o(),Q(F,{key:1,items:le(z,Z,G)},{default:O(()=>[e("div",Up,[z==null?(o(),i("span",Vp,"NULL")):(o(),i("span",Op,n(String(z).slice(0,200)),1))])]),_:2},1032,["items"]))],8,Fp))),128)),e("td",Np,[E.value===G?(o(),i("div",Yp,[p(C,{size:"xs",color:"primary",variant:"ghost",icon:"i-heroicons-check",onClick:ve}),p(C,{size:"xs",color:"neutral",variant:"ghost",icon:"i-heroicons-x-mark",onClick:ce})])):(o(),i("div",Hp,[p(C,{size:"xs",variant:"ghost",icon:"i-heroicons-pencil-square",onClick:z=>Y(G)},null,8,["onClick"]),p(C,{size:"xs",variant:"ghost",color:"error",icon:"i-heroicons-trash",onClick:z=>U(G)},null,8,["onClick"])]))])]))),128))])])):P("",!0)]),e("div",Wp,[e("span",Kp,n(x.value>0?a(t)("analysis.debug.tableBrowser.rowCount",{count:x.value}):""),1),S.value>1?(o(),i("div",Qp,[p(C,{size:"xs",variant:"ghost",disabled:$.value<=1,icon:"i-heroicons-chevron-left",onClick:N[3]||(N[3]=J=>$.value--)},null,8,["disabled"]),e("span",Gp,n(a(t)("analysis.debug.tableBrowser.page",{current:$.value,total:S.value})),1),p(C,{size:"xs",variant:"ghost",disabled:$.value>=S.value,icon:"i-heroicons-chevron-right",onClick:N[4]||(N[4]=J=>$.value++)},null,8,["disabled"])])):P("",!0)])])}}}),Xp={class:"flex h-full"},Zp={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"},ev={key:0,class:"py-2"},tv={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},av=["title","onClick"],sv={class:"truncate text-xs font-medium"},ov={class:"truncate text-[10px] opacity-50"},nv={key:1,class:"border-t border-gray-200 py-2 dark:border-gray-700"},rv={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},lv=["title","onClick"],iv={class:"truncate text-xs font-medium"},cv={class:"truncate text-[10px] opacity-50"},dv={class:"flex flex-1 flex-col gap-4 overflow-y-auto p-4"},uv={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"},mv={class:"text-sm font-medium text-primary-700 dark:text-primary-300"},gv={class:"mt-1 text-xs text-primary-600/70 dark:text-primary-400/70"},pv={key:1,class:"flex flex-col gap-3"},vv={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},hv={class:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3"},yv={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},fv={key:0,class:"text-red-500"},xv={key:1,class:"ml-1 text-gray-400"},bv={key:2,class:"ml-1 text-gray-400"},kv={class:"flex items-center gap-3"},_v={key:3,class:"text-xs text-gray-500 dark:text-gray-400"},wv={key:2,class:"flex-1 min-h-0"},$v={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},Cv={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"},Sv={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"},Tv={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"},Iv=pe({__name:"ToolTestTab",props:{sessionId:{}},setup(l){const{t:s}=he(),t=l,c=f([]),r=f(""),m=f({}),u=f(!1),d=f(null),g=f(null),v=f(null),h=f(!1),$=f(null);function x(w){const y=`ai.chat.message.tools.${w}`,A=s(y);return A!==y?A:w}const S=k(()=>c.value.filter(w=>w.category==="core")),E=k(()=>c.value.filter(w=>w.category==="analysis")),M=k(()=>c.value.find(w=>w.name===r.value)),L=k(()=>{const w=M.value;if(!w?.parameters)return[];const y=w.parameters;if(!y.properties)return[];const A=new Set(y.required??[]);return Object.entries(y.properties).map(([q,B])=>{const j={name:q,type:B.type??"string",description:B.description??"",required:A.has(q),defaultValue:B.default};if(B.enum&&(j.enumValues=B.enum),B.type==="array"){j.isArray=!0;const _=B.items;j.arrayItemType=_?.type??"string"}return j})});me(r,()=>{m.value={},g.value=null,v.value=null,$.value=null}),Me(async()=>{try{c.value=await je().getToolCatalog(),c.value.length>0&&(r.value=c.value[0].name)}catch(w){console.error("Failed to load tool catalog:",w)}});function b(){const w={};for(const y of L.value){const A=m.value[y.name];if(!(A===void 0||A===""))if(y.type==="number"){const q=Number(A);isNaN(q)||(w[y.name]=q)}else y.isArray?w[y.name]=A.split(",").map(q=>q.trim()).filter(Boolean):w[y.name]=A}return w}async function I(){if(!r.value||u.value)return;u.value=!0,g.value=null,v.value=null,h.value=!1,$.value=null;const w=`tool_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;d.value=w;try{const y=b(),A=await je().executeTool(w,r.value,y,t.sessionId);if(A.error==="cancelled")return;A.success?($.value=A.elapsed??null,h.value=!!A.truncated,g.value=A.truncated?A.details?._preview??"":JSON.stringify(A.details??A.content,null,2)):v.value=A.error??"Unknown error"}catch(y){v.value=String(y)}finally{u.value=!1,d.value=null}}async function R(){d.value&&(await je().cancelToolTest(d.value),u.value=!1,d.value=null)}return(w,y)=>{const A=Ht,q=pt,B=Le,j=ye;return o(),i("div",Xp,[e("div",Zp,[S.value.length>0?(o(),i("div",ev,[e("div",tv,n(a(s)("ai.lab.toolTest.coreTools")),1),(o(!0),i(oe,null,ue(S.value,_=>(o(),i("button",{key:_.name,class:ae(["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:T=>r.value=_.name},[e("span",sv,n(x(_.name)),1),e("span",ov,n(_.name),1)],10,av))),128))])):P("",!0),E.value.length>0?(o(),i("div",nv,[e("div",rv,n(a(s)("ai.lab.toolTest.analysisTools")),1),(o(!0),i(oe,null,ue(E.value,_=>(o(),i("button",{key:_.name,class:ae(["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:T=>r.value=_.name},[e("span",iv,n(x(_.name)),1),e("span",cv,n(_.name),1)],10,lv))),128))])):P("",!0)]),e("div",dv,[M.value?(o(),i("div",uv,[e("div",mv,n(x(M.value.name)),1),e("div",gv,n(M.value.description),1)])):P("",!0),L.value.length>0?(o(),i("div",pv,[e("h3",vv,n(a(s)("ai.lab.toolTest.parameters")),1),e("div",hv,[(o(!0),i(oe,null,ue(L.value,_=>(o(),i("div",{key:_.name,class:"flex flex-col gap-1"},[e("label",yv,[ne(n(_.name)+" ",1),_.required?(o(),i("span",fv,"*")):P("",!0),_.type==="number"?(o(),i("span",xv,"(number)")):P("",!0),_.isArray?(o(),i("span",bv,"("+n(_.arrayItemType)+"[])",1)):P("",!0)]),_.enumValues?(o(),Q(A,{key:0,modelValue:m.value[_.name],"onUpdate:modelValue":T=>m.value[_.name]=T,items:_.enumValues,placeholder:_.description,size:"sm"},null,8,["modelValue","onUpdate:modelValue","items","placeholder"])):(o(),Q(q,{key:1,modelValue:m.value[_.name],"onUpdate:modelValue":T=>m.value[_.name]=T,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))])])):P("",!0),e("div",kv,[u.value?(o(),Q(B,{key:1,color:"error",icon:"i-heroicons-stop",onClick:R},{default:O(()=>[ne(n(a(s)("ai.lab.toolTest.cancel")),1)]),_:1})):(o(),Q(B,{key:0,color:"primary",disabled:!r.value,icon:"i-heroicons-play",onClick:I},{default:O(()=>[ne(n(a(s)("ai.lab.toolTest.execute")),1)]),_:1},8,["disabled"])),u.value?(o(),Q(j,{key:2,name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin text-gray-400"})):P("",!0),$.value!==null?(o(),i("span",_v,n(a(s)("ai.lab.toolTest.elapsed",{ms:$.value})),1)):P("",!0)]),g.value||v.value?(o(),i("div",wv,[e("h3",$v,n(a(s)("ai.lab.toolTest.result")),1),v.value?(o(),i("div",Cv,n(v.value),1)):(o(),i(oe,{key:1},[h.value?(o(),i("div",Sv,n(a(s)("ai.lab.toolTest.truncated")),1)):P("",!0),e("pre",Tv,n(g.value),1)],64))])):P("",!0)])])}}}),Mv={class:"flex h-full flex-col"},Lv={class:"min-h-0 flex-1 overflow-hidden"},Dv=pe({__name:"DebugTab",props:{sessionId:{}},setup(l){const{t:s}=he(),t=l,c=[{id:"sql-tables",label:s("analysis.debug.sqlTables"),icon:"i-heroicons-table-cells"},{id:"basic-tools",label:s("analysis.debug.basicTools"),icon:"i-heroicons-wrench-screwdriver"}],r=f("sql-tables");return(m,u)=>(o(),i("div",Mv,[p(a(ra),{modelValue:r.value,"onUpdate:modelValue":u[0]||(u[0]=d=>r.value=d),items:c,"persist-key":"debugTab"},null,8,["modelValue"]),e("div",Lv,[p(st,{name:"fade",mode:"out-in"},{default:O(()=>[r.value==="sql-tables"?(o(),Q(Jp,{key:0,class:"h-full","session-id":t.sessionId},null,8,["session-id"])):r.value==="basic-tools"?(o(),Q(Iv,{key:1,class:"h-full","session-id":t.sessionId},null,8,["session-id"])):P("",!0)]),_:1})])]))}}),Yb=et(Dv,[["__scopeId","data-v-d712cb76"]]);var Se=(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))(Se||{});const Av={[Se.TEXT]:"text",[Se.IMAGE]:"image",[Se.VOICE]:"voice",[Se.VIDEO]:"video",[Se.FILE]:"file",[Se.EMOJI]:"emoji",[Se.LINK]:"link",[Se.LOCATION]:"location",[Se.RED_PACKET]:"redPacket",[Se.TRANSFER]:"transfer",[Se.POKE]:"poke",[Se.CALL]:"call",[Se.SHARE]:"share",[Se.REPLY]:"reply",[Se.FORWARD]:"forward",[Se.CONTACT]:"contact",[Se.SYSTEM]:"system",[Se.RECALL]:"recall",[Se.OTHER]:"other"};function Ot(l,s){const t=Av[l];return s&&t?s(`common.messageType.${t}`):s?s("common.messageType.unknown"):"未知"}function Hb(l){const s=k(()=>Va(l)),t=k(()=>{const r=s.value;return r.length<2?!1:new Set(r.map(u=>fe(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=>fe(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 $=Math.floor(h.length/2),x=h[$].date,S=t.value?"YYYY/MM/DD":"MM/DD";d.push(fe(x).format(S));const E=h.reduce((L,b)=>L+b.messageCount,0),M=Math.round(E/h.length);g.push(M)}return{labels:d,values:g}});return{isMultiYear:t,dailyChartData:c}}function qv(l,s){const{t}=he(),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(y=>y.type===1)?.count||0),h=k(()=>l.hourlyActivity.length?l.hourlyActivity.reduce((w,y)=>y.messageCount>w.messageCount?y:w,l.hourlyActivity[0]):null),$=k(()=>s.value.length?s.value.reduce((w,y)=>y.messageCount>w.messageCount?y:w,s.value[0]):null),x=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")]),S=k(()=>{if(!s.value.length)return{weekday:0,weekend:0};const w=s.value.filter(q=>q.weekday>=1&&q.weekday<=5).reduce((q,B)=>q+B.messageCount,0),y=s.value.filter(q=>q.weekday>=6&&q.weekday<=7).reduce((q,B)=>q+B.messageCount,0),A=w+y;return{weekday:A>0?Math.round(w/A*100):0,weekend:A>0?Math.round(y/A*100):0}}),E=k(()=>l.dailyActivity.length?l.dailyActivity.reduce((w,y)=>y.messageCount>w.messageCount?y:w,l.dailyActivity[0]):null),M=k(()=>l.dailyActivity.filter(w=>w.messageCount>0).length),L=k(()=>{if(!l.timeRange)return 0;const w=fe.unix(l.timeRange.start);return fe.unix(l.timeRange.end).diff(w,"day")+1}),b=k(()=>L.value>0?Math.round(M.value/L.value*100):0),I=k(()=>{if(!l.hourlyActivity.length)return{count:0,ratio:0};const w=l.hourlyActivity.reduce((A,q)=>A+q.messageCount,0),y=l.hourlyActivity.filter(A=>A.hour>=0&&A.hour<=4).reduce((A,q)=>A+q.messageCount,0);return{count:y,ratio:w>0?Math.round(y/w*100):0}}),R=k(()=>{if(!l.dailyActivity.length)return 0;const w=[...l.dailyActivity].filter(q=>q.messageCount>0).sort((q,B)=>fe(q.date).valueOf()-fe(B.date).valueOf());if(w.length===0)return 0;let y=1,A=1;for(let q=1;q<w.length;q++){const B=fe(w[q-1].date);fe(w[q].date).diff(B,"day")===1?A++:(A>y&&(y=A),A=1)}return A>y&&(y=A),y});return{durationDays:c,displayMessageCount:r,displayMemberCount:m,dailyAvgMessages:g,totalDurationDays:u,totalDailyAvgMessages:d,imageCount:v,peakHour:h,peakWeekday:$,weekdayNames:x,weekdayVsWeekend:S,peakDay:E,activeDays:M,totalDays:L,activeRate:b,lateNightChat:I,maxConsecutiveDays:R}}const Rv={key:0,class:"relative z-10 px-6 pb-6 pt-2 sm:px-8"},Ev={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},zv={class:"min-w-0"},Pv={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},jv={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Fv={key:1,class:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4"},Bv={class:"text-sm text-gray-500"},Uv={class:"text-sm text-gray-500"},Vv={class:"ml-1 font-semibold text-pink-500"},Ov={class:"text-sm text-gray-500"},Nv={class:"text-sm text-gray-500"},Yv={class:"text-sm text-gray-500"},Hv={class:"text-sm text-gray-500"},Wv={class:"text-sm text-gray-500"},Kv={class:"text-sm text-gray-500"},Qv=pe({__name:"OverviewStatCards",props:{dailyAvgMessages:{},durationDays:{},imageCount:{},peakHour:{},peakWeekday:{},weekdayNames:{},weekdayVsWeekend:{},peakDay:{},activeDays:{},totalDays:{},activeRate:{},lateNightCount:{},lateNightRatio:{},maxConsecutiveDays:{},flat:{type:Boolean,default:!1}},setup(l){const{t:s}=he(),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?fe(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=ye;return l.flat?(o(),i("div",Rv,[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",Ev,[(o(!0),i(oe,null,ue(c.value,d=>(o(),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:ae(["mt-0.5 h-3.5 w-3.5 shrink-0",d.colorClass])},null,8,["name","class"]),e("div",zv,[e("div",{class:ae(["truncate font-mono text-sm font-black leading-tight tabular-nums",d.colorClass])},n(d.value),3),e("div",Pv,n(d.label),1),e("div",jv,n(d.subtext),1)])]))),128))])])):(o(),i("div",Fv,[p(a(Ge),{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:O(()=>[e("span",Bv,n(a(s)("analysis.overview.statCards.daysCount",{count:l.durationDays})),1)]),_:1},8,["label","value"]),p(a(Ge),{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:O(()=>[e("span",Uv,n(a(s)("analysis.overview.statCards.peakHour")),1),e("span",Vv,n(l.peakHour?.hour||0)+":00",1)]),_:1},8,["label","value"]),p(a(Ge),{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:O(()=>[e("span",Ov,n(a(s)("analysis.overview.statCards.messagesOnDay",{count:l.peakWeekday?.messageCount??0})),1)]),_:1},8,["label","value"]),p(a(Ge),{label:a(s)("analysis.overview.statCards.weekendActivity"),value:`${l.weekdayVsWeekend.weekend}%`,icon:"i-heroicons-sun","icon-bg":"green"},{subtext:O(()=>[e("span",Nv,n(a(s)("analysis.overview.statCards.weekendRatio")),1)]),_:1},8,["label","value"]),p(a(Ge),{label:a(s)("analysis.overview.statCards.mostActiveDate"),value:l.peakDay?a(fe)(l.peakDay.date).format("MM/DD"):"-",icon:"i-heroicons-fire","icon-bg":"red"},{subtext:O(()=>[e("span",Yv,n(a(s)("analysis.overview.statCards.messagesOnDay",{count:l.peakDay?.messageCount??0})),1)]),_:1},8,["label","value"]),p(a(Ge),{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:O(()=>[e("span",Hv,n(a(s)("analysis.overview.statCards.lateNightRatio",{ratio:l.lateNightRatio})),1)]),_:1},8,["label","value"]),p(a(Ge),{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:O(()=>[e("span",Wv,n(a(s)("analysis.overview.statCards.longestStreak")),1)]),_:1},8,["label","value"]),p(a(Ge),{label:a(s)("analysis.overview.statCards.activityRate"),value:`${l.activeRate}%`,icon:"i-heroicons-chart-bar","icon-bg":"gray"},{subtext:O(()=>[e("span",Kv,n(a(s)("analysis.overview.statCards.activeDaysRatio")),1)]),_:1},8,["label","value"])]))}}}),Gv={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Jv={class:"text-3xl font-bold tracking-tight text-gray-900 dark:text-gray-100"},Xv={class:"mt-4 flex items-start gap-6 sm:gap-24"},Zv={class:"min-w-0 flex flex-col gap-2 text-sm font-medium text-gray-500 dark:text-gray-400"},eh={class:"flex items-center gap-2"},th={class:"flex h-6 w-6 shrink-0 items-center justify-center"},ah={class:"whitespace-nowrap"},sh={key:0,class:"flex items-center gap-2"},oh={class:"flex h-6 w-6 shrink-0 items-center justify-center"},nh={class:"font-mono text-xs opacity-90 whitespace-nowrap"},rh={class:"flex shrink-0 gap-6"},lh={class:"flex flex-col gap-1 text-center"},ih={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},ch={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},dh={class:"flex flex-col gap-1 text-center"},uh={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},mh={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},gh={class:"flex flex-col gap-1 text-center"},ph={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},vh={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},hh={class:"flex flex-col gap-1 text-center"},yh={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},fh={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},xh={class:"relative z-10 px-6 pb-2 sm:px-8"},bh={class:"overflow-x-auto overflow-y-hidden scrollbar-hide py-1"},Wb=pe({__name:"OverviewIdentityCard",props:{session:{},dailyActivity:{},messageTypes:{},hourlyActivity:{},timeRange:{},selectedYear:{},filteredMessageCount:{},timeFilter:{}},setup(l){vt([Kt,Za,va,It,Qt,ht]);const{t:s,locale:t}=he(),c=mt(),r=l,m=f([]);async function u(){if(r.session.id)try{m.value=await qe().getWeekdayActivity(r.session.id,r.timeFilter)}catch(H){console.error("加载星期活跃度失败:",H)}}me(()=>[r.session.id,r.timeFilter],()=>u(),{immediate:!0,deep:!0});const{durationDays:d,displayMessageCount:g,dailyAvgMessages:v,imageCount:h,peakHour:$,peakWeekday:x,weekdayNames:S,weekdayVsWeekend:E,peakDay:M,activeDays:L,totalDays:b,activeRate:I,lateNightChat:R,maxConsecutiveDays:w}=qv(r,m),y=f(null);let A=null;const q=k(()=>r.timeRange?Pt(r.timeRange.start,r.timeRange.end,"YYYY/MM/DD"):""),B=k(()=>{const H=new Date,U=new Date(H);U.setFullYear(U.getFullYear()-1),U.setDate(U.getDate()+1);const te=se=>se.toISOString().slice(0,10);return[te(U),te(H)]}),j=k(()=>{const[H,U]=B.value,te=new Date(H+"T00:00:00Z"),se=new Date(U+"T00:00:00Z"),le=new Map;r.dailyActivity.filter(D=>D.date>=H&&D.date<=U).forEach(D=>le.set(D.date,D.messageCount));const K=[],N=new Date(te);for(;N<=se;){const D=N.toISOString().slice(0,10),C=le.get(D)||0;K.push({value:[D,C],itemStyle:C===0?{color:W.value}:void 0}),N.setUTCDate(N.getUTCDate()+1)}return K}),_=k(()=>r.dailyActivity.length===0?10:Math.max(...r.dailyActivity.map(H=>H.messageCount),1)),T={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"),ee=k(()=>({tooltip:{trigger:"item",formatter:H=>{const U=H.value[0],te=H.value[1];return`${U}<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?T.dark:T.light},textStyle:{color:c.value?"#8b949e":"#6b7280",fontSize:10},show:!0},calendar:{top:20,left:30,cellSize:[13,13],range:B.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:j.value,renderItem:(H,U)=>{const te=U.coord(U.value(0)),se=H.coordSys.cellWidth,le=H.coordSys.cellHeight,K=Math.min(se,le)-3;return{type:"rect",shape:{x:te[0]-K/2,y:te[1]-K/2,width:K,height:K,r:3},style:{fill:U.visual("color")}}},itemStyle:{borderColor:c.value?"transparent":"rgba(0,0,0,0.02)",borderWidth:1}}]}));function Y(){y.value&&(A=yt(y.value,void 0,{renderer:"canvas"}),A.setOption({backgroundColor:"transparent",...ee.value}))}function ce(){A&&A.setOption({backgroundColor:"transparent",...ee.value},{notMerge:!0})}function ve(){A?.resize()}return me([()=>r.dailyActivity,t],()=>ce()),me(c,()=>{A?.dispose(),Y()}),Me(()=>{Y(),window.addEventListener("resize",ve)}),it(()=>{window.removeEventListener("resize",ve),A?.dispose()}),(H,U)=>{const te=ye;return o(),Q(a(ot),{variant:"elevated",decorative:"",class:"flex flex-col"},{default:O(()=>[e("div",Gv,[e("h2",Jv,n(l.session.name),1),e("div",Xv,[e("div",Zv,[e("div",eh,[e("div",th,[l.session.type==="group"?(o(),Q(te,{key:0,name:"i-heroicons-user-group",class:"h-4 w-4 opacity-70"})):(o(),Q(te,{key:1,name:"i-heroicons-user",class:"h-4 w-4 opacity-70"}))]),e("span",ah,n(l.session.platform.toUpperCase())+" · "+n(l.session.type==="private"?a(s)("analysis.overview.identity.privateChat"):a(s)("analysis.overview.identity.groupChat")),1)]),q.value?(o(),i("div",sh,[e("div",oh,[p(te,{name:"i-heroicons-calendar",class:"h-4 w-4 opacity-70"})]),e("span",nh,n(q.value),1)])):P("",!0)]),e("div",rh,[e("div",lh,[e("span",ih,n(a(g).toLocaleString()),1),e("span",ch,n(a(s)("analysis.overview.identity.totalMessages")),1)]),e("div",dh,[e("span",uh,n(a(d).toLocaleString()),1),e("span",mh,n(a(s)("analysis.overview.identity.durationDays")),1)]),e("div",gh,[e("span",ph,n(a(L).toLocaleString()),1),e("span",vh,n(a(s)("analysis.overview.identity.activeDays")),1)]),e("div",hh,[e("span",yh,n(a(v).toLocaleString()),1),e("span",fh,n(a(s)("analysis.overview.identity.dailyAvgMessages")),1)])])])]),e("div",xh,[U[0]||(U[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",bh,[e("div",{ref_key:"chartRef",ref:y,class:"h-[140px] min-w-[700px] lg:w-full"},null,512)])]),p(Qv,{flat:"","daily-avg-messages":a(v),"duration-days":a(d),"image-count":a(h),"peak-hour":a($),"peak-weekday":a(x),"weekday-names":a(S),"weekday-vs-weekend":a(E),"peak-day":a(M),"active-days":a(L),"total-days":a(b),"active-rate":a(I),"late-night-count":a(R).count,"late-night-ratio":a(R).ratio,"max-consecutive-days":a(w)},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})}}}),kh={class:"p-5"},Kb=pe({__name:"DailyTrendCard",props:{dailyActivity:{},dailyChartData:{}},setup(l){const{t:s}=he();return(t,c)=>l.dailyActivity.length>0?(o(),Q(a(Ue),{key:0,title:a(s)("analysis.overview.dailyTrend.title"),"show-divider":!1},{default:O(()=>[e("div",kh,[p(a(Ft),{data:l.dailyChartData,height:288},null,8,["data"])])]),_:1},8,["title"])):P("",!0)}}),_h={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},wh={class:"flex items-center gap-6 sm:gap-10"},$h={class:"min-w-0 flex-1"},Ch={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},Sh={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},Th={class:"mb-4 flex min-w-0 flex-wrap items-baseline gap-2"},Ih={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Mh={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Lh={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Dh={key:1,class:"flex min-w-0 max-w-full flex-wrap items-center gap-x-1.5 gap-y-1.5"},Ah={class:"text-base font-medium text-gray-600 dark:text-gray-300"},qh={class:"font-bold tabular-nums text-pink-500 dark:text-pink-400"},Rh={class:"flex shrink-0 flex-col items-center"},Eh={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},zh={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Ph={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},jh={class:"min-w-0 flex-1"},Fh={class:"flex items-center justify-between gap-1"},Bh={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},Uh={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Vh={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"},Oh={class:"flex items-center gap-1.5"},Nh={class:"text-[9px] font-medium uppercase tracking-widest"},Yh=pe({__name:"TypeProfileCard",props:{sessionId:{},messageTypes:{},textStats:{},timeFilter:{}},setup(l){vt([ma,It,ht]);const{t:s}=he(),t=mt(),c=l,r=k(()=>c.messageTypes.reduce((_,T)=>_+T.count,0)),m=k(()=>c.messageTypes.find(_=>_.type===Se.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=f({first:"",last:""});async function v(){if(c.sessionId)try{const _=await qe().getDailyActivity(c.sessionId,c.timeFilter);if(_.length>0){const T=[..._].sort((W,ee)=>W.date.localeCompare(ee.date));g.value={first:fe(T[0].date).format("YYYY/MM/DD"),last:fe(T[T.length-1].date).format("YYYY/MM/DD")}}}catch{}}function h(_){return c.messageTypes.find(T=>T.type===_)?.count??0}const $=k(()=>[{label:s("views.message.typeCard.nonTextImage"),count:h(Se.IMAGE),unit:s("views.message.typeCard.unitImage")},{label:s("views.message.typeCard.nonTextEmoji"),count:h(Se.EMOJI),unit:s("views.message.typeCard.unitEmoji")},{label:s("views.message.typeCard.nonTextVoice"),count:h(Se.VOICE),unit:s("views.message.typeCard.unitVoice")},{label:s("views.message.typeCard.nonTextVideo"),count:h(Se.VIDEO),unit:s("views.message.typeCard.unitVideo")},{label:s("views.message.typeCard.nonTextFile"),count:h(Se.FILE),unit:s("views.message.typeCard.unitFile")},{label:s("views.message.typeCard.nonTextLink"),count:h(Se.LINK),unit:s("views.message.typeCard.unitLink")}].filter(_=>_.count>0)),x=f(30),S=f(0),E=f(!1),M=[{label:"20",value:20},{label:"30",value:30},{label:"50",value:50},{label:"80",value:80},{label:"100",value:100}],L=k({get:()=>x.value,set:_=>{x.value!==_&&(x.value=_,b())}});async function b(){if(c.sessionId){E.value=!0;try{S.value=await qe().getLongMessageCount(c.sessionId,c.timeFilter,x.value)}catch(_){console.error("[chart-message] Failed to load essay count:",_)}finally{E.value=!1}}}me(()=>[c.sessionId,c.timeFilter],()=>{b(),v()},{immediate:!0,deep:!0});const I=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:S.value.toLocaleString(),subtext:s("views.message.profile.essayLoverDesc",{threshold:x.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:$.value.slice(0,3).map(_=>`${_.label} ${_.count}`).join(" · ")||"-",colorClass:"text-pink-600 dark:text-pink-400"}]),R=f(null);let w=null;const y=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],A=k(()=>[...c.messageTypes].sort((T,W)=>W.count-T.count).slice(0,8).map((T,W)=>({name:Ot(T.type,s),value:T.count,itemStyle:{color:y[W%y.length]}})));function q(){R.value&&(w=yt(R.value,void 0,{renderer:"canvas"}),B())}function B(){w&&w.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:A.value}]},{notMerge:!0})}function j(){w?.resize()}return me(()=>c.messageTypes,()=>B()),me(t,()=>{w?.dispose(),q()}),Me(()=>{q(),window.addEventListener("resize",j)}),it(()=>{window.removeEventListener("resize",j),w?.dispose()}),(_,T)=>{const W=ye,ee=Tt;return o(),Q(a(ot),{variant:"elevated",decorative:"",class:"flex flex-col"},{default:O(()=>[e("div",_h,[e("div",wh,[e("div",$h,[e("div",Ch,[g.value.first?(o(),i("p",Sh,n(g.value.first)+" – "+n(g.value.last),1)):P("",!0),e("div",Th,[e("span",Ih,n(a(s)("views.message.profile.heroLine1Prefix")),1),e("span",Mh,n(r.value.toLocaleString()),1),e("span",Lh,n(a(s)("views.message.profile.heroLine1Suffix")),1)]),$.value.length>0?(o(),i("div",Dh,[e("span",Ah,n(a(s)("views.message.typeCard.nonTextPrefix")),1),(o(!0),i(oe,null,ue($.value,Y=>(o(),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",qh,n(Y.count.toLocaleString()),1),e("span",null,n(Y.unit),1)]))),128))])):P("",!0)])]),e("div",Rh,[e("div",Eh,n(a(s)("views.message.profile.typeDistribution")),1),e("div",{ref_key:"donutRef",ref:R,style:{width:"130px",height:"130px"}},null,512)])])]),e("div",zh,[T[1]||(T[1]=e("div",{class:"mb-3 flex items-center justify-between"},[e("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Type Profile ")],-1)),e("div",Ph,[(o(!0),i(oe,null,ue(I.value,Y=>(o(),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:ae(["mt-0.5 h-3.5 w-3.5 shrink-0",Y.colorClass])},null,8,["name","class"]),e("div",jh,[e("div",Fh,[e("div",{class:ae(["truncate font-mono text-sm font-black leading-tight tabular-nums",Y.colorClass])},n(Y.value),3),Y.slot==="essay-threshold"?(o(),Q(ee,{key:0,modelValue:L.value,"onUpdate:modelValue":T[0]||(T[0]=ce=>L.value=ce),items:M,"value-key":"value",size:"xs",class:"relative z-120 w-16 shrink-0",ui:{content:"z-[121]"},disabled:E.value},null,8,["modelValue","disabled"])):P("",!0)]),e("div",Bh,n(Y.label),1),e("div",Uh,n(Y.subtext),1)])]))),128))])]),e("div",Vh,[e("div",Oh,[p(W,{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",Nh,n(a(s)("views.message.typeCard.watermark")),1)])]),_:1})}}}),Hh={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-6"},Wh={class:"p-5"},Kh={key:0,class:"grid grid-cols-1 gap-6 lg:grid-cols-2 lg:items-center"},Qh={class:"space-y-3"},Gh={class:"min-w-20 shrink-0 text-sm text-gray-700 dark:text-gray-300"},Jh={class:"flex-1"},Xh={class:"h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800"},Zh={class:"shrink-0 text-right"},ey={class:"text-sm font-medium text-gray-900 dark:text-white"},ty={class:"ml-1 text-xs text-gray-400"},ay={key:1,class:"flex h-48 items-center justify-center text-gray-400"},sy={class:"p-5"},oy={class:"mb-5 grid grid-cols-2 gap-3 sm:grid-cols-4"},ny={class:"rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50"},ry={class:"font-mono text-xl font-bold text-gray-900 dark:text-white"},ly={class:"mt-1 text-xs text-gray-500"},iy={class:"rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50"},cy={class:"font-mono text-xl font-bold text-indigo-600 dark:text-indigo-400"},dy={class:"mt-1 text-xs text-gray-500"},uy={class:"rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50"},my={class:"font-mono text-xl font-bold text-pink-600 dark:text-pink-400"},gy={class:"mt-1 text-xs text-gray-500"},py={class:"rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50"},vy={class:"font-mono text-xl font-bold text-emerald-600 dark:text-emerald-400"},hy={class:"mt-1 text-xs text-gray-500"},yy={class:"mb-5 rounded-lg border border-gray-200 p-4 dark:border-gray-700"},fy={class:"mb-2 text-xs font-medium text-gray-500 dark:text-gray-400"},xy={class:"flex items-center gap-4 text-sm"},by={class:"flex items-center gap-1.5"},ky={class:"font-mono font-medium text-gray-900 dark:text-white"},_y={class:"flex items-center gap-1.5"},wy={class:"font-mono font-medium text-gray-900 dark:text-white"},$y={class:"flex items-center gap-1.5"},Cy={class:"font-mono font-medium text-gray-900 dark:text-white"},Sy={class:"flex items-center gap-1.5"},Ty={class:"font-mono font-medium text-gray-900 dark:text-white"},Iy={class:"mt-3 grid grid-cols-3 gap-3 text-xs"},My={class:"text-gray-500"},Ly={class:"ml-1 font-medium text-emerald-600 dark:text-emerald-400"},Dy={class:"text-gray-400"},Ay={class:"text-gray-500"},qy={class:"ml-1 font-medium text-indigo-600 dark:text-indigo-400"},Ry={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},Ey={class:"text-xs text-gray-400"},zy={class:"p-5"},Py={key:1,class:"flex h-48 items-center justify-center text-gray-400"},jy={class:"text-xs text-gray-400"},Fy={class:"p-5"},By={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Qb=pe({__name:"TypeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(l){const s=l,{t}=he(),c=f(!0),r=f([]),m=f([]),u=f([]),d=f({textCount:0,avgLength:0,maxLength:0,shortCount:0}),g=f({p25:0,p50:0,p75:0,p90:0}),v=f(0),h=k(()=>{const I=[...r.value].sort((R,w)=>w.count-R.count);return{labels:I.map(R=>Ot(R.type,t)),values:I.map(R=>R.count)}}),$=k(()=>{const I=r.value.reduce((w,y)=>w+y.count,0);return[...r.value].sort((w,y)=>y.count-w.count).map(w=>({name:Ot(w.type,t),count:w.count,percentage:I>0?Math.round(w.count/I*100):0}))}),x=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"];function S(I){return x[I%x.length]}const E=k(()=>({labels:m.value.map(I=>String(I.len)),values:m.value.map(I=>I.count)})),M=k(()=>({labels:u.value.map(I=>I.range),values:u.value.map(I=>I.count)})),L=k(()=>d.value.textCount===0?0:Math.round(d.value.shortCount/d.value.textCount*100));async function b(){if(s.sessionId){c.value=!0;try{const I=qe(),[R,w,y,A,q]=await Promise.all([I.getMessageTypeDistribution(s.sessionId,s.timeFilter),I.getMessageLengthDistribution(s.sessionId,s.timeFilter),I.getTextStats(s.sessionId,s.timeFilter),I.getTextLengthPercentiles(s.sessionId,s.timeFilter),I.getLongMessageCount(s.sessionId,s.timeFilter,30)]);r.value=R,m.value=w.detail,u.value=w.grouped,d.value=y,g.value=A,v.value=q}catch(I){console.error("[chart-message] Failed to load type analysis data:",I)}finally{c.value=!1}}}return me(()=>[s.sessionId,s.timeFilter],()=>b(),{immediate:!0,deep:!0}),(I,R)=>(o(),i("div",{class:ae(c.value?"h-full":"")},[c.value?(o(),Q(a(ct),{key:0,variant:"page",text:a(t)("common.loading")},null,8,["text"])):(o(),i("div",Hh,[r.value.length>0?(o(),Q(Yh,{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"])):P("",!0),p(a(Ue),{title:a(t)("views.message.typeDistribution"),"show-divider":!1},{default:O(()=>[e("div",Wh,[h.value.values.length>0?(o(),i("div",Kh,[e("div",null,[p(a(Bt),{data:h.value,height:280,"show-legend":!1},null,8,["data"])]),e("div",null,[e("div",Qh,[(o(!0),i(oe,null,ue($.value,(w,y)=>(o(),i("div",{key:y,class:"flex items-center gap-3"},[e("div",{class:"h-3 w-3 shrink-0 rounded-full",style:Ne({backgroundColor:S(y)})},null,4),e("div",Gh,n(w.name),1),e("div",Jh,[e("div",Xh,[e("div",{class:"h-full rounded-full transition-all",style:Ne({width:`${w.percentage}%`,backgroundColor:S(y)})},null,4)])]),e("div",Zh,[e("span",ey,n(w.count.toLocaleString()),1),e("span",ty,"("+n(w.percentage)+"%)",1)])]))),128))])])])):(o(),i("div",ay,n(a(t)("views.message.noData")),1))])]),_:1},8,["title"]),p(a(Ue),{title:a(t)("views.message.typeAnalysis.textDepthTitle"),"show-divider":!1},{default:O(()=>[e("div",sy,[e("div",oy,[e("div",ny,[e("div",ry,n(d.value.textCount.toLocaleString()),1),e("div",ly,n(a(t)("views.message.typeAnalysis.textTotal")),1)]),e("div",iy,[e("div",cy,n(d.value.avgLength||0),1),e("div",dy,n(a(t)("views.message.typeAnalysis.avgLength")),1)]),e("div",uy,[e("div",my,n(g.value.p50),1),e("div",gy,n(a(t)("views.message.typeAnalysis.medianLength")),1)]),e("div",py,[e("div",vy,n(d.value.maxLength),1),e("div",hy,n(a(t)("views.message.typeAnalysis.maxLength")),1)])]),e("div",yy,[e("div",fy,n(a(t)("views.message.typeAnalysis.percentiles")),1),e("div",xy,[e("div",by,[R[0]||(R[0]=e("span",{class:"text-gray-500"},"P25",-1)),e("span",ky,n(g.value.p25),1)]),e("div",_y,[R[1]||(R[1]=e("span",{class:"text-gray-500"},"P50",-1)),e("span",wy,n(g.value.p50),1)]),e("div",$y,[R[2]||(R[2]=e("span",{class:"text-gray-500"},"P75",-1)),e("span",Cy,n(g.value.p75),1)]),e("div",Sy,[R[3]||(R[3]=e("span",{class:"text-gray-500"},"P90",-1)),e("span",Ty,n(g.value.p90),1)])]),e("div",Iy,[e("div",null,[e("span",My,n(a(t)("views.message.typeAnalysis.shortMessages")),1),e("span",Ly,n(L.value)+"%",1),e("span",Dy,"("+n(d.value.shortCount)+")",1)]),e("div",null,[e("span",Ay,n(a(t)("views.message.typeAnalysis.essayMessages")),1),e("span",qy,n(v.value),1)])])])])]),_:1},8,["title"]),e("div",Ry,[p(a(Ue),{title:a(t)("views.message.lengthDetailTitle"),"show-divider":!1},{headerRight:O(()=>[e("span",Ey,n(a(t)("views.message.lengthDetailHint")),1)]),default:O(()=>[e("div",zy,[E.value.values.some(w=>w>0)?(o(),Q(a(Xe),{key:0,data:E.value,height:200},null,8,["data"])):(o(),i("div",Py,n(a(t)("views.message.noTextMessages")),1))])]),_:1},8,["title"]),p(a(Ue),{title:a(t)("views.message.lengthGroupedTitle"),"show-divider":!1},{headerRight:O(()=>[e("span",jy,n(a(t)("views.message.lengthGroupedHint")),1)]),default:O(()=>[e("div",Fy,[M.value.values.some(w=>w>0)?(o(),Q(a(Xe),{key:0,data:M.value,height:200},null,8,["data"])):(o(),i("div",By,n(a(t)("views.message.noTextMessages")),1))])]),_:1},8,["title"])])]))],2))}}),Uy={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Vy={class:"flex items-start gap-6 sm:gap-10"},Oy={class:"min-w-0 flex-1"},Ny={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},Yy={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},Hy={class:"mb-3 flex items-baseline gap-2"},Wy={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Ky={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Qy={class:"font-bold text-3xl text-indigo-500 dark:text-indigo-400"},Gy={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Jy={class:"flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},Xy={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Zy={class:"font-bold text-xl text-pink-500 dark:text-pink-400"},ef={class:"text-base font-medium text-gray-600 dark:text-gray-300"},tf={class:"text-base font-medium text-amber-600 dark:text-amber-400"},af={class:"flex shrink-0 flex-col items-center"},sf={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},of={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},nf={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},rf={class:"min-w-0 flex-1"},lf={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},cf={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},df={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"},uf={class:"flex items-center gap-1.5"},mf={class:"text-[9px] font-medium uppercase tracking-widest"},gf=pe({__name:"TimeProfileCard",props:{hourlyActivity:{},weekdayActivity:{},dailyActivity:{}},setup(l){vt([ga,pa,ht]);const{t:s}=he(),t=mt(),c=l,r=k(()=>c.dailyActivity.filter(w=>w.messageCount>0).length),m=k(()=>c.dailyActivity.reduce((w,y)=>w+y.messageCount,0)),u=k(()=>{if(c.dailyActivity.length===0)return{first:"",last:"",days:0};const w=[...c.dailyActivity].sort((q,B)=>q.date.localeCompare(B.date)),y=fe(w[0].date),A=fe(w[w.length-1].date);return{first:y.format("YYYY/MM/DD"),last:A.format("YYYY/MM/DD"),days:A.diff(y,"day")+1}}),d=k(()=>r.value===0?0:Math.round(m.value/r.value)),g=k(()=>c.dailyActivity.length===0?null:c.dailyActivity.reduce((w,y)=>y.messageCount>w.messageCount?y:w,c.dailyActivity[0])),v=k(()=>c.hourlyActivity.length===0?[]:[...c.hourlyActivity].sort((w,y)=>y.messageCount-w.messageCount).slice(0,3)),h=k(()=>{if(c.hourlyActivity.length===0&&c.weekdayActivity.length===0)return null;const w=u.value.days>0?r.value/u.value.days:0,y=c.weekdayActivity.filter(H=>H.weekday===6||H.weekday===7),A=c.weekdayActivity.filter(H=>H.weekday>=1&&H.weekday<=5),q=y.reduce((H,U)=>H+U.messageCount,0),B=A.reduce((H,U)=>H+U.messageCount,0),j=q+B,_=j>0?q/j:0,T=c.hourlyActivity.reduce((H,U)=>H+U.messageCount,0),W=c.hourlyActivity.filter(H=>H.hour>=22||H.hour<5).reduce((H,U)=>H+U.messageCount,0),ee=c.hourlyActivity.filter(H=>H.hour>=18&&H.hour<22).reduce((H,U)=>H+U.messageCount,0),Y=T>0?W/T:0,ce=T>0?ee/T:0;if(w>=.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&&j>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(ce>=.4)return{label:s("views.message.timeCard.personalityEveningChat"),icon:"i-heroicons-sparkles"};const ve=[...c.hourlyActivity].sort((H,U)=>U.messageCount-H.messageCount)[0];return ve?ve.hour>=5&&ve.hour<9?{label:s("views.message.timeCard.personalityEarlyBird"),icon:"i-heroicons-sun"}:ve.hour>=12&&ve.hour<14?{label:s("views.message.timeCard.personalityLunchChat"),icon:"i-heroicons-clock"}:{label:s("views.message.timeCard.personalityDaytime"),icon:"i-heroicons-sun"}:null}),$=k(()=>{const w=c.weekdayActivity.filter(j=>j.weekday===6||j.weekday===7),y=c.weekdayActivity.filter(j=>j.weekday>=1&&j.weekday<=5),A=w.reduce((j,_)=>j+_.messageCount,0),q=y.reduce((j,_)=>j+_.messageCount,0),B=A+q;return B===0?0:Math.round(A/B*100)}),x=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")]),S=k(()=>{if(c.weekdayActivity.length===0)return null;const w=[...c.weekdayActivity].sort((y,A)=>A.messageCount-y.messageCount)[0];return{name:x.value[w.weekday-1],count:w.messageCount}}),E=k(()=>[{icon:"i-heroicons-fire",label:s("views.message.timeCard.peakRecord"),value:g.value?fe(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(w=>`${w.hour}:00`).join(" > "):"",colorClass:"text-cyan-600 dark:text-cyan-400"},{icon:"i-heroicons-calendar-days",label:s("views.message.timeCard.peakWeekdayLabel"),value:S.value?.name||"-",subtext:S.value?`${S.value.count.toLocaleString()}`:"",colorClass:"text-violet-600 dark:text-violet-400"},{icon:"i-heroicons-building-office",label:s("views.message.timeCard.weekendRatio"),value:`${$.value}%`,subtext:s("views.message.timeCard.weekendRatioDesc"),colorClass:"text-amber-600 dark:text-amber-400"}]),M=f(null);let L=null;function b(){M.value&&(L=yt(M.value,void 0,{renderer:"canvas"}),I())}function I(){if(!L)return;const w=new Map(c.hourlyActivity.map(B=>[B.hour,B.messageCount])),y=[];for(let B=0;B<24;B++)y.push(w.get(B)||0);const A=Math.max(...y,1),q=y.map(B=>{const j=B/A;return j>.8?t.value?"#f472b6":"#ec4899":j>.5?t.value?"#a78bfa":"#8b5cf6":t.value?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.08)"});L.setOption({backgroundColor:"transparent",tooltip:{trigger:"axis",formatter:B=>`${B[0].axisValue}:00 — ${B[0].value}`},grid:{left:0,right:0,top:4,bottom:16},xAxis:{type:"category",data:Array.from({length:24},(B,j)=>`${j}`),axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:9,color:t.value?"#6b7280":"#9ca3af",interval:B=>B%6===0}},yAxis:{type:"value",show:!1},series:[{type:"bar",data:y.map((B,j)=>({value:B,itemStyle:{color:q[j]}})),barWidth:"60%",itemStyle:{borderRadius:[2,2,0,0]}}]},{notMerge:!0})}function R(){L?.resize()}return me(()=>c.hourlyActivity,()=>I()),me(t,()=>{L?.dispose(),b()}),Me(()=>{b(),window.addEventListener("resize",R)}),it(()=>{window.removeEventListener("resize",R),L?.dispose()}),(w,y)=>{const A=ye;return o(),Q(a(ot),{variant:"elevated",decorative:"",class:"flex flex-col"},{default:O(()=>[e("div",Uy,[e("div",Vy,[e("div",Oy,[e("div",Ny,[u.value.first?(o(),i("p",Yy,n(u.value.first)+" – "+n(u.value.last),1)):P("",!0),e("div",Hy,[e("span",Wy,n(u.value.days),1),e("span",Ky,n(a(s)("views.message.timeCard.heroDaysIn")),1),e("span",Qy,n(r.value),1),e("span",Gy,n(a(s)("views.message.timeCard.heroDaysActive")),1)]),e("div",Jy,[e("span",Xy,n(a(s)("views.message.timeCard.heroAvgPrefix")),1),e("span",Zy,n(d.value),1),e("span",ef,n(a(s)("views.message.timeCard.heroAvgSuffix")),1),h.value?(o(),i(oe,{key:0},[p(A,{name:h.value.icon,class:"ml-2 h-4 w-4 text-amber-500"},null,8,["name"]),e("span",tf,n(h.value.label),1)],64)):P("",!0)])])]),e("div",af,[e("div",sf,n(a(s)("views.message.timeCard.hourlyDistribution")),1),e("div",{ref_key:"barRef",ref:M,style:{width:"180px",height:"110px"}},null,512)])])]),e("div",of,[y[0]||(y[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",nf,[(o(!0),i(oe,null,ue(E.value,q=>(o(),i("div",{key:q.icon+q.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(A,{name:q.icon,class:ae(["mt-0.5 h-3.5 w-3.5 shrink-0",q.colorClass])},null,8,["name","class"]),e("div",rf,[e("div",{class:ae(["truncate font-mono text-sm font-black leading-tight tabular-nums",q.colorClass])},n(q.value),3),e("div",lf,n(q.label),1),e("div",cf,n(q.subtext),1)])]))),128))])]),e("div",df,[e("div",uf,[p(A,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),y[1]||(y[1]=e("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),e("span",mf,n(a(s)("views.message.timeCard.watermark")),1)])]),_:1})}}}),pf={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-6"},vf={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},hf={class:"p-5"},yf={class:"p-5"},ff={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},xf={class:"p-5"},bf={class:"p-5"},kf={key:1,class:"flex h-48 items-center justify-center text-gray-400"},_f={class:"text-xs text-gray-400"},wf={class:"p-5"},$f={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Cf={class:"text-xs text-gray-400"},Sf={class:"p-5"},Tf={class:"flex items-center gap-2"},If={class:"text-xs text-gray-400"},Mf={class:"p-5"},Lf={key:1,class:"flex h-32 items-center justify-center text-gray-400"},Gb=pe({__name:"TimeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(l){const s=l,{t}=he(),c=f(!0),r=f([]),m=f([]),u=f([]),d=f([]),g=f([]),v=f([]),h=f([]),$=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],x=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")]),S=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")]),E=k(()=>{const j=new Map(m.value.map(W=>[W.hour,W.messageCount])),_=[],T=[];for(let W=0;W<24;W++)_.push(`${W}`),T.push(j.get(W)||0);return{labels:_,values:T}}),M=k(()=>{const j=new Map(u.value.map(T=>[T.weekday,T.messageCount])),_=[];for(let T=1;T<=7;T++)_.push(j.get(T)||0);return{labels:x.value,values:_}}),L=k(()=>{const j=new Map(d.value.map(T=>[T.month,T.messageCount])),_=[];for(let T=1;T<=12;T++)_.push(j.get(T)||0);return{labels:S.value,values:_}}),b=k(()=>{const j=[...g.value].sort((_,T)=>_.year-T.year);return{labels:j.map(_=>String(_.year)),values:j.map(_=>_.messageCount)}}),I=k(()=>{const j=Array.from({length:24},(ee,Y)=>`${Y}:00`),_=x.value,T=r.value.reduce((ee,Y)=>ee+Y.count,0)||1,W=[];for(let ee=1;ee<=7;ee++)for(let Y=0;Y<24;Y++){const ce=u.value.find(U=>U.weekday===ee)?.messageCount||0,ve=m.value.find(U=>U.hour===Y)?.messageCount||0,H=Math.round(ce*ve/T);W.push([Y,ee-1,H])}return{xLabels:j,yLabels:_,data:W}}),R=k(()=>v.value.map(j=>({date:j.date,value:j.messageCount}))),w=k(()=>{const j=new Set;return v.value.forEach(_=>{const T=parseInt(_.date.split("-")[0]);isNaN(T)||j.add(T)}),Array.from(j).sort((_,T)=>T-_)}),y=f(new Date().getFullYear()),A=k(()=>{const j=y.value;return R.value.filter(_=>_.date.startsWith(`${j}-`))}),q=k(()=>{if(h.value.length===0)return{};const j=[...new Set(h.value.map(Y=>Y.month))].sort(),_=new Map;if(h.value.forEach(Y=>{const ce=_.get(Y.memberId);ce?ce.total+=Y.count:_.set(Y.memberId,{name:Y.memberName,total:Y.count})}),_.size<=2){const Y=new Map;return h.value.forEach(ce=>{Y.set(ce.month,(Y.get(ce.month)||0)+ce.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:j,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:j.map(ce=>Y.get(ce)||0)}]}}const ee=[..._.entries()].sort((Y,ce)=>ce[1].total-Y[1].total).slice(0,10).map(([Y,ce],ve)=>{const H=new Map(h.value.filter(U=>U.memberId===Y).map(U=>[U.month,U.count]));return{name:ce.name,type:"line",stack:"total",areaStyle:{opacity:.3},smooth:!0,symbol:"none",itemStyle:{color:$[ve%$.length]},data:j.map(U=>H.get(U)||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:j,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{type:"dashed",opacity:.3}}},series:ee}});async function B(){if(s.sessionId){c.value=!0;try{const j=qe(),[_,T,W,ee,Y,ce,ve]=await Promise.all([j.getMessageTypeDistribution(s.sessionId,s.timeFilter),j.getHourlyActivity(s.sessionId,s.timeFilter),j.getWeekdayActivity(s.sessionId,s.timeFilter),j.getMonthlyActivity(s.sessionId,s.timeFilter),j.getYearlyActivity(s.sessionId,s.timeFilter),j.getDailyActivity(s.sessionId,s.timeFilter),j.getMemberMonthlyTrend(s.sessionId,s.timeFilter)]);r.value=_,m.value=T,u.value=W,d.value=ee,g.value=Y,v.value=ce,h.value=ve,w.value.length>0&&(y.value=w.value[0])}catch(j){console.error("[chart-message] Failed to load time analysis data:",j)}finally{c.value=!1}}}return me(()=>[s.sessionId,s.timeFilter],()=>B(),{immediate:!0,deep:!0}),(j,_)=>{const T=Tt;return o(),i("div",{class:ae(c.value?"h-full":"")},[c.value?(o(),Q(a(ct),{key:0,variant:"page",text:a(t)("common.loading")},null,8,["text"])):(o(),i("div",pf,[v.value.length>0?(o(),Q(gf,{key:0,"hourly-activity":m.value,"weekday-activity":u.value,"daily-activity":v.value},null,8,["hourly-activity","weekday-activity","daily-activity"])):P("",!0),e("div",vf,[p(a(Ue),{title:a(t)("views.message.hourlyDistribution"),"show-divider":!1},{default:O(()=>[e("div",hf,[p(a(Xe),{data:E.value,height:200},null,8,["data"])])]),_:1},8,["title"]),p(a(Ue),{title:a(t)("views.message.weekdayDistribution"),"show-divider":!1},{default:O(()=>[e("div",yf,[p(a(Xe),{data:M.value,height:200},null,8,["data"])])]),_:1},8,["title"])]),e("div",ff,[p(a(Ue),{title:a(t)("views.message.monthlyDistribution"),"show-divider":!1},{default:O(()=>[e("div",xf,[p(a(Xe),{data:L.value,height:200},null,8,["data"])])]),_:1},8,["title"]),p(a(Ue),{title:a(t)("views.message.yearlyDistribution"),"show-divider":!1},{default:O(()=>[e("div",bf,[b.value.values.length>0?(o(),Q(a(Xe),{key:0,data:b.value,height:200},null,8,["data"])):(o(),i("div",kf,n(a(t)("views.message.noData")),1))])]),_:1},8,["title"])]),p(a(Ue),{title:a(t)("views.message.timeAnalysis.memberTrendTitle"),"show-divider":!1},{headerRight:O(()=>[e("span",_f,n(a(t)("views.message.timeAnalysis.memberTrendHint")),1)]),default:O(()=>[e("div",wf,[h.value.length>0?(o(),Q(a(ft),{key:0,option:q.value,height:280},null,8,["option"])):(o(),i("div",$f,n(a(t)("views.message.noData")),1))])]),_:1},8,["title"]),p(a(Ue),{title:a(t)("views.message.timeHeatmap"),"show-divider":!1},{headerRight:O(()=>[e("span",Cf,n(a(t)("views.message.heatmapHint")),1)]),default:O(()=>[e("div",Sf,[p(a(jt),{data:I.value,height:320},null,8,["data"])])]),_:1},8,["title"]),p(a(Ue),{title:a(t)("views.message.calendarHeatmap"),"show-divider":!1},{headerRight:O(()=>[e("div",Tf,[e("span",If,n(a(t)("views.message.calendarHint")),1),w.value.length>1?(o(),Q(T,{key:0,modelValue:y.value,"onUpdate:modelValue":_[0]||(_[0]=W=>y.value=W),items:w.value.map(W=>({value:W,label:String(W)})),size:"xs",class:"w-20"},null,8,["modelValue","items"])):P("",!0)])]),default:O(()=>[e("div",Mf,[A.value.length>0?(o(),Q(a(P0),{key:0,data:A.value,year:y.value,height:180},null,8,["data","year"])):(o(),i("div",Lf,n(a(t)("views.message.noData")),1))])]),_:1},8,["title"])]))],2)}}}),Df={class:"p-6"},Af={class:"mb-4 flex items-center justify-between"},qf={class:"flex items-center gap-3"},Rf={class:"text-lg font-semibold text-gray-900 dark:text-white"},Ef={class:"text-sm text-gray-500 dark:text-gray-400"},zf={class:"h-56 overflow-y-auto rounded-lg border border-gray-200 dark:border-gray-700"},Pf={key:0,class:"flex h-full items-center justify-center"},jf={key:1,class:"flex h-full items-center justify-center"},Ff={class:"text-sm text-gray-500 dark:text-gray-400"},Bf={key:2,class:"divide-y divide-gray-100 dark:divide-gray-800"},Uf=["onClick"],Vf=["src","alt"],Of={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"},Nf={class:"min-w-0 flex-1"},Yf={class:"truncate text-sm font-medium text-gray-900 dark:text-white"},Hf={class:"truncate text-xs text-gray-500 dark:text-gray-400"},Wf={class:"mt-3 text-xs text-gray-500 dark:text-gray-400"},Kf={key:0,class:"mt-2"},Qf={class:"mt-5 flex items-center justify-between gap-2"},Gf={key:1},Jf={class:"flex gap-2"},Xf=pe({__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}=he(),m=Ye(),u=la(),d=k({get:()=>t.modelValue,set:q=>c("update:modelValue",q)}),g=f([]),v=f(!1),h=f(!1),$=f(!1),x=f(""),S=f(null),E=k(()=>u.currentSession?.ownerId??null);function M(q){return q.groupNickname||q.accountName||q.platformId}const L=k(()=>{const q=x.value.trim().toLowerCase(),B=g.value.filter(j=>j.platformId&&j.platformId.trim()!=="");return q?B.filter(j=>[j.platformId,j.accountName??"",j.groupNickname??"",...j.aliases].some(_=>_.toLowerCase().includes(q))):B});async function b(){if(t.sessionId){v.value=!0;try{g.value=await qe().getMembers(t.sessionId)}catch(q){console.error("加载成员列表失败:",q)}finally{v.value=!1}}}async function I(){if(!(!t.sessionId||!t.autoCheck)&&!E.value)try{const q=await u.tryApplyOwnerProfile(t.sessionId);if(q.applied||q.reason==="already_set"||q.reason==="missing_session"||q.dismissed)return;d.value=!0}catch(q){console.error("检查会话 owner 失败:",q)}}async function R(){if(!(!S.value||!t.sessionId)){h.value=!0;try{const q=await u.setOwnerAndApplyProfile(t.sessionId,S.value);q.updatedSessionIds.length>0?m.success(r("members.ownerPrompt.saved"),{description:r("members.ownerPrompt.appliedToOthers",{count:q.updatedSessionIds.length})}):m.success(r("members.ownerPrompt.saved")),c("saved",q.ownerId),d.value=!1}catch(q){console.error("设置会话 owner 失败:",q),m.fail(r("members.ownerPrompt.saveFailed"))}finally{h.value=!1}}}async function w(){if(!(!t.sessionId||!E.value)){h.value=!0;try{await u.updateSessionOwnerId(t.sessionId,null)&&(S.value=null,c("cleared"),d.value=!1)}catch(q){console.error("清除会话 owner 失败:",q)}finally{h.value=!1}}}async function y(){if(t.sessionId){$.value=!0;try{await u.dismissOwnerPrompt(t.sessionId),d.value=!1}catch(q){console.error("忽略 owner 提醒失败:",q)}finally{$.value=!1}}}function A(){d.value=!1}return me(d,q=>{q&&(x.value="",S.value=E.value,b())}),me(()=>t.sessionId,()=>{I()}),Me(()=>{I()}),(q,B)=>{const j=ye,_=Le,T=pt,W=Fe;return o(),Q(W,{open:d.value,"onUpdate:open":B[1]||(B[1]=ee=>d.value=ee),ui:{content:"max-w-md"}},{content:O(()=>[e("div",Df,[e("div",Af,[e("div",qf,[e("div",{class:ae(["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(j,{name:"i-heroicons-user",class:"h-5 w-5 text-white"})],2),e("div",null,[e("h3",Rf,n(a(r)("members.ownerPrompt.title")),1),e("p",Ef,n(a(r)("members.ownerPrompt.subtitle")),1)])]),p(_,{icon:"i-heroicons-x-mark",color:"neutral",variant:"ghost",size:"sm",onClick:A})]),p(T,{modelValue:x.value,"onUpdate:modelValue":B[0]||(B[0]=ee=>x.value=ee),placeholder:a(r)("members.ownerPrompt.searchPlaceholder"),icon:"i-heroicons-magnifying-glass",class:"mb-3 w-full"},null,8,["modelValue","placeholder"]),e("div",zf,[v.value?(o(),i("div",Pf,[p(j,{name:"i-heroicons-arrow-path",class:"h-5 w-5 animate-spin text-gray-400"})])):L.value.length===0?(o(),i("div",jf,[e("p",Ff,n(x.value?a(r)("members.ownerPrompt.noMatch"):a(r)("members.ownerPrompt.empty")),1)])):(o(),i("ul",Bf,[(o(!0),i(oe,null,ue(L.value,ee=>(o(),i("li",{key:ee.id},[e("button",{type:"button",class:ae(["flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-gray-50 dark:hover:bg-gray-800/50",S.value===ee.platformId?"bg-primary-50 dark:bg-primary-900/20":""]),onClick:Y=>S.value=ee.platformId},[ee.avatar?(o(),i("img",{key:0,src:ee.avatar,alt:M(ee),class:"h-8 w-8 shrink-0 rounded-full object-cover"},null,8,Vf)):(o(),i("div",Of,n(M(ee).slice(0,1)),1)),e("div",Nf,[e("p",Yf,n(M(ee)),1),e("p",Hf,n(ee.platformId),1)]),S.value===ee.platformId?(o(),Q(j,{key:2,name:"i-heroicons-check-circle-solid",class:"h-5 w-5 shrink-0 text-primary-500"})):P("",!0)],10,Uf)]))),128))]))]),e("p",Wf,n(a(r)("members.ownerPrompt.description")),1),E.value?(o(),i("div",Kf,[p(_,{variant:"link",color:"neutral",size:"xs",disabled:h.value,onClick:w},{default:O(()=>[ne(n(a(r)("members.ownerPrompt.clear")),1)]),_:1},8,["disabled"])])):P("",!0),e("div",Qf,[E.value?(o(),i("span",Gf)):(o(),Q(_,{key:0,variant:"ghost",color:"neutral",size:"sm",loading:$.value,onClick:y},{default:O(()=>[ne(n(a(r)("members.ownerPrompt.dontRemind")),1)]),_:1},8,["loading"])),e("div",Jf,[p(_,{variant:"ghost",color:"neutral",onClick:A},{default:O(()=>[ne(n(a(r)("members.ownerPrompt.later")),1)]),_:1}),p(_,{color:"primary",loading:h.value,disabled:!S.value,onClick:R},{default:O(()=>[ne(n(a(r)("members.ownerPrompt.save")),1)]),_:1},8,["loading","disabled"])])])])]),_:1},8,["open"])}}}),Zf={class:"w-150 rounded-lg border border-gray-200 bg-white p-3 shadow-sm dark:border-gray-700 dark:bg-gray-900"},ex={class:"flex items-center justify-between gap-3"},tx={class:"flex items-center gap-2"},ax={class:"text-sm font-medium text-gray-900 dark:text-white"},sx={class:"text-xs text-gray-500 dark:text-gray-400"},Jb=pe({__name:"OwnerEntryCard",props:{sessionId:{},members:{},chatType:{}},setup(l){const{t:s}=he(),t=la(),c=l,r=f(!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=ye,$=Le;return o(),i("div",Zf,[e("div",ex,[e("div",tx,[e("div",{class:ae(["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",ax,n(d.value?a(s)("members.ownerPrompt.currentOwner",{name:d.value}):a(s)("members.ownerPrompt.choose")),1),e("p",sx,n(a(s)("members.ownerPrompt.helper")),1)])]),p($,{size:"sm",variant:d.value?"outline":"solid",color:"primary",onClick:v[0]||(v[0]=x=>r.value=!0)},{default:O(()=>[ne(n(d.value?a(s)("members.ownerPrompt.change"):a(s)("members.ownerPrompt.choose")),1)]),_:1},8,["variant"])]),p(Xf,{modelValue:r.value,"onUpdate:modelValue":v[1]||(v[1]=x=>r.value=x),"session-id":l.sessionId,"chat-type":l.chatType},null,8,["modelValue","session-id","chat-type"])])}}}),ox={key:1,class:"flex items-center"},nx={class:"whitespace-nowrap px-0.5 text-sm font-medium text-gray-700 dark:text-gray-300"},rx={key:2,class:"flex items-center"},lx={class:"whitespace-nowrap px-0.5 text-sm font-medium text-gray-700 dark:text-gray-300"},ix={key:3,class:"flex items-center gap-1"},cx=pe({__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}=he(),m=f(!1),u=f([]),d=f(null),g=f("recent"),v=f(365),h=f(0),$=f(0),x=f(1),S=f(""),E=f(""),M=f(!1);function L(C){const F=new Date(C*1e3);return{year:F.getFullYear(),quarter:Math.floor(F.getMonth()/3)+1}}function b(C,F){const J=(F-1)*3,G=new Date(C,J,1,0,0,0),z=new Date(C,J+3,0,23,59,59);return{startTs:Math.floor(G.getTime()/1e3),endTs:Math.floor(z.getTime()/1e3)}}function I(C){const F=new Date(C,0,1,0,0,0),J=new Date(C,11,31,23,59,59);return{startTs:Math.floor(F.getTime()/1e3),endTs:Math.floor(J.getTime()/1e3)}}const R=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"}]),w=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}]),y=k(()=>d.value?L(d.value.start):{year:0,quarter:1}),A=k(()=>d.value?L(d.value.end):{year:0,quarter:1}),q=k(()=>{const C=y.value;return $.value>C.year||$.value===C.year&&x.value>C.quarter}),B=k(()=>{const C=A.value;return $.value<C.year||$.value===C.year&&x.value<C.quarter}),j=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),T=k(()=>r("common.timeSelect.quarter.label",{year:$.value,quarter:x.value})),W=k(()=>r("common.timeSelect.year.label",{year:h.value}));function ee(C){return{365:r("common.timeSelect.display.recent365"),730:r("common.timeSelect.display.recent730"),1825:r("common.timeSelect.display.recent1825")}[C]||""}function Y(C){return[365,730,1825,0].includes(C)?C:365}function ce(){if(!d.value)return null;const C={mode:g.value};switch(g.value){case"recent":{if(C.recentDays=v.value,v.value===0)return{startTs:d.value.start,endTs:d.value.end,displayLabel:Pt(d.value.start,d.value.end),isFullRange:!0,state:C};const F=d.value.end;return{startTs:Math.max(F-v.value*86400,d.value.start),endTs:F,displayLabel:ee(v.value),isFullRange:!1,state:C}}case"quarter":return C.quarterYear=$.value,C.quarter=x.value,{...b($.value,x.value),displayLabel:T.value,isFullRange:!1,state:C};case"year":return C.year=h.value,{...I(h.value),displayLabel:W.value,isFullRange:!1,state:C};case"custom":{if(C.customStart=S.value,C.customEnd=E.value,!S.value||!E.value)return null;let F=fe(S.value).startOf("day").unix(),J=fe(E.value).endOf("day").unix();return F>J&&([F,J]=[J,F]),{startTs:F,endTs:J,displayLabel:Pt(F,J),isFullRange:!1,state:C}}}}function ve(){const C=ce();C&&c("update:modelValue",C)}function H(C){let F=$.value,J=x.value+C;J>4&&(F++,J=1),J<1&&(F--,J=4);const G=y.value,z=A.value;F<G.year||F===G.year&&J<G.quarter||F>z.year||F===z.year&&J>z.quarter||($.value=F,x.value=J,ve())}function U(C){const F=u.value,G=F.indexOf(h.value)-C;G>=0&&G<F.length&&(h.value=F[G],ve())}function te(C){if(d.value)switch(C){case"recent":v.value=Y(v.value);break;case"quarter":{const{year:F,quarter:J}=L(d.value.end);$.value=F,x.value=J;break}case"year":{h.value=u.value[0]||new Date(d.value.end*1e3).getFullYear();break}case"custom":{const F=d.value.end,J=Math.max(F-30*86400,d.value.start);S.value=fe.unix(J).format("YYYY-MM-DD"),E.value=fe.unix(F).format("YYYY-MM-DD");break}}}const se=k({get:()=>g.value,set:C=>{g.value=C,M.value=!0,te(C),M.value=!1,ve()}}),le=k({get:()=>v.value,set:C=>{v.value=C,ve()}}),K=k({get:()=>S.value,set:C=>{S.value=C,E.value&&ve()}}),N=k({get:()=>E.value,set:C=>{E.value=C,S.value&&ve()}});async function D(){if(!t.sessionId){u.value=[],d.value=null,c("update:fullRange",null),c("update:availableYears",[]),m.value=!0;return}try{const C=qe(),[F,J]=await Promise.all([C.getAvailableYears(t.sessionId),C.getTimeRange(t.sessionId)]);u.value=F,d.value=J,c("update:fullRange",J),c("update:availableYears",F);const G=t.initialState,z=G?.mode??"recent";switch(g.value=z,M.value=!0,z){case"recent":v.value=Y(G?.recentDays??365);break;case"quarter":{if(G?.quarterYear&&G?.quarter)$.value=G.quarterYear,x.value=G.quarter;else if(J){const{year:Z,quarter:ge}=L(J.end);$.value=Z,x.value=ge}break}case"year":{G?.year&&F.includes(G.year)?h.value=G.year:h.value=F[0]||0;break}case"custom":{if(G?.customStart&&G?.customEnd)S.value=G.customStart,E.value=G.customEnd;else if(J){const Z=J.end,ge=Math.max(Z-30*86400,J.start);S.value=fe.unix(ge).format("YYYY-MM-DD"),E.value=fe.unix(Z).format("YYYY-MM-DD")}break}}M.value=!1,ve()}catch(C){console.error("TimeSelect 加载数据失败:",C),u.value=[],d.value=null,c("update:fullRange",null),c("update:availableYears",[])}finally{m.value=!0}}return Me(()=>D()),me(()=>t.sessionId,()=>{m.value=!1,D()}),(C,F)=>{const J=Tt,G=Le;return m.value?(o(),i("div",{key:0,class:ae(["flex items-center gap-2",{invisible:!l.visible}])},[p(J,{modelValue:se.value,"onUpdate:modelValue":F[0]||(F[0]=z=>se.value=z),items:R.value,size:"md",class:"w-28 shrink-0"},null,8,["modelValue","items"]),g.value==="recent"?(o(),Q(Je,{key:0,modelValue:le.value,"onUpdate:modelValue":F[1]||(F[1]=z=>le.value=z),items:w.value,size:"sm",class:"min-w-0 shrink"},null,8,["modelValue","items"])):g.value==="quarter"?(o(),i("div",ox,[p(G,{icon:"i-heroicons-chevron-left",size:"sm",variant:"ghost",color:"neutral",disabled:!q.value,onClick:F[2]||(F[2]=z=>H(-1))},null,8,["disabled"]),e("span",nx,n(T.value),1),p(G,{icon:"i-heroicons-chevron-right",size:"sm",variant:"ghost",color:"neutral",disabled:!B.value,onClick:F[3]||(F[3]=z=>H(1))},null,8,["disabled"])])):g.value==="year"?(o(),i("div",rx,[p(G,{icon:"i-heroicons-chevron-left",size:"sm",variant:"ghost",color:"neutral",disabled:!j.value,onClick:F[4]||(F[4]=z=>U(-1))},null,8,["disabled"]),e("span",lx,n(W.value),1),p(G,{icon:"i-heroicons-chevron-right",size:"sm",variant:"ghost",color:"neutral",disabled:!_.value,onClick:F[5]||(F[5]=z=>U(1))},null,8,["disabled"])])):g.value==="custom"?(o(),i("div",ix,[p(Xt,{modelValue:K.value,"onUpdate:modelValue":F[6]||(F[6]=z=>K.value=z),"width-class":"w-28",clearable:!1},null,8,["modelValue"]),F[8]||(F[8]=e("span",{class:"text-xs text-gray-400"},"-",-1)),p(Xt,{modelValue:N.value,"onUpdate:modelValue":F[7]||(F[7]=z=>N.value=z),"width-class":"w-28",clearable:!1},null,8,["modelValue"])])):P("",!0)],2)):P("",!0)}}}),dx={class:"flex items-center justify-between"},ux=["src","alt"],mx={class:"group/title flex items-baseline gap-2"},gx={class:"header-actions relative z-[40] flex items-center gap-2"},px=pe({__name:"PageHeader",props:{title:{},description:{},icon:{},iconClass:{},avatar:{},size:{default:"default"}},setup(l){const s=l;return(t,c)=>{const r=ye;return o(),i("div",{class:ae(["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",dx,[e("div",{class:ae(["flex items-center",s.size==="compact"?"gap-2.5":"gap-3"])},[l.avatar?(o(),i("img",{key:0,src:l.avatar,alt:l.title,class:ae(["object-cover",s.size==="compact"?"h-6 w-6 rounded-md":"h-10 w-10 rounded-xl"])},null,10,ux)):l.icon?(o(),i("div",{key:1,class:ae(["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:ae(["text-white",s.size==="compact"?"h-3 w-3":"h-5 w-5"])},null,8,["name","class"])],2)):P("",!0),e("div",mx,[e("h1",{class:ae(["font-semibold text-gray-900 dark:text-white",s.size==="compact"?"text-base":"text-lg"])},n(l.title),3),l.description?(o(),i("p",{key:0,class:ae(["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"])},n(l.description),3)):P("",!0)])],2),c[0]||(c[0]=e("div",{class:"flex-1 self-stretch mx-4",style:{"-webkit-app-region":"drag"}},null,-1)),e("div",gx,[Ve(t.$slots,"actions",{},void 0,!0)])]),Ve(t.$slots,"default",{},void 0,!0)],2)}}}),vx=et(px,[["__scopeId","data-v-b3e18446"]]),hx={class:"mt-3 flex items-center justify-between gap-3"},yx={class:"flex shrink-0 items-center gap-0.5 overflow-x-auto scrollbar-hide"},fx=["onClick"],xx={class:"whitespace-nowrap"},Xb=pe({__name:"SessionAnalysisHeader",props:zt({title:{},avatar:{},icon:{},iconClass:{},tabs:{},currentSessionId:{},initialTimeState:{}},{activeTab:{required:!0},activeTabModifiers:{},timeRangeValue:{required:!0},timeRangeValueModifiers:{}}),emits:zt(["openIncrementalImport","openMemberManagement","openChatRecord","update:fullRange","update:availableYears"],["update:activeTab","update:timeRangeValue"]),setup(l,{emit:s}){const t=Et(l,"activeTab"),c=Et(l,"timeRangeValue"),r=s,{t:m}=he(),u=dt(),d=k(()=>!["ai-chat","memory","lab","debug"].includes(t.value));return(g,v)=>{const h=Le,$=gt,x=ye;return o(),Q(vx,{title:l.title,avatar:l.avatar,size:"compact",icon:l.icon,"icon-class":l.iconClass},{actions:O(()=>[a(u).toolsPanelPosition==="header"?(o(),i(oe,{key:0},[p($,{text:a(m)("analysis.tooltip.incrementalImport")},{default:O(()=>[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]=S=>r("openIncrementalImport"))})]),_:1},8,["text"]),p($,{text:a(m)("analysis.tooltip.memberManagement")},{default:O(()=>[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]=S=>r("openMemberManagement"))})]),_:1},8,["text"]),p($,{text:a(m)("analysis.tooltip.viewChatRecord")},{default:O(()=>[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]=S=>r("openChatRecord"))})]),_:1},8,["text"]),p(rt,{color:"gray"}),p($,{text:a(m)("analysis.tooltip.more")},{default:O(()=>[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]=S=>a(u).toggleToolsPanelOpen())})]),_:1},8,["text"])],64)):(o(),Q(rt,{key:1,color:"gray"}))]),default:O(()=>[e("div",hx,[e("div",yx,[(o(!0),i(oe,null,ue(l.tabs,S=>(o(),i("button",{key:S.id,class:ae(["flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-sm font-medium transition-all",[t.value===S.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:E=>t.value=S.id},[p(x,{name:S.icon,class:"h-4 w-4"},null,8,["name"]),e("span",xx,n(a(m)(S.labelKey)),1)],10,fx))),128))]),p(cx,{modelValue:c.value,"onUpdate:modelValue":v[4]||(v[4]=S=>c.value=S),"session-id":l.currentSessionId??void 0,visible:d.value,"initial-state":l.initialTimeState,"onUpdate:fullRange":v[5]||(v[5]=S=>r("update:fullRange",S)),"onUpdate:availableYears":v[6]||(v[6]=S=>r("update:availableYears",S))},null,8,["modelValue","session-id","visible","initial-state"])])]),_:1},8,["title","avatar","icon","icon-class"])}}}),bx={class:"p-6"},kx={class:"mb-4 flex items-center justify-between"},_x={class:"flex items-center gap-2"},wx={class:"flex h-10 w-10 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/30"},$x={class:"text-lg font-semibold text-gray-900 dark:text-white"},Cx={class:"text-sm text-gray-500 dark:text-gray-400"},Sx={key:0,class:"flex items-center justify-center py-8"},Tx={key:0,class:"space-y-4"},Ix={class:"rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-800/50 dark:bg-amber-900/20"},Mx={class:"flex gap-3"},Lx={class:"text-sm font-medium text-amber-800 dark:text-amber-200"},Dx={class:"mt-1 text-sm text-amber-700 dark:text-amber-300"},Ax={class:"rounded-lg bg-gray-50 p-4 dark:bg-gray-800/50"},qx={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},Rx={class:"space-y-1 text-sm text-gray-600 dark:text-gray-400"},Ex={class:"flex items-start gap-2"},zx={class:"flex items-start gap-2"},Px={class:"flex items-start gap-2"},jx={key:1,class:"space-y-4"},Fx={class:"rounded-lg border border-green-200 bg-green-50 p-4 dark:border-green-800/50 dark:bg-green-900/20"},Bx={class:"flex gap-3"},Ux={class:"text-sm font-medium text-green-800 dark:text-green-200"},Vx={class:"mt-1 text-sm text-green-700 dark:text-green-300"},Ox={class:"text-sm text-gray-500 dark:text-gray-400"},Nx={class:"mt-6 flex justify-end gap-2"},Zb=pe({__name:"SessionIndexModal",props:{sessionId:{},modelValue:{type:Boolean},messageCount:{}},emits:["update:modelValue","generated"],setup(l,{emit:s}){const t=l,c=s,{t:r}=he(),m=f(!1),u=f(0),d=f(!1),g=f(!0),v=f(!1),h=k({get:()=>t.modelValue??!1,set:b=>c("update:modelValue",b)}),$=k(()=>!v.value);async function x(){if(t.sessionId&&t.messageCount!==0){g.value=!0;try{const b=await Lt().getStats(t.sessionId);m.value=b.hasIndex,u.value=b.sessionCount,m.value||(v.value=!0,h.value=!0)}catch(b){console.error("检查会话索引失败:",b)}finally{g.value=!1}}}async function S(){if(t.sessionId){g.value=!0;try{const b=await Lt().getStats(t.sessionId);m.value=b.hasIndex,u.value=b.sessionCount}catch(b){console.error("检查会话索引失败:",b)}finally{g.value=!1}}}async function E(){if(t.sessionId){d.value=!0;try{const b=ja(),I=await Lt().generate(t.sessionId,b);m.value=!0,u.value=I,c("generated",I),v.value=!1,h.value=!1}catch(b){console.error("生成会话索引失败:",b)}finally{d.value=!1}}}function M(){$.value&&(h.value=!1)}function L(b){!b&&!$.value||(h.value=b,b&&!v.value&&S())}return me(()=>t.sessionId,()=>{x()}),Me(()=>{x()}),(b,I)=>{const R=ye,w=Le,y=Fe;return o(),Q(y,{open:h.value,dismissible:$.value,"onUpdate:open":L},{content:O(()=>[e("div",bx,[e("div",kx,[e("div",_x,[e("div",wx,[p(R,{name:"i-heroicons-clock",class:"h-5 w-5 text-blue-600 dark:text-blue-400"})]),e("div",null,[e("h3",$x,n(a(r)("records.sessionIndex.title")),1),e("p",Cx,n(a(r)("records.sessionIndex.subtitle")),1)])]),$.value?(o(),Q(w,{key:0,icon:"i-heroicons-x-mark",color:"neutral",variant:"ghost",size:"sm",onClick:M})):P("",!0)]),g.value?(o(),i("div",Sx,[p(R,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):(o(),i(oe,{key:1},[m.value?(o(),i("div",jx,[e("div",Fx,[e("div",Bx,[p(R,{name:"i-heroicons-check-circle",class:"h-5 w-5 shrink-0 text-green-500"}),e("div",null,[e("p",Ux,n(a(r)("records.sessionIndex.generated")),1),e("p",Vx,n(a(r)("records.sessionIndex.sessionCount",{count:u.value})),1)])])]),e("p",Ox,n(a(r)("records.sessionIndex.regenerateHint")),1)])):(o(),i("div",Tx,[e("div",Ix,[e("div",Mx,[p(R,{name:"i-heroicons-exclamation-triangle",class:"h-5 w-5 shrink-0 text-amber-500"}),e("div",null,[e("p",Lx,n(a(r)("records.sessionIndex.notGenerated")),1),e("p",Dx,n(a(r)("records.sessionIndex.notGeneratedHint")),1)])])]),e("div",Ax,[e("h4",qx,n(a(r)("records.sessionIndex.whatIsIt")),1),e("ul",Rx,[e("li",Ex,[p(R,{name:"i-heroicons-check",class:"mt-0.5 h-4 w-4 shrink-0 text-green-500"}),ne(" "+n(a(r)("records.sessionIndex.benefit1")),1)]),e("li",zx,[p(R,{name:"i-heroicons-check",class:"mt-0.5 h-4 w-4 shrink-0 text-green-500"}),ne(" "+n(a(r)("records.sessionIndex.benefit2")),1)]),e("li",Px,[p(R,{name:"i-heroicons-check",class:"mt-0.5 h-4 w-4 shrink-0 text-green-500"}),ne(" "+n(a(r)("records.sessionIndex.benefit3")),1)])])])]))],64)),e("div",Nx,[$.value?(o(),Q(w,{key:0,variant:"ghost",onClick:M},{default:O(()=>[ne(n(a(r)("records.sessionIndex.cancel")),1)]),_:1})):P("",!0),p(w,{color:"primary",loading:d.value,onClick:E},{default:O(()=>[d.value?P("",!0):(o(),Q(R,{key:0,name:m.value?"i-heroicons-arrow-path":"i-heroicons-sparkles",class:"mr-1 h-4 w-4"},null,8,["name"])),ne(" "+n(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"])}}}),Yx={class:"min-h-[200px]"},Hx={key:0,class:"space-y-4"},Wx={class:"text-sm text-gray-600 dark:text-gray-400"},Kx={class:"text-sm text-gray-600 dark:text-gray-400"},Qx={key:1,class:"flex flex-col items-center justify-center py-10"},Gx={class:"text-gray-600 dark:text-gray-400"},Jx={class:"mt-2 text-sm text-gray-500"},Xx={key:2,class:"space-y-6"},Zx={class:"rounded-lg bg-gray-50 p-4 dark:bg-gray-800"},eb={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},tb={class:"grid grid-cols-3 gap-4 text-center"},ab={class:"text-2xl font-bold text-gray-900 dark:text-white"},sb={class:"text-xs text-gray-500"},ob={class:"text-2xl font-bold text-green-600 dark:text-green-400"},nb={class:"text-xs text-gray-500"},rb={class:"text-2xl font-bold text-gray-400"},lb={class:"text-xs text-gray-500"},ib={key:0,class:"text-center text-sm text-amber-600 dark:text-amber-400"},cb={key:3,class:"flex flex-col items-center justify-center py-10"},db={class:"text-gray-600 dark:text-gray-400"},ub={key:0,class:"mt-4 w-full max-w-xs"},mb={key:4,class:"flex flex-col items-center justify-center py-10"},gb={class:"text-lg font-medium text-gray-900 dark:text-white"},pb={class:"mt-2 text-sm text-gray-600 dark:text-gray-400"},vb={key:5,class:"flex flex-col items-center justify-center py-10"},hb={class:"text-lg font-medium text-gray-900 dark:text-white"},yb={class:"mt-2 text-sm text-red-600 dark:text-red-400"},fb={class:"flex w-full justify-end gap-2"},ek=pe({__name:"IncrementalImportModal",props:{modelValue:{type:Boolean},sessionId:{},sessionName:{}},emits:["update:modelValue","imported"],setup(l,{emit:s}){const t=l,c=s,{t:r}=he(),m=f("select"),u=f(null),d=f(null),g=f(null),v=f(null),h=f(null),$=f(null),x=k({get:()=>t.modelValue,set:y=>c("update:modelValue",y)});me(x,y=>{y||S()});function S(){m.value="select",u.value=null,g.value=null,v.value=null,h.value=null,$.value=null}async function E({files:y,paths:A}){if(y.length>0)u.value={source:y[0],name:y[0].name};else{h.value=r("home.import.cannotReadPath");return}await L()}function M(){d.value?.openFileDialog()}async function L(){if(u.value){m.value="analyzing",h.value=null;try{const y=await Zt().analyzeIncrementalImport(t.sessionId,u.value.source);if(y.error){m.value="error",h.value=w(y.error);return}g.value={newMessageCount:y.newMessageCount,duplicateCount:y.duplicateCount,totalInFile:y.totalInFile},m.value="preview"}catch(y){m.value="error",h.value=String(y)}}}async function b(){if(u.value){m.value="importing",v.value={stage:"saving",progress:0,message:""};try{const y=await Zt().incrementalImport(t.sessionId,u.value.source,A=>{v.value=A});y.success?($.value={newMessageCount:y.newMessageCount},m.value="done"):(m.value="error",h.value=w(y.error||"error.import_failed"))}catch(y){m.value="error",h.value=String(y)}}}function I(){$.value&&c("imported",$.value.newMessageCount),x.value=!1}function R(){m.value="select",u.value=null,g.value=null,h.value=null}function w(y){if(y.startsWith("error.")){const A=`home.import.errors.${y.slice(6)}`,q=r(A);return q!==A?q:y}return y}return(y,A)=>{const q=ye,B=Ha,j=Le,_=Fe;return o(),Q(_,{open:x.value,"onUpdate:open":A[1]||(A[1]=T=>x.value=T),title:a(r)("analysis.incremental.title")},{body:O(()=>[e("div",Yx,[m.value==="select"?(o(),i("div",Hx,[e("p",Wx,n(a(r)("analysis.incremental.description",{name:l.sessionName})),1),p(a(Ka),{ref_key:"dropZoneRef",ref:d,accept:[".json",".jsonl",".txt"],class:"w-full",onFiles:E},{default:O(({isDragOver:T})=>[e("div",{class:ae(["flex cursor-pointer flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 py-10 transition-colors",T?"border-pink-500 bg-pink-50/50 dark:border-pink-400 dark:bg-pink-500/10":"border-gray-300 hover:border-pink-400 dark:border-gray-600 dark:hover:border-pink-500"]),onClick:Pe(M,["stop"])},[p(q,{name:"i-heroicons-arrow-up-tray",class:"mb-3 h-10 w-10 text-gray-400"}),e("p",Kx,n(T?a(r)("home.import.dropHint"):a(r)("analysis.incremental.dropHint")),1)],2)]),_:1},512)])):m.value==="analyzing"?(o(),i("div",Qx,[p(q,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),e("p",Gx,n(a(r)("analysis.incremental.analyzing")),1),e("p",Jx,n(u.value?.name),1)])):m.value==="preview"&&g.value?(o(),i("div",Xx,[e("div",Zx,[e("p",eb,n(u.value?.name),1),e("div",tb,[e("div",null,[e("p",ab,n(g.value.totalInFile.toLocaleString()),1),e("p",sb,n(a(r)("analysis.incremental.totalInFile")),1)]),e("div",null,[e("p",ob,n(g.value.newMessageCount.toLocaleString()),1),e("p",nb,n(a(r)("analysis.incremental.newMessages")),1)]),e("div",null,[e("p",rb,n(g.value.duplicateCount.toLocaleString()),1),e("p",lb,n(a(r)("analysis.incremental.duplicates")),1)])])]),g.value.newMessageCount===0?(o(),i("p",ib,[p(q,{name:"i-heroicons-exclamation-triangle",class:"mr-1 inline-block h-4 w-4"}),ne(" "+n(a(r)("analysis.incremental.noNewMessages")),1)])):P("",!0)])):m.value==="importing"?(o(),i("div",cb,[p(q,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),e("p",db,n(a(r)("analysis.incremental.importing")),1),v.value?(o(),i("div",ub,[p(B,{value:v.value.progress,size:"sm"},null,8,["value"])])):P("",!0)])):m.value==="done"&&$.value?(o(),i("div",mb,[p(q,{name:"i-heroicons-check-circle",class:"mb-4 h-12 w-12 text-green-500"}),e("p",gb,n(a(r)("analysis.incremental.success")),1),e("p",pb,n(a(r)("analysis.incremental.successDetail",{count:$.value.newMessageCount})),1)])):m.value==="error"?(o(),i("div",vb,[p(q,{name:"i-heroicons-x-circle",class:"mb-4 h-12 w-12 text-red-500"}),e("p",hb,n(a(r)("analysis.incremental.failed")),1),e("p",yb,n(h.value),1)])):P("",!0)])]),footer:O(()=>[e("div",fb,[m.value==="select"?(o(),Q(j,{key:0,color:"neutral",variant:"ghost",onClick:A[0]||(A[0]=T=>x.value=!1)},{default:O(()=>[ne(n(a(r)("common.cancel")),1)]),_:1})):m.value==="preview"?(o(),i(oe,{key:1},[p(j,{color:"neutral",variant:"ghost",onClick:R},{default:O(()=>[ne(n(a(r)("common.back")),1)]),_:1}),p(j,{color:"primary",disabled:!g.value||g.value.newMessageCount===0,onClick:b},{default:O(()=>[ne(n(a(r)("analysis.incremental.import",{count:g.value?.newMessageCount||0})),1)]),_:1},8,["disabled"])],64)):m.value==="done"||m.value==="error"?(o(),i(oe,{key:2},[m.value==="error"?(o(),Q(j,{key:0,color:"neutral",variant:"ghost",onClick:R},{default:O(()=>[ne(n(a(r)("common.retry")),1)]),_:1})):P("",!0),p(j,{color:"primary",onClick:I},{default:O(()=>[ne(n(a(r)("common.done")),1)]),_:1})],64)):P("",!0)])]),_:1},8,["open","title"])}}}),xb={key:0,class:"fixed right-0 top-1/3"},bb={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"},kb=["onClick"],_b={class:"mb-2 flex items-center justify-between"},wb={class:"px-0.5 text-[9px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"},$b={class:"flex flex-col gap-1.5"},Cb=["onClick"],Sb={class:"whitespace-nowrap"},tk=pe({__name:"ActionToolsPanel",emits:["openIncrementalImport","openSessionIndex","openMemberManagement","openChatRecord","openMessageExport"],setup(l,{emit:s}){const{t}=he(),c=dt(),{isToolsPanelMini:r,toolsPanelPosition:m,isToolsPanelOpen:u}=Ze(c),d=k(()=>m.value==="header"),g=k(()=>!d.value||u.value),v=f(null),h=s;function $(L){h(L),d.value&&(u.value=!1)}function x(L){if(!d.value||!u.value)return;const b=L.target;b instanceof Element&&(v.value?.contains(b)||b.closest("[data-tools-panel-trigger]")||(u.value=!1))}const S=[{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:"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"}],E=[{event:"openSessionIndex",icon:"i-heroicons-clock",hoverColor:"group-hover:text-blue-500",miniHoverBg:"hover:text-blue-500",labelKey:"analysis.tooltip.sessionIndex"},{event:"openMessageExport",icon:"i-heroicons-document-arrow-down",hoverColor:"group-hover:text-green-500",miniHoverBg:"hover:text-green-500",labelKey:"analysis.messageExport.title"}],M=k(()=>d.value?E:S);return me(m,()=>{u.value=!1}),Me(()=>{document.addEventListener("mousedown",x)}),Ct(()=>{document.removeEventListener("mousedown",x)}),(L,b)=>{const I=ye,R=gt;return!d.value&&a(r)?(o(),i("div",xb,[e("div",bb,[(o(),i(oe,null,ue(S,w=>p(R,{key:w.event,text:a(t)(w.labelKey),popper:{placement:"left"}},{default:O(()=>[e("button",{class:ae(["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",w.miniHoverBg]),onClick:y=>$(w.event)},[p(I,{name:w.icon,class:"h-3.5 w-3.5"},null,8,["name"])],10,kb)]),_:2},1032,["text"])),64)),b[2]||(b[2]=e("div",{class:"my-0.5 h-px w-4 bg-gray-200 dark:bg-gray-700"},null,-1)),p(R,{text:a(t)("analysis.toolsPanel.exitMini"),popper:{placement:"left"}},{default:O(()=>[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:b[0]||(b[0]=w=>a(c).toggleToolsPanelMini())},[p(I,{name:"i-heroicons-arrows-pointing-out",class:"h-3 w-3"})])]),_:1},8,["text"])])])):(o(),i("div",{key:1,class:ae(["fixed right-0 z-40",d.value?"top-14":"top-1/3"])},[e("div",{class:ae(["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",_b,[e("span",wb,n(a(t)("analysis.overview.tools")),1),d.value?P("",!0):(o(),Q(R,{key:0,text:a(t)("analysis.toolsPanel.miniMode"),popper:{placement:"left"}},{default:O(()=>[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:b[1]||(b[1]=w=>a(c).toggleToolsPanelMini())},[p(I,{name:"i-heroicons-arrows-pointing-in",class:"h-3 w-3"})])]),_:1},8,["text"]))]),e("div",$b,[(o(!0),i(oe,null,ue(M.value,w=>(o(),i("button",{key:w.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:y=>$(w.event)},[p(I,{name:w.icon,class:ae(["h-3.5 w-3.5 text-gray-400 transition-colors dark:text-gray-500",w.hoverColor])},null,8,["name","class"]),e("span",Sb,n(a(t)(w.labelKey)),1)],8,Cb))),128))])],512)],2)],2))}}}),Tb={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"},Ib={class:"flex w-full flex-col items-center gap-3"},Mb={class:"whitespace-nowrap"},ak=pe({__name:"DebugToolsPanel",setup(l){const s=$t(),t=mt(),c=Ba(t),r=f(!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.setLocale($)}),h=Fa.map($=>({label:$.nativeName,value:$.code}));return($,x)=>{const S=ye,E=Wa;return o(),i("div",{class:"fixed right-0 top-[70%] z-40",onMouseenter:d,onMouseleave:g},[e("div",{class:ae(["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(S,{name:"i-heroicons-bug-ant",class:"h-3.5 w-3.5"})],2),e("div",{class:ae(["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",Tb,[x[2]||(x[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",Ib,[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:x[0]||(x[0]=M=>a(c)())},[p(S,{name:a(t)?"i-heroicons-moon-solid":"i-heroicons-sun-solid",class:ae(["h-3.5 w-3.5 transition-colors",a(t)?"text-indigo-400":"text-amber-400"])},null,8,["name","class"]),e("span",Mb,n(a(t)?"Dark":"Light"),1)]),p(E,{modelValue:v.value,"onUpdate:modelValue":x[1]||(x[1]=M=>v.value=M),items:a(h),content:!1,orientation:"vertical",size:"xs"},null,8,["modelValue","items"])])])],2)],32)}}});export{Nb as A,Ob as B,Kd as C,Yb as D,ak as E,ot as F,ft as _,Ue as a,Fb as b,ct as c,Ub as d,G0 as e,ta as f,ns as g,Wb as h,Bt as i,Kb as j,Ot as k,Pb as l,Xe as m,cg as n,Qb as o,Gb as p,Vb as q,Jb as r,jb as s,Bb as t,Hb as u,Xb as v,tk as w,Zb as x,Xf as y,ek as z};
|