chatlab-cli 0.22.0 → 0.22.1
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/dist/{chunk-6GLMVWGA.mjs → chunk-LZ3W6NS5.mjs} +9 -9
- package/dist/{chunk-3UBWLWXB.mjs → chunk-OC2W5Q5T.mjs} +2 -2
- package/dist/{chunk-4U45E7TO.mjs → chunk-QRC3RSER.mjs} +2 -2
- package/dist/{chunk-QJQJIUUS.mjs → chunk-SQKT45MM.mjs} +73 -25
- package/dist/chunk-SQKT45MM.mjs.map +1 -0
- package/dist/{chunk-AMMSVJG4.mjs → chunk-XPBPKH6B.mjs} +32 -13
- package/dist/chunk-XPBPKH6B.mjs.map +1 -0
- package/dist/{chunk-D2XJ4Z7G.mjs → chunk-Z2LYMKCC.mjs} +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/{http-R5UECMPJ.mjs → http-O5P4BYXU.mjs} +6 -6
- package/dist/{import-3LOWRXWA.mjs → import-BDLL3DG7.mjs} +4 -4
- package/dist/index.mjs +6 -6
- package/dist/{mcp-WBHNLED2.mjs → mcp-L2TPZFE7.mjs} +3 -3
- package/dist/{src-UHM2UDRD.mjs → src-FVJL5ENA.mjs} +2 -2
- package/dist/{stream-import-V6Z7DXSW.mjs → stream-import-ZTEW3YVL.mjs} +3 -3
- package/dist-web/assets/{DebugToolsPanel.vue_vue_type_script_setup_true_lang-CxYyne-Q.js → DebugToolsPanel.vue_vue_type_script_setup_true_lang-CqacsKDU.js} +1 -1
- package/dist-web/assets/{MessageExportModal-De5_tX6a.js → MessageExportModal-D1GY6WSV.js} +1 -1
- package/dist-web/assets/{electron-H65bUnhW.js → electron-CsUM2O_Y.js} +1 -1
- package/dist-web/assets/{fetch-cFjLAPG2.js → fetch-BOogCPfg.js} +1 -1
- package/dist-web/assets/{fetch-Q-PqsiMb.js → fetch-CxwnEEqk.js} +1 -1
- package/dist-web/assets/index-CM29Kc4p.js +173 -0
- package/dist-web/assets/index-D183wYuz.js +7 -0
- package/dist-web/assets/{index-BJUGnYn5.js → index-DOwQB7In.js} +1 -1
- package/dist-web/assets/index-DSpvXged.css +1 -0
- package/dist-web/assets/{index-D_ksezTw.js → index-DTxRy2FH.js} +3 -3
- package/dist-web/assets/{index-B_31fXeB.js → index-grds3iG-.js} +2 -2
- package/dist-web/assets/{web-CZe0Ismu.js → web-Cx5APyCN.js} +1 -1
- package/dist-web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-AMMSVJG4.mjs.map +0 -1
- package/dist/chunk-QJQJIUUS.mjs.map +0 -1
- package/dist-web/assets/index-CbOwHYzO.css +0 -1
- package/dist-web/assets/index-DKMUn8F5.js +0 -173
- package/dist-web/assets/index-Dhg3SDb6.js +0 -7
- /package/dist/{chunk-6GLMVWGA.mjs.map → chunk-LZ3W6NS5.mjs.map} +0 -0
- /package/dist/{chunk-3UBWLWXB.mjs.map → chunk-OC2W5Q5T.mjs.map} +0 -0
- /package/dist/{chunk-4U45E7TO.mjs.map → chunk-QRC3RSER.mjs.map} +0 -0
- /package/dist/{chunk-D2XJ4Z7G.mjs.map → chunk-Z2LYMKCC.mjs.map} +0 -0
- /package/dist/{http-R5UECMPJ.mjs.map → http-O5P4BYXU.mjs.map} +0 -0
- /package/dist/{import-3LOWRXWA.mjs.map → import-BDLL3DG7.mjs.map} +0 -0
- /package/dist/{mcp-WBHNLED2.mjs.map → mcp-L2TPZFE7.mjs.map} +0 -0
- /package/dist/{src-UHM2UDRD.mjs.map → src-FVJL5ENA.mjs.map} +0 -0
- /package/dist/{stream-import-V6Z7DXSW.mjs.map → stream-import-ZTEW3YVL.mjs.map} +0 -0
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
getWeekdayActivity,
|
|
27
27
|
searchMessagesLike,
|
|
28
28
|
searchSessions
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-SQKT45MM.mjs";
|
|
30
30
|
|
|
31
31
|
// ../../packages/tools/src/definitions/sql-query.ts
|
|
32
32
|
var inputSchema = {
|
|
@@ -1341,4 +1341,4 @@ export {
|
|
|
1341
1341
|
MCP_TOOL_REGISTRY,
|
|
1342
1342
|
CoreDataProvider
|
|
1343
1343
|
};
|
|
1344
|
-
//# sourceMappingURL=chunk-
|
|
1344
|
+
//# sourceMappingURL=chunk-Z2LYMKCC.mjs.map
|
package/dist/cli.mjs
CHANGED
|
@@ -6,9 +6,9 @@ const __filename = __fileURLToPath(import.meta.url);
|
|
|
6
6
|
const __dirname = __pathDirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
run
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LZ3W6NS5.mjs";
|
|
10
10
|
import "./chunk-6NB475AA.mjs";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-SQKT45MM.mjs";
|
|
12
12
|
import "./chunk-VSOWNKPA.mjs";
|
|
13
13
|
export {
|
|
14
14
|
run
|
|
@@ -13,12 +13,12 @@ import {
|
|
|
13
13
|
registerWebRoutes,
|
|
14
14
|
startHttpServer,
|
|
15
15
|
stopHttpServer
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-XPBPKH6B.mjs";
|
|
17
|
+
import "./chunk-OC2W5Q5T.mjs";
|
|
18
|
+
import "./chunk-QRC3RSER.mjs";
|
|
19
|
+
import "./chunk-Z2LYMKCC.mjs";
|
|
20
20
|
import "./chunk-6NB475AA.mjs";
|
|
21
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-SQKT45MM.mjs";
|
|
22
22
|
import "./chunk-VSOWNKPA.mjs";
|
|
23
23
|
export {
|
|
24
24
|
createServer,
|
|
@@ -30,4 +30,4 @@ export {
|
|
|
30
30
|
startHttpServer,
|
|
31
31
|
stopHttpServer
|
|
32
32
|
};
|
|
33
|
-
//# sourceMappingURL=http-
|
|
33
|
+
//# sourceMappingURL=http-O5P4BYXU.mjs.map
|
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
detectFormat as detectFormat2,
|
|
9
9
|
importData,
|
|
10
10
|
parseFile
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-OC2W5Q5T.mjs";
|
|
12
12
|
import {
|
|
13
13
|
analyzeIncrementalImport,
|
|
14
14
|
analyzeNewImport,
|
|
15
15
|
incrementalImport,
|
|
16
16
|
streamImport
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-QRC3RSER.mjs";
|
|
18
18
|
import {
|
|
19
19
|
detectAllFormats,
|
|
20
20
|
detectFormat,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
getFormatFeatureById,
|
|
23
23
|
getSupportedFormats,
|
|
24
24
|
scanMultiChatFile
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-SQKT45MM.mjs";
|
|
26
26
|
import "./chunk-VSOWNKPA.mjs";
|
|
27
27
|
export {
|
|
28
28
|
analyzeIncrementalImport,
|
|
@@ -39,4 +39,4 @@ export {
|
|
|
39
39
|
scanMultiChatFile,
|
|
40
40
|
streamImport
|
|
41
41
|
};
|
|
42
|
-
//# sourceMappingURL=import-
|
|
42
|
+
//# sourceMappingURL=import-BDLL3DG7.mjs.map
|
package/dist/index.mjs
CHANGED
|
@@ -6,16 +6,16 @@ const __filename = __fileURLToPath(import.meta.url);
|
|
|
6
6
|
const __dirname = __pathDirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
run
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LZ3W6NS5.mjs";
|
|
10
10
|
import {
|
|
11
11
|
startHttpServer,
|
|
12
12
|
stopHttpServer
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-XPBPKH6B.mjs";
|
|
14
|
+
import "./chunk-OC2W5Q5T.mjs";
|
|
15
|
+
import "./chunk-QRC3RSER.mjs";
|
|
16
|
+
import "./chunk-Z2LYMKCC.mjs";
|
|
17
17
|
import "./chunk-6NB475AA.mjs";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-SQKT45MM.mjs";
|
|
19
19
|
import "./chunk-VSOWNKPA.mjs";
|
|
20
20
|
export {
|
|
21
21
|
run,
|
|
@@ -7,7 +7,7 @@ const __dirname = __pathDirname(__filename);
|
|
|
7
7
|
import {
|
|
8
8
|
CoreDataProvider,
|
|
9
9
|
MCP_TOOL_REGISTRY
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-Z2LYMKCC.mjs";
|
|
11
11
|
import {
|
|
12
12
|
getVersion,
|
|
13
13
|
resolveCliPath
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
hasPendingElectronDataWarning,
|
|
22
22
|
loadConfig,
|
|
23
23
|
verifyCliDataPath
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-SQKT45MM.mjs";
|
|
25
25
|
import "./chunk-VSOWNKPA.mjs";
|
|
26
26
|
|
|
27
27
|
// src/mcp.ts
|
|
@@ -403,4 +403,4 @@ async function startCliMcpServer() {
|
|
|
403
403
|
export {
|
|
404
404
|
startCliMcpServer
|
|
405
405
|
};
|
|
406
|
-
//# sourceMappingURL=mcp-
|
|
406
|
+
//# sourceMappingURL=mcp-L2TPZFE7.mjs.map
|
|
@@ -169,7 +169,7 @@ import {
|
|
|
169
169
|
verifyCliDataPath,
|
|
170
170
|
wasElectronUsed,
|
|
171
171
|
writeParseResultToDb
|
|
172
|
-
} from "./chunk-
|
|
172
|
+
} from "./chunk-SQKT45MM.mjs";
|
|
173
173
|
import "./chunk-VSOWNKPA.mjs";
|
|
174
174
|
export {
|
|
175
175
|
AIConversationManager,
|
|
@@ -337,4 +337,4 @@ export {
|
|
|
337
337
|
wasElectronUsed,
|
|
338
338
|
writeParseResultToDb
|
|
339
339
|
};
|
|
340
|
-
//# sourceMappingURL=src-
|
|
340
|
+
//# sourceMappingURL=src-FVJL5ENA.mjs.map
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
analyzeNewImport,
|
|
10
10
|
incrementalImport,
|
|
11
11
|
streamImport
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-QRC3RSER.mjs";
|
|
13
13
|
import {
|
|
14
14
|
detectAllFormats,
|
|
15
15
|
detectFormat,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
getFormatFeatureById,
|
|
18
18
|
getSupportedFormats,
|
|
19
19
|
scanMultiChatFile
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-SQKT45MM.mjs";
|
|
21
21
|
import "./chunk-VSOWNKPA.mjs";
|
|
22
22
|
export {
|
|
23
23
|
analyzeIncrementalImport,
|
|
@@ -31,4 +31,4 @@ export {
|
|
|
31
31
|
scanMultiChatFile,
|
|
32
32
|
streamImport
|
|
33
33
|
};
|
|
34
|
-
//# sourceMappingURL=stream-import-
|
|
34
|
+
//# sourceMappingURL=stream-import-ZTEW3YVL.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/EChartWordcloud-Ubal_aYg.js","assets/vendor-echarts-wordcloud-CZ9gsX8l.js","assets/vendor-echarts-C5u62NnM.js","assets/vendor-zrender-DFl4U2Oe.js","assets/vendor-reka-ui-CW2cIgMu.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as wa,t as be,u as ye,h as Ue,T as Xe,v as Wt,w as ze,_ as et,x as We,y as it,s as Ze,i as xt,z as bt,A as $a,B as mt,a as kt,n as _t,D as Ca,p as Xt,d as Sa,f as Dt,g as Ta,e as Kt,c as Ia,E as Ma}from"./index-
|
|
2
|
+
import{r as wa,t as be,u as ye,h as Ue,T as Xe,v as Wt,w as ze,_ as et,x as We,y as it,s as Ze,i as xt,z as bt,A as $a,B as mt,a as kt,n as _t,D as Ca,p as Xt,d as Sa,f as Dt,g as Ta,e as Kt,c as Ia,E as Ma}from"./index-D183wYuz.js";import{t as je,w as ue,h as w,b as h,d as De,p as ge,G as n,P as c,Q as ee,a5 as e,U as O,L as g,O as Oe,H as Z,K as V,T as l,a0 as He,R as oe,Z as re,u as a,a3 as me,bA as Fe,bB as nt,a9 as Pe,by as rt,J as Da,W as La,bD as tt,n as qe,z as Ut,F as gt,bH as lt,bI as Zt,k as Aa}from"./vendor-reka-ui-CW2cIgMu.js";import{b as xe,l as vt,a as Ae,c as ea,g as Ne,_ as wt,e as $t,D as Ea,p as ta,f as aa,k as Ft,j as Ra,E as Bt,u as qa,n as za,h as Oa}from"./vendor-nuxt-ui-7OAuiz_i.js";import{_ as sa}from"./vendor-snapdom-XnBoh1gd.js";import{a as dt,M as jt,_ as Na}from"./index-DOwQB7In.js";import"./vendor-echarts-wordcloud-CZ9gsX8l.js";import{u as Ct,m as St,v as oa,t as na,w as Pa,o as Vt,x as Ua,j as Tt,k as Fa,p as ra,q as Yt,n as ut,y as la,z as Ba}from"./vendor-echarts-C5u62NnM.js";function ja(o,s,t,i="group",r="zh-CN"){const u=wa(),{chatKey:v,state:d}=u.ensureSessionState({sessionId:o,sessionName:s,timeFilter:t,chatType:i,locale:r});return u.resetToSelectorOnEnter(v),u.applySessionAssistantSelection(v),{messages:je(d,"messages"),sourceMessages:je(d,"sourceMessages"),currentKeywords:je(d,"currentKeywords"),isLoadingSource:je(d,"isLoadingSource"),isAIThinking:je(d,"isAIThinking"),currentConversationId:je(d,"currentConversationId"),currentToolStatus:je(d,"currentToolStatus"),toolsUsedInCurrentRound:je(d,"toolsUsedInCurrentRound"),sessionTokenUsage:je(d,"sessionTokenUsage"),agentStatus:je(d,"agentStatus"),selectedAssistantId:je(d,"selectedAssistantId"),sendMessage:(m,p)=>u.sendMessage(v,m,p),loadConversation:m=>u.loadConversation(v,m),startNewConversation:m=>u.startNewConversation(v,m),loadMoreSourceMessages:()=>u.loadMoreSourceMessages(),updateMaxMessages:()=>u.updateMaxMessages(),stopGeneration:()=>u.stopGeneration(v),selectAssistantForSession:m=>u.selectAssistantForSession(v,m)}}const Lt=new Map;function Va(o,s,t){const{activeTab:i,isInitialLoad:r,currentSessionId:u,onTimeRangeChange:v}=t,d=h(null),m=h(null),p=h([]),_=w(()=>{const b=d.value;if(b)return{startTs:b.startTs,endTs:b.endTs}}),f=w(()=>{const b=d.value;return b?`${b.startTs}-${b.endTs}`:"init"}),x=w(()=>{const b=d.value;return!b||b.isFullRange?null:new Date(b.startTs*1e3).getFullYear()}),$=w(()=>{const b=o.query,I=b.timeMode;return I?{mode:I,recentDays:b.timeDays?Number(b.timeDays):void 0,year:b.timeYear?Number(b.timeYear):void 0,quarterYear:b.timeYear?Number(b.timeYear):void 0,quarter:b.timeQuarter?Number(b.timeQuarter):void 0,customStart:b.timeStart||void 0,customEnd:b.timeEnd||void 0}:u.value&&Lt.has(u.value)?Lt.get(u.value):{mode:"recent",recentDays:365}});ue([i,d],([b,I])=>{if(r.value||!I)return;const k=I.state,M={tab:b,timeMode:k.mode,timeDays:void 0,timeYear:void 0,timeQuarter:void 0,timeStart:void 0,timeEnd:void 0};k.mode==="recent"&&(M.timeDays=k.recentDays),k.mode==="year"&&(M.timeYear=k.year),k.mode==="quarter"&&(M.timeYear=k.quarterYear,M.timeQuarter=k.quarter),k.mode==="custom"&&(M.timeStart=k.customStart,M.timeEnd=k.customEnd),s.replace({query:{...o.query,...M}})}),ue(d,b=>{!b||!u.value||(Lt.set(u.value,b.state),v?.())},{immediate:!0});function E(){d.value=null,m.value=null,p.value=[]}return{timeRangeValue:d,fullTimeRange:m,availableYears:p,timeFilter:_,timeFilterKey:f,selectedYearForOverview:x,initialTimeState:$,resetTimeRange:E}}function Qt(o){const s=new Date(o*1e3),t=s.getFullYear(),i=String(s.getMonth()+1).padStart(2,"0"),r=String(s.getDate()).padStart(2,"0");return`${t}-${i}-${r}`}function vf(o){return be.unix(o).format("YYYY-MM-DD HH:mm:ss")}function pf(o,s){const t=Qt(o);if(s===null)return`${t} ~ 至今`;const i=Qt(s);return t===i?t:`${t} ~ ${i}`}function zt(o,s,t="YYYY/MM/DD",i=" - "){const r=be.unix(o).format(t),u=be.unix(s).format(t);return r===u?r:`${r}${i}${u}`}function Gt(o,s){return new Intl.DateTimeFormat(s,{year:"numeric",month:"long",day:"numeric"}).format(new Date(o*1e3))}function Ya(o){return o===0?"bg-linear-to-r from-amber-400 to-orange-500 text-white":o===1?"bg-linear-to-r from-gray-300 to-gray-400 text-white":o===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 hf(o){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[o%s.length]}function Ha(o,s,t,i){const r=[];r.push(`# ${o}`),r.push(""),r.push(`> ${i.createdAt}: ${be(t).format("YYYY-MM-DD HH:mm:ss")}`),r.push(""),r.push("---"),r.push("");for(const u of s){const v=be(u.timestamp).format("YYYY-MM-DD HH:mm:ss"),d=u.role==="user"?i.user:i.assistant;r.push(`### ${d}`),r.push(`*${v}*`),r.push(""),r.push(u.content),r.push(""),r.push("---"),r.push("")}return r.join(`
|
|
3
3
|
`)}function Wa(o,s,t,i){const r=[];r.push(`${o}`),r.push(`${i.createdAt}: ${be(t).format("YYYY-MM-DD HH:mm:ss")}`),r.push(""),r.push("=".repeat(50)),r.push("");for(const u of s){const v=be(u.timestamp).format("YYYY-MM-DD HH:mm:ss"),d=u.role==="user"?i.user:i.assistant;r.push(`[${d}] ${v}`),r.push(""),r.push(u.content),r.push(""),r.push("-".repeat(50)),r.push("")}return r.join(`
|
|
4
4
|
`)}function Ka(o){return o.replace(/[/\\?%*:|"<>]/g,"_")}async function Qa(o,s,t,i,r){if(s.length===0)return{success:!1,error:"No messages to export"};let u,v;const d=be(t).format("YYYYMMDD_HHmmss"),m=Ka(o);i==="markdown"?(u=Ha(o,s,t,r),v=`${m}_${d}.md`):(u=Wa(o,s,t,r),v=`${m}_${d}.txt`);const p=`data:text/plain;charset=utf-8,${encodeURIComponent(u)}`;return await window.cacheApi.saveToDownloads(v,p)}function Ga(o){const s=o.columns.join(","),t=o.rows.map(i=>i.map(r=>r===null?"":`"${String(r).replace(/"/g,'""')}"`).join(","));return[s,...t].join(`
|
|
5
5
|
`)}function Ja(o){const s=o.rows.map(t=>{const i={};return o.columns.forEach((r,u)=>{i[r]=t[u]}),i});return JSON.stringify(s,null,2)}async function Xa(o,s){if(o.rows.length===0)return{success:!1,error:"No data to export"};const i=`sql_result_${be().format("YYYYMMDD_HHmmss")}.${s}`;let r,u;s==="json"?(r=Ja(o),u="application/json"):(r=Ga(o),u="text/csv");const v=`data:${u};charset=utf-8,${encodeURIComponent(r)}`;return await window.cacheApi.saveToDownloads(i,v)}function yf(o){const{route:s,router:t,currentSessionId:i,selectSession:r,defaultTab:u,validTabIds:v}=o,d=h(!0),m=h(!0),p=h(null),_=h([]),f=h([]),x=h([]),$=h([]);function E(){const S=s.query.tab;return S&&v.includes(S)?S:u}const b=h(E()),{timeRangeValue:I,fullTimeRange:k,availableYears:M,timeFilter:q,selectedYearForOverview:T,initialTimeState:y}=Va(s,t,{activeTab:b,isInitialLoad:m,currentSessionId:i,onTimeRangeChange:()=>A()});function L(){const S=s.params.id;S&&(r(S),i.value!==S&&t.replace("/"))}async function C(){if(i.value)try{const S=await Ue().getSession(i.value);p.value=S}catch(S){console.error("加载基础数据失败:",S)}}async function A(){if(i.value){d.value=!0;try{const S=q.value,D=Ue(),[P,le,se,W]=await Promise.all([D.getMemberActivity(i.value,S),D.getHourlyActivity(i.value,S),D.getDailyActivity(i.value,S),D.getMessageTypeDistribution(i.value,S)]);_.value=P,f.value=le,x.value=se,$.value=W}catch(S){console.error("加载分析数据失败:",S)}finally{d.value=!1}}}async function N(){i.value&&(m.value=!0,await C(),m.value=!1)}return ue(()=>s.params.id,()=>{b.value=E(),L()}),ue(()=>s.query.tab,()=>{b.value=E()}),ue(i,()=>{N()},{immediate:!0}),De(()=>{L()}),{activeTab:b,isLoading:d,isInitialLoad:m,session:p,memberActivity:_,hourlyActivity:f,dailyActivity:x,messageTypes:$,timeRangeValue:I,fullTimeRange:k,availableYears:M,timeFilter:q,selectedYearForOverview:T,initialTimeState:y,syncSession:L,loadData:N,loadAnalysisData:A}}function ff(o){const{session:s,fullTimeRange:t,timeRangeValue:i,descriptionKey:r}=o,{t:u,locale:v}=ye(),d=w(()=>{const _=t.value?.start??i.value?.startTs,f=Math.floor(Date.now()/1e3);return Gt(_??f,v.value)}),m=w(()=>Gt(Math.floor(Date.now()/1e3),v.value));return{headerDescription:w(()=>u(r,{startDate:d.value,endDate:m.value,messageCount:s.value?.messageCount??0})),headerStartDate:d,headerEndDate:m}}const Za=["data-theme-card"],es={key:0,class:"pointer-events-none absolute inset-0 overflow-hidden"},ts={key:1,class:"absolute right-3 top-3 z-50 opacity-0 transition-opacity duration-200 group-hover/card:opacity-100"},ct=ge({__name:"ThemeCard",props:{variant:{default:"section"},decorative:{type:Boolean,default:!1},capturable:{type:Boolean,default:!0}},setup(o){const s=o,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"},i=w(()=>{const u=`relative isolate overflow-hidden ${t[s.variant]}`;return s.capturable?`group/card ${u}`:u}),r=w(()=>s.decorative&&s.variant==="elevated");return(u,v)=>(n(),c("div",{class:ee(i.value),"data-theme-card":o.capturable?"":void 0},[r.value?(n(),c("div",es,[...v[0]||(v[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)])])):O("",!0),o.capturable?(n(),c("div",ts,[g(dt,{type:"element","target-selector":"[data-theme-card]",size:"xs"})])):O("",!0),Oe(u.$slots,"default")],10,Za))}}),as={class:"flex items-center justify-between"},ss={class:"font-semibold text-gray-900 dark:text-white whitespace-nowrap"},os={key:0,class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},Ve=ge({__name:"SectionCard",props:{title:{},description:{},showDivider:{type:Boolean,default:!0},scrollable:{type:Boolean,default:!1},maxHeightVh:{default:60}},setup(o){const s=o,t=w(()=>{if(s.scrollable)return{maxHeight:`${s.maxHeightVh}vh`,overflowY:"auto"}});return(i,r)=>(n(),Z(ct,{variant:"section"},{default:V(()=>[e("div",{class:ee(["px-5 py-3",{"border-b border-gray-200 dark:border-white/5":o.showDivider&&i.$slots.default}])},[e("div",as,[e("div",null,[e("p",ss,l(o.title),1),o.description?(n(),c("p",os,l(o.description),1)):O("",!0)]),Oe(i.$slots,"headerRight")])],2),o.scrollable?(n(),c("div",{key:0,style:He(t.value)},[Oe(i.$slots,"default")],4)):Oe(i.$slots,"default",{key:1}),Oe(i.$slots,"footer")]),_:3}))}}),ns={class:"flex items-start justify-between"},rs={class:"min-w-0 flex-1"},ls={class:"text-sm font-medium text-gray-500 dark:text-gray-400"},is={key:1,class:"text-xl"},cs={key:0,class:"mt-4 flex items-center text-sm"},ds={class:"text-gray-500 dark:text-gray-400"},Je=ge({__name:"StatCard",props:{label:{},value:{},valueColor:{},subtext:{},icon:{},iconBg:{}},setup(o){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(i,r)=>{const u=xe;return n(),Z(ct,{variant:"card",class:"p-5"},{default:V(()=>[e("div",ns,[e("div",rs,[e("p",ls,l(o.label),1),e("p",{class:ee(["mt-2 truncate text-2xl font-bold tracking-tight",o.valueColor?s[o.valueColor]:"text-gray-900 dark:text-white"])},l(o.value),3)]),o.icon?(n(),c("div",{key:0,class:ee(["ml-4 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl",t[o.iconBg||"gray"]])},[o.icon.startsWith("i-")?(n(),Z(u,{key:0,name:o.icon,class:"h-5 w-5"},null,8,["name"])):(n(),c("span",is,l(o.icon),1))],2)):O("",!0)]),o.subtext||i.$slots.subtext?(n(),c("div",cs,[Oe(i.$slots,"subtext",{},()=>[e("span",ds,l(o.subtext),1)])])):O("",!0)]),_:3})}}}),us={key:0,class:"mb-2 block text-2xl"},xf=ge({__name:"EmptyState",props:{text:{},icon:{},padding:{}},setup(o){const s={sm:"px-4 py-4",md:"px-5 py-8",lg:"px-6 py-12"};return(t,i)=>(n(),c("div",{class:ee(["text-center text-sm text-gray-400",s[o.padding||"md"]])},[o.icon?(n(),c("span",us,l(o.icon),1)):O("",!0),oe(" "+l(o.text||"暂无数据"),1)],2))}}),ms={class:"flex flex-col items-center justify-center text-center"},gs={key:0,class:"mt-2 text-sm text-gray-500"},ft=ge({__name:"LoadingState",props:{text:{},height:{},variant:{default:"inline"}},setup(o){const s=o,t=w(()=>{const i="flex items-center justify-center";switch(s.variant){case"page":return`${i} h-full w-full`;case"overlay":return`${i} absolute inset-0 z-10 bg-white/50 backdrop-blur-sm dark:bg-gray-950/50`;default:return`${i} ${s.height||"py-8"}`}});return(i,r)=>{const u=xe;return n(),c("div",{class:ee(t.value)},[e("div",ms,[g(u,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-pink-500"}),o.text?(n(),c("p",gs,l(o.text),1)):O("",!0)])],2)}}}),vs={key:1,class:"flex items-center"},ps={class:"whitespace-nowrap px-0.5 text-sm font-medium text-gray-700 dark:text-gray-300"},hs={key:2,class:"flex items-center"},ys={class:"whitespace-nowrap px-0.5 text-sm font-medium text-gray-700 dark:text-gray-300"},fs={key:3,class:"flex items-center gap-1"},bf=ge({__name:"TimeSelect",props:{sessionId:{},modelValue:{},visible:{type:Boolean,default:!0},initialState:{}},emits:["update:modelValue","update:fullRange","update:availableYears"],setup(o,{emit:s}){const t=o,i=s,{t:r}=ye(),u=h(!1),v=h([]),d=h(null),m=h("recent"),p=h(365),_=h(0),f=h(0),x=h(1),$=h(""),E=h(""),b=h(!1);function I(j){const J=new Date(j*1e3);return{year:J.getFullYear(),quarter:Math.floor(J.getMonth()/3)+1}}function k(j,J){const ce=(J-1)*3,ve=new Date(j,ce,1,0,0,0),G=new Date(j,ce+3,0,23,59,59);return{startTs:Math.floor(ve.getTime()/1e3),endTs:Math.floor(G.getTime()/1e3)}}function M(j){const J=new Date(j,0,1,0,0,0),ce=new Date(j,11,31,23,59,59);return{startTs:Math.floor(J.getTime()/1e3),endTs:Math.floor(ce.getTime()/1e3)}}const q=w(()=>[{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"}]),T=w(()=>[{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=w(()=>d.value?I(d.value.start):{year:0,quarter:1}),L=w(()=>d.value?I(d.value.end):{year:0,quarter:1}),C=w(()=>{const j=y.value;return f.value>j.year||f.value===j.year&&x.value>j.quarter}),A=w(()=>{const j=L.value;return f.value<j.year||f.value===j.year&&x.value<j.quarter}),N=w(()=>v.value.length===0?!1:v.value.indexOf(_.value)<v.value.length-1),S=w(()=>v.value.length===0?!1:v.value.indexOf(_.value)>0),D=w(()=>r("common.timeSelect.quarter.label",{year:f.value,quarter:x.value})),P=w(()=>r("common.timeSelect.year.label",{year:_.value}));function le(j){return{365:r("common.timeSelect.display.recent365"),730:r("common.timeSelect.display.recent730"),1825:r("common.timeSelect.display.recent1825")}[j]||""}function se(j){return[365,730,1825,0].includes(j)?j:365}function W(){if(!d.value)return null;const j={mode:m.value};switch(m.value){case"recent":{if(j.recentDays=p.value,p.value===0)return{startTs:d.value.start,endTs:d.value.end,displayLabel:zt(d.value.start,d.value.end),isFullRange:!0,state:j};const J=d.value.end;return{startTs:Math.max(J-p.value*86400,d.value.start),endTs:J,displayLabel:le(p.value),isFullRange:!1,state:j}}case"quarter":return j.quarterYear=f.value,j.quarter=x.value,{...k(f.value,x.value),displayLabel:D.value,isFullRange:!1,state:j};case"year":return j.year=_.value,{...M(_.value),displayLabel:P.value,isFullRange:!1,state:j};case"custom":{if(j.customStart=$.value,j.customEnd=E.value,!$.value||!E.value)return null;let J=be($.value).startOf("day").unix(),ce=be(E.value).endOf("day").unix();return J>ce&&([J,ce]=[ce,J]),{startTs:J,endTs:ce,displayLabel:zt(J,ce),isFullRange:!1,state:j}}}}function F(){const j=W();j&&i("update:modelValue",j)}function R(j){let J=f.value,ce=x.value+j;ce>4&&(J++,ce=1),ce<1&&(J--,ce=4);const ve=y.value,G=L.value;J<ve.year||J===ve.year&&ce<ve.quarter||J>G.year||J===G.year&&ce>G.quarter||(f.value=J,x.value=ce,F())}function z(j){const J=v.value,ve=J.indexOf(_.value)-j;ve>=0&&ve<J.length&&(_.value=J[ve],F())}function Y(j){if(d.value)switch(j){case"recent":p.value=se(p.value);break;case"quarter":{const{year:J,quarter:ce}=I(d.value.end);f.value=J,x.value=ce;break}case"year":{_.value=v.value[0]||new Date(d.value.end*1e3).getFullYear();break}case"custom":{const J=d.value.end,ce=Math.max(J-30*86400,d.value.start);$.value=be.unix(ce).format("YYYY-MM-DD"),E.value=be.unix(J).format("YYYY-MM-DD");break}}}const Q=w({get:()=>m.value,set:j=>{m.value=j,b.value=!0,Y(j),b.value=!1,F()}}),ie=w({get:()=>p.value,set:j=>{p.value=j,F()}}),H=w({get:()=>$.value,set:j=>{$.value=j,E.value&&F()}}),U=w({get:()=>E.value,set:j=>{E.value=j,$.value&&F()}});async function B(){if(!t.sessionId){v.value=[],d.value=null,i("update:fullRange",null),i("update:availableYears",[]),u.value=!0;return}try{const j=Ue(),[J,ce]=await Promise.all([j.getAvailableYears(t.sessionId),j.getTimeRange(t.sessionId)]);v.value=J,d.value=ce,i("update:fullRange",ce),i("update:availableYears",J);const ve=t.initialState,G=ve?.mode??"recent";switch(m.value=G,b.value=!0,G){case"recent":p.value=se(ve?.recentDays??365);break;case"quarter":{if(ve?.quarterYear&&ve?.quarter)f.value=ve.quarterYear,x.value=ve.quarter;else if(ce){const{year:te,quarter:he}=I(ce.end);f.value=te,x.value=he}break}case"year":{ve?.year&&J.includes(ve.year)?_.value=ve.year:_.value=J[0]||0;break}case"custom":{if(ve?.customStart&&ve?.customEnd)$.value=ve.customStart,E.value=ve.customEnd;else if(ce){const te=ce.end,he=Math.max(te-30*86400,ce.start);$.value=be.unix(he).format("YYYY-MM-DD"),E.value=be.unix(te).format("YYYY-MM-DD")}break}}b.value=!1,F()}catch(j){console.error("TimeSelect 加载数据失败:",j),v.value=[],d.value=null,i("update:fullRange",null),i("update:availableYears",[])}finally{u.value=!0}}return De(()=>B()),ue(()=>t.sessionId,()=>{u.value=!1,B()}),(j,J)=>{const ce=vt,ve=Ae;return u.value?(n(),c("div",{key:0,class:ee(["flex items-center gap-2",{invisible:!o.visible}])},[g(ce,{modelValue:Q.value,"onUpdate:modelValue":J[0]||(J[0]=G=>Q.value=G),items:q.value,size:"md",class:"w-28 shrink-0"},null,8,["modelValue","items"]),m.value==="recent"?(n(),Z(Xe,{key:0,modelValue:ie.value,"onUpdate:modelValue":J[1]||(J[1]=G=>ie.value=G),items:T.value,size:"sm",class:"min-w-0 shrink"},null,8,["modelValue","items"])):m.value==="quarter"?(n(),c("div",vs,[g(ve,{icon:"i-heroicons-chevron-left",size:"sm",variant:"ghost",color:"neutral",disabled:!C.value,onClick:J[2]||(J[2]=G=>R(-1))},null,8,["disabled"]),e("span",ps,l(D.value),1),g(ve,{icon:"i-heroicons-chevron-right",size:"sm",variant:"ghost",color:"neutral",disabled:!A.value,onClick:J[3]||(J[3]=G=>R(1))},null,8,["disabled"])])):m.value==="year"?(n(),c("div",hs,[g(ve,{icon:"i-heroicons-chevron-left",size:"sm",variant:"ghost",color:"neutral",disabled:!N.value,onClick:J[4]||(J[4]=G=>z(-1))},null,8,["disabled"]),e("span",ys,l(P.value),1),g(ve,{icon:"i-heroicons-chevron-right",size:"sm",variant:"ghost",color:"neutral",disabled:!S.value,onClick:J[5]||(J[5]=G=>z(1))},null,8,["disabled"])])):m.value==="custom"?(n(),c("div",fs,[g(Wt,{modelValue:H.value,"onUpdate:modelValue":J[6]||(J[6]=G=>H.value=G),"width-class":"w-28",clearable:!1},null,8,["modelValue"]),J[8]||(J[8]=e("span",{class:"text-xs text-gray-400"},"-",-1)),g(Wt,{modelValue:U.value,"onUpdate:modelValue":J[7]||(J[7]=G=>U.value=G),"width-class":"w-28",clearable:!1},null,8,["modelValue"])])):O("",!0)],2)):O("",!0)}}}),xs=["disabled"],bs={key:0,class:"flex-1 overflow-y-auto p-2"},ks={key:0,class:"flex items-center justify-center py-8"},_s={key:1,class:"flex flex-col items-center justify-center py-12 text-center"},ws={class:"flex h-12 w-12 items-center justify-center rounded-full bg-gray-50 dark:bg-gray-800"},$s={class:"mt-3 text-xs text-gray-400"},Cs={key:2,class:"space-y-3"},Ss={class:"px-2 pb-1 pt-1.5 text-[10px] font-medium tracking-wide text-gray-400 dark:text-gray-500"},Ts={class:"space-y-0.5"},Is=["onClick"],Ms=["placeholder","onBlur","onKeyup"],Ds={key:1,class:"flex items-center"},Ls={class:"line-clamp-1 min-w-0 flex-1 text-sm leading-snug"},As={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"},Es={class:"w-28 p-1"},Rs=["disabled","onClick"],qs=["disabled","onClick"],zs={key:1,class:"flex flex-1 flex-col items-center gap-2 overflow-y-auto py-2"},Os=["title","disabled"],Ns=["title","onClick"],Ps=ge({__name:"ConversationList",props:{sessionId:{},activeId:{},disabled:{type:Boolean}},emits:["select","create","delete"],setup(o,{expose:s,emit:t}){const{t:i}=ye(),r=o,u=t,v=h([]),d=h(!1),m=h(null),p=h(""),_=h(!1),f=h(null);async function x(){d.value=!0;try{v.value=await ze().getConversations(r.sessionId)}catch(T){console.error("加载对话列表失败:",T)}finally{d.value=!1}}const $=w(()=>{if(v.value.length===0)return[];const T=be(),y=T.subtract(7,"day").startOf("day"),L=T.subtract(30,"day").startOf("day"),C=[],A=[],N=new Map;for(const P of v.value){const le=be(P.updatedAt*1e3);if(le.isAfter(y))C.push(P);else if(le.isAfter(L))A.push(P);else{const se=le.format("YYYY-MM");N.has(se)||N.set(se,[]),N.get(se).push(P)}}const S=[];C.length>0&&S.push({label:i("ai.chat.conversation.group.last7Days"),conversations:C}),A.length>0&&S.push({label:i("ai.chat.conversation.group.last30Days"),conversations:A});const D=[...N.keys()].sort((P,le)=>le.localeCompare(P));for(const P of D){const le=be(P+"-01");S.push({label:le.format(le.year()===T.year()?"M月":"YYYY年M月"),conversations:N.get(P)})}return S});function E(T){return T.title||i("ai.chat.conversation.newChat")}function b(T){r.disabled||(m.value=T.id,p.value=T.title||"")}async function I(T){if(!r.disabled){if(p.value.trim())try{await ze().updateConversationTitle(T,p.value.trim());const y=v.value.find(L=>L.id===T);y&&(y.title=p.value.trim())}catch(y){console.error("更新标题失败:",y)}m.value=null}}function k(T){f.value=null,b(T)}function M(T){f.value=null,q(T)}async function q(T){if(!r.disabled)try{await ze().deleteConversation(T),v.value=v.value.filter(y=>y.id!==T),u("delete",T)}catch(y){console.error("删除对话失败:",y)}}return De(()=>{x()}),ue(()=>r.sessionId,()=>{x()}),s({refresh:x}),(T,y)=>{const L=xe,C=Ae,A=ea;return n(),c("div",{class:ee(["flex flex-col border-r border-gray-200 bg-white transition-all dark:border-gray-800 dark:bg-gray-900",_.value?"w-10":"w-64"])},[e("div",{class:ee(["flex items-center border-b border-gray-200 dark:border-gray-800",_.value?"justify-center px-0 py-2":"justify-between pl-3 pr-2 py-2"])},[_.value?(n(),c("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:y[2]||(y[2]=N=>_.value=!_.value)},[g(L,{name:"i-heroicons-chevron-right",class:"h-4 w-4"})])):(n(),c(re,{key:0},[e("button",{class:ee(["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":o.disabled}]),disabled:o.disabled,onClick:y[0]||(y[0]=N=>!o.disabled&&u("create"))},[g(L,{name:"i-heroicons-plus",class:"h-3.5 w-3.5"}),e("span",null,l(a(i)("ai.chat.conversation.newConversation")),1)],10,xs),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:y[1]||(y[1]=N=>_.value=!_.value)},[g(L,{name:"i-heroicons-chevron-left",class:"h-4 w-4"})])],64))],2),_.value?(n(),c("div",zs,[e("button",{class:ee(["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":o.disabled}]),title:a(i)("ai.chat.conversation.newConversation"),disabled:o.disabled,onClick:y[7]||(y[7]=N=>!o.disabled&&u("create"))},[g(L,{name:"i-heroicons-plus",class:"h-4 w-4"})],10,Os),y[8]||(y[8]=e("div",{class:"h-px w-6 bg-gray-200 dark:bg-gray-800"},null,-1)),(n(!0),c(re,null,me(v.value,N=>(n(),c("button",{key:N.id,class:ee(["rounded p-1 transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",[o.activeId===N.id?"text-pink-500":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"]]),title:E(N),onClick:S=>u("select",N.id)},[g(L,{name:"i-heroicons-chat-bubble-left",class:"h-4 w-4"})],10,Ns))),128))])):(n(),c("div",bs,[d.value?(n(),c("div",ks,[g(L,{name:"i-heroicons-arrow-path",class:"h-5 w-5 animate-spin text-gray-400"})])):v.value.length===0?(n(),c("div",_s,[e("div",ws,[g(L,{name:"i-heroicons-chat-bubble-left",class:"h-6 w-6 text-gray-300 dark:text-gray-600"})]),e("p",$s,l(a(i)("ai.chat.conversation.empty")),1),g(C,{class:"mt-2",size:"xs",variant:"link",color:"primary",disabled:o.disabled,onClick:y[3]||(y[3]=N=>!o.disabled&&u("create"))},{default:V(()=>[oe(l(a(i)("ai.chat.conversation.startNew")),1)]),_:1},8,["disabled"])])):(n(),c("div",Cs,[(n(!0),c(re,null,me($.value,N=>(n(),c("div",{key:N.label},[e("div",Ss,l(N.label),1),e("div",Ts,[(n(!0),c(re,null,me(N.conversations,S=>(n(),c("div",{key:S.id,class:ee(["group relative rounded-lg px-3 py-2 transition-all",["cursor-pointer",o.activeId===S.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:D=>u("select",S.id)},[m.value===S.id?Fe((n(),c("input",{key:0,"onUpdate:modelValue":y[4]||(y[4]=D=>p.value=D),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(i)("ai.chat.conversation.titlePlaceholder"),autoFocus:"",onBlur:D=>I(S.id),onKeyup:rt(D=>I(S.id),["enter"]),onClick:y[5]||(y[5]=Pe(()=>{},["stop"]))},null,40,Ms)),[[nt,p.value]]):(n(),c("div",Ds,[e("p",Ls,l(E(S)),1),e("div",{class:ee(["ml-1 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",{"opacity-100":o.activeId===S.id||f.value===S.id}]),onClick:y[6]||(y[6]=Pe(()=>{},["stop"]))},[g(A,{open:f.value===S.id,ui:{content:"z-50 p-0"},"onUpdate:open":D=>f.value=D?S.id:null},{content:V(()=>[e("div",Es,[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:o.disabled,onClick:D=>k(S)},[g(L,{name:"i-heroicons-pencil",class:"h-3.5 w-3.5"}),oe(" "+l(a(i)("ai.chat.conversation.rename")),1)],8,Rs),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:o.disabled,onClick:D=>M(S.id)},[g(L,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"}),oe(" "+l(a(i)("ai.chat.conversation.delete")),1)],8,qs)])]),default:V(()=>[e("button",As,[g(L,{name:"i-heroicons-ellipsis-horizontal",class:"h-4 w-4"})])]),_:2},1032,["open","onUpdate:open"])],2)]))],10,Is))),128))])]))),128))]))]))],2)}}}),Us={class:"writing-vertical text-xs"},Fs={class:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800"},Bs={class:"flex items-center gap-2"},js={class:"font-medium text-gray-900 dark:text-white"},Vs={key:0,class:"border-b border-gray-200 px-4 py-2 dark:border-gray-800"},Ys={class:"flex flex-wrap items-center gap-2"},Hs={class:"text-xs text-gray-500"},Ws={class:"flex-1 overflow-y-auto"},Ks={key:0,class:"flex items-center justify-center py-8"},Qs={key:1,class:"flex flex-col items-center justify-center py-8 text-center"},Gs={class:"mt-2 text-sm text-gray-500"},Js={class:"text-xs text-gray-400"},Xs={key:2,class:"divide-y divide-gray-100 dark:divide-gray-800"},Zs={class:"mb-1 flex items-center justify-between"},eo={class:"text-sm font-medium text-gray-900 dark:text-white"},to={class:"text-xs text-gray-400"},ao=["innerHTML"],so={key:1,class:"border-t border-gray-200 px-4 py-2 dark:border-gray-800"},oo={class:"flex items-center justify-between"},no={class:"text-xs text-gray-500"},ro={key:2,class:"pointer-events-none absolute inset-0 overflow-hidden rounded-xl opacity-[0.03]"},lo=ge({__name:"DataSourcePanel",props:{messages:{},keywords:{},isLoading:{type:Boolean},isCollapsed:{type:Boolean}},emits:["toggle","loadMore"],setup(o,{emit:s}){const{t}=ye(),i=o,r=s;function u(d){return be(d).format("MM-DD HH:mm")}function v(d){if(!i.keywords.length)return d;const m=i.keywords.join("|"),p=new RegExp(`(${m})`,"gi");return d.replace(p,'<mark class="bg-yellow-200 dark:bg-yellow-800/50 px-0.5 rounded">$1</mark>')}return(d,m)=>{const p=xe,_=Ae;return n(),c("div",{class:ee(["relative flex flex-col rounded-xl bg-white shadow-sm transition-all duration-300 dark:bg-gray-900",[o.isCollapsed?"w-12":"w-full"]])},[o.isCollapsed?(n(),c("button",{key:0,class:"flex h-full flex-col items-center justify-center gap-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",onClick:m[0]||(m[0]=f=>r("toggle"))},[g(p,{name:"i-heroicons-chevron-left",class:"h-5 w-5"}),e("span",Us,l(a(t)("ai.chat.dataSource.title")),1)])):(n(),c(re,{key:1},[e("div",Fs,[e("div",Bs,[g(p,{name:"i-heroicons-document-magnifying-glass",class:"h-5 w-5 text-gray-500"}),e("span",js,l(a(t)("ai.chat.dataSource.title")),1)]),g(_,{icon:"i-heroicons-chevron-right",color:"gray",variant:"ghost",size:"xs",onClick:m[1]||(m[1]=f=>r("toggle"))})]),o.keywords.length>0?(n(),c("div",Vs,[e("div",Ys,[e("span",Hs,l(a(t)("ai.chat.dataSource.keywords")),1),(n(!0),c(re,null,me(o.keywords,f=>(n(),c("span",{key:f,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"},l(f),1))),128))])])):O("",!0),e("div",Ws,[o.isLoading?(n(),c("div",Ks,[g(p,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):o.messages.length===0?(n(),c("div",Qs,[g(p,{name:"i-heroicons-inbox",class:"h-10 w-10 text-gray-300 dark:text-gray-600"}),e("p",Gs,l(a(t)("ai.chat.dataSource.empty")),1),e("p",Js,l(a(t)("ai.chat.dataSource.emptyHint")),1)])):(n(),c("div",Xs,[(n(!0),c(re,null,me(o.messages,f=>(n(),c("div",{key:f.id,class:"px-4 py-3 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[e("div",Zs,[e("span",eo,l(f.senderName),1),e("span",to,l(u(f.timestamp)),1)]),e("p",{class:"line-clamp-3 text-sm text-gray-600 dark:text-gray-400",innerHTML:v(f.content)},null,8,ao)]))),128))]))]),o.messages.length>0?(n(),c("div",so,[e("div",oo,[e("span",no,l(a(t)("ai.chat.dataSource.totalRecords",{count:o.messages.length})),1),g(_,{size:"xs",variant:"ghost",onClick:m[2]||(m[2]=f=>r("loadMore"))},{default:V(()=>[oe(l(a(t)("ai.chat.dataSource.loadMore")),1)]),_:1})])])):O("",!0)],64)),o.isCollapsed?O("",!0):(n(),c("div",ro,[...m[3]||(m[3]=[e("div",{class:"data-flow-bg absolute inset-0"},null,-1)])]))],2)}}}),io=et(lo,[["__scopeId","data-v-19a25590"]]),co={class:"flex max-h-[80vh] flex-col overflow-hidden"},uo={class:"shrink-0 border-b border-gray-200 px-6 py-4 dark:border-gray-800"},mo={class:"flex items-center justify-between"},go={class:"flex items-center gap-3"},vo={class:"flex h-8 w-8 items-center justify-center rounded-lg bg-red-100 dark:bg-red-900/40"},po={class:"text-lg font-semibold text-gray-900 dark:text-white"},ho={class:"flex-1 overflow-y-auto px-6 py-4"},yo={class:"flex flex-col gap-4"},fo={class:"text-sm font-semibold text-gray-700 dark:text-gray-300"},xo={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"},bo={class:"m-0 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-red-600 dark:text-red-400"},ko={key:1,class:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-gray-900"},_o={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"},wo={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"},$o={key:0,class:"py-8 text-center text-sm text-gray-400 dark:text-gray-500"},Co={class:"shrink-0 border-t border-gray-200 px-6 py-3 dark:border-gray-800"},So={class:"flex justify-end"},To=ge({__name:"ErrorDetailModal",props:La({error:{}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:["update:open"],setup(o){const{t:s}=ye(),t=We(),i=Da(o,"open"),r=o,u=w(()=>{const m=r.error,p=[];return m.url&&p.push({label:s("ai.chat.error.requestUrl"),value:m.url}),m.statusCode!=null&&p.push({label:s("ai.chat.error.statusCode"),value:String(m.statusCode)}),m.responseBody&&p.push({label:s("ai.chat.error.responseBody"),value:v(m.responseBody),isCode:!0}),m.responseHeaders&&p.push({label:s("ai.chat.error.responseHeaders"),value:JSON.stringify(m.responseHeaders,null,2),isCode:!0}),m.name&&p.push({label:s("ai.chat.error.name"),value:m.name}),m.message&&p.push({label:s("ai.chat.error.message"),value:m.message}),m.stack&&p.push({label:s("ai.chat.error.stack"),value:m.stack,isStack:!0}),m.cause&&p.push({label:s("ai.chat.error.cause"),value:v(m.cause),isCode:!0}),m.provider&&p.push({label:s("ai.chat.error.provider"),value:m.provider}),m.requestBody&&p.push({label:s("ai.chat.error.requestBody"),value:v(m.requestBody),isCode:!0}),p});function v(m){try{return JSON.stringify(JSON.parse(m),null,2)}catch{return m}}function d(){const m=u.value.map(p=>`${p.label}: ${p.value}`).join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as de,a as le,k as ce,b as se,g as ue,r as ge}from"./vendor-nuxt-ui-7OAuiz_i.js";import{u as J,d as ne,T as ye,h as ie,f as ve,H as me,b as xe,x as he,w as O,j as pe}from"./index-Dhg3SDb6.js";import{p as X,J as Q,w as W,d as re,G as l,P as u,a5 as t,R as T,T as n,u as y,L as I,K as R,Z as N,a3 as Z,H as Y,U as H,bA as ae,bB as oe,b as $,h as P,bE as fe,a0 as q,a9 as ke,Q as te,n as be,by as _e,W as we,bp as G}from"./vendor-reka-ui-CW2cIgMu.js";import{c as $e}from"./DebugToolsPanel.vue_vue_type_script_setup_true_lang-CxYyne-Q.js";import"./vendor-snapdom-XnBoh1gd.js";import"./index-BJUGnYn5.js";import"./vendor-echarts-wordcloud-CZ9gsX8l.js";import"./vendor-echarts-C5u62NnM.js";import"./vendor-zrender-DFl4U2Oe.js";const Se={class:"p-4 space-y-6"},Ie={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Ce={class:"text-gray-500 text-xs ml-1"},Te={class:"flex gap-2 mb-2"},Me={key:0,class:"flex flex-wrap gap-2"},ze=["onClick"],De={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Le={class:"space-y-2"},Be={key:0,class:"flex gap-2 items-center"},Fe={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Ue={class:"text-gray-500 text-xs ml-1"},Re={class:"max-h-60 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded-md"},Pe={key:0,class:"p-4 text-center text-gray-500"},Ve={key:1,class:"p-4 text-center text-gray-500 text-sm"},He={key:2,class:"divide-y divide-gray-100 dark:divide-gray-700"},je=["checked","onChange"],Ee={class:"text-sm text-gray-700 dark:text-gray-300 truncate"},Ne={class:"text-xs text-gray-400 ml-auto"},Ae={key:0,class:"mt-2 text-xs text-gray-500"},Ke={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Ye={class:"text-gray-500 text-xs ml-1"},We=X({__name:"ConditionPanel",props:{keywords:{default:()=>[]},keywordsModifiers:{},timeRange:{default:null},timeRangeModifiers:{},senderIds:{default:()=>[]},senderIdsModifiers:{},contextSize:{default:10},contextSizeModifiers:{}},emits:["update:keywords","update:timeRange","update:senderIds","update:contextSize"],setup(v){const{t:C}=J(),M=ne(),h=Q(v,"keywords"),m=Q(v,"timeRange"),w=Q(v,"senderIds"),z=Q(v,"contextSize"),L=$(""),r=$([]),p=$(!1),k=$("all"),x=$(""),D=$(""),B=[{id:"all",label:"analysis.filter.allTime"},{id:"today",label:"analysis.filter.today"},{id:"week",label:"analysis.filter.lastWeek"},{id:"month",label:"analysis.filter.lastMonth"},{id:"3months",label:"analysis.filter.last3Months"},{id:"year",label:"analysis.filter.lastYear"},{id:"custom",label:"analysis.filter.customTime"}],F=P(()=>B.map(s=>({label:C(s.label),value:s.id})));W(k,()=>{a()});const j=$(null);async function E(){const s=M.currentSessionId;if(s){p.value=!0;try{r.value=await ie().getMembers(s)}catch(e){console.error("加载成员失败:",e)}finally{p.value=!1}}}async function V(){const s=M.currentSessionId;if(s)try{const e=await ie().getTimeRange(s);e&&(j.value=e)}catch(e){console.error("加载时间范围失败:",e)}}function U(){const s=L.value.trim();s&&!h.value.includes(s)&&(h.value=[...h.value,s],L.value="")}function c(s){h.value=h.value.filter(e=>e!==s)}function g(s){s.key==="Enter"&&(s.preventDefault(),U())}function o(s){w.value.includes(s)?w.value=w.value.filter(e=>e!==s):w.value=[...w.value,s]}function a(){const s=Math.floor(Date.now()/1e3),e=new Date;e.setHours(0,0,0,0);const d=Math.floor(e.getTime()/1e3);switch(k.value){case"all":m.value=null;break;case"today":m.value={start:d,end:s};break;case"week":m.value={start:s-10080*60,end:s};break;case"month":m.value={start:s-720*60*60,end:s};break;case"3months":m.value={start:s-2160*60*60,end:s};break;case"year":m.value={start:s-365*24*60*60,end:s};break;case"custom":if(x.value&&D.value){const f=new Date(x.value).getTime()/1e3,i=new Date(D.value).getTime()/1e3+86399;m.value={start:f,end:i}}break}}const b=$(""),A=P(()=>{if(!b.value)return r.value;const s=b.value.toLowerCase();return r.value.filter(e=>e.accountName?.toLowerCase().includes(s)||e.groupNickname?.toLowerCase().includes(s)||e.platformId.toLowerCase().includes(s)||e.aliases.some(d=>d.toLowerCase().includes(s)))});return re(()=>{E(),V()}),(s,e)=>{const d=de,f=le,i=se,S=ce;return l(),u("div",Se,[t("div",null,[t("label",Ie,[T(n(y(C)("analysis.filter.keywords"))+" ",1),t("span",Ce,"("+n(y(C)("analysis.filter.keywordsHint"))+")",1)]),t("div",Te,[I(d,{modelValue:L.value,"onUpdate:modelValue":e[0]||(e[0]=_=>L.value=_),placeholder:y(C)("analysis.filter.keywordPlaceholder"),class:"flex-1",onKeydown:g},null,8,["modelValue","placeholder"]),I(f,{size:"sm",onClick:U},{default:R(()=>[T(n(y(C)("common.add")),1)]),_:1})]),h.value.length>0?(l(),u("div",Me,[(l(!0),u(N,null,Z(h.value,_=>(l(),Y(S,{key:_,color:"primary",variant:"subtle",class:"gap-1"},{default:R(()=>[T(n(_)+" ",1),t("button",{class:"ml-1 hover:text-red-500",onClick:K=>c(_)},[I(i,{name:"i-heroicons-x-mark",class:"w-3 h-3"})],8,ze)]),_:2},1024))),128))])):H("",!0)]),t("div",null,[t("label",De,n(y(C)("analysis.filter.timeRange")),1),t("div",Le,[I(ye,{modelValue:k.value,"onUpdate:modelValue":e[1]||(e[1]=_=>k.value=_),items:F.value,size:"sm"},null,8,["modelValue","items"]),k.value==="custom"?(l(),u("div",Be,[ae(t("input",{"onUpdate:modelValue":e[2]||(e[2]=_=>x.value=_),type:"date",class:"flex-1 px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800",onChange:a},null,544),[[oe,x.value]]),e[6]||(e[6]=t("span",{class:"text-gray-500"},"~",-1)),ae(t("input",{"onUpdate:modelValue":e[3]||(e[3]=_=>D.value=_),type:"date",class:"flex-1 px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800",onChange:a},null,544),[[oe,D.value]])])):H("",!0)])]),t("div",null,[t("label",Fe,[T(n(y(C)("analysis.filter.senders"))+" ",1),t("span",Ue,"("+n(y(C)("analysis.filter.sendersHint"))+")",1)]),I(d,{modelValue:b.value,"onUpdate:modelValue":e[4]||(e[4]=_=>b.value=_),placeholder:y(C)("analysis.filter.searchMember"),icon:"i-heroicons-magnifying-glass",size:"sm",class:"mb-2"},null,8,["modelValue","placeholder"]),t("div",Re,[p.value?(l(),u("div",Pe,[I(i,{name:"i-heroicons-arrow-path",class:"w-5 h-5 animate-spin"})])):A.value.length===0?(l(),u("div",Ve,n(y(C)("analysis.filter.noMembers")),1)):(l(),u("div",He,[(l(!0),u(N,null,Z(A.value,_=>(l(),u("label",{key:_.id,class:"flex items-center gap-2 px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer"},[t("input",{type:"checkbox",checked:w.value.includes(_.id),class:"text-primary-500 rounded",onChange:K=>o(_.id)},null,40,je),t("span",Ee,n(_.groupNickname||_.accountName||_.platformId),1),t("span",Ne,"("+n(_.messageCount)+")",1)]))),128))]))]),w.value.length>0?(l(),u("div",Ae,n(y(C)("analysis.filter.selectedCount",{count:w.value.length})),1)):H("",!0)]),t("div",null,[t("label",Ke,[T(n(y(C)("analysis.filter.contextSize"))+" ",1),t("span",Ye,"±"+n(z.value)+" "+n(y(C)("analysis.filter.messages")),1)]),ae(t("input",{"onUpdate:modelValue":e[5]||(e[5]=_=>z.value=_),type:"range",min:"0",max:"50",step:"5",class:"w-full h-2 bg-gray-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer"},null,512),[[oe,z.value,void 0,{number:!0}]]),e[7]||(e[7]=t("div",{class:"flex justify-between text-xs text-gray-400 mt-1"},[t("span",null,"0"),t("span",null,"25"),t("span",null,"50")],-1))])])}}}),Oe={class:"p-4 flex flex-col h-full min-h-0"},Ge={key:0,class:"flex-none mb-2 text-sm text-primary-500"},Qe={class:"flex-1 min-h-0"},Ze={key:0,class:"flex items-center justify-center h-full"},qe={key:1,class:"flex items-center justify-center h-full text-gray-500 text-sm"},Je=["onClick"],Xe={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},et={class:"flex items-center gap-2"},tt={class:"text-xs text-gray-500"},st=["checked","onChange"],nt=["checked","onChange"],at={class:"flex-1 min-w-0"},ot={class:"flex items-center gap-2"},lt={class:"text-sm text-gray-700 dark:text-gray-300"},rt={class:"flex items-center gap-2 text-xs text-gray-500"},it=X({__name:"SessionPanel",props:{selectedIds:{default:()=>[]},selectedIdsModifiers:{}},emits:["update:selectedIds"],setup(v){const{t:C}=J(),M=ne(),h=Q(v,"selectedIds"),m=$(new Set);W(h,c=>{m.value=new Set(c)},{immediate:!0});const w=$([]),z=$(!1),L=$(null),r=P(()=>{const c={};for(const a of w.value){const b=new Date(a.startTs*1e3).toLocaleDateString();c[b]||(c[b]=[]),c[b].push(a)}const g=Object.keys(c).sort((a,b)=>new Date(b).getTime()-new Date(a).getTime()),o=[];for(const a of g){o.push({type:"date",date:a,sessionCount:c[a].length});for(const b of c[a])o.push({type:"session",session:b,date:a})}return o}),p=fe(P(()=>({count:r.value.length,getScrollElement:()=>L.value,estimateSize:c=>r.value[c]?.type==="date"?36:56,overscan:10}))),k=P(()=>p.value.getVirtualItems());async function x(){const c=M.currentSessionId;if(c){z.value=!0;try{w.value=await ve().getSessions(c)}catch(g){console.error("加载会话失败:",g)}finally{z.value=!1}}}function D(c){return m.value.has(c)}function B(c){const g=new Set(m.value);g.has(c)?g.delete(c):g.add(c),m.value=g,h.value=Array.from(g)}function F(c){return r.value.filter(g=>g.type==="session"&&g.date===c).map(g=>g.session.id)}function j(c){const g=F(c),o=g.every(b=>m.value.has(b)),a=new Set(m.value);if(o)for(const b of g)a.delete(b);else for(const b of g)a.add(b);m.value=a,h.value=Array.from(a)}function E(c){const g=F(c);return g.length>0&&g.every(o=>m.value.has(o))}function V(c){return new Date(c*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})}function U(c,g){const o=g-c;return o<60?`${o}秒`:o<3600?`${Math.floor(o/60)}分钟`:`${Math.floor(o/3600)}小时${Math.floor(o%3600/60)}分钟`}return re(()=>{x()}),(c,g)=>{const o=se;return l(),u("div",Oe,[h.value.length>0?(l(),u("div",Ge,n(y(C)("analysis.filter.selectedSessions",{count:h.value.length})),1)):H("",!0),t("div",Qe,[z.value?(l(),u("div",Ze,[I(o,{name:"i-heroicons-arrow-path",class:"w-6 h-6 animate-spin text-gray-400"})])):w.value.length===0?(l(),u("div",qe,n(y(C)("analysis.filter.noSessions")),1)):(l(),u("div",{key:2,ref_key:"scrollContainerRef",ref:L,class:"h-full overflow-y-auto"},[t("div",{style:q({height:`${y(p).getTotalSize()}px`,position:"relative"})},[(l(!0),u(N,null,Z(k.value,a=>(l(),u("div",{key:String(a.key),style:q({position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${a.start}px)`})},[r.value[a.index].type==="date"?(l(),u("div",{key:0,class:"flex items-center justify-between px-2 py-1.5 bg-gray-100 dark:bg-gray-800 rounded-md cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-700",onClick:b=>j(r.value[a.index].date)},[t("span",Xe,n(r.value[a.index].date),1),t("div",et,[t("span",tt,n(r.value[a.index].sessionCount)+" 个会话",1),t("input",{type:"checkbox",checked:E(r.value[a.index].date),class:"text-primary-500 rounded",onClick:g[0]||(g[0]=ke(()=>{},["stop"])),onChange:b=>j(r.value[a.index].date)},null,40,st)])],8,Je)):(l(),u("label",{key:1,class:te(["flex items-center gap-3 px-3 py-2 ml-2 rounded-md hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer border border-transparent",{"border-primary-300 bg-primary-50 dark:border-primary-600 dark:bg-primary-900/20":D(r.value[a.index].session.id)}])},[t("input",{type:"checkbox",checked:D(r.value[a.index].session.id),class:"text-primary-500 rounded",onChange:b=>B(r.value[a.index].session.id)},null,40,nt),t("div",at,[t("div",ot,[t("span",lt,n(V(r.value[a.index].session.startTs))+" - "+n(V(r.value[a.index].session.endTs)),1)]),t("div",rt,[t("span",null,n(r.value[a.index].session.messageCount)+" 条消息",1),g[1]||(g[1]=t("span",null,"·",-1)),t("span",null,n(U(r.value[a.index].session.startTs,r.value[a.index].session.endTs)),1)])])],2))],4))),128))],4)],512))])])}}}),dt={class:"flex-1 flex flex-col overflow-hidden bg-gray-50 dark:bg-gray-900"},ct={key:0,class:"flex-none px-4 py-3 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"},ut={class:"flex items-center justify-between mb-2"},ft={class:"flex items-center gap-6 text-sm"},gt={class:"text-gray-600 dark:text-gray-400"},yt={class:"font-medium text-gray-900 dark:text-white"},vt={class:"text-gray-600 dark:text-gray-400"},mt={class:"font-medium text-gray-900 dark:text-white"},xt={class:"text-gray-600 dark:text-gray-400"},ht={class:"font-medium text-primary-500"},pt={class:"text-gray-600 dark:text-gray-400"},kt={class:"font-medium text-gray-900 dark:text-white"},bt={class:"flex-1 min-h-0 flex overflow-hidden"},_t={key:1,class:"w-full h-full flex items-center justify-center"},wt={class:"text-center text-gray-400"},$t={key:2,class:"flex-1 flex items-center justify-center"},St={class:"text-center text-gray-400"},It={class:"w-64 flex-none border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 flex flex-col"},Ct={class:"flex-none px-3 py-2 border-b border-gray-200 dark:border-gray-700"},Tt={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Mt=["onClick"],zt={class:"flex items-center justify-between mb-1"},Dt={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Lt={key:0,class:"text-xs text-primary-500"},Bt={class:"text-xs text-gray-500"},Ft={class:"flex items-center gap-2 text-xs text-gray-400 mt-1"},Ut={key:0,class:"py-3 text-center text-sm text-gray-500 dark:text-gray-400 border-t border-gray-100 dark:border-gray-700"},Rt={key:1,class:"py-3 text-center text-xs text-gray-400 dark:text-gray-500"},Pt={class:"flex-1 overflow-hidden"},Vt={key:1,class:"flex items-center justify-center h-full text-gray-400"},Ht=X({__name:"PreviewPanel",props:{result:{},isLoading:{type:Boolean},isLoadingMore:{type:Boolean}},emits:["load-more"],setup(v,{emit:C}){const{t:M}=J(),h=v,m=C,w=$(0);let z=!1;const L=$(null),r=$(null),p=$(null);function k(s){if(!h.result)return null;const e=h.result.blocks.length-1-s;return h.result.blocks[e]}const x=P(()=>h.result?.blocks.length??0),D=fe(P(()=>({count:x.value,getScrollElement:()=>p.value,estimateSize:()=>72,overscan:5}))),B=P(()=>D.value.getVirtualItems()),F=P(()=>{if(x.value===0)return[];const s=k(w.value);return s?s.messages.map(e=>({id:e.id,senderName:e.senderName,senderPlatformId:e.senderPlatformId,senderAliases:e.senderAliases,senderAvatar:e.senderAvatar,content:e.content,timestamp:e.timestamp,type:e.type,replyToMessageId:e.replyToMessageId,replyToContent:e.replyToContent,replyToSenderName:e.replyToSenderName})):[]}),j=P(()=>{if(x.value===0)return[];const s=k(w.value);return s?s.messages.filter(e=>e.isHit).map(e=>e.id):[]}),E={startTs:0,endTs:0},V=P(()=>{if(!h.result||h.result.blocks.length===0)return!1;const s=h.result.blocks,e=new Date(s[0].startTs*1e3).getFullYear(),d=new Date(s[s.length-1].endTs*1e3).getFullYear();return e!==d});function U(s){const e={month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"};return V.value&&(e.year="numeric"),new Date(s*1e3).toLocaleString("zh-CN",e)}function c(s,e){const d=e-s;return d<60?`${d}秒`:d<3600?`${Math.floor(d/60)}分钟`:`${Math.floor(d/3600)}h${Math.floor(d%3600/60)}m`}function g(s){w.value=s;const e=k(s);if(e){const d=e.messages.find(f=>f.isHit);d&&(L.value=d.id)}}function o(){z||x.value!==0&&w.value<x.value-1&&(z=!0,w.value++,b(w.value),setTimeout(()=>{z=!1},300))}function a(){}function b(s){D.value.scrollToIndex(s,{align:"center"})}W(()=>h.result,()=>{w.value=0,L.value=null}),W(L,async s=>{s!==null&&(await be(),setTimeout(()=>{r.value?.scrollToMessage(s),L.value=null},100))});function A(s){const e=s.target;if(!e||!h.result?.pagination?.hasMore||h.isLoadingMore)return;const d=100,{scrollTop:f,scrollHeight:i,clientHeight:S}=e;i-f-S<d&&m("load-more")}return(s,e)=>{const d=se;return l(),u("div",dt,[v.result&&v.result.blocks.length>0?(l(),u("div",ct,[t("div",ut,[t("div",ft,[t("span",gt,[T(n(y(M)("analysis.filter.stats.blocks"))+": ",1),t("span",yt,[T(n(v.result.blocks.length)+" ",1),v.result.pagination&&v.result.pagination.totalBlocks>v.result.blocks.length?(l(),u(N,{key:0},[T(" / "+n(v.result.pagination.totalBlocks),1)],64)):H("",!0)])]),t("span",vt,[T(n(y(M)("analysis.filter.stats.messages"))+": ",1),t("span",mt,n(v.result.stats.totalMessages),1)]),t("span",xt,[T(n(y(M)("analysis.filter.stats.hits"))+": ",1),t("span",ht,n(v.result.pagination?.totalHits??v.result.stats.hitMessages),1)]),t("span",pt,[T(n(y(M)("analysis.filter.stats.chars"))+": ",1),t("span",kt,n(v.result.stats.totalChars.toLocaleString()),1)])])])])):H("",!0),t("div",bt,[v.isLoading?(l(),Y($e,{key:0,variant:"page",text:y(M)("analysis.filter.filtering")},null,8,["text"])):v.result?v.result.blocks.length===0?(l(),u("div",$t,[t("div",St,[I(d,{name:"i-heroicons-magnifying-glass",class:"w-12 h-12 mb-3 mx-auto"}),t("p",null,n(y(M)("analysis.filter.noResults")),1)])])):(l(),u(N,{key:3},[t("div",It,[t("div",Ct,[t("span",Tt,[T(n(y(M)("analysis.filter.stats.blocks"))+" ("+n(v.result.blocks.length)+" ",1),v.result.pagination&&v.result.pagination.totalBlocks>v.result.blocks.length?(l(),u(N,{key:0},[T(" /"+n(v.result.pagination.totalBlocks),1)],64)):H("",!0),e[1]||(e[1]=T(" ) ",-1))])]),t("div",{ref_key:"blockListRef",ref:p,class:"flex-1 overflow-y-auto",onScroll:A},[t("div",{style:q({height:`${y(D).getTotalSize()}px`,position:"relative"})},[(l(!0),u(N,null,Z(B.value,f=>(l(),u("div",{key:String(f.key),style:q({position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${f.start}px)`})},[t("div",{class:te(["px-3 py-2 cursor-pointer border-b border-gray-100 dark:border-gray-700 transition-colors",w.value===f.index?"bg-primary-50 dark:bg-primary-900/30 border-l-2 border-l-primary-500":"hover:bg-gray-50 dark:hover:bg-gray-700/50"]),onClick:i=>g(f.index)},[t("div",zt,[t("span",Dt," #"+n(f.index+1),1),(k(f.index)?.hitCount??0)>0?(l(),u("span",Lt," 含 "+n(k(f.index)?.hitCount)+" 个结果 ",1)):H("",!0)]),t("div",Bt,n(U(k(f.index)?.startTs??0)),1),t("div",Ft,[t("span",null,n(k(f.index)?.messages.length??0)+" 条",1),e[2]||(e[2]=t("span",null,"·",-1)),t("span",null,n(c(k(f.index)?.startTs??0,k(f.index)?.endTs??0)),1)])],10,Mt)],4))),128))],4),v.result.pagination?.hasMore?(l(),u("div",Ut,[v.isLoadingMore?(l(),u(N,{key:0},[I(d,{name:"i-heroicons-arrow-path",class:"w-4 h-4 animate-spin inline mr-1"}),T(" "+n(y(M)("common.loading")),1)],64)):(l(),u("button",{key:1,class:"text-primary-500 hover:text-primary-600",onClick:e[0]||(e[0]=f=>m("load-more"))},n(y(M)("analysis.filter.loadMore")),1))])):v.result.pagination&&v.result.blocks.length>=v.result.pagination.totalBlocks?(l(),u("div",Rt,n(y(M)("analysis.filter.allLoaded")),1)):H("",!0)],544)]),t("div",Pt,[F.value.length>0?(l(),Y(me,{key:0,ref_key:"messageListRef",ref:r,query:E,"external-messages":F.value,"hit-message-ids":j.value,class:"h-full",onReachBottom:o,onReachTop:a},null,8,["external-messages","hit-message-ids"])):(l(),u("div",Vt,n(y(M)("analysis.filter.noResults")),1))])],64)):(l(),u("div",_t,[t("div",wt,[I(d,{name:"i-heroicons-funnel",class:"w-12 h-12 mb-3 mx-auto"}),t("p",null,n(y(M)("analysis.filter.emptyHint")),1)])]))])])}}}),jt={class:"flex items-center justify-between"},Et={class:"text-lg font-semibold"},Nt={class:"max-h-96 overflow-y-auto"},At={key:0,class:"py-8 text-center text-gray-500"},Kt={key:1,class:"divide-y divide-gray-200 dark:divide-gray-700"},Yt={class:"flex items-start justify-between gap-2"},Wt={class:"flex-1 min-w-0"},Ot={key:0,class:"flex items-center gap-2 mb-1"},Gt={key:1,class:"flex items-center gap-2 mb-1"},Qt={class:"font-medium text-gray-900 dark:text-white"},Zt=["onClick"],qt={class:"text-sm text-gray-600 dark:text-gray-400 truncate"},Jt={class:"text-xs text-gray-400 mt-1"},Xt={class:"flex items-center gap-1"},es=X({__name:"FilterHistory",props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:we(["load"],["update:open"]),setup(v,{expose:C,emit:M}){const{t:h}=J(),m=ne(),w=xe(),z=Q(v,"open"),L=M,r=$([]);let p=[];const k=$(null),x=$("");async function D(){try{p=(await w.getPreferences()).filterHistory??[],r.value=p.filter(a=>a.sessionId===m.currentSessionId)}catch(o){console.error("Failed to load filter history:",o)}}function B(){p=[...p.filter(a=>a.sessionId!==m.currentSessionId),...r.value],w.savePreferences({filterHistory:p}).catch(a=>{console.error("Failed to save filter history:",a)})}function F(o){r.value=r.value.filter(a=>a.id!==o),B()}function j(o){L("load",{mode:o.mode,conditionFilter:o.conditionFilter,selectedSessionIds:o.selectedSessionIds})}function E(o){k.value=o.id,x.value=o.name}function V(o){o.name=x.value||o.name,k.value=null,B()}function U(){k.value=null}function c(o){return new Date(o).toLocaleString()}function g(o){if(o.mode==="condition"){const a=[];return o.conditionFilter?.keywords.length&&a.push(`关键词: ${o.conditionFilter.keywords.join(", ")}`),o.conditionFilter?.senderIds.length&&a.push(`${o.conditionFilter.senderIds.length} 位成员`),a.join(" | ")||"无条件"}else return`${o.selectedSessionIds?.length||0} 个会话`}return W(z,o=>{o&&D()}),re(()=>{D()}),C({saveCondition(o){const a={id:`filter_${Date.now()}`,sessionId:m.currentSessionId||"",createdAt:Date.now(),name:`筛选 ${r.value.length+1}`,...o};r.value.unshift(a),r.value=r.value.slice(0,20),B()}}),(o,a)=>{const b=le,A=de,s=ce,e=se,d=ge,f=ue;return l(),Y(f,{open:z.value,"onUpdate:open":a[2]||(a[2]=i=>z.value=i)},{content:R(()=>[I(d,null,{header:R(()=>[t("div",jt,[t("h3",Et,n(y(h)("analysis.filter.historyTitle")),1),I(b,{variant:"ghost",icon:"i-heroicons-x-mark",size:"sm",onClick:a[0]||(a[0]=i=>z.value=!1)})])]),default:R(()=>[t("div",Nt,[r.value.length===0?(l(),u("div",At,n(y(h)("analysis.filter.noHistory")),1)):(l(),u("div",Kt,[(l(!0),u(N,null,Z(r.value,i=>(l(),u("div",{key:i.id,class:"py-3 hover:bg-gray-50 dark:hover:bg-gray-800 px-2 rounded-md"},[t("div",Yt,[t("div",Wt,[k.value===i.id?(l(),u("div",Ot,[I(A,{modelValue:x.value,"onUpdate:modelValue":a[1]||(a[1]=S=>x.value=S),size:"sm",class:"flex-1",onKeydown:_e(S=>V(i),["enter"])},null,8,["modelValue","onKeydown"]),I(b,{size:"xs",onClick:S=>V(i)},{default:R(()=>[T(n(y(h)("common.save")),1)]),_:1},8,["onClick"]),I(b,{size:"xs",variant:"ghost",onClick:U},{default:R(()=>[T(n(y(h)("common.cancel")),1)]),_:1})])):(l(),u("div",Gt,[t("span",Qt,n(i.name),1),I(s,{color:i.mode==="condition"?"primary":"green",size:"xs"},{default:R(()=>[T(n(i.mode==="condition"?"条件":"会话"),1)]),_:2},1032,["color"]),t("button",{class:"text-gray-400 hover:text-gray-600",onClick:S=>E(i)},[I(e,{name:"i-heroicons-pencil",class:"w-3 h-3"})],8,Zt)])),t("p",qt,n(g(i)),1),t("p",Jt,n(c(i.createdAt)),1)]),t("div",Xt,[I(b,{size:"xs",variant:"soft",onClick:S=>j(i)},{default:R(()=>[T(n(y(h)("common.load")),1)]),_:1},8,["onClick"]),I(b,{size:"xs",variant:"ghost",color:"red",onClick:S=>F(i.id)},{default:R(()=>[I(e,{name:"i-heroicons-trash",class:"w-4 h-4"})]),_:1},8,["onClick"])])])]))),128))]))])]),_:1})]),_:1},8,["open"])}}}),ts={class:"flex h-[85vh] flex-col overflow-hidden bg-white dark:bg-gray-900"},ss={class:"flex flex-none items-center justify-between border-b border-gray-200 px-5 py-3 dark:border-gray-700"},ns={class:"flex items-center gap-4"},as={class:"text-lg font-semibold text-gray-900 dark:text-white"},os={class:"flex items-center gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},ls={class:"flex items-center gap-2"},rs={class:"flex flex-1 overflow-hidden"},is={class:"flex w-80 flex-none flex-col border-r border-gray-200 dark:border-gray-700"},ds={class:"min-h-0 flex-1 overflow-y-auto"},cs={class:"flex-none border-t border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-900"},us={class:"flex flex-1 flex-col overflow-hidden"},fs={key:0,class:"flex flex-none flex-col gap-2 border-t border-gray-200 bg-gray-50 px-4 py-3 dark:border-gray-700 dark:bg-gray-800"},gs={key:0,class:"w-full"},ys={class:"mb-1 flex items-center justify-between text-sm text-gray-600 dark:text-gray-400"},vs={class:"h-2 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},ms={class:"flex items-center justify-end gap-3"},ee=50,Is=X({__name:"MessageExportModal",props:{modelValue:{type:Boolean}},emits:["update:modelValue"],setup(v,{emit:C}){const M=v,h=C,{t:m}=J(),w=he(),z=ne(),L=P({get:()=>M.modelValue,set:s=>h("update:modelValue",s)}),r=$("condition"),p=$({keywords:[],timeRange:null,senderIds:[],contextSize:10}),k=$([]),x=$(null),D=$(!1),B=$(!1),F=$(!1),j=P(()=>D.value?!1:r.value==="condition"?p.value.keywords.length>0||p.value.senderIds.length>0||p.value.timeRange!==null:k.value.length>0);async function E(){const s=z.currentSessionId;if(s){D.value=!0,x.value=null;try{if(r.value==="condition"){const e=G(p.value),d=e.keywords.length>0?[...e.keywords]:void 0,f=e.timeRange?{startTs:e.timeRange.start,endTs:e.timeRange.end}:void 0,i=e.senderIds.length>0?[...e.senderIds]:void 0,S=e.contextSize,_=await O().filterMessagesWithContext(s,d,f,i,S,1,ee);x.value=_}else{if(k.value.length===0)return;const e=[...G(k.value)],d=await O().getMultipleSessionsMessages(s,e,1,ee);x.value=d}}catch(e){console.error("筛选失败:",e)}finally{D.value=!1}}}async function V(){const s=z.currentSessionId;if(!s||!x.value||!x.value.pagination.hasMore||B.value)return;B.value=!0;const e=x.value.pagination.page+1;try{let d;if(r.value==="condition"){const f=G(p.value),i=f.keywords.length>0?[...f.keywords]:void 0,S=f.timeRange?{startTs:f.timeRange.start,endTs:f.timeRange.end}:void 0,_=f.senderIds.length>0?[...f.senderIds]:void 0,K=f.contextSize;d=await O().filterMessagesWithContext(s,i,S,_,K,e,ee)}else{const f=[...G(k.value)];d=await O().getMultipleSessionsMessages(s,f,e,ee)}d&&d.blocks.length>0&&(x.value={blocks:[...x.value.blocks,...d.blocks],stats:x.value.stats,pagination:d.pagination})}catch(d){console.error("加载更多失败:",d)}finally{B.value=!1}}const U=$(!1),c=$(null);let g=null;function o(){g=O().onExportProgress(s=>{c.value={percentage:s.percentage,message:s.message},(s.stage==="done"||s.stage==="error")&&(c.value=null)})}function a(){g&&(g(),g=null),c.value=null}async function b(){if(!x.value||x.value.blocks.length===0)return;const s=z.currentSessionId;if(!s)return;const d=z.currentSession?.name||"未知会话",f=await pe().showOpenDialog({title:"选择保存目录",properties:["openDirectory","createDirectory"]});if(f.canceled||!f.filePaths[0])return;const i=f.filePaths[0];U.value=!0,c.value={percentage:0,message:m("analysis.filter.exportPreparing")},o();try{const S=G(p.value),_={sessionId:s,sessionName:d,outputDir:i,filterMode:r.value,keywords:S.keywords.length>0?[...S.keywords]:void 0,timeFilter:S.timeRange?{startTs:S.timeRange.start,endTs:S.timeRange.end}:void 0,senderIds:S.senderIds.length>0?[...S.senderIds]:void 0,contextSize:S.contextSize,chatSessionIds:r.value==="session"?[...G(k.value)]:void 0},K=await O().exportFilterResultToFile(_);K.success&&K.filePath?w.success(m("analysis.filter.exportSuccess"),{description:K.filePath}):w.fail(m("analysis.filter.exportFailed"),{description:K.error||m("common.error.unknown")})}catch(S){console.error("导出失败:",S),w.fail(m("analysis.filter.exportFailed"),{description:String(S)})}finally{a(),U.value=!1}}W(r,()=>{x.value=null}),W(L,s=>{s||(x.value=null,a())});function A(s){r.value=s.mode,s.mode==="condition"&&s.conditionFilter?p.value={...s.conditionFilter}:s.mode==="session"&&s.selectedSessionIds&&(k.value=[...s.selectedSessionIds]),F.value=!1}return(s,e)=>{const d=le,f=ue;return l(),Y(f,{open:L.value,"onUpdate:open":e[10]||(e[10]=i=>L.value=i),ui:{content:"sm:max-w-[95vw]"}},{content:R(()=>[t("div",ts,[t("div",ss,[t("div",ns,[t("h2",as,n(y(m)("analysis.messageExport.title")),1),t("div",os,[t("button",{class:te(["rounded-md px-3 py-1.5 text-sm font-medium transition-colors",r.value==="condition"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white"]),onClick:e[0]||(e[0]=i=>r.value="condition")},n(y(m)("analysis.filter.conditionMode")),3),t("button",{class:te(["rounded-md px-3 py-1.5 text-sm font-medium transition-colors",r.value==="session"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white"]),onClick:e[1]||(e[1]=i=>r.value="session")},n(y(m)("analysis.filter.sessionMode")),3)])]),t("div",ls,[I(d,{variant:"ghost",icon:"i-heroicons-clock",size:"sm",onClick:e[2]||(e[2]=i=>F.value=!0)},{default:R(()=>[T(n(y(m)("analysis.filter.history")),1)]),_:1}),I(d,{variant:"ghost",icon:"i-heroicons-x-mark",size:"sm",onClick:e[3]||(e[3]=i=>L.value=!1)})])]),t("div",rs,[t("div",is,[t("div",ds,[r.value==="condition"?(l(),Y(We,{key:0,keywords:p.value.keywords,"onUpdate:keywords":e[4]||(e[4]=i=>p.value.keywords=i),"time-range":p.value.timeRange,"onUpdate:timeRange":e[5]||(e[5]=i=>p.value.timeRange=i),"sender-ids":p.value.senderIds,"onUpdate:senderIds":e[6]||(e[6]=i=>p.value.senderIds=i),"context-size":p.value.contextSize,"onUpdate:contextSize":e[7]||(e[7]=i=>p.value.contextSize=i)},null,8,["keywords","time-range","sender-ids","context-size"])):(l(),Y(it,{key:1,"selected-ids":k.value,"onUpdate:selectedIds":e[8]||(e[8]=i=>k.value=i)},null,8,["selected-ids"]))]),t("div",cs,[I(d,{block:"",color:"primary",loading:D.value,disabled:!j.value,onClick:E},{default:R(()=>[T(n(y(m)("analysis.filter.execute")),1)]),_:1},8,["loading","disabled"])])]),t("div",us,[I(Ht,{result:x.value,"is-loading":D.value,"is-loading-more":B.value,onLoadMore:V},null,8,["result","is-loading","is-loading-more"]),x.value&&x.value.blocks.length>0?(l(),u("div",fs,[U.value&&c.value?(l(),u("div",gs,[t("div",ys,[t("span",null,n(c.value.message),1),t("span",null,n(c.value.percentage)+"%",1)]),t("div",vs,[t("div",{class:"h-full bg-primary-500 transition-all duration-300",style:q({width:`${c.value.percentage}%`})},null,4)])])):H("",!0),t("div",ms,[I(d,{variant:"outline",icon:"i-heroicons-document-arrow-down",loading:U.value,disabled:U.value,onClick:b},{default:R(()=>[T(n(y(m)("analysis.filter.export")),1)]),_:1},8,["loading","disabled"])])])):H("",!0)])]),I(es,{open:F.value,"onUpdate:open":e[9]||(e[9]=i=>F.value=i),onLoad:A},null,8,["open"])])]),_:1},8,["open"])}}});export{Is as default};
|
|
1
|
+
import{e as de,a as le,k as ce,b as se,g as ue,r as ge}from"./vendor-nuxt-ui-7OAuiz_i.js";import{u as J,d as ne,T as ye,h as ie,f as ve,H as me,b as xe,x as he,w as O,j as pe}from"./index-D183wYuz.js";import{p as X,J as Q,w as W,d as re,G as l,P as u,a5 as t,R as T,T as n,u as y,L as I,K as R,Z as N,a3 as Z,H as Y,U as H,bA as ae,bB as oe,b as $,h as P,bE as fe,a0 as q,a9 as ke,Q as te,n as be,by as _e,W as we,bp as G}from"./vendor-reka-ui-CW2cIgMu.js";import{c as $e}from"./DebugToolsPanel.vue_vue_type_script_setup_true_lang-CqacsKDU.js";import"./vendor-snapdom-XnBoh1gd.js";import"./index-DOwQB7In.js";import"./vendor-echarts-wordcloud-CZ9gsX8l.js";import"./vendor-echarts-C5u62NnM.js";import"./vendor-zrender-DFl4U2Oe.js";const Se={class:"p-4 space-y-6"},Ie={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Ce={class:"text-gray-500 text-xs ml-1"},Te={class:"flex gap-2 mb-2"},Me={key:0,class:"flex flex-wrap gap-2"},ze=["onClick"],De={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Le={class:"space-y-2"},Be={key:0,class:"flex gap-2 items-center"},Fe={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Ue={class:"text-gray-500 text-xs ml-1"},Re={class:"max-h-60 overflow-y-auto border border-gray-200 dark:border-gray-700 rounded-md"},Pe={key:0,class:"p-4 text-center text-gray-500"},Ve={key:1,class:"p-4 text-center text-gray-500 text-sm"},He={key:2,class:"divide-y divide-gray-100 dark:divide-gray-700"},je=["checked","onChange"],Ee={class:"text-sm text-gray-700 dark:text-gray-300 truncate"},Ne={class:"text-xs text-gray-400 ml-auto"},Ae={key:0,class:"mt-2 text-xs text-gray-500"},Ke={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"},Ye={class:"text-gray-500 text-xs ml-1"},We=X({__name:"ConditionPanel",props:{keywords:{default:()=>[]},keywordsModifiers:{},timeRange:{default:null},timeRangeModifiers:{},senderIds:{default:()=>[]},senderIdsModifiers:{},contextSize:{default:10},contextSizeModifiers:{}},emits:["update:keywords","update:timeRange","update:senderIds","update:contextSize"],setup(v){const{t:C}=J(),M=ne(),h=Q(v,"keywords"),m=Q(v,"timeRange"),w=Q(v,"senderIds"),z=Q(v,"contextSize"),L=$(""),r=$([]),p=$(!1),k=$("all"),x=$(""),D=$(""),B=[{id:"all",label:"analysis.filter.allTime"},{id:"today",label:"analysis.filter.today"},{id:"week",label:"analysis.filter.lastWeek"},{id:"month",label:"analysis.filter.lastMonth"},{id:"3months",label:"analysis.filter.last3Months"},{id:"year",label:"analysis.filter.lastYear"},{id:"custom",label:"analysis.filter.customTime"}],F=P(()=>B.map(s=>({label:C(s.label),value:s.id})));W(k,()=>{a()});const j=$(null);async function E(){const s=M.currentSessionId;if(s){p.value=!0;try{r.value=await ie().getMembers(s)}catch(e){console.error("加载成员失败:",e)}finally{p.value=!1}}}async function V(){const s=M.currentSessionId;if(s)try{const e=await ie().getTimeRange(s);e&&(j.value=e)}catch(e){console.error("加载时间范围失败:",e)}}function U(){const s=L.value.trim();s&&!h.value.includes(s)&&(h.value=[...h.value,s],L.value="")}function c(s){h.value=h.value.filter(e=>e!==s)}function g(s){s.key==="Enter"&&(s.preventDefault(),U())}function o(s){w.value.includes(s)?w.value=w.value.filter(e=>e!==s):w.value=[...w.value,s]}function a(){const s=Math.floor(Date.now()/1e3),e=new Date;e.setHours(0,0,0,0);const d=Math.floor(e.getTime()/1e3);switch(k.value){case"all":m.value=null;break;case"today":m.value={start:d,end:s};break;case"week":m.value={start:s-10080*60,end:s};break;case"month":m.value={start:s-720*60*60,end:s};break;case"3months":m.value={start:s-2160*60*60,end:s};break;case"year":m.value={start:s-365*24*60*60,end:s};break;case"custom":if(x.value&&D.value){const f=new Date(x.value).getTime()/1e3,i=new Date(D.value).getTime()/1e3+86399;m.value={start:f,end:i}}break}}const b=$(""),A=P(()=>{if(!b.value)return r.value;const s=b.value.toLowerCase();return r.value.filter(e=>e.accountName?.toLowerCase().includes(s)||e.groupNickname?.toLowerCase().includes(s)||e.platformId.toLowerCase().includes(s)||e.aliases.some(d=>d.toLowerCase().includes(s)))});return re(()=>{E(),V()}),(s,e)=>{const d=de,f=le,i=se,S=ce;return l(),u("div",Se,[t("div",null,[t("label",Ie,[T(n(y(C)("analysis.filter.keywords"))+" ",1),t("span",Ce,"("+n(y(C)("analysis.filter.keywordsHint"))+")",1)]),t("div",Te,[I(d,{modelValue:L.value,"onUpdate:modelValue":e[0]||(e[0]=_=>L.value=_),placeholder:y(C)("analysis.filter.keywordPlaceholder"),class:"flex-1",onKeydown:g},null,8,["modelValue","placeholder"]),I(f,{size:"sm",onClick:U},{default:R(()=>[T(n(y(C)("common.add")),1)]),_:1})]),h.value.length>0?(l(),u("div",Me,[(l(!0),u(N,null,Z(h.value,_=>(l(),Y(S,{key:_,color:"primary",variant:"subtle",class:"gap-1"},{default:R(()=>[T(n(_)+" ",1),t("button",{class:"ml-1 hover:text-red-500",onClick:K=>c(_)},[I(i,{name:"i-heroicons-x-mark",class:"w-3 h-3"})],8,ze)]),_:2},1024))),128))])):H("",!0)]),t("div",null,[t("label",De,n(y(C)("analysis.filter.timeRange")),1),t("div",Le,[I(ye,{modelValue:k.value,"onUpdate:modelValue":e[1]||(e[1]=_=>k.value=_),items:F.value,size:"sm"},null,8,["modelValue","items"]),k.value==="custom"?(l(),u("div",Be,[ae(t("input",{"onUpdate:modelValue":e[2]||(e[2]=_=>x.value=_),type:"date",class:"flex-1 px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800",onChange:a},null,544),[[oe,x.value]]),e[6]||(e[6]=t("span",{class:"text-gray-500"},"~",-1)),ae(t("input",{"onUpdate:modelValue":e[3]||(e[3]=_=>D.value=_),type:"date",class:"flex-1 px-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800",onChange:a},null,544),[[oe,D.value]])])):H("",!0)])]),t("div",null,[t("label",Fe,[T(n(y(C)("analysis.filter.senders"))+" ",1),t("span",Ue,"("+n(y(C)("analysis.filter.sendersHint"))+")",1)]),I(d,{modelValue:b.value,"onUpdate:modelValue":e[4]||(e[4]=_=>b.value=_),placeholder:y(C)("analysis.filter.searchMember"),icon:"i-heroicons-magnifying-glass",size:"sm",class:"mb-2"},null,8,["modelValue","placeholder"]),t("div",Re,[p.value?(l(),u("div",Pe,[I(i,{name:"i-heroicons-arrow-path",class:"w-5 h-5 animate-spin"})])):A.value.length===0?(l(),u("div",Ve,n(y(C)("analysis.filter.noMembers")),1)):(l(),u("div",He,[(l(!0),u(N,null,Z(A.value,_=>(l(),u("label",{key:_.id,class:"flex items-center gap-2 px-3 py-2 hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer"},[t("input",{type:"checkbox",checked:w.value.includes(_.id),class:"text-primary-500 rounded",onChange:K=>o(_.id)},null,40,je),t("span",Ee,n(_.groupNickname||_.accountName||_.platformId),1),t("span",Ne,"("+n(_.messageCount)+")",1)]))),128))]))]),w.value.length>0?(l(),u("div",Ae,n(y(C)("analysis.filter.selectedCount",{count:w.value.length})),1)):H("",!0)]),t("div",null,[t("label",Ke,[T(n(y(C)("analysis.filter.contextSize"))+" ",1),t("span",Ye,"±"+n(z.value)+" "+n(y(C)("analysis.filter.messages")),1)]),ae(t("input",{"onUpdate:modelValue":e[5]||(e[5]=_=>z.value=_),type:"range",min:"0",max:"50",step:"5",class:"w-full h-2 bg-gray-200 dark:bg-gray-700 rounded-lg appearance-none cursor-pointer"},null,512),[[oe,z.value,void 0,{number:!0}]]),e[7]||(e[7]=t("div",{class:"flex justify-between text-xs text-gray-400 mt-1"},[t("span",null,"0"),t("span",null,"25"),t("span",null,"50")],-1))])])}}}),Oe={class:"p-4 flex flex-col h-full min-h-0"},Ge={key:0,class:"flex-none mb-2 text-sm text-primary-500"},Qe={class:"flex-1 min-h-0"},Ze={key:0,class:"flex items-center justify-center h-full"},qe={key:1,class:"flex items-center justify-center h-full text-gray-500 text-sm"},Je=["onClick"],Xe={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},et={class:"flex items-center gap-2"},tt={class:"text-xs text-gray-500"},st=["checked","onChange"],nt=["checked","onChange"],at={class:"flex-1 min-w-0"},ot={class:"flex items-center gap-2"},lt={class:"text-sm text-gray-700 dark:text-gray-300"},rt={class:"flex items-center gap-2 text-xs text-gray-500"},it=X({__name:"SessionPanel",props:{selectedIds:{default:()=>[]},selectedIdsModifiers:{}},emits:["update:selectedIds"],setup(v){const{t:C}=J(),M=ne(),h=Q(v,"selectedIds"),m=$(new Set);W(h,c=>{m.value=new Set(c)},{immediate:!0});const w=$([]),z=$(!1),L=$(null),r=P(()=>{const c={};for(const a of w.value){const b=new Date(a.startTs*1e3).toLocaleDateString();c[b]||(c[b]=[]),c[b].push(a)}const g=Object.keys(c).sort((a,b)=>new Date(b).getTime()-new Date(a).getTime()),o=[];for(const a of g){o.push({type:"date",date:a,sessionCount:c[a].length});for(const b of c[a])o.push({type:"session",session:b,date:a})}return o}),p=fe(P(()=>({count:r.value.length,getScrollElement:()=>L.value,estimateSize:c=>r.value[c]?.type==="date"?36:56,overscan:10}))),k=P(()=>p.value.getVirtualItems());async function x(){const c=M.currentSessionId;if(c){z.value=!0;try{w.value=await ve().getSessions(c)}catch(g){console.error("加载会话失败:",g)}finally{z.value=!1}}}function D(c){return m.value.has(c)}function B(c){const g=new Set(m.value);g.has(c)?g.delete(c):g.add(c),m.value=g,h.value=Array.from(g)}function F(c){return r.value.filter(g=>g.type==="session"&&g.date===c).map(g=>g.session.id)}function j(c){const g=F(c),o=g.every(b=>m.value.has(b)),a=new Set(m.value);if(o)for(const b of g)a.delete(b);else for(const b of g)a.add(b);m.value=a,h.value=Array.from(a)}function E(c){const g=F(c);return g.length>0&&g.every(o=>m.value.has(o))}function V(c){return new Date(c*1e3).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})}function U(c,g){const o=g-c;return o<60?`${o}秒`:o<3600?`${Math.floor(o/60)}分钟`:`${Math.floor(o/3600)}小时${Math.floor(o%3600/60)}分钟`}return re(()=>{x()}),(c,g)=>{const o=se;return l(),u("div",Oe,[h.value.length>0?(l(),u("div",Ge,n(y(C)("analysis.filter.selectedSessions",{count:h.value.length})),1)):H("",!0),t("div",Qe,[z.value?(l(),u("div",Ze,[I(o,{name:"i-heroicons-arrow-path",class:"w-6 h-6 animate-spin text-gray-400"})])):w.value.length===0?(l(),u("div",qe,n(y(C)("analysis.filter.noSessions")),1)):(l(),u("div",{key:2,ref_key:"scrollContainerRef",ref:L,class:"h-full overflow-y-auto"},[t("div",{style:q({height:`${y(p).getTotalSize()}px`,position:"relative"})},[(l(!0),u(N,null,Z(k.value,a=>(l(),u("div",{key:String(a.key),style:q({position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${a.start}px)`})},[r.value[a.index].type==="date"?(l(),u("div",{key:0,class:"flex items-center justify-between px-2 py-1.5 bg-gray-100 dark:bg-gray-800 rounded-md cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-700",onClick:b=>j(r.value[a.index].date)},[t("span",Xe,n(r.value[a.index].date),1),t("div",et,[t("span",tt,n(r.value[a.index].sessionCount)+" 个会话",1),t("input",{type:"checkbox",checked:E(r.value[a.index].date),class:"text-primary-500 rounded",onClick:g[0]||(g[0]=ke(()=>{},["stop"])),onChange:b=>j(r.value[a.index].date)},null,40,st)])],8,Je)):(l(),u("label",{key:1,class:te(["flex items-center gap-3 px-3 py-2 ml-2 rounded-md hover:bg-gray-50 dark:hover:bg-gray-800 cursor-pointer border border-transparent",{"border-primary-300 bg-primary-50 dark:border-primary-600 dark:bg-primary-900/20":D(r.value[a.index].session.id)}])},[t("input",{type:"checkbox",checked:D(r.value[a.index].session.id),class:"text-primary-500 rounded",onChange:b=>B(r.value[a.index].session.id)},null,40,nt),t("div",at,[t("div",ot,[t("span",lt,n(V(r.value[a.index].session.startTs))+" - "+n(V(r.value[a.index].session.endTs)),1)]),t("div",rt,[t("span",null,n(r.value[a.index].session.messageCount)+" 条消息",1),g[1]||(g[1]=t("span",null,"·",-1)),t("span",null,n(U(r.value[a.index].session.startTs,r.value[a.index].session.endTs)),1)])])],2))],4))),128))],4)],512))])])}}}),dt={class:"flex-1 flex flex-col overflow-hidden bg-gray-50 dark:bg-gray-900"},ct={key:0,class:"flex-none px-4 py-3 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700"},ut={class:"flex items-center justify-between mb-2"},ft={class:"flex items-center gap-6 text-sm"},gt={class:"text-gray-600 dark:text-gray-400"},yt={class:"font-medium text-gray-900 dark:text-white"},vt={class:"text-gray-600 dark:text-gray-400"},mt={class:"font-medium text-gray-900 dark:text-white"},xt={class:"text-gray-600 dark:text-gray-400"},ht={class:"font-medium text-primary-500"},pt={class:"text-gray-600 dark:text-gray-400"},kt={class:"font-medium text-gray-900 dark:text-white"},bt={class:"flex-1 min-h-0 flex overflow-hidden"},_t={key:1,class:"w-full h-full flex items-center justify-center"},wt={class:"text-center text-gray-400"},$t={key:2,class:"flex-1 flex items-center justify-center"},St={class:"text-center text-gray-400"},It={class:"w-64 flex-none border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 flex flex-col"},Ct={class:"flex-none px-3 py-2 border-b border-gray-200 dark:border-gray-700"},Tt={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Mt=["onClick"],zt={class:"flex items-center justify-between mb-1"},Dt={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Lt={key:0,class:"text-xs text-primary-500"},Bt={class:"text-xs text-gray-500"},Ft={class:"flex items-center gap-2 text-xs text-gray-400 mt-1"},Ut={key:0,class:"py-3 text-center text-sm text-gray-500 dark:text-gray-400 border-t border-gray-100 dark:border-gray-700"},Rt={key:1,class:"py-3 text-center text-xs text-gray-400 dark:text-gray-500"},Pt={class:"flex-1 overflow-hidden"},Vt={key:1,class:"flex items-center justify-center h-full text-gray-400"},Ht=X({__name:"PreviewPanel",props:{result:{},isLoading:{type:Boolean},isLoadingMore:{type:Boolean}},emits:["load-more"],setup(v,{emit:C}){const{t:M}=J(),h=v,m=C,w=$(0);let z=!1;const L=$(null),r=$(null),p=$(null);function k(s){if(!h.result)return null;const e=h.result.blocks.length-1-s;return h.result.blocks[e]}const x=P(()=>h.result?.blocks.length??0),D=fe(P(()=>({count:x.value,getScrollElement:()=>p.value,estimateSize:()=>72,overscan:5}))),B=P(()=>D.value.getVirtualItems()),F=P(()=>{if(x.value===0)return[];const s=k(w.value);return s?s.messages.map(e=>({id:e.id,senderName:e.senderName,senderPlatformId:e.senderPlatformId,senderAliases:e.senderAliases,senderAvatar:e.senderAvatar,content:e.content,timestamp:e.timestamp,type:e.type,replyToMessageId:e.replyToMessageId,replyToContent:e.replyToContent,replyToSenderName:e.replyToSenderName})):[]}),j=P(()=>{if(x.value===0)return[];const s=k(w.value);return s?s.messages.filter(e=>e.isHit).map(e=>e.id):[]}),E={startTs:0,endTs:0},V=P(()=>{if(!h.result||h.result.blocks.length===0)return!1;const s=h.result.blocks,e=new Date(s[0].startTs*1e3).getFullYear(),d=new Date(s[s.length-1].endTs*1e3).getFullYear();return e!==d});function U(s){const e={month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"};return V.value&&(e.year="numeric"),new Date(s*1e3).toLocaleString("zh-CN",e)}function c(s,e){const d=e-s;return d<60?`${d}秒`:d<3600?`${Math.floor(d/60)}分钟`:`${Math.floor(d/3600)}h${Math.floor(d%3600/60)}m`}function g(s){w.value=s;const e=k(s);if(e){const d=e.messages.find(f=>f.isHit);d&&(L.value=d.id)}}function o(){z||x.value!==0&&w.value<x.value-1&&(z=!0,w.value++,b(w.value),setTimeout(()=>{z=!1},300))}function a(){}function b(s){D.value.scrollToIndex(s,{align:"center"})}W(()=>h.result,()=>{w.value=0,L.value=null}),W(L,async s=>{s!==null&&(await be(),setTimeout(()=>{r.value?.scrollToMessage(s),L.value=null},100))});function A(s){const e=s.target;if(!e||!h.result?.pagination?.hasMore||h.isLoadingMore)return;const d=100,{scrollTop:f,scrollHeight:i,clientHeight:S}=e;i-f-S<d&&m("load-more")}return(s,e)=>{const d=se;return l(),u("div",dt,[v.result&&v.result.blocks.length>0?(l(),u("div",ct,[t("div",ut,[t("div",ft,[t("span",gt,[T(n(y(M)("analysis.filter.stats.blocks"))+": ",1),t("span",yt,[T(n(v.result.blocks.length)+" ",1),v.result.pagination&&v.result.pagination.totalBlocks>v.result.blocks.length?(l(),u(N,{key:0},[T(" / "+n(v.result.pagination.totalBlocks),1)],64)):H("",!0)])]),t("span",vt,[T(n(y(M)("analysis.filter.stats.messages"))+": ",1),t("span",mt,n(v.result.stats.totalMessages),1)]),t("span",xt,[T(n(y(M)("analysis.filter.stats.hits"))+": ",1),t("span",ht,n(v.result.pagination?.totalHits??v.result.stats.hitMessages),1)]),t("span",pt,[T(n(y(M)("analysis.filter.stats.chars"))+": ",1),t("span",kt,n(v.result.stats.totalChars.toLocaleString()),1)])])])])):H("",!0),t("div",bt,[v.isLoading?(l(),Y($e,{key:0,variant:"page",text:y(M)("analysis.filter.filtering")},null,8,["text"])):v.result?v.result.blocks.length===0?(l(),u("div",$t,[t("div",St,[I(d,{name:"i-heroicons-magnifying-glass",class:"w-12 h-12 mb-3 mx-auto"}),t("p",null,n(y(M)("analysis.filter.noResults")),1)])])):(l(),u(N,{key:3},[t("div",It,[t("div",Ct,[t("span",Tt,[T(n(y(M)("analysis.filter.stats.blocks"))+" ("+n(v.result.blocks.length)+" ",1),v.result.pagination&&v.result.pagination.totalBlocks>v.result.blocks.length?(l(),u(N,{key:0},[T(" /"+n(v.result.pagination.totalBlocks),1)],64)):H("",!0),e[1]||(e[1]=T(" ) ",-1))])]),t("div",{ref_key:"blockListRef",ref:p,class:"flex-1 overflow-y-auto",onScroll:A},[t("div",{style:q({height:`${y(D).getTotalSize()}px`,position:"relative"})},[(l(!0),u(N,null,Z(B.value,f=>(l(),u("div",{key:String(f.key),style:q({position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${f.start}px)`})},[t("div",{class:te(["px-3 py-2 cursor-pointer border-b border-gray-100 dark:border-gray-700 transition-colors",w.value===f.index?"bg-primary-50 dark:bg-primary-900/30 border-l-2 border-l-primary-500":"hover:bg-gray-50 dark:hover:bg-gray-700/50"]),onClick:i=>g(f.index)},[t("div",zt,[t("span",Dt," #"+n(f.index+1),1),(k(f.index)?.hitCount??0)>0?(l(),u("span",Lt," 含 "+n(k(f.index)?.hitCount)+" 个结果 ",1)):H("",!0)]),t("div",Bt,n(U(k(f.index)?.startTs??0)),1),t("div",Ft,[t("span",null,n(k(f.index)?.messages.length??0)+" 条",1),e[2]||(e[2]=t("span",null,"·",-1)),t("span",null,n(c(k(f.index)?.startTs??0,k(f.index)?.endTs??0)),1)])],10,Mt)],4))),128))],4),v.result.pagination?.hasMore?(l(),u("div",Ut,[v.isLoadingMore?(l(),u(N,{key:0},[I(d,{name:"i-heroicons-arrow-path",class:"w-4 h-4 animate-spin inline mr-1"}),T(" "+n(y(M)("common.loading")),1)],64)):(l(),u("button",{key:1,class:"text-primary-500 hover:text-primary-600",onClick:e[0]||(e[0]=f=>m("load-more"))},n(y(M)("analysis.filter.loadMore")),1))])):v.result.pagination&&v.result.blocks.length>=v.result.pagination.totalBlocks?(l(),u("div",Rt,n(y(M)("analysis.filter.allLoaded")),1)):H("",!0)],544)]),t("div",Pt,[F.value.length>0?(l(),Y(me,{key:0,ref_key:"messageListRef",ref:r,query:E,"external-messages":F.value,"hit-message-ids":j.value,class:"h-full",onReachBottom:o,onReachTop:a},null,8,["external-messages","hit-message-ids"])):(l(),u("div",Vt,n(y(M)("analysis.filter.noResults")),1))])],64)):(l(),u("div",_t,[t("div",wt,[I(d,{name:"i-heroicons-funnel",class:"w-12 h-12 mb-3 mx-auto"}),t("p",null,n(y(M)("analysis.filter.emptyHint")),1)])]))])])}}}),jt={class:"flex items-center justify-between"},Et={class:"text-lg font-semibold"},Nt={class:"max-h-96 overflow-y-auto"},At={key:0,class:"py-8 text-center text-gray-500"},Kt={key:1,class:"divide-y divide-gray-200 dark:divide-gray-700"},Yt={class:"flex items-start justify-between gap-2"},Wt={class:"flex-1 min-w-0"},Ot={key:0,class:"flex items-center gap-2 mb-1"},Gt={key:1,class:"flex items-center gap-2 mb-1"},Qt={class:"font-medium text-gray-900 dark:text-white"},Zt=["onClick"],qt={class:"text-sm text-gray-600 dark:text-gray-400 truncate"},Jt={class:"text-xs text-gray-400 mt-1"},Xt={class:"flex items-center gap-1"},es=X({__name:"FilterHistory",props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:we(["load"],["update:open"]),setup(v,{expose:C,emit:M}){const{t:h}=J(),m=ne(),w=xe(),z=Q(v,"open"),L=M,r=$([]);let p=[];const k=$(null),x=$("");async function D(){try{p=(await w.getPreferences()).filterHistory??[],r.value=p.filter(a=>a.sessionId===m.currentSessionId)}catch(o){console.error("Failed to load filter history:",o)}}function B(){p=[...p.filter(a=>a.sessionId!==m.currentSessionId),...r.value],w.savePreferences({filterHistory:p}).catch(a=>{console.error("Failed to save filter history:",a)})}function F(o){r.value=r.value.filter(a=>a.id!==o),B()}function j(o){L("load",{mode:o.mode,conditionFilter:o.conditionFilter,selectedSessionIds:o.selectedSessionIds})}function E(o){k.value=o.id,x.value=o.name}function V(o){o.name=x.value||o.name,k.value=null,B()}function U(){k.value=null}function c(o){return new Date(o).toLocaleString()}function g(o){if(o.mode==="condition"){const a=[];return o.conditionFilter?.keywords.length&&a.push(`关键词: ${o.conditionFilter.keywords.join(", ")}`),o.conditionFilter?.senderIds.length&&a.push(`${o.conditionFilter.senderIds.length} 位成员`),a.join(" | ")||"无条件"}else return`${o.selectedSessionIds?.length||0} 个会话`}return W(z,o=>{o&&D()}),re(()=>{D()}),C({saveCondition(o){const a={id:`filter_${Date.now()}`,sessionId:m.currentSessionId||"",createdAt:Date.now(),name:`筛选 ${r.value.length+1}`,...o};r.value.unshift(a),r.value=r.value.slice(0,20),B()}}),(o,a)=>{const b=le,A=de,s=ce,e=se,d=ge,f=ue;return l(),Y(f,{open:z.value,"onUpdate:open":a[2]||(a[2]=i=>z.value=i)},{content:R(()=>[I(d,null,{header:R(()=>[t("div",jt,[t("h3",Et,n(y(h)("analysis.filter.historyTitle")),1),I(b,{variant:"ghost",icon:"i-heroicons-x-mark",size:"sm",onClick:a[0]||(a[0]=i=>z.value=!1)})])]),default:R(()=>[t("div",Nt,[r.value.length===0?(l(),u("div",At,n(y(h)("analysis.filter.noHistory")),1)):(l(),u("div",Kt,[(l(!0),u(N,null,Z(r.value,i=>(l(),u("div",{key:i.id,class:"py-3 hover:bg-gray-50 dark:hover:bg-gray-800 px-2 rounded-md"},[t("div",Yt,[t("div",Wt,[k.value===i.id?(l(),u("div",Ot,[I(A,{modelValue:x.value,"onUpdate:modelValue":a[1]||(a[1]=S=>x.value=S),size:"sm",class:"flex-1",onKeydown:_e(S=>V(i),["enter"])},null,8,["modelValue","onKeydown"]),I(b,{size:"xs",onClick:S=>V(i)},{default:R(()=>[T(n(y(h)("common.save")),1)]),_:1},8,["onClick"]),I(b,{size:"xs",variant:"ghost",onClick:U},{default:R(()=>[T(n(y(h)("common.cancel")),1)]),_:1})])):(l(),u("div",Gt,[t("span",Qt,n(i.name),1),I(s,{color:i.mode==="condition"?"primary":"green",size:"xs"},{default:R(()=>[T(n(i.mode==="condition"?"条件":"会话"),1)]),_:2},1032,["color"]),t("button",{class:"text-gray-400 hover:text-gray-600",onClick:S=>E(i)},[I(e,{name:"i-heroicons-pencil",class:"w-3 h-3"})],8,Zt)])),t("p",qt,n(g(i)),1),t("p",Jt,n(c(i.createdAt)),1)]),t("div",Xt,[I(b,{size:"xs",variant:"soft",onClick:S=>j(i)},{default:R(()=>[T(n(y(h)("common.load")),1)]),_:1},8,["onClick"]),I(b,{size:"xs",variant:"ghost",color:"red",onClick:S=>F(i.id)},{default:R(()=>[I(e,{name:"i-heroicons-trash",class:"w-4 h-4"})]),_:1},8,["onClick"])])])]))),128))]))])]),_:1})]),_:1},8,["open"])}}}),ts={class:"flex h-[85vh] flex-col overflow-hidden bg-white dark:bg-gray-900"},ss={class:"flex flex-none items-center justify-between border-b border-gray-200 px-5 py-3 dark:border-gray-700"},ns={class:"flex items-center gap-4"},as={class:"text-lg font-semibold text-gray-900 dark:text-white"},os={class:"flex items-center gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},ls={class:"flex items-center gap-2"},rs={class:"flex flex-1 overflow-hidden"},is={class:"flex w-80 flex-none flex-col border-r border-gray-200 dark:border-gray-700"},ds={class:"min-h-0 flex-1 overflow-y-auto"},cs={class:"flex-none border-t border-gray-200 bg-white p-4 dark:border-gray-700 dark:bg-gray-900"},us={class:"flex flex-1 flex-col overflow-hidden"},fs={key:0,class:"flex flex-none flex-col gap-2 border-t border-gray-200 bg-gray-50 px-4 py-3 dark:border-gray-700 dark:bg-gray-800"},gs={key:0,class:"w-full"},ys={class:"mb-1 flex items-center justify-between text-sm text-gray-600 dark:text-gray-400"},vs={class:"h-2 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},ms={class:"flex items-center justify-end gap-3"},ee=50,Is=X({__name:"MessageExportModal",props:{modelValue:{type:Boolean}},emits:["update:modelValue"],setup(v,{emit:C}){const M=v,h=C,{t:m}=J(),w=he(),z=ne(),L=P({get:()=>M.modelValue,set:s=>h("update:modelValue",s)}),r=$("condition"),p=$({keywords:[],timeRange:null,senderIds:[],contextSize:10}),k=$([]),x=$(null),D=$(!1),B=$(!1),F=$(!1),j=P(()=>D.value?!1:r.value==="condition"?p.value.keywords.length>0||p.value.senderIds.length>0||p.value.timeRange!==null:k.value.length>0);async function E(){const s=z.currentSessionId;if(s){D.value=!0,x.value=null;try{if(r.value==="condition"){const e=G(p.value),d=e.keywords.length>0?[...e.keywords]:void 0,f=e.timeRange?{startTs:e.timeRange.start,endTs:e.timeRange.end}:void 0,i=e.senderIds.length>0?[...e.senderIds]:void 0,S=e.contextSize,_=await O().filterMessagesWithContext(s,d,f,i,S,1,ee);x.value=_}else{if(k.value.length===0)return;const e=[...G(k.value)],d=await O().getMultipleSessionsMessages(s,e,1,ee);x.value=d}}catch(e){console.error("筛选失败:",e)}finally{D.value=!1}}}async function V(){const s=z.currentSessionId;if(!s||!x.value||!x.value.pagination.hasMore||B.value)return;B.value=!0;const e=x.value.pagination.page+1;try{let d;if(r.value==="condition"){const f=G(p.value),i=f.keywords.length>0?[...f.keywords]:void 0,S=f.timeRange?{startTs:f.timeRange.start,endTs:f.timeRange.end}:void 0,_=f.senderIds.length>0?[...f.senderIds]:void 0,K=f.contextSize;d=await O().filterMessagesWithContext(s,i,S,_,K,e,ee)}else{const f=[...G(k.value)];d=await O().getMultipleSessionsMessages(s,f,e,ee)}d&&d.blocks.length>0&&(x.value={blocks:[...x.value.blocks,...d.blocks],stats:x.value.stats,pagination:d.pagination})}catch(d){console.error("加载更多失败:",d)}finally{B.value=!1}}const U=$(!1),c=$(null);let g=null;function o(){g=O().onExportProgress(s=>{c.value={percentage:s.percentage,message:s.message},(s.stage==="done"||s.stage==="error")&&(c.value=null)})}function a(){g&&(g(),g=null),c.value=null}async function b(){if(!x.value||x.value.blocks.length===0)return;const s=z.currentSessionId;if(!s)return;const d=z.currentSession?.name||"未知会话",f=await pe().showOpenDialog({title:"选择保存目录",properties:["openDirectory","createDirectory"]});if(f.canceled||!f.filePaths[0])return;const i=f.filePaths[0];U.value=!0,c.value={percentage:0,message:m("analysis.filter.exportPreparing")},o();try{const S=G(p.value),_={sessionId:s,sessionName:d,outputDir:i,filterMode:r.value,keywords:S.keywords.length>0?[...S.keywords]:void 0,timeFilter:S.timeRange?{startTs:S.timeRange.start,endTs:S.timeRange.end}:void 0,senderIds:S.senderIds.length>0?[...S.senderIds]:void 0,contextSize:S.contextSize,chatSessionIds:r.value==="session"?[...G(k.value)]:void 0},K=await O().exportFilterResultToFile(_);K.success&&K.filePath?w.success(m("analysis.filter.exportSuccess"),{description:K.filePath}):w.fail(m("analysis.filter.exportFailed"),{description:K.error||m("common.error.unknown")})}catch(S){console.error("导出失败:",S),w.fail(m("analysis.filter.exportFailed"),{description:String(S)})}finally{a(),U.value=!1}}W(r,()=>{x.value=null}),W(L,s=>{s||(x.value=null,a())});function A(s){r.value=s.mode,s.mode==="condition"&&s.conditionFilter?p.value={...s.conditionFilter}:s.mode==="session"&&s.selectedSessionIds&&(k.value=[...s.selectedSessionIds]),F.value=!1}return(s,e)=>{const d=le,f=ue;return l(),Y(f,{open:L.value,"onUpdate:open":e[10]||(e[10]=i=>L.value=i),ui:{content:"sm:max-w-[95vw]"}},{content:R(()=>[t("div",ts,[t("div",ss,[t("div",ns,[t("h2",as,n(y(m)("analysis.messageExport.title")),1),t("div",os,[t("button",{class:te(["rounded-md px-3 py-1.5 text-sm font-medium transition-colors",r.value==="condition"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white"]),onClick:e[0]||(e[0]=i=>r.value="condition")},n(y(m)("analysis.filter.conditionMode")),3),t("button",{class:te(["rounded-md px-3 py-1.5 text-sm font-medium transition-colors",r.value==="session"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white"]),onClick:e[1]||(e[1]=i=>r.value="session")},n(y(m)("analysis.filter.sessionMode")),3)])]),t("div",ls,[I(d,{variant:"ghost",icon:"i-heroicons-clock",size:"sm",onClick:e[2]||(e[2]=i=>F.value=!0)},{default:R(()=>[T(n(y(m)("analysis.filter.history")),1)]),_:1}),I(d,{variant:"ghost",icon:"i-heroicons-x-mark",size:"sm",onClick:e[3]||(e[3]=i=>L.value=!1)})])]),t("div",rs,[t("div",is,[t("div",ds,[r.value==="condition"?(l(),Y(We,{key:0,keywords:p.value.keywords,"onUpdate:keywords":e[4]||(e[4]=i=>p.value.keywords=i),"time-range":p.value.timeRange,"onUpdate:timeRange":e[5]||(e[5]=i=>p.value.timeRange=i),"sender-ids":p.value.senderIds,"onUpdate:senderIds":e[6]||(e[6]=i=>p.value.senderIds=i),"context-size":p.value.contextSize,"onUpdate:contextSize":e[7]||(e[7]=i=>p.value.contextSize=i)},null,8,["keywords","time-range","sender-ids","context-size"])):(l(),Y(it,{key:1,"selected-ids":k.value,"onUpdate:selectedIds":e[8]||(e[8]=i=>k.value=i)},null,8,["selected-ids"]))]),t("div",cs,[I(d,{block:"",color:"primary",loading:D.value,disabled:!j.value,onClick:E},{default:R(()=>[T(n(y(m)("analysis.filter.execute")),1)]),_:1},8,["loading","disabled"])])]),t("div",us,[I(Ht,{result:x.value,"is-loading":D.value,"is-loading-more":B.value,onLoadMore:V},null,8,["result","is-loading","is-loading-more"]),x.value&&x.value.blocks.length>0?(l(),u("div",fs,[U.value&&c.value?(l(),u("div",gs,[t("div",ys,[t("span",null,n(c.value.message),1),t("span",null,n(c.value.percentage)+"%",1)]),t("div",vs,[t("div",{class:"h-full bg-primary-500 transition-all duration-300",style:q({width:`${c.value.percentage}%`})},null,4)])])):H("",!0),t("div",ms,[I(d,{variant:"outline",icon:"i-heroicons-document-arrow-down",loading:U.value,disabled:U.value,onClick:b},{default:R(()=>[T(n(y(m)("analysis.filter.export")),1)]),_:1},8,["loading","disabled"])])])):H("",!0)])]),I(es,{open:F.value,"onUpdate:open":e[9]||(e[9]=i=>F.value=i),onLoad:A},null,8,["open"])])]),_:1},8,["open"])}}});export{Is as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
class
|
|
1
|
+
class a{generate(e,n){return window.sessionApi.generate(e,n)}generateIncremental(e,n){return window.sessionApi.generateIncremental(e,n)}hasIndex(e){return window.sessionApi.hasIndex(e)}getStats(e){return window.sessionApi.getStats(e)}clear(e){return window.sessionApi.clear(e)}updateGapThreshold(e,n){return window.sessionApi.updateGapThreshold(e,n)}getSessions(e){return window.sessionApi.getSessions(e)}getByTimeRange(e,n,s){return window.sessionApi.getByTimeRange(e,n,s)}getRecent(e,n){return window.sessionApi.getRecent(e,n)}generateSummary(e,n,s,r,i){return window.sessionApi.generateSummary(e,n,s,r,i)}generateSummaries(e,n,s){return window.sessionApi.generateSummaries(e,n,s)}checkCanGenerateSummary(e,n){return window.sessionApi.checkCanGenerateSummary(e,n)}}export{a as ElectronSessionIndexAdapter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{G as
|
|
1
|
+
import{G as c}from"./index-D183wYuz.js";import"./vendor-reka-ui-CW2cIgMu.js";import"./vendor-nuxt-ui-7OAuiz_i.js";import"./vendor-snapdom-XnBoh1gd.js";function i(){return c("data")}class p{async generate(s,t=1800){const e=await fetch(`/_web/sessions/${s}/generate-index`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gapThreshold:t})});if(!e.ok)throw new Error(`Failed to generate session index: ${e.status}`);return(await e.json()).sessionCount}async generateIncremental(s,t=1800){const e=await fetch(`/_web/sessions/${s}/generate-incremental-index`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gapThreshold:t})});if(!e.ok)throw new Error(`Failed to generate incremental session index: ${e.status}`);return(await e.json()).sessionCount}async hasIndex(s){return(await this.getStats(s)).hasIndex}async getStats(s){try{const e=(await i().pluginQuery(s,"SELECT COUNT(*) as cnt FROM chat_session",[]))[0]?.cnt??0;return{hasIndex:e>0,sessionCount:e,gapThreshold:1800}}catch{return{hasIndex:!1,sessionCount:0,gapThreshold:1800}}}async clear(s){return await fetch(`/_web/sessions/${s}/clear-index`,{method:"POST"}),!0}async updateGapThreshold(s,t){return!0}async getSessions(s){return i().pluginQuery(s,"SELECT id, start_ts as startTs, end_ts as endTs, message_count as messageCount, summary FROM chat_session ORDER BY start_ts ASC",[])}async getByTimeRange(s,t,e){return i().pluginQuery(s,"SELECT id, start_ts as startTs, end_ts as endTs, message_count as messageCount, summary FROM chat_session WHERE start_ts >= ? AND end_ts <= ? ORDER BY start_ts ASC",[t,e])}async getRecent(s,t){return i().pluginQuery(s,"SELECT id, start_ts as startTs, end_ts as endTs, message_count as messageCount, summary FROM chat_session ORDER BY start_ts DESC LIMIT ?",[t])}async generateSummary(s,t,e,a,r){try{const n=await fetch(`/_web/sessions/${s}/summaries/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatSessionId:t,locale:e,forceRegenerate:a,strategy:r})}),o=await n.json();return n.ok?o:{success:!1,error:o.error||`HTTP ${n.status}`}}catch(n){return{success:!1,error:n instanceof Error?n.message:String(n)}}}async generateSummaries(s,t,e){let a=0,r=0;const n=0;for(const o of t)try{(await this.generateSummary(s,o,e)).success?a++:r++}catch{r++}return{success:a,failed:r,skipped:n}}async checkCanGenerateSummary(s,t){try{const e=await fetch(`/_web/sessions/${s}/summaries/check-can-generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatSessionIds:t})});return e.ok?await e.json():{}}catch{return{}}}}export{p as FetchSessionIndexAdapter};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{G as w}from"./index-
|
|
1
|
+
import{G as w}from"./index-D183wYuz.js";import"./vendor-reka-ui-CW2cIgMu.js";import"./vendor-nuxt-ui-7OAuiz_i.js";import"./vendor-snapdom-XnBoh1gd.js";const x=`
|
|
2
2
|
msg.id,
|
|
3
3
|
m.id as senderId,
|
|
4
4
|
COALESCE(m.group_nickname, m.account_name, m.platform_id) as senderName,
|