chatlab-cli 0.34.1 → 0.34.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chat-command-OWKJJ736.mjs → chat-command-6IOH2QRF.mjs} +9 -9
- package/dist/{chunk-ZM5DSHFF.mjs → chunk-2XCNTG4O.mjs} +313 -76
- package/dist/chunk-2XCNTG4O.mjs.map +1 -0
- package/dist/{chunk-RRC6U56Y.mjs → chunk-4LW6443F.mjs} +1570 -687
- package/dist/chunk-4LW6443F.mjs.map +1 -0
- package/dist/{chunk-OHFVX2HH.mjs → chunk-4RLZFGO5.mjs} +2 -2
- package/dist/{chunk-GHZFNAMF.mjs → chunk-52P5ZRBD.mjs} +2 -2
- package/dist/{chunk-XEGEOU2D.mjs → chunk-652KEAX3.mjs} +2 -2
- package/dist/{chunk-J7HAIT3T.mjs → chunk-72RWABYJ.mjs} +2 -2
- package/dist/{chunk-MPHFZYB7.mjs → chunk-H6D4DZOC.mjs} +4 -4
- package/dist/{chunk-3RWYALUP.mjs → chunk-INBJ7SND.mjs} +50 -25
- package/dist/chunk-INBJ7SND.mjs.map +1 -0
- package/dist/{chunk-VTCZM2JS.mjs → chunk-JX6MFS6F.mjs} +43 -23
- package/dist/chunk-JX6MFS6F.mjs.map +1 -0
- package/dist/{chunk-RMW3524R.mjs → chunk-MENKFEPC.mjs} +149 -44
- package/dist/chunk-MENKFEPC.mjs.map +1 -0
- package/dist/{chunk-YRCFDZ5Q.mjs → chunk-U6MVJSXX.mjs} +170 -66
- package/dist/chunk-U6MVJSXX.mjs.map +1 -0
- package/dist/chunk-UMBEHBIZ.mjs +41 -0
- package/dist/chunk-UMBEHBIZ.mjs.map +1 -0
- package/dist/{chunk-GFHSSCCR.mjs → chunk-VSOWNKPA.mjs} +1 -11
- package/dist/cli.mjs +10 -9
- package/dist/contacts-worker.mjs +3 -3
- package/dist/global-insight-worker.mjs +2 -2
- package/dist/{http-X55S6MTO.mjs → http-HSK46XEU.mjs} +13 -12
- package/dist/{import-4AX6IX57.mjs → import-DF2WD2HE.mjs} +10 -8
- package/dist/index.mjs +13 -12
- package/dist/{mcp-GWC52AWE.mjs → mcp-A2RND7KN.mjs} +12 -12
- package/dist/people-relationships-worker.mjs +3 -3
- package/dist/semantic-index-worker.mjs +1 -1
- package/dist/{service-KGL3RAIA.mjs → service-KZTHBDQ5.mjs} +2 -2
- package/dist/{src-DLLM4SEO.mjs → src-SHFHW2QB.mjs} +27 -7
- package/dist/{stream-import-K24HWAAZ.mjs → stream-import-GZ2QDE3Z.mjs} +10 -8
- package/dist/{undici-ZSXBT7EA.mjs → undici-MU5I3L6Q.mjs} +2 -2
- package/dist/{update-checker-LGMTEKMT.mjs → update-checker-3N7HQEP2.mjs} +2 -2
- package/dist/{worker-runtime-6KKR55TD.mjs → worker-runtime-OWN56GG5.mjs} +14 -8
- package/dist/worker-runtime-OWN56GG5.mjs.map +1 -0
- package/dist-cli-web/assets/{ActionToolsPanel.vue_vue_type_script_setup_true_lang-D1BiZuQL.js → ActionToolsPanel.vue_vue_type_script_setup_true_lang-B06LYYS9.js} +14 -14
- package/dist-cli-web/assets/{BufferResource-IPkSmPao.js → BufferResource-BdKXeRZS.js} +1 -1
- package/dist-cli-web/assets/{CanvasRenderer-OAQy65em.js → CanvasRenderer-DDRdIyZ8.js} +1 -1
- package/dist-cli-web/assets/{DataDirCleanupNotice-jEI-YjFp.js → DataDirCleanupNotice-CP8P1lsL.js} +1 -1
- package/dist-cli-web/assets/{EChartWordcloud-Pi48JdN2.js → EChartWordcloud-CqknPGui.js} +1 -1
- package/dist-cli-web/assets/{Filter-FQD30cRE.js → Filter-B2eEAPxI.js} +1 -1
- package/dist-cli-web/assets/{LoadingState.vue_vue_type_script_setup_true_lang-CCK5yTju.js → LoadingState.vue_vue_type_script_setup_true_lang-BFaXTz1c.js} +1 -1
- package/dist-cli-web/assets/{MessageExportModal-CZn3LbeY.js → MessageExportModal-CZge6qub.js} +1 -1
- package/dist-cli-web/assets/{PageHeader-B9B9K9by.js → PageHeader-CxKbcLDc.js} +1 -1
- package/dist-cli-web/assets/{RelationshipGalaxyCanvas-CbTmpnZ6.js → RelationshipGalaxyCanvas-CwQ63TPi.js} +7 -7
- package/dist-cli-web/assets/RelationshipGalaxyThreeCanvas-BLqISQe5.js +4108 -0
- package/dist-cli-web/assets/{RelationshipGalaxyThreeCanvas-CeYJABxI.css → RelationshipGalaxyThreeCanvas-CMuibfiA.css} +1 -1
- package/dist-cli-web/assets/{RenderTargetSystem-DnptJCQ0.js → RenderTargetSystem-eC_VrDAr.js} +1 -1
- package/dist-cli-web/assets/{ThemeCard.vue_vue_type_script_setup_true_lang-JXMFY6aD.js → ThemeCard.vue_vue_type_script_setup_true_lang-DVmpDz05.js} +1 -1
- package/dist-cli-web/assets/{TimeSelect.vue_vue_type_script_setup_true_lang-QAZFwx5S.js → TimeSelect.vue_vue_type_script_setup_true_lang-CCH1UQGc.js} +1 -1
- package/dist-cli-web/assets/{WebGLRenderer-BmjIF5se.js → WebGLRenderer-CRp_HC84.js} +1 -1
- package/dist-cli-web/assets/{WebGPURenderer-DkNcKkqj.js → WebGPURenderer-WIUnEhpi.js} +1 -1
- package/dist-cli-web/assets/{annual-summary-time-range-DJ0HWI_t.js → annual-summary-time-range-R3pLPEuN.js} +1 -1
- package/dist-cli-web/assets/{base-CnuE0ss0.js → base-CLwWn3Rs.js} +1 -1
- package/dist-cli-web/assets/{browserAll-C_NnyNBz.js → browserAll-B29Ox2in.js} +1 -1
- package/dist-cli-web/assets/cli-web-CVLb5Pkq.js +1 -0
- package/dist-cli-web/assets/{dateFormat-p6nibkgt.js → dateFormat-T7kMS5IP.js} +1 -1
- package/dist-cli-web/assets/{fetch-C4KJ7tGz.js → fetch-BBgZQob_.js} +1 -1
- package/dist-cli-web/assets/{fetch-BfYranz7.js → fetch-BKBlpBl4.js} +1 -1
- package/dist-cli-web/assets/{fetch-Ch4IMKin.js → fetch-BLi6Jsjg.js} +1 -1
- package/dist-cli-web/assets/{fetch-WElo3Vix.js → fetch-CYaGyohV.js} +1 -1
- package/dist-cli-web/assets/{fetch-CMhV3TYQ.js → fetch-Cm2WR2Cv.js} +1 -1
- package/dist-cli-web/assets/{fetch-DajjPQtq.js → fetch-D8hJZa8o.js} +1 -1
- package/dist-cli-web/assets/fetch-D9sn99zX.js +4 -0
- package/dist-cli-web/assets/{fetch-WIOgRPd9.js → fetch-DsHf-61a.js} +1 -1
- package/dist-cli-web/assets/{fetch-Bsm5YQ_7.js → fetch-DvrVGAzR.js} +1 -1
- package/dist-cli-web/assets/{fetch-BBUvWvOM.js → fetch-L6PKD8-N.js} +1 -1
- package/dist-cli-web/assets/{index-dObiAHg6.js → index-0qcENyvH.js} +1 -1
- package/dist-cli-web/assets/{index-DLnlRLCx.js → index-AkF_KqVI.js} +1 -1
- package/dist-cli-web/assets/index-BVOFyB9E.js +137 -0
- package/dist-cli-web/assets/{index-CjoTcSEc.js → index-BkdOH41D.js} +1 -1
- package/dist-cli-web/assets/index-C4TuoOLM.js +2 -0
- package/dist-cli-web/assets/{index-BcWaPFz7.js → index-C6Mk-Xqt.js} +1 -1
- package/dist-cli-web/assets/{index-Bb6EtLMB.js → index-CkgUsaeX.js} +1 -1
- package/dist-cli-web/assets/{index-CKkIHbie.js → index-CuAy1Xmt.js} +3 -3
- package/dist-cli-web/assets/index-CxGtGxLW.css +1 -0
- package/dist-cli-web/assets/index-D_0qeKKc.js +53 -0
- package/dist-cli-web/assets/{index-CsyURmWU.js → index-DeR0Vukh.js} +1 -1
- package/dist-cli-web/assets/{index-CbacXZN3.js → index-Dx-XvfIK.js} +2 -2
- package/dist-cli-web/assets/{index-BE4nd1aX.js → index-_DrviTnP.js} +1 -1
- package/dist-cli-web/assets/{index-x74lBtei.js → index-xN0sjOLK.js} +1 -1
- package/dist-cli-web/assets/{people-page-header-BW5cNPl7.js → people-page-header-CCNJOrmK.js} +1 -1
- package/dist-cli-web/assets/telemetry-DPC69b73.js +1 -0
- package/dist-cli-web/assets/{webworkerAll-8AFsQkH1.js → webworkerAll-B2qvP2qR.js} +1 -1
- package/dist-cli-web/index.html +1 -1
- package/package.json +3 -2
- package/dist/chunk-3RWYALUP.mjs.map +0 -1
- package/dist/chunk-RMW3524R.mjs.map +0 -1
- package/dist/chunk-RRC6U56Y.mjs.map +0 -1
- package/dist/chunk-VTCZM2JS.mjs.map +0 -1
- package/dist/chunk-YRCFDZ5Q.mjs.map +0 -1
- package/dist/chunk-ZM5DSHFF.mjs.map +0 -1
- package/dist/onnxruntime_binding-6Q6HXASN.node +0 -0
- package/dist/onnxruntime_binding-EKZT2NRK.node +0 -0
- package/dist/onnxruntime_binding-P6S7V3CI.node +0 -0
- package/dist/onnxruntime_binding-PJNNIIUO.node +0 -0
- package/dist/onnxruntime_binding-UN6SPTQK.node +0 -0
- package/dist/transformers.node-PUMHAODN.mjs +0 -42889
- package/dist/transformers.node-PUMHAODN.mjs.map +0 -1
- package/dist/worker-runtime-6KKR55TD.mjs.map +0 -1
- package/dist-cli-web/assets/RelationshipGalaxyThreeCanvas-Cu6NmKOq.js +0 -4108
- package/dist-cli-web/assets/cli-web-t1gabACJ.js +0 -1
- package/dist-cli-web/assets/fetch-_Hb-KRSr.js +0 -3
- package/dist-cli-web/assets/index-B8I5Pax_.js +0 -2
- package/dist-cli-web/assets/index-CsX1Wt8l.js +0 -173
- package/dist-cli-web/assets/index-DmrrdYXH.css +0 -1
- package/dist-cli-web/assets/index-YzfjPohq.js +0 -53
- /package/dist/{chat-command-OWKJJ736.mjs.map → chat-command-6IOH2QRF.mjs.map} +0 -0
- /package/dist/{chunk-OHFVX2HH.mjs.map → chunk-4RLZFGO5.mjs.map} +0 -0
- /package/dist/{chunk-GHZFNAMF.mjs.map → chunk-52P5ZRBD.mjs.map} +0 -0
- /package/dist/{chunk-XEGEOU2D.mjs.map → chunk-652KEAX3.mjs.map} +0 -0
- /package/dist/{chunk-J7HAIT3T.mjs.map → chunk-72RWABYJ.mjs.map} +0 -0
- /package/dist/{chunk-MPHFZYB7.mjs.map → chunk-H6D4DZOC.mjs.map} +0 -0
- /package/dist/{chunk-GFHSSCCR.mjs.map → chunk-VSOWNKPA.mjs.map} +0 -0
- /package/dist/{http-X55S6MTO.mjs.map → http-HSK46XEU.mjs.map} +0 -0
- /package/dist/{import-4AX6IX57.mjs.map → import-DF2WD2HE.mjs.map} +0 -0
- /package/dist/{mcp-GWC52AWE.mjs.map → mcp-A2RND7KN.mjs.map} +0 -0
- /package/dist/{service-KGL3RAIA.mjs.map → service-KZTHBDQ5.mjs.map} +0 -0
- /package/dist/{src-DLLM4SEO.mjs.map → src-SHFHW2QB.mjs.map} +0 -0
- /package/dist/{stream-import-K24HWAAZ.mjs.map → stream-import-GZ2QDE3Z.mjs.map} +0 -0
- /package/dist/{undici-ZSXBT7EA.mjs.map → undici-MU5I3L6Q.mjs.map} +0 -0
- /package/dist/{update-checker-LGMTEKMT.mjs.map → update-checker-3N7HQEP2.mjs.map} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{b1 as Ut,a as M,G as t,b2 as ct,d as ue,b3 as Dt,b4 as Ct,b5 as Ns,b6 as xa,b7 as wt,w as fe,o as r,E as U,F as B,r as ye,b8 as Qa,h as R,an as De,ad as He,b9 as Et,ba as Ja,b as z,bb as jt,bc as Us,bd as Ws,be as Hs,bf as Xa,g as p,ar as Ge,al as Oe,bg as Ks,C as Re,O as tt,bh as ba,bi as xt,b0 as ze,bj as Je,bk as Ys,bl as Gs,bm as Qs,s as Js,bn as Fa,a7 as Qt,bo as Xs,bp as Zs,bq as Za,br as en,c as m,Z as ie,$ as pe,V as es,P as et,bs as tn,S as ts,bt as an,bu as sn,bv as nn,bw as on,bx as ln,by as rn,bz as un,bA as as,bB as cn,bC as dn,bD as ht,bE as mn,bF as gn,bG as pn,I as le,t as d,bH as zt,bI as hn,bJ as fn,bK as vn,bL as lt,bM as yn,bN as We,bO as ss,e as Ee,av as Jt,M as Ke,f as a,n as X,_ as _e,A as we,H as Ue,J as Xe,a3 as nt,aW as ka,B as bt,ap as ut,ak as _a,K as wa,D as ns,bP as $a,bQ as os,a1 as Qe,a2 as ft,ay as ls,U as vt,Y as dt,a8 as Ca,a0 as Wt,bR as xn,bS as rs,bT as is,bU as bn,bV as Sa,bW as us,bX as Ra,bY as At,bZ as Ht,b_ as kn,b$ as _n,aj as Bt,c0 as qt,af as Ia,c1 as Ta,c2 as Va,c3 as Tt,a5 as cs,c4 as ds,ae as $t,c5 as wn,c6 as $n,T as pt,aX as Cn,a6 as Ye,aI as ms,c7 as Sn,aM as yt,az as St,c8 as In,c9 as It,aq as Xt,ca as Tn,cb as Ft,cc as Mn,cd as An,ce as Vt,aB as Ma,aA as Zt,ao as gt,au as gs,cf as zn,aY as ps,j as Oa,m as qn,cg as Ln,a4 as Dn,aC as En,ch as Bn,ci as Fn,ax as Rn,R as Vn,as as On,z as Pn,cj as jn,ck as Nn,Q as Un,cl as Wn,cm as Hn,aF as Kn,aH as Yn,aG as Pa}from"./index-YzfjPohq.js";import{a as Lt,M as Aa,_ as Gn}from"./index-dObiAHg6.js";import{_ as mt}from"./ThemeCard.vue_vue_type_script_setup_true_lang-JXMFY6aD.js";import{C as Qn,a as ea,_ as rt,g as ma}from"./base-CnuE0ss0.js";import"./vendor-echarts-wordcloud-Ca8n6qS6.js";import{_ as Kt}from"./LoadingState.vue_vue_type_script_setup_true_lang-CCK5yTju.js";import{u as ta,p as hs,z as fs,j as za,v as vs,i as aa,k as sa,m as Jn,n as Xn,t as Zn,A as eo}from"./vendor-echarts-B-i_56Av.js";import{f as to,d as ja}from"./dateFormat-p6nibkgt.js";import{_ as ao}from"./TimeSelect.vue_vue_type_script_setup_true_lang-QAZFwx5S.js";import{P as so}from"./PageHeader-B9B9K9by.js";function Nt(i,l,e){const n=i.findIndex(c=>Ut(c,l)),s=i.findIndex(c=>Ut(c,e));if(n===-1||s===-1)return[];const[u,o]=[n,s].sort((c,g)=>c-g);return i.slice(u,o+1)}function ys(i){const l=M(()=>t(i)),e=M(()=>new Intl.Collator("en",{usage:"search",...l.value}));return{startsWith:(o,c)=>c.length===0?!0:(o=o.normalize("NFC"),c=c.normalize("NFC"),e.value.compare(o.slice(0,c.length),c)===0),endsWith:(o,c)=>c.length===0?!0:(o=o.normalize("NFC"),c=c.normalize("NFC"),e.value.compare(o.slice(-c.length),c)===0),contains:(o,c)=>{if(c.length===0)return!0;o=o.normalize("NFC"),c=c.normalize("NFC");let g=0;const h=c.length;for(;g+h<=o.length;g++){const f=o.slice(g,g+h);if(e.value.compare(c,f)===0)return!0}return!1}}}function Na(i){return i?.querySelector("[data-state=checked]")}function no(i,l,e){return i===void 0?!1:Array.isArray(i)?i.some(n=>it(n,l,e)):it(i,l,e)}function it(i,l,e){return i===void 0||l===void 0?!1:typeof i=="string"?i===l:typeof e=="function"?e(i,l):typeof e=="string"?i?.[e]===l?.[e]:Ut(i,l)}const[Rt,oo]=ct("ListboxRoot");var lo=ue({__name:"ListboxRoot",props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},multiple:{type:Boolean,required:!1},orientation:{type:String,required:!1,default:"vertical"},dir:{type:String,required:!1},disabled:{type:Boolean,required:!1},selectionBehavior:{type:String,required:!1,default:"toggle"},highlightOnHover:{type:Boolean,required:!1},by:{type:[String,Function],required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue","highlight","entryFocus","leave"],setup(i,{expose:l,emit:e}){const n=i,s=e,{multiple:u,highlightOnHover:o,orientation:c,disabled:g,selectionBehavior:h,dir:f}=Dt(n),{getItems:b}=Ct({isProvider:!0}),{handleTypeaheadSearch:y}=Ns(),{primitiveElement:k,currentElement:x}=Et(),_=Hs(),C=xa(f),$=Ja(x),S=z(),T=z(!1),v=z(!0),w=wt(n,"modelValue",s,{defaultValue:n.defaultValue??(u.value?[]:void 0),passive:n.modelValue===void 0,deep:!0});function E(oe){if(T.value=!0,n.multiple){const Q=Array.isArray(w.value)?[...w.value]:[],J=Q.findIndex(ge=>it(ge,oe,n.by));n.selectionBehavior==="toggle"?(J===-1?Q.push(oe):Q.splice(J,1),w.value=Q):(w.value=[oe],S.value=oe)}else n.selectionBehavior==="toggle"&&it(w.value,oe,n.by)?w.value=void 0:w.value=oe;setTimeout(()=>{T.value=!1},1)}const F=z(null),D=z(null),A=z(!1),I=z(!1),q=jt(),Y=jt(),G=jt();function Z(){return b().map(oe=>oe.ref).filter(oe=>oe.dataset.disabled!=="")}function ce(oe,Q=!0,J){if(!oe)return;F.value=oe,(J??v.value)&&F.value.focus(),Q&&F.value.scrollIntoView({block:"nearest"});const ge=b().find(ke=>ke.ref===oe);s("highlight",ge)}function ne(oe){if(A.value)G.trigger(oe);else{const Q=b().find(J=>it(J.value,oe,n.by));Q&&(F.value=Q.ref,ce(Q.ref))}}function H(oe){F.value&&F.value.isConnected&&(oe.preventDefault(),oe.stopPropagation(),I.value||F.value.click())}function W(oe){if(v.value){if(T.value=!0,A.value)Y.trigger(oe);else{const Q=oe.altKey||oe.ctrlKey||oe.metaKey;if(Q&&oe.key==="a"&&u.value){const J=b(),ge=J.map($e=>$e.value);w.value=[...ge],oe.preventDefault();const ke=J.at(-1);ke&&ce(ke.ref)}else if(!Q){const J=y(oe.key,b());J&&ce(J)}}setTimeout(()=>{T.value=!1},1)}}function re(){I.value=!0}function ve(){De(()=>{I.value=!1})}function he(){De(()=>{const oe=new KeyboardEvent("keydown",{key:"PageUp"});j(oe)})}function ee(oe){const Q=F.value;Q?.isConnected&&(D.value=Q),F.value=null,s("leave",oe)}function te(oe){const Q=new CustomEvent("listbox.entryFocus",{bubbles:!1,cancelable:!0});if(oe.currentTarget?.dispatchEvent(Q),s("entryFocus",Q),!Q.defaultPrevented)if(D.value)ce(D.value);else{const J=Z()?.[0];ce(J)}}function j(oe){const Q=Us(oe,c.value,C.value);if(!Q)return;let J=Z();if(F.value){if(Q==="last")J.reverse();else if(Q==="prev"||Q==="next"){Q==="prev"&&J.reverse();const ge=J.indexOf(F.value);J=J.slice(ge+1)}de(oe,J[0])}if(J.length){const ge=!F.value&&Q==="prev"?J.length-1:0;ce(J[ge])}if(A.value)return Y.trigger(oe)}function de(oe,Q){if(!(A.value||n.selectionBehavior!=="replace"||!u.value||!Array.isArray(w.value)||(oe.altKey||oe.ctrlKey||oe.metaKey)&&!oe.shiftKey)&&oe.shiftKey){const ge=b().filter(Le=>Le.ref.dataset.disabled!=="");let ke=ge.find(Le=>Le.ref===Q)?.value;if(oe.key===_.END?ke=ge.at(-1)?.value:oe.key===_.HOME&&(ke=ge[0]?.value),!ke||!S.value)return;const $e=Nt(ge.map(Le=>Le.value),S.value,ke);w.value=$e}}async function be(oe,Q=!0){if(Ws)if(await De(),A.value)q.trigger({event:oe,scroll:Q});else{const J=Z(),ge=J.find($e=>$e.dataset.state==="checked"),ke=Q?void 0:!1;ge?ce(ge,Q,ke):J.length&&ce(J[0],Q,ke)}}let xe=!1;return fe(w,()=>{if(!T.value){const oe=xe;xe=!0,De(()=>{be(void 0,oe)})}},{immediate:!0,deep:!0}),l({highlightedElement:F,highlightItem:ne,highlightFirstItem:he,highlightSelected:be,getItems:b}),oo({modelValue:w,onValueChange:E,multiple:u,orientation:c,dir:C,disabled:g,highlightOnHover:o,highlightedElement:F,isVirtual:A,virtualFocusHook:q,virtualKeydownHook:Y,virtualHighlightHook:G,by:n.by,firstValue:S,selectionBehavior:h,focusable:v,onLeave:ee,onEnter:te,changeHighlight:ce,onKeydownEnter:H,onKeydownNavigation:j,onKeydownTypeAhead:W,onCompositionStart:re,onCompositionEnd:ve,highlightFirstItem:he}),(oe,Q)=>(r(),U(t(He),{ref_key:"primitiveElement",ref:k,as:oe.as,"as-child":oe.asChild,dir:t(C),"data-disabled":t(g)?"":void 0,onPointerleave:ee,onFocusout:Q[0]||(Q[0]=async J=>{const ge=J.relatedTarget||J.target;await De(),F.value&&t(x)&&!t(x).contains(ge)&&ee(J)})},{default:B(()=>[ye(oe.$slots,"default",{modelValue:t(w)}),t($)&&oe.name?(r(),U(t(Qa),{key:0,name:oe.name,value:t(w),disabled:t(g),required:oe.required},null,8,["name","value","disabled","required"])):R("v-if",!0)]),_:3},8,["as","as-child","dir","data-disabled"]))}}),ro=lo,io=ue({__name:"ListboxContent",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(i){const{CollectionSlot:l}=Ct(),e=Rt(),n=Xa(!1,10);return(s,u)=>(r(),U(t(l),null,{default:B(()=>[p(t(He),{role:"listbox",as:s.as,"as-child":s.asChild,tabindex:t(e).focusable.value?t(e).highlightedElement.value?"-1":"0":"-1","aria-orientation":t(e).orientation.value,"aria-multiselectable":!!t(e).multiple.value,"data-orientation":t(e).orientation.value,onMousedown:u[0]||(u[0]=Oe(o=>n.value=!0,["left"])),onFocus:u[1]||(u[1]=o=>{t(n)||t(e).onEnter(o)}),onKeydown:[u[2]||(u[2]=Ge(o=>{t(e).orientation.value==="vertical"&&(o.key==="ArrowLeft"||o.key==="ArrowRight")||t(e).orientation.value==="horizontal"&&(o.key==="ArrowUp"||o.key==="ArrowDown")||(o.preventDefault(),t(e).focusable.value&&t(e).onKeydownNavigation(o))},["down","up","left","right","home","end"])),Ge(t(e).onKeydownEnter,["enter"]),t(e).onKeydownTypeAhead]},{default:B(()=>[ye(s.$slots,"default")]),_:3},8,["as","as-child","tabindex","aria-orientation","aria-multiselectable","data-orientation","onKeydown"])]),_:3}))}}),uo=io,co=ue({__name:"ListboxFilter",props:{modelValue:{type:String,required:!1},autoFocus:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"input"}},emits:["update:modelValue"],setup(i,{emit:l}){const e=i,s=wt(e,"modelValue",l,{defaultValue:"",passive:e.modelValue===void 0}),u=Rt(),{primitiveElement:o,currentElement:c}=Et(),g=M(()=>e.disabled||u.disabled.value||!1),h=z();Ks(()=>h.value=u.highlightedElement.value?.id),Re(()=>{u.focusable.value=!1,setTimeout(()=>{e.autoFocus&&c.value?.focus()},1)}),tt(()=>{u.focusable.value=!0});const{isComposing:f,handleCompositionStart:b,handleCompositionEnd:y}=ba($=>{s.value=$.target.value,u.onCompositionEnd(),u.highlightFirstItem()});function k(){u.onCompositionStart(),b()}function x($){f.value||(s.value=$.target.value,u.highlightFirstItem())}function _($){f.value||($.preventDefault(),u.onKeydownNavigation($))}function C($){f.value||u.onKeydownEnter($)}return($,S)=>(r(),U(t(He),{ref_key:"primitiveElement",ref:o,as:$.as,"as-child":$.asChild,value:t(s),disabled:g.value?"":void 0,"data-disabled":g.value?"":void 0,"aria-disabled":g.value??void 0,"aria-activedescendant":h.value,type:"text",onKeydown:[Ge(_,["down","up","home","end"]),Ge(C,["enter"])],onInput:x,onCompositionstart:k,onCompositionend:t(y)},{default:B(()=>[ye($.$slots,"default",{modelValue:t(s)})]),_:3},8,["as","as-child","value","disabled","data-disabled","aria-disabled","aria-activedescendant","onCompositionend"]))}}),mo=co;const[Pw,go]=ct("ListboxGroup");var po=ue({__name:"ListboxGroup",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(i){const l=i,e=xt(void 0,"reka-listbox-group");return go({id:e}),(n,s)=>(r(),U(t(He),ze({role:"group"},l,{"aria-labelledby":t(e)}),{default:B(()=>[ye(n.$slots,"default")]),_:3},16,["aria-labelledby"]))}}),ho=po;const fo="listbox.select",[vo,yo]=ct("ListboxItem");var xo=ue({__name:"ListboxItem",props:{value:{type:null,required:!0},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"div"}},emits:["select"],setup(i,{emit:l}){const e=i,n=l,s=xt(void 0,"reka-listbox-item"),{CollectionItem:u}=Ct(),{forwardRef:o,currentElement:c}=Je(),g=Rt(),h=M(()=>c.value!=null&&c.value===g.highlightedElement.value),f=M(()=>no(g.modelValue.value,e.value,g.by)),b=M(()=>g.disabled.value||e.disabled);async function y(x){n("select",x),!x?.defaultPrevented&&!b.value&&x&&(g.onValueChange(e.value),g.changeHighlight(c.value))}function k(x){const _={originalEvent:x,value:e.value};Gs(fo,y,_)}return yo({isSelected:f}),(x,_)=>(r(),U(t(u),{value:x.value},{default:B(()=>[Ys([h.value,f.value,b.value,t(g).focusable.value],()=>p(t(He),ze({id:t(s)},x.$attrs,{ref:t(o),role:"option",tabindex:t(g).focusable.value?h.value?"0":"-1":-1,"aria-selected":f.value,as:x.as,"as-child":x.asChild,disabled:b.value?"":void 0,"data-disabled":b.value?"":void 0,"data-highlighted":h.value?"":void 0,"data-state":f.value?"checked":"unchecked",onClick:k,onKeydown:Ge(Oe(k,["prevent"]),["space"]),onPointermove:_[0]||(_[0]=()=>{t(g).highlightedElement.value!==t(c)&&t(g).highlightOnHover.value&&t(g).changeHighlight(t(c),!1,!1)})}),{default:B(()=>[ye(x.$slots,"default")]),_:3},16,["id","tabindex","aria-selected","as","as-child","disabled","data-disabled","data-highlighted","data-state","onKeydown"]),_,1)]),_:3},8,["value"]))}}),bo=xo,ko=ue({__name:"ListboxItemIndicator",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(i){const l=i;Je();const e=vo();return(n,s)=>t(e).isSelected.value?(r(),U(t(He),ze({key:0,"aria-hidden":"true"},l),{default:B(()=>[ye(n.$slots,"default")]),_:3},16)):R("v-if",!0)}}),_o=ko;function wo(i,l,e){const n=new Array(i);return new Proxy(n,{get(s,u,o){if(typeof u=="string"){const c=u.charCodeAt(0);if(c>=48&&c<=57){const g=+u;if(Number.isInteger(g)&&g>=0&&g<i){let h=s[g];if(!h){const f=l[g*2];h=s[g]={index:g,key:e(g),start:f,size:l[g*2+1],end:f+l[g*2+1],lane:0}}return h}}if(u==="length")return i}return Reflect.get(s,u,o)}})}function _t(i,l,e){let n=e.initialDeps??[],s,u=!0;function o(){const c=i();return(c.length!==n.length||c.some((h,f)=>n[f]!==h))&&(n=c,s=l(...c),e?.onChange&&!(u&&e.skipInitialOnChange)&&e.onChange(s),u=!1),s}return o.updateDeps=c=>{n=c},o}function Ua(i,l){if(i===void 0)throw new Error("Unexpected undefined");return i}const $o=(i,l)=>Math.abs(i-l)<1.01,Co=(i,l,e)=>{let n;return function(...s){i.clearTimeout(n),n=i.setTimeout(()=>l.apply(this,s),e)}};let Mt;const la=()=>{if(Mt!==void 0)return Mt;if(typeof navigator>"u")return Mt=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Mt=!0;const i=navigator.maxTouchPoints;return Mt=navigator.platform==="MacIntel"&&i!==void 0&&i>0},Wa=i=>{const{offsetWidth:l,offsetHeight:e}=i;return{width:l,height:e}},So=i=>i,Io=i=>{const l=Math.max(i.startIndex-i.overscan,0),n=Math.min(i.endIndex+i.overscan,i.count-1)-l+1,s=new Array(n);for(let u=0;u<n;u++)s[u]=l+u;return s},To=(i,l)=>{const e=i.scrollElement;if(!e)return;const n=i.targetWindow;if(!n)return;const s=o=>{const{width:c,height:g}=o;l({width:Math.round(c),height:Math.round(g)})};if(s(Wa(e)),!n.ResizeObserver)return()=>{};const u=new n.ResizeObserver(o=>{const c=()=>{const g=o[0];if(g?.borderBoxSize){const h=g.borderBoxSize[0];if(h){s({width:h.inlineSize,height:h.blockSize});return}}s(Wa(e))};i.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return u.observe(e,{box:"border-box"}),()=>{u.unobserve(e)}},Yt={passive:!0},Mo=typeof window>"u"?!0:"onscrollend"in window,Ao=(i,l,e)=>{const n=i.scrollElement;if(!n)return;const s=i.targetWindow;if(!s)return;const u=i.options.useScrollendEvent&&Mo;let o=0;const c=u?null:Co(s,()=>l(o,!1),i.options.isScrollingResetDelay),g=b=>()=>{o=e(n),c?.(),l(o,b)},h=g(!0),f=g(!1);return n.addEventListener("scroll",h,Yt),u&&n.addEventListener("scrollend",f,Yt),()=>{n.removeEventListener("scroll",h),u&&n.removeEventListener("scrollend",f)}},zo=(i,l)=>Ao(i,l,e=>{const{horizontal:n,isRtl:s}=i.options;return n?e.scrollLeft*(s&&-1||1):e.scrollTop}),qo=(i,l,e)=>{if(e.options.useCachedMeasurements){const n=e.indexFromElement(i),s=e.options.getItemKey(n);return e.itemSizeCache.get(s)??e.options.estimateSize(n)}if(l?.borderBoxSize){const n=l.borderBoxSize[0];if(n)return Math.round(n[e.options.horizontal?"inlineSize":"blockSize"])}if(!l){const n=e.indexFromElement(i),s=e.options.getItemKey(n),u=e.itemSizeCache.get(s);if(u!==void 0)return u}return i[e.options.horizontal?"offsetWidth":"offsetHeight"]},Lo=(i,{adjustments:l=0,behavior:e},n)=>{var s,u;(u=(s=n.scrollElement)==null?void 0:s.scrollTo)==null||u.call(s,{[n.options.horizontal?"left":"top"]:i+l,behavior:e})},Do=Lo;class Eo{constructor(l){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e,n,s;return((s=(n=(e=this.targetWindow)==null?void 0:e.performance)==null?void 0:n.now)==null?void 0:s.call(n))??Date.now()},this.observer=(()=>{let e=null;const n=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(s=>{s.forEach(u=>{const o=()=>{const c=u.target,g=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);for(const[h,f]of this.elementsCache)if(f===c){this.elementsCache.delete(h);break}return}this.shouldMeasureDuringScroll(g)&&this.resizeItem(g,this.options.measureElement(c,u,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var s;(s=n())==null||s.disconnect(),e=null},observe:s=>{var u;return(u=n())==null?void 0:u.observe(s,{box:"border-box"})},unobserve:s=>{var u;return(u=n())==null?void 0:u.unobserve(s)}}})(),this.range=null,this.setOptions=e=>{var n,s;const u={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:So,rangeExtractor:Io,onChange:()=>{},measureElement:qo,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const y in e){const k=e[y];k!==void 0&&(u[y]=k)}const o=this.options;let c=null,g=null,h=!1;if(o!==void 0&&o.enabled&&u.enabled&&u.anchorTo==="end"&&this.scrollElement!==null){const y=o.count,k=u.count,x=this.getMeasurements(),_=y>0?((n=x[0])==null?void 0:n.key)??o.getItemKey(0):null,C=y>0?((s=x[y-1])==null?void 0:s.key)??o.getItemKey(y-1):null;if(k!==y||y>0&&k>0&&(u.getItemKey(0)!==_||u.getItemKey(k-1)!==C)){h=!0;const T=y>0?this.getVirtualItemForOffset(this.getScrollOffset())??x[0]:null;T&&(c=[T.key,this.getScrollOffset()-T.start]);const v=u.followOnAppend===!0?"auto":u.followOnAppend||null;v&&k>y&&this.isAtEnd(o.scrollEndThreshold)&&(y===0||u.getItemKey(k-1)!==C)&&(g=v)}}this.options=u,h&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,b=0;if(c&&this.scrollOffset!==null){const[y,k]=c,x=this.getMeasurements(),{count:_,getItemKey:C}=this.options;let $=0;for(;$<_&&C($)!==y;)$++;if($<_){const S=x[$];if(S){const T=S.start+k;T!==this.scrollOffset&&(b=T-this.scrollOffset,this.scrollOffset=T,f=!0)}}}(f||g)&&(this.pendingScrollAnchor=[f?c[0]:null,f?c[1]:0,g,b])},this.notify=e=>{var n,s;(s=(n=this.options).onChange)==null||s.call(n,this,e)},this.maybeNotify=_t(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;const n=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==n){if(this.cleanup(),!n){this.maybeNotify();return}if(this.scrollElement=n,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((e=this.scrollElement)==null?void 0:e.window)??null,this.elementsCache.forEach(u=>{this.observer.observe(u)}),this.unsubs.push(this.options.observeElementRect(this,u=>{this.scrollRect=u,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(u,o)=>{if(o&&this._intendedScrollOffset===null&&u===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(u-this._intendedScrollOffset)<1.5&&(u=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const c=this.getScrollOffset();this.scrollDirection=o?c===u?this.scrollDirection:c<u?"forward":"backward":null,this.scrollOffset=u,this.isScrolling=o,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const u=this.scrollElement,o=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},c=()=>{this._iosTouching=!1,!(!la()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};u.addEventListener("touchstart",o,Yt),u.addEventListener("touchend",c,Yt),this.unsubs.push(()=>{u.removeEventListener("touchstart",o),u.removeEventListener("touchend",c),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const s=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,s&&this.scrollElement&&this.options.enabled){const[u,o,c,g]=s;u!==null&&!c&&(la()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?g!==0&&(this._iosDeferredAdjustment+=g):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),c&&this.scrollToEnd({behavior:c})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const e=this.getScrollOffset(),n=this.getMaxScrollOffset();if(e<0||e>n)return;const s=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=s,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=_t(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,n,s,u,o,c,g,h)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMin=null,{count:e,paddingStart:n,scrollMargin:s,getItemKey:u,enabled:o,lanes:c,laneAssignmentMode:g,gap:h}),{key:!1}),this.getMeasurements=_t(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:n,scrollMargin:s,getItemKey:u,enabled:o,lanes:c,laneAssignmentMode:g,gap:h},f)=>{const b=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(const $ of this.laneAssignments.keys())$>=e&&this.laneAssignments.delete($);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach($=>{this.itemSizeCache.set($.key,$.size)}));const y=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),c===1){const $=e*2;let S=this._flatMeasurements;if(!S||S.length<$){const w=new Float64Array($);S&&y>0&&w.set(S.subarray(0,y*2)),S=w,this._flatMeasurements=S}let T;if(y===0)T=n+s;else{const w=y-1;T=S[w*2]+S[w*2+1]+h}for(let w=y;w<e;w++){const E=u(w),F=b.get(E),D=typeof F=="number"?F:this.options.estimateSize(w);S[w*2]=T,S[w*2+1]=D,T+=D+h}const v=wo(e,S,u);return this.measurementsCache=v,v}const k=this.measurementsCache.slice(0,y),x=new Array(c).fill(void 0),_=new Float64Array(c);let C=0;for(let $=0;$<y;$++){const S=k[$];S&&(x[S.lane]===void 0&&C++,x[S.lane]=$,_[S.lane]=S.end)}for(let $=y;$<e;$++){const S=u($),T=this.laneAssignments.get($);let v,w;const E=g==="estimate"||b.has(S);if(T!==void 0&&this.options.lanes>1){v=T;const I=x[v],q=I!==void 0?k[I]:void 0;w=q?q.end+h:n+s}else if(C===c){let I=0,q=_[0],Y=x[0];for(let G=1;G<c;G++){const Z=_[G];(Z<q||Z===q&&x[G]<Y)&&(I=G,q=Z,Y=x[G])}v=I,w=q+h,E&&this.laneAssignments.set($,v)}else v=$%this.options.lanes,w=n+s,E&&this.laneAssignments.set($,v);const F=b.get(S),D=typeof F=="number"?F:this.options.estimateSize($),A=w+D;k[$]={index:$,start:w,size:D,end:A,key:S,lane:v},x[v]===void 0&&C++,x[v]=$,_[v]=A}return this.measurementsCache=k,k},{key:!1,debug:()=>this.options.debug}),this.calculateRange=_t(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,n,s,u)=>e.length===0||n===0?(this.range=null,null):(this.range=Fo(e,n,s,u,u===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=_t(()=>{let e=null,n=null;const s=this.calculateRange();return s&&(e=s.startIndex,n=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,n]},(e,n,s,u,o)=>u===null||o===null?[]:e({startIndex:u,endIndex:o,overscan:n,count:s}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{const n=this.options.indexAttribute,s=e.getAttribute(n);return s?parseInt(s,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var n;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const s=this.scrollState.index??((n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index);if(s!==void 0&&this.range){const u=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,s-u),c=Math.min(this.options.count-1,s+u);return e>=o&&e<=c}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((o,c)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(c))});return}const n=this.indexFromElement(e),s=this.options.getItemKey(n),u=this.elementsCache.get(s);u!==e&&(u&&this.observer.unobserve(u),this.observer.observe(e),this.elementsCache.set(s,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,n)=>{var s,u;if(e<0||e>=this.options.count)return;let o,c,g;const h=this._flatMeasurements;if(this.options.lanes===1&&h!==null)g=this.options.getItemKey(e),c=h[e*2],o=h[e*2+1];else{const y=this.measurementsCache[e];if(!y)return;g=y.key,c=y.start,o=y.size}const f=this.itemSizeCache.get(g)??o,b=n-f;if(b!==0){const y=this.options.anchorTo==="end"&&((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,k=y?this.getTotalSize():0,x=((u=this.scrollState)==null?void 0:u.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:g,start:c,size:o,end:c+o,lane:0},b,this):c<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(g)||this.scrollDirection!=="backward"));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(g,n),this.itemSizeCacheVersion++,y?this.applyScrollAdjustment(this.getTotalSize()-k):x&&this.applyScrollAdjustment(b),this.notify(!1)}},this.getVirtualItems=_t(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,n)=>{const s=[];for(let u=0,o=e.length;u<o;u++){const c=e[u],g=n[c];s.push(g)}return s},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{const n=this.getMeasurements();if(n.length===0)return;const s=this._flatMeasurements,u=this.options.lanes===1&&s!=null,o=xs(0,n.length-1,u?c=>s[c*2]:c=>Ua(n[c]).start,e);return Ua(n[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,n,s=0)=>{if(!this.scrollElement)return 0;const u=this.getSize(),o=this.getScrollOffset();n==="auto"&&(n=e>=o+u?"end":"start"),n==="center"?e+=(s-u)/2:n==="end"&&(e-=u);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,e),0)},this.getOffsetForIndex=(e,n="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));const s=this.getSize(),u=this.getScrollOffset(),o=this.measurementsCache[e];if(!o)return;if(n==="auto")if(o.end>=u+s-this.options.scrollPaddingEnd)n="end";else if(o.start<=u+this.options.scrollPaddingStart)n="start";else return[u,n];if(n==="end"&&e===this.options.count-1)return[this.getMaxScrollOffset(),n];const c=n==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,n,o.size),n]},this.scrollToOffset=(e,{align:n="start",behavior:s="auto"}={})=>{const u=this.getOffsetForAlignment(e,n),o=this.now();this.scrollState={index:null,align:n,behavior:s,startedAt:o,lastTargetOffset:u,stableFrames:0},this._scrollToOffset(u,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:n="auto",behavior:s="auto"}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));const u=this.getOffsetForIndex(e,n);if(!u)return;const[o,c]=u,g=this.now();this.scrollState={index:e,align:c,behavior:s,startedAt:g,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:n="auto"}={})=>{const s=this.getScrollOffset()+e,u=this.now();this.scrollState={index:null,align:"start",behavior:n,startedAt:u,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{var e;const n=this.getMeasurements();let s;if(n.length===0)s=this.options.paddingStart;else if(this.options.lanes===1){const u=n.length-1,o=this._flatMeasurements;o!=null?s=o[u*2]+o[u*2+1]:s=((e=n[u])==null?void 0:e.end)??0}else{const u=Array(this.options.lanes).fill(null);let o=n.length-1;for(;o>=0&&u.some(c=>c===null);){const c=n[o];u[c.lane]===null&&(u[c.lane]=c.end),o--}s=Math.max(...u.filter(c=>c!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const e=[];if(this.itemSizeCache.size===0)return e;const n=this.getMeasurements();for(const s of n)s&&this.itemSizeCache.has(s.key)&&e.push({index:s.index,key:s.key,start:s.start,size:s.size,end:s.end,lane:s.lane});return e},this._scrollToOffset=(e,{adjustments:n,behavior:s})=>{this._intendedScrollOffset=e+(n??0),this.options.scrollToFn(e,{behavior:s,adjustments:n},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(l)}applyScrollAdjustment(l,e){l!==0&&(la()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=l:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:e}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const n=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,s=n?n[0]:this.scrollState.lastTargetOffset,u=1,o=s!==this.scrollState.lastTargetOffset;if(!o&&$o(s,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=u){this.getScrollOffset()!==s&&this._scrollToOffset(s,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const c=this.getSize()||600,g=Math.abs(s-this.getScrollOffset()),h=this.scrollState.behavior==="smooth"&&g>c;this.scrollState.lastTargetOffset=s,h||(this.scrollState.behavior="auto"),this._scrollToOffset(s,{adjustments:void 0,behavior:h?"smooth":"auto"})}this.scheduleScrollReconcile()}}const xs=(i,l,e,n)=>{for(;i<=l;){const s=(i+l)/2|0,u=e(s);if(u<n)i=s+1;else if(u>n)l=s-1;else return s}return i>0?i-1:0};function Bo(i,l,e){let n=0;for(;n<=l;){const s=(n+l)/2|0,u=i[s*2];if(u<e)n=s+1;else if(u>e)l=s-1;else return s}return n>0?n-1:0}function Fo(i,l,e,n,s){const u=i.length-1;if(i.length<=n)return{startIndex:0,endIndex:u};if(n===1&&s!==null){const h=Bo(s,u,e);let f=h;const b=e+l;for(;f<u&&s[f*2]+s[f*2+1]<b;)f++;return{startIndex:h,endIndex:f}}let c=xs(0,u,h=>i[h].start,e),g=c;if(n===1)for(;g<u&&i[g].end<e+l;)g++;else if(n>1){const h=Array(n).fill(0);for(;g<u&&h.some(b=>b<e+l);){const b=i[g];h[b.lane]=b.end,g++}const f=Array(n).fill(e+l);for(;c>=0&&f.some(b=>b>=e);){const b=i[c];f[b.lane]=b.start,c--}c=Math.max(0,c-c%n),g=Math.min(u,g+(n-1-g%n))}return{startIndex:c,endIndex:g}}function Ro(i){const l=new Eo(t(i)),e=Js(l),n=l._didMount();return fe(()=>t(i).getScrollElement(),s=>{s&&l._willUpdate()},{immediate:!0}),fe(()=>t(i),s=>{l.setOptions({...s,onChange:(u,o)=>{var c;Fa(e),(c=s.onChange)==null||c.call(s,u,o)}}),l._willUpdate(),Fa(e)},{immediate:!0}),Qs(n),e}function Vo(i){return Ro(M(()=>({observeElementRect:To,observeElementOffset:zo,scrollToFn:Do,...t(i)})))}var Oo=ue({__name:"ListboxVirtualizer",props:{options:{type:Array,required:!0},overscan:{type:Number,required:!1},estimateSize:{type:[Number,Function],required:!1},textContent:{type:Function,required:!1}},setup(i){const l=i,e=Qt(),n=Rt(),s=Xs(),{getItems:u}=Ct();n.isVirtual.value=!0;const o=M(()=>{const y=s.value;if(y){const k=window.getComputedStyle(y);return{start:Number.parseFloat(k.paddingBlockStart||k.paddingTop),end:Number.parseFloat(k.paddingBlockEnd||k.paddingBottom)}}else return{start:0,end:0}}),c=Vo({get scrollPaddingStart(){return o.value.start},get scrollPaddingEnd(){return o.value.end},get count(){return l.options.length},get horizontal(){return n.orientation.value==="horizontal"},estimateSize(y){return typeof l.estimateSize=="function"?l.estimateSize(y):l.estimateSize??28},getScrollElement(){return s.value},overscan:l.overscan??12}),g=M(()=>c.value.getVirtualItems().map(y=>{const k=e.default({option:l.options[y.index],virtualizer:c.value,virtualItem:y})[0],x=k.type===ie&&Array.isArray(k.children)?k.children.find(_=>typeof _.type!="symbol"):k;return{item:y,is:tn(x,{key:`${y.key}`,"data-index":y.index,"aria-setsize":l.options.length,"aria-posinset":y.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${y.start}px)`,overflowAnchor:"none"}})}}));n.virtualFocusHook.on(({event:y,scroll:k})=>{const x=l.options.findIndex(_=>Array.isArray(n.modelValue.value)?it(_,n.modelValue.value[0],n.by):it(_,n.modelValue.value,n.by));x!==-1?(y?.preventDefault(),c.value.scrollToIndex(x,{align:"start"}),requestAnimationFrame(()=>{const _=Na(s.value);_&&(n.changeHighlight(_,k,k?void 0:!1),y&&_?.focus())})):k?n.highlightFirstItem():requestAnimationFrame(()=>{const _=u().find(C=>C.ref.dataset.disabled!=="")?.ref;_&&n.changeHighlight(_,!1,!1)})}),n.virtualHighlightHook.on(y=>{const k=l.options.findIndex(x=>it(x,y,n.by));c.value.scrollToIndex(k,{align:"start"}),requestAnimationFrame(()=>{const x=Na(s.value);x&&n.changeHighlight(x)})});const h=Xa("",1e3),f=M(()=>{const y=k=>l.textContent?l.textContent(k):k?.toString().toLowerCase();return l.options.map((k,x)=>({index:x,textContent:y(k)}))});function b(y,k){if(!n.firstValue?.value||!n.multiple.value||!Array.isArray(n.modelValue.value))return;const _=u().filter($=>$.ref.dataset.disabled!=="").find($=>$.ref===n.highlightedElement.value)?.value;if(!_)return;let C=null;switch(k){case"prev":case"next":{C=Nt(l.options,n.firstValue.value,_);break}case"first":{C=Nt(l.options,n.firstValue.value,l.options?.[0]);break}case"last":{C=Nt(l.options,n.firstValue.value,l.options.at(-1));break}}n.modelValue.value=C}return n.virtualKeydownHook.on(y=>{const k=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!k)return;let _=Zs[y.key];if(k&&y.key==="a"&&n.multiple.value?(y.preventDefault(),n.modelValue.value=[...l.options],_="last"):y.shiftKey&&_&&b(y,_),["first","last"].includes(_)){y.preventDefault();const C=_==="first"?0:l.options.length-1;c.value.scrollToIndex(C),requestAnimationFrame(()=>{const $=u(),S=_==="first"?$[0]:$.at(-1);S&&n.changeHighlight(S.ref)})}else if(!_&&!k){h.value+=y.key;const C=Number(Za()?.getAttribute("data-index")),$=f.value[C].textContent,S=f.value.map(w=>w.textContent??""),T=en(S,h.value,$),v=f.value.find(w=>w.textContent===T);v&&(c.value.scrollToIndex(v.index,{align:"start"}),requestAnimationFrame(()=>{const w=s.value.querySelector(`[data-index="${v.index}"]`);w instanceof HTMLElement&&n.changeHighlight(w)}))}}),(y,k)=>(r(),m("div",{"data-reka-virtualizer":"",style:et({position:"relative",width:"100%",height:`${t(c).getTotalSize()}px`})},[(r(!0),m(ie,null,pe(g.value,({is:x,item:_})=>(r(),U(es(x),{key:_.index}))),128))],4))}}),Po=Oo;const[at,jo]=ct("ComboboxRoot");var No=ue({__name:"ComboboxRoot",props:{open:{type:Boolean,required:!1,default:void 0},defaultOpen:{type:Boolean,required:!1},resetSearchTermOnBlur:{type:Boolean,required:!1,default:!0},resetSearchTermOnSelect:{type:Boolean,required:!1,default:!0},openOnFocus:{type:Boolean,required:!1,default:!1},openOnClick:{type:Boolean,required:!1,default:!1},ignoreFilter:{type:Boolean,required:!1},resetModelValueOnClear:{type:Boolean,required:!1,default:!1},modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},multiple:{type:Boolean,required:!1},dir:{type:String,required:!1},disabled:{type:Boolean,required:!1},highlightOnHover:{type:Boolean,required:!1,default:!0},by:{type:[String,Function],required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue","highlight","update:open"],setup(i,{expose:l,emit:e}){const n=i,s=e,{primitiveElement:u,currentElement:o}=Et(),{multiple:c,disabled:g,ignoreFilter:h,resetSearchTermOnSelect:f,openOnFocus:b,openOnClick:y,dir:k,resetModelValueOnClear:x,highlightOnHover:_}=Dt(n),C=xa(k),$=wt(n,"modelValue",s,{defaultValue:n.defaultValue??(c.value?[]:void 0),passive:n.modelValue===void 0,deep:!0}),S=wt(n,"open",s,{defaultValue:n.defaultOpen,passive:n.open===void 0});async function T(ne){S.value=ne,G.value="",ne?(await De(),u.value?.highlightSelected(),w.value=!0,F.value?.focus()):(w.value=!1,setTimeout(()=>{!ne&&n.resetSearchTermOnBlur&&v.trigger()},1))}const v=jt(),w=z(!1),E=z(!1),F=z(),D=z(),A=M(()=>u.value?.highlightedElement??void 0),I=z(new Map),q=z(new Map),{contains:Y}=ys({sensitivity:"base"}),G=z(""),Z=M(ne=>{if(!G.value||n.ignoreFilter||E.value)return{count:I.value.size,items:ne?.items??new Map,groups:ne?.groups??new Set(q.value.keys())};let H=0;const W=new Map,re=new Set;for(const[ve,he]of I.value){const ee=Y(he,G.value);W.set(ve,ee?1:0),ee&&H++}for(const[ve,he]of q.value)for(const ee of he)if(W.get(ee)>0){re.add(ve);break}return{count:H,items:W,groups:re}}),ce=sn();return Re(()=>{ce?.exposed&&(ce.exposed.highlightItem=u.value?.highlightItem,ce.exposed.highlightFirstItem=u.value?.highlightFirstItem,ce.exposed.highlightSelected=u.value?.highlightSelected)}),l({filtered:Z,highlightedElement:A,highlightItem:u.value?.highlightItem,highlightFirstItem:u.value?.highlightFirstItem,highlightSelected:u.value?.highlightSelected}),jo({modelValue:$,multiple:c,disabled:g,open:S,onOpenChange:T,contentId:"",isUserInputted:w,isVirtual:E,inputElement:F,highlightedElement:A,onInputElementChange:ne=>F.value=ne,triggerElement:D,onTriggerElementChange:ne=>D.value=ne,parentElement:o,resetSearchTermOnSelect:f,onResetSearchTerm:v.on,allItems:I,allGroups:q,filterSearch:G,filterState:Z,ignoreFilter:h,openOnFocus:b,openOnClick:y,resetModelValueOnClear:x}),(ne,H)=>(r(),U(t(an),null,{default:B(()=>[p(t(ro),ze({ref_key:"primitiveElement",ref:u},ne.$attrs,{modelValue:t($),"onUpdate:modelValue":H[0]||(H[0]=W=>ts($)?$.value=W:null),style:{pointerEvents:t(S)?"auto":void 0},as:ne.as,"as-child":ne.asChild,dir:t(C),multiple:t(c),name:ne.name,required:ne.required,disabled:t(g),"highlight-on-hover":t(_),by:n.by,onHighlight:H[1]||(H[1]=W=>s("highlight",W))}),{default:B(()=>[ye(ne.$slots,"default",{open:t(S),modelValue:t($)})]),_:3},16,["modelValue","style","as","as-child","dir","multiple","name","required","disabled","highlight-on-hover","by"])]),_:3}))}}),Uo=No,Wo=ue({__name:"ComboboxAnchor",props:{reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(i){const{forwardRef:l}=Je();return(e,n)=>(r(),U(t(nn),{"as-child":"",reference:e.reference},{default:B(()=>[p(t(He),ze({ref:t(l),"as-child":e.asChild,as:e.as},e.$attrs),{default:B(()=>[ye(e.$slots,"default")]),_:3},16,["as-child","as"])]),_:3},8,["reference"]))}}),Ho=Wo;const[Ko,Yo]=ct("ComboboxContent");var Go=ue({__name:"ComboboxContentImpl",props:{position:{type:String,required:!1,default:"inline"},bodyLock:{type:Boolean,required:!1},hideWhenEmpty:{type:Boolean,required:!1},side:{type:null,required:!1},sideOffset:{type:Number,required:!1},sideFlip:{type:Boolean,required:!1},align:{type:null,required:!1},alignOffset:{type:Number,required:!1},alignFlip:{type:Boolean,required:!1},avoidCollisions:{type:Boolean,required:!1},collisionBoundary:{type:null,required:!1},collisionPadding:{type:[Number,Object],required:!1},arrowPadding:{type:Number,required:!1},hideShiftedArrow:{type:Boolean,required:!1},sticky:{type:String,required:!1},hideWhenDetached:{type:Boolean,required:!1},positionStrategy:{type:String,required:!1},updatePositionStrategy:{type:String,required:!1},disableUpdateOnLayoutShift:{type:Boolean,required:!1},prioritizePosition:{type:Boolean,required:!1},reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},disableOutsidePointerEvents:{type:Boolean,required:!1}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside"],setup(i,{emit:l}){const e=i,n=l,{position:s}=Dt(e),u=at(),o=M(()=>u.ignoreFilter.value?u.allItems.value.size===0:u.filterState.value.count===0),{forwardRef:c,currentElement:g}=Je();on(e.bodyLock),ln(),rn(u.parentElement);const h=M(()=>e.position==="popper"?e:{}),f=un(h.value),b={boxSizing:"border-box","--reka-combobox-content-transform-origin":"var(--reka-popper-transform-origin)","--reka-combobox-content-available-width":"var(--reka-popper-available-width)","--reka-combobox-content-available-height":"var(--reka-popper-available-height)","--reka-combobox-trigger-width":"var(--reka-popper-anchor-width)","--reka-combobox-trigger-height":"var(--reka-popper-anchor-height)"};Yo({position:s});const y=z(!1);Re(()=>{u.inputElement.value&&(y.value=g.value.contains(u.inputElement.value),y.value&&u.inputElement.value.focus())}),tt(()=>{const x=Za();y.value&&(!x||x===document.body)&&u.triggerElement.value?.focus()});function k(x){if(u.parentElement.value?.contains(x))return!0;const C=(x instanceof Element?x.closest("label"):null)?.control;return!!C&&!!u.parentElement.value?.contains(C)}return(x,_)=>(r(),U(t(uo),{"as-child":""},{default:B(()=>[p(t(as),{"as-child":"",onMountAutoFocus:_[5]||(_[5]=Oe(()=>{},["prevent"])),onUnmountAutoFocus:_[6]||(_[6]=Oe(()=>{},["prevent"]))},{default:B(()=>[p(t(cn),{"as-child":"","disable-outside-pointer-events":x.disableOutsidePointerEvents,onDismiss:_[0]||(_[0]=C=>t(u).onOpenChange(!1)),onFocusOutside:_[1]||(_[1]=C=>{k(C.target)&&C.preventDefault(),n("focusOutside",C)}),onInteractOutside:_[2]||(_[2]=C=>n("interactOutside",C)),onEscapeKeyDown:_[3]||(_[3]=C=>n("escapeKeyDown",C)),onPointerDownOutside:_[4]||(_[4]=C=>{k(C.target)&&C.preventDefault(),n("pointerDownOutside",C)})},{default:B(()=>[(r(),U(es(t(s)==="popper"?t(dn):t(He)),ze({...x.$attrs,...t(f)},{id:t(u).contentId,ref:t(c),"data-state":t(u).open.value?"open":"closed","data-empty":o.value?"":void 0,style:{display:e.hideWhenEmpty&&o.value?"none":"flex",flexDirection:"column",outline:"none",...t(s)==="popper"?b:{}}}),{default:B(()=>[ye(x.$slots,"default")]),_:3},16,["id","data-state","data-empty","style"]))]),_:3},8,["disable-outside-pointer-events"])]),_:3})]),_:3}))}}),Qo=Go,Jo=ue({__name:"ComboboxArrow",props:{width:{type:Number,required:!1,default:10},height:{type:Number,required:!1,default:5},rounded:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"svg"}},setup(i){const l=i,e=at(),n=Ko();return Je(),(s,u)=>t(e).open.value&&t(n).position.value==="popper"?(r(),U(t(mn),ht(ze({key:0},l)),{default:B(()=>[ye(s.$slots,"default")]),_:3},16)):R("v-if",!0)}}),Xo=Jo,Zo=ue({__name:"ComboboxCancel",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(i){const l=i;Je();const e=at();function n(){e.filterSearch.value="",e.inputElement.value&&(e.inputElement.value.value="",e.inputElement.value.focus()),e.resetModelValueOnClear?.value&&(e.modelValue.value=e.multiple.value?[]:null)}return(s,u)=>(r(),U(t(He),ze({type:s.as==="button"?"button":void 0},l,{tabindex:"-1",onClick:n}),{default:B(()=>[ye(s.$slots,"default")]),_:3},16,["type"]))}}),el=Zo,tl=ue({__name:"ComboboxContent",props:{forceMount:{type:Boolean,required:!1},position:{type:String,required:!1},bodyLock:{type:Boolean,required:!1},hideWhenEmpty:{type:Boolean,required:!1},side:{type:null,required:!1},sideOffset:{type:Number,required:!1},sideFlip:{type:Boolean,required:!1},align:{type:null,required:!1},alignOffset:{type:Number,required:!1},alignFlip:{type:Boolean,required:!1},avoidCollisions:{type:Boolean,required:!1},collisionBoundary:{type:null,required:!1},collisionPadding:{type:[Number,Object],required:!1},arrowPadding:{type:Number,required:!1},hideShiftedArrow:{type:Boolean,required:!1},sticky:{type:String,required:!1},hideWhenDetached:{type:Boolean,required:!1},positionStrategy:{type:String,required:!1},updatePositionStrategy:{type:String,required:!1},disableUpdateOnLayoutShift:{type:Boolean,required:!1},prioritizePosition:{type:Boolean,required:!1},reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},disableOutsidePointerEvents:{type:Boolean,required:!1}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside"],setup(i,{emit:l}){const s=gn(i,l),{forwardRef:u}=Je(),o=at();return o.contentId||=xt(void 0,"reka-combobox-content"),(c,g)=>(r(),U(t(pn),{present:c.forceMount||t(o).open.value},{default:B(()=>[p(Qo,ze({...t(s),...c.$attrs},{ref:t(u)}),{default:B(()=>[ye(c.$slots,"default")]),_:3},16)]),_:3},8,["present"]))}}),al=tl,sl=ue({__name:"ComboboxEmpty",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(i){const l=i,e=at(),n=M(()=>e.ignoreFilter.value?e.allItems.value.size===0:e.filterState.value.count===0);return(s,u)=>n.value?(r(),U(t(He),ht(ze({key:0},l)),{default:B(()=>[ye(s.$slots,"default",{},()=>[u[0]||(u[0]=le("No options"))])]),_:3},16)):R("v-if",!0)}}),nl=sl;const[bs,ol]=ct("ComboboxGroup");var ll=ue({__name:"ComboboxGroup",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(i){const l=i,e=xt(void 0,"reka-combobox-group"),n=at(),s=M(()=>n.ignoreFilter.value?!0:n.filterSearch.value?n.filterState.value.groups.has(e):!0),u=ol({id:e,labelId:""});return Re(()=>{n.allGroups.value.has(e)||n.allGroups.value.set(e,new Set)}),tt(()=>{n.allGroups.value.delete(e)}),(o,c)=>(r(),U(t(ho),ze({id:t(e),"aria-labelledby":t(u).labelId},l,{hidden:s.value?void 0:!0}),{default:B(()=>[ye(o.$slots,"default")]),_:3},16,["id","aria-labelledby","hidden"]))}}),ra=ll,rl=ue({__name:"ComboboxInput",props:{displayValue:{type:Function,required:!1},modelValue:{type:String,required:!1},autoFocus:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"input"}},emits:["update:modelValue"],setup(i,{emit:l}){const e=i,n=l,s=at(),u=Rt(),{primitiveElement:o,currentElement:c}=Et(),g=wt(e,"modelValue",n,{passive:e.modelValue===void 0});Re(()=>{c.value&&s.onInputElementChange(c.value)});const{isComposing:h,handleCompositionStart:f,handleCompositionEnd:b}=ba(T=>{const v=T.target;v&&k(v.value)});function y(T){h.value||(T.preventDefault(),s.open.value||s.onOpenChange(!0))}function k(T){s.open.value?s.filterSearch.value=T:(s.onOpenChange(!0),De(()=>{T&&(s.filterSearch.value=T,u.highlightFirstItem())}))}function x(T){h.value||k(T.target.value)}function _(){s.openOnFocus.value&&!s.open.value&&s.onOpenChange(!0)}function C(T){if(!s.open.value)return;const v=T.relatedTarget;if(!v)return;const w=s.parentElement.value?.contains(v),E=document.getElementById(s.contentId)?.contains(v);!w&&!E&&requestAnimationFrame(()=>{if(!s.open.value)return;const F=document.activeElement;!s.parentElement.value?.contains(F)&&!document.getElementById(s.contentId)?.contains(F)&&s.onOpenChange(!1)})}function $(){s.openOnClick.value&&!s.open.value&&s.onOpenChange(!0)}function S(){const T=s.modelValue.value;e.displayValue?g.value=e.displayValue(T):!s.multiple.value&&T&&!Array.isArray(T)&&typeof T!="object"?g.value=T.toString():g.value="",De(()=>{g.value=g.value})}return s.onResetSearchTerm(()=>{S()}),fe(s.modelValue,async()=>{!s.isUserInputted.value&&s.resetSearchTermOnSelect.value&&S()},{immediate:!0,deep:!0}),fe(s.filterState,(T,v)=>{!s.isVirtual.value&&v.count===0&&u.highlightFirstItem()}),(T,v)=>(r(),U(t(mo),{ref_key:"primitiveElement",ref:o,modelValue:t(g),"onUpdate:modelValue":v[0]||(v[0]=w=>ts(g)?g.value=w:null),as:T.as,"as-child":T.asChild,"auto-focus":T.autoFocus,disabled:T.disabled,"aria-expanded":t(s).open.value,"aria-controls":t(s).contentId,"aria-autocomplete":"list",role:"combobox",autocomplete:"off",onClick:$,onInput:x,onKeydown:Ge(y,["down","up"]),onFocus:_,onBlur:C,onCompositionstart:t(f),onCompositionend:t(b)},{default:B(()=>[ye(T.$slots,"default")]),_:3},8,["modelValue","as","as-child","auto-focus","disabled","aria-expanded","aria-controls","onCompositionstart","onCompositionend"]))}}),il=rl,ul=ue({__name:"ComboboxItem",props:{textValue:{type:String,required:!1},value:{type:null,required:!0},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["select"],setup(i,{emit:l}){const e=i,n=l,s=xt(void 0,"reka-combobox-item"),u=at(),o=bs(null),{primitiveElement:c,currentElement:g}=Et();if(e.value==="")throw new Error("A <ComboboxItem /> must have a value prop that is not an empty string. This is because the Combobox value can be set to an empty string to clear the selection and show the placeholder.");const h=M(()=>{if(u.isVirtual.value||u.ignoreFilter.value||!u.filterSearch.value)return!0;{const f=u.filterState.value.items.get(s);return f===void 0?!0:f>0}});return Re(()=>{u.allItems.value.set(s,e.textValue||g.value.textContent||g.value.innerText);const f=o?.id;f&&(u.allGroups.value.has(f)?u.allGroups.value.get(f)?.add(s):u.allGroups.value.set(f,new Set([s])))}),tt(()=>{u.allItems.value.delete(s)}),(f,b)=>h.value?(r(),U(t(bo),ze({key:0},e,{id:t(s),ref_key:"primitiveElement",ref:c,disabled:t(u).disabled.value||f.disabled,onSelect:b[0]||(b[0]=y=>{n("select",y),!y.defaultPrevented&&(!t(u).multiple.value&&!f.disabled&&!t(u).disabled.value?(y.preventDefault(),t(u).onOpenChange(!1),t(u).modelValue.value=e.value):t(u).multiple.value&&t(u).inputElement.value?.focus())})}),{default:B(()=>[ye(f.$slots,"default",{},()=>[le(d(f.value),1)])]),_:3},16,["id","disabled"])):R("v-if",!0)}}),Ha=ul,cl=ue({__name:"ComboboxItemIndicator",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(i){const l=i;return(e,n)=>(r(),U(t(_o),ht(zt(l)),{default:B(()=>[ye(e.$slots,"default")]),_:3},16))}}),dl=cl,ml=ue({__name:"ComboboxLabel",props:{for:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"div"}},setup(i){const l=i;Je();const e=bs({id:"",labelId:""});return e.labelId||=xt(void 0,"reka-combobox-group-label"),(n,s)=>(r(),U(t(He),ze(l,{id:t(e).labelId}),{default:B(()=>[ye(n.$slots,"default")]),_:3},16,["id"]))}}),gl=ml,pl=ue({__name:"ComboboxPortal",props:{to:{type:null,required:!1},disabled:{type:Boolean,required:!1},defer:{type:Boolean,required:!1},forceMount:{type:Boolean,required:!1}},setup(i){const l=i;return(e,n)=>(r(),U(t(hn),ht(zt(l)),{default:B(()=>[ye(e.$slots,"default")]),_:3},16))}}),hl=pl,fl=ue({__name:"ComboboxSeparator",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(i){const l=i;return Je(),(e,n)=>(r(),U(t(He),ze(l,{"aria-hidden":"true"}),{default:B(()=>[ye(e.$slots,"default")]),_:3},16))}}),vl=fl,yl=ue({__name:"ComboboxTrigger",props:{disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(i){const l=i,{forwardRef:e,currentElement:n}=Je(),s=at(),u=M(()=>l.disabled||s.disabled.value||!1);return Re(()=>{n.value&&s.onTriggerElementChange(n.value)}),(o,c)=>(r(),U(t(He),ze(l,{ref:t(e),type:o.as==="button"?"button":void 0,tabindex:"-1","aria-label":"Show popup","aria-haspopup":"listbox","aria-expanded":t(s).open.value,"aria-controls":t(s).contentId,"data-state":t(s).open.value?"open":"closed",disabled:u.value,"data-disabled":u.value?"":void 0,"aria-disabled":u.value??void 0,onClick:c[0]||(c[0]=g=>t(s).onOpenChange(!t(s).open.value))}),{default:B(()=>[ye(o.$slots,"default")]),_:3},16,["type","aria-expanded","aria-controls","data-state","disabled","data-disabled","aria-disabled"]))}}),xl=yl,bl=ue({__name:"ComboboxVirtualizer",props:{options:{type:Array,required:!0},overscan:{type:Number,required:!1},estimateSize:{type:[Number,Function],required:!1},textContent:{type:Function,required:!1}},setup(i){const l=i,e=at();return e.isVirtual.value=!0,(n,s)=>(r(),U(Po,ht(zt(l)),{default:B(u=>[ye(n.$slots,"default",ht(zt(u)))]),_:3},16))}}),kl=bl;const[qa,_l]=ct("TagsInputRoot");var wl=ue({__name:"TagsInputRoot",props:{modelValue:{type:[Array,null],required:!1},defaultValue:{type:Array,required:!1,default:()=>[]},addOnPaste:{type:Boolean,required:!1},addOnTab:{type:Boolean,required:!1},addOnBlur:{type:Boolean,required:!1},duplicate:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},delimiter:{type:null,required:!1,default:","},dir:{type:String,required:!1},max:{type:Number,required:!1,default:0},id:{type:String,required:!1},convertValue:{type:Function,required:!1},displayValue:{type:Function,required:!1,default:i=>i.toString()},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue","invalid","addTag","removeTag"],setup(i,{emit:l}){const e=i,n=l,{addOnPaste:s,disabled:u,delimiter:o,max:c,id:g,dir:h,addOnBlur:f,addOnTab:b}=Dt(e),y=xa(h),k=wt(e,"modelValue",n,{defaultValue:e.defaultValue,passive:!0,deep:!0}),{forwardRef:x,currentElement:_}=Je(),{focused:C}=fn(_),$=Ja(_),{getItems:S,CollectionSlot:T}=Ct({isProvider:!0}),v=z(),w=z(!1),E=M(()=>Array.isArray(k.value)?[...k.value]:[]);function F(D){if(D!==-1){const A=S().filter(I=>I.ref.dataset.disabled!=="");k.value=k.value.filter((I,q)=>q!==D),n("removeTag",A[D].value)}}return _l({modelValue:k,onAddValue:D=>{const A=[...E.value],I=A.length>0&&typeof A[0]=="object",q=A.length>0&&typeof e.defaultValue[0]=="object";if((I||q)&&typeof e.convertValue!="function")throw new Error("You must provide a `convertValue` function when using objects as values.");const Y=e.convertValue?e.convertValue(D):D;if(A.length>=c.value&&c.value)return n("invalid",Y),!1;if(e.duplicate)return k.value=[...A,Y],n("addTag",Y),!0;if(A.includes(Y))w.value=!0;else return k.value=[...A,Y],n("addTag",Y),!0;return n("invalid",Y),!1},onRemoveValue:F,onInputKeydown:D=>{if(D.isComposing)return;const A=D.target,I=S().map(Y=>Y.ref).filter(Y=>Y.dataset.disabled!=="");if(!I.length)return;const q=I.at(-1);switch(D.key){case"Delete":case"Backspace":{if(A.selectionStart!==0||A.selectionEnd!==0)break;if(v.value){const Y=I.findIndex(G=>G===v.value);F(Y),v.value=v.value===q?I.at(Y-1):I.at(Y+1),D.preventDefault()}else D.key==="Backspace"&&(v.value=q,D.preventDefault());break}case"Home":case"End":case"ArrowRight":case"ArrowLeft":{const Y=D.key==="ArrowRight"&&y.value==="ltr"||D.key==="ArrowLeft"&&y.value==="rtl",G=!Y;if(A.selectionStart!==0||A.selectionEnd!==0)break;if(G&&!v.value)v.value=q,D.preventDefault();else if(Y&&q&&v.value===q)v.value=void 0,D.preventDefault();else if(v.value){const Z=vn(D,v.value,void 0,{itemsArray:I,loop:!1,dir:y.value});Z&&(v.value=Z),D.preventDefault()}break}case"ArrowUp":case"ArrowDown":{v.value&&D.preventDefault();break}default:v.value=void 0}},selectedElement:v,isInvalidInput:w,addOnPaste:s,addOnBlur:f,addOnTab:b,dir:y,disabled:u,delimiter:o,max:c,id:g,displayValue:e.displayValue}),(D,A)=>(r(),U(t(T),null,{default:B(()=>[p(t(He),{ref:t(x),dir:t(y),as:D.as,"as-child":D.asChild,"data-invalid":w.value?"":void 0,"data-disabled":t(u)?"":void 0,"data-focused":t(C)?"":void 0},{default:B(()=>[ye(D.$slots,"default",{modelValue:t(k)}),t($)&&D.name?(r(),U(t(Qa),{key:0,name:D.name,value:t(k),required:D.required,disabled:t(u)},null,8,["name","value","required","disabled"])):R("v-if",!0)]),_:3},8,["dir","as","as-child","data-invalid","data-disabled","data-focused"])]),_:3}))}}),$l=wl,Cl=ue({__name:"TagsInputInput",props:{placeholder:{type:String,required:!1},autoFocus:{type:Boolean,required:!1},maxLength:{type:Number,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"input"}},setup(i){const l=i,e=qa(),{forwardRef:n,currentElement:s}=Je();function u(x){if(e.selectedElement.value=void 0,!e.addOnBlur.value)return;const _=x.target,C=x.relatedTarget,$=_.getAttribute("aria-controls");if($&&C?.closest(`#${CSS.escape($)}`)||!_.value)return;e.onAddValue(_.value)&&(_.value="")}function o(x){e.addOnTab.value&&f(x)}const{isComposing:c,handleCompositionStart:g,handleCompositionEnd:h}=ba();async function f(x){if(c.value||(await De(),x.defaultPrevented))return;const _=x.target;if(!_.value)return;e.onAddValue(_.value)&&(_.value=""),x.preventDefault()}function b(x){if(c.value||(e.isInvalidInput.value=!1,x.data===null))return;const _=e.delimiter.value;if(_===x.data||_ instanceof RegExp&&_.test(x.data)){const $=x.target;if($.value=$.value.replace(_,""),$.value.trim()===""){$.value="";return}e.onAddValue($.value)&&($.value="")}}function y(x){c.value||e.onInputKeydown(x)}function k(x){if(e.addOnPaste.value){x.preventDefault();const _=x.clipboardData;if(!_)return;const C=_.getData("text");e.delimiter.value?C.split(e.delimiter.value).forEach(S=>{e.onAddValue(S)}):e.onAddValue(C)}}return Re(()=>{const x=s.value.nodeName==="INPUT"?s.value:s.value.querySelector("input");x&&setTimeout(()=>{l.autoFocus&&x?.focus()},1)}),(x,_)=>(r(),U(t(He),{id:t(e).id?.value,ref:t(n),type:"text",autocomplete:"off",autocorrect:"off",autocapitalize:"off",as:x.as,"as-child":x.asChild,maxlength:x.maxLength,placeholder:x.placeholder,disabled:t(e).disabled.value,"data-invalid":t(e).isInvalidInput.value?"":void 0,onInput:b,onKeydown:[Ge(f,["enter"]),Ge(o,["tab"]),y],onBlur:u,onCompositionstart:t(g),onCompositionend:t(h),onPaste:k},{default:B(()=>[ye(x.$slots,"default")]),_:3},8,["id","as","as-child","maxlength","placeholder","disabled","data-invalid","onCompositionstart","onCompositionend"]))}}),Sl=Cl;const[ks,Il]=ct("TagsInputItem");var Tl=ue({__name:"TagsInputItem",props:{value:{type:null,required:!0},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(i){const l=i,{value:e}=Dt(l),n=qa(),{forwardRef:s,currentElement:u}=Je(),{CollectionItem:o}=Ct(),c=M(()=>n.selectedElement.value===u.value),g=M(()=>l.disabled||n.disabled.value),h=Il({value:e,isSelected:c,disabled:g,textId:"",displayValue:M(()=>n.displayValue(e.value))});return(f,b)=>(r(),U(t(o),{value:t(e)},{default:B(()=>[p(t(He),{ref:t(s),as:f.as,"as-child":f.asChild,"aria-labelledby":t(h).textId,"aria-current":c.value,"data-disabled":g.value?"":void 0,"data-state":c.value?"active":"inactive"},{default:B(()=>[ye(f.$slots,"default")]),_:3},8,["as","as-child","aria-labelledby","aria-current","data-disabled","data-state"])]),_:3},8,["value"]))}}),Ml=Tl,Al=ue({__name:"TagsInputItemDelete",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(i){const l=i;Je();const e=qa(),n=ks(),s=M(()=>n.disabled?.value||e.disabled.value);function u(){if(s.value)return;const o=e.modelValue.value.findIndex(c=>Ut(c,n.value.value));e.onRemoveValue(o)}return(o,c)=>(r(),U(t(He),ze({tabindex:"-1"},l,{"aria-labelledby":t(n).textId,"aria-current":t(n).isSelected.value,"data-state":t(n).isSelected.value?"active":"inactive","data-disabled":s.value?"":void 0,type:o.as==="button"?"button":void 0,onClick:u}),{default:B(()=>[ye(o.$slots,"default")]),_:3},16,["aria-labelledby","aria-current","data-state","data-disabled","type"]))}}),zl=Al,ql=ue({__name:"TagsInputItemText",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(i){const l=i,e=ks();return Je(),e.textId||=xt(void 0,"reka-tags-input-item-text"),(n,s)=>(r(),U(t(He),ze(l,{id:t(e).textId}),{default:B(()=>[ye(n.$slots,"default",{},()=>[le(d(t(e).displayValue.value),1)])]),_:3},16,["id"]))}}),Ll=ql;const Dl={none:[],qwen:["default","off","high"],deepseek_v4:["default","off","high","xhigh"],deepseek_hybrid:["default","off","auto"],o_series:["default","low","medium","high"],gpt5:["default","minimal","low","medium","high"],gpt5_1:["default","off","low","medium","high"],gpt5_2plus:["default","off","minimal","low","medium","high","xhigh"],grok:["default","low","high"],kimi:["default","off","auto","low","medium","high"],doubao:["default","off","auto","high"],hunyuan:["default","off","high"],gemini:["default","off","low","medium","high"],default:["default","off","low","medium","high"]},Ka=/^(?!.*-non-reasoning\b)(o\d+(?:-[\w-]+)?|.*\b(?:reasoning|reasoner|thinking|think)\b.*|.*-[rR]\d+.*|.*\bqwq(?:-[\w-]+)?\b.*|.*\bhunyuan-t1(?:-[\w-]+)?\b.*|.*\bgrok-(?:3-mini|4|4-fast|build)(?:-[\w-]+)?\b.*)$/i;function El(i,l){const e=l.toLowerCase(),n=i.toLowerCase();if(e.includes("-non-reasoning")||n==="anthropic")return"none";if(n==="gemini")return/gemini-(?:2\.5|3(?:\.\d+)?-(?:flash|pro)|flash-latest|pro-latest)/i.test(e)?"gemini":"none";if(n==="qwen"||/\bqwen|qwq/i.test(e))return"qwen";if(/deepseek[_-]v([4-9]|\d{2,})/i.test(e)||/deepseek-ai\/deepseek-r1/i.test(e))return"deepseek_v4";if(/deepseek[_-]chat|deepseek[_-]v3/i.test(e))return"deepseek_hybrid";if(n==="openai"||n==="openai-compatible"){if(/gpt-5\.[2-9]|gpt-5\.[1-9]\d/.test(e))return"gpt5_2plus";if(/gpt-5\.1/.test(e))return"gpt5_1";if(/gpt-5/.test(e))return"gpt5";if(/^o\d/.test(e))return"o_series"}return/^o\d/.test(e)?"o_series":/\bgrok-(?:3-mini|4|4-fast|build)\b/i.test(e)?"grok":/\bkimi-k(?:2-thinking|2\.[5-9]|[3-9])/i.test(e)||n==="kimi"&&/thinking/i.test(e)?"kimi":/\bdoubao-.*seed/i.test(e)||n==="doubao"&&/seed/i.test(e)?"doubao":/\bhunyuan-(?:t1|a13b)/i.test(e)?"hunyuan":n==="glm"||/\bglm-?(?:5|4\.[5-7]|z1|zero)/i.test(e)?"qwen":n==="siliconflow"&&/r[1-9]/i.test(e)?"deepseek_v4":n==="openrouter"?/deepseek.*(v[4-9]|r\d)/i.test(e)?"deepseek_v4":/deepseek[_-]?(chat|v3)/i.test(e)?"deepseek_hybrid":/\bgrok-(?:3-mini|4|4-fast|build)\b/i.test(e)?"grok":/\bkimi-k(?:2-thinking|2\.[5-9]|[3-9])/i.test(e)?"kimi":Ka.test(e)?"default":"none":/\bmimo-v2/i.test(e)||/\bminimax-m[123]/i.test(e)||/\bseed-oss/i.test(e)?"deepseek_hybrid":/\bbaichuan-m[23]/i.test(e)||/\bmagistral/i.test(e)||/\bmistral-small-2603/i.test(e)||/\bstep-(?:3|r1-v-mini)/i.test(e)||/\bgemma-?4/i.test(e)||/\bpangu-pro-moe/i.test(e)||/\bsonar-deep-research/i.test(e)||/\bring-(?:1t|mini|flash)/i.test(e)?"default":/\bqwen|qwq/i.test(e)?"qwen":/deepseek[_-]?r\d|deepseek[_-]?v[4-9]/i.test(e)?"deepseek_v4":/^o\d/i.test(e)?"o_series":Ka.test(e)?"default":"none"}function Bl(i,l){const e=El(i,l);return Dl[e]}function Fl(){const{contains:i,startsWith:l}=ys({sensitivity:"base"});function e(o,c){return i(o,c)?i(c,o)?0:l(o,c)?1:2:null}function n(o,c,g){if(typeof o!="object"||o===null)return e(String(o),c);let h=null;for(const f of g){const b=lt(o,f);if(b==null)continue;const y=Array.isArray(b)?b.map(String):[String(b)];for(const k of y){const x=e(k,c);if(x!==null&&(h===null||x<h)&&(h=x),h===0)return 0}}return h}function s(o,c,g){if(!c)return o;const h=[];for(const f of o){const b=n(f,c,g);b!==null&&h.push({item:f,score:b})}return h.sort((f,b)=>f.score-b.score),h.map(({item:f})=>f)}function u(o,c,g){return c?o.map(h=>{const f=[];for(const b of h){if(b==null)continue;if(g.isStructural?.(b)){f.push({item:b,score:-1});continue}const y=n(b,c,g.fields);y!==null&&f.push({item:b,score:y})}return f.sort((b,y)=>b.score-y.score),f.map(({item:b})=>b)}).filter(h=>h.some(f=>!g.isStructural?.(f))):o}return{score:e,scoreItem:n,filter:s,filterGroups:u}}function Rl(i,l,e,n="group",s="zh-CN"){const u=yn(),{chatKey:o,state:c}=u.ensureSessionState({sessionId:i,sessionName:l,timeFilter:e,chatType:n,locale:s});return u.resetToSelectorOnEnter(o),u.applySessionAssistantSelection(o),{messages:We(c,"messages"),sourceMessages:We(c,"sourceMessages"),currentKeywords:We(c,"currentKeywords"),isLoadingSource:We(c,"isLoadingSource"),isAIThinking:We(c,"isAIThinking"),currentAIChatId:We(c,"currentAIChatId"),currentToolStatus:We(c,"currentToolStatus"),toolsUsedInCurrentRound:We(c,"toolsUsedInCurrentRound"),sessionTokenUsage:We(c,"sessionTokenUsage"),agentStatus:We(c,"agentStatus"),selectedAssistantId:We(c,"selectedAssistantId"),sendMessage:(g,h)=>u.sendMessage(o,g,h),editMessageAndRegenerate:(g,h,f)=>u.editMessageAndRegenerate(o,g,h,f),loadAIChat:g=>u.loadAIChat(o,g),startNewAIChat:g=>u.startNewAIChat(o,g),loadMoreSourceMessages:()=>u.loadMoreSourceMessages(),updateMaxMessages:()=>u.updateMaxMessages(),stopGeneration:()=>u.stopGeneration(o),selectAssistantForSession:g=>u.selectAssistantForSession(o,g)}}const ia=new Map;function Vl(i,l,e){const{activeTab:n,isInitialLoad:s,currentSessionId:u,onTimeRangeChange:o}=e,c=z(null),g=z(null),h=z([]),f=M(()=>{const x=c.value;if(x)return{startTs:x.startTs,endTs:x.endTs}}),b=M(()=>{const x=c.value;return x?`${x.startTs}-${x.endTs}`:"init"}),y=M(()=>{const x=i.query,_=x.timeMode;return _?{mode:_,recentDays:x.timeDays?Number(x.timeDays):void 0,year:x.timeYear?Number(x.timeYear):void 0,quarterYear:x.timeYear?Number(x.timeYear):void 0,quarter:x.timeQuarter?Number(x.timeQuarter):void 0,customStart:x.timeStart||void 0,customEnd:x.timeEnd||void 0}:u.value&&ia.has(u.value)?ia.get(u.value):{mode:"recent",recentDays:365}});fe([n,c],([x,_])=>{if(s.value||!_)return;const C=_.state,$={tab:x,timeMode:C.mode,timeDays:void 0,timeYear:void 0,timeQuarter:void 0,timeStart:void 0,timeEnd:void 0};C.mode==="recent"&&($.timeDays=C.recentDays),C.mode==="year"&&($.timeYear=C.year),C.mode==="quarter"&&($.timeYear=C.quarterYear,$.timeQuarter=C.quarter),C.mode==="custom"&&($.timeStart=C.customStart,$.timeEnd=C.customEnd),l.replace({query:{...i.query,...$}})}),fe(c,x=>{!x||!u.value||(ss(),ia.set(u.value,x.state),o?.())},{immediate:!0});function k(){c.value=null,g.value=null,h.value=[]}return{timeRangeValue:c,fullTimeRange:g,availableYears:h,timeFilter:f,timeFilterKey:b,initialTimeState:y,resetTimeRange:k}}function Ol(i){return i.content.trim()?i.content:i.contentBlocks?.filter(e=>e.type==="text"&&!!e.text).map(e=>e.text).join("")??""}function ga(i){return i.flatMap(l=>{if(l.role!=="user"&&l.role!=="assistant")return[];const e=Ol(l);return e.trim()?[{role:l.role,content:e,timestamp:l.timestamp}]:[]})}function Pl(i){return ga(i).length>0}function jl(i,l,e,n){const s=[];s.push(`# ${i}`),s.push(""),s.push(`> ${n.createdAt}: ${Ee(e).format("YYYY-MM-DD HH:mm:ss")}`),s.push(""),s.push("---"),s.push("");for(const u of l){const o=Ee(u.timestamp).format("YYYY-MM-DD HH:mm:ss"),c=u.role==="user"?n.user:n.assistant;s.push(`### ${c}`),s.push(`*${o}*`),s.push(""),s.push(u.content),s.push(""),s.push("---"),s.push("")}return s.join(`
|
|
3
|
-
`)}function
|
|
4
|
-
`)}function
|
|
5
|
-
`)}function Kl(i){const l=i.rows.map(e=>{const n={};return i.columns.forEach((s,u)=>{n[s]=e[u]}),n});return JSON.stringify(l,null,2)}async function Yl(i,l){if(i.rows.length===0)return{success:!1,error:"No data to export"};const n=`sql_result_${Ee().format("YYYYMMDD_HHmmss")}.${l}`;let s,u;l==="json"?(s=Kl(i),u="application/json"):(s=Hl(i),u="text/csv");const o=`data:${u};charset=utf-8,${encodeURIComponent(s)}`,{useCacheService:c}=await Jt(async()=>{const{useCacheService:h}=await import("./index-YzfjPohq.js").then(f=>f.co);return{useCacheService:h}},__vite__mapDeps([0,1,2]));return await c().saveToDownloads(n,o)}function jw(i){const{route:l,router:e,currentSessionId:n,selectSession:s,defaultTab:u,validTabIds:o}=i,c=z(!0),g=z(!0),h=z(null),f=z([]),b=z([]),y=z([]),k=z([]);let x=0;function _(){const I=l.query.tab;return I&&o.includes(I)?I:u}const C=z(_()),{timeRangeValue:$,fullTimeRange:S,availableYears:T,timeFilter:v,initialTimeState:w}=Vl(l,e,{activeTab:C,isInitialLoad:g,currentSessionId:n,onTimeRangeChange:()=>D()});function E(){const I=l.params.id;I&&(s(I),n.value!==I&&e.replace("/"))}async function F(){if(n.value)try{const I=await Ke().getSession(n.value);h.value=I}catch(I){console.error("加载基础数据失败:",I)}}async function D(){const I=n.value;if(!I)return;const q=++x;c.value=!0;try{const Y=v.value,G=Ke(),[Z,ce,ne,H]=await Promise.all([G.getMemberActivity(I,Y),G.getHourlyActivity(I,Y),G.getDailyActivity(I,Y),G.getMessageTypeDistribution(I,Y)]);if(q!==x)return;f.value=Z,b.value=ce,y.value=ne,k.value=H}catch(Y){q===x&&console.error("加载分析数据失败:",Y)}finally{q===x&&(c.value=!1)}}async function A(){n.value&&(g.value=!0,await F(),g.value=!1)}return fe(()=>l.params.id,()=>{C.value=_(),E()}),fe(()=>l.query.tab,()=>{C.value=_()}),fe(n,()=>{x++,ss(),A()},{immediate:!0}),Re(()=>{E()}),{activeTab:C,isLoading:c,isInitialLoad:g,session:h,memberActivity:f,hourlyActivity:b,dailyActivity:y,messageTypes:k,timeRangeValue:$,fullTimeRange:S,availableYears:T,timeFilter:v,initialTimeState:w,syncSession:E,loadData:A,loadAnalysisData:D}}const Gl={class:"pointer-events-none absolute right-3 top-3 z-50 opacity-0 transition-opacity duration-200 group-hover/card:pointer-events-auto group-hover/card:opacity-100"},Ql=ue({__name:"CardCaptureOverlay",setup(i){return(l,e)=>(r(),m("div",Gl,[p(Lt,{type:"element","target-selector":"[data-capturable-card]",size:"xs"})]))}}),na=ue({__name:"ReportCard",props:{capturable:{type:Boolean,default:!0}},setup(i){return(l,e)=>(r(),U(mt,{"data-capturable-card":"",class:"group/card relative isolate flex flex-col"},{default:B(()=>[p(Qn),i.capturable?(r(),U(Ql,{key:0})):R("",!0),ye(l.$slots,"default")]),_:3}))}}),Jl={class:"flex items-center justify-between"},Xl={class:"font-semibold text-gray-900 dark:text-white whitespace-nowrap"},Zl={key:0,class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},er={class:"flex items-center gap-2"},tr={key:0,class:"pointer-events-none opacity-0 transition-opacity duration-200 group-hover/card:pointer-events-auto group-hover/card:opacity-100"},Ze=ue({__name:"SectionCard",props:{title:{},description:{},capturable:{type:Boolean,default:!0},showDivider:{type:Boolean,default:!0},scrollable:{type:Boolean,default:!1},maxHeightVh:{default:60}},setup(i){const l=i,e=M(()=>{if(l.scrollable)return{maxHeight:`${l.maxHeightVh}vh`,overflowY:"auto"}});return(n,s)=>(r(),U(mt,{class:"group/card","data-section-card":""},{default:B(()=>[a("div",{class:X(["px-5 py-3",{"border-b border-gray-200 dark:border-white/5":i.showDivider&&n.$slots.default}])},[a("div",Jl,[a("div",null,[a("p",Xl,d(i.title),1),i.description?(r(),m("p",Zl,d(i.description),1)):R("",!0)]),a("div",er,[ye(n.$slots,"headerRight"),i.capturable?(r(),m("div",tr,[p(Lt,{type:"element","target-selector":"[data-section-card]",size:"xs"})])):R("",!0)])])],2),i.scrollable?(r(),m("div",{key:0,style:et(e.value)},[ye(n.$slots,"default")],4)):ye(n.$slots,"default",{key:1}),ye(n.$slots,"footer")]),_:3}))}}),ar={class:"flex items-start justify-between"},sr={class:"min-w-0 flex-1"},nr={class:"text-sm font-medium text-gray-500 dark:text-gray-400"},or={key:1,class:"text-xl"},lr={key:0,class:"mt-4 flex items-center text-sm"},rr={class:"text-gray-500 dark:text-gray-400"},ot=ue({__name:"StatCard",props:{label:{},value:{},valueColor:{},subtext:{},icon:{},iconBg:{}},setup(i){const l={pink:"text-pink-600 dark:text-pink-400",amber:"text-amber-600 dark:text-amber-400",blue:"text-blue-600 dark:text-blue-400",green:"text-green-600 dark:text-green-400",red:"text-red-600 dark:text-red-400",gray:"text-gray-900 dark:text-white"},e={pink:"bg-pink-100 dark:bg-pink-500/10",amber:"bg-amber-100 dark:bg-amber-500/10",blue:"bg-blue-100 dark:bg-blue-500/10",green:"bg-green-100 dark:bg-green-500/10",red:"bg-red-100 dark:bg-red-500/10",gray:"bg-gray-100 dark:bg-white/5"};return(n,s)=>{const u=_e;return r(),U(mt,{class:"p-5"},{default:B(()=>[a("div",ar,[a("div",sr,[a("p",nr,d(i.label),1),a("p",{class:X(["mt-2 truncate text-2xl font-bold tracking-tight",i.valueColor?l[i.valueColor]:"text-gray-900 dark:text-white"])},d(i.value),3)]),i.icon?(r(),m("div",{key:0,class:X(["ml-4 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl",e[i.iconBg||"gray"]])},[i.icon.startsWith("i-")?(r(),U(u,{key:0,name:i.icon,class:"h-5 w-5"},null,8,["name"])):(r(),m("span",or,d(i.icon),1))],2)):R("",!0)]),i.subtext||n.$slots.subtext?(r(),m("div",lr,[ye(n.$slots,"subtext",{},()=>[a("span",rr,d(i.subtext),1)])])):R("",!0)]),_:3})}}}),ir={key:0,class:"mb-2 block text-2xl"},Nw=ue({__name:"EmptyState",props:{text:{},icon:{},padding:{}},setup(i){const l={sm:"px-4 py-4",md:"px-5 py-8",lg:"px-6 py-12"};return(e,n)=>(r(),m("div",{class:X(["text-center text-sm text-gray-400",l[i.padding||"md"]])},[i.icon?(r(),m("span",ir,d(i.icon),1)):R("",!0),le(" "+d(i.text||"暂无数据"),1)],2))}}),ur={"zh-CN":{message:"消息记录",member:"成员",meta:"群信息",member_name_history:"昵称历史"},"en-US":{message:"Messages",member:"Members",meta:"Chat Info",member_name_history:"Nickname History"}},pa={"zh-CN":{message:{id:"消息ID",sender_id:"发送者ID",sender_account_name:"发送时账号名",sender_group_nickname:"发送时群昵称",ts:"时间戳(秒)",type:"消息类型",content:"消息内容"},member:{id:"成员ID",platform_id:"平台ID",account_name:"账号名称",group_nickname:"群昵称",aliases:"自定义别名"},meta:{name:"群名称",platform:"平台",type:"聊天类型",imported_at:"导入时间"},member_name_history:{id:"记录ID",member_id:"成员ID",name_type:"名称类型",name:"昵称值",start_ts:"开始时间",end_ts:"结束时间"}},"en-US":{message:{id:"Message ID",sender_id:"Sender ID",sender_account_name:"Sender Account",sender_group_nickname:"Sender Nickname",ts:"Timestamp (sec)",type:"Message Type",content:"Content"},member:{id:"Member ID",platform_id:"Platform ID",account_name:"Account Name",group_nickname:"Group Nickname",aliases:"Custom Aliases"},meta:{name:"Chat Name",platform:"Platform",type:"Chat Type",imported_at:"Imported At"},member_name_history:{id:"Record ID",member_id:"Member ID",name_type:"Name Type",name:"Nickname",start_ts:"Start Time",end_ts:"End Time"}}};function ha(i,l="zh-CN"){return ur[_s(l)]?.[i]||i}function La(i,l,e="zh-CN"){return pa[_s(e)]?.[i]?.[l]||l}function _s(i){return i.startsWith("zh")?"zh-CN":"en-US"}const cr={key:0,class:"text-xs font-medium text-gray-500 dark:text-gray-400"},dr={key:0,class:"flex-1 overflow-y-auto p-2"},mr=["onClick"],gr={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},pr={class:"flex-1 truncate text-right text-xs text-gray-400"},hr={key:0,class:"ml-4 mt-1 space-y-0.5"},fr=["title","onDblclick"],vr={class:"font-mono text-gray-700 dark:text-gray-300"},yr={class:"flex-1 truncate text-right text-[10px] text-gray-400"},xr={key:1,class:"flex flex-1 flex-col items-center gap-1 overflow-y-auto px-2 pb-2"},br=["title","onClick"],kr=ue({__name:"SchemaPanel",props:{sessionId:{}},emits:["insertColumn"],setup(i,{expose:l,emit:e}){const{t:n,locale:s}=we(),u=i,o=e,c=z(!1),g=z([]),h=z(new Set);async function f(){try{g.value=await Ke().getSchema(u.sessionId),g.value.forEach(x=>h.value.add(x.name))}catch(x){console.error("加载 Schema 失败:",x)}}function b(x){h.value.has(x)?h.value.delete(x):h.value.add(x)}function y(x){c.value=!1,h.value.add(x)}function k(x,_){o("insertColumn",x,_)}return l({loadSchema:f,schema:g}),Re(()=>{f()}),(x,_)=>{const C=_e,$=Ue;return r(),m("div",{class:X(["m-3 flex h-[calc(100%-1.5rem)] shrink-0 flex-col overflow-hidden rounded-lg bg-white transition-all duration-300 ease-in-out dark:bg-sidebar-dark",c.value?"w-14":"w-56"])},[a("div",{class:X(["flex items-center",c.value?"justify-center px-2 pb-2 pt-5":"justify-between border-b border-gray-200 py-2 pl-3 pr-2 dark:border-gray-800"])},[c.value?R("",!0):(r(),m("span",cr,d(t(n)("ai.sqlLab.schema.tables")),1)),c.value?(r(),m("button",{key:2,type:"button",class:"group relative flex h-9 w-9 cursor-pointer items-center justify-center rounded-full hover:bg-gray-200/60 dark:hover:bg-white/[0.06]",onClick:_[1]||(_[1]=S=>c.value=!c.value)},[p(C,{name:"i-lucide-panel-right-open",class:"size-4 scale-x-[-1]"})])):(r(),U($,{key:1,color:"neutral",variant:"ghost",size:"sm",class:"group flex h-9 w-9 cursor-pointer items-center justify-center rounded-full hover:bg-gray-200/60 dark:hover:bg-white/[0.06]",onClick:_[0]||(_[0]=S=>c.value=!c.value)},{default:B(()=>[p(C,{name:"i-lucide-panel-right",class:"size-4 scale-x-[-1] group-hover:hidden"}),p(C,{name:"i-lucide-panel-right-close",class:"size-4 hidden scale-x-[-1] group-hover:block"})]),_:1}))],2),c.value?(r(),m("div",xr,[(r(!0),m(ie,null,pe(g.value,S=>(r(),m("button",{key:S.name,class:"flex h-10 w-10 items-center justify-center rounded-lg text-gray-600 transition-colors hover:bg-gray-200/40 hover:text-primary-600 dark:text-gray-300 dark:hover:bg-white/[0.06] dark:hover:text-primary-400",title:`${t(ha)(S.name,t(s))} (${S.name})`,onClick:T=>y(S.name)},[p(C,{name:"i-heroicons-table-cells",class:"h-5 w-5"})],8,br))),128))])):(r(),m("div",dr,[(r(!0),m(ie,null,pe(g.value,S=>(r(),m("div",{key:S.name,class:"mb-2"},[a("button",{class:"flex w-full items-center gap-1 rounded px-2 py-1.5 text-left transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",onClick:T=>b(S.name)},[p(C,{name:h.value.has(S.name)?"i-heroicons-chevron-down":"i-heroicons-chevron-right",class:"h-3 w-3 shrink-0 text-gray-400"},null,8,["name"]),p(C,{name:"i-heroicons-table-cells",class:"h-4 w-4 shrink-0 text-pink-500"}),a("span",gr,d(S.name),1),a("span",pr,d(t(ha)(S.name,t(s))),1)],8,mr),h.value.has(S.name)?(r(),m("div",hr,[(r(!0),m(ie,null,pe(S.columns,T=>(r(),m("button",{key:T.name,class:"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",title:t(n)("ai.sqlLab.schema.doubleClickToInsert"),onDblclick:v=>k(S.name,T.name)},[T.pk?(r(),U(C,{key:0,name:"i-heroicons-key",class:"h-3 w-3 shrink-0 text-yellow-500",title:t(n)("ai.sqlLab.schema.primaryKey")},null,8,["title"])):R("",!0),a("span",vr,d(T.name),1),a("span",yr,d(t(La)(S.name,T.name,t(s))),1)],40,fr))),128))])):R("",!0)]))),128))]))],2)}}}),_r={class:"max-h-[70vh] overflow-hidden p-6"},wr={class:"mb-4 flex items-center gap-2"},$r={class:"text-lg font-semibold text-gray-900 dark:text-white"},Cr={key:0,class:"max-h-[50vh] space-y-3 overflow-y-auto pr-2"},Sr={class:"mb-2 flex items-start justify-between gap-2"},Ir={class:"flex-1 text-sm font-medium text-gray-700 dark:text-gray-300"},Tr={class:"shrink-0 text-xs text-gray-400"},Mr={class:"mb-2 rounded bg-white p-2 dark:bg-gray-800"},Ar={class:"whitespace-pre-wrap break-all font-mono text-xs text-gray-600 dark:text-gray-400"},zr={key:0,class:"mb-2 text-xs text-gray-500 dark:text-gray-400"},qr={class:"flex justify-end gap-2"},Lr={key:1,class:"py-8 text-center text-gray-500 dark:text-gray-400"},Dr={class:"text-sm"},Er={class:"mt-4 flex justify-end"},Br=ue({__name:"AIHistoryModal",props:{open:{type:Boolean},history:{}},emits:["update:open","execute","delete"],setup(i,{emit:l}){const{t:e}=we(),n=l;function s(u){const o=new Date(u),c=new Date,g=c.getTime()-u;return g<6e4?e("ai.sqlLab.history.justNow"):g<36e5?e("ai.sqlLab.history.minutesAgo",{count:Math.floor(g/6e4)}):g<864e5?e("ai.sqlLab.history.hoursAgo",{count:Math.floor(g/36e5)}):o.toDateString()===c.toDateString()?e("ai.sqlLab.history.today"):`${o.getMonth()+1}/${o.getDate()}`}return(u,o)=>{const c=_e,g=Ue,h=Xe;return r(),U(h,{open:i.open,ui:{content:"max-w-5xl"},"onUpdate:open":o[1]||(o[1]=f=>n("update:open",f))},{content:B(()=>[a("div",_r,[a("div",wr,[p(c,{name:"i-heroicons-clock",class:"h-5 w-5 text-pink-500"}),a("h3",$r,d(t(e)("ai.sqlLab.history.title")),1)]),i.history.length>0?(r(),m("div",Cr,[(r(!0),m(ie,null,pe(i.history,f=>(r(),m("div",{key:f.id,class:"rounded-lg border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-page-dark"},[a("div",Sr,[a("p",Ir,d(f.prompt),1),a("span",Tr,d(s(f.timestamp)),1)]),a("div",Mr,[a("pre",Ar,d(f.sql),1)]),f.explanation?(r(),m("p",zr,d(f.explanation),1)):R("",!0),a("div",qr,[p(g,{variant:"ghost",size:"xs",color:"error",onClick:b=>n("delete",f.id)},{default:B(()=>[p(c,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"})]),_:1},8,["onClick"]),p(g,{size:"xs",onClick:b=>n("execute",f)},{default:B(()=>[p(c,{name:"i-heroicons-play",class:"mr-1 h-3.5 w-3.5"}),le(" "+d(t(e)("ai.sqlLab.history.execute")),1)]),_:1},8,["onClick"])])]))),128))])):(r(),m("div",Lr,[p(c,{name:"i-heroicons-clock",class:"mx-auto mb-2 h-8 w-8 text-gray-300 dark:text-gray-600"}),a("p",Dr,d(t(e)("ai.sqlLab.history.empty")),1)])),a("div",Er,[p(g,{variant:"ghost",onClick:o[0]||(o[0]=f=>n("update:open",!1))},{default:B(()=>[le(d(t(e)("common.close")),1)]),_:1})])])]),_:1},8,["open"])}}}),Fr={class:"flex flex-1 flex-col overflow-hidden"},Rr={key:0,class:"border-b border-red-200 bg-red-50 p-4 dark:border-red-900 dark:bg-red-950"},Vr={class:"flex items-start gap-2"},Or={class:"min-w-0 flex-1"},Pr={class:"text-sm font-medium text-red-800 dark:text-red-200"},jr={class:"mt-1 break-all font-mono text-xs text-red-600 dark:text-red-400"},Nr={key:1,class:"flex items-center justify-between border-b border-gray-200 bg-gray-50 px-4 py-2 dark:border-gray-800 dark:bg-page-dark"},Ur={class:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400"},Wr={class:"flex cursor-pointer items-center gap-1.5"},Hr={class:"text-xs"},Kr={class:"flex items-center gap-2"},Yr={key:2,class:"flex-1 overflow-auto"},Gr={class:"min-w-full divide-y divide-gray-200 dark:divide-gray-700"},Qr={class:"sticky top-0 bg-gray-100 dark:bg-page-dark"},Jr=["onClick"],Xr={class:"flex items-center gap-1"},Zr={class:"flex flex-col"},ei={class:"text-gray-700 dark:text-gray-300"},ti={key:0,class:"font-mono text-[10px] text-gray-400"},ai={key:0,class:"sticky right-0 w-12 bg-gray-100 px-2 py-2 dark:bg-page-dark"},si={class:"divide-y divide-gray-200 bg-white dark:divide-gray-700 dark:bg-page-dark"},ni=["title"],oi={key:0,class:"sticky right-0 w-12 bg-white px-2 py-2 dark:bg-page-dark"},li={key:3,class:"flex shrink-0 items-center gap-4 border-t border-gray-200 bg-gray-50 px-4 py-2 dark:border-gray-800 dark:bg-page-dark"},ri={class:"flex items-center gap-1"},ii={class:"mx-2 text-xs text-gray-600 dark:text-gray-400"},ui={class:"flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400"},ci={key:4,class:"flex flex-1 items-center justify-center text-gray-500 dark:text-gray-400"},di={class:"text-center"},mi={class:"mt-2 text-sm"},gi={key:5,class:"flex flex-1 items-center justify-center text-gray-500 dark:text-gray-400"},pi={class:"text-center"},hi={class:"mt-2 text-sm"},fi={class:"mt-1 text-xs text-gray-400"},vi={class:"max-h-[70vh] overflow-hidden p-6"},yi={class:"mb-4 flex items-center gap-2"},xi={class:"text-lg font-semibold text-gray-900 dark:text-white"},bi={key:0,class:"flex items-center justify-center py-8"},ki={class:"ml-2 text-sm text-gray-500"},_i={key:1,class:"max-h-[50vh] overflow-y-auto"},wi=["innerHTML"],$i={key:0,class:"mt-2 flex items-center text-xs text-gray-400"},Ci={key:2,class:"rounded-lg bg-red-50 p-4 dark:bg-red-950"},Si={class:"text-sm text-red-600 dark:text-red-400"},Ii={class:"mt-4 flex justify-end gap-2"},Ti=ue({__name:"ResultTable",props:{result:{},error:{},sql:{},prompt:{}},setup(i,{expose:l}){const{t:e,locale:n}=we(),s=nt(),u=ka(),o=bt(),{aiGlobalSettings:c}=ut(u),g=[/^ts$/i,/^timestamp$/i,/^time$/i,/_at$/i,/_ts$/i,/_time$/i,/^date$/i];function h(Q){return g.some(J=>J.test(Q))}function f(Q){if(typeof Q!="number"||!Number.isFinite(Q))return!1;const J=946684800,ge=4102444800,ke=J*1e3,$e=ge*1e3;return Q>=J&&Q<=ge||Q>=ke&&Q<=$e}function b(Q){const ge=Q>1e10?Q:Q*1e3;return Ee(ge).format("YYYY-MM-DD HH:mm:ss")}const y=[/^id$/i,/^message_id$/i,/^msg_id$/i,/^msgid$/i];function k(Q){return Q.findIndex(J=>y.some(ge=>ge.test(J)))}function x(Q){o.openChatRecordDrawer({scrollToMessageId:Q})}const _=new Aa({html:!1,breaks:!0,linkify:!0,typographer:!0}),C=i,$=z(null),S=z("asc"),T=z(1),v=z(100),w=[50,100,200,500],E=z(localStorage.getItem("sql-lab-readable-time")!=="false");function F(){E.value=!E.value,localStorage.setItem("sql-lab-readable-time",String(E.value))}const D=z(!1),A=z(!1),I=z(""),q=z(null),Y=z(""),G=z(!1);function Z(Q){const J=Q.split("."),ge=J.length>1?J[J.length-1]:Q,ke=pa[n.value]||pa["zh-CN"];for(const $e of Object.values(ke))if($e[ge])return $e[ge];return null}const ce=M(()=>{if(!C.result||!$.value)return C.result?.rows||[];const Q=C.result.columns.indexOf($.value);return Q===-1?C.result.rows:[...C.result.rows].sort((J,ge)=>{const ke=J[Q],$e=ge[Q];if(ke===null)return 1;if($e===null)return-1;if(typeof ke=="number"&&typeof $e=="number")return S.value==="asc"?ke-$e:$e-ke;const Le=String(ke).localeCompare(String($e));return S.value==="asc"?Le:-Le})}),ne=M(()=>C.result?Math.ceil(ce.value.length/v.value):0),H=M(()=>{const Q=(T.value-1)*v.value,J=Q+v.value;return ce.value.slice(Q,J)}),W=M(()=>C.result?k(C.result.columns):-1),re=M(()=>W.value!==-1);function ve(Q){$.value===Q?S.value=S.value==="asc"?"desc":"asc":($.value=Q,S.value="asc"),T.value=1}function he(Q){v.value=Q,T.value=1}function ee(Q,J){return Q===null?"NULL":typeof Q=="object"?JSON.stringify(Q):E.value&&J&&h(J)&&f(Q)?b(Q):String(Q)}async function te(){if(!(!C.result||G.value)){G.value=!0;try{const Q=c.value.sqlExportFormat??"csv",J=await Yl({columns:C.result.columns,rows:C.result.rows},Q);if(J.success&&J.filePath){const ge=J.filePath.split("/").pop()||J.filePath;s.add({title:e("common.exportSuccess"),description:ge,color:"primary",actions:[{label:e("common.openFolder"),onClick:()=>{ns().showInFolder(J.filePath)}}]})}else s.fail(e("common.exportFailed"),{description:J.error})}catch(Q){console.error("导出失败:",Q),s.fail(e("common.exportFailed"),{description:String(Q)})}finally{G.value=!1}}}function j(){$.value=null,S.value="asc",T.value=1}function de(){if(!C.result)return"";const Q=50,J=C.result.rows.slice(0,Q),ge=C.result.columns.join(" | "),ke=C.result.columns.map(()=>"---").join(" | "),$e=J.map(Be=>Be.map(Te=>Te===null?"NULL":String(Te).slice(0,50)).join(" | "));let Le=`| ${ge} |
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-D_0qeKKc.js","assets/vendor-snapdom--nZvo8Sg.js","assets/index-DrjoMv9s.css","assets/EChartWordcloud-CqknPGui.js","assets/vendor-echarts-wordcloud-Ca8n6qS6.js","assets/vendor-echarts-B-i_56Av.js","assets/vendor-zrender-5DcYjSZk.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{b0 as Ut,a as M,G as t,b1 as ct,d as ue,b2 as Dt,b3 as Ct,b4 as Ns,b5 as xa,b6 as wt,w as he,o as r,E as U,F as B,r as ye,b7 as Qa,h as R,an as De,ad as He,b8 as Et,b9 as Ja,b as z,ba as jt,bb as Us,bc as Ws,bd as Hs,be as Xa,g as p,ar as Ge,al as Oe,bf as Ks,C as Re,O as tt,bg as ba,bh as xt,a$ as ze,bi as Je,bj as Ys,bk as Gs,bl as Qs,s as Js,bm as Fa,a7 as Qt,bn as Xs,bo as Zs,bp as Za,bq as en,c as m,Z as ie,$ as pe,V as es,P as et,br as tn,S as ts,bs as an,bt as sn,bu as nn,bv as on,bw as ln,bx as rn,by as un,bz as as,bA as cn,bB as dn,bC as ht,bD as mn,bE as gn,bF as pn,I as le,t as d,bG as zt,bH as hn,bI as fn,bJ as vn,bK as lt,bL as yn,bM as We,bN as ss,e as Ee,av as Jt,M as Ke,bO as xn,f as a,n as X,_ as _e,A as we,H as Ue,J as Xe,a3 as nt,aV as ka,B as bt,ap as ut,ak as _a,K as wa,D as ns,bP as $a,bQ as os,a1 as Qe,a2 as ft,ay as ls,U as vt,Y as dt,a8 as Ca,a0 as Wt,bR as bn,bS as rs,bT as is,bU as kn,bV as Sa,bW as us,bX as Ra,bY as At,bZ as Ht,b_ as _n,b$ as wn,aj as Bt,c0 as qt,af as Ia,c1 as Ta,c2 as Va,c3 as Tt,a5 as cs,c4 as ds,ae as $t,c5 as $n,c6 as Cn,T as pt,aW as Sn,a6 as Ye,aI as ms,c7 as In,aL as yt,az as St,c8 as Tn,c9 as It,aq as Xt,ca as Mn,cb as Ft,cc as An,cd as zn,ce as Vt,aB as Ma,aA as Zt,ao as gt,au as gs,cf as qn,aX as ps,j as Oa,m as Ln,cg as Dn,a4 as En,aC as Bn,ch as Fn,ci as Rn,ax as Vn,R as On,as as Pn,z as jn,cj as Nn,ck as Un,Q as Wn,cl as Hn,cm as Kn,aF as Yn,aH as Gn,aG as Pa}from"./index-D_0qeKKc.js";import{a as Lt,M as Aa,_ as Qn}from"./index-0qcENyvH.js";import{_ as mt}from"./ThemeCard.vue_vue_type_script_setup_true_lang-DVmpDz05.js";import{C as Jn,a as ea,_ as rt,g as ma}from"./base-CLwWn3Rs.js";import"./vendor-echarts-wordcloud-Ca8n6qS6.js";import{_ as Kt}from"./LoadingState.vue_vue_type_script_setup_true_lang-BFaXTz1c.js";import{u as ta,p as hs,z as fs,j as za,v as vs,i as aa,k as sa,m as Xn,n as Zn,t as eo,A as to}from"./vendor-echarts-B-i_56Av.js";import{f as ao,d as ja}from"./dateFormat-T7kMS5IP.js";import{_ as so}from"./TimeSelect.vue_vue_type_script_setup_true_lang-CCH1UQGc.js";import{P as no}from"./PageHeader-CxKbcLDc.js";function Nt(i,l,e){const n=i.findIndex(c=>Ut(c,l)),s=i.findIndex(c=>Ut(c,e));if(n===-1||s===-1)return[];const[u,o]=[n,s].sort((c,g)=>c-g);return i.slice(u,o+1)}function ys(i){const l=M(()=>t(i)),e=M(()=>new Intl.Collator("en",{usage:"search",...l.value}));return{startsWith:(o,c)=>c.length===0?!0:(o=o.normalize("NFC"),c=c.normalize("NFC"),e.value.compare(o.slice(0,c.length),c)===0),endsWith:(o,c)=>c.length===0?!0:(o=o.normalize("NFC"),c=c.normalize("NFC"),e.value.compare(o.slice(-c.length),c)===0),contains:(o,c)=>{if(c.length===0)return!0;o=o.normalize("NFC"),c=c.normalize("NFC");let g=0;const h=c.length;for(;g+h<=o.length;g++){const f=o.slice(g,g+h);if(e.value.compare(c,f)===0)return!0}return!1}}}function Na(i){return i?.querySelector("[data-state=checked]")}function oo(i,l,e){return i===void 0?!1:Array.isArray(i)?i.some(n=>it(n,l,e)):it(i,l,e)}function it(i,l,e){return i===void 0||l===void 0?!1:typeof i=="string"?i===l:typeof e=="function"?e(i,l):typeof e=="string"?i?.[e]===l?.[e]:Ut(i,l)}const[Rt,lo]=ct("ListboxRoot");var ro=ue({__name:"ListboxRoot",props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},multiple:{type:Boolean,required:!1},orientation:{type:String,required:!1,default:"vertical"},dir:{type:String,required:!1},disabled:{type:Boolean,required:!1},selectionBehavior:{type:String,required:!1,default:"toggle"},highlightOnHover:{type:Boolean,required:!1},by:{type:[String,Function],required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue","highlight","entryFocus","leave"],setup(i,{expose:l,emit:e}){const n=i,s=e,{multiple:u,highlightOnHover:o,orientation:c,disabled:g,selectionBehavior:h,dir:f}=Dt(n),{getItems:b}=Ct({isProvider:!0}),{handleTypeaheadSearch:y}=Ns(),{primitiveElement:k,currentElement:x}=Et(),_=Hs(),C=xa(f),$=Ja(x),I=z(),T=z(!1),v=z(!0),w=wt(n,"modelValue",s,{defaultValue:n.defaultValue??(u.value?[]:void 0),passive:n.modelValue===void 0,deep:!0});function E(oe){if(T.value=!0,n.multiple){const Q=Array.isArray(w.value)?[...w.value]:[],J=Q.findIndex(ge=>it(ge,oe,n.by));n.selectionBehavior==="toggle"?(J===-1?Q.push(oe):Q.splice(J,1),w.value=Q):(w.value=[oe],I.value=oe)}else n.selectionBehavior==="toggle"&&it(w.value,oe,n.by)?w.value=void 0:w.value=oe;setTimeout(()=>{T.value=!1},1)}const F=z(null),D=z(null),A=z(!1),S=z(!1),q=jt(),Y=jt(),G=jt();function Z(){return b().map(oe=>oe.ref).filter(oe=>oe.dataset.disabled!=="")}function ce(oe,Q=!0,J){if(!oe)return;F.value=oe,(J??v.value)&&F.value.focus(),Q&&F.value.scrollIntoView({block:"nearest"});const ge=b().find(ke=>ke.ref===oe);s("highlight",ge)}function ne(oe){if(A.value)G.trigger(oe);else{const Q=b().find(J=>it(J.value,oe,n.by));Q&&(F.value=Q.ref,ce(Q.ref))}}function H(oe){F.value&&F.value.isConnected&&(oe.preventDefault(),oe.stopPropagation(),S.value||F.value.click())}function W(oe){if(v.value){if(T.value=!0,A.value)Y.trigger(oe);else{const Q=oe.altKey||oe.ctrlKey||oe.metaKey;if(Q&&oe.key==="a"&&u.value){const J=b(),ge=J.map($e=>$e.value);w.value=[...ge],oe.preventDefault();const ke=J.at(-1);ke&&ce(ke.ref)}else if(!Q){const J=y(oe.key,b());J&&ce(J)}}setTimeout(()=>{T.value=!1},1)}}function re(){S.value=!0}function ve(){De(()=>{S.value=!1})}function fe(){De(()=>{const oe=new KeyboardEvent("keydown",{key:"PageUp"});j(oe)})}function ee(oe){const Q=F.value;Q?.isConnected&&(D.value=Q),F.value=null,s("leave",oe)}function te(oe){const Q=new CustomEvent("listbox.entryFocus",{bubbles:!1,cancelable:!0});if(oe.currentTarget?.dispatchEvent(Q),s("entryFocus",Q),!Q.defaultPrevented)if(D.value)ce(D.value);else{const J=Z()?.[0];ce(J)}}function j(oe){const Q=Us(oe,c.value,C.value);if(!Q)return;let J=Z();if(F.value){if(Q==="last")J.reverse();else if(Q==="prev"||Q==="next"){Q==="prev"&&J.reverse();const ge=J.indexOf(F.value);J=J.slice(ge+1)}de(oe,J[0])}if(J.length){const ge=!F.value&&Q==="prev"?J.length-1:0;ce(J[ge])}if(A.value)return Y.trigger(oe)}function de(oe,Q){if(!(A.value||n.selectionBehavior!=="replace"||!u.value||!Array.isArray(w.value)||(oe.altKey||oe.ctrlKey||oe.metaKey)&&!oe.shiftKey)&&oe.shiftKey){const ge=b().filter(Le=>Le.ref.dataset.disabled!=="");let ke=ge.find(Le=>Le.ref===Q)?.value;if(oe.key===_.END?ke=ge.at(-1)?.value:oe.key===_.HOME&&(ke=ge[0]?.value),!ke||!I.value)return;const $e=Nt(ge.map(Le=>Le.value),I.value,ke);w.value=$e}}async function be(oe,Q=!0){if(Ws)if(await De(),A.value)q.trigger({event:oe,scroll:Q});else{const J=Z(),ge=J.find($e=>$e.dataset.state==="checked"),ke=Q?void 0:!1;ge?ce(ge,Q,ke):J.length&&ce(J[0],Q,ke)}}let xe=!1;return he(w,()=>{if(!T.value){const oe=xe;xe=!0,De(()=>{be(void 0,oe)})}},{immediate:!0,deep:!0}),l({highlightedElement:F,highlightItem:ne,highlightFirstItem:fe,highlightSelected:be,getItems:b}),lo({modelValue:w,onValueChange:E,multiple:u,orientation:c,dir:C,disabled:g,highlightOnHover:o,highlightedElement:F,isVirtual:A,virtualFocusHook:q,virtualKeydownHook:Y,virtualHighlightHook:G,by:n.by,firstValue:I,selectionBehavior:h,focusable:v,onLeave:ee,onEnter:te,changeHighlight:ce,onKeydownEnter:H,onKeydownNavigation:j,onKeydownTypeAhead:W,onCompositionStart:re,onCompositionEnd:ve,highlightFirstItem:fe}),(oe,Q)=>(r(),U(t(He),{ref_key:"primitiveElement",ref:k,as:oe.as,"as-child":oe.asChild,dir:t(C),"data-disabled":t(g)?"":void 0,onPointerleave:ee,onFocusout:Q[0]||(Q[0]=async J=>{const ge=J.relatedTarget||J.target;await De(),F.value&&t(x)&&!t(x).contains(ge)&&ee(J)})},{default:B(()=>[ye(oe.$slots,"default",{modelValue:t(w)}),t($)&&oe.name?(r(),U(t(Qa),{key:0,name:oe.name,value:t(w),disabled:t(g),required:oe.required},null,8,["name","value","disabled","required"])):R("v-if",!0)]),_:3},8,["as","as-child","dir","data-disabled"]))}}),io=ro,uo=ue({__name:"ListboxContent",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(i){const{CollectionSlot:l}=Ct(),e=Rt(),n=Xa(!1,10);return(s,u)=>(r(),U(t(l),null,{default:B(()=>[p(t(He),{role:"listbox",as:s.as,"as-child":s.asChild,tabindex:t(e).focusable.value?t(e).highlightedElement.value?"-1":"0":"-1","aria-orientation":t(e).orientation.value,"aria-multiselectable":!!t(e).multiple.value,"data-orientation":t(e).orientation.value,onMousedown:u[0]||(u[0]=Oe(o=>n.value=!0,["left"])),onFocus:u[1]||(u[1]=o=>{t(n)||t(e).onEnter(o)}),onKeydown:[u[2]||(u[2]=Ge(o=>{t(e).orientation.value==="vertical"&&(o.key==="ArrowLeft"||o.key==="ArrowRight")||t(e).orientation.value==="horizontal"&&(o.key==="ArrowUp"||o.key==="ArrowDown")||(o.preventDefault(),t(e).focusable.value&&t(e).onKeydownNavigation(o))},["down","up","left","right","home","end"])),Ge(t(e).onKeydownEnter,["enter"]),t(e).onKeydownTypeAhead]},{default:B(()=>[ye(s.$slots,"default")]),_:3},8,["as","as-child","tabindex","aria-orientation","aria-multiselectable","data-orientation","onKeydown"])]),_:3}))}}),co=uo,mo=ue({__name:"ListboxFilter",props:{modelValue:{type:String,required:!1},autoFocus:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"input"}},emits:["update:modelValue"],setup(i,{emit:l}){const e=i,s=wt(e,"modelValue",l,{defaultValue:"",passive:e.modelValue===void 0}),u=Rt(),{primitiveElement:o,currentElement:c}=Et(),g=M(()=>e.disabled||u.disabled.value||!1),h=z();Ks(()=>h.value=u.highlightedElement.value?.id),Re(()=>{u.focusable.value=!1,setTimeout(()=>{e.autoFocus&&c.value?.focus()},1)}),tt(()=>{u.focusable.value=!0});const{isComposing:f,handleCompositionStart:b,handleCompositionEnd:y}=ba($=>{s.value=$.target.value,u.onCompositionEnd(),u.highlightFirstItem()});function k(){u.onCompositionStart(),b()}function x($){f.value||(s.value=$.target.value,u.highlightFirstItem())}function _($){f.value||($.preventDefault(),u.onKeydownNavigation($))}function C($){f.value||u.onKeydownEnter($)}return($,I)=>(r(),U(t(He),{ref_key:"primitiveElement",ref:o,as:$.as,"as-child":$.asChild,value:t(s),disabled:g.value?"":void 0,"data-disabled":g.value?"":void 0,"aria-disabled":g.value??void 0,"aria-activedescendant":h.value,type:"text",onKeydown:[Ge(_,["down","up","home","end"]),Ge(C,["enter"])],onInput:x,onCompositionstart:k,onCompositionend:t(y)},{default:B(()=>[ye($.$slots,"default",{modelValue:t(s)})]),_:3},8,["as","as-child","value","disabled","data-disabled","aria-disabled","aria-activedescendant","onCompositionend"]))}}),go=mo;const[jw,po]=ct("ListboxGroup");var ho=ue({__name:"ListboxGroup",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(i){const l=i,e=xt(void 0,"reka-listbox-group");return po({id:e}),(n,s)=>(r(),U(t(He),ze({role:"group"},l,{"aria-labelledby":t(e)}),{default:B(()=>[ye(n.$slots,"default")]),_:3},16,["aria-labelledby"]))}}),fo=ho;const vo="listbox.select",[yo,xo]=ct("ListboxItem");var bo=ue({__name:"ListboxItem",props:{value:{type:null,required:!0},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"div"}},emits:["select"],setup(i,{emit:l}){const e=i,n=l,s=xt(void 0,"reka-listbox-item"),{CollectionItem:u}=Ct(),{forwardRef:o,currentElement:c}=Je(),g=Rt(),h=M(()=>c.value!=null&&c.value===g.highlightedElement.value),f=M(()=>oo(g.modelValue.value,e.value,g.by)),b=M(()=>g.disabled.value||e.disabled);async function y(x){n("select",x),!x?.defaultPrevented&&!b.value&&x&&(g.onValueChange(e.value),g.changeHighlight(c.value))}function k(x){const _={originalEvent:x,value:e.value};Gs(vo,y,_)}return xo({isSelected:f}),(x,_)=>(r(),U(t(u),{value:x.value},{default:B(()=>[Ys([h.value,f.value,b.value,t(g).focusable.value],()=>p(t(He),ze({id:t(s)},x.$attrs,{ref:t(o),role:"option",tabindex:t(g).focusable.value?h.value?"0":"-1":-1,"aria-selected":f.value,as:x.as,"as-child":x.asChild,disabled:b.value?"":void 0,"data-disabled":b.value?"":void 0,"data-highlighted":h.value?"":void 0,"data-state":f.value?"checked":"unchecked",onClick:k,onKeydown:Ge(Oe(k,["prevent"]),["space"]),onPointermove:_[0]||(_[0]=()=>{t(g).highlightedElement.value!==t(c)&&t(g).highlightOnHover.value&&t(g).changeHighlight(t(c),!1,!1)})}),{default:B(()=>[ye(x.$slots,"default")]),_:3},16,["id","tabindex","aria-selected","as","as-child","disabled","data-disabled","data-highlighted","data-state","onKeydown"]),_,1)]),_:3},8,["value"]))}}),ko=bo,_o=ue({__name:"ListboxItemIndicator",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(i){const l=i;Je();const e=yo();return(n,s)=>t(e).isSelected.value?(r(),U(t(He),ze({key:0,"aria-hidden":"true"},l),{default:B(()=>[ye(n.$slots,"default")]),_:3},16)):R("v-if",!0)}}),wo=_o;function $o(i,l,e){const n=new Array(i);return new Proxy(n,{get(s,u,o){if(typeof u=="string"){const c=u.charCodeAt(0);if(c>=48&&c<=57){const g=+u;if(Number.isInteger(g)&&g>=0&&g<i){let h=s[g];if(!h){const f=l[g*2];h=s[g]={index:g,key:e(g),start:f,size:l[g*2+1],end:f+l[g*2+1],lane:0}}return h}}if(u==="length")return i}return Reflect.get(s,u,o)}})}function _t(i,l,e){let n=e.initialDeps??[],s,u=!0;function o(){const c=i();return(c.length!==n.length||c.some((h,f)=>n[f]!==h))&&(n=c,s=l(...c),e?.onChange&&!(u&&e.skipInitialOnChange)&&e.onChange(s),u=!1),s}return o.updateDeps=c=>{n=c},o}function Ua(i,l){if(i===void 0)throw new Error("Unexpected undefined");return i}const Co=(i,l)=>Math.abs(i-l)<1.01,So=(i,l,e)=>{let n;return function(...s){i.clearTimeout(n),n=i.setTimeout(()=>l.apply(this,s),e)}};let Mt;const la=()=>{if(Mt!==void 0)return Mt;if(typeof navigator>"u")return Mt=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Mt=!0;const i=navigator.maxTouchPoints;return Mt=navigator.platform==="MacIntel"&&i!==void 0&&i>0},Wa=i=>{const{offsetWidth:l,offsetHeight:e}=i;return{width:l,height:e}},Io=i=>i,To=i=>{const l=Math.max(i.startIndex-i.overscan,0),n=Math.min(i.endIndex+i.overscan,i.count-1)-l+1,s=new Array(n);for(let u=0;u<n;u++)s[u]=l+u;return s},Mo=(i,l)=>{const e=i.scrollElement;if(!e)return;const n=i.targetWindow;if(!n)return;const s=o=>{const{width:c,height:g}=o;l({width:Math.round(c),height:Math.round(g)})};if(s(Wa(e)),!n.ResizeObserver)return()=>{};const u=new n.ResizeObserver(o=>{const c=()=>{const g=o[0];if(g?.borderBoxSize){const h=g.borderBoxSize[0];if(h){s({width:h.inlineSize,height:h.blockSize});return}}s(Wa(e))};i.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return u.observe(e,{box:"border-box"}),()=>{u.unobserve(e)}},Yt={passive:!0},Ao=typeof window>"u"?!0:"onscrollend"in window,zo=(i,l,e)=>{const n=i.scrollElement;if(!n)return;const s=i.targetWindow;if(!s)return;const u=i.options.useScrollendEvent&&Ao;let o=0;const c=u?null:So(s,()=>l(o,!1),i.options.isScrollingResetDelay),g=b=>()=>{o=e(n),c?.(),l(o,b)},h=g(!0),f=g(!1);return n.addEventListener("scroll",h,Yt),u&&n.addEventListener("scrollend",f,Yt),()=>{n.removeEventListener("scroll",h),u&&n.removeEventListener("scrollend",f)}},qo=(i,l)=>zo(i,l,e=>{const{horizontal:n,isRtl:s}=i.options;return n?e.scrollLeft*(s&&-1||1):e.scrollTop}),Lo=(i,l,e)=>{if(e.options.useCachedMeasurements){const n=e.indexFromElement(i),s=e.options.getItemKey(n);return e.itemSizeCache.get(s)??e.options.estimateSize(n)}if(l?.borderBoxSize){const n=l.borderBoxSize[0];if(n)return Math.round(n[e.options.horizontal?"inlineSize":"blockSize"])}if(!l){const n=e.indexFromElement(i),s=e.options.getItemKey(n),u=e.itemSizeCache.get(s);if(u!==void 0)return u}return i[e.options.horizontal?"offsetWidth":"offsetHeight"]},Do=(i,{adjustments:l=0,behavior:e},n)=>{var s,u;(u=(s=n.scrollElement)==null?void 0:s.scrollTo)==null||u.call(s,{[n.options.horizontal?"left":"top"]:i+l,behavior:e})},Eo=Do;class Bo{constructor(l){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e,n,s;return((s=(n=(e=this.targetWindow)==null?void 0:e.performance)==null?void 0:n.now)==null?void 0:s.call(n))??Date.now()},this.observer=(()=>{let e=null;const n=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(s=>{s.forEach(u=>{const o=()=>{const c=u.target,g=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);for(const[h,f]of this.elementsCache)if(f===c){this.elementsCache.delete(h);break}return}this.shouldMeasureDuringScroll(g)&&this.resizeItem(g,this.options.measureElement(c,u,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var s;(s=n())==null||s.disconnect(),e=null},observe:s=>{var u;return(u=n())==null?void 0:u.observe(s,{box:"border-box"})},unobserve:s=>{var u;return(u=n())==null?void 0:u.unobserve(s)}}})(),this.range=null,this.setOptions=e=>{var n,s;const u={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Io,rangeExtractor:To,onChange:()=>{},measureElement:Lo,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const y in e){const k=e[y];k!==void 0&&(u[y]=k)}const o=this.options;let c=null,g=null,h=!1;if(o!==void 0&&o.enabled&&u.enabled&&u.anchorTo==="end"&&this.scrollElement!==null){const y=o.count,k=u.count,x=this.getMeasurements(),_=y>0?((n=x[0])==null?void 0:n.key)??o.getItemKey(0):null,C=y>0?((s=x[y-1])==null?void 0:s.key)??o.getItemKey(y-1):null;if(k!==y||y>0&&k>0&&(u.getItemKey(0)!==_||u.getItemKey(k-1)!==C)){h=!0;const T=y>0?this.getVirtualItemForOffset(this.getScrollOffset())??x[0]:null;T&&(c=[T.key,this.getScrollOffset()-T.start]);const v=u.followOnAppend===!0?"auto":u.followOnAppend||null;v&&k>y&&this.isAtEnd(o.scrollEndThreshold)&&(y===0||u.getItemKey(k-1)!==C)&&(g=v)}}this.options=u,h&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,b=0;if(c&&this.scrollOffset!==null){const[y,k]=c,x=this.getMeasurements(),{count:_,getItemKey:C}=this.options;let $=0;for(;$<_&&C($)!==y;)$++;if($<_){const I=x[$];if(I){const T=I.start+k;T!==this.scrollOffset&&(b=T-this.scrollOffset,this.scrollOffset=T,f=!0)}}}(f||g)&&(this.pendingScrollAnchor=[f?c[0]:null,f?c[1]:0,g,b])},this.notify=e=>{var n,s;(s=(n=this.options).onChange)==null||s.call(n,this,e)},this.maybeNotify=_t(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;const n=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==n){if(this.cleanup(),!n){this.maybeNotify();return}if(this.scrollElement=n,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((e=this.scrollElement)==null?void 0:e.window)??null,this.elementsCache.forEach(u=>{this.observer.observe(u)}),this.unsubs.push(this.options.observeElementRect(this,u=>{this.scrollRect=u,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(u,o)=>{if(o&&this._intendedScrollOffset===null&&u===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(u-this._intendedScrollOffset)<1.5&&(u=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const c=this.getScrollOffset();this.scrollDirection=o?c===u?this.scrollDirection:c<u?"forward":"backward":null,this.scrollOffset=u,this.isScrolling=o,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const u=this.scrollElement,o=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},c=()=>{this._iosTouching=!1,!(!la()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};u.addEventListener("touchstart",o,Yt),u.addEventListener("touchend",c,Yt),this.unsubs.push(()=>{u.removeEventListener("touchstart",o),u.removeEventListener("touchend",c),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const s=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,s&&this.scrollElement&&this.options.enabled){const[u,o,c,g]=s;u!==null&&!c&&(la()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?g!==0&&(this._iosDeferredAdjustment+=g):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),c&&this.scrollToEnd({behavior:c})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const e=this.getScrollOffset(),n=this.getMaxScrollOffset();if(e<0||e>n)return;const s=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=s,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=_t(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,n,s,u,o,c,g,h)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMin=null,{count:e,paddingStart:n,scrollMargin:s,getItemKey:u,enabled:o,lanes:c,laneAssignmentMode:g,gap:h}),{key:!1}),this.getMeasurements=_t(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:n,scrollMargin:s,getItemKey:u,enabled:o,lanes:c,laneAssignmentMode:g,gap:h},f)=>{const b=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(const $ of this.laneAssignments.keys())$>=e&&this.laneAssignments.delete($);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach($=>{this.itemSizeCache.set($.key,$.size)}));const y=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),c===1){const $=e*2;let I=this._flatMeasurements;if(!I||I.length<$){const w=new Float64Array($);I&&y>0&&w.set(I.subarray(0,y*2)),I=w,this._flatMeasurements=I}let T;if(y===0)T=n+s;else{const w=y-1;T=I[w*2]+I[w*2+1]+h}for(let w=y;w<e;w++){const E=u(w),F=b.get(E),D=typeof F=="number"?F:this.options.estimateSize(w);I[w*2]=T,I[w*2+1]=D,T+=D+h}const v=$o(e,I,u);return this.measurementsCache=v,v}const k=this.measurementsCache.slice(0,y),x=new Array(c).fill(void 0),_=new Float64Array(c);let C=0;for(let $=0;$<y;$++){const I=k[$];I&&(x[I.lane]===void 0&&C++,x[I.lane]=$,_[I.lane]=I.end)}for(let $=y;$<e;$++){const I=u($),T=this.laneAssignments.get($);let v,w;const E=g==="estimate"||b.has(I);if(T!==void 0&&this.options.lanes>1){v=T;const S=x[v],q=S!==void 0?k[S]:void 0;w=q?q.end+h:n+s}else if(C===c){let S=0,q=_[0],Y=x[0];for(let G=1;G<c;G++){const Z=_[G];(Z<q||Z===q&&x[G]<Y)&&(S=G,q=Z,Y=x[G])}v=S,w=q+h,E&&this.laneAssignments.set($,v)}else v=$%this.options.lanes,w=n+s,E&&this.laneAssignments.set($,v);const F=b.get(I),D=typeof F=="number"?F:this.options.estimateSize($),A=w+D;k[$]={index:$,start:w,size:D,end:A,key:I,lane:v},x[v]===void 0&&C++,x[v]=$,_[v]=A}return this.measurementsCache=k,k},{key:!1,debug:()=>this.options.debug}),this.calculateRange=_t(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,n,s,u)=>e.length===0||n===0?(this.range=null,null):(this.range=Ro(e,n,s,u,u===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=_t(()=>{let e=null,n=null;const s=this.calculateRange();return s&&(e=s.startIndex,n=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,n]},(e,n,s,u,o)=>u===null||o===null?[]:e({startIndex:u,endIndex:o,overscan:n,count:s}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{const n=this.options.indexAttribute,s=e.getAttribute(n);return s?parseInt(s,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var n;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const s=this.scrollState.index??((n=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:n.index);if(s!==void 0&&this.range){const u=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,s-u),c=Math.min(this.options.count-1,s+u);return e>=o&&e<=c}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((o,c)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(c))});return}const n=this.indexFromElement(e),s=this.options.getItemKey(n),u=this.elementsCache.get(s);u!==e&&(u&&this.observer.unobserve(u),this.observer.observe(e),this.elementsCache.set(s,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,n)=>{var s,u;if(e<0||e>=this.options.count)return;let o,c,g;const h=this._flatMeasurements;if(this.options.lanes===1&&h!==null)g=this.options.getItemKey(e),c=h[e*2],o=h[e*2+1];else{const y=this.measurementsCache[e];if(!y)return;g=y.key,c=y.start,o=y.size}const f=this.itemSizeCache.get(g)??o,b=n-f;if(b!==0){const y=this.options.anchorTo==="end"&&((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,k=y?this.getTotalSize():0,x=((u=this.scrollState)==null?void 0:u.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:g,start:c,size:o,end:c+o,lane:0},b,this):c<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(g)||this.scrollDirection!=="backward"));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(g,n),this.itemSizeCacheVersion++,y?this.applyScrollAdjustment(this.getTotalSize()-k):x&&this.applyScrollAdjustment(b),this.notify(!1)}},this.getVirtualItems=_t(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,n)=>{const s=[];for(let u=0,o=e.length;u<o;u++){const c=e[u],g=n[c];s.push(g)}return s},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{const n=this.getMeasurements();if(n.length===0)return;const s=this._flatMeasurements,u=this.options.lanes===1&&s!=null,o=xs(0,n.length-1,u?c=>s[c*2]:c=>Ua(n[c]).start,e);return Ua(n[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,n,s=0)=>{if(!this.scrollElement)return 0;const u=this.getSize(),o=this.getScrollOffset();n==="auto"&&(n=e>=o+u?"end":"start"),n==="center"?e+=(s-u)/2:n==="end"&&(e-=u);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,e),0)},this.getOffsetForIndex=(e,n="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));const s=this.getSize(),u=this.getScrollOffset(),o=this.measurementsCache[e];if(!o)return;if(n==="auto")if(o.end>=u+s-this.options.scrollPaddingEnd)n="end";else if(o.start<=u+this.options.scrollPaddingStart)n="start";else return[u,n];if(n==="end"&&e===this.options.count-1)return[this.getMaxScrollOffset(),n];const c=n==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,n,o.size),n]},this.scrollToOffset=(e,{align:n="start",behavior:s="auto"}={})=>{const u=this.getOffsetForAlignment(e,n),o=this.now();this.scrollState={index:null,align:n,behavior:s,startedAt:o,lastTargetOffset:u,stableFrames:0},this._scrollToOffset(u,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:n="auto",behavior:s="auto"}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));const u=this.getOffsetForIndex(e,n);if(!u)return;const[o,c]=u,g=this.now();this.scrollState={index:e,align:c,behavior:s,startedAt:g,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:n="auto"}={})=>{const s=this.getScrollOffset()+e,u=this.now();this.scrollState={index:null,align:"start",behavior:n,startedAt:u,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{var e;const n=this.getMeasurements();let s;if(n.length===0)s=this.options.paddingStart;else if(this.options.lanes===1){const u=n.length-1,o=this._flatMeasurements;o!=null?s=o[u*2]+o[u*2+1]:s=((e=n[u])==null?void 0:e.end)??0}else{const u=Array(this.options.lanes).fill(null);let o=n.length-1;for(;o>=0&&u.some(c=>c===null);){const c=n[o];u[c.lane]===null&&(u[c.lane]=c.end),o--}s=Math.max(...u.filter(c=>c!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const e=[];if(this.itemSizeCache.size===0)return e;const n=this.getMeasurements();for(const s of n)s&&this.itemSizeCache.has(s.key)&&e.push({index:s.index,key:s.key,start:s.start,size:s.size,end:s.end,lane:s.lane});return e},this._scrollToOffset=(e,{adjustments:n,behavior:s})=>{this._intendedScrollOffset=e+(n??0),this.options.scrollToFn(e,{behavior:s,adjustments:n},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(l)}applyScrollAdjustment(l,e){l!==0&&(la()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=l:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:e}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const n=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,s=n?n[0]:this.scrollState.lastTargetOffset,u=1,o=s!==this.scrollState.lastTargetOffset;if(!o&&Co(s,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=u){this.getScrollOffset()!==s&&this._scrollToOffset(s,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const c=this.getSize()||600,g=Math.abs(s-this.getScrollOffset()),h=this.scrollState.behavior==="smooth"&&g>c;this.scrollState.lastTargetOffset=s,h||(this.scrollState.behavior="auto"),this._scrollToOffset(s,{adjustments:void 0,behavior:h?"smooth":"auto"})}this.scheduleScrollReconcile()}}const xs=(i,l,e,n)=>{for(;i<=l;){const s=(i+l)/2|0,u=e(s);if(u<n)i=s+1;else if(u>n)l=s-1;else return s}return i>0?i-1:0};function Fo(i,l,e){let n=0;for(;n<=l;){const s=(n+l)/2|0,u=i[s*2];if(u<e)n=s+1;else if(u>e)l=s-1;else return s}return n>0?n-1:0}function Ro(i,l,e,n,s){const u=i.length-1;if(i.length<=n)return{startIndex:0,endIndex:u};if(n===1&&s!==null){const h=Fo(s,u,e);let f=h;const b=e+l;for(;f<u&&s[f*2]+s[f*2+1]<b;)f++;return{startIndex:h,endIndex:f}}let c=xs(0,u,h=>i[h].start,e),g=c;if(n===1)for(;g<u&&i[g].end<e+l;)g++;else if(n>1){const h=Array(n).fill(0);for(;g<u&&h.some(b=>b<e+l);){const b=i[g];h[b.lane]=b.end,g++}const f=Array(n).fill(e+l);for(;c>=0&&f.some(b=>b>=e);){const b=i[c];f[b.lane]=b.start,c--}c=Math.max(0,c-c%n),g=Math.min(u,g+(n-1-g%n))}return{startIndex:c,endIndex:g}}function Vo(i){const l=new Bo(t(i)),e=Js(l),n=l._didMount();return he(()=>t(i).getScrollElement(),s=>{s&&l._willUpdate()},{immediate:!0}),he(()=>t(i),s=>{l.setOptions({...s,onChange:(u,o)=>{var c;Fa(e),(c=s.onChange)==null||c.call(s,u,o)}}),l._willUpdate(),Fa(e)},{immediate:!0}),Qs(n),e}function Oo(i){return Vo(M(()=>({observeElementRect:Mo,observeElementOffset:qo,scrollToFn:Eo,...t(i)})))}var Po=ue({__name:"ListboxVirtualizer",props:{options:{type:Array,required:!0},overscan:{type:Number,required:!1},estimateSize:{type:[Number,Function],required:!1},textContent:{type:Function,required:!1}},setup(i){const l=i,e=Qt(),n=Rt(),s=Xs(),{getItems:u}=Ct();n.isVirtual.value=!0;const o=M(()=>{const y=s.value;if(y){const k=window.getComputedStyle(y);return{start:Number.parseFloat(k.paddingBlockStart||k.paddingTop),end:Number.parseFloat(k.paddingBlockEnd||k.paddingBottom)}}else return{start:0,end:0}}),c=Oo({get scrollPaddingStart(){return o.value.start},get scrollPaddingEnd(){return o.value.end},get count(){return l.options.length},get horizontal(){return n.orientation.value==="horizontal"},estimateSize(y){return typeof l.estimateSize=="function"?l.estimateSize(y):l.estimateSize??28},getScrollElement(){return s.value},overscan:l.overscan??12}),g=M(()=>c.value.getVirtualItems().map(y=>{const k=e.default({option:l.options[y.index],virtualizer:c.value,virtualItem:y})[0],x=k.type===ie&&Array.isArray(k.children)?k.children.find(_=>typeof _.type!="symbol"):k;return{item:y,is:tn(x,{key:`${y.key}`,"data-index":y.index,"aria-setsize":l.options.length,"aria-posinset":y.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${y.start}px)`,overflowAnchor:"none"}})}}));n.virtualFocusHook.on(({event:y,scroll:k})=>{const x=l.options.findIndex(_=>Array.isArray(n.modelValue.value)?it(_,n.modelValue.value[0],n.by):it(_,n.modelValue.value,n.by));x!==-1?(y?.preventDefault(),c.value.scrollToIndex(x,{align:"start"}),requestAnimationFrame(()=>{const _=Na(s.value);_&&(n.changeHighlight(_,k,k?void 0:!1),y&&_?.focus())})):k?n.highlightFirstItem():requestAnimationFrame(()=>{const _=u().find(C=>C.ref.dataset.disabled!=="")?.ref;_&&n.changeHighlight(_,!1,!1)})}),n.virtualHighlightHook.on(y=>{const k=l.options.findIndex(x=>it(x,y,n.by));c.value.scrollToIndex(k,{align:"start"}),requestAnimationFrame(()=>{const x=Na(s.value);x&&n.changeHighlight(x)})});const h=Xa("",1e3),f=M(()=>{const y=k=>l.textContent?l.textContent(k):k?.toString().toLowerCase();return l.options.map((k,x)=>({index:x,textContent:y(k)}))});function b(y,k){if(!n.firstValue?.value||!n.multiple.value||!Array.isArray(n.modelValue.value))return;const _=u().filter($=>$.ref.dataset.disabled!=="").find($=>$.ref===n.highlightedElement.value)?.value;if(!_)return;let C=null;switch(k){case"prev":case"next":{C=Nt(l.options,n.firstValue.value,_);break}case"first":{C=Nt(l.options,n.firstValue.value,l.options?.[0]);break}case"last":{C=Nt(l.options,n.firstValue.value,l.options.at(-1));break}}n.modelValue.value=C}return n.virtualKeydownHook.on(y=>{const k=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!k)return;let _=Zs[y.key];if(k&&y.key==="a"&&n.multiple.value?(y.preventDefault(),n.modelValue.value=[...l.options],_="last"):y.shiftKey&&_&&b(y,_),["first","last"].includes(_)){y.preventDefault();const C=_==="first"?0:l.options.length-1;c.value.scrollToIndex(C),requestAnimationFrame(()=>{const $=u(),I=_==="first"?$[0]:$.at(-1);I&&n.changeHighlight(I.ref)})}else if(!_&&!k){h.value+=y.key;const C=Number(Za()?.getAttribute("data-index")),$=f.value[C].textContent,I=f.value.map(w=>w.textContent??""),T=en(I,h.value,$),v=f.value.find(w=>w.textContent===T);v&&(c.value.scrollToIndex(v.index,{align:"start"}),requestAnimationFrame(()=>{const w=s.value.querySelector(`[data-index="${v.index}"]`);w instanceof HTMLElement&&n.changeHighlight(w)}))}}),(y,k)=>(r(),m("div",{"data-reka-virtualizer":"",style:et({position:"relative",width:"100%",height:`${t(c).getTotalSize()}px`})},[(r(!0),m(ie,null,pe(g.value,({is:x,item:_})=>(r(),U(es(x),{key:_.index}))),128))],4))}}),jo=Po;const[at,No]=ct("ComboboxRoot");var Uo=ue({__name:"ComboboxRoot",props:{open:{type:Boolean,required:!1,default:void 0},defaultOpen:{type:Boolean,required:!1},resetSearchTermOnBlur:{type:Boolean,required:!1,default:!0},resetSearchTermOnSelect:{type:Boolean,required:!1,default:!0},openOnFocus:{type:Boolean,required:!1,default:!1},openOnClick:{type:Boolean,required:!1,default:!1},ignoreFilter:{type:Boolean,required:!1},resetModelValueOnClear:{type:Boolean,required:!1,default:!1},modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},multiple:{type:Boolean,required:!1},dir:{type:String,required:!1},disabled:{type:Boolean,required:!1},highlightOnHover:{type:Boolean,required:!1,default:!0},by:{type:[String,Function],required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue","highlight","update:open"],setup(i,{expose:l,emit:e}){const n=i,s=e,{primitiveElement:u,currentElement:o}=Et(),{multiple:c,disabled:g,ignoreFilter:h,resetSearchTermOnSelect:f,openOnFocus:b,openOnClick:y,dir:k,resetModelValueOnClear:x,highlightOnHover:_}=Dt(n),C=xa(k),$=wt(n,"modelValue",s,{defaultValue:n.defaultValue??(c.value?[]:void 0),passive:n.modelValue===void 0,deep:!0}),I=wt(n,"open",s,{defaultValue:n.defaultOpen,passive:n.open===void 0});async function T(ne){I.value=ne,G.value="",ne?(await De(),u.value?.highlightSelected(),w.value=!0,F.value?.focus()):(w.value=!1,setTimeout(()=>{!ne&&n.resetSearchTermOnBlur&&v.trigger()},1))}const v=jt(),w=z(!1),E=z(!1),F=z(),D=z(),A=M(()=>u.value?.highlightedElement??void 0),S=z(new Map),q=z(new Map),{contains:Y}=ys({sensitivity:"base"}),G=z(""),Z=M(ne=>{if(!G.value||n.ignoreFilter||E.value)return{count:S.value.size,items:ne?.items??new Map,groups:ne?.groups??new Set(q.value.keys())};let H=0;const W=new Map,re=new Set;for(const[ve,fe]of S.value){const ee=Y(fe,G.value);W.set(ve,ee?1:0),ee&&H++}for(const[ve,fe]of q.value)for(const ee of fe)if(W.get(ee)>0){re.add(ve);break}return{count:H,items:W,groups:re}}),ce=sn();return Re(()=>{ce?.exposed&&(ce.exposed.highlightItem=u.value?.highlightItem,ce.exposed.highlightFirstItem=u.value?.highlightFirstItem,ce.exposed.highlightSelected=u.value?.highlightSelected)}),l({filtered:Z,highlightedElement:A,highlightItem:u.value?.highlightItem,highlightFirstItem:u.value?.highlightFirstItem,highlightSelected:u.value?.highlightSelected}),No({modelValue:$,multiple:c,disabled:g,open:I,onOpenChange:T,contentId:"",isUserInputted:w,isVirtual:E,inputElement:F,highlightedElement:A,onInputElementChange:ne=>F.value=ne,triggerElement:D,onTriggerElementChange:ne=>D.value=ne,parentElement:o,resetSearchTermOnSelect:f,onResetSearchTerm:v.on,allItems:S,allGroups:q,filterSearch:G,filterState:Z,ignoreFilter:h,openOnFocus:b,openOnClick:y,resetModelValueOnClear:x}),(ne,H)=>(r(),U(t(an),null,{default:B(()=>[p(t(io),ze({ref_key:"primitiveElement",ref:u},ne.$attrs,{modelValue:t($),"onUpdate:modelValue":H[0]||(H[0]=W=>ts($)?$.value=W:null),style:{pointerEvents:t(I)?"auto":void 0},as:ne.as,"as-child":ne.asChild,dir:t(C),multiple:t(c),name:ne.name,required:ne.required,disabled:t(g),"highlight-on-hover":t(_),by:n.by,onHighlight:H[1]||(H[1]=W=>s("highlight",W))}),{default:B(()=>[ye(ne.$slots,"default",{open:t(I),modelValue:t($)})]),_:3},16,["modelValue","style","as","as-child","dir","multiple","name","required","disabled","highlight-on-hover","by"])]),_:3}))}}),Wo=Uo,Ho=ue({__name:"ComboboxAnchor",props:{reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(i){const{forwardRef:l}=Je();return(e,n)=>(r(),U(t(nn),{"as-child":"",reference:e.reference},{default:B(()=>[p(t(He),ze({ref:t(l),"as-child":e.asChild,as:e.as},e.$attrs),{default:B(()=>[ye(e.$slots,"default")]),_:3},16,["as-child","as"])]),_:3},8,["reference"]))}}),Ko=Ho;const[Yo,Go]=ct("ComboboxContent");var Qo=ue({__name:"ComboboxContentImpl",props:{position:{type:String,required:!1,default:"inline"},bodyLock:{type:Boolean,required:!1},hideWhenEmpty:{type:Boolean,required:!1},side:{type:null,required:!1},sideOffset:{type:Number,required:!1},sideFlip:{type:Boolean,required:!1},align:{type:null,required:!1},alignOffset:{type:Number,required:!1},alignFlip:{type:Boolean,required:!1},avoidCollisions:{type:Boolean,required:!1},collisionBoundary:{type:null,required:!1},collisionPadding:{type:[Number,Object],required:!1},arrowPadding:{type:Number,required:!1},hideShiftedArrow:{type:Boolean,required:!1},sticky:{type:String,required:!1},hideWhenDetached:{type:Boolean,required:!1},positionStrategy:{type:String,required:!1},updatePositionStrategy:{type:String,required:!1},disableUpdateOnLayoutShift:{type:Boolean,required:!1},prioritizePosition:{type:Boolean,required:!1},reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},disableOutsidePointerEvents:{type:Boolean,required:!1}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside"],setup(i,{emit:l}){const e=i,n=l,{position:s}=Dt(e),u=at(),o=M(()=>u.ignoreFilter.value?u.allItems.value.size===0:u.filterState.value.count===0),{forwardRef:c,currentElement:g}=Je();on(e.bodyLock),ln(),rn(u.parentElement);const h=M(()=>e.position==="popper"?e:{}),f=un(h.value),b={boxSizing:"border-box","--reka-combobox-content-transform-origin":"var(--reka-popper-transform-origin)","--reka-combobox-content-available-width":"var(--reka-popper-available-width)","--reka-combobox-content-available-height":"var(--reka-popper-available-height)","--reka-combobox-trigger-width":"var(--reka-popper-anchor-width)","--reka-combobox-trigger-height":"var(--reka-popper-anchor-height)"};Go({position:s});const y=z(!1);Re(()=>{u.inputElement.value&&(y.value=g.value.contains(u.inputElement.value),y.value&&u.inputElement.value.focus())}),tt(()=>{const x=Za();y.value&&(!x||x===document.body)&&u.triggerElement.value?.focus()});function k(x){if(u.parentElement.value?.contains(x))return!0;const C=(x instanceof Element?x.closest("label"):null)?.control;return!!C&&!!u.parentElement.value?.contains(C)}return(x,_)=>(r(),U(t(co),{"as-child":""},{default:B(()=>[p(t(as),{"as-child":"",onMountAutoFocus:_[5]||(_[5]=Oe(()=>{},["prevent"])),onUnmountAutoFocus:_[6]||(_[6]=Oe(()=>{},["prevent"]))},{default:B(()=>[p(t(cn),{"as-child":"","disable-outside-pointer-events":x.disableOutsidePointerEvents,onDismiss:_[0]||(_[0]=C=>t(u).onOpenChange(!1)),onFocusOutside:_[1]||(_[1]=C=>{k(C.target)&&C.preventDefault(),n("focusOutside",C)}),onInteractOutside:_[2]||(_[2]=C=>n("interactOutside",C)),onEscapeKeyDown:_[3]||(_[3]=C=>n("escapeKeyDown",C)),onPointerDownOutside:_[4]||(_[4]=C=>{k(C.target)&&C.preventDefault(),n("pointerDownOutside",C)})},{default:B(()=>[(r(),U(es(t(s)==="popper"?t(dn):t(He)),ze({...x.$attrs,...t(f)},{id:t(u).contentId,ref:t(c),"data-state":t(u).open.value?"open":"closed","data-empty":o.value?"":void 0,style:{display:e.hideWhenEmpty&&o.value?"none":"flex",flexDirection:"column",outline:"none",...t(s)==="popper"?b:{}}}),{default:B(()=>[ye(x.$slots,"default")]),_:3},16,["id","data-state","data-empty","style"]))]),_:3},8,["disable-outside-pointer-events"])]),_:3})]),_:3}))}}),Jo=Qo,Xo=ue({__name:"ComboboxArrow",props:{width:{type:Number,required:!1,default:10},height:{type:Number,required:!1,default:5},rounded:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"svg"}},setup(i){const l=i,e=at(),n=Yo();return Je(),(s,u)=>t(e).open.value&&t(n).position.value==="popper"?(r(),U(t(mn),ht(ze({key:0},l)),{default:B(()=>[ye(s.$slots,"default")]),_:3},16)):R("v-if",!0)}}),Zo=Xo,el=ue({__name:"ComboboxCancel",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(i){const l=i;Je();const e=at();function n(){e.filterSearch.value="",e.inputElement.value&&(e.inputElement.value.value="",e.inputElement.value.focus()),e.resetModelValueOnClear?.value&&(e.modelValue.value=e.multiple.value?[]:null)}return(s,u)=>(r(),U(t(He),ze({type:s.as==="button"?"button":void 0},l,{tabindex:"-1",onClick:n}),{default:B(()=>[ye(s.$slots,"default")]),_:3},16,["type"]))}}),tl=el,al=ue({__name:"ComboboxContent",props:{forceMount:{type:Boolean,required:!1},position:{type:String,required:!1},bodyLock:{type:Boolean,required:!1},hideWhenEmpty:{type:Boolean,required:!1},side:{type:null,required:!1},sideOffset:{type:Number,required:!1},sideFlip:{type:Boolean,required:!1},align:{type:null,required:!1},alignOffset:{type:Number,required:!1},alignFlip:{type:Boolean,required:!1},avoidCollisions:{type:Boolean,required:!1},collisionBoundary:{type:null,required:!1},collisionPadding:{type:[Number,Object],required:!1},arrowPadding:{type:Number,required:!1},hideShiftedArrow:{type:Boolean,required:!1},sticky:{type:String,required:!1},hideWhenDetached:{type:Boolean,required:!1},positionStrategy:{type:String,required:!1},updatePositionStrategy:{type:String,required:!1},disableUpdateOnLayoutShift:{type:Boolean,required:!1},prioritizePosition:{type:Boolean,required:!1},reference:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},disableOutsidePointerEvents:{type:Boolean,required:!1}},emits:["escapeKeyDown","pointerDownOutside","focusOutside","interactOutside"],setup(i,{emit:l}){const s=gn(i,l),{forwardRef:u}=Je(),o=at();return o.contentId||=xt(void 0,"reka-combobox-content"),(c,g)=>(r(),U(t(pn),{present:c.forceMount||t(o).open.value},{default:B(()=>[p(Jo,ze({...t(s),...c.$attrs},{ref:t(u)}),{default:B(()=>[ye(c.$slots,"default")]),_:3},16)]),_:3},8,["present"]))}}),sl=al,nl=ue({__name:"ComboboxEmpty",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(i){const l=i,e=at(),n=M(()=>e.ignoreFilter.value?e.allItems.value.size===0:e.filterState.value.count===0);return(s,u)=>n.value?(r(),U(t(He),ht(ze({key:0},l)),{default:B(()=>[ye(s.$slots,"default",{},()=>[u[0]||(u[0]=le("No options"))])]),_:3},16)):R("v-if",!0)}}),ol=nl;const[bs,ll]=ct("ComboboxGroup");var rl=ue({__name:"ComboboxGroup",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(i){const l=i,e=xt(void 0,"reka-combobox-group"),n=at(),s=M(()=>n.ignoreFilter.value?!0:n.filterSearch.value?n.filterState.value.groups.has(e):!0),u=ll({id:e,labelId:""});return Re(()=>{n.allGroups.value.has(e)||n.allGroups.value.set(e,new Set)}),tt(()=>{n.allGroups.value.delete(e)}),(o,c)=>(r(),U(t(fo),ze({id:t(e),"aria-labelledby":t(u).labelId},l,{hidden:s.value?void 0:!0}),{default:B(()=>[ye(o.$slots,"default")]),_:3},16,["id","aria-labelledby","hidden"]))}}),ra=rl,il=ue({__name:"ComboboxInput",props:{displayValue:{type:Function,required:!1},modelValue:{type:String,required:!1},autoFocus:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"input"}},emits:["update:modelValue"],setup(i,{emit:l}){const e=i,n=l,s=at(),u=Rt(),{primitiveElement:o,currentElement:c}=Et(),g=wt(e,"modelValue",n,{passive:e.modelValue===void 0});Re(()=>{c.value&&s.onInputElementChange(c.value)});const{isComposing:h,handleCompositionStart:f,handleCompositionEnd:b}=ba(T=>{const v=T.target;v&&k(v.value)});function y(T){h.value||(T.preventDefault(),s.open.value||s.onOpenChange(!0))}function k(T){s.open.value?s.filterSearch.value=T:(s.onOpenChange(!0),De(()=>{T&&(s.filterSearch.value=T,u.highlightFirstItem())}))}function x(T){h.value||k(T.target.value)}function _(){s.openOnFocus.value&&!s.open.value&&s.onOpenChange(!0)}function C(T){if(!s.open.value)return;const v=T.relatedTarget;if(!v)return;const w=s.parentElement.value?.contains(v),E=document.getElementById(s.contentId)?.contains(v);!w&&!E&&requestAnimationFrame(()=>{if(!s.open.value)return;const F=document.activeElement;!s.parentElement.value?.contains(F)&&!document.getElementById(s.contentId)?.contains(F)&&s.onOpenChange(!1)})}function $(){s.openOnClick.value&&!s.open.value&&s.onOpenChange(!0)}function I(){const T=s.modelValue.value;e.displayValue?g.value=e.displayValue(T):!s.multiple.value&&T&&!Array.isArray(T)&&typeof T!="object"?g.value=T.toString():g.value="",De(()=>{g.value=g.value})}return s.onResetSearchTerm(()=>{I()}),he(s.modelValue,async()=>{!s.isUserInputted.value&&s.resetSearchTermOnSelect.value&&I()},{immediate:!0,deep:!0}),he(s.filterState,(T,v)=>{!s.isVirtual.value&&v.count===0&&u.highlightFirstItem()}),(T,v)=>(r(),U(t(go),{ref_key:"primitiveElement",ref:o,modelValue:t(g),"onUpdate:modelValue":v[0]||(v[0]=w=>ts(g)?g.value=w:null),as:T.as,"as-child":T.asChild,"auto-focus":T.autoFocus,disabled:T.disabled,"aria-expanded":t(s).open.value,"aria-controls":t(s).contentId,"aria-autocomplete":"list",role:"combobox",autocomplete:"off",onClick:$,onInput:x,onKeydown:Ge(y,["down","up"]),onFocus:_,onBlur:C,onCompositionstart:t(f),onCompositionend:t(b)},{default:B(()=>[ye(T.$slots,"default")]),_:3},8,["modelValue","as","as-child","auto-focus","disabled","aria-expanded","aria-controls","onCompositionstart","onCompositionend"]))}}),ul=il,cl=ue({__name:"ComboboxItem",props:{textValue:{type:String,required:!1},value:{type:null,required:!0},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["select"],setup(i,{emit:l}){const e=i,n=l,s=xt(void 0,"reka-combobox-item"),u=at(),o=bs(null),{primitiveElement:c,currentElement:g}=Et();if(e.value==="")throw new Error("A <ComboboxItem /> must have a value prop that is not an empty string. This is because the Combobox value can be set to an empty string to clear the selection and show the placeholder.");const h=M(()=>{if(u.isVirtual.value||u.ignoreFilter.value||!u.filterSearch.value)return!0;{const f=u.filterState.value.items.get(s);return f===void 0?!0:f>0}});return Re(()=>{u.allItems.value.set(s,e.textValue||g.value.textContent||g.value.innerText);const f=o?.id;f&&(u.allGroups.value.has(f)?u.allGroups.value.get(f)?.add(s):u.allGroups.value.set(f,new Set([s])))}),tt(()=>{u.allItems.value.delete(s)}),(f,b)=>h.value?(r(),U(t(ko),ze({key:0},e,{id:t(s),ref_key:"primitiveElement",ref:c,disabled:t(u).disabled.value||f.disabled,onSelect:b[0]||(b[0]=y=>{n("select",y),!y.defaultPrevented&&(!t(u).multiple.value&&!f.disabled&&!t(u).disabled.value?(y.preventDefault(),t(u).onOpenChange(!1),t(u).modelValue.value=e.value):t(u).multiple.value&&t(u).inputElement.value?.focus())})}),{default:B(()=>[ye(f.$slots,"default",{},()=>[le(d(f.value),1)])]),_:3},16,["id","disabled"])):R("v-if",!0)}}),Ha=cl,dl=ue({__name:"ComboboxItemIndicator",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(i){const l=i;return(e,n)=>(r(),U(t(wo),ht(zt(l)),{default:B(()=>[ye(e.$slots,"default")]),_:3},16))}}),ml=dl,gl=ue({__name:"ComboboxLabel",props:{for:{type:String,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"div"}},setup(i){const l=i;Je();const e=bs({id:"",labelId:""});return e.labelId||=xt(void 0,"reka-combobox-group-label"),(n,s)=>(r(),U(t(He),ze(l,{id:t(e).labelId}),{default:B(()=>[ye(n.$slots,"default")]),_:3},16,["id"]))}}),pl=gl,hl=ue({__name:"ComboboxPortal",props:{to:{type:null,required:!1},disabled:{type:Boolean,required:!1},defer:{type:Boolean,required:!1},forceMount:{type:Boolean,required:!1}},setup(i){const l=i;return(e,n)=>(r(),U(t(hn),ht(zt(l)),{default:B(()=>[ye(e.$slots,"default")]),_:3},16))}}),fl=hl,vl=ue({__name:"ComboboxSeparator",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(i){const l=i;return Je(),(e,n)=>(r(),U(t(He),ze(l,{"aria-hidden":"true"}),{default:B(()=>[ye(e.$slots,"default")]),_:3},16))}}),yl=vl,xl=ue({__name:"ComboboxTrigger",props:{disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(i){const l=i,{forwardRef:e,currentElement:n}=Je(),s=at(),u=M(()=>l.disabled||s.disabled.value||!1);return Re(()=>{n.value&&s.onTriggerElementChange(n.value)}),(o,c)=>(r(),U(t(He),ze(l,{ref:t(e),type:o.as==="button"?"button":void 0,tabindex:"-1","aria-label":"Show popup","aria-haspopup":"listbox","aria-expanded":t(s).open.value,"aria-controls":t(s).contentId,"data-state":t(s).open.value?"open":"closed",disabled:u.value,"data-disabled":u.value?"":void 0,"aria-disabled":u.value??void 0,onClick:c[0]||(c[0]=g=>t(s).onOpenChange(!t(s).open.value))}),{default:B(()=>[ye(o.$slots,"default")]),_:3},16,["type","aria-expanded","aria-controls","data-state","disabled","data-disabled","aria-disabled"]))}}),bl=xl,kl=ue({__name:"ComboboxVirtualizer",props:{options:{type:Array,required:!0},overscan:{type:Number,required:!1},estimateSize:{type:[Number,Function],required:!1},textContent:{type:Function,required:!1}},setup(i){const l=i,e=at();return e.isVirtual.value=!0,(n,s)=>(r(),U(jo,ht(zt(l)),{default:B(u=>[ye(n.$slots,"default",ht(zt(u)))]),_:3},16))}}),_l=kl;const[qa,wl]=ct("TagsInputRoot");var $l=ue({__name:"TagsInputRoot",props:{modelValue:{type:[Array,null],required:!1},defaultValue:{type:Array,required:!1,default:()=>[]},addOnPaste:{type:Boolean,required:!1},addOnTab:{type:Boolean,required:!1},addOnBlur:{type:Boolean,required:!1},duplicate:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},delimiter:{type:null,required:!1,default:","},dir:{type:String,required:!1},max:{type:Number,required:!1,default:0},id:{type:String,required:!1},convertValue:{type:Function,required:!1},displayValue:{type:Function,required:!1,default:i=>i.toString()},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:["update:modelValue","invalid","addTag","removeTag"],setup(i,{emit:l}){const e=i,n=l,{addOnPaste:s,disabled:u,delimiter:o,max:c,id:g,dir:h,addOnBlur:f,addOnTab:b}=Dt(e),y=xa(h),k=wt(e,"modelValue",n,{defaultValue:e.defaultValue,passive:!0,deep:!0}),{forwardRef:x,currentElement:_}=Je(),{focused:C}=fn(_),$=Ja(_),{getItems:I,CollectionSlot:T}=Ct({isProvider:!0}),v=z(),w=z(!1),E=M(()=>Array.isArray(k.value)?[...k.value]:[]);function F(D){if(D!==-1){const A=I().filter(S=>S.ref.dataset.disabled!=="");k.value=k.value.filter((S,q)=>q!==D),n("removeTag",A[D].value)}}return wl({modelValue:k,onAddValue:D=>{const A=[...E.value],S=A.length>0&&typeof A[0]=="object",q=A.length>0&&typeof e.defaultValue[0]=="object";if((S||q)&&typeof e.convertValue!="function")throw new Error("You must provide a `convertValue` function when using objects as values.");const Y=e.convertValue?e.convertValue(D):D;if(A.length>=c.value&&c.value)return n("invalid",Y),!1;if(e.duplicate)return k.value=[...A,Y],n("addTag",Y),!0;if(A.includes(Y))w.value=!0;else return k.value=[...A,Y],n("addTag",Y),!0;return n("invalid",Y),!1},onRemoveValue:F,onInputKeydown:D=>{if(D.isComposing)return;const A=D.target,S=I().map(Y=>Y.ref).filter(Y=>Y.dataset.disabled!=="");if(!S.length)return;const q=S.at(-1);switch(D.key){case"Delete":case"Backspace":{if(A.selectionStart!==0||A.selectionEnd!==0)break;if(v.value){const Y=S.findIndex(G=>G===v.value);F(Y),v.value=v.value===q?S.at(Y-1):S.at(Y+1),D.preventDefault()}else D.key==="Backspace"&&(v.value=q,D.preventDefault());break}case"Home":case"End":case"ArrowRight":case"ArrowLeft":{const Y=D.key==="ArrowRight"&&y.value==="ltr"||D.key==="ArrowLeft"&&y.value==="rtl",G=!Y;if(A.selectionStart!==0||A.selectionEnd!==0)break;if(G&&!v.value)v.value=q,D.preventDefault();else if(Y&&q&&v.value===q)v.value=void 0,D.preventDefault();else if(v.value){const Z=vn(D,v.value,void 0,{itemsArray:S,loop:!1,dir:y.value});Z&&(v.value=Z),D.preventDefault()}break}case"ArrowUp":case"ArrowDown":{v.value&&D.preventDefault();break}default:v.value=void 0}},selectedElement:v,isInvalidInput:w,addOnPaste:s,addOnBlur:f,addOnTab:b,dir:y,disabled:u,delimiter:o,max:c,id:g,displayValue:e.displayValue}),(D,A)=>(r(),U(t(T),null,{default:B(()=>[p(t(He),{ref:t(x),dir:t(y),as:D.as,"as-child":D.asChild,"data-invalid":w.value?"":void 0,"data-disabled":t(u)?"":void 0,"data-focused":t(C)?"":void 0},{default:B(()=>[ye(D.$slots,"default",{modelValue:t(k)}),t($)&&D.name?(r(),U(t(Qa),{key:0,name:D.name,value:t(k),required:D.required,disabled:t(u)},null,8,["name","value","required","disabled"])):R("v-if",!0)]),_:3},8,["dir","as","as-child","data-invalid","data-disabled","data-focused"])]),_:3}))}}),Cl=$l,Sl=ue({__name:"TagsInputInput",props:{placeholder:{type:String,required:!1},autoFocus:{type:Boolean,required:!1},maxLength:{type:Number,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"input"}},setup(i){const l=i,e=qa(),{forwardRef:n,currentElement:s}=Je();function u(x){if(e.selectedElement.value=void 0,!e.addOnBlur.value)return;const _=x.target,C=x.relatedTarget,$=_.getAttribute("aria-controls");if($&&C?.closest(`#${CSS.escape($)}`)||!_.value)return;e.onAddValue(_.value)&&(_.value="")}function o(x){e.addOnTab.value&&f(x)}const{isComposing:c,handleCompositionStart:g,handleCompositionEnd:h}=ba();async function f(x){if(c.value||(await De(),x.defaultPrevented))return;const _=x.target;if(!_.value)return;e.onAddValue(_.value)&&(_.value=""),x.preventDefault()}function b(x){if(c.value||(e.isInvalidInput.value=!1,x.data===null))return;const _=e.delimiter.value;if(_===x.data||_ instanceof RegExp&&_.test(x.data)){const $=x.target;if($.value=$.value.replace(_,""),$.value.trim()===""){$.value="";return}e.onAddValue($.value)&&($.value="")}}function y(x){c.value||e.onInputKeydown(x)}function k(x){if(e.addOnPaste.value){x.preventDefault();const _=x.clipboardData;if(!_)return;const C=_.getData("text");e.delimiter.value?C.split(e.delimiter.value).forEach(I=>{e.onAddValue(I)}):e.onAddValue(C)}}return Re(()=>{const x=s.value.nodeName==="INPUT"?s.value:s.value.querySelector("input");x&&setTimeout(()=>{l.autoFocus&&x?.focus()},1)}),(x,_)=>(r(),U(t(He),{id:t(e).id?.value,ref:t(n),type:"text",autocomplete:"off",autocorrect:"off",autocapitalize:"off",as:x.as,"as-child":x.asChild,maxlength:x.maxLength,placeholder:x.placeholder,disabled:t(e).disabled.value,"data-invalid":t(e).isInvalidInput.value?"":void 0,onInput:b,onKeydown:[Ge(f,["enter"]),Ge(o,["tab"]),y],onBlur:u,onCompositionstart:t(g),onCompositionend:t(h),onPaste:k},{default:B(()=>[ye(x.$slots,"default")]),_:3},8,["id","as","as-child","maxlength","placeholder","disabled","data-invalid","onCompositionstart","onCompositionend"]))}}),Il=Sl;const[ks,Tl]=ct("TagsInputItem");var Ml=ue({__name:"TagsInputItem",props:{value:{type:null,required:!0},disabled:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(i){const l=i,{value:e}=Dt(l),n=qa(),{forwardRef:s,currentElement:u}=Je(),{CollectionItem:o}=Ct(),c=M(()=>n.selectedElement.value===u.value),g=M(()=>l.disabled||n.disabled.value),h=Tl({value:e,isSelected:c,disabled:g,textId:"",displayValue:M(()=>n.displayValue(e.value))});return(f,b)=>(r(),U(t(o),{value:t(e)},{default:B(()=>[p(t(He),{ref:t(s),as:f.as,"as-child":f.asChild,"aria-labelledby":t(h).textId,"aria-current":c.value,"data-disabled":g.value?"":void 0,"data-state":c.value?"active":"inactive"},{default:B(()=>[ye(f.$slots,"default")]),_:3},8,["as","as-child","aria-labelledby","aria-current","data-disabled","data-state"])]),_:3},8,["value"]))}}),Al=Ml,zl=ue({__name:"TagsInputItemDelete",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"button"}},setup(i){const l=i;Je();const e=qa(),n=ks(),s=M(()=>n.disabled?.value||e.disabled.value);function u(){if(s.value)return;const o=e.modelValue.value.findIndex(c=>Ut(c,n.value.value));e.onRemoveValue(o)}return(o,c)=>(r(),U(t(He),ze({tabindex:"-1"},l,{"aria-labelledby":t(n).textId,"aria-current":t(n).isSelected.value,"data-state":t(n).isSelected.value?"active":"inactive","data-disabled":s.value?"":void 0,type:o.as==="button"?"button":void 0,onClick:u}),{default:B(()=>[ye(o.$slots,"default")]),_:3},16,["aria-labelledby","aria-current","data-state","data-disabled","type"]))}}),ql=zl,Ll=ue({__name:"TagsInputItemText",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(i){const l=i,e=ks();return Je(),e.textId||=xt(void 0,"reka-tags-input-item-text"),(n,s)=>(r(),U(t(He),ze(l,{id:t(e).textId}),{default:B(()=>[ye(n.$slots,"default",{},()=>[le(d(t(e).displayValue.value),1)])]),_:3},16,["id"]))}}),Dl=Ll;const El={none:[],qwen:["default","off","high"],deepseek_v4:["default","off","high","xhigh"],deepseek_hybrid:["default","off","auto"],o_series:["default","low","medium","high"],gpt5:["default","minimal","low","medium","high"],gpt5_1:["default","off","low","medium","high"],gpt5_2plus:["default","off","minimal","low","medium","high","xhigh"],grok:["default","low","high"],kimi:["default","off","auto","low","medium","high"],doubao:["default","off","auto","high"],hunyuan:["default","off","high"],gemini:["default","off","low","medium","high"],default:["default","off","low","medium","high"]},Ka=/^(?!.*-non-reasoning\b)(o\d+(?:-[\w-]+)?|.*\b(?:reasoning|reasoner|thinking|think)\b.*|.*-[rR]\d+.*|.*\bqwq(?:-[\w-]+)?\b.*|.*\bhunyuan-t1(?:-[\w-]+)?\b.*|.*\bgrok-(?:3-mini|4|4-fast|build)(?:-[\w-]+)?\b.*)$/i;function Bl(i,l){const e=l.toLowerCase(),n=i.toLowerCase();if(e.includes("-non-reasoning")||n==="anthropic")return"none";if(n==="gemini")return/gemini-(?:2\.5|3(?:\.\d+)?-(?:flash|pro)|flash-latest|pro-latest)/i.test(e)?"gemini":"none";if(n==="qwen"||/\bqwen|qwq/i.test(e))return"qwen";if(/deepseek[_-]v([4-9]|\d{2,})/i.test(e)||/deepseek-ai\/deepseek-r1/i.test(e))return"deepseek_v4";if(/deepseek[_-]chat|deepseek[_-]v3/i.test(e))return"deepseek_hybrid";if(n==="openai"||n==="openai-compatible"){if(/gpt-5\.[2-9]|gpt-5\.[1-9]\d/.test(e))return"gpt5_2plus";if(/gpt-5\.1/.test(e))return"gpt5_1";if(/gpt-5/.test(e))return"gpt5";if(/^o\d/.test(e))return"o_series"}return/^o\d/.test(e)?"o_series":/\bgrok-(?:3-mini|4|4-fast|build)\b/i.test(e)?"grok":/\bkimi-k(?:2-thinking|2\.[5-9]|[3-9])/i.test(e)||n==="kimi"&&/thinking/i.test(e)?"kimi":/\bdoubao-.*seed/i.test(e)||n==="doubao"&&/seed/i.test(e)?"doubao":/\bhunyuan-(?:t1|a13b)/i.test(e)?"hunyuan":n==="glm"||/\bglm-?(?:5|4\.[5-7]|z1|zero)/i.test(e)?"qwen":n==="siliconflow"&&/r[1-9]/i.test(e)?"deepseek_v4":n==="openrouter"?/deepseek.*(v[4-9]|r\d)/i.test(e)?"deepseek_v4":/deepseek[_-]?(chat|v3)/i.test(e)?"deepseek_hybrid":/\bgrok-(?:3-mini|4|4-fast|build)\b/i.test(e)?"grok":/\bkimi-k(?:2-thinking|2\.[5-9]|[3-9])/i.test(e)?"kimi":Ka.test(e)?"default":"none":/\bmimo-v2/i.test(e)||/\bminimax-m[123]/i.test(e)||/\bseed-oss/i.test(e)?"deepseek_hybrid":/\bbaichuan-m[23]/i.test(e)||/\bmagistral/i.test(e)||/\bmistral-small-2603/i.test(e)||/\bstep-(?:3|r1-v-mini)/i.test(e)||/\bgemma-?4/i.test(e)||/\bpangu-pro-moe/i.test(e)||/\bsonar-deep-research/i.test(e)||/\bring-(?:1t|mini|flash)/i.test(e)?"default":/\bqwen|qwq/i.test(e)?"qwen":/deepseek[_-]?r\d|deepseek[_-]?v[4-9]/i.test(e)?"deepseek_v4":/^o\d/i.test(e)?"o_series":Ka.test(e)?"default":"none"}function Fl(i,l){const e=Bl(i,l);return El[e]}function Rl(){const{contains:i,startsWith:l}=ys({sensitivity:"base"});function e(o,c){return i(o,c)?i(c,o)?0:l(o,c)?1:2:null}function n(o,c,g){if(typeof o!="object"||o===null)return e(String(o),c);let h=null;for(const f of g){const b=lt(o,f);if(b==null)continue;const y=Array.isArray(b)?b.map(String):[String(b)];for(const k of y){const x=e(k,c);if(x!==null&&(h===null||x<h)&&(h=x),h===0)return 0}}return h}function s(o,c,g){if(!c)return o;const h=[];for(const f of o){const b=n(f,c,g);b!==null&&h.push({item:f,score:b})}return h.sort((f,b)=>f.score-b.score),h.map(({item:f})=>f)}function u(o,c,g){return c?o.map(h=>{const f=[];for(const b of h){if(b==null)continue;if(g.isStructural?.(b)){f.push({item:b,score:-1});continue}const y=n(b,c,g.fields);y!==null&&f.push({item:b,score:y})}return f.sort((b,y)=>b.score-y.score),f.map(({item:b})=>b)}).filter(h=>h.some(f=>!g.isStructural?.(f))):o}return{score:e,scoreItem:n,filter:s,filterGroups:u}}function Vl(i,l,e,n="group",s="zh-CN"){const u=yn(),{chatKey:o,state:c}=u.ensureSessionState({sessionId:i,sessionName:l,timeFilter:e,chatType:n,locale:s});return u.resetToSelectorOnEnter(o),u.applySessionAssistantSelection(o),{messages:We(c,"messages"),sourceMessages:We(c,"sourceMessages"),currentKeywords:We(c,"currentKeywords"),isLoadingSource:We(c,"isLoadingSource"),isAIThinking:We(c,"isAIThinking"),currentAIChatId:We(c,"currentAIChatId"),currentToolStatus:We(c,"currentToolStatus"),toolsUsedInCurrentRound:We(c,"toolsUsedInCurrentRound"),sessionTokenUsage:We(c,"sessionTokenUsage"),agentStatus:We(c,"agentStatus"),selectedAssistantId:We(c,"selectedAssistantId"),sendMessage:(g,h)=>u.sendMessage(o,g,h),editMessageAndRegenerate:(g,h,f)=>u.editMessageAndRegenerate(o,g,h,f),loadAIChat:g=>u.loadAIChat(o,g),startNewAIChat:g=>u.startNewAIChat(o,g),loadMoreSourceMessages:()=>u.loadMoreSourceMessages(),updateMaxMessages:()=>u.updateMaxMessages(),stopGeneration:()=>u.stopGeneration(o),selectAssistantForSession:g=>u.selectAssistantForSession(o,g)}}const ia=new Map;function Ol(i,l,e){const{activeTab:n,isInitialLoad:s,currentSessionId:u,onTimeRangeChange:o}=e,c=z(null),g=z(null),h=z([]),f=M(()=>{const x=c.value;if(x)return{startTs:x.startTs,endTs:x.endTs}}),b=M(()=>{const x=c.value;return x?`${x.startTs}-${x.endTs}`:"init"}),y=M(()=>{const x=i.query,_=x.timeMode;return _?{mode:_,recentDays:x.timeDays?Number(x.timeDays):void 0,year:x.timeYear?Number(x.timeYear):void 0,quarterYear:x.timeYear?Number(x.timeYear):void 0,quarter:x.timeQuarter?Number(x.timeQuarter):void 0,customStart:x.timeStart||void 0,customEnd:x.timeEnd||void 0}:u.value&&ia.has(u.value)?ia.get(u.value):{mode:"recent",recentDays:365}});he([n,c],([x,_])=>{if(s.value||!_)return;const C=_.state,$={tab:x,timeMode:C.mode,timeDays:void 0,timeYear:void 0,timeQuarter:void 0,timeStart:void 0,timeEnd:void 0};C.mode==="recent"&&($.timeDays=C.recentDays),C.mode==="year"&&($.timeYear=C.year),C.mode==="quarter"&&($.timeYear=C.quarterYear,$.timeQuarter=C.quarter),C.mode==="custom"&&($.timeStart=C.customStart,$.timeEnd=C.customEnd),l.replace({query:{...i.query,...$}})}),he(c,x=>{!x||!u.value||(ss(),ia.set(u.value,x.state),o?.())},{immediate:!0});function k(){c.value=null,g.value=null,h.value=[]}return{timeRangeValue:c,fullTimeRange:g,availableYears:h,timeFilter:f,timeFilterKey:b,initialTimeState:y,resetTimeRange:k}}function Pl(i){return i.content.trim()?i.content:i.contentBlocks?.filter(e=>e.type==="text"&&!!e.text).map(e=>e.text).join("")??""}function ga(i){return i.flatMap(l=>{if(l.role!=="user"&&l.role!=="assistant")return[];const e=Pl(l);return e.trim()?[{role:l.role,content:e,timestamp:l.timestamp}]:[]})}function jl(i){return ga(i).length>0}function Nl(i,l,e,n){const s=[];s.push(`# ${i}`),s.push(""),s.push(`> ${n.createdAt}: ${Ee(e).format("YYYY-MM-DD HH:mm:ss")}`),s.push(""),s.push("---"),s.push("");for(const u of l){const o=Ee(u.timestamp).format("YYYY-MM-DD HH:mm:ss"),c=u.role==="user"?n.user:n.assistant;s.push(`### ${c}`),s.push(`*${o}*`),s.push(""),s.push(u.content),s.push(""),s.push("---"),s.push("")}return s.join(`
|
|
3
|
+
`)}function Ul(i,l,e,n){const s=[];s.push(`${i}`),s.push(`${n.createdAt}: ${Ee(e).format("YYYY-MM-DD HH:mm:ss")}`),s.push(""),s.push("=".repeat(50)),s.push("");for(const u of l){const o=Ee(u.timestamp).format("YYYY-MM-DD HH:mm:ss"),c=u.role==="user"?n.user:n.assistant;s.push(`[${c}] ${o}`),s.push(""),s.push(u.content),s.push(""),s.push("-".repeat(50)),s.push("")}return s.join(`
|
|
4
|
+
`)}function Wl(i){return i.replace(/[/\\?%*:|"<>]/g,"_")}async function Hl(i,l,e,n,s){if(l.length===0)return{success:!1,error:"No messages to export"};let u,o;const c=Ee(e).format("YYYYMMDD_HHmmss"),g=Wl(i);n==="markdown"?(u=Nl(i,l,e,s),o=`${g}_${c}.md`):(u=Ul(i,l,e,s),o=`${g}_${c}.txt`);const h=`data:text/plain;charset=utf-8,${encodeURIComponent(u)}`,{useCacheService:f}=await Jt(async()=>{const{useCacheService:y}=await import("./index-D_0qeKKc.js").then(k=>k.co);return{useCacheService:y}},__vite__mapDeps([0,1,2]));return await f().saveToDownloads(o,h)}function Kl(i){const l=i.columns.join(","),e=i.rows.map(n=>n.map(s=>s===null?"":`"${String(s).replace(/"/g,'""')}"`).join(","));return[l,...e].join(`
|
|
5
|
+
`)}function Yl(i){const l=i.rows.map(e=>{const n={};return i.columns.forEach((s,u)=>{n[s]=e[u]}),n});return JSON.stringify(l,null,2)}async function Gl(i,l){if(i.rows.length===0)return{success:!1,error:"No data to export"};const n=`sql_result_${Ee().format("YYYYMMDD_HHmmss")}.${l}`;let s,u;l==="json"?(s=Yl(i),u="application/json"):(s=Kl(i),u="text/csv");const o=`data:${u};charset=utf-8,${encodeURIComponent(s)}`,{useCacheService:c}=await Jt(async()=>{const{useCacheService:h}=await import("./index-D_0qeKKc.js").then(f=>f.co);return{useCacheService:h}},__vite__mapDeps([0,1,2]));return await c().saveToDownloads(n,o)}function Nw(i){const{route:l,router:e,currentSessionId:n,selectSession:s,defaultTab:u,validTabIds:o}=i,c=z(!0),g=z(!0),h=z(null),f=z([]),b=z([]),y=z([]),k=z([]);let x=0;function _(){const S=l.query.tab;return S&&o.includes(S)?S:u}const C=z(_());he(C,S=>{const q={insights:"insights",ranking:"ranking","ai-chat":"ai_chat",lab:"sql_lab"}[S];q&&xn("feature_used",{feature_id:q})},{immediate:!0});const{timeRangeValue:$,fullTimeRange:I,availableYears:T,timeFilter:v,initialTimeState:w}=Ol(l,e,{activeTab:C,isInitialLoad:g,currentSessionId:n,onTimeRangeChange:()=>D()});function E(){const S=l.params.id;S&&(s(S),n.value!==S&&e.replace("/"))}async function F(){if(n.value)try{const S=await Ke().getSession(n.value);h.value=S}catch(S){console.error("加载基础数据失败:",S)}}async function D(){const S=n.value;if(!S)return;const q=++x;c.value=!0;try{const Y=v.value,G=Ke(),[Z,ce,ne,H]=await Promise.all([G.getMemberActivity(S,Y),G.getHourlyActivity(S,Y),G.getDailyActivity(S,Y),G.getMessageTypeDistribution(S,Y)]);if(q!==x)return;f.value=Z,b.value=ce,y.value=ne,k.value=H}catch(Y){q===x&&console.error("加载分析数据失败:",Y)}finally{q===x&&(c.value=!1)}}async function A(){n.value&&(g.value=!0,await F(),g.value=!1)}return he(()=>l.params.id,()=>{C.value=_(),E()}),he(()=>l.query.tab,()=>{C.value=_()}),he(n,()=>{x++,ss(),A()},{immediate:!0}),Re(()=>{E()}),{activeTab:C,isLoading:c,isInitialLoad:g,session:h,memberActivity:f,hourlyActivity:b,dailyActivity:y,messageTypes:k,timeRangeValue:$,fullTimeRange:I,availableYears:T,timeFilter:v,initialTimeState:w,syncSession:E,loadData:A,loadAnalysisData:D}}const Ql={class:"pointer-events-none absolute right-3 top-3 z-50 opacity-0 transition-opacity duration-200 group-hover/card:pointer-events-auto group-hover/card:opacity-100"},Jl=ue({__name:"CardCaptureOverlay",setup(i){return(l,e)=>(r(),m("div",Ql,[p(Lt,{type:"element","target-selector":"[data-capturable-card]",size:"xs"})]))}}),na=ue({__name:"ReportCard",props:{capturable:{type:Boolean,default:!0}},setup(i){return(l,e)=>(r(),U(mt,{"data-capturable-card":"",class:"group/card relative isolate flex flex-col"},{default:B(()=>[p(Jn),i.capturable?(r(),U(Jl,{key:0})):R("",!0),ye(l.$slots,"default")]),_:3}))}}),Xl={class:"flex items-center justify-between"},Zl={class:"font-semibold text-gray-900 dark:text-white whitespace-nowrap"},er={key:0,class:"mt-1 text-sm text-gray-500 dark:text-gray-400"},tr={class:"flex items-center gap-2"},ar={key:0,class:"pointer-events-none opacity-0 transition-opacity duration-200 group-hover/card:pointer-events-auto group-hover/card:opacity-100"},Ze=ue({__name:"SectionCard",props:{title:{},description:{},capturable:{type:Boolean,default:!0},showDivider:{type:Boolean,default:!0},scrollable:{type:Boolean,default:!1},maxHeightVh:{default:60}},setup(i){const l=i,e=M(()=>{if(l.scrollable)return{maxHeight:`${l.maxHeightVh}vh`,overflowY:"auto"}});return(n,s)=>(r(),U(mt,{class:"group/card","data-section-card":""},{default:B(()=>[a("div",{class:X(["px-5 py-3",{"border-b border-gray-200 dark:border-white/5":i.showDivider&&n.$slots.default}])},[a("div",Xl,[a("div",null,[a("p",Zl,d(i.title),1),i.description?(r(),m("p",er,d(i.description),1)):R("",!0)]),a("div",tr,[ye(n.$slots,"headerRight"),i.capturable?(r(),m("div",ar,[p(Lt,{type:"element","target-selector":"[data-section-card]",size:"xs"})])):R("",!0)])])],2),i.scrollable?(r(),m("div",{key:0,style:et(e.value)},[ye(n.$slots,"default")],4)):ye(n.$slots,"default",{key:1}),ye(n.$slots,"footer")]),_:3}))}}),sr={class:"flex items-start justify-between"},nr={class:"min-w-0 flex-1"},or={class:"text-sm font-medium text-gray-500 dark:text-gray-400"},lr={key:1,class:"text-xl"},rr={key:0,class:"mt-4 flex items-center text-sm"},ir={class:"text-gray-500 dark:text-gray-400"},ot=ue({__name:"StatCard",props:{label:{},value:{},valueColor:{},subtext:{},icon:{},iconBg:{}},setup(i){const l={pink:"text-pink-600 dark:text-pink-400",amber:"text-amber-600 dark:text-amber-400",blue:"text-blue-600 dark:text-blue-400",green:"text-green-600 dark:text-green-400",red:"text-red-600 dark:text-red-400",gray:"text-gray-900 dark:text-white"},e={pink:"bg-pink-100 dark:bg-pink-500/10",amber:"bg-amber-100 dark:bg-amber-500/10",blue:"bg-blue-100 dark:bg-blue-500/10",green:"bg-green-100 dark:bg-green-500/10",red:"bg-red-100 dark:bg-red-500/10",gray:"bg-gray-100 dark:bg-white/5"};return(n,s)=>{const u=_e;return r(),U(mt,{class:"p-5"},{default:B(()=>[a("div",sr,[a("div",nr,[a("p",or,d(i.label),1),a("p",{class:X(["mt-2 truncate text-2xl font-bold tracking-tight",i.valueColor?l[i.valueColor]:"text-gray-900 dark:text-white"])},d(i.value),3)]),i.icon?(r(),m("div",{key:0,class:X(["ml-4 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl",e[i.iconBg||"gray"]])},[i.icon.startsWith("i-")?(r(),U(u,{key:0,name:i.icon,class:"h-5 w-5"},null,8,["name"])):(r(),m("span",lr,d(i.icon),1))],2)):R("",!0)]),i.subtext||n.$slots.subtext?(r(),m("div",rr,[ye(n.$slots,"subtext",{},()=>[a("span",ir,d(i.subtext),1)])])):R("",!0)]),_:3})}}}),ur={key:0,class:"mb-2 block text-2xl"},Uw=ue({__name:"EmptyState",props:{text:{},icon:{},padding:{}},setup(i){const l={sm:"px-4 py-4",md:"px-5 py-8",lg:"px-6 py-12"};return(e,n)=>(r(),m("div",{class:X(["text-center text-sm text-gray-400",l[i.padding||"md"]])},[i.icon?(r(),m("span",ur,d(i.icon),1)):R("",!0),le(" "+d(i.text||"暂无数据"),1)],2))}}),cr={"zh-CN":{message:"消息记录",member:"成员",meta:"群信息",member_name_history:"昵称历史"},"en-US":{message:"Messages",member:"Members",meta:"Chat Info",member_name_history:"Nickname History"}},pa={"zh-CN":{message:{id:"消息ID",sender_id:"发送者ID",sender_account_name:"发送时账号名",sender_group_nickname:"发送时群昵称",ts:"时间戳(秒)",type:"消息类型",content:"消息内容"},member:{id:"成员ID",platform_id:"平台ID",account_name:"账号名称",group_nickname:"群昵称",aliases:"自定义别名"},meta:{name:"群名称",platform:"平台",type:"聊天类型",imported_at:"导入时间"},member_name_history:{id:"记录ID",member_id:"成员ID",name_type:"名称类型",name:"昵称值",start_ts:"开始时间",end_ts:"结束时间"}},"en-US":{message:{id:"Message ID",sender_id:"Sender ID",sender_account_name:"Sender Account",sender_group_nickname:"Sender Nickname",ts:"Timestamp (sec)",type:"Message Type",content:"Content"},member:{id:"Member ID",platform_id:"Platform ID",account_name:"Account Name",group_nickname:"Group Nickname",aliases:"Custom Aliases"},meta:{name:"Chat Name",platform:"Platform",type:"Chat Type",imported_at:"Imported At"},member_name_history:{id:"Record ID",member_id:"Member ID",name_type:"Name Type",name:"Nickname",start_ts:"Start Time",end_ts:"End Time"}}};function ha(i,l="zh-CN"){return cr[_s(l)]?.[i]||i}function La(i,l,e="zh-CN"){return pa[_s(e)]?.[i]?.[l]||l}function _s(i){return i.startsWith("zh")?"zh-CN":"en-US"}const dr={key:0,class:"text-xs font-medium text-gray-500 dark:text-gray-400"},mr={key:0,class:"flex-1 overflow-y-auto p-2"},gr=["onClick"],pr={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},hr={class:"flex-1 truncate text-right text-xs text-gray-400"},fr={key:0,class:"ml-4 mt-1 space-y-0.5"},vr=["title","onDblclick"],yr={class:"font-mono text-gray-700 dark:text-gray-300"},xr={class:"flex-1 truncate text-right text-[10px] text-gray-400"},br={key:1,class:"flex flex-1 flex-col items-center gap-1 overflow-y-auto px-2 pb-2"},kr=["title","onClick"],_r=ue({__name:"SchemaPanel",props:{sessionId:{}},emits:["insertColumn"],setup(i,{expose:l,emit:e}){const{t:n,locale:s}=we(),u=i,o=e,c=z(!1),g=z([]),h=z(new Set);async function f(){try{g.value=await Ke().getSchema(u.sessionId),g.value.forEach(x=>h.value.add(x.name))}catch(x){console.error("加载 Schema 失败:",x)}}function b(x){h.value.has(x)?h.value.delete(x):h.value.add(x)}function y(x){c.value=!1,h.value.add(x)}function k(x,_){o("insertColumn",x,_)}return l({loadSchema:f,schema:g}),Re(()=>{f()}),(x,_)=>{const C=_e,$=Ue;return r(),m("div",{class:X(["m-3 flex h-[calc(100%-1.5rem)] shrink-0 flex-col overflow-hidden rounded-lg bg-white transition-all duration-300 ease-in-out dark:bg-sidebar-dark",c.value?"w-14":"w-56"])},[a("div",{class:X(["flex items-center",c.value?"justify-center px-2 pb-2 pt-5":"justify-between border-b border-gray-200 py-2 pl-3 pr-2 dark:border-gray-800"])},[c.value?R("",!0):(r(),m("span",dr,d(t(n)("ai.sqlLab.schema.tables")),1)),c.value?(r(),m("button",{key:2,type:"button",class:"group relative flex h-9 w-9 cursor-pointer items-center justify-center rounded-full hover:bg-gray-200/60 dark:hover:bg-white/[0.06]",onClick:_[1]||(_[1]=I=>c.value=!c.value)},[p(C,{name:"i-lucide-panel-right-open",class:"size-4 scale-x-[-1]"})])):(r(),U($,{key:1,color:"neutral",variant:"ghost",size:"sm",class:"group flex h-9 w-9 cursor-pointer items-center justify-center rounded-full hover:bg-gray-200/60 dark:hover:bg-white/[0.06]",onClick:_[0]||(_[0]=I=>c.value=!c.value)},{default:B(()=>[p(C,{name:"i-lucide-panel-right",class:"size-4 scale-x-[-1] group-hover:hidden"}),p(C,{name:"i-lucide-panel-right-close",class:"size-4 hidden scale-x-[-1] group-hover:block"})]),_:1}))],2),c.value?(r(),m("div",br,[(r(!0),m(ie,null,pe(g.value,I=>(r(),m("button",{key:I.name,class:"flex h-10 w-10 items-center justify-center rounded-lg text-gray-600 transition-colors hover:bg-gray-200/40 hover:text-primary-600 dark:text-gray-300 dark:hover:bg-white/[0.06] dark:hover:text-primary-400",title:`${t(ha)(I.name,t(s))} (${I.name})`,onClick:T=>y(I.name)},[p(C,{name:"i-heroicons-table-cells",class:"h-5 w-5"})],8,kr))),128))])):(r(),m("div",mr,[(r(!0),m(ie,null,pe(g.value,I=>(r(),m("div",{key:I.name,class:"mb-2"},[a("button",{class:"flex w-full items-center gap-1 rounded px-2 py-1.5 text-left transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",onClick:T=>b(I.name)},[p(C,{name:h.value.has(I.name)?"i-heroicons-chevron-down":"i-heroicons-chevron-right",class:"h-3 w-3 shrink-0 text-gray-400"},null,8,["name"]),p(C,{name:"i-heroicons-table-cells",class:"h-4 w-4 shrink-0 text-pink-500"}),a("span",pr,d(I.name),1),a("span",hr,d(t(ha)(I.name,t(s))),1)],8,gr),h.value.has(I.name)?(r(),m("div",fr,[(r(!0),m(ie,null,pe(I.columns,T=>(r(),m("button",{key:T.name,class:"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",title:t(n)("ai.sqlLab.schema.doubleClickToInsert"),onDblclick:v=>k(I.name,T.name)},[T.pk?(r(),U(C,{key:0,name:"i-heroicons-key",class:"h-3 w-3 shrink-0 text-yellow-500",title:t(n)("ai.sqlLab.schema.primaryKey")},null,8,["title"])):R("",!0),a("span",yr,d(T.name),1),a("span",xr,d(t(La)(I.name,T.name,t(s))),1)],40,vr))),128))])):R("",!0)]))),128))]))],2)}}}),wr={class:"max-h-[70vh] overflow-hidden p-6"},$r={class:"mb-4 flex items-center gap-2"},Cr={class:"text-lg font-semibold text-gray-900 dark:text-white"},Sr={key:0,class:"max-h-[50vh] space-y-3 overflow-y-auto pr-2"},Ir={class:"mb-2 flex items-start justify-between gap-2"},Tr={class:"flex-1 text-sm font-medium text-gray-700 dark:text-gray-300"},Mr={class:"shrink-0 text-xs text-gray-400"},Ar={class:"mb-2 rounded bg-white p-2 dark:bg-gray-800"},zr={class:"whitespace-pre-wrap break-all font-mono text-xs text-gray-600 dark:text-gray-400"},qr={key:0,class:"mb-2 text-xs text-gray-500 dark:text-gray-400"},Lr={class:"flex justify-end gap-2"},Dr={key:1,class:"py-8 text-center text-gray-500 dark:text-gray-400"},Er={class:"text-sm"},Br={class:"mt-4 flex justify-end"},Fr=ue({__name:"AIHistoryModal",props:{open:{type:Boolean},history:{}},emits:["update:open","execute","delete"],setup(i,{emit:l}){const{t:e}=we(),n=l;function s(u){const o=new Date(u),c=new Date,g=c.getTime()-u;return g<6e4?e("ai.sqlLab.history.justNow"):g<36e5?e("ai.sqlLab.history.minutesAgo",{count:Math.floor(g/6e4)}):g<864e5?e("ai.sqlLab.history.hoursAgo",{count:Math.floor(g/36e5)}):o.toDateString()===c.toDateString()?e("ai.sqlLab.history.today"):`${o.getMonth()+1}/${o.getDate()}`}return(u,o)=>{const c=_e,g=Ue,h=Xe;return r(),U(h,{open:i.open,ui:{content:"max-w-5xl"},"onUpdate:open":o[1]||(o[1]=f=>n("update:open",f))},{content:B(()=>[a("div",wr,[a("div",$r,[p(c,{name:"i-heroicons-clock",class:"h-5 w-5 text-pink-500"}),a("h3",Cr,d(t(e)("ai.sqlLab.history.title")),1)]),i.history.length>0?(r(),m("div",Sr,[(r(!0),m(ie,null,pe(i.history,f=>(r(),m("div",{key:f.id,class:"rounded-lg border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-page-dark"},[a("div",Ir,[a("p",Tr,d(f.prompt),1),a("span",Mr,d(s(f.timestamp)),1)]),a("div",Ar,[a("pre",zr,d(f.sql),1)]),f.explanation?(r(),m("p",qr,d(f.explanation),1)):R("",!0),a("div",Lr,[p(g,{variant:"ghost",size:"xs",color:"error",onClick:b=>n("delete",f.id)},{default:B(()=>[p(c,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"})]),_:1},8,["onClick"]),p(g,{size:"xs",onClick:b=>n("execute",f)},{default:B(()=>[p(c,{name:"i-heroicons-play",class:"mr-1 h-3.5 w-3.5"}),le(" "+d(t(e)("ai.sqlLab.history.execute")),1)]),_:1},8,["onClick"])])]))),128))])):(r(),m("div",Dr,[p(c,{name:"i-heroicons-clock",class:"mx-auto mb-2 h-8 w-8 text-gray-300 dark:text-gray-600"}),a("p",Er,d(t(e)("ai.sqlLab.history.empty")),1)])),a("div",Br,[p(g,{variant:"ghost",onClick:o[0]||(o[0]=f=>n("update:open",!1))},{default:B(()=>[le(d(t(e)("common.close")),1)]),_:1})])])]),_:1},8,["open"])}}}),Rr={class:"flex flex-1 flex-col overflow-hidden"},Vr={key:0,class:"border-b border-red-200 bg-red-50 p-4 dark:border-red-900 dark:bg-red-950"},Or={class:"flex items-start gap-2"},Pr={class:"min-w-0 flex-1"},jr={class:"text-sm font-medium text-red-800 dark:text-red-200"},Nr={class:"mt-1 break-all font-mono text-xs text-red-600 dark:text-red-400"},Ur={key:1,class:"flex items-center justify-between border-b border-gray-200 bg-gray-50 px-4 py-2 dark:border-gray-800 dark:bg-page-dark"},Wr={class:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400"},Hr={class:"flex cursor-pointer items-center gap-1.5"},Kr={class:"text-xs"},Yr={class:"flex items-center gap-2"},Gr={key:2,class:"flex-1 overflow-auto"},Qr={class:"min-w-full divide-y divide-gray-200 dark:divide-gray-700"},Jr={class:"sticky top-0 bg-gray-100 dark:bg-page-dark"},Xr=["onClick"],Zr={class:"flex items-center gap-1"},ei={class:"flex flex-col"},ti={class:"text-gray-700 dark:text-gray-300"},ai={key:0,class:"font-mono text-[10px] text-gray-400"},si={key:0,class:"sticky right-0 w-12 bg-gray-100 px-2 py-2 dark:bg-page-dark"},ni={class:"divide-y divide-gray-200 bg-white dark:divide-gray-700 dark:bg-page-dark"},oi=["title"],li={key:0,class:"sticky right-0 w-12 bg-white px-2 py-2 dark:bg-page-dark"},ri={key:3,class:"flex shrink-0 items-center gap-4 border-t border-gray-200 bg-gray-50 px-4 py-2 dark:border-gray-800 dark:bg-page-dark"},ii={class:"flex items-center gap-1"},ui={class:"mx-2 text-xs text-gray-600 dark:text-gray-400"},ci={class:"flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400"},di={key:4,class:"flex flex-1 items-center justify-center text-gray-500 dark:text-gray-400"},mi={class:"text-center"},gi={class:"mt-2 text-sm"},pi={key:5,class:"flex flex-1 items-center justify-center text-gray-500 dark:text-gray-400"},hi={class:"text-center"},fi={class:"mt-2 text-sm"},vi={class:"mt-1 text-xs text-gray-400"},yi={class:"max-h-[70vh] overflow-hidden p-6"},xi={class:"mb-4 flex items-center gap-2"},bi={class:"text-lg font-semibold text-gray-900 dark:text-white"},ki={key:0,class:"flex items-center justify-center py-8"},_i={class:"ml-2 text-sm text-gray-500"},wi={key:1,class:"max-h-[50vh] overflow-y-auto"},$i=["innerHTML"],Ci={key:0,class:"mt-2 flex items-center text-xs text-gray-400"},Si={key:2,class:"rounded-lg bg-red-50 p-4 dark:bg-red-950"},Ii={class:"text-sm text-red-600 dark:text-red-400"},Ti={class:"mt-4 flex justify-end gap-2"},Mi=ue({__name:"ResultTable",props:{result:{},error:{},sql:{},prompt:{}},setup(i,{expose:l}){const{t:e,locale:n}=we(),s=nt(),u=ka(),o=bt(),{aiGlobalSettings:c}=ut(u),g=[/^ts$/i,/^timestamp$/i,/^time$/i,/_at$/i,/_ts$/i,/_time$/i,/^date$/i];function h(Q){return g.some(J=>J.test(Q))}function f(Q){if(typeof Q!="number"||!Number.isFinite(Q))return!1;const J=946684800,ge=4102444800,ke=J*1e3,$e=ge*1e3;return Q>=J&&Q<=ge||Q>=ke&&Q<=$e}function b(Q){const ge=Q>1e10?Q:Q*1e3;return Ee(ge).format("YYYY-MM-DD HH:mm:ss")}const y=[/^id$/i,/^message_id$/i,/^msg_id$/i,/^msgid$/i];function k(Q){return Q.findIndex(J=>y.some(ge=>ge.test(J)))}function x(Q){o.openChatRecordDrawer({scrollToMessageId:Q})}const _=new Aa({html:!1,breaks:!0,linkify:!0,typographer:!0}),C=i,$=z(null),I=z("asc"),T=z(1),v=z(100),w=[50,100,200,500],E=z(localStorage.getItem("sql-lab-readable-time")!=="false");function F(){E.value=!E.value,localStorage.setItem("sql-lab-readable-time",String(E.value))}const D=z(!1),A=z(!1),S=z(""),q=z(null),Y=z(""),G=z(!1);function Z(Q){const J=Q.split("."),ge=J.length>1?J[J.length-1]:Q,ke=pa[n.value]||pa["zh-CN"];for(const $e of Object.values(ke))if($e[ge])return $e[ge];return null}const ce=M(()=>{if(!C.result||!$.value)return C.result?.rows||[];const Q=C.result.columns.indexOf($.value);return Q===-1?C.result.rows:[...C.result.rows].sort((J,ge)=>{const ke=J[Q],$e=ge[Q];if(ke===null)return 1;if($e===null)return-1;if(typeof ke=="number"&&typeof $e=="number")return I.value==="asc"?ke-$e:$e-ke;const Le=String(ke).localeCompare(String($e));return I.value==="asc"?Le:-Le})}),ne=M(()=>C.result?Math.ceil(ce.value.length/v.value):0),H=M(()=>{const Q=(T.value-1)*v.value,J=Q+v.value;return ce.value.slice(Q,J)}),W=M(()=>C.result?k(C.result.columns):-1),re=M(()=>W.value!==-1);function ve(Q){$.value===Q?I.value=I.value==="asc"?"desc":"asc":($.value=Q,I.value="asc"),T.value=1}function fe(Q){v.value=Q,T.value=1}function ee(Q,J){return Q===null?"NULL":typeof Q=="object"?JSON.stringify(Q):E.value&&J&&h(J)&&f(Q)?b(Q):String(Q)}async function te(){if(!(!C.result||G.value)){G.value=!0;try{const Q=c.value.sqlExportFormat??"csv",J=await Gl({columns:C.result.columns,rows:C.result.rows},Q);if(J.success&&J.filePath){const ge=J.filePath.split("/").pop()||J.filePath;s.add({title:e("common.exportSuccess"),description:ge,color:"primary",actions:[{label:e("common.openFolder"),onClick:()=>{ns().showInFolder(J.filePath)}}]})}else s.fail(e("common.exportFailed"),{description:J.error})}catch(Q){console.error("导出失败:",Q),s.fail(e("common.exportFailed"),{description:String(Q)})}finally{G.value=!1}}}function j(){$.value=null,I.value="asc",T.value=1}function de(){if(!C.result)return"";const Q=50,J=C.result.rows.slice(0,Q),ge=C.result.columns.join(" | "),ke=C.result.columns.map(()=>"---").join(" | "),$e=J.map(Be=>Be.map(Te=>Te===null?"NULL":String(Te).slice(0,50)).join(" | "));let Le=`| ${ge} |
|
|
6
6
|
| ${ke} |
|
|
7
7
|
`;return Le+=$e.map(Be=>`| ${Be} |`).join(`
|
|
8
8
|
`),C.result.rows.length>Q&&(Le+=`
|
|
9
9
|
|
|
10
|
-
(仅展示前 ${Q} 行,共 ${C.result.rowCount} 行)`),Le}async function be(){D.value=!0,
|
|
10
|
+
(仅展示前 ${Q} 行,共 ${C.result.rowCount} 行)`),Le}async function be(){D.value=!0,S.value="",q.value=null,Y.value="",await xe()}async function xe(){if(!await $a().hasConfig()){q.value=e("common.errorNoAIConfig");return}A.value=!0,q.value=null,Y.value="";try{const J=de();let ge="";C.prompt&&(ge=`用户的查询意图:${C.prompt}
|
|
11
11
|
|
|
12
12
|
`),C.sql&&(ge+=`执行的 SQL 语句:
|
|
13
13
|
\`\`\`sql
|
|
@@ -23,7 +23,7 @@ ${J}
|
|
|
23
23
|
请提供:
|
|
24
24
|
1. 结果概述(一句话总结)
|
|
25
25
|
2. 关键发现(2-4 个要点)
|
|
26
|
-
3. 如有明显的趋势或异常,请指出`,$e=await os().chatStream([{role:"system",content:"你是一个数据分析专家,擅长从查询结果中提取关键信息和洞察。请用简洁清晰的中文回答。"},{role:"user",content:ke}],{temperature:.3,maxTokens:1e3},Le=>{Le.content&&(Y.value+=Le.content)});$e.success?
|
|
26
|
+
3. 如有明显的趋势或异常,请指出`,$e=await os().chatStream([{role:"system",content:"你是一个数据分析专家,擅长从查询结果中提取关键信息和洞察。请用简洁清晰的中文回答。"},{role:"user",content:ke}],{temperature:.3,maxTokens:1e3},Le=>{Le.content&&(Y.value+=Le.content)});$e.success?S.value=Y.value:q.value=$e.error||e("ai.sqlLab.result.errorSummary")}catch(J){q.value=J.message||String(J)}finally{A.value=!1}}function oe(){D.value=!1,S.value="",q.value=null,Y.value=""}return l({resetSort:j}),(Q,J)=>{const ge=_e,ke=_a,$e=Ue,Le=wa,Be=Xe;return r(),m("div",Rr,[i.error?(r(),m("div",Vr,[a("div",Or,[p(ge,{name:"i-heroicons-exclamation-circle",class:"mt-0.5 h-5 w-5 shrink-0 text-red-500"}),a("div",Pr,[a("p",jr,d(t(e)("ai.sqlLab.result.queryError")),1),a("p",Nr,d(i.error),1)])])])):R("",!0),i.result?(r(),m("div",Ur,[a("div",Wr,[a("label",Hr,[p(ke,{"model-value":E.value,size:"xs","onUpdate:modelValue":F},null,8,["model-value"]),a("span",Kr,d(t(e)("ai.sqlLab.result.readableTime")),1)]),J[5]||(J[5]=a("span",{class:"text-gray-300 dark:text-gray-600"},"|",-1)),a("span",null,[p(ge,{name:"i-heroicons-table-cells",class:"mr-1 inline h-4 w-4"}),le(" "+d(t(e)("ai.sqlLab.result.rows",{count:i.result.rowCount})),1)]),a("span",null,[p(ge,{name:"i-heroicons-clock",class:"mr-1 inline h-4 w-4"}),le(" "+d(i.result.duration)+" ms ",1)])]),a("div",Yr,[p($e,{variant:"ghost",size:"xs",onClick:be},{default:B(()=>[p(ge,{name:"i-heroicons-sparkles",class:"mr-1 h-4 w-4"}),le(" "+d(t(e)("ai.sqlLab.result.summarize")),1)]),_:1}),p($e,{variant:"ghost",size:"xs",loading:G.value,onClick:te},{default:B(()=>[p(ge,{name:"i-heroicons-arrow-down-tray",class:"mr-1 h-4 w-4"}),le(" "+d(t(e)("common.export")),1)]),_:1},8,["loading"])])])):R("",!0),i.result&&i.result.rows.length>0?(r(),m("div",Gr,[a("table",Qr,[a("thead",Jr,[a("tr",null,[(r(!0),m(ie,null,pe(i.result.columns,(Te,Pe)=>(r(),m("th",{key:Pe,class:"cursor-pointer whitespace-nowrap px-4 py-2 text-left text-xs font-medium transition-colors hover:bg-gray-200 dark:hover:bg-gray-700",onClick:je=>ve(Te)},[a("div",Zr,[a("div",ei,[a("span",ti,d(Z(Te)||Te),1),Z(Te)?(r(),m("span",ai,d(Te),1)):R("",!0)]),$.value===Te?(r(),U(ge,{key:0,name:I.value==="asc"?"i-heroicons-chevron-up":"i-heroicons-chevron-down",class:"h-3 w-3 text-gray-500"},null,8,["name"])):R("",!0)])],8,Xr))),128)),re.value?(r(),m("th",si)):R("",!0)])]),a("tbody",ni,[(r(!0),m(ie,null,pe(H.value,(Te,Pe)=>(r(),m("tr",{key:Pe,class:"hover:bg-gray-50 dark:hover:bg-gray-800"},[(r(!0),m(ie,null,pe(Te,(je,Se)=>(r(),m("td",{key:Se,class:X(["max-w-xs truncate whitespace-nowrap px-4 py-2 font-mono text-sm text-gray-700 dark:text-gray-300",{"text-gray-400 italic":je===null}]),title:ee(je,i.result.columns[Se])},d(ee(je,i.result.columns[Se])),11,oi))),128)),re.value?(r(),m("td",li,[p($e,{icon:"i-heroicons-chat-bubble-left-right",color:"neutral",variant:"ghost",size:"xs",title:t(e)("ai.sqlLab.result.viewChat"),onClick:je=>x(Te[W.value])},null,8,["title","onClick"])])):R("",!0)]))),128))])])])):R("",!0),i.result&&i.result.rows.length>0&&ne.value>1?(r(),m("div",ri,[a("div",ii,[p($e,{icon:"i-heroicons-chevron-double-left",variant:"ghost",size:"xs",disabled:T.value===1,onClick:J[0]||(J[0]=Te=>T.value=1)},null,8,["disabled"]),p($e,{icon:"i-heroicons-chevron-left",variant:"ghost",size:"xs",disabled:T.value===1,onClick:J[1]||(J[1]=Te=>T.value--)},null,8,["disabled"]),a("span",ui,d(T.value)+" / "+d(ne.value),1),p($e,{icon:"i-heroicons-chevron-right",variant:"ghost",size:"xs",disabled:T.value>=ne.value,onClick:J[2]||(J[2]=Te=>T.value++)},null,8,["disabled"]),p($e,{icon:"i-heroicons-chevron-double-right",variant:"ghost",size:"xs",disabled:T.value>=ne.value,onClick:J[3]||(J[3]=Te=>T.value=ne.value)},null,8,["disabled"])]),a("div",ci,[a("span",null,d(t(e)("ai.sqlLab.result.pageSize")),1),p(Le,{"model-value":v.value,items:w.map(Te=>({label:String(Te),value:Te})),size:"xs",class:"w-20","onUpdate:modelValue":fe},null,8,["model-value","items"])])])):R("",!0),i.result&&i.result.rows.length===0?(r(),m("div",di,[a("div",mi,[p(ge,{name:"i-heroicons-inbox",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),a("p",gi,d(t(e)("ai.sqlLab.result.emptyResult")),1)])])):R("",!0),!i.result&&!i.error?(r(),m("div",pi,[a("div",hi,[p(ge,{name:"i-heroicons-command-line",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),a("p",fi,d(t(e)("ai.sqlLab.result.initialState")),1),a("p",vi,d(t(e)("ai.sqlLab.result.initialHint")),1)])])):R("",!0),p(Be,{open:D.value,"onUpdate:open":J[4]||(J[4]=Te=>D.value=Te)},{content:B(()=>[a("div",yi,[a("div",xi,[p(ge,{name:"i-heroicons-sparkles",class:"h-5 w-5 text-pink-500"}),a("h3",bi,d(t(e)("ai.sqlLab.result.summaryTitle")),1)]),A.value&&!Y.value?(r(),m("div",ki,[p(ge,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-pink-500"}),a("span",_i,d(t(e)("ai.sqlLab.result.analyzing")),1)])):Y.value||S.value?(r(),m("div",wi,[a("div",{class:"prose prose-sm max-w-none rounded-lg bg-gray-50 p-4 dark:prose-invert dark:bg-page-dark",innerHTML:t(_).render(Y.value||S.value)},null,8,$i),A.value?(r(),m("div",Ci,[p(ge,{name:"i-heroicons-arrow-path",class:"mr-1 h-3 w-3 animate-spin"}),le(" "+d(t(e)("common.generating")),1)])):R("",!0)])):R("",!0),q.value?(r(),m("div",Si,[a("p",Ii,d(q.value),1)])):R("",!0),a("div",Ti,[!A.value&&S.value?(r(),U($e,{key:0,variant:"outline",onClick:xe},{default:B(()=>[p(ge,{name:"i-heroicons-arrow-path",class:"mr-1 h-4 w-4"}),le(" "+d(t(e)("common.regenerate")),1)]),_:1})):R("",!0),p($e,{variant:"ghost",onClick:oe},{default:B(()=>[le(d(t(e)("common.close")),1)]),_:1})])])]),_:1},8,["open"])])}}}),Ai={class:"main-content flex h-full"},zi={class:"flex flex-1 flex-col overflow-hidden"},qi={class:"flex flex-col border-b border-gray-200 bg-gray-50 p-4 dark:border-gray-800 dark:bg-page-dark"},Li={class:"mx-auto w-full max-w-3xl"},Di=["placeholder"],Ei=["placeholder"],Bi={class:"mt-1 flex items-center justify-between"},Fi={class:"flex items-center gap-2"},Ri={key:0,class:"text-xs text-gray-400"},Vi={class:"flex items-center gap-2"},Oi={key:0,class:"ml-1 text-xs text-gray-400"},Pi={key:0,class:"flex-1 overflow-auto p-4"},ji={class:"mb-2 flex items-center gap-1.5 text-sm font-medium text-gray-600 dark:text-gray-300"},Ni={key:0,class:"text-gray-500"},Ui={key:1,class:"text-pink-500"},Wi=["open"],Hi={class:"cursor-pointer select-none text-xs font-medium text-gray-500 dark:text-gray-400"},Ki={key:1,class:"whitespace-pre-wrap break-all font-mono text-xs leading-5 text-gray-600 dark:text-gray-400"},Yi={key:2,class:"font-mono text-xs text-gray-400"},Gi=ue({__name:"SQLLabTab",props:{sessionId:{},chatType:{}},setup(i){const{t:l,locale:e}=we(),n=i,s=z(null),u=z(null);function o(W){return l(W==="group"?"ai.sqlLab.generate.defaultPromptGroup":"ai.sqlLab.generate.defaultPromptPrivate")}const c=z("SELECT * FROM message LIMIT 10"),g=z(o(n.chatType)),h=z("prompt"),f=z(!1),b=z(!1),y=z(null),k=z(null),x=z(""),_=z(""),C=z(""),$=z(!1),I=z(null),T=z(!1),v=z([]);function w(){try{const W=`sql-lab-history-${n.sessionId}`,re=localStorage.getItem(W);re&&(v.value=JSON.parse(re))}catch(W){console.error("加载历史记录失败:",W)}}function E(){try{const W=`sql-lab-history-${n.sessionId}`;localStorage.setItem(W,JSON.stringify(v.value))}catch(W){console.error("保存历史记录失败:",W)}}function F(W,re,ve){const fe={id:`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,prompt:W,sql:re,explanation:ve,timestamp:Date.now()};v.value.unshift(fe),v.value.length>50&&(v.value=v.value.slice(0,50)),E()}function D(W){v.value=v.value.filter(re=>re.id!==W),E()}async function A(){if(!c.value.trim()){y.value=l("ai.sqlLab.editor.errorEmptySQL");return}f.value=!0,y.value=null,k.value=null,u.value?.resetSort();try{k.value=await Ke().executeSQL(n.sessionId,c.value)}catch(W){y.value=W.message||String(W)}finally{f.value=!1}}function S(W,re){(W.ctrlKey||W.metaKey)&&W.key==="Enter"&&(W.preventDefault(),re==="prompt"?ne():A())}function q(W,re){c.value+=`${W}.${re}`}function Y(){h.value=h.value==="prompt"?"sql":"prompt"}function G(W){const re=[];for(const ve of W){re.push(`### ${ve.name} (${ha(ve.name,e.value)})`),re.push("| 列名 | 说明 | 类型 |"),re.push("|------|------|------|");for(const fe of ve.columns){const ee=fe.pk?" (主键)":"";re.push(`| ${fe.name} | ${La(ve.name,fe.name,e.value)}${ee} | ${fe.type} |`)}re.push("")}return re.join(`
|
|
27
27
|
`)}function Z(W,re){return`你是一个 SQLite 数据库专家。用户需要查询聊天记录数据库。
|
|
28
28
|
|
|
29
29
|
## 数据库结构
|
|
@@ -65,11 +65,11 @@ ${W}
|
|
|
65
65
|
1. 仅输出 JSON,不要有任何其他文字
|
|
66
66
|
2. SQL 中的查询结果限制在合理范围内(建议 LIMIT 100)
|
|
67
67
|
3. 确保 SQL 语法正确
|
|
68
|
-
4. 若用户需求包含多个分析目标,仅选择第一个目标生成 SQL`}function ce(W){let re=W.trim();re=re.replace(/^```json?\n?/i,"").replace(/\n?```$/i,"");try{const ve=JSON.parse(re);return{sql:(ve.sql||"").trim(),explanation:(ve.explanation||"").trim()}}catch{return re=re.replace(/^```sql?\n?/i,"").replace(/\n?```$/i,""),{sql:re.trim(),explanation:""}}}async function ne(){const W=g.value.trim();if(!W){y.value=l("ai.sqlLab.generate.errorEmptyPrompt");return}if(!await $a().hasConfig()){y.value=l("common.errorNoAIConfig");return}const ve=s.value?.schema||[];if(ve.length===0){y.value=l("common.error.unknown");return}b.value=!0,k.value=null,y.value=null,_.value="",C.value="",$.value=!1;let he="";try{const ee=Z(W,ve),te=await os().chatStream([{role:"system",content:"你是一个 SQLite 专家,请以 JSON 格式输出 sql 和 explanation 字段。"},{role:"user",content:ee}],{temperature:.1,maxTokens:4096},de=>{if(de.thinking!==void 0){de.thinkingDone?$.value=!1:($.value=!0,de.thinking&&(C.value+=de.thinking,De(()=>{S.value&&(S.value.scrollTop=S.value.scrollHeight)})));return}de.error&&(he=de.error),de.isFinished&&de.finishReason==="length"&&(he=l("ai.sqlLab.generate.errorTokenLimit")),de.content&&(_.value+=de.content)});if(!te.success){y.value=te.error||he||l("ai.sqlLab.generate.errorGenerate");return}if(he){y.value=he;return}const j=ce(_.value);if(!j.sql){y.value=_.value?`${l("ai.sqlLab.generate.errorGenerate")}: ${_.value.slice(0,200)}`:l("ai.sqlLab.generate.errorGenerate");return}c.value=j.sql,x.value=W,F(W,j.sql,j.explanation),await A()}catch(ee){y.value=ee.message||String(ee)}finally{b.value=!1}}async function H(W){c.value=W.sql,x.value=W.prompt,T.value=!1,await A()}return Re(()=>{w()}),fe(()=>n.chatType,W=>{g.value=o(W)}),(W,re)=>{const ve=_e,he=Ue;return r(),m("div",Mi,[p(t(kr),{ref_key:"schemaPanelRef",ref:s,"session-id":i.sessionId,onInsertColumn:q},null,8,["session-id"]),a("div",Ai,[a("div",zi,[a("div",qi,[h.value==="prompt"?Qe((r(),m("textarea",{key:0,"onUpdate:modelValue":re[0]||(re[0]=ee=>g.value=ee),class:"h-32 w-full resize-none rounded-2xl border-0 bg-white p-3 text-sm text-gray-800 shadow-[0_2px_14px_rgba(0,0,0,0.04)] outline-none ring-1 ring-gray-200/60 transition-all placeholder:text-gray-400 focus:ring-primary-500/40 focus:shadow-[0_4px_20px_rgba(0,0,0,0.08)] dark:bg-page-dark dark:text-gray-200 dark:ring-white/5 dark:placeholder:text-gray-500 dark:focus:ring-primary-500/40",placeholder:t(l)("ai.sqlLab.generate.placeholder"),spellcheck:"false",onKeydown:re[1]||(re[1]=ee=>I(ee,"prompt"))},null,40,Li)),[[ft,g.value]]):Qe((r(),m("textarea",{key:1,"onUpdate:modelValue":re[2]||(re[2]=ee=>c.value=ee),class:"h-32 w-full resize-none rounded-2xl border-0 bg-white p-3 font-mono text-sm text-gray-800 shadow-[0_2px_14px_rgba(0,0,0,0.04)] outline-none ring-1 ring-gray-200/60 transition-all placeholder:text-gray-400 focus:ring-primary-500/40 focus:shadow-[0_4px_20px_rgba(0,0,0,0.08)] dark:bg-page-dark dark:text-gray-200 dark:ring-white/5 dark:placeholder:text-gray-500 dark:focus:ring-primary-500/40",placeholder:t(l)("ai.sqlLab.editor.placeholder"),spellcheck:"false",onKeydown:re[3]||(re[3]=ee=>I(ee,"sql"))},null,40,Di)),[[ft,c.value]]),a("div",Ei,[a("div",Bi,[p(he,{variant:"ghost",size:"xs",onClick:Y},{default:B(()=>[p(ve,{name:"i-heroicons-arrows-right-left",class:"mr-1 h-3.5 w-3.5"}),le(" "+d(h.value==="prompt"?t(l)("ai.sqlLab.editor.switchToSQLMode"):t(l)("ai.sqlLab.editor.switchToPromptMode")),1)]),_:1}),h.value==="sql"?(r(),m("span",Fi,d(t(l)("ai.sqlLab.editor.tip")),1)):R("",!0)]),a("div",Ri,[p(he,{variant:"ghost",size:"sm",disabled:v.value.length===0,onClick:re[4]||(re[4]=ee=>T.value=!0)},{default:B(()=>[p(ve,{name:"i-heroicons-clock",class:"mr-1 h-4 w-4"}),le(" "+d(t(l)("ai.sqlLab.editor.history"))+" ",1),v.value.length>0?(r(),m("span",Vi,"("+d(v.value.length)+")",1)):R("",!0)]),_:1},8,["disabled"]),h.value==="prompt"?(r(),U(he,{key:0,color:"primary",size:"sm",loading:b.value||f.value,disabled:!g.value.trim(),onClick:ne},{default:B(()=>[p(ve,{name:"i-heroicons-sparkles",class:"mr-1 h-4 w-4"}),le(" "+d(t(l)("ai.sqlLab.editor.generateAndRun")),1)]),_:1},8,["loading","disabled"])):(r(),U(he,{key:1,color:"primary",size:"sm",loading:f.value,onClick:A},{default:B(()=>[p(ve,{name:"i-heroicons-play",class:"mr-1 h-4 w-4"}),le(" "+d(t(l)("ai.sqlLab.editor.run")),1)]),_:1},8,["loading"]))])])])]),h.value==="prompt"&&!k.value&&!y.value&&(_.value||C.value||b.value)?(r(),m("div",Oi,[p(t(mt),{class:"mx-auto w-full max-w-3xl p-4"},{default:B(()=>[a("p",Pi,[p(ve,{name:"i-heroicons-cpu-chip",class:"h-4 w-4"}),le(" "+d(t(l)("ai.sqlLab.generate.aiOutput"))+" ",1),$.value?(r(),m("span",ji,d(t(l)("ai.sqlLab.generate.thinking")),1)):b.value?(r(),m("span",Ni,d(t(l)("common.generating")),1)):R("",!0)]),C.value?(r(),m("details",{key:0,class:"mb-3",open:$.value},[a("summary",Wi,d(t(l)("ai.sqlLab.generate.thinkingProcess")),1),a("pre",{ref_key:"thinkingPreRef",ref:S,class:"mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-all rounded border border-gray-200 bg-gray-50 p-2 font-mono text-xs leading-5 text-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400"},d(C.value),513)],8,Ui)):R("",!0),_.value?(r(),m("pre",Hi,d(_.value),1)):C.value?R("",!0):(r(),m("p",Ki,d(t(l)("ai.sqlLab.generate.waitingAI")),1))]),_:1})])):(r(),U(t(Ti),{key:1,ref_key:"resultTableRef",ref:u,result:k.value,error:y.value,sql:c.value,prompt:x.value},null,8,["result","error","sql","prompt"]))]),p(t(Br),{open:T.value,"onUpdate:open":re[5]||(re[5]=ee=>T.value=ee),history:v.value,onExecute:H,onDelete:D},null,8,["open","history"])])}}}),Gi={class:"flex h-full flex-col"},Qi={class:"min-h-0 flex-1 overflow-hidden"},Ji=ue({__name:"LabTab",props:{sessionId:{},chatType:{}},setup(i){const l=i,{t:e}=we(),n=M(()=>[{id:"sql-lab",label:e("ai.tab.sqlLab"),icon:"i-heroicons-command-line"}]),s=z("sql-lab");return(u,o)=>(r(),m("div",Gi,[p(t(ls),{modelValue:s.value,"onUpdate:modelValue":o[0]||(o[0]=c=>s.value=c),items:n.value,"persist-key":"labTab"},null,8,["modelValue","items"]),a("div",Qi,[p(vt,{name:"fade",mode:"out-in"},{default:B(()=>[s.value==="sql-lab"?(r(),U(Yi,{key:0,class:"h-full","session-id":l.sessionId,"chat-type":l.chatType},null,8,["session-id","chat-type"])):R("",!0)]),_:1})])]))}}),Uw=dt(Ji,[["__scopeId","data-v-7fc6fe33"]]),Xi={class:"flex h-full items-center justify-center"},Zi={class:"max-w-sm text-center"},eu={class:"mt-3 text-sm text-gray-400 dark:text-gray-500"},tu=["href"],Ww=ue({__name:"MemoryTab",props:{sessionId:{},sessionName:{}},setup(i){const{t:l,te:e}=we(),n=M(()=>e("analysis.memory.joinLink")?l("analysis.memory.joinLink"):"");return(s,u)=>{const o=_e;return r(),m("div",Xi,[a("div",Zi,[p(o,{name:"i-heroicons-light-bulb",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),a("p",eu,d(t(l)("analysis.memory.comingSoon")),1),n.value?(r(),m("a",{key:0,href:n.value,target:"_blank",rel:"noopener noreferrer",class:"mt-2 inline-block text-sm text-primary-500 hover:text-primary-600 dark:text-primary-400 dark:hover:text-primary-300"},d(n.value),9,tu)):R("",!0)])])}}});function au(i,l){if(typeof i!="object"||i===null)return!1;const e=lt(i,l);return e!=null&&e!==""}function Ya(i,l){return l?{xs:44,sm:48,md:52,lg:56,xl:60}[i]:{xs:24,sm:28,md:32,lg:36,xl:40}[i]}function su(i,l,e,n){const s=Ya(l,!0),u=Ya(l,!1);return n?()=>s:e?o=>au(i[o],e)?s:u:()=>u}const nu={slots:{base:["relative group rounded-md inline-flex items-center disabled:cursor-not-allowed disabled:opacity-75","transition-colors"],leading:"absolute inset-y-0 start-0 flex items-center",leadingIcon:"shrink-0 text-dimmed",leadingAvatar:"shrink-0",leadingAvatarSize:"",trailing:"absolute inset-y-0 end-0 flex items-center",trailingIcon:"shrink-0 text-dimmed",value:"truncate pointer-events-none",placeholder:"truncate text-dimmed",arrow:"fill-bg stroke-default",content:["max-h-[min(15rem,var(--reka-select-content-available-height,15rem))] w-(--reka-select-trigger-width) bg-default shadow-lg rounded-md ring ring-default overflow-hidden origin-(--reka-select-content-transform-origin) pointer-events-auto flex flex-col","max-h-[min(15rem,var(--reka-combobox-content-available-height,15rem))] origin-(--reka-combobox-content-transform-origin) w-(--reka-combobox-trigger-width)"],viewport:"relative scroll-py-1 overflow-y-auto flex-1",group:"p-1 isolate",empty:"text-center text-muted",label:"font-semibold text-highlighted",separator:"-mx-1 my-1 h-px bg-border",item:["group relative w-full flex items-start select-none outline-none before:absolute before:z-[-1] before:inset-px before:rounded-md data-disabled:cursor-not-allowed data-disabled:opacity-75 text-default data-highlighted:not-data-disabled:text-highlighted data-highlighted:not-data-disabled:before:bg-elevated/50","transition-colors before:transition-colors"],itemLeadingIcon:["shrink-0 text-dimmed group-data-highlighted:not-group-data-disabled:text-default","transition-colors"],itemLeadingAvatar:"shrink-0",itemLeadingAvatarSize:"",itemLeadingChip:"shrink-0",itemLeadingChipSize:"",itemTrailing:"ms-auto inline-flex gap-1.5 items-center",itemTrailingIcon:"shrink-0",itemWrapper:"flex-1 flex flex-col min-w-0",itemLabel:"truncate",itemDescription:"truncate text-muted",input:"border-b border-default",focusScope:"flex flex-col min-h-0",trailingClear:"p-0"},variants:{fieldGroup:{horizontal:"not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]",vertical:"not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]"},size:{xs:{base:"px-2 py-1 text-xs gap-1",leading:"ps-2",trailing:"pe-2",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4",label:"p-1 text-[10px]/3 gap-1",item:"p-1 text-xs gap-1",itemLeadingIcon:"size-4",itemLeadingAvatarSize:"3xs",itemLeadingChip:"size-4",itemLeadingChipSize:"sm",itemTrailingIcon:"size-4",empty:"p-2 text-xs"},sm:{base:"px-2.5 py-1.5 text-xs gap-1.5",leading:"ps-2.5",trailing:"pe-2.5",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4",label:"p-1.5 text-[10px]/3 gap-1.5",item:"p-1.5 text-xs gap-1.5",itemLeadingIcon:"size-4",itemLeadingAvatarSize:"3xs",itemLeadingChip:"size-4",itemLeadingChipSize:"sm",itemTrailingIcon:"size-4",empty:"p-2.5 text-xs"},md:{base:"px-2.5 py-1.5 text-sm gap-1.5",leading:"ps-2.5",trailing:"pe-2.5",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5",label:"p-1.5 text-xs gap-1.5",item:"p-1.5 text-sm gap-1.5",itemLeadingIcon:"size-5",itemLeadingAvatarSize:"2xs",itemLeadingChip:"size-5",itemLeadingChipSize:"md",itemTrailingIcon:"size-5",empty:"p-2.5 text-sm"},lg:{base:"px-3 py-2 text-sm gap-2",leading:"ps-3",trailing:"pe-3",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5",label:"p-2 text-xs gap-2",item:"p-2 text-sm gap-2",itemLeadingIcon:"size-5",itemLeadingAvatarSize:"2xs",itemLeadingChip:"size-5",itemLeadingChipSize:"md",itemTrailingIcon:"size-5",empty:"p-3 text-sm"},xl:{base:"px-3 py-2 text-base gap-2",leading:"ps-3",trailing:"pe-3",leadingIcon:"size-6",leadingAvatarSize:"xs",trailingIcon:"size-6",label:"p-2 text-sm gap-2",item:"p-2 text-base gap-2",itemLeadingIcon:"size-6",itemLeadingAvatarSize:"xs",itemLeadingChip:"size-6",itemLeadingChipSize:"lg",itemTrailingIcon:"size-6",empty:"p-3 text-base"}},variant:{outline:"text-highlighted bg-default ring ring-inset ring-accented hover:bg-elevated disabled:bg-default",soft:"text-highlighted bg-elevated/50 hover:bg-elevated focus:bg-elevated disabled:bg-elevated/50",subtle:"text-highlighted bg-elevated ring ring-inset ring-accented hover:bg-accented/75 disabled:bg-elevated",ghost:"text-highlighted bg-transparent hover:bg-elevated focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent",none:"text-highlighted bg-transparent focus:outline-none"},color:{primary:"",secondary:"",success:"",info:"",warning:"",error:"",neutral:""},leading:{true:""},trailing:{true:""},loading:{true:""},highlight:{true:""},fixed:{false:""},type:{file:"file:me-1.5 file:font-medium file:text-muted file:outline-none"},position:{popper:{content:"data-[state=open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in]"},"item-aligned":{content:""}},multiple:{true:""},virtualize:{true:{viewport:"p-1 isolate"},false:{viewport:"divide-y divide-default"}}},compoundVariants:[{color:"primary",variant:["outline","subtle"],class:"outline-primary/25 focus-visible:outline-3 focus-visible:ring-primary"},{color:"secondary",variant:["outline","subtle"],class:"outline-secondary/25 focus-visible:outline-3 focus-visible:ring-secondary"},{color:"success",variant:["outline","subtle"],class:"outline-success/25 focus-visible:outline-3 focus-visible:ring-success"},{color:"info",variant:["outline","subtle"],class:"outline-info/25 focus-visible:outline-3 focus-visible:ring-info"},{color:"warning",variant:["outline","subtle"],class:"outline-warning/25 focus-visible:outline-3 focus-visible:ring-warning"},{color:"error",variant:["outline","subtle"],class:"outline-error/25 focus-visible:outline-3 focus-visible:ring-error"},{color:"primary",variant:["soft","ghost"],class:"outline-primary/25 focus-visible:outline-3"},{color:"secondary",variant:["soft","ghost"],class:"outline-secondary/25 focus-visible:outline-3"},{color:"success",variant:["soft","ghost"],class:"outline-success/25 focus-visible:outline-3"},{color:"info",variant:["soft","ghost"],class:"outline-info/25 focus-visible:outline-3"},{color:"warning",variant:["soft","ghost"],class:"outline-warning/25 focus-visible:outline-3"},{color:"error",variant:["soft","ghost"],class:"outline-error/25 focus-visible:outline-3"},{color:"primary",highlight:!0,class:"ring ring-inset ring-primary"},{color:"secondary",highlight:!0,class:"ring ring-inset ring-secondary"},{color:"success",highlight:!0,class:"ring ring-inset ring-success"},{color:"info",highlight:!0,class:"ring ring-inset ring-info"},{color:"warning",highlight:!0,class:"ring ring-inset ring-warning"},{color:"error",highlight:!0,class:"ring ring-inset ring-error"},{color:"neutral",variant:["outline","subtle"],class:"outline-inverted/25 focus-visible:outline-3 focus-visible:ring-inverted"},{color:"neutral",variant:["soft","ghost"],class:"outline-inverted/25 focus-visible:outline-3"},{color:"neutral",highlight:!0,class:"ring ring-inset ring-inverted"},{leading:!0,size:"xs",class:"ps-7"},{leading:!0,size:"sm",class:"ps-8"},{leading:!0,size:"md",class:"ps-9"},{leading:!0,size:"lg",class:"ps-10"},{leading:!0,size:"xl",class:"ps-11"},{trailing:!0,size:"xs",class:"pe-7"},{trailing:!0,size:"sm",class:"pe-8"},{trailing:!0,size:"md",class:"pe-9"},{trailing:!0,size:"lg",class:"pe-10"},{trailing:!0,size:"xl",class:"pe-11"},{loading:!0,leading:!0,class:{leadingIcon:"animate-spin"}},{loading:!0,leading:!1,trailing:!0,class:{trailingIcon:"animate-spin"}},{fixed:!1,size:"xs",class:"md:text-xs"},{fixed:!1,size:"sm",class:"md:text-xs"},{fixed:!1,size:"md",class:"md:text-sm"},{fixed:!1,size:"lg",class:"md:text-sm"}],defaultVariants:{size:"md",color:"primary",variant:"outline",position:"popper"}},Da=Object.assign({inheritAttrs:!1},{__name:"SelectMenu",props:qt({id:{type:String,required:!1},placeholder:{type:String,required:!1},searchInput:{type:[Boolean,Object],required:!1,default:!0},color:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},required:{type:Boolean,required:!1},trailingIcon:{type:null,required:!1},selectedIcon:{type:null,required:!1},clear:{type:[Boolean,Object],required:!1},clearIcon:{type:null,required:!1},content:{type:Object,required:!1},arrow:{type:[Boolean,Object],required:!1},portal:{type:[Boolean,String],required:!1,skipCheck:!0,default:!0},virtualize:{type:[Boolean,Object],required:!1,default:!1},valueKey:{type:null,required:!1},labelKey:{type:null,required:!1,default:"label"},descriptionKey:{type:null,required:!1,default:"description"},items:{type:null,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1},modelModifiers:{type:null,required:!1},multiple:{type:Boolean,required:!1},highlight:{type:Boolean,required:!1},createItem:{type:[Boolean,String,Object],required:!1},filterFields:{type:Array,required:!1},ignoreFilter:{type:Boolean,required:!1},autofocus:{type:Boolean,required:!1},autofocusDelay:{type:Number,required:!1,default:0},class:{type:null,required:!1},ui:{type:Object,required:!1},open:{type:Boolean,required:!1},defaultOpen:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},name:{type:String,required:!1},resetSearchTermOnBlur:{type:Boolean,required:!1,default:!0},resetSearchTermOnSelect:{type:Boolean,required:!1,default:!0},resetModelValueOnClear:{type:Boolean,required:!1,default:!0},highlightOnHover:{type:Boolean,required:!1},by:{type:[String,Function],required:!1},icon:{type:null,required:!1},avatar:{type:Object,required:!1},leading:{type:Boolean,required:!1},leadingIcon:{type:null,required:!1},trailing:{type:Boolean,required:!1},loading:{type:Boolean,required:!1},loadingIcon:{type:null,required:!1}},{searchTerm:{type:String,default:""},searchTermModifiers:{}}),emits:qt(["change","blur","focus","create","clear","highlight","update:modelValue","update:open"],["update:searchTerm"]),setup(i,{expose:l,emit:e}){const n=i,s=e,u=Qt(),o=Ca("selectMenu",n),c=Wt(i,"searchTerm",{type:String,default:""}),{t:g}=xn(),h=Ia(),{filterGroups:f}=Fl(),b=rs(is(o,"modelValue","defaultValue","open","defaultOpen","required","multiple","resetSearchTermOnBlur","resetSearchTermOnSelect","resetModelValueOnClear","highlightOnHover","by"),s),y=bn(We(()=>o.portal)),k=We(()=>Tt(o.content,{side:"bottom",sideOffset:8,collisionPadding:8,position:"popper"})),x=We(()=>Tt(o.arrow,{rounded:!0})),_=M(()=>typeof o.clear=="object"?o.clear:{}),C=We(()=>o.virtualize?Tt(typeof o.virtualize=="boolean"?{}:o.virtualize,{estimateSize:su(Q.value,re.value||"md",o.descriptionKey,!!u["item-description"])}):!1),$=We(()=>Tt(o.searchInput,{placeholder:g("selectMenu.search"),variant:"none"})),{emitFormBlur:S,emitFormFocus:T,emitFormInput:v,emitFormChange:w,size:E,color:F,id:D,name:A,highlight:I,disabled:q,ariaAttrs:Y}=Sa(n),{orientation:G,size:Z}=us(n),{isLeading:ce,isTrailing:ne,leadingIconName:H,trailingIconName:W}=Ta(We(()=>Tt(o,{trailingIcon:h.ui.icons.chevronDown}))),re=M(()=>Z.value||E.value),[ve,he]=Ra(),[ee,te]=Ra({props:{item:{type:[Object,String,Number,Boolean],required:!0},index:{type:Number,required:!1}}}),j=M(()=>$t({extend:$t(nu),...h.ui?.selectMenu||{}})({color:F.value??o.color,variant:o.variant,size:re?.value??o.size,loading:o.loading,highlight:I.value??o.highlight,leading:ce.value||!!o.avatar||!!u.leading,trailing:ne.value||!!u.trailing,fieldGroup:G.value,virtualize:!!o.virtualize,multiple:o.multiple}));function de(L){if(o.multiple&&Array.isArray(L)){const P=L.map(N=>Va(xe.value,N,{labelKey:o.labelKey,valueKey:o.valueKey,by:o.by})).filter(N=>N!=null&&N!=="");return P.length>0?P.join(", "):void 0}return Va(xe.value,L,{labelKey:o.labelKey,valueKey:o.valueKey,by:o.by})}const be=M(()=>o.items?.length?$n(o.items)?o.items:[o.items]:[]),xe=M(()=>be.value.flatMap(L=>L)),oe=M(()=>{if(o.ignoreFilter||!c.value)return be.value;const L=Array.isArray(o.filterFields)?o.filterFields:[o.labelKey];return f(be.value,c.value,{fields:L,isStructural:P=>Se(P)&&!!P.type&&["label","separator"].includes(P.type)})}),Q=M(()=>oe.value.flatMap(L=>L)),J=M(()=>{if(!o.createItem||!c.value)return!1;const L=o.valueKey?{[o.valueKey]:c.value}:c.value;return typeof o.createItem=="object"&&o.createItem.when==="always"||o.createItem==="always"?!Q.value.find(P=>wn(P,L,o.by??o.valueKey)):!Q.value.length}),ge=M(()=>typeof o.createItem=="object"?o.createItem.position:"bottom"),ke=At("triggerRef");function $e(){o.autofocus&&ke.value?.$el?.focus({focusVisible:!0})}Re(()=>{setTimeout(()=>{$e()},o.autofocusDelay)});function Le(L){if(cs(o.modelValue)===L)return;o.modelModifiers?.trim&&(typeof L=="string"||L===null||L===void 0)&&(L=L?.trim()??null),o.modelModifiers?.number&&(L=ds(L)),o.modelModifiers?.nullable&&(L??=null),o.modelModifiers?.optional&&!o.modelModifiers?.nullable&&L!==null&&(L??=void 0);const P=new Event("change",{target:{value:L}});s("change",P),w(),v(),o.resetSearchTermOnSelect&&(c.value="")}const Be=z(!1);function Te(L){Be.value=L;let P;if(L){const N=new FocusEvent("focus");s("focus",N),T(),clearTimeout(P)}else{const N=new FocusEvent("blur");s("blur",N),S(),o.resetSearchTermOnBlur&&(P=setTimeout(()=>{c.value=""},100))}}function Pe(L){L.preventDefault(),L.stopPropagation(),s("create",c.value)}function je(L,P){if(Se(P)){if(P.disabled){L.preventDefault();return}P.onSelect?.(L)}}function Se(L){return typeof L=="object"&&L!==null}function me(L){return o.multiple&&Array.isArray(L)?L.length===0:L==null||L===""}function O(){s("clear")}const V=At("viewportRef"),K=At("comboboxRootRef");return fe(()=>o.items,async()=>{Be.value&&(await De(),K.value?.highlightFirstItem?.())},{flush:"post"}),l({triggerRef:We(()=>ke.value?.$el),viewportRef:We(()=>V.value)}),(L,P)=>(r(),m(ie,null,[p(t(ve),null,{default:B(()=>[p(t(Ha),{"data-slot":"item",class:X(j.value.item({class:t(o).ui?.item})),value:c.value,onSelect:Pe},{default:B(()=>[a("span",{"data-slot":"itemLabel",class:X(j.value.itemLabel({class:t(o).ui?.itemLabel}))},[ye(L.$slots,"create-item-label",{item:c.value},()=>[le(d(t(g)("selectMenu.create",{label:c.value})),1)])],2)]),_:3},8,["class","value"])]),_:3}),p(t(ee),null,{default:B(({item:N,index:ae})=>[Se(N)&&N.type==="label"?(r(),U(t(gl),{key:0,"data-slot":"label",class:X(j.value.label({class:[t(o).ui?.label,N.ui?.label,N.class]}))},{default:B(()=>[le(d(t(lt)(N,t(o).labelKey)),1)]),_:2},1032,["class"])):Se(N)&&N.type==="separator"?(r(),U(t(vl),{key:1,"data-slot":"separator",class:X(j.value.separator({class:[t(o).ui?.separator,N.ui?.separator,N.class]}))},null,8,["class"])):(r(),U(t(Ha),{key:2,"data-slot":"item",class:X(j.value.item({class:[t(o).ui?.item,Se(N)&&N.ui?.item,Se(N)&&N.class]})),disabled:Se(N)&&N.disabled,value:t(o).valueKey&&Se(N)?t(lt)(N,t(o).valueKey):N,onSelect:se=>je(se,N)},{default:B(()=>[ye(L.$slots,"item",{item:N,index:ae,ui:j.value},()=>[ye(L.$slots,"item-leading",{item:N,index:ae,ui:j.value},()=>[Se(N)&&N.icon?(r(),U(_e,{key:0,name:N.icon,"data-slot":"itemLeadingIcon",class:X(j.value.itemLeadingIcon({class:[t(o).ui?.itemLeadingIcon,N.ui?.itemLeadingIcon]}))},null,8,["name","class"])):Se(N)&&N.avatar?(r(),U(Ht,ze({key:1,size:N.ui?.itemLeadingAvatarSize||t(o).ui?.itemLeadingAvatarSize||j.value.itemLeadingAvatarSize()},N.avatar,{"data-slot":"itemLeadingAvatar",class:j.value.itemLeadingAvatar({class:[t(o).ui?.itemLeadingAvatar,N.ui?.itemLeadingAvatar]})}),null,16,["size","class"])):Se(N)&&N.chip?(r(),U(kn,ze({key:2,size:N.ui?.itemLeadingChipSize||t(o).ui?.itemLeadingChipSize||j.value.itemLeadingChipSize(),inset:"",standalone:""},N.chip,{"data-slot":"itemLeadingChip",class:j.value.itemLeadingChip({class:[t(o).ui?.itemLeadingChip,N.ui?.itemLeadingChip]})}),null,16,["size","class"])):R("",!0)]),a("span",{"data-slot":"itemWrapper",class:X(j.value.itemWrapper({class:[t(o).ui?.itemWrapper,Se(N)&&N.ui?.itemWrapper]}))},[a("span",{"data-slot":"itemLabel",class:X(j.value.itemLabel({class:[t(o).ui?.itemLabel,Se(N)&&N.ui?.itemLabel]}))},[ye(L.$slots,"item-label",{item:N,index:ae},()=>[le(d(Se(N)?t(lt)(N,t(o).labelKey):N),1)])],2),Se(N)&&(t(lt)(N,t(o).descriptionKey)||u["item-description"])?(r(),m("span",{key:0,"data-slot":"itemDescription",class:X(j.value.itemDescription({class:[t(o).ui?.itemDescription,Se(N)&&N.ui?.itemDescription]}))},[ye(L.$slots,"item-description",{item:N,index:ae},()=>[le(d(t(lt)(N,t(o).descriptionKey)),1)])],2)):R("",!0)],2),a("span",{"data-slot":"itemTrailing",class:X(j.value.itemTrailing({class:[t(o).ui?.itemTrailing,Se(N)&&N.ui?.itemTrailing]}))},[ye(L.$slots,"item-trailing",{item:N,index:ae,ui:j.value}),p(t(dl),{"as-child":""},{default:B(()=>[p(_e,{name:t(o).selectedIcon||t(h).ui.icons.check,"data-slot":"itemTrailingIcon",class:X(j.value.itemTrailingIcon({class:[t(o).ui?.itemTrailingIcon,Se(N)&&N.ui?.itemTrailingIcon]}))},null,8,["name","class"])]),_:2},1024)],2)])]),_:2},1032,["class","disabled","value","onSelect"]))]),_:3}),p(t(Uo),ze({ref_key:"comboboxRootRef",ref:K},t(b),{"ignore-filter":"","as-child":"",name:t(A),disabled:t(q),"onUpdate:modelValue":Le,"onUpdate:open":Te}),{default:B(({modelValue:N,open:ae})=>[p(t(Ho),{"as-child":""},{default:B(()=>[p(t(xl),ze({id:t(D),ref_key:"triggerRef",ref:ke,"data-slot":"base",class:j.value.base({class:[t(o).ui?.base,t(o).class]}),tabindex:"0"},{...L.$attrs,...t(Y)}),{default:B(()=>[t(ce)||t(o).avatar||u.leading?(r(),m("span",{key:0,"data-slot":"leading",class:X(j.value.leading({class:t(o).ui?.leading}))},[ye(L.$slots,"leading",{modelValue:N,open:ae,ui:j.value},()=>[t(ce)&&t(H)?(r(),U(_e,{key:0,name:t(H),"data-slot":"leadingIcon",class:X(j.value.leadingIcon({class:t(o).ui?.leadingIcon}))},null,8,["name","class"])):t(o).avatar?(r(),U(Ht,ze({key:1,size:t(o).ui?.itemLeadingAvatarSize||j.value.itemLeadingAvatarSize()},t(o).avatar,{"data-slot":"itemLeadingAvatar",class:j.value.itemLeadingAvatar({class:t(o).ui?.itemLeadingAvatar})}),null,16,["size","class"])):R("",!0)])],2)):R("",!0),ye(L.$slots,"default",{modelValue:N,open:ae,ui:j.value},()=>[(r(!0),m(ie,null,pe([de(N)],se=>(r(),m(ie,{key:se},[se!=null?(r(),m("span",{key:0,"data-slot":"value",class:X(j.value.value({class:t(o).ui?.value}))},d(se),3)):(r(),m("span",{key:1,"data-slot":"placeholder",class:X(j.value.placeholder({class:t(o).ui?.placeholder}))},d(t(o).placeholder??" "),3))],64))),128))]),t(ne)||u.trailing||t(o).clear?(r(),m("span",{key:1,"data-slot":"trailing",class:X(j.value.trailing({class:t(o).ui?.trailing}))},[ye(L.$slots,"trailing",{modelValue:N,open:ae,ui:j.value},()=>[t(o).clear&&!me(N)?(r(),U(t(el),{key:0,"as-child":""},{default:B(()=>[p(Ue,ze({as:"span",icon:t(o).clearIcon||t(h).ui.icons.close,size:re.value,variant:"link",color:"neutral",tabindex:"-1"},_.value,{"data-slot":"trailingClear",class:j.value.trailingClear({class:t(o).ui?.trailingClear}),onClick:Oe(O,["stop"])}),null,16,["icon","size","class"])]),_:1})):t(W)?(r(),U(_e,{key:1,name:t(W),"data-slot":"trailingIcon",class:X(j.value.trailingIcon({class:t(o).ui?.trailingIcon}))},null,8,["name","class"])):R("",!0)])],2)):R("",!0)]),_:2},1040,["id","class"])]),_:2},1024),p(t(hl),ht(zt(t(y))),{default:B(()=>[p(t(_n),null,{default:B(()=>[p(t(al),ze({"data-slot":"content",class:j.value.content({class:t(o).ui?.content})},k.value),{default:B(()=>[p(t(as),{trapped:"","data-slot":"focusScope",class:X(j.value.focusScope({class:t(o).ui?.focusScope}))},{default:B(()=>[ye(L.$slots,"content-top"),t(o).searchInput?(r(),U(t(il),{key:0,modelValue:c.value,"onUpdate:modelValue":P[1]||(P[1]=se=>c.value=se),"display-value":()=>c.value,"as-child":""},{default:B(()=>[p(Bt,ze({autofocus:"",autocomplete:"off",size:re.value},$.value,{"model-modifiers":{trim:t(o).modelModifiers?.trim},"data-slot":"input",class:j.value.input({class:t(o).ui?.input}),onChange:P[0]||(P[0]=Oe(()=>{},["stop"]))}),null,16,["size","model-modifiers","class"])]),_:1},8,["modelValue","display-value"])):R("",!0),p(t(nl),{"data-slot":"empty",class:X(j.value.empty({class:t(o).ui?.empty}))},{default:B(()=>[ye(L.$slots,"empty",{searchTerm:c.value},()=>[le(d(c.value?t(g)("selectMenu.noMatch",{searchTerm:c.value}):t(g)("selectMenu.noData")),1)])]),_:3},8,["class"]),a("div",{ref_key:"viewportRef",ref:V,role:"presentation","data-slot":"viewport",class:X(j.value.viewport({class:t(o).ui?.viewport}))},[t(o).virtualize?(r(),m(ie,{key:0},[J.value&&ge.value==="top"?(r(),U(t(he),{key:0})):R("",!0),p(t(kl),ze({options:Q.value,"text-content":se=>Se(se)?t(lt)(se,t(o).labelKey):String(se)},C.value),{default:B(({option:se,virtualItem:Ve})=>[p(t(te),{item:se,index:Ve.index},null,8,["item","index"])]),_:1},16,["options","text-content"]),J.value&&ge.value==="bottom"?(r(),U(t(he),{key:1})):R("",!0)],64)):(r(),m(ie,{key:1},[J.value&&ge.value==="top"?(r(),U(t(ra),{key:0,"data-slot":"group",class:X(j.value.group({class:t(o).ui?.group}))},{default:B(()=>[p(t(he))]),_:1},8,["class"])):R("",!0),(r(!0),m(ie,null,pe(oe.value,(se,Ve)=>(r(),U(t(ra),{key:`group-${Ve}`,"data-slot":"group",class:X(j.value.group({class:t(o).ui?.group}))},{default:B(()=>[(r(!0),m(ie,null,pe(se,(qe,Me)=>(r(),U(t(te),{key:`group-${Ve}-${Me}`,item:qe,index:Me},null,8,["item","index"]))),128))]),_:2},1032,["class"]))),128)),J.value&&ge.value==="bottom"?(r(),U(t(ra),{key:1,"data-slot":"group",class:X(j.value.group({class:t(o).ui?.group}))},{default:B(()=>[p(t(he))]),_:1},8,["class"])):R("",!0)],64))],2),ye(L.$slots,"content-bottom")]),_:3},8,["class"]),t(o).arrow?(r(),U(t(Xo),ze({key:0},x.value,{"data-slot":"arrow",class:j.value.arrow({class:t(o).ui?.arrow})}),null,16,["class"])):R("",!0)]),_:3},16,["class"])]),_:3})]),_:3},16)]),_:3},16,["name","disabled"])],64))}}),ou={class:"h-full p-3"},lu={class:"relative z-20 flex items-center gap-2 border-b border-gray-200 px-4 py-2 dark:border-gray-700"},ru={key:0,class:"mx-4 mt-2 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-400"},iu={class:"flex-1 overflow-auto"},uu={key:0,class:"flex h-full items-center justify-center"},cu={class:"text-sm text-gray-400"},du={key:1,class:"w-full border-collapse text-xs"},mu={class:"sticky top-0 bg-gray-50 dark:bg-page-dark"},gu={class:"font-mono text-xs font-medium text-gray-700 dark:text-gray-300"},pu={class:"text-[10px] leading-tight text-gray-400"},hu={class:"border-b border-r border-gray-100 px-2 py-1.5 text-gray-400 dark:border-gray-800"},fu=["title"],vu=["onUpdate:modelValue"],yu={class:"w-full truncate px-2 py-1.5"},xu={key:0,class:"italic text-gray-400"},bu={key:1},ku={class:"border-b border-gray-100 px-2 py-1.5 text-center dark:border-gray-800"},_u={key:0,class:"flex items-center justify-center gap-1"},wu={key:1,class:"flex items-center justify-center gap-1"},$u={class:"flex items-center justify-between border-t border-gray-200 px-4 py-2 dark:border-gray-700"},Cu={class:"text-xs text-gray-500 dark:text-gray-400"},Su={key:0,class:"flex items-center gap-3"},Iu={class:"text-xs text-gray-500 dark:text-gray-400"},Ot=100,Tu=ue({__name:"TableBrowser",props:{sessionId:{}},setup(i){const l=["member","meta","message","message_context","member_name_history"],{t:e,locale:n}=we(),s=i,u=z(localStorage.getItem("debug_dbSource")||"chat"),o=z([]),c=z(""),g=z(null),h=z(!1),f=z(null),b=z(1),y=z(0),k=M(()=>Math.max(1,Math.ceil(y.value/Ot))),x=z(null),_=z({}),C=z(!1),$=M(()=>u.value==="ai"),S=z([]),T=z(""),v=M(()=>$.value&&c.value==="ai_message"&&S.value.length>0),w=M(()=>{const ee={label:e("analysis.debug.tableBrowser.allConversations"),value:"__all__"},te=S.value.map(j=>({label:j.title||j.id.slice(0,16),value:j.id}));return[ee,...te]});async function E(){if(!$.value){S.value=[];return}try{const ee=s.sessionId.replace(/'/g,"''"),te=await Ye().executeAiSQL(`SELECT id, title FROM ai_chat WHERE session_id = '${ee}' ORDER BY updated_at DESC`);S.value=te.rows.map(j=>({id:String(j[0]),title:j[1]?String(j[1]):null})),T.value="__all__"}catch{S.value=[]}}const F=M(()=>[{label:e("analysis.debug.tableBrowser.chatDb"),value:"chat"},{label:e("analysis.debug.tableBrowser.aiDb"),value:"ai"}]),D=M(()=>{const ee=[...o.value];return ee.sort((te,j)=>{const de=l.indexOf(te.name),be=l.indexOf(j.name);return de!==-1&&be!==-1?de-be:de!==-1?-1:be!==-1?1:0}),ee}),A=M(()=>D.value.map(ee=>({label:ee.name,value:ee.name})));async function I(ee){return u.value==="ai"?await Ye().executeAiSQL(ee):await Ke().executeSQL(s.sessionId,ee)}async function q(){try{if(u.value==="ai"?o.value=await Ye().getAiSchema():o.value=await Ke().getSchema(s.sessionId),D.value.length>0){const ee=$.value?"ai_message":D.value[0].name;c.value=D.value.some(te=>te.name===ee)?ee:D.value[0].name}else c.value="",g.value=null}catch(ee){console.error("Failed to load schema:",ee)}}function Y(){if(!$.value)return"";const ee=s.sessionId.replace(/'/g,"''"),te=c.value;return te==="ai_chat"?` WHERE "session_id" = '${ee}'`:te==="ai_message"?T.value&&T.value!=="__all__"?` WHERE "ai_chat_id" = '${T.value.replace(/'/g,"''")}'`:` WHERE "ai_chat_id" IN (SELECT "id" FROM "ai_chat" WHERE "session_id" = '${ee}')`:""}async function G(){if(c.value){h.value=!0,f.value=null,x.value=null;try{const ee=Y(),te=await I(`SELECT COUNT(*) as cnt FROM "${c.value}"${ee}`);y.value=te?.rows?.[0]?.[0]??0;const j=(b.value-1)*Ot;g.value=await I(`SELECT * FROM "${c.value}"${ee} ORDER BY rowid DESC LIMIT ${Ot} OFFSET ${j}`)}catch(ee){f.value=ee.message||String(ee),g.value=null}finally{h.value=!1}}}function Z(ee){if(!g.value)return;x.value=ee;const te=g.value.rows[ee],j={};g.value.columns.forEach((de,be)=>{j[de]=te[be]==null?"":String(te[be])}),_.value=j}function ce(){x.value=null,_.value={}}async function ne(){if(x.value===null||!g.value)return;const ee=c.value,te=o.value.find(J=>J.name===ee);if(!te)return;const j=te.columns.find(J=>J.pk);if(!j){f.value="No primary key found for this table";return}const de=g.value.rows[x.value],be=g.value.columns.indexOf(j.name),xe=de[be],oe=g.value.columns.filter(J=>J!==j.name).map(J=>`"${J}" = '${_.value[J].replace(/'/g,"''")}'`).join(", "),Q=`UPDATE "${ee}" SET ${oe} WHERE "${j.name}" = '${String(xe).replace(/'/g,"''")}'`;try{await I(Q),ce(),await G()}catch(J){f.value=J.message||String(J)}}async function H(ee){if(!g.value)return;const te=c.value,j=o.value.find(J=>J.name===te);if(!j)return;const de=j.columns.find(J=>J.pk);if(!de){f.value="No primary key found for this table";return}const be=g.value.rows[ee],xe=g.value.columns.indexOf(de.name),oe=be[xe],Q=`DELETE FROM "${te}" WHERE "${de.name}" = '${String(oe).replace(/'/g,"''")}'`;try{await I(Q),await G()}catch(J){f.value=J.message||String(J)}}function W(ee){confirm(e("analysis.debug.tableBrowser.confirmDelete"))&&H(ee)}async function re(){if(confirm(e("analysis.debug.tableBrowser.confirmClearDebug"))){C.value=!0;try{(await Ye().clearDebugContext()).success&&await G()}catch(ee){f.value=ee.message||String(ee)}finally{C.value=!1}}}function ve(ee){navigator.clipboard.writeText(ee)}function he(ee,te,j){if(!g.value)return[];const de=ee==null?"NULL":String(ee),be=g.value.rows[j],xe={};return g.value.columns.forEach((oe,Q)=>{xe[oe]=be[Q]}),[[{label:e("analysis.debug.tableBrowser.copyCell"),class:"p-2",onSelect:()=>ve(de)},{label:e("analysis.debug.tableBrowser.editRow"),class:"p-2",onSelect:()=>Z(j)},{label:e("analysis.debug.tableBrowser.copyRow"),class:"p-2",onSelect:()=>ve(JSON.stringify(xe,null,2))},{label:e("analysis.debug.tableBrowser.deleteRow"),class:"p-2 text-red-600 dark:text-red-400",onSelect:()=>H(j)}]]}return fe(u,ee=>{localStorage.setItem("debug_dbSource",ee),c.value="",g.value=null,y.value=0,b.value=1,T.value="",q(),E()}),fe(c,ee=>{ee&&(b.value=1,G())}),fe(T,()=>{c.value==="ai_message"&&(b.value=1,G())}),fe(b,()=>{G()}),Re(async()=>{await Promise.all([q(),E()]),c.value&&await G()}),(ee,te)=>{const j=Da,de=Ue,be=Cn;return r(),m("div",ou,[p(t(mt),{shadow:!1,class:"flex h-full min-w-0 flex-col"},{default:B(()=>[a("div",lu,[p(t(pt),{modelValue:u.value,"onUpdate:modelValue":te[0]||(te[0]=xe=>u.value=xe),items:F.value,size:"xs"},null,8,["modelValue","items"]),te[5]||(te[5]=a("div",{class:"mx-1 h-4 w-px bg-gray-200 dark:bg-gray-700"},null,-1)),a("div",{class:X([$.value?"max-w-[50%]":"flex-1","min-w-0"])},[p(t(pt),{modelValue:c.value,"onUpdate:modelValue":te[1]||(te[1]=xe=>c.value=xe),items:A.value,size:"xs"},null,8,["modelValue","items"])],2),v.value?(r(),U(j,{key:0,modelValue:T.value,"onUpdate:modelValue":te[2]||(te[2]=xe=>T.value=xe),items:w.value,"value-key":"value",class:"w-48",size:"xs",ui:{content:"z-50"}},null,8,["modelValue","items"])):R("",!0),te[6]||(te[6]=a("div",{class:"flex-1"},null,-1)),$.value&&c.value==="ai_message"?(r(),U(de,{key:1,variant:"ghost",size:"xs",color:"error",icon:"i-heroicons-trash",loading:C.value,onClick:re},{default:B(()=>[le(d(t(e)("analysis.debug.tableBrowser.clearDebugContext")),1)]),_:1},8,["loading"])):R("",!0),p(de,{variant:"ghost",size:"xs",icon:"i-heroicons-arrow-path",loading:h.value,onClick:G},{default:B(()=>[le(d(t(e)("analysis.debug.tableBrowser.refresh")),1)]),_:1},8,["loading"])]),f.value?(r(),m("div",ru,d(f.value),1)):R("",!0),a("div",iu,[!g.value&&!h.value?(r(),m("div",uu,[a("p",cu,d(t(e)("analysis.debug.tableBrowser.noData")),1)])):g.value?(r(),m("table",du,[a("thead",mu,[a("tr",null,[te[7]||(te[7]=a("th",{class:"whitespace-nowrap border-b border-r border-gray-200 px-2 py-1.5 text-left font-medium text-gray-500 dark:border-gray-700 dark:text-gray-400"}," # ",-1)),(r(!0),m(ie,null,pe(g.value.columns,xe=>(r(),m("th",{key:xe,class:"border-b border-r border-gray-200 px-2 py-1.5 text-left dark:border-gray-700"},[a("div",gu,d(xe),1),a("div",pu,d(t(La)(c.value,xe,t(n))),1)]))),128)),te[8]||(te[8]=a("th",{class:"whitespace-nowrap border-b border-gray-200 px-2 py-1.5 text-center font-medium text-gray-500 dark:border-gray-700 dark:text-gray-400"}," 操作 ",-1))])]),a("tbody",null,[(r(!0),m(ie,null,pe(g.value.rows,(xe,oe)=>(r(),m("tr",{key:oe,class:"transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[a("td",hu,d((b.value-1)*Ot+oe+1),1),(r(!0),m(ie,null,pe(xe,(Q,J)=>(r(),m("td",{key:J,class:"max-w-[300px] border-b border-r border-gray-100 p-0 text-gray-700 dark:border-gray-800 dark:text-gray-300",title:Q==null?"NULL":String(Q)},[x.value===oe?Qe((r(),m("input",{key:0,"onUpdate:modelValue":ge=>_.value[g.value.columns[J]]=ge,class:"w-full px-2 py-1.5 rounded border border-gray-300 bg-white text-xs dark:border-gray-600 dark:bg-gray-800"},null,8,vu)),[[ft,_.value[g.value.columns[J]]]]):(r(),U(be,{key:1,items:he(Q,J,oe)},{default:B(()=>[a("div",yu,[Q==null?(r(),m("span",xu,"NULL")):(r(),m("span",bu,d(String(Q).slice(0,200)),1))])]),_:2},1032,["items"]))],8,fu))),128)),a("td",ku,[x.value===oe?(r(),m("div",_u,[p(de,{size:"xs",color:"primary",variant:"ghost",icon:"i-heroicons-check",onClick:ne}),p(de,{size:"xs",color:"neutral",variant:"ghost",icon:"i-heroicons-x-mark",onClick:ce})])):(r(),m("div",wu,[p(de,{size:"xs",variant:"ghost",icon:"i-heroicons-pencil-square",onClick:Q=>Z(oe)},null,8,["onClick"]),p(de,{size:"xs",variant:"ghost",color:"error",icon:"i-heroicons-trash",onClick:Q=>W(oe)},null,8,["onClick"])]))])]))),128))])])):R("",!0)]),a("div",$u,[a("span",Cu,d(y.value>0?t(e)("analysis.debug.tableBrowser.rowCount",{count:y.value}):""),1),k.value>1?(r(),m("div",Su,[p(de,{size:"xs",variant:"ghost",disabled:b.value<=1,icon:"i-heroicons-chevron-left",onClick:te[3]||(te[3]=xe=>b.value--)},null,8,["disabled"]),a("span",Iu,d(t(e)("analysis.debug.tableBrowser.page",{current:b.value,total:k.value})),1),p(de,{size:"xs",variant:"ghost",disabled:b.value>=k.value,icon:"i-heroicons-chevron-right",onClick:te[4]||(te[4]=xe=>b.value++)},null,8,["disabled"])])):R("",!0)])]),_:1})])}}}),Mu={class:"flex h-full"},Au={class:"m-3 h-[calc(100%-1.5rem)] w-56 shrink-0 overflow-y-auto rounded-lg bg-white shadow-elevated dark:bg-sidebar-dark"},zu={key:0,class:"py-2"},qu={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},Lu=["title","onClick"],Du={class:"truncate text-xs font-medium"},Eu={class:"truncate text-[10px] opacity-50"},Bu={key:1,class:"border-t border-gray-200 py-2 dark:border-gray-700"},Fu={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},Ru=["title","onClick"],Vu={class:"truncate text-xs font-medium"},Ou={class:"truncate text-[10px] opacity-50"},Pu={class:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4"},ju={key:0,class:"rounded-lg border border-primary-200 bg-primary-50/50 px-4 py-3 dark:border-primary-800 dark:bg-primary-900/20"},Nu={class:"text-sm font-medium text-primary-700 dark:text-primary-300"},Uu={class:"mt-1 text-xs text-primary-600/70 dark:text-primary-400/70"},Wu={key:1,class:"flex flex-col gap-3"},Hu={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Ku={class:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3"},Yu={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},Gu={key:0,class:"text-red-500"},Qu={key:1,class:"ml-1 text-gray-400"},Ju={key:2,class:"ml-1 text-gray-400"},Xu={class:"flex items-center gap-3"},Zu={key:3,class:"text-xs text-gray-500 dark:text-gray-400"},ec={key:2,class:"flex-1 min-h-0"},tc={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},ac={key:0,class:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-400"},sc={key:0,class:"mb-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-400"},nc={class:"max-h-[60vh] overflow-auto rounded-lg border border-gray-200 bg-gray-50 p-3 text-xs leading-relaxed text-gray-800 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200"},oc=ue({__name:"ToolTestTab",props:{sessionId:{}},setup(i){const{t:l}=we(),e=i,n=z([]),s=z(""),u=z({}),o=z(!1),c=z(null),g=z(null),h=z(null),f=z(!1),b=z(null);function y(v){const w=`ai.assistant.builtinToolDesc.${v}`,E=l(w);return E!==w?E:v}const k=M(()=>n.value.filter(v=>v.category==="core")),x=M(()=>n.value.filter(v=>v.category==="analysis")),_=M(()=>n.value.find(v=>v.name===s.value)),C=M(()=>{const v=_.value;if(!v?.parameters)return[];const w=v.parameters;if(!w.properties)return[];const E=new Set(w.required??[]);return Object.entries(w.properties).map(([F,D])=>{const A={name:F,type:D.type??"string",description:D.description??"",required:E.has(F),defaultValue:D.default};if(D.enum&&(A.enumValues=D.enum),D.type==="array"){A.isArray=!0;const I=D.items;A.arrayItemType=I?.type??"string"}return A})});fe(s,()=>{u.value={},g.value=null,h.value=null,b.value=null}),Re(async()=>{try{n.value=await Ye().getToolCatalog(),n.value.length>0&&(s.value=n.value[0].name)}catch(v){console.error("Failed to load tool catalog:",v)}});function $(){const v={};for(const w of C.value){const E=u.value[w.name];if(!(E===void 0||E===""))if(w.type==="number"){const F=Number(E);isNaN(F)||(v[w.name]=F)}else w.isArray?v[w.name]=E.split(",").map(F=>F.trim()).filter(Boolean):v[w.name]=E}return v}async function S(){if(!s.value||o.value)return;o.value=!0,g.value=null,h.value=null,f.value=!1,b.value=null;const v=`tool_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;c.value=v;try{const w=$(),E=await Ye().executeTool(v,s.value,w,e.sessionId);if(E.error==="cancelled")return;E.success?(b.value=E.elapsed??null,f.value=!!E.truncated,g.value=E.truncated?E.details?._preview??"":JSON.stringify(E.details??E.content,null,2)):h.value=E.error??"Unknown error"}catch(w){h.value=String(w)}finally{o.value=!1,c.value=null}}async function T(){c.value&&(await Ye().cancelToolTest(c.value),o.value=!1,c.value=null)}return(v,w)=>{const E=Da,F=Bt,D=Ue,A=_e;return r(),m("div",Mu,[a("div",Au,[k.value.length>0?(r(),m("div",zu,[a("div",qu,d(t(l)("ai.lab.toolTest.coreTools")),1),(r(!0),m(ie,null,pe(k.value,I=>(r(),m("button",{key:I.name,class:X(["flex w-full flex-col px-3 py-1.5 text-left transition-colors",[s.value===I.name?"bg-primary-50 text-primary-700 dark:bg-primary-900/30 dark:text-primary-300":"text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700/50"]]),title:I.description,onClick:q=>s.value=I.name},[a("span",Du,d(y(I.name)),1),a("span",Eu,d(I.name),1)],10,Lu))),128))])):R("",!0),x.value.length>0?(r(),m("div",Bu,[a("div",Fu,d(t(l)("ai.lab.toolTest.analysisTools")),1),(r(!0),m(ie,null,pe(x.value,I=>(r(),m("button",{key:I.name,class:X(["flex w-full flex-col px-3 py-1.5 text-left transition-colors",[s.value===I.name?"bg-primary-50 text-primary-700 dark:bg-primary-900/30 dark:text-primary-300":"text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700/50"]]),title:I.description,onClick:q=>s.value=I.name},[a("span",Vu,d(y(I.name)),1),a("span",Ou,d(I.name),1)],10,Ru))),128))])):R("",!0)]),p(t(mt),{class:"my-3 mr-3 flex min-w-0 flex-1 flex-col"},{default:B(()=>[a("div",Pu,[_.value?(r(),m("div",ju,[a("div",Nu,d(y(_.value.name)),1),a("div",Uu,d(_.value.description),1)])):R("",!0),C.value.length>0?(r(),m("div",Wu,[a("h3",Hu,d(t(l)("ai.lab.toolTest.parameters")),1),a("div",Ku,[(r(!0),m(ie,null,pe(C.value,I=>(r(),m("div",{key:I.name,class:"flex flex-col gap-1"},[a("label",Yu,[le(d(I.name)+" ",1),I.required?(r(),m("span",Gu,"*")):R("",!0),I.type==="number"?(r(),m("span",Qu,"(number)")):R("",!0),I.isArray?(r(),m("span",Ju,"("+d(I.arrayItemType)+"[])",1)):R("",!0)]),I.enumValues?(r(),U(E,{key:0,modelValue:u.value[I.name],"onUpdate:modelValue":q=>u.value[I.name]=q,items:I.enumValues,placeholder:I.description,size:"sm"},null,8,["modelValue","onUpdate:modelValue","items","placeholder"])):(r(),U(F,{key:1,modelValue:u.value[I.name],"onUpdate:modelValue":q=>u.value[I.name]=q,placeholder:I.isArray?t(l)("ai.lab.toolTest.arrayPlaceholder"):I.defaultValue!==void 0?String(I.defaultValue):I.description,type:I.type==="number"?"number":"text",size:"sm"},null,8,["modelValue","onUpdate:modelValue","placeholder","type"]))]))),128))])])):R("",!0),a("div",Xu,[o.value?(r(),U(D,{key:1,color:"error",icon:"i-heroicons-stop",onClick:T},{default:B(()=>[le(d(t(l)("ai.lab.toolTest.cancel")),1)]),_:1})):(r(),U(D,{key:0,color:"primary",disabled:!s.value,icon:"i-heroicons-play",onClick:S},{default:B(()=>[le(d(t(l)("ai.lab.toolTest.execute")),1)]),_:1},8,["disabled"])),o.value?(r(),U(A,{key:2,name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin text-gray-400"})):R("",!0),b.value!==null?(r(),m("span",Zu,d(t(l)("ai.lab.toolTest.elapsed",{ms:b.value})),1)):R("",!0)]),g.value||h.value?(r(),m("div",ec,[a("h3",tc,d(t(l)("ai.lab.toolTest.result")),1),h.value?(r(),m("div",ac,d(h.value),1)):(r(),m(ie,{key:1},[f.value?(r(),m("div",sc,d(t(l)("ai.lab.toolTest.truncated")),1)):R("",!0),a("pre",nc,d(g.value),1)],64))])):R("",!0)])]),_:1})])}}}),lc={class:"flex h-full flex-col"},rc={class:"min-h-0 flex-1 overflow-hidden"},ic=ue({__name:"DebugTab",props:{sessionId:{}},setup(i){const{t:l}=we(),e=i,n=[{id:"sql-tables",label:l("analysis.debug.sqlTables"),icon:"i-heroicons-table-cells"},{id:"basic-tools",label:l("analysis.debug.basicTools"),icon:"i-heroicons-wrench-screwdriver"}],s=z("sql-tables");return(u,o)=>(r(),m("div",lc,[p(t(ls),{modelValue:s.value,"onUpdate:modelValue":o[0]||(o[0]=c=>s.value=c),items:n,"persist-key":"debugTab"},null,8,["modelValue"]),a("div",rc,[p(vt,{name:"fade",mode:"out-in"},{default:B(()=>[s.value==="sql-tables"?(r(),U(Tu,{key:0,class:"h-full","session-id":e.sessionId},null,8,["session-id"])):s.value==="basic-tools"?(r(),U(oc,{key:1,class:"h-full","session-id":e.sessionId},null,8,["session-id"])):R("",!0)]),_:1})])]))}}),Hw=dt(ic,[["__scopeId","data-v-b3b3d1a4"]]),uc=["disabled"],cc={key:0,class:"flex-1 overflow-y-auto p-2"},dc={key:0,class:"flex items-center justify-center py-8"},mc={key:1,class:"flex flex-col items-center justify-center py-12 text-center"},gc={class:"flex h-12 w-12 items-center justify-center rounded-full bg-gray-50 dark:bg-gray-800"},pc={class:"mt-3 text-xs text-gray-400"},hc={key:2,class:"space-y-3"},fc={class:"px-2 pb-1 pt-1.5 text-[10px] font-medium tracking-wide text-gray-400 dark:text-gray-500"},vc={class:"space-y-0.5"},yc=["onClick"],xc=["placeholder","onBlur","onKeyup"],bc={key:1,class:"flex items-center"},kc={class:"line-clamp-1 min-w-0 flex-1 text-sm leading-snug"},_c={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"},wc={class:"w-28 p-1"},$c=["disabled","onClick"],Cc=["onClick"],Sc=["disabled","onClick"],Ic={key:1,class:"flex flex-1 flex-col items-center gap-1 overflow-y-auto px-2 pb-2"},Tc=["title","disabled"],Mc=["title","onClick"],Ac={key:0,class:"absolute -left-2 top-1/2 h-4.5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary-500"},zc=ue({__name:"ConversationList",props:{sessionId:{},activeId:{},disabled:{type:Boolean}},emits:["select","create","delete"],setup(i,{expose:l,emit:e}){const{t:n}=we(),s=i,u=e,o=z([]),c=z(!1),g=z(null),h=z(""),f=z(!1),b=z(null);async function y(){c.value=!0;try{o.value=await Ye().getAIChats(s.sessionId)}catch(w){console.error("加载对话列表失败:",w)}finally{c.value=!1}}const k=M(()=>{if(o.value.length===0)return[];const w=Ee(),E=w.subtract(7,"day").startOf("day"),F=w.subtract(30,"day").startOf("day"),D=[],A=[],I=new Map;for(const G of o.value){const Z=Ee(G.updatedAt*1e3);if(Z.isAfter(E))D.push(G);else if(Z.isAfter(F))A.push(G);else{const ce=Z.format("YYYY-MM");I.has(ce)||I.set(ce,[]),I.get(ce).push(G)}}const q=[];D.length>0&&q.push({label:n("ai.chat.conversation.group.last7Days"),conversations:D}),A.length>0&&q.push({label:n("ai.chat.conversation.group.last30Days"),conversations:A});const Y=[...I.keys()].sort((G,Z)=>Z.localeCompare(G));for(const G of Y){const Z=Ee(G+"-01");q.push({label:Z.format(Z.year()===w.year()?"M月":"YYYY年M月"),conversations:I.get(G)})}return q});function x(w){return w.title||n("ai.chat.conversation.newChat")}function _(w){s.disabled||(g.value=w.id,h.value=w.title||"")}async function C(w){if(!s.disabled){if(h.value.trim())try{await Ye().updateAIChatTitle(w,h.value.trim());const E=o.value.find(F=>F.id===w);E&&(E.title=h.value.trim())}catch(E){console.error("更新标题失败:",E)}g.value=null}}function $(w){b.value=null,_(w)}function S(w){b.value=null,navigator.clipboard.writeText(w)}function T(w){b.value=null,v(w)}async function v(w){if(!s.disabled)try{await Ye().deleteAIChat(w),o.value=o.value.filter(E=>E.id!==w),u("delete",w)}catch(E){console.error("删除对话失败:",E)}}return Re(()=>{y()}),fe(()=>s.sessionId,()=>{y()}),l({refresh:y}),(w,E)=>{const F=_e,D=Ue,A=ms;return r(),m("div",{class:X(["m-3 flex h-[calc(100%-1.5rem)] shrink-0 flex-col overflow-hidden rounded-lg bg-white transition-all duration-300 ease-in-out dark:bg-sidebar-dark",f.value?"w-14":"w-64"])},[a("div",{class:X(["flex items-center",f.value?"justify-center px-2 pb-2 pt-5":"justify-between border-b border-gray-200 py-2 pl-3 pr-2 dark:border-gray-800"])},[f.value?(r(),m("button",{key:1,type:"button",class:"group relative flex h-9 w-9 cursor-pointer items-center justify-center rounded-full hover:bg-gray-200/60 dark:hover:bg-white/[0.06]",onClick:E[2]||(E[2]=I=>f.value=!f.value)},[p(F,{name:"i-lucide-panel-right-open",class:"size-4 scale-x-[-1]"})])):(r(),m(ie,{key:0},[a("button",{class:X(["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":i.disabled}]),disabled:i.disabled,onClick:E[0]||(E[0]=I=>!i.disabled&&u("create"))},[p(F,{name:"i-heroicons-plus",class:"h-3.5 w-3.5"}),a("span",null,d(t(n)("ai.chat.conversation.newConversation")),1)],10,uc),p(D,{color:"neutral",variant:"ghost",size:"sm",class:"group flex h-9 w-9 cursor-pointer items-center justify-center rounded-full hover:bg-gray-200/60 dark:hover:bg-white/[0.06]",onClick:E[1]||(E[1]=I=>f.value=!f.value)},{default:B(()=>[p(F,{name:"i-lucide-panel-right",class:"size-4 scale-x-[-1] group-hover:hidden"}),p(F,{name:"i-lucide-panel-right-close",class:"size-4 hidden scale-x-[-1] group-hover:block"})]),_:1})],64))],2),f.value?(r(),m("div",Ic,[a("button",{class:X(["flex h-10 w-10 items-center justify-center rounded-lg text-gray-600 transition-colors hover:bg-gray-200/40 hover:text-primary-600 dark:text-gray-300 dark:hover:bg-white/[0.06] dark:hover:text-primary-400",{"cursor-not-allowed opacity-50":i.disabled}]),title:t(n)("ai.chat.conversation.newConversation"),disabled:i.disabled,onClick:E[7]||(E[7]=I=>!i.disabled&&u("create"))},[p(F,{name:"i-heroicons-plus",class:"h-5 w-5"})],10,Tc),(r(!0),m(ie,null,pe(o.value,I=>(r(),m("button",{key:I.id,class:X(["relative mx-auto flex h-10 w-10 items-center justify-center rounded-lg transition-all duration-200",[i.activeId===I.id?"bg-gray-200/50 text-primary-600 dark:bg-white/[0.07] dark:text-primary-400 dark:ring-1 dark:ring-white/10":"text-gray-600 hover:bg-gray-200/40 dark:text-gray-300 dark:hover:bg-white/[0.06]"]]),title:x(I),onClick:q=>u("select",I.id)},[i.activeId===I.id?(r(),m("span",Ac)):R("",!0),p(F,{name:"i-heroicons-chat-bubble-left",class:"h-5 w-5"})],10,Mc))),128))])):(r(),m("div",cc,[c.value?(r(),m("div",dc,[p(F,{name:"i-heroicons-arrow-path",class:"h-5 w-5 animate-spin text-gray-400"})])):o.value.length===0?(r(),m("div",mc,[a("div",gc,[p(F,{name:"i-heroicons-chat-bubble-left",class:"h-6 w-6 text-gray-300 dark:text-gray-600"})]),a("p",pc,d(t(n)("ai.chat.conversation.empty")),1),p(D,{class:"mt-2",size:"xs",variant:"link",color:"primary",disabled:i.disabled,onClick:E[3]||(E[3]=I=>!i.disabled&&u("create"))},{default:B(()=>[le(d(t(n)("ai.chat.conversation.startNew")),1)]),_:1},8,["disabled"])])):(r(),m("div",hc,[(r(!0),m(ie,null,pe(k.value,I=>(r(),m("div",{key:I.label},[a("div",fc,d(I.label),1),a("div",vc,[(r(!0),m(ie,null,pe(I.conversations,q=>(r(),m("div",{key:q.id,class:X(["group relative rounded-lg px-3 py-2 transition-all",["cursor-pointer",i.activeId===q.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:Y=>u("select",q.id)},[g.value===q.id?Qe((r(),m("input",{key:0,"onUpdate:modelValue":E[4]||(E[4]=Y=>h.value=Y),class:"w-full rounded border-none bg-white px-2 py-1 text-sm shadow-sm outline-none ring-1 ring-gray-200 focus:ring-2 focus:ring-primary-500 dark:bg-page-dark dark:ring-gray-700",placeholder:t(n)("ai.chat.conversation.titlePlaceholder"),autoFocus:"",onBlur:Y=>C(q.id),onKeyup:Ge(Y=>C(q.id),["enter"]),onClick:E[5]||(E[5]=Oe(()=>{},["stop"]))},null,40,xc)),[[ft,h.value]]):(r(),m("div",bc,[a("p",kc,d(x(q)),1),a("div",{class:X(["ml-1 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",{"opacity-100":i.activeId===q.id||b.value===q.id}]),onClick:E[6]||(E[6]=Oe(()=>{},["stop"]))},[p(A,{open:b.value===q.id,ui:{content:"z-50 p-0"},"onUpdate:open":Y=>b.value=Y?q.id:null},{content:B(()=>[a("div",wc,[a("button",{class:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-xs text-gray-600 transition-colors hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800",disabled:i.disabled,onClick:Y=>$(q)},[p(F,{name:"i-heroicons-pencil",class:"h-3.5 w-3.5"}),le(" "+d(t(n)("ai.chat.conversation.rename")),1)],8,$c),a("button",{class:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-xs text-gray-600 transition-colors hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800",onClick:Y=>S(q.id)},[p(F,{name:"i-heroicons-clipboard-document",class:"h-3.5 w-3.5"}),le(" "+d(t(n)("ai.chat.conversation.copyId")),1)],8,Cc),a("button",{class:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-xs text-red-500 transition-colors hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/30",disabled:i.disabled,onClick:Y=>T(q.id)},[p(F,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"}),le(" "+d(t(n)("ai.chat.conversation.delete")),1)],8,Sc)])]),default:B(()=>[a("button",_c,[p(F,{name:"i-heroicons-ellipsis-horizontal",class:"h-4 w-4"})])]),_:2},1032,["open","onUpdate:open"])],2)]))],10,yc))),128))])]))),128))]))]))],2)}}}),qc={class:"writing-vertical text-xs"},Lc={class:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800"},Dc={class:"flex items-center gap-2"},Ec={class:"font-medium text-gray-900 dark:text-white"},Bc={key:0,class:"border-b border-gray-200 px-4 py-2 dark:border-gray-800"},Fc={class:"flex flex-wrap items-center gap-2"},Rc={class:"text-xs text-gray-500"},Vc={class:"flex-1 overflow-y-auto"},Oc={key:0,class:"flex items-center justify-center py-8"},Pc={key:1,class:"flex flex-col items-center justify-center py-8 text-center"},jc={class:"mt-2 text-sm text-gray-500"},Nc={class:"text-xs text-gray-400"},Uc={key:2,class:"divide-y divide-gray-100 dark:divide-gray-800"},Wc={class:"mb-1 flex items-center justify-between"},Hc={class:"text-sm font-medium text-gray-900 dark:text-white"},Kc={class:"text-xs text-gray-400"},Yc=["innerHTML"],Gc={key:1,class:"border-t border-gray-200 px-4 py-2 dark:border-gray-800"},Qc={class:"flex items-center justify-between"},Jc={class:"text-xs text-gray-500"},Xc={key:2,class:"pointer-events-none absolute inset-0 overflow-hidden rounded-xl opacity-[0.03]"},Zc=ue({__name:"DataSourcePanel",props:{messages:{},keywords:{},isLoading:{type:Boolean},isCollapsed:{type:Boolean}},emits:["toggle","loadMore"],setup(i,{emit:l}){const{t:e}=we(),n=i,s=l;function u(c){return Ee(c).format("MM-DD HH:mm")}function o(c){if(!n.keywords.length)return c;const g=n.keywords.join("|"),h=new RegExp(`(${g})`,"gi");return c.replace(h,'<mark class="bg-yellow-200 dark:bg-yellow-800/50 px-0.5 rounded">$1</mark>')}return(c,g)=>{const h=_e,f=Ue;return r(),m("div",{class:X(["relative flex flex-col rounded-xl bg-white transition-all duration-300 dark:bg-page-dark",[i.isCollapsed?"w-12":"w-full"]])},[i.isCollapsed?(r(),m("button",{key:0,class:"flex h-full flex-col items-center justify-center gap-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",onClick:g[0]||(g[0]=b=>s("toggle"))},[p(h,{name:"i-heroicons-chevron-left",class:"h-5 w-5"}),a("span",qc,d(t(e)("ai.chat.dataSource.title")),1)])):(r(),m(ie,{key:1},[a("div",Lc,[a("div",Dc,[p(h,{name:"i-heroicons-document-magnifying-glass",class:"h-5 w-5 text-gray-500"}),a("span",Ec,d(t(e)("ai.chat.dataSource.title")),1)]),p(f,{icon:"i-heroicons-chevron-right",color:"gray",variant:"ghost",size:"xs",onClick:g[1]||(g[1]=b=>s("toggle"))})]),i.keywords.length>0?(r(),m("div",Bc,[a("div",Fc,[a("span",Rc,d(t(e)("ai.chat.dataSource.keywords")),1),(r(!0),m(ie,null,pe(i.keywords,b=>(r(),m("span",{key:b,class:"rounded-full bg-violet-100 px-2 py-0.5 text-xs text-violet-700 dark:bg-violet-900/30 dark:text-violet-400"},d(b),1))),128))])])):R("",!0),a("div",Vc,[i.isLoading?(r(),m("div",Oc,[p(h,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):i.messages.length===0?(r(),m("div",Pc,[p(h,{name:"i-heroicons-inbox",class:"h-10 w-10 text-gray-300 dark:text-gray-600"}),a("p",jc,d(t(e)("ai.chat.dataSource.empty")),1),a("p",Nc,d(t(e)("ai.chat.dataSource.emptyHint")),1)])):(r(),m("div",Uc,[(r(!0),m(ie,null,pe(i.messages,b=>(r(),m("div",{key:b.id,class:"px-4 py-3 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[a("div",Wc,[a("span",Hc,d(b.senderName),1),a("span",Kc,d(u(b.timestamp)),1)]),a("p",{class:"line-clamp-3 text-sm text-gray-600 dark:text-gray-400",innerHTML:o(b.content)},null,8,Yc)]))),128))]))]),i.messages.length>0?(r(),m("div",Gc,[a("div",Qc,[a("span",Jc,d(t(e)("ai.chat.dataSource.totalRecords",{count:i.messages.length})),1),p(f,{size:"xs",variant:"ghost",onClick:g[2]||(g[2]=b=>s("loadMore"))},{default:B(()=>[le(d(t(e)("ai.chat.dataSource.loadMore")),1)]),_:1})])])):R("",!0)],64)),i.isCollapsed?R("",!0):(r(),m("div",Xc,[...g[3]||(g[3]=[a("div",{class:"data-flow-bg absolute inset-0"},null,-1)])]))],2)}}}),ed=dt(Zc,[["__scopeId","data-v-a9962add"]]),td={class:"flex max-h-[80vh] flex-col overflow-hidden"},ad={class:"shrink-0 border-b border-gray-200 px-6 py-4 dark:border-gray-800"},sd={class:"flex items-center justify-between"},nd={class:"flex items-center gap-3"},od={class:"flex h-8 w-8 items-center justify-center rounded-lg bg-red-100 dark:bg-red-900/40"},ld={class:"text-lg font-semibold text-gray-900 dark:text-white"},rd={class:"flex-1 overflow-y-auto px-6 py-4"},id={class:"flex flex-col gap-4"},ud={class:"text-sm font-semibold text-gray-700 dark:text-gray-300"},cd={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"},dd={class:"m-0 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-red-600 dark:text-red-400"},md={key:1,class:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-page-dark"},gd={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"},pd={key:2,class:"select-text break-words rounded-md border border-gray-200 bg-gray-50 px-3 py-2 font-mono text-xs text-gray-700 dark:border-gray-700 dark:bg-page-dark dark:text-gray-300"},hd={key:0,class:"py-8 text-center text-sm text-gray-400 dark:text-gray-500"},fd={class:"shrink-0 border-t border-gray-200 px-6 py-3 dark:border-gray-800"},vd={class:"flex justify-end"},yd=ue({__name:"ErrorDetailModal",props:qt({error:{}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:["update:open"],setup(i){const{t:l}=we(),e=nt(),n=Wt(i,"open"),s=i,u=M(()=>{const g=s.error,h=[];return g.url&&h.push({label:l("ai.chat.error.requestUrl"),value:g.url}),g.statusCode!=null&&h.push({label:l("ai.chat.error.statusCode"),value:String(g.statusCode)}),g.responseBody&&h.push({label:l("ai.chat.error.responseBody"),value:o(g.responseBody),isCode:!0}),g.responseHeaders&&h.push({label:l("ai.chat.error.responseHeaders"),value:JSON.stringify(g.responseHeaders,null,2),isCode:!0}),g.name&&h.push({label:l("ai.chat.error.name"),value:g.name}),g.message&&h.push({label:l("ai.chat.error.message"),value:g.message}),g.stack&&h.push({label:l("ai.chat.error.stack"),value:g.stack,isStack:!0}),g.cause&&h.push({label:l("ai.chat.error.cause"),value:o(g.cause),isCode:!0}),g.provider&&h.push({label:l("ai.chat.error.provider"),value:g.provider}),g.requestBody&&h.push({label:l("ai.chat.error.requestBody"),value:o(g.requestBody),isCode:!0}),h});function o(g){try{return JSON.stringify(JSON.parse(g),null,2)}catch{return g}}function c(){const g=u.value.map(h=>`${h.label}: ${h.value}`).join(`
|
|
68
|
+
4. 若用户需求包含多个分析目标,仅选择第一个目标生成 SQL`}function ce(W){let re=W.trim();re=re.replace(/^```json?\n?/i,"").replace(/\n?```$/i,"");try{const ve=JSON.parse(re);return{sql:(ve.sql||"").trim(),explanation:(ve.explanation||"").trim()}}catch{return re=re.replace(/^```sql?\n?/i,"").replace(/\n?```$/i,""),{sql:re.trim(),explanation:""}}}async function ne(){const W=g.value.trim();if(!W){y.value=l("ai.sqlLab.generate.errorEmptyPrompt");return}if(!await $a().hasConfig()){y.value=l("common.errorNoAIConfig");return}const ve=s.value?.schema||[];if(ve.length===0){y.value=l("common.error.unknown");return}b.value=!0,k.value=null,y.value=null,_.value="",C.value="",$.value=!1;let fe="";try{const ee=Z(W,ve),te=await os().chatStream([{role:"system",content:"你是一个 SQLite 专家,请以 JSON 格式输出 sql 和 explanation 字段。"},{role:"user",content:ee}],{temperature:.1,maxTokens:4096},de=>{if(de.thinking!==void 0){de.thinkingDone?$.value=!1:($.value=!0,de.thinking&&(C.value+=de.thinking,De(()=>{I.value&&(I.value.scrollTop=I.value.scrollHeight)})));return}de.error&&(fe=de.error),de.isFinished&&de.finishReason==="length"&&(fe=l("ai.sqlLab.generate.errorTokenLimit")),de.content&&(_.value+=de.content)});if(!te.success){y.value=te.error||fe||l("ai.sqlLab.generate.errorGenerate");return}if(fe){y.value=fe;return}const j=ce(_.value);if(!j.sql){y.value=_.value?`${l("ai.sqlLab.generate.errorGenerate")}: ${_.value.slice(0,200)}`:l("ai.sqlLab.generate.errorGenerate");return}c.value=j.sql,x.value=W,F(W,j.sql,j.explanation),await A()}catch(ee){y.value=ee.message||String(ee)}finally{b.value=!1}}async function H(W){c.value=W.sql,x.value=W.prompt,T.value=!1,await A()}return Re(()=>{w()}),he(()=>n.chatType,W=>{g.value=o(W)}),(W,re)=>{const ve=_e,fe=Ue;return r(),m("div",Ai,[p(t(_r),{ref_key:"schemaPanelRef",ref:s,"session-id":i.sessionId,onInsertColumn:q},null,8,["session-id"]),a("div",zi,[a("div",qi,[a("div",Li,[h.value==="prompt"?Qe((r(),m("textarea",{key:0,"onUpdate:modelValue":re[0]||(re[0]=ee=>g.value=ee),class:"h-32 w-full resize-none rounded-2xl border-0 bg-white p-3 text-sm text-gray-800 shadow-[0_2px_14px_rgba(0,0,0,0.04)] outline-none ring-1 ring-gray-200/60 transition-all placeholder:text-gray-400 focus:ring-primary-500/40 focus:shadow-[0_4px_20px_rgba(0,0,0,0.08)] dark:bg-page-dark dark:text-gray-200 dark:ring-white/5 dark:placeholder:text-gray-500 dark:focus:ring-primary-500/40",placeholder:t(l)("ai.sqlLab.generate.placeholder"),spellcheck:"false",onKeydown:re[1]||(re[1]=ee=>S(ee,"prompt"))},null,40,Di)),[[ft,g.value]]):Qe((r(),m("textarea",{key:1,"onUpdate:modelValue":re[2]||(re[2]=ee=>c.value=ee),class:"h-32 w-full resize-none rounded-2xl border-0 bg-white p-3 font-mono text-sm text-gray-800 shadow-[0_2px_14px_rgba(0,0,0,0.04)] outline-none ring-1 ring-gray-200/60 transition-all placeholder:text-gray-400 focus:ring-primary-500/40 focus:shadow-[0_4px_20px_rgba(0,0,0,0.08)] dark:bg-page-dark dark:text-gray-200 dark:ring-white/5 dark:placeholder:text-gray-500 dark:focus:ring-primary-500/40",placeholder:t(l)("ai.sqlLab.editor.placeholder"),spellcheck:"false",onKeydown:re[3]||(re[3]=ee=>S(ee,"sql"))},null,40,Ei)),[[ft,c.value]]),a("div",Bi,[a("div",Fi,[p(fe,{variant:"ghost",size:"xs",onClick:Y},{default:B(()=>[p(ve,{name:"i-heroicons-arrows-right-left",class:"mr-1 h-3.5 w-3.5"}),le(" "+d(h.value==="prompt"?t(l)("ai.sqlLab.editor.switchToSQLMode"):t(l)("ai.sqlLab.editor.switchToPromptMode")),1)]),_:1}),h.value==="sql"?(r(),m("span",Ri,d(t(l)("ai.sqlLab.editor.tip")),1)):R("",!0)]),a("div",Vi,[p(fe,{variant:"ghost",size:"sm",disabled:v.value.length===0,onClick:re[4]||(re[4]=ee=>T.value=!0)},{default:B(()=>[p(ve,{name:"i-heroicons-clock",class:"mr-1 h-4 w-4"}),le(" "+d(t(l)("ai.sqlLab.editor.history"))+" ",1),v.value.length>0?(r(),m("span",Oi,"("+d(v.value.length)+")",1)):R("",!0)]),_:1},8,["disabled"]),h.value==="prompt"?(r(),U(fe,{key:0,color:"primary",size:"sm",loading:b.value||f.value,disabled:!g.value.trim(),onClick:ne},{default:B(()=>[p(ve,{name:"i-heroicons-sparkles",class:"mr-1 h-4 w-4"}),le(" "+d(t(l)("ai.sqlLab.editor.generateAndRun")),1)]),_:1},8,["loading","disabled"])):(r(),U(fe,{key:1,color:"primary",size:"sm",loading:f.value,onClick:A},{default:B(()=>[p(ve,{name:"i-heroicons-play",class:"mr-1 h-4 w-4"}),le(" "+d(t(l)("ai.sqlLab.editor.run")),1)]),_:1},8,["loading"]))])])])]),h.value==="prompt"&&!k.value&&!y.value&&(_.value||C.value||b.value)?(r(),m("div",Pi,[p(t(mt),{class:"mx-auto w-full max-w-3xl p-4"},{default:B(()=>[a("p",ji,[p(ve,{name:"i-heroicons-cpu-chip",class:"h-4 w-4"}),le(" "+d(t(l)("ai.sqlLab.generate.aiOutput"))+" ",1),$.value?(r(),m("span",Ni,d(t(l)("ai.sqlLab.generate.thinking")),1)):b.value?(r(),m("span",Ui,d(t(l)("common.generating")),1)):R("",!0)]),C.value?(r(),m("details",{key:0,class:"mb-3",open:$.value},[a("summary",Hi,d(t(l)("ai.sqlLab.generate.thinkingProcess")),1),a("pre",{ref_key:"thinkingPreRef",ref:I,class:"mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-all rounded border border-gray-200 bg-gray-50 p-2 font-mono text-xs leading-5 text-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-400"},d(C.value),513)],8,Wi)):R("",!0),_.value?(r(),m("pre",Ki,d(_.value),1)):C.value?R("",!0):(r(),m("p",Yi,d(t(l)("ai.sqlLab.generate.waitingAI")),1))]),_:1})])):(r(),U(t(Mi),{key:1,ref_key:"resultTableRef",ref:u,result:k.value,error:y.value,sql:c.value,prompt:x.value},null,8,["result","error","sql","prompt"]))]),p(t(Fr),{open:T.value,"onUpdate:open":re[5]||(re[5]=ee=>T.value=ee),history:v.value,onExecute:H,onDelete:D},null,8,["open","history"])])}}}),Qi={class:"flex h-full flex-col"},Ji={class:"min-h-0 flex-1 overflow-hidden"},Xi=ue({__name:"LabTab",props:{sessionId:{},chatType:{}},setup(i){const l=i,{t:e}=we(),n=M(()=>[{id:"sql-lab",label:e("ai.tab.sqlLab"),icon:"i-heroicons-command-line"}]),s=z("sql-lab");return(u,o)=>(r(),m("div",Qi,[p(t(ls),{modelValue:s.value,"onUpdate:modelValue":o[0]||(o[0]=c=>s.value=c),items:n.value,"persist-key":"labTab"},null,8,["modelValue","items"]),a("div",Ji,[p(vt,{name:"fade",mode:"out-in"},{default:B(()=>[s.value==="sql-lab"?(r(),U(Gi,{key:0,class:"h-full","session-id":l.sessionId,"chat-type":l.chatType},null,8,["session-id","chat-type"])):R("",!0)]),_:1})])]))}}),Ww=dt(Xi,[["__scopeId","data-v-7fc6fe33"]]),Zi={class:"flex h-full items-center justify-center"},eu={class:"max-w-sm text-center"},tu={class:"mt-3 text-sm text-gray-400 dark:text-gray-500"},au=["href"],Hw=ue({__name:"MemoryTab",props:{sessionId:{},sessionName:{}},setup(i){const{t:l,te:e}=we(),n=M(()=>e("analysis.memory.joinLink")?l("analysis.memory.joinLink"):"");return(s,u)=>{const o=_e;return r(),m("div",Zi,[a("div",eu,[p(o,{name:"i-heroicons-light-bulb",class:"mx-auto h-12 w-12 text-gray-300 dark:text-gray-600"}),a("p",tu,d(t(l)("analysis.memory.comingSoon")),1),n.value?(r(),m("a",{key:0,href:n.value,target:"_blank",rel:"noopener noreferrer",class:"mt-2 inline-block text-sm text-primary-500 hover:text-primary-600 dark:text-primary-400 dark:hover:text-primary-300"},d(n.value),9,au)):R("",!0)])])}}});function su(i,l){if(typeof i!="object"||i===null)return!1;const e=lt(i,l);return e!=null&&e!==""}function Ya(i,l){return l?{xs:44,sm:48,md:52,lg:56,xl:60}[i]:{xs:24,sm:28,md:32,lg:36,xl:40}[i]}function nu(i,l,e,n){const s=Ya(l,!0),u=Ya(l,!1);return n?()=>s:e?o=>su(i[o],e)?s:u:()=>u}const ou={slots:{base:["relative group rounded-md inline-flex items-center disabled:cursor-not-allowed disabled:opacity-75","transition-colors"],leading:"absolute inset-y-0 start-0 flex items-center",leadingIcon:"shrink-0 text-dimmed",leadingAvatar:"shrink-0",leadingAvatarSize:"",trailing:"absolute inset-y-0 end-0 flex items-center",trailingIcon:"shrink-0 text-dimmed",value:"truncate pointer-events-none",placeholder:"truncate text-dimmed",arrow:"fill-bg stroke-default",content:["max-h-[min(15rem,var(--reka-select-content-available-height,15rem))] w-(--reka-select-trigger-width) bg-default shadow-lg rounded-md ring ring-default overflow-hidden origin-(--reka-select-content-transform-origin) pointer-events-auto flex flex-col","max-h-[min(15rem,var(--reka-combobox-content-available-height,15rem))] origin-(--reka-combobox-content-transform-origin) w-(--reka-combobox-trigger-width)"],viewport:"relative scroll-py-1 overflow-y-auto flex-1",group:"p-1 isolate",empty:"text-center text-muted",label:"font-semibold text-highlighted",separator:"-mx-1 my-1 h-px bg-border",item:["group relative w-full flex items-start select-none outline-none before:absolute before:z-[-1] before:inset-px before:rounded-md data-disabled:cursor-not-allowed data-disabled:opacity-75 text-default data-highlighted:not-data-disabled:text-highlighted data-highlighted:not-data-disabled:before:bg-elevated/50","transition-colors before:transition-colors"],itemLeadingIcon:["shrink-0 text-dimmed group-data-highlighted:not-group-data-disabled:text-default","transition-colors"],itemLeadingAvatar:"shrink-0",itemLeadingAvatarSize:"",itemLeadingChip:"shrink-0",itemLeadingChipSize:"",itemTrailing:"ms-auto inline-flex gap-1.5 items-center",itemTrailingIcon:"shrink-0",itemWrapper:"flex-1 flex flex-col min-w-0",itemLabel:"truncate",itemDescription:"truncate text-muted",input:"border-b border-default",focusScope:"flex flex-col min-h-0",trailingClear:"p-0"},variants:{fieldGroup:{horizontal:"not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]",vertical:"not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]"},size:{xs:{base:"px-2 py-1 text-xs gap-1",leading:"ps-2",trailing:"pe-2",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4",label:"p-1 text-[10px]/3 gap-1",item:"p-1 text-xs gap-1",itemLeadingIcon:"size-4",itemLeadingAvatarSize:"3xs",itemLeadingChip:"size-4",itemLeadingChipSize:"sm",itemTrailingIcon:"size-4",empty:"p-2 text-xs"},sm:{base:"px-2.5 py-1.5 text-xs gap-1.5",leading:"ps-2.5",trailing:"pe-2.5",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4",label:"p-1.5 text-[10px]/3 gap-1.5",item:"p-1.5 text-xs gap-1.5",itemLeadingIcon:"size-4",itemLeadingAvatarSize:"3xs",itemLeadingChip:"size-4",itemLeadingChipSize:"sm",itemTrailingIcon:"size-4",empty:"p-2.5 text-xs"},md:{base:"px-2.5 py-1.5 text-sm gap-1.5",leading:"ps-2.5",trailing:"pe-2.5",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5",label:"p-1.5 text-xs gap-1.5",item:"p-1.5 text-sm gap-1.5",itemLeadingIcon:"size-5",itemLeadingAvatarSize:"2xs",itemLeadingChip:"size-5",itemLeadingChipSize:"md",itemTrailingIcon:"size-5",empty:"p-2.5 text-sm"},lg:{base:"px-3 py-2 text-sm gap-2",leading:"ps-3",trailing:"pe-3",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5",label:"p-2 text-xs gap-2",item:"p-2 text-sm gap-2",itemLeadingIcon:"size-5",itemLeadingAvatarSize:"2xs",itemLeadingChip:"size-5",itemLeadingChipSize:"md",itemTrailingIcon:"size-5",empty:"p-3 text-sm"},xl:{base:"px-3 py-2 text-base gap-2",leading:"ps-3",trailing:"pe-3",leadingIcon:"size-6",leadingAvatarSize:"xs",trailingIcon:"size-6",label:"p-2 text-sm gap-2",item:"p-2 text-base gap-2",itemLeadingIcon:"size-6",itemLeadingAvatarSize:"xs",itemLeadingChip:"size-6",itemLeadingChipSize:"lg",itemTrailingIcon:"size-6",empty:"p-3 text-base"}},variant:{outline:"text-highlighted bg-default ring ring-inset ring-accented hover:bg-elevated disabled:bg-default",soft:"text-highlighted bg-elevated/50 hover:bg-elevated focus:bg-elevated disabled:bg-elevated/50",subtle:"text-highlighted bg-elevated ring ring-inset ring-accented hover:bg-accented/75 disabled:bg-elevated",ghost:"text-highlighted bg-transparent hover:bg-elevated focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent",none:"text-highlighted bg-transparent focus:outline-none"},color:{primary:"",secondary:"",success:"",info:"",warning:"",error:"",neutral:""},leading:{true:""},trailing:{true:""},loading:{true:""},highlight:{true:""},fixed:{false:""},type:{file:"file:me-1.5 file:font-medium file:text-muted file:outline-none"},position:{popper:{content:"data-[state=open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in]"},"item-aligned":{content:""}},multiple:{true:""},virtualize:{true:{viewport:"p-1 isolate"},false:{viewport:"divide-y divide-default"}}},compoundVariants:[{color:"primary",variant:["outline","subtle"],class:"outline-primary/25 focus-visible:outline-3 focus-visible:ring-primary"},{color:"secondary",variant:["outline","subtle"],class:"outline-secondary/25 focus-visible:outline-3 focus-visible:ring-secondary"},{color:"success",variant:["outline","subtle"],class:"outline-success/25 focus-visible:outline-3 focus-visible:ring-success"},{color:"info",variant:["outline","subtle"],class:"outline-info/25 focus-visible:outline-3 focus-visible:ring-info"},{color:"warning",variant:["outline","subtle"],class:"outline-warning/25 focus-visible:outline-3 focus-visible:ring-warning"},{color:"error",variant:["outline","subtle"],class:"outline-error/25 focus-visible:outline-3 focus-visible:ring-error"},{color:"primary",variant:["soft","ghost"],class:"outline-primary/25 focus-visible:outline-3"},{color:"secondary",variant:["soft","ghost"],class:"outline-secondary/25 focus-visible:outline-3"},{color:"success",variant:["soft","ghost"],class:"outline-success/25 focus-visible:outline-3"},{color:"info",variant:["soft","ghost"],class:"outline-info/25 focus-visible:outline-3"},{color:"warning",variant:["soft","ghost"],class:"outline-warning/25 focus-visible:outline-3"},{color:"error",variant:["soft","ghost"],class:"outline-error/25 focus-visible:outline-3"},{color:"primary",highlight:!0,class:"ring ring-inset ring-primary"},{color:"secondary",highlight:!0,class:"ring ring-inset ring-secondary"},{color:"success",highlight:!0,class:"ring ring-inset ring-success"},{color:"info",highlight:!0,class:"ring ring-inset ring-info"},{color:"warning",highlight:!0,class:"ring ring-inset ring-warning"},{color:"error",highlight:!0,class:"ring ring-inset ring-error"},{color:"neutral",variant:["outline","subtle"],class:"outline-inverted/25 focus-visible:outline-3 focus-visible:ring-inverted"},{color:"neutral",variant:["soft","ghost"],class:"outline-inverted/25 focus-visible:outline-3"},{color:"neutral",highlight:!0,class:"ring ring-inset ring-inverted"},{leading:!0,size:"xs",class:"ps-7"},{leading:!0,size:"sm",class:"ps-8"},{leading:!0,size:"md",class:"ps-9"},{leading:!0,size:"lg",class:"ps-10"},{leading:!0,size:"xl",class:"ps-11"},{trailing:!0,size:"xs",class:"pe-7"},{trailing:!0,size:"sm",class:"pe-8"},{trailing:!0,size:"md",class:"pe-9"},{trailing:!0,size:"lg",class:"pe-10"},{trailing:!0,size:"xl",class:"pe-11"},{loading:!0,leading:!0,class:{leadingIcon:"animate-spin"}},{loading:!0,leading:!1,trailing:!0,class:{trailingIcon:"animate-spin"}},{fixed:!1,size:"xs",class:"md:text-xs"},{fixed:!1,size:"sm",class:"md:text-xs"},{fixed:!1,size:"md",class:"md:text-sm"},{fixed:!1,size:"lg",class:"md:text-sm"}],defaultVariants:{size:"md",color:"primary",variant:"outline",position:"popper"}},Da=Object.assign({inheritAttrs:!1},{__name:"SelectMenu",props:qt({id:{type:String,required:!1},placeholder:{type:String,required:!1},searchInput:{type:[Boolean,Object],required:!1,default:!0},color:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},required:{type:Boolean,required:!1},trailingIcon:{type:null,required:!1},selectedIcon:{type:null,required:!1},clear:{type:[Boolean,Object],required:!1},clearIcon:{type:null,required:!1},content:{type:Object,required:!1},arrow:{type:[Boolean,Object],required:!1},portal:{type:[Boolean,String],required:!1,skipCheck:!0,default:!0},virtualize:{type:[Boolean,Object],required:!1,default:!1},valueKey:{type:null,required:!1},labelKey:{type:null,required:!1,default:"label"},descriptionKey:{type:null,required:!1,default:"description"},items:{type:null,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1},modelModifiers:{type:null,required:!1},multiple:{type:Boolean,required:!1},highlight:{type:Boolean,required:!1},createItem:{type:[Boolean,String,Object],required:!1},filterFields:{type:Array,required:!1},ignoreFilter:{type:Boolean,required:!1},autofocus:{type:Boolean,required:!1},autofocusDelay:{type:Number,required:!1,default:0},class:{type:null,required:!1},ui:{type:Object,required:!1},open:{type:Boolean,required:!1},defaultOpen:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},name:{type:String,required:!1},resetSearchTermOnBlur:{type:Boolean,required:!1,default:!0},resetSearchTermOnSelect:{type:Boolean,required:!1,default:!0},resetModelValueOnClear:{type:Boolean,required:!1,default:!0},highlightOnHover:{type:Boolean,required:!1},by:{type:[String,Function],required:!1},icon:{type:null,required:!1},avatar:{type:Object,required:!1},leading:{type:Boolean,required:!1},leadingIcon:{type:null,required:!1},trailing:{type:Boolean,required:!1},loading:{type:Boolean,required:!1},loadingIcon:{type:null,required:!1}},{searchTerm:{type:String,default:""},searchTermModifiers:{}}),emits:qt(["change","blur","focus","create","clear","highlight","update:modelValue","update:open"],["update:searchTerm"]),setup(i,{expose:l,emit:e}){const n=i,s=e,u=Qt(),o=Ca("selectMenu",n),c=Wt(i,"searchTerm",{type:String,default:""}),{t:g}=bn(),h=Ia(),{filterGroups:f}=Rl(),b=rs(is(o,"modelValue","defaultValue","open","defaultOpen","required","multiple","resetSearchTermOnBlur","resetSearchTermOnSelect","resetModelValueOnClear","highlightOnHover","by"),s),y=kn(We(()=>o.portal)),k=We(()=>Tt(o.content,{side:"bottom",sideOffset:8,collisionPadding:8,position:"popper"})),x=We(()=>Tt(o.arrow,{rounded:!0})),_=M(()=>typeof o.clear=="object"?o.clear:{}),C=We(()=>o.virtualize?Tt(typeof o.virtualize=="boolean"?{}:o.virtualize,{estimateSize:nu(Q.value,re.value||"md",o.descriptionKey,!!u["item-description"])}):!1),$=We(()=>Tt(o.searchInput,{placeholder:g("selectMenu.search"),variant:"none"})),{emitFormBlur:I,emitFormFocus:T,emitFormInput:v,emitFormChange:w,size:E,color:F,id:D,name:A,highlight:S,disabled:q,ariaAttrs:Y}=Sa(n),{orientation:G,size:Z}=us(n),{isLeading:ce,isTrailing:ne,leadingIconName:H,trailingIconName:W}=Ta(We(()=>Tt(o,{trailingIcon:h.ui.icons.chevronDown}))),re=M(()=>Z.value||E.value),[ve,fe]=Ra(),[ee,te]=Ra({props:{item:{type:[Object,String,Number,Boolean],required:!0},index:{type:Number,required:!1}}}),j=M(()=>$t({extend:$t(ou),...h.ui?.selectMenu||{}})({color:F.value??o.color,variant:o.variant,size:re?.value??o.size,loading:o.loading,highlight:S.value??o.highlight,leading:ce.value||!!o.avatar||!!u.leading,trailing:ne.value||!!u.trailing,fieldGroup:G.value,virtualize:!!o.virtualize,multiple:o.multiple}));function de(L){if(o.multiple&&Array.isArray(L)){const P=L.map(N=>Va(xe.value,N,{labelKey:o.labelKey,valueKey:o.valueKey,by:o.by})).filter(N=>N!=null&&N!=="");return P.length>0?P.join(", "):void 0}return Va(xe.value,L,{labelKey:o.labelKey,valueKey:o.valueKey,by:o.by})}const be=M(()=>o.items?.length?Cn(o.items)?o.items:[o.items]:[]),xe=M(()=>be.value.flatMap(L=>L)),oe=M(()=>{if(o.ignoreFilter||!c.value)return be.value;const L=Array.isArray(o.filterFields)?o.filterFields:[o.labelKey];return f(be.value,c.value,{fields:L,isStructural:P=>Se(P)&&!!P.type&&["label","separator"].includes(P.type)})}),Q=M(()=>oe.value.flatMap(L=>L)),J=M(()=>{if(!o.createItem||!c.value)return!1;const L=o.valueKey?{[o.valueKey]:c.value}:c.value;return typeof o.createItem=="object"&&o.createItem.when==="always"||o.createItem==="always"?!Q.value.find(P=>$n(P,L,o.by??o.valueKey)):!Q.value.length}),ge=M(()=>typeof o.createItem=="object"?o.createItem.position:"bottom"),ke=At("triggerRef");function $e(){o.autofocus&&ke.value?.$el?.focus({focusVisible:!0})}Re(()=>{setTimeout(()=>{$e()},o.autofocusDelay)});function Le(L){if(cs(o.modelValue)===L)return;o.modelModifiers?.trim&&(typeof L=="string"||L===null||L===void 0)&&(L=L?.trim()??null),o.modelModifiers?.number&&(L=ds(L)),o.modelModifiers?.nullable&&(L??=null),o.modelModifiers?.optional&&!o.modelModifiers?.nullable&&L!==null&&(L??=void 0);const P=new Event("change",{target:{value:L}});s("change",P),w(),v(),o.resetSearchTermOnSelect&&(c.value="")}const Be=z(!1);function Te(L){Be.value=L;let P;if(L){const N=new FocusEvent("focus");s("focus",N),T(),clearTimeout(P)}else{const N=new FocusEvent("blur");s("blur",N),I(),o.resetSearchTermOnBlur&&(P=setTimeout(()=>{c.value=""},100))}}function Pe(L){L.preventDefault(),L.stopPropagation(),s("create",c.value)}function je(L,P){if(Se(P)){if(P.disabled){L.preventDefault();return}P.onSelect?.(L)}}function Se(L){return typeof L=="object"&&L!==null}function me(L){return o.multiple&&Array.isArray(L)?L.length===0:L==null||L===""}function O(){s("clear")}const V=At("viewportRef"),K=At("comboboxRootRef");return he(()=>o.items,async()=>{Be.value&&(await De(),K.value?.highlightFirstItem?.())},{flush:"post"}),l({triggerRef:We(()=>ke.value?.$el),viewportRef:We(()=>V.value)}),(L,P)=>(r(),m(ie,null,[p(t(ve),null,{default:B(()=>[p(t(Ha),{"data-slot":"item",class:X(j.value.item({class:t(o).ui?.item})),value:c.value,onSelect:Pe},{default:B(()=>[a("span",{"data-slot":"itemLabel",class:X(j.value.itemLabel({class:t(o).ui?.itemLabel}))},[ye(L.$slots,"create-item-label",{item:c.value},()=>[le(d(t(g)("selectMenu.create",{label:c.value})),1)])],2)]),_:3},8,["class","value"])]),_:3}),p(t(ee),null,{default:B(({item:N,index:ae})=>[Se(N)&&N.type==="label"?(r(),U(t(pl),{key:0,"data-slot":"label",class:X(j.value.label({class:[t(o).ui?.label,N.ui?.label,N.class]}))},{default:B(()=>[le(d(t(lt)(N,t(o).labelKey)),1)]),_:2},1032,["class"])):Se(N)&&N.type==="separator"?(r(),U(t(yl),{key:1,"data-slot":"separator",class:X(j.value.separator({class:[t(o).ui?.separator,N.ui?.separator,N.class]}))},null,8,["class"])):(r(),U(t(Ha),{key:2,"data-slot":"item",class:X(j.value.item({class:[t(o).ui?.item,Se(N)&&N.ui?.item,Se(N)&&N.class]})),disabled:Se(N)&&N.disabled,value:t(o).valueKey&&Se(N)?t(lt)(N,t(o).valueKey):N,onSelect:se=>je(se,N)},{default:B(()=>[ye(L.$slots,"item",{item:N,index:ae,ui:j.value},()=>[ye(L.$slots,"item-leading",{item:N,index:ae,ui:j.value},()=>[Se(N)&&N.icon?(r(),U(_e,{key:0,name:N.icon,"data-slot":"itemLeadingIcon",class:X(j.value.itemLeadingIcon({class:[t(o).ui?.itemLeadingIcon,N.ui?.itemLeadingIcon]}))},null,8,["name","class"])):Se(N)&&N.avatar?(r(),U(Ht,ze({key:1,size:N.ui?.itemLeadingAvatarSize||t(o).ui?.itemLeadingAvatarSize||j.value.itemLeadingAvatarSize()},N.avatar,{"data-slot":"itemLeadingAvatar",class:j.value.itemLeadingAvatar({class:[t(o).ui?.itemLeadingAvatar,N.ui?.itemLeadingAvatar]})}),null,16,["size","class"])):Se(N)&&N.chip?(r(),U(_n,ze({key:2,size:N.ui?.itemLeadingChipSize||t(o).ui?.itemLeadingChipSize||j.value.itemLeadingChipSize(),inset:"",standalone:""},N.chip,{"data-slot":"itemLeadingChip",class:j.value.itemLeadingChip({class:[t(o).ui?.itemLeadingChip,N.ui?.itemLeadingChip]})}),null,16,["size","class"])):R("",!0)]),a("span",{"data-slot":"itemWrapper",class:X(j.value.itemWrapper({class:[t(o).ui?.itemWrapper,Se(N)&&N.ui?.itemWrapper]}))},[a("span",{"data-slot":"itemLabel",class:X(j.value.itemLabel({class:[t(o).ui?.itemLabel,Se(N)&&N.ui?.itemLabel]}))},[ye(L.$slots,"item-label",{item:N,index:ae},()=>[le(d(Se(N)?t(lt)(N,t(o).labelKey):N),1)])],2),Se(N)&&(t(lt)(N,t(o).descriptionKey)||u["item-description"])?(r(),m("span",{key:0,"data-slot":"itemDescription",class:X(j.value.itemDescription({class:[t(o).ui?.itemDescription,Se(N)&&N.ui?.itemDescription]}))},[ye(L.$slots,"item-description",{item:N,index:ae},()=>[le(d(t(lt)(N,t(o).descriptionKey)),1)])],2)):R("",!0)],2),a("span",{"data-slot":"itemTrailing",class:X(j.value.itemTrailing({class:[t(o).ui?.itemTrailing,Se(N)&&N.ui?.itemTrailing]}))},[ye(L.$slots,"item-trailing",{item:N,index:ae,ui:j.value}),p(t(ml),{"as-child":""},{default:B(()=>[p(_e,{name:t(o).selectedIcon||t(h).ui.icons.check,"data-slot":"itemTrailingIcon",class:X(j.value.itemTrailingIcon({class:[t(o).ui?.itemTrailingIcon,Se(N)&&N.ui?.itemTrailingIcon]}))},null,8,["name","class"])]),_:2},1024)],2)])]),_:2},1032,["class","disabled","value","onSelect"]))]),_:3}),p(t(Wo),ze({ref_key:"comboboxRootRef",ref:K},t(b),{"ignore-filter":"","as-child":"",name:t(A),disabled:t(q),"onUpdate:modelValue":Le,"onUpdate:open":Te}),{default:B(({modelValue:N,open:ae})=>[p(t(Ko),{"as-child":""},{default:B(()=>[p(t(bl),ze({id:t(D),ref_key:"triggerRef",ref:ke,"data-slot":"base",class:j.value.base({class:[t(o).ui?.base,t(o).class]}),tabindex:"0"},{...L.$attrs,...t(Y)}),{default:B(()=>[t(ce)||t(o).avatar||u.leading?(r(),m("span",{key:0,"data-slot":"leading",class:X(j.value.leading({class:t(o).ui?.leading}))},[ye(L.$slots,"leading",{modelValue:N,open:ae,ui:j.value},()=>[t(ce)&&t(H)?(r(),U(_e,{key:0,name:t(H),"data-slot":"leadingIcon",class:X(j.value.leadingIcon({class:t(o).ui?.leadingIcon}))},null,8,["name","class"])):t(o).avatar?(r(),U(Ht,ze({key:1,size:t(o).ui?.itemLeadingAvatarSize||j.value.itemLeadingAvatarSize()},t(o).avatar,{"data-slot":"itemLeadingAvatar",class:j.value.itemLeadingAvatar({class:t(o).ui?.itemLeadingAvatar})}),null,16,["size","class"])):R("",!0)])],2)):R("",!0),ye(L.$slots,"default",{modelValue:N,open:ae,ui:j.value},()=>[(r(!0),m(ie,null,pe([de(N)],se=>(r(),m(ie,{key:se},[se!=null?(r(),m("span",{key:0,"data-slot":"value",class:X(j.value.value({class:t(o).ui?.value}))},d(se),3)):(r(),m("span",{key:1,"data-slot":"placeholder",class:X(j.value.placeholder({class:t(o).ui?.placeholder}))},d(t(o).placeholder??" "),3))],64))),128))]),t(ne)||u.trailing||t(o).clear?(r(),m("span",{key:1,"data-slot":"trailing",class:X(j.value.trailing({class:t(o).ui?.trailing}))},[ye(L.$slots,"trailing",{modelValue:N,open:ae,ui:j.value},()=>[t(o).clear&&!me(N)?(r(),U(t(tl),{key:0,"as-child":""},{default:B(()=>[p(Ue,ze({as:"span",icon:t(o).clearIcon||t(h).ui.icons.close,size:re.value,variant:"link",color:"neutral",tabindex:"-1"},_.value,{"data-slot":"trailingClear",class:j.value.trailingClear({class:t(o).ui?.trailingClear}),onClick:Oe(O,["stop"])}),null,16,["icon","size","class"])]),_:1})):t(W)?(r(),U(_e,{key:1,name:t(W),"data-slot":"trailingIcon",class:X(j.value.trailingIcon({class:t(o).ui?.trailingIcon}))},null,8,["name","class"])):R("",!0)])],2)):R("",!0)]),_:2},1040,["id","class"])]),_:2},1024),p(t(fl),ht(zt(t(y))),{default:B(()=>[p(t(wn),null,{default:B(()=>[p(t(sl),ze({"data-slot":"content",class:j.value.content({class:t(o).ui?.content})},k.value),{default:B(()=>[p(t(as),{trapped:"","data-slot":"focusScope",class:X(j.value.focusScope({class:t(o).ui?.focusScope}))},{default:B(()=>[ye(L.$slots,"content-top"),t(o).searchInput?(r(),U(t(ul),{key:0,modelValue:c.value,"onUpdate:modelValue":P[1]||(P[1]=se=>c.value=se),"display-value":()=>c.value,"as-child":""},{default:B(()=>[p(Bt,ze({autofocus:"",autocomplete:"off",size:re.value},$.value,{"model-modifiers":{trim:t(o).modelModifiers?.trim},"data-slot":"input",class:j.value.input({class:t(o).ui?.input}),onChange:P[0]||(P[0]=Oe(()=>{},["stop"]))}),null,16,["size","model-modifiers","class"])]),_:1},8,["modelValue","display-value"])):R("",!0),p(t(ol),{"data-slot":"empty",class:X(j.value.empty({class:t(o).ui?.empty}))},{default:B(()=>[ye(L.$slots,"empty",{searchTerm:c.value},()=>[le(d(c.value?t(g)("selectMenu.noMatch",{searchTerm:c.value}):t(g)("selectMenu.noData")),1)])]),_:3},8,["class"]),a("div",{ref_key:"viewportRef",ref:V,role:"presentation","data-slot":"viewport",class:X(j.value.viewport({class:t(o).ui?.viewport}))},[t(o).virtualize?(r(),m(ie,{key:0},[J.value&&ge.value==="top"?(r(),U(t(fe),{key:0})):R("",!0),p(t(_l),ze({options:Q.value,"text-content":se=>Se(se)?t(lt)(se,t(o).labelKey):String(se)},C.value),{default:B(({option:se,virtualItem:Ve})=>[p(t(te),{item:se,index:Ve.index},null,8,["item","index"])]),_:1},16,["options","text-content"]),J.value&&ge.value==="bottom"?(r(),U(t(fe),{key:1})):R("",!0)],64)):(r(),m(ie,{key:1},[J.value&&ge.value==="top"?(r(),U(t(ra),{key:0,"data-slot":"group",class:X(j.value.group({class:t(o).ui?.group}))},{default:B(()=>[p(t(fe))]),_:1},8,["class"])):R("",!0),(r(!0),m(ie,null,pe(oe.value,(se,Ve)=>(r(),U(t(ra),{key:`group-${Ve}`,"data-slot":"group",class:X(j.value.group({class:t(o).ui?.group}))},{default:B(()=>[(r(!0),m(ie,null,pe(se,(qe,Me)=>(r(),U(t(te),{key:`group-${Ve}-${Me}`,item:qe,index:Me},null,8,["item","index"]))),128))]),_:2},1032,["class"]))),128)),J.value&&ge.value==="bottom"?(r(),U(t(ra),{key:1,"data-slot":"group",class:X(j.value.group({class:t(o).ui?.group}))},{default:B(()=>[p(t(fe))]),_:1},8,["class"])):R("",!0)],64))],2),ye(L.$slots,"content-bottom")]),_:3},8,["class"]),t(o).arrow?(r(),U(t(Zo),ze({key:0},x.value,{"data-slot":"arrow",class:j.value.arrow({class:t(o).ui?.arrow})}),null,16,["class"])):R("",!0)]),_:3},16,["class"])]),_:3})]),_:3},16)]),_:3},16,["name","disabled"])],64))}}),lu={class:"h-full p-3"},ru={class:"relative z-20 flex items-center gap-2 border-b border-gray-200 px-4 py-2 dark:border-gray-700"},iu={key:0,class:"mx-4 mt-2 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-400"},uu={class:"flex-1 overflow-auto"},cu={key:0,class:"flex h-full items-center justify-center"},du={class:"text-sm text-gray-400"},mu={key:1,class:"w-full border-collapse text-xs"},gu={class:"sticky top-0 bg-gray-50 dark:bg-page-dark"},pu={class:"font-mono text-xs font-medium text-gray-700 dark:text-gray-300"},hu={class:"text-[10px] leading-tight text-gray-400"},fu={class:"border-b border-r border-gray-100 px-2 py-1.5 text-gray-400 dark:border-gray-800"},vu=["title"],yu=["onUpdate:modelValue"],xu={class:"w-full truncate px-2 py-1.5"},bu={key:0,class:"italic text-gray-400"},ku={key:1},_u={class:"border-b border-gray-100 px-2 py-1.5 text-center dark:border-gray-800"},wu={key:0,class:"flex items-center justify-center gap-1"},$u={key:1,class:"flex items-center justify-center gap-1"},Cu={class:"flex items-center justify-between border-t border-gray-200 px-4 py-2 dark:border-gray-700"},Su={class:"text-xs text-gray-500 dark:text-gray-400"},Iu={key:0,class:"flex items-center gap-3"},Tu={class:"text-xs text-gray-500 dark:text-gray-400"},Ot=100,Mu=ue({__name:"TableBrowser",props:{sessionId:{}},setup(i){const l=["member","meta","message","message_context","member_name_history"],{t:e,locale:n}=we(),s=i,u=z(localStorage.getItem("debug_dbSource")||"chat"),o=z([]),c=z(""),g=z(null),h=z(!1),f=z(null),b=z(1),y=z(0),k=M(()=>Math.max(1,Math.ceil(y.value/Ot))),x=z(null),_=z({}),C=z(!1),$=M(()=>u.value==="ai"),I=z([]),T=z(""),v=M(()=>$.value&&c.value==="ai_message"&&I.value.length>0),w=M(()=>{const ee={label:e("analysis.debug.tableBrowser.allConversations"),value:"__all__"},te=I.value.map(j=>({label:j.title||j.id.slice(0,16),value:j.id}));return[ee,...te]});async function E(){if(!$.value){I.value=[];return}try{const ee=s.sessionId.replace(/'/g,"''"),te=await Ye().executeAiSQL(`SELECT id, title FROM ai_chat WHERE session_id = '${ee}' ORDER BY updated_at DESC`);I.value=te.rows.map(j=>({id:String(j[0]),title:j[1]?String(j[1]):null})),T.value="__all__"}catch{I.value=[]}}const F=M(()=>[{label:e("analysis.debug.tableBrowser.chatDb"),value:"chat"},{label:e("analysis.debug.tableBrowser.aiDb"),value:"ai"}]),D=M(()=>{const ee=[...o.value];return ee.sort((te,j)=>{const de=l.indexOf(te.name),be=l.indexOf(j.name);return de!==-1&&be!==-1?de-be:de!==-1?-1:be!==-1?1:0}),ee}),A=M(()=>D.value.map(ee=>({label:ee.name,value:ee.name})));async function S(ee){return u.value==="ai"?await Ye().executeAiSQL(ee):await Ke().executeSQL(s.sessionId,ee)}async function q(){try{if(u.value==="ai"?o.value=await Ye().getAiSchema():o.value=await Ke().getSchema(s.sessionId),D.value.length>0){const ee=$.value?"ai_message":D.value[0].name;c.value=D.value.some(te=>te.name===ee)?ee:D.value[0].name}else c.value="",g.value=null}catch(ee){console.error("Failed to load schema:",ee)}}function Y(){if(!$.value)return"";const ee=s.sessionId.replace(/'/g,"''"),te=c.value;return te==="ai_chat"?` WHERE "session_id" = '${ee}'`:te==="ai_message"?T.value&&T.value!=="__all__"?` WHERE "ai_chat_id" = '${T.value.replace(/'/g,"''")}'`:` WHERE "ai_chat_id" IN (SELECT "id" FROM "ai_chat" WHERE "session_id" = '${ee}')`:""}async function G(){if(c.value){h.value=!0,f.value=null,x.value=null;try{const ee=Y(),te=await S(`SELECT COUNT(*) as cnt FROM "${c.value}"${ee}`);y.value=te?.rows?.[0]?.[0]??0;const j=(b.value-1)*Ot;g.value=await S(`SELECT * FROM "${c.value}"${ee} ORDER BY rowid DESC LIMIT ${Ot} OFFSET ${j}`)}catch(ee){f.value=ee.message||String(ee),g.value=null}finally{h.value=!1}}}function Z(ee){if(!g.value)return;x.value=ee;const te=g.value.rows[ee],j={};g.value.columns.forEach((de,be)=>{j[de]=te[be]==null?"":String(te[be])}),_.value=j}function ce(){x.value=null,_.value={}}async function ne(){if(x.value===null||!g.value)return;const ee=c.value,te=o.value.find(J=>J.name===ee);if(!te)return;const j=te.columns.find(J=>J.pk);if(!j){f.value="No primary key found for this table";return}const de=g.value.rows[x.value],be=g.value.columns.indexOf(j.name),xe=de[be],oe=g.value.columns.filter(J=>J!==j.name).map(J=>`"${J}" = '${_.value[J].replace(/'/g,"''")}'`).join(", "),Q=`UPDATE "${ee}" SET ${oe} WHERE "${j.name}" = '${String(xe).replace(/'/g,"''")}'`;try{await S(Q),ce(),await G()}catch(J){f.value=J.message||String(J)}}async function H(ee){if(!g.value)return;const te=c.value,j=o.value.find(J=>J.name===te);if(!j)return;const de=j.columns.find(J=>J.pk);if(!de){f.value="No primary key found for this table";return}const be=g.value.rows[ee],xe=g.value.columns.indexOf(de.name),oe=be[xe],Q=`DELETE FROM "${te}" WHERE "${de.name}" = '${String(oe).replace(/'/g,"''")}'`;try{await S(Q),await G()}catch(J){f.value=J.message||String(J)}}function W(ee){confirm(e("analysis.debug.tableBrowser.confirmDelete"))&&H(ee)}async function re(){if(confirm(e("analysis.debug.tableBrowser.confirmClearDebug"))){C.value=!0;try{(await Ye().clearDebugContext()).success&&await G()}catch(ee){f.value=ee.message||String(ee)}finally{C.value=!1}}}function ve(ee){navigator.clipboard.writeText(ee)}function fe(ee,te,j){if(!g.value)return[];const de=ee==null?"NULL":String(ee),be=g.value.rows[j],xe={};return g.value.columns.forEach((oe,Q)=>{xe[oe]=be[Q]}),[[{label:e("analysis.debug.tableBrowser.copyCell"),class:"p-2",onSelect:()=>ve(de)},{label:e("analysis.debug.tableBrowser.editRow"),class:"p-2",onSelect:()=>Z(j)},{label:e("analysis.debug.tableBrowser.copyRow"),class:"p-2",onSelect:()=>ve(JSON.stringify(xe,null,2))},{label:e("analysis.debug.tableBrowser.deleteRow"),class:"p-2 text-red-600 dark:text-red-400",onSelect:()=>H(j)}]]}return he(u,ee=>{localStorage.setItem("debug_dbSource",ee),c.value="",g.value=null,y.value=0,b.value=1,T.value="",q(),E()}),he(c,ee=>{ee&&(b.value=1,G())}),he(T,()=>{c.value==="ai_message"&&(b.value=1,G())}),he(b,()=>{G()}),Re(async()=>{await Promise.all([q(),E()]),c.value&&await G()}),(ee,te)=>{const j=Da,de=Ue,be=Sn;return r(),m("div",lu,[p(t(mt),{shadow:!1,class:"flex h-full min-w-0 flex-col"},{default:B(()=>[a("div",ru,[p(t(pt),{modelValue:u.value,"onUpdate:modelValue":te[0]||(te[0]=xe=>u.value=xe),items:F.value,size:"xs"},null,8,["modelValue","items"]),te[5]||(te[5]=a("div",{class:"mx-1 h-4 w-px bg-gray-200 dark:bg-gray-700"},null,-1)),a("div",{class:X([$.value?"max-w-[50%]":"flex-1","min-w-0"])},[p(t(pt),{modelValue:c.value,"onUpdate:modelValue":te[1]||(te[1]=xe=>c.value=xe),items:A.value,size:"xs"},null,8,["modelValue","items"])],2),v.value?(r(),U(j,{key:0,modelValue:T.value,"onUpdate:modelValue":te[2]||(te[2]=xe=>T.value=xe),items:w.value,"value-key":"value",class:"w-48",size:"xs",ui:{content:"z-50"}},null,8,["modelValue","items"])):R("",!0),te[6]||(te[6]=a("div",{class:"flex-1"},null,-1)),$.value&&c.value==="ai_message"?(r(),U(de,{key:1,variant:"ghost",size:"xs",color:"error",icon:"i-heroicons-trash",loading:C.value,onClick:re},{default:B(()=>[le(d(t(e)("analysis.debug.tableBrowser.clearDebugContext")),1)]),_:1},8,["loading"])):R("",!0),p(de,{variant:"ghost",size:"xs",icon:"i-heroicons-arrow-path",loading:h.value,onClick:G},{default:B(()=>[le(d(t(e)("analysis.debug.tableBrowser.refresh")),1)]),_:1},8,["loading"])]),f.value?(r(),m("div",iu,d(f.value),1)):R("",!0),a("div",uu,[!g.value&&!h.value?(r(),m("div",cu,[a("p",du,d(t(e)("analysis.debug.tableBrowser.noData")),1)])):g.value?(r(),m("table",mu,[a("thead",gu,[a("tr",null,[te[7]||(te[7]=a("th",{class:"whitespace-nowrap border-b border-r border-gray-200 px-2 py-1.5 text-left font-medium text-gray-500 dark:border-gray-700 dark:text-gray-400"}," # ",-1)),(r(!0),m(ie,null,pe(g.value.columns,xe=>(r(),m("th",{key:xe,class:"border-b border-r border-gray-200 px-2 py-1.5 text-left dark:border-gray-700"},[a("div",pu,d(xe),1),a("div",hu,d(t(La)(c.value,xe,t(n))),1)]))),128)),te[8]||(te[8]=a("th",{class:"whitespace-nowrap border-b border-gray-200 px-2 py-1.5 text-center font-medium text-gray-500 dark:border-gray-700 dark:text-gray-400"}," 操作 ",-1))])]),a("tbody",null,[(r(!0),m(ie,null,pe(g.value.rows,(xe,oe)=>(r(),m("tr",{key:oe,class:"transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[a("td",fu,d((b.value-1)*Ot+oe+1),1),(r(!0),m(ie,null,pe(xe,(Q,J)=>(r(),m("td",{key:J,class:"max-w-[300px] border-b border-r border-gray-100 p-0 text-gray-700 dark:border-gray-800 dark:text-gray-300",title:Q==null?"NULL":String(Q)},[x.value===oe?Qe((r(),m("input",{key:0,"onUpdate:modelValue":ge=>_.value[g.value.columns[J]]=ge,class:"w-full px-2 py-1.5 rounded border border-gray-300 bg-white text-xs dark:border-gray-600 dark:bg-gray-800"},null,8,yu)),[[ft,_.value[g.value.columns[J]]]]):(r(),U(be,{key:1,items:fe(Q,J,oe)},{default:B(()=>[a("div",xu,[Q==null?(r(),m("span",bu,"NULL")):(r(),m("span",ku,d(String(Q).slice(0,200)),1))])]),_:2},1032,["items"]))],8,vu))),128)),a("td",_u,[x.value===oe?(r(),m("div",wu,[p(de,{size:"xs",color:"primary",variant:"ghost",icon:"i-heroicons-check",onClick:ne}),p(de,{size:"xs",color:"neutral",variant:"ghost",icon:"i-heroicons-x-mark",onClick:ce})])):(r(),m("div",$u,[p(de,{size:"xs",variant:"ghost",icon:"i-heroicons-pencil-square",onClick:Q=>Z(oe)},null,8,["onClick"]),p(de,{size:"xs",variant:"ghost",color:"error",icon:"i-heroicons-trash",onClick:Q=>W(oe)},null,8,["onClick"])]))])]))),128))])])):R("",!0)]),a("div",Cu,[a("span",Su,d(y.value>0?t(e)("analysis.debug.tableBrowser.rowCount",{count:y.value}):""),1),k.value>1?(r(),m("div",Iu,[p(de,{size:"xs",variant:"ghost",disabled:b.value<=1,icon:"i-heroicons-chevron-left",onClick:te[3]||(te[3]=xe=>b.value--)},null,8,["disabled"]),a("span",Tu,d(t(e)("analysis.debug.tableBrowser.page",{current:b.value,total:k.value})),1),p(de,{size:"xs",variant:"ghost",disabled:b.value>=k.value,icon:"i-heroicons-chevron-right",onClick:te[4]||(te[4]=xe=>b.value++)},null,8,["disabled"])])):R("",!0)])]),_:1})])}}}),Au={class:"flex h-full"},zu={class:"m-3 h-[calc(100%-1.5rem)] w-56 shrink-0 overflow-y-auto rounded-lg bg-white shadow-elevated dark:bg-sidebar-dark"},qu={key:0,class:"py-2"},Lu={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},Du=["title","onClick"],Eu={class:"truncate text-xs font-medium"},Bu={class:"truncate text-[10px] opacity-50"},Fu={key:1,class:"border-t border-gray-200 py-2 dark:border-gray-700"},Ru={class:"px-3 py-1.5 text-[11px] font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"},Vu=["title","onClick"],Ou={class:"truncate text-xs font-medium"},Pu={class:"truncate text-[10px] opacity-50"},ju={class:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4"},Nu={key:0,class:"rounded-lg border border-primary-200 bg-primary-50/50 px-4 py-3 dark:border-primary-800 dark:bg-primary-900/20"},Uu={class:"text-sm font-medium text-primary-700 dark:text-primary-300"},Wu={class:"mt-1 text-xs text-primary-600/70 dark:text-primary-400/70"},Hu={key:1,class:"flex flex-col gap-3"},Ku={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},Yu={class:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3"},Gu={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},Qu={key:0,class:"text-red-500"},Ju={key:1,class:"ml-1 text-gray-400"},Xu={key:2,class:"ml-1 text-gray-400"},Zu={class:"flex items-center gap-3"},ec={key:3,class:"text-xs text-gray-500 dark:text-gray-400"},tc={key:2,class:"flex-1 min-h-0"},ac={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},sc={key:0,class:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-400"},nc={key:0,class:"mb-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-800 dark:bg-amber-900/20 dark:text-amber-400"},oc={class:"max-h-[60vh] overflow-auto rounded-lg border border-gray-200 bg-gray-50 p-3 text-xs leading-relaxed text-gray-800 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200"},lc=ue({__name:"ToolTestTab",props:{sessionId:{}},setup(i){const{t:l}=we(),e=i,n=z([]),s=z(""),u=z({}),o=z(!1),c=z(null),g=z(null),h=z(null),f=z(!1),b=z(null);function y(v){const w=`ai.assistant.builtinToolDesc.${v}`,E=l(w);return E!==w?E:v}const k=M(()=>n.value.filter(v=>v.category==="core")),x=M(()=>n.value.filter(v=>v.category==="analysis")),_=M(()=>n.value.find(v=>v.name===s.value)),C=M(()=>{const v=_.value;if(!v?.parameters)return[];const w=v.parameters;if(!w.properties)return[];const E=new Set(w.required??[]);return Object.entries(w.properties).map(([F,D])=>{const A={name:F,type:D.type??"string",description:D.description??"",required:E.has(F),defaultValue:D.default};if(D.enum&&(A.enumValues=D.enum),D.type==="array"){A.isArray=!0;const S=D.items;A.arrayItemType=S?.type??"string"}return A})});he(s,()=>{u.value={},g.value=null,h.value=null,b.value=null}),Re(async()=>{try{n.value=await Ye().getToolCatalog(),n.value.length>0&&(s.value=n.value[0].name)}catch(v){console.error("Failed to load tool catalog:",v)}});function $(){const v={};for(const w of C.value){const E=u.value[w.name];if(!(E===void 0||E===""))if(w.type==="number"){const F=Number(E);isNaN(F)||(v[w.name]=F)}else w.isArray?v[w.name]=E.split(",").map(F=>F.trim()).filter(Boolean):v[w.name]=E}return v}async function I(){if(!s.value||o.value)return;o.value=!0,g.value=null,h.value=null,f.value=!1,b.value=null;const v=`tool_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;c.value=v;try{const w=$(),E=await Ye().executeTool(v,s.value,w,e.sessionId);if(E.error==="cancelled")return;E.success?(b.value=E.elapsed??null,f.value=!!E.truncated,g.value=E.truncated?E.details?._preview??"":JSON.stringify(E.details??E.content,null,2)):h.value=E.error??"Unknown error"}catch(w){h.value=String(w)}finally{o.value=!1,c.value=null}}async function T(){c.value&&(await Ye().cancelToolTest(c.value),o.value=!1,c.value=null)}return(v,w)=>{const E=Da,F=Bt,D=Ue,A=_e;return r(),m("div",Au,[a("div",zu,[k.value.length>0?(r(),m("div",qu,[a("div",Lu,d(t(l)("ai.lab.toolTest.coreTools")),1),(r(!0),m(ie,null,pe(k.value,S=>(r(),m("button",{key:S.name,class:X(["flex w-full flex-col px-3 py-1.5 text-left transition-colors",[s.value===S.name?"bg-primary-50 text-primary-700 dark:bg-primary-900/30 dark:text-primary-300":"text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700/50"]]),title:S.description,onClick:q=>s.value=S.name},[a("span",Eu,d(y(S.name)),1),a("span",Bu,d(S.name),1)],10,Du))),128))])):R("",!0),x.value.length>0?(r(),m("div",Fu,[a("div",Ru,d(t(l)("ai.lab.toolTest.analysisTools")),1),(r(!0),m(ie,null,pe(x.value,S=>(r(),m("button",{key:S.name,class:X(["flex w-full flex-col px-3 py-1.5 text-left transition-colors",[s.value===S.name?"bg-primary-50 text-primary-700 dark:bg-primary-900/30 dark:text-primary-300":"text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700/50"]]),title:S.description,onClick:q=>s.value=S.name},[a("span",Ou,d(y(S.name)),1),a("span",Pu,d(S.name),1)],10,Vu))),128))])):R("",!0)]),p(t(mt),{class:"my-3 mr-3 flex min-w-0 flex-1 flex-col"},{default:B(()=>[a("div",ju,[_.value?(r(),m("div",Nu,[a("div",Uu,d(y(_.value.name)),1),a("div",Wu,d(_.value.description),1)])):R("",!0),C.value.length>0?(r(),m("div",Hu,[a("h3",Ku,d(t(l)("ai.lab.toolTest.parameters")),1),a("div",Yu,[(r(!0),m(ie,null,pe(C.value,S=>(r(),m("div",{key:S.name,class:"flex flex-col gap-1"},[a("label",Gu,[le(d(S.name)+" ",1),S.required?(r(),m("span",Qu,"*")):R("",!0),S.type==="number"?(r(),m("span",Ju,"(number)")):R("",!0),S.isArray?(r(),m("span",Xu,"("+d(S.arrayItemType)+"[])",1)):R("",!0)]),S.enumValues?(r(),U(E,{key:0,modelValue:u.value[S.name],"onUpdate:modelValue":q=>u.value[S.name]=q,items:S.enumValues,placeholder:S.description,size:"sm"},null,8,["modelValue","onUpdate:modelValue","items","placeholder"])):(r(),U(F,{key:1,modelValue:u.value[S.name],"onUpdate:modelValue":q=>u.value[S.name]=q,placeholder:S.isArray?t(l)("ai.lab.toolTest.arrayPlaceholder"):S.defaultValue!==void 0?String(S.defaultValue):S.description,type:S.type==="number"?"number":"text",size:"sm"},null,8,["modelValue","onUpdate:modelValue","placeholder","type"]))]))),128))])])):R("",!0),a("div",Zu,[o.value?(r(),U(D,{key:1,color:"error",icon:"i-heroicons-stop",onClick:T},{default:B(()=>[le(d(t(l)("ai.lab.toolTest.cancel")),1)]),_:1})):(r(),U(D,{key:0,color:"primary",disabled:!s.value,icon:"i-heroicons-play",onClick:I},{default:B(()=>[le(d(t(l)("ai.lab.toolTest.execute")),1)]),_:1},8,["disabled"])),o.value?(r(),U(A,{key:2,name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin text-gray-400"})):R("",!0),b.value!==null?(r(),m("span",ec,d(t(l)("ai.lab.toolTest.elapsed",{ms:b.value})),1)):R("",!0)]),g.value||h.value?(r(),m("div",tc,[a("h3",ac,d(t(l)("ai.lab.toolTest.result")),1),h.value?(r(),m("div",sc,d(h.value),1)):(r(),m(ie,{key:1},[f.value?(r(),m("div",nc,d(t(l)("ai.lab.toolTest.truncated")),1)):R("",!0),a("pre",oc,d(g.value),1)],64))])):R("",!0)])]),_:1})])}}}),rc={class:"flex h-full flex-col"},ic={class:"min-h-0 flex-1 overflow-hidden"},uc=ue({__name:"DebugTab",props:{sessionId:{}},setup(i){const{t:l}=we(),e=i,n=[{id:"sql-tables",label:l("analysis.debug.sqlTables"),icon:"i-heroicons-table-cells"},{id:"basic-tools",label:l("analysis.debug.basicTools"),icon:"i-heroicons-wrench-screwdriver"}],s=z("sql-tables");return(u,o)=>(r(),m("div",rc,[p(t(ls),{modelValue:s.value,"onUpdate:modelValue":o[0]||(o[0]=c=>s.value=c),items:n,"persist-key":"debugTab"},null,8,["modelValue"]),a("div",ic,[p(vt,{name:"fade",mode:"out-in"},{default:B(()=>[s.value==="sql-tables"?(r(),U(Mu,{key:0,class:"h-full","session-id":e.sessionId},null,8,["session-id"])):s.value==="basic-tools"?(r(),U(lc,{key:1,class:"h-full","session-id":e.sessionId},null,8,["session-id"])):R("",!0)]),_:1})])]))}}),Kw=dt(uc,[["__scopeId","data-v-b3b3d1a4"]]),cc=["disabled"],dc={key:0,class:"flex-1 overflow-y-auto p-2"},mc={key:0,class:"flex items-center justify-center py-8"},gc={key:1,class:"flex flex-col items-center justify-center py-12 text-center"},pc={class:"flex h-12 w-12 items-center justify-center rounded-full bg-gray-50 dark:bg-gray-800"},hc={class:"mt-3 text-xs text-gray-400"},fc={key:2,class:"space-y-3"},vc={class:"px-2 pb-1 pt-1.5 text-[10px] font-medium tracking-wide text-gray-400 dark:text-gray-500"},yc={class:"space-y-0.5"},xc=["onClick"],bc=["placeholder","onBlur","onKeyup"],kc={key:1,class:"flex items-center"},_c={class:"line-clamp-1 min-w-0 flex-1 text-sm leading-snug"},wc={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"},$c={class:"w-28 p-1"},Cc=["disabled","onClick"],Sc=["onClick"],Ic=["disabled","onClick"],Tc={key:1,class:"flex flex-1 flex-col items-center gap-1 overflow-y-auto px-2 pb-2"},Mc=["title","disabled"],Ac=["title","onClick"],zc={key:0,class:"absolute -left-2 top-1/2 h-4.5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary-500"},qc=ue({__name:"ConversationList",props:{sessionId:{},activeId:{},disabled:{type:Boolean}},emits:["select","create","delete"],setup(i,{expose:l,emit:e}){const{t:n}=we(),s=i,u=e,o=z([]),c=z(!1),g=z(null),h=z(""),f=z(!1),b=z(null);async function y(){c.value=!0;try{o.value=await Ye().getAIChats(s.sessionId)}catch(w){console.error("加载对话列表失败:",w)}finally{c.value=!1}}const k=M(()=>{if(o.value.length===0)return[];const w=Ee(),E=w.subtract(7,"day").startOf("day"),F=w.subtract(30,"day").startOf("day"),D=[],A=[],S=new Map;for(const G of o.value){const Z=Ee(G.updatedAt*1e3);if(Z.isAfter(E))D.push(G);else if(Z.isAfter(F))A.push(G);else{const ce=Z.format("YYYY-MM");S.has(ce)||S.set(ce,[]),S.get(ce).push(G)}}const q=[];D.length>0&&q.push({label:n("ai.chat.conversation.group.last7Days"),conversations:D}),A.length>0&&q.push({label:n("ai.chat.conversation.group.last30Days"),conversations:A});const Y=[...S.keys()].sort((G,Z)=>Z.localeCompare(G));for(const G of Y){const Z=Ee(G+"-01");q.push({label:Z.format(Z.year()===w.year()?"M月":"YYYY年M月"),conversations:S.get(G)})}return q});function x(w){return w.title||n("ai.chat.conversation.newChat")}function _(w){s.disabled||(g.value=w.id,h.value=w.title||"")}async function C(w){if(!s.disabled){if(h.value.trim())try{await Ye().updateAIChatTitle(w,h.value.trim());const E=o.value.find(F=>F.id===w);E&&(E.title=h.value.trim())}catch(E){console.error("更新标题失败:",E)}g.value=null}}function $(w){b.value=null,_(w)}function I(w){b.value=null,navigator.clipboard.writeText(w)}function T(w){b.value=null,v(w)}async function v(w){if(!s.disabled)try{await Ye().deleteAIChat(w),o.value=o.value.filter(E=>E.id!==w),u("delete",w)}catch(E){console.error("删除对话失败:",E)}}return Re(()=>{y()}),he(()=>s.sessionId,()=>{y()}),l({refresh:y}),(w,E)=>{const F=_e,D=Ue,A=ms;return r(),m("div",{class:X(["m-3 flex h-[calc(100%-1.5rem)] shrink-0 flex-col overflow-hidden rounded-lg bg-white transition-all duration-300 ease-in-out dark:bg-sidebar-dark",f.value?"w-14":"w-64"])},[a("div",{class:X(["flex items-center",f.value?"justify-center px-2 pb-2 pt-5":"justify-between border-b border-gray-200 py-2 pl-3 pr-2 dark:border-gray-800"])},[f.value?(r(),m("button",{key:1,type:"button",class:"group relative flex h-9 w-9 cursor-pointer items-center justify-center rounded-full hover:bg-gray-200/60 dark:hover:bg-white/[0.06]",onClick:E[2]||(E[2]=S=>f.value=!f.value)},[p(F,{name:"i-lucide-panel-right-open",class:"size-4 scale-x-[-1]"})])):(r(),m(ie,{key:0},[a("button",{class:X(["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":i.disabled}]),disabled:i.disabled,onClick:E[0]||(E[0]=S=>!i.disabled&&u("create"))},[p(F,{name:"i-heroicons-plus",class:"h-3.5 w-3.5"}),a("span",null,d(t(n)("ai.chat.conversation.newConversation")),1)],10,cc),p(D,{color:"neutral",variant:"ghost",size:"sm",class:"group flex h-9 w-9 cursor-pointer items-center justify-center rounded-full hover:bg-gray-200/60 dark:hover:bg-white/[0.06]",onClick:E[1]||(E[1]=S=>f.value=!f.value)},{default:B(()=>[p(F,{name:"i-lucide-panel-right",class:"size-4 scale-x-[-1] group-hover:hidden"}),p(F,{name:"i-lucide-panel-right-close",class:"size-4 hidden scale-x-[-1] group-hover:block"})]),_:1})],64))],2),f.value?(r(),m("div",Tc,[a("button",{class:X(["flex h-10 w-10 items-center justify-center rounded-lg text-gray-600 transition-colors hover:bg-gray-200/40 hover:text-primary-600 dark:text-gray-300 dark:hover:bg-white/[0.06] dark:hover:text-primary-400",{"cursor-not-allowed opacity-50":i.disabled}]),title:t(n)("ai.chat.conversation.newConversation"),disabled:i.disabled,onClick:E[7]||(E[7]=S=>!i.disabled&&u("create"))},[p(F,{name:"i-heroicons-plus",class:"h-5 w-5"})],10,Mc),(r(!0),m(ie,null,pe(o.value,S=>(r(),m("button",{key:S.id,class:X(["relative mx-auto flex h-10 w-10 items-center justify-center rounded-lg transition-all duration-200",[i.activeId===S.id?"bg-gray-200/50 text-primary-600 dark:bg-white/[0.07] dark:text-primary-400 dark:ring-1 dark:ring-white/10":"text-gray-600 hover:bg-gray-200/40 dark:text-gray-300 dark:hover:bg-white/[0.06]"]]),title:x(S),onClick:q=>u("select",S.id)},[i.activeId===S.id?(r(),m("span",zc)):R("",!0),p(F,{name:"i-heroicons-chat-bubble-left",class:"h-5 w-5"})],10,Ac))),128))])):(r(),m("div",dc,[c.value?(r(),m("div",mc,[p(F,{name:"i-heroicons-arrow-path",class:"h-5 w-5 animate-spin text-gray-400"})])):o.value.length===0?(r(),m("div",gc,[a("div",pc,[p(F,{name:"i-heroicons-chat-bubble-left",class:"h-6 w-6 text-gray-300 dark:text-gray-600"})]),a("p",hc,d(t(n)("ai.chat.conversation.empty")),1),p(D,{class:"mt-2",size:"xs",variant:"link",color:"primary",disabled:i.disabled,onClick:E[3]||(E[3]=S=>!i.disabled&&u("create"))},{default:B(()=>[le(d(t(n)("ai.chat.conversation.startNew")),1)]),_:1},8,["disabled"])])):(r(),m("div",fc,[(r(!0),m(ie,null,pe(k.value,S=>(r(),m("div",{key:S.label},[a("div",vc,d(S.label),1),a("div",yc,[(r(!0),m(ie,null,pe(S.conversations,q=>(r(),m("div",{key:q.id,class:X(["group relative rounded-lg px-3 py-2 transition-all",["cursor-pointer",i.activeId===q.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:Y=>u("select",q.id)},[g.value===q.id?Qe((r(),m("input",{key:0,"onUpdate:modelValue":E[4]||(E[4]=Y=>h.value=Y),class:"w-full rounded border-none bg-white px-2 py-1 text-sm shadow-sm outline-none ring-1 ring-gray-200 focus:ring-2 focus:ring-primary-500 dark:bg-page-dark dark:ring-gray-700",placeholder:t(n)("ai.chat.conversation.titlePlaceholder"),autoFocus:"",onBlur:Y=>C(q.id),onKeyup:Ge(Y=>C(q.id),["enter"]),onClick:E[5]||(E[5]=Oe(()=>{},["stop"]))},null,40,bc)),[[ft,h.value]]):(r(),m("div",kc,[a("p",_c,d(x(q)),1),a("div",{class:X(["ml-1 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",{"opacity-100":i.activeId===q.id||b.value===q.id}]),onClick:E[6]||(E[6]=Oe(()=>{},["stop"]))},[p(A,{open:b.value===q.id,ui:{content:"z-50 p-0"},"onUpdate:open":Y=>b.value=Y?q.id:null},{content:B(()=>[a("div",$c,[a("button",{class:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-xs text-gray-600 transition-colors hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800",disabled:i.disabled,onClick:Y=>$(q)},[p(F,{name:"i-heroicons-pencil",class:"h-3.5 w-3.5"}),le(" "+d(t(n)("ai.chat.conversation.rename")),1)],8,Cc),a("button",{class:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-xs text-gray-600 transition-colors hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800",onClick:Y=>I(q.id)},[p(F,{name:"i-heroicons-clipboard-document",class:"h-3.5 w-3.5"}),le(" "+d(t(n)("ai.chat.conversation.copyId")),1)],8,Sc),a("button",{class:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-xs text-red-500 transition-colors hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/30",disabled:i.disabled,onClick:Y=>T(q.id)},[p(F,{name:"i-heroicons-trash",class:"h-3.5 w-3.5"}),le(" "+d(t(n)("ai.chat.conversation.delete")),1)],8,Ic)])]),default:B(()=>[a("button",wc,[p(F,{name:"i-heroicons-ellipsis-horizontal",class:"h-4 w-4"})])]),_:2},1032,["open","onUpdate:open"])],2)]))],10,xc))),128))])]))),128))]))]))],2)}}}),Lc={class:"writing-vertical text-xs"},Dc={class:"flex items-center justify-between border-b border-gray-200 px-4 py-3 dark:border-gray-800"},Ec={class:"flex items-center gap-2"},Bc={class:"font-medium text-gray-900 dark:text-white"},Fc={key:0,class:"border-b border-gray-200 px-4 py-2 dark:border-gray-800"},Rc={class:"flex flex-wrap items-center gap-2"},Vc={class:"text-xs text-gray-500"},Oc={class:"flex-1 overflow-y-auto"},Pc={key:0,class:"flex items-center justify-center py-8"},jc={key:1,class:"flex flex-col items-center justify-center py-8 text-center"},Nc={class:"mt-2 text-sm text-gray-500"},Uc={class:"text-xs text-gray-400"},Wc={key:2,class:"divide-y divide-gray-100 dark:divide-gray-800"},Hc={class:"mb-1 flex items-center justify-between"},Kc={class:"text-sm font-medium text-gray-900 dark:text-white"},Yc={class:"text-xs text-gray-400"},Gc=["innerHTML"],Qc={key:1,class:"border-t border-gray-200 px-4 py-2 dark:border-gray-800"},Jc={class:"flex items-center justify-between"},Xc={class:"text-xs text-gray-500"},Zc={key:2,class:"pointer-events-none absolute inset-0 overflow-hidden rounded-xl opacity-[0.03]"},ed=ue({__name:"DataSourcePanel",props:{messages:{},keywords:{},isLoading:{type:Boolean},isCollapsed:{type:Boolean}},emits:["toggle","loadMore"],setup(i,{emit:l}){const{t:e}=we(),n=i,s=l;function u(c){return Ee(c).format("MM-DD HH:mm")}function o(c){if(!n.keywords.length)return c;const g=n.keywords.join("|"),h=new RegExp(`(${g})`,"gi");return c.replace(h,'<mark class="bg-yellow-200 dark:bg-yellow-800/50 px-0.5 rounded">$1</mark>')}return(c,g)=>{const h=_e,f=Ue;return r(),m("div",{class:X(["relative flex flex-col rounded-xl bg-white transition-all duration-300 dark:bg-page-dark",[i.isCollapsed?"w-12":"w-full"]])},[i.isCollapsed?(r(),m("button",{key:0,class:"flex h-full flex-col items-center justify-center gap-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",onClick:g[0]||(g[0]=b=>s("toggle"))},[p(h,{name:"i-heroicons-chevron-left",class:"h-5 w-5"}),a("span",Lc,d(t(e)("ai.chat.dataSource.title")),1)])):(r(),m(ie,{key:1},[a("div",Dc,[a("div",Ec,[p(h,{name:"i-heroicons-document-magnifying-glass",class:"h-5 w-5 text-gray-500"}),a("span",Bc,d(t(e)("ai.chat.dataSource.title")),1)]),p(f,{icon:"i-heroicons-chevron-right",color:"gray",variant:"ghost",size:"xs",onClick:g[1]||(g[1]=b=>s("toggle"))})]),i.keywords.length>0?(r(),m("div",Fc,[a("div",Rc,[a("span",Vc,d(t(e)("ai.chat.dataSource.keywords")),1),(r(!0),m(ie,null,pe(i.keywords,b=>(r(),m("span",{key:b,class:"rounded-full bg-violet-100 px-2 py-0.5 text-xs text-violet-700 dark:bg-violet-900/30 dark:text-violet-400"},d(b),1))),128))])])):R("",!0),a("div",Oc,[i.isLoading?(r(),m("div",Pc,[p(h,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):i.messages.length===0?(r(),m("div",jc,[p(h,{name:"i-heroicons-inbox",class:"h-10 w-10 text-gray-300 dark:text-gray-600"}),a("p",Nc,d(t(e)("ai.chat.dataSource.empty")),1),a("p",Uc,d(t(e)("ai.chat.dataSource.emptyHint")),1)])):(r(),m("div",Wc,[(r(!0),m(ie,null,pe(i.messages,b=>(r(),m("div",{key:b.id,class:"px-4 py-3 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50"},[a("div",Hc,[a("span",Kc,d(b.senderName),1),a("span",Yc,d(u(b.timestamp)),1)]),a("p",{class:"line-clamp-3 text-sm text-gray-600 dark:text-gray-400",innerHTML:o(b.content)},null,8,Gc)]))),128))]))]),i.messages.length>0?(r(),m("div",Qc,[a("div",Jc,[a("span",Xc,d(t(e)("ai.chat.dataSource.totalRecords",{count:i.messages.length})),1),p(f,{size:"xs",variant:"ghost",onClick:g[2]||(g[2]=b=>s("loadMore"))},{default:B(()=>[le(d(t(e)("ai.chat.dataSource.loadMore")),1)]),_:1})])])):R("",!0)],64)),i.isCollapsed?R("",!0):(r(),m("div",Zc,[...g[3]||(g[3]=[a("div",{class:"data-flow-bg absolute inset-0"},null,-1)])]))],2)}}}),td=dt(ed,[["__scopeId","data-v-a9962add"]]),ad={class:"flex max-h-[80vh] flex-col overflow-hidden"},sd={class:"shrink-0 border-b border-gray-200 px-6 py-4 dark:border-gray-800"},nd={class:"flex items-center justify-between"},od={class:"flex items-center gap-3"},ld={class:"flex h-8 w-8 items-center justify-center rounded-lg bg-red-100 dark:bg-red-900/40"},rd={class:"text-lg font-semibold text-gray-900 dark:text-white"},id={class:"flex-1 overflow-y-auto px-6 py-4"},ud={class:"flex flex-col gap-4"},cd={class:"text-sm font-semibold text-gray-700 dark:text-gray-300"},dd={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"},md={class:"m-0 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-red-600 dark:text-red-400"},gd={key:1,class:"rounded-md border border-gray-200 bg-gray-50 p-3 dark:border-gray-700 dark:bg-page-dark"},pd={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"},hd={key:2,class:"select-text break-words rounded-md border border-gray-200 bg-gray-50 px-3 py-2 font-mono text-xs text-gray-700 dark:border-gray-700 dark:bg-page-dark dark:text-gray-300"},fd={key:0,class:"py-8 text-center text-sm text-gray-400 dark:text-gray-500"},vd={class:"shrink-0 border-t border-gray-200 px-6 py-3 dark:border-gray-800"},yd={class:"flex justify-end"},xd=ue({__name:"ErrorDetailModal",props:qt({error:{}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:["update:open"],setup(i){const{t:l}=we(),e=nt(),n=Wt(i,"open"),s=i,u=M(()=>{const g=s.error,h=[];return g.url&&h.push({label:l("ai.chat.error.requestUrl"),value:g.url}),g.statusCode!=null&&h.push({label:l("ai.chat.error.statusCode"),value:String(g.statusCode)}),g.responseBody&&h.push({label:l("ai.chat.error.responseBody"),value:o(g.responseBody),isCode:!0}),g.responseHeaders&&h.push({label:l("ai.chat.error.responseHeaders"),value:JSON.stringify(g.responseHeaders,null,2),isCode:!0}),g.name&&h.push({label:l("ai.chat.error.name"),value:g.name}),g.message&&h.push({label:l("ai.chat.error.message"),value:g.message}),g.stack&&h.push({label:l("ai.chat.error.stack"),value:g.stack,isStack:!0}),g.cause&&h.push({label:l("ai.chat.error.cause"),value:o(g.cause),isCode:!0}),g.provider&&h.push({label:l("ai.chat.error.provider"),value:g.provider}),g.requestBody&&h.push({label:l("ai.chat.error.requestBody"),value:o(g.requestBody),isCode:!0}),h});function o(g){try{return JSON.stringify(JSON.parse(g),null,2)}catch{return g}}function c(){const g=u.value.map(h=>`${h.label}: ${h.value}`).join(`
|
|
69
69
|
|
|
70
|
-
`);navigator.clipboard.writeText(g).then(()=>{e.success(l("ai.chat.error.copied"))})}return(g,h)=>{const f=_e,b=Ue,y=Xe;return r(),U(y,{open:n.value,"onUpdate:open":h[1]||(h[1]=k=>n.value=k),ui:{content:"sm:max-w-[700px] z-[100]",overlay:"backdrop-blur-sm z-[99]"}},{content:B(()=>[a("div",td,[a("div",ad,[a("div",sd,[a("div",nd,[a("div",od,[p(f,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4 text-red-600 dark:text-red-400"})]),a("h2",ld,d(t(l)("ai.chat.error.detail")),1)]),p(b,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:h[0]||(h[0]=k=>n.value=!1)})])]),a("div",rd,[a("div",id,[(r(!0),m(ie,null,pe(u.value,(k,x)=>(r(),m("div",{key:x,class:"flex flex-col gap-1.5"},[a("div",ud,d(k.label),1),k.isStack?(r(),m("div",cd,[a("pre",dd,d(k.value),1)])):k.isCode?(r(),m("div",md,[a("pre",gd,d(k.value),1)])):(r(),m("div",pd,d(k.value),1))]))),128)),u.value.length===0?(r(),m("div",hd,d(t(l)("ai.chat.error.unknown")),1)):R("",!0)])]),a("div",fd,[a("div",vd,[p(b,{icon:"i-heroicons-document-duplicate",variant:"soft",color:"neutral",size:"sm",onClick:c},{default:B(()=>[le(d(t(l)("ai.chat.error.copyAll")),1)]),_:1})])])])]),_:1},8,["open"])}}}),xd={class:"mb-1.5 flex items-center gap-2"},bd={class:"flex shrink-0 items-center justify-center text-red-500 dark:text-red-400"},kd={class:"pr-5 text-[13px] font-semibold leading-[1.4] text-red-600 dark:text-red-400"},_d={class:"ml-6 line-clamp-3 break-words text-xs leading-normal text-gray-600 dark:text-gray-400"},wd={class:"mt-2.5 ml-6 flex items-center"},$d={class:"ml-auto inline-flex items-center gap-0.5 text-xs text-gray-400 transition-colors duration-150 group-hover:text-red-500 dark:text-gray-500 dark:group-hover:text-red-400"},Cd=ue({__name:"ErrorBlock",props:{error:{}},setup(i){const{t:l}=we(),e=z(!1);function n(s){return s.friendlyMessage||s.message||l("ai.chat.error.unknown")}return(s,u)=>{const o=_e;return r(),m(ie,null,[a("div",{class:"group relative my-2 w-full min-w-[320px] cursor-pointer rounded-lg border border-red-200 bg-red-50/60 px-3.5 py-3 text-[13px] transition-all duration-200 hover:border-red-300 hover:bg-red-50 dark:border-red-900/30 dark:bg-red-950/20 dark:hover:border-red-800/50 dark:hover:bg-red-950/30",onClick:u[0]||(u[0]=c=>e.value=!0)},[a("div",xd,[a("div",bd,[p(o,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4"})]),a("div",kd,d(t(l)("ai.chat.error.title")),1)]),a("div",_d,d(n(i.error)),1),a("div",wd,[a("div",$d,[le(d(t(l)("ai.chat.error.viewDetail"))+" ",1),p(o,{name:"i-heroicons-chevron-right",class:"h-3.5 w-3.5"})])])]),p(yd,{open:e.value,"onUpdate:open":u[1]||(u[1]=c=>e.value=c),error:i.error},null,8,["open","error"])],64)}}}),fa=ue({__name:"EChartHeatmap",props:{data:{},height:{default:280},mode:{default:"expanded"},minColor:{default:"#fee5e8"},maxColor:{default:"#ee4567"}},setup(i){const l=i,e=M(()=>{let s=0;for(const[,,u]of l.data.data)u>s&&(s=u);return s||1}),n=M(()=>{const s=l.mode==="compact",u=l.data.xLabels.length,o=l.data.yLabels.length;return{tooltip:{position:"top",confine:!0,extraCssText:"max-width: min(360px, 70vw); white-space: normal; word-break: break-word;",formatter:c=>{const g=l.data.xLabels[c.data[0]],h=l.data.yLabels[c.data[1]],f=c.data[2];return`${h} ${g}<br/>消息数: <strong>${f}</strong>`},backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:s?52:72,right:20,top:s?12:24,bottom:s?52:70,outerBoundsMode:"same"},xAxis:{type:"category",data:l.data.xLabels,splitArea:{show:!0},axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:s?10:11,color:"#6b7280",interval:s&&u>16?"auto":0,hideOverlap:!0}},yAxis:{type:"category",data:l.data.yLabels,splitArea:{show:!0},axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:s?10:11,color:"#6b7280",interval:s&&o>14?"auto":0,hideOverlap:!0}},visualMap:{min:0,max:e.value,calculable:!0,orient:"horizontal",left:"center",bottom:0,itemWidth:s?8:10,itemHeight:s?84:120,inRange:{color:[l.minColor,l.maxColor]},textStyle:{color:"#6b7280",fontSize:11}},series:[{type:"heatmap",data:l.data.data,label:{show:!1},emphasis:{itemStyle:{shadowBlur:10,shadowColor:"rgba(0, 0, 0, 0.5)"}}}]}});return(s,u)=>(r(),U(ea,{option:n.value,height:i.height},null,8,["option","height"]))}}),va=ue({__name:"EChartLine",props:{data:{},height:{default:288},mode:{default:"expanded"},showArea:{type:Boolean,default:!0},smooth:{type:Boolean,default:!0}},setup(i){const l=i,e=M(()=>{const n=!!l.data.series?.length,s=l.mode==="compact",u=l.data.series?.length??0,o=l.data.labels.length,c=u>(s?3:8),g=!s&&o>30,h=n?l.data.series.map(f=>({name:f.name,type:"line",data:f.values,smooth:l.smooth,symbol:"circle",symbolSize:4,showSymbol:!s&&o<=80,lineStyle:{width:2},areaStyle:l.showArea?{opacity:.08}:void 0,emphasis:{focus:"series"}})):[{type:"line",data:l.data.values,smooth:l.smooth,symbol:"circle",symbolSize:4,showSymbol:!s&&o<=80,lineStyle:{width:2,color:"#ee4567"},itemStyle:{color:"#ee4567"},areaStyle:l.showArea?{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(238, 69, 103, 0.3)"},{offset:1,color:"rgba(238, 69, 103, 0.05)"}]}}:void 0,emphasis:{focus:"series",itemStyle:{color:"#ee4567",borderColor:"#fff",borderWidth:2}}}];return{tooltip:{trigger:"axis",confine:!0,extraCssText:"max-width: min(420px, 76vw); white-space: normal; word-break: break-word;",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:50,right:20,top:n?s?44:56:20,bottom:g?66:34,outerBoundsMode:"same"},legend:n?{type:c?"scroll":"plain",top:0,left:8,right:8,height:32,textStyle:{color:"#6b7280",fontSize:11}}:void 0,xAxis:{type:"category",data:l.data.labels,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:11,color:"#6b7280",interval:"auto",hideOverlap:!0}},yAxis:{type:"value",axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{type:"dashed",color:"#e5e7eb"}}},dataZoom:g?[{type:"inside",throttle:50},{type:"slider",height:18,bottom:18,showDetail:!1}]:void 0,series:h}});return(n,s)=>(r(),U(ea,{option:e.value,height:i.height},null,8,["option","height"]))}}),ya=ue({__name:"EChartPie",props:{data:{},height:{default:280},mode:{default:"expanded"},doughnut:{type:Boolean,default:!0},innerRadius:{default:"50%"},showLegend:{type:Boolean,default:!0}},setup(i){const l=i,e=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"],n=M(()=>{const s=l.data.labels.map((y,k)=>({name:y,value:l.data.values[k]})),u=l.data.labels.length,o=l.mode==="compact",c=u>(o?8:14),g=u>(o?6:12),h=o?{type:g?"scroll":"plain",orient:"horizontal",left:8,right:8,bottom:0,height:28,textStyle:{fontSize:11,overflow:"truncate",width:72}}:{type:g?"scroll":"plain",orient:"vertical",right:10,top:24,bottom:24,textStyle:{fontSize:12,overflow:"truncate",width:120}},f=!o&&!c,b=l.showLegend&&!f;return{color:e,tooltip:{trigger:"item",formatter:"{b}: {c} ({d}%)",confine:!0,extraCssText:"max-width: min(360px, 70vw); white-space: normal; word-break: break-word;",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},legend:b?h:void 0,series:[{type:"pie",radius:l.doughnut?[l.innerRadius,o?"58%":"68%"]:o?"58%":"68%",center:b?o?["50%","42%"]:["38%","50%"]:["50%",o?"46%":"50%"],avoidLabelOverlap:!0,itemStyle:{borderRadius:4,borderColor:"#fff",borderWidth:2},label:{show:f,formatter:"{b}",overflow:"truncate",width:110,alignTo:"edge",edgeDistance:12},emphasis:{label:{show:f,fontSize:14,fontWeight:"bold",overflow:"truncate",width:140},itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}},data:s}]}});return(s,u)=>(r(),U(ea,{option:n.value,height:i.height},null,8,["option","height"]))}}),Sd={class:"my-2 w-full overflow-hidden rounded-lg border border-gray-200 bg-white/80 dark:border-gray-700/70 dark:bg-page-dark/70"},Id={class:"border-b border-gray-100 px-3 py-2 dark:border-gray-800"},Td={class:"flex min-w-0 items-start justify-between gap-3"},Md={class:"min-w-0"},Ad={class:"truncate text-sm font-semibold text-gray-900 dark:text-gray-100"},zd={key:0,class:"mt-0.5 line-clamp-2 text-xs text-gray-500 dark:text-gray-400"},qd={class:"flex shrink-0 items-center gap-1.5"},Ld={class:"rounded-md bg-gray-100 px-1.5 py-0.5 text-[10px] uppercase text-gray-500 dark:bg-gray-800"},Dd={class:"flex max-h-[92vh] flex-col overflow-hidden bg-white dark:bg-page-dark"},Ed={class:"flex items-start justify-between gap-4 border-b border-gray-200 px-5 py-4 dark:border-gray-800"},Bd={class:"min-w-0"},Fd={class:"truncate text-base font-semibold text-gray-900 dark:text-gray-100"},Rd={key:0,class:"mt-1 line-clamp-2 text-xs text-gray-500 dark:text-gray-400"},Vd={class:"mt-1 text-[11px] text-gray-400 dark:text-gray-500"},Od={class:"min-h-0 flex-1 overflow-auto p-4"},Pd={key:0,class:"flex h-64 items-center justify-center text-xs text-gray-400 dark:text-gray-500"},jd={class:"mt-1 text-[11px] text-gray-400 dark:text-gray-500"},Nd={class:"px-2 py-3"},Ud={key:0,class:"flex h-32 items-center justify-center text-xs text-gray-400 dark:text-gray-500"},Wd=ue({__name:"ChartBlockRenderer",props:{chart:{}},setup(i){const{t:l}=we(),e=i,n=z(!1),s=M(()=>e.chart.spec.title),u=M(()=>e.chart.spec.subtitle||e.chart.spec.description||""),o=M(()=>e.chart.spec.display?.height??(e.chart.spec.type==="heatmap"?300:260)),c=M(()=>e.chart.rowCount===0),g=M(()=>{const $=[];return e.chart.spec.unit&&$.push(e.chart.spec.unit),e.chart.truncated&&$.push(l("ai.chat.message.chart.truncated")),$.push(l("ai.chat.message.chart.rows",{count:e.chart.rowCount})),$.join(" · ")}),h=M(()=>e.chart.data),f=M(()=>e.chart.data),b=M(()=>e.chart.data),y=M(()=>e.chart.data),k=M(()=>e.chart.spec.type==="pie"?b.value.labels.length>8:e.chart.spec.type==="line"?f.value.labels.length>28||(f.value.series?.length??0)>4:e.chart.spec.type==="bar"?h.value.labels.length>12:e.chart.spec.type==="heatmap"?y.value.xLabels.length*y.value.yLabels.length>180:!1),x=M(()=>{const $=k.value?320:380;return Math.min(o.value,$)}),_=M(()=>{const $=o.value;if(e.chart.spec.type==="pie")return Math.max($,560);if(e.chart.spec.type==="line")return Math.max($,f.value.labels.length>40?620:540);if(e.chart.spec.type==="bar"){const S=e.chart.spec.display?.horizontal?h.value.labels.length*28+120:520;return Math.min(Math.max($,S),820)}return e.chart.spec.type==="heatmap"?Math.min(Math.max($,y.value.yLabels.length*22+150,560),860):Math.max($,520)}),C=M(()=>e.chart.spec.type==="pie"?"640px":e.chart.spec.type==="bar"?"720px":"780px");return($,S)=>{const T=Ue,v=Xe;return r(),m("div",Sd,[a("div",Id,[a("div",Td,[a("div",Md,[a("h3",Ad,d(s.value),1),u.value?(r(),m("p",zd,d(u.value),1)):R("",!0)]),a("div",qd,[a("span",Ld,d(i.chart.spec.type),1),p(v,{open:n.value,"onUpdate:open":S[2]||(S[2]=w=>n.value=w),ui:{overlay:"z-[10040] backdrop-blur-sm",content:"z-[10050] w-[96vw] max-w-6xl max-h-[92vh] overflow-hidden"}},{content:B(()=>[a("div",Dd,[a("div",Ed,[a("div",Bd,[a("h3",Fd,d(s.value),1),u.value?(r(),m("p",Rd,d(u.value),1)):R("",!0),a("p",Vd,d(g.value),1)]),p(T,{icon:"i-heroicons-x-mark",size:"sm",color:"neutral",variant:"ghost",class:"shrink-0",title:t(l)("common.close"),"aria-label":t(l)("common.close"),onClick:S[1]||(S[1]=w=>n.value=!1)},null,8,["title","aria-label"])]),a("div",Od,[a("div",{class:"mx-auto w-full",style:et({minWidth:C.value})},[c.value?(r(),m("div",Pd,d(t(l)("ai.chat.message.chart.empty")),1)):i.chart.spec.type==="bar"?(r(),U(rt,{key:1,data:h.value,height:_.value,mode:"expanded",horizontal:i.chart.spec.display?.horizontal},null,8,["data","height","horizontal"])):i.chart.spec.type==="line"?(r(),U(va,{key:2,data:f.value,height:_.value,mode:"expanded"},null,8,["data","height"])):i.chart.spec.type==="pie"?(r(),U(ya,{key:3,data:b.value,height:_.value,mode:"expanded","show-legend":i.chart.spec.display?.showLegend??!0},null,8,["data","height","show-legend"])):i.chart.spec.type==="heatmap"?(r(),U(fa,{key:4,data:y.value,height:_.value,mode:"expanded"},null,8,["data","height"])):R("",!0)],4)])])]),default:B(()=>[p(T,{icon:"i-heroicons-arrows-pointing-out",size:"xs",color:"neutral",variant:"ghost",class:"no-capture",title:t(l)("ai.chat.message.chart.expand"),"aria-label":t(l)("ai.chat.message.chart.expand"),onClick:S[0]||(S[0]=Oe(()=>{},["stop"]))},null,8,["title","aria-label"])]),_:1},8,["open"])])]),a("p",jd,d(g.value),1)]),a("div",Nd,[c.value?(r(),m("div",Ud,d(t(l)("ai.chat.message.chart.empty")),1)):i.chart.spec.type==="bar"?(r(),U(rt,{key:1,data:h.value,height:x.value,mode:"compact",horizontal:i.chart.spec.display?.horizontal},null,8,["data","height","horizontal"])):i.chart.spec.type==="line"?(r(),U(va,{key:2,data:f.value,height:x.value,mode:"compact"},null,8,["data","height"])):i.chart.spec.type==="pie"?(r(),U(ya,{key:3,data:b.value,height:x.value,mode:"compact","show-legend":i.chart.spec.display?.showLegend??!0},null,8,["data","height","show-legend"])):i.chart.spec.type==="heatmap"?(r(),U(fa,{key:4,data:y.value,height:x.value,mode:"compact"},null,8,["data","height"])):R("",!0)])])}}}),Hd={class:"my-1.5 w-full overflow-hidden rounded-lg border border-gray-200 bg-gray-50/60 text-[13px] dark:border-gray-700/60 dark:bg-gray-800/30"},Kd={class:"text-xs font-semibold text-gray-700 dark:text-gray-200"},Yd={key:0,class:"flex min-w-0 items-center gap-2"},Gd={key:0,class:"truncate text-[11px] text-gray-400 dark:text-gray-500"},Qd={class:"ml-auto flex shrink-0 items-center gap-1.5"},Jd={class:"text-[11px] text-gray-400 dark:text-gray-500"},Xd={key:0,class:"border-t border-gray-200/70 px-3 py-2 dark:border-gray-700/50"},Zd={class:"mb-2 space-y-0.5 text-xs text-gray-600 dark:text-gray-400"},em={class:"font-medium"},tm={key:0},am={class:"font-medium"},sm={key:0,class:"mb-2 space-y-1"},nm={key:1,class:"py-1.5 text-center text-xs text-gray-400 dark:text-gray-500"},om={key:2,class:"space-y-2"},lm={class:"flex items-center gap-2"},rm={class:"ml-auto shrink-0 text-[11px] text-gray-400 dark:text-gray-500"},im={key:0,class:"mt-1 text-[11px] text-gray-500 dark:text-gray-400"},um={class:"mt-1 space-y-0.5"},cm=["onClick"],dm={class:"min-w-0 flex-1 text-xs leading-snug text-gray-600 dark:text-gray-300"},mm={key:0,class:"mr-1 text-gray-400 dark:text-gray-500"},gm={class:"line-clamp-2 break-words align-middle"},pm={key:3,class:"mt-1.5 text-right text-[11px] text-gray-400 dark:text-gray-500"},hm=ue({__name:"EvidenceBlock",props:{evidence:{}},setup(i){const l=i,{t:e}=we(),n=bt(),s=z(!1),u=["included","uncertain","excluded"],o=M(()=>[...l.evidence.groups].sort((k,x)=>u.indexOf(k.status)-u.indexOf(x.status))),c=M(()=>l.evidence.groups.reduce((k,x)=>k+x.sources.length,0)),g=M(()=>u.map(k=>({status:k,count:l.evidence.groups.filter(x=>x.status===k).length})).filter(k=>k.count>0)),h=M(()=>l.evidence.warnings??[]),f={included:"bg-emerald-50 text-emerald-600 dark:bg-emerald-900/20 dark:text-emerald-400",uncertain:"bg-amber-50 text-amber-600 dark:bg-amber-900/20 dark:text-amber-400",excluded:"bg-gray-100 text-gray-500 dark:bg-gray-800/40 dark:text-gray-400"},b={included:"bg-emerald-500",uncertain:"bg-amber-500",excluded:"bg-gray-400"};function y(k){n.openChatRecordDrawer({scrollToMessageId:k})}return(k,x)=>{const _=_e;return r(),m("div",Hd,[a("button",{type:"button",class:"flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-gray-100/60 dark:hover:bg-gray-800/40",onClick:x[0]||(x[0]=C=>s.value=!s.value)},[p(_,{name:"i-heroicons-document-magnifying-glass",class:"h-4 w-4 shrink-0 text-primary-500"}),a("span",Kd,d(t(e)("ai.chat.evidence.title")),1),s.value?R("",!0):(r(),m("div",Yd,[(r(!0),m(ie,null,pe(g.value,C=>(r(),m("span",{key:C.status,class:"flex shrink-0 items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400"},[a("span",{class:X(["h-1.5 w-1.5 rounded-full",b[C.status]])},null,2),le(" "+d(t(e)(`ai.chat.evidence.group.${C.status}`))+" "+d(C.count),1)]))),128)),g.value.length===0?(r(),m("span",Gd,d(t(e)("ai.chat.evidence.empty")),1)):R("",!0)])),a("span",Qd,[a("span",Jd,d(t(e)(`ai.chat.evidence.mode.${i.evidence.mode}`)),1),p(_,{name:s.value?"i-heroicons-chevron-up":"i-heroicons-chevron-down",class:"h-3.5 w-3.5 text-gray-400 dark:text-gray-500"},null,8,["name"])])]),s.value?(r(),m("div",Xd,[a("div",Zd,[a("div",null,[a("span",em,d(t(e)("ai.chat.evidence.query"))+":",1),le(" "+d(i.evidence.query),1)]),i.evidence.criteria?(r(),m("div",tm,[a("span",am,d(t(e)("ai.chat.evidence.criteria"))+":",1),le(" "+d(i.evidence.criteria),1)])):R("",!0)]),h.value.length>0?(r(),m("div",sm,[(r(!0),m(ie,null,pe(h.value,C=>(r(),m("div",{key:C,class:"flex items-start gap-1.5 rounded bg-amber-50/70 px-2 py-1 text-[11px] text-amber-600 dark:bg-amber-900/15 dark:text-amber-400"},[p(_,{name:"i-heroicons-exclamation-triangle",class:"mt-0.5 h-3 w-3 shrink-0"}),a("span",null,d(t(e)(`ai.chat.evidence.warning.${C}`)),1)]))),128))])):R("",!0),o.value.length===0?(r(),m("div",nm,d(t(e)("ai.chat.evidence.empty")),1)):(r(),m("div",om,[(r(!0),m(ie,null,pe(o.value,C=>(r(),m("div",{key:C.id,class:"rounded-md border border-gray-200/80 bg-white px-2.5 py-1.5 dark:border-gray-700/50 dark:bg-page-dark/30"},[a("div",lm,[a("span",{class:X(["rounded px-1.5 py-0.5 text-[11px] font-medium",f[C.status]])},d(t(e)(`ai.chat.evidence.group.${C.status}`)),3),a("span",rm,d(C.title),1)]),C.reason?(r(),m("div",im,d(C.reason),1)):R("",!0),a("ul",um,[(r(!0),m(ie,null,pe(C.sources,($,S)=>(r(),m("li",{key:`${C.id}-${S}`,class:"group/source flex cursor-pointer items-start gap-1.5 rounded px-1.5 py-1 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/40",onClick:T=>y($.messageId)},[a("div",dm,[$.senderName?(r(),m("span",mm,d($.senderName)+": ",1)):R("",!0),a("span",gm,d($.snippet),1)]),p(_,{name:"i-heroicons-arrow-top-right-on-square",class:"mt-0.5 h-3 w-3 shrink-0 text-gray-400 opacity-0 transition-opacity group-hover/source:opacity-100 dark:text-gray-500"})],8,cm))),128))])]))),128))])),o.value.length>0?(r(),m("div",pm,d(t(e)("ai.chat.evidence.totalSources",{count:c.value})),1)):R("",!0)])):R("",!0)])}}}),fm=/^\s*!\[[^\]\n]*\]\(\s*(?:(?:https?:\/\/(?:localhost|127\.0\.0\.1)(?::\d+)?)?\/?|\.\/)?chart[\w-]*(?:\.(?:png|jpg|jpeg|webp|svg))?(?:\?[^)\s]*)?\s*(?:"[^"]*")?\s*\)\s*$/gim;function vm(i){return i&&i.replace(fm,"").replace(/\n{3,}/g,`
|
|
70
|
+
`);navigator.clipboard.writeText(g).then(()=>{e.success(l("ai.chat.error.copied"))})}return(g,h)=>{const f=_e,b=Ue,y=Xe;return r(),U(y,{open:n.value,"onUpdate:open":h[1]||(h[1]=k=>n.value=k),ui:{content:"sm:max-w-[700px] z-[100]",overlay:"backdrop-blur-sm z-[99]"}},{content:B(()=>[a("div",ad,[a("div",sd,[a("div",nd,[a("div",od,[a("div",ld,[p(f,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4 text-red-600 dark:text-red-400"})]),a("h2",rd,d(t(l)("ai.chat.error.detail")),1)]),p(b,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:h[0]||(h[0]=k=>n.value=!1)})])]),a("div",id,[a("div",ud,[(r(!0),m(ie,null,pe(u.value,(k,x)=>(r(),m("div",{key:x,class:"flex flex-col gap-1.5"},[a("div",cd,d(k.label),1),k.isStack?(r(),m("div",dd,[a("pre",md,d(k.value),1)])):k.isCode?(r(),m("div",gd,[a("pre",pd,d(k.value),1)])):(r(),m("div",hd,d(k.value),1))]))),128)),u.value.length===0?(r(),m("div",fd,d(t(l)("ai.chat.error.unknown")),1)):R("",!0)])]),a("div",vd,[a("div",yd,[p(b,{icon:"i-heroicons-document-duplicate",variant:"soft",color:"neutral",size:"sm",onClick:c},{default:B(()=>[le(d(t(l)("ai.chat.error.copyAll")),1)]),_:1})])])])]),_:1},8,["open"])}}}),bd={class:"mb-1.5 flex items-center gap-2"},kd={class:"flex shrink-0 items-center justify-center text-red-500 dark:text-red-400"},_d={class:"pr-5 text-[13px] font-semibold leading-[1.4] text-red-600 dark:text-red-400"},wd={class:"ml-6 line-clamp-3 break-words text-xs leading-normal text-gray-600 dark:text-gray-400"},$d={class:"mt-2.5 ml-6 flex items-center"},Cd={class:"ml-auto inline-flex items-center gap-0.5 text-xs text-gray-400 transition-colors duration-150 group-hover:text-red-500 dark:text-gray-500 dark:group-hover:text-red-400"},Sd=ue({__name:"ErrorBlock",props:{error:{}},setup(i){const{t:l}=we(),e=z(!1);function n(s){return s.friendlyMessage||s.message||l("ai.chat.error.unknown")}return(s,u)=>{const o=_e;return r(),m(ie,null,[a("div",{class:"group relative my-2 w-full min-w-[320px] cursor-pointer rounded-lg border border-red-200 bg-red-50/60 px-3.5 py-3 text-[13px] transition-all duration-200 hover:border-red-300 hover:bg-red-50 dark:border-red-900/30 dark:bg-red-950/20 dark:hover:border-red-800/50 dark:hover:bg-red-950/30",onClick:u[0]||(u[0]=c=>e.value=!0)},[a("div",bd,[a("div",kd,[p(o,{name:"i-heroicons-exclamation-triangle",class:"h-4 w-4"})]),a("div",_d,d(t(l)("ai.chat.error.title")),1)]),a("div",wd,d(n(i.error)),1),a("div",$d,[a("div",Cd,[le(d(t(l)("ai.chat.error.viewDetail"))+" ",1),p(o,{name:"i-heroicons-chevron-right",class:"h-3.5 w-3.5"})])])]),p(xd,{open:e.value,"onUpdate:open":u[1]||(u[1]=c=>e.value=c),error:i.error},null,8,["open","error"])],64)}}}),fa=ue({__name:"EChartHeatmap",props:{data:{},height:{default:280},mode:{default:"expanded"},minColor:{default:"#fee5e8"},maxColor:{default:"#ee4567"}},setup(i){const l=i,e=M(()=>{let s=0;for(const[,,u]of l.data.data)u>s&&(s=u);return s||1}),n=M(()=>{const s=l.mode==="compact",u=l.data.xLabels.length,o=l.data.yLabels.length;return{tooltip:{position:"top",confine:!0,extraCssText:"max-width: min(360px, 70vw); white-space: normal; word-break: break-word;",formatter:c=>{const g=l.data.xLabels[c.data[0]],h=l.data.yLabels[c.data[1]],f=c.data[2];return`${h} ${g}<br/>消息数: <strong>${f}</strong>`},backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:s?52:72,right:20,top:s?12:24,bottom:s?52:70,outerBoundsMode:"same"},xAxis:{type:"category",data:l.data.xLabels,splitArea:{show:!0},axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:s?10:11,color:"#6b7280",interval:s&&u>16?"auto":0,hideOverlap:!0}},yAxis:{type:"category",data:l.data.yLabels,splitArea:{show:!0},axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:s?10:11,color:"#6b7280",interval:s&&o>14?"auto":0,hideOverlap:!0}},visualMap:{min:0,max:e.value,calculable:!0,orient:"horizontal",left:"center",bottom:0,itemWidth:s?8:10,itemHeight:s?84:120,inRange:{color:[l.minColor,l.maxColor]},textStyle:{color:"#6b7280",fontSize:11}},series:[{type:"heatmap",data:l.data.data,label:{show:!1},emphasis:{itemStyle:{shadowBlur:10,shadowColor:"rgba(0, 0, 0, 0.5)"}}}]}});return(s,u)=>(r(),U(ea,{option:n.value,height:i.height},null,8,["option","height"]))}}),va=ue({__name:"EChartLine",props:{data:{},height:{default:288},mode:{default:"expanded"},showArea:{type:Boolean,default:!0},smooth:{type:Boolean,default:!0}},setup(i){const l=i,e=M(()=>{const n=!!l.data.series?.length,s=l.mode==="compact",u=l.data.series?.length??0,o=l.data.labels.length,c=u>(s?3:8),g=!s&&o>30,h=n?l.data.series.map(f=>({name:f.name,type:"line",data:f.values,smooth:l.smooth,symbol:"circle",symbolSize:4,showSymbol:!s&&o<=80,lineStyle:{width:2},areaStyle:l.showArea?{opacity:.08}:void 0,emphasis:{focus:"series"}})):[{type:"line",data:l.data.values,smooth:l.smooth,symbol:"circle",symbolSize:4,showSymbol:!s&&o<=80,lineStyle:{width:2,color:"#ee4567"},itemStyle:{color:"#ee4567"},areaStyle:l.showArea?{color:{type:"linear",x:0,y:0,x2:0,y2:1,colorStops:[{offset:0,color:"rgba(238, 69, 103, 0.3)"},{offset:1,color:"rgba(238, 69, 103, 0.05)"}]}}:void 0,emphasis:{focus:"series",itemStyle:{color:"#ee4567",borderColor:"#fff",borderWidth:2}}}];return{tooltip:{trigger:"axis",confine:!0,extraCssText:"max-width: min(420px, 76vw); white-space: normal; word-break: break-word;",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:50,right:20,top:n?s?44:56:20,bottom:g?66:34,outerBoundsMode:"same"},legend:n?{type:c?"scroll":"plain",top:0,left:8,right:8,height:32,textStyle:{color:"#6b7280",fontSize:11}}:void 0,xAxis:{type:"category",data:l.data.labels,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:11,color:"#6b7280",interval:"auto",hideOverlap:!0}},yAxis:{type:"value",axisLine:{show:!1},axisTick:{show:!1},splitLine:{lineStyle:{type:"dashed",color:"#e5e7eb"}}},dataZoom:g?[{type:"inside",throttle:50},{type:"slider",height:18,bottom:18,showDetail:!1}]:void 0,series:h}});return(n,s)=>(r(),U(ea,{option:e.value,height:i.height},null,8,["option","height"]))}}),ya=ue({__name:"EChartPie",props:{data:{},height:{default:280},mode:{default:"expanded"},doughnut:{type:Boolean,default:!0},innerRadius:{default:"50%"},showLegend:{type:Boolean,default:!0}},setup(i){const l=i,e=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"],n=M(()=>{const s=l.data.labels.map((y,k)=>({name:y,value:l.data.values[k]})),u=l.data.labels.length,o=l.mode==="compact",c=u>(o?8:14),g=u>(o?6:12),h=o?{type:g?"scroll":"plain",orient:"horizontal",left:8,right:8,bottom:0,height:28,textStyle:{fontSize:11,overflow:"truncate",width:72}}:{type:g?"scroll":"plain",orient:"vertical",right:10,top:24,bottom:24,textStyle:{fontSize:12,overflow:"truncate",width:120}},f=!o&&!c,b=l.showLegend&&!f;return{color:e,tooltip:{trigger:"item",formatter:"{b}: {c} ({d}%)",confine:!0,extraCssText:"max-width: min(360px, 70vw); white-space: normal; word-break: break-word;",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},legend:b?h:void 0,series:[{type:"pie",radius:l.doughnut?[l.innerRadius,o?"58%":"68%"]:o?"58%":"68%",center:b?o?["50%","42%"]:["38%","50%"]:["50%",o?"46%":"50%"],avoidLabelOverlap:!0,itemStyle:{borderRadius:4,borderColor:"#fff",borderWidth:2},label:{show:f,formatter:"{b}",overflow:"truncate",width:110,alignTo:"edge",edgeDistance:12},emphasis:{label:{show:f,fontSize:14,fontWeight:"bold",overflow:"truncate",width:140},itemStyle:{shadowBlur:10,shadowOffsetX:0,shadowColor:"rgba(0, 0, 0, 0.5)"}},data:s}]}});return(s,u)=>(r(),U(ea,{option:n.value,height:i.height},null,8,["option","height"]))}}),Id={class:"my-2 w-full overflow-hidden rounded-lg border border-gray-200 bg-white/80 dark:border-gray-700/70 dark:bg-page-dark/70"},Td={class:"border-b border-gray-100 px-3 py-2 dark:border-gray-800"},Md={class:"flex min-w-0 items-start justify-between gap-3"},Ad={class:"min-w-0"},zd={class:"truncate text-sm font-semibold text-gray-900 dark:text-gray-100"},qd={key:0,class:"mt-0.5 line-clamp-2 text-xs text-gray-500 dark:text-gray-400"},Ld={class:"flex shrink-0 items-center gap-1.5"},Dd={class:"rounded-md bg-gray-100 px-1.5 py-0.5 text-[10px] uppercase text-gray-500 dark:bg-gray-800"},Ed={class:"flex max-h-[92vh] flex-col overflow-hidden bg-white dark:bg-page-dark"},Bd={class:"flex items-start justify-between gap-4 border-b border-gray-200 px-5 py-4 dark:border-gray-800"},Fd={class:"min-w-0"},Rd={class:"truncate text-base font-semibold text-gray-900 dark:text-gray-100"},Vd={key:0,class:"mt-1 line-clamp-2 text-xs text-gray-500 dark:text-gray-400"},Od={class:"mt-1 text-[11px] text-gray-400 dark:text-gray-500"},Pd={class:"min-h-0 flex-1 overflow-auto p-4"},jd={key:0,class:"flex h-64 items-center justify-center text-xs text-gray-400 dark:text-gray-500"},Nd={class:"mt-1 text-[11px] text-gray-400 dark:text-gray-500"},Ud={class:"px-2 py-3"},Wd={key:0,class:"flex h-32 items-center justify-center text-xs text-gray-400 dark:text-gray-500"},Hd=ue({__name:"ChartBlockRenderer",props:{chart:{}},setup(i){const{t:l}=we(),e=i,n=z(!1),s=M(()=>e.chart.spec.title),u=M(()=>e.chart.spec.subtitle||e.chart.spec.description||""),o=M(()=>e.chart.spec.display?.height??(e.chart.spec.type==="heatmap"?300:260)),c=M(()=>e.chart.rowCount===0),g=M(()=>{const $=[];return e.chart.spec.unit&&$.push(e.chart.spec.unit),e.chart.truncated&&$.push(l("ai.chat.message.chart.truncated")),$.push(l("ai.chat.message.chart.rows",{count:e.chart.rowCount})),$.join(" · ")}),h=M(()=>e.chart.data),f=M(()=>e.chart.data),b=M(()=>e.chart.data),y=M(()=>e.chart.data),k=M(()=>e.chart.spec.type==="pie"?b.value.labels.length>8:e.chart.spec.type==="line"?f.value.labels.length>28||(f.value.series?.length??0)>4:e.chart.spec.type==="bar"?h.value.labels.length>12:e.chart.spec.type==="heatmap"?y.value.xLabels.length*y.value.yLabels.length>180:!1),x=M(()=>{const $=k.value?320:380;return Math.min(o.value,$)}),_=M(()=>{const $=o.value;if(e.chart.spec.type==="pie")return Math.max($,560);if(e.chart.spec.type==="line")return Math.max($,f.value.labels.length>40?620:540);if(e.chart.spec.type==="bar"){const I=e.chart.spec.display?.horizontal?h.value.labels.length*28+120:520;return Math.min(Math.max($,I),820)}return e.chart.spec.type==="heatmap"?Math.min(Math.max($,y.value.yLabels.length*22+150,560),860):Math.max($,520)}),C=M(()=>e.chart.spec.type==="pie"?"640px":e.chart.spec.type==="bar"?"720px":"780px");return($,I)=>{const T=Ue,v=Xe;return r(),m("div",Id,[a("div",Td,[a("div",Md,[a("div",Ad,[a("h3",zd,d(s.value),1),u.value?(r(),m("p",qd,d(u.value),1)):R("",!0)]),a("div",Ld,[a("span",Dd,d(i.chart.spec.type),1),p(v,{open:n.value,"onUpdate:open":I[2]||(I[2]=w=>n.value=w),ui:{overlay:"z-[10040] backdrop-blur-sm",content:"z-[10050] w-[96vw] max-w-6xl max-h-[92vh] overflow-hidden"}},{content:B(()=>[a("div",Ed,[a("div",Bd,[a("div",Fd,[a("h3",Rd,d(s.value),1),u.value?(r(),m("p",Vd,d(u.value),1)):R("",!0),a("p",Od,d(g.value),1)]),p(T,{icon:"i-heroicons-x-mark",size:"sm",color:"neutral",variant:"ghost",class:"shrink-0",title:t(l)("common.close"),"aria-label":t(l)("common.close"),onClick:I[1]||(I[1]=w=>n.value=!1)},null,8,["title","aria-label"])]),a("div",Pd,[a("div",{class:"mx-auto w-full",style:et({minWidth:C.value})},[c.value?(r(),m("div",jd,d(t(l)("ai.chat.message.chart.empty")),1)):i.chart.spec.type==="bar"?(r(),U(rt,{key:1,data:h.value,height:_.value,mode:"expanded",horizontal:i.chart.spec.display?.horizontal},null,8,["data","height","horizontal"])):i.chart.spec.type==="line"?(r(),U(va,{key:2,data:f.value,height:_.value,mode:"expanded"},null,8,["data","height"])):i.chart.spec.type==="pie"?(r(),U(ya,{key:3,data:b.value,height:_.value,mode:"expanded","show-legend":i.chart.spec.display?.showLegend??!0},null,8,["data","height","show-legend"])):i.chart.spec.type==="heatmap"?(r(),U(fa,{key:4,data:y.value,height:_.value,mode:"expanded"},null,8,["data","height"])):R("",!0)],4)])])]),default:B(()=>[p(T,{icon:"i-heroicons-arrows-pointing-out",size:"xs",color:"neutral",variant:"ghost",class:"no-capture",title:t(l)("ai.chat.message.chart.expand"),"aria-label":t(l)("ai.chat.message.chart.expand"),onClick:I[0]||(I[0]=Oe(()=>{},["stop"]))},null,8,["title","aria-label"])]),_:1},8,["open"])])]),a("p",Nd,d(g.value),1)]),a("div",Ud,[c.value?(r(),m("div",Wd,d(t(l)("ai.chat.message.chart.empty")),1)):i.chart.spec.type==="bar"?(r(),U(rt,{key:1,data:h.value,height:x.value,mode:"compact",horizontal:i.chart.spec.display?.horizontal},null,8,["data","height","horizontal"])):i.chart.spec.type==="line"?(r(),U(va,{key:2,data:f.value,height:x.value,mode:"compact"},null,8,["data","height"])):i.chart.spec.type==="pie"?(r(),U(ya,{key:3,data:b.value,height:x.value,mode:"compact","show-legend":i.chart.spec.display?.showLegend??!0},null,8,["data","height","show-legend"])):i.chart.spec.type==="heatmap"?(r(),U(fa,{key:4,data:y.value,height:x.value,mode:"compact"},null,8,["data","height"])):R("",!0)])])}}}),Kd={class:"my-1.5 w-full overflow-hidden rounded-lg border border-gray-200 bg-gray-50/60 text-[13px] dark:border-gray-700/60 dark:bg-gray-800/30"},Yd={class:"text-xs font-semibold text-gray-700 dark:text-gray-200"},Gd={key:0,class:"flex min-w-0 items-center gap-2"},Qd={key:0,class:"truncate text-[11px] text-gray-400 dark:text-gray-500"},Jd={class:"ml-auto flex shrink-0 items-center gap-1.5"},Xd={class:"text-[11px] text-gray-400 dark:text-gray-500"},Zd={key:0,class:"border-t border-gray-200/70 px-3 py-2 dark:border-gray-700/50"},em={class:"mb-2 space-y-0.5 text-xs text-gray-600 dark:text-gray-400"},tm={class:"font-medium"},am={key:0},sm={class:"font-medium"},nm={key:0,class:"mb-2 space-y-1"},om={key:1,class:"py-1.5 text-center text-xs text-gray-400 dark:text-gray-500"},lm={key:2,class:"space-y-2"},rm={class:"flex items-center gap-2"},im={class:"ml-auto shrink-0 text-[11px] text-gray-400 dark:text-gray-500"},um={key:0,class:"mt-1 text-[11px] text-gray-500 dark:text-gray-400"},cm={class:"mt-1 space-y-0.5"},dm=["onClick"],mm={class:"min-w-0 flex-1 text-xs leading-snug text-gray-600 dark:text-gray-300"},gm={key:0,class:"mr-1 text-gray-400 dark:text-gray-500"},pm={class:"line-clamp-2 break-words align-middle"},hm={key:3,class:"mt-1.5 text-right text-[11px] text-gray-400 dark:text-gray-500"},fm=ue({__name:"EvidenceBlock",props:{evidence:{}},setup(i){const l=i,{t:e}=we(),n=bt(),s=z(!1),u=["included","uncertain","excluded"],o=M(()=>[...l.evidence.groups].sort((k,x)=>u.indexOf(k.status)-u.indexOf(x.status))),c=M(()=>l.evidence.groups.reduce((k,x)=>k+x.sources.length,0)),g=M(()=>u.map(k=>({status:k,count:l.evidence.groups.filter(x=>x.status===k).length})).filter(k=>k.count>0)),h=M(()=>l.evidence.warnings??[]),f={included:"bg-emerald-50 text-emerald-600 dark:bg-emerald-900/20 dark:text-emerald-400",uncertain:"bg-amber-50 text-amber-600 dark:bg-amber-900/20 dark:text-amber-400",excluded:"bg-gray-100 text-gray-500 dark:bg-gray-800/40 dark:text-gray-400"},b={included:"bg-emerald-500",uncertain:"bg-amber-500",excluded:"bg-gray-400"};function y(k){n.openChatRecordDrawer({scrollToMessageId:k})}return(k,x)=>{const _=_e;return r(),m("div",Kd,[a("button",{type:"button",class:"flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-gray-100/60 dark:hover:bg-gray-800/40",onClick:x[0]||(x[0]=C=>s.value=!s.value)},[p(_,{name:"i-heroicons-document-magnifying-glass",class:"h-4 w-4 shrink-0 text-primary-500"}),a("span",Yd,d(t(e)("ai.chat.evidence.title")),1),s.value?R("",!0):(r(),m("div",Gd,[(r(!0),m(ie,null,pe(g.value,C=>(r(),m("span",{key:C.status,class:"flex shrink-0 items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400"},[a("span",{class:X(["h-1.5 w-1.5 rounded-full",b[C.status]])},null,2),le(" "+d(t(e)(`ai.chat.evidence.group.${C.status}`))+" "+d(C.count),1)]))),128)),g.value.length===0?(r(),m("span",Qd,d(t(e)("ai.chat.evidence.empty")),1)):R("",!0)])),a("span",Jd,[a("span",Xd,d(t(e)(`ai.chat.evidence.mode.${i.evidence.mode}`)),1),p(_,{name:s.value?"i-heroicons-chevron-up":"i-heroicons-chevron-down",class:"h-3.5 w-3.5 text-gray-400 dark:text-gray-500"},null,8,["name"])])]),s.value?(r(),m("div",Zd,[a("div",em,[a("div",null,[a("span",tm,d(t(e)("ai.chat.evidence.query"))+":",1),le(" "+d(i.evidence.query),1)]),i.evidence.criteria?(r(),m("div",am,[a("span",sm,d(t(e)("ai.chat.evidence.criteria"))+":",1),le(" "+d(i.evidence.criteria),1)])):R("",!0)]),h.value.length>0?(r(),m("div",nm,[(r(!0),m(ie,null,pe(h.value,C=>(r(),m("div",{key:C,class:"flex items-start gap-1.5 rounded bg-amber-50/70 px-2 py-1 text-[11px] text-amber-600 dark:bg-amber-900/15 dark:text-amber-400"},[p(_,{name:"i-heroicons-exclamation-triangle",class:"mt-0.5 h-3 w-3 shrink-0"}),a("span",null,d(t(e)(`ai.chat.evidence.warning.${C}`)),1)]))),128))])):R("",!0),o.value.length===0?(r(),m("div",om,d(t(e)("ai.chat.evidence.empty")),1)):(r(),m("div",lm,[(r(!0),m(ie,null,pe(o.value,C=>(r(),m("div",{key:C.id,class:"rounded-md border border-gray-200/80 bg-white px-2.5 py-1.5 dark:border-gray-700/50 dark:bg-page-dark/30"},[a("div",rm,[a("span",{class:X(["rounded px-1.5 py-0.5 text-[11px] font-medium",f[C.status]])},d(t(e)(`ai.chat.evidence.group.${C.status}`)),3),a("span",im,d(C.title),1)]),C.reason?(r(),m("div",um,d(C.reason),1)):R("",!0),a("ul",cm,[(r(!0),m(ie,null,pe(C.sources,($,I)=>(r(),m("li",{key:`${C.id}-${I}`,class:"group/source flex cursor-pointer items-start gap-1.5 rounded px-1.5 py-1 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/40",onClick:T=>y($.messageId)},[a("div",mm,[$.senderName?(r(),m("span",gm,d($.senderName)+": ",1)):R("",!0),a("span",pm,d($.snippet),1)]),p(_,{name:"i-heroicons-arrow-top-right-on-square",class:"mt-0.5 h-3 w-3 shrink-0 text-gray-400 opacity-0 transition-opacity group-hover/source:opacity-100 dark:text-gray-500"})],8,dm))),128))])]))),128))])),o.value.length>0?(r(),m("div",hm,d(t(e)("ai.chat.evidence.totalSources",{count:c.value})),1)):R("",!0)])):R("",!0)])}}}),vm=/^\s*!\[[^\]\n]*\]\(\s*(?:(?:https?:\/\/(?:localhost|127\.0\.0\.1)(?::\d+)?)?\/?|\.\/)?chart[\w-]*(?:\.(?:png|jpg|jpeg|webp|svg))?(?:\?[^)\s]*)?\s*(?:"[^"]*")?\s*\)\s*$/gim;function ym(i){return i&&i.replace(vm,"").replace(/\n{3,}/g,`
|
|
71
71
|
|
|
72
|
-
`).replace(/^\n+|\n+$/g,"")}function ym(i,l,e){for(let n=l+1;n<i.length;n+=1)if(e(i[n]))return!0;return!1}function xm(i,l){const e=[];return i.forEach((n,s)=>{if(!(l.isFoldableProcessBlock(n)||l.isTextBlock(n)&&ym(i,s,l.isFoldableProcessBlock))){e.push({type:"visible",block:n});return}const o=e[e.length-1];o?.type==="process"?o.blocks.push(n):e.push({type:"process",blocks:[n]})}),e}function bm(i){return i.flatMap(l=>l.type==="visible"?[l.block]:[])}function km(i,l){const e=Math.max(0,Math.round(i/1e3));if(l.startsWith("zh")||l.startsWith("ja")){if(e<60)return`${e}秒`;if(e<3600){const h=Math.floor(e/60),f=e%60;return`${h}分${f.toString().padStart(2,"0")}秒`}const o=Math.floor(e/3600),c=Math.floor(e%3600/60),g=e%60;return`${o}时${c.toString().padStart(2,"0")}分${g.toString().padStart(2,"0")}秒`}if(e<60)return`${e}s`;if(e<3600){const o=Math.floor(e/60),c=e%60;return`${o}m ${c.toString().padStart(2,"0")}s`}const n=Math.floor(e/3600),s=Math.floor(e%3600/60),u=e%60;return`${n}h ${s.toString().padStart(2,"0")}m ${u.toString().padStart(2,"0")}s`}function _m(i,l){return i.type!=="process"?0:i.blocks.reduce((e,n)=>e+(l(n)??0),0)}function wm(i,l){if(l.isProcessing)return l.labels.processing;const e=_m(i,l.getBlockDurationMs),n=e>0?` ${km(e,l.locale)}`:"";return`${l.labels.processed}${n}`}const $m={key:0,class:"w-full rounded-lg border border-gray-200 bg-gray-50/80 dark:border-gray-700/50 dark:bg-gray-800/40"},Cm={class:"flex cursor-pointer select-none items-center gap-2 px-3 py-2 text-xs font-medium text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"},Sm={class:"border-t border-gray-200/60 px-3 py-2.5 dark:border-gray-700/40"},Im=["innerHTML"],Tm={class:"mt-2 text-[11px] text-gray-400 dark:text-gray-500"},Mm={key:0,class:"rounded-2xl bg-gray-100 p-4 text-gray-900 dark:bg-gray-800 dark:text-gray-100"},Am=["onKeydown"],zm={class:"mt-2 flex items-center justify-between"},qm={class:"flex cursor-pointer items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400"},Lm={class:"flex gap-2"},Dm={key:1,class:"rounded-3xl bg-gray-100 px-5 py-3 text-gray-900 dark:bg-gray-800 dark:text-gray-100"},Em=["innerHTML"],Bm={key:2,class:"space-y-2"},Fm=["aria-expanded","onClick"],Rm={class:"truncate"},Vm={key:0,class:"py-1 text-gray-900 dark:text-gray-100"},Om=["innerHTML"],Pm={key:0,class:"ml-1 inline-block h-4 w-1.5 animate-pulse rounded-sm bg-gray-800 dark:bg-gray-200"},jm={key:1,class:"mb-2 border-l-2 border-gray-200 pl-4 py-1 text-sm text-gray-500 dark:border-gray-700 dark:text-gray-400"},Nm={class:"cursor-pointer select-none text-xs font-medium transition-colors hover:text-gray-700 dark:hover:text-gray-300"},Um={key:0,class:"ml-2 text-xs text-gray-400 dark:text-gray-500"},Wm={key:1,class:"ml-2 inline-flex items-center gap-1 text-[11px] text-gray-400 dark:text-gray-500"},Hm={class:"mt-2 prose prose-sm dark:prose-invert max-w-none leading-relaxed text-xs"},Km={key:0,class:"mb-2 font-medium text-gray-700 dark:text-gray-200"},Ym={class:"not-prose space-y-2 text-xs leading-relaxed"},Gm={class:"font-medium text-gray-800 dark:text-gray-200"},Qm={key:0,class:"mt-1 text-gray-500 dark:text-gray-400"},Jm={class:"mt-0.5 text-gray-500 dark:text-gray-400"},Xm={key:1,class:"not-prose mt-2 border-t border-gray-100 pt-2 dark:border-gray-800"},Zm={class:"text-[11px] font-medium text-gray-500 dark:text-gray-400"},eg={class:"mt-1 list-disc space-y-0.5 pl-4 text-xs leading-relaxed text-gray-600 dark:text-gray-300"},tg=["innerHTML"],ag={key:2,class:"inline-flex items-center gap-1.5 rounded-lg bg-gray-50 px-3 py-1.5 text-xs font-medium text-gray-600 dark:bg-gray-800/50 dark:text-gray-400"},sg={key:3,open:"",class:"mb-2 border-l-2 border-gray-200 py-1 pl-4 text-sm text-gray-600 dark:border-gray-700 dark:text-gray-400"},ng={class:"flex cursor-pointer select-none items-center gap-2 text-xs font-medium text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"},og={class:"min-w-0 truncate"},lg={class:"mt-2"},rg=["innerHTML"],ig={key:1,class:"space-y-2"},ug={class:"font-medium text-gray-800 dark:text-gray-200"},cg={class:"mt-1 text-gray-500 dark:text-gray-400"},dg={class:"mt-0.5 text-gray-500 dark:text-gray-400"},mg={key:2,class:"mt-2 border-t border-gray-100 pt-2 dark:border-gray-800"},gg={class:"text-[11px] font-medium text-gray-500 dark:text-gray-400"},pg={class:"mt-1 list-disc space-y-0.5 pl-4 text-xs leading-relaxed text-gray-600 dark:text-gray-300"},hg={key:4,class:"mb-2 border-l-2 border-gray-200 py-1 pl-4 text-sm text-gray-600 dark:border-gray-700 dark:text-gray-400"},fg={class:"flex items-center gap-2 text-xs font-medium text-gray-500 dark:text-gray-400"},vg={key:0,class:"inline-flex items-center gap-1 text-[11px] font-normal text-gray-400 dark:text-gray-500"},yg=["innerHTML"],xg={key:7,class:"w-full max-w-full"},bg={class:"inline-flex cursor-pointer list-none select-none [&::-webkit-details-marker]:hidden"},kg={class:"flex min-w-0 items-baseline gap-1.5 font-medium"},_g={key:0,class:"max-w-[200px] truncate text-[11px] font-normal opacity-75 sm:max-w-[300px]"},wg={class:"shrink-0 text-[11px] font-normal opacity-75"},$g={class:"mt-2 max-w-full rounded-lg border border-gray-200 bg-gray-50/80 dark:border-gray-700/70 dark:bg-page-dark/40"},Cg={class:"flex items-center justify-between gap-2 border-b border-gray-200/70 px-3 py-2 dark:border-gray-700/70"},Sg={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Ig={key:0,class:"border-b border-amber-200/70 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-300"},Tg={class:"max-h-[28rem] overflow-auto whitespace-pre-wrap break-words px-3 py-2.5 text-xs leading-relaxed text-gray-700 dark:text-gray-200"},Mg={class:"flex min-w-0 items-baseline gap-1.5 font-medium"},Ag={key:0,class:"max-w-[200px] truncate text-[11px] font-normal opacity-75 sm:max-w-[300px]"},zg={key:1,class:"shrink-0 text-[11px] font-normal opacity-75"},qg={key:0,class:"flex items-center gap-2 px-1 py-2 text-sm text-gray-500 dark:text-gray-400"},Lg={key:3,class:"py-1 text-gray-900 dark:text-gray-100"},Dg=["innerHTML"],Eg={key:0,class:"ml-1 inline-block h-4 w-1.5 animate-pulse rounded-sm bg-gray-800 dark:bg-gray-200"},Bg={class:"text-xs text-gray-400"},ua=ue({__name:"ChatMessage",props:{messageId:{},role:{},content:{},timestamp:{},isStreaming:{type:Boolean},contentBlocks:{},showCaptureButton:{type:Boolean},editable:{type:Boolean}},emits:["edit","fork"],setup(i,{emit:l}){const{t:e,te:n,locale:s}=we(),u=nt(),o=i,c=l,g=M(()=>Ee(o.timestamp).format("HH:mm")),h=M(()=>o.role==="user"),f=M(()=>o.role==="summary"),b=z(!1),y=z(o.content),k=z(null),x=M(()=>h.value&&o.editable&&!o.isStreaming&&!!o.messageId),_=M(()=>!h.value&&!f.value&&!o.isStreaming&&!!o.messageId),C=z(!1),$=new Aa({html:!1,breaks:!0,linkify:!0,typographer:!0});$.renderer.rules.link_open=(O,V,K,L,P)=>(O[V].attrSet("target","_blank"),O[V].attrSet("rel","noopener noreferrer"),P.renderToken(O,V,K));function S(O){return O?$.render(O):""}function T(O){const V=O?.toLowerCase()||"think";return V==="analysis"?e("ai.chat.message.think.labels.analysis"):V==="reasoning"?e("ai.chat.message.think.labels.reasoning"):V==="reflection"?e("ai.chat.message.think.labels.reflection"):V==="plan_validation"?e("ai.chat.message.think.labels.planValidation"):V==="think"||V==="thought"||V==="thinking"?e("ai.chat.message.think.labels.think"):e("ai.chat.message.think.labels.other",{tag:O})}function v(O){if(!O)return"";const V=(O/1e3).toFixed(1);return e("ai.chat.message.think.duration",{seconds:V})}const w=M(()=>o.content?$.render(I(o.content)):"");fe(()=>o.content,O=>{b.value||(y.value=O)});function E(){const O=k.value;if(!O)return;O.style.height="auto";const V=384,K=Math.min(O.scrollHeight,V);O.style.height=`${K}px`,O.style.overflowY=O.scrollHeight>V?"auto":"hidden"}async function F(){x.value&&(y.value=o.content,b.value=!0,await De(),E(),k.value?.focus())}function D(){b.value=!1,y.value=o.content,C.value=!1}function A(){if(!o.messageId)return;const O=y.value.trim();if(!O||O===o.content.trim()){D();return}b.value=!1,c("edit",{messageId:o.messageId,content:O,overwriteSubsequent:C.value}),C.value=!1}function I(O){return vm(O)}const q=M(()=>{const O=o.contentBlocks||[];return O.filter((V,K)=>V.type==="text"?I(V.text).trim().length>0:V.type==="think"?V.text.trim().length>0:V.type==="error"?!In(O,K,{isStreaming:o.isStreaming}):!0)});function Y(O){return O.type==="think"||O.type==="tool"||O.type==="plan"||O.type==="plan_draft"}function G(O){return O.type==="text"}const Z=M(()=>xm(q.value,{isFoldableProcessBlock:Y,isTextBlock:G})),ce=M(()=>bm(Z.value)),ne=z({});function H(O){return O.type==="process"?O.blocks:[O.block]}function W(O){return`${o.messageId??o.timestamp}:process:${O}`}function re(O){const V=W(O),K=ne.value[V];return K!==void 0?K:ee(O)}function ve(O){const V=W(O);ne.value={...ne.value,[V]:!re(O)}}function he(O){return q.value[q.value.length-1]===O}function ee(O){return!!o.isStreaming&&O===Z.value.length-1}function te(O){return O.type==="think"?O.durationMs??0:O.type==="tool"?O.tool.durationMs??0:0}function j(O,V){return wm(O,{getBlockDurationMs:te,isProcessing:ee(V),labels:{processed:e("ai.chat.message.process.processed"),processing:e("ai.chat.message.process.processing")},locale:s.value})}const de=M(()=>o.role==="assistant"&&q.value.length>0);function be(O){return n(`ai.assistant.builtinToolDesc.${O.name}`)?e(`ai.assistant.builtinToolDesc.${O.name}`):O.displayName}function xe(O){return O==="running"?"running":O==="done"?"done":"error"}function oe(O){return O.displayResult??O.result??""}function Q(O){return O.status!=="running"&&oe(O).trim().length>0}function J(O){return!O.displayResult&&(O.result??"").includes("…[truncated]")}async function ge(O){const V=oe(O);if(V.trim())try{await navigator.clipboard.writeText(V),u.success(e("ai.chat.message.toolResult.copySuccess"))}catch(K){u.fail(e("ai.chat.message.toolResult.copyFailed"),{description:String(K)})}}function ke(O){return O.length===0?e("ai.chat.message.plan.noTools"):O.join(", ")}function $e(O){try{const V=JSON.parse(O.trim());if(!V||typeof V!="object")return null;const K=V,L=Array.isArray(K.steps)?K.steps.filter(P=>!!P&&typeof P=="object").map(P=>({goal:typeof P.goal=="string"?P.goal:"",suggestedTools:Array.isArray(P.suggestedTools)?P.suggestedTools.filter(N=>typeof N=="string"):[],evidenceNeeded:typeof P.evidenceNeeded=="string"?P.evidenceNeeded:""})).filter(P=>P.goal):[];return{title:typeof K.title=="string"?K.title:void 0,steps:L,successCriteria:Array.isArray(K.successCriteria)?K.successCriteria.filter(P=>typeof P=="string"):[]}}catch{return null}}const Le=new Map;function Be(O){const V=Le.get(O);if(V)return V;const K=$e(O);return K&&Le.set(O,K),K}function Te(O){if(O.start_time||O.end_time){const V=O.start_time?String(O.start_time):"",K=O.end_time?String(O.end_time):"";return V&&K?`${V} ~ ${K}`:V||K}if(O.year)if(s.value.startsWith("zh")){let V=`${O.year}年`;return O.month&&(V+=`${O.month}月`,O.day&&(V+=`${O.day}日`,O.hour!==void 0&&(V+=` ${O.hour}点`))),V}else{const V=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];let K="";if(O.month){if(K=V[O.month-1]||String(O.month),O.day&&(K+=` ${O.day}`,O.hour!==void 0)){const L=O.hour,P=L>=12?"pm":"am",N=L%12||12;K+=`, ${N}${P}`}K+=`, ${O.year}`}else K=String(O.year);return K}return""}function Pe(O){if(!O.params)return"";const V=O.name,K=O.params;if(V==="search_messages"){const P=K.keywords,N=[];P&&P.length>0&&N.push(`${e("ai.chat.message.toolParams.keywords")}: ${P.join(", ")}`);const ae=Te(K);return ae&&N.push(`${e("ai.chat.message.toolParams.time")}: ${ae}`),N.join(" | ")}if(V==="get_recent_messages"){const P=[];P.push(e("ai.chat.message.toolParams.getMessages",{count:K.limit||100}));const N=Te(K);return N&&P.push(N),P.join(" | ")}if(V==="get_conversation_between"){const P=[],N=Te(K);return N&&P.push(`${e("ai.chat.message.toolParams.time")}: ${N}`),K.limit&&P.push(e("ai.chat.message.toolParams.limit",{count:K.limit})),P.join(" | ")}if(V==="get_message_context"){const P=K.message_ids,N=K.context_size||20;return P&&P.length>0?e("ai.chat.message.toolParams.contextWithMessages",{msgCount:P.length,contextSize:N}):e("ai.chat.message.toolParams.context",{size:N})}if(V==="get_member_stats")return e("ai.chat.message.toolParams.topMembers",{count:K.top_n||10});if(V==="get_time_stats"){const P=K.type;return e(`ai.chat.message.toolParams.timeStats.${P}`)||String(K.type)}if(V==="render_chart"){const P=K.spec&&typeof K.spec=="object"?K.spec:null;return[P?.title,P?.type].filter(ae=>typeof ae=="string"&&ae.length>0).join(" | ")}if(V==="get_members")return K.search?`${e("ai.chat.message.toolParams.search")}: ${K.search}`:e("ai.chat.message.toolParams.getMemberList");if(V==="get_member_name_history")return`${e("ai.chat.message.toolParams.memberId")}: ${K.member_id}`;if(V==="semantic_search_current_chat"){const P=typeof K.query=="string"?K.query:"";return P?P.length>40?`“${P.slice(0,40)}…”`:`“${P}”`:""}const L=[];for(const[P,N]of Object.entries(K)){if(N==null||N==="")continue;const ae=typeof N=="object"?JSON.stringify(N):String(N),se=ae.length>30?ae.substring(0,30)+"...":ae;if(L.push(`${P}: ${se}`),L.length>=3){L.push("...");break}}return L.join(" | ")}const je=M(()=>!de.value&&o.content.trim()?I(o.content):de.value?ce.value.map(V=>{if(V.type==="text")return I(V.text);if(V.type==="think"){const K=T(V.tag),L=V.text.split(`
|
|
72
|
+
`).replace(/^\n+|\n+$/g,"")}function xm(i,l,e){for(let n=l+1;n<i.length;n+=1)if(e(i[n]))return!0;return!1}function bm(i,l){const e=[];return i.forEach((n,s)=>{if(!(l.isFoldableProcessBlock(n)||l.isTextBlock(n)&&xm(i,s,l.isFoldableProcessBlock))){e.push({type:"visible",block:n});return}const o=e[e.length-1];o?.type==="process"?o.blocks.push(n):e.push({type:"process",blocks:[n]})}),e}function km(i){return i.flatMap(l=>l.type==="visible"?[l.block]:[])}function _m(i,l){const e=Math.max(0,Math.round(i/1e3));if(l.startsWith("zh")||l.startsWith("ja")){if(e<60)return`${e}秒`;if(e<3600){const h=Math.floor(e/60),f=e%60;return`${h}分${f.toString().padStart(2,"0")}秒`}const o=Math.floor(e/3600),c=Math.floor(e%3600/60),g=e%60;return`${o}时${c.toString().padStart(2,"0")}分${g.toString().padStart(2,"0")}秒`}if(e<60)return`${e}s`;if(e<3600){const o=Math.floor(e/60),c=e%60;return`${o}m ${c.toString().padStart(2,"0")}s`}const n=Math.floor(e/3600),s=Math.floor(e%3600/60),u=e%60;return`${n}h ${s.toString().padStart(2,"0")}m ${u.toString().padStart(2,"0")}s`}function wm(i,l){return i.type!=="process"?0:i.blocks.reduce((e,n)=>e+(l(n)??0),0)}function $m(i,l){if(l.isProcessing)return l.labels.processing;const e=wm(i,l.getBlockDurationMs),n=e>0?` ${_m(e,l.locale)}`:"";return`${l.labels.processed}${n}`}const Cm={key:0,class:"w-full rounded-lg border border-gray-200 bg-gray-50/80 dark:border-gray-700/50 dark:bg-gray-800/40"},Sm={class:"flex cursor-pointer select-none items-center gap-2 px-3 py-2 text-xs font-medium text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"},Im={class:"border-t border-gray-200/60 px-3 py-2.5 dark:border-gray-700/40"},Tm=["innerHTML"],Mm={class:"mt-2 text-[11px] text-gray-400 dark:text-gray-500"},Am={key:0,class:"rounded-2xl bg-gray-100 p-4 text-gray-900 dark:bg-gray-800 dark:text-gray-100"},zm=["onKeydown"],qm={class:"mt-2 flex items-center justify-between"},Lm={class:"flex cursor-pointer items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400"},Dm={class:"flex gap-2"},Em={key:1,class:"rounded-3xl bg-gray-100 px-5 py-3 text-gray-900 dark:bg-gray-800 dark:text-gray-100"},Bm=["innerHTML"],Fm={key:2,class:"space-y-2"},Rm=["aria-expanded","onClick"],Vm={class:"truncate"},Om={key:0,class:"py-1 text-gray-900 dark:text-gray-100"},Pm=["innerHTML"],jm={key:0,class:"ml-1 inline-block h-4 w-1.5 animate-pulse rounded-sm bg-gray-800 dark:bg-gray-200"},Nm={key:1,class:"mb-2 border-l-2 border-gray-200 pl-4 py-1 text-sm text-gray-500 dark:border-gray-700 dark:text-gray-400"},Um={class:"cursor-pointer select-none text-xs font-medium transition-colors hover:text-gray-700 dark:hover:text-gray-300"},Wm={key:0,class:"ml-2 text-xs text-gray-400 dark:text-gray-500"},Hm={key:1,class:"ml-2 inline-flex items-center gap-1 text-[11px] text-gray-400 dark:text-gray-500"},Km={class:"mt-2 prose prose-sm dark:prose-invert max-w-none leading-relaxed text-xs"},Ym={key:0,class:"mb-2 font-medium text-gray-700 dark:text-gray-200"},Gm={class:"not-prose space-y-2 text-xs leading-relaxed"},Qm={class:"font-medium text-gray-800 dark:text-gray-200"},Jm={key:0,class:"mt-1 text-gray-500 dark:text-gray-400"},Xm={class:"mt-0.5 text-gray-500 dark:text-gray-400"},Zm={key:1,class:"not-prose mt-2 border-t border-gray-100 pt-2 dark:border-gray-800"},eg={class:"text-[11px] font-medium text-gray-500 dark:text-gray-400"},tg={class:"mt-1 list-disc space-y-0.5 pl-4 text-xs leading-relaxed text-gray-600 dark:text-gray-300"},ag=["innerHTML"],sg={key:2,class:"inline-flex items-center gap-1.5 rounded-lg bg-gray-50 px-3 py-1.5 text-xs font-medium text-gray-600 dark:bg-gray-800/50 dark:text-gray-400"},ng={key:3,open:"",class:"mb-2 border-l-2 border-gray-200 py-1 pl-4 text-sm text-gray-600 dark:border-gray-700 dark:text-gray-400"},og={class:"flex cursor-pointer select-none items-center gap-2 text-xs font-medium text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"},lg={class:"min-w-0 truncate"},rg={class:"mt-2"},ig=["innerHTML"],ug={key:1,class:"space-y-2"},cg={class:"font-medium text-gray-800 dark:text-gray-200"},dg={class:"mt-1 text-gray-500 dark:text-gray-400"},mg={class:"mt-0.5 text-gray-500 dark:text-gray-400"},gg={key:2,class:"mt-2 border-t border-gray-100 pt-2 dark:border-gray-800"},pg={class:"text-[11px] font-medium text-gray-500 dark:text-gray-400"},hg={class:"mt-1 list-disc space-y-0.5 pl-4 text-xs leading-relaxed text-gray-600 dark:text-gray-300"},fg={key:4,class:"mb-2 border-l-2 border-gray-200 py-1 pl-4 text-sm text-gray-600 dark:border-gray-700 dark:text-gray-400"},vg={class:"flex items-center gap-2 text-xs font-medium text-gray-500 dark:text-gray-400"},yg={key:0,class:"inline-flex items-center gap-1 text-[11px] font-normal text-gray-400 dark:text-gray-500"},xg=["innerHTML"],bg={key:7,class:"w-full max-w-full"},kg={class:"inline-flex cursor-pointer list-none select-none [&::-webkit-details-marker]:hidden"},_g={class:"flex min-w-0 items-baseline gap-1.5 font-medium"},wg={key:0,class:"max-w-[200px] truncate text-[11px] font-normal opacity-75 sm:max-w-[300px]"},$g={class:"shrink-0 text-[11px] font-normal opacity-75"},Cg={class:"mt-2 max-w-full rounded-lg border border-gray-200 bg-gray-50/80 dark:border-gray-700/70 dark:bg-page-dark/40"},Sg={class:"flex items-center justify-between gap-2 border-b border-gray-200/70 px-3 py-2 dark:border-gray-700/70"},Ig={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Tg={key:0,class:"border-b border-amber-200/70 bg-amber-50 px-3 py-2 text-xs text-amber-700 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-300"},Mg={class:"max-h-[28rem] overflow-auto whitespace-pre-wrap break-words px-3 py-2.5 text-xs leading-relaxed text-gray-700 dark:text-gray-200"},Ag={class:"flex min-w-0 items-baseline gap-1.5 font-medium"},zg={key:0,class:"max-w-[200px] truncate text-[11px] font-normal opacity-75 sm:max-w-[300px]"},qg={key:1,class:"shrink-0 text-[11px] font-normal opacity-75"},Lg={key:0,class:"flex items-center gap-2 px-1 py-2 text-sm text-gray-500 dark:text-gray-400"},Dg={key:3,class:"py-1 text-gray-900 dark:text-gray-100"},Eg=["innerHTML"],Bg={key:0,class:"ml-1 inline-block h-4 w-1.5 animate-pulse rounded-sm bg-gray-800 dark:bg-gray-200"},Fg={class:"text-xs text-gray-400"},ua=ue({__name:"ChatMessage",props:{messageId:{},role:{},content:{},timestamp:{},isStreaming:{type:Boolean},contentBlocks:{},showCaptureButton:{type:Boolean},editable:{type:Boolean}},emits:["edit","fork"],setup(i,{emit:l}){const{t:e,te:n,locale:s}=we(),u=nt(),o=i,c=l,g=M(()=>Ee(o.timestamp).format("HH:mm")),h=M(()=>o.role==="user"),f=M(()=>o.role==="summary"),b=z(!1),y=z(o.content),k=z(null),x=M(()=>h.value&&o.editable&&!o.isStreaming&&!!o.messageId),_=M(()=>!h.value&&!f.value&&!o.isStreaming&&!!o.messageId),C=z(!1),$=new Aa({html:!1,breaks:!0,linkify:!0,typographer:!0});$.renderer.rules.link_open=(O,V,K,L,P)=>(O[V].attrSet("target","_blank"),O[V].attrSet("rel","noopener noreferrer"),P.renderToken(O,V,K));function I(O){return O?$.render(O):""}function T(O){const V=O?.toLowerCase()||"think";return V==="analysis"?e("ai.chat.message.think.labels.analysis"):V==="reasoning"?e("ai.chat.message.think.labels.reasoning"):V==="reflection"?e("ai.chat.message.think.labels.reflection"):V==="plan_validation"?e("ai.chat.message.think.labels.planValidation"):V==="think"||V==="thought"||V==="thinking"?e("ai.chat.message.think.labels.think"):e("ai.chat.message.think.labels.other",{tag:O})}function v(O){if(!O)return"";const V=(O/1e3).toFixed(1);return e("ai.chat.message.think.duration",{seconds:V})}const w=M(()=>o.content?$.render(S(o.content)):"");he(()=>o.content,O=>{b.value||(y.value=O)});function E(){const O=k.value;if(!O)return;O.style.height="auto";const V=384,K=Math.min(O.scrollHeight,V);O.style.height=`${K}px`,O.style.overflowY=O.scrollHeight>V?"auto":"hidden"}async function F(){x.value&&(y.value=o.content,b.value=!0,await De(),E(),k.value?.focus())}function D(){b.value=!1,y.value=o.content,C.value=!1}function A(){if(!o.messageId)return;const O=y.value.trim();if(!O||O===o.content.trim()){D();return}b.value=!1,c("edit",{messageId:o.messageId,content:O,overwriteSubsequent:C.value}),C.value=!1}function S(O){return ym(O)}const q=M(()=>{const O=o.contentBlocks||[];return O.filter((V,K)=>V.type==="text"?S(V.text).trim().length>0:V.type==="think"?V.text.trim().length>0:V.type==="error"?!Tn(O,K,{isStreaming:o.isStreaming}):!0)});function Y(O){return O.type==="think"||O.type==="tool"||O.type==="plan"||O.type==="plan_draft"}function G(O){return O.type==="text"}const Z=M(()=>bm(q.value,{isFoldableProcessBlock:Y,isTextBlock:G})),ce=M(()=>km(Z.value)),ne=z({});function H(O){return O.type==="process"?O.blocks:[O.block]}function W(O){return`${o.messageId??o.timestamp}:process:${O}`}function re(O){const V=W(O),K=ne.value[V];return K!==void 0?K:ee(O)}function ve(O){const V=W(O);ne.value={...ne.value,[V]:!re(O)}}function fe(O){return q.value[q.value.length-1]===O}function ee(O){return!!o.isStreaming&&O===Z.value.length-1}function te(O){return O.type==="think"?O.durationMs??0:O.type==="tool"?O.tool.durationMs??0:0}function j(O,V){return $m(O,{getBlockDurationMs:te,isProcessing:ee(V),labels:{processed:e("ai.chat.message.process.processed"),processing:e("ai.chat.message.process.processing")},locale:s.value})}const de=M(()=>o.role==="assistant"&&q.value.length>0);function be(O){return n(`ai.assistant.builtinToolDesc.${O.name}`)?e(`ai.assistant.builtinToolDesc.${O.name}`):O.displayName}function xe(O){return O==="running"?"running":O==="done"?"done":"error"}function oe(O){return O.displayResult??O.result??""}function Q(O){return O.status!=="running"&&oe(O).trim().length>0}function J(O){return!O.displayResult&&(O.result??"").includes("…[truncated]")}async function ge(O){const V=oe(O);if(V.trim())try{await navigator.clipboard.writeText(V),u.success(e("ai.chat.message.toolResult.copySuccess"))}catch(K){u.fail(e("ai.chat.message.toolResult.copyFailed"),{description:String(K)})}}function ke(O){return O.length===0?e("ai.chat.message.plan.noTools"):O.join(", ")}function $e(O){try{const V=JSON.parse(O.trim());if(!V||typeof V!="object")return null;const K=V,L=Array.isArray(K.steps)?K.steps.filter(P=>!!P&&typeof P=="object").map(P=>({goal:typeof P.goal=="string"?P.goal:"",suggestedTools:Array.isArray(P.suggestedTools)?P.suggestedTools.filter(N=>typeof N=="string"):[],evidenceNeeded:typeof P.evidenceNeeded=="string"?P.evidenceNeeded:""})).filter(P=>P.goal):[];return{title:typeof K.title=="string"?K.title:void 0,steps:L,successCriteria:Array.isArray(K.successCriteria)?K.successCriteria.filter(P=>typeof P=="string"):[]}}catch{return null}}const Le=new Map;function Be(O){const V=Le.get(O);if(V)return V;const K=$e(O);return K&&Le.set(O,K),K}function Te(O){if(O.start_time||O.end_time){const V=O.start_time?String(O.start_time):"",K=O.end_time?String(O.end_time):"";return V&&K?`${V} ~ ${K}`:V||K}if(O.year)if(s.value.startsWith("zh")){let V=`${O.year}年`;return O.month&&(V+=`${O.month}月`,O.day&&(V+=`${O.day}日`,O.hour!==void 0&&(V+=` ${O.hour}点`))),V}else{const V=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];let K="";if(O.month){if(K=V[O.month-1]||String(O.month),O.day&&(K+=` ${O.day}`,O.hour!==void 0)){const L=O.hour,P=L>=12?"pm":"am",N=L%12||12;K+=`, ${N}${P}`}K+=`, ${O.year}`}else K=String(O.year);return K}return""}function Pe(O){if(!O.params)return"";const V=O.name,K=O.params;if(V==="search_messages"){const P=K.keywords,N=[];P&&P.length>0&&N.push(`${e("ai.chat.message.toolParams.keywords")}: ${P.join(", ")}`);const ae=Te(K);return ae&&N.push(`${e("ai.chat.message.toolParams.time")}: ${ae}`),N.join(" | ")}if(V==="get_recent_messages"){const P=[];P.push(e("ai.chat.message.toolParams.getMessages",{count:K.limit||100}));const N=Te(K);return N&&P.push(N),P.join(" | ")}if(V==="get_conversation_between"){const P=[],N=Te(K);return N&&P.push(`${e("ai.chat.message.toolParams.time")}: ${N}`),K.limit&&P.push(e("ai.chat.message.toolParams.limit",{count:K.limit})),P.join(" | ")}if(V==="get_message_context"){const P=K.message_ids,N=K.context_size||20;return P&&P.length>0?e("ai.chat.message.toolParams.contextWithMessages",{msgCount:P.length,contextSize:N}):e("ai.chat.message.toolParams.context",{size:N})}if(V==="get_member_stats")return e("ai.chat.message.toolParams.topMembers",{count:K.top_n||10});if(V==="get_time_stats"){const P=K.type;return e(`ai.chat.message.toolParams.timeStats.${P}`)||String(K.type)}if(V==="render_chart"){const P=K.spec&&typeof K.spec=="object"?K.spec:null;return[P?.title,P?.type].filter(ae=>typeof ae=="string"&&ae.length>0).join(" | ")}if(V==="get_members")return K.search?`${e("ai.chat.message.toolParams.search")}: ${K.search}`:e("ai.chat.message.toolParams.getMemberList");if(V==="get_member_name_history")return`${e("ai.chat.message.toolParams.memberId")}: ${K.member_id}`;if(V==="semantic_search_current_chat"){const P=typeof K.query=="string"?K.query:"";return P?P.length>40?`“${P.slice(0,40)}…”`:`“${P}”`:""}const L=[];for(const[P,N]of Object.entries(K)){if(N==null||N==="")continue;const ae=typeof N=="object"?JSON.stringify(N):String(N),se=ae.length>30?ae.substring(0,30)+"...":ae;if(L.push(`${P}: ${se}`),L.length>=3){L.push("...");break}}return L.join(" | ")}const je=M(()=>!de.value&&o.content.trim()?S(o.content):de.value?ce.value.map(V=>{if(V.type==="text")return S(V.text);if(V.type==="think"){const K=T(V.tag),L=V.text.split(`
|
|
73
73
|
`).map(P=>`> ${P}`).join(`
|
|
74
74
|
`);return`> ${K}
|
|
75
75
|
>
|
|
@@ -97,8 +97,8 @@ ${V.text.split(`
|
|
|
97
97
|
`).map(K=>`> ${K}`).join(`
|
|
98
98
|
`)}`;if(V.type==="tool"){const K=be(V.tool),L=Pe(V.tool),P=L?` (${L})`:"";return`- [${xe(V.tool.status)}] ${K}${P}`}return""}).filter(V=>V.trim().length>0).join(`
|
|
99
99
|
|
|
100
|
-
`):""),Se=M(()=>!o.isStreaming&&je.value.trim().length>0);async function me(){if(Se.value)try{await navigator.clipboard.writeText(je.value),u.success(e("ai.chat.message.copy.success"))}catch(O){u.fail(e("ai.chat.message.copy.failed"),{description:String(O)})}}return(O,V)=>{const K=_e,L=Ue,P=St;return r(),m("div",{class:X(["flex items-start gap-3",[h.value&&!b.value?"flex-row-reverse":"",f.value?"justify-center":""]])},[a("div",{class:X([h.value&&!b.value?"max-w-[85%] min-w-0":"w-full min-w-0"])},[f.value?(r(),m("details",$m,[a("summary",Cm,[p(K,{name:"i-heroicons-arrow-path",class:"h-3.5 w-3.5 shrink-0"}),a("span",null,d(t(e)("ai.chat.message.summary.label")),1),p(K,{name:"i-heroicons-chevron-right",class:"ml-auto h-3 w-3 transition-transform [[open]>&]:rotate-90"})]),a("div",Sm,[a("div",{class:"prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:w.value},null,8,Im),a("p",Tm,d(t(e)("ai.chat.message.summary.info")),1)])])):h.value?(r(),m(ie,{key:1},[b.value?(r(),m("div",Mm,[Qe(a("textarea",{ref_key:"editTextareaRef",ref:k,"onUpdate:modelValue":V[0]||(V[0]=N=>y.value=N),rows:"2",class:"w-full resize-none rounded-xl border border-primary-200 bg-white/90 px-4 py-3 text-sm leading-relaxed outline-none focus:border-primary-400 dark:border-primary-400/40 dark:bg-page-dark/70",onInput:E,onKeydown:[Ge(Oe(D,["prevent"]),["esc"]),Ge(Oe(A,["ctrl","prevent"]),["enter"]),Ge(Oe(A,["meta","prevent"]),["enter"])]},null,40,Am),[[ft,y.value]]),a("div",zm,[a("label",qm,[Qe(a("input",{"onUpdate:modelValue":V[1]||(V[1]=N=>C.value=N),type:"checkbox",class:"h-3.5 w-3.5 rounded border-gray-300 text-primary-500 focus:ring-primary-500 dark:border-gray-600"},null,512),[[Sn,C.value]]),le(" "+d(t(e)("ai.chat.message.edit.overwriteSubsequent")),1)]),a("div",Lm,[p(L,{size:"xs",variant:"ghost",color:"gray",onClick:D},{default:B(()=>[le(d(t(e)("common.cancel")),1)]),_:1}),p(L,{size:"xs",color:"primary",onClick:A},{default:B(()=>[le(d(t(e)("ai.chat.message.edit.submit")),1)]),_:1})])])])):(r(),m("div",Dm,[a("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:w.value},null,8,Em)]))],64)):de.value?(r(),m("div",Bm,[(r(!0),m(ie,null,pe(Z.value,(N,ae)=>(r(),m("div",{key:ae,class:X([N.type==="process"?"py-1":""])},[N.type==="process"?(r(),m("button",{key:0,type:"button",class:"inline-flex max-w-full items-center gap-1.5 text-left text-xs text-gray-400 transition-colors hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300","aria-expanded":re(ae),onClick:se=>ve(ae)},[p(K,{name:re(ae)?"i-heroicons-chevron-down":"i-heroicons-chevron-right",class:"h-3 w-3 shrink-0"},null,8,["name"]),a("span",Rm,d(j(N,ae)),1),ee(ae)?(r(),U(K,{key:0,name:"i-heroicons-arrow-path",class:"h-3 w-3 shrink-0 animate-spin"})):R("",!0)],8,Fm)):R("",!0),Qe(a("div",{class:X([N.type==="process"?"mt-2 space-y-2 pl-4":""])},[(r(!0),m(ie,null,pe(H(N),(se,Ve)=>(r(),m(ie,{key:`${ae}-${Ve}`},[se.type==="text"?(r(),m("div",Vm,[a("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:S(I(se.text))},null,8,Om),i.isStreaming&&he(se)?(r(),m("span",Pm)):R("",!0)])):se.type==="think"?(r(),m("details",jm,[a("summary",Nm,[le(d(T(se.tag))+" ",1),se.durationMs?(r(),m("span",Um,d(v(se.durationMs)),1)):R("",!0),i.isStreaming&&he(se)?(r(),m("span",Wm,[a("span",null,d(t(e)("ai.chat.message.think.loading")),1),V[3]||(V[3]=a("span",{class:"flex gap-0.5"},[a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1))])):R("",!0)]),a("div",Hm,[se.tag==="plan_validation"&&Be(se.text)?(r(),m(ie,{key:0},[Be(se.text)?.title?(r(),m("div",Km,d(Be(se.text)?.title),1)):R("",!0),a("ol",Ym,[(r(!0),m(ie,null,pe(Be(se.text)?.steps,(qe,Me)=>(r(),m("li",{key:Me,class:"text-gray-600 dark:text-gray-300"},[a("div",Gm,d(qe.goal),1),qe.evidenceNeeded?(r(),m("div",Qm,d(t(e)("ai.chat.message.plan.evidenceNeeded"))+": "+d(qe.evidenceNeeded),1)):R("",!0),a("div",Jm,d(t(e)("ai.chat.message.plan.suggestedTools"))+": "+d(ke(qe.suggestedTools)),1)]))),128))]),Be(se.text)?.successCriteria.length?(r(),m("div",Xm,[a("div",Zm,d(t(e)("ai.chat.message.plan.successCriteria")),1),a("ul",eg,[(r(!0),m(ie,null,pe(Be(se.text)?.successCriteria,(qe,Me)=>(r(),m("li",{key:Me},d(qe),1))),128))])])):R("",!0)],64)):(r(),m("div",{key:1,innerHTML:S(se.text)},null,8,tg))])])):se.type==="skill"?(r(),m("div",ag,[p(K,{name:"i-heroicons-bolt",class:"h-3.5 w-3.5"}),a("span",null,d(t(e)("ai.skill.active.label",{name:se.skillName})),1)])):se.type==="plan"?(r(),m("details",sg,[a("summary",ng,[p(K,{name:"i-heroicons-clipboard-document-list",class:"h-3.5 w-3.5 shrink-0"}),a("span",og,d(t(e)("ai.chat.message.plan.label"))+" · "+d(se.plan.title),1)]),a("div",lg,[se.displayText?(r(),m("div",{key:0,class:"prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:S(se.displayText)},null,8,rg)):(r(),m("ol",ig,[(r(!0),m(ie,null,pe(se.plan.steps,(qe,Me)=>(r(),m("li",{key:Me,class:"text-xs leading-relaxed"},[a("div",ug,d(Me+1)+". "+d(qe.goal),1),a("div",cg,d(t(e)("ai.chat.message.plan.evidenceNeeded"))+": "+d(qe.evidenceNeeded),1),a("div",dg,d(t(e)("ai.chat.message.plan.suggestedTools"))+": "+d(ke(qe.suggestedTools)),1)]))),128))])),se.displayText?R("",!0):(r(),m("div",mg,[a("div",gg,d(t(e)("ai.chat.message.plan.successCriteria")),1),a("ul",pg,[(r(!0),m(ie,null,pe(se.plan.successCriteria,(qe,Me)=>(r(),m("li",{key:Me},d(qe),1))),128))])]))])])):se.type==="plan_draft"?(r(),m("div",hg,[a("div",fg,[p(K,{name:"i-heroicons-clipboard-document-list",class:"h-3.5 w-3.5 shrink-0"}),a("span",null,d(t(e)("ai.chat.message.plan.label")),1),i.isStreaming?(r(),m("span",vg,[...V[4]||(V[4]=[a("span",{class:"flex gap-0.5"},[a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1)])])):R("",!0)]),a("div",{class:"mt-2 prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:S(se.text)},null,8,yg)])):se.type==="chart"?(r(),U(Wd,{key:5,chart:se.chart},null,8,["chart"])):se.type==="evidence"?(r(),U(hm,{key:6,evidence:se.evidence},null,8,["evidence"])):se.type==="tool"&&Q(se.tool)?(r(),m("details",xg,[a("summary",bg,[a("div",{class:X(["flex w-fit items-center gap-1.5 rounded-lg bg-gray-50 px-2.5 py-1 text-xs text-gray-500 transition-colors hover:bg-gray-100 dark:bg-gray-800/30 dark:text-gray-400/80 dark:hover:bg-gray-800/60",[se.tool.status==="error"?"bg-red-50 text-red-600 dark:bg-red-900/20 dark:text-red-400":""]])},[p(K,{name:se.tool.status==="error"?"i-heroicons-exclamation-circle":"i-heroicons-wrench-screwdriver",class:"h-3.5 w-3.5 shrink-0"},null,8,["name"]),a("div",kg,[a("span",null,d(be(se.tool)),1),Pe(se.tool)?(r(),m("span",_g,d(Pe(se.tool)),1)):R("",!0),a("span",wg," · "+d(t(e)("ai.chat.message.toolResult.view")),1)]),p(K,{name:"i-heroicons-chevron-right",class:"h-3 w-3 shrink-0 transition-transform [[open]>&]:rotate-90"})],2)]),a("div",$g,[a("div",Cg,[a("span",Sg,d(t(e)("ai.chat.message.toolResult.title")),1),p(L,{size:"xs",variant:"ghost",color:"primary",icon:"i-heroicons-document-duplicate",title:t(e)("ai.chat.message.toolResult.copy"),onClick:Oe(qe=>ge(se.tool),["stop"])},null,8,["title","onClick"])]),J(se.tool)?(r(),m("div",Ig,d(t(e)("ai.chat.message.toolResult.displayTruncated")),1)):R("",!0),a("pre",Tg,d(oe(se.tool)),1)])])):se.type==="tool"?(r(),m("div",{key:8,class:X(["flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs transition-colors",[se.tool.status==="running"?"bg-gray-100 text-gray-600 dark:bg-gray-800/50 dark:text-gray-400":se.tool.status==="done"?"bg-gray-50 text-gray-500 dark:bg-gray-800/30 dark:text-gray-400/80":"bg-red-50 text-red-600 dark:bg-red-900/20 dark:text-red-400"]])},[p(K,{name:se.tool.status==="running"?"i-heroicons-arrow-path":se.tool.status==="done"?"i-heroicons-wrench-screwdriver":"i-heroicons-exclamation-circle",class:X(["h-3.5 w-3.5 shrink-0",[se.tool.status==="running"?"animate-spin":""]])},null,8,["name","class"]),a("div",Mg,[a("span",null,d(be(se.tool)),1),Pe(se.tool)?(r(),m("span",Ag,d(Pe(se.tool)),1)):R("",!0),se.tool.status==="done"&&se.tool.durationMs?(r(),m("span",zg," · "+d(v(se.tool.durationMs)),1)):R("",!0)])],2)):se.type==="error"?(r(),U(Cd,{key:9,error:se.error},null,8,["error"])):R("",!0)],64))),128))],2),[[yt,N.type!=="process"||re(ae)]])],2))),128)),i.isStreaming&&q.value.length>0&&q.value[q.value.length-1].type==="tool"?(r(),m("div",qg,[V[5]||(V[5]=a("span",{class:"flex gap-1"},[a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1)),a("span",null,d(t(e)("ai.chat.message.generating")),1)])):R("",!0)])):(r(),m("div",Lg,[a("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:w.value},null,8,Dg),i.isStreaming?(r(),m("span",Eg)):R("",!0)])),!f.value&&!i.isStreaming?(r(),m("div",{key:4,class:X(["mt-1 flex items-center gap-2 px-1",[h.value?"flex-row-reverse":""]])},[a("span",Bg,d(g.value),1),p(P,{text:t(e)("ai.chat.message.copy.tooltip"),class:"no-capture"},{default:B(()=>[p(L,{icon:"i-heroicons-document-duplicate",variant:"ghost",color:"primary",size:"xs",disabled:!Se.value,onClick:me},null,8,["disabled"])]),_:1},8,["text"]),x.value?(r(),U(P,{key:0,text:t(e)("ai.chat.message.edit.tooltip"),class:"no-capture"},{default:B(()=>[p(L,{icon:"i-heroicons-pencil-square",variant:"ghost",color:"primary",size:"xs",onClick:F})]),_:1},8,["text"])):R("",!0),_.value?(r(),U(P,{key:1,text:t(e)("ai.chat.message.fork.tooltip"),class:"no-capture"},{default:B(()=>[p(L,{icon:"i-heroicons-arrow-top-right-on-square",variant:"ghost",color:"primary",size:"xs",onClick:V[2]||(V[2]=N=>c("fork",i.messageId))})]),_:1},8,["text"])):R("",!0),i.showCaptureButton&&!h.value&&!i.isStreaming?(r(),U(Lt,{key:2,size:"xs",type:"element","target-selector":".qa-pair","markdown-fix":"","capture-frame":"","progressive-narrowing":!0})):R("",!0)],2)):R("",!0)],2)],2)}}}),Fg={key:0,class:"absolute bottom-full left-0 z-20 mb-1.5 w-[240px] max-w-[calc(100vw-2rem)]"},Rg={class:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-overlay dark:border-gray-700 dark:bg-page-dark"},Vg={class:"flex items-center justify-between border-b border-gray-100 px-2.5 py-1.5 dark:border-gray-800"},Og={class:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400"},Pg=["title"],jg={key:0,class:"px-3 py-4 text-center text-xs text-gray-500 dark:text-gray-400"},Ng=["onMouseenter","onClick"],Ug={class:"min-w-0 flex-1"},Wg={class:"flex items-center gap-1.5"},Hg={class:"truncate text-xs font-medium"},Kg={class:"mt-0.5 line-clamp-2 text-[11px] leading-4 text-gray-500 dark:text-gray-400"},Yg={key:2,class:"px-3 py-4 text-center"},Gg={class:"text-sm font-medium text-gray-700 dark:text-gray-200"},Qg={class:"mt-1 text-xs leading-5 text-gray-500 dark:text-gray-400"},Jg=ue({__name:"MemberMentionMenu",props:{visible:{type:Boolean},members:{},highlightIndex:{},loading:{type:Boolean}},emits:["select","close","highlight"],setup(i,{emit:l}){const{t:e}=we(),n=i,s=l,u=z(null);return fe(()=>[n.visible,n.highlightIndex,n.members.length],async([o,c])=>{if(!o||!u.value)return;await De(),u.value.querySelectorAll("[data-mention-item]")[c]?.scrollIntoView({block:"nearest"})}),(o,c)=>{const g=_e;return r(),U(vt,{name:"mention-menu"},{default:B(()=>[i.visible?(r(),m("div",Fg,[a("div",Rg,[a("div",Vg,[a("div",Og,[a("span",null,d(t(e)("ai.chat.input.mentionHint")),1)]),a("button",{type:"button",class:"rounded-md p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:t(e)("common.close"),onClick:c[0]||(c[0]=h=>s("close"))},[p(g,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5"})],8,Pg)]),n.loading?(r(),m("div",jg,d(t(e)("common.loading")),1)):n.members.length>0?(r(),m("div",{key:1,ref_key:"listRef",ref:u,class:"max-h-72 overflow-y-auto p-1.5"},[(r(!0),m(ie,null,pe(n.members,(h,f)=>(r(),m("button",{key:`${h.memberId}-${h.insertName}`,type:"button","data-mention-item":"",class:X(["flex w-full items-start justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left transition-colors",f===n.highlightIndex?"bg-primary-50 text-gray-900 dark:bg-primary-950/30 dark:text-gray-100":"text-gray-700 hover:bg-gray-50 dark:text-gray-200 dark:hover:bg-gray-800/80"]),onMouseenter:b=>s("highlight",f),onClick:b=>s("select",h)},[a("div",Ug,[a("div",Wg,[a("span",Hg,"@"+d(h.insertName),1)]),a("p",Kg,d(h.subtitle),1)])],42,Ng))),128))],512)):(r(),m("div",Yg,[a("p",Gg,d(t(e)("ai.chat.input.mentionEmpty")),1),a("p",Qg,d(t(e)("ai.chat.input.mentionEmptyHint")),1)]))])])):R("",!0)]),_:1})}}}),Xg=dt(Jg,[["__scopeId","data-v-7bc45150"]]),Zg={key:0,class:"absolute bottom-full left-0 z-20 mb-1.5 w-[240px] max-w-[calc(100vw-2rem)]"},ep={class:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-overlay dark:border-gray-700 dark:bg-page-dark"},tp={class:"flex items-center justify-between border-b border-gray-100 px-2.5 py-1.5 dark:border-gray-800"},ap={class:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400"},sp=["title"],np=["onMouseenter","onClick"],op={class:"min-w-0 flex-1"},lp={class:"flex items-center gap-1.5"},rp={class:"truncate text-xs font-medium"},ip={class:"mt-0.5 line-clamp-1 text-xs leading-4 text-gray-500 dark:text-gray-400"},up={key:1,class:"px-3 py-4 text-center"},cp={class:"text-sm font-medium text-gray-700 dark:text-gray-200"},dp={class:"mt-1 text-xs leading-5 text-gray-500 dark:text-gray-400"},mp={key:0,class:"absolute top-1/2 left-full ml-1 flex max-h-[min(348px,calc(100vh-10rem))] w-[300px] -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-overlay dark:border-gray-700 dark:bg-page-dark"},gp={class:"border-b border-gray-100 px-3 py-2 dark:border-gray-800"},pp={class:"truncate text-sm font-medium text-gray-900 dark:text-gray-100"},hp={class:"mt-0.5 text-xs leading-5 text-gray-500 dark:text-gray-400"},fp={key:0,class:"mt-1 flex items-start gap-1.5 text-[11px] leading-4"},vp={class:"shrink-0 font-medium text-gray-600 dark:text-gray-300"},yp={class:"line-clamp-1 min-w-0 flex-1 text-gray-500 dark:text-gray-400"},xp={key:1,class:"mt-0.5 flex items-start gap-1.5 text-[11px] leading-4"},bp={class:"shrink-0 font-medium text-gray-600 dark:text-gray-300"},kp={class:"line-clamp-1 min-w-0 flex-1 text-gray-500 dark:text-gray-400"},_p={class:"min-h-0 flex-1 overflow-y-auto px-3 py-2"},wp={key:0,class:"text-xs text-gray-400 dark:text-gray-500"},$p=["innerHTML"],Cp={key:2,class:"text-xs leading-relaxed text-gray-400 dark:text-gray-500"},Sp=ue({__name:"SlashCommandMenu",props:{visible:{type:Boolean},skills:{},highlightIndex:{},activeSkillId:{}},emits:["select","close","manage","highlight"],setup(i,{emit:l}){const{t:e,te:n}=we(),s=It(),u=i,o=l,c=z({}),g=z(""),h=z(!1),f=z(null),b=new Aa({html:!1,breaks:!0,linkify:!0,typographer:!0}),y=M(()=>{if(u.skills.length===0)return null;const $=Math.min(u.highlightIndex,u.skills.length-1);return u.skills[$]??null}),k=M(()=>g.value?b.render(g.value):"");function x($){const S=`ai.assistant.builtinToolDesc.${$}`;return n(S)?e(S):$}const _=M(()=>y.value?.tags.join(" / ")||""),C=M(()=>y.value?.tools.map($=>x($)).join(" / ")||"");return fe(()=>[u.visible,y.value?.id],async([$,S])=>{if(!$||!S){g.value="",h.value=!1;return}if(c.value[S]){g.value=c.value[S],h.value=!1;return}h.value=!0;const v=(await s.getSkillConfig(S))?.prompt?.trim()||"";c.value={...c.value,[S]:v},y.value?.id===S&&(g.value=v,h.value=!1)},{immediate:!0}),fe(()=>[u.visible,u.highlightIndex,u.skills.length],async([$,S])=>{if(!$||!f.value)return;await De(),f.value.querySelectorAll("[data-slash-item]")[S]?.scrollIntoView({block:"nearest"})}),($,S)=>{const T=_e;return r(),U(vt,{name:"slash-menu"},{default:B(()=>[i.visible?(r(),m("div",Zg,[a("div",ep,[a("div",tp,[a("div",ap,[a("span",null,d(t(e)("ai.chat.input.slashHint")),1)]),a("button",{type:"button",class:"rounded-md p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:t(e)("common.close"),onClick:S[0]||(S[0]=v=>o("close"))},[p(T,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5"})],8,sp)]),u.skills.length>0?(r(),m("div",{key:0,ref_key:"listRef",ref:f,class:"max-h-72 overflow-y-auto p-1.5"},[(r(!0),m(ie,null,pe(u.skills,(v,w)=>(r(),m("button",{key:v.id,type:"button","data-slash-item":"",class:X(["flex w-full items-start justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left transition-colors",w===u.highlightIndex?"bg-primary-50 text-gray-900 dark:bg-primary-950/30 dark:text-gray-100":"text-gray-700 hover:bg-gray-50 dark:text-gray-200 dark:hover:bg-gray-800/80"]),onMouseenter:E=>o("highlight",w),onClick:E=>o("select",v)},[a("div",op,[a("div",lp,[a("span",rp,d(v.name),1),u.activeSkillId===v.id?(r(),U(T,{key:0,name:"i-heroicons-check-circle-20-solid",class:"h-3.5 w-3.5 shrink-0 text-primary-500"})):R("",!0)]),a("p",ip,d(v.description),1)])],42,np))),128))],512)):(r(),m("div",up,[a("p",cp,d(t(e)("ai.chat.input.slashEmpty")),1),a("p",dp,d(t(e)("ai.chat.input.slashEmptyHint")),1)])),a("button",{type:"button",class:"flex w-full items-center justify-between border-t border-gray-100 px-2.5 py-1.5 text-xs text-gray-600 transition-colors hover:bg-gray-50 hover:text-gray-900 dark:border-gray-800 dark:text-gray-300 dark:hover:bg-gray-800/80 dark:hover:text-gray-100",onClick:S[1]||(S[1]=v=>o("manage"))},[a("span",null,d(t(e)("ai.chat.input.manageSkills")),1),p(T,{name:"i-heroicons-arrow-top-right-on-square",class:"h-3.5 w-3.5"})])]),u.skills.length>0&&y.value?(r(),m("div",mp,[a("div",gp,[a("p",pp,d(y.value.name),1),a("p",hp,d(y.value.description),1),_.value?(r(),m("div",fp,[a("span",vp,d(t(e)("ai.chat.input.previewTagsLabel")),1),a("span",yp,d(_.value),1)])):R("",!0),C.value?(r(),m("div",xp,[a("span",bp,d(t(e)("ai.chat.input.previewToolsLabel")),1),a("span",kp,d(C.value),1)])):R("",!0)]),a("div",_p,[h.value?(r(),m("div",wp,d(t(e)("common.loading")),1)):k.value?(r(),m("div",{key:1,class:"prose prose-sm max-w-none text-xs leading-5 dark:prose-invert prose-headings:mb-1.5 prose-headings:mt-2 prose-p:my-1.5 prose-ul:my-1.5 prose-ol:my-1.5",innerHTML:k.value},null,8,$p)):(r(),m("div",Cp,d(t(e)("ai.chat.input.previewUnavailable")),1))])])):R("",!0)])):R("",!0)]),_:1})}}}),Ip=dt(Sp,[["__scopeId","data-v-0f67bc21"]]),Tp={class:"shrink-0 pt-2 pb-2"},Mp={class:"relative px-4 pt-2.5 pb-2.5"},Ap={class:"flex items-start gap-2 pr-10"},zp={key:0,class:"inline-flex max-w-[180px] shrink-0 items-center rounded-md bg-primary-50 px-2 text-sm leading-6 font-medium text-primary-700 dark:bg-primary-500/10 dark:text-primary-400"},qp={class:"truncate"},Lp=["disabled","placeholder"],Dp=["disabled","title"],Ep=ue({__name:"AIChatInput",props:{sessionId:{},disabled:{type:Boolean},status:{},chatType:{}},emits:["send","stop","manageSkills","skillActivated"],setup(i,{expose:l,emit:e}){const{t:n}=we(),s=i,u=e,o=It(),{compatibleSkills:c,activeSkill:g,activeSkillId:h,isLoaded:f}=ut(o),b=z(null),y=z(null),k=z(""),x=z([]),_=z([]),C=z(!1),$=z(!1),S=z(""),T=z(0),v=z(!1),w=z(""),E=z(0),F=z(null),D=z(!1),A=z(null),I=z(null),q=z(!1),Y=M(()=>k.value.trim().length>0&&!s.disabled),G=M(()=>g.value&&k.value.trim().length===0?n("ai.chat.input.placeholderWithActiveSkill",{name:g.value.name}):n("ai.chat.input.placeholderWithSlash")),Z=M(()=>s.status==="streaming"?"":Y.value?n("ai.chat.input.send"):g.value?n("ai.chat.input.needMoreThanSkill"):n("ai.chat.input.needQuestion")),ce=M(()=>{const L=new Map;return x.value.forEach(P=>{const N=P.groupNickname||P.accountName||P.platformId;L.set(N,(L.get(N)??0)+1)}),x.value.map(P=>{const N=P.groupNickname||P.accountName||P.platformId,ae=(L.get(N)??0)>1?`${N}·${P.platformId}`:N,se=[P.platformId];return P.aliases.length>0&&se.push(P.aliases.join(" / ")),{memberId:P.id,platformId:P.platformId,displayName:N,aliases:[...P.aliases],mentionText:`@${ae}`,insertName:ae,subtitle:se.join(" · "),searchText:[N,P.groupNickname||"",P.accountName||"",P.platformId,ae,P.aliases.join(" ")].join(" ").toLocaleLowerCase()}})}),ne=M(()=>{const L=S.value.trim().toLocaleLowerCase();return L?c.value.filter(P=>[P.name,P.description,P.tags.join(" ")].join(" ").toLocaleLowerCase().includes(L)):c.value}),H=M(()=>{const L=w.value.trim().toLocaleLowerCase();return L?ce.value.filter(P=>P.searchText.includes(L)):ce.value});function W(){if(!y.value)return;const L=y.value;L.style.height="auto";const P=192,N=Math.min(L.scrollHeight,P);L.style.height=`${N}px`,L.style.overflowY=L.scrollHeight>P?"auto":"hidden"}function re(){y.value?.focus()}async function ve(){if(!s.sessionId){x.value=[];return}C.value=!0;try{const L=await Ke().getMembers(s.sessionId);x.value=[...L].sort((P,N)=>N.messageCount-P.messageCount)}catch(L){console.error("加载 AI @ 成员列表失败:",L),x.value=[]}finally{C.value=!1}}function he(){$.value=!1,S.value="",T.value=0}function ee(){v.value=!1,w.value="",E.value=0,F.value=null}function te(){/^\s*\/([^\n]*)$/.test(k.value)&&(A.value=k.value),he()}function j(){F.value&&(I.value=F.value.rawToken),ee()}function de(L){if(s.disabled){he();return}A.value&&A.value!==L&&(A.value=null);const P=L.match(/^\s*\/([^\n]*)$/);if(!P){he();return}const N=!$.value||S.value!==P[1];if(S.value=P[1],A.value===L){$.value=!1;return}$.value=!0,N&&(T.value=0)}function be(){const L=y.value,P=k.value.length;return{start:L?.selectionStart??P,end:L?.selectionEnd??P}}function xe(L){const{start:P,end:N}=be();if(P!==N)return null;const ae=L.slice(0,P),se=ae.match(/@([^\s@]*)$/);if(!se)return null;const Ve=se[1],qe=ae.length-Ve.length-1;return{start:qe,end:P,rawToken:ae.slice(qe),query:Ve}}function oe(L){if(s.disabled||$.value){ee();return}const P=xe(L);if(I.value&&I.value!==P?.rawToken&&(I.value=null),!P){ee();return}const N=!v.value||w.value!==P.query||F.value?.rawToken!==P.rawToken;if(w.value=P.query,F.value={start:P.start,end:P.end,rawToken:P.rawToken},I.value===P.rawToken){v.value=!1;return}v.value=!0,N&&(E.value=0)}function Q(L){if(de(L),$.value){ee();return}oe(L)}function J(L){_.value=_.value.filter(P=>L.includes(P.mentionText))}function ge(){const{start:L,end:P}=be();if(L!==P||L===0)return!1;const N=[...new Set(_.value.map(ae=>ae.mentionText))].sort((ae,se)=>se.length-ae.length);for(const ae of N){let se=k.value.indexOf(ae);for(;se!==-1;){const Ve=se,qe=se+ae.length,Me=k.value[qe]===" "?qe+1:qe;if(L>Ve&&L<=Me)return q.value=!0,k.value=k.value.slice(0,Ve)+k.value.slice(Me),I.value=null,De(()=>{W(),re(),y.value?.setSelectionRange(Ve,Ve),q.value=!1,Q(k.value)}),!0;se=k.value.indexOf(ae,se+ae.length)}}return!1}function ke(){o.activateSkill(null),De(re)}function $e(){s.disabled||(h.value&&o.activateSkill(null),q.value=!0,k.value="/",A.value=null,De(()=>{W(),re(),y.value?.setSelectionRange(1,1),q.value=!1,Q(k.value)}))}function Le(L){s.disabled||(q.value=!0,k.value=L,A.value=null,De(()=>{W(),re();const P=k.value.length;y.value?.setSelectionRange(P,P),q.value=!1,Q(k.value)}))}function Be(L){if(s.disabled||!F.value)return;const P=k.value.slice(0,F.value.start),N=k.value.slice(F.value.end),ae=`@${L.insertName}`,se=`${P}${ae} ${N}`;_.value=[..._.value.filter(Ve=>Ve.memberId!==L.memberId),{memberId:L.memberId,platformId:L.platformId,displayName:L.displayName,aliases:[...L.aliases],mentionText:ae}],q.value=!0,k.value=se,I.value=null,ee(),De(()=>{const Ve=P.length+ae.length+1;W(),re(),y.value?.setSelectionRange(Ve,Ve),q.value=!1,Q(k.value)})}function Te(){Y.value&&(u("send",{content:k.value.trim(),mentionedMembers:[..._.value]}),k.value="",A.value=null,I.value=null,_.value=[],ee(),h.value&&o.activateSkill(null))}function Pe(L){s.disabled||(o.activateSkill(L.id),u("skillActivated",L),k.value="",A.value=null,he(),De(()=>{re()}))}function je(){te(),u("manageSkills")}function Se(L){if(!ne.value.length)return;const P=ne.value.length;T.value=(T.value+L+P)%P}function me(L){if(!H.value.length)return;const P=H.value.length;E.value=(E.value+L+P)%P}function O(L){if(L.key==="Backspace"&&k.value.length===0&&h.value){L.preventDefault(),ke();return}if(L.key==="Backspace"&&ge()){L.preventDefault();return}if(v.value){if(L.key==="ArrowDown"){L.preventDefault(),me(1);return}if(L.key==="ArrowUp"){L.preventDefault(),me(-1);return}if(L.key==="Escape"){L.preventDefault(),j();return}if(L.key==="Enter"&&!L.shiftKey&&!D.value||L.key==="Tab"){L.preventDefault();const P=H.value[E.value];P&&Be(P);return}}if($.value){if(L.key==="ArrowDown"){L.preventDefault(),Se(1);return}if(L.key==="ArrowUp"){L.preventDefault(),Se(-1);return}if(L.key==="Escape"){L.preventDefault(),te();return}if(L.key==="Enter"&&!L.shiftKey&&!D.value||L.key==="Tab"){L.preventDefault();const P=ne.value[T.value];P&&Pe(P);return}}L.key==="Enter"&&!L.shiftKey&&!D.value&&(L.preventDefault(),Te())}function V(L){if(!$.value&&!v.value||!b.value)return;const P=L.target;P instanceof Node&&!b.value.contains(P)&&(te(),j())}function K(){q.value||Q(k.value)}return fe(()=>s.chatType,L=>{o.setFilterContext(L)},{immediate:!0}),fe(k,async L=>{J(L),q.value||Q(L),await De(),W()}),fe(ne,L=>{if(L.length===0){T.value=0;return}T.value>=L.length&&(T.value=L.length-1)},{immediate:!0}),fe(H,L=>{if(L.length===0){E.value=0;return}E.value>=L.length&&(E.value=L.length-1)},{immediate:!0}),fe(()=>s.disabled,L=>{L&&(te(),j())}),fe(()=>s.sessionId,()=>{_.value=[],ee(),ve()},{immediate:!0}),Re(async()=>{f.value||await o.loadSkills(),await De(),W(),document.addEventListener("mousedown",V)}),Xt(()=>{document.removeEventListener("mousedown",V)}),l({fillInput:Le,openSkillSelector:$e}),(L,P)=>{const N=_e;return r(),m("div",Tp,[a("div",{ref_key:"rootRef",ref:b,class:"relative w-full max-w-4xl mx-auto"},[p(Ip,{visible:$.value,skills:ne.value,"highlight-index":T.value,"active-skill-id":t(h),onSelect:Pe,onClose:te,onManage:je,onHighlight:P[0]||(P[0]=ae=>T.value=ae)},null,8,["visible","skills","highlight-index","active-skill-id"]),p(Xg,{visible:v.value,members:H.value,"highlight-index":E.value,loading:C.value,onSelect:Be,onClose:j,onHighlight:P[1]||(P[1]=ae=>E.value=ae)},null,8,["visible","members","highlight-index","loading"]),a("div",{class:X(["flex flex-col overflow-hidden rounded-2xl bg-white shadow-[0_2px_14px_rgba(0,0,0,0.04)] ring-1 ring-gray-200/60 transition-all dark:bg-page-dark dark:ring-white/5",s.disabled?"bg-gray-50/50 dark:bg-page-dark/50":"focus-within:ring-primary-500/40 focus-within:shadow-[0_4px_20px_rgba(0,0,0,0.08)] dark:focus-within:ring-primary-500/40"])},[a("div",Mp,[a("div",Ap,[t(g)?(r(),m("div",zp,[a("span",qp,"/"+d(t(g).name),1)])):R("",!0),Qe(a("textarea",{ref_key:"textareaRef",ref:y,"onUpdate:modelValue":P[2]||(P[2]=ae=>k.value=ae),rows:"2",class:"min-h-[48px] min-w-0 flex-1 resize-none border-0 bg-transparent px-0 py-0 text-sm leading-6 text-gray-900 outline-none placeholder:text-gray-400 disabled:cursor-not-allowed disabled:text-gray-400 dark:text-gray-100 dark:placeholder:text-gray-500 dark:disabled:text-gray-500",disabled:s.disabled,placeholder:G.value,onKeydown:O,onClick:K,onKeyup:K,onSelect:K,onCompositionstart:P[3]||(P[3]=ae=>D.value=!0),onCompositionend:P[4]||(P[4]=ae=>D.value=!1)},null,40,Lp),[[ft,k.value]])]),s.status==="streaming"?(r(),m("button",{key:0,type:"button",class:"absolute right-3 bottom-2 flex h-7 w-7 items-center justify-center rounded-full bg-primary-500 text-white shadow-sm transition-colors hover:bg-primary-600",onClick:P[5]||(P[5]=ae=>u("stop"))},[p(N,{name:"i-heroicons-stop-16-solid",class:"h-3.5 w-3.5"})])):(r(),m("button",{key:1,type:"button",class:X(["absolute right-3 bottom-2 flex h-7 w-7 items-center justify-center rounded-full transition-all duration-200",Y.value?"bg-primary-500 text-white hover:bg-primary-600 shadow-sm":"bg-gray-100 text-gray-400 dark:bg-gray-800 dark:text-gray-500"]),disabled:!Y.value,title:Z.value,onClick:Te},[p(N,{name:"i-heroicons-arrow-up-20-solid",class:"h-4 w-4"})],10,Dp))])],2)],512)])}}}),Bp={key:0,class:"flex w-fit items-center gap-1.5 rounded-lg bg-gray-100 px-2.5 py-1 text-xs transition-colors dark:bg-gray-800/50"},Fp={class:"font-medium text-gray-600 dark:text-gray-400"},Rp={key:1,class:"flex items-start gap-3"},Vp={class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-linear-to-br from-pink-500 to-pink-600"},Op={class:"rounded-2xl rounded-tl-sm bg-gray-100 px-4 py-3 dark:bg-gray-800"},Pp={key:0,class:"space-y-2"},jp={class:"flex items-center gap-2"},Np={key:0,class:"flex gap-1"},Up={key:1,class:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400"},Wp={key:0,class:"flex flex-wrap gap-1"},Hp={class:"text-xs text-gray-400"},Kp={key:1,class:"flex items-center gap-2"},Yp={class:"text-sm text-gray-600 dark:text-gray-400"},Gp=ue({__name:"AIThinkingIndicator",props:{currentToolStatus:{},toolsUsed:{},agentStatus:{}},setup(i){const{t:l,te:e}=we();function n(o,c){const g=`ai.assistant.builtinToolDesc.${o}`;return e(g)?l(g):c||o}const s=i,u=M(()=>s.agentStatus?.phase==="compressing");return(o,c)=>{const g=_e;return u.value?(r(),m("div",Bp,[p(g,{name:"i-heroicons-arrow-path",class:"h-3.5 w-3.5 shrink-0 animate-spin text-gray-600 dark:text-gray-400"}),a("span",Fp,d(t(l)("ai.chat.thinking.compressing")),1)])):(r(),m("div",Rp,[a("div",Vp,[p(g,{name:"i-heroicons-sparkles",class:"h-4 w-4 text-white"})]),a("div",Op,[i.currentToolStatus?(r(),m("div",Pp,[a("div",jp,[a("span",{class:X(["inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium",[i.currentToolStatus.status==="running"?"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-300":i.currentToolStatus.status==="done"?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300"]])},[p(g,{name:i.currentToolStatus.status==="running"?"i-heroicons-cog-6-tooth":i.currentToolStatus.status==="done"?"i-heroicons-check-circle":"i-heroicons-x-circle",class:X(["h-3 w-3",{"animate-spin":i.currentToolStatus.status==="running"}])},null,8,["name","class"]),le(" "+d(n(i.currentToolStatus.name,i.currentToolStatus.displayName)),1)],2),i.currentToolStatus.status==="running"?(r(),m("span",Np,[...c[0]||(c[0]=[a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:0ms]"},null,-1),a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:150ms]"},null,-1),a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:300ms]"},null,-1)])])):i.currentToolStatus.status==="done"?(r(),m("span",Up,[a("span",null,d(t(l)("ai.chat.thinking.processingResult")),1),c[1]||(c[1]=a("span",{class:"flex gap-1"},[a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1))])):R("",!0)]),i.toolsUsed.length>1?(r(),m("div",Wp,[a("span",Hp,d(t(l)("ai.chat.thinking.called")),1),(r(!0),m(ie,null,pe(i.toolsUsed.slice(0,-1),h=>(r(),m("span",{key:h,class:"inline-flex items-center gap-1 rounded-full bg-gray-200 px-2 py-0.5 text-xs text-gray-600 dark:bg-gray-700 dark:text-gray-400"},[p(g,{name:"i-heroicons-check",class:"h-3 w-3 text-green-500"}),le(" "+d(n(h)),1)]))),128))])):R("",!0)])):(r(),m("div",Kp,[a("span",Yp,d(t(l)("ai.chat.thinking.analyzing")),1),c[2]||(c[2]=a("span",{class:"flex gap-1"},[a("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:0ms]"}),a("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:150ms]"}),a("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:300ms]"})],-1))]))])]))}}}),Qp={class:"relative z-20 flex items-center justify-between"},Jp={class:"flex items-center gap-1"},Xp=["disabled"],Zp={class:"max-w-[160px] truncate"},e0=["title"],t0={class:"w-40 py-1"},a0={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},s0=["onClick"],n0={class:"flex items-center gap-1"},o0=["title"],l0={class:"hidden shrink-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-xs text-gray-400 dark:text-gray-500 md:flex"},r0={class:"h-1.5 w-10 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},i0={class:"text-[10px]"},u0={class:"space-y-0.5 whitespace-nowrap text-xs"},c0={key:0},d0=["title","disabled"],m0={class:"hidden xl:inline"},g0=["title","disabled"],p0={class:"hidden xl:inline"},h0=ue({__name:"ChatStatusBar",props:{sessionTokenUsage:{},agentStatus:{},currentAIChatId:{},currentMessages:{},fallbackTitle:{},estimatedContextTokens:{}},setup(i){const{t:l}=we(),e=nt(),n=bt(),s=i,u=ka(),o=Tn(),{aiGlobalSettings:c}=ut(u),{defaultAssistantConfig:g,isLoading:h}=ut(o),f=z(!1),b=M(()=>s.agentStatus?l(`ai.chat.statusBar.agent.phase.${s.agentStatus.phase}`):""),y=M(()=>s.agentStatus?l(`ai.chat.statusBar.agent.phaseShort.${s.agentStatus.phase}`):""),k=M(()=>{if(!s.agentStatus)return"text-gray-500 bg-gray-100 dark:bg-gray-800 dark:text-gray-300";switch(s.agentStatus.phase){case"compressing":return"text-purple-600 bg-purple-50 dark:bg-purple-900/30 dark:text-purple-300";case"tool_running":return"text-indigo-600 bg-indigo-50 dark:bg-indigo-900/30 dark:text-indigo-300";case"thinking":return"text-blue-600 bg-blue-50 dark:bg-blue-900/30 dark:text-blue-300";case"responding":return"text-emerald-600 bg-emerald-50 dark:bg-emerald-900/30 dark:text-emerald-300";case"completed":return"text-green-600 bg-green-50 dark:bg-green-900/30 dark:text-green-300";case"aborted":return"text-amber-600 bg-amber-50 dark:bg-amber-900/30 dark:text-amber-300";case"error":return"text-red-600 bg-red-50 dark:bg-red-900/30 dark:text-red-300";default:return"text-gray-500 bg-gray-100 dark:bg-gray-800 dark:text-gray-300"}});function x(te){return Number.isFinite(te)?new Intl.NumberFormat().format(Math.max(0,Math.round(te))):"0"}function _(te){const j=Math.max(0,Math.round(te));return j>=1e6?`${(j/1e6).toFixed(1).replace(/\.0$/,"")}M`:j>=1e3?`${(j/1e3).toFixed(1).replace(/\.0$/,"")}k`:String(j)}const C=M(()=>x(s.sessionTokenUsage.totalTokens)),$=M(()=>_(s.sessionTokenUsage.totalTokens)),S=M(()=>s.sessionTokenUsage.cacheReadTokens>0),T=M(()=>_(s.sessionTokenUsage.cacheReadTokens)),v=M(()=>s.agentStatus?.contextTokens?s.agentStatus.contextTokens:s.estimatedContextTokens&&s.estimatedContextTokens>0?s.estimatedContextTokens:0),w=M(()=>{const te=g.value,j=o.defaultAssistant?.modelId||te?.model;return!te||!j?128e3:(o.getModelById(te.provider,j)||o.findModelAcrossProviders(j))?.contextWindow??128e3}),E=M(()=>v.value<=0||w.value<=0?0:Math.min(100,Math.round(v.value/w.value*100))),F=M(()=>{const te=E.value;return te>=80?"bg-red-500":te>=60?"bg-amber-500":"bg-emerald-500"}),D=M(()=>s.agentStatus?[`${l("ai.chat.statusBar.agent.label")}: ${b.value}`,`${l("ai.chat.statusBar.agent.contextTokens")}: ${x(s.agentStatus.contextTokens)}`,`${l("ai.chat.statusBar.tokenUsageTitle")}: ${C.value}`].join(`
|
|
101
|
-
`):"");function A(){n.openSettings("ai","defaultModel")}const I=z(!1),q=M(()=>ga(s.currentMessages??[])),Y=M(()=>!!s.currentAIChatId||Pl(s.currentMessages??[]));function G(){return{createdAt:l("ai.chat.conversation.export.createdAt"),user:l("ai.chat.conversation.export.user"),assistant:l("ai.chat.conversation.export.assistant")}}function Z(te){return te.map(j=>({...j,timestamp:j.timestamp*1e3}))}async function ce(){if(!(I.value||!Y.value)){I.value=!0;try{const te=c.value.exportFormat||"markdown",j=G();let de=s.fallbackTitle||l("ai.chat.conversation.newChat"),be=q.value[0]?.timestamp??Date.now(),xe=q.value;if(s.currentAIChatId){const[Q,J]=await Promise.all([Ye().getAIChat(s.currentAIChatId),Ye().getMessages(s.currentAIChatId)]);Q&&(de=Q.title||de,be=Q.createdAt*1e3);const ge=ga(Z(J));ge.length>0&&(xe=ge)}if(xe.length===0){e.warn(l("ai.chat.conversation.export.noMessages"));return}const oe=await Wl(de,xe,be,te,j);if(oe.success&&oe.filePath){const Q=oe.filePath.split("/").pop()||oe.filePath,J=oe.filePath;e.add({title:l("common.exportSuccess"),description:Q,color:"primary",actions:[{label:l("common.openFolder"),onClick:()=>{ns().showInFolder(J)}}]})}else e.fail(l("common.exportFailed"),{description:oe.error})}catch(te){console.error("导出对话失败:",te),e.fail(l("common.exportFailed"),{description:String(te)})}finally{I.value=!1}}}async function ne(){if(!f.value){f.value=!0;try{const te=await Ye().showAiLogFile();te?.success||e.fail(l("ai.chat.statusBar.log.openFailed"),{description:te?.error||l("ai.chat.statusBar.log.openFailedDesc")})}catch(te){console.error("打开 AI 日志失败:",te),e.fail(l("ai.chat.statusBar.log.openFailed"),{description:String(te)})}finally{f.value=!1}}}const H=z(!1),W=M(()=>{const te=g.value,j=o.defaultAssistant?.modelId||te?.model;return!te?.provider||!j?[]:Bl(te.provider,j)}),re=M(()=>W.value.length>0),ve=M(()=>{const te=o.defaultAssistant;return!te?.configId||!te?.modelId?"default":u.getThinkingLevel(te.configId,te.modelId)??"default"});function he(te){const j=o.defaultAssistant;!j?.configId||!j?.modelId||(u.setThinkingLevel(j.configId,j.modelId,te),H.value=!1)}const ee=M(()=>l(`ai.chat.statusBar.thinking.level.${ve.value}`));return(te,j)=>{const de=_e,be=ms,xe=St;return r(),m("div",Qp,[a("div",Jp,[a("button",{class:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-300",disabled:t(h),onClick:A},[p(de,{name:"i-heroicons-cpu-chip",class:"h-3.5 w-3.5"}),a("span",Zp,d(t(o).defaultAssistant?.modelId?t(o).getModelById(t(g)?.provider??"",t(o).defaultAssistant.modelId)?.name||t(o).defaultAssistant.modelId:t(l)("ai.chat.statusBar.model.notConfigured")),1)],8,Xp),re.value?(r(),U(be,{key:0,open:H.value,"onUpdate:open":j[0]||(j[0]=oe=>H.value=oe),ui:{content:"z-[80] p-0"}},{content:B(()=>[a("div",t0,[a("div",a0,d(t(l)("ai.chat.statusBar.thinking.title")),1),(r(!0),m(ie,null,pe(W.value,oe=>(r(),m("button",{key:oe,class:X(["flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",ve.value===oe?"text-primary-600 dark:text-primary-400":"text-gray-700 dark:text-gray-300"]),onClick:Q=>he(oe)},[p(de,{name:ve.value===oe?"i-heroicons-check-circle-solid":"i-heroicons-light-bulb",class:X(["h-4 w-4 shrink-0",ve.value===oe?"text-primary-500":"text-gray-400"])},null,8,["name","class"]),a("span",null,d(t(l)(`ai.chat.statusBar.thinking.level.${oe}`)),1)],10,s0))),128))])]),default:B(()=>[a("button",{class:X(["flex items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",ve.value==="default"||ve.value==="off"?"text-gray-400 dark:text-gray-500":"text-primary-500 dark:text-primary-400"]),title:t(l)("ai.chat.statusBar.thinking.tooltip")},[p(de,{name:"i-heroicons-light-bulb",class:"h-3.5 w-3.5"}),a("span",null,d(ee.value),1)],10,e0)]),_:1},8,["open"])):R("",!0)]),a("div",n0,[i.agentStatus?(r(),m("div",{key:0,class:"hidden shrink-0 items-center gap-1 rounded-lg bg-gray-50/90 px-1.5 py-1 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.35)] dark:bg-gray-800/70 dark:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.04)] lg:flex",title:D.value},[a("span",{class:X(["rounded px-1 py-0.5 text-[10px] font-medium",k.value])},d(y.value),3)],8,o0)):R("",!0),v.value>0?(r(),U(xe,{key:1,ui:{content:"h-auto py-1.5"}},{content:B(()=>[a("div",u0,[a("div",null,d(t(l)("ai.chat.statusBar.agent.contextTokens"))+": "+d(_(v.value))+" / "+d(_(w.value)),1),a("div",null,d(t(l)("ai.chat.statusBar.tokenUsageTitle"))+": "+d($.value),1),S.value?(r(),m("div",c0,d(t(l)("ai.chat.statusBar.cacheHit"))+": "+d(T.value),1)):R("",!0)])]),default:B(()=>[a("div",l0,[a("div",r0,[a("div",{class:X(["h-full rounded-full transition-all duration-300",F.value]),style:et({width:`${E.value}%`})},null,6)]),a("span",i0,d(E.value)+"%",1)])]),_:1})):R("",!0),a("button",{class:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:t(l)("ai.chat.statusBar.export.title"),disabled:I.value||!Y.value,onClick:ce},[p(de,{name:"i-heroicons-arrow-down-tray",class:"h-3.5 w-3.5"}),a("span",m0,d(t(l)("ai.chat.statusBar.export.label")),1)],8,d0),a("button",{class:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:t(l)("ai.chat.statusBar.log.title"),disabled:f.value,onClick:ne},[p(de,{name:"i-heroicons-document-text",class:"h-3.5 w-3.5"}),a("span",p0,d(t(l)("ai.chat.statusBar.log.label")),1)],8,g0)])])}}}),f0={class:"assistant-bar-wrapper flex justify-center"},v0=["onClick"],y0={key:0,class:"absolute right-0 top-full z-30 mt-2 w-56 overflow-hidden rounded-xl border border-gray-200/80 bg-white/95 p-1 shadow-overlay backdrop-blur-md dark:border-gray-700 dark:bg-page-dark/95"},x0={class:"custom-scrollbar max-h-60 space-y-0.5 overflow-y-auto"},b0=["onClick"],k0={class:"truncate font-medium"},Pt=4,_0=ue({__name:"AssistantInlineBar",props:{chatType:{},locale:{},selectedId:{}},emits:["select","market"],setup(i,{emit:l}){const e=i,n=l,s=z(!1),u=z(null);function o(v){n("select",v),s.value=!1}function c(){x.value.length!==0&&(s.value=!s.value)}function g(v){if(!s.value||!u.value)return;const w=v.target;w instanceof Node&&!u.value.contains(w)&&(s.value=!1)}const h=Ft(),{filteredAssistants:f,isLoaded:b}=ut(h),y=M(()=>{const v=Mn(e.locale);return[...f.value].sort((w,E)=>w.id===v?-1:E.id===v?1:0)}),k=M(()=>{const v=y.value;if(v.length<=Pt)return v;const w=v.findIndex(E=>E.id===e.selectedId);if(w!==-1&&w>=Pt-1){const E=v.slice(0,Pt-1),F=v[w];return[...E,F]}return v.slice(0,Pt)}),x=M(()=>{const v=new Set(k.value.map(w=>w.id));return y.value.filter(w=>!v.has(w.id))});fe(()=>[e.chatType,e.locale],([v,w])=>{h.setFilterContext(v,w)},{immediate:!0});const _=z([]),C=z(null);let $=null;const S=z({width:"0px",transform:"translateX(0px)",opacity:0}),T=async()=>{await De();const v=k.value.findIndex(w=>w.id===e.selectedId);if(v!==-1&&_.value[v]){const w=_.value[v];S.value={width:`${w.offsetWidth+6}px`,transform:`translateX(${w.offsetLeft-3}px)`,opacity:1}}else S.value.opacity=0};return fe(()=>[e.selectedId,k.value],()=>{T()},{deep:!0}),Re(async()=>{b.value||await h.loadAssistants(),T(),document.addEventListener("mousedown",g),typeof ResizeObserver<"u"&&C.value&&($=new ResizeObserver(()=>{T()}),$.observe(C.value))}),tt(()=>{document.removeEventListener("mousedown",g),$&&$.disconnect()}),(v,w)=>{const E=_e;return r(),m("div",f0,[a("div",{ref_key:"containerRef",ref:C,class:"assistant-bar-grid relative flex items-center justify-center gap-1.5 rounded-full bg-gray-50/60 p-[3px] shadow-inner ring-1 ring-inset ring-gray-900/5 backdrop-blur-md dark:bg-gray-800/40 dark:ring-white/10 z-0 overflow-hidden sm:overflow-visible"},[a("div",{class:"absolute left-0 inset-y-0 -z-10 rounded-full bg-white ring-[1.5px] ring-primary-500 shadow-sm transition-all duration-350 ease-out dark:bg-primary-700/15 dark:ring-primary-500",style:et(S.value)},null,4),(r(!0),m(ie,null,pe(k.value,(F,D)=>(r(),m("button",{key:F.id,ref_for:!0,ref:A=>{A&&(_.value[D]=A)},class:X(["relative z-10 flex h-[32px] items-center justify-center whitespace-nowrap rounded-full px-4 text-[13px] font-medium transition-colors duration-200",[i.selectedId===F.id?"text-primary-600 dark:text-primary-400":"text-gray-500 hover:bg-gray-200/50 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-700/50 dark:hover:text-gray-200"]]),onClick:A=>n("select",F.id)},d(F.name),11,v0))),128)),x.value.length>0?(r(),m("div",{key:0,ref_key:"overflowMenuRef",ref:u,class:"relative z-20"},[a("button",{type:"button",class:"relative z-10 flex h-[32px] w-[32px] ml-0.5 items-center justify-center rounded-full text-gray-500 transition-colors duration-200 hover:bg-gray-200/50 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-700/50 dark:hover:text-gray-200",onClick:c},[p(E,{name:"i-heroicons-ellipsis-horizontal",class:"h-5 w-5"})]),s.value?(r(),m("div",y0,[a("div",x0,[w[1]||(w[1]=a("p",{class:"px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500"}," 更多助手 ",-1)),(r(!0),m(ie,null,pe(x.value,F=>(r(),m("button",{key:F.id,type:"button",class:X(["flex w-full items-center justify-between rounded-md px-2.5 py-1.5 text-left text-sm transition-colors",[i.selectedId===F.id?"bg-primary-50 text-primary-600 dark:bg-primary-500/10 dark:text-primary-400":"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800"]]),onClick:D=>o(F.id)},[a("span",k0,d(F.name),1),i.selectedId===F.id?(r(),U(E,{key:0,name:"i-heroicons-check",class:"h-4 w-4 shrink-0"})):R("",!0)],10,b0))),128))])])):R("",!0)],512)):R("",!0),a("button",{type:"button",class:"relative z-10 flex h-[32px] w-[32px] items-center justify-center rounded-full text-gray-500 transition-colors duration-200 hover:bg-gray-200/50 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-700/50 dark:hover:text-gray-200",onClick:w[0]||(w[0]=F=>n("market"))},[p(E,{name:"i-heroicons-plus",class:"h-[18px] w-[18px]"})])],512)])}}}),w0=dt(_0,[["__scopeId","data-v-169115ce"]]),$0={slots:{root:"relative inline-flex items-center",base:["w-full rounded-md border-0 appearance-none placeholder:text-dimmed disabled:cursor-not-allowed disabled:opacity-75","transition-colors"],leading:"absolute start-0 flex items-start",leadingIcon:"shrink-0 text-dimmed",leadingAvatar:"shrink-0",leadingAvatarSize:"",trailing:"absolute end-0 flex items-start",trailingIcon:"shrink-0 text-dimmed"},variants:{fieldGroup:{horizontal:{root:"group has-focus-visible:z-[1]",base:"group-not-only:group-first:rounded-e-none group-not-only:group-last:rounded-s-none group-not-last:group-not-first:rounded-none"},vertical:{root:"group has-focus-visible:z-[1]",base:"group-not-only:group-first:rounded-b-none group-not-only:group-last:rounded-t-none group-not-last:group-not-first:rounded-none"}},size:{xs:{base:"px-2 py-1 text-sm/4 gap-1",leading:"ps-2 inset-y-1",trailing:"pe-2 inset-y-1",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4"},sm:{base:"px-2.5 py-1.5 text-sm/4 gap-1.5",leading:"ps-2.5 inset-y-1.5",trailing:"pe-2.5 inset-y-1.5",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4"},md:{base:"px-2.5 py-1.5 text-base/5 gap-1.5",leading:"ps-2.5 inset-y-1.5",trailing:"pe-2.5 inset-y-1.5",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5"},lg:{base:"px-3 py-2 text-base/5 gap-2",leading:"ps-3 inset-y-2",trailing:"pe-3 inset-y-2",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5"},xl:{base:"px-3 py-2 text-base gap-2",leading:"ps-3 inset-y-2",trailing:"pe-3 inset-y-2",leadingIcon:"size-6",leadingAvatarSize:"xs",trailingIcon:"size-6"}},variant:{outline:"text-highlighted bg-default ring ring-inset ring-accented",soft:"text-highlighted bg-elevated/50 hover:bg-elevated focus:bg-elevated disabled:bg-elevated/50",subtle:"text-highlighted bg-elevated ring ring-inset ring-accented",ghost:"text-highlighted bg-transparent hover:bg-elevated focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent",none:"text-highlighted bg-transparent focus:outline-none"},color:{primary:"",secondary:"",success:"",info:"",warning:"",error:"",neutral:""},leading:{true:""},trailing:{true:""},loading:{true:""},highlight:{true:""},fixed:{false:""},type:{file:"file:me-1.5 file:font-medium file:text-muted file:outline-none"},autoresize:{true:{base:"resize-none"}}},compoundVariants:[{color:"primary",variant:["outline","subtle"],class:"outline-primary/25 focus-visible:outline-3 focus-visible:ring-primary"},{color:"secondary",variant:["outline","subtle"],class:"outline-secondary/25 focus-visible:outline-3 focus-visible:ring-secondary"},{color:"success",variant:["outline","subtle"],class:"outline-success/25 focus-visible:outline-3 focus-visible:ring-success"},{color:"info",variant:["outline","subtle"],class:"outline-info/25 focus-visible:outline-3 focus-visible:ring-info"},{color:"warning",variant:["outline","subtle"],class:"outline-warning/25 focus-visible:outline-3 focus-visible:ring-warning"},{color:"error",variant:["outline","subtle"],class:"outline-error/25 focus-visible:outline-3 focus-visible:ring-error"},{color:"primary",variant:["soft","ghost"],class:"outline-primary/25 focus-visible:outline-3"},{color:"secondary",variant:["soft","ghost"],class:"outline-secondary/25 focus-visible:outline-3"},{color:"success",variant:["soft","ghost"],class:"outline-success/25 focus-visible:outline-3"},{color:"info",variant:["soft","ghost"],class:"outline-info/25 focus-visible:outline-3"},{color:"warning",variant:["soft","ghost"],class:"outline-warning/25 focus-visible:outline-3"},{color:"error",variant:["soft","ghost"],class:"outline-error/25 focus-visible:outline-3"},{color:"primary",highlight:!0,class:"ring ring-inset ring-primary"},{color:"secondary",highlight:!0,class:"ring ring-inset ring-secondary"},{color:"success",highlight:!0,class:"ring ring-inset ring-success"},{color:"info",highlight:!0,class:"ring ring-inset ring-info"},{color:"warning",highlight:!0,class:"ring ring-inset ring-warning"},{color:"error",highlight:!0,class:"ring ring-inset ring-error"},{color:"neutral",variant:["outline","subtle"],class:"outline-inverted/25 focus-visible:outline-3 focus-visible:ring-inverted"},{color:"neutral",variant:["soft","ghost"],class:"outline-inverted/25 focus-visible:outline-3"},{color:"neutral",highlight:!0,class:"ring ring-inset ring-inverted"},{leading:!0,size:"xs",class:"ps-7"},{leading:!0,size:"sm",class:"ps-8"},{leading:!0,size:"md",class:"ps-9"},{leading:!0,size:"lg",class:"ps-10"},{leading:!0,size:"xl",class:"ps-11"},{trailing:!0,size:"xs",class:"pe-7"},{trailing:!0,size:"sm",class:"pe-8"},{trailing:!0,size:"md",class:"pe-9"},{trailing:!0,size:"lg",class:"pe-10"},{trailing:!0,size:"xl",class:"pe-11"},{loading:!0,leading:!0,class:{leadingIcon:"animate-spin"}},{loading:!0,leading:!1,trailing:!0,class:{trailingIcon:"animate-spin"}},{fixed:!1,size:"xs",class:"md:text-xs"},{fixed:!1,size:"sm",class:"md:text-xs"},{fixed:!1,size:"md",class:"md:text-sm"},{fixed:!1,size:"lg",class:"md:text-sm"}],defaultVariants:{size:"md",color:"primary",variant:"outline"}},C0=["id","value","name","rows","placeholder","disabled","required"],S0=Object.assign({inheritAttrs:!1},{__name:"Textarea",props:{as:{type:null,required:!1},id:{type:String,required:!1},name:{type:String,required:!1},placeholder:{type:String,required:!1},color:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},required:{type:Boolean,required:!1},autofocus:{type:Boolean,required:!1},autofocusDelay:{type:Number,required:!1,default:0},autoresize:{type:Boolean,required:!1},autoresizeDelay:{type:Number,required:!1,default:0},disabled:{type:Boolean,required:!1},rows:{type:Number,required:!1,default:3},maxrows:{type:Number,required:!1,default:0},highlight:{type:Boolean,required:!1},fixed:{type:Boolean,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1},modelModifiers:{type:null,required:!1},class:{type:null,required:!1},ui:{type:Object,required:!1},icon:{type:null,required:!1},avatar:{type:Object,required:!1},leading:{type:Boolean,required:!1},leadingIcon:{type:null,required:!1},trailing:{type:Boolean,required:!1},trailingIcon:{type:null,required:!1},loading:{type:Boolean,required:!1},loadingIcon:{type:null,required:!1}},emits:["update:modelValue","blur","change"],setup(i,{expose:l,emit:e}){const n=i,s=e,u=Qt(),o=Ca("textarea",n),c=An(o,"modelValue",s,{defaultValue:o.defaultValue}),g=Ia(),{emitFormFocus:h,emitFormBlur:f,emitFormInput:b,emitFormChange:y,size:k,color:x,id:_,name:C,highlight:$,disabled:S,ariaAttrs:T}=Sa(n,{deferInputValidation:!0}),{isLeading:v,isTrailing:w,leadingIconName:E,trailingIconName:F}=Ta(o),D=M(()=>$t({extend:$t($0),...g.ui?.textarea||{}})({color:x.value??o.color,variant:o.variant,size:k?.value??o.size,loading:o.loading,highlight:$.value??o.highlight,fixed:o.fixed,autoresize:o.autoresize,leading:v.value||!!o.avatar||!!u.leading,trailing:w.value||!!u.trailing})),A=At("textareaRef");function I(ne){o.modelModifiers?.trim&&(typeof ne=="string"||ne===null||ne===void 0)&&(ne=ne?.trim()??null),o.modelModifiers?.number&&(ne=ds(ne)),o.modelModifiers?.nullable&&(ne||=null),o.modelModifiers?.optional&&!o.modelModifiers?.nullable&&ne!==null&&(ne||=void 0),c.value=ne,b()}function q(ne){ce(),o.modelModifiers?.lazy||I(ne.target.value)}function Y(ne){const H=ne.target.value;o.modelModifiers?.lazy&&I(H),o.modelModifiers?.trim&&(ne.target.value=H.trim()),y(),s("change",ne)}function G(ne){f(),s("blur",ne)}function Z(){o.autofocus&&A.value?.focus()}function ce(){if(o.autoresize&&A.value){A.value.rows=o.rows;const ne=A.value.style.overflow;A.value.style.overflow="hidden";const H=window.getComputedStyle(A.value),W=Number.parseInt(H.paddingTop),re=Number.parseInt(H.paddingBottom),ve=W+re,he=Number.parseInt(H.lineHeight),{scrollHeight:ee}=A.value,te=(ee-ve)/he;te>o.rows&&(A.value.rows=o.maxrows?Math.min(te,o.maxrows):te),A.value.style.overflow=ne}}return fe(c,()=>{De(ce)}),Re(()=>{setTimeout(()=>{Z()},o.autofocusDelay),setTimeout(async()=>{await De(),ce()},o.autoresizeDelay)}),l({textareaRef:A,autoResize:ce}),(ne,H)=>(r(),U(t(He),{as:t(o).as,"data-slot":"root",class:X(D.value.root({class:[t(o).ui?.root,t(o).class]}))},{default:B(()=>[a("textarea",ze({id:t(_),ref_key:"textareaRef",ref:A,value:t(c),name:t(C),rows:t(o).rows,placeholder:t(o).placeholder,"data-slot":"base",class:D.value.base({class:t(o).ui?.base}),disabled:t(S),required:t(o).required},{...ne.$attrs,...t(T)},{onInput:q,onBlur:G,onChange:Y,onFocus:H[0]||(H[0]=(...W)=>t(h)&&t(h)(...W))}),null,16,C0),ye(ne.$slots,"default",{ui:D.value}),t(v)||t(o).avatar||u.leading?(r(),m("span",{key:0,"data-slot":"leading",class:X(D.value.leading({class:t(o).ui?.leading}))},[ye(ne.$slots,"leading",{ui:D.value},()=>[t(v)&&t(E)?(r(),U(_e,{key:0,name:t(E),"data-slot":"leadingIcon",class:X(D.value.leadingIcon({class:t(o).ui?.leadingIcon}))},null,8,["name","class"])):t(o).avatar?(r(),U(Ht,ze({key:1,size:t(o).ui?.leadingAvatarSize||D.value.leadingAvatarSize()},t(o).avatar,{"data-slot":"leadingAvatar",class:D.value.leadingAvatar({class:t(o).ui?.leadingAvatar})}),null,16,["size","class"])):R("",!0)])],2)):R("",!0),t(w)||u.trailing?(r(),m("span",{key:1,"data-slot":"trailing",class:X(D.value.trailing({class:t(o).ui?.trailing}))},[ye(ne.$slots,"trailing",{ui:D.value},()=>[t(F)?(r(),U(_e,{key:0,name:t(F),"data-slot":"trailingIcon",class:X(D.value.trailingIcon({class:t(o).ui?.trailingIcon}))},null,8,["name","class"])):R("",!0)])],2)):R("",!0)]),_:3},8,["as","class"]))}}),I0={class:"p-6"},T0={class:"mb-4 flex items-start justify-between gap-3"},M0={class:"min-w-0"},A0={class:"text-lg font-semibold text-gray-900 dark:text-white"},z0={key:0,class:"mt-1 text-xs text-amber-600 dark:text-amber-400"},q0={key:0,class:"flex items-center justify-center py-12"},L0={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},D0={key:0,class:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary-100 px-1 text-[10px] text-primary-600 dark:bg-primary-900/30 dark:text-primary-400"},E0={class:"max-h-[500px] overflow-y-auto pr-1"},B0={class:"space-y-5"},F0={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},R0={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},V0={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},O0={class:"flex flex-wrap gap-2"},P0=["disabled","onClick"],j0={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},N0={class:"flex flex-wrap gap-2"},U0=["disabled","onClick"],W0={class:"mt-1 text-[10px] text-gray-400"},H0={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},K0={class:"space-y-2"},Y0={key:0,class:"flex items-center gap-2"},G0={class:"space-y-5"},Q0={class:"mb-1 text-sm font-medium text-gray-700 dark:text-gray-300"},J0={class:"mb-2.5 text-[10px] text-gray-400"},X0={class:"grid grid-cols-2 gap-1.5"},Z0={class:"min-w-0"},eh={class:"truncate text-xs font-medium text-gray-600 dark:text-gray-400"},th={class:"truncate text-[10px] text-gray-400 dark:text-gray-500"},ah={class:"mb-1 flex items-center justify-between"},sh={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},nh={key:0,class:"flex gap-2"},oh={class:"mb-2.5 text-[10px] text-gray-400"},lh={class:"grid grid-cols-2 gap-1.5"},rh=["checked","disabled","onChange"],ih={class:"min-w-0"},uh={class:"truncate text-xs font-medium text-gray-800 dark:text-gray-200"},ch={class:"truncate text-[10px] text-gray-500 dark:text-gray-400"},dh={class:"mt-6 flex items-center justify-between"},mh={class:"flex gap-2"},gh=ue({__name:"AssistantConfigModal",props:{open:{type:Boolean},assistantId:{},readonly:{type:Boolean},scrollToSection:{}},emits:["update:open","saved","created"],setup(i,{emit:l}){const{t:e}=we(),n=i,s=l,u=nt(),o=Ft(),c=z(!1),g=z(!1),h=z(null),f=z(!1),b=z("basic"),y=M(()=>[{value:"",label:e("ai.assistant.config.chatTypeAll")},{value:"group",label:e("ai.assistant.config.chatTypeGroup")},{value:"private",label:e("ai.assistant.config.chatTypePrivate")}]),k=[{value:"zh",label:"简体中文"},{value:"en",label:"English"},{value:"ja",label:"日本語"}],x=M(()=>o.builtinToolCatalog.filter(H=>H.category==="core").map(H=>({name:H.name,description:e(`ai.assistant.builtinToolDesc.${H.name}`)}))),_=M(()=>o.builtinToolCatalog.filter(H=>H.category==="analysis").map(H=>({name:H.name,description:e(`ai.assistant.builtinToolDesc.${H.name}`)}))),C=z({name:"",systemPrompt:"",presetQuestions:[],applicableChatType:"",supportedLocales:[],allowedBuiltinTools:[]}),$=z(""),S=z(null),T=M(()=>C.value.allowedBuiltinTools.length);Re(async()=>{o.builtinToolCatalog.length===0&&await o.loadBuiltinToolCatalog()}),fe(()=>[n.open,n.assistantId],async([H,W])=>{H&&(b.value="basic",W?(f.value=!1,await w(W)):n.readonly||(f.value=!0,v()),n.scrollToSection==="presetQuestions"&&(await De(),setTimeout(()=>{S.value?.scrollIntoView({behavior:"smooth",block:"center"})},100)))},{immediate:!0});function v(){h.value={id:"",name:"",systemPrompt:"",presetQuestions:[],allowedBuiltinTools:[],applicableChatTypes:[],supportedLocales:[]},C.value={name:"",systemPrompt:"",presetQuestions:[],applicableChatType:"",supportedLocales:[],allowedBuiltinTools:[]},c.value=!1}async function w(H){c.value=!0;try{h.value=await o.getAssistantConfig(H),h.value&&(C.value={name:h.value.name,systemPrompt:h.value.systemPrompt,presetQuestions:[...h.value.presetQuestions],applicableChatType:h.value.applicableChatTypes?.[0]||"",supportedLocales:[...h.value.supportedLocales||[]],allowedBuiltinTools:[...h.value.allowedBuiltinTools||[]]})}catch(W){console.error("[AssistantConfigModal] Failed to load config:",W),u.fail(e("ai.assistant.toast.loadFailed"),{description:String(W)})}finally{c.value=!1}}async function E(){g.value=!0;try{const H={name:C.value.name,systemPrompt:C.value.systemPrompt,presetQuestions:[...C.value.presetQuestions],applicableChatTypes:C.value.applicableChatType?[C.value.applicableChatType]:[],supportedLocales:[...C.value.supportedLocales],allowedBuiltinTools:[...C.value.allowedBuiltinTools]};if(f.value){const W=await o.createAssistant(H);W.success?(u.success(e("ai.assistant.toast.createSuccess")),s("created",W.id),ne()):u.fail(e("ai.assistant.toast.createFailed"),{description:W.error||e("ai.assistant.toast.unknownError")})}else{if(!n.assistantId)return;const W=await o.updateAssistant(n.assistantId,H);W.success?(u.success(e("ai.assistant.toast.saveSuccess")),s("saved"),ne()):u.fail(e("ai.assistant.toast.saveFailed"),{description:W.error||e("ai.assistant.toast.unknownError")})}}catch(H){console.error("[AssistantConfigModal] Save failed:",H),u.fail(e("ai.assistant.toast.saveFailed"),{description:String(H)})}finally{g.value=!1}}async function F(){if(!(!n.assistantId||!h.value?.builtinId)){g.value=!0;try{const H=await o.resetAssistant(n.assistantId);H.success?(u.success(e("ai.assistant.toast.resetSuccess")),await w(n.assistantId),s("saved")):u.fail(e("ai.assistant.toast.resetFailed"),{description:H.error||e("ai.assistant.toast.unknownError")})}catch(H){u.fail(e("ai.assistant.toast.resetFailed"),{description:String(H)})}finally{g.value=!1}}}function D(){const H=$.value.trim();H&&!C.value.presetQuestions.includes(H)&&(C.value.presetQuestions.push(H),$.value="")}function A(H){C.value.presetQuestions.splice(H,1)}function I(H){const W=C.value.allowedBuiltinTools.indexOf(H);W>=0?C.value.allowedBuiltinTools.splice(W,1):C.value.allowedBuiltinTools.push(H)}function q(H){return C.value.allowedBuiltinTools.includes(H)}function Y(){C.value.allowedBuiltinTools=_.value.map(H=>H.name)}function G(){C.value.allowedBuiltinTools=[]}function Z(H){C.value.applicableChatType=H}function ce(H){const W=C.value.supportedLocales.indexOf(H);W>=0?C.value.supportedLocales.splice(W,1):C.value.supportedLocales.push(H)}function ne(){s("update:open",!1)}return(H,W)=>{const re=Ue,ve=_e,he=Bt,ee=S0,te=Xe;return r(),U(te,{open:i.open,ui:{content:"sm:max-w-2xl z-100"},"onUpdate:open":W[5]||(W[5]=j=>s("update:open",j))},{content:B(()=>[a("div",I0,[a("div",T0,[a("div",M0,[a("h2",A0,d(i.readonly?t(e)("ai.assistant.config.viewTitle"):f.value?t(e)("ai.assistant.config.createTitle"):t(e)("ai.assistant.config.editTitle")),1),i.readonly?R("",!0):(r(),m("p",z0,d(t(e)("ai.assistant.config.betaWarning")),1))]),p(re,{icon:"i-heroicons-x-mark",variant:"ghost",size:"sm",class:"shrink-0",onClick:ne})]),c.value?(r(),m("div",q0,[p(ve,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):h.value?(r(),m(ie,{key:1},[a("div",L0,[a("button",{class:X(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",b.value==="basic"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:W[0]||(W[0]=j=>b.value="basic")},d(t(e)("ai.assistant.config.tabs.basic")),3),a("button",{class:X(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",b.value==="tools"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:W[1]||(W[1]=j=>b.value="tools")},[le(d(t(e)("ai.assistant.config.tabs.tools"))+" ",1),T.value>0?(r(),m("span",D0,d(T.value),1)):R("",!0)],2)]),a("div",E0,[Qe(a("div",B0,[a("div",null,[a("label",F0,d(t(e)("ai.assistant.config.name")),1),p(he,{modelValue:C.value.name,"onUpdate:modelValue":W[2]||(W[2]=j=>C.value.name=j),class:"w-full",disabled:i.readonly},null,8,["modelValue","disabled"])]),a("div",null,[a("label",R0,d(t(e)("ai.assistant.config.systemPrompt")),1),p(ee,{modelValue:C.value.systemPrompt,"onUpdate:modelValue":W[3]||(W[3]=j=>C.value.systemPrompt=j),rows:5,autoresize:"",class:"w-full font-mono text-sm",disabled:i.readonly},null,8,["modelValue","disabled"])]),a("div",null,[a("label",V0,d(t(e)("ai.assistant.config.chatType")),1),a("div",O0,[(r(!0),m(ie,null,pe(y.value,j=>(r(),m("button",{key:j.value,type:"button",class:X(["rounded-lg border px-3 py-1.5 text-xs transition-colors",C.value.applicableChatType===j.value?"border-primary-500 bg-primary-50 text-primary-700 dark:border-primary-400 dark:bg-primary-950/30 dark:text-primary-300":"border-gray-200 text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:text-gray-400"]),disabled:i.readonly,onClick:de=>Z(j.value)},d(j.label),11,P0))),128))])]),a("div",null,[a("label",j0,d(t(e)("ai.assistant.config.locale")),1),a("div",N0,[(r(),m(ie,null,pe(k,j=>a("button",{key:j.value,type:"button",class:X(["rounded-lg border px-3 py-1.5 text-xs transition-colors",C.value.supportedLocales.includes(j.value)?"border-primary-500 bg-primary-50 text-primary-700 dark:border-primary-400 dark:bg-primary-950/30 dark:text-primary-300":"border-gray-200 text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:text-gray-400"]),disabled:i.readonly,onClick:de=>ce(j.value)},d(j.label),11,U0)),64))]),a("p",W0,d(t(e)("ai.assistant.config.localeHint")),1)]),a("div",{ref_key:"presetQuestionsRef",ref:S},[a("label",H0,d(t(e)("ai.assistant.config.presetQuestions")),1),a("div",K0,[(r(!0),m(ie,null,pe(C.value.presetQuestions,(j,de)=>(r(),m("div",{key:de,class:"flex items-center gap-2"},[p(he,{modelValue:C.value.presetQuestions[de],"onUpdate:modelValue":be=>C.value.presetQuestions[de]=be,class:"min-w-0 flex-1",size:"sm",disabled:i.readonly},null,8,["modelValue","onUpdate:modelValue","disabled"]),i.readonly?R("",!0):(r(),U(re,{key:0,color:"error",variant:"ghost",icon:"i-heroicons-trash",size:"xs",class:"shrink-0",onClick:be=>A(de)},null,8,["onClick"]))]))),128)),i.readonly?R("",!0):(r(),m("div",Y0,[p(he,{modelValue:$.value,"onUpdate:modelValue":W[4]||(W[4]=j=>$.value=j),placeholder:t(e)("ai.assistant.config.addQuestion"),class:"min-w-0 flex-1",size:"sm",onKeyup:Ge(D,["enter"])},null,8,["modelValue","placeholder"]),p(re,{color:"primary",variant:"soft",icon:"i-heroicons-plus",size:"xs",class:"shrink-0",onClick:D})]))])],512)],512),[[yt,b.value==="basic"]]),Qe(a("div",G0,[a("div",null,[a("h3",Q0,d(t(e)("ai.assistant.config.coreTools")),1),a("p",J0,d(t(e)("ai.assistant.config.coreToolsHint")),1),a("div",X0,[(r(!0),m(ie,null,pe(x.value,j=>(r(),m("label",{key:j.name,class:"flex items-start gap-2 rounded-md border border-gray-200 bg-gray-50/50 px-2.5 py-2 opacity-70 dark:border-gray-700 dark:bg-gray-800/30"},[W[6]||(W[6]=a("input",{type:"checkbox",checked:"",disabled:"",class:"mt-0.5 h-3.5 w-3.5 shrink-0 rounded border-gray-300 text-gray-400"},null,-1)),a("div",Z0,[a("div",eh,d(j.name),1),a("div",th,d(j.description),1)])]))),128))])]),a("div",null,[a("div",ah,[a("h3",sh,d(t(e)("ai.assistant.config.analysisTools")),1),i.readonly?R("",!0):(r(),m("div",nh,[a("button",{class:"text-[10px] text-primary-500 hover:text-primary-600",onClick:Y},d(t(e)("ai.assistant.config.selectAll")),1),W[7]||(W[7]=a("span",{class:"text-[10px] text-gray-300 dark:text-gray-600"},"|",-1)),a("button",{class:"text-[10px] text-primary-500 hover:text-primary-600",onClick:G},d(t(e)("ai.assistant.config.deselectAll")),1)]))]),a("p",oh,d(t(e)("ai.assistant.config.analysisToolsHint")),1),a("div",lh,[(r(!0),m(ie,null,pe(_.value,j=>(r(),m("label",{key:j.name,class:X(["flex cursor-pointer items-start gap-2 rounded-md border px-2.5 py-2 transition-colors",q(j.name)?"border-primary-200 bg-primary-50/50 dark:border-primary-800 dark:bg-primary-950/20":"border-gray-200 dark:border-gray-700"])},[a("input",{type:"checkbox",checked:q(j.name),disabled:i.readonly,class:"mt-0.5 h-3.5 w-3.5 shrink-0 rounded border-gray-300 text-primary-600 focus:ring-primary-500",onChange:de=>I(j.name)},null,40,rh),a("div",ih,[a("div",uh,d(j.name),1),a("div",ch,d(j.description),1)])],2))),128))])])],512),[[yt,b.value==="tools"]])]),a("div",dh,[a("div",null,[!i.readonly&&!f.value&&h.value?.builtinId?(r(),U(re,{key:0,variant:"outline",color:"warning",loading:g.value,onClick:F},{default:B(()=>[le(d(t(e)("ai.assistant.config.resetDefault")),1)]),_:1},8,["loading"])):R("",!0)]),a("div",mh,[p(re,{variant:"ghost",onClick:ne},{default:B(()=>[le(d(i.readonly?t(e)("common.close"):t(e)("common.cancel")),1)]),_:1}),i.readonly?R("",!0):(r(),U(re,{key:0,color:"primary",loading:g.value,onClick:E},{default:B(()=>[le(d(f.value?t(e)("ai.assistant.config.create"):t(e)("common.save")),1)]),_:1},8,["loading"]))])])],64)):R("",!0)])]),_:1},8,["open"])}}}),ph={class:"p-6"},hh={class:"mb-4 flex items-center justify-between"},fh={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},vh={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},yh={key:0,class:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary-100 px-1 text-[10px] text-primary-600 dark:bg-primary-900/30 dark:text-primary-400"},xh={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},bh={class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},kh={class:"min-w-0 flex-1"},_h={class:"flex items-center gap-2"},wh={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},$h={key:0,class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},Ch={key:1,class:"inline-flex shrink-0 items-center rounded-full bg-green-100 px-2 py-0.5 text-[10px] font-medium text-green-700 dark:bg-green-900/30 dark:text-green-400"},Sh={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},Ih={class:"flex shrink-0 items-center gap-1.5"},Th=["title","onClick"],Mh=["title","onClick"],Ah=["title","onClick"],zh={key:0,class:"py-12 text-center text-sm text-gray-400"},qh={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},Lh={key:0,class:"py-12 text-center text-sm text-gray-400"},Dh={key:1,class:"py-12 text-center"},Eh={class:"text-sm text-gray-500 dark:text-gray-400"},Bh={key:2,class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},Fh={class:"min-w-0 flex-1"},Rh={class:"flex items-center gap-2"},Vh={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Oh={key:0,class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},Ph={key:1,class:"inline-flex shrink-0 items-center rounded-full bg-green-100 px-2 py-0.5 text-[10px] font-medium text-green-700 dark:bg-green-900/30 dark:text-green-400"},jh={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},Nh={class:"flex shrink-0 items-center gap-2"},Uh=["disabled","onClick"],Wh={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},Hh=["disabled","onClick"],Kh=["title","onClick"],Yh={key:3,class:"py-12 text-center text-sm text-gray-400"},Gh=ue({__name:"AssistantMarketModal",props:{open:{type:Boolean}},emits:["update:open","configure","view-config","create"],setup(i,{emit:l}){const{t:e,locale:n}=we(),s=nt(),u=i,o=l,c=Ft(),{assistants:g,cloudCatalogWithStatus:h,cloudLoading:f,cloudError:b}=ut(c),y=z("local"),k=M(()=>{const A=n.value;return[...g.value].filter(I=>!I.supportedLocales?.length||I.supportedLocales.some(q=>A.startsWith(q))).sort((I,q)=>I.name.localeCompare(q.name))}),x=M(()=>[...h.value].sort((A,I)=>A.name.localeCompare(I.name))),_=z(new Set);fe(()=>[u.open,y.value],([A,I])=>{A&&I==="market"&&c.fetchCloudCatalog(n.value)},{immediate:!0});function C(A){o("configure",A)}async function $(A){Vt(A)||await c.deleteAssistant(A)}async function S(A){await c.duplicateAssistant(A)}function T(){o("create")}async function v(A){if(!_.value.has(A.id)){_.value=new Set([..._.value,A.id]);try{const I=await c.importFromCloud(A);I.success?s.success(e("ai.assistant.market.importSuccess")):s.fail(e("ai.assistant.market.importFailed"),{description:I.error})}finally{const I=new Set(_.value);I.delete(A.id),_.value=I}}}async function w(A){if(!_.value.has(A.id)){_.value=new Set([..._.value,A.id]);try{const I=await c.deleteAssistant(A.id);if(!I.success){s.fail(e("ai.assistant.market.importFailed"),{description:I.error});return}const q=await c.importFromCloud(A);q.success?s.success(e("ai.assistant.market.importSuccess")):s.fail(e("ai.assistant.market.importFailed"),{description:q.error})}finally{const I=new Set(_.value);I.delete(A.id),_.value=I}}}function E(A){o("view-config",A)}function F(){c.fetchCloudCatalog(n.value)}function D(A){return A?.length?A.map(q=>e(q==="group"?"ai.assistant.config.chatTypeGroup":"ai.assistant.config.chatTypePrivate")).join(" / "):null}return(A,I)=>{const q=_e,Y=Xe;return r(),U(Y,{open:i.open,ui:{content:"sm:max-w-xl z-50"},"onUpdate:open":I[3]||(I[3]=G=>o("update:open",G))},{content:B(()=>[a("div",ph,[a("div",hh,[a("h2",fh,d(t(e)("ai.assistant.market.title")),1),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:I[0]||(I[0]=G=>o("update:open",!1))},[p(q,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),a("div",vh,[a("button",{class:X(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",y.value==="local"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:I[1]||(I[1]=G=>y.value="local")},[le(d(t(e)("ai.assistant.market.tabs.local"))+" ",1),k.value.length?(r(),m("span",yh,d(k.value.length),1)):R("",!0)],2),a("button",{class:X(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",y.value==="market"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:I[2]||(I[2]=G=>y.value="market")},d(t(e)("ai.assistant.market.tabs.market")),3)]),Qe(a("div",null,[a("p",xh,d(t(e)("ai.assistant.market.localHint")),1),a("div",bh,[(r(!0),m(ie,null,pe(k.value,G=>(r(),m("div",{key:G.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[a("div",kh,[a("div",_h,[a("h3",wh,d(G.name),1),D(G.applicableChatTypes)?(r(),m("span",$h,d(D(G.applicableChatTypes)),1)):R("",!0),t(Vt)(G.id)?(r(),m("span",Ch,d(t(e)("ai.assistant.market.default")),1)):R("",!0)]),a("p",Sh,d(G.systemPrompt),1)]),a("div",Ih,[a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:t(e)("common.edit"),onClick:Oe(Z=>C(G.id),["stop"])},[p(q,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})],8,Th),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:t(e)("ai.assistant.market.duplicate"),onClick:Oe(Z=>S(G.id),["stop"])},[p(q,{name:"i-heroicons-document-duplicate",class:"h-4 w-4"})],8,Mh),t(Vt)(G.id)?R("",!0):(r(),m("button",{key:0,class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500 dark:hover:bg-red-900/20 dark:hover:text-red-400",title:t(e)("common.delete"),onClick:Oe(Z=>$(G.id),["stop"])},[p(q,{name:"i-heroicons-trash",class:"h-4 w-4"})],8,Ah))])]))),128))]),a("button",{type:"button",class:"mt-3 flex w-full items-center justify-center gap-1.5 rounded-xl border-2 border-dashed border-gray-300 py-4 text-sm text-gray-500 transition-colors hover:border-primary-400 hover:text-primary-600 dark:border-gray-600 dark:text-gray-400 dark:hover:border-primary-500 dark:hover:text-primary-400",onClick:T},[p(q,{name:"i-heroicons-plus",class:"h-4 w-4"}),le(" "+d(t(e)("ai.assistant.market.addAssistant")),1)]),k.value.length===0?(r(),m("div",zh,d(t(e)("ai.assistant.market.noLocal")),1)):R("",!0)],512),[[yt,y.value==="local"]]),Qe(a("div",null,[a("p",qh,d(t(e)("ai.assistant.market.marketHint")),1),t(f)?(r(),m("div",Lh,d(t(e)("ai.assistant.market.loading")),1)):t(b)?(r(),m("div",Dh,[a("p",Eh,d(t(e)("ai.assistant.market.loadFailed")),1),a("button",{type:"button",class:"mt-3 rounded-lg bg-primary-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-600",onClick:F},d(t(e)("ai.assistant.market.retry")),1)])):(r(),m("div",Bh,[(r(!0),m(ie,null,pe(x.value,G=>(r(),m("div",{key:G.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[a("div",Fh,[a("div",Rh,[a("h3",Vh,d(G.name),1),D(G.applicableChatTypes)?(r(),m("span",Oh,d(D(G.applicableChatTypes)),1)):R("",!0),t(Vt)(G.id)?(r(),m("span",Ph,d(t(e)("ai.assistant.market.default")),1)):R("",!0)]),a("p",jh,d(G.description),1)]),a("div",Nh,[G.imported?(r(),m(ie,{key:1},[a("span",Wh,d(t(e)("ai.assistant.market.imported")),1),a("button",{class:"rounded-lg px-3 py-1.5 text-xs font-medium text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-300 disabled:opacity-50",disabled:_.value.has(G.id),onClick:Z=>w(G)},d(_.value.has(G.id)?t(e)("ai.assistant.market.importing"):t(e)("ai.assistant.market.reimport")),9,Hh)],64)):(r(),m("button",{key:0,class:"rounded-lg bg-primary-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50",disabled:_.value.has(G.id),onClick:Z=>v(G)},d(_.value.has(G.id)?t(e)("ai.assistant.market.importing"):t(e)("ai.assistant.market.import")),9,Uh)),G.imported?(r(),m("button",{key:2,class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:t(e)("ai.assistant.market.viewConfig"),onClick:Oe(Z=>E(G.id),["stop"])},[p(q,{name:"i-heroicons-eye",class:"h-4 w-4"})],8,Kh)):R("",!0)])]))),128))])),!t(f)&&!t(b)&&x.value.length===0?(r(),m("div",Yh,d(t(e)("ai.assistant.market.noCatalog")),1)):R("",!0)],512),[[yt,y.value==="market"]])])]),_:1},8,["open"])}}}),Qh={class:"p-5"},Jh={class:"flex items-start gap-3"},Xh={class:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-primary-50 text-primary-600 dark:bg-primary-950/40 dark:text-primary-400"},Zh={class:"min-w-0"},ef={class:"font-semibold text-gray-900 dark:text-white"},tf={class:"mt-1.5 text-sm leading-6 text-gray-600 dark:text-gray-400"},af={class:"mt-4 rounded-lg bg-gray-50 px-3 py-2.5 dark:bg-gray-800/70"},sf={class:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300"},nf={class:"truncate"},of={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},lf={class:"mt-5 flex justify-end gap-2"},rf=ue({__name:"AssistantUpgradeModal",props:{open:{type:Boolean},backupName:{},upgrading:{type:Boolean},skipping:{type:Boolean}},emits:["skip","confirm"],setup(i,{emit:l}){const e=l,{t:n}=we();return(s,u)=>{const o=_e,c=Ue,g=Xe;return r(),U(g,{open:i.open,dismissible:!1,ui:{content:"sm:max-w-md z-50",overlay:"z-40"}},{content:B(()=>[a("div",Qh,[a("div",Jh,[a("div",Xh,[p(o,{name:"i-lucide-sparkles",class:"h-5 w-5"})]),a("div",Zh,[a("h3",ef,d(t(n)("ai.assistant.upgrade.title")),1),a("p",tf,d(t(n)("ai.assistant.upgrade.message",{backupName:i.backupName})),1)])]),a("div",af,[a("div",sf,[p(o,{name:"i-lucide-copy-check",class:"h-4 w-4 shrink-0 text-gray-400"}),a("span",nf,d(i.backupName),1)])]),a("p",of,d(t(n)("ai.assistant.upgrade.skipHint")),1),a("div",lf,[p(c,{variant:"soft",loading:i.skipping,disabled:i.upgrading,onClick:u[0]||(u[0]=h=>e("skip"))},{default:B(()=>[le(d(t(n)("ai.assistant.upgrade.skip")),1)]),_:1},8,["loading","disabled"]),p(c,{color:"primary",loading:i.upgrading,disabled:i.skipping,onClick:u[1]||(u[1]=h=>e("confirm"))},{default:B(()=>[le(d(t(n)("ai.assistant.upgrade.confirm")),1)]),_:1},8,["loading","disabled"])])])]),_:1},8,["open"])}}}),uf={class:"p-6"},cf={class:"mb-4 flex items-center justify-between"},df={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},mf={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},gf={key:0,class:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary-100 px-1 text-[10px] text-primary-600 dark:bg-primary-900/30 dark:text-primary-400"},pf={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},hf={class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},ff={class:"min-w-0 flex-1"},vf={class:"flex items-center gap-2"},yf={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},xf={class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},bf={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},kf={key:0,class:"mt-1.5 flex flex-wrap gap-1"},_f={class:"flex shrink-0 items-center gap-1.5"},wf=["title","onClick"],$f=["title","onClick"],Cf={key:0,class:"py-12 text-center text-sm text-gray-400"},Sf={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},If={key:0,class:"py-12 text-center text-sm text-gray-400"},Tf={key:1,class:"py-12 text-center"},Mf={class:"text-sm text-gray-500 dark:text-gray-400"},Af={key:2,class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},zf={class:"min-w-0 flex-1"},qf={class:"flex items-center gap-2"},Lf={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Df={class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},Ef={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},Bf={key:0,class:"mt-1.5 flex flex-wrap gap-1"},Ff={class:"flex shrink-0 items-center gap-2"},Rf=["disabled","onClick"],Vf={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},Of=["disabled","onClick"],Pf={key:3,class:"py-12 text-center text-sm text-gray-400"},jf=ue({__name:"SkillMarketModal",props:{open:{type:Boolean}},emits:["update:open","configure","create"],setup(i,{emit:l}){const{t:e,locale:n}=we(),s=nt(),u=i,o=l,c=It(),{skills:g,cloudCatalogWithStatus:h,cloudLoading:f,cloudError:b}=ut(c),y=z("local"),k=z(new Set);Re(()=>{c.setFilterContext("group",n.value)}),fe(()=>[u.open,y.value],([F,D])=>{F&&D==="market"&&(c.setFilterContext("group",n.value),c.fetchCloudCatalog())},{immediate:!0});const x=M(()=>[...g.value].sort((F,D)=>F.name.localeCompare(D.name))),_=M(()=>[...h.value].sort((F,D)=>F.name.localeCompare(D.name)));function C(F){return e(F==="group"?"ai.skill.config.chatScopeGroup":F==="private"?"ai.skill.config.chatScopePrivate":"ai.skill.config.chatScopeAll")}function $(F){o("configure",F)}async function S(F){await c.deleteSkill(F)}function T(){o("create")}async function v(F){if(!k.value.has(F.id)){k.value=new Set([...k.value,F.id]);try{const D=await c.importFromCloud(F);D.success?s.success(e("ai.skill.market.importSuccess")):s.fail(e("ai.skill.market.importFailed"),{description:D.error})}finally{const D=new Set(k.value);D.delete(F.id),k.value=D}}}async function w(F){if(!k.value.has(F.id)){k.value=new Set([...k.value,F.id]);try{const D=await c.deleteSkill(F.id);if(!D.success){s.fail(e("ai.skill.market.importFailed"),{description:D.error});return}const A=await c.importFromCloud(F);A.success?s.success(e("ai.skill.market.importSuccess")):s.fail(e("ai.skill.market.importFailed"),{description:A.error})}finally{const D=new Set(k.value);D.delete(F.id),k.value=D}}}function E(){c.fetchCloudCatalog()}return(F,D)=>{const A=_e,I=Xe;return r(),U(I,{open:i.open,ui:{content:"sm:max-w-xl z-50"},"onUpdate:open":D[3]||(D[3]=q=>o("update:open",q))},{content:B(()=>[a("div",uf,[a("div",cf,[a("h2",df,d(t(e)("ai.skill.market.title")),1),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:D[0]||(D[0]=q=>o("update:open",!1))},[p(A,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),a("div",mf,[a("button",{class:X(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",y.value==="local"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:D[1]||(D[1]=q=>y.value="local")},[le(d(t(e)("ai.skill.market.tabs.local"))+" ",1),t(g).length?(r(),m("span",gf,d(t(g).length),1)):R("",!0)],2),a("button",{class:X(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",y.value==="market"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:D[2]||(D[2]=q=>y.value="market")},d(t(e)("ai.skill.market.tabs.market")),3)]),Qe(a("div",null,[a("p",pf,d(t(e)("ai.skill.market.localHint")),1),a("div",hf,[(r(!0),m(ie,null,pe(x.value,q=>(r(),m("div",{key:q.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[a("div",ff,[a("div",vf,[a("h3",yf,d(q.name),1),a("span",xf,d(C(q.chatScope)),1)]),a("p",bf,d(q.description),1),q.tags.length?(r(),m("div",kf,[(r(!0),m(ie,null,pe(q.tags,Y=>(r(),m("span",{key:Y,class:"rounded-full bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-500 dark:bg-gray-700 dark:text-gray-400"},d(Y),1))),128))])):R("",!0)]),a("div",_f,[a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:t(e)("common.edit"),onClick:Oe(Y=>$(q.id),["stop"])},[p(A,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})],8,wf),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500 dark:hover:bg-red-900/20 dark:hover:text-red-400",title:t(e)("common.delete"),onClick:Oe(Y=>S(q.id),["stop"])},[p(A,{name:"i-heroicons-trash",class:"h-4 w-4"})],8,$f)])]))),128))]),a("button",{type:"button",class:"mt-3 flex w-full items-center justify-center gap-1.5 rounded-xl border-2 border-dashed border-gray-300 py-4 text-sm text-gray-500 transition-colors hover:border-primary-400 hover:text-primary-600 dark:border-gray-600 dark:text-gray-400 dark:hover:border-primary-500 dark:hover:text-primary-400",onClick:T},[p(A,{name:"i-heroicons-plus",class:"h-4 w-4"}),le(" "+d(t(e)("ai.skill.market.addSkill")),1)]),x.value.length===0?(r(),m("div",Cf,d(t(e)("ai.skill.market.noLocal")),1)):R("",!0)],512),[[yt,y.value==="local"]]),Qe(a("div",null,[a("p",Sf,d(t(e)("ai.skill.market.marketHint")),1),t(f)?(r(),m("div",If,d(t(e)("ai.skill.market.loading")),1)):t(b)?(r(),m("div",Tf,[a("p",Mf,d(t(e)("ai.skill.market.loadFailed")),1),a("button",{type:"button",class:"mt-3 rounded-lg bg-primary-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-600",onClick:E},d(t(e)("ai.skill.market.retry")),1)])):(r(),m("div",Af,[(r(!0),m(ie,null,pe(_.value,q=>(r(),m("div",{key:q.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[a("div",zf,[a("div",qf,[a("h3",Lf,d(q.name),1),a("span",Df,d(C(q.chatScope)),1)]),a("p",Ef,d(q.description),1),q.tags?.length?(r(),m("div",Bf,[(r(!0),m(ie,null,pe(q.tags,Y=>(r(),m("span",{key:Y,class:"rounded-full bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-500 dark:bg-gray-700 dark:text-gray-400"},d(Y),1))),128))])):R("",!0)]),a("div",Ff,[q.imported?(r(),m(ie,{key:1},[a("span",Vf,d(t(e)("ai.skill.market.imported")),1),a("button",{class:"rounded-lg px-3 py-1.5 text-xs font-medium text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-300 disabled:opacity-50",disabled:k.value.has(q.id),onClick:Y=>w(q)},d(k.value.has(q.id)?t(e)("ai.skill.market.importing"):t(e)("ai.skill.market.reimport")),9,Of)],64)):(r(),m("button",{key:0,class:"rounded-lg bg-primary-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50",disabled:k.value.has(q.id),onClick:Y=>v(q)},d(k.value.has(q.id)?t(e)("ai.skill.market.importing"):t(e)("ai.skill.market.import")),9,Rf))])]))),128))])),!t(f)&&!t(b)&&_.value.length===0?(r(),m("div",Pf,d(t(e)("ai.skill.market.noCatalog")),1)):R("",!0)],512),[[yt,y.value==="market"]])])]),_:1},8,["open"])}}}),Nf={class:"p-6"},Uf={class:"mb-4 flex items-center justify-between"},Wf={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},Hf={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},Kf={key:0,class:"flex h-64 items-center justify-center text-gray-400"},Yf={class:"mt-4 flex justify-end gap-2"},Gf=["disabled"],Qf=`---
|
|
100
|
+
`):""),Se=M(()=>!o.isStreaming&&je.value.trim().length>0);async function me(){if(Se.value)try{await navigator.clipboard.writeText(je.value),u.success(e("ai.chat.message.copy.success"))}catch(O){u.fail(e("ai.chat.message.copy.failed"),{description:String(O)})}}return(O,V)=>{const K=_e,L=Ue,P=St;return r(),m("div",{class:X(["flex items-start gap-3",[h.value&&!b.value?"flex-row-reverse":"",f.value?"justify-center":""]])},[a("div",{class:X([h.value&&!b.value?"max-w-[85%] min-w-0":"w-full min-w-0"])},[f.value?(r(),m("details",Cm,[a("summary",Sm,[p(K,{name:"i-heroicons-arrow-path",class:"h-3.5 w-3.5 shrink-0"}),a("span",null,d(t(e)("ai.chat.message.summary.label")),1),p(K,{name:"i-heroicons-chevron-right",class:"ml-auto h-3 w-3 transition-transform [[open]>&]:rotate-90"})]),a("div",Im,[a("div",{class:"prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:w.value},null,8,Tm),a("p",Mm,d(t(e)("ai.chat.message.summary.info")),1)])])):h.value?(r(),m(ie,{key:1},[b.value?(r(),m("div",Am,[Qe(a("textarea",{ref_key:"editTextareaRef",ref:k,"onUpdate:modelValue":V[0]||(V[0]=N=>y.value=N),rows:"2",class:"w-full resize-none rounded-xl border border-primary-200 bg-white/90 px-4 py-3 text-sm leading-relaxed outline-none focus:border-primary-400 dark:border-primary-400/40 dark:bg-page-dark/70",onInput:E,onKeydown:[Ge(Oe(D,["prevent"]),["esc"]),Ge(Oe(A,["ctrl","prevent"]),["enter"]),Ge(Oe(A,["meta","prevent"]),["enter"])]},null,40,zm),[[ft,y.value]]),a("div",qm,[a("label",Lm,[Qe(a("input",{"onUpdate:modelValue":V[1]||(V[1]=N=>C.value=N),type:"checkbox",class:"h-3.5 w-3.5 rounded border-gray-300 text-primary-500 focus:ring-primary-500 dark:border-gray-600"},null,512),[[In,C.value]]),le(" "+d(t(e)("ai.chat.message.edit.overwriteSubsequent")),1)]),a("div",Dm,[p(L,{size:"xs",variant:"ghost",color:"gray",onClick:D},{default:B(()=>[le(d(t(e)("common.cancel")),1)]),_:1}),p(L,{size:"xs",color:"primary",onClick:A},{default:B(()=>[le(d(t(e)("ai.chat.message.edit.submit")),1)]),_:1})])])])):(r(),m("div",Em,[a("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:w.value},null,8,Bm)]))],64)):de.value?(r(),m("div",Fm,[(r(!0),m(ie,null,pe(Z.value,(N,ae)=>(r(),m("div",{key:ae,class:X([N.type==="process"?"py-1":""])},[N.type==="process"?(r(),m("button",{key:0,type:"button",class:"inline-flex max-w-full items-center gap-1.5 text-left text-xs text-gray-400 transition-colors hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300","aria-expanded":re(ae),onClick:se=>ve(ae)},[p(K,{name:re(ae)?"i-heroicons-chevron-down":"i-heroicons-chevron-right",class:"h-3 w-3 shrink-0"},null,8,["name"]),a("span",Vm,d(j(N,ae)),1),ee(ae)?(r(),U(K,{key:0,name:"i-heroicons-arrow-path",class:"h-3 w-3 shrink-0 animate-spin"})):R("",!0)],8,Rm)):R("",!0),Qe(a("div",{class:X([N.type==="process"?"mt-2 space-y-2 pl-4":""])},[(r(!0),m(ie,null,pe(H(N),(se,Ve)=>(r(),m(ie,{key:`${ae}-${Ve}`},[se.type==="text"?(r(),m("div",Om,[a("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:I(S(se.text))},null,8,Pm),i.isStreaming&&fe(se)?(r(),m("span",jm)):R("",!0)])):se.type==="think"?(r(),m("details",Nm,[a("summary",Um,[le(d(T(se.tag))+" ",1),se.durationMs?(r(),m("span",Wm,d(v(se.durationMs)),1)):R("",!0),i.isStreaming&&fe(se)?(r(),m("span",Hm,[a("span",null,d(t(e)("ai.chat.message.think.loading")),1),V[3]||(V[3]=a("span",{class:"flex gap-0.5"},[a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1))])):R("",!0)]),a("div",Km,[se.tag==="plan_validation"&&Be(se.text)?(r(),m(ie,{key:0},[Be(se.text)?.title?(r(),m("div",Ym,d(Be(se.text)?.title),1)):R("",!0),a("ol",Gm,[(r(!0),m(ie,null,pe(Be(se.text)?.steps,(qe,Me)=>(r(),m("li",{key:Me,class:"text-gray-600 dark:text-gray-300"},[a("div",Qm,d(qe.goal),1),qe.evidenceNeeded?(r(),m("div",Jm,d(t(e)("ai.chat.message.plan.evidenceNeeded"))+": "+d(qe.evidenceNeeded),1)):R("",!0),a("div",Xm,d(t(e)("ai.chat.message.plan.suggestedTools"))+": "+d(ke(qe.suggestedTools)),1)]))),128))]),Be(se.text)?.successCriteria.length?(r(),m("div",Zm,[a("div",eg,d(t(e)("ai.chat.message.plan.successCriteria")),1),a("ul",tg,[(r(!0),m(ie,null,pe(Be(se.text)?.successCriteria,(qe,Me)=>(r(),m("li",{key:Me},d(qe),1))),128))])])):R("",!0)],64)):(r(),m("div",{key:1,innerHTML:I(se.text)},null,8,ag))])])):se.type==="skill"?(r(),m("div",sg,[p(K,{name:"i-heroicons-bolt",class:"h-3.5 w-3.5"}),a("span",null,d(t(e)("ai.skill.active.label",{name:se.skillName})),1)])):se.type==="plan"?(r(),m("details",ng,[a("summary",og,[p(K,{name:"i-heroicons-clipboard-document-list",class:"h-3.5 w-3.5 shrink-0"}),a("span",lg,d(t(e)("ai.chat.message.plan.label"))+" · "+d(se.plan.title),1)]),a("div",rg,[se.displayText?(r(),m("div",{key:0,class:"prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:I(se.displayText)},null,8,ig)):(r(),m("ol",ug,[(r(!0),m(ie,null,pe(se.plan.steps,(qe,Me)=>(r(),m("li",{key:Me,class:"text-xs leading-relaxed"},[a("div",cg,d(Me+1)+". "+d(qe.goal),1),a("div",dg,d(t(e)("ai.chat.message.plan.evidenceNeeded"))+": "+d(qe.evidenceNeeded),1),a("div",mg,d(t(e)("ai.chat.message.plan.suggestedTools"))+": "+d(ke(qe.suggestedTools)),1)]))),128))])),se.displayText?R("",!0):(r(),m("div",gg,[a("div",pg,d(t(e)("ai.chat.message.plan.successCriteria")),1),a("ul",hg,[(r(!0),m(ie,null,pe(se.plan.successCriteria,(qe,Me)=>(r(),m("li",{key:Me},d(qe),1))),128))])]))])])):se.type==="plan_draft"?(r(),m("div",fg,[a("div",vg,[p(K,{name:"i-heroicons-clipboard-document-list",class:"h-3.5 w-3.5 shrink-0"}),a("span",null,d(t(e)("ai.chat.message.plan.label")),1),i.isStreaming?(r(),m("span",yg,[...V[4]||(V[4]=[a("span",{class:"flex gap-0.5"},[a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1)])])):R("",!0)]),a("div",{class:"mt-2 prose prose-sm dark:prose-invert max-w-none text-xs leading-relaxed text-gray-600 dark:text-gray-300",innerHTML:I(se.text)},null,8,xg)])):se.type==="chart"?(r(),U(Hd,{key:5,chart:se.chart},null,8,["chart"])):se.type==="evidence"?(r(),U(fm,{key:6,evidence:se.evidence},null,8,["evidence"])):se.type==="tool"&&Q(se.tool)?(r(),m("details",bg,[a("summary",kg,[a("div",{class:X(["flex w-fit items-center gap-1.5 rounded-lg bg-gray-50 px-2.5 py-1 text-xs text-gray-500 transition-colors hover:bg-gray-100 dark:bg-gray-800/30 dark:text-gray-400/80 dark:hover:bg-gray-800/60",[se.tool.status==="error"?"bg-red-50 text-red-600 dark:bg-red-900/20 dark:text-red-400":""]])},[p(K,{name:se.tool.status==="error"?"i-heroicons-exclamation-circle":"i-heroicons-wrench-screwdriver",class:"h-3.5 w-3.5 shrink-0"},null,8,["name"]),a("div",_g,[a("span",null,d(be(se.tool)),1),Pe(se.tool)?(r(),m("span",wg,d(Pe(se.tool)),1)):R("",!0),a("span",$g," · "+d(t(e)("ai.chat.message.toolResult.view")),1)]),p(K,{name:"i-heroicons-chevron-right",class:"h-3 w-3 shrink-0 transition-transform [[open]>&]:rotate-90"})],2)]),a("div",Cg,[a("div",Sg,[a("span",Ig,d(t(e)("ai.chat.message.toolResult.title")),1),p(L,{size:"xs",variant:"ghost",color:"primary",icon:"i-heroicons-document-duplicate",title:t(e)("ai.chat.message.toolResult.copy"),onClick:Oe(qe=>ge(se.tool),["stop"])},null,8,["title","onClick"])]),J(se.tool)?(r(),m("div",Tg,d(t(e)("ai.chat.message.toolResult.displayTruncated")),1)):R("",!0),a("pre",Mg,d(oe(se.tool)),1)])])):se.type==="tool"?(r(),m("div",{key:8,class:X(["flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs transition-colors",[se.tool.status==="running"?"bg-gray-100 text-gray-600 dark:bg-gray-800/50 dark:text-gray-400":se.tool.status==="done"?"bg-gray-50 text-gray-500 dark:bg-gray-800/30 dark:text-gray-400/80":"bg-red-50 text-red-600 dark:bg-red-900/20 dark:text-red-400"]])},[p(K,{name:se.tool.status==="running"?"i-heroicons-arrow-path":se.tool.status==="done"?"i-heroicons-wrench-screwdriver":"i-heroicons-exclamation-circle",class:X(["h-3.5 w-3.5 shrink-0",[se.tool.status==="running"?"animate-spin":""]])},null,8,["name","class"]),a("div",Ag,[a("span",null,d(be(se.tool)),1),Pe(se.tool)?(r(),m("span",zg,d(Pe(se.tool)),1)):R("",!0),se.tool.status==="done"&&se.tool.durationMs?(r(),m("span",qg," · "+d(v(se.tool.durationMs)),1)):R("",!0)])],2)):se.type==="error"?(r(),U(Sd,{key:9,error:se.error},null,8,["error"])):R("",!0)],64))),128))],2),[[yt,N.type!=="process"||re(ae)]])],2))),128)),i.isStreaming&&q.value.length>0&&q.value[q.value.length-1].type==="tool"?(r(),m("div",Lg,[V[5]||(V[5]=a("span",{class:"flex gap-1"},[a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1)),a("span",null,d(t(e)("ai.chat.message.generating")),1)])):R("",!0)])):(r(),m("div",Dg,[a("div",{class:"prose prose-sm dark:prose-invert max-w-none leading-relaxed",innerHTML:w.value},null,8,Eg),i.isStreaming?(r(),m("span",Bg)):R("",!0)])),!f.value&&!i.isStreaming?(r(),m("div",{key:4,class:X(["mt-1 flex items-center gap-2 px-1",[h.value?"flex-row-reverse":""]])},[a("span",Fg,d(g.value),1),p(P,{text:t(e)("ai.chat.message.copy.tooltip"),class:"no-capture"},{default:B(()=>[p(L,{icon:"i-heroicons-document-duplicate",variant:"ghost",color:"primary",size:"xs",disabled:!Se.value,onClick:me},null,8,["disabled"])]),_:1},8,["text"]),x.value?(r(),U(P,{key:0,text:t(e)("ai.chat.message.edit.tooltip"),class:"no-capture"},{default:B(()=>[p(L,{icon:"i-heroicons-pencil-square",variant:"ghost",color:"primary",size:"xs",onClick:F})]),_:1},8,["text"])):R("",!0),_.value?(r(),U(P,{key:1,text:t(e)("ai.chat.message.fork.tooltip"),class:"no-capture"},{default:B(()=>[p(L,{icon:"i-heroicons-arrow-top-right-on-square",variant:"ghost",color:"primary",size:"xs",onClick:V[2]||(V[2]=N=>c("fork",i.messageId))})]),_:1},8,["text"])):R("",!0),i.showCaptureButton&&!h.value&&!i.isStreaming?(r(),U(Lt,{key:2,size:"xs",type:"element","target-selector":".qa-pair","markdown-fix":"","capture-frame":"","progressive-narrowing":!0})):R("",!0)],2)):R("",!0)],2)],2)}}}),Rg={key:0,class:"absolute bottom-full left-0 z-20 mb-1.5 w-[240px] max-w-[calc(100vw-2rem)]"},Vg={class:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-overlay dark:border-gray-700 dark:bg-page-dark"},Og={class:"flex items-center justify-between border-b border-gray-100 px-2.5 py-1.5 dark:border-gray-800"},Pg={class:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400"},jg=["title"],Ng={key:0,class:"px-3 py-4 text-center text-xs text-gray-500 dark:text-gray-400"},Ug=["onMouseenter","onClick"],Wg={class:"min-w-0 flex-1"},Hg={class:"flex items-center gap-1.5"},Kg={class:"truncate text-xs font-medium"},Yg={class:"mt-0.5 line-clamp-2 text-[11px] leading-4 text-gray-500 dark:text-gray-400"},Gg={key:2,class:"px-3 py-4 text-center"},Qg={class:"text-sm font-medium text-gray-700 dark:text-gray-200"},Jg={class:"mt-1 text-xs leading-5 text-gray-500 dark:text-gray-400"},Xg=ue({__name:"MemberMentionMenu",props:{visible:{type:Boolean},members:{},highlightIndex:{},loading:{type:Boolean}},emits:["select","close","highlight"],setup(i,{emit:l}){const{t:e}=we(),n=i,s=l,u=z(null);return he(()=>[n.visible,n.highlightIndex,n.members.length],async([o,c])=>{if(!o||!u.value)return;await De(),u.value.querySelectorAll("[data-mention-item]")[c]?.scrollIntoView({block:"nearest"})}),(o,c)=>{const g=_e;return r(),U(vt,{name:"mention-menu"},{default:B(()=>[i.visible?(r(),m("div",Rg,[a("div",Vg,[a("div",Og,[a("div",Pg,[a("span",null,d(t(e)("ai.chat.input.mentionHint")),1)]),a("button",{type:"button",class:"rounded-md p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:t(e)("common.close"),onClick:c[0]||(c[0]=h=>s("close"))},[p(g,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5"})],8,jg)]),n.loading?(r(),m("div",Ng,d(t(e)("common.loading")),1)):n.members.length>0?(r(),m("div",{key:1,ref_key:"listRef",ref:u,class:"max-h-72 overflow-y-auto p-1.5"},[(r(!0),m(ie,null,pe(n.members,(h,f)=>(r(),m("button",{key:`${h.memberId}-${h.insertName}`,type:"button","data-mention-item":"",class:X(["flex w-full items-start justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left transition-colors",f===n.highlightIndex?"bg-primary-50 text-gray-900 dark:bg-primary-950/30 dark:text-gray-100":"text-gray-700 hover:bg-gray-50 dark:text-gray-200 dark:hover:bg-gray-800/80"]),onMouseenter:b=>s("highlight",f),onClick:b=>s("select",h)},[a("div",Wg,[a("div",Hg,[a("span",Kg,"@"+d(h.insertName),1)]),a("p",Yg,d(h.subtitle),1)])],42,Ug))),128))],512)):(r(),m("div",Gg,[a("p",Qg,d(t(e)("ai.chat.input.mentionEmpty")),1),a("p",Jg,d(t(e)("ai.chat.input.mentionEmptyHint")),1)]))])])):R("",!0)]),_:1})}}}),Zg=dt(Xg,[["__scopeId","data-v-7bc45150"]]),ep={key:0,class:"absolute bottom-full left-0 z-20 mb-1.5 w-[240px] max-w-[calc(100vw-2rem)]"},tp={class:"overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-overlay dark:border-gray-700 dark:bg-page-dark"},ap={class:"flex items-center justify-between border-b border-gray-100 px-2.5 py-1.5 dark:border-gray-800"},sp={class:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400"},np=["title"],op=["onMouseenter","onClick"],lp={class:"min-w-0 flex-1"},rp={class:"flex items-center gap-1.5"},ip={class:"truncate text-xs font-medium"},up={class:"mt-0.5 line-clamp-1 text-xs leading-4 text-gray-500 dark:text-gray-400"},cp={key:1,class:"px-3 py-4 text-center"},dp={class:"text-sm font-medium text-gray-700 dark:text-gray-200"},mp={class:"mt-1 text-xs leading-5 text-gray-500 dark:text-gray-400"},gp={key:0,class:"absolute top-1/2 left-full ml-1 flex max-h-[min(348px,calc(100vh-10rem))] w-[300px] -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-overlay dark:border-gray-700 dark:bg-page-dark"},pp={class:"border-b border-gray-100 px-3 py-2 dark:border-gray-800"},hp={class:"truncate text-sm font-medium text-gray-900 dark:text-gray-100"},fp={class:"mt-0.5 text-xs leading-5 text-gray-500 dark:text-gray-400"},vp={key:0,class:"mt-1 flex items-start gap-1.5 text-[11px] leading-4"},yp={class:"shrink-0 font-medium text-gray-600 dark:text-gray-300"},xp={class:"line-clamp-1 min-w-0 flex-1 text-gray-500 dark:text-gray-400"},bp={key:1,class:"mt-0.5 flex items-start gap-1.5 text-[11px] leading-4"},kp={class:"shrink-0 font-medium text-gray-600 dark:text-gray-300"},_p={class:"line-clamp-1 min-w-0 flex-1 text-gray-500 dark:text-gray-400"},wp={class:"min-h-0 flex-1 overflow-y-auto px-3 py-2"},$p={key:0,class:"text-xs text-gray-400 dark:text-gray-500"},Cp=["innerHTML"],Sp={key:2,class:"text-xs leading-relaxed text-gray-400 dark:text-gray-500"},Ip=ue({__name:"SlashCommandMenu",props:{visible:{type:Boolean},skills:{},highlightIndex:{},activeSkillId:{}},emits:["select","close","manage","highlight"],setup(i,{emit:l}){const{t:e,te:n}=we(),s=It(),u=i,o=l,c=z({}),g=z(""),h=z(!1),f=z(null),b=new Aa({html:!1,breaks:!0,linkify:!0,typographer:!0}),y=M(()=>{if(u.skills.length===0)return null;const $=Math.min(u.highlightIndex,u.skills.length-1);return u.skills[$]??null}),k=M(()=>g.value?b.render(g.value):"");function x($){const I=`ai.assistant.builtinToolDesc.${$}`;return n(I)?e(I):$}const _=M(()=>y.value?.tags.join(" / ")||""),C=M(()=>y.value?.tools.map($=>x($)).join(" / ")||"");return he(()=>[u.visible,y.value?.id],async([$,I])=>{if(!$||!I){g.value="",h.value=!1;return}if(c.value[I]){g.value=c.value[I],h.value=!1;return}h.value=!0;const v=(await s.getSkillConfig(I))?.prompt?.trim()||"";c.value={...c.value,[I]:v},y.value?.id===I&&(g.value=v,h.value=!1)},{immediate:!0}),he(()=>[u.visible,u.highlightIndex,u.skills.length],async([$,I])=>{if(!$||!f.value)return;await De(),f.value.querySelectorAll("[data-slash-item]")[I]?.scrollIntoView({block:"nearest"})}),($,I)=>{const T=_e;return r(),U(vt,{name:"slash-menu"},{default:B(()=>[i.visible?(r(),m("div",ep,[a("div",tp,[a("div",ap,[a("div",sp,[a("span",null,d(t(e)("ai.chat.input.slashHint")),1)]),a("button",{type:"button",class:"rounded-md p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:t(e)("common.close"),onClick:I[0]||(I[0]=v=>o("close"))},[p(T,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5"})],8,np)]),u.skills.length>0?(r(),m("div",{key:0,ref_key:"listRef",ref:f,class:"max-h-72 overflow-y-auto p-1.5"},[(r(!0),m(ie,null,pe(u.skills,(v,w)=>(r(),m("button",{key:v.id,type:"button","data-slash-item":"",class:X(["flex w-full items-start justify-between gap-1.5 rounded-lg px-2.5 py-1.5 text-left transition-colors",w===u.highlightIndex?"bg-primary-50 text-gray-900 dark:bg-primary-950/30 dark:text-gray-100":"text-gray-700 hover:bg-gray-50 dark:text-gray-200 dark:hover:bg-gray-800/80"]),onMouseenter:E=>o("highlight",w),onClick:E=>o("select",v)},[a("div",lp,[a("div",rp,[a("span",ip,d(v.name),1),u.activeSkillId===v.id?(r(),U(T,{key:0,name:"i-heroicons-check-circle-20-solid",class:"h-3.5 w-3.5 shrink-0 text-primary-500"})):R("",!0)]),a("p",up,d(v.description),1)])],42,op))),128))],512)):(r(),m("div",cp,[a("p",dp,d(t(e)("ai.chat.input.slashEmpty")),1),a("p",mp,d(t(e)("ai.chat.input.slashEmptyHint")),1)])),a("button",{type:"button",class:"flex w-full items-center justify-between border-t border-gray-100 px-2.5 py-1.5 text-xs text-gray-600 transition-colors hover:bg-gray-50 hover:text-gray-900 dark:border-gray-800 dark:text-gray-300 dark:hover:bg-gray-800/80 dark:hover:text-gray-100",onClick:I[1]||(I[1]=v=>o("manage"))},[a("span",null,d(t(e)("ai.chat.input.manageSkills")),1),p(T,{name:"i-heroicons-arrow-top-right-on-square",class:"h-3.5 w-3.5"})])]),u.skills.length>0&&y.value?(r(),m("div",gp,[a("div",pp,[a("p",hp,d(y.value.name),1),a("p",fp,d(y.value.description),1),_.value?(r(),m("div",vp,[a("span",yp,d(t(e)("ai.chat.input.previewTagsLabel")),1),a("span",xp,d(_.value),1)])):R("",!0),C.value?(r(),m("div",bp,[a("span",kp,d(t(e)("ai.chat.input.previewToolsLabel")),1),a("span",_p,d(C.value),1)])):R("",!0)]),a("div",wp,[h.value?(r(),m("div",$p,d(t(e)("common.loading")),1)):k.value?(r(),m("div",{key:1,class:"prose prose-sm max-w-none text-xs leading-5 dark:prose-invert prose-headings:mb-1.5 prose-headings:mt-2 prose-p:my-1.5 prose-ul:my-1.5 prose-ol:my-1.5",innerHTML:k.value},null,8,Cp)):(r(),m("div",Sp,d(t(e)("ai.chat.input.previewUnavailable")),1))])])):R("",!0)])):R("",!0)]),_:1})}}}),Tp=dt(Ip,[["__scopeId","data-v-0f67bc21"]]),Mp={class:"shrink-0 pt-2 pb-2"},Ap={class:"relative px-4 pt-2.5 pb-2.5"},zp={class:"flex items-start gap-2 pr-10"},qp={key:0,class:"inline-flex max-w-[180px] shrink-0 items-center rounded-md bg-primary-50 px-2 text-sm leading-6 font-medium text-primary-700 dark:bg-primary-500/10 dark:text-primary-400"},Lp={class:"truncate"},Dp=["disabled","placeholder"],Ep=["disabled","title"],Bp=ue({__name:"AIChatInput",props:{sessionId:{},disabled:{type:Boolean},status:{},chatType:{}},emits:["send","stop","manageSkills","skillActivated"],setup(i,{expose:l,emit:e}){const{t:n}=we(),s=i,u=e,o=It(),{compatibleSkills:c,activeSkill:g,activeSkillId:h,isLoaded:f}=ut(o),b=z(null),y=z(null),k=z(""),x=z([]),_=z([]),C=z(!1),$=z(!1),I=z(""),T=z(0),v=z(!1),w=z(""),E=z(0),F=z(null),D=z(!1),A=z(null),S=z(null),q=z(!1),Y=M(()=>k.value.trim().length>0&&!s.disabled),G=M(()=>g.value&&k.value.trim().length===0?n("ai.chat.input.placeholderWithActiveSkill",{name:g.value.name}):n("ai.chat.input.placeholderWithSlash")),Z=M(()=>s.status==="streaming"?"":Y.value?n("ai.chat.input.send"):g.value?n("ai.chat.input.needMoreThanSkill"):n("ai.chat.input.needQuestion")),ce=M(()=>{const L=new Map;return x.value.forEach(P=>{const N=P.groupNickname||P.accountName||P.platformId;L.set(N,(L.get(N)??0)+1)}),x.value.map(P=>{const N=P.groupNickname||P.accountName||P.platformId,ae=(L.get(N)??0)>1?`${N}·${P.platformId}`:N,se=[P.platformId];return P.aliases.length>0&&se.push(P.aliases.join(" / ")),{memberId:P.id,platformId:P.platformId,displayName:N,aliases:[...P.aliases],mentionText:`@${ae}`,insertName:ae,subtitle:se.join(" · "),searchText:[N,P.groupNickname||"",P.accountName||"",P.platformId,ae,P.aliases.join(" ")].join(" ").toLocaleLowerCase()}})}),ne=M(()=>{const L=I.value.trim().toLocaleLowerCase();return L?c.value.filter(P=>[P.name,P.description,P.tags.join(" ")].join(" ").toLocaleLowerCase().includes(L)):c.value}),H=M(()=>{const L=w.value.trim().toLocaleLowerCase();return L?ce.value.filter(P=>P.searchText.includes(L)):ce.value});function W(){if(!y.value)return;const L=y.value;L.style.height="auto";const P=192,N=Math.min(L.scrollHeight,P);L.style.height=`${N}px`,L.style.overflowY=L.scrollHeight>P?"auto":"hidden"}function re(){y.value?.focus()}async function ve(){if(!s.sessionId){x.value=[];return}C.value=!0;try{const L=await Ke().getMembers(s.sessionId);x.value=[...L].sort((P,N)=>N.messageCount-P.messageCount)}catch(L){console.error("加载 AI @ 成员列表失败:",L),x.value=[]}finally{C.value=!1}}function fe(){$.value=!1,I.value="",T.value=0}function ee(){v.value=!1,w.value="",E.value=0,F.value=null}function te(){/^\s*\/([^\n]*)$/.test(k.value)&&(A.value=k.value),fe()}function j(){F.value&&(S.value=F.value.rawToken),ee()}function de(L){if(s.disabled){fe();return}A.value&&A.value!==L&&(A.value=null);const P=L.match(/^\s*\/([^\n]*)$/);if(!P){fe();return}const N=!$.value||I.value!==P[1];if(I.value=P[1],A.value===L){$.value=!1;return}$.value=!0,N&&(T.value=0)}function be(){const L=y.value,P=k.value.length;return{start:L?.selectionStart??P,end:L?.selectionEnd??P}}function xe(L){const{start:P,end:N}=be();if(P!==N)return null;const ae=L.slice(0,P),se=ae.match(/@([^\s@]*)$/);if(!se)return null;const Ve=se[1],qe=ae.length-Ve.length-1;return{start:qe,end:P,rawToken:ae.slice(qe),query:Ve}}function oe(L){if(s.disabled||$.value){ee();return}const P=xe(L);if(S.value&&S.value!==P?.rawToken&&(S.value=null),!P){ee();return}const N=!v.value||w.value!==P.query||F.value?.rawToken!==P.rawToken;if(w.value=P.query,F.value={start:P.start,end:P.end,rawToken:P.rawToken},S.value===P.rawToken){v.value=!1;return}v.value=!0,N&&(E.value=0)}function Q(L){if(de(L),$.value){ee();return}oe(L)}function J(L){_.value=_.value.filter(P=>L.includes(P.mentionText))}function ge(){const{start:L,end:P}=be();if(L!==P||L===0)return!1;const N=[...new Set(_.value.map(ae=>ae.mentionText))].sort((ae,se)=>se.length-ae.length);for(const ae of N){let se=k.value.indexOf(ae);for(;se!==-1;){const Ve=se,qe=se+ae.length,Me=k.value[qe]===" "?qe+1:qe;if(L>Ve&&L<=Me)return q.value=!0,k.value=k.value.slice(0,Ve)+k.value.slice(Me),S.value=null,De(()=>{W(),re(),y.value?.setSelectionRange(Ve,Ve),q.value=!1,Q(k.value)}),!0;se=k.value.indexOf(ae,se+ae.length)}}return!1}function ke(){o.activateSkill(null),De(re)}function $e(){s.disabled||(h.value&&o.activateSkill(null),q.value=!0,k.value="/",A.value=null,De(()=>{W(),re(),y.value?.setSelectionRange(1,1),q.value=!1,Q(k.value)}))}function Le(L){s.disabled||(q.value=!0,k.value=L,A.value=null,De(()=>{W(),re();const P=k.value.length;y.value?.setSelectionRange(P,P),q.value=!1,Q(k.value)}))}function Be(L){if(s.disabled||!F.value)return;const P=k.value.slice(0,F.value.start),N=k.value.slice(F.value.end),ae=`@${L.insertName}`,se=`${P}${ae} ${N}`;_.value=[..._.value.filter(Ve=>Ve.memberId!==L.memberId),{memberId:L.memberId,platformId:L.platformId,displayName:L.displayName,aliases:[...L.aliases],mentionText:ae}],q.value=!0,k.value=se,S.value=null,ee(),De(()=>{const Ve=P.length+ae.length+1;W(),re(),y.value?.setSelectionRange(Ve,Ve),q.value=!1,Q(k.value)})}function Te(){Y.value&&(u("send",{content:k.value.trim(),mentionedMembers:[..._.value]}),k.value="",A.value=null,S.value=null,_.value=[],ee(),h.value&&o.activateSkill(null))}function Pe(L){s.disabled||(o.activateSkill(L.id),u("skillActivated",L),k.value="",A.value=null,fe(),De(()=>{re()}))}function je(){te(),u("manageSkills")}function Se(L){if(!ne.value.length)return;const P=ne.value.length;T.value=(T.value+L+P)%P}function me(L){if(!H.value.length)return;const P=H.value.length;E.value=(E.value+L+P)%P}function O(L){if(L.key==="Backspace"&&k.value.length===0&&h.value){L.preventDefault(),ke();return}if(L.key==="Backspace"&&ge()){L.preventDefault();return}if(v.value){if(L.key==="ArrowDown"){L.preventDefault(),me(1);return}if(L.key==="ArrowUp"){L.preventDefault(),me(-1);return}if(L.key==="Escape"){L.preventDefault(),j();return}if(L.key==="Enter"&&!L.shiftKey&&!D.value||L.key==="Tab"){L.preventDefault();const P=H.value[E.value];P&&Be(P);return}}if($.value){if(L.key==="ArrowDown"){L.preventDefault(),Se(1);return}if(L.key==="ArrowUp"){L.preventDefault(),Se(-1);return}if(L.key==="Escape"){L.preventDefault(),te();return}if(L.key==="Enter"&&!L.shiftKey&&!D.value||L.key==="Tab"){L.preventDefault();const P=ne.value[T.value];P&&Pe(P);return}}L.key==="Enter"&&!L.shiftKey&&!D.value&&(L.preventDefault(),Te())}function V(L){if(!$.value&&!v.value||!b.value)return;const P=L.target;P instanceof Node&&!b.value.contains(P)&&(te(),j())}function K(){q.value||Q(k.value)}return he(()=>s.chatType,L=>{o.setFilterContext(L)},{immediate:!0}),he(k,async L=>{J(L),q.value||Q(L),await De(),W()}),he(ne,L=>{if(L.length===0){T.value=0;return}T.value>=L.length&&(T.value=L.length-1)},{immediate:!0}),he(H,L=>{if(L.length===0){E.value=0;return}E.value>=L.length&&(E.value=L.length-1)},{immediate:!0}),he(()=>s.disabled,L=>{L&&(te(),j())}),he(()=>s.sessionId,()=>{_.value=[],ee(),ve()},{immediate:!0}),Re(async()=>{f.value||await o.loadSkills(),await De(),W(),document.addEventListener("mousedown",V)}),Xt(()=>{document.removeEventListener("mousedown",V)}),l({fillInput:Le,openSkillSelector:$e}),(L,P)=>{const N=_e;return r(),m("div",Mp,[a("div",{ref_key:"rootRef",ref:b,class:"relative w-full max-w-4xl mx-auto"},[p(Tp,{visible:$.value,skills:ne.value,"highlight-index":T.value,"active-skill-id":t(h),onSelect:Pe,onClose:te,onManage:je,onHighlight:P[0]||(P[0]=ae=>T.value=ae)},null,8,["visible","skills","highlight-index","active-skill-id"]),p(Zg,{visible:v.value,members:H.value,"highlight-index":E.value,loading:C.value,onSelect:Be,onClose:j,onHighlight:P[1]||(P[1]=ae=>E.value=ae)},null,8,["visible","members","highlight-index","loading"]),a("div",{class:X(["flex flex-col overflow-hidden rounded-2xl bg-white shadow-[0_2px_14px_rgba(0,0,0,0.04)] ring-1 ring-gray-200/60 transition-all dark:bg-page-dark dark:ring-white/5",s.disabled?"bg-gray-50/50 dark:bg-page-dark/50":"focus-within:ring-primary-500/40 focus-within:shadow-[0_4px_20px_rgba(0,0,0,0.08)] dark:focus-within:ring-primary-500/40"])},[a("div",Ap,[a("div",zp,[t(g)?(r(),m("div",qp,[a("span",Lp,"/"+d(t(g).name),1)])):R("",!0),Qe(a("textarea",{ref_key:"textareaRef",ref:y,"onUpdate:modelValue":P[2]||(P[2]=ae=>k.value=ae),rows:"2",class:"min-h-[48px] min-w-0 flex-1 resize-none border-0 bg-transparent px-0 py-0 text-sm leading-6 text-gray-900 outline-none placeholder:text-gray-400 disabled:cursor-not-allowed disabled:text-gray-400 dark:text-gray-100 dark:placeholder:text-gray-500 dark:disabled:text-gray-500",disabled:s.disabled,placeholder:G.value,onKeydown:O,onClick:K,onKeyup:K,onSelect:K,onCompositionstart:P[3]||(P[3]=ae=>D.value=!0),onCompositionend:P[4]||(P[4]=ae=>D.value=!1)},null,40,Dp),[[ft,k.value]])]),s.status==="streaming"?(r(),m("button",{key:0,type:"button",class:"absolute right-3 bottom-2 flex h-7 w-7 items-center justify-center rounded-full bg-primary-500 text-white shadow-sm transition-colors hover:bg-primary-600",onClick:P[5]||(P[5]=ae=>u("stop"))},[p(N,{name:"i-heroicons-stop-16-solid",class:"h-3.5 w-3.5"})])):(r(),m("button",{key:1,type:"button",class:X(["absolute right-3 bottom-2 flex h-7 w-7 items-center justify-center rounded-full transition-all duration-200",Y.value?"bg-primary-500 text-white hover:bg-primary-600 shadow-sm":"bg-gray-100 text-gray-400 dark:bg-gray-800 dark:text-gray-500"]),disabled:!Y.value,title:Z.value,onClick:Te},[p(N,{name:"i-heroicons-arrow-up-20-solid",class:"h-4 w-4"})],10,Ep))])],2)],512)])}}}),Fp={key:0,class:"flex w-fit items-center gap-1.5 rounded-lg bg-gray-100 px-2.5 py-1 text-xs transition-colors dark:bg-gray-800/50"},Rp={class:"font-medium text-gray-600 dark:text-gray-400"},Vp={key:1,class:"flex items-start gap-3"},Op={class:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-linear-to-br from-pink-500 to-pink-600"},Pp={class:"rounded-2xl rounded-tl-sm bg-gray-100 px-4 py-3 dark:bg-gray-800"},jp={key:0,class:"space-y-2"},Np={class:"flex items-center gap-2"},Up={key:0,class:"flex gap-1"},Wp={key:1,class:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400"},Hp={key:0,class:"flex flex-wrap gap-1"},Kp={class:"text-xs text-gray-400"},Yp={key:1,class:"flex items-center gap-2"},Gp={class:"text-sm text-gray-600 dark:text-gray-400"},Qp=ue({__name:"AIThinkingIndicator",props:{currentToolStatus:{},toolsUsed:{},agentStatus:{}},setup(i){const{t:l,te:e}=we();function n(o,c){const g=`ai.assistant.builtinToolDesc.${o}`;return e(g)?l(g):c||o}const s=i,u=M(()=>s.agentStatus?.phase==="compressing");return(o,c)=>{const g=_e;return u.value?(r(),m("div",Fp,[p(g,{name:"i-heroicons-arrow-path",class:"h-3.5 w-3.5 shrink-0 animate-spin text-gray-600 dark:text-gray-400"}),a("span",Rp,d(t(l)("ai.chat.thinking.compressing")),1)])):(r(),m("div",Vp,[a("div",Op,[p(g,{name:"i-heroicons-sparkles",class:"h-4 w-4 text-white"})]),a("div",Pp,[i.currentToolStatus?(r(),m("div",jp,[a("div",Np,[a("span",{class:X(["inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium",[i.currentToolStatus.status==="running"?"bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-300":i.currentToolStatus.status==="done"?"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300":"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300"]])},[p(g,{name:i.currentToolStatus.status==="running"?"i-heroicons-cog-6-tooth":i.currentToolStatus.status==="done"?"i-heroicons-check-circle":"i-heroicons-x-circle",class:X(["h-3 w-3",{"animate-spin":i.currentToolStatus.status==="running"}])},null,8,["name","class"]),le(" "+d(n(i.currentToolStatus.name,i.currentToolStatus.displayName)),1)],2),i.currentToolStatus.status==="running"?(r(),m("span",Up,[...c[0]||(c[0]=[a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:0ms]"},null,-1),a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:150ms]"},null,-1),a("span",{class:"h-1.5 w-1.5 animate-bounce rounded-full bg-pink-500 [animation-delay:300ms]"},null,-1)])])):i.currentToolStatus.status==="done"?(r(),m("span",Wp,[a("span",null,d(t(l)("ai.chat.thinking.processingResult")),1),c[1]||(c[1]=a("span",{class:"flex gap-1"},[a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:0ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:150ms]"}),a("span",{class:"h-1 w-1 animate-bounce rounded-full bg-gray-400 [animation-delay:300ms]"})],-1))])):R("",!0)]),i.toolsUsed.length>1?(r(),m("div",Hp,[a("span",Kp,d(t(l)("ai.chat.thinking.called")),1),(r(!0),m(ie,null,pe(i.toolsUsed.slice(0,-1),h=>(r(),m("span",{key:h,class:"inline-flex items-center gap-1 rounded-full bg-gray-200 px-2 py-0.5 text-xs text-gray-600 dark:bg-gray-700 dark:text-gray-400"},[p(g,{name:"i-heroicons-check",class:"h-3 w-3 text-green-500"}),le(" "+d(n(h)),1)]))),128))])):R("",!0)])):(r(),m("div",Yp,[a("span",Gp,d(t(l)("ai.chat.thinking.analyzing")),1),c[2]||(c[2]=a("span",{class:"flex gap-1"},[a("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:0ms]"}),a("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:150ms]"}),a("span",{class:"h-2 w-2 animate-bounce rounded-full bg-pink-500 [animation-delay:300ms]"})],-1))]))])]))}}}),Jp={class:"relative z-20 flex items-center justify-between"},Xp={class:"flex items-center gap-1"},Zp=["disabled"],e0={class:"max-w-[160px] truncate"},t0=["title"],a0={class:"w-40 py-1"},s0={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},n0=["onClick"],o0={class:"flex items-center gap-1"},l0=["title"],r0={class:"hidden shrink-0 items-center gap-1.5 rounded-md px-1.5 py-1 text-xs text-gray-400 dark:text-gray-500 md:flex"},i0={class:"h-1.5 w-10 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},u0={class:"text-[10px]"},c0={class:"space-y-0.5 whitespace-nowrap text-xs"},d0={key:0},m0=["title","disabled"],g0={class:"hidden xl:inline"},p0=["title","disabled"],h0={class:"hidden xl:inline"},f0=ue({__name:"ChatStatusBar",props:{sessionTokenUsage:{},agentStatus:{},currentAIChatId:{},currentMessages:{},fallbackTitle:{},estimatedContextTokens:{}},setup(i){const{t:l}=we(),e=nt(),n=bt(),s=i,u=ka(),o=Mn(),{aiGlobalSettings:c}=ut(u),{defaultAssistantConfig:g,isLoading:h}=ut(o),f=z(!1),b=M(()=>s.agentStatus?l(`ai.chat.statusBar.agent.phase.${s.agentStatus.phase}`):""),y=M(()=>s.agentStatus?l(`ai.chat.statusBar.agent.phaseShort.${s.agentStatus.phase}`):""),k=M(()=>{if(!s.agentStatus)return"text-gray-500 bg-gray-100 dark:bg-gray-800 dark:text-gray-300";switch(s.agentStatus.phase){case"compressing":return"text-purple-600 bg-purple-50 dark:bg-purple-900/30 dark:text-purple-300";case"tool_running":return"text-indigo-600 bg-indigo-50 dark:bg-indigo-900/30 dark:text-indigo-300";case"thinking":return"text-blue-600 bg-blue-50 dark:bg-blue-900/30 dark:text-blue-300";case"responding":return"text-emerald-600 bg-emerald-50 dark:bg-emerald-900/30 dark:text-emerald-300";case"completed":return"text-green-600 bg-green-50 dark:bg-green-900/30 dark:text-green-300";case"aborted":return"text-amber-600 bg-amber-50 dark:bg-amber-900/30 dark:text-amber-300";case"error":return"text-red-600 bg-red-50 dark:bg-red-900/30 dark:text-red-300";default:return"text-gray-500 bg-gray-100 dark:bg-gray-800 dark:text-gray-300"}});function x(te){return Number.isFinite(te)?new Intl.NumberFormat().format(Math.max(0,Math.round(te))):"0"}function _(te){const j=Math.max(0,Math.round(te));return j>=1e6?`${(j/1e6).toFixed(1).replace(/\.0$/,"")}M`:j>=1e3?`${(j/1e3).toFixed(1).replace(/\.0$/,"")}k`:String(j)}const C=M(()=>x(s.sessionTokenUsage.totalTokens)),$=M(()=>_(s.sessionTokenUsage.totalTokens)),I=M(()=>s.sessionTokenUsage.cacheReadTokens>0),T=M(()=>_(s.sessionTokenUsage.cacheReadTokens)),v=M(()=>s.agentStatus?.contextTokens?s.agentStatus.contextTokens:s.estimatedContextTokens&&s.estimatedContextTokens>0?s.estimatedContextTokens:0),w=M(()=>{const te=g.value,j=o.defaultAssistant?.modelId||te?.model;return!te||!j?128e3:(o.getModelById(te.provider,j)||o.findModelAcrossProviders(j))?.contextWindow??128e3}),E=M(()=>v.value<=0||w.value<=0?0:Math.min(100,Math.round(v.value/w.value*100))),F=M(()=>{const te=E.value;return te>=80?"bg-red-500":te>=60?"bg-amber-500":"bg-emerald-500"}),D=M(()=>s.agentStatus?[`${l("ai.chat.statusBar.agent.label")}: ${b.value}`,`${l("ai.chat.statusBar.agent.contextTokens")}: ${x(s.agentStatus.contextTokens)}`,`${l("ai.chat.statusBar.tokenUsageTitle")}: ${C.value}`].join(`
|
|
101
|
+
`):"");function A(){n.openSettings("ai","defaultModel")}const S=z(!1),q=M(()=>ga(s.currentMessages??[])),Y=M(()=>!!s.currentAIChatId||jl(s.currentMessages??[]));function G(){return{createdAt:l("ai.chat.conversation.export.createdAt"),user:l("ai.chat.conversation.export.user"),assistant:l("ai.chat.conversation.export.assistant")}}function Z(te){return te.map(j=>({...j,timestamp:j.timestamp*1e3}))}async function ce(){if(!(S.value||!Y.value)){S.value=!0;try{const te=c.value.exportFormat||"markdown",j=G();let de=s.fallbackTitle||l("ai.chat.conversation.newChat"),be=q.value[0]?.timestamp??Date.now(),xe=q.value;if(s.currentAIChatId){const[Q,J]=await Promise.all([Ye().getAIChat(s.currentAIChatId),Ye().getMessages(s.currentAIChatId)]);Q&&(de=Q.title||de,be=Q.createdAt*1e3);const ge=ga(Z(J));ge.length>0&&(xe=ge)}if(xe.length===0){e.warn(l("ai.chat.conversation.export.noMessages"));return}const oe=await Hl(de,xe,be,te,j);if(oe.success&&oe.filePath){const Q=oe.filePath.split("/").pop()||oe.filePath,J=oe.filePath;e.add({title:l("common.exportSuccess"),description:Q,color:"primary",actions:[{label:l("common.openFolder"),onClick:()=>{ns().showInFolder(J)}}]})}else e.fail(l("common.exportFailed"),{description:oe.error})}catch(te){console.error("导出对话失败:",te),e.fail(l("common.exportFailed"),{description:String(te)})}finally{S.value=!1}}}async function ne(){if(!f.value){f.value=!0;try{const te=await Ye().showAiLogFile();te?.success||e.fail(l("ai.chat.statusBar.log.openFailed"),{description:te?.error||l("ai.chat.statusBar.log.openFailedDesc")})}catch(te){console.error("打开 AI 日志失败:",te),e.fail(l("ai.chat.statusBar.log.openFailed"),{description:String(te)})}finally{f.value=!1}}}const H=z(!1),W=M(()=>{const te=g.value,j=o.defaultAssistant?.modelId||te?.model;return!te?.provider||!j?[]:Fl(te.provider,j)}),re=M(()=>W.value.length>0),ve=M(()=>{const te=o.defaultAssistant;return!te?.configId||!te?.modelId?"default":u.getThinkingLevel(te.configId,te.modelId)??"default"});function fe(te){const j=o.defaultAssistant;!j?.configId||!j?.modelId||(u.setThinkingLevel(j.configId,j.modelId,te),H.value=!1)}const ee=M(()=>l(`ai.chat.statusBar.thinking.level.${ve.value}`));return(te,j)=>{const de=_e,be=ms,xe=St;return r(),m("div",Jp,[a("div",Xp,[a("button",{class:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-300",disabled:t(h),onClick:A},[p(de,{name:"i-heroicons-cpu-chip",class:"h-3.5 w-3.5"}),a("span",e0,d(t(o).defaultAssistant?.modelId?t(o).getModelById(t(g)?.provider??"",t(o).defaultAssistant.modelId)?.name||t(o).defaultAssistant.modelId:t(l)("ai.chat.statusBar.model.notConfigured")),1)],8,Zp),re.value?(r(),U(be,{key:0,open:H.value,"onUpdate:open":j[0]||(j[0]=oe=>H.value=oe),ui:{content:"z-[80] p-0"}},{content:B(()=>[a("div",a0,[a("div",s0,d(t(l)("ai.chat.statusBar.thinking.title")),1),(r(!0),m(ie,null,pe(W.value,oe=>(r(),m("button",{key:oe,class:X(["flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",ve.value===oe?"text-primary-600 dark:text-primary-400":"text-gray-700 dark:text-gray-300"]),onClick:Q=>fe(oe)},[p(de,{name:ve.value===oe?"i-heroicons-check-circle-solid":"i-heroicons-light-bulb",class:X(["h-4 w-4 shrink-0",ve.value===oe?"text-primary-500":"text-gray-400"])},null,8,["name","class"]),a("span",null,d(t(l)(`ai.chat.statusBar.thinking.level.${oe}`)),1)],10,n0))),128))])]),default:B(()=>[a("button",{class:X(["flex items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors hover:bg-gray-100 dark:hover:bg-gray-800",ve.value==="default"||ve.value==="off"?"text-gray-400 dark:text-gray-500":"text-primary-500 dark:text-primary-400"]),title:t(l)("ai.chat.statusBar.thinking.tooltip")},[p(de,{name:"i-heroicons-light-bulb",class:"h-3.5 w-3.5"}),a("span",null,d(ee.value),1)],10,t0)]),_:1},8,["open"])):R("",!0)]),a("div",o0,[i.agentStatus?(r(),m("div",{key:0,class:"hidden shrink-0 items-center gap-1 rounded-lg bg-gray-50/90 px-1.5 py-1 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.35)] dark:bg-gray-800/70 dark:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.04)] lg:flex",title:D.value},[a("span",{class:X(["rounded px-1 py-0.5 text-[10px] font-medium",k.value])},d(y.value),3)],8,l0)):R("",!0),v.value>0?(r(),U(xe,{key:1,ui:{content:"h-auto py-1.5"}},{content:B(()=>[a("div",c0,[a("div",null,d(t(l)("ai.chat.statusBar.agent.contextTokens"))+": "+d(_(v.value))+" / "+d(_(w.value)),1),a("div",null,d(t(l)("ai.chat.statusBar.tokenUsageTitle"))+": "+d($.value),1),I.value?(r(),m("div",d0,d(t(l)("ai.chat.statusBar.cacheHit"))+": "+d(T.value),1)):R("",!0)])]),default:B(()=>[a("div",r0,[a("div",i0,[a("div",{class:X(["h-full rounded-full transition-all duration-300",F.value]),style:et({width:`${E.value}%`})},null,6)]),a("span",u0,d(E.value)+"%",1)])]),_:1})):R("",!0),a("button",{class:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:t(l)("ai.chat.statusBar.export.title"),disabled:S.value||!Y.value,onClick:ce},[p(de,{name:"i-heroicons-arrow-down-tray",class:"h-3.5 w-3.5"}),a("span",g0,d(t(l)("ai.chat.statusBar.export.label")),1)],8,m0),a("button",{class:"flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-60 dark:hover:bg-gray-800 dark:hover:text-gray-300",title:t(l)("ai.chat.statusBar.log.title"),disabled:f.value,onClick:ne},[p(de,{name:"i-heroicons-document-text",class:"h-3.5 w-3.5"}),a("span",h0,d(t(l)("ai.chat.statusBar.log.label")),1)],8,p0)])])}}}),v0={class:"assistant-bar-wrapper flex justify-center"},y0=["onClick"],x0={key:0,class:"absolute right-0 top-full z-30 mt-2 w-56 overflow-hidden rounded-xl border border-gray-200/80 bg-white/95 p-1 shadow-overlay backdrop-blur-md dark:border-gray-700 dark:bg-page-dark/95"},b0={class:"custom-scrollbar max-h-60 space-y-0.5 overflow-y-auto"},k0=["onClick"],_0={class:"truncate font-medium"},Pt=4,w0=ue({__name:"AssistantInlineBar",props:{chatType:{},locale:{},selectedId:{}},emits:["select","market"],setup(i,{emit:l}){const e=i,n=l,s=z(!1),u=z(null);function o(v){n("select",v),s.value=!1}function c(){x.value.length!==0&&(s.value=!s.value)}function g(v){if(!s.value||!u.value)return;const w=v.target;w instanceof Node&&!u.value.contains(w)&&(s.value=!1)}const h=Ft(),{filteredAssistants:f,isLoaded:b}=ut(h),y=M(()=>{const v=An(e.locale);return[...f.value].sort((w,E)=>w.id===v?-1:E.id===v?1:0)}),k=M(()=>{const v=y.value;if(v.length<=Pt)return v;const w=v.findIndex(E=>E.id===e.selectedId);if(w!==-1&&w>=Pt-1){const E=v.slice(0,Pt-1),F=v[w];return[...E,F]}return v.slice(0,Pt)}),x=M(()=>{const v=new Set(k.value.map(w=>w.id));return y.value.filter(w=>!v.has(w.id))});he(()=>[e.chatType,e.locale],([v,w])=>{h.setFilterContext(v,w)},{immediate:!0});const _=z([]),C=z(null);let $=null;const I=z({width:"0px",transform:"translateX(0px)",opacity:0}),T=async()=>{await De();const v=k.value.findIndex(w=>w.id===e.selectedId);if(v!==-1&&_.value[v]){const w=_.value[v];I.value={width:`${w.offsetWidth+6}px`,transform:`translateX(${w.offsetLeft-3}px)`,opacity:1}}else I.value.opacity=0};return he(()=>[e.selectedId,k.value],()=>{T()},{deep:!0}),Re(async()=>{b.value||await h.loadAssistants(),T(),document.addEventListener("mousedown",g),typeof ResizeObserver<"u"&&C.value&&($=new ResizeObserver(()=>{T()}),$.observe(C.value))}),tt(()=>{document.removeEventListener("mousedown",g),$&&$.disconnect()}),(v,w)=>{const E=_e;return r(),m("div",v0,[a("div",{ref_key:"containerRef",ref:C,class:"assistant-bar-grid relative flex items-center justify-center gap-1.5 rounded-full bg-gray-50/60 p-[3px] shadow-inner ring-1 ring-inset ring-gray-900/5 backdrop-blur-md dark:bg-gray-800/40 dark:ring-white/10 z-0 overflow-hidden sm:overflow-visible"},[a("div",{class:"absolute left-0 inset-y-0 -z-10 rounded-full bg-white ring-[1.5px] ring-primary-500 shadow-sm transition-all duration-350 ease-out dark:bg-primary-700/15 dark:ring-primary-500",style:et(I.value)},null,4),(r(!0),m(ie,null,pe(k.value,(F,D)=>(r(),m("button",{key:F.id,ref_for:!0,ref:A=>{A&&(_.value[D]=A)},class:X(["relative z-10 flex h-[32px] items-center justify-center whitespace-nowrap rounded-full px-4 text-[13px] font-medium transition-colors duration-200",[i.selectedId===F.id?"text-primary-600 dark:text-primary-400":"text-gray-500 hover:bg-gray-200/50 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-700/50 dark:hover:text-gray-200"]]),onClick:A=>n("select",F.id)},d(F.name),11,y0))),128)),x.value.length>0?(r(),m("div",{key:0,ref_key:"overflowMenuRef",ref:u,class:"relative z-20"},[a("button",{type:"button",class:"relative z-10 flex h-[32px] w-[32px] ml-0.5 items-center justify-center rounded-full text-gray-500 transition-colors duration-200 hover:bg-gray-200/50 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-700/50 dark:hover:text-gray-200",onClick:c},[p(E,{name:"i-heroicons-ellipsis-horizontal",class:"h-5 w-5"})]),s.value?(r(),m("div",x0,[a("div",b0,[w[1]||(w[1]=a("p",{class:"px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500"}," 更多助手 ",-1)),(r(!0),m(ie,null,pe(x.value,F=>(r(),m("button",{key:F.id,type:"button",class:X(["flex w-full items-center justify-between rounded-md px-2.5 py-1.5 text-left text-sm transition-colors",[i.selectedId===F.id?"bg-primary-50 text-primary-600 dark:bg-primary-500/10 dark:text-primary-400":"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800"]]),onClick:D=>o(F.id)},[a("span",_0,d(F.name),1),i.selectedId===F.id?(r(),U(E,{key:0,name:"i-heroicons-check",class:"h-4 w-4 shrink-0"})):R("",!0)],10,k0))),128))])])):R("",!0)],512)):R("",!0),a("button",{type:"button",class:"relative z-10 flex h-[32px] w-[32px] items-center justify-center rounded-full text-gray-500 transition-colors duration-200 hover:bg-gray-200/50 hover:text-gray-800 dark:text-gray-400 dark:hover:bg-gray-700/50 dark:hover:text-gray-200",onClick:w[0]||(w[0]=F=>n("market"))},[p(E,{name:"i-heroicons-plus",class:"h-[18px] w-[18px]"})])],512)])}}}),$0=dt(w0,[["__scopeId","data-v-169115ce"]]),C0={slots:{root:"relative inline-flex items-center",base:["w-full rounded-md border-0 appearance-none placeholder:text-dimmed disabled:cursor-not-allowed disabled:opacity-75","transition-colors"],leading:"absolute start-0 flex items-start",leadingIcon:"shrink-0 text-dimmed",leadingAvatar:"shrink-0",leadingAvatarSize:"",trailing:"absolute end-0 flex items-start",trailingIcon:"shrink-0 text-dimmed"},variants:{fieldGroup:{horizontal:{root:"group has-focus-visible:z-[1]",base:"group-not-only:group-first:rounded-e-none group-not-only:group-last:rounded-s-none group-not-last:group-not-first:rounded-none"},vertical:{root:"group has-focus-visible:z-[1]",base:"group-not-only:group-first:rounded-b-none group-not-only:group-last:rounded-t-none group-not-last:group-not-first:rounded-none"}},size:{xs:{base:"px-2 py-1 text-sm/4 gap-1",leading:"ps-2 inset-y-1",trailing:"pe-2 inset-y-1",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4"},sm:{base:"px-2.5 py-1.5 text-sm/4 gap-1.5",leading:"ps-2.5 inset-y-1.5",trailing:"pe-2.5 inset-y-1.5",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4"},md:{base:"px-2.5 py-1.5 text-base/5 gap-1.5",leading:"ps-2.5 inset-y-1.5",trailing:"pe-2.5 inset-y-1.5",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5"},lg:{base:"px-3 py-2 text-base/5 gap-2",leading:"ps-3 inset-y-2",trailing:"pe-3 inset-y-2",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5"},xl:{base:"px-3 py-2 text-base gap-2",leading:"ps-3 inset-y-2",trailing:"pe-3 inset-y-2",leadingIcon:"size-6",leadingAvatarSize:"xs",trailingIcon:"size-6"}},variant:{outline:"text-highlighted bg-default ring ring-inset ring-accented",soft:"text-highlighted bg-elevated/50 hover:bg-elevated focus:bg-elevated disabled:bg-elevated/50",subtle:"text-highlighted bg-elevated ring ring-inset ring-accented",ghost:"text-highlighted bg-transparent hover:bg-elevated focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent",none:"text-highlighted bg-transparent focus:outline-none"},color:{primary:"",secondary:"",success:"",info:"",warning:"",error:"",neutral:""},leading:{true:""},trailing:{true:""},loading:{true:""},highlight:{true:""},fixed:{false:""},type:{file:"file:me-1.5 file:font-medium file:text-muted file:outline-none"},autoresize:{true:{base:"resize-none"}}},compoundVariants:[{color:"primary",variant:["outline","subtle"],class:"outline-primary/25 focus-visible:outline-3 focus-visible:ring-primary"},{color:"secondary",variant:["outline","subtle"],class:"outline-secondary/25 focus-visible:outline-3 focus-visible:ring-secondary"},{color:"success",variant:["outline","subtle"],class:"outline-success/25 focus-visible:outline-3 focus-visible:ring-success"},{color:"info",variant:["outline","subtle"],class:"outline-info/25 focus-visible:outline-3 focus-visible:ring-info"},{color:"warning",variant:["outline","subtle"],class:"outline-warning/25 focus-visible:outline-3 focus-visible:ring-warning"},{color:"error",variant:["outline","subtle"],class:"outline-error/25 focus-visible:outline-3 focus-visible:ring-error"},{color:"primary",variant:["soft","ghost"],class:"outline-primary/25 focus-visible:outline-3"},{color:"secondary",variant:["soft","ghost"],class:"outline-secondary/25 focus-visible:outline-3"},{color:"success",variant:["soft","ghost"],class:"outline-success/25 focus-visible:outline-3"},{color:"info",variant:["soft","ghost"],class:"outline-info/25 focus-visible:outline-3"},{color:"warning",variant:["soft","ghost"],class:"outline-warning/25 focus-visible:outline-3"},{color:"error",variant:["soft","ghost"],class:"outline-error/25 focus-visible:outline-3"},{color:"primary",highlight:!0,class:"ring ring-inset ring-primary"},{color:"secondary",highlight:!0,class:"ring ring-inset ring-secondary"},{color:"success",highlight:!0,class:"ring ring-inset ring-success"},{color:"info",highlight:!0,class:"ring ring-inset ring-info"},{color:"warning",highlight:!0,class:"ring ring-inset ring-warning"},{color:"error",highlight:!0,class:"ring ring-inset ring-error"},{color:"neutral",variant:["outline","subtle"],class:"outline-inverted/25 focus-visible:outline-3 focus-visible:ring-inverted"},{color:"neutral",variant:["soft","ghost"],class:"outline-inverted/25 focus-visible:outline-3"},{color:"neutral",highlight:!0,class:"ring ring-inset ring-inverted"},{leading:!0,size:"xs",class:"ps-7"},{leading:!0,size:"sm",class:"ps-8"},{leading:!0,size:"md",class:"ps-9"},{leading:!0,size:"lg",class:"ps-10"},{leading:!0,size:"xl",class:"ps-11"},{trailing:!0,size:"xs",class:"pe-7"},{trailing:!0,size:"sm",class:"pe-8"},{trailing:!0,size:"md",class:"pe-9"},{trailing:!0,size:"lg",class:"pe-10"},{trailing:!0,size:"xl",class:"pe-11"},{loading:!0,leading:!0,class:{leadingIcon:"animate-spin"}},{loading:!0,leading:!1,trailing:!0,class:{trailingIcon:"animate-spin"}},{fixed:!1,size:"xs",class:"md:text-xs"},{fixed:!1,size:"sm",class:"md:text-xs"},{fixed:!1,size:"md",class:"md:text-sm"},{fixed:!1,size:"lg",class:"md:text-sm"}],defaultVariants:{size:"md",color:"primary",variant:"outline"}},S0=["id","value","name","rows","placeholder","disabled","required"],I0=Object.assign({inheritAttrs:!1},{__name:"Textarea",props:{as:{type:null,required:!1},id:{type:String,required:!1},name:{type:String,required:!1},placeholder:{type:String,required:!1},color:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},required:{type:Boolean,required:!1},autofocus:{type:Boolean,required:!1},autofocusDelay:{type:Number,required:!1,default:0},autoresize:{type:Boolean,required:!1},autoresizeDelay:{type:Number,required:!1,default:0},disabled:{type:Boolean,required:!1},rows:{type:Number,required:!1,default:3},maxrows:{type:Number,required:!1,default:0},highlight:{type:Boolean,required:!1},fixed:{type:Boolean,required:!1},defaultValue:{type:null,required:!1},modelValue:{type:null,required:!1},modelModifiers:{type:null,required:!1},class:{type:null,required:!1},ui:{type:Object,required:!1},icon:{type:null,required:!1},avatar:{type:Object,required:!1},leading:{type:Boolean,required:!1},leadingIcon:{type:null,required:!1},trailing:{type:Boolean,required:!1},trailingIcon:{type:null,required:!1},loading:{type:Boolean,required:!1},loadingIcon:{type:null,required:!1}},emits:["update:modelValue","blur","change"],setup(i,{expose:l,emit:e}){const n=i,s=e,u=Qt(),o=Ca("textarea",n),c=zn(o,"modelValue",s,{defaultValue:o.defaultValue}),g=Ia(),{emitFormFocus:h,emitFormBlur:f,emitFormInput:b,emitFormChange:y,size:k,color:x,id:_,name:C,highlight:$,disabled:I,ariaAttrs:T}=Sa(n,{deferInputValidation:!0}),{isLeading:v,isTrailing:w,leadingIconName:E,trailingIconName:F}=Ta(o),D=M(()=>$t({extend:$t(C0),...g.ui?.textarea||{}})({color:x.value??o.color,variant:o.variant,size:k?.value??o.size,loading:o.loading,highlight:$.value??o.highlight,fixed:o.fixed,autoresize:o.autoresize,leading:v.value||!!o.avatar||!!u.leading,trailing:w.value||!!u.trailing})),A=At("textareaRef");function S(ne){o.modelModifiers?.trim&&(typeof ne=="string"||ne===null||ne===void 0)&&(ne=ne?.trim()??null),o.modelModifiers?.number&&(ne=ds(ne)),o.modelModifiers?.nullable&&(ne||=null),o.modelModifiers?.optional&&!o.modelModifiers?.nullable&&ne!==null&&(ne||=void 0),c.value=ne,b()}function q(ne){ce(),o.modelModifiers?.lazy||S(ne.target.value)}function Y(ne){const H=ne.target.value;o.modelModifiers?.lazy&&S(H),o.modelModifiers?.trim&&(ne.target.value=H.trim()),y(),s("change",ne)}function G(ne){f(),s("blur",ne)}function Z(){o.autofocus&&A.value?.focus()}function ce(){if(o.autoresize&&A.value){A.value.rows=o.rows;const ne=A.value.style.overflow;A.value.style.overflow="hidden";const H=window.getComputedStyle(A.value),W=Number.parseInt(H.paddingTop),re=Number.parseInt(H.paddingBottom),ve=W+re,fe=Number.parseInt(H.lineHeight),{scrollHeight:ee}=A.value,te=(ee-ve)/fe;te>o.rows&&(A.value.rows=o.maxrows?Math.min(te,o.maxrows):te),A.value.style.overflow=ne}}return he(c,()=>{De(ce)}),Re(()=>{setTimeout(()=>{Z()},o.autofocusDelay),setTimeout(async()=>{await De(),ce()},o.autoresizeDelay)}),l({textareaRef:A,autoResize:ce}),(ne,H)=>(r(),U(t(He),{as:t(o).as,"data-slot":"root",class:X(D.value.root({class:[t(o).ui?.root,t(o).class]}))},{default:B(()=>[a("textarea",ze({id:t(_),ref_key:"textareaRef",ref:A,value:t(c),name:t(C),rows:t(o).rows,placeholder:t(o).placeholder,"data-slot":"base",class:D.value.base({class:t(o).ui?.base}),disabled:t(I),required:t(o).required},{...ne.$attrs,...t(T)},{onInput:q,onBlur:G,onChange:Y,onFocus:H[0]||(H[0]=(...W)=>t(h)&&t(h)(...W))}),null,16,S0),ye(ne.$slots,"default",{ui:D.value}),t(v)||t(o).avatar||u.leading?(r(),m("span",{key:0,"data-slot":"leading",class:X(D.value.leading({class:t(o).ui?.leading}))},[ye(ne.$slots,"leading",{ui:D.value},()=>[t(v)&&t(E)?(r(),U(_e,{key:0,name:t(E),"data-slot":"leadingIcon",class:X(D.value.leadingIcon({class:t(o).ui?.leadingIcon}))},null,8,["name","class"])):t(o).avatar?(r(),U(Ht,ze({key:1,size:t(o).ui?.leadingAvatarSize||D.value.leadingAvatarSize()},t(o).avatar,{"data-slot":"leadingAvatar",class:D.value.leadingAvatar({class:t(o).ui?.leadingAvatar})}),null,16,["size","class"])):R("",!0)])],2)):R("",!0),t(w)||u.trailing?(r(),m("span",{key:1,"data-slot":"trailing",class:X(D.value.trailing({class:t(o).ui?.trailing}))},[ye(ne.$slots,"trailing",{ui:D.value},()=>[t(F)?(r(),U(_e,{key:0,name:t(F),"data-slot":"trailingIcon",class:X(D.value.trailingIcon({class:t(o).ui?.trailingIcon}))},null,8,["name","class"])):R("",!0)])],2)):R("",!0)]),_:3},8,["as","class"]))}}),T0={class:"p-6"},M0={class:"mb-4 flex items-start justify-between gap-3"},A0={class:"min-w-0"},z0={class:"text-lg font-semibold text-gray-900 dark:text-white"},q0={key:0,class:"mt-1 text-xs text-amber-600 dark:text-amber-400"},L0={key:0,class:"flex items-center justify-center py-12"},D0={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},E0={key:0,class:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary-100 px-1 text-[10px] text-primary-600 dark:bg-primary-900/30 dark:text-primary-400"},B0={class:"max-h-[500px] overflow-y-auto pr-1"},F0={class:"space-y-5"},R0={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},V0={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},O0={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},P0={class:"flex flex-wrap gap-2"},j0=["disabled","onClick"],N0={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},U0={class:"flex flex-wrap gap-2"},W0=["disabled","onClick"],H0={class:"mt-1 text-[10px] text-gray-400"},K0={class:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-gray-300"},Y0={class:"space-y-2"},G0={key:0,class:"flex items-center gap-2"},Q0={class:"space-y-5"},J0={class:"mb-1 text-sm font-medium text-gray-700 dark:text-gray-300"},X0={class:"mb-2.5 text-[10px] text-gray-400"},Z0={class:"grid grid-cols-2 gap-1.5"},eh={class:"min-w-0"},th={class:"truncate text-xs font-medium text-gray-600 dark:text-gray-400"},ah={class:"truncate text-[10px] text-gray-400 dark:text-gray-500"},sh={class:"mb-1 flex items-center justify-between"},nh={class:"text-sm font-medium text-gray-700 dark:text-gray-300"},oh={key:0,class:"flex gap-2"},lh={class:"mb-2.5 text-[10px] text-gray-400"},rh={class:"grid grid-cols-2 gap-1.5"},ih=["checked","disabled","onChange"],uh={class:"min-w-0"},ch={class:"truncate text-xs font-medium text-gray-800 dark:text-gray-200"},dh={class:"truncate text-[10px] text-gray-500 dark:text-gray-400"},mh={class:"mt-6 flex items-center justify-between"},gh={class:"flex gap-2"},ph=ue({__name:"AssistantConfigModal",props:{open:{type:Boolean},assistantId:{},readonly:{type:Boolean},scrollToSection:{}},emits:["update:open","saved","created"],setup(i,{emit:l}){const{t:e}=we(),n=i,s=l,u=nt(),o=Ft(),c=z(!1),g=z(!1),h=z(null),f=z(!1),b=z("basic"),y=M(()=>[{value:"",label:e("ai.assistant.config.chatTypeAll")},{value:"group",label:e("ai.assistant.config.chatTypeGroup")},{value:"private",label:e("ai.assistant.config.chatTypePrivate")}]),k=[{value:"zh",label:"简体中文"},{value:"en",label:"English"},{value:"ja",label:"日本語"}],x=M(()=>o.builtinToolCatalog.filter(H=>H.category==="core").map(H=>({name:H.name,description:e(`ai.assistant.builtinToolDesc.${H.name}`)}))),_=M(()=>o.builtinToolCatalog.filter(H=>H.category==="analysis").map(H=>({name:H.name,description:e(`ai.assistant.builtinToolDesc.${H.name}`)}))),C=z({name:"",systemPrompt:"",presetQuestions:[],applicableChatType:"",supportedLocales:[],allowedBuiltinTools:[]}),$=z(""),I=z(null),T=M(()=>C.value.allowedBuiltinTools.length);Re(async()=>{o.builtinToolCatalog.length===0&&await o.loadBuiltinToolCatalog()}),he(()=>[n.open,n.assistantId],async([H,W])=>{H&&(b.value="basic",W?(f.value=!1,await w(W)):n.readonly||(f.value=!0,v()),n.scrollToSection==="presetQuestions"&&(await De(),setTimeout(()=>{I.value?.scrollIntoView({behavior:"smooth",block:"center"})},100)))},{immediate:!0});function v(){h.value={id:"",name:"",systemPrompt:"",presetQuestions:[],allowedBuiltinTools:[],applicableChatTypes:[],supportedLocales:[]},C.value={name:"",systemPrompt:"",presetQuestions:[],applicableChatType:"",supportedLocales:[],allowedBuiltinTools:[]},c.value=!1}async function w(H){c.value=!0;try{h.value=await o.getAssistantConfig(H),h.value&&(C.value={name:h.value.name,systemPrompt:h.value.systemPrompt,presetQuestions:[...h.value.presetQuestions],applicableChatType:h.value.applicableChatTypes?.[0]||"",supportedLocales:[...h.value.supportedLocales||[]],allowedBuiltinTools:[...h.value.allowedBuiltinTools||[]]})}catch(W){console.error("[AssistantConfigModal] Failed to load config:",W),u.fail(e("ai.assistant.toast.loadFailed"),{description:String(W)})}finally{c.value=!1}}async function E(){g.value=!0;try{const H={name:C.value.name,systemPrompt:C.value.systemPrompt,presetQuestions:[...C.value.presetQuestions],applicableChatTypes:C.value.applicableChatType?[C.value.applicableChatType]:[],supportedLocales:[...C.value.supportedLocales],allowedBuiltinTools:[...C.value.allowedBuiltinTools]};if(f.value){const W=await o.createAssistant(H);W.success?(u.success(e("ai.assistant.toast.createSuccess")),s("created",W.id),ne()):u.fail(e("ai.assistant.toast.createFailed"),{description:W.error||e("ai.assistant.toast.unknownError")})}else{if(!n.assistantId)return;const W=await o.updateAssistant(n.assistantId,H);W.success?(u.success(e("ai.assistant.toast.saveSuccess")),s("saved"),ne()):u.fail(e("ai.assistant.toast.saveFailed"),{description:W.error||e("ai.assistant.toast.unknownError")})}}catch(H){console.error("[AssistantConfigModal] Save failed:",H),u.fail(e("ai.assistant.toast.saveFailed"),{description:String(H)})}finally{g.value=!1}}async function F(){if(!(!n.assistantId||!h.value?.builtinId)){g.value=!0;try{const H=await o.resetAssistant(n.assistantId);H.success?(u.success(e("ai.assistant.toast.resetSuccess")),await w(n.assistantId),s("saved")):u.fail(e("ai.assistant.toast.resetFailed"),{description:H.error||e("ai.assistant.toast.unknownError")})}catch(H){u.fail(e("ai.assistant.toast.resetFailed"),{description:String(H)})}finally{g.value=!1}}}function D(){const H=$.value.trim();H&&!C.value.presetQuestions.includes(H)&&(C.value.presetQuestions.push(H),$.value="")}function A(H){C.value.presetQuestions.splice(H,1)}function S(H){const W=C.value.allowedBuiltinTools.indexOf(H);W>=0?C.value.allowedBuiltinTools.splice(W,1):C.value.allowedBuiltinTools.push(H)}function q(H){return C.value.allowedBuiltinTools.includes(H)}function Y(){C.value.allowedBuiltinTools=_.value.map(H=>H.name)}function G(){C.value.allowedBuiltinTools=[]}function Z(H){C.value.applicableChatType=H}function ce(H){const W=C.value.supportedLocales.indexOf(H);W>=0?C.value.supportedLocales.splice(W,1):C.value.supportedLocales.push(H)}function ne(){s("update:open",!1)}return(H,W)=>{const re=Ue,ve=_e,fe=Bt,ee=I0,te=Xe;return r(),U(te,{open:i.open,ui:{content:"sm:max-w-2xl z-100"},"onUpdate:open":W[5]||(W[5]=j=>s("update:open",j))},{content:B(()=>[a("div",T0,[a("div",M0,[a("div",A0,[a("h2",z0,d(i.readonly?t(e)("ai.assistant.config.viewTitle"):f.value?t(e)("ai.assistant.config.createTitle"):t(e)("ai.assistant.config.editTitle")),1),i.readonly?R("",!0):(r(),m("p",q0,d(t(e)("ai.assistant.config.betaWarning")),1))]),p(re,{icon:"i-heroicons-x-mark",variant:"ghost",size:"sm",class:"shrink-0",onClick:ne})]),c.value?(r(),m("div",L0,[p(ve,{name:"i-heroicons-arrow-path",class:"h-6 w-6 animate-spin text-gray-400"})])):h.value?(r(),m(ie,{key:1},[a("div",D0,[a("button",{class:X(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",b.value==="basic"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:W[0]||(W[0]=j=>b.value="basic")},d(t(e)("ai.assistant.config.tabs.basic")),3),a("button",{class:X(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",b.value==="tools"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:W[1]||(W[1]=j=>b.value="tools")},[le(d(t(e)("ai.assistant.config.tabs.tools"))+" ",1),T.value>0?(r(),m("span",E0,d(T.value),1)):R("",!0)],2)]),a("div",B0,[Qe(a("div",F0,[a("div",null,[a("label",R0,d(t(e)("ai.assistant.config.name")),1),p(fe,{modelValue:C.value.name,"onUpdate:modelValue":W[2]||(W[2]=j=>C.value.name=j),class:"w-full",disabled:i.readonly},null,8,["modelValue","disabled"])]),a("div",null,[a("label",V0,d(t(e)("ai.assistant.config.systemPrompt")),1),p(ee,{modelValue:C.value.systemPrompt,"onUpdate:modelValue":W[3]||(W[3]=j=>C.value.systemPrompt=j),rows:5,autoresize:"",class:"w-full font-mono text-sm",disabled:i.readonly},null,8,["modelValue","disabled"])]),a("div",null,[a("label",O0,d(t(e)("ai.assistant.config.chatType")),1),a("div",P0,[(r(!0),m(ie,null,pe(y.value,j=>(r(),m("button",{key:j.value,type:"button",class:X(["rounded-lg border px-3 py-1.5 text-xs transition-colors",C.value.applicableChatType===j.value?"border-primary-500 bg-primary-50 text-primary-700 dark:border-primary-400 dark:bg-primary-950/30 dark:text-primary-300":"border-gray-200 text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:text-gray-400"]),disabled:i.readonly,onClick:de=>Z(j.value)},d(j.label),11,j0))),128))])]),a("div",null,[a("label",N0,d(t(e)("ai.assistant.config.locale")),1),a("div",U0,[(r(),m(ie,null,pe(k,j=>a("button",{key:j.value,type:"button",class:X(["rounded-lg border px-3 py-1.5 text-xs transition-colors",C.value.supportedLocales.includes(j.value)?"border-primary-500 bg-primary-50 text-primary-700 dark:border-primary-400 dark:bg-primary-950/30 dark:text-primary-300":"border-gray-200 text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:text-gray-400"]),disabled:i.readonly,onClick:de=>ce(j.value)},d(j.label),11,W0)),64))]),a("p",H0,d(t(e)("ai.assistant.config.localeHint")),1)]),a("div",{ref_key:"presetQuestionsRef",ref:I},[a("label",K0,d(t(e)("ai.assistant.config.presetQuestions")),1),a("div",Y0,[(r(!0),m(ie,null,pe(C.value.presetQuestions,(j,de)=>(r(),m("div",{key:de,class:"flex items-center gap-2"},[p(fe,{modelValue:C.value.presetQuestions[de],"onUpdate:modelValue":be=>C.value.presetQuestions[de]=be,class:"min-w-0 flex-1",size:"sm",disabled:i.readonly},null,8,["modelValue","onUpdate:modelValue","disabled"]),i.readonly?R("",!0):(r(),U(re,{key:0,color:"error",variant:"ghost",icon:"i-heroicons-trash",size:"xs",class:"shrink-0",onClick:be=>A(de)},null,8,["onClick"]))]))),128)),i.readonly?R("",!0):(r(),m("div",G0,[p(fe,{modelValue:$.value,"onUpdate:modelValue":W[4]||(W[4]=j=>$.value=j),placeholder:t(e)("ai.assistant.config.addQuestion"),class:"min-w-0 flex-1",size:"sm",onKeyup:Ge(D,["enter"])},null,8,["modelValue","placeholder"]),p(re,{color:"primary",variant:"soft",icon:"i-heroicons-plus",size:"xs",class:"shrink-0",onClick:D})]))])],512)],512),[[yt,b.value==="basic"]]),Qe(a("div",Q0,[a("div",null,[a("h3",J0,d(t(e)("ai.assistant.config.coreTools")),1),a("p",X0,d(t(e)("ai.assistant.config.coreToolsHint")),1),a("div",Z0,[(r(!0),m(ie,null,pe(x.value,j=>(r(),m("label",{key:j.name,class:"flex items-start gap-2 rounded-md border border-gray-200 bg-gray-50/50 px-2.5 py-2 opacity-70 dark:border-gray-700 dark:bg-gray-800/30"},[W[6]||(W[6]=a("input",{type:"checkbox",checked:"",disabled:"",class:"mt-0.5 h-3.5 w-3.5 shrink-0 rounded border-gray-300 text-gray-400"},null,-1)),a("div",eh,[a("div",th,d(j.name),1),a("div",ah,d(j.description),1)])]))),128))])]),a("div",null,[a("div",sh,[a("h3",nh,d(t(e)("ai.assistant.config.analysisTools")),1),i.readonly?R("",!0):(r(),m("div",oh,[a("button",{class:"text-[10px] text-primary-500 hover:text-primary-600",onClick:Y},d(t(e)("ai.assistant.config.selectAll")),1),W[7]||(W[7]=a("span",{class:"text-[10px] text-gray-300 dark:text-gray-600"},"|",-1)),a("button",{class:"text-[10px] text-primary-500 hover:text-primary-600",onClick:G},d(t(e)("ai.assistant.config.deselectAll")),1)]))]),a("p",lh,d(t(e)("ai.assistant.config.analysisToolsHint")),1),a("div",rh,[(r(!0),m(ie,null,pe(_.value,j=>(r(),m("label",{key:j.name,class:X(["flex cursor-pointer items-start gap-2 rounded-md border px-2.5 py-2 transition-colors",q(j.name)?"border-primary-200 bg-primary-50/50 dark:border-primary-800 dark:bg-primary-950/20":"border-gray-200 dark:border-gray-700"])},[a("input",{type:"checkbox",checked:q(j.name),disabled:i.readonly,class:"mt-0.5 h-3.5 w-3.5 shrink-0 rounded border-gray-300 text-primary-600 focus:ring-primary-500",onChange:de=>S(j.name)},null,40,ih),a("div",uh,[a("div",ch,d(j.name),1),a("div",dh,d(j.description),1)])],2))),128))])])],512),[[yt,b.value==="tools"]])]),a("div",mh,[a("div",null,[!i.readonly&&!f.value&&h.value?.builtinId?(r(),U(re,{key:0,variant:"outline",color:"warning",loading:g.value,onClick:F},{default:B(()=>[le(d(t(e)("ai.assistant.config.resetDefault")),1)]),_:1},8,["loading"])):R("",!0)]),a("div",gh,[p(re,{variant:"ghost",onClick:ne},{default:B(()=>[le(d(i.readonly?t(e)("common.close"):t(e)("common.cancel")),1)]),_:1}),i.readonly?R("",!0):(r(),U(re,{key:0,color:"primary",loading:g.value,onClick:E},{default:B(()=>[le(d(f.value?t(e)("ai.assistant.config.create"):t(e)("common.save")),1)]),_:1},8,["loading"]))])])],64)):R("",!0)])]),_:1},8,["open"])}}}),hh={class:"p-6"},fh={class:"mb-4 flex items-center justify-between"},vh={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},yh={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},xh={key:0,class:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary-100 px-1 text-[10px] text-primary-600 dark:bg-primary-900/30 dark:text-primary-400"},bh={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},kh={class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},_h={class:"min-w-0 flex-1"},wh={class:"flex items-center gap-2"},$h={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Ch={key:0,class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},Sh={key:1,class:"inline-flex shrink-0 items-center rounded-full bg-green-100 px-2 py-0.5 text-[10px] font-medium text-green-700 dark:bg-green-900/30 dark:text-green-400"},Ih={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},Th={class:"flex shrink-0 items-center gap-1.5"},Mh=["title","onClick"],Ah=["title","onClick"],zh=["title","onClick"],qh={key:0,class:"py-12 text-center text-sm text-gray-400"},Lh={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},Dh={key:0,class:"py-12 text-center text-sm text-gray-400"},Eh={key:1,class:"py-12 text-center"},Bh={class:"text-sm text-gray-500 dark:text-gray-400"},Fh={key:2,class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},Rh={class:"min-w-0 flex-1"},Vh={class:"flex items-center gap-2"},Oh={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Ph={key:0,class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},jh={key:1,class:"inline-flex shrink-0 items-center rounded-full bg-green-100 px-2 py-0.5 text-[10px] font-medium text-green-700 dark:bg-green-900/30 dark:text-green-400"},Nh={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},Uh={class:"flex shrink-0 items-center gap-2"},Wh=["disabled","onClick"],Hh={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},Kh=["disabled","onClick"],Yh=["title","onClick"],Gh={key:3,class:"py-12 text-center text-sm text-gray-400"},Qh=ue({__name:"AssistantMarketModal",props:{open:{type:Boolean}},emits:["update:open","configure","view-config","create"],setup(i,{emit:l}){const{t:e,locale:n}=we(),s=nt(),u=i,o=l,c=Ft(),{assistants:g,cloudCatalogWithStatus:h,cloudLoading:f,cloudError:b}=ut(c),y=z("local"),k=M(()=>{const A=n.value;return[...g.value].filter(S=>!S.supportedLocales?.length||S.supportedLocales.some(q=>A.startsWith(q))).sort((S,q)=>S.name.localeCompare(q.name))}),x=M(()=>[...h.value].sort((A,S)=>A.name.localeCompare(S.name))),_=z(new Set);he(()=>[u.open,y.value],([A,S])=>{A&&S==="market"&&c.fetchCloudCatalog(n.value)},{immediate:!0});function C(A){o("configure",A)}async function $(A){Vt(A)||await c.deleteAssistant(A)}async function I(A){await c.duplicateAssistant(A)}function T(){o("create")}async function v(A){if(!_.value.has(A.id)){_.value=new Set([..._.value,A.id]);try{const S=await c.importFromCloud(A);S.success?s.success(e("ai.assistant.market.importSuccess")):s.fail(e("ai.assistant.market.importFailed"),{description:S.error})}finally{const S=new Set(_.value);S.delete(A.id),_.value=S}}}async function w(A){if(!_.value.has(A.id)){_.value=new Set([..._.value,A.id]);try{const S=await c.deleteAssistant(A.id);if(!S.success){s.fail(e("ai.assistant.market.importFailed"),{description:S.error});return}const q=await c.importFromCloud(A);q.success?s.success(e("ai.assistant.market.importSuccess")):s.fail(e("ai.assistant.market.importFailed"),{description:q.error})}finally{const S=new Set(_.value);S.delete(A.id),_.value=S}}}function E(A){o("view-config",A)}function F(){c.fetchCloudCatalog(n.value)}function D(A){return A?.length?A.map(q=>e(q==="group"?"ai.assistant.config.chatTypeGroup":"ai.assistant.config.chatTypePrivate")).join(" / "):null}return(A,S)=>{const q=_e,Y=Xe;return r(),U(Y,{open:i.open,ui:{content:"sm:max-w-xl z-50"},"onUpdate:open":S[3]||(S[3]=G=>o("update:open",G))},{content:B(()=>[a("div",hh,[a("div",fh,[a("h2",vh,d(t(e)("ai.assistant.market.title")),1),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:S[0]||(S[0]=G=>o("update:open",!1))},[p(q,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),a("div",yh,[a("button",{class:X(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",y.value==="local"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:S[1]||(S[1]=G=>y.value="local")},[le(d(t(e)("ai.assistant.market.tabs.local"))+" ",1),k.value.length?(r(),m("span",xh,d(k.value.length),1)):R("",!0)],2),a("button",{class:X(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",y.value==="market"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:S[2]||(S[2]=G=>y.value="market")},d(t(e)("ai.assistant.market.tabs.market")),3)]),Qe(a("div",null,[a("p",bh,d(t(e)("ai.assistant.market.localHint")),1),a("div",kh,[(r(!0),m(ie,null,pe(k.value,G=>(r(),m("div",{key:G.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[a("div",_h,[a("div",wh,[a("h3",$h,d(G.name),1),D(G.applicableChatTypes)?(r(),m("span",Ch,d(D(G.applicableChatTypes)),1)):R("",!0),t(Vt)(G.id)?(r(),m("span",Sh,d(t(e)("ai.assistant.market.default")),1)):R("",!0)]),a("p",Ih,d(G.systemPrompt),1)]),a("div",Th,[a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:t(e)("common.edit"),onClick:Oe(Z=>C(G.id),["stop"])},[p(q,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})],8,Mh),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:t(e)("ai.assistant.market.duplicate"),onClick:Oe(Z=>I(G.id),["stop"])},[p(q,{name:"i-heroicons-document-duplicate",class:"h-4 w-4"})],8,Ah),t(Vt)(G.id)?R("",!0):(r(),m("button",{key:0,class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500 dark:hover:bg-red-900/20 dark:hover:text-red-400",title:t(e)("common.delete"),onClick:Oe(Z=>$(G.id),["stop"])},[p(q,{name:"i-heroicons-trash",class:"h-4 w-4"})],8,zh))])]))),128))]),a("button",{type:"button",class:"mt-3 flex w-full items-center justify-center gap-1.5 rounded-xl border-2 border-dashed border-gray-300 py-4 text-sm text-gray-500 transition-colors hover:border-primary-400 hover:text-primary-600 dark:border-gray-600 dark:text-gray-400 dark:hover:border-primary-500 dark:hover:text-primary-400",onClick:T},[p(q,{name:"i-heroicons-plus",class:"h-4 w-4"}),le(" "+d(t(e)("ai.assistant.market.addAssistant")),1)]),k.value.length===0?(r(),m("div",qh,d(t(e)("ai.assistant.market.noLocal")),1)):R("",!0)],512),[[yt,y.value==="local"]]),Qe(a("div",null,[a("p",Lh,d(t(e)("ai.assistant.market.marketHint")),1),t(f)?(r(),m("div",Dh,d(t(e)("ai.assistant.market.loading")),1)):t(b)?(r(),m("div",Eh,[a("p",Bh,d(t(e)("ai.assistant.market.loadFailed")),1),a("button",{type:"button",class:"mt-3 rounded-lg bg-primary-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-600",onClick:F},d(t(e)("ai.assistant.market.retry")),1)])):(r(),m("div",Fh,[(r(!0),m(ie,null,pe(x.value,G=>(r(),m("div",{key:G.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[a("div",Rh,[a("div",Vh,[a("h3",Oh,d(G.name),1),D(G.applicableChatTypes)?(r(),m("span",Ph,d(D(G.applicableChatTypes)),1)):R("",!0),t(Vt)(G.id)?(r(),m("span",jh,d(t(e)("ai.assistant.market.default")),1)):R("",!0)]),a("p",Nh,d(G.description),1)]),a("div",Uh,[G.imported?(r(),m(ie,{key:1},[a("span",Hh,d(t(e)("ai.assistant.market.imported")),1),a("button",{class:"rounded-lg px-3 py-1.5 text-xs font-medium text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-300 disabled:opacity-50",disabled:_.value.has(G.id),onClick:Z=>w(G)},d(_.value.has(G.id)?t(e)("ai.assistant.market.importing"):t(e)("ai.assistant.market.reimport")),9,Kh)],64)):(r(),m("button",{key:0,class:"rounded-lg bg-primary-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50",disabled:_.value.has(G.id),onClick:Z=>v(G)},d(_.value.has(G.id)?t(e)("ai.assistant.market.importing"):t(e)("ai.assistant.market.import")),9,Wh)),G.imported?(r(),m("button",{key:2,class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:t(e)("ai.assistant.market.viewConfig"),onClick:Oe(Z=>E(G.id),["stop"])},[p(q,{name:"i-heroicons-eye",class:"h-4 w-4"})],8,Yh)):R("",!0)])]))),128))])),!t(f)&&!t(b)&&x.value.length===0?(r(),m("div",Gh,d(t(e)("ai.assistant.market.noCatalog")),1)):R("",!0)],512),[[yt,y.value==="market"]])])]),_:1},8,["open"])}}}),Jh={class:"p-5"},Xh={class:"flex items-start gap-3"},Zh={class:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-primary-50 text-primary-600 dark:bg-primary-950/40 dark:text-primary-400"},ef={class:"min-w-0"},tf={class:"font-semibold text-gray-900 dark:text-white"},af={class:"mt-1.5 text-sm leading-6 text-gray-600 dark:text-gray-400"},sf={class:"mt-4 rounded-lg bg-gray-50 px-3 py-2.5 dark:bg-gray-800/70"},nf={class:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300"},of={class:"truncate"},lf={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},rf={class:"mt-5 flex justify-end gap-2"},uf=ue({__name:"AssistantUpgradeModal",props:{open:{type:Boolean},backupName:{},upgrading:{type:Boolean},skipping:{type:Boolean}},emits:["skip","confirm"],setup(i,{emit:l}){const e=l,{t:n}=we();return(s,u)=>{const o=_e,c=Ue,g=Xe;return r(),U(g,{open:i.open,dismissible:!1,ui:{content:"sm:max-w-md z-50",overlay:"z-40"}},{content:B(()=>[a("div",Jh,[a("div",Xh,[a("div",Zh,[p(o,{name:"i-lucide-sparkles",class:"h-5 w-5"})]),a("div",ef,[a("h3",tf,d(t(n)("ai.assistant.upgrade.title")),1),a("p",af,d(t(n)("ai.assistant.upgrade.message",{backupName:i.backupName})),1)])]),a("div",sf,[a("div",nf,[p(o,{name:"i-lucide-copy-check",class:"h-4 w-4 shrink-0 text-gray-400"}),a("span",of,d(i.backupName),1)])]),a("p",lf,d(t(n)("ai.assistant.upgrade.skipHint")),1),a("div",rf,[p(c,{variant:"soft",loading:i.skipping,disabled:i.upgrading,onClick:u[0]||(u[0]=h=>e("skip"))},{default:B(()=>[le(d(t(n)("ai.assistant.upgrade.skip")),1)]),_:1},8,["loading","disabled"]),p(c,{color:"primary",loading:i.upgrading,disabled:i.skipping,onClick:u[1]||(u[1]=h=>e("confirm"))},{default:B(()=>[le(d(t(n)("ai.assistant.upgrade.confirm")),1)]),_:1},8,["loading","disabled"])])])]),_:1},8,["open"])}}}),cf={class:"p-6"},df={class:"mb-4 flex items-center justify-between"},mf={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},gf={class:"mb-4 flex gap-1 rounded-lg bg-gray-100 p-1 dark:bg-gray-800"},pf={key:0,class:"ml-1 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-primary-100 px-1 text-[10px] text-primary-600 dark:bg-primary-900/30 dark:text-primary-400"},hf={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},ff={class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},vf={class:"min-w-0 flex-1"},yf={class:"flex items-center gap-2"},xf={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},bf={class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},kf={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},_f={key:0,class:"mt-1.5 flex flex-wrap gap-1"},wf={class:"flex shrink-0 items-center gap-1.5"},$f=["title","onClick"],Cf=["title","onClick"],Sf={key:0,class:"py-12 text-center text-sm text-gray-400"},If={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},Tf={key:0,class:"py-12 text-center text-sm text-gray-400"},Mf={key:1,class:"py-12 text-center"},Af={class:"text-sm text-gray-500 dark:text-gray-400"},zf={key:2,class:"max-h-[400px] space-y-3 overflow-y-auto pr-1"},qf={class:"min-w-0 flex-1"},Lf={class:"flex items-center gap-2"},Df={class:"text-sm font-semibold text-gray-900 dark:text-gray-100"},Ef={class:"inline-flex shrink-0 items-center rounded-full bg-blue-100 px-2 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"},Bf={class:"mt-1 line-clamp-1 text-xs text-gray-500 dark:text-gray-400"},Ff={key:0,class:"mt-1.5 flex flex-wrap gap-1"},Rf={class:"flex shrink-0 items-center gap-2"},Vf=["disabled","onClick"],Of={class:"px-3 py-1.5 text-xs font-medium text-gray-400 dark:text-gray-500"},Pf=["disabled","onClick"],jf={key:3,class:"py-12 text-center text-sm text-gray-400"},Nf=ue({__name:"SkillMarketModal",props:{open:{type:Boolean}},emits:["update:open","configure","create"],setup(i,{emit:l}){const{t:e,locale:n}=we(),s=nt(),u=i,o=l,c=It(),{skills:g,cloudCatalogWithStatus:h,cloudLoading:f,cloudError:b}=ut(c),y=z("local"),k=z(new Set);Re(()=>{c.setFilterContext("group",n.value)}),he(()=>[u.open,y.value],([F,D])=>{F&&D==="market"&&(c.setFilterContext("group",n.value),c.fetchCloudCatalog())},{immediate:!0});const x=M(()=>[...g.value].sort((F,D)=>F.name.localeCompare(D.name))),_=M(()=>[...h.value].sort((F,D)=>F.name.localeCompare(D.name)));function C(F){return e(F==="group"?"ai.skill.config.chatScopeGroup":F==="private"?"ai.skill.config.chatScopePrivate":"ai.skill.config.chatScopeAll")}function $(F){o("configure",F)}async function I(F){await c.deleteSkill(F)}function T(){o("create")}async function v(F){if(!k.value.has(F.id)){k.value=new Set([...k.value,F.id]);try{const D=await c.importFromCloud(F);D.success?s.success(e("ai.skill.market.importSuccess")):s.fail(e("ai.skill.market.importFailed"),{description:D.error})}finally{const D=new Set(k.value);D.delete(F.id),k.value=D}}}async function w(F){if(!k.value.has(F.id)){k.value=new Set([...k.value,F.id]);try{const D=await c.deleteSkill(F.id);if(!D.success){s.fail(e("ai.skill.market.importFailed"),{description:D.error});return}const A=await c.importFromCloud(F);A.success?s.success(e("ai.skill.market.importSuccess")):s.fail(e("ai.skill.market.importFailed"),{description:A.error})}finally{const D=new Set(k.value);D.delete(F.id),k.value=D}}}function E(){c.fetchCloudCatalog()}return(F,D)=>{const A=_e,S=Xe;return r(),U(S,{open:i.open,ui:{content:"sm:max-w-xl z-50"},"onUpdate:open":D[3]||(D[3]=q=>o("update:open",q))},{content:B(()=>[a("div",cf,[a("div",df,[a("h2",mf,d(t(e)("ai.skill.market.title")),1),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:D[0]||(D[0]=q=>o("update:open",!1))},[p(A,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),a("div",gf,[a("button",{class:X(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",y.value==="local"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:D[1]||(D[1]=q=>y.value="local")},[le(d(t(e)("ai.skill.market.tabs.local"))+" ",1),t(g).length?(r(),m("span",pf,d(t(g).length),1)):R("",!0)],2),a("button",{class:X(["flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",y.value==="market"?"bg-white text-gray-900 shadow-sm dark:bg-gray-700 dark:text-white":"text-gray-500 hover:text-gray-700 dark:text-gray-400"]),onClick:D[2]||(D[2]=q=>y.value="market")},d(t(e)("ai.skill.market.tabs.market")),3)]),Qe(a("div",null,[a("p",hf,d(t(e)("ai.skill.market.localHint")),1),a("div",ff,[(r(!0),m(ie,null,pe(x.value,q=>(r(),m("div",{key:q.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[a("div",vf,[a("div",yf,[a("h3",xf,d(q.name),1),a("span",bf,d(C(q.chatScope)),1)]),a("p",kf,d(q.description),1),q.tags.length?(r(),m("div",_f,[(r(!0),m(ie,null,pe(q.tags,Y=>(r(),m("span",{key:Y,class:"rounded-full bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-500 dark:bg-gray-700 dark:text-gray-400"},d(Y),1))),128))])):R("",!0)]),a("div",wf,[a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:t(e)("common.edit"),onClick:Oe(Y=>$(q.id),["stop"])},[p(A,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})],8,$f),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-50 hover:text-red-500 dark:hover:bg-red-900/20 dark:hover:text-red-400",title:t(e)("common.delete"),onClick:Oe(Y=>I(q.id),["stop"])},[p(A,{name:"i-heroicons-trash",class:"h-4 w-4"})],8,Cf)])]))),128))]),a("button",{type:"button",class:"mt-3 flex w-full items-center justify-center gap-1.5 rounded-xl border-2 border-dashed border-gray-300 py-4 text-sm text-gray-500 transition-colors hover:border-primary-400 hover:text-primary-600 dark:border-gray-600 dark:text-gray-400 dark:hover:border-primary-500 dark:hover:text-primary-400",onClick:T},[p(A,{name:"i-heroicons-plus",class:"h-4 w-4"}),le(" "+d(t(e)("ai.skill.market.addSkill")),1)]),x.value.length===0?(r(),m("div",Sf,d(t(e)("ai.skill.market.noLocal")),1)):R("",!0)],512),[[yt,y.value==="local"]]),Qe(a("div",null,[a("p",If,d(t(e)("ai.skill.market.marketHint")),1),t(f)?(r(),m("div",Tf,d(t(e)("ai.skill.market.loading")),1)):t(b)?(r(),m("div",Mf,[a("p",Af,d(t(e)("ai.skill.market.loadFailed")),1),a("button",{type:"button",class:"mt-3 rounded-lg bg-primary-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-600",onClick:E},d(t(e)("ai.skill.market.retry")),1)])):(r(),m("div",zf,[(r(!0),m(ie,null,pe(_.value,q=>(r(),m("div",{key:q.id,class:"flex items-center gap-4 rounded-xl border border-gray-200 bg-white p-4 transition-colors dark:border-gray-700 dark:bg-gray-800"},[a("div",qf,[a("div",Lf,[a("h3",Df,d(q.name),1),a("span",Ef,d(C(q.chatScope)),1)]),a("p",Bf,d(q.description),1),q.tags?.length?(r(),m("div",Ff,[(r(!0),m(ie,null,pe(q.tags,Y=>(r(),m("span",{key:Y,class:"rounded-full bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-500 dark:bg-gray-700 dark:text-gray-400"},d(Y),1))),128))])):R("",!0)]),a("div",Rf,[q.imported?(r(),m(ie,{key:1},[a("span",Of,d(t(e)("ai.skill.market.imported")),1),a("button",{class:"rounded-lg px-3 py-1.5 text-xs font-medium text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-300 disabled:opacity-50",disabled:k.value.has(q.id),onClick:Y=>w(q)},d(k.value.has(q.id)?t(e)("ai.skill.market.importing"):t(e)("ai.skill.market.reimport")),9,Pf)],64)):(r(),m("button",{key:0,class:"rounded-lg bg-primary-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50",disabled:k.value.has(q.id),onClick:Y=>v(q)},d(k.value.has(q.id)?t(e)("ai.skill.market.importing"):t(e)("ai.skill.market.import")),9,Vf))])]))),128))])),!t(f)&&!t(b)&&_.value.length===0?(r(),m("div",jf,d(t(e)("ai.skill.market.noCatalog")),1)):R("",!0)],512),[[yt,y.value==="market"]])])]),_:1},8,["open"])}}}),Uf={class:"p-6"},Wf={class:"mb-4 flex items-center justify-between"},Hf={class:"text-lg font-bold text-gray-900 dark:text-gray-100"},Kf={class:"mb-3 text-xs text-gray-500 dark:text-gray-400"},Yf={key:0,class:"flex h-64 items-center justify-center text-gray-400"},Gf={class:"mt-4 flex justify-end gap-2"},Qf=["disabled"],Jf=`---
|
|
102
102
|
name: ""
|
|
103
103
|
description: ""
|
|
104
104
|
tags: []
|
|
@@ -106,5 +106,5 @@ chatScope: all
|
|
|
106
106
|
tools: []
|
|
107
107
|
---
|
|
108
108
|
|
|
109
|
-
`,
|
|
110
|
-
`);o.value=x}}finally{c.value=!1}}},{immediate:!0});async function f(){if(o.value.trim()){g.value=!0;try{if(h.value){const b=await u.createSkill(o.value);b.success&&b.id&&(s("created",b.id),s("update:open",!1))}else n.skillId&&(await u.updateSkill(n.skillId,o.value)).success&&(s("saved"),s("update:open",!1))}finally{g.value=!1}}}return(b,y)=>{const k=_e,x=Xe;return r(),U(x,{open:i.open,ui:{content:"sm:max-w-2xl z-50"},"onUpdate:open":y[3]||(y[3]=_=>s("update:open",_))},{content:B(()=>[a("div",Nf,[a("div",Uf,[a("h2",Wf,d(h.value?t(e)("ai.skill.config.createTitle"):t(e)("ai.skill.config.editTitle")),1),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:y[0]||(y[0]=_=>s("update:open",!1))},[p(k,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),a("p",Hf,d(t(e)("ai.skill.config.rawEditorHint")),1),c.value?(r(),m("div",Kf,[p(k,{name:"i-heroicons-arrow-path",class:"mr-2 h-5 w-5 animate-spin"})])):Qe((r(),m("textarea",{key:1,"onUpdate:modelValue":y[1]||(y[1]=_=>o.value=_),class:"h-[400px] w-full resize-none rounded-lg border border-gray-300 bg-gray-50 p-3 font-mono text-xs text-gray-900 focus:border-primary-500 focus:ring-1 focus:ring-primary-500 dark:border-gray-600 dark:bg-page-dark dark:text-gray-100",spellcheck:"false"},null,512)),[[ft,o.value]]),a("div",Yf,[a("button",{class:"rounded-lg px-4 py-2 text-sm text-gray-500 transition-colors hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800",onClick:y[2]||(y[2]=_=>s("update:open",!1))},d(t(e)("common.cancel")),1),a("button",{class:"rounded-lg bg-primary-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50",disabled:g.value||!o.value.trim(),onClick:f},d(h.value?t(e)("ai.skill.config.create"):t(e)("ai.skill.config.save")),9,Gf)])])]),_:1},8,["open"])}}}),Xf={key:0,class:"relative"},Zf={class:"relative flex flex-nowrap gap-2"},ev=["disabled"],tv=["disabled"],av={class:"inline-flex items-center gap-1"},sv={key:0,class:"absolute left-0 bottom-full z-20 mb-2 w-[320px] max-w-[calc(100vw-3rem)]"},nv={class:"mb-1.5 flex justify-start"},ov={class:"flex flex-wrap gap-2"},lv=["disabled","onClick"],ca="rounded-full ring-1 ring-inset ring-gray-200/80 bg-white/60 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.05)] backdrop-blur-md px-3 py-1.5 text-xs text-gray-600 transition-all duration-300 hover:-translate-y-[1px] hover:ring-primary-300 hover:bg-white/90 hover:text-primary-600 hover:shadow-[0_4px_12px_-2px_rgba(0,0,0,0.08)] disabled:cursor-not-allowed disabled:opacity-50 dark:ring-gray-700/60 dark:bg-gray-800/60 dark:text-gray-300 dark:hover:ring-primary-500/50 dark:hover:bg-gray-800/90 dark:hover:text-primary-400",rv=ue({__name:"PresetQuestions",props:{questions:{},disabled:{type:Boolean},leadingActionLabel:{}},emits:["select","leadingAction","editQuestions"],setup(i,{emit:l}){const{t:e}=we(),n=i,s=l,u=z(!1);let o=null;function c(b){u.value=!1,s("select",b)}function g(){n.disabled||n.questions.length===0||(o&&(clearTimeout(o),o=null),u.value=!0)}function h(){o=setTimeout(()=>{u.value=!1},150)}function f(){u.value=!1,s("editQuestions")}return Xt(()=>{o&&clearTimeout(o)}),(b,y)=>{const k=_e;return i.leadingActionLabel||i.questions.length>0?(r(),m("div",Xf,[a("div",Zf,[i.leadingActionLabel?(r(),m("button",{key:0,class:X(ca),disabled:n.disabled,onClick:y[0]||(y[0]=x=>s("leadingAction"))},d(i.leadingActionLabel),9,ev)):R("",!0),i.questions.length>0?(r(),m("div",{key:1,class:"relative shrink-0",onMouseenter:g,onMouseleave:h},[a("button",{class:X([ca,u.value?"ring-primary-300 bg-white/90 text-primary-600 dark:ring-primary-500/50 dark:bg-gray-800/90 dark:text-primary-400":""]),disabled:n.disabled},[a("span",av,[p(k,{name:"i-heroicons-chat-bubble-left-ellipsis",class:"h-3.5 w-3.5"}),le(" "+d(t(e)("ai.chat.input.quickAsk")),1)])],10,tv),p(vt,{"enter-active-class":"transition duration-200 ease-out","enter-from-class":"opacity-0 translate-y-2","enter-to-class":"opacity-100 translate-y-0","leave-active-class":"transition duration-150 ease-in","leave-from-class":"opacity-100 translate-y-0","leave-to-class":"opacity-0 translate-y-2"},{default:B(()=>[u.value?(r(),m("div",sv,[a("div",nv,[a("button",{class:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] text-gray-400 transition-colors hover:text-primary-500 dark:text-gray-500 dark:hover:text-primary-400",onClick:f},[p(k,{name:"i-heroicons-pencil-square",class:"h-3 w-3"}),le(" "+d(t(e)("ai.chat.input.editQuickAsk")),1)])]),a("div",ov,[(r(!0),m(ie,null,pe(i.questions,(x,_)=>(r(),m("button",{key:_,class:X(ca),disabled:n.disabled,onClick:C=>c(x)},d(x),9,lv))),128))])])):R("",!0)]),_:1})],32)):R("",!0)])])):R("",!0)}}}),iv=30;function uv(i,l){const e=z(null),n=z(!0),s=z(!1);function u(h=!1){setTimeout(()=>{e.value&&(h||n.value)&&(e.value.scrollTop=e.value.scrollHeight,n.value=!0,s.value=!1)},100)}function o(h){h.deltaY<0&&l.value&&(n.value=!1,s.value=!0)}function c(){if(!e.value)return;const{scrollTop:h,scrollHeight:f,clientHeight:b}=e.value;f-h-b<iv&&(n.value=!0,s.value=!1)}function g(){u(!0)}return fe(()=>{const h=i.value[i.value.length-1];return[i.value.length,h?.content,h?.contentBlocks?.length]},()=>u()),Re(()=>{e.value&&(e.value.addEventListener("scroll",c),e.value.addEventListener("wheel",o,{passive:!0})),i.value.length>0&&u(!0)}),Xt(()=>{e.value&&(e.value.removeEventListener("scroll",c),e.value.removeEventListener("wheel",o))}),{messagesContainer:e,showScrollToBottom:s,scrollToBottom:u,handleScrollToBottom:g}}function cv(){const i=Ft(),l=It(),e=z(!1),n=z(null),s=z(!1),u=z(!1),o=z(!1),c=z(!1),g=z(null);function h(w){n.value=w,s.value=!1,e.value=!0}function f(){u.value=!0}function b(w){n.value=w,s.value=!1,e.value=!0}function y(w){n.value=w,s.value=!0,e.value=!0}function k(){n.value=null,s.value=!1,e.value=!0}async function x(w){await i.loadAssistants(),await i.loadBuiltinCatalog()}async function _(){await i.loadAssistants()}function C(){o.value=!0}function $(w){g.value=w,c.value=!0}function S(){g.value=null,c.value=!0}async function T(){await l.loadSkills()}async function v(w){await l.loadSkills(),await l.loadBuiltinCatalog()}return{configModalVisible:e,configModalAssistantId:n,configModalReadonly:s,marketModalVisible:u,handleConfigureAssistant:h,handleOpenMarket:f,handleMarketConfigure:b,handleMarketViewConfig:y,handleCreateAssistant:k,handleAssistantCreated:x,handleAssistantConfigSaved:_,skillMarketModalVisible:o,skillConfigModalVisible:c,skillConfigModalSkillId:g,handleOpenSkillMarket:C,handleSkillMarketConfigure:$,handleCreateSkill:S,handleSkillConfigSaved:T,handleSkillCreated:v}}function dv(i){const l=[];let e=null;for(const n of i)n.role==="user"?(e&&l.push({user:e,assistant:null,standalone:null,id:e.id}),e=n):n.role==="assistant"?(l.push({user:e,assistant:n,standalone:null,id:e?.id||n.id}),e=null):(e&&(l.push({user:e,assistant:null,standalone:null,id:e.id}),e=null),l.push({user:null,assistant:null,standalone:n,id:n.id}));return e&&l.push({user:e,assistant:null,standalone:null,id:e.id}),l}const mv={class:"main-content flex h-full overflow-hidden"},gv={class:"flex h-full flex-1 overflow-hidden"},pv={class:"flex h-full flex-1"},hv={class:"relative flex min-w-[480px] flex-1 flex-col overflow-hidden"},fv={key:0,class:"flex items-center gap-1.5 px-3 py-1.5"},vv=["disabled"],yv={key:0,class:"flex w-full flex-col items-center justify-center animate-fade-in"},xv={key:0,class:"mb-3 text-center text-2xl font-semibold tracking-tight text-gray-800 dark:text-gray-100"},bv={class:"text-primary-600 dark:text-primary-400"},kv={key:1,class:"relative mb-8 w-full max-w-lg"},_v={class:"flex w-full justify-center"},wv={key:1,class:"qa-pair space-y-6 pb-4"},$v={key:1,class:"px-4 pb-2"},Cv={class:"mx-auto max-w-[740px]"},Sv={class:"px-4 pb-2"},Iv={class:"mx-auto max-w-[740px]"},Tv={key:0,class:"w-80 shrink-0 border-l border-gray-200 bg-gray-50/50 p-4 dark:border-gray-800 dark:bg-page-dark/50"},Mv=ue({__name:"ChatExplorer",props:{sessionId:{},sessionName:{},timeFilter:{},chatType:{}},setup(i,{expose:l}){const{t:e}=we(),n=nt(),s=Ma(),u=Ft(),o=It(),c=i,{messages:g,sourceMessages:h,currentKeywords:f,isLoadingSource:b,isAIThinking:y,currentAIChatId:k,currentToolStatus:x,toolsUsedInCurrentRound:_,sessionTokenUsage:C,agentStatus:$,selectedAssistantId:S,sendMessage:T,editMessageAndRegenerate:v,loadAIChat:w,startNewAIChat:E,loadMoreSourceMessages:F,updateMaxMessages:D,stopGeneration:A,selectAssistantForSession:I}=Rl(c.sessionId,c.sessionName,c.timeFilter,c.chatType??"group",s.locale),q=uv(g,y),{showScrollToBottom:Y,scrollToBottom:G,handleScrollToBottom:Z}=q,{configModalVisible:ce,configModalAssistantId:ne,configModalReadonly:H,marketModalVisible:W,skillMarketModalVisible:re,skillConfigModalVisible:ve,skillConfigModalSkillId:he,handleConfigureAssistant:ee,handleOpenMarket:te,handleMarketConfigure:j,handleMarketViewConfig:de,handleCreateAssistant:be,handleAssistantCreated:xe,handleAssistantConfigSaved:oe,handleOpenSkillMarket:Q,handleSkillMarketConfigure:J,handleCreateSkill:ge,handleSkillConfigSaved:ke,handleSkillCreated:$e}=cv(),Le=ka(),Be=z(0);fe(()=>k.value,async Ce=>{if(!Ce){Be.value=0;return}try{const Ie=await Ye().estimateContextTokens(Ce);Ie.success&&(Be.value=Ie.tokens)}catch{Be.value=0}},{immediate:!0});const Te=M(()=>u.selectedAssistant?.presetQuestions??[]),Pe=M(()=>c.chatType??"group"),je=z(!1),Se=z(!1),me=z(!0),O=z(void 0),V=z(null),K=z(null),L=z(null),P=z(!1),N=z(!1),ae=z(!1),se=M(()=>{const Ce=L.value?.name||e("ai.assistant.fallbackName");return e("ai.assistant.upgrade.backupName",{name:Ce})}),Ve=M(()=>dv(g.value));async function qe(){me.value=!0;try{Se.value=await $a().hasConfig()}catch(Ce){console.error("检查 LLM 配置失败:",Ce),Se.value=!1}finally{me.value=!1}}async function Me(){await qe(),Se.value&&await D()}l({refreshConfig:Me});const Fe=M(()=>{const Ce=u.selectedAssistant;if(!Ce)return{name:"",preview:""};const Ie=Ce.systemPrompt.replace(/#{1,6}\s+[^\n]*/g,"").replace(/\n+/g," ").replace(/\s+/g," ").trim();return{name:Ce.name,preview:Ie}}),st=M(()=>!!S.value&&g.value.length===0&&!y.value);function oa(){n.warn(e("ai.chat.backgroundTask.runningTitle"),{description:e("ai.chat.backgroundTask.runningDescription")})}function Ea(){n.warn(e("ai.chat.backgroundTask.blockedAction"))}function Cs(Ce){if(Ce!==S.value){if(!I(Ce)){Ea();return}o.activateSkill(null),E()}}async function Ss(Ce){const Ie=await T(Ce);!Ie.success&&Ie.reason==="busy"&&oa()}function Is(){const Ce=u.selectedAssistant?.id;Ce&&(O.value="presetQuestions",ee(Ce))}function Ts(Ce){ce.value=Ce,Ce||(O.value=void 0)}function Ms(){K.value?.openSkillSelector()}function As(){G(!0)}async function Ba(){const Ce=await u.checkDefaultAssistantUpgrade(s.locale);Ce&&(L.value=Ce,P.value=!0)}async function zs(){const Ce=L.value;if(!(!Ce||N.value||ae.value)){ae.value=!0;try{const Ie=await u.skipAssistantUpgrade(Ce);if(!Ie.success){n.fail(e("ai.assistant.upgrade.skipFailed"),{description:Ie.error||e("ai.assistant.toast.unknownError")});return}P.value=!1,L.value=null}finally{ae.value=!1}}}async function qs(){const Ce=L.value;if(!(!Ce||N.value||ae.value)){N.value=!0;try{const Ie=se.value,kt=await u.upgradeAssistantWithBackup(Ce,Ie);if(!kt.success){n.fail(e("ai.assistant.upgrade.failed"),{description:kt.error||e("ai.assistant.toast.unknownError")});return}P.value=!1,L.value=null,n.success(e("ai.assistant.upgrade.success"),{description:e("ai.assistant.upgrade.successDescription",{name:Ie})})}finally{N.value=!1}}}async function Ls(Ce){const Ie=await T(Ce.content,{mentionedMembers:Ce.mentionedMembers});if(!Ie.success){Ie.reason==="busy"&&oa();return}G(!0),V.value?.refresh()}async function Ds(Ce){const Ie=await v(Ce.messageId,Ce.content,{overwriteSubsequent:Ce.overwriteSubsequent});if(!Ie.success){Ie.reason==="busy"&&oa();return}G(!0),V.value?.refresh()}async function Es(Ce){if(k.value)try{const Ie=await Ye().forkAIChat(k.value,Ce);await w(Ie.id),V.value?.refresh(),G(!0),n.success(e("ai.chat.fork.success"))}catch(Ie){n.fail(e("ai.chat.fork.failed"),{description:String(Ie)})}}function Bs(){je.value=!je.value}async function Fs(){await F()}async function Rs(Ce){await w(Ce),G(!0)}function Vs(){if(y.value){Ea();return}E()}function Os(Ce){k.value===Ce&&E()}function Ps(){A()}return qe(),D(),Re(()=>{Ba()}),fe(()=>s.locale,()=>{Ba()}),fe(()=>Le.aiConfigVersion,async()=>{await Me()}),(Ce,Ie)=>{const kt=_e,js=St;return r(),m("div",mv,[p(zc,{ref_key:"conversationListRef",ref:V,"session-id":i.sessionId,"active-id":t(k),disabled:t(y),onSelect:Rs,onCreate:Vs,onDelete:Os},null,8,["session-id","active-id","disabled"]),a("div",gv,[a("div",pv,[a("div",hv,[t(g).length>0||t(y)?(r(),m("div",fv,[a("button",{class:X(["flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",{"cursor-not-allowed opacity-50":t(y)||!t(u).selectedAssistant?.id}]),disabled:t(y)||!t(u).selectedAssistant?.id,onClick:Ie[0]||(Ie[0]=Ae=>t(ee)(t(u).selectedAssistant.id))},[p(kt,{name:"i-heroicons-sparkles",class:"h-3.5 w-3.5"}),a("span",null,d(t(u).selectedAssistant?.name||t(e)("ai.assistant.fallbackName")),1)],10,vv)])):R("",!0),a("div",{ref:t(q).messagesContainer,class:X(["relative min-h-0 flex-1 overflow-x-hidden overflow-y-auto p-4",{"p-0!":t(g).length===0&&!t(y)}])},[a("div",{class:X(["mx-auto max-w-3xl space-y-6",{"flex min-h-full flex-col justify-center px-4 pb-32 pt-4 space-y-0!":t(g).length===0&&!t(y),"px-4":t(g).length>0||t(y)}])},[t(g).length===0&&!t(y)?(r(),m("div",yv,[Fe.value.name?(r(),m("h2",xv,[le(d(t(e)("ai.assistant.selector.heroTitlePrefix","使用"))+" ",1),a("span",bv,d(Fe.value.name),1),le(" "+d(t(e)("ai.assistant.selector.heroTitleSuffix","开始对话")),1)])):R("",!0),st.value&&Fe.value.name?(r(),m("div",kv,[a("p",{class:"cursor-pointer pr-7 text-center text-sm leading-relaxed text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300 line-clamp-2",onClick:Ie[1]||(Ie[1]=Ae=>t(ee)(t(u).selectedAssistant.id))},[p(js,{text:t(e)("ai.assistant.config.systemPrompt","系统设定"),popper:{placement:"top"}},{default:B(()=>[le(d(Fe.value.preview),1)]),_:1},8,["text"])]),a("button",{type:"button",class:"absolute bottom-0 right-0 rounded-md p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-200",onClick:Ie[2]||(Ie[2]=Oe(Ae=>t(ee)(t(u).selectedAssistant.id),["stop"]))},[p(kt,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})])])):R("",!0),a("div",_v,[p(w0,{"chat-type":Pe.value,locale:t(s).locale,"selected-id":t(S),onSelect:Cs,onMarket:t(te)},null,8,["chat-type","locale","selected-id","onMarket"])])])):R("",!0),(r(!0),m(ie,null,pe(Ve.value,Ae=>(r(),m(ie,{key:Ae.id},[Ae.standalone?(r(),U(ua,{key:0,role:Ae.standalone.role,content:Ae.standalone.content,timestamp:Ae.standalone.timestamp},null,8,["role","content","timestamp"])):(r(),m("div",wv,[Ae.user&&(Ae.user.role==="user"||Ae.user.content)?(r(),U(ua,{key:0,role:Ae.user.role,"message-id":Ae.user.id,content:Ae.user.content,timestamp:Ae.user.timestamp,"is-streaming":Ae.user.isStreaming,"content-blocks":Ae.user.contentBlocks,editable:!t(y),onEdit:Ds},null,8,["role","message-id","content","timestamp","is-streaming","content-blocks","editable"])):R("",!0),Ae.assistant&&(Ae.assistant.content||Ae.assistant.contentBlocks&&Ae.assistant.contentBlocks.length>0)?(r(),U(ua,{key:1,role:Ae.assistant.role,"message-id":Ae.assistant.id,content:Ae.assistant.content,timestamp:Ae.assistant.timestamp,"is-streaming":Ae.assistant.isStreaming,"content-blocks":Ae.assistant.contentBlocks,"show-capture-button":!Ae.assistant.isStreaming,onFork:Es},null,8,["role","message-id","content","timestamp","is-streaming","content-blocks","show-capture-button"])):R("",!0)]))],64))),128)),t(y)&&!t(g)[t(g).length-1]?.content&&!(t(g)[t(g).length-1]?.contentBlocks?.length??0)?(r(),U(Gp,{key:1,"current-tool-status":t(x),"tools-used":t(_),"agent-status":t($)},null,8,["current-tool-status","tools-used","agent-status"])):R("",!0)],2)],2),p(vt,{name:"fade-up"},{default:B(()=>[t(Y)?(r(),m("button",{key:0,class:"absolute bottom-20 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full bg-gray-800/90 px-3 py-1.5 text-xs text-white shadow-lg backdrop-blur-sm transition-all hover:bg-gray-700 dark:bg-gray-700/90 dark:hover:bg-gray-600",onClick:Ie[3]||(Ie[3]=(...Ae)=>t(Z)&&t(Z)(...Ae))},[p(kt,{name:"i-heroicons-arrow-down",class:"h-3.5 w-3.5"}),a("span",null,d(t(e)("ai.chat.scrollToBottom")),1)])):R("",!0)]),_:1}),t(g).length===0&&!t(y)?(r(),m("div",$v,[a("div",Cv,[p(rv,{questions:Te.value,"leading-action-label":t(e)("ai.chat.input.useSkill"),onSelect:Ss,onLeadingAction:Ms,onEditQuestions:Is},null,8,["questions","leading-action-label"])])])):R("",!0),a("div",Sv,[a("div",Iv,[p(Ep,{ref_key:"chatInputRef",ref:K,"session-id":i.sessionId,disabled:t(y),status:t(y)?"streaming":"ready","chat-type":Pe.value,onSend:Ls,onStop:Ps,onManageSkills:t(Q),onSkillActivated:As},null,8,["session-id","disabled","status","chat-type","onManageSkills"]),p(h0,{"session-token-usage":t(C),"agent-status":t($),"current-ai-chat-id":t(k),"current-messages":t(g),"fallback-title":i.sessionName,"estimated-context-tokens":Be.value},null,8,["session-token-usage","agent-status","current-ai-chat-id","current-messages","fallback-title","estimated-context-tokens"])])])])]),p(vt,{name:"slide-fade"},{default:B(()=>[t(h).length>0&&!je.value?(r(),m("div",Tv,[p(ed,{messages:t(h),keywords:t(f),"is-loading":t(b),"is-collapsed":je.value,class:"h-full",onToggle:Bs,onLoadMore:Fs},null,8,["messages","keywords","is-loading","is-collapsed"])])):R("",!0)]),_:1})]),p(gh,{open:t(ce),"assistant-id":t(ne),readonly:t(H),"scroll-to-section":O.value,"onUpdate:open":Ts,onSaved:t(oe),onCreated:t(xe)},null,8,["open","assistant-id","readonly","scroll-to-section","onSaved","onCreated"]),p(rf,{open:P.value,"backup-name":se.value,upgrading:N.value,skipping:ae.value,onSkip:zs,onConfirm:qs},null,8,["open","backup-name","upgrading","skipping"]),p(Gh,{open:t(W),"onUpdate:open":Ie[4]||(Ie[4]=Ae=>W.value=Ae),onConfigure:t(j),onViewConfig:t(de),onCreate:t(be)},null,8,["open","onConfigure","onViewConfig","onCreate"]),p(jf,{open:t(re),"onUpdate:open":Ie[5]||(Ie[5]=Ae=>re.value=Ae),onConfigure:t(J),onCreate:t(ge)},null,8,["open","onConfigure","onCreate"]),p(Jf,{open:t(ve),"skill-id":t(he),"onUpdate:open":Ie[6]||(Ie[6]=Ae=>ve.value=Ae),onSaved:t(ke),onCreated:t($e)},null,8,["open","skill-id","onSaved","onCreated"])])}}}),Kw=dt(Mv,[["__scopeId","data-v-3b042ff8"]]),da="__ALL__",Av=ue({__name:"UserSelect",props:{sessionId:{},modelValue:{}},emits:["update:modelValue"],setup(i,{emit:l}){const{t:e}=we(),n=i,s=l,u=z([]),o=z(!1),c=M({get:()=>n.modelValue===null?da:String(n.modelValue),set:f=>{s("update:modelValue",f===da?null:parseInt(f))}}),g=M(()=>{const f=[{value:da,label:e("common.userSelect.allMembers")}];return u.value.forEach(b=>{const y=b.groupNickname||b.accountName||b.platformId;f.push({value:String(b.id),label:`${y} (${b.messageCount})`})}),f});async function h(){if(n.sessionId){o.value=!0;try{const f=await Ke().getMembers(n.sessionId);u.value=f.sort((b,y)=>y.messageCount-b.messageCount)}catch(f){console.error("加载成员列表失败:",f)}finally{o.value=!1}}}return fe(()=>n.sessionId,()=>{s("update:modelValue",null),h()},{immediate:!0}),(f,b)=>{const y=Da;return r(),U(y,{modelValue:c.value,"onUpdate:modelValue":b[0]||(b[0]=k=>c.value=k),items:g.value,loading:o.value,virtualize:{estimateSize:32,overscan:10},"value-key":"value",class:"w-48"},null,8,["modelValue","items","loading"])}}}),zv=ue({__name:"EChartCalendar",props:{data:{},height:{default:180},year:{}},setup(i){ta([hs,fs,za,vs,aa]);const l=i,{t:e,locale:n}=we(),s=Zt(),u=z(null);let o=null;const c=M(()=>{if(l.year)return l.year;if(l.data.length===0)return new Date().getFullYear();const _=l.data.map(C=>parseInt(C.date.split("-")[0]));return Math.max(..._)}),g=M(()=>l.data.length===0?10:Math.max(...l.data.map(_=>_.value),1)),h=M(()=>l.data.map(_=>[_.date,_.value])),f={light:["#fee5e8","#fbb5c2","#f7758c","#ee4567"],dark:["#3d1f24","#6b2f3a","#a34557","#ee4567"]},b=M(()=>({tooltip:{trigger:"item",formatter:_=>{const C=_.data[0],$=_.data[1];return`${C}<br/>${e("views.message.calendarTooltipMessages")}: ${$}`}},visualMap:{min:0,max:g.value,calculable:!1,orient:"horizontal",left:"center",bottom:0,itemWidth:10,itemHeight:100,text:[`${g.value}`,"0"],inRange:{color:s.value?f.dark:f.light},textStyle:{color:s.value?"#9ca3af":"#6b7280",fontSize:10},show:!0},calendar:{top:30,left:40,cellSize:[13,13],range:String(c.value),itemStyle:{borderWidth:2,borderColor:s.value?"#1f2937":"#ffffff"},yearLabel:{show:!0,position:"top",color:s.value?"#9ca3af":"#6b7280",fontSize:12},monthLabel:{show:!0,color:s.value?"#9ca3af":"#6b7280",fontSize:10,nameMap:[e("common.month.jan"),e("common.month.feb"),e("common.month.mar"),e("common.month.apr"),e("common.month.may"),e("common.month.jun"),e("common.month.jul"),e("common.month.aug"),e("common.month.sep"),e("common.month.oct"),e("common.month.nov"),e("common.month.dec")]},dayLabel:{show:!0,firstDay:1,color:s.value?"#6b7280":"#9ca3af",fontSize:10,nameMap:[e("common.weekday.sun"),e("common.weekday.mon"),e("common.weekday.tue"),e("common.weekday.wed"),e("common.weekday.thu"),e("common.weekday.fri"),e("common.weekday.sat")]},splitLine:{show:!1}},series:[{type:"heatmap",coordinateSystem:"calendar",data:h.value}]}));function y(){u.value&&(o=sa(u.value,s.value?"dark":void 0,{renderer:"canvas"}),o.setOption({backgroundColor:"transparent",...b.value}))}function k(){o&&o.setOption({backgroundColor:"transparent",...b.value},{notMerge:!0})}function x(){o?.resize()}return fe([()=>l.data,s,n],()=>{k()}),fe(()=>l.year,()=>{k()}),Re(()=>{y(),window.addEventListener("resize",x)}),tt(()=>{window.removeEventListener("resize",x),o?.dispose()}),(_,C)=>(r(),m("div",{ref_key:"chartRef",ref:u,style:et({height:`${i.height}px`,width:"100%"})},null,4))}}),qv={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Lv={class:"flex items-center gap-6 sm:gap-10"},Dv={class:"min-w-0 flex-1"},Ev={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},Bv={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},Fv={class:"mb-4 flex min-w-0 flex-wrap items-baseline gap-2"},Rv={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Vv={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Ov={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Pv={key:1,class:"flex min-w-0 max-w-full flex-wrap items-center gap-x-1.5 gap-y-1.5"},jv={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Nv={class:"font-bold tabular-nums text-pink-500 dark:text-pink-400"},Uv={class:"flex shrink-0 flex-col items-center"},Wv={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},Hv={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Kv={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Yv={class:"min-w-0 flex-1"},Gv={class:"flex items-center justify-between gap-1"},Qv={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},Jv={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Xv={class:"relative z-10 flex items-center justify-between px-6 pb-4 opacity-40 mix-blend-luminosity dark:opacity-30 sm:px-8 sm:pb-5"},Zv={class:"flex items-center gap-1.5"},ey={class:"text-[9px] font-medium uppercase tracking-widest"},ty=ue({__name:"TypeProfileCard",props:{sessionId:{},messageTypes:{},textStats:{},timeFilter:{}},setup(i){ta([Jn,za,aa]);const{t:l}=we(),e=Zt(),n=i,s=M(()=>n.messageTypes.reduce((I,q)=>I+q.count,0)),u=M(()=>n.messageTypes.find(I=>I.type===gt.TEXT)?.count??0),o=M(()=>{if(s.value===0)return 0;const I=s.value-u.value;return Math.round(I/s.value*100)}),c=M(()=>n.textStats.textCount===0?0:Math.round(n.textStats.shortCount/n.textStats.textCount*100)),g=z({first:"",last:""});async function h(){if(n.sessionId)try{const I=await Ke().getDailyActivity(n.sessionId,n.timeFilter);if(I.length>0){const q=[...I].sort((Y,G)=>Y.date.localeCompare(G.date));g.value={first:Ee(q[0].date).format("YYYY/MM/DD"),last:Ee(q[q.length-1].date).format("YYYY/MM/DD")}}}catch{}}function f(I){return n.messageTypes.find(q=>q.type===I)?.count??0}const b=M(()=>[{label:l("views.message.typeCard.nonTextImage"),count:f(gt.IMAGE),unit:l("views.message.typeCard.unitImage")},{label:l("views.message.typeCard.nonTextEmoji"),count:f(gt.EMOJI),unit:l("views.message.typeCard.unitEmoji")},{label:l("views.message.typeCard.nonTextVoice"),count:f(gt.VOICE),unit:l("views.message.typeCard.unitVoice")},{label:l("views.message.typeCard.nonTextVideo"),count:f(gt.VIDEO),unit:l("views.message.typeCard.unitVideo")},{label:l("views.message.typeCard.nonTextFile"),count:f(gt.FILE),unit:l("views.message.typeCard.unitFile")},{label:l("views.message.typeCard.nonTextLink"),count:f(gt.LINK),unit:l("views.message.typeCard.unitLink")}].filter(I=>I.count>0)),y=z(30),k=z(0),x=z(!1),_=[{label:"20",value:20},{label:"30",value:30},{label:"50",value:50},{label:"80",value:80},{label:"100",value:100}],C=M({get:()=>y.value,set:I=>{y.value!==I&&(y.value=I,$())}});async function $(){if(n.sessionId){x.value=!0;try{k.value=await Ke().getLongMessageCount(n.sessionId,n.timeFilter,y.value)}catch(I){console.error("[chart-message] Failed to load essay count:",I)}finally{x.value=!1}}}fe(()=>[n.sessionId,n.timeFilter],()=>{$(),h()},{immediate:!0,deep:!0});const S=M(()=>[{icon:"i-heroicons-pencil-square",label:l("views.message.profile.textExpression"),value:l("views.message.profile.avgLengthUnit",{count:n.textStats.avgLength||0}),subtext:n.textStats.maxLength>0?l("views.message.profile.textExpressionDesc",{count:n.textStats.maxLength}):"",colorClass:"text-violet-600 dark:text-violet-400"},{icon:"i-heroicons-chat-bubble-bottom-center-text",label:l("views.message.profile.shortMaster"),value:`${c.value}%`,subtext:l("views.message.profile.shortMasterDesc",{count:n.textStats.shortCount}),colorClass:"text-emerald-600 dark:text-emerald-400"},{icon:"i-heroicons-document-text",label:l("views.message.profile.essayLover"),value:k.value.toLocaleString(),subtext:l("views.message.profile.essayLoverDesc",{threshold:y.value}),colorClass:"text-indigo-600 dark:text-indigo-400",slot:"essay-threshold"},{icon:"i-heroicons-photo",label:l("views.message.profile.mediaRichness"),value:`${o.value}%`,subtext:b.value.slice(0,3).map(I=>`${I.label} ${I.count}`).join(" · ")||"-",colorClass:"text-pink-600 dark:text-pink-400"}]),T=z(null);let v=null;const w=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],E=M(()=>[...n.messageTypes].sort((q,Y)=>Y.count-q.count).slice(0,8).map((q,Y)=>({name:ma(q.type,l),value:q.count,itemStyle:{color:w[Y%w.length]}})));function F(){T.value&&(v=sa(T.value,void 0,{renderer:"canvas"}),D())}function D(){v&&v.setOption({backgroundColor:"transparent",tooltip:{trigger:"item",formatter:"{b}: {c} ({d}%)"},series:[{type:"pie",radius:["50%","78%"],center:["50%","50%"],avoidLabelOverlap:!1,padAngle:2,itemStyle:{borderRadius:4},label:{show:!1},emphasis:{label:{show:!1},scaleSize:4},data:E.value}]},{notMerge:!0})}function A(){v?.resize()}return fe(()=>n.messageTypes,()=>D()),fe(e,()=>{v?.dispose(),F()}),Re(()=>{F(),window.addEventListener("resize",A)}),tt(()=>{window.removeEventListener("resize",A),v?.dispose()}),(I,q)=>{const Y=_e,G=wa;return r(),U(t(na),null,{default:B(()=>[a("div",qv,[a("div",Lv,[a("div",Dv,[a("div",Ev,[g.value.first?(r(),m("p",Bv,d(g.value.first)+" – "+d(g.value.last),1)):R("",!0),a("div",Fv,[a("span",Rv,d(t(l)("views.message.profile.heroLine1Prefix")),1),a("span",Vv,d(s.value.toLocaleString()),1),a("span",Ov,d(t(l)("views.message.profile.heroLine1Suffix")),1)]),b.value.length>0?(r(),m("div",Pv,[a("span",jv,d(t(l)("views.message.typeCard.nonTextPrefix")),1),(r(!0),m(ie,null,pe(b.value,Z=>(r(),m("span",{key:Z.label,class:"inline-flex items-center gap-1 rounded-full bg-gray-100 px-2.5 py-0.5 text-xs font-semibold text-gray-700 dark:bg-white/10 dark:text-gray-200"},[a("span",Nv,d(Z.count.toLocaleString()),1),a("span",null,d(Z.unit),1)]))),128))])):R("",!0)])]),a("div",Uv,[a("div",Wv,d(t(l)("views.message.profile.typeDistribution")),1),a("div",{ref_key:"donutRef",ref:T,style:{width:"130px",height:"130px"}},null,512)])])]),a("div",Hv,[q[1]||(q[1]=a("div",{class:"mb-3 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Type Profile ")],-1)),a("div",Kv,[(r(!0),m(ie,null,pe(S.value,Z=>(r(),m("div",{key:Z.icon+Z.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[p(Y,{name:Z.icon,class:X(["mt-0.5 h-3.5 w-3.5 shrink-0",Z.colorClass])},null,8,["name","class"]),a("div",Yv,[a("div",Gv,[a("div",{class:X(["truncate font-mono text-sm font-black leading-tight tabular-nums",Z.colorClass])},d(Z.value),3),Z.slot==="essay-threshold"?(r(),U(G,{key:0,modelValue:C.value,"onUpdate:modelValue":q[0]||(q[0]=ce=>C.value=ce),items:_,"value-key":"value",size:"xs",class:"relative z-120 w-16 shrink-0",ui:{content:"z-[121]"},disabled:x.value},null,8,["modelValue","disabled"])):R("",!0)]),a("div",Qv,d(Z.label),1),a("div",Jv,d(Z.subtext),1)])]))),128))])]),a("div",Xv,[a("div",Zv,[p(Y,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),q[2]||(q[2]=a("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),a("span",ey,d(t(l)("views.message.typeCard.watermark")),1)])]),_:1})}}}),ay={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-4 sm:p-6"},sy={class:"p-5"},ny={key:0,class:"grid grid-cols-1 gap-6 lg:grid-cols-2 lg:items-center"},oy={class:"space-y-3"},ly={class:"min-w-20 shrink-0 text-sm text-gray-700 dark:text-gray-300"},ry={class:"flex-1"},iy={class:"h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800"},uy={class:"shrink-0 text-right"},cy={class:"text-sm font-medium text-gray-900 dark:text-white"},dy={class:"ml-1 text-xs text-gray-400"},my={key:1,class:"flex h-48 items-center justify-center text-gray-400"},gy={class:"p-5"},py={class:"mb-5 grid grid-cols-2 gap-3 sm:grid-cols-4"},hy={class:"p-3"},fy={class:"font-mono text-xl font-bold text-gray-900 dark:text-white"},vy={class:"mt-1 text-xs text-gray-500"},yy={class:"p-3"},xy={class:"font-mono text-xl font-bold text-indigo-600 dark:text-indigo-400"},by={class:"mt-1 text-xs text-gray-500"},ky={class:"p-3"},_y={class:"font-mono text-xl font-bold text-pink-600 dark:text-pink-400"},wy={class:"mt-1 text-xs text-gray-500"},$y={class:"p-3"},Cy={class:"font-mono text-xl font-bold text-emerald-600 dark:text-emerald-400"},Sy={class:"mt-1 text-xs text-gray-500"},Iy={class:"mb-5 rounded-lg border border-gray-200 p-4 dark:border-gray-700"},Ty={class:"mb-2 text-xs font-medium text-gray-500 dark:text-gray-400"},My={class:"flex items-center gap-4 text-sm"},Ay={class:"flex items-center gap-1.5"},zy={class:"font-mono font-medium text-gray-900 dark:text-white"},qy={class:"flex items-center gap-1.5"},Ly={class:"font-mono font-medium text-gray-900 dark:text-white"},Dy={class:"flex items-center gap-1.5"},Ey={class:"font-mono font-medium text-gray-900 dark:text-white"},By={class:"flex items-center gap-1.5"},Fy={class:"font-mono font-medium text-gray-900 dark:text-white"},Ry={class:"mt-3 grid grid-cols-3 gap-3 text-xs"},Vy={class:"text-gray-500"},Oy={class:"ml-1 font-medium text-emerald-600 dark:text-emerald-400"},Py={class:"text-gray-400"},jy={class:"text-gray-500"},Ny={class:"ml-1 font-medium text-indigo-600 dark:text-indigo-400"},Uy={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},Wy={class:"text-xs text-gray-400"},Hy={class:"p-5"},Ky={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Yy={class:"text-xs text-gray-400"},Gy={class:"p-5"},Qy={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Yw=ue({__name:"TypeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(i){const l=i,{t:e}=we(),n=z(!0),s=z([]),u=z([]),o=z([]),c=z({textCount:0,avgLength:0,maxLength:0,shortCount:0}),g=z({p25:0,p50:0,p75:0,p90:0}),h=z(0),f=M(()=>{const S=[...s.value].sort((T,v)=>v.count-T.count);return{labels:S.map(T=>ma(T.type,e)),values:S.map(T=>T.count)}}),b=M(()=>{const S=s.value.reduce((v,w)=>v+w.count,0);return[...s.value].sort((v,w)=>w.count-v.count).map(v=>({name:ma(v.type,e),count:v.count,percentage:S>0?Math.round(v.count/S*100):0}))}),y=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"];function k(S){return y[S%y.length]}const x=M(()=>({labels:u.value.map(S=>String(S.len)),values:u.value.map(S=>S.count)})),_=M(()=>({labels:o.value.map(S=>S.range),values:o.value.map(S=>S.count)})),C=M(()=>c.value.textCount===0?0:Math.round(c.value.shortCount/c.value.textCount*100));async function $(){if(l.sessionId){n.value=!0;try{const S=Ke(),[T,v,w,E,F]=await Promise.all([S.getMessageTypeDistribution(l.sessionId,l.timeFilter),S.getMessageLengthDistribution(l.sessionId,l.timeFilter),S.getTextStats(l.sessionId,l.timeFilter),S.getTextLengthPercentiles(l.sessionId,l.timeFilter),S.getLongMessageCount(l.sessionId,l.timeFilter,30)]);s.value=T,u.value=v.detail,o.value=v.grouped,c.value=w,g.value=E,h.value=F}catch(S){console.error("[chart-message] Failed to load type analysis data:",S)}finally{n.value=!1}}}return fe(()=>[l.sessionId,l.timeFilter],()=>$(),{immediate:!0,deep:!0}),(S,T)=>(r(),m("div",{class:X(n.value?"h-full":"")},[n.value?(r(),U(t(Kt),{key:0,variant:"page",text:t(e)("common.loading")},null,8,["text"])):(r(),m("div",ay,[s.value.length>0?(r(),U(ty,{key:0,"session-id":i.sessionId,"message-types":s.value,"text-stats":c.value,"time-filter":i.timeFilter},null,8,["session-id","message-types","text-stats","time-filter"])):R("",!0),p(t(Ze),{title:t(e)("views.message.typeDistribution"),"show-divider":!1},{default:B(()=>[a("div",sy,[f.value.values.length>0?(r(),m("div",ny,[a("div",null,[p(t(ya),{data:f.value,height:280,"show-legend":!1},null,8,["data"])]),a("div",null,[a("div",oy,[(r(!0),m(ie,null,pe(b.value,(v,w)=>(r(),m("div",{key:w,class:"flex items-center gap-3"},[a("div",{class:"h-3 w-3 shrink-0 rounded-full",style:et({backgroundColor:k(w)})},null,4),a("div",ly,d(v.name),1),a("div",ry,[a("div",iy,[a("div",{class:"h-full rounded-full transition-all",style:et({width:`${v.percentage}%`,backgroundColor:k(w)})},null,4)])]),a("div",uy,[a("span",cy,d(v.count.toLocaleString()),1),a("span",dy,"("+d(v.percentage)+"%)",1)])]))),128))])])])):(r(),m("div",my,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"]),p(t(Ze),{title:t(e)("views.message.typeAnalysis.textDepthTitle"),"show-divider":!1},{default:B(()=>[a("div",gy,[a("div",py,[a("div",hy,[a("div",fy,d(c.value.textCount.toLocaleString()),1),a("div",vy,d(t(e)("views.message.typeAnalysis.textTotal")),1)]),a("div",yy,[a("div",xy,d(c.value.avgLength||0),1),a("div",by,d(t(e)("views.message.typeAnalysis.avgLength")),1)]),a("div",ky,[a("div",_y,d(g.value.p50),1),a("div",wy,d(t(e)("views.message.typeAnalysis.medianLength")),1)]),a("div",$y,[a("div",Cy,d(c.value.maxLength),1),a("div",Sy,d(t(e)("views.message.typeAnalysis.maxLength")),1)])]),a("div",Iy,[a("div",Ty,d(t(e)("views.message.typeAnalysis.percentiles")),1),a("div",My,[a("div",Ay,[T[0]||(T[0]=a("span",{class:"text-gray-500"},"P25",-1)),a("span",zy,d(g.value.p25),1)]),a("div",qy,[T[1]||(T[1]=a("span",{class:"text-gray-500"},"P50",-1)),a("span",Ly,d(g.value.p50),1)]),a("div",Dy,[T[2]||(T[2]=a("span",{class:"text-gray-500"},"P75",-1)),a("span",Ey,d(g.value.p75),1)]),a("div",By,[T[3]||(T[3]=a("span",{class:"text-gray-500"},"P90",-1)),a("span",Fy,d(g.value.p90),1)])]),a("div",Ry,[a("div",null,[a("span",Vy,d(t(e)("views.message.typeAnalysis.shortMessages")),1),a("span",Oy,d(C.value)+"%",1),a("span",Py,"("+d(c.value.shortCount)+")",1)]),a("div",null,[a("span",jy,d(t(e)("views.message.typeAnalysis.essayMessages")),1),a("span",Ny,d(h.value),1)])])])])]),_:1},8,["title"]),a("div",Uy,[p(t(Ze),{title:t(e)("views.message.lengthDetailTitle"),"show-divider":!1},{headerRight:B(()=>[a("span",Wy,d(t(e)("views.message.lengthDetailHint")),1)]),default:B(()=>[a("div",Hy,[x.value.values.some(v=>v>0)?(r(),U(t(rt),{key:0,data:x.value,height:200},null,8,["data"])):(r(),m("div",Ky,d(t(e)("views.message.noTextMessages")),1))])]),_:1},8,["title"]),p(t(Ze),{title:t(e)("views.message.lengthGroupedTitle"),"show-divider":!1},{headerRight:B(()=>[a("span",Yy,d(t(e)("views.message.lengthGroupedHint")),1)]),default:B(()=>[a("div",Gy,[_.value.values.some(v=>v>0)?(r(),U(t(rt),{key:0,data:_.value,height:200},null,8,["data"])):(r(),m("div",Qy,d(t(e)("views.message.noTextMessages")),1))])]),_:1},8,["title"])])]))],2))}}),Jy={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Xy={class:"flex items-start gap-6 sm:gap-10"},Zy={class:"min-w-0 flex-1"},ex={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},tx={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},ax={class:"mb-3 flex items-baseline gap-2"},sx={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},nx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},ox={class:"font-bold text-3xl text-indigo-500 dark:text-indigo-400"},lx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},rx={class:"flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},ix={class:"text-base font-medium text-gray-600 dark:text-gray-300"},ux={class:"font-bold text-xl text-pink-500 dark:text-pink-400"},cx={class:"text-base font-medium text-gray-600 dark:text-gray-300"},dx={class:"text-base font-medium text-amber-600 dark:text-amber-400"},mx={class:"flex shrink-0 flex-col items-center"},gx={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},px={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},hx={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},fx={class:"min-w-0 flex-1"},vx={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},yx={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},xx={class:"relative z-10 flex items-center justify-between px-6 pb-4 opacity-40 mix-blend-luminosity dark:opacity-30 sm:px-8 sm:pb-5"},bx={class:"flex items-center gap-1.5"},kx={class:"text-[9px] font-medium uppercase tracking-widest"},_x=ue({__name:"TimeProfileCard",props:{hourlyActivity:{},weekdayActivity:{},dailyActivity:{}},setup(i){ta([Xn,Zn,aa]);const{t:l}=we(),e=Zt(),n=i,s=M(()=>n.dailyActivity.filter(v=>v.messageCount>0).length),u=M(()=>n.dailyActivity.reduce((v,w)=>v+w.messageCount,0)),o=M(()=>{if(n.dailyActivity.length===0)return{first:"",last:"",days:0};const v=[...n.dailyActivity].sort((F,D)=>F.date.localeCompare(D.date)),w=Ee(v[0].date),E=Ee(v[v.length-1].date);return{first:w.format("YYYY/MM/DD"),last:E.format("YYYY/MM/DD"),days:E.diff(w,"day")+1}}),c=M(()=>s.value===0?0:Math.round(u.value/s.value)),g=M(()=>n.dailyActivity.length===0?null:n.dailyActivity.reduce((v,w)=>w.messageCount>v.messageCount?w:v,n.dailyActivity[0])),h=M(()=>n.hourlyActivity.length===0?[]:[...n.hourlyActivity].sort((v,w)=>w.messageCount-v.messageCount).slice(0,3)),f=M(()=>{if(n.hourlyActivity.length===0&&n.weekdayActivity.length===0)return null;const v=o.value.days>0?s.value/o.value.days:0,w=n.weekdayActivity.filter(H=>H.weekday===6||H.weekday===7),E=n.weekdayActivity.filter(H=>H.weekday>=1&&H.weekday<=5),F=w.reduce((H,W)=>H+W.messageCount,0),D=E.reduce((H,W)=>H+W.messageCount,0),A=F+D,I=A>0?F/A:0,q=n.hourlyActivity.reduce((H,W)=>H+W.messageCount,0),Y=n.hourlyActivity.filter(H=>H.hour>=22||H.hour<5).reduce((H,W)=>H+W.messageCount,0),G=n.hourlyActivity.filter(H=>H.hour>=18&&H.hour<22).reduce((H,W)=>H+W.messageCount,0),Z=q>0?Y/q:0,ce=q>0?G/q:0;if(v>=.9)return{label:l("views.message.timeCard.personalityEveryday"),icon:"i-heroicons-fire"};if(I>=.55)return{label:l("views.message.timeCard.personalityWeekend"),icon:"i-heroicons-calendar"};if(I<=.2&&A>0)return{label:l("views.message.timeCard.personalityWeekday"),icon:"i-heroicons-briefcase"};if(Z>=.3)return{label:l("views.message.timeCard.personalityNightOwl"),icon:"i-heroicons-moon"};if(ce>=.4)return{label:l("views.message.timeCard.personalityEveningChat"),icon:"i-heroicons-sparkles"};const ne=[...n.hourlyActivity].sort((H,W)=>W.messageCount-H.messageCount)[0];return ne?ne.hour>=5&&ne.hour<9?{label:l("views.message.timeCard.personalityEarlyBird"),icon:"i-heroicons-sun"}:ne.hour>=12&&ne.hour<14?{label:l("views.message.timeCard.personalityLunchChat"),icon:"i-heroicons-clock"}:{label:l("views.message.timeCard.personalityDaytime"),icon:"i-heroicons-sun"}:null}),b=M(()=>{const v=n.weekdayActivity.filter(A=>A.weekday===6||A.weekday===7),w=n.weekdayActivity.filter(A=>A.weekday>=1&&A.weekday<=5),E=v.reduce((A,I)=>A+I.messageCount,0),F=w.reduce((A,I)=>A+I.messageCount,0),D=E+F;return D===0?0:Math.round(E/D*100)}),y=M(()=>[l("common.weekday.mon"),l("common.weekday.tue"),l("common.weekday.wed"),l("common.weekday.thu"),l("common.weekday.fri"),l("common.weekday.sat"),l("common.weekday.sun")]),k=M(()=>{if(n.weekdayActivity.length===0)return null;const v=[...n.weekdayActivity].sort((w,E)=>E.messageCount-w.messageCount)[0];return{name:y.value[v.weekday-1],count:v.messageCount}}),x=M(()=>[{icon:"i-heroicons-fire",label:l("views.message.timeCard.peakRecord"),value:g.value?Ee(g.value.date).format("MM/DD"):"-",subtext:g.value?l("views.message.timeCard.peakRecordDesc",{count:g.value.messageCount}):"",colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-clock",label:l("views.message.timeCard.topHoursLabel"),value:h.value.length>0?`${h.value[0].hour}:00`:"-",subtext:h.value.length>=2?h.value.map(v=>`${v.hour}:00`).join(" > "):"",colorClass:"text-cyan-600 dark:text-cyan-400"},{icon:"i-heroicons-calendar-days",label:l("views.message.timeCard.peakWeekdayLabel"),value:k.value?.name||"-",subtext:k.value?`${k.value.count.toLocaleString()}`:"",colorClass:"text-violet-600 dark:text-violet-400"},{icon:"i-heroicons-building-office",label:l("views.message.timeCard.weekendRatio"),value:`${b.value}%`,subtext:l("views.message.timeCard.weekendRatioDesc"),colorClass:"text-amber-600 dark:text-amber-400"}]),_=z(null);let C=null;function $(){_.value&&(C=sa(_.value,void 0,{renderer:"canvas"}),S())}function S(){if(!C)return;const v=new Map(n.hourlyActivity.map(D=>[D.hour,D.messageCount])),w=[];for(let D=0;D<24;D++)w.push(v.get(D)||0);const E=Math.max(...w,1),F=w.map(D=>{const A=D/E;return A>.8?e.value?"#f472b6":"#ec4899":A>.5?e.value?"#a78bfa":"#8b5cf6":e.value?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.08)"});C.setOption({backgroundColor:"transparent",tooltip:{trigger:"axis",formatter:D=>`${D[0].axisValue}:00 — ${D[0].value}`},grid:{left:0,right:0,top:4,bottom:16},xAxis:{type:"category",data:Array.from({length:24},(D,A)=>`${A}`),axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:9,color:e.value?"#6b7280":"#9ca3af",interval:D=>D%6===0}},yAxis:{type:"value",show:!1},series:[{type:"bar",data:w.map((D,A)=>({value:D,itemStyle:{color:F[A]}})),barWidth:"60%",itemStyle:{borderRadius:[2,2,0,0]}}]},{notMerge:!0})}function T(){C?.resize()}return fe(()=>n.hourlyActivity,()=>S()),fe(e,()=>{C?.dispose(),$()}),Re(()=>{$(),window.addEventListener("resize",T)}),tt(()=>{window.removeEventListener("resize",T),C?.dispose()}),(v,w)=>{const E=_e;return r(),U(t(na),null,{default:B(()=>[a("div",Jy,[a("div",Xy,[a("div",Zy,[a("div",ex,[o.value.first?(r(),m("p",tx,d(o.value.first)+" – "+d(o.value.last),1)):R("",!0),a("div",ax,[a("span",sx,d(o.value.days),1),a("span",nx,d(t(l)("views.message.timeCard.heroDaysIn")),1),a("span",ox,d(s.value),1),a("span",lx,d(t(l)("views.message.timeCard.heroDaysActive")),1)]),a("div",rx,[a("span",ix,d(t(l)("views.message.timeCard.heroAvgPrefix")),1),a("span",ux,d(c.value),1),a("span",cx,d(t(l)("views.message.timeCard.heroAvgSuffix")),1),f.value?(r(),m(ie,{key:0},[p(E,{name:f.value.icon,class:"ml-2 h-4 w-4 text-amber-500"},null,8,["name"]),a("span",dx,d(f.value.label),1)],64)):R("",!0)])])]),a("div",mx,[a("div",gx,d(t(l)("views.message.timeCard.hourlyDistribution")),1),a("div",{ref_key:"barRef",ref:_,style:{width:"180px",height:"110px"}},null,512)])])]),a("div",px,[w[0]||(w[0]=a("div",{class:"mb-3 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Time Profile ")],-1)),a("div",hx,[(r(!0),m(ie,null,pe(x.value,F=>(r(),m("div",{key:F.icon+F.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[p(E,{name:F.icon,class:X(["mt-0.5 h-3.5 w-3.5 shrink-0",F.colorClass])},null,8,["name","class"]),a("div",fx,[a("div",{class:X(["truncate font-mono text-sm font-black leading-tight tabular-nums",F.colorClass])},d(F.value),3),a("div",vx,d(F.label),1),a("div",yx,d(F.subtext),1)])]))),128))])]),a("div",xx,[a("div",bx,[p(E,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),w[1]||(w[1]=a("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),a("span",kx,d(t(l)("views.message.timeCard.watermark")),1)])]),_:1})}}}),wx={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-4 sm:p-6"},$x={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},Cx={class:"p-5"},Sx={class:"p-5"},Ix={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},Tx={class:"p-5"},Mx={class:"p-5"},Ax={key:1,class:"flex h-48 items-center justify-center text-gray-400"},zx={class:"text-xs text-gray-400"},qx={class:"p-5"},Lx={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Dx={class:"text-xs text-gray-400"},Ex={class:"p-5"},Bx={class:"flex items-center gap-2"},Fx={class:"text-xs text-gray-400"},Rx={class:"p-5"},Vx={key:1,class:"flex h-32 items-center justify-center text-gray-400"},Gw=ue({__name:"TimeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(i){const l=i,{t:e}=we(),n=z(!0),s=z([]),u=z([]),o=z([]),c=z([]),g=z([]),h=z([]),f=z([]),b=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],y=M(()=>[e("common.weekday.mon"),e("common.weekday.tue"),e("common.weekday.wed"),e("common.weekday.thu"),e("common.weekday.fri"),e("common.weekday.sat"),e("common.weekday.sun")]),k=M(()=>[e("common.month.jan"),e("common.month.feb"),e("common.month.mar"),e("common.month.apr"),e("common.month.may"),e("common.month.jun"),e("common.month.jul"),e("common.month.aug"),e("common.month.sep"),e("common.month.oct"),e("common.month.nov"),e("common.month.dec")]),x=M(()=>{const A=new Map(u.value.map(Y=>[Y.hour,Y.messageCount])),I=[],q=[];for(let Y=0;Y<24;Y++)I.push(`${Y}`),q.push(A.get(Y)||0);return{labels:I,values:q}}),_=M(()=>{const A=new Map(o.value.map(q=>[q.weekday,q.messageCount])),I=[];for(let q=1;q<=7;q++)I.push(A.get(q)||0);return{labels:y.value,values:I}}),C=M(()=>{const A=new Map(c.value.map(q=>[q.month,q.messageCount])),I=[];for(let q=1;q<=12;q++)I.push(A.get(q)||0);return{labels:k.value,values:I}}),$=M(()=>{const A=[...g.value].sort((I,q)=>I.year-q.year);return{labels:A.map(I=>String(I.year)),values:A.map(I=>I.messageCount)}}),S=M(()=>{const A=Array.from({length:24},(G,Z)=>`${Z}:00`),I=y.value,q=s.value.reduce((G,Z)=>G+Z.count,0)||1,Y=[];for(let G=1;G<=7;G++)for(let Z=0;Z<24;Z++){const ce=o.value.find(W=>W.weekday===G)?.messageCount||0,ne=u.value.find(W=>W.hour===Z)?.messageCount||0,H=Math.round(ce*ne/q);Y.push([Z,G-1,H])}return{xLabels:A,yLabels:I,data:Y}}),T=M(()=>h.value.map(A=>({date:A.date,value:A.messageCount}))),v=M(()=>{const A=new Set;return h.value.forEach(I=>{const q=parseInt(I.date.split("-")[0]);isNaN(q)||A.add(q)}),Array.from(A).sort((I,q)=>q-I)}),w=z(new Date().getFullYear()),E=M(()=>{const A=w.value;return T.value.filter(I=>I.date.startsWith(`${A}-`))}),F=M(()=>{if(f.value.length===0)return{};const A=[...new Set(f.value.map(Z=>Z.month))].sort(),I=new Map;if(f.value.forEach(Z=>{const ce=I.get(Z.memberId);ce?ce.total+=Z.count:I.set(Z.memberId,{name:Z.memberName,total:Z.count})}),I.size<=2){const Z=new Map;return f.value.forEach(ce=>{Z.set(ce.month,(Z.get(ce.month)||0)+ce.count)}),{tooltip:{trigger:"axis",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:50,right:20,top:10,bottom:30},xAxis:{type:"category",data:A,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{type:"dashed",opacity:.3}}},series:[{type:"line",smooth:!0,symbol:"none",areaStyle:{opacity:.2},itemStyle:{color:"#6366f1"},data:A.map(ce=>Z.get(ce)||0)}]}}const G=[...I.entries()].sort((Z,ce)=>ce[1].total-Z[1].total).slice(0,10).map(([Z,ce],ne)=>{const H=new Map(f.value.filter(W=>W.memberId===Z).map(W=>[W.month,W.count]));return{name:ce.name,type:"line",stack:"total",areaStyle:{opacity:.3},smooth:!0,symbol:"none",itemStyle:{color:b[ne%b.length]},data:A.map(W=>H.get(W)||0)}});return{tooltip:{trigger:"axis",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},legend:{bottom:0,textStyle:{fontSize:11}},grid:{left:50,right:20,top:10,bottom:40},xAxis:{type:"category",data:A,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{type:"dashed",opacity:.3}}},series:G}});async function D(){if(l.sessionId){n.value=!0;try{const A=Ke(),[I,q,Y,G,Z,ce,ne]=await Promise.all([A.getMessageTypeDistribution(l.sessionId,l.timeFilter),A.getHourlyActivity(l.sessionId,l.timeFilter),A.getWeekdayActivity(l.sessionId,l.timeFilter),A.getMonthlyActivity(l.sessionId,l.timeFilter),A.getYearlyActivity(l.sessionId,l.timeFilter),A.getDailyActivity(l.sessionId,l.timeFilter),A.getMemberMonthlyTrend(l.sessionId,l.timeFilter)]);s.value=I,u.value=q,o.value=Y,c.value=G,g.value=Z,h.value=ce,f.value=ne,v.value.length>0&&(w.value=v.value[0])}catch(A){console.error("[chart-message] Failed to load time analysis data:",A)}finally{n.value=!1}}}return fe(()=>[l.sessionId,l.timeFilter],()=>D(),{immediate:!0,deep:!0}),(A,I)=>{const q=wa;return r(),m("div",{class:X(n.value?"h-full":"")},[n.value?(r(),U(t(Kt),{key:0,variant:"page",text:t(e)("common.loading")},null,8,["text"])):(r(),m("div",wx,[h.value.length>0?(r(),U(_x,{key:0,"hourly-activity":u.value,"weekday-activity":o.value,"daily-activity":h.value},null,8,["hourly-activity","weekday-activity","daily-activity"])):R("",!0),a("div",$x,[p(t(Ze),{title:t(e)("views.message.hourlyDistribution"),"show-divider":!1},{default:B(()=>[a("div",Cx,[p(t(rt),{data:x.value,height:200},null,8,["data"])])]),_:1},8,["title"]),p(t(Ze),{title:t(e)("views.message.weekdayDistribution"),"show-divider":!1},{default:B(()=>[a("div",Sx,[p(t(rt),{data:_.value,height:200},null,8,["data"])])]),_:1},8,["title"])]),a("div",Ix,[p(t(Ze),{title:t(e)("views.message.monthlyDistribution"),"show-divider":!1},{default:B(()=>[a("div",Tx,[p(t(rt),{data:C.value,height:200},null,8,["data"])])]),_:1},8,["title"]),p(t(Ze),{title:t(e)("views.message.yearlyDistribution"),"show-divider":!1},{default:B(()=>[a("div",Mx,[$.value.values.length>0?(r(),U(t(rt),{key:0,data:$.value,height:200},null,8,["data"])):(r(),m("div",Ax,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"])]),p(t(Ze),{title:t(e)("views.message.timeAnalysis.memberTrendTitle"),"show-divider":!1},{headerRight:B(()=>[a("span",zx,d(t(e)("views.message.timeAnalysis.memberTrendHint")),1)]),default:B(()=>[a("div",qx,[f.value.length>0?(r(),U(t(ea),{key:0,option:F.value,height:280},null,8,["option"])):(r(),m("div",Lx,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"]),p(t(Ze),{title:t(e)("views.message.timeHeatmap"),"show-divider":!1},{headerRight:B(()=>[a("span",Dx,d(t(e)("views.message.heatmapHint")),1)]),default:B(()=>[a("div",Ex,[p(t(fa),{data:S.value,height:320},null,8,["data"])])]),_:1},8,["title"]),p(t(Ze),{title:t(e)("views.message.calendarHeatmap"),"show-divider":!1},{headerRight:B(()=>[a("div",Bx,[a("span",Fx,d(t(e)("views.message.calendarHint")),1),v.value.length>1?(r(),U(q,{key:0,modelValue:w.value,"onUpdate:modelValue":I[0]||(I[0]=Y=>w.value=Y),items:v.value.map(Y=>({value:Y,label:String(Y)})),size:"xs",class:"w-20"},null,8,["modelValue","items"])):R("",!0)])]),default:B(()=>[a("div",Rx,[E.value.length>0?(r(),U(t(zv),{key:0,data:E.value,year:w.value,height:180},null,8,["data","year"])):(r(),m("div",Vx,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"])]))],2)}}}),Ox={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Px={class:"flex items-center gap-6 sm:gap-10"},jx={class:"min-w-0 flex-1"},Nx={class:"flex flex-col gap-2 text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},Ux={key:0,class:"mb-0 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},Wx={class:"flex items-baseline gap-x-1.5"},Hx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Kx={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Yx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Gx={class:"flex items-baseline gap-x-1.5"},Qx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Jx={class:"font-black text-3xl text-pink-500 dark:text-pink-400"},Xx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Zx={key:1,class:"mt-1 flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},eb={class:"text-base font-medium text-gray-600 dark:text-gray-300"},tb=["onClick"],ab={key:0,class:"text-gray-400"},sb={key:0,class:"hidden shrink-0 overflow-hidden rounded-lg sm:block"},nb={class:"relative",style:{width:"360px",height:"220px"}},ob={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},lb={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},rb={class:"min-w-0 flex-1"},ib={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},ub={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},cb={class:"relative z-10 flex items-center justify-between px-6 pb-4 opacity-40 mix-blend-luminosity dark:opacity-30 sm:px-8 sm:pb-5"},db={class:"flex items-center gap-1.5"},mb={class:"text-[9px] font-medium uppercase tracking-widest"},gb=ue({__name:"TopicProfileCard",props:{totalMessages:{},totalWords:{},uniqueWords:{},topWords:{},topicWords:{},posTagStats:{},timeFilter:{}},emits:["wordClick"],setup(i,{emit:l}){const e=gs(()=>Jt(()=>import("./EChartWordcloud-Pi48JdN2.js"),__vite__mapDeps([3,4,5,6,0,1,2]))),{t:n}=we(),s=i,u=l,o=M(()=>{const{startTs:x,endTs:_}=s.timeFilter??{};return x&&_?`${Ee(x*1e3).format("YYYY/MM/DD")} – ${Ee(_*1e3).format("YYYY/MM/DD")}`:""}),c=M(()=>(s.topicWords?.length?s.topicWords:s.topWords).slice(0,5)),g=M(()=>({words:(s.topicWords?.length?s.topicWords:s.topWords).slice(0,50).map(_=>({word:_.word,count:_.count,percentage:_.percentage}))})),h=M(()=>s.totalWords===0?0:Math.round(s.uniqueWords/s.totalWords*100)),f=M(()=>{if(!s.posTagStats?.length)return{key:"Balanced",label:n("quotes.topicProfile.styleBalanced"),desc:n("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"};const x=new Map(s.posTagStats.map(E=>[E.tag,E.count])),_=(x.get("n")||0)+(x.get("ns")||0)+(x.get("nt")||0)+(x.get("nz")||0),C=(x.get("v")||0)+(x.get("vn")||0)+(x.get("vd")||0),$=(x.get("a")||0)+(x.get("ad")||0)+(x.get("an")||0),S=_+C+$;if(S===0)return{key:"Balanced",label:n("quotes.topicProfile.styleBalanced"),desc:n("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"};const T=_/S,v=C/S,w=$/S;return T>.5?{key:"Encyclopedia",label:n("quotes.topicProfile.styleEncyclopedia"),desc:n("quotes.topicProfile.styleEncyclopediaDesc"),icon:"i-heroicons-book-open-solid",colorClass:"text-indigo-600 dark:text-indigo-400"}:v>.45?{key:"Action",label:n("quotes.topicProfile.styleAction"),desc:n("quotes.topicProfile.styleActionDesc"),icon:"i-heroicons-rocket-launch-solid",colorClass:"text-orange-600 dark:text-orange-400"}:w>.3?{key:"Expressive",label:n("quotes.topicProfile.styleExpressive"),desc:n("quotes.topicProfile.styleExpressiveDesc"),icon:"i-heroicons-paint-brush-solid",colorClass:"text-pink-600 dark:text-pink-400"}:{key:"Balanced",label:n("quotes.topicProfile.styleBalanced"),desc:n("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"}}),b=M(()=>{if(s.topWords.length===0)return{label:n("quotes.topicProfile.expressionMixed"),desc:n("quotes.topicProfile.expressionMixedDesc"),icon:"i-heroicons-chat-bubble-left-right-solid",colorClass:"text-emerald-600 dark:text-emerald-400"};const x=s.topWords.reduce(($,S)=>$+S.word.length*S.count,0),_=s.topWords.reduce(($,S)=>$+S.count,0),C=x/_;return C<2.5?{label:n("quotes.topicProfile.expressionCasual"),desc:n("quotes.topicProfile.expressionCasualDesc"),icon:"i-heroicons-face-smile-solid",colorClass:"text-amber-600 dark:text-amber-400"}:C>3.5?{label:n("quotes.topicProfile.expressionFormal"),desc:n("quotes.topicProfile.expressionFormalDesc"),icon:"i-heroicons-academic-cap-solid",colorClass:"text-violet-600 dark:text-violet-400"}:{label:n("quotes.topicProfile.expressionMixed"),desc:n("quotes.topicProfile.expressionMixedDesc"),icon:"i-heroicons-chat-bubble-left-right-solid",colorClass:"text-emerald-600 dark:text-emerald-400"}}),y=M(()=>[{icon:"i-heroicons-fire-solid",label:n("quotes.topicProfile.hotTopic"),value:c.value[0]?.word??"-",subtext:c.value[0]?n("quotes.topicProfile.hotTopicDesc",{count:c.value[0].count}):"",colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-sparkles-solid",label:n("quotes.topicProfile.richness"),value:n("quotes.topicProfile.richnessValue",{value:h.value}),subtext:n("quotes.topicProfile.richnessDesc",{unique:s.uniqueWords.toLocaleString(),total:s.totalWords.toLocaleString()}),colorClass:"text-blue-600 dark:text-blue-400"},{icon:f.value.icon,label:n("quotes.topicProfile.chatStyle"),value:f.value.label,subtext:f.value.desc,colorClass:f.value.colorClass},{icon:b.value.icon,label:n("quotes.topicProfile.expressionStyle"),value:b.value.label,subtext:b.value.desc,colorClass:b.value.colorClass}]),k=["#6366f1","#ec4899","#f97316","#22c55e","#3b82f6","#8b5cf6","#14b8a6","#f43f5e"];return(x,_)=>{const C=_e;return r(),U(t(na),null,{default:B(()=>[a("div",Ox,[a("div",Px,[a("div",jx,[a("div",Nx,[o.value?(r(),m("p",Ux,d(o.value),1)):R("",!0),a("div",Wx,[a("span",Hx,d(t(n)("quotes.topicProfile.heroPrefix")),1),a("span",Kx,d(i.totalMessages.toLocaleString()),1),a("span",Yx,d(t(n)("quotes.topicProfile.heroMiddle")),1)]),a("div",Gx,[a("span",Qx,d(t(n)("quotes.topicProfile.heroMiddleSecond")),1),a("span",Jx,d(i.uniqueWords.toLocaleString()),1),a("span",Xx,d(t(n)("quotes.topicProfile.heroSuffix")),1)]),c.value.length>0?(r(),m("div",Zx,[a("span",eb,d(t(n)("quotes.topicProfile.topTopicsPrefix")),1),(r(!0),m(ie,null,pe(c.value,($,S)=>(r(),m(ie,{key:$.word},[a("span",{class:"cursor-pointer font-bold text-xl transition-opacity hover:opacity-70",style:et({color:k[S%k.length]}),onClick:T=>u("wordClick",$.word)},d($.word),13,tb),S<c.value.length-1?(r(),m("span",ab,"·")):R("",!0)],64))),128))])):R("",!0)])]),g.value.words.length>0?(r(),m("div",sb,[a("div",nb,[p(t(e),{data:g.value,height:"100%","max-words":50,"size-scale":.8,"draw-out-of-bound":!0,shape:"rectangle","color-scheme":"default",onWordClick:_[0]||(_[0]=$=>u("wordClick",$))},null,8,["data"])])])):R("",!0)])]),a("div",ob,[_[1]||(_[1]=a("div",{class:"mb-3 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Topic Profile ")],-1)),a("div",lb,[(r(!0),m(ie,null,pe(y.value,$=>(r(),m("div",{key:$.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[p(C,{name:$.icon,class:X(["mt-0.5 h-3.5 w-3.5 shrink-0",$.colorClass])},null,8,["name","class"]),a("div",rb,[a("div",{class:X(["truncate font-mono text-sm font-black leading-tight tabular-nums",$.colorClass])},d($.value),3),a("div",ib,d($.label),1),a("div",ub,d($.subtext),1)])]))),128))])]),a("div",cb,[a("div",db,[p(C,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),_[2]||(_[2]=a("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),a("span",mb,d(t(n)("quotes.topicProfile.watermark")),1)])]),_:1})}}}),pb={class:"px-5 py-4 sm:px-6"},hb={class:"mb-4 flex items-center gap-2"},fb={class:"text-[15px] font-black tracking-tight text-gray-900 dark:text-white"},vb={class:"flex flex-wrap justify-center gap-2"},yb=["onClick"],xb=ue({__name:"SharedTopicsCard",props:{sessionId:{},timeFilter:{},dictType:{},excludeWords:{}},emits:["wordClick"],setup(i,{emit:l}){const{t:e}=we(),n=Ma(),s=i,u=l,o=M(()=>n.locale),c=z([]),g=z([]),h=M(()=>c.value.slice(0,20)),f=["bg-indigo-50 text-indigo-600 ring-1 ring-indigo-500/20 dark:bg-indigo-500/10 dark:text-indigo-400 dark:ring-indigo-500/30","bg-pink-50 text-pink-600 ring-1 ring-pink-500/20 dark:bg-pink-500/10 dark:text-pink-400 dark:ring-pink-500/30","bg-orange-50 text-orange-600 ring-1 ring-orange-500/20 dark:bg-orange-500/10 dark:text-orange-400 dark:ring-orange-500/30","bg-green-50 text-green-600 ring-1 ring-green-500/20 dark:bg-green-500/10 dark:text-green-400 dark:ring-green-500/30","bg-blue-50 text-blue-600 ring-1 ring-blue-500/20 dark:bg-blue-500/10 dark:text-blue-400 dark:ring-blue-500/30","bg-violet-50 text-violet-600 ring-1 ring-violet-500/20 dark:bg-violet-500/10 dark:text-violet-400 dark:ring-violet-500/30","bg-teal-50 text-teal-600 ring-1 ring-teal-500/20 dark:bg-teal-500/10 dark:text-teal-400 dark:ring-teal-500/30","bg-rose-50 text-rose-600 ring-1 ring-rose-500/20 dark:bg-rose-500/10 dark:text-rose-400 dark:ring-rose-500/30","bg-yellow-50 text-yellow-600 ring-1 ring-yellow-500/20 dark:bg-yellow-500/10 dark:text-yellow-400 dark:ring-yellow-500/30","bg-cyan-50 text-cyan-600 ring-1 ring-cyan-500/20 dark:bg-cyan-500/10 dark:text-cyan-400 dark:ring-cyan-500/30"];async function b(){if(s.sessionId)try{g.value.length===0&&(g.value=await Ke().getMembers(s.sessionId));const y=[...g.value].sort((T,v)=>v.messageCount-T.messageCount).slice(0,2);if(y.length<2){c.value=[];return}const k={locale:o.value,timeFilter:s.timeFilter?{startTs:s.timeFilter.startTs,endTs:s.timeFilter.endTs}:void 0,topN:100,minCount:2,posFilterMode:"meaningful",enableStopwords:!0,dictType:s.dictType??"default",excludeWords:s.excludeWords?.length?[...s.excludeWords]:void 0},x=Ke(),[_,C]=await Promise.all([x.getWordFrequency(s.sessionId,{...k,memberId:y[0].id}),x.getWordFrequency(s.sessionId,{...k,memberId:y[1].id})]),$=new Map(C.words.map(T=>[T.word,T.count])),S=[];for(const T of _.words){const v=$.get(T.word);v&&S.push({word:T.word,countA:T.count,countB:v})}S.sort((T,v)=>v.countA+v.countB-(T.countA+T.countB)),c.value=S.slice(0,30)}catch(y){console.error("加载共同话题数据失败:",y),c.value=[]}}return fe(()=>s.sessionId,()=>{g.value=[]}),fe(()=>[s.sessionId,s.timeFilter,s.dictType,s.excludeWords],()=>{b()},{immediate:!0,deep:!0}),(y,k)=>{const x=_e;return h.value.length>0?(r(),U(t(mt),{key:0},{default:B(()=>[a("div",pb,[a("div",hb,[p(x,{name:"i-heroicons-link",class:"h-4 w-4 text-emerald-500"}),a("span",fb,d(t(e)("quotes.topicProfile.sharedTopics")),1)]),a("div",vb,[(r(!0),m(ie,null,pe(h.value,(_,C)=>(r(),m("span",{key:_.word,class:X(["cursor-pointer rounded-full px-3 py-1 text-xs font-bold transition-opacity hover:opacity-80",f[C%f.length]]),onClick:$=>u("wordClick",_.word)},d(_.word),11,yb))),128))])])]),_:1})):R("",!0)}}}),ws=zn("wordFilter",()=>{const i=z([]),l=z(null),e=z({}),n=z(!1);function s(){return`wf_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function u($,S=[]){const T={id:s(),name:$,words:[...S],createdAt:Date.now()};return i.value.push(T),T}function o($,S){const T=i.value.find(v=>v.id===$);T&&(S.name!==void 0&&(T.name=S.name),S.words!==void 0&&(T.words=[...S.words]))}function c($){i.value=i.value.filter(S=>S.id!==$),l.value===$&&(l.value=null);for(const[S,T]of Object.entries(e.value))T===$&&delete e.value[S]}function g($){l.value=$}function h($,S){e.value[$]=S}function f($){delete e.value[$]}function b($){return $ in e.value?e.value[$]:l.value}function y($){const S=b($);return S?i.value.find(v=>v.id===S)?.words??[]:[]}function k($){return i.value.find(S=>S.id===$)}const x=M(()=>i.value.map($=>({label:$.name,value:$.id,isDefault:$.id===l.value,wordCount:$.words.length})));function _(){n.value=!0}function C(){n.value=!1}return{schemes:i,defaultSchemeId:l,sessionSchemeOverrides:e,showWordFilterModal:n,schemeOptions:x,createScheme:u,updateScheme:o,deleteScheme:c,setDefaultScheme:g,setSessionScheme:h,clearSessionScheme:f,getActiveSchemeId:b,getExcludeWords:y,getSchemeById:k,openModal:_,closeModal:C}},{persist:!1,backendPersist:{pick:["schemes","defaultSchemeId","sessionSchemeOverrides"],key:"wordFilter"}}),bb={class:"flex flex-col",style:{height:"520px"}},kb={class:"flex items-center justify-between border-b border-gray-200 px-6 py-4 dark:border-white/5"},_b={class:"flex items-center gap-3"},wb={class:"flex h-9 w-9 items-center justify-center rounded-xl bg-linear-to-br from-pink-400 to-pink-600"},$b={class:"text-lg font-semibold text-gray-900 dark:text-white"},Cb={class:"flex flex-1 overflow-hidden"},Sb={class:"flex w-[200px] shrink-0 flex-col border-r border-gray-200 dark:border-white/5"},Ib={class:"flex items-center justify-between px-3 py-2"},Tb={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Mb={class:"flex-1 overflow-y-auto px-2 pb-2"},Ab=["onClick"],zb={class:"truncate text-sm"},qb={class:"ml-auto text-xs text-gray-400 dark:text-gray-500"},Lb={key:0,class:"px-3 py-8 text-center text-xs text-gray-400 dark:text-gray-500"},Db={class:"flex flex-1 flex-col overflow-hidden"},Eb={class:"flex-1 space-y-4 overflow-y-auto p-5"},Bb={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},Fb={class:"flex items-center gap-2"},Rb={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},Vb={class:"flex gap-2"},Ob={class:"mb-1.5 flex items-center justify-between"},Pb={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},jb={class:"ml-1 text-gray-400 dark:text-gray-500"},Nb={key:0,class:"flex max-h-[220px] flex-wrap gap-1.5 overflow-y-auto rounded-lg border border-gray-200 p-3 dark:border-white/5"},Ub={key:1,class:"rounded-lg border border-dashed border-gray-300 px-4 py-6 text-center text-xs text-gray-400 dark:border-gray-600 dark:text-gray-500"},Wb={class:"flex shrink-0 justify-end border-t border-gray-200 px-5 py-3 dark:border-white/5"},Hb={key:1,class:"flex flex-1 flex-col items-center justify-center gap-3 text-gray-400 dark:text-gray-500"},Kb={class:"text-sm"},Yb=ue({__name:"WordFilterModal",setup(i){const{t:l}=we(),e=ws(),n=M({get:()=>e.showWordFilterModal,set:S=>S?e.openModal():e.closeModal()}),s=z(null),u=z(""),o=z(""),c=z(null),g=M(()=>s.value?e.getSchemeById(s.value)??null:null),h=M(()=>s.value===e.defaultSchemeId);fe(n,S=>{S&&(e.schemes.length>0&&!s.value&&(s.value=e.schemes[0].id),f())}),fe(s,()=>{f(),o.value=""});function f(){u.value=g.value?.name??""}function b(){const S=e.createScheme(l("wordFilter.defaultSchemeName"));s.value=S.id,De(()=>{c.value?.focus(),c.value?.select()})}function y(){if(!s.value)return;const S=e.schemes.findIndex(T=>T.id===s.value);if(e.deleteScheme(s.value),e.schemes.length>0){const T=Math.min(S,e.schemes.length-1);s.value=e.schemes[T].id}else s.value=null}function k(){!s.value||!u.value.trim()||e.updateScheme(s.value,{name:u.value.trim()})}function x(){s.value&&(h.value?e.setDefaultScheme(null):e.setDefaultScheme(s.value))}function _(){if(!s.value||!o.value.trim())return;const T=o.value.trim().split(/[,,\n\r\t;;|、\s]+/).map(F=>F.trim()).filter(F=>F.length>0);if(T.length===0)return;const v=g.value;if(!v)return;const w=new Set(v.words.map(F=>F.toLowerCase())),E=T.filter(F=>!w.has(F.toLowerCase()));E.length>0&&e.updateScheme(s.value,{words:[...v.words,...E]}),o.value=""}function C(S){if(!s.value)return;const T=g.value;T&&e.updateScheme(s.value,{words:T.words.filter(v=>v!==S)})}function $(){s.value&&e.updateScheme(s.value,{words:[]})}return(S,T)=>{const v=_e,w=Ue,E=Bt,F=ps,D=Xe;return r(),U(D,{open:n.value,"onUpdate:open":T[4]||(T[4]=A=>n.value=A),ui:{content:"max-w-3xl z-50"}},{content:B(()=>[a("div",bb,[a("div",kb,[a("div",_b,[a("div",wb,[p(v,{name:"i-heroicons-funnel",class:"h-4.5 w-4.5 text-white"})]),a("h2",$b,d(t(l)("wordFilter.title")),1)]),p(w,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:T[0]||(T[0]=A=>n.value=!1)})]),a("div",Cb,[a("div",Sb,[a("div",Ib,[a("span",Tb,d(t(l)("wordFilter.schemeList")),1),p(w,{icon:"i-heroicons-plus",size:"xs",variant:"ghost",color:"primary",onClick:b})]),a("div",Mb,[(r(!0),m(ie,null,pe(t(e).schemes,A=>(r(),m("div",{key:A.id,class:X(["group mb-1 flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 transition-colors",s.value===A.id?"bg-primary-50 text-primary-700 dark:bg-primary-900/20 dark:text-primary-300":"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-white/5"]),onClick:I=>s.value=A.id},[A.id===t(e).defaultSchemeId?(r(),U(v,{key:0,name:"i-heroicons-star-solid",class:"h-3.5 w-3.5 shrink-0 text-amber-500"})):R("",!0),a("span",zb,d(A.name),1),a("span",qb,d(A.words.length),1)],10,Ab))),128)),t(e).schemes.length===0?(r(),m("div",Lb,d(t(l)("wordFilter.emptyScheme")),1)):R("",!0)])]),a("div",Db,[g.value?(r(),m(ie,{key:0},[a("div",Eb,[a("div",null,[a("label",Bb,d(t(l)("wordFilter.schemeName")),1),p(E,{ref_key:"nameInputRef",ref:c,modelValue:u.value,"onUpdate:modelValue":T[1]||(T[1]=A=>u.value=A),size:"sm",placeholder:t(l)("wordFilter.schemeNamePlaceholder"),onBlur:k,onKeydown:Ge(k,["enter"])},null,8,["modelValue","placeholder"])]),a("div",Fb,[p(w,{size:"xs",variant:h.value?"solid":"soft",color:h.value?"warning":"neutral",icon:h.value?"i-heroicons-star-solid":"i-heroicons-star",onClick:x},{default:B(()=>[le(d(h.value?t(l)("wordFilter.isDefault"):t(l)("wordFilter.setDefault")),1)]),_:1},8,["variant","color","icon"]),p(w,{size:"xs",variant:"soft",color:"error",icon:"i-heroicons-trash",onClick:y},{default:B(()=>[le(d(t(l)("wordFilter.deleteScheme")),1)]),_:1})]),a("div",null,[a("label",Rb,d(t(l)("wordFilter.addWords")),1),a("div",Vb,[p(E,{modelValue:o.value,"onUpdate:modelValue":T[2]||(T[2]=A=>o.value=A),size:"sm",class:"flex-1",placeholder:t(l)("wordFilter.addWordsPlaceholder"),onKeydown:Ge(_,["enter"])},null,8,["modelValue","placeholder"]),p(w,{size:"sm",color:"primary",icon:"i-heroicons-plus",onClick:_},{default:B(()=>[le(d(t(l)("wordFilter.add")),1)]),_:1})])]),a("div",null,[a("div",Ob,[a("label",Pb,[le(d(t(l)("wordFilter.wordList"))+" ",1),a("span",jb,"("+d(g.value.words.length)+")",1)]),g.value.words.length>0?(r(),U(w,{key:0,size:"xs",variant:"ghost",color:"error",onClick:$},{default:B(()=>[le(d(t(l)("wordFilter.clearAll")),1)]),_:1})):R("",!0)]),g.value.words.length>0?(r(),m("div",Nb,[(r(!0),m(ie,null,pe(g.value.words,A=>(r(),U(F,{key:A,color:"neutral",variant:"subtle",class:"group/badge cursor-default gap-1 pr-1"},{default:B(()=>[le(d(A)+" ",1),p(v,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5 cursor-pointer text-gray-400 transition-colors hover:text-red-500",onClick:I=>C(A)},null,8,["onClick"])]),_:2},1024))),128))])):(r(),m("div",Ub,d(t(l)("wordFilter.emptyWords")),1))])]),a("div",Wb,[p(w,{color:"primary",variant:"soft",onClick:T[3]||(T[3]=A=>n.value=!1)},{default:B(()=>[le(d(t(l)("wordFilter.close")),1)]),_:1})])],64)):(r(),m("div",Hb,[p(v,{name:"i-heroicons-funnel",class:"h-10 w-10"}),a("p",Kb,d(t(l)("wordFilter.selectOrCreate")),1),p(w,{size:"sm",color:"primary",variant:"soft",icon:"i-heroicons-plus",onClick:b},{default:B(()=>[le(d(t(l)("wordFilter.createScheme")),1)]),_:1})]))])])])]),_:1},8,["open"])}}}),Gb={class:"main-content mx-auto max-w-[920px] space-y-6 p-4 sm:p-6"},Qb={key:0,class:"flex flex-col gap-3 rounded-lg border border-primary-200 bg-primary-50/70 p-4 dark:border-primary-800 dark:bg-primary-950/30 sm:flex-row sm:items-center sm:justify-between"},Jb={class:"flex min-w-0 items-start gap-3"},Xb={class:"min-w-0 text-sm text-primary-700 dark:text-primary-300"},Zb={class:"flex shrink-0 flex-wrap gap-2"},e1={key:1,class:"space-y-6"},t1={class:"flex flex-col gap-6 p-4 sm:p-6 lg:flex-row"},a1={class:"flex min-w-0 flex-1 flex-col"},s1={class:"relative w-full",style:{"aspect-ratio":"16 / 9"}},n1={key:1,class:"absolute inset-0 flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-gray-200 bg-gray-50/40 text-gray-500 dark:border-gray-700 dark:bg-gray-800/30 dark:text-gray-400"},o1={class:"text-xs font-medium"},l1={class:"px-4 text-center text-[11px]"},r1={key:0,class:"mt-2 text-center text-xs text-gray-500 dark:text-gray-400"},i1={class:"w-full shrink-0 space-y-4 lg:w-[280px]"},u1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},c1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},d1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},m1={key:0},g1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},p1={class:"space-y-2"},h1={class:"text-xs text-gray-400 dark:text-gray-500"},f1={key:1},v1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},y1={class:"flex items-center"},x1={key:2,class:"space-y-2"},b1={class:"flex items-center justify-between"},k1={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},_1={class:"flex gap-1"},w1={class:"flex max-h-[360px] flex-wrap gap-1.5 overflow-y-auto"},$1={key:0,class:"ml-1 opacity-60"},C1={class:"mb-2 flex items-center justify-between"},S1={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},I1={key:0,class:"mt-1 text-xs text-gray-400 dark:text-gray-500"},T1={class:"space-y-4"},M1={class:"text-sm text-gray-600 dark:text-gray-300"},A1={class:"flex justify-end gap-2"},z1="default",Ga="chatlab_zhTW_dict_prompt_dismissed",Qw=ue({__name:"WordcloudTab",props:{sessionId:{},timeFilter:{},memberId:{},showSharedTopics:{type:Boolean},enableNodeNlpFeatures:{type:Boolean,default:!0},enableRecordNavigation:{type:Boolean,default:!0}},setup(i){const l=gs(()=>Jt(()=>import("./EChartWordcloud-Pi48JdN2.js"),__vite__mapDeps([3,4,5,6,0,1,2]))),{t:e}=we(),n=Ma(),s=bt(),u=ws(),o=nt(),c=i,g=z(!1),h=z([]),f=z({totalMessages:0,totalWords:0,uniqueWords:0}),b=z(1.25),y=z(150),k=M(()=>{const me=h.value.slice(0,y.value),O=me.reduce((V,K)=>V+K.count,0);return{words:me.map(V=>({word:V.word,count:V.count,percentage:O>0?Math.round(V.count/O*1e4)/100:0}))}}),x=z(c.enableNodeNlpFeatures?"meaningful":"all"),_=z(!0),C=z([]),$=z([]),S=z(new Map),T=["n","nr","ns","nt","nz","nw","vn","a","an"],v=z([]),w=M(()=>k.value.words.map(me=>({word:me.word,count:me.count,percentage:me.percentage??0}))),E=M(()=>[...S.value.entries()].map(([me,O])=>({tag:me,count:O}))),F=z(null),D=M({get:()=>u.getActiveSchemeId(c.sessionId),set:me=>u.setSessionScheme(c.sessionId,me)}),A=M(()=>[{label:e("wordFilter.noFilter"),value:"__none__"},...u.schemeOptions.map(me=>({label:me.isDefault?`${me.label} ★`:me.label,value:me.value}))]),I=M({get:()=>D.value??"__none__",set:me=>{D.value=me==="__none__"?null:me}}),q=M(()=>u.getExcludeWords(c.sessionId)),Y=z("default"),G=z([]),Z=z(!1),ce=z(null),ne=z(!1),H=z(!c.enableNodeNlpFeatures),W=M(()=>n.locale),re=M(()=>n.locale==="zh-TW"),ve=M(()=>W.value.startsWith("zh")),he=M(()=>G.value.filter(me=>me.downloaded).map(me=>({label:e(`quotes.wordcloud.dict.${me.id==="zh-CN"?"zhCN":me.id==="zh-TW"?"zhTW":me.id}`),value:me.id}))),ee=M(()=>G.value.some(me=>me.downloaded)),te=M(()=>!c.enableNodeNlpFeatures||!ve.value||H.value),j=M(()=>G.value.filter(me=>!me.downloaded));async function de(){if(c.enableNodeNlpFeatures)try{G.value=await Oa("/nlp/dicts"),re.value&&Y.value==="default"&&G.value.find(V=>V.id==="zh-TW")?.downloaded&&(Y.value="zh-TW"),G.value.find(O=>O.id==="zh-CN")?.downloaded&&Y.value==="default"&&(Y.value="zh-CN")}catch(me){console.error("Failed to get dict list:",me)}finally{H.value=!0}}async function be(me){Z.value=!0,ce.value=me;try{const O=await qn(`/nlp/dicts/${me}/download`);O.success?(await de(),Y.value=me,o.success(e("quotes.wordcloud.dict.downloadSuccess"))):o.fail(e("quotes.wordcloud.dict.downloadFailed"),{description:O.error})}catch{o.fail(e("quotes.wordcloud.dict.downloadFailed"))}finally{Z.value=!1,ce.value=null,ne.value=!1}}function xe(){ne.value=!1,localStorage.setItem(Ga,"true")}function oe(){const me=G.value.find(O=>O.id==="zh-TW");re.value&&me&&!me.downloaded&&!localStorage.getItem(Ga)&&(ne.value=!0)}const Q=M(()=>[{label:e("quotes.wordcloud.posFilter.all"),value:"all"},{label:e("quotes.wordcloud.posFilter.meaningful"),value:"meaningful"},{label:e("quotes.wordcloud.posFilter.custom"),value:"custom"}]),J=[{label:"80",value:80},{label:"100",value:100},{label:"150",value:150},{label:"200",value:200},{label:"300",value:300}],ge=Math.max(...J.map(me=>me.value)),ke=M(()=>[{label:e("quotes.wordcloud.size.small"),value:.75},{label:e("quotes.wordcloud.size.medium"),value:1},{label:e("quotes.wordcloud.size.large"),value:1.25},{label:e("quotes.wordcloud.size.xlarge"),value:1.5}]),$e=M(()=>$.value.map(me=>({label:me.name,tag:me.tag,value:me.tag,count:S.value.get(me.tag)||0,meaningful:me.meaningful})));async function Le(){if(c.enableNodeNlpFeatures)try{const me=await Oa("/nlp/pos-tags");$.value=me,C.value=me.filter(O=>O.meaningful).map(O=>O.tag)}catch(me){console.error("加载词性标签失败:",me)}}let Be=0;async function Te(){if(!c.sessionId||!te.value)return;const me=++Be;try{const O=await Ke().getWordFrequency(c.sessionId,{locale:W.value,timeFilter:c.timeFilter?{startTs:c.timeFilter.startTs,endTs:c.timeFilter.endTs}:void 0,memberId:F.value??void 0,topN:50,minCount:2,posFilterMode:c.enableNodeNlpFeatures?"custom":"all",customPosTags:c.enableNodeNlpFeatures?[...T]:void 0,enableStopwords:!0,dictType:Y.value,excludeWords:q.value.length>0?[...q.value]:void 0});if(me!==Be)return;v.value=O.words.map(V=>({word:V.word,count:V.count,percentage:V.percentage}))}catch(O){if(console.error("加载话题迷你词云数据失败:",O),me!==Be)return;v.value=[]}}let Pe=0;async function je(){if(!c.sessionId||!te.value)return;const me=++Pe;h.value.length===0&&(g.value=!0);try{const O=await Ke().getWordFrequency(c.sessionId,{locale:W.value,timeFilter:c.timeFilter?{startTs:c.timeFilter.startTs,endTs:c.timeFilter.endTs}:void 0,memberId:F.value??void 0,topN:ge,minCount:2,posFilterMode:c.enableNodeNlpFeatures?x.value:"all",customPosTags:c.enableNodeNlpFeatures&&x.value==="custom"?[...C.value]:void 0,enableStopwords:_.value,dictType:Y.value,excludeWords:q.value.length>0?[...q.value]:void 0});if(me!==Pe)return;if(h.value=O.words.map(V=>({word:V.word,count:V.count,percentage:V.percentage})),f.value={totalMessages:O.totalMessages,totalWords:O.totalWords,uniqueWords:O.uniqueWords},O.posTagStats){const V=new Map;for(const K of O.posTagStats)V.set(K.tag,K.count);S.value=V}}catch(O){if(console.error("加载词频数据失败:",O),me!==Pe)return;h.value=[]}finally{me===Pe&&(g.value=!1)}}fe(()=>c.sessionId,()=>{F.value=null,h.value=[],v.value=[],f.value={totalMessages:0,totalWords:0,uniqueWords:0},S.value=new Map}),fe(()=>[c.sessionId,c.timeFilter,F.value,x.value,_.value,Y.value,q.value,te.value],()=>{je()},{immediate:!0,deep:!0}),fe(()=>[c.sessionId,c.timeFilter,F.value,Y.value,q.value,te.value],()=>{Te()},{immediate:!0,deep:!0}),fe(C,()=>{x.value==="custom"&&je()},{deep:!0}),fe(W,()=>{je()});function Se(me){c.enableRecordNavigation&&s.openChatRecordDrawer({keywords:[me]})}return Re(async()=>{c.enableNodeNlpFeatures&&(Le(),await de(),oe())}),(me,O)=>{const V=_e,K=Ue,L=_a,P=ps,N=Xe;return r(),m("div",Gb,[c.enableNodeNlpFeatures&&ve.value&&!ee.value?(r(),m("div",Qb,[a("div",Jb,[p(V,{name:"i-heroicons-information-circle",class:"mt-0.5 shrink-0 text-xl text-primary-500"}),a("p",Xb,d(t(e)("quotes.wordcloud.dict.needDownload")),1)]),a("div",Zb,[(r(!0),m(ie,null,pe(G.value,ae=>(r(),U(K,{key:ae.id,size:"sm",color:"primary",loading:Z.value&&ce.value===ae.id,disabled:Z.value&&ce.value!==ae.id,icon:"i-heroicons-arrow-down-tray",onClick:se=>be(ae.id)},{default:B(()=>[le(d(t(e)(`quotes.wordcloud.dict.download_${ae.id}`,ae.label)),1)]),_:2},1032,["loading","disabled","onClick"]))),128))])])):R("",!0),te.value?(r(),m("div",e1,[g.value&&w.value.length===0?(r(),U(t(Kt),{key:0,text:t(e)("quotes.wordcloud.loading"),class:"py-8"},null,8,["text"])):R("",!0),p(gb,{"total-messages":f.value.totalMessages,"total-words":f.value.totalWords,"unique-words":f.value.uniqueWords,"top-words":w.value,"topic-words":v.value,"pos-tag-stats":E.value,"time-filter":c.timeFilter,onWordClick:Se},null,8,["total-messages","total-words","unique-words","top-words","topic-words","pos-tag-stats","time-filter"]),c.showSharedTopics?(r(),U(xb,{key:1,"session-id":c.sessionId,"time-filter":c.timeFilter,"dict-type":Y.value,"exclude-words":q.value,onWordClick:Se},null,8,["session-id","time-filter","dict-type","exclude-words"])):R("",!0),p(t(Ze),{title:t(e)("quotes.wordcloud.stats.wordsLabel"),"show-divider":!1},{default:B(()=>[a("div",t1,[a("div",a1,[a("div",s1,[g.value?(r(),U(t(Kt),{key:0,text:t(e)("quotes.wordcloud.loading"),class:"absolute inset-0 z-10 rounded-lg bg-white/80 dark:bg-page-dark/80"},null,8,["text"])):w.value.length===0?(r(),m("div",n1,[p(V,{name:"i-heroicons-chat-bubble-bottom-center-text",class:"text-2xl"}),a("p",o1,d(t(e)("quotes.wordcloud.empty.title")),1),a("p",l1,d(t(e)("quotes.wordcloud.empty.description")),1)])):(r(),U(t(l),{key:2,data:k.value,height:"100%","max-words":y.value,"color-scheme":z1,"size-scale":b.value,loading:g.value,onWordClick:Se},null,8,["data","max-words","size-scale","loading"]))]),c.enableRecordNavigation?(r(),m("p",r1,d(t(e)("quotes.wordcloud.stats.clickHint")),1)):R("",!0)]),a("div",i1,[a("div",null,[a("h4",u1,d(t(e)("quotes.wordcloud.config.maxWords")),1),p(t(pt),{modelValue:y.value,"onUpdate:modelValue":O[0]||(O[0]=ae=>y.value=ae),size:"xs",items:J},null,8,["modelValue"])]),a("div",null,[a("h4",c1,d(t(e)("quotes.wordcloud.config.sizeScale")),1),p(t(pt),{modelValue:b.value,"onUpdate:modelValue":O[1]||(O[1]=ae=>b.value=ae),size:"xs",items:ke.value},null,8,["modelValue","items"])]),a("div",null,[a("h4",d1,d(t(e)("quotes.wordcloud.config.userFilter")),1),p(Av,{modelValue:F.value,"onUpdate:modelValue":O[2]||(O[2]=ae=>F.value=ae),"session-id":c.sessionId,class:"w-full"},null,8,["modelValue","session-id"])]),c.enableNodeNlpFeatures?(r(),m("div",m1,[a("h4",g1,d(t(e)("quotes.wordcloud.config.dict")),1),a("div",p1,[he.value.length>1?(r(),U(t(pt),{key:0,modelValue:Y.value,"onUpdate:modelValue":O[3]||(O[3]=ae=>Y.value=ae),size:"xs",items:he.value},null,8,["modelValue","items"])):R("",!0),(r(!0),m(ie,null,pe(j.value,ae=>(r(),m("div",{key:ae.id,class:"flex items-center gap-2"},[p(K,{size:"xs",variant:"soft",color:"primary",loading:Z.value&&ce.value===ae.id,disabled:Z.value&&ce.value!==ae.id,icon:"i-heroicons-arrow-down-tray",onClick:se=>be(ae.id)},{default:B(()=>[le(d(t(e)(`quotes.wordcloud.dict.download_${ae.id}`,t(e)("quotes.wordcloud.dict.download"))),1)]),_:2},1032,["loading","disabled","onClick"]),a("span",h1,d(t(e)("quotes.wordcloud.dict.downloadHint")),1)]))),128))])])):R("",!0),c.enableNodeNlpFeatures?(r(),m("div",f1,[a("h4",v1,d(t(e)("quotes.wordcloud.config.posFilter")),1),p(t(pt),{modelValue:x.value,"onUpdate:modelValue":O[4]||(O[4]=ae=>x.value=ae),size:"xs",items:Q.value},null,8,["modelValue","items"])])):R("",!0),a("div",y1,[p(L,{modelValue:_.value,"onUpdate:modelValue":O[5]||(O[5]=ae=>_.value=ae),label:t(e)("quotes.wordcloud.config.enableStopwords")},null,8,["modelValue","label"])]),c.enableNodeNlpFeatures&&x.value==="custom"?(r(),m("div",x1,[a("div",b1,[a("h4",k1,d(t(e)("quotes.wordcloud.posFilter.customHint")),1),a("div",_1,[p(K,{size:"xs",variant:"ghost",color:"neutral",onClick:O[6]||(O[6]=ae=>C.value=$.value.filter(se=>se.meaningful).map(se=>se.tag))},{default:B(()=>[le(d(t(e)("quotes.wordcloud.posFilter.selectMeaningful")),1)]),_:1}),p(K,{size:"xs",variant:"ghost",color:"neutral",onClick:O[7]||(O[7]=ae=>C.value=$.value.map(se=>se.tag))},{default:B(()=>[le(d(t(e)("quotes.wordcloud.posFilter.selectAll")),1)]),_:1}),p(K,{size:"xs",variant:"ghost",color:"neutral",onClick:O[8]||(O[8]=ae=>C.value=[])},{default:B(()=>[le(d(t(e)("quotes.wordcloud.posFilter.clearAll")),1)]),_:1})])]),a("div",w1,[(r(!0),m(ie,null,pe($e.value,ae=>(r(),U(P,{key:ae.value,color:C.value.includes(ae.value)?"primary":"neutral",variant:C.value.includes(ae.value)?"solid":"outline",class:"cursor-pointer select-none transition-colors",onClick:()=>{C.value.includes(ae.value)?C.value=C.value.filter(se=>se!==ae.value):C.value=[...C.value,ae.value]}},{default:B(()=>[le(d(ae.label)+" ",1),ae.count>0?(r(),m("span",$1,"("+d(ae.count)+")",1)):R("",!0)]),_:2},1032,["color","variant","onClick"]))),128))])])):R("",!0),a("div",null,[a("div",C1,[a("h4",S1,d(t(e)("wordFilter.filterScheme")),1),p(K,{size:"xs",variant:"ghost",color:"neutral",icon:"i-heroicons-cog-6-tooth","aria-label":t(e)("wordFilter.manage"),onClick:O[9]||(O[9]=ae=>t(u).openModal())},null,8,["aria-label"])]),p(t(pt),{modelValue:I.value,"onUpdate:modelValue":O[10]||(O[10]=ae=>I.value=ae),size:"xs",items:A.value},null,8,["modelValue","items"]),q.value.length>0?(r(),m("p",I1,d(t(e)("wordFilter.activeCount",{count:q.value.length})),1)):R("",!0)])])])]),_:1},8,["title"])])):R("",!0),c.enableNodeNlpFeatures?(r(),U(N,{key:2,open:ne.value,"onUpdate:open":O[12]||(O[12]=ae=>ne.value=ae),title:t(e)("quotes.wordcloud.dict.promptTitle")},{body:B(()=>[a("div",T1,[a("p",M1,d(t(e)("quotes.wordcloud.dict.promptDescription")),1),a("div",A1,[p(K,{variant:"ghost",color:"neutral",onClick:xe},{default:B(()=>[le(d(t(e)("quotes.wordcloud.dict.promptLater")),1)]),_:1}),p(K,{color:"primary",loading:Z.value,onClick:O[11]||(O[11]=ae=>be("zh-TW"))},{default:B(()=>[le(d(t(e)("quotes.wordcloud.dict.promptDownload")),1)]),_:1},8,["loading"])])])]),_:1},8,["open","title"])):R("",!0),p(Yb)])}}});function Jw(i){const l=M(()=>Ln(i)),e=M(()=>{const s=l.value;return s.length<2?!1:new Set(s.map(o=>Ee(o.date).year())).size>1}),n=M(()=>{const s=l.value,u=50;if(s.length<=u){const h=e.value?"YYYY/MM/DD":"MM/DD";return{labels:s.map(f=>Ee(f.date).format(h)),values:s.map(f=>f.messageCount)}}const o=Math.ceil(s.length/u),c=[],g=[];for(let h=0;h<s.length;h+=o){const f=s.slice(h,h+o);if(f.length===0)continue;const b=Math.floor(f.length/2),y=f[b].date,k=e.value?"YYYY/MM/DD":"MM/DD";c.push(Ee(y).format(k));const x=f.reduce((C,$)=>C+$.messageCount,0),_=Math.round(x/f.length);g.push(_)}return{labels:c,values:g}});return{isMultiYear:e,dailyChartData:n}}const q1=86400;function Gt(i){return typeof i=="number"&&Number.isFinite(i)}function L1(i){return Gt(i?.startTs)&&Gt(i?.endTs)}function $s(i,l){const e=l?.startTs??i?.start,n=l?.endTs??i?.end;return!Gt(e)||!Gt(n)||n<e?null:{start:e,end:n}}function D1(i,l=0){return!i||i.end<i.start?0:Math.max(Math.ceil((i.end-i.start)/q1),l,1)}function E1(i){return i?[Ee.unix(i.start).format("YYYY-MM-DD"),Ee.unix(i.end).format("YYYY-MM-DD")]:null}function B1(i,l){const{t:e}=we(),n=M(()=>$s(i.timeRange,i.timeFilter)),s=M(()=>L1(i.timeFilter)),u=M(()=>i.dailyActivity.filter(E=>E.messageCount>0).length),o=M(()=>D1(n.value,u.value)),c=M(()=>s.value?i.filteredMessageCount:i.session.messageCount),g=M(()=>s.value?i.filteredMemberCount??i.session.memberCount:i.session.memberCount),h=M(()=>o.value),f=M(()=>h.value===0?0:Math.round(c.value/h.value)),b=M(()=>o.value===0?0:Math.round(c.value/o.value)),y=M(()=>i.messageTypes.find(F=>F.type===1)?.count||0),k=M(()=>i.hourlyActivity.length?i.hourlyActivity.reduce((E,F)=>F.messageCount>E.messageCount?F:E,i.hourlyActivity[0]):null),x=M(()=>l.value.length?l.value.reduce((E,F)=>F.messageCount>E.messageCount?F:E,l.value[0]):null),_=M(()=>[e("common.weekday.mon"),e("common.weekday.tue"),e("common.weekday.wed"),e("common.weekday.thu"),e("common.weekday.fri"),e("common.weekday.sat"),e("common.weekday.sun")]),C=M(()=>{if(!l.value.length)return{weekday:0,weekend:0};const E=l.value.filter(A=>A.weekday>=1&&A.weekday<=5).reduce((A,I)=>A+I.messageCount,0),F=l.value.filter(A=>A.weekday>=6&&A.weekday<=7).reduce((A,I)=>A+I.messageCount,0),D=E+F;return{weekday:D>0?Math.round(E/D*100):0,weekend:D>0?Math.round(F/D*100):0}}),$=M(()=>i.dailyActivity.length?i.dailyActivity.reduce((E,F)=>F.messageCount>E.messageCount?F:E,i.dailyActivity[0]):null),S=M(()=>o.value),T=M(()=>S.value>0?Math.round(u.value/S.value*100):0),v=M(()=>{if(!i.hourlyActivity.length)return{count:0,ratio:0};const E=i.hourlyActivity.reduce((D,A)=>D+A.messageCount,0),F=i.hourlyActivity.filter(D=>D.hour>=0&&D.hour<=4).reduce((D,A)=>D+A.messageCount,0);return{count:F,ratio:E>0?Math.round(F/E*100):0}}),w=M(()=>{if(!i.dailyActivity.length)return 0;const E=[...i.dailyActivity].filter(A=>A.messageCount>0).sort((A,I)=>Ee(A.date).valueOf()-Ee(I.date).valueOf());if(E.length===0)return 0;let F=1,D=1;for(let A=1;A<E.length;A++){const I=Ee(E[A-1].date);Ee(E[A].date).diff(I,"day")===1?D++:(D>F&&(F=D),D=1)}return D>F&&(F=D),F});return{durationDays:o,displayMessageCount:c,displayMemberCount:g,dailyAvgMessages:b,totalDurationDays:h,totalDailyAvgMessages:f,imageCount:y,peakHour:k,peakWeekday:x,weekdayNames:_,weekdayVsWeekend:C,peakDay:$,activeDays:u,totalDays:S,activeRate:T,lateNightChat:v,maxConsecutiveDays:w}}function F1(i){const l=z([]);let e=0;async function n(){const s=++e,u=i.sessionId();if(!u){l.value=[];return}try{const o=await Ke().getWeekdayActivity(u,i.timeFilter());s===e&&(l.value=o)}catch(o){s===e&&console.error("Failed to load weekday activity:",o)}}return fe([i.sessionId,i.timeFilter],()=>n(),{immediate:!0,deep:!0}),{weekdayActivity:l}}const R1={key:0,class:"relative z-10 px-5 pb-5 pt-2 sm:px-8 sm:pb-6"},V1={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},O1={class:"min-w-0"},P1={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},j1={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},N1={key:1,class:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4"},U1={class:"text-sm text-gray-500"},W1={class:"text-sm text-gray-500"},H1={class:"ml-1 font-semibold text-pink-500"},K1={class:"text-sm text-gray-500"},Y1={class:"text-sm text-gray-500"},G1={class:"text-sm text-gray-500"},Q1={class:"text-sm text-gray-500"},J1={class:"text-sm text-gray-500"},X1={class:"text-sm text-gray-500"},Z1=ue({__name:"OverviewStatCards",props:{dailyAvgMessages:{},durationDays:{},imageCount:{},peakHour:{},peakWeekday:{},weekdayNames:{},weekdayVsWeekend:{},peakDay:{},activeDays:{},totalDays:{},activeRate:{},lateNightCount:{},lateNightRatio:{},maxConsecutiveDays:{},flat:{type:Boolean,default:!1}},setup(i){const{t:l}=we(),e=i,n=M(()=>[{icon:"i-heroicons-chat-bubble-left-right",label:l("analysis.overview.statCards.dailyAvgMessages"),value:l("analysis.overview.statCards.messagesCount",{count:e.dailyAvgMessages}),subtext:l("analysis.overview.statCards.daysCount",{count:e.durationDays}),colorClass:"text-blue-600 dark:text-blue-400"},{icon:"i-heroicons-photo",label:l("analysis.overview.statCards.imageMessages"),value:l("analysis.overview.statCards.imagesCount",{count:e.imageCount}),subtext:`${l("analysis.overview.statCards.peakHour")} ${e.peakHour?.hour||0}:00`,colorClass:"text-pink-600 dark:text-pink-400"},{icon:"i-heroicons-calendar-days",label:l("analysis.overview.statCards.mostActiveWeekday"),value:e.peakWeekday?e.weekdayNames[e.peakWeekday.weekday-1]:"-",subtext:l("analysis.overview.statCards.messagesOnDay",{count:e.peakWeekday?.messageCount??0}),colorClass:"text-amber-600 dark:text-amber-400"},{icon:"i-heroicons-sun",label:l("analysis.overview.statCards.weekendActivity"),value:`${e.weekdayVsWeekend.weekend}%`,subtext:l("analysis.overview.statCards.weekendRatio"),colorClass:"text-green-600 dark:text-green-400"},{icon:"i-heroicons-fire",label:l("analysis.overview.statCards.mostActiveDate"),value:e.peakDay?Ee(e.peakDay.date).format("MM/DD"):"-",subtext:l("analysis.overview.statCards.messagesOnDay",{count:e.peakDay?.messageCount??0}),colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-moon",label:l("analysis.overview.statCards.lateNightChat"),value:l("analysis.overview.statCards.messagesCount",{count:e.lateNightCount}),subtext:l("analysis.overview.statCards.lateNightRatio",{ratio:e.lateNightRatio}),colorClass:"text-indigo-600 dark:text-indigo-400"},{icon:"i-heroicons-bolt",label:l("analysis.overview.statCards.consecutiveStreak"),value:l("analysis.overview.statCards.daysStreak",{count:e.maxConsecutiveDays}),subtext:l("analysis.overview.statCards.longestStreak"),colorClass:"text-amber-600 dark:text-amber-400"},{icon:"i-heroicons-chart-bar",label:l("analysis.overview.statCards.activityRate"),value:`${e.activeRate}%`,subtext:l("analysis.overview.statCards.activeDaysRatio"),colorClass:"text-gray-900 dark:text-white"}]);return(s,u)=>{const o=_e;return i.flat?(r(),m("div",R1,[u[0]||(u[0]=a("div",{class:"mb-3 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"},"Key Metrics")],-1)),a("div",V1,[(r(!0),m(ie,null,pe(n.value,c=>(r(),m("div",{key:c.icon+c.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[p(o,{name:c.icon,class:X(["mt-0.5 h-3.5 w-3.5 shrink-0",c.colorClass])},null,8,["name","class"]),a("div",O1,[a("div",{class:X(["truncate font-mono text-sm font-black leading-tight tabular-nums",c.colorClass])},d(c.value),3),a("div",P1,d(c.label),1),a("div",j1,d(c.subtext),1)])]))),128))])])):(r(),m("div",N1,[p(t(ot),{label:t(l)("analysis.overview.statCards.dailyAvgMessages"),value:t(l)("analysis.overview.statCards.messagesCount",{count:i.dailyAvgMessages}),icon:"i-heroicons-chat-bubble-left-right","icon-bg":"blue"},{subtext:B(()=>[a("span",U1,d(t(l)("analysis.overview.statCards.daysCount",{count:i.durationDays})),1)]),_:1},8,["label","value"]),p(t(ot),{label:t(l)("analysis.overview.statCards.imageMessages"),value:t(l)("analysis.overview.statCards.imagesCount",{count:i.imageCount}),icon:"i-heroicons-photo","icon-bg":"pink"},{subtext:B(()=>[a("span",W1,d(t(l)("analysis.overview.statCards.peakHour")),1),a("span",H1,d(i.peakHour?.hour||0)+":00",1)]),_:1},8,["label","value"]),p(t(ot),{label:t(l)("analysis.overview.statCards.mostActiveWeekday"),value:i.peakWeekday?i.weekdayNames[i.peakWeekday.weekday-1]:"-",icon:"i-heroicons-calendar-days","icon-bg":"amber"},{subtext:B(()=>[a("span",K1,d(t(l)("analysis.overview.statCards.messagesOnDay",{count:i.peakWeekday?.messageCount??0})),1)]),_:1},8,["label","value"]),p(t(ot),{label:t(l)("analysis.overview.statCards.weekendActivity"),value:`${i.weekdayVsWeekend.weekend}%`,icon:"i-heroicons-sun","icon-bg":"green"},{subtext:B(()=>[a("span",Y1,d(t(l)("analysis.overview.statCards.weekendRatio")),1)]),_:1},8,["label","value"]),p(t(ot),{label:t(l)("analysis.overview.statCards.mostActiveDate"),value:i.peakDay?t(Ee)(i.peakDay.date).format("MM/DD"):"-",icon:"i-heroicons-fire","icon-bg":"red"},{subtext:B(()=>[a("span",G1,d(t(l)("analysis.overview.statCards.messagesOnDay",{count:i.peakDay?.messageCount??0})),1)]),_:1},8,["label","value"]),p(t(ot),{label:t(l)("analysis.overview.statCards.lateNightChat"),value:t(l)("analysis.overview.statCards.messagesCount",{count:i.lateNightCount}),icon:"i-heroicons-moon","icon-bg":"blue"},{subtext:B(()=>[a("span",Q1,d(t(l)("analysis.overview.statCards.lateNightRatio",{ratio:i.lateNightRatio})),1)]),_:1},8,["label","value"]),p(t(ot),{label:t(l)("analysis.overview.statCards.consecutiveStreak"),value:t(l)("analysis.overview.statCards.daysStreak",{count:i.maxConsecutiveDays}),icon:"i-heroicons-bolt","icon-bg":"amber"},{subtext:B(()=>[a("span",J1,d(t(l)("analysis.overview.statCards.longestStreak")),1)]),_:1},8,["label","value"]),p(t(ot),{label:t(l)("analysis.overview.statCards.activityRate"),value:`${i.activeRate}%`,icon:"i-heroicons-chart-bar","icon-bg":"gray"},{subtext:B(()=>[a("span",X1,d(t(l)("analysis.overview.statCards.activeDaysRatio")),1)]),_:1},8,["label","value"])]))}}}),ek={class:"relative z-10 px-5 pt-6 pb-4 sm:px-8 sm:pt-8"},tk={class:"text-2xl font-bold tracking-tight text-gray-900 sm:text-3xl dark:text-gray-100"},ak={class:"mt-4 flex flex-col gap-5 sm:flex-row sm:items-start sm:gap-24"},sk={class:"min-w-0 flex flex-col gap-2 text-sm font-medium text-gray-500 dark:text-gray-400"},nk={class:"flex items-center gap-2"},ok={class:"flex h-6 w-6 shrink-0 items-center justify-center"},lk={class:"whitespace-nowrap"},rk={key:0,class:"flex items-center gap-2"},ik={class:"flex h-6 w-6 shrink-0 items-center justify-center"},uk={class:"font-mono text-xs opacity-90 whitespace-nowrap"},ck={class:"grid grid-cols-2 gap-x-8 gap-y-4 sm:flex sm:shrink-0 sm:gap-6"},dk={class:"flex flex-col gap-1 text-center"},mk={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},gk={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},pk={class:"flex flex-col gap-1 text-center"},hk={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},fk={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},vk={class:"flex flex-col gap-1 text-center"},yk={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},xk={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},bk={class:"flex flex-col gap-1 text-center"},kk={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},_k={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},wk={class:"relative z-10 px-5 pb-2 sm:px-8"},$k={class:"overflow-x-auto overflow-y-hidden scrollbar-hide py-1"},Xw=ue({__name:"OverviewIdentityCard",props:{session:{},dailyActivity:{},messageTypes:{},hourlyActivity:{},timeRange:{},filteredMessageCount:{},filteredMemberCount:{},timeFilter:{},capturable:{type:Boolean,default:!0}},setup(i){ta([hs,eo,fs,za,vs,aa]);const{t:l,locale:e}=we(),n=Zt(),s=i,{weekdayActivity:u}=F1({sessionId:()=>s.session.id,timeFilter:()=>s.timeFilter}),{durationDays:o,displayMessageCount:c,dailyAvgMessages:g,imageCount:h,peakHour:f,peakWeekday:b,weekdayNames:y,weekdayVsWeekend:k,peakDay:x,activeDays:_,totalDays:C,activeRate:$,lateNightChat:S,maxConsecutiveDays:T}=B1(s,u),v=z(null);let w=null;const E=M(()=>$s(s.timeRange,s.timeFilter)),F=M(()=>E.value?to(E.value.start,E.value.end,"YYYY/MM/DD"):""),D=M(()=>{const H=E1(E.value);if(H)return H;const ve=(he=>he.toISOString().slice(0,10))(new Date);return[ve,ve]}),A=M(()=>{const[H,W]=D.value,re=new Date(H+"T00:00:00Z"),ve=new Date(W+"T00:00:00Z"),he=new Map;s.dailyActivity.filter(j=>j.date>=H&&j.date<=W).forEach(j=>he.set(j.date,j.messageCount));const ee=[],te=new Date(re);for(;te<=ve;){const j=te.toISOString().slice(0,10),de=he.get(j)||0;ee.push({value:[j,de],itemStyle:de===0?{color:Y.value}:void 0}),te.setUTCDate(te.getUTCDate()+1)}return ee}),I=M(()=>s.dailyActivity.length===0?10:Math.max(...s.dailyActivity.map(H=>H.messageCount),1)),q={light:["#fce4ec","#f8a4b8","#f06292","#e91e63"],dark:["rgba(238, 69, 103, 0.15)","rgba(238, 69, 103, 0.45)","rgba(238, 69, 103, 0.75)","rgba(238, 69, 103, 1)"]},Y=M(()=>n.value?"rgba(255, 255, 255, 0.04)":"#ebedf0"),G=M(()=>({tooltip:{trigger:"item",formatter:H=>{const W=H.value[0],re=H.value[1];return`${W}<br/>${l("views.message.calendarTooltipMessages")}: ${re}`}},visualMap:{min:1,max:I.value,calculable:!1,orient:"horizontal",left:"center",bottom:0,itemWidth:10,itemHeight:80,text:[`${I.value}`,"1"],inRange:{color:n.value?q.dark:q.light},textStyle:{color:n.value?"#8b949e":"#6b7280",fontSize:10},show:!0},calendar:{top:20,left:30,cellSize:[13,13],range:D.value,itemStyle:{borderWidth:0,color:"transparent"},yearLabel:{show:!1},monthLabel:{show:!0,color:n.value?"#8b949e":"#6b7280",fontSize:10,nameMap:[l("common.month.jan"),l("common.month.feb"),l("common.month.mar"),l("common.month.apr"),l("common.month.may"),l("common.month.jun"),l("common.month.jul"),l("common.month.aug"),l("common.month.sep"),l("common.month.oct"),l("common.month.nov"),l("common.month.dec")]},dayLabel:{show:!0,firstDay:1,color:n.value?"#8b949e":"#9ca3af",fontSize:10,nameMap:[l("common.weekday.sun"),l("common.weekday.mon"),l("common.weekday.tue"),l("common.weekday.wed"),l("common.weekday.thu"),l("common.weekday.fri"),l("common.weekday.sat")]},splitLine:{show:!1}},series:[{type:"custom",coordinateSystem:"calendar",data:A.value,renderItem:(H,W)=>{const re=W.coord(W.value(0)),ve=H.coordSys.cellWidth,he=H.coordSys.cellHeight,ee=Math.min(ve,he)-3;return{type:"rect",shape:{x:re[0]-ee/2,y:re[1]-ee/2,width:ee,height:ee,r:3},style:{fill:W.visual("color")}}},itemStyle:{borderColor:n.value?"transparent":"rgba(0,0,0,0.02)",borderWidth:1}}]}));function Z(){v.value&&(w=sa(v.value,void 0,{renderer:"canvas"}),w.setOption({backgroundColor:"transparent",...G.value}))}function ce(){w&&w.setOption({backgroundColor:"transparent",...G.value},{notMerge:!0})}function ne(){w?.resize()}return fe([()=>s.dailyActivity,e,D],()=>ce()),fe(n,()=>{w?.dispose(),Z()}),Re(()=>{Z(),window.addEventListener("resize",ne)}),tt(()=>{window.removeEventListener("resize",ne),w?.dispose()}),(H,W)=>{const re=_e;return r(),U(t(na),{capturable:i.capturable},{default:B(()=>[a("div",ek,[a("h2",tk,d(i.session.name),1),a("div",ak,[a("div",sk,[a("div",nk,[a("div",ok,[i.session.type==="group"?(r(),U(re,{key:0,name:"i-heroicons-user-group",class:"h-4 w-4 opacity-70"})):(r(),U(re,{key:1,name:"i-heroicons-user",class:"h-4 w-4 opacity-70"}))]),a("span",lk,d(i.session.platform.toUpperCase())+" · "+d(i.session.type==="private"?t(l)("analysis.overview.identity.privateChat"):t(l)("analysis.overview.identity.groupChat")),1)]),F.value?(r(),m("div",rk,[a("div",ik,[p(re,{name:"i-heroicons-calendar",class:"h-4 w-4 opacity-70"})]),a("span",uk,d(F.value),1)])):R("",!0)]),a("div",ck,[a("div",dk,[a("span",mk,d(t(c).toLocaleString()),1),a("span",gk,d(t(l)("analysis.overview.identity.totalMessages")),1)]),a("div",pk,[a("span",hk,d(t(o).toLocaleString()),1),a("span",fk,d(t(l)("analysis.overview.identity.durationDays")),1)]),a("div",vk,[a("span",yk,d(t(_).toLocaleString()),1),a("span",xk,d(t(l)("analysis.overview.identity.activeDays")),1)]),a("div",bk,[a("span",kk,d(t(g).toLocaleString()),1),a("span",_k,d(t(l)("analysis.overview.identity.dailyAvgMessages")),1)])])])]),a("div",wk,[W[0]||(W[0]=a("div",{class:"mb-2 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Activity Heatmap ")],-1)),a("div",$k,[a("div",{ref_key:"chartRef",ref:v,class:"h-[140px] min-w-[700px] lg:w-full"},null,512)])]),p(Z1,{flat:"","daily-avg-messages":t(g),"duration-days":t(o),"image-count":t(h),"peak-hour":t(f),"peak-weekday":t(b),"weekday-names":t(y),"weekday-vs-weekend":t(k),"peak-day":t(x),"active-days":t(_),"total-days":t(C),"active-rate":t($),"late-night-count":t(S).count,"late-night-ratio":t(S).ratio,"max-consecutive-days":t(T)},null,8,["daily-avg-messages","duration-days","image-count","peak-hour","peak-weekday","weekday-names","weekday-vs-weekend","peak-day","active-days","total-days","active-rate","late-night-count","late-night-ratio","max-consecutive-days"])]),_:1},8,["capturable"])}}}),Ck={class:"p-3 sm:p-5"},Zw=ue({__name:"DailyTrendCard",props:{dailyActivity:{},dailyChartData:{},capturable:{type:Boolean,default:!0}},setup(i){const{t:l}=we();return(e,n)=>i.dailyActivity.length>0?(r(),U(t(Ze),{key:0,title:t(l)("analysis.overview.dailyTrend.title"),capturable:i.capturable,"show-divider":!1},{default:B(()=>[a("div",Ck,[p(t(va),{data:i.dailyChartData,height:288},null,8,["data"])])]),_:1},8,["title","capturable"])):R("",!0)}}),Sk={slots:{root:["relative inline-flex items-center","flex-wrap"],base:["rounded-md","transition-colors"],leading:"absolute inset-y-0 start-0 flex items-center",leadingIcon:"shrink-0 text-dimmed",leadingAvatar:"shrink-0",leadingAvatarSize:"",trailing:"absolute inset-y-0 end-0 flex items-center",trailingIcon:"shrink-0 text-dimmed",item:'px-1.5 py-0.5 rounded-sm font-medium inline-flex items-center gap-0.5 ring ring-inset ring-accented bg-elevated text-default data-disabled:cursor-not-allowed data-disabled:opacity-75 wrap-anywhere data-[state="active"]:bg-accented',itemText:"",itemDelete:["inline-flex items-center rounded-xs text-dimmed hover:text-default hover:bg-accented/75 disabled:pointer-events-none","transition-colors"],itemDeleteIcon:"shrink-0",input:"flex-1 border-0 bg-transparent placeholder:text-dimmed focus:outline-none disabled:cursor-not-allowed disabled:opacity-75"},variants:{fieldGroup:{horizontal:"not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]",vertical:"not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]"},size:{xs:{base:"px-2 py-1 text-sm/4 gap-1",leading:"ps-2",trailing:"pe-2",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4",item:"text-[10px]/3",itemDeleteIcon:"size-3"},sm:{base:"px-2.5 py-1.5 text-sm/4 gap-1.5",leading:"ps-2.5",trailing:"pe-2.5",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4",item:"text-[10px]/3",itemDeleteIcon:"size-3"},md:{base:"px-2.5 py-1.5 text-base/5 gap-1.5",leading:"ps-2.5",trailing:"pe-2.5",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5",item:"text-xs",itemDeleteIcon:"size-3.5"},lg:{base:"px-3 py-2 text-base/5 gap-2",leading:"ps-3",trailing:"pe-3",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5",item:"text-xs",itemDeleteIcon:"size-3.5"},xl:{base:"px-3 py-2 text-base gap-2",leading:"ps-3",trailing:"pe-3",leadingIcon:"size-6",leadingAvatarSize:"xs",trailingIcon:"size-6",item:"text-sm",itemDeleteIcon:"size-4"}},variant:{outline:"text-highlighted bg-default ring ring-inset ring-accented",soft:"text-highlighted bg-elevated/50 hover:bg-elevated has-focus:bg-elevated disabled:bg-elevated/50",subtle:"text-highlighted bg-elevated ring ring-inset ring-accented",ghost:"text-highlighted bg-transparent hover:bg-elevated has-focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent",none:"text-highlighted bg-transparent has-focus:outline-none"},color:{primary:"",secondary:"",success:"",info:"",warning:"",error:"",neutral:""},leading:{true:""},trailing:{true:""},loading:{true:""},highlight:{true:""},fixed:{false:""},type:{file:"file:me-1.5 file:font-medium file:text-muted file:outline-none"}},compoundVariants:[{color:"primary",variant:["outline","subtle"],class:"outline-primary/25 has-focus-visible:outline-3 has-focus-visible:ring-primary"},{color:"secondary",variant:["outline","subtle"],class:"outline-secondary/25 has-focus-visible:outline-3 has-focus-visible:ring-secondary"},{color:"success",variant:["outline","subtle"],class:"outline-success/25 has-focus-visible:outline-3 has-focus-visible:ring-success"},{color:"info",variant:["outline","subtle"],class:"outline-info/25 has-focus-visible:outline-3 has-focus-visible:ring-info"},{color:"warning",variant:["outline","subtle"],class:"outline-warning/25 has-focus-visible:outline-3 has-focus-visible:ring-warning"},{color:"error",variant:["outline","subtle"],class:"outline-error/25 has-focus-visible:outline-3 has-focus-visible:ring-error"},{color:"primary",variant:["soft","ghost"],class:"outline-primary/25 has-focus-visible:outline-3"},{color:"secondary",variant:["soft","ghost"],class:"outline-secondary/25 has-focus-visible:outline-3"},{color:"success",variant:["soft","ghost"],class:"outline-success/25 has-focus-visible:outline-3"},{color:"info",variant:["soft","ghost"],class:"outline-info/25 has-focus-visible:outline-3"},{color:"warning",variant:["soft","ghost"],class:"outline-warning/25 has-focus-visible:outline-3"},{color:"error",variant:["soft","ghost"],class:"outline-error/25 has-focus-visible:outline-3"},{color:"primary",highlight:!0,class:"ring ring-inset ring-primary"},{color:"secondary",highlight:!0,class:"ring ring-inset ring-secondary"},{color:"success",highlight:!0,class:"ring ring-inset ring-success"},{color:"info",highlight:!0,class:"ring ring-inset ring-info"},{color:"warning",highlight:!0,class:"ring ring-inset ring-warning"},{color:"error",highlight:!0,class:"ring ring-inset ring-error"},{color:"neutral",variant:["outline","subtle"],class:"outline-inverted/25 has-focus-visible:outline-3 has-focus-visible:ring-inverted"},{color:"neutral",variant:["soft","ghost"],class:"outline-inverted/25 has-focus-visible:outline-3"},{color:"neutral",highlight:!0,class:"ring ring-inset ring-inverted"},{leading:!0,size:"xs",class:"ps-7"},{leading:!0,size:"sm",class:"ps-8"},{leading:!0,size:"md",class:"ps-9"},{leading:!0,size:"lg",class:"ps-10"},{leading:!0,size:"xl",class:"ps-11"},{trailing:!0,size:"xs",class:"pe-7"},{trailing:!0,size:"sm",class:"pe-8"},{trailing:!0,size:"md",class:"pe-9"},{trailing:!0,size:"lg",class:"pe-10"},{trailing:!0,size:"xl",class:"pe-11"},{loading:!0,leading:!0,class:{leadingIcon:"animate-spin"}},{loading:!0,leading:!1,trailing:!0,class:{trailingIcon:"animate-spin"}},{fixed:!1,size:"xs",class:"md:text-xs"},{fixed:!1,size:"sm",class:"md:text-xs"},{fixed:!1,size:"md",class:"md:text-sm"},{fixed:!1,size:"lg",class:"md:text-sm"}],defaultVariants:{size:"md",color:"primary",variant:"outline"}},Ik=Object.assign({inheritAttrs:!1},{__name:"InputTags",props:{as:{type:null,required:!1},placeholder:{type:String,required:!1},maxLength:{type:Number,required:!1},color:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},autofocus:{type:Boolean,required:!1},autofocusDelay:{type:Number,required:!1,default:0},deleteIcon:{type:null,required:!1},highlight:{type:Boolean,required:!1},fixed:{type:Boolean,required:!1},class:{type:null,required:!1},ui:{type:Object,required:!1},modelValue:{type:[Array,null],required:!1},defaultValue:{type:Array,required:!1},addOnPaste:{type:Boolean,required:!1},addOnTab:{type:Boolean,required:!1},addOnBlur:{type:Boolean,required:!1},duplicate:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},delimiter:{type:null,required:!1},max:{type:Number,required:!1},id:{type:String,required:!1},convertValue:{type:Function,required:!1},displayValue:{type:Function,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1},icon:{type:null,required:!1},avatar:{type:Object,required:!1},leading:{type:Boolean,required:!1},leadingIcon:{type:null,required:!1},trailing:{type:Boolean,required:!1},trailingIcon:{type:null,required:!1},loading:{type:Boolean,required:!1},loadingIcon:{type:null,required:!1}},emits:["change","blur","focus","update:modelValue","invalid","addTag","removeTag"],setup(i,{expose:l,emit:e}){const n=i,s=e,u=Qt(),o=Ca("inputTags",n),c=Ia(),g=rs(is(o,"as","addOnPaste","addOnTab","addOnBlur","duplicate","delimiter","max","convertValue","displayValue","required"),s),{emitFormBlur:h,emitFormFocus:f,emitFormChange:b,emitFormInput:y,size:k,color:x,id:_,name:C,highlight:$,disabled:S,ariaAttrs:T}=Sa(n),{orientation:v,size:w}=us(n),{isLeading:E,isTrailing:F,leadingIconName:D,trailingIconName:A}=Ta(o),I=M(()=>w.value||k.value),q=M(()=>$t({extend:$t(Sk),...c.ui?.inputTags||{}})({color:x.value??o.color,variant:o.variant,size:I?.value??o.size,loading:o.loading,highlight:$.value??o.highlight,fixed:o.fixed,leading:E.value||!!o.avatar||!!u.leading,trailing:F.value||!!u.trailing,fieldGroup:v.value})),Y=At("inputRef");function G(){o.autofocus&&Y.value?.$el?.focus()}Re(()=>{setTimeout(()=>{G()},o.autofocusDelay)});function Z(H){if(cs(o.modelValue)===H)return;const W=new Event("change",{target:{value:H}});s("change",W),b(),y()}function ce(H){s("blur",H),h()}function ne(H){s("focus",H),f()}return l({inputRef:We(()=>Y.value?.$el)}),(H,W)=>(r(),U(t($l),ze({id:t(_),"model-value":t(o).modelValue,"default-value":t(o).defaultValue,"data-slot":"root",class:q.value.root({class:[q.value.base({class:t(o).ui?.base}),t(o).ui?.root,t(o).class]})},t(g),{name:t(C),disabled:t(S),"onUpdate:modelValue":Z}),{default:B(({modelValue:re})=>[(r(!0),m(ie,null,pe(re,(ve,he)=>(r(),U(t(Ml),{key:he,value:ve,"data-slot":"item",class:X(q.value.item({class:[t(o).ui?.item]}))},{default:B(()=>[p(t(Ll),{"data-slot":"itemText",class:X(q.value.itemText({class:[t(o).ui?.itemText]}))},{default:B(()=>[u["item-text"]?ye(H.$slots,"item-text",{key:0,item:ve,index:he,ui:q.value}):R("",!0)]),_:2},1032,["class"]),p(t(zl),{"data-slot":"itemDelete",class:X(q.value.itemDelete({class:[t(o).ui?.itemDelete]})),disabled:t(S)},{default:B(()=>[ye(H.$slots,"item-delete",{item:ve,index:he,ui:q.value},()=>[p(_e,{name:t(o).deleteIcon||t(c).ui.icons.close,"data-slot":"itemDeleteIcon",class:X(q.value.itemDeleteIcon({class:[t(o).ui?.itemDeleteIcon]}))},null,8,["name","class"])])]),_:2},1032,["class","disabled"])]),_:2},1032,["value","class"]))),128)),p(t(Sl),ze({ref_key:"inputRef",ref:Y},{...H.$attrs,...t(T)},{placeholder:t(o).placeholder,"max-length":t(o).maxLength,"data-slot":"input",class:q.value.input({class:t(o).ui?.input}),onBlur:ce,onFocus:ne}),null,16,["placeholder","max-length","class"]),ye(H.$slots,"default",{ui:q.value}),t(E)||t(o).avatar||u.leading?(r(),m("span",{key:0,"data-slot":"leading",class:X(q.value.leading({class:t(o).ui?.leading}))},[ye(H.$slots,"leading",{ui:q.value},()=>[t(E)&&t(D)?(r(),U(_e,{key:0,name:t(D),"data-slot":"leadingIcon",class:X(q.value.leadingIcon({class:t(o).ui?.leadingIcon}))},null,8,["name","class"])):t(o).avatar?(r(),U(Ht,ze({key:1,size:t(o).ui?.leadingAvatarSize||q.value.leadingAvatarSize()},t(o).avatar,{"data-slot":"leadingAvatar",class:q.value.leadingAvatar({class:t(o).ui?.leadingAvatar})}),null,16,["size","class"])):R("",!0)])],2)):R("",!0),t(F)||u.trailing?(r(),m("span",{key:1,"data-slot":"trailing",class:X(q.value.trailing({class:t(o).ui?.trailing}))},[ye(H.$slots,"trailing",{ui:q.value},()=>[t(A)?(r(),U(_e,{key:0,name:t(A),"data-slot":"trailingIcon",class:X(q.value.trailingIcon({class:t(o).ui?.trailingIcon}))},null,8,["name","class"])):R("",!0)])],2)):R("",!0)]),_:3},16,["id","model-value","default-value","class","name","disabled"]))}}),Tk={class:"flex items-center justify-between gap-3"},Mk={class:"flex items-center gap-2"},Ak={class:"text-sm font-medium text-gray-900 dark:text-white"},zk={class:"text-xs text-gray-500 dark:text-gray-400"},qk=ue({__name:"OwnerEntryCard",props:{sessionId:{},members:{},chatType:{}},setup(i){const{t:l}=we(),e=Dn(),n=i,s=z(!1);function u(g){return g.groupNickname||g.accountName||g.platformId}const o=M(()=>{const g=e.currentSession?.ownerId;return g&&n.members.find(h=>h.platformId===g)||null}),c=M(()=>o.value?u(o.value):e.currentSession?.ownerId??"");return(g,h)=>{const f=_e,b=Ue;return r(),U(t(mt),{class:"w-150 p-3"},{default:B(()=>[a("div",Tk,[a("div",Mk,[a("div",{class:X(["flex h-8 w-8 items-center justify-center rounded-full bg-linear-to-br",i.chatType==="group"?"from-pink-400 to-pink-600":"from-purple-400 to-purple-600"])},[p(f,{name:"i-heroicons-user",class:"h-4 w-4 text-white"})],2),a("div",null,[a("h3",Ak,d(c.value?t(l)("members.ownerPrompt.currentOwner",{name:c.value}):t(l)("members.ownerPrompt.choose")),1),a("p",zk,d(t(l)("members.ownerPrompt.helper")),1)])]),p(b,{size:"sm",variant:c.value?"outline":"solid",color:"primary",onClick:h[0]||(h[0]=y=>s.value=!0)},{default:B(()=>[le(d(c.value?t(l)("members.ownerPrompt.change"):t(l)("members.ownerPrompt.choose")),1)]),_:1},8,["variant"])]),p(En,{modelValue:s.value,"onUpdate:modelValue":h[1]||(h[1]=y=>s.value=y),"session-id":i.sessionId,"chat-type":i.chatType},null,8,["modelValue","session-id","chat-type"])]),_:1})}}}),Lk={key:0,class:"mb-6"},Dk={class:"flex items-center gap-3"},Ek={class:"text-xl font-bold text-gray-900 dark:text-white"},Bk={class:"text-sm text-gray-500 dark:text-gray-400"},Fk={class:"mb-4 flex flex-wrap items-center justify-between gap-3"},Rk={key:0,class:"flex items-center gap-2"},Vk={class:"text-xs text-gray-500 dark:text-gray-400"},Ok={key:0,class:"flex flex-1 items-center justify-center"},Pk={key:1,class:"flex flex-1 flex-col items-center justify-center gap-3"},jk={class:"text-sm text-gray-500 dark:text-gray-400"},Nk={key:2,class:"flex flex-1 flex-col items-center justify-center"},Uk={class:"text-gray-500 dark:text-gray-400"},Wk={key:3,class:"min-h-0 flex-1 overflow-x-auto overflow-y-hidden"},Hk={key:0,"aria-hidden":"true"},Kk={class:"flex shrink-0 flex-col leading-none"},Yk={class:"flex shrink-0 flex-col leading-none"},Gk={class:"flex shrink-0 flex-col leading-none"},Qk={class:"inline-flex items-center gap-1.5"},Jk={class:"text-right"},Xk=["data-index","onClick"],Zk={key:0,class:"flex justify-center"},e_={class:"flex min-w-0 items-center gap-2.5"},t_={class:"min-w-0"},a_=["title"],s_=["title"],n_=["title"],o_={class:"text-right font-mono text-sm font-semibold tabular-nums text-gray-900 dark:text-white"},l_=["title"],r_={class:"flex justify-end gap-1"},i_={class:"p-6 text-center"},u_={class:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30"},c_={class:"mb-2 text-lg font-semibold text-gray-900 dark:text-white"},d_={class:"mb-6 text-sm text-gray-500 dark:text-gray-400"},m_={class:"flex justify-center gap-3"},g_={class:"p-6 text-center"},p_={class:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30"},h_={class:"mb-2 text-lg font-semibold text-gray-900 dark:text-white"},f_={class:"mb-6 text-sm text-gray-500 dark:text-gray-400"},v_={class:"flex justify-center gap-3"},y_={class:"p-6"},x_={class:"mb-4 flex items-center gap-3"},b_={class:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100 dark:bg-amber-900/30"},k_={class:"text-lg font-semibold text-gray-900 dark:text-white"},__={class:"mb-2 text-sm text-gray-600 dark:text-gray-400"},w_={class:"mb-6 text-xs text-amber-700 dark:text-amber-300"},$_={class:"flex justify-end gap-2"},C_=64,S_=ue({__name:"MemberList",props:{sessionId:{},showHeader:{type:Boolean,default:!0},chatType:{default:"group"}},emits:["data-changed"],setup(i,{emit:l}){const{t:e}=we(),n=Ke(),s=bt(),u=i,o=l,c=z([]),g=z(!1),h=z(!1),f=z(""),b=M(()=>jn(u.chatType,c.value.length)),y=M(()=>u.chatType==="group"?"":b.value?"member-table-grid--private":"member-table-grid--private-without-selection"),k=z(null),x=z(!1),_=z(!1),C=z(!1),$=z(!1),S=z(!1),{sortState:T,toggleSort:v,resetSort:w,isSortActive:E}=Bn({initialState:{field:"messageCount",direction:"desc"}}),F=z(new Set);let D=0;function A(V,K){const L=K instanceof Error?K:new Error(String(K));console.error(V,L),Pn(`${V} ${L.message}`,L.stack)}function I(V){return V.groupNickname||V.accountName||V.platformId}function q(V){return I(V).slice(0,1)}function Y(V){s.openChatRecordDrawer({sessionId:u.sessionId,memberId:V.id,memberName:I(V)})}const G=M(()=>Nn(c.value,f.value,T.value)),{selectedIds:Z,setSelection:ce,clearSelection:ne,handleRowClick:H,handleRowMouseDown:W}=Fn({rows:G,getRowId:V=>V.id}),re=M(()=>c.value.filter(V=>Z.value.has(V.id))),ve=M(()=>re.value.length===2),he=M(()=>re.value.reduce((V,K)=>V+K.messageCount,0));function ee(V,K,L){b.value&&H(V,K,L)}function te(V){b.value&&W(V)}const j=M(()=>{if(re.value.length!==2)return null;const[V,K]=re.value;return K.messageCount>V.messageCount||K.messageCount===V.messageCount&&K.id<V.id?{primary:K,secondary:V}:{primary:V,secondary:K}});function de(V,K){return E(V,K)?"text-primary-500 dark:text-primary-400":"text-gray-300 dark:text-gray-600"}const be=z(null),xe=Rn(M(()=>({count:G.value.length,getScrollElement:()=>be.value,estimateSize:()=>C_,overscan:8,getItemKey:V=>G.value[V]?.id??V}))),oe=M(()=>xe.value.getVirtualItems().map(V=>({virtualItem:V,member:G.value[V.index]}))),Q=M(()=>xe.value.getTotalSize());function J(V){V instanceof HTMLElement&&xe.value.measureElement(V)}async function ge(){await De(),be.value?.scrollTo({top:0}),xe.value.measure()}async function ke(){const V=u.sessionId;if(!V)return;const K=++D;g.value=!0,h.value=!1;try{const L=await n.getMembers(V);if(K!==D||V!==u.sessionId)return;c.value=L,await De(),xe.value.measure()}catch(L){K===D&&(h.value=!0),A("Failed to load member list:",L)}finally{K===D&&(g.value=!1)}}function $e(V,K){const L=new Set(F.value);K?L.add(V):L.delete(V),F.value=L}async function Le(V,K){const L=u.sessionId,P=JSON.parse(JSON.stringify(K)),N=JSON.stringify(V.aliases),ae=JSON.stringify(P);if(N!==ae){$e(V.id,!0);try{if(await n.updateMemberAliases(L,V.id,P)&&L===u.sessionId){const Ve=c.value.findIndex(qe=>qe.id===V.id);Ve!==-1&&(c.value[Ve]={...c.value[Ve],aliases:P},await De(),xe.value.measure())}}catch(se){A("Failed to save member aliases:",se)}finally{$e(V.id,!1)}}}function Be(V){k.value=V}function Te(){k.value=null}async function Pe(){if(k.value){x.value=!0;try{const V=k.value.id;if(await n.deleteMember(u.sessionId,V)){const L=new Set(Z.value);L.delete(V),ce(L),await ke(),o("data-changed")}}catch(V){A("Failed to delete member:",V)}finally{x.value=!1,k.value=null}}}function je(){Z.value.size!==0&&(_.value=!0)}async function Se(){const V=u.sessionId,K=Array.from(Z.value);if(K.length!==0){C.value=!0;try{await n.deleteMembers(V,K)&&V===u.sessionId&&(_.value=!1,ne(),await ke(),o("data-changed"))}catch(L){A("Failed to delete selected members:",L)}finally{C.value=!1}}}function me(){ve.value&&($.value=!0)}async function O(){if(j.value){S.value=!0;try{await n.mergeMembers(u.sessionId,j.value.primary.id,j.value.secondary.id)&&($.value=!1,ne(),await ke(),o("data-changed"))}catch(V){A("Failed to merge members:",V)}finally{S.value=!1}}}return fe([f,T],ge),fe(b,V=>{V||ne()}),fe(()=>u.sessionId,()=>{D+=1,c.value=[],h.value=!1,F.value=new Set,f.value="",w(),ne(),ge(),ke()},{immediate:!0}),tt(()=>{D+=1}),(V,K)=>{const L=Ue,P=Bt,N=_e,ae=St,se=_a,Ve=Ik,qe=Xe;return r(),m("div",{class:X(["main-content",u.showHeader?"max-w-5xl p-6":"flex h-full max-w-none flex-col overflow-hidden p-4"])},[u.showHeader?(r(),m("div",Lk,[a("div",Dk,[a("div",null,[a("h2",Ek,d(t(e)(u.chatType==="private"?"members.private.title":"members.list.title")),1),a("p",Bk,d(t(e)(u.chatType==="private"?"members.private.description":"members.list.description",{count:c.value.length})),1)])])])):R("",!0),p(qk,{class:"mb-6","session-id":i.sessionId,members:c.value,"chat-type":u.chatType},null,8,["session-id","members","chat-type"]),a("div",Fk,[p(P,{modelValue:f.value,"onUpdate:modelValue":K[1]||(K[1]=Me=>f.value=Me),placeholder:t(e)("members.list.searchPlaceholder"),icon:"i-heroicons-magnifying-glass",class:"w-full md:w-100"},Vn({_:2},[f.value?{name:"trailing",fn:B(()=>[p(L,{icon:"i-heroicons-x-mark",variant:"link",color:"neutral",size:"xs",onClick:K[0]||(K[0]=Me=>f.value="")})]),key:"0"}:void 0]),1032,["modelValue","placeholder"]),b.value?(r(),m("div",Rk,[g.value&&c.value.length>0?(r(),U(N,{key:0,name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin text-primary-500"})):R("",!0),a("span",Vk,d(t(e)("members.list.selectedCount",{count:t(Z).size})),1),p(L,{icon:"i-heroicons-link",size:"sm",color:"primary",disabled:!ve.value,onClick:me},{default:B(()=>[le(d(t(e)("members.list.mergeSelected")),1)]),_:1},8,["disabled"]),p(L,{icon:"i-heroicons-trash",size:"sm",color:"error",variant:"outline",disabled:t(Z).size===0,onClick:je},{default:B(()=>[le(d(t(e)("members.list.deleteSelected")),1)]),_:1},8,["disabled"])])):R("",!0)]),a("div",{class:X(["flex min-h-[240px] flex-col overflow-hidden rounded-lg border border-gray-200/60 bg-card-bg dark:border-white/5 dark:bg-card-dark",u.showHeader?"h-[500px]":"min-h-0 flex-1"])},[g.value&&c.value.length===0?(r(),m("div",Ok,[p(N,{name:"i-heroicons-arrow-path",class:"h-8 w-8 animate-spin text-primary-500"})])):h.value&&c.value.length===0?(r(),m("div",Pk,[p(N,{name:"i-heroicons-exclamation-circle",class:"h-10 w-10 text-red-400"}),a("p",jk,d(t(e)("members.list.loadError")),1),p(L,{size:"sm",variant:"outline",icon:"i-heroicons-arrow-path",onClick:ke},{default:B(()=>[le(d(t(e)("common.retry")),1)]),_:1})])):G.value.length===0?(r(),m("div",Nk,[p(N,{name:"i-heroicons-user-group",class:"mb-3 h-12 w-12 text-gray-300 dark:text-gray-600"}),a("p",Uk,d(f.value?t(e)("members.list.noMatch"):t(e)("members.list.empty")),1)])):(r(),m("div",Wk,[a("div",{class:X(["flex h-full flex-col",u.chatType==="private"?"min-w-[920px]":"min-w-[1120px]"])},[a("div",{class:X(["member-table-grid shrink-0 border-b border-gray-200 bg-gray-50 px-3 py-2 text-xs font-medium text-gray-500 dark:border-white/5 dark:bg-page-dark/80 dark:text-gray-400",y.value])},[b.value?(r(),m("span",Hk)):R("",!0),a("span",null,d(t(e)("members.list.table.accountName")),1),u.chatType==="group"?(r(),m("button",{key:1,type:"button",class:"flex items-center justify-start gap-1.5 text-left transition-colors hover:text-gray-700 dark:hover:text-gray-200",onClick:K[2]||(K[2]=Me=>t(v)("groupNickname"))},[le(d(t(e)("members.list.table.groupNickname"))+" ",1),a("span",Kk,[p(N,{name:"i-heroicons-chevron-up",class:X(["h-2.5 w-2.5",de("groupNickname","asc")])},null,8,["class"]),p(N,{name:"i-heroicons-chevron-down",class:X(["-mt-0.5 h-2.5 w-2.5",de("groupNickname","desc")])},null,8,["class"])])])):R("",!0),a("button",{type:"button",class:"flex items-center justify-end gap-1.5 text-right transition-colors hover:text-gray-700 dark:hover:text-gray-200",onClick:K[3]||(K[3]=Me=>t(v)("messageCount"))},[le(d(t(e)("members.list.table.messageCount"))+" ",1),a("span",Yk,[p(N,{name:"i-heroicons-chevron-up",class:X(["h-2.5 w-2.5",de("messageCount","asc")])},null,8,["class"]),p(N,{name:"i-heroicons-chevron-down",class:X(["-mt-0.5 h-2.5 w-2.5",de("messageCount","desc")])},null,8,["class"])])]),a("button",{type:"button",class:"flex items-center justify-end gap-1.5 text-right transition-colors hover:text-gray-700 dark:hover:text-gray-200",onClick:K[4]||(K[4]=Me=>t(v)("lastMessageTs"))},[le(d(t(e)("members.list.table.lastMessageTime"))+" ",1),a("span",Gk,[p(N,{name:"i-heroicons-chevron-up",class:X(["h-2.5 w-2.5",de("lastMessageTs","asc")])},null,8,["class"]),p(N,{name:"i-heroicons-chevron-down",class:X(["-mt-0.5 h-2.5 w-2.5",de("lastMessageTs","desc")])},null,8,["class"])])]),a("span",Qk,[a("span",null,d(t(e)("members.list.table.customAlias")),1),p(ae,{text:t(e)("members.list.tip"),popper:{placement:"top"}},{default:B(()=>[p(N,{name:"i-heroicons-question-mark-circle",class:"h-4 w-4 text-gray-400 dark:text-gray-500"})]),_:1},8,["text"])]),a("span",Jk,d(t(e)("members.list.table.actions")),1)],2),a("div",{ref_key:"listScrollRef",ref:be,class:"min-h-0 flex-1 overflow-y-auto"},[a("div",{class:"relative",style:et({height:`${Q.value}px`})},[(r(!0),m(ie,null,pe(oe.value,({virtualItem:Me,member:Fe})=>(r(),m("div",{key:String(Me.key),ref_for:!0,ref:J,"data-index":Me.index,class:X(["member-table-grid absolute left-0 top-0 w-full min-h-16 border-b border-gray-100/80 px-3 py-2 transition-colors hover:bg-gray-50 dark:border-white/5 dark:hover:bg-gray-800/30",[y.value,b.value?"cursor-pointer":"",b.value&&t(Z).has(Fe.id)?"bg-primary-50/70 dark:bg-primary-950/20":""]]),style:et({transform:`translateY(${Me.start}px)`}),onMousedown:te,onClick:st=>ee(Me.index,Fe.id,st)},[b.value?(r(),m("div",Zk,[p(se,{"model-value":t(Z).has(Fe.id),onClick:Oe(st=>ee(Me.index,Fe.id,st),["stop"])},null,8,["model-value","onClick"])])):R("",!0),a("div",e_,[p(On,{src:Fe.avatar,alt:I(Fe),text:q(Fe),"fallback-class":["flex h-8 w-8 items-center justify-center rounded-full text-[10px] font-bold","bg-primary-500 text-white"]},null,8,["src","alt","text"]),a("div",t_,[a("p",{class:"truncate text-sm font-medium text-gray-900 dark:text-white",title:Fe.accountName||"-"},d(Fe.accountName||"-"),9,a_),a("p",{class:"truncate text-xs text-gray-400 dark:text-gray-500",title:Fe.platformId},d(Fe.platformId),9,s_)])]),u.chatType==="group"?(r(),m("p",{key:1,class:X(["truncate text-sm text-gray-700 dark:text-gray-300",Fe.groupNickname?"font-medium":"text-gray-400 dark:text-gray-500"]),title:Fe.groupNickname||"-"},d(Fe.groupNickname||"-"),11,n_)):R("",!0),a("span",o_,d(Fe.messageCount.toLocaleString()),1),a("span",{class:"text-right font-mono text-xs tabular-nums text-gray-600 dark:text-gray-400",title:Fe.lastMessageTs===null?"-":t(ja)(Fe.lastMessageTs)},d(Fe.lastMessageTs===null?"-":t(ja)(Fe.lastMessageTs)),9,l_),p(Ve,{"model-value":Fe.aliases,placeholder:t(e)("members.list.aliasPlaceholder"),loading:F.value.has(Fe.id),size:"xs",class:"w-full",onClick:K[5]||(K[5]=Oe(()=>{},["stop"])),"onUpdate:modelValue":st=>Le(Fe,st)},null,8,["model-value","placeholder","loading","onUpdate:modelValue"]),a("div",r_,[p(L,{icon:"i-heroicons-chat-bubble-left-ellipsis",size:"xs",color:"neutral",variant:"ghost",title:t(e)("common.viewChatRecords"),onClick:Oe(st=>Y(Fe),["stop"])},null,8,["title","onClick"]),p(L,{icon:"i-heroicons-trash",size:"xs",color:"error",variant:"ghost",title:t(e)("members.list.delete"),onClick:Oe(st=>Be(Fe),["stop"])},null,8,["title","onClick"])])],46,Xk))),128))],4)],512)],2)]))],2),p(qe,{open:!!k.value,ui:{content:"max-w-sm"},"onUpdate:open":K[6]||(K[6]=Me=>k.value=null)},{content:B(()=>[a("div",i_,[a("div",u_,[p(N,{name:"i-heroicons-exclamation-triangle",class:"h-7 w-7 text-red-500"})]),a("h3",c_,d(t(e)("members.list.modal.title")),1),a("p",d_,d(t(e)("members.list.modal.content",{name:k.value?I(k.value):"",count:k.value?.messageCount.toLocaleString()})),1),a("div",m_,[p(L,{variant:"outline",onClick:Te},{default:B(()=>[le(d(t(e)("members.list.modal.cancel")),1)]),_:1}),p(L,{color:"error",loading:x.value,onClick:Pe},{default:B(()=>[le(d(t(e)("members.list.modal.confirm")),1)]),_:1},8,["loading"])])])]),_:1},8,["open"]),p(qe,{open:_.value,ui:{content:"max-w-sm"},"onUpdate:open":K[8]||(K[8]=Me=>_.value=Me)},{content:B(()=>[a("div",g_,[a("div",p_,[p(N,{name:"i-heroicons-exclamation-triangle",class:"h-7 w-7 text-red-500"})]),a("h3",h_,d(t(e)("members.list.batchDeleteModal.title")),1),a("p",f_,d(t(e)("members.list.batchDeleteModal.content",{count:re.value.length,messageCount:he.value.toLocaleString()})),1),a("div",v_,[p(L,{variant:"outline",disabled:C.value,onClick:K[7]||(K[7]=Me=>_.value=!1)},{default:B(()=>[le(d(t(e)("members.list.modal.cancel")),1)]),_:1},8,["disabled"]),p(L,{color:"error",loading:C.value,onClick:Se},{default:B(()=>[le(d(t(e)("members.list.modal.confirm")),1)]),_:1},8,["loading"])])])]),_:1},8,["open"]),p(qe,{open:$.value,ui:{content:"max-w-md"},"onUpdate:open":K[10]||(K[10]=Me=>$.value=Me)},{content:B(()=>[a("div",y_,[a("div",x_,[a("div",b_,[p(N,{name:"i-heroicons-link",class:"h-5 w-5 text-amber-600 dark:text-amber-400"})]),a("h3",k_,d(t(e)("members.list.mergeModal.title")),1)]),a("p",__,d(t(e)("members.list.mergeModal.content",{source:j.value?I(j.value.secondary):"",sourceCount:j.value?j.value.secondary.messageCount.toLocaleString():"0",target:j.value?I(j.value.primary):"",targetCount:j.value?j.value.primary.messageCount.toLocaleString():"0"})),1),a("p",w_,d(t(e)("members.list.mergeModal.hint")),1),a("div",$_,[p(L,{variant:"outline",disabled:S.value,onClick:K[9]||(K[9]=Me=>$.value=!1)},{default:B(()=>[le(d(t(e)("members.list.mergeModal.cancel")),1)]),_:1},8,["disabled"]),p(L,{color:"primary",loading:S.value,onClick:O},{default:B(()=>[le(d(t(e)("members.list.mergeModal.confirm")),1)]),_:1},8,["loading"])])])]),_:1},8,["open"])],2)}}}),e2=dt(S_,[["__scopeId","data-v-0754d30f"]]),I_={class:"mt-3 flex flex-col items-stretch gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3"},T_={class:"max-w-full overflow-x-auto scrollbar-hide"},t2=ue({__name:"SessionAnalysisHeader",props:qt({title:{},avatar:{},icon:{},iconClass:{},tabs:{},currentSessionId:{},initialTimeState:{},showSessionActions:{type:Boolean,default:!0}},{activeTab:{required:!0},activeTabModifiers:{},timeRangeValue:{required:!0},timeRangeValueModifiers:{}}),emits:qt(["openIncrementalImport","openMemberManagement","openChatRecord","update:fullRange","update:availableYears"],["update:activeTab","update:timeRangeValue"]),setup(i,{emit:l}){const e=Wt(i,"activeTab"),n=Wt(i,"timeRangeValue"),s=i,u=l,{t:o}=we(),c=bt(),g=M(()=>!["ai-chat","memory","lab","debug"].includes(e.value)),h=M(()=>s.tabs.map(f=>({id:f.id,label:o(f.labelKey),icon:f.icon})));return(f,b)=>{const y=Ue,k=St;return r(),U(so,{title:i.title,avatar:i.avatar,size:"compact",icon:i.icon,"icon-class":i.iconClass},{actions:B(()=>[i.showSessionActions&&t(c).toolsPanelPosition==="header"?(r(),m(ie,{key:0},[p(k,{text:t(o)("analysis.tooltip.viewChatRecord")},{default:B(()=>[p(y,{icon:"i-heroicons-chat-bubble-bottom-center-text",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:b[0]||(b[0]=x=>u("openChatRecord"))})]),_:1},8,["text"]),p(k,{text:t(o)("analysis.tooltip.incrementalImport")},{default:B(()=>[p(y,{icon:"i-heroicons-plus-circle",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:b[1]||(b[1]=x=>u("openIncrementalImport"))})]),_:1},8,["text"]),p(k,{text:t(o)("analysis.tooltip.memberManagement")},{default:B(()=>[p(y,{icon:"i-heroicons-user-group",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:b[2]||(b[2]=x=>u("openMemberManagement"))})]),_:1},8,["text"]),p(Lt,{color:"gray"}),p(k,{text:t(o)("analysis.tooltip.more")},{default:B(()=>[p(y,{"data-tools-panel-trigger":"",icon:"i-heroicons-ellipsis-horizontal",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:b[3]||(b[3]=x=>t(c).toggleToolsPanelOpen())})]),_:1},8,["text"])],64)):i.showSessionActions?(r(),U(Lt,{key:1,color:"gray"})):R("",!0)]),default:B(()=>[a("div",I_,[p(t(Un),{modelValue:e.value,"onUpdate:modelValue":b[4]||(b[4]=x=>e.value=x),class:"min-w-0 shrink",items:h.value},null,8,["modelValue","items"]),a("div",T_,[p(ao,{modelValue:n.value,"onUpdate:modelValue":b[5]||(b[5]=x=>n.value=x),"session-id":i.currentSessionId??void 0,visible:g.value,"initial-state":i.initialTimeState,size:"sm","onUpdate:fullRange":b[6]||(b[6]=x=>u("update:fullRange",x)),"onUpdate:availableYears":b[7]||(b[7]=x=>u("update:availableYears",x))},null,8,["modelValue","session-id","visible","initial-state"])])])]),_:1},8,["title","avatar","icon","icon-class"])}}}),M_={class:"space-y-4 p-5"},A_={class:"flex items-center gap-2"},z_={class:"text-base font-semibold text-gray-900 dark:text-white"},q_={key:0,class:"flex items-center gap-2 text-sm text-gray-400"},L_={class:"rounded-lg border border-gray-200 bg-gray-50 p-3 text-sm dark:border-gray-700 dark:bg-gray-800/50"},D_={class:"flex items-center justify-between"},E_={class:"text-gray-500"},B_={class:"font-medium text-gray-800 dark:text-gray-200"},F_={key:0,class:"mt-1 flex items-center justify-between"},R_={class:"text-gray-500"},V_={class:"text-gray-700 dark:text-gray-300"},O_={key:1,class:"mt-2"},P_={class:"flex items-center justify-between text-xs text-gray-500"},j_={class:"mt-1 h-1.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},N_={key:2,class:"mt-1 text-xs text-red-500"},U_={class:"text-sm text-gray-600 dark:text-gray-400"},W_={key:0,class:"rounded border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-700 dark:border-amber-800/50 dark:bg-amber-900/20 dark:text-amber-400"},H_={class:"flex justify-end gap-2"},K_={class:"text-xs text-gray-400"},Y_={class:"flex flex-wrap justify-end gap-2"},Ne="settings.ai.semanticIndex",a2=ue({__name:"SemanticIndexSessionModal",props:{modelValue:{type:Boolean},sessionId:{},messageCount:{}},emits:["update:modelValue"],setup(i,{emit:l}){const e=i,n=l,{t:s}=we(),u=Wn(),o=M({get:()=>e.modelValue,set:T=>n("update:modelValue",T)}),c=z(null),g=z(!1),h=z(!1),f=z(!1),b=M(()=>{const T=c.value;return!T||!T.enabled?s(`${Ne}.session.notEnabled`):T.needsRebuild?s(`${Ne}.state.needsRebuild`):T.running||T.queued||T.indexStatus==="running"?s(`${Ne}.state.building`):T.indexStatus==="completed"?s(`${Ne}.state.completed`):T.indexStatus==="failed"?s(`${Ne}.state.failed`):T.indexStatus==="paused"?s(`${Ne}.state.paused`):s(`${Ne}.state.pending`)}),y=M(()=>{const T=c.value;return!!T&&(T.running||T.queued||T.indexStatus==="running")}),k=M(()=>c.value&&c.value.totalMessages>0?Math.round(c.value.indexedMessages/c.value.totalMessages*100):0);let x=null;function _(){x&&(clearTimeout(x),x=null)}function C(){_(),x=setTimeout(async()=>{try{c.value=await u.status(e.sessionId)}catch(T){console.error("[semantic-index] poll status failed:",T)}y.value&&e.modelValue?C():_()},1500)}async function $(){h.value=!0;try{const[T,v]=await Promise.all([u.getConfig(),u.status(e.sessionId)]);g.value=T.config.enabled&&T.configured&&(T.config.mode==="local"?!!T.config.local.modelId:!!T.config.api?.baseUrl&&!!T.config.api?.model&&(!Hn(T.config.api?.baseUrl)||T.apiKeySet)),c.value=v}catch(T){console.error("[semantic-index] load session status failed:",T)}finally{h.value=!1}y.value&&C()}async function S(T){f.value=!0;try{c.value=await u[T](e.sessionId)}catch(v){console.error(`[semantic-index] ${T} failed:`,v)}finally{f.value=!1}y.value?C():_()}return fe(()=>e.modelValue,T=>{T?$():_()}),tt(_),(T,v)=>{const w=_e,E=Ue,F=Xe;return r(),U(F,{open:o.value,"onUpdate:open":v[10]||(v[10]=D=>o.value=D),ui:{content:"z-[101]",overlay:"z-[100]"}},{content:B(()=>[a("div",M_,[a("div",A_,[p(w,{name:"i-heroicons-circle-stack",class:"h-5 w-5 text-blue-500"}),a("h3",z_,d(t(s)(`${Ne}.title`)),1)]),h.value?(r(),m("div",q_,[p(w,{name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin"}),le(" "+d(t(s)("common.loading")),1)])):(r(),m(ie,{key:1},[a("div",L_,[a("div",D_,[a("span",E_,d(t(s)(`${Ne}.session.statusLabel`)),1),a("span",B_,d(b.value),1)]),c.value?.enabled&&c.value.indexStatus==="completed"?(r(),m("div",F_,[a("span",R_,d(t(s)(`${Ne}.session.coverageLabel`)),1),a("span",V_,d(k.value)+"%",1)])):R("",!0),y.value?(r(),m("div",O_,[a("div",P_,[a("span",null,d(t(s)(`${Ne}.session.progressLabel`)),1),a("span",null,d(c.value?.indexedMessages??0)+" / "+d(c.value?.totalMessages??0)+" ("+d(k.value)+"%) ",1)]),a("div",j_,[a("div",{class:"h-full rounded-full bg-blue-500 transition-all duration-500",style:et({width:`${k.value}%`})},null,4)])])):R("",!0),c.value?.error?(r(),m("p",N_,d(c.value.error),1)):R("",!0)]),c.value?.enabled?(r(),m(ie,{key:1},[a("p",K_,d(t(s)(`${Ne}.session.buildVsEnable`)),1),a("div",Y_,[y.value?(r(),m(ie,{key:0},[p(E,{variant:"soft",loading:f.value,onClick:v[2]||(v[2]=D=>S("pause"))},{default:B(()=>[le(d(t(s)(`${Ne}.action.pause`)),1)]),_:1},8,["loading"]),p(E,{color:"error",variant:"soft",disabled:f.value,onClick:v[3]||(v[3]=D=>S("cancel"))},{default:B(()=>[le(d(t(s)(`${Ne}.action.cancel`)),1)]),_:1},8,["disabled"])],64)):c.value?.indexStatus==="completed"&&!c.value?.needsRebuild?(r(),U(E,{key:1,variant:"soft",loading:f.value,onClick:v[4]||(v[4]=D=>S("rebuild"))},{default:B(()=>[le(d(t(s)(`${Ne}.action.rebuild`)),1)]),_:1},8,["loading"])):c.value?.needsRebuild?(r(),U(E,{key:2,color:"primary",loading:f.value,onClick:v[5]||(v[5]=D=>S("rebuild"))},{default:B(()=>[le(d(t(s)(`${Ne}.action.rebuild`)),1)]),_:1},8,["loading"])):c.value?.indexStatus==="failed"?(r(),U(E,{key:3,color:"primary",loading:f.value,onClick:v[6]||(v[6]=D=>S("build"))},{default:B(()=>[le(d(t(s)(`${Ne}.session.retry`)),1)]),_:1},8,["loading"])):c.value?.indexStatus==="paused"?(r(),U(E,{key:4,color:"primary",loading:f.value,onClick:v[7]||(v[7]=D=>S("build"))},{default:B(()=>[le(d(t(s)(`${Ne}.session.continue`)),1)]),_:1},8,["loading"])):(r(),U(E,{key:5,color:"primary",loading:f.value,onClick:v[8]||(v[8]=D=>S("build"))},{default:B(()=>[le(d(t(s)(`${Ne}.action.build`)),1)]),_:1},8,["loading"])),p(E,{variant:"ghost",color:"neutral",disabled:f.value,onClick:v[9]||(v[9]=D=>S("remove"))},{default:B(()=>[le(d(t(s)(`${Ne}.action.remove`)),1)]),_:1},8,["disabled"])])],64)):(r(),m(ie,{key:0},[a("p",U_,d(t(s)(`${Ne}.session.enableHint`)),1),g.value?R("",!0):(r(),m("p",W_,d(t(s)(`${Ne}.session.configFirst`)),1)),a("div",H_,[p(E,{variant:"ghost",onClick:v[0]||(v[0]=D=>o.value=!1)},{default:B(()=>[le(d(t(s)("common.close")),1)]),_:1}),p(E,{color:"primary",loading:f.value,disabled:!g.value,onClick:v[1]||(v[1]=D=>S("enable"))},{default:B(()=>[le(d(t(s)(`${Ne}.session.enable`)),1)]),_:1},8,["loading","disabled"])])],64))],64))])]),_:1},8,["open"])}}}),G_={class:"min-h-[200px]"},Q_={key:0,class:"space-y-4"},J_={class:"text-sm text-gray-600 dark:text-gray-400"},X_={class:"text-sm text-gray-600 dark:text-gray-400"},Z_={key:1,class:"flex flex-col items-center justify-center py-10"},ew={class:"text-gray-600 dark:text-gray-400"},tw={class:"mt-2 text-sm text-gray-500"},aw={key:2,class:"space-y-6"},sw={class:"rounded-lg bg-gray-50 p-4 dark:bg-gray-800"},nw={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},ow={class:"grid grid-cols-3 gap-4 text-center"},lw={class:"text-2xl font-bold text-gray-900 dark:text-white"},rw={class:"text-xs text-gray-500"},iw={class:"text-2xl font-bold text-green-600 dark:text-green-400"},uw={class:"text-xs text-gray-500"},cw={class:"text-2xl font-bold text-gray-400"},dw={class:"text-xs text-gray-500"},mw={key:0,class:"text-center text-sm text-amber-600 dark:text-amber-400"},gw={key:3,class:"flex flex-col items-center justify-center py-10"},pw={class:"text-gray-600 dark:text-gray-400"},hw={key:0,class:"mt-4 w-full max-w-xs"},fw={key:4,class:"flex flex-col items-center justify-center py-10"},vw={class:"text-lg font-medium text-gray-900 dark:text-white"},yw={class:"mt-2 text-sm text-gray-600 dark:text-gray-400"},xw={key:5,class:"flex flex-col items-center justify-center py-10"},bw={class:"text-lg font-medium text-gray-900 dark:text-white"},kw={class:"mt-2 text-sm text-red-600 dark:text-red-400"},_w={class:"flex w-full justify-end gap-2"},s2=ue({__name:"IncrementalImportModal",props:{modelValue:{type:Boolean},sessionId:{},sessionName:{}},emits:["update:modelValue","imported"],setup(i,{emit:l}){const e=i,n=l,{t:s}=we(),u=z("select"),o=z(null),c=z(null),g=z(null),h=z(null),f=z(null),b=z(null),y=M({get:()=>e.modelValue,set:w=>n("update:modelValue",w)});fe(y,w=>{w||k()});function k(){u.value="select",o.value=null,g.value=null,h.value=null,f.value=null,b.value=null}async function x({files:w,paths:E}){if(w.length>0)o.value={source:w[0],name:w[0].name};else{f.value=s("home.import.cannotReadPath");return}await C()}function _(){c.value?.openFileDialog()}async function C(){if(o.value){u.value="analyzing",f.value=null;try{const w=await Pa().analyzeIncrementalImport(e.sessionId,o.value.source);if(w.error){u.value="error",f.value=v(w.error);return}g.value={newMessageCount:w.newMessageCount,duplicateCount:w.duplicateCount,totalInFile:w.totalInFile},u.value="preview"}catch(w){u.value="error",f.value=String(w)}}}async function $(){if(o.value){u.value="importing",h.value={stage:"saving",progress:0,message:""};try{const w=await Pa().incrementalImport(e.sessionId,o.value.source,E=>{h.value=E});w.success?(b.value={newMessageCount:w.newMessageCount},u.value="done"):(u.value="error",f.value=v(w.error||"error.import_failed"))}catch(w){u.value="error",f.value=String(w)}}}function S(){b.value&&n("imported",b.value.newMessageCount),y.value=!1}function T(){u.value="select",o.value=null,g.value=null,f.value=null}function v(w){if(w.startsWith("error.")){const E=`home.import.errors.${w.slice(6)}`,F=s(E);return F!==E?F:w}return w}return(w,E)=>{const F=Kn,D=_e,A=Yn,I=Ue,q=Xe;return r(),U(q,{open:y.value,"onUpdate:open":E[1]||(E[1]=Y=>y.value=Y),title:t(s)("analysis.incremental.title")},{body:B(()=>[a("div",G_,[u.value==="select"?(r(),m("div",Q_,[a("p",J_,d(t(s)("analysis.incremental.description",{name:i.sessionName})),1),p(F,{color:"info",variant:"soft",icon:"i-heroicons-information-circle",description:t(s)("analysis.incremental.homeAutoImportHint")},null,8,["description"]),p(t(Gn),{ref_key:"dropZoneRef",ref:c,accept:[".json",".jsonl",".txt"],class:"w-full",onFiles:x},{default:B(({isDragOver:Y})=>[a("div",{class:X(["flex cursor-pointer flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 py-10 transition-colors",Y?"border-pink-500 bg-pink-50/50 dark:border-pink-400 dark:bg-pink-500/10":"border-gray-300 hover:border-pink-400 dark:border-gray-600 dark:hover:border-pink-500"]),onClick:Oe(_,["stop"])},[p(D,{name:"i-heroicons-arrow-up-tray",class:"mb-3 h-10 w-10 text-gray-400"}),a("p",X_,d(Y?t(s)("home.import.dropHint"):t(s)("analysis.incremental.dropHint")),1)],2)]),_:1},512)])):u.value==="analyzing"?(r(),m("div",Z_,[p(D,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),a("p",ew,d(t(s)("analysis.incremental.analyzing")),1),a("p",tw,d(o.value?.name),1)])):u.value==="preview"&&g.value?(r(),m("div",aw,[a("div",sw,[a("p",nw,d(o.value?.name),1),a("div",ow,[a("div",null,[a("p",lw,d(g.value.totalInFile.toLocaleString()),1),a("p",rw,d(t(s)("analysis.incremental.totalInFile")),1)]),a("div",null,[a("p",iw,d(g.value.newMessageCount.toLocaleString()),1),a("p",uw,d(t(s)("analysis.incremental.newMessages")),1)]),a("div",null,[a("p",cw,d(g.value.duplicateCount.toLocaleString()),1),a("p",dw,d(t(s)("analysis.incremental.duplicates")),1)])])]),g.value.newMessageCount===0?(r(),m("p",mw,[p(D,{name:"i-heroicons-exclamation-triangle",class:"mr-1 inline-block h-4 w-4"}),le(" "+d(t(s)("analysis.incremental.noNewMessages")),1)])):R("",!0)])):u.value==="importing"?(r(),m("div",gw,[p(D,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),a("p",pw,d(t(s)("analysis.incremental.importing")),1),h.value?(r(),m("div",hw,[p(A,{value:h.value.progress,size:"sm"},null,8,["value"])])):R("",!0)])):u.value==="done"&&b.value?(r(),m("div",fw,[p(D,{name:"i-heroicons-check-circle",class:"mb-4 h-12 w-12 text-green-500"}),a("p",vw,d(t(s)("analysis.incremental.success")),1),a("p",yw,d(t(s)("analysis.incremental.successDetail",{count:b.value.newMessageCount})),1)])):u.value==="error"?(r(),m("div",xw,[p(D,{name:"i-heroicons-x-circle",class:"mb-4 h-12 w-12 text-red-500"}),a("p",bw,d(t(s)("analysis.incremental.failed")),1),a("p",kw,d(f.value),1)])):R("",!0)])]),footer:B(()=>[a("div",_w,[u.value==="select"?(r(),U(I,{key:0,color:"neutral",variant:"ghost",onClick:E[0]||(E[0]=Y=>y.value=!1)},{default:B(()=>[le(d(t(s)("common.cancel")),1)]),_:1})):u.value==="preview"?(r(),m(ie,{key:1},[p(I,{color:"neutral",variant:"ghost",onClick:T},{default:B(()=>[le(d(t(s)("common.back")),1)]),_:1}),p(I,{color:"primary",disabled:!g.value||g.value.newMessageCount===0,onClick:$},{default:B(()=>[le(d(t(s)("analysis.incremental.import",{count:g.value?.newMessageCount||0})),1)]),_:1},8,["disabled"])],64)):u.value==="done"||u.value==="error"?(r(),m(ie,{key:2},[u.value==="error"?(r(),U(I,{key:0,color:"neutral",variant:"ghost",onClick:T},{default:B(()=>[le(d(t(s)("common.retry")),1)]),_:1})):R("",!0),p(I,{color:"primary",onClick:S},{default:B(()=>[le(d(t(s)("common.done")),1)]),_:1})],64)):R("",!0)])]),_:1},8,["open","title"])}}}),ww={key:0,class:"fixed right-0 top-1/3"},$w={class:"no-capture flex flex-col items-center gap-0.5 rounded-l-lg border border-r-0 border-gray-200/60 bg-white py-1.5 shadow-sm dark:border-white/5 dark:bg-page-dark"},Cw=["onClick"],Sw={class:"mb-2 flex items-center justify-between"},Iw={class:"px-0.5 text-[9px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"},Tw={class:"flex flex-col gap-1.5"},Mw=["onClick"],Aw={class:"whitespace-nowrap"},n2=ue({__name:"ActionToolsPanel",emits:["openIncrementalImport","openSemanticIndex","openMemberManagement","openChatRecord","openMessageExport"],setup(i,{emit:l}){const{t:e}=we(),n=bt(),{isToolsPanelMini:s,toolsPanelPosition:u,isToolsPanelOpen:o}=ut(n),c=M(()=>u.value==="header"),g=M(()=>!c.value||o.value),h=z(null),f=l;function b(C){f(C),c.value&&(o.value=!1)}function y(C){if(!c.value||!o.value)return;const $=C.target;$ instanceof Element&&(h.value?.contains($)||$.closest("[data-tools-panel-trigger]")||(o.value=!1))}const k=[{event:"openIncrementalImport",icon:"i-heroicons-plus-circle",hoverColor:"group-hover:text-pink-500",miniHoverBg:"hover:text-pink-500",labelKey:"analysis.tooltip.incrementalImport"},{event:"openSemanticIndex",icon:"i-heroicons-circle-stack",hoverColor:"group-hover:text-indigo-500",miniHoverBg:"hover:text-indigo-500",labelKey:"analysis.tooltip.semanticIndex"},{event:"openMemberManagement",icon:"i-heroicons-user-group",hoverColor:"group-hover:text-purple-500",miniHoverBg:"hover:text-purple-500",labelKey:"analysis.tooltip.memberManagement"},{event:"openChatRecord",icon:"i-heroicons-chat-bubble-bottom-center-text",hoverColor:"group-hover:text-cyan-500",miniHoverBg:"hover:text-cyan-500",labelKey:"analysis.tooltip.viewChatRecord"},{event:"openMessageExport",icon:"i-heroicons-document-arrow-down",hoverColor:"group-hover:text-green-500",miniHoverBg:"hover:text-green-500",labelKey:"analysis.messageExport.title"}],x=[{event:"openSemanticIndex",icon:"i-heroicons-circle-stack",hoverColor:"group-hover:text-indigo-500",miniHoverBg:"hover:text-indigo-500",labelKey:"analysis.tooltip.semanticIndex"},{event:"openMessageExport",icon:"i-heroicons-document-arrow-down",hoverColor:"group-hover:text-green-500",miniHoverBg:"hover:text-green-500",labelKey:"analysis.messageExport.title"}],_=M(()=>c.value?x:k);return fe(u,()=>{o.value=!1}),Re(()=>{document.addEventListener("mousedown",y)}),Xt(()=>{document.removeEventListener("mousedown",y)}),(C,$)=>{const S=_e,T=St;return!c.value&&t(s)?(r(),m("div",ww,[a("div",$w,[(r(),m(ie,null,pe(k,v=>p(T,{key:v.event,text:t(e)(v.labelKey),popper:{placement:"left"}},{default:B(()=>[a("button",{class:X(["flex h-7 w-7 items-center justify-center rounded-md text-gray-400 transition-colors hover:bg-gray-100 dark:text-gray-500 dark:hover:bg-white/5",v.miniHoverBg]),onClick:w=>b(v.event)},[p(S,{name:v.icon,class:"h-3.5 w-3.5"},null,8,["name"])],10,Cw)]),_:2},1032,["text"])),64)),$[2]||($[2]=a("div",{class:"my-0.5 h-px w-4 bg-gray-200 dark:bg-gray-700"},null,-1)),p(T,{text:t(e)("analysis.toolsPanel.exitMini"),popper:{placement:"left"}},{default:B(()=>[a("button",{class:"flex h-7 w-7 items-center justify-center rounded-md text-gray-300 transition-colors hover:bg-gray-100 hover:text-gray-500 dark:text-gray-600 dark:hover:bg-white/5 dark:hover:text-gray-400",onClick:$[0]||($[0]=v=>t(n).toggleToolsPanelMini())},[p(S,{name:"i-heroicons-arrows-pointing-out",class:"h-3 w-3"})])]),_:1},8,["text"])])])):(r(),m("div",{key:1,class:X(["fixed right-0 z-40",c.value?"top-14":"top-1/3"])},[a("div",{class:X(["absolute right-0 top-0 transition-all duration-250 ease-in-out",g.value?"translate-x-0 opacity-100":"pointer-events-none translate-x-full opacity-0"])},[a("div",{ref_key:"panelRef",ref:h,class:"no-capture flex w-40 flex-col rounded-l-xl border border-r-0 border-gray-200/60 bg-white p-3 shadow-overlay dark:border-white/5 dark:bg-page-dark"},[a("div",Sw,[a("span",Iw,d(t(e)("analysis.overview.tools")),1),c.value?R("",!0):(r(),U(T,{key:0,text:t(e)("analysis.toolsPanel.miniMode"),popper:{placement:"left"}},{default:B(()=>[a("button",{class:"flex h-5 w-5 items-center justify-center rounded text-gray-300 transition-colors hover:text-gray-500 dark:text-gray-600 dark:hover:text-gray-400",onClick:$[1]||($[1]=v=>t(n).toggleToolsPanelMini())},[p(S,{name:"i-heroicons-arrows-pointing-in",class:"h-3 w-3"})])]),_:1},8,["text"]))]),a("div",Tw,[(r(!0),m(ie,null,pe(_.value,v=>(r(),m("button",{key:v.event,class:"group flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs font-medium text-gray-600 transition-all hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-white/5 dark:hover:text-white",onClick:w=>b(v.event)},[p(S,{name:v.icon,class:X(["h-3.5 w-3.5 text-gray-400 transition-colors dark:text-gray-500",v.hoverColor])},null,8,["name","class"]),a("span",Aw,d(t(e)(v.labelKey)),1)],8,Mw))),128))])],512)],2)],2))}}});export{Kw as C,Hw as D,Uw as L,e2 as M,na as _,Nw as a,Ze as b,Xw as c,ya as d,Zw as e,Av as f,Yw as g,Gw as h,Qw as i,jw as j,t2 as k,n2 as l,a2 as m,s2 as n,Ww as o,Jw as u};
|
|
109
|
+
`,Xf=ue({__name:"SkillConfigModal",props:{open:{type:Boolean},skillId:{}},emits:["update:open","saved","created"],setup(i,{emit:l}){const{t:e}=we(),n=i,s=l,u=It(),o=z(""),c=z(!1),g=z(!1),h=z(!1);he(()=>[n.open,n.skillId],async([b,y])=>{if(b){if(!y){h.value=!0,o.value=Jf;return}h.value=!1,c.value=!0;try{const k=await u.getSkillConfig(y);if(k){const x=["---",`name: "${k.name}"`,`description: "${k.description}"`,`tags: [${k.tags.map(_=>`"${_}"`).join(", ")}]`,`chatScope: ${k.chatScope}`,k.tools.length?`tools: [${k.tools.map(_=>`"${_}"`).join(", ")}]`:"tools: []",k.builtinId?`builtinId: ${k.builtinId}`:"","---","",k.prompt].filter(Boolean).join(`
|
|
110
|
+
`);o.value=x}}finally{c.value=!1}}},{immediate:!0});async function f(){if(o.value.trim()){g.value=!0;try{if(h.value){const b=await u.createSkill(o.value);b.success&&b.id&&(s("created",b.id),s("update:open",!1))}else n.skillId&&(await u.updateSkill(n.skillId,o.value)).success&&(s("saved"),s("update:open",!1))}finally{g.value=!1}}}return(b,y)=>{const k=_e,x=Xe;return r(),U(x,{open:i.open,ui:{content:"sm:max-w-2xl z-50"},"onUpdate:open":y[3]||(y[3]=_=>s("update:open",_))},{content:B(()=>[a("div",Uf,[a("div",Wf,[a("h2",Hf,d(h.value?t(e)("ai.skill.config.createTitle"):t(e)("ai.skill.config.editTitle")),1),a("button",{class:"rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-300",onClick:y[0]||(y[0]=_=>s("update:open",!1))},[p(k,{name:"i-heroicons-x-mark",class:"h-5 w-5"})])]),a("p",Kf,d(t(e)("ai.skill.config.rawEditorHint")),1),c.value?(r(),m("div",Yf,[p(k,{name:"i-heroicons-arrow-path",class:"mr-2 h-5 w-5 animate-spin"})])):Qe((r(),m("textarea",{key:1,"onUpdate:modelValue":y[1]||(y[1]=_=>o.value=_),class:"h-[400px] w-full resize-none rounded-lg border border-gray-300 bg-gray-50 p-3 font-mono text-xs text-gray-900 focus:border-primary-500 focus:ring-1 focus:ring-primary-500 dark:border-gray-600 dark:bg-page-dark dark:text-gray-100",spellcheck:"false"},null,512)),[[ft,o.value]]),a("div",Gf,[a("button",{class:"rounded-lg px-4 py-2 text-sm text-gray-500 transition-colors hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800",onClick:y[2]||(y[2]=_=>s("update:open",!1))},d(t(e)("common.cancel")),1),a("button",{class:"rounded-lg bg-primary-500 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50",disabled:g.value||!o.value.trim(),onClick:f},d(h.value?t(e)("ai.skill.config.create"):t(e)("ai.skill.config.save")),9,Qf)])])]),_:1},8,["open"])}}}),Zf={key:0,class:"relative"},ev={class:"relative flex flex-nowrap gap-2"},tv=["disabled"],av=["disabled"],sv={class:"inline-flex items-center gap-1"},nv={key:0,class:"absolute left-0 bottom-full z-20 mb-2 w-[320px] max-w-[calc(100vw-3rem)]"},ov={class:"mb-1.5 flex justify-start"},lv={class:"flex flex-wrap gap-2"},rv=["disabled","onClick"],ca="rounded-full ring-1 ring-inset ring-gray-200/80 bg-white/60 shadow-[0_2px_8px_-2px_rgba(0,0,0,0.05)] backdrop-blur-md px-3 py-1.5 text-xs text-gray-600 transition-all duration-300 hover:-translate-y-[1px] hover:ring-primary-300 hover:bg-white/90 hover:text-primary-600 hover:shadow-[0_4px_12px_-2px_rgba(0,0,0,0.08)] disabled:cursor-not-allowed disabled:opacity-50 dark:ring-gray-700/60 dark:bg-gray-800/60 dark:text-gray-300 dark:hover:ring-primary-500/50 dark:hover:bg-gray-800/90 dark:hover:text-primary-400",iv=ue({__name:"PresetQuestions",props:{questions:{},disabled:{type:Boolean},leadingActionLabel:{}},emits:["select","leadingAction","editQuestions"],setup(i,{emit:l}){const{t:e}=we(),n=i,s=l,u=z(!1);let o=null;function c(b){u.value=!1,s("select",b)}function g(){n.disabled||n.questions.length===0||(o&&(clearTimeout(o),o=null),u.value=!0)}function h(){o=setTimeout(()=>{u.value=!1},150)}function f(){u.value=!1,s("editQuestions")}return Xt(()=>{o&&clearTimeout(o)}),(b,y)=>{const k=_e;return i.leadingActionLabel||i.questions.length>0?(r(),m("div",Zf,[a("div",ev,[i.leadingActionLabel?(r(),m("button",{key:0,class:X(ca),disabled:n.disabled,onClick:y[0]||(y[0]=x=>s("leadingAction"))},d(i.leadingActionLabel),9,tv)):R("",!0),i.questions.length>0?(r(),m("div",{key:1,class:"relative shrink-0",onMouseenter:g,onMouseleave:h},[a("button",{class:X([ca,u.value?"ring-primary-300 bg-white/90 text-primary-600 dark:ring-primary-500/50 dark:bg-gray-800/90 dark:text-primary-400":""]),disabled:n.disabled},[a("span",sv,[p(k,{name:"i-heroicons-chat-bubble-left-ellipsis",class:"h-3.5 w-3.5"}),le(" "+d(t(e)("ai.chat.input.quickAsk")),1)])],10,av),p(vt,{"enter-active-class":"transition duration-200 ease-out","enter-from-class":"opacity-0 translate-y-2","enter-to-class":"opacity-100 translate-y-0","leave-active-class":"transition duration-150 ease-in","leave-from-class":"opacity-100 translate-y-0","leave-to-class":"opacity-0 translate-y-2"},{default:B(()=>[u.value?(r(),m("div",nv,[a("div",ov,[a("button",{class:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] text-gray-400 transition-colors hover:text-primary-500 dark:text-gray-500 dark:hover:text-primary-400",onClick:f},[p(k,{name:"i-heroicons-pencil-square",class:"h-3 w-3"}),le(" "+d(t(e)("ai.chat.input.editQuickAsk")),1)])]),a("div",lv,[(r(!0),m(ie,null,pe(i.questions,(x,_)=>(r(),m("button",{key:_,class:X(ca),disabled:n.disabled,onClick:C=>c(x)},d(x),9,rv))),128))])])):R("",!0)]),_:1})],32)):R("",!0)])])):R("",!0)}}}),uv=30;function cv(i,l){const e=z(null),n=z(!0),s=z(!1);function u(h=!1){setTimeout(()=>{e.value&&(h||n.value)&&(e.value.scrollTop=e.value.scrollHeight,n.value=!0,s.value=!1)},100)}function o(h){h.deltaY<0&&l.value&&(n.value=!1,s.value=!0)}function c(){if(!e.value)return;const{scrollTop:h,scrollHeight:f,clientHeight:b}=e.value;f-h-b<uv&&(n.value=!0,s.value=!1)}function g(){u(!0)}return he(()=>{const h=i.value[i.value.length-1];return[i.value.length,h?.content,h?.contentBlocks?.length]},()=>u()),Re(()=>{e.value&&(e.value.addEventListener("scroll",c),e.value.addEventListener("wheel",o,{passive:!0})),i.value.length>0&&u(!0)}),Xt(()=>{e.value&&(e.value.removeEventListener("scroll",c),e.value.removeEventListener("wheel",o))}),{messagesContainer:e,showScrollToBottom:s,scrollToBottom:u,handleScrollToBottom:g}}function dv(){const i=Ft(),l=It(),e=z(!1),n=z(null),s=z(!1),u=z(!1),o=z(!1),c=z(!1),g=z(null);function h(w){n.value=w,s.value=!1,e.value=!0}function f(){u.value=!0}function b(w){n.value=w,s.value=!1,e.value=!0}function y(w){n.value=w,s.value=!0,e.value=!0}function k(){n.value=null,s.value=!1,e.value=!0}async function x(w){await i.loadAssistants(),await i.loadBuiltinCatalog()}async function _(){await i.loadAssistants()}function C(){o.value=!0}function $(w){g.value=w,c.value=!0}function I(){g.value=null,c.value=!0}async function T(){await l.loadSkills()}async function v(w){await l.loadSkills(),await l.loadBuiltinCatalog()}return{configModalVisible:e,configModalAssistantId:n,configModalReadonly:s,marketModalVisible:u,handleConfigureAssistant:h,handleOpenMarket:f,handleMarketConfigure:b,handleMarketViewConfig:y,handleCreateAssistant:k,handleAssistantCreated:x,handleAssistantConfigSaved:_,skillMarketModalVisible:o,skillConfigModalVisible:c,skillConfigModalSkillId:g,handleOpenSkillMarket:C,handleSkillMarketConfigure:$,handleCreateSkill:I,handleSkillConfigSaved:T,handleSkillCreated:v}}function mv(i){const l=[];let e=null;for(const n of i)n.role==="user"?(e&&l.push({user:e,assistant:null,standalone:null,id:e.id}),e=n):n.role==="assistant"?(l.push({user:e,assistant:n,standalone:null,id:e?.id||n.id}),e=null):(e&&(l.push({user:e,assistant:null,standalone:null,id:e.id}),e=null),l.push({user:null,assistant:null,standalone:n,id:n.id}));return e&&l.push({user:e,assistant:null,standalone:null,id:e.id}),l}const gv={class:"main-content flex h-full overflow-hidden"},pv={class:"flex h-full flex-1 overflow-hidden"},hv={class:"flex h-full flex-1"},fv={class:"relative flex min-w-[480px] flex-1 flex-col overflow-hidden"},vv={key:0,class:"flex items-center gap-1.5 px-3 py-1.5"},yv=["disabled"],xv={key:0,class:"flex w-full flex-col items-center justify-center animate-fade-in"},bv={key:0,class:"mb-3 text-center text-2xl font-semibold tracking-tight text-gray-800 dark:text-gray-100"},kv={class:"text-primary-600 dark:text-primary-400"},_v={key:1,class:"relative mb-8 w-full max-w-lg"},wv={class:"flex w-full justify-center"},$v={key:1,class:"qa-pair space-y-6 pb-4"},Cv={key:1,class:"px-4 pb-2"},Sv={class:"mx-auto max-w-[740px]"},Iv={class:"px-4 pb-2"},Tv={class:"mx-auto max-w-[740px]"},Mv={key:0,class:"w-80 shrink-0 border-l border-gray-200 bg-gray-50/50 p-4 dark:border-gray-800 dark:bg-page-dark/50"},Av=ue({__name:"ChatExplorer",props:{sessionId:{},sessionName:{},timeFilter:{},chatType:{}},setup(i,{expose:l}){const{t:e}=we(),n=nt(),s=Ma(),u=Ft(),o=It(),c=i,{messages:g,sourceMessages:h,currentKeywords:f,isLoadingSource:b,isAIThinking:y,currentAIChatId:k,currentToolStatus:x,toolsUsedInCurrentRound:_,sessionTokenUsage:C,agentStatus:$,selectedAssistantId:I,sendMessage:T,editMessageAndRegenerate:v,loadAIChat:w,startNewAIChat:E,loadMoreSourceMessages:F,updateMaxMessages:D,stopGeneration:A,selectAssistantForSession:S}=Vl(c.sessionId,c.sessionName,c.timeFilter,c.chatType??"group",s.locale),q=cv(g,y),{showScrollToBottom:Y,scrollToBottom:G,handleScrollToBottom:Z}=q,{configModalVisible:ce,configModalAssistantId:ne,configModalReadonly:H,marketModalVisible:W,skillMarketModalVisible:re,skillConfigModalVisible:ve,skillConfigModalSkillId:fe,handleConfigureAssistant:ee,handleOpenMarket:te,handleMarketConfigure:j,handleMarketViewConfig:de,handleCreateAssistant:be,handleAssistantCreated:xe,handleAssistantConfigSaved:oe,handleOpenSkillMarket:Q,handleSkillMarketConfigure:J,handleCreateSkill:ge,handleSkillConfigSaved:ke,handleSkillCreated:$e}=dv(),Le=ka(),Be=z(0);he(()=>k.value,async Ce=>{if(!Ce){Be.value=0;return}try{const Ie=await Ye().estimateContextTokens(Ce);Ie.success&&(Be.value=Ie.tokens)}catch{Be.value=0}},{immediate:!0});const Te=M(()=>u.selectedAssistant?.presetQuestions??[]),Pe=M(()=>c.chatType??"group"),je=z(!1),Se=z(!1),me=z(!0),O=z(void 0),V=z(null),K=z(null),L=z(null),P=z(!1),N=z(!1),ae=z(!1),se=M(()=>{const Ce=L.value?.name||e("ai.assistant.fallbackName");return e("ai.assistant.upgrade.backupName",{name:Ce})}),Ve=M(()=>mv(g.value));async function qe(){me.value=!0;try{Se.value=await $a().hasConfig()}catch(Ce){console.error("检查 LLM 配置失败:",Ce),Se.value=!1}finally{me.value=!1}}async function Me(){await qe(),Se.value&&await D()}l({refreshConfig:Me});const Fe=M(()=>{const Ce=u.selectedAssistant;if(!Ce)return{name:"",preview:""};const Ie=Ce.systemPrompt.replace(/#{1,6}\s+[^\n]*/g,"").replace(/\n+/g," ").replace(/\s+/g," ").trim();return{name:Ce.name,preview:Ie}}),st=M(()=>!!I.value&&g.value.length===0&&!y.value);function oa(){n.warn(e("ai.chat.backgroundTask.runningTitle"),{description:e("ai.chat.backgroundTask.runningDescription")})}function Ea(){n.warn(e("ai.chat.backgroundTask.blockedAction"))}function Cs(Ce){if(Ce!==I.value){if(!S(Ce)){Ea();return}o.activateSkill(null),E()}}async function Ss(Ce){const Ie=await T(Ce);!Ie.success&&Ie.reason==="busy"&&oa()}function Is(){const Ce=u.selectedAssistant?.id;Ce&&(O.value="presetQuestions",ee(Ce))}function Ts(Ce){ce.value=Ce,Ce||(O.value=void 0)}function Ms(){K.value?.openSkillSelector()}function As(){G(!0)}async function Ba(){const Ce=await u.checkDefaultAssistantUpgrade(s.locale);Ce&&(L.value=Ce,P.value=!0)}async function zs(){const Ce=L.value;if(!(!Ce||N.value||ae.value)){ae.value=!0;try{const Ie=await u.skipAssistantUpgrade(Ce);if(!Ie.success){n.fail(e("ai.assistant.upgrade.skipFailed"),{description:Ie.error||e("ai.assistant.toast.unknownError")});return}P.value=!1,L.value=null}finally{ae.value=!1}}}async function qs(){const Ce=L.value;if(!(!Ce||N.value||ae.value)){N.value=!0;try{const Ie=se.value,kt=await u.upgradeAssistantWithBackup(Ce,Ie);if(!kt.success){n.fail(e("ai.assistant.upgrade.failed"),{description:kt.error||e("ai.assistant.toast.unknownError")});return}P.value=!1,L.value=null,n.success(e("ai.assistant.upgrade.success"),{description:e("ai.assistant.upgrade.successDescription",{name:Ie})})}finally{N.value=!1}}}async function Ls(Ce){const Ie=await T(Ce.content,{mentionedMembers:Ce.mentionedMembers});if(!Ie.success){Ie.reason==="busy"&&oa();return}G(!0),V.value?.refresh()}async function Ds(Ce){const Ie=await v(Ce.messageId,Ce.content,{overwriteSubsequent:Ce.overwriteSubsequent});if(!Ie.success){Ie.reason==="busy"&&oa();return}G(!0),V.value?.refresh()}async function Es(Ce){if(k.value)try{const Ie=await Ye().forkAIChat(k.value,Ce);await w(Ie.id),V.value?.refresh(),G(!0),n.success(e("ai.chat.fork.success"))}catch(Ie){n.fail(e("ai.chat.fork.failed"),{description:String(Ie)})}}function Bs(){je.value=!je.value}async function Fs(){await F()}async function Rs(Ce){await w(Ce),G(!0)}function Vs(){if(y.value){Ea();return}E()}function Os(Ce){k.value===Ce&&E()}function Ps(){A()}return qe(),D(),Re(()=>{Ba()}),he(()=>s.locale,()=>{Ba()}),he(()=>Le.aiConfigVersion,async()=>{await Me()}),(Ce,Ie)=>{const kt=_e,js=St;return r(),m("div",gv,[p(qc,{ref_key:"conversationListRef",ref:V,"session-id":i.sessionId,"active-id":t(k),disabled:t(y),onSelect:Rs,onCreate:Vs,onDelete:Os},null,8,["session-id","active-id","disabled"]),a("div",pv,[a("div",hv,[a("div",fv,[t(g).length>0||t(y)?(r(),m("div",vv,[a("button",{class:X(["flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",{"cursor-not-allowed opacity-50":t(y)||!t(u).selectedAssistant?.id}]),disabled:t(y)||!t(u).selectedAssistant?.id,onClick:Ie[0]||(Ie[0]=Ae=>t(ee)(t(u).selectedAssistant.id))},[p(kt,{name:"i-heroicons-sparkles",class:"h-3.5 w-3.5"}),a("span",null,d(t(u).selectedAssistant?.name||t(e)("ai.assistant.fallbackName")),1)],10,yv)])):R("",!0),a("div",{ref:t(q).messagesContainer,class:X(["relative min-h-0 flex-1 overflow-x-hidden overflow-y-auto p-4",{"p-0!":t(g).length===0&&!t(y)}])},[a("div",{class:X(["mx-auto max-w-3xl space-y-6",{"flex min-h-full flex-col justify-center px-4 pb-32 pt-4 space-y-0!":t(g).length===0&&!t(y),"px-4":t(g).length>0||t(y)}])},[t(g).length===0&&!t(y)?(r(),m("div",xv,[Fe.value.name?(r(),m("h2",bv,[le(d(t(e)("ai.assistant.selector.heroTitlePrefix","使用"))+" ",1),a("span",kv,d(Fe.value.name),1),le(" "+d(t(e)("ai.assistant.selector.heroTitleSuffix","开始对话")),1)])):R("",!0),st.value&&Fe.value.name?(r(),m("div",_v,[a("p",{class:"cursor-pointer pr-7 text-center text-sm leading-relaxed text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300 line-clamp-2",onClick:Ie[1]||(Ie[1]=Ae=>t(ee)(t(u).selectedAssistant.id))},[p(js,{text:t(e)("ai.assistant.config.systemPrompt","系统设定"),popper:{placement:"top"}},{default:B(()=>[le(d(Fe.value.preview),1)]),_:1},8,["text"])]),a("button",{type:"button",class:"absolute bottom-0 right-0 rounded-md p-0.5 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-200",onClick:Ie[2]||(Ie[2]=Oe(Ae=>t(ee)(t(u).selectedAssistant.id),["stop"]))},[p(kt,{name:"i-heroicons-pencil-square",class:"h-4 w-4"})])])):R("",!0),a("div",wv,[p($0,{"chat-type":Pe.value,locale:t(s).locale,"selected-id":t(I),onSelect:Cs,onMarket:t(te)},null,8,["chat-type","locale","selected-id","onMarket"])])])):R("",!0),(r(!0),m(ie,null,pe(Ve.value,Ae=>(r(),m(ie,{key:Ae.id},[Ae.standalone?(r(),U(ua,{key:0,role:Ae.standalone.role,content:Ae.standalone.content,timestamp:Ae.standalone.timestamp},null,8,["role","content","timestamp"])):(r(),m("div",$v,[Ae.user&&(Ae.user.role==="user"||Ae.user.content)?(r(),U(ua,{key:0,role:Ae.user.role,"message-id":Ae.user.id,content:Ae.user.content,timestamp:Ae.user.timestamp,"is-streaming":Ae.user.isStreaming,"content-blocks":Ae.user.contentBlocks,editable:!t(y),onEdit:Ds},null,8,["role","message-id","content","timestamp","is-streaming","content-blocks","editable"])):R("",!0),Ae.assistant&&(Ae.assistant.content||Ae.assistant.contentBlocks&&Ae.assistant.contentBlocks.length>0)?(r(),U(ua,{key:1,role:Ae.assistant.role,"message-id":Ae.assistant.id,content:Ae.assistant.content,timestamp:Ae.assistant.timestamp,"is-streaming":Ae.assistant.isStreaming,"content-blocks":Ae.assistant.contentBlocks,"show-capture-button":!Ae.assistant.isStreaming,onFork:Es},null,8,["role","message-id","content","timestamp","is-streaming","content-blocks","show-capture-button"])):R("",!0)]))],64))),128)),t(y)&&!t(g)[t(g).length-1]?.content&&!(t(g)[t(g).length-1]?.contentBlocks?.length??0)?(r(),U(Qp,{key:1,"current-tool-status":t(x),"tools-used":t(_),"agent-status":t($)},null,8,["current-tool-status","tools-used","agent-status"])):R("",!0)],2)],2),p(vt,{name:"fade-up"},{default:B(()=>[t(Y)?(r(),m("button",{key:0,class:"absolute bottom-20 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full bg-gray-800/90 px-3 py-1.5 text-xs text-white shadow-lg backdrop-blur-sm transition-all hover:bg-gray-700 dark:bg-gray-700/90 dark:hover:bg-gray-600",onClick:Ie[3]||(Ie[3]=(...Ae)=>t(Z)&&t(Z)(...Ae))},[p(kt,{name:"i-heroicons-arrow-down",class:"h-3.5 w-3.5"}),a("span",null,d(t(e)("ai.chat.scrollToBottom")),1)])):R("",!0)]),_:1}),t(g).length===0&&!t(y)?(r(),m("div",Cv,[a("div",Sv,[p(iv,{questions:Te.value,"leading-action-label":t(e)("ai.chat.input.useSkill"),onSelect:Ss,onLeadingAction:Ms,onEditQuestions:Is},null,8,["questions","leading-action-label"])])])):R("",!0),a("div",Iv,[a("div",Tv,[p(Bp,{ref_key:"chatInputRef",ref:K,"session-id":i.sessionId,disabled:t(y),status:t(y)?"streaming":"ready","chat-type":Pe.value,onSend:Ls,onStop:Ps,onManageSkills:t(Q),onSkillActivated:As},null,8,["session-id","disabled","status","chat-type","onManageSkills"]),p(f0,{"session-token-usage":t(C),"agent-status":t($),"current-ai-chat-id":t(k),"current-messages":t(g),"fallback-title":i.sessionName,"estimated-context-tokens":Be.value},null,8,["session-token-usage","agent-status","current-ai-chat-id","current-messages","fallback-title","estimated-context-tokens"])])])])]),p(vt,{name:"slide-fade"},{default:B(()=>[t(h).length>0&&!je.value?(r(),m("div",Mv,[p(td,{messages:t(h),keywords:t(f),"is-loading":t(b),"is-collapsed":je.value,class:"h-full",onToggle:Bs,onLoadMore:Fs},null,8,["messages","keywords","is-loading","is-collapsed"])])):R("",!0)]),_:1})]),p(ph,{open:t(ce),"assistant-id":t(ne),readonly:t(H),"scroll-to-section":O.value,"onUpdate:open":Ts,onSaved:t(oe),onCreated:t(xe)},null,8,["open","assistant-id","readonly","scroll-to-section","onSaved","onCreated"]),p(uf,{open:P.value,"backup-name":se.value,upgrading:N.value,skipping:ae.value,onSkip:zs,onConfirm:qs},null,8,["open","backup-name","upgrading","skipping"]),p(Qh,{open:t(W),"onUpdate:open":Ie[4]||(Ie[4]=Ae=>W.value=Ae),onConfigure:t(j),onViewConfig:t(de),onCreate:t(be)},null,8,["open","onConfigure","onViewConfig","onCreate"]),p(Nf,{open:t(re),"onUpdate:open":Ie[5]||(Ie[5]=Ae=>re.value=Ae),onConfigure:t(J),onCreate:t(ge)},null,8,["open","onConfigure","onCreate"]),p(Xf,{open:t(ve),"skill-id":t(fe),"onUpdate:open":Ie[6]||(Ie[6]=Ae=>ve.value=Ae),onSaved:t(ke),onCreated:t($e)},null,8,["open","skill-id","onSaved","onCreated"])])}}}),Yw=dt(Av,[["__scopeId","data-v-3b042ff8"]]),da="__ALL__",zv=ue({__name:"UserSelect",props:{sessionId:{},modelValue:{}},emits:["update:modelValue"],setup(i,{emit:l}){const{t:e}=we(),n=i,s=l,u=z([]),o=z(!1),c=M({get:()=>n.modelValue===null?da:String(n.modelValue),set:f=>{s("update:modelValue",f===da?null:parseInt(f))}}),g=M(()=>{const f=[{value:da,label:e("common.userSelect.allMembers")}];return u.value.forEach(b=>{const y=b.groupNickname||b.accountName||b.platformId;f.push({value:String(b.id),label:`${y} (${b.messageCount})`})}),f});async function h(){if(n.sessionId){o.value=!0;try{const f=await Ke().getMembers(n.sessionId);u.value=f.sort((b,y)=>y.messageCount-b.messageCount)}catch(f){console.error("加载成员列表失败:",f)}finally{o.value=!1}}}return he(()=>n.sessionId,()=>{s("update:modelValue",null),h()},{immediate:!0}),(f,b)=>{const y=Da;return r(),U(y,{modelValue:c.value,"onUpdate:modelValue":b[0]||(b[0]=k=>c.value=k),items:g.value,loading:o.value,virtualize:{estimateSize:32,overscan:10},"value-key":"value",class:"w-48"},null,8,["modelValue","items","loading"])}}}),qv=ue({__name:"EChartCalendar",props:{data:{},height:{default:180},year:{}},setup(i){ta([hs,fs,za,vs,aa]);const l=i,{t:e,locale:n}=we(),s=Zt(),u=z(null);let o=null;const c=M(()=>{if(l.year)return l.year;if(l.data.length===0)return new Date().getFullYear();const _=l.data.map(C=>parseInt(C.date.split("-")[0]));return Math.max(..._)}),g=M(()=>l.data.length===0?10:Math.max(...l.data.map(_=>_.value),1)),h=M(()=>l.data.map(_=>[_.date,_.value])),f={light:["#fee5e8","#fbb5c2","#f7758c","#ee4567"],dark:["#3d1f24","#6b2f3a","#a34557","#ee4567"]},b=M(()=>({tooltip:{trigger:"item",formatter:_=>{const C=_.data[0],$=_.data[1];return`${C}<br/>${e("views.message.calendarTooltipMessages")}: ${$}`}},visualMap:{min:0,max:g.value,calculable:!1,orient:"horizontal",left:"center",bottom:0,itemWidth:10,itemHeight:100,text:[`${g.value}`,"0"],inRange:{color:s.value?f.dark:f.light},textStyle:{color:s.value?"#9ca3af":"#6b7280",fontSize:10},show:!0},calendar:{top:30,left:40,cellSize:[13,13],range:String(c.value),itemStyle:{borderWidth:2,borderColor:s.value?"#1f2937":"#ffffff"},yearLabel:{show:!0,position:"top",color:s.value?"#9ca3af":"#6b7280",fontSize:12},monthLabel:{show:!0,color:s.value?"#9ca3af":"#6b7280",fontSize:10,nameMap:[e("common.month.jan"),e("common.month.feb"),e("common.month.mar"),e("common.month.apr"),e("common.month.may"),e("common.month.jun"),e("common.month.jul"),e("common.month.aug"),e("common.month.sep"),e("common.month.oct"),e("common.month.nov"),e("common.month.dec")]},dayLabel:{show:!0,firstDay:1,color:s.value?"#6b7280":"#9ca3af",fontSize:10,nameMap:[e("common.weekday.sun"),e("common.weekday.mon"),e("common.weekday.tue"),e("common.weekday.wed"),e("common.weekday.thu"),e("common.weekday.fri"),e("common.weekday.sat")]},splitLine:{show:!1}},series:[{type:"heatmap",coordinateSystem:"calendar",data:h.value}]}));function y(){u.value&&(o=sa(u.value,s.value?"dark":void 0,{renderer:"canvas"}),o.setOption({backgroundColor:"transparent",...b.value}))}function k(){o&&o.setOption({backgroundColor:"transparent",...b.value},{notMerge:!0})}function x(){o?.resize()}return he([()=>l.data,s,n],()=>{k()}),he(()=>l.year,()=>{k()}),Re(()=>{y(),window.addEventListener("resize",x)}),tt(()=>{window.removeEventListener("resize",x),o?.dispose()}),(_,C)=>(r(),m("div",{ref_key:"chartRef",ref:u,style:et({height:`${i.height}px`,width:"100%"})},null,4))}}),Lv={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Dv={class:"flex items-center gap-6 sm:gap-10"},Ev={class:"min-w-0 flex-1"},Bv={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},Fv={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},Rv={class:"mb-4 flex min-w-0 flex-wrap items-baseline gap-2"},Vv={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Ov={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Pv={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},jv={key:1,class:"flex min-w-0 max-w-full flex-wrap items-center gap-x-1.5 gap-y-1.5"},Nv={class:"text-base font-medium text-gray-600 dark:text-gray-300"},Uv={class:"font-bold tabular-nums text-pink-500 dark:text-pink-400"},Wv={class:"flex shrink-0 flex-col items-center"},Hv={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},Kv={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},Yv={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},Gv={class:"min-w-0 flex-1"},Qv={class:"flex items-center justify-between gap-1"},Jv={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},Xv={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},Zv={class:"relative z-10 flex items-center justify-between px-6 pb-4 opacity-40 mix-blend-luminosity dark:opacity-30 sm:px-8 sm:pb-5"},ey={class:"flex items-center gap-1.5"},ty={class:"text-[9px] font-medium uppercase tracking-widest"},ay=ue({__name:"TypeProfileCard",props:{sessionId:{},messageTypes:{},textStats:{},timeFilter:{}},setup(i){ta([Xn,za,aa]);const{t:l}=we(),e=Zt(),n=i,s=M(()=>n.messageTypes.reduce((S,q)=>S+q.count,0)),u=M(()=>n.messageTypes.find(S=>S.type===gt.TEXT)?.count??0),o=M(()=>{if(s.value===0)return 0;const S=s.value-u.value;return Math.round(S/s.value*100)}),c=M(()=>n.textStats.textCount===0?0:Math.round(n.textStats.shortCount/n.textStats.textCount*100)),g=z({first:"",last:""});async function h(){if(n.sessionId)try{const S=await Ke().getDailyActivity(n.sessionId,n.timeFilter);if(S.length>0){const q=[...S].sort((Y,G)=>Y.date.localeCompare(G.date));g.value={first:Ee(q[0].date).format("YYYY/MM/DD"),last:Ee(q[q.length-1].date).format("YYYY/MM/DD")}}}catch{}}function f(S){return n.messageTypes.find(q=>q.type===S)?.count??0}const b=M(()=>[{label:l("views.message.typeCard.nonTextImage"),count:f(gt.IMAGE),unit:l("views.message.typeCard.unitImage")},{label:l("views.message.typeCard.nonTextEmoji"),count:f(gt.EMOJI),unit:l("views.message.typeCard.unitEmoji")},{label:l("views.message.typeCard.nonTextVoice"),count:f(gt.VOICE),unit:l("views.message.typeCard.unitVoice")},{label:l("views.message.typeCard.nonTextVideo"),count:f(gt.VIDEO),unit:l("views.message.typeCard.unitVideo")},{label:l("views.message.typeCard.nonTextFile"),count:f(gt.FILE),unit:l("views.message.typeCard.unitFile")},{label:l("views.message.typeCard.nonTextLink"),count:f(gt.LINK),unit:l("views.message.typeCard.unitLink")}].filter(S=>S.count>0)),y=z(30),k=z(0),x=z(!1),_=[{label:"20",value:20},{label:"30",value:30},{label:"50",value:50},{label:"80",value:80},{label:"100",value:100}],C=M({get:()=>y.value,set:S=>{y.value!==S&&(y.value=S,$())}});async function $(){if(n.sessionId){x.value=!0;try{k.value=await Ke().getLongMessageCount(n.sessionId,n.timeFilter,y.value)}catch(S){console.error("[chart-message] Failed to load essay count:",S)}finally{x.value=!1}}}he(()=>[n.sessionId,n.timeFilter],()=>{$(),h()},{immediate:!0,deep:!0});const I=M(()=>[{icon:"i-heroicons-pencil-square",label:l("views.message.profile.textExpression"),value:l("views.message.profile.avgLengthUnit",{count:n.textStats.avgLength||0}),subtext:n.textStats.maxLength>0?l("views.message.profile.textExpressionDesc",{count:n.textStats.maxLength}):"",colorClass:"text-violet-600 dark:text-violet-400"},{icon:"i-heroicons-chat-bubble-bottom-center-text",label:l("views.message.profile.shortMaster"),value:`${c.value}%`,subtext:l("views.message.profile.shortMasterDesc",{count:n.textStats.shortCount}),colorClass:"text-emerald-600 dark:text-emerald-400"},{icon:"i-heroicons-document-text",label:l("views.message.profile.essayLover"),value:k.value.toLocaleString(),subtext:l("views.message.profile.essayLoverDesc",{threshold:y.value}),colorClass:"text-indigo-600 dark:text-indigo-400",slot:"essay-threshold"},{icon:"i-heroicons-photo",label:l("views.message.profile.mediaRichness"),value:`${o.value}%`,subtext:b.value.slice(0,3).map(S=>`${S.label} ${S.count}`).join(" · ")||"-",colorClass:"text-pink-600 dark:text-pink-400"}]),T=z(null);let v=null;const w=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],E=M(()=>[...n.messageTypes].sort((q,Y)=>Y.count-q.count).slice(0,8).map((q,Y)=>({name:ma(q.type,l),value:q.count,itemStyle:{color:w[Y%w.length]}})));function F(){T.value&&(v=sa(T.value,void 0,{renderer:"canvas"}),D())}function D(){v&&v.setOption({backgroundColor:"transparent",tooltip:{trigger:"item",formatter:"{b}: {c} ({d}%)"},series:[{type:"pie",radius:["50%","78%"],center:["50%","50%"],avoidLabelOverlap:!1,padAngle:2,itemStyle:{borderRadius:4},label:{show:!1},emphasis:{label:{show:!1},scaleSize:4},data:E.value}]},{notMerge:!0})}function A(){v?.resize()}return he(()=>n.messageTypes,()=>D()),he(e,()=>{v?.dispose(),F()}),Re(()=>{F(),window.addEventListener("resize",A)}),tt(()=>{window.removeEventListener("resize",A),v?.dispose()}),(S,q)=>{const Y=_e,G=wa;return r(),U(t(na),null,{default:B(()=>[a("div",Lv,[a("div",Dv,[a("div",Ev,[a("div",Bv,[g.value.first?(r(),m("p",Fv,d(g.value.first)+" – "+d(g.value.last),1)):R("",!0),a("div",Rv,[a("span",Vv,d(t(l)("views.message.profile.heroLine1Prefix")),1),a("span",Ov,d(s.value.toLocaleString()),1),a("span",Pv,d(t(l)("views.message.profile.heroLine1Suffix")),1)]),b.value.length>0?(r(),m("div",jv,[a("span",Nv,d(t(l)("views.message.typeCard.nonTextPrefix")),1),(r(!0),m(ie,null,pe(b.value,Z=>(r(),m("span",{key:Z.label,class:"inline-flex items-center gap-1 rounded-full bg-gray-100 px-2.5 py-0.5 text-xs font-semibold text-gray-700 dark:bg-white/10 dark:text-gray-200"},[a("span",Uv,d(Z.count.toLocaleString()),1),a("span",null,d(Z.unit),1)]))),128))])):R("",!0)])]),a("div",Wv,[a("div",Hv,d(t(l)("views.message.profile.typeDistribution")),1),a("div",{ref_key:"donutRef",ref:T,style:{width:"130px",height:"130px"}},null,512)])])]),a("div",Kv,[q[1]||(q[1]=a("div",{class:"mb-3 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Type Profile ")],-1)),a("div",Yv,[(r(!0),m(ie,null,pe(I.value,Z=>(r(),m("div",{key:Z.icon+Z.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[p(Y,{name:Z.icon,class:X(["mt-0.5 h-3.5 w-3.5 shrink-0",Z.colorClass])},null,8,["name","class"]),a("div",Gv,[a("div",Qv,[a("div",{class:X(["truncate font-mono text-sm font-black leading-tight tabular-nums",Z.colorClass])},d(Z.value),3),Z.slot==="essay-threshold"?(r(),U(G,{key:0,modelValue:C.value,"onUpdate:modelValue":q[0]||(q[0]=ce=>C.value=ce),items:_,"value-key":"value",size:"xs",class:"relative z-120 w-16 shrink-0",ui:{content:"z-[121]"},disabled:x.value},null,8,["modelValue","disabled"])):R("",!0)]),a("div",Jv,d(Z.label),1),a("div",Xv,d(Z.subtext),1)])]))),128))])]),a("div",Zv,[a("div",ey,[p(Y,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),q[2]||(q[2]=a("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),a("span",ty,d(t(l)("views.message.typeCard.watermark")),1)])]),_:1})}}}),sy={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-4 sm:p-6"},ny={class:"p-5"},oy={key:0,class:"grid grid-cols-1 gap-6 lg:grid-cols-2 lg:items-center"},ly={class:"space-y-3"},ry={class:"min-w-20 shrink-0 text-sm text-gray-700 dark:text-gray-300"},iy={class:"flex-1"},uy={class:"h-2 overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800"},cy={class:"shrink-0 text-right"},dy={class:"text-sm font-medium text-gray-900 dark:text-white"},my={class:"ml-1 text-xs text-gray-400"},gy={key:1,class:"flex h-48 items-center justify-center text-gray-400"},py={class:"p-5"},hy={class:"mb-5 grid grid-cols-2 gap-3 sm:grid-cols-4"},fy={class:"p-3"},vy={class:"font-mono text-xl font-bold text-gray-900 dark:text-white"},yy={class:"mt-1 text-xs text-gray-500"},xy={class:"p-3"},by={class:"font-mono text-xl font-bold text-indigo-600 dark:text-indigo-400"},ky={class:"mt-1 text-xs text-gray-500"},_y={class:"p-3"},wy={class:"font-mono text-xl font-bold text-pink-600 dark:text-pink-400"},$y={class:"mt-1 text-xs text-gray-500"},Cy={class:"p-3"},Sy={class:"font-mono text-xl font-bold text-emerald-600 dark:text-emerald-400"},Iy={class:"mt-1 text-xs text-gray-500"},Ty={class:"mb-5 rounded-lg border border-gray-200 p-4 dark:border-gray-700"},My={class:"mb-2 text-xs font-medium text-gray-500 dark:text-gray-400"},Ay={class:"flex items-center gap-4 text-sm"},zy={class:"flex items-center gap-1.5"},qy={class:"font-mono font-medium text-gray-900 dark:text-white"},Ly={class:"flex items-center gap-1.5"},Dy={class:"font-mono font-medium text-gray-900 dark:text-white"},Ey={class:"flex items-center gap-1.5"},By={class:"font-mono font-medium text-gray-900 dark:text-white"},Fy={class:"flex items-center gap-1.5"},Ry={class:"font-mono font-medium text-gray-900 dark:text-white"},Vy={class:"mt-3 grid grid-cols-3 gap-3 text-xs"},Oy={class:"text-gray-500"},Py={class:"ml-1 font-medium text-emerald-600 dark:text-emerald-400"},jy={class:"text-gray-400"},Ny={class:"text-gray-500"},Uy={class:"ml-1 font-medium text-indigo-600 dark:text-indigo-400"},Wy={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},Hy={class:"text-xs text-gray-400"},Ky={class:"p-5"},Yy={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Gy={class:"text-xs text-gray-400"},Qy={class:"p-5"},Jy={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Gw=ue({__name:"TypeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(i){const l=i,{t:e}=we(),n=z(!0),s=z([]),u=z([]),o=z([]),c=z({textCount:0,avgLength:0,maxLength:0,shortCount:0}),g=z({p25:0,p50:0,p75:0,p90:0}),h=z(0),f=M(()=>{const I=[...s.value].sort((T,v)=>v.count-T.count);return{labels:I.map(T=>ma(T.type,e)),values:I.map(T=>T.count)}}),b=M(()=>{const I=s.value.reduce((v,w)=>v+w.count,0);return[...s.value].sort((v,w)=>w.count-v.count).map(v=>({name:ma(v.type,e),count:v.count,percentage:I>0?Math.round(v.count/I*100):0}))}),y=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"];function k(I){return y[I%y.length]}const x=M(()=>({labels:u.value.map(I=>String(I.len)),values:u.value.map(I=>I.count)})),_=M(()=>({labels:o.value.map(I=>I.range),values:o.value.map(I=>I.count)})),C=M(()=>c.value.textCount===0?0:Math.round(c.value.shortCount/c.value.textCount*100));async function $(){if(l.sessionId){n.value=!0;try{const I=Ke(),[T,v,w,E,F]=await Promise.all([I.getMessageTypeDistribution(l.sessionId,l.timeFilter),I.getMessageLengthDistribution(l.sessionId,l.timeFilter),I.getTextStats(l.sessionId,l.timeFilter),I.getTextLengthPercentiles(l.sessionId,l.timeFilter),I.getLongMessageCount(l.sessionId,l.timeFilter,30)]);s.value=T,u.value=v.detail,o.value=v.grouped,c.value=w,g.value=E,h.value=F}catch(I){console.error("[chart-message] Failed to load type analysis data:",I)}finally{n.value=!1}}}return he(()=>[l.sessionId,l.timeFilter],()=>$(),{immediate:!0,deep:!0}),(I,T)=>(r(),m("div",{class:X(n.value?"h-full":"")},[n.value?(r(),U(t(Kt),{key:0,variant:"page",text:t(e)("common.loading")},null,8,["text"])):(r(),m("div",sy,[s.value.length>0?(r(),U(ay,{key:0,"session-id":i.sessionId,"message-types":s.value,"text-stats":c.value,"time-filter":i.timeFilter},null,8,["session-id","message-types","text-stats","time-filter"])):R("",!0),p(t(Ze),{title:t(e)("views.message.typeDistribution"),"show-divider":!1},{default:B(()=>[a("div",ny,[f.value.values.length>0?(r(),m("div",oy,[a("div",null,[p(t(ya),{data:f.value,height:280,"show-legend":!1},null,8,["data"])]),a("div",null,[a("div",ly,[(r(!0),m(ie,null,pe(b.value,(v,w)=>(r(),m("div",{key:w,class:"flex items-center gap-3"},[a("div",{class:"h-3 w-3 shrink-0 rounded-full",style:et({backgroundColor:k(w)})},null,4),a("div",ry,d(v.name),1),a("div",iy,[a("div",uy,[a("div",{class:"h-full rounded-full transition-all",style:et({width:`${v.percentage}%`,backgroundColor:k(w)})},null,4)])]),a("div",cy,[a("span",dy,d(v.count.toLocaleString()),1),a("span",my,"("+d(v.percentage)+"%)",1)])]))),128))])])])):(r(),m("div",gy,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"]),p(t(Ze),{title:t(e)("views.message.typeAnalysis.textDepthTitle"),"show-divider":!1},{default:B(()=>[a("div",py,[a("div",hy,[a("div",fy,[a("div",vy,d(c.value.textCount.toLocaleString()),1),a("div",yy,d(t(e)("views.message.typeAnalysis.textTotal")),1)]),a("div",xy,[a("div",by,d(c.value.avgLength||0),1),a("div",ky,d(t(e)("views.message.typeAnalysis.avgLength")),1)]),a("div",_y,[a("div",wy,d(g.value.p50),1),a("div",$y,d(t(e)("views.message.typeAnalysis.medianLength")),1)]),a("div",Cy,[a("div",Sy,d(c.value.maxLength),1),a("div",Iy,d(t(e)("views.message.typeAnalysis.maxLength")),1)])]),a("div",Ty,[a("div",My,d(t(e)("views.message.typeAnalysis.percentiles")),1),a("div",Ay,[a("div",zy,[T[0]||(T[0]=a("span",{class:"text-gray-500"},"P25",-1)),a("span",qy,d(g.value.p25),1)]),a("div",Ly,[T[1]||(T[1]=a("span",{class:"text-gray-500"},"P50",-1)),a("span",Dy,d(g.value.p50),1)]),a("div",Ey,[T[2]||(T[2]=a("span",{class:"text-gray-500"},"P75",-1)),a("span",By,d(g.value.p75),1)]),a("div",Fy,[T[3]||(T[3]=a("span",{class:"text-gray-500"},"P90",-1)),a("span",Ry,d(g.value.p90),1)])]),a("div",Vy,[a("div",null,[a("span",Oy,d(t(e)("views.message.typeAnalysis.shortMessages")),1),a("span",Py,d(C.value)+"%",1),a("span",jy,"("+d(c.value.shortCount)+")",1)]),a("div",null,[a("span",Ny,d(t(e)("views.message.typeAnalysis.essayMessages")),1),a("span",Uy,d(h.value),1)])])])])]),_:1},8,["title"]),a("div",Wy,[p(t(Ze),{title:t(e)("views.message.lengthDetailTitle"),"show-divider":!1},{headerRight:B(()=>[a("span",Hy,d(t(e)("views.message.lengthDetailHint")),1)]),default:B(()=>[a("div",Ky,[x.value.values.some(v=>v>0)?(r(),U(t(rt),{key:0,data:x.value,height:200},null,8,["data"])):(r(),m("div",Yy,d(t(e)("views.message.noTextMessages")),1))])]),_:1},8,["title"]),p(t(Ze),{title:t(e)("views.message.lengthGroupedTitle"),"show-divider":!1},{headerRight:B(()=>[a("span",Gy,d(t(e)("views.message.lengthGroupedHint")),1)]),default:B(()=>[a("div",Qy,[_.value.values.some(v=>v>0)?(r(),U(t(rt),{key:0,data:_.value,height:200},null,8,["data"])):(r(),m("div",Jy,d(t(e)("views.message.noTextMessages")),1))])]),_:1},8,["title"])])]))],2))}}),Xy={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},Zy={class:"flex items-start gap-6 sm:gap-10"},ex={class:"min-w-0 flex-1"},tx={class:"flex flex-col text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},ax={key:0,class:"mb-2 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},sx={class:"mb-3 flex items-baseline gap-2"},nx={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},ox={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},lx={class:"font-bold text-3xl text-indigo-500 dark:text-indigo-400"},rx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},ix={class:"flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},ux={class:"text-base font-medium text-gray-600 dark:text-gray-300"},cx={class:"font-bold text-xl text-pink-500 dark:text-pink-400"},dx={class:"text-base font-medium text-gray-600 dark:text-gray-300"},mx={class:"text-base font-medium text-amber-600 dark:text-amber-400"},gx={class:"flex shrink-0 flex-col items-center"},px={class:"mb-1 text-[10px] font-bold text-gray-500 dark:text-gray-400"},hx={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},fx={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},vx={class:"min-w-0 flex-1"},yx={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},xx={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},bx={class:"relative z-10 flex items-center justify-between px-6 pb-4 opacity-40 mix-blend-luminosity dark:opacity-30 sm:px-8 sm:pb-5"},kx={class:"flex items-center gap-1.5"},_x={class:"text-[9px] font-medium uppercase tracking-widest"},wx=ue({__name:"TimeProfileCard",props:{hourlyActivity:{},weekdayActivity:{},dailyActivity:{}},setup(i){ta([Zn,eo,aa]);const{t:l}=we(),e=Zt(),n=i,s=M(()=>n.dailyActivity.filter(v=>v.messageCount>0).length),u=M(()=>n.dailyActivity.reduce((v,w)=>v+w.messageCount,0)),o=M(()=>{if(n.dailyActivity.length===0)return{first:"",last:"",days:0};const v=[...n.dailyActivity].sort((F,D)=>F.date.localeCompare(D.date)),w=Ee(v[0].date),E=Ee(v[v.length-1].date);return{first:w.format("YYYY/MM/DD"),last:E.format("YYYY/MM/DD"),days:E.diff(w,"day")+1}}),c=M(()=>s.value===0?0:Math.round(u.value/s.value)),g=M(()=>n.dailyActivity.length===0?null:n.dailyActivity.reduce((v,w)=>w.messageCount>v.messageCount?w:v,n.dailyActivity[0])),h=M(()=>n.hourlyActivity.length===0?[]:[...n.hourlyActivity].sort((v,w)=>w.messageCount-v.messageCount).slice(0,3)),f=M(()=>{if(n.hourlyActivity.length===0&&n.weekdayActivity.length===0)return null;const v=o.value.days>0?s.value/o.value.days:0,w=n.weekdayActivity.filter(H=>H.weekday===6||H.weekday===7),E=n.weekdayActivity.filter(H=>H.weekday>=1&&H.weekday<=5),F=w.reduce((H,W)=>H+W.messageCount,0),D=E.reduce((H,W)=>H+W.messageCount,0),A=F+D,S=A>0?F/A:0,q=n.hourlyActivity.reduce((H,W)=>H+W.messageCount,0),Y=n.hourlyActivity.filter(H=>H.hour>=22||H.hour<5).reduce((H,W)=>H+W.messageCount,0),G=n.hourlyActivity.filter(H=>H.hour>=18&&H.hour<22).reduce((H,W)=>H+W.messageCount,0),Z=q>0?Y/q:0,ce=q>0?G/q:0;if(v>=.9)return{label:l("views.message.timeCard.personalityEveryday"),icon:"i-heroicons-fire"};if(S>=.55)return{label:l("views.message.timeCard.personalityWeekend"),icon:"i-heroicons-calendar"};if(S<=.2&&A>0)return{label:l("views.message.timeCard.personalityWeekday"),icon:"i-heroicons-briefcase"};if(Z>=.3)return{label:l("views.message.timeCard.personalityNightOwl"),icon:"i-heroicons-moon"};if(ce>=.4)return{label:l("views.message.timeCard.personalityEveningChat"),icon:"i-heroicons-sparkles"};const ne=[...n.hourlyActivity].sort((H,W)=>W.messageCount-H.messageCount)[0];return ne?ne.hour>=5&&ne.hour<9?{label:l("views.message.timeCard.personalityEarlyBird"),icon:"i-heroicons-sun"}:ne.hour>=12&&ne.hour<14?{label:l("views.message.timeCard.personalityLunchChat"),icon:"i-heroicons-clock"}:{label:l("views.message.timeCard.personalityDaytime"),icon:"i-heroicons-sun"}:null}),b=M(()=>{const v=n.weekdayActivity.filter(A=>A.weekday===6||A.weekday===7),w=n.weekdayActivity.filter(A=>A.weekday>=1&&A.weekday<=5),E=v.reduce((A,S)=>A+S.messageCount,0),F=w.reduce((A,S)=>A+S.messageCount,0),D=E+F;return D===0?0:Math.round(E/D*100)}),y=M(()=>[l("common.weekday.mon"),l("common.weekday.tue"),l("common.weekday.wed"),l("common.weekday.thu"),l("common.weekday.fri"),l("common.weekday.sat"),l("common.weekday.sun")]),k=M(()=>{if(n.weekdayActivity.length===0)return null;const v=[...n.weekdayActivity].sort((w,E)=>E.messageCount-w.messageCount)[0];return{name:y.value[v.weekday-1],count:v.messageCount}}),x=M(()=>[{icon:"i-heroicons-fire",label:l("views.message.timeCard.peakRecord"),value:g.value?Ee(g.value.date).format("MM/DD"):"-",subtext:g.value?l("views.message.timeCard.peakRecordDesc",{count:g.value.messageCount}):"",colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-clock",label:l("views.message.timeCard.topHoursLabel"),value:h.value.length>0?`${h.value[0].hour}:00`:"-",subtext:h.value.length>=2?h.value.map(v=>`${v.hour}:00`).join(" > "):"",colorClass:"text-cyan-600 dark:text-cyan-400"},{icon:"i-heroicons-calendar-days",label:l("views.message.timeCard.peakWeekdayLabel"),value:k.value?.name||"-",subtext:k.value?`${k.value.count.toLocaleString()}`:"",colorClass:"text-violet-600 dark:text-violet-400"},{icon:"i-heroicons-building-office",label:l("views.message.timeCard.weekendRatio"),value:`${b.value}%`,subtext:l("views.message.timeCard.weekendRatioDesc"),colorClass:"text-amber-600 dark:text-amber-400"}]),_=z(null);let C=null;function $(){_.value&&(C=sa(_.value,void 0,{renderer:"canvas"}),I())}function I(){if(!C)return;const v=new Map(n.hourlyActivity.map(D=>[D.hour,D.messageCount])),w=[];for(let D=0;D<24;D++)w.push(v.get(D)||0);const E=Math.max(...w,1),F=w.map(D=>{const A=D/E;return A>.8?e.value?"#f472b6":"#ec4899":A>.5?e.value?"#a78bfa":"#8b5cf6":e.value?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.08)"});C.setOption({backgroundColor:"transparent",tooltip:{trigger:"axis",formatter:D=>`${D[0].axisValue}:00 — ${D[0].value}`},grid:{left:0,right:0,top:4,bottom:16},xAxis:{type:"category",data:Array.from({length:24},(D,A)=>`${A}`),axisLine:{show:!1},axisTick:{show:!1},axisLabel:{fontSize:9,color:e.value?"#6b7280":"#9ca3af",interval:D=>D%6===0}},yAxis:{type:"value",show:!1},series:[{type:"bar",data:w.map((D,A)=>({value:D,itemStyle:{color:F[A]}})),barWidth:"60%",itemStyle:{borderRadius:[2,2,0,0]}}]},{notMerge:!0})}function T(){C?.resize()}return he(()=>n.hourlyActivity,()=>I()),he(e,()=>{C?.dispose(),$()}),Re(()=>{$(),window.addEventListener("resize",T)}),tt(()=>{window.removeEventListener("resize",T),C?.dispose()}),(v,w)=>{const E=_e;return r(),U(t(na),null,{default:B(()=>[a("div",Xy,[a("div",Zy,[a("div",ex,[a("div",tx,[o.value.first?(r(),m("p",ax,d(o.value.first)+" – "+d(o.value.last),1)):R("",!0),a("div",sx,[a("span",nx,d(o.value.days),1),a("span",ox,d(t(l)("views.message.timeCard.heroDaysIn")),1),a("span",lx,d(s.value),1),a("span",rx,d(t(l)("views.message.timeCard.heroDaysActive")),1)]),a("div",ix,[a("span",ux,d(t(l)("views.message.timeCard.heroAvgPrefix")),1),a("span",cx,d(c.value),1),a("span",dx,d(t(l)("views.message.timeCard.heroAvgSuffix")),1),f.value?(r(),m(ie,{key:0},[p(E,{name:f.value.icon,class:"ml-2 h-4 w-4 text-amber-500"},null,8,["name"]),a("span",mx,d(f.value.label),1)],64)):R("",!0)])])]),a("div",gx,[a("div",px,d(t(l)("views.message.timeCard.hourlyDistribution")),1),a("div",{ref_key:"barRef",ref:_,style:{width:"180px",height:"110px"}},null,512)])])]),a("div",hx,[w[0]||(w[0]=a("div",{class:"mb-3 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Time Profile ")],-1)),a("div",fx,[(r(!0),m(ie,null,pe(x.value,F=>(r(),m("div",{key:F.icon+F.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[p(E,{name:F.icon,class:X(["mt-0.5 h-3.5 w-3.5 shrink-0",F.colorClass])},null,8,["name","class"]),a("div",vx,[a("div",{class:X(["truncate font-mono text-sm font-black leading-tight tabular-nums",F.colorClass])},d(F.value),3),a("div",yx,d(F.label),1),a("div",xx,d(F.subtext),1)])]))),128))])]),a("div",bx,[a("div",kx,[p(E,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),w[1]||(w[1]=a("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),a("span",_x,d(t(l)("views.message.timeCard.watermark")),1)])]),_:1})}}}),$x={key:1,class:"main-content mx-auto max-w-[920px] space-y-6 p-4 sm:p-6"},Cx={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},Sx={class:"p-5"},Ix={class:"p-5"},Tx={class:"grid grid-cols-1 gap-6 lg:grid-cols-2"},Mx={class:"p-5"},Ax={class:"p-5"},zx={key:1,class:"flex h-48 items-center justify-center text-gray-400"},qx={class:"text-xs text-gray-400"},Lx={class:"p-5"},Dx={key:1,class:"flex h-48 items-center justify-center text-gray-400"},Ex={class:"text-xs text-gray-400"},Bx={class:"p-5"},Fx={class:"flex items-center gap-2"},Rx={class:"text-xs text-gray-400"},Vx={class:"p-5"},Ox={key:1,class:"flex h-32 items-center justify-center text-gray-400"},Qw=ue({__name:"TimeAnalysisView",props:{sessionId:{},sessionName:{},timeFilter:{}},setup(i){const l=i,{t:e}=we(),n=z(!0),s=z([]),u=z([]),o=z([]),c=z([]),g=z([]),h=z([]),f=z([]),b=["#6366f1","#ec4899","#f97316","#22c55e","#06b6d4","#8b5cf6","#f43f5e","#eab308","#14b8a6","#3b82f6"],y=M(()=>[e("common.weekday.mon"),e("common.weekday.tue"),e("common.weekday.wed"),e("common.weekday.thu"),e("common.weekday.fri"),e("common.weekday.sat"),e("common.weekday.sun")]),k=M(()=>[e("common.month.jan"),e("common.month.feb"),e("common.month.mar"),e("common.month.apr"),e("common.month.may"),e("common.month.jun"),e("common.month.jul"),e("common.month.aug"),e("common.month.sep"),e("common.month.oct"),e("common.month.nov"),e("common.month.dec")]),x=M(()=>{const A=new Map(u.value.map(Y=>[Y.hour,Y.messageCount])),S=[],q=[];for(let Y=0;Y<24;Y++)S.push(`${Y}`),q.push(A.get(Y)||0);return{labels:S,values:q}}),_=M(()=>{const A=new Map(o.value.map(q=>[q.weekday,q.messageCount])),S=[];for(let q=1;q<=7;q++)S.push(A.get(q)||0);return{labels:y.value,values:S}}),C=M(()=>{const A=new Map(c.value.map(q=>[q.month,q.messageCount])),S=[];for(let q=1;q<=12;q++)S.push(A.get(q)||0);return{labels:k.value,values:S}}),$=M(()=>{const A=[...g.value].sort((S,q)=>S.year-q.year);return{labels:A.map(S=>String(S.year)),values:A.map(S=>S.messageCount)}}),I=M(()=>{const A=Array.from({length:24},(G,Z)=>`${Z}:00`),S=y.value,q=s.value.reduce((G,Z)=>G+Z.count,0)||1,Y=[];for(let G=1;G<=7;G++)for(let Z=0;Z<24;Z++){const ce=o.value.find(W=>W.weekday===G)?.messageCount||0,ne=u.value.find(W=>W.hour===Z)?.messageCount||0,H=Math.round(ce*ne/q);Y.push([Z,G-1,H])}return{xLabels:A,yLabels:S,data:Y}}),T=M(()=>h.value.map(A=>({date:A.date,value:A.messageCount}))),v=M(()=>{const A=new Set;return h.value.forEach(S=>{const q=parseInt(S.date.split("-")[0]);isNaN(q)||A.add(q)}),Array.from(A).sort((S,q)=>q-S)}),w=z(new Date().getFullYear()),E=M(()=>{const A=w.value;return T.value.filter(S=>S.date.startsWith(`${A}-`))}),F=M(()=>{if(f.value.length===0)return{};const A=[...new Set(f.value.map(Z=>Z.month))].sort(),S=new Map;if(f.value.forEach(Z=>{const ce=S.get(Z.memberId);ce?ce.total+=Z.count:S.set(Z.memberId,{name:Z.memberName,total:Z.count})}),S.size<=2){const Z=new Map;return f.value.forEach(ce=>{Z.set(ce.month,(Z.get(ce.month)||0)+ce.count)}),{tooltip:{trigger:"axis",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},grid:{left:50,right:20,top:10,bottom:30},xAxis:{type:"category",data:A,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{type:"dashed",opacity:.3}}},series:[{type:"line",smooth:!0,symbol:"none",areaStyle:{opacity:.2},itemStyle:{color:"#6366f1"},data:A.map(ce=>Z.get(ce)||0)}]}}const G=[...S.entries()].sort((Z,ce)=>ce[1].total-Z[1].total).slice(0,10).map(([Z,ce],ne)=>{const H=new Map(f.value.filter(W=>W.memberId===Z).map(W=>[W.month,W.count]));return{name:ce.name,type:"line",stack:"total",areaStyle:{opacity:.3},smooth:!0,symbol:"none",itemStyle:{color:b[ne%b.length]},data:A.map(W=>H.get(W)||0)}});return{tooltip:{trigger:"axis",backgroundColor:"rgba(0, 0, 0, 0.8)",borderColor:"transparent",textStyle:{color:"#fff"}},legend:{bottom:0,textStyle:{fontSize:11}},grid:{left:50,right:20,top:10,bottom:40},xAxis:{type:"category",data:A,boundaryGap:!1,axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",splitLine:{lineStyle:{type:"dashed",opacity:.3}}},series:G}});async function D(){if(l.sessionId){n.value=!0;try{const A=Ke(),[S,q,Y,G,Z,ce,ne]=await Promise.all([A.getMessageTypeDistribution(l.sessionId,l.timeFilter),A.getHourlyActivity(l.sessionId,l.timeFilter),A.getWeekdayActivity(l.sessionId,l.timeFilter),A.getMonthlyActivity(l.sessionId,l.timeFilter),A.getYearlyActivity(l.sessionId,l.timeFilter),A.getDailyActivity(l.sessionId,l.timeFilter),A.getMemberMonthlyTrend(l.sessionId,l.timeFilter)]);s.value=S,u.value=q,o.value=Y,c.value=G,g.value=Z,h.value=ce,f.value=ne,v.value.length>0&&(w.value=v.value[0])}catch(A){console.error("[chart-message] Failed to load time analysis data:",A)}finally{n.value=!1}}}return he(()=>[l.sessionId,l.timeFilter],()=>D(),{immediate:!0,deep:!0}),(A,S)=>{const q=wa;return r(),m("div",{class:X(n.value?"h-full":"")},[n.value?(r(),U(t(Kt),{key:0,variant:"page",text:t(e)("common.loading")},null,8,["text"])):(r(),m("div",$x,[h.value.length>0?(r(),U(wx,{key:0,"hourly-activity":u.value,"weekday-activity":o.value,"daily-activity":h.value},null,8,["hourly-activity","weekday-activity","daily-activity"])):R("",!0),a("div",Cx,[p(t(Ze),{title:t(e)("views.message.hourlyDistribution"),"show-divider":!1},{default:B(()=>[a("div",Sx,[p(t(rt),{data:x.value,height:200},null,8,["data"])])]),_:1},8,["title"]),p(t(Ze),{title:t(e)("views.message.weekdayDistribution"),"show-divider":!1},{default:B(()=>[a("div",Ix,[p(t(rt),{data:_.value,height:200},null,8,["data"])])]),_:1},8,["title"])]),a("div",Tx,[p(t(Ze),{title:t(e)("views.message.monthlyDistribution"),"show-divider":!1},{default:B(()=>[a("div",Mx,[p(t(rt),{data:C.value,height:200},null,8,["data"])])]),_:1},8,["title"]),p(t(Ze),{title:t(e)("views.message.yearlyDistribution"),"show-divider":!1},{default:B(()=>[a("div",Ax,[$.value.values.length>0?(r(),U(t(rt),{key:0,data:$.value,height:200},null,8,["data"])):(r(),m("div",zx,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"])]),p(t(Ze),{title:t(e)("views.message.timeAnalysis.memberTrendTitle"),"show-divider":!1},{headerRight:B(()=>[a("span",qx,d(t(e)("views.message.timeAnalysis.memberTrendHint")),1)]),default:B(()=>[a("div",Lx,[f.value.length>0?(r(),U(t(ea),{key:0,option:F.value,height:280},null,8,["option"])):(r(),m("div",Dx,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"]),p(t(Ze),{title:t(e)("views.message.timeHeatmap"),"show-divider":!1},{headerRight:B(()=>[a("span",Ex,d(t(e)("views.message.heatmapHint")),1)]),default:B(()=>[a("div",Bx,[p(t(fa),{data:I.value,height:320},null,8,["data"])])]),_:1},8,["title"]),p(t(Ze),{title:t(e)("views.message.calendarHeatmap"),"show-divider":!1},{headerRight:B(()=>[a("div",Fx,[a("span",Rx,d(t(e)("views.message.calendarHint")),1),v.value.length>1?(r(),U(q,{key:0,modelValue:w.value,"onUpdate:modelValue":S[0]||(S[0]=Y=>w.value=Y),items:v.value.map(Y=>({value:Y,label:String(Y)})),size:"xs",class:"w-20"},null,8,["modelValue","items"])):R("",!0)])]),default:B(()=>[a("div",Vx,[E.value.length>0?(r(),U(t(qv),{key:0,data:E.value,year:w.value,height:180},null,8,["data","year"])):(r(),m("div",Ox,d(t(e)("views.message.noData")),1))])]),_:1},8,["title"])]))],2)}}}),Px={class:"relative z-10 px-6 pt-8 pb-4 sm:px-8"},jx={class:"flex items-center gap-6 sm:gap-10"},Nx={class:"min-w-0 flex-1"},Ux={class:"flex flex-col gap-2 text-[15px] leading-relaxed text-gray-600 dark:text-gray-300"},Wx={key:0,class:"mb-0 text-sm font-medium tracking-wide text-gray-500 dark:text-gray-400"},Hx={class:"flex items-baseline gap-x-1.5"},Kx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Yx={class:"font-black text-5xl tracking-tight text-gray-900 dark:text-white"},Gx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Qx={class:"flex items-baseline gap-x-1.5"},Jx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},Xx={class:"font-black text-3xl text-pink-500 dark:text-pink-400"},Zx={class:"text-xl font-medium text-gray-700 dark:text-gray-300"},eb={key:1,class:"mt-1 flex items-baseline flex-wrap gap-x-1.5 gap-y-1"},tb={class:"text-base font-medium text-gray-600 dark:text-gray-300"},ab=["onClick"],sb={key:0,class:"text-gray-400"},nb={key:0,class:"hidden shrink-0 overflow-hidden rounded-lg sm:block"},ob={class:"relative",style:{width:"360px",height:"220px"}},lb={class:"relative z-10 px-6 pb-6 pt-4 sm:px-8"},rb={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},ib={class:"min-w-0 flex-1"},ub={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},cb={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},db={class:"relative z-10 flex items-center justify-between px-6 pb-4 opacity-40 mix-blend-luminosity dark:opacity-30 sm:px-8 sm:pb-5"},mb={class:"flex items-center gap-1.5"},gb={class:"text-[9px] font-medium uppercase tracking-widest"},pb=ue({__name:"TopicProfileCard",props:{totalMessages:{},totalWords:{},uniqueWords:{},topWords:{},topicWords:{},posTagStats:{},timeFilter:{}},emits:["wordClick"],setup(i,{emit:l}){const e=gs(()=>Jt(()=>import("./EChartWordcloud-CqknPGui.js"),__vite__mapDeps([3,4,5,6,0,1,2]))),{t:n}=we(),s=i,u=l,o=M(()=>{const{startTs:x,endTs:_}=s.timeFilter??{};return x&&_?`${Ee(x*1e3).format("YYYY/MM/DD")} – ${Ee(_*1e3).format("YYYY/MM/DD")}`:""}),c=M(()=>(s.topicWords?.length?s.topicWords:s.topWords).slice(0,5)),g=M(()=>({words:(s.topicWords?.length?s.topicWords:s.topWords).slice(0,50).map(_=>({word:_.word,count:_.count,percentage:_.percentage}))})),h=M(()=>s.totalWords===0?0:Math.round(s.uniqueWords/s.totalWords*100)),f=M(()=>{if(!s.posTagStats?.length)return{key:"Balanced",label:n("quotes.topicProfile.styleBalanced"),desc:n("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"};const x=new Map(s.posTagStats.map(E=>[E.tag,E.count])),_=(x.get("n")||0)+(x.get("ns")||0)+(x.get("nt")||0)+(x.get("nz")||0),C=(x.get("v")||0)+(x.get("vn")||0)+(x.get("vd")||0),$=(x.get("a")||0)+(x.get("ad")||0)+(x.get("an")||0),I=_+C+$;if(I===0)return{key:"Balanced",label:n("quotes.topicProfile.styleBalanced"),desc:n("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"};const T=_/I,v=C/I,w=$/I;return T>.5?{key:"Encyclopedia",label:n("quotes.topicProfile.styleEncyclopedia"),desc:n("quotes.topicProfile.styleEncyclopediaDesc"),icon:"i-heroicons-book-open-solid",colorClass:"text-indigo-600 dark:text-indigo-400"}:v>.45?{key:"Action",label:n("quotes.topicProfile.styleAction"),desc:n("quotes.topicProfile.styleActionDesc"),icon:"i-heroicons-rocket-launch-solid",colorClass:"text-orange-600 dark:text-orange-400"}:w>.3?{key:"Expressive",label:n("quotes.topicProfile.styleExpressive"),desc:n("quotes.topicProfile.styleExpressiveDesc"),icon:"i-heroicons-paint-brush-solid",colorClass:"text-pink-600 dark:text-pink-400"}:{key:"Balanced",label:n("quotes.topicProfile.styleBalanced"),desc:n("quotes.topicProfile.styleBalancedDesc"),icon:"i-heroicons-scale-solid",colorClass:"text-cyan-600 dark:text-cyan-400"}}),b=M(()=>{if(s.topWords.length===0)return{label:n("quotes.topicProfile.expressionMixed"),desc:n("quotes.topicProfile.expressionMixedDesc"),icon:"i-heroicons-chat-bubble-left-right-solid",colorClass:"text-emerald-600 dark:text-emerald-400"};const x=s.topWords.reduce(($,I)=>$+I.word.length*I.count,0),_=s.topWords.reduce(($,I)=>$+I.count,0),C=x/_;return C<2.5?{label:n("quotes.topicProfile.expressionCasual"),desc:n("quotes.topicProfile.expressionCasualDesc"),icon:"i-heroicons-face-smile-solid",colorClass:"text-amber-600 dark:text-amber-400"}:C>3.5?{label:n("quotes.topicProfile.expressionFormal"),desc:n("quotes.topicProfile.expressionFormalDesc"),icon:"i-heroicons-academic-cap-solid",colorClass:"text-violet-600 dark:text-violet-400"}:{label:n("quotes.topicProfile.expressionMixed"),desc:n("quotes.topicProfile.expressionMixedDesc"),icon:"i-heroicons-chat-bubble-left-right-solid",colorClass:"text-emerald-600 dark:text-emerald-400"}}),y=M(()=>[{icon:"i-heroicons-fire-solid",label:n("quotes.topicProfile.hotTopic"),value:c.value[0]?.word??"-",subtext:c.value[0]?n("quotes.topicProfile.hotTopicDesc",{count:c.value[0].count}):"",colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-sparkles-solid",label:n("quotes.topicProfile.richness"),value:n("quotes.topicProfile.richnessValue",{value:h.value}),subtext:n("quotes.topicProfile.richnessDesc",{unique:s.uniqueWords.toLocaleString(),total:s.totalWords.toLocaleString()}),colorClass:"text-blue-600 dark:text-blue-400"},{icon:f.value.icon,label:n("quotes.topicProfile.chatStyle"),value:f.value.label,subtext:f.value.desc,colorClass:f.value.colorClass},{icon:b.value.icon,label:n("quotes.topicProfile.expressionStyle"),value:b.value.label,subtext:b.value.desc,colorClass:b.value.colorClass}]),k=["#6366f1","#ec4899","#f97316","#22c55e","#3b82f6","#8b5cf6","#14b8a6","#f43f5e"];return(x,_)=>{const C=_e;return r(),U(t(na),null,{default:B(()=>[a("div",Px,[a("div",jx,[a("div",Nx,[a("div",Ux,[o.value?(r(),m("p",Wx,d(o.value),1)):R("",!0),a("div",Hx,[a("span",Kx,d(t(n)("quotes.topicProfile.heroPrefix")),1),a("span",Yx,d(i.totalMessages.toLocaleString()),1),a("span",Gx,d(t(n)("quotes.topicProfile.heroMiddle")),1)]),a("div",Qx,[a("span",Jx,d(t(n)("quotes.topicProfile.heroMiddleSecond")),1),a("span",Xx,d(i.uniqueWords.toLocaleString()),1),a("span",Zx,d(t(n)("quotes.topicProfile.heroSuffix")),1)]),c.value.length>0?(r(),m("div",eb,[a("span",tb,d(t(n)("quotes.topicProfile.topTopicsPrefix")),1),(r(!0),m(ie,null,pe(c.value,($,I)=>(r(),m(ie,{key:$.word},[a("span",{class:"cursor-pointer font-bold text-xl transition-opacity hover:opacity-70",style:et({color:k[I%k.length]}),onClick:T=>u("wordClick",$.word)},d($.word),13,ab),I<c.value.length-1?(r(),m("span",sb,"·")):R("",!0)],64))),128))])):R("",!0)])]),g.value.words.length>0?(r(),m("div",nb,[a("div",ob,[p(t(e),{data:g.value,height:"100%","max-words":50,"size-scale":.8,"draw-out-of-bound":!0,shape:"rectangle","color-scheme":"default",onWordClick:_[0]||(_[0]=$=>u("wordClick",$))},null,8,["data"])])])):R("",!0)])]),a("div",lb,[_[1]||(_[1]=a("div",{class:"mb-3 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Topic Profile ")],-1)),a("div",rb,[(r(!0),m(ie,null,pe(y.value,$=>(r(),m("div",{key:$.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[p(C,{name:$.icon,class:X(["mt-0.5 h-3.5 w-3.5 shrink-0",$.colorClass])},null,8,["name","class"]),a("div",ib,[a("div",{class:X(["truncate font-mono text-sm font-black leading-tight tabular-nums",$.colorClass])},d($.value),3),a("div",ub,d($.label),1),a("div",cb,d($.subtext),1)])]))),128))])]),a("div",db,[a("div",mb,[p(C,{name:"i-heroicons-chat-bubble-left-right-solid",class:"h-3.5 w-3.5"}),_[2]||(_[2]=a("span",{class:"text-[10px] font-bold uppercase tracking-wider"},"ChatLab",-1))]),a("span",gb,d(t(n)("quotes.topicProfile.watermark")),1)])]),_:1})}}}),hb={class:"px-5 py-4 sm:px-6"},fb={class:"mb-4 flex items-center gap-2"},vb={class:"text-[15px] font-black tracking-tight text-gray-900 dark:text-white"},yb={class:"flex flex-wrap justify-center gap-2"},xb=["onClick"],bb=ue({__name:"SharedTopicsCard",props:{sessionId:{},timeFilter:{},dictType:{},excludeWords:{}},emits:["wordClick"],setup(i,{emit:l}){const{t:e}=we(),n=Ma(),s=i,u=l,o=M(()=>n.locale),c=z([]),g=z([]),h=M(()=>c.value.slice(0,20)),f=["bg-indigo-50 text-indigo-600 ring-1 ring-indigo-500/20 dark:bg-indigo-500/10 dark:text-indigo-400 dark:ring-indigo-500/30","bg-pink-50 text-pink-600 ring-1 ring-pink-500/20 dark:bg-pink-500/10 dark:text-pink-400 dark:ring-pink-500/30","bg-orange-50 text-orange-600 ring-1 ring-orange-500/20 dark:bg-orange-500/10 dark:text-orange-400 dark:ring-orange-500/30","bg-green-50 text-green-600 ring-1 ring-green-500/20 dark:bg-green-500/10 dark:text-green-400 dark:ring-green-500/30","bg-blue-50 text-blue-600 ring-1 ring-blue-500/20 dark:bg-blue-500/10 dark:text-blue-400 dark:ring-blue-500/30","bg-violet-50 text-violet-600 ring-1 ring-violet-500/20 dark:bg-violet-500/10 dark:text-violet-400 dark:ring-violet-500/30","bg-teal-50 text-teal-600 ring-1 ring-teal-500/20 dark:bg-teal-500/10 dark:text-teal-400 dark:ring-teal-500/30","bg-rose-50 text-rose-600 ring-1 ring-rose-500/20 dark:bg-rose-500/10 dark:text-rose-400 dark:ring-rose-500/30","bg-yellow-50 text-yellow-600 ring-1 ring-yellow-500/20 dark:bg-yellow-500/10 dark:text-yellow-400 dark:ring-yellow-500/30","bg-cyan-50 text-cyan-600 ring-1 ring-cyan-500/20 dark:bg-cyan-500/10 dark:text-cyan-400 dark:ring-cyan-500/30"];async function b(){if(s.sessionId)try{g.value.length===0&&(g.value=await Ke().getMembers(s.sessionId));const y=[...g.value].sort((T,v)=>v.messageCount-T.messageCount).slice(0,2);if(y.length<2){c.value=[];return}const k={locale:o.value,timeFilter:s.timeFilter?{startTs:s.timeFilter.startTs,endTs:s.timeFilter.endTs}:void 0,topN:100,minCount:2,posFilterMode:"meaningful",enableStopwords:!0,dictType:s.dictType??"default",excludeWords:s.excludeWords?.length?[...s.excludeWords]:void 0},x=Ke(),[_,C]=await Promise.all([x.getWordFrequency(s.sessionId,{...k,memberId:y[0].id}),x.getWordFrequency(s.sessionId,{...k,memberId:y[1].id})]),$=new Map(C.words.map(T=>[T.word,T.count])),I=[];for(const T of _.words){const v=$.get(T.word);v&&I.push({word:T.word,countA:T.count,countB:v})}I.sort((T,v)=>v.countA+v.countB-(T.countA+T.countB)),c.value=I.slice(0,30)}catch(y){console.error("加载共同话题数据失败:",y),c.value=[]}}return he(()=>s.sessionId,()=>{g.value=[]}),he(()=>[s.sessionId,s.timeFilter,s.dictType,s.excludeWords],()=>{b()},{immediate:!0,deep:!0}),(y,k)=>{const x=_e;return h.value.length>0?(r(),U(t(mt),{key:0},{default:B(()=>[a("div",hb,[a("div",fb,[p(x,{name:"i-heroicons-link",class:"h-4 w-4 text-emerald-500"}),a("span",vb,d(t(e)("quotes.topicProfile.sharedTopics")),1)]),a("div",yb,[(r(!0),m(ie,null,pe(h.value,(_,C)=>(r(),m("span",{key:_.word,class:X(["cursor-pointer rounded-full px-3 py-1 text-xs font-bold transition-opacity hover:opacity-80",f[C%f.length]]),onClick:$=>u("wordClick",_.word)},d(_.word),11,xb))),128))])])]),_:1})):R("",!0)}}}),ws=qn("wordFilter",()=>{const i=z([]),l=z(null),e=z({}),n=z(!1);function s(){return`wf_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function u($,I=[]){const T={id:s(),name:$,words:[...I],createdAt:Date.now()};return i.value.push(T),T}function o($,I){const T=i.value.find(v=>v.id===$);T&&(I.name!==void 0&&(T.name=I.name),I.words!==void 0&&(T.words=[...I.words]))}function c($){i.value=i.value.filter(I=>I.id!==$),l.value===$&&(l.value=null);for(const[I,T]of Object.entries(e.value))T===$&&delete e.value[I]}function g($){l.value=$}function h($,I){e.value[$]=I}function f($){delete e.value[$]}function b($){return $ in e.value?e.value[$]:l.value}function y($){const I=b($);return I?i.value.find(v=>v.id===I)?.words??[]:[]}function k($){return i.value.find(I=>I.id===$)}const x=M(()=>i.value.map($=>({label:$.name,value:$.id,isDefault:$.id===l.value,wordCount:$.words.length})));function _(){n.value=!0}function C(){n.value=!1}return{schemes:i,defaultSchemeId:l,sessionSchemeOverrides:e,showWordFilterModal:n,schemeOptions:x,createScheme:u,updateScheme:o,deleteScheme:c,setDefaultScheme:g,setSessionScheme:h,clearSessionScheme:f,getActiveSchemeId:b,getExcludeWords:y,getSchemeById:k,openModal:_,closeModal:C}},{persist:!1,backendPersist:{pick:["schemes","defaultSchemeId","sessionSchemeOverrides"],key:"wordFilter"}}),kb={class:"flex flex-col",style:{height:"520px"}},_b={class:"flex items-center justify-between border-b border-gray-200 px-6 py-4 dark:border-white/5"},wb={class:"flex items-center gap-3"},$b={class:"flex h-9 w-9 items-center justify-center rounded-xl bg-linear-to-br from-pink-400 to-pink-600"},Cb={class:"text-lg font-semibold text-gray-900 dark:text-white"},Sb={class:"flex flex-1 overflow-hidden"},Ib={class:"flex w-[200px] shrink-0 flex-col border-r border-gray-200 dark:border-white/5"},Tb={class:"flex items-center justify-between px-3 py-2"},Mb={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},Ab={class:"flex-1 overflow-y-auto px-2 pb-2"},zb=["onClick"],qb={class:"truncate text-sm"},Lb={class:"ml-auto text-xs text-gray-400 dark:text-gray-500"},Db={key:0,class:"px-3 py-8 text-center text-xs text-gray-400 dark:text-gray-500"},Eb={class:"flex flex-1 flex-col overflow-hidden"},Bb={class:"flex-1 space-y-4 overflow-y-auto p-5"},Fb={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},Rb={class:"flex items-center gap-2"},Vb={class:"mb-1.5 block text-xs font-medium text-gray-600 dark:text-gray-400"},Ob={class:"flex gap-2"},Pb={class:"mb-1.5 flex items-center justify-between"},jb={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},Nb={class:"ml-1 text-gray-400 dark:text-gray-500"},Ub={key:0,class:"flex max-h-[220px] flex-wrap gap-1.5 overflow-y-auto rounded-lg border border-gray-200 p-3 dark:border-white/5"},Wb={key:1,class:"rounded-lg border border-dashed border-gray-300 px-4 py-6 text-center text-xs text-gray-400 dark:border-gray-600 dark:text-gray-500"},Hb={class:"flex shrink-0 justify-end border-t border-gray-200 px-5 py-3 dark:border-white/5"},Kb={key:1,class:"flex flex-1 flex-col items-center justify-center gap-3 text-gray-400 dark:text-gray-500"},Yb={class:"text-sm"},Gb=ue({__name:"WordFilterModal",setup(i){const{t:l}=we(),e=ws(),n=M({get:()=>e.showWordFilterModal,set:I=>I?e.openModal():e.closeModal()}),s=z(null),u=z(""),o=z(""),c=z(null),g=M(()=>s.value?e.getSchemeById(s.value)??null:null),h=M(()=>s.value===e.defaultSchemeId);he(n,I=>{I&&(e.schemes.length>0&&!s.value&&(s.value=e.schemes[0].id),f())}),he(s,()=>{f(),o.value=""});function f(){u.value=g.value?.name??""}function b(){const I=e.createScheme(l("wordFilter.defaultSchemeName"));s.value=I.id,De(()=>{c.value?.focus(),c.value?.select()})}function y(){if(!s.value)return;const I=e.schemes.findIndex(T=>T.id===s.value);if(e.deleteScheme(s.value),e.schemes.length>0){const T=Math.min(I,e.schemes.length-1);s.value=e.schemes[T].id}else s.value=null}function k(){!s.value||!u.value.trim()||e.updateScheme(s.value,{name:u.value.trim()})}function x(){s.value&&(h.value?e.setDefaultScheme(null):e.setDefaultScheme(s.value))}function _(){if(!s.value||!o.value.trim())return;const T=o.value.trim().split(/[,,\n\r\t;;|、\s]+/).map(F=>F.trim()).filter(F=>F.length>0);if(T.length===0)return;const v=g.value;if(!v)return;const w=new Set(v.words.map(F=>F.toLowerCase())),E=T.filter(F=>!w.has(F.toLowerCase()));E.length>0&&e.updateScheme(s.value,{words:[...v.words,...E]}),o.value=""}function C(I){if(!s.value)return;const T=g.value;T&&e.updateScheme(s.value,{words:T.words.filter(v=>v!==I)})}function $(){s.value&&e.updateScheme(s.value,{words:[]})}return(I,T)=>{const v=_e,w=Ue,E=Bt,F=ps,D=Xe;return r(),U(D,{open:n.value,"onUpdate:open":T[4]||(T[4]=A=>n.value=A),ui:{content:"max-w-3xl z-50"}},{content:B(()=>[a("div",kb,[a("div",_b,[a("div",wb,[a("div",$b,[p(v,{name:"i-heroicons-funnel",class:"h-4.5 w-4.5 text-white"})]),a("h2",Cb,d(t(l)("wordFilter.title")),1)]),p(w,{icon:"i-heroicons-x-mark",variant:"ghost",color:"neutral",size:"sm",onClick:T[0]||(T[0]=A=>n.value=!1)})]),a("div",Sb,[a("div",Ib,[a("div",Tb,[a("span",Mb,d(t(l)("wordFilter.schemeList")),1),p(w,{icon:"i-heroicons-plus",size:"xs",variant:"ghost",color:"primary",onClick:b})]),a("div",Ab,[(r(!0),m(ie,null,pe(t(e).schemes,A=>(r(),m("div",{key:A.id,class:X(["group mb-1 flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 transition-colors",s.value===A.id?"bg-primary-50 text-primary-700 dark:bg-primary-900/20 dark:text-primary-300":"text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-white/5"]),onClick:S=>s.value=A.id},[A.id===t(e).defaultSchemeId?(r(),U(v,{key:0,name:"i-heroicons-star-solid",class:"h-3.5 w-3.5 shrink-0 text-amber-500"})):R("",!0),a("span",qb,d(A.name),1),a("span",Lb,d(A.words.length),1)],10,zb))),128)),t(e).schemes.length===0?(r(),m("div",Db,d(t(l)("wordFilter.emptyScheme")),1)):R("",!0)])]),a("div",Eb,[g.value?(r(),m(ie,{key:0},[a("div",Bb,[a("div",null,[a("label",Fb,d(t(l)("wordFilter.schemeName")),1),p(E,{ref_key:"nameInputRef",ref:c,modelValue:u.value,"onUpdate:modelValue":T[1]||(T[1]=A=>u.value=A),size:"sm",placeholder:t(l)("wordFilter.schemeNamePlaceholder"),onBlur:k,onKeydown:Ge(k,["enter"])},null,8,["modelValue","placeholder"])]),a("div",Rb,[p(w,{size:"xs",variant:h.value?"solid":"soft",color:h.value?"warning":"neutral",icon:h.value?"i-heroicons-star-solid":"i-heroicons-star",onClick:x},{default:B(()=>[le(d(h.value?t(l)("wordFilter.isDefault"):t(l)("wordFilter.setDefault")),1)]),_:1},8,["variant","color","icon"]),p(w,{size:"xs",variant:"soft",color:"error",icon:"i-heroicons-trash",onClick:y},{default:B(()=>[le(d(t(l)("wordFilter.deleteScheme")),1)]),_:1})]),a("div",null,[a("label",Vb,d(t(l)("wordFilter.addWords")),1),a("div",Ob,[p(E,{modelValue:o.value,"onUpdate:modelValue":T[2]||(T[2]=A=>o.value=A),size:"sm",class:"flex-1",placeholder:t(l)("wordFilter.addWordsPlaceholder"),onKeydown:Ge(_,["enter"])},null,8,["modelValue","placeholder"]),p(w,{size:"sm",color:"primary",icon:"i-heroicons-plus",onClick:_},{default:B(()=>[le(d(t(l)("wordFilter.add")),1)]),_:1})])]),a("div",null,[a("div",Pb,[a("label",jb,[le(d(t(l)("wordFilter.wordList"))+" ",1),a("span",Nb,"("+d(g.value.words.length)+")",1)]),g.value.words.length>0?(r(),U(w,{key:0,size:"xs",variant:"ghost",color:"error",onClick:$},{default:B(()=>[le(d(t(l)("wordFilter.clearAll")),1)]),_:1})):R("",!0)]),g.value.words.length>0?(r(),m("div",Ub,[(r(!0),m(ie,null,pe(g.value.words,A=>(r(),U(F,{key:A,color:"neutral",variant:"subtle",class:"group/badge cursor-default gap-1 pr-1"},{default:B(()=>[le(d(A)+" ",1),p(v,{name:"i-heroicons-x-mark",class:"h-3.5 w-3.5 cursor-pointer text-gray-400 transition-colors hover:text-red-500",onClick:S=>C(A)},null,8,["onClick"])]),_:2},1024))),128))])):(r(),m("div",Wb,d(t(l)("wordFilter.emptyWords")),1))])]),a("div",Hb,[p(w,{color:"primary",variant:"soft",onClick:T[3]||(T[3]=A=>n.value=!1)},{default:B(()=>[le(d(t(l)("wordFilter.close")),1)]),_:1})])],64)):(r(),m("div",Kb,[p(v,{name:"i-heroicons-funnel",class:"h-10 w-10"}),a("p",Yb,d(t(l)("wordFilter.selectOrCreate")),1),p(w,{size:"sm",color:"primary",variant:"soft",icon:"i-heroicons-plus",onClick:b},{default:B(()=>[le(d(t(l)("wordFilter.createScheme")),1)]),_:1})]))])])])]),_:1},8,["open"])}}}),Qb={class:"main-content mx-auto max-w-[920px] space-y-6 p-4 sm:p-6"},Jb={key:0,class:"flex flex-col gap-3 rounded-lg border border-primary-200 bg-primary-50/70 p-4 dark:border-primary-800 dark:bg-primary-950/30 sm:flex-row sm:items-center sm:justify-between"},Xb={class:"flex min-w-0 items-start gap-3"},Zb={class:"min-w-0 text-sm text-primary-700 dark:text-primary-300"},e1={class:"flex shrink-0 flex-wrap gap-2"},t1={key:1,class:"space-y-6"},a1={class:"flex flex-col gap-6 p-4 sm:p-6 lg:flex-row"},s1={class:"flex min-w-0 flex-1 flex-col"},n1={class:"relative w-full",style:{"aspect-ratio":"16 / 9"}},o1={key:1,class:"absolute inset-0 flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-gray-200 bg-gray-50/40 text-gray-500 dark:border-gray-700 dark:bg-gray-800/30 dark:text-gray-400"},l1={class:"text-xs font-medium"},r1={class:"px-4 text-center text-[11px]"},i1={key:0,class:"mt-2 text-center text-xs text-gray-500 dark:text-gray-400"},u1={class:"w-full shrink-0 space-y-4 lg:w-[280px]"},c1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},d1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},m1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},g1={key:0},p1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},h1={class:"space-y-2"},f1={class:"text-xs text-gray-400 dark:text-gray-500"},v1={key:1},y1={class:"mb-2 text-xs font-medium text-gray-600 dark:text-gray-400"},x1={class:"flex items-center"},b1={key:2,class:"space-y-2"},k1={class:"flex items-center justify-between"},_1={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},w1={class:"flex gap-1"},$1={class:"flex max-h-[360px] flex-wrap gap-1.5 overflow-y-auto"},C1={key:0,class:"ml-1 opacity-60"},S1={class:"mb-2 flex items-center justify-between"},I1={class:"text-xs font-medium text-gray-600 dark:text-gray-400"},T1={key:0,class:"mt-1 text-xs text-gray-400 dark:text-gray-500"},M1={class:"space-y-4"},A1={class:"text-sm text-gray-600 dark:text-gray-300"},z1={class:"flex justify-end gap-2"},q1="default",Ga="chatlab_zhTW_dict_prompt_dismissed",Jw=ue({__name:"WordcloudTab",props:{sessionId:{},timeFilter:{},memberId:{},showSharedTopics:{type:Boolean},enableNodeNlpFeatures:{type:Boolean,default:!0},enableRecordNavigation:{type:Boolean,default:!0}},setup(i){const l=gs(()=>Jt(()=>import("./EChartWordcloud-CqknPGui.js"),__vite__mapDeps([3,4,5,6,0,1,2]))),{t:e}=we(),n=Ma(),s=bt(),u=ws(),o=nt(),c=i,g=z(!1),h=z([]),f=z({totalMessages:0,totalWords:0,uniqueWords:0}),b=z(1.25),y=z(150),k=M(()=>{const me=h.value.slice(0,y.value),O=me.reduce((V,K)=>V+K.count,0);return{words:me.map(V=>({word:V.word,count:V.count,percentage:O>0?Math.round(V.count/O*1e4)/100:0}))}}),x=z(c.enableNodeNlpFeatures?"meaningful":"all"),_=z(!0),C=z([]),$=z([]),I=z(new Map),T=["n","nr","ns","nt","nz","nw","vn","a","an"],v=z([]),w=M(()=>k.value.words.map(me=>({word:me.word,count:me.count,percentage:me.percentage??0}))),E=M(()=>[...I.value.entries()].map(([me,O])=>({tag:me,count:O}))),F=z(null),D=M({get:()=>u.getActiveSchemeId(c.sessionId),set:me=>u.setSessionScheme(c.sessionId,me)}),A=M(()=>[{label:e("wordFilter.noFilter"),value:"__none__"},...u.schemeOptions.map(me=>({label:me.isDefault?`${me.label} ★`:me.label,value:me.value}))]),S=M({get:()=>D.value??"__none__",set:me=>{D.value=me==="__none__"?null:me}}),q=M(()=>u.getExcludeWords(c.sessionId)),Y=z("default"),G=z([]),Z=z(!1),ce=z(null),ne=z(!1),H=z(!c.enableNodeNlpFeatures),W=M(()=>n.locale),re=M(()=>n.locale==="zh-TW"),ve=M(()=>W.value.startsWith("zh")),fe=M(()=>G.value.filter(me=>me.downloaded).map(me=>({label:e(`quotes.wordcloud.dict.${me.id==="zh-CN"?"zhCN":me.id==="zh-TW"?"zhTW":me.id}`),value:me.id}))),ee=M(()=>G.value.some(me=>me.downloaded)),te=M(()=>!c.enableNodeNlpFeatures||!ve.value||H.value),j=M(()=>G.value.filter(me=>!me.downloaded));async function de(){if(c.enableNodeNlpFeatures)try{G.value=await Oa("/nlp/dicts"),re.value&&Y.value==="default"&&G.value.find(V=>V.id==="zh-TW")?.downloaded&&(Y.value="zh-TW"),G.value.find(O=>O.id==="zh-CN")?.downloaded&&Y.value==="default"&&(Y.value="zh-CN")}catch(me){console.error("Failed to get dict list:",me)}finally{H.value=!0}}async function be(me){Z.value=!0,ce.value=me;try{const O=await Ln(`/nlp/dicts/${me}/download`);O.success?(await de(),Y.value=me,o.success(e("quotes.wordcloud.dict.downloadSuccess"))):o.fail(e("quotes.wordcloud.dict.downloadFailed"),{description:O.error})}catch{o.fail(e("quotes.wordcloud.dict.downloadFailed"))}finally{Z.value=!1,ce.value=null,ne.value=!1}}function xe(){ne.value=!1,localStorage.setItem(Ga,"true")}function oe(){const me=G.value.find(O=>O.id==="zh-TW");re.value&&me&&!me.downloaded&&!localStorage.getItem(Ga)&&(ne.value=!0)}const Q=M(()=>[{label:e("quotes.wordcloud.posFilter.all"),value:"all"},{label:e("quotes.wordcloud.posFilter.meaningful"),value:"meaningful"},{label:e("quotes.wordcloud.posFilter.custom"),value:"custom"}]),J=[{label:"80",value:80},{label:"100",value:100},{label:"150",value:150},{label:"200",value:200},{label:"300",value:300}],ge=Math.max(...J.map(me=>me.value)),ke=M(()=>[{label:e("quotes.wordcloud.size.small"),value:.75},{label:e("quotes.wordcloud.size.medium"),value:1},{label:e("quotes.wordcloud.size.large"),value:1.25},{label:e("quotes.wordcloud.size.xlarge"),value:1.5}]),$e=M(()=>$.value.map(me=>({label:me.name,tag:me.tag,value:me.tag,count:I.value.get(me.tag)||0,meaningful:me.meaningful})));async function Le(){if(c.enableNodeNlpFeatures)try{const me=await Oa("/nlp/pos-tags");$.value=me,C.value=me.filter(O=>O.meaningful).map(O=>O.tag)}catch(me){console.error("加载词性标签失败:",me)}}let Be=0;async function Te(){if(!c.sessionId||!te.value)return;const me=++Be;try{const O=await Ke().getWordFrequency(c.sessionId,{locale:W.value,timeFilter:c.timeFilter?{startTs:c.timeFilter.startTs,endTs:c.timeFilter.endTs}:void 0,memberId:F.value??void 0,topN:50,minCount:2,posFilterMode:c.enableNodeNlpFeatures?"custom":"all",customPosTags:c.enableNodeNlpFeatures?[...T]:void 0,enableStopwords:!0,dictType:Y.value,excludeWords:q.value.length>0?[...q.value]:void 0});if(me!==Be)return;v.value=O.words.map(V=>({word:V.word,count:V.count,percentage:V.percentage}))}catch(O){if(console.error("加载话题迷你词云数据失败:",O),me!==Be)return;v.value=[]}}let Pe=0;async function je(){if(!c.sessionId||!te.value)return;const me=++Pe;h.value.length===0&&(g.value=!0);try{const O=await Ke().getWordFrequency(c.sessionId,{locale:W.value,timeFilter:c.timeFilter?{startTs:c.timeFilter.startTs,endTs:c.timeFilter.endTs}:void 0,memberId:F.value??void 0,topN:ge,minCount:2,posFilterMode:c.enableNodeNlpFeatures?x.value:"all",customPosTags:c.enableNodeNlpFeatures&&x.value==="custom"?[...C.value]:void 0,enableStopwords:_.value,dictType:Y.value,excludeWords:q.value.length>0?[...q.value]:void 0});if(me!==Pe)return;if(h.value=O.words.map(V=>({word:V.word,count:V.count,percentage:V.percentage})),f.value={totalMessages:O.totalMessages,totalWords:O.totalWords,uniqueWords:O.uniqueWords},O.posTagStats){const V=new Map;for(const K of O.posTagStats)V.set(K.tag,K.count);I.value=V}}catch(O){if(console.error("加载词频数据失败:",O),me!==Pe)return;h.value=[]}finally{me===Pe&&(g.value=!1)}}he(()=>c.sessionId,()=>{F.value=null,h.value=[],v.value=[],f.value={totalMessages:0,totalWords:0,uniqueWords:0},I.value=new Map}),he(()=>[c.sessionId,c.timeFilter,F.value,x.value,_.value,Y.value,q.value,te.value],()=>{je()},{immediate:!0,deep:!0}),he(()=>[c.sessionId,c.timeFilter,F.value,Y.value,q.value,te.value],()=>{Te()},{immediate:!0,deep:!0}),he(C,()=>{x.value==="custom"&&je()},{deep:!0}),he(W,()=>{je()});function Se(me){c.enableRecordNavigation&&s.openChatRecordDrawer({keywords:[me]})}return Re(async()=>{c.enableNodeNlpFeatures&&(Le(),await de(),oe())}),(me,O)=>{const V=_e,K=Ue,L=_a,P=ps,N=Xe;return r(),m("div",Qb,[c.enableNodeNlpFeatures&&ve.value&&!ee.value?(r(),m("div",Jb,[a("div",Xb,[p(V,{name:"i-heroicons-information-circle",class:"mt-0.5 shrink-0 text-xl text-primary-500"}),a("p",Zb,d(t(e)("quotes.wordcloud.dict.needDownload")),1)]),a("div",e1,[(r(!0),m(ie,null,pe(G.value,ae=>(r(),U(K,{key:ae.id,size:"sm",color:"primary",loading:Z.value&&ce.value===ae.id,disabled:Z.value&&ce.value!==ae.id,icon:"i-heroicons-arrow-down-tray",onClick:se=>be(ae.id)},{default:B(()=>[le(d(t(e)(`quotes.wordcloud.dict.download_${ae.id}`,ae.label)),1)]),_:2},1032,["loading","disabled","onClick"]))),128))])])):R("",!0),te.value?(r(),m("div",t1,[g.value&&w.value.length===0?(r(),U(t(Kt),{key:0,text:t(e)("quotes.wordcloud.loading"),class:"py-8"},null,8,["text"])):R("",!0),p(pb,{"total-messages":f.value.totalMessages,"total-words":f.value.totalWords,"unique-words":f.value.uniqueWords,"top-words":w.value,"topic-words":v.value,"pos-tag-stats":E.value,"time-filter":c.timeFilter,onWordClick:Se},null,8,["total-messages","total-words","unique-words","top-words","topic-words","pos-tag-stats","time-filter"]),c.showSharedTopics?(r(),U(bb,{key:1,"session-id":c.sessionId,"time-filter":c.timeFilter,"dict-type":Y.value,"exclude-words":q.value,onWordClick:Se},null,8,["session-id","time-filter","dict-type","exclude-words"])):R("",!0),p(t(Ze),{title:t(e)("quotes.wordcloud.stats.wordsLabel"),"show-divider":!1},{default:B(()=>[a("div",a1,[a("div",s1,[a("div",n1,[g.value?(r(),U(t(Kt),{key:0,text:t(e)("quotes.wordcloud.loading"),class:"absolute inset-0 z-10 rounded-lg bg-white/80 dark:bg-page-dark/80"},null,8,["text"])):w.value.length===0?(r(),m("div",o1,[p(V,{name:"i-heroicons-chat-bubble-bottom-center-text",class:"text-2xl"}),a("p",l1,d(t(e)("quotes.wordcloud.empty.title")),1),a("p",r1,d(t(e)("quotes.wordcloud.empty.description")),1)])):(r(),U(t(l),{key:2,data:k.value,height:"100%","max-words":y.value,"color-scheme":q1,"size-scale":b.value,loading:g.value,onWordClick:Se},null,8,["data","max-words","size-scale","loading"]))]),c.enableRecordNavigation?(r(),m("p",i1,d(t(e)("quotes.wordcloud.stats.clickHint")),1)):R("",!0)]),a("div",u1,[a("div",null,[a("h4",c1,d(t(e)("quotes.wordcloud.config.maxWords")),1),p(t(pt),{modelValue:y.value,"onUpdate:modelValue":O[0]||(O[0]=ae=>y.value=ae),size:"xs",items:J},null,8,["modelValue"])]),a("div",null,[a("h4",d1,d(t(e)("quotes.wordcloud.config.sizeScale")),1),p(t(pt),{modelValue:b.value,"onUpdate:modelValue":O[1]||(O[1]=ae=>b.value=ae),size:"xs",items:ke.value},null,8,["modelValue","items"])]),a("div",null,[a("h4",m1,d(t(e)("quotes.wordcloud.config.userFilter")),1),p(zv,{modelValue:F.value,"onUpdate:modelValue":O[2]||(O[2]=ae=>F.value=ae),"session-id":c.sessionId,class:"w-full"},null,8,["modelValue","session-id"])]),c.enableNodeNlpFeatures?(r(),m("div",g1,[a("h4",p1,d(t(e)("quotes.wordcloud.config.dict")),1),a("div",h1,[fe.value.length>1?(r(),U(t(pt),{key:0,modelValue:Y.value,"onUpdate:modelValue":O[3]||(O[3]=ae=>Y.value=ae),size:"xs",items:fe.value},null,8,["modelValue","items"])):R("",!0),(r(!0),m(ie,null,pe(j.value,ae=>(r(),m("div",{key:ae.id,class:"flex items-center gap-2"},[p(K,{size:"xs",variant:"soft",color:"primary",loading:Z.value&&ce.value===ae.id,disabled:Z.value&&ce.value!==ae.id,icon:"i-heroicons-arrow-down-tray",onClick:se=>be(ae.id)},{default:B(()=>[le(d(t(e)(`quotes.wordcloud.dict.download_${ae.id}`,t(e)("quotes.wordcloud.dict.download"))),1)]),_:2},1032,["loading","disabled","onClick"]),a("span",f1,d(t(e)("quotes.wordcloud.dict.downloadHint")),1)]))),128))])])):R("",!0),c.enableNodeNlpFeatures?(r(),m("div",v1,[a("h4",y1,d(t(e)("quotes.wordcloud.config.posFilter")),1),p(t(pt),{modelValue:x.value,"onUpdate:modelValue":O[4]||(O[4]=ae=>x.value=ae),size:"xs",items:Q.value},null,8,["modelValue","items"])])):R("",!0),a("div",x1,[p(L,{modelValue:_.value,"onUpdate:modelValue":O[5]||(O[5]=ae=>_.value=ae),label:t(e)("quotes.wordcloud.config.enableStopwords")},null,8,["modelValue","label"])]),c.enableNodeNlpFeatures&&x.value==="custom"?(r(),m("div",b1,[a("div",k1,[a("h4",_1,d(t(e)("quotes.wordcloud.posFilter.customHint")),1),a("div",w1,[p(K,{size:"xs",variant:"ghost",color:"neutral",onClick:O[6]||(O[6]=ae=>C.value=$.value.filter(se=>se.meaningful).map(se=>se.tag))},{default:B(()=>[le(d(t(e)("quotes.wordcloud.posFilter.selectMeaningful")),1)]),_:1}),p(K,{size:"xs",variant:"ghost",color:"neutral",onClick:O[7]||(O[7]=ae=>C.value=$.value.map(se=>se.tag))},{default:B(()=>[le(d(t(e)("quotes.wordcloud.posFilter.selectAll")),1)]),_:1}),p(K,{size:"xs",variant:"ghost",color:"neutral",onClick:O[8]||(O[8]=ae=>C.value=[])},{default:B(()=>[le(d(t(e)("quotes.wordcloud.posFilter.clearAll")),1)]),_:1})])]),a("div",$1,[(r(!0),m(ie,null,pe($e.value,ae=>(r(),U(P,{key:ae.value,color:C.value.includes(ae.value)?"primary":"neutral",variant:C.value.includes(ae.value)?"solid":"outline",class:"cursor-pointer select-none transition-colors",onClick:()=>{C.value.includes(ae.value)?C.value=C.value.filter(se=>se!==ae.value):C.value=[...C.value,ae.value]}},{default:B(()=>[le(d(ae.label)+" ",1),ae.count>0?(r(),m("span",C1,"("+d(ae.count)+")",1)):R("",!0)]),_:2},1032,["color","variant","onClick"]))),128))])])):R("",!0),a("div",null,[a("div",S1,[a("h4",I1,d(t(e)("wordFilter.filterScheme")),1),p(K,{size:"xs",variant:"ghost",color:"neutral",icon:"i-heroicons-cog-6-tooth","aria-label":t(e)("wordFilter.manage"),onClick:O[9]||(O[9]=ae=>t(u).openModal())},null,8,["aria-label"])]),p(t(pt),{modelValue:S.value,"onUpdate:modelValue":O[10]||(O[10]=ae=>S.value=ae),size:"xs",items:A.value},null,8,["modelValue","items"]),q.value.length>0?(r(),m("p",T1,d(t(e)("wordFilter.activeCount",{count:q.value.length})),1)):R("",!0)])])])]),_:1},8,["title"])])):R("",!0),c.enableNodeNlpFeatures?(r(),U(N,{key:2,open:ne.value,"onUpdate:open":O[12]||(O[12]=ae=>ne.value=ae),title:t(e)("quotes.wordcloud.dict.promptTitle")},{body:B(()=>[a("div",M1,[a("p",A1,d(t(e)("quotes.wordcloud.dict.promptDescription")),1),a("div",z1,[p(K,{variant:"ghost",color:"neutral",onClick:xe},{default:B(()=>[le(d(t(e)("quotes.wordcloud.dict.promptLater")),1)]),_:1}),p(K,{color:"primary",loading:Z.value,onClick:O[11]||(O[11]=ae=>be("zh-TW"))},{default:B(()=>[le(d(t(e)("quotes.wordcloud.dict.promptDownload")),1)]),_:1},8,["loading"])])])]),_:1},8,["open","title"])):R("",!0),p(Gb)])}}});function Xw(i){const l=M(()=>Dn(i)),e=M(()=>{const s=l.value;return s.length<2?!1:new Set(s.map(o=>Ee(o.date).year())).size>1}),n=M(()=>{const s=l.value,u=50;if(s.length<=u){const h=e.value?"YYYY/MM/DD":"MM/DD";return{labels:s.map(f=>Ee(f.date).format(h)),values:s.map(f=>f.messageCount)}}const o=Math.ceil(s.length/u),c=[],g=[];for(let h=0;h<s.length;h+=o){const f=s.slice(h,h+o);if(f.length===0)continue;const b=Math.floor(f.length/2),y=f[b].date,k=e.value?"YYYY/MM/DD":"MM/DD";c.push(Ee(y).format(k));const x=f.reduce((C,$)=>C+$.messageCount,0),_=Math.round(x/f.length);g.push(_)}return{labels:c,values:g}});return{isMultiYear:e,dailyChartData:n}}const L1=86400;function Gt(i){return typeof i=="number"&&Number.isFinite(i)}function D1(i){return Gt(i?.startTs)&&Gt(i?.endTs)}function $s(i,l){const e=l?.startTs??i?.start,n=l?.endTs??i?.end;return!Gt(e)||!Gt(n)||n<e?null:{start:e,end:n}}function E1(i,l=0){return!i||i.end<i.start?0:Math.max(Math.ceil((i.end-i.start)/L1),l,1)}function B1(i){return i?[Ee.unix(i.start).format("YYYY-MM-DD"),Ee.unix(i.end).format("YYYY-MM-DD")]:null}function F1(i,l){const{t:e}=we(),n=M(()=>$s(i.timeRange,i.timeFilter)),s=M(()=>D1(i.timeFilter)),u=M(()=>i.dailyActivity.filter(E=>E.messageCount>0).length),o=M(()=>E1(n.value,u.value)),c=M(()=>s.value?i.filteredMessageCount:i.session.messageCount),g=M(()=>s.value?i.filteredMemberCount??i.session.memberCount:i.session.memberCount),h=M(()=>o.value),f=M(()=>h.value===0?0:Math.round(c.value/h.value)),b=M(()=>o.value===0?0:Math.round(c.value/o.value)),y=M(()=>i.messageTypes.find(F=>F.type===1)?.count||0),k=M(()=>i.hourlyActivity.length?i.hourlyActivity.reduce((E,F)=>F.messageCount>E.messageCount?F:E,i.hourlyActivity[0]):null),x=M(()=>l.value.length?l.value.reduce((E,F)=>F.messageCount>E.messageCount?F:E,l.value[0]):null),_=M(()=>[e("common.weekday.mon"),e("common.weekday.tue"),e("common.weekday.wed"),e("common.weekday.thu"),e("common.weekday.fri"),e("common.weekday.sat"),e("common.weekday.sun")]),C=M(()=>{if(!l.value.length)return{weekday:0,weekend:0};const E=l.value.filter(A=>A.weekday>=1&&A.weekday<=5).reduce((A,S)=>A+S.messageCount,0),F=l.value.filter(A=>A.weekday>=6&&A.weekday<=7).reduce((A,S)=>A+S.messageCount,0),D=E+F;return{weekday:D>0?Math.round(E/D*100):0,weekend:D>0?Math.round(F/D*100):0}}),$=M(()=>i.dailyActivity.length?i.dailyActivity.reduce((E,F)=>F.messageCount>E.messageCount?F:E,i.dailyActivity[0]):null),I=M(()=>o.value),T=M(()=>I.value>0?Math.round(u.value/I.value*100):0),v=M(()=>{if(!i.hourlyActivity.length)return{count:0,ratio:0};const E=i.hourlyActivity.reduce((D,A)=>D+A.messageCount,0),F=i.hourlyActivity.filter(D=>D.hour>=0&&D.hour<=4).reduce((D,A)=>D+A.messageCount,0);return{count:F,ratio:E>0?Math.round(F/E*100):0}}),w=M(()=>{if(!i.dailyActivity.length)return 0;const E=[...i.dailyActivity].filter(A=>A.messageCount>0).sort((A,S)=>Ee(A.date).valueOf()-Ee(S.date).valueOf());if(E.length===0)return 0;let F=1,D=1;for(let A=1;A<E.length;A++){const S=Ee(E[A-1].date);Ee(E[A].date).diff(S,"day")===1?D++:(D>F&&(F=D),D=1)}return D>F&&(F=D),F});return{durationDays:o,displayMessageCount:c,displayMemberCount:g,dailyAvgMessages:b,totalDurationDays:h,totalDailyAvgMessages:f,imageCount:y,peakHour:k,peakWeekday:x,weekdayNames:_,weekdayVsWeekend:C,peakDay:$,activeDays:u,totalDays:I,activeRate:T,lateNightChat:v,maxConsecutiveDays:w}}function R1(i){const l=z([]);let e=0;async function n(){const s=++e,u=i.sessionId();if(!u){l.value=[];return}try{const o=await Ke().getWeekdayActivity(u,i.timeFilter());s===e&&(l.value=o)}catch(o){s===e&&console.error("Failed to load weekday activity:",o)}}return he([i.sessionId,i.timeFilter],()=>n(),{immediate:!0,deep:!0}),{weekdayActivity:l}}const V1={key:0,class:"relative z-10 px-5 pb-5 pt-2 sm:px-8 sm:pb-6"},O1={class:"grid grid-cols-2 gap-3 lg:grid-cols-4"},P1={class:"min-w-0"},j1={class:"mt-0.5 truncate text-[10px] font-medium text-gray-500 dark:text-gray-400"},N1={class:"mt-0.5 truncate text-[9px] text-gray-400 dark:text-gray-500"},U1={key:1,class:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4"},W1={class:"text-sm text-gray-500"},H1={class:"text-sm text-gray-500"},K1={class:"ml-1 font-semibold text-pink-500"},Y1={class:"text-sm text-gray-500"},G1={class:"text-sm text-gray-500"},Q1={class:"text-sm text-gray-500"},J1={class:"text-sm text-gray-500"},X1={class:"text-sm text-gray-500"},Z1={class:"text-sm text-gray-500"},ek=ue({__name:"OverviewStatCards",props:{dailyAvgMessages:{},durationDays:{},imageCount:{},peakHour:{},peakWeekday:{},weekdayNames:{},weekdayVsWeekend:{},peakDay:{},activeDays:{},totalDays:{},activeRate:{},lateNightCount:{},lateNightRatio:{},maxConsecutiveDays:{},flat:{type:Boolean,default:!1}},setup(i){const{t:l}=we(),e=i,n=M(()=>[{icon:"i-heroicons-chat-bubble-left-right",label:l("analysis.overview.statCards.dailyAvgMessages"),value:l("analysis.overview.statCards.messagesCount",{count:e.dailyAvgMessages}),subtext:l("analysis.overview.statCards.daysCount",{count:e.durationDays}),colorClass:"text-blue-600 dark:text-blue-400"},{icon:"i-heroicons-photo",label:l("analysis.overview.statCards.imageMessages"),value:l("analysis.overview.statCards.imagesCount",{count:e.imageCount}),subtext:`${l("analysis.overview.statCards.peakHour")} ${e.peakHour?.hour||0}:00`,colorClass:"text-pink-600 dark:text-pink-400"},{icon:"i-heroicons-calendar-days",label:l("analysis.overview.statCards.mostActiveWeekday"),value:e.peakWeekday?e.weekdayNames[e.peakWeekday.weekday-1]:"-",subtext:l("analysis.overview.statCards.messagesOnDay",{count:e.peakWeekday?.messageCount??0}),colorClass:"text-amber-600 dark:text-amber-400"},{icon:"i-heroicons-sun",label:l("analysis.overview.statCards.weekendActivity"),value:`${e.weekdayVsWeekend.weekend}%`,subtext:l("analysis.overview.statCards.weekendRatio"),colorClass:"text-green-600 dark:text-green-400"},{icon:"i-heroicons-fire",label:l("analysis.overview.statCards.mostActiveDate"),value:e.peakDay?Ee(e.peakDay.date).format("MM/DD"):"-",subtext:l("analysis.overview.statCards.messagesOnDay",{count:e.peakDay?.messageCount??0}),colorClass:"text-red-600 dark:text-red-400"},{icon:"i-heroicons-moon",label:l("analysis.overview.statCards.lateNightChat"),value:l("analysis.overview.statCards.messagesCount",{count:e.lateNightCount}),subtext:l("analysis.overview.statCards.lateNightRatio",{ratio:e.lateNightRatio}),colorClass:"text-indigo-600 dark:text-indigo-400"},{icon:"i-heroicons-bolt",label:l("analysis.overview.statCards.consecutiveStreak"),value:l("analysis.overview.statCards.daysStreak",{count:e.maxConsecutiveDays}),subtext:l("analysis.overview.statCards.longestStreak"),colorClass:"text-amber-600 dark:text-amber-400"},{icon:"i-heroicons-chart-bar",label:l("analysis.overview.statCards.activityRate"),value:`${e.activeRate}%`,subtext:l("analysis.overview.statCards.activeDaysRatio"),colorClass:"text-gray-900 dark:text-white"}]);return(s,u)=>{const o=_e;return i.flat?(r(),m("div",V1,[u[0]||(u[0]=a("div",{class:"mb-3 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"},"Key Metrics")],-1)),a("div",O1,[(r(!0),m(ie,null,pe(n.value,c=>(r(),m("div",{key:c.icon+c.label,class:"flex min-w-0 items-start gap-2 px-2.5 py-2"},[p(o,{name:c.icon,class:X(["mt-0.5 h-3.5 w-3.5 shrink-0",c.colorClass])},null,8,["name","class"]),a("div",P1,[a("div",{class:X(["truncate font-mono text-sm font-black leading-tight tabular-nums",c.colorClass])},d(c.value),3),a("div",j1,d(c.label),1),a("div",N1,d(c.subtext),1)])]))),128))])])):(r(),m("div",U1,[p(t(ot),{label:t(l)("analysis.overview.statCards.dailyAvgMessages"),value:t(l)("analysis.overview.statCards.messagesCount",{count:i.dailyAvgMessages}),icon:"i-heroicons-chat-bubble-left-right","icon-bg":"blue"},{subtext:B(()=>[a("span",W1,d(t(l)("analysis.overview.statCards.daysCount",{count:i.durationDays})),1)]),_:1},8,["label","value"]),p(t(ot),{label:t(l)("analysis.overview.statCards.imageMessages"),value:t(l)("analysis.overview.statCards.imagesCount",{count:i.imageCount}),icon:"i-heroicons-photo","icon-bg":"pink"},{subtext:B(()=>[a("span",H1,d(t(l)("analysis.overview.statCards.peakHour")),1),a("span",K1,d(i.peakHour?.hour||0)+":00",1)]),_:1},8,["label","value"]),p(t(ot),{label:t(l)("analysis.overview.statCards.mostActiveWeekday"),value:i.peakWeekday?i.weekdayNames[i.peakWeekday.weekday-1]:"-",icon:"i-heroicons-calendar-days","icon-bg":"amber"},{subtext:B(()=>[a("span",Y1,d(t(l)("analysis.overview.statCards.messagesOnDay",{count:i.peakWeekday?.messageCount??0})),1)]),_:1},8,["label","value"]),p(t(ot),{label:t(l)("analysis.overview.statCards.weekendActivity"),value:`${i.weekdayVsWeekend.weekend}%`,icon:"i-heroicons-sun","icon-bg":"green"},{subtext:B(()=>[a("span",G1,d(t(l)("analysis.overview.statCards.weekendRatio")),1)]),_:1},8,["label","value"]),p(t(ot),{label:t(l)("analysis.overview.statCards.mostActiveDate"),value:i.peakDay?t(Ee)(i.peakDay.date).format("MM/DD"):"-",icon:"i-heroicons-fire","icon-bg":"red"},{subtext:B(()=>[a("span",Q1,d(t(l)("analysis.overview.statCards.messagesOnDay",{count:i.peakDay?.messageCount??0})),1)]),_:1},8,["label","value"]),p(t(ot),{label:t(l)("analysis.overview.statCards.lateNightChat"),value:t(l)("analysis.overview.statCards.messagesCount",{count:i.lateNightCount}),icon:"i-heroicons-moon","icon-bg":"blue"},{subtext:B(()=>[a("span",J1,d(t(l)("analysis.overview.statCards.lateNightRatio",{ratio:i.lateNightRatio})),1)]),_:1},8,["label","value"]),p(t(ot),{label:t(l)("analysis.overview.statCards.consecutiveStreak"),value:t(l)("analysis.overview.statCards.daysStreak",{count:i.maxConsecutiveDays}),icon:"i-heroicons-bolt","icon-bg":"amber"},{subtext:B(()=>[a("span",X1,d(t(l)("analysis.overview.statCards.longestStreak")),1)]),_:1},8,["label","value"]),p(t(ot),{label:t(l)("analysis.overview.statCards.activityRate"),value:`${i.activeRate}%`,icon:"i-heroicons-chart-bar","icon-bg":"gray"},{subtext:B(()=>[a("span",Z1,d(t(l)("analysis.overview.statCards.activeDaysRatio")),1)]),_:1},8,["label","value"])]))}}}),tk={class:"relative z-10 px-5 pt-6 pb-4 sm:px-8 sm:pt-8"},ak={class:"text-2xl font-bold tracking-tight text-gray-900 sm:text-3xl dark:text-gray-100"},sk={class:"mt-4 flex flex-col gap-5 sm:flex-row sm:items-start sm:gap-24"},nk={class:"min-w-0 flex flex-col gap-2 text-sm font-medium text-gray-500 dark:text-gray-400"},ok={class:"flex items-center gap-2"},lk={class:"flex h-6 w-6 shrink-0 items-center justify-center"},rk={class:"whitespace-nowrap"},ik={key:0,class:"flex items-center gap-2"},uk={class:"flex h-6 w-6 shrink-0 items-center justify-center"},ck={class:"font-mono text-xs opacity-90 whitespace-nowrap"},dk={class:"grid grid-cols-2 gap-x-8 gap-y-4 sm:flex sm:shrink-0 sm:gap-6"},mk={class:"flex flex-col gap-1 text-center"},gk={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},pk={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},hk={class:"flex flex-col gap-1 text-center"},fk={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},vk={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},yk={class:"flex flex-col gap-1 text-center"},xk={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},bk={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},kk={class:"flex flex-col gap-1 text-center"},_k={class:"text-2xl font-black font-mono tracking-tight text-gray-900 dark:text-white"},wk={class:"text-xs font-medium text-gray-500 dark:text-gray-400"},$k={class:"relative z-10 px-5 pb-2 sm:px-8"},Ck={class:"overflow-x-auto overflow-y-hidden scrollbar-hide py-1"},Zw=ue({__name:"OverviewIdentityCard",props:{session:{},dailyActivity:{},messageTypes:{},hourlyActivity:{},timeRange:{},filteredMessageCount:{},filteredMemberCount:{},timeFilter:{},capturable:{type:Boolean,default:!0}},setup(i){ta([hs,to,fs,za,vs,aa]);const{t:l,locale:e}=we(),n=Zt(),s=i,{weekdayActivity:u}=R1({sessionId:()=>s.session.id,timeFilter:()=>s.timeFilter}),{durationDays:o,displayMessageCount:c,dailyAvgMessages:g,imageCount:h,peakHour:f,peakWeekday:b,weekdayNames:y,weekdayVsWeekend:k,peakDay:x,activeDays:_,totalDays:C,activeRate:$,lateNightChat:I,maxConsecutiveDays:T}=F1(s,u),v=z(null);let w=null;const E=M(()=>$s(s.timeRange,s.timeFilter)),F=M(()=>E.value?ao(E.value.start,E.value.end,"YYYY/MM/DD"):""),D=M(()=>{const H=B1(E.value);if(H)return H;const ve=(fe=>fe.toISOString().slice(0,10))(new Date);return[ve,ve]}),A=M(()=>{const[H,W]=D.value,re=new Date(H+"T00:00:00Z"),ve=new Date(W+"T00:00:00Z"),fe=new Map;s.dailyActivity.filter(j=>j.date>=H&&j.date<=W).forEach(j=>fe.set(j.date,j.messageCount));const ee=[],te=new Date(re);for(;te<=ve;){const j=te.toISOString().slice(0,10),de=fe.get(j)||0;ee.push({value:[j,de],itemStyle:de===0?{color:Y.value}:void 0}),te.setUTCDate(te.getUTCDate()+1)}return ee}),S=M(()=>s.dailyActivity.length===0?10:Math.max(...s.dailyActivity.map(H=>H.messageCount),1)),q={light:["#fce4ec","#f8a4b8","#f06292","#e91e63"],dark:["rgba(238, 69, 103, 0.15)","rgba(238, 69, 103, 0.45)","rgba(238, 69, 103, 0.75)","rgba(238, 69, 103, 1)"]},Y=M(()=>n.value?"rgba(255, 255, 255, 0.04)":"#ebedf0"),G=M(()=>({tooltip:{trigger:"item",formatter:H=>{const W=H.value[0],re=H.value[1];return`${W}<br/>${l("views.message.calendarTooltipMessages")}: ${re}`}},visualMap:{min:1,max:S.value,calculable:!1,orient:"horizontal",left:"center",bottom:0,itemWidth:10,itemHeight:80,text:[`${S.value}`,"1"],inRange:{color:n.value?q.dark:q.light},textStyle:{color:n.value?"#8b949e":"#6b7280",fontSize:10},show:!0},calendar:{top:20,left:30,cellSize:[13,13],range:D.value,itemStyle:{borderWidth:0,color:"transparent"},yearLabel:{show:!1},monthLabel:{show:!0,color:n.value?"#8b949e":"#6b7280",fontSize:10,nameMap:[l("common.month.jan"),l("common.month.feb"),l("common.month.mar"),l("common.month.apr"),l("common.month.may"),l("common.month.jun"),l("common.month.jul"),l("common.month.aug"),l("common.month.sep"),l("common.month.oct"),l("common.month.nov"),l("common.month.dec")]},dayLabel:{show:!0,firstDay:1,color:n.value?"#8b949e":"#9ca3af",fontSize:10,nameMap:[l("common.weekday.sun"),l("common.weekday.mon"),l("common.weekday.tue"),l("common.weekday.wed"),l("common.weekday.thu"),l("common.weekday.fri"),l("common.weekday.sat")]},splitLine:{show:!1}},series:[{type:"custom",coordinateSystem:"calendar",data:A.value,renderItem:(H,W)=>{const re=W.coord(W.value(0)),ve=H.coordSys.cellWidth,fe=H.coordSys.cellHeight,ee=Math.min(ve,fe)-3;return{type:"rect",shape:{x:re[0]-ee/2,y:re[1]-ee/2,width:ee,height:ee,r:3},style:{fill:W.visual("color")}}},itemStyle:{borderColor:n.value?"transparent":"rgba(0,0,0,0.02)",borderWidth:1}}]}));function Z(){v.value&&(w=sa(v.value,void 0,{renderer:"canvas"}),w.setOption({backgroundColor:"transparent",...G.value}))}function ce(){w&&w.setOption({backgroundColor:"transparent",...G.value},{notMerge:!0})}function ne(){w?.resize()}return he([()=>s.dailyActivity,e,D],()=>ce()),he(n,()=>{w?.dispose(),Z()}),Re(()=>{Z(),window.addEventListener("resize",ne)}),tt(()=>{window.removeEventListener("resize",ne),w?.dispose()}),(H,W)=>{const re=_e;return r(),U(t(na),{capturable:i.capturable},{default:B(()=>[a("div",tk,[a("h2",ak,d(i.session.name),1),a("div",sk,[a("div",nk,[a("div",ok,[a("div",lk,[i.session.type==="group"?(r(),U(re,{key:0,name:"i-heroicons-user-group",class:"h-4 w-4 opacity-70"})):(r(),U(re,{key:1,name:"i-heroicons-user",class:"h-4 w-4 opacity-70"}))]),a("span",rk,d(i.session.platform.toUpperCase())+" · "+d(i.session.type==="private"?t(l)("analysis.overview.identity.privateChat"):t(l)("analysis.overview.identity.groupChat")),1)]),F.value?(r(),m("div",ik,[a("div",uk,[p(re,{name:"i-heroicons-calendar",class:"h-4 w-4 opacity-70"})]),a("span",ck,d(F.value),1)])):R("",!0)]),a("div",dk,[a("div",mk,[a("span",gk,d(t(c).toLocaleString()),1),a("span",pk,d(t(l)("analysis.overview.identity.totalMessages")),1)]),a("div",hk,[a("span",fk,d(t(o).toLocaleString()),1),a("span",vk,d(t(l)("analysis.overview.identity.durationDays")),1)]),a("div",yk,[a("span",xk,d(t(_).toLocaleString()),1),a("span",bk,d(t(l)("analysis.overview.identity.activeDays")),1)]),a("div",kk,[a("span",_k,d(t(g).toLocaleString()),1),a("span",wk,d(t(l)("analysis.overview.identity.dailyAvgMessages")),1)])])])]),a("div",$k,[W[0]||(W[0]=a("div",{class:"mb-2 flex items-center justify-between"},[a("span",{class:"text-[10px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"}," Activity Heatmap ")],-1)),a("div",Ck,[a("div",{ref_key:"chartRef",ref:v,class:"h-[140px] min-w-[700px] lg:w-full"},null,512)])]),p(ek,{flat:"","daily-avg-messages":t(g),"duration-days":t(o),"image-count":t(h),"peak-hour":t(f),"peak-weekday":t(b),"weekday-names":t(y),"weekday-vs-weekend":t(k),"peak-day":t(x),"active-days":t(_),"total-days":t(C),"active-rate":t($),"late-night-count":t(I).count,"late-night-ratio":t(I).ratio,"max-consecutive-days":t(T)},null,8,["daily-avg-messages","duration-days","image-count","peak-hour","peak-weekday","weekday-names","weekday-vs-weekend","peak-day","active-days","total-days","active-rate","late-night-count","late-night-ratio","max-consecutive-days"])]),_:1},8,["capturable"])}}}),Sk={class:"p-3 sm:p-5"},e2=ue({__name:"DailyTrendCard",props:{dailyActivity:{},dailyChartData:{},capturable:{type:Boolean,default:!0}},setup(i){const{t:l}=we();return(e,n)=>i.dailyActivity.length>0?(r(),U(t(Ze),{key:0,title:t(l)("analysis.overview.dailyTrend.title"),capturable:i.capturable,"show-divider":!1},{default:B(()=>[a("div",Sk,[p(t(va),{data:i.dailyChartData,height:288},null,8,["data"])])]),_:1},8,["title","capturable"])):R("",!0)}}),Ik={slots:{root:["relative inline-flex items-center","flex-wrap"],base:["rounded-md","transition-colors"],leading:"absolute inset-y-0 start-0 flex items-center",leadingIcon:"shrink-0 text-dimmed",leadingAvatar:"shrink-0",leadingAvatarSize:"",trailing:"absolute inset-y-0 end-0 flex items-center",trailingIcon:"shrink-0 text-dimmed",item:'px-1.5 py-0.5 rounded-sm font-medium inline-flex items-center gap-0.5 ring ring-inset ring-accented bg-elevated text-default data-disabled:cursor-not-allowed data-disabled:opacity-75 wrap-anywhere data-[state="active"]:bg-accented',itemText:"",itemDelete:["inline-flex items-center rounded-xs text-dimmed hover:text-default hover:bg-accented/75 disabled:pointer-events-none","transition-colors"],itemDeleteIcon:"shrink-0",input:"flex-1 border-0 bg-transparent placeholder:text-dimmed focus:outline-none disabled:cursor-not-allowed disabled:opacity-75"},variants:{fieldGroup:{horizontal:"not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]",vertical:"not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]"},size:{xs:{base:"px-2 py-1 text-sm/4 gap-1",leading:"ps-2",trailing:"pe-2",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4",item:"text-[10px]/3",itemDeleteIcon:"size-3"},sm:{base:"px-2.5 py-1.5 text-sm/4 gap-1.5",leading:"ps-2.5",trailing:"pe-2.5",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4",item:"text-[10px]/3",itemDeleteIcon:"size-3"},md:{base:"px-2.5 py-1.5 text-base/5 gap-1.5",leading:"ps-2.5",trailing:"pe-2.5",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5",item:"text-xs",itemDeleteIcon:"size-3.5"},lg:{base:"px-3 py-2 text-base/5 gap-2",leading:"ps-3",trailing:"pe-3",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5",item:"text-xs",itemDeleteIcon:"size-3.5"},xl:{base:"px-3 py-2 text-base gap-2",leading:"ps-3",trailing:"pe-3",leadingIcon:"size-6",leadingAvatarSize:"xs",trailingIcon:"size-6",item:"text-sm",itemDeleteIcon:"size-4"}},variant:{outline:"text-highlighted bg-default ring ring-inset ring-accented",soft:"text-highlighted bg-elevated/50 hover:bg-elevated has-focus:bg-elevated disabled:bg-elevated/50",subtle:"text-highlighted bg-elevated ring ring-inset ring-accented",ghost:"text-highlighted bg-transparent hover:bg-elevated has-focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent",none:"text-highlighted bg-transparent has-focus:outline-none"},color:{primary:"",secondary:"",success:"",info:"",warning:"",error:"",neutral:""},leading:{true:""},trailing:{true:""},loading:{true:""},highlight:{true:""},fixed:{false:""},type:{file:"file:me-1.5 file:font-medium file:text-muted file:outline-none"}},compoundVariants:[{color:"primary",variant:["outline","subtle"],class:"outline-primary/25 has-focus-visible:outline-3 has-focus-visible:ring-primary"},{color:"secondary",variant:["outline","subtle"],class:"outline-secondary/25 has-focus-visible:outline-3 has-focus-visible:ring-secondary"},{color:"success",variant:["outline","subtle"],class:"outline-success/25 has-focus-visible:outline-3 has-focus-visible:ring-success"},{color:"info",variant:["outline","subtle"],class:"outline-info/25 has-focus-visible:outline-3 has-focus-visible:ring-info"},{color:"warning",variant:["outline","subtle"],class:"outline-warning/25 has-focus-visible:outline-3 has-focus-visible:ring-warning"},{color:"error",variant:["outline","subtle"],class:"outline-error/25 has-focus-visible:outline-3 has-focus-visible:ring-error"},{color:"primary",variant:["soft","ghost"],class:"outline-primary/25 has-focus-visible:outline-3"},{color:"secondary",variant:["soft","ghost"],class:"outline-secondary/25 has-focus-visible:outline-3"},{color:"success",variant:["soft","ghost"],class:"outline-success/25 has-focus-visible:outline-3"},{color:"info",variant:["soft","ghost"],class:"outline-info/25 has-focus-visible:outline-3"},{color:"warning",variant:["soft","ghost"],class:"outline-warning/25 has-focus-visible:outline-3"},{color:"error",variant:["soft","ghost"],class:"outline-error/25 has-focus-visible:outline-3"},{color:"primary",highlight:!0,class:"ring ring-inset ring-primary"},{color:"secondary",highlight:!0,class:"ring ring-inset ring-secondary"},{color:"success",highlight:!0,class:"ring ring-inset ring-success"},{color:"info",highlight:!0,class:"ring ring-inset ring-info"},{color:"warning",highlight:!0,class:"ring ring-inset ring-warning"},{color:"error",highlight:!0,class:"ring ring-inset ring-error"},{color:"neutral",variant:["outline","subtle"],class:"outline-inverted/25 has-focus-visible:outline-3 has-focus-visible:ring-inverted"},{color:"neutral",variant:["soft","ghost"],class:"outline-inverted/25 has-focus-visible:outline-3"},{color:"neutral",highlight:!0,class:"ring ring-inset ring-inverted"},{leading:!0,size:"xs",class:"ps-7"},{leading:!0,size:"sm",class:"ps-8"},{leading:!0,size:"md",class:"ps-9"},{leading:!0,size:"lg",class:"ps-10"},{leading:!0,size:"xl",class:"ps-11"},{trailing:!0,size:"xs",class:"pe-7"},{trailing:!0,size:"sm",class:"pe-8"},{trailing:!0,size:"md",class:"pe-9"},{trailing:!0,size:"lg",class:"pe-10"},{trailing:!0,size:"xl",class:"pe-11"},{loading:!0,leading:!0,class:{leadingIcon:"animate-spin"}},{loading:!0,leading:!1,trailing:!0,class:{trailingIcon:"animate-spin"}},{fixed:!1,size:"xs",class:"md:text-xs"},{fixed:!1,size:"sm",class:"md:text-xs"},{fixed:!1,size:"md",class:"md:text-sm"},{fixed:!1,size:"lg",class:"md:text-sm"}],defaultVariants:{size:"md",color:"primary",variant:"outline"}},Tk=Object.assign({inheritAttrs:!1},{__name:"InputTags",props:{as:{type:null,required:!1},placeholder:{type:String,required:!1},maxLength:{type:Number,required:!1},color:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},autofocus:{type:Boolean,required:!1},autofocusDelay:{type:Number,required:!1,default:0},deleteIcon:{type:null,required:!1},highlight:{type:Boolean,required:!1},fixed:{type:Boolean,required:!1},class:{type:null,required:!1},ui:{type:Object,required:!1},modelValue:{type:[Array,null],required:!1},defaultValue:{type:Array,required:!1},addOnPaste:{type:Boolean,required:!1},addOnTab:{type:Boolean,required:!1},addOnBlur:{type:Boolean,required:!1},duplicate:{type:Boolean,required:!1},disabled:{type:Boolean,required:!1},delimiter:{type:null,required:!1},max:{type:Number,required:!1},id:{type:String,required:!1},convertValue:{type:Function,required:!1},displayValue:{type:Function,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1},icon:{type:null,required:!1},avatar:{type:Object,required:!1},leading:{type:Boolean,required:!1},leadingIcon:{type:null,required:!1},trailing:{type:Boolean,required:!1},trailingIcon:{type:null,required:!1},loading:{type:Boolean,required:!1},loadingIcon:{type:null,required:!1}},emits:["change","blur","focus","update:modelValue","invalid","addTag","removeTag"],setup(i,{expose:l,emit:e}){const n=i,s=e,u=Qt(),o=Ca("inputTags",n),c=Ia(),g=rs(is(o,"as","addOnPaste","addOnTab","addOnBlur","duplicate","delimiter","max","convertValue","displayValue","required"),s),{emitFormBlur:h,emitFormFocus:f,emitFormChange:b,emitFormInput:y,size:k,color:x,id:_,name:C,highlight:$,disabled:I,ariaAttrs:T}=Sa(n),{orientation:v,size:w}=us(n),{isLeading:E,isTrailing:F,leadingIconName:D,trailingIconName:A}=Ta(o),S=M(()=>w.value||k.value),q=M(()=>$t({extend:$t(Ik),...c.ui?.inputTags||{}})({color:x.value??o.color,variant:o.variant,size:S?.value??o.size,loading:o.loading,highlight:$.value??o.highlight,fixed:o.fixed,leading:E.value||!!o.avatar||!!u.leading,trailing:F.value||!!u.trailing,fieldGroup:v.value})),Y=At("inputRef");function G(){o.autofocus&&Y.value?.$el?.focus()}Re(()=>{setTimeout(()=>{G()},o.autofocusDelay)});function Z(H){if(cs(o.modelValue)===H)return;const W=new Event("change",{target:{value:H}});s("change",W),b(),y()}function ce(H){s("blur",H),h()}function ne(H){s("focus",H),f()}return l({inputRef:We(()=>Y.value?.$el)}),(H,W)=>(r(),U(t(Cl),ze({id:t(_),"model-value":t(o).modelValue,"default-value":t(o).defaultValue,"data-slot":"root",class:q.value.root({class:[q.value.base({class:t(o).ui?.base}),t(o).ui?.root,t(o).class]})},t(g),{name:t(C),disabled:t(I),"onUpdate:modelValue":Z}),{default:B(({modelValue:re})=>[(r(!0),m(ie,null,pe(re,(ve,fe)=>(r(),U(t(Al),{key:fe,value:ve,"data-slot":"item",class:X(q.value.item({class:[t(o).ui?.item]}))},{default:B(()=>[p(t(Dl),{"data-slot":"itemText",class:X(q.value.itemText({class:[t(o).ui?.itemText]}))},{default:B(()=>[u["item-text"]?ye(H.$slots,"item-text",{key:0,item:ve,index:fe,ui:q.value}):R("",!0)]),_:2},1032,["class"]),p(t(ql),{"data-slot":"itemDelete",class:X(q.value.itemDelete({class:[t(o).ui?.itemDelete]})),disabled:t(I)},{default:B(()=>[ye(H.$slots,"item-delete",{item:ve,index:fe,ui:q.value},()=>[p(_e,{name:t(o).deleteIcon||t(c).ui.icons.close,"data-slot":"itemDeleteIcon",class:X(q.value.itemDeleteIcon({class:[t(o).ui?.itemDeleteIcon]}))},null,8,["name","class"])])]),_:2},1032,["class","disabled"])]),_:2},1032,["value","class"]))),128)),p(t(Il),ze({ref_key:"inputRef",ref:Y},{...H.$attrs,...t(T)},{placeholder:t(o).placeholder,"max-length":t(o).maxLength,"data-slot":"input",class:q.value.input({class:t(o).ui?.input}),onBlur:ce,onFocus:ne}),null,16,["placeholder","max-length","class"]),ye(H.$slots,"default",{ui:q.value}),t(E)||t(o).avatar||u.leading?(r(),m("span",{key:0,"data-slot":"leading",class:X(q.value.leading({class:t(o).ui?.leading}))},[ye(H.$slots,"leading",{ui:q.value},()=>[t(E)&&t(D)?(r(),U(_e,{key:0,name:t(D),"data-slot":"leadingIcon",class:X(q.value.leadingIcon({class:t(o).ui?.leadingIcon}))},null,8,["name","class"])):t(o).avatar?(r(),U(Ht,ze({key:1,size:t(o).ui?.leadingAvatarSize||q.value.leadingAvatarSize()},t(o).avatar,{"data-slot":"leadingAvatar",class:q.value.leadingAvatar({class:t(o).ui?.leadingAvatar})}),null,16,["size","class"])):R("",!0)])],2)):R("",!0),t(F)||u.trailing?(r(),m("span",{key:1,"data-slot":"trailing",class:X(q.value.trailing({class:t(o).ui?.trailing}))},[ye(H.$slots,"trailing",{ui:q.value},()=>[t(A)?(r(),U(_e,{key:0,name:t(A),"data-slot":"trailingIcon",class:X(q.value.trailingIcon({class:t(o).ui?.trailingIcon}))},null,8,["name","class"])):R("",!0)])],2)):R("",!0)]),_:3},16,["id","model-value","default-value","class","name","disabled"]))}}),Mk={class:"flex items-center justify-between gap-3"},Ak={class:"flex items-center gap-2"},zk={class:"text-sm font-medium text-gray-900 dark:text-white"},qk={class:"text-xs text-gray-500 dark:text-gray-400"},Lk=ue({__name:"OwnerEntryCard",props:{sessionId:{},members:{},chatType:{}},setup(i){const{t:l}=we(),e=En(),n=i,s=z(!1);function u(g){return g.groupNickname||g.accountName||g.platformId}const o=M(()=>{const g=e.currentSession?.ownerId;return g&&n.members.find(h=>h.platformId===g)||null}),c=M(()=>o.value?u(o.value):e.currentSession?.ownerId??"");return(g,h)=>{const f=_e,b=Ue;return r(),U(t(mt),{class:"w-150 p-3"},{default:B(()=>[a("div",Mk,[a("div",Ak,[a("div",{class:X(["flex h-8 w-8 items-center justify-center rounded-full bg-linear-to-br",i.chatType==="group"?"from-pink-400 to-pink-600":"from-purple-400 to-purple-600"])},[p(f,{name:"i-heroicons-user",class:"h-4 w-4 text-white"})],2),a("div",null,[a("h3",zk,d(c.value?t(l)("members.ownerPrompt.currentOwner",{name:c.value}):t(l)("members.ownerPrompt.choose")),1),a("p",qk,d(t(l)("members.ownerPrompt.helper")),1)])]),p(b,{size:"sm",variant:c.value?"outline":"solid",color:"primary",onClick:h[0]||(h[0]=y=>s.value=!0)},{default:B(()=>[le(d(c.value?t(l)("members.ownerPrompt.change"):t(l)("members.ownerPrompt.choose")),1)]),_:1},8,["variant"])]),p(Bn,{modelValue:s.value,"onUpdate:modelValue":h[1]||(h[1]=y=>s.value=y),"session-id":i.sessionId,"chat-type":i.chatType},null,8,["modelValue","session-id","chat-type"])]),_:1})}}}),Dk={key:0,class:"mb-6"},Ek={class:"flex items-center gap-3"},Bk={class:"text-xl font-bold text-gray-900 dark:text-white"},Fk={class:"text-sm text-gray-500 dark:text-gray-400"},Rk={class:"mb-4 flex flex-wrap items-center justify-between gap-3"},Vk={key:0,class:"flex items-center gap-2"},Ok={class:"text-xs text-gray-500 dark:text-gray-400"},Pk={key:0,class:"flex flex-1 items-center justify-center"},jk={key:1,class:"flex flex-1 flex-col items-center justify-center gap-3"},Nk={class:"text-sm text-gray-500 dark:text-gray-400"},Uk={key:2,class:"flex flex-1 flex-col items-center justify-center"},Wk={class:"text-gray-500 dark:text-gray-400"},Hk={key:3,class:"min-h-0 flex-1 overflow-x-auto overflow-y-hidden"},Kk={key:0,"aria-hidden":"true"},Yk={class:"flex shrink-0 flex-col leading-none"},Gk={class:"flex shrink-0 flex-col leading-none"},Qk={class:"flex shrink-0 flex-col leading-none"},Jk={class:"inline-flex items-center gap-1.5"},Xk={class:"text-right"},Zk=["data-index","onClick"],e_={key:0,class:"flex justify-center"},t_={class:"flex min-w-0 items-center gap-2.5"},a_={class:"min-w-0"},s_=["title"],n_=["title"],o_=["title"],l_={class:"text-right font-mono text-sm font-semibold tabular-nums text-gray-900 dark:text-white"},r_=["title"],i_={class:"flex justify-end gap-1"},u_={class:"p-6 text-center"},c_={class:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30"},d_={class:"mb-2 text-lg font-semibold text-gray-900 dark:text-white"},m_={class:"mb-6 text-sm text-gray-500 dark:text-gray-400"},g_={class:"flex justify-center gap-3"},p_={class:"p-6 text-center"},h_={class:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/30"},f_={class:"mb-2 text-lg font-semibold text-gray-900 dark:text-white"},v_={class:"mb-6 text-sm text-gray-500 dark:text-gray-400"},y_={class:"flex justify-center gap-3"},x_={class:"p-6"},b_={class:"mb-4 flex items-center gap-3"},k_={class:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100 dark:bg-amber-900/30"},__={class:"text-lg font-semibold text-gray-900 dark:text-white"},w_={class:"mb-2 text-sm text-gray-600 dark:text-gray-400"},$_={class:"mb-6 text-xs text-amber-700 dark:text-amber-300"},C_={class:"flex justify-end gap-2"},S_=64,I_=ue({__name:"MemberList",props:{sessionId:{},showHeader:{type:Boolean,default:!0},chatType:{default:"group"}},emits:["data-changed"],setup(i,{emit:l}){const{t:e}=we(),n=Ke(),s=bt(),u=i,o=l,c=z([]),g=z(!1),h=z(!1),f=z(""),b=M(()=>Nn(u.chatType,c.value.length)),y=M(()=>u.chatType==="group"?"":b.value?"member-table-grid--private":"member-table-grid--private-without-selection"),k=z(null),x=z(!1),_=z(!1),C=z(!1),$=z(!1),I=z(!1),{sortState:T,toggleSort:v,resetSort:w,isSortActive:E}=Fn({initialState:{field:"messageCount",direction:"desc"}}),F=z(new Set);let D=0;function A(V,K){const L=K instanceof Error?K:new Error(String(K));console.error(V,L),jn(`${V} ${L.message}`,L.stack)}function S(V){return V.groupNickname||V.accountName||V.platformId}function q(V){return S(V).slice(0,1)}function Y(V){s.openChatRecordDrawer({sessionId:u.sessionId,memberId:V.id,memberName:S(V)})}const G=M(()=>Un(c.value,f.value,T.value)),{selectedIds:Z,setSelection:ce,clearSelection:ne,handleRowClick:H,handleRowMouseDown:W}=Rn({rows:G,getRowId:V=>V.id}),re=M(()=>c.value.filter(V=>Z.value.has(V.id))),ve=M(()=>re.value.length===2),fe=M(()=>re.value.reduce((V,K)=>V+K.messageCount,0));function ee(V,K,L){b.value&&H(V,K,L)}function te(V){b.value&&W(V)}const j=M(()=>{if(re.value.length!==2)return null;const[V,K]=re.value;return K.messageCount>V.messageCount||K.messageCount===V.messageCount&&K.id<V.id?{primary:K,secondary:V}:{primary:V,secondary:K}});function de(V,K){return E(V,K)?"text-primary-500 dark:text-primary-400":"text-gray-300 dark:text-gray-600"}const be=z(null),xe=Vn(M(()=>({count:G.value.length,getScrollElement:()=>be.value,estimateSize:()=>S_,overscan:8,getItemKey:V=>G.value[V]?.id??V}))),oe=M(()=>xe.value.getVirtualItems().map(V=>({virtualItem:V,member:G.value[V.index]}))),Q=M(()=>xe.value.getTotalSize());function J(V){V instanceof HTMLElement&&xe.value.measureElement(V)}async function ge(){await De(),be.value?.scrollTo({top:0}),xe.value.measure()}async function ke(){const V=u.sessionId;if(!V)return;const K=++D;g.value=!0,h.value=!1;try{const L=await n.getMembers(V);if(K!==D||V!==u.sessionId)return;c.value=L,await De(),xe.value.measure()}catch(L){K===D&&(h.value=!0),A("Failed to load member list:",L)}finally{K===D&&(g.value=!1)}}function $e(V,K){const L=new Set(F.value);K?L.add(V):L.delete(V),F.value=L}async function Le(V,K){const L=u.sessionId,P=JSON.parse(JSON.stringify(K)),N=JSON.stringify(V.aliases),ae=JSON.stringify(P);if(N!==ae){$e(V.id,!0);try{if(await n.updateMemberAliases(L,V.id,P)&&L===u.sessionId){const Ve=c.value.findIndex(qe=>qe.id===V.id);Ve!==-1&&(c.value[Ve]={...c.value[Ve],aliases:P},await De(),xe.value.measure())}}catch(se){A("Failed to save member aliases:",se)}finally{$e(V.id,!1)}}}function Be(V){k.value=V}function Te(){k.value=null}async function Pe(){if(k.value){x.value=!0;try{const V=k.value.id;if(await n.deleteMember(u.sessionId,V)){const L=new Set(Z.value);L.delete(V),ce(L),await ke(),o("data-changed")}}catch(V){A("Failed to delete member:",V)}finally{x.value=!1,k.value=null}}}function je(){Z.value.size!==0&&(_.value=!0)}async function Se(){const V=u.sessionId,K=Array.from(Z.value);if(K.length!==0){C.value=!0;try{await n.deleteMembers(V,K)&&V===u.sessionId&&(_.value=!1,ne(),await ke(),o("data-changed"))}catch(L){A("Failed to delete selected members:",L)}finally{C.value=!1}}}function me(){ve.value&&($.value=!0)}async function O(){if(j.value){I.value=!0;try{await n.mergeMembers(u.sessionId,j.value.primary.id,j.value.secondary.id)&&($.value=!1,ne(),await ke(),o("data-changed"))}catch(V){A("Failed to merge members:",V)}finally{I.value=!1}}}return he([f,T],ge),he(b,V=>{V||ne()}),he(()=>u.sessionId,()=>{D+=1,c.value=[],h.value=!1,F.value=new Set,f.value="",w(),ne(),ge(),ke()},{immediate:!0}),tt(()=>{D+=1}),(V,K)=>{const L=Ue,P=Bt,N=_e,ae=St,se=_a,Ve=Tk,qe=Xe;return r(),m("div",{class:X(["main-content",u.showHeader?"max-w-5xl p-6":"flex h-full max-w-none flex-col overflow-hidden p-4"])},[u.showHeader?(r(),m("div",Dk,[a("div",Ek,[a("div",null,[a("h2",Bk,d(t(e)(u.chatType==="private"?"members.private.title":"members.list.title")),1),a("p",Fk,d(t(e)(u.chatType==="private"?"members.private.description":"members.list.description",{count:c.value.length})),1)])])])):R("",!0),p(Lk,{class:"mb-6","session-id":i.sessionId,members:c.value,"chat-type":u.chatType},null,8,["session-id","members","chat-type"]),a("div",Rk,[p(P,{modelValue:f.value,"onUpdate:modelValue":K[1]||(K[1]=Me=>f.value=Me),placeholder:t(e)("members.list.searchPlaceholder"),icon:"i-heroicons-magnifying-glass",class:"w-full md:w-100"},On({_:2},[f.value?{name:"trailing",fn:B(()=>[p(L,{icon:"i-heroicons-x-mark",variant:"link",color:"neutral",size:"xs",onClick:K[0]||(K[0]=Me=>f.value="")})]),key:"0"}:void 0]),1032,["modelValue","placeholder"]),b.value?(r(),m("div",Vk,[g.value&&c.value.length>0?(r(),U(N,{key:0,name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin text-primary-500"})):R("",!0),a("span",Ok,d(t(e)("members.list.selectedCount",{count:t(Z).size})),1),p(L,{icon:"i-heroicons-link",size:"sm",color:"primary",disabled:!ve.value,onClick:me},{default:B(()=>[le(d(t(e)("members.list.mergeSelected")),1)]),_:1},8,["disabled"]),p(L,{icon:"i-heroicons-trash",size:"sm",color:"error",variant:"outline",disabled:t(Z).size===0,onClick:je},{default:B(()=>[le(d(t(e)("members.list.deleteSelected")),1)]),_:1},8,["disabled"])])):R("",!0)]),a("div",{class:X(["flex min-h-[240px] flex-col overflow-hidden rounded-lg border border-gray-200/60 bg-card-bg dark:border-white/5 dark:bg-card-dark",u.showHeader?"h-[500px]":"min-h-0 flex-1"])},[g.value&&c.value.length===0?(r(),m("div",Pk,[p(N,{name:"i-heroicons-arrow-path",class:"h-8 w-8 animate-spin text-primary-500"})])):h.value&&c.value.length===0?(r(),m("div",jk,[p(N,{name:"i-heroicons-exclamation-circle",class:"h-10 w-10 text-red-400"}),a("p",Nk,d(t(e)("members.list.loadError")),1),p(L,{size:"sm",variant:"outline",icon:"i-heroicons-arrow-path",onClick:ke},{default:B(()=>[le(d(t(e)("common.retry")),1)]),_:1})])):G.value.length===0?(r(),m("div",Uk,[p(N,{name:"i-heroicons-user-group",class:"mb-3 h-12 w-12 text-gray-300 dark:text-gray-600"}),a("p",Wk,d(f.value?t(e)("members.list.noMatch"):t(e)("members.list.empty")),1)])):(r(),m("div",Hk,[a("div",{class:X(["flex h-full flex-col",u.chatType==="private"?"min-w-[920px]":"min-w-[1120px]"])},[a("div",{class:X(["member-table-grid shrink-0 border-b border-gray-200 bg-gray-50 px-3 py-2 text-xs font-medium text-gray-500 dark:border-white/5 dark:bg-page-dark/80 dark:text-gray-400",y.value])},[b.value?(r(),m("span",Kk)):R("",!0),a("span",null,d(t(e)("members.list.table.accountName")),1),u.chatType==="group"?(r(),m("button",{key:1,type:"button",class:"flex items-center justify-start gap-1.5 text-left transition-colors hover:text-gray-700 dark:hover:text-gray-200",onClick:K[2]||(K[2]=Me=>t(v)("groupNickname"))},[le(d(t(e)("members.list.table.groupNickname"))+" ",1),a("span",Yk,[p(N,{name:"i-heroicons-chevron-up",class:X(["h-2.5 w-2.5",de("groupNickname","asc")])},null,8,["class"]),p(N,{name:"i-heroicons-chevron-down",class:X(["-mt-0.5 h-2.5 w-2.5",de("groupNickname","desc")])},null,8,["class"])])])):R("",!0),a("button",{type:"button",class:"flex items-center justify-end gap-1.5 text-right transition-colors hover:text-gray-700 dark:hover:text-gray-200",onClick:K[3]||(K[3]=Me=>t(v)("messageCount"))},[le(d(t(e)("members.list.table.messageCount"))+" ",1),a("span",Gk,[p(N,{name:"i-heroicons-chevron-up",class:X(["h-2.5 w-2.5",de("messageCount","asc")])},null,8,["class"]),p(N,{name:"i-heroicons-chevron-down",class:X(["-mt-0.5 h-2.5 w-2.5",de("messageCount","desc")])},null,8,["class"])])]),a("button",{type:"button",class:"flex items-center justify-end gap-1.5 text-right transition-colors hover:text-gray-700 dark:hover:text-gray-200",onClick:K[4]||(K[4]=Me=>t(v)("lastMessageTs"))},[le(d(t(e)("members.list.table.lastMessageTime"))+" ",1),a("span",Qk,[p(N,{name:"i-heroicons-chevron-up",class:X(["h-2.5 w-2.5",de("lastMessageTs","asc")])},null,8,["class"]),p(N,{name:"i-heroicons-chevron-down",class:X(["-mt-0.5 h-2.5 w-2.5",de("lastMessageTs","desc")])},null,8,["class"])])]),a("span",Jk,[a("span",null,d(t(e)("members.list.table.customAlias")),1),p(ae,{text:t(e)("members.list.tip"),popper:{placement:"top"}},{default:B(()=>[p(N,{name:"i-heroicons-question-mark-circle",class:"h-4 w-4 text-gray-400 dark:text-gray-500"})]),_:1},8,["text"])]),a("span",Xk,d(t(e)("members.list.table.actions")),1)],2),a("div",{ref_key:"listScrollRef",ref:be,class:"min-h-0 flex-1 overflow-y-auto"},[a("div",{class:"relative",style:et({height:`${Q.value}px`})},[(r(!0),m(ie,null,pe(oe.value,({virtualItem:Me,member:Fe})=>(r(),m("div",{key:String(Me.key),ref_for:!0,ref:J,"data-index":Me.index,class:X(["member-table-grid absolute left-0 top-0 w-full min-h-16 border-b border-gray-100/80 px-3 py-2 transition-colors hover:bg-gray-50 dark:border-white/5 dark:hover:bg-gray-800/30",[y.value,b.value?"cursor-pointer":"",b.value&&t(Z).has(Fe.id)?"bg-primary-50/70 dark:bg-primary-950/20":""]]),style:et({transform:`translateY(${Me.start}px)`}),onMousedown:te,onClick:st=>ee(Me.index,Fe.id,st)},[b.value?(r(),m("div",e_,[p(se,{"model-value":t(Z).has(Fe.id),onClick:Oe(st=>ee(Me.index,Fe.id,st),["stop"])},null,8,["model-value","onClick"])])):R("",!0),a("div",t_,[p(Pn,{src:Fe.avatar,alt:S(Fe),text:q(Fe),"fallback-class":["flex h-8 w-8 items-center justify-center rounded-full text-[10px] font-bold","bg-primary-500 text-white"]},null,8,["src","alt","text"]),a("div",a_,[a("p",{class:"truncate text-sm font-medium text-gray-900 dark:text-white",title:Fe.accountName||"-"},d(Fe.accountName||"-"),9,s_),a("p",{class:"truncate text-xs text-gray-400 dark:text-gray-500",title:Fe.platformId},d(Fe.platformId),9,n_)])]),u.chatType==="group"?(r(),m("p",{key:1,class:X(["truncate text-sm text-gray-700 dark:text-gray-300",Fe.groupNickname?"font-medium":"text-gray-400 dark:text-gray-500"]),title:Fe.groupNickname||"-"},d(Fe.groupNickname||"-"),11,o_)):R("",!0),a("span",l_,d(Fe.messageCount.toLocaleString()),1),a("span",{class:"text-right font-mono text-xs tabular-nums text-gray-600 dark:text-gray-400",title:Fe.lastMessageTs===null?"-":t(ja)(Fe.lastMessageTs)},d(Fe.lastMessageTs===null?"-":t(ja)(Fe.lastMessageTs)),9,r_),p(Ve,{"model-value":Fe.aliases,placeholder:t(e)("members.list.aliasPlaceholder"),loading:F.value.has(Fe.id),size:"xs",class:"w-full",onClick:K[5]||(K[5]=Oe(()=>{},["stop"])),"onUpdate:modelValue":st=>Le(Fe,st)},null,8,["model-value","placeholder","loading","onUpdate:modelValue"]),a("div",i_,[p(L,{icon:"i-heroicons-chat-bubble-left-ellipsis",size:"xs",color:"neutral",variant:"ghost",title:t(e)("common.viewChatRecords"),onClick:Oe(st=>Y(Fe),["stop"])},null,8,["title","onClick"]),p(L,{icon:"i-heroicons-trash",size:"xs",color:"error",variant:"ghost",title:t(e)("members.list.delete"),onClick:Oe(st=>Be(Fe),["stop"])},null,8,["title","onClick"])])],46,Zk))),128))],4)],512)],2)]))],2),p(qe,{open:!!k.value,ui:{content:"max-w-sm"},"onUpdate:open":K[6]||(K[6]=Me=>k.value=null)},{content:B(()=>[a("div",u_,[a("div",c_,[p(N,{name:"i-heroicons-exclamation-triangle",class:"h-7 w-7 text-red-500"})]),a("h3",d_,d(t(e)("members.list.modal.title")),1),a("p",m_,d(t(e)("members.list.modal.content",{name:k.value?S(k.value):"",count:k.value?.messageCount.toLocaleString()})),1),a("div",g_,[p(L,{variant:"outline",onClick:Te},{default:B(()=>[le(d(t(e)("members.list.modal.cancel")),1)]),_:1}),p(L,{color:"error",loading:x.value,onClick:Pe},{default:B(()=>[le(d(t(e)("members.list.modal.confirm")),1)]),_:1},8,["loading"])])])]),_:1},8,["open"]),p(qe,{open:_.value,ui:{content:"max-w-sm"},"onUpdate:open":K[8]||(K[8]=Me=>_.value=Me)},{content:B(()=>[a("div",p_,[a("div",h_,[p(N,{name:"i-heroicons-exclamation-triangle",class:"h-7 w-7 text-red-500"})]),a("h3",f_,d(t(e)("members.list.batchDeleteModal.title")),1),a("p",v_,d(t(e)("members.list.batchDeleteModal.content",{count:re.value.length,messageCount:fe.value.toLocaleString()})),1),a("div",y_,[p(L,{variant:"outline",disabled:C.value,onClick:K[7]||(K[7]=Me=>_.value=!1)},{default:B(()=>[le(d(t(e)("members.list.modal.cancel")),1)]),_:1},8,["disabled"]),p(L,{color:"error",loading:C.value,onClick:Se},{default:B(()=>[le(d(t(e)("members.list.modal.confirm")),1)]),_:1},8,["loading"])])])]),_:1},8,["open"]),p(qe,{open:$.value,ui:{content:"max-w-md"},"onUpdate:open":K[10]||(K[10]=Me=>$.value=Me)},{content:B(()=>[a("div",x_,[a("div",b_,[a("div",k_,[p(N,{name:"i-heroicons-link",class:"h-5 w-5 text-amber-600 dark:text-amber-400"})]),a("h3",__,d(t(e)("members.list.mergeModal.title")),1)]),a("p",w_,d(t(e)("members.list.mergeModal.content",{source:j.value?S(j.value.secondary):"",sourceCount:j.value?j.value.secondary.messageCount.toLocaleString():"0",target:j.value?S(j.value.primary):"",targetCount:j.value?j.value.primary.messageCount.toLocaleString():"0"})),1),a("p",$_,d(t(e)("members.list.mergeModal.hint")),1),a("div",C_,[p(L,{variant:"outline",disabled:I.value,onClick:K[9]||(K[9]=Me=>$.value=!1)},{default:B(()=>[le(d(t(e)("members.list.mergeModal.cancel")),1)]),_:1},8,["disabled"]),p(L,{color:"primary",loading:I.value,onClick:O},{default:B(()=>[le(d(t(e)("members.list.mergeModal.confirm")),1)]),_:1},8,["loading"])])])]),_:1},8,["open"])],2)}}}),t2=dt(I_,[["__scopeId","data-v-0754d30f"]]),T_={class:"mt-3 flex flex-col items-stretch gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3"},M_={class:"max-w-full overflow-x-auto scrollbar-hide"},a2=ue({__name:"SessionAnalysisHeader",props:qt({title:{},avatar:{},icon:{},iconClass:{},tabs:{},currentSessionId:{},initialTimeState:{},showSessionActions:{type:Boolean,default:!0}},{activeTab:{required:!0},activeTabModifiers:{},timeRangeValue:{required:!0},timeRangeValueModifiers:{}}),emits:qt(["openIncrementalImport","openMemberManagement","openChatRecord","update:fullRange","update:availableYears"],["update:activeTab","update:timeRangeValue"]),setup(i,{emit:l}){const e=Wt(i,"activeTab"),n=Wt(i,"timeRangeValue"),s=i,u=l,{t:o}=we(),c=bt(),g=M(()=>!["ai-chat","memory","lab","debug"].includes(e.value)),h=M(()=>s.tabs.map(f=>({id:f.id,label:o(f.labelKey),icon:f.icon})));return(f,b)=>{const y=Ue,k=St;return r(),U(no,{title:i.title,avatar:i.avatar,size:"compact",icon:i.icon,"icon-class":i.iconClass},{actions:B(()=>[i.showSessionActions&&t(c).toolsPanelPosition==="header"?(r(),m(ie,{key:0},[p(k,{text:t(o)("analysis.tooltip.viewChatRecord")},{default:B(()=>[p(y,{icon:"i-heroicons-chat-bubble-bottom-center-text",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:b[0]||(b[0]=x=>u("openChatRecord"))})]),_:1},8,["text"]),p(k,{text:t(o)("analysis.tooltip.incrementalImport")},{default:B(()=>[p(y,{icon:"i-heroicons-plus-circle",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:b[1]||(b[1]=x=>u("openIncrementalImport"))})]),_:1},8,["text"]),p(k,{text:t(o)("analysis.tooltip.memberManagement")},{default:B(()=>[p(y,{icon:"i-heroicons-user-group",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:b[2]||(b[2]=x=>u("openMemberManagement"))})]),_:1},8,["text"]),p(Lt,{color:"gray"}),p(k,{text:t(o)("analysis.tooltip.more")},{default:B(()=>[p(y,{"data-tools-panel-trigger":"",icon:"i-heroicons-ellipsis-horizontal",variant:"ghost",color:"gray",size:"sm",class:"hover:bg-gray-100 dark:hover:bg-gray-800",onClick:b[3]||(b[3]=x=>t(c).toggleToolsPanelOpen())})]),_:1},8,["text"])],64)):i.showSessionActions?(r(),U(Lt,{key:1,color:"gray"})):R("",!0)]),default:B(()=>[a("div",T_,[p(t(Wn),{modelValue:e.value,"onUpdate:modelValue":b[4]||(b[4]=x=>e.value=x),class:"min-w-0 shrink",items:h.value},null,8,["modelValue","items"]),a("div",M_,[p(so,{modelValue:n.value,"onUpdate:modelValue":b[5]||(b[5]=x=>n.value=x),"session-id":i.currentSessionId??void 0,visible:g.value,"initial-state":i.initialTimeState,size:"sm","onUpdate:fullRange":b[6]||(b[6]=x=>u("update:fullRange",x)),"onUpdate:availableYears":b[7]||(b[7]=x=>u("update:availableYears",x))},null,8,["modelValue","session-id","visible","initial-state"])])])]),_:1},8,["title","avatar","icon","icon-class"])}}}),A_={class:"space-y-4 p-5"},z_={class:"flex items-center gap-2"},q_={class:"text-base font-semibold text-gray-900 dark:text-white"},L_={key:0,class:"flex items-center gap-2 text-sm text-gray-400"},D_={class:"rounded-lg border border-gray-200 bg-gray-50 p-3 text-sm dark:border-gray-700 dark:bg-gray-800/50"},E_={class:"flex items-center justify-between"},B_={class:"text-gray-500"},F_={class:"font-medium text-gray-800 dark:text-gray-200"},R_={key:0,class:"mt-1 flex items-center justify-between"},V_={class:"text-gray-500"},O_={class:"text-gray-700 dark:text-gray-300"},P_={key:1,class:"mt-2"},j_={class:"flex items-center justify-between text-xs text-gray-500"},N_={class:"mt-1 h-1.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700"},U_={key:2,class:"mt-1 text-xs text-red-500"},W_={class:"text-sm text-gray-600 dark:text-gray-400"},H_={key:0,class:"rounded border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-700 dark:border-amber-800/50 dark:bg-amber-900/20 dark:text-amber-400"},K_={class:"flex justify-end gap-2"},Y_={class:"text-xs text-gray-400"},G_={class:"flex flex-wrap justify-end gap-2"},Ne="settings.ai.semanticIndex",s2=ue({__name:"SemanticIndexSessionModal",props:{modelValue:{type:Boolean},sessionId:{},messageCount:{}},emits:["update:modelValue"],setup(i,{emit:l}){const e=i,n=l,{t:s}=we(),u=Hn(),o=M({get:()=>e.modelValue,set:T=>n("update:modelValue",T)}),c=z(null),g=z(!1),h=z(!1),f=z(!1),b=M(()=>{const T=c.value;return!T||!T.enabled?s(`${Ne}.session.notEnabled`):T.needsRebuild?s(`${Ne}.state.needsRebuild`):T.running||T.queued||T.indexStatus==="running"?s(`${Ne}.state.building`):T.indexStatus==="completed"?s(`${Ne}.state.completed`):T.indexStatus==="failed"?s(`${Ne}.state.failed`):T.indexStatus==="paused"?s(`${Ne}.state.paused`):s(`${Ne}.state.pending`)}),y=M(()=>{const T=c.value;return!!T&&(T.running||T.queued||T.indexStatus==="running")}),k=M(()=>c.value&&c.value.totalMessages>0?Math.round(c.value.indexedMessages/c.value.totalMessages*100):0);let x=null;function _(){x&&(clearTimeout(x),x=null)}function C(){_(),x=setTimeout(async()=>{try{c.value=await u.status(e.sessionId)}catch(T){console.error("[semantic-index] poll status failed:",T)}y.value&&e.modelValue?C():_()},1500)}async function $(){h.value=!0;try{const[T,v]=await Promise.all([u.getConfig(),u.status(e.sessionId)]);g.value=T.config.enabled&&T.configured&&(T.config.mode==="local"?!!T.config.local.modelId:!!T.config.api?.baseUrl&&!!T.config.api?.model&&(!Kn(T.config.api?.baseUrl)||T.apiKeySet)),c.value=v}catch(T){console.error("[semantic-index] load session status failed:",T)}finally{h.value=!1}y.value&&C()}async function I(T){f.value=!0;try{c.value=await u[T](e.sessionId)}catch(v){console.error(`[semantic-index] ${T} failed:`,v)}finally{f.value=!1}y.value?C():_()}return he(()=>e.modelValue,T=>{T?$():_()}),tt(_),(T,v)=>{const w=_e,E=Ue,F=Xe;return r(),U(F,{open:o.value,"onUpdate:open":v[10]||(v[10]=D=>o.value=D),ui:{content:"z-[101]",overlay:"z-[100]"}},{content:B(()=>[a("div",A_,[a("div",z_,[p(w,{name:"i-heroicons-circle-stack",class:"h-5 w-5 text-blue-500"}),a("h3",q_,d(t(s)(`${Ne}.title`)),1)]),h.value?(r(),m("div",L_,[p(w,{name:"i-heroicons-arrow-path",class:"h-4 w-4 animate-spin"}),le(" "+d(t(s)("common.loading")),1)])):(r(),m(ie,{key:1},[a("div",D_,[a("div",E_,[a("span",B_,d(t(s)(`${Ne}.session.statusLabel`)),1),a("span",F_,d(b.value),1)]),c.value?.enabled&&c.value.indexStatus==="completed"?(r(),m("div",R_,[a("span",V_,d(t(s)(`${Ne}.session.coverageLabel`)),1),a("span",O_,d(k.value)+"%",1)])):R("",!0),y.value?(r(),m("div",P_,[a("div",j_,[a("span",null,d(t(s)(`${Ne}.session.progressLabel`)),1),a("span",null,d(c.value?.indexedMessages??0)+" / "+d(c.value?.totalMessages??0)+" ("+d(k.value)+"%) ",1)]),a("div",N_,[a("div",{class:"h-full rounded-full bg-blue-500 transition-all duration-500",style:et({width:`${k.value}%`})},null,4)])])):R("",!0),c.value?.error?(r(),m("p",U_,d(c.value.error),1)):R("",!0)]),c.value?.enabled?(r(),m(ie,{key:1},[a("p",Y_,d(t(s)(`${Ne}.session.buildVsEnable`)),1),a("div",G_,[y.value?(r(),m(ie,{key:0},[p(E,{variant:"soft",loading:f.value,onClick:v[2]||(v[2]=D=>I("pause"))},{default:B(()=>[le(d(t(s)(`${Ne}.action.pause`)),1)]),_:1},8,["loading"]),p(E,{color:"error",variant:"soft",disabled:f.value,onClick:v[3]||(v[3]=D=>I("cancel"))},{default:B(()=>[le(d(t(s)(`${Ne}.action.cancel`)),1)]),_:1},8,["disabled"])],64)):c.value?.indexStatus==="completed"&&!c.value?.needsRebuild?(r(),U(E,{key:1,variant:"soft",loading:f.value,onClick:v[4]||(v[4]=D=>I("rebuild"))},{default:B(()=>[le(d(t(s)(`${Ne}.action.rebuild`)),1)]),_:1},8,["loading"])):c.value?.needsRebuild?(r(),U(E,{key:2,color:"primary",loading:f.value,onClick:v[5]||(v[5]=D=>I("rebuild"))},{default:B(()=>[le(d(t(s)(`${Ne}.action.rebuild`)),1)]),_:1},8,["loading"])):c.value?.indexStatus==="failed"?(r(),U(E,{key:3,color:"primary",loading:f.value,onClick:v[6]||(v[6]=D=>I("build"))},{default:B(()=>[le(d(t(s)(`${Ne}.session.retry`)),1)]),_:1},8,["loading"])):c.value?.indexStatus==="paused"?(r(),U(E,{key:4,color:"primary",loading:f.value,onClick:v[7]||(v[7]=D=>I("build"))},{default:B(()=>[le(d(t(s)(`${Ne}.session.continue`)),1)]),_:1},8,["loading"])):(r(),U(E,{key:5,color:"primary",loading:f.value,onClick:v[8]||(v[8]=D=>I("build"))},{default:B(()=>[le(d(t(s)(`${Ne}.action.build`)),1)]),_:1},8,["loading"])),p(E,{variant:"ghost",color:"neutral",disabled:f.value,onClick:v[9]||(v[9]=D=>I("remove"))},{default:B(()=>[le(d(t(s)(`${Ne}.action.remove`)),1)]),_:1},8,["disabled"])])],64)):(r(),m(ie,{key:0},[a("p",W_,d(t(s)(`${Ne}.session.enableHint`)),1),g.value?R("",!0):(r(),m("p",H_,d(t(s)(`${Ne}.session.configFirst`)),1)),a("div",K_,[p(E,{variant:"ghost",onClick:v[0]||(v[0]=D=>o.value=!1)},{default:B(()=>[le(d(t(s)("common.close")),1)]),_:1}),p(E,{color:"primary",loading:f.value,disabled:!g.value,onClick:v[1]||(v[1]=D=>I("enable"))},{default:B(()=>[le(d(t(s)(`${Ne}.session.enable`)),1)]),_:1},8,["loading","disabled"])])],64))],64))])]),_:1},8,["open"])}}}),Q_={class:"min-h-[200px]"},J_={key:0,class:"space-y-4"},X_={class:"text-sm text-gray-600 dark:text-gray-400"},Z_={class:"text-sm text-gray-600 dark:text-gray-400"},ew={key:1,class:"flex flex-col items-center justify-center py-10"},tw={class:"text-gray-600 dark:text-gray-400"},aw={class:"mt-2 text-sm text-gray-500"},sw={key:2,class:"space-y-6"},nw={class:"rounded-lg bg-gray-50 p-4 dark:bg-gray-800"},ow={class:"mb-2 text-sm font-medium text-gray-700 dark:text-gray-300"},lw={class:"grid grid-cols-3 gap-4 text-center"},rw={class:"text-2xl font-bold text-gray-900 dark:text-white"},iw={class:"text-xs text-gray-500"},uw={class:"text-2xl font-bold text-green-600 dark:text-green-400"},cw={class:"text-xs text-gray-500"},dw={class:"text-2xl font-bold text-gray-400"},mw={class:"text-xs text-gray-500"},gw={key:0,class:"text-center text-sm text-amber-600 dark:text-amber-400"},pw={key:3,class:"flex flex-col items-center justify-center py-10"},hw={class:"text-gray-600 dark:text-gray-400"},fw={key:0,class:"mt-4 w-full max-w-xs"},vw={key:4,class:"flex flex-col items-center justify-center py-10"},yw={class:"text-lg font-medium text-gray-900 dark:text-white"},xw={class:"mt-2 text-sm text-gray-600 dark:text-gray-400"},bw={key:5,class:"flex flex-col items-center justify-center py-10"},kw={class:"text-lg font-medium text-gray-900 dark:text-white"},_w={class:"mt-2 text-sm text-red-600 dark:text-red-400"},ww={class:"flex w-full justify-end gap-2"},n2=ue({__name:"IncrementalImportModal",props:{modelValue:{type:Boolean},sessionId:{},sessionName:{}},emits:["update:modelValue","imported"],setup(i,{emit:l}){const e=i,n=l,{t:s}=we(),u=z("select"),o=z(null),c=z(null),g=z(null),h=z(null),f=z(null),b=z(null),y=M({get:()=>e.modelValue,set:w=>n("update:modelValue",w)});he(y,w=>{w||k()});function k(){u.value="select",o.value=null,g.value=null,h.value=null,f.value=null,b.value=null}async function x({files:w,paths:E}){if(w.length>0)o.value={source:w[0],name:w[0].name};else{f.value=s("home.import.cannotReadPath");return}await C()}function _(){c.value?.openFileDialog()}async function C(){if(o.value){u.value="analyzing",f.value=null;try{const w=await Pa().analyzeIncrementalImport(e.sessionId,o.value.source);if(w.error){u.value="error",f.value=v(w.error);return}g.value={newMessageCount:w.newMessageCount,duplicateCount:w.duplicateCount,totalInFile:w.totalInFile},u.value="preview"}catch(w){u.value="error",f.value=String(w)}}}async function $(){if(o.value){u.value="importing",h.value={stage:"saving",progress:0,message:""};try{const w=await Pa().incrementalImport(e.sessionId,o.value.source,E=>{h.value=E});w.success?(b.value={newMessageCount:w.newMessageCount},u.value="done"):(u.value="error",f.value=v(w.error||"error.import_failed"))}catch(w){u.value="error",f.value=String(w)}}}function I(){b.value&&n("imported",b.value.newMessageCount),y.value=!1}function T(){u.value="select",o.value=null,g.value=null,f.value=null}function v(w){if(w.startsWith("error.")){const E=`home.import.errors.${w.slice(6)}`,F=s(E);return F!==E?F:w}return w}return(w,E)=>{const F=Yn,D=_e,A=Gn,S=Ue,q=Xe;return r(),U(q,{open:y.value,"onUpdate:open":E[1]||(E[1]=Y=>y.value=Y),title:t(s)("analysis.incremental.title")},{body:B(()=>[a("div",Q_,[u.value==="select"?(r(),m("div",J_,[a("p",X_,d(t(s)("analysis.incremental.description",{name:i.sessionName})),1),p(F,{color:"info",variant:"soft",icon:"i-heroicons-information-circle",description:t(s)("analysis.incremental.homeAutoImportHint")},null,8,["description"]),p(t(Qn),{ref_key:"dropZoneRef",ref:c,accept:[".json",".jsonl",".txt"],class:"w-full",onFiles:x},{default:B(({isDragOver:Y})=>[a("div",{class:X(["flex cursor-pointer flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 py-10 transition-colors",Y?"border-pink-500 bg-pink-50/50 dark:border-pink-400 dark:bg-pink-500/10":"border-gray-300 hover:border-pink-400 dark:border-gray-600 dark:hover:border-pink-500"]),onClick:Oe(_,["stop"])},[p(D,{name:"i-heroicons-arrow-up-tray",class:"mb-3 h-10 w-10 text-gray-400"}),a("p",Z_,d(Y?t(s)("home.import.dropHint"):t(s)("analysis.incremental.dropHint")),1)],2)]),_:1},512)])):u.value==="analyzing"?(r(),m("div",ew,[p(D,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),a("p",tw,d(t(s)("analysis.incremental.analyzing")),1),a("p",aw,d(o.value?.name),1)])):u.value==="preview"&&g.value?(r(),m("div",sw,[a("div",nw,[a("p",ow,d(o.value?.name),1),a("div",lw,[a("div",null,[a("p",rw,d(g.value.totalInFile.toLocaleString()),1),a("p",iw,d(t(s)("analysis.incremental.totalInFile")),1)]),a("div",null,[a("p",uw,d(g.value.newMessageCount.toLocaleString()),1),a("p",cw,d(t(s)("analysis.incremental.newMessages")),1)]),a("div",null,[a("p",dw,d(g.value.duplicateCount.toLocaleString()),1),a("p",mw,d(t(s)("analysis.incremental.duplicates")),1)])])]),g.value.newMessageCount===0?(r(),m("p",gw,[p(D,{name:"i-heroicons-exclamation-triangle",class:"mr-1 inline-block h-4 w-4"}),le(" "+d(t(s)("analysis.incremental.noNewMessages")),1)])):R("",!0)])):u.value==="importing"?(r(),m("div",pw,[p(D,{name:"i-heroicons-arrow-path",class:"mb-4 h-10 w-10 animate-spin text-pink-500"}),a("p",hw,d(t(s)("analysis.incremental.importing")),1),h.value?(r(),m("div",fw,[p(A,{value:h.value.progress,size:"sm"},null,8,["value"])])):R("",!0)])):u.value==="done"&&b.value?(r(),m("div",vw,[p(D,{name:"i-heroicons-check-circle",class:"mb-4 h-12 w-12 text-green-500"}),a("p",yw,d(t(s)("analysis.incremental.success")),1),a("p",xw,d(t(s)("analysis.incremental.successDetail",{count:b.value.newMessageCount})),1)])):u.value==="error"?(r(),m("div",bw,[p(D,{name:"i-heroicons-x-circle",class:"mb-4 h-12 w-12 text-red-500"}),a("p",kw,d(t(s)("analysis.incremental.failed")),1),a("p",_w,d(f.value),1)])):R("",!0)])]),footer:B(()=>[a("div",ww,[u.value==="select"?(r(),U(S,{key:0,color:"neutral",variant:"ghost",onClick:E[0]||(E[0]=Y=>y.value=!1)},{default:B(()=>[le(d(t(s)("common.cancel")),1)]),_:1})):u.value==="preview"?(r(),m(ie,{key:1},[p(S,{color:"neutral",variant:"ghost",onClick:T},{default:B(()=>[le(d(t(s)("common.back")),1)]),_:1}),p(S,{color:"primary",disabled:!g.value||g.value.newMessageCount===0,onClick:$},{default:B(()=>[le(d(t(s)("analysis.incremental.import",{count:g.value?.newMessageCount||0})),1)]),_:1},8,["disabled"])],64)):u.value==="done"||u.value==="error"?(r(),m(ie,{key:2},[u.value==="error"?(r(),U(S,{key:0,color:"neutral",variant:"ghost",onClick:T},{default:B(()=>[le(d(t(s)("common.retry")),1)]),_:1})):R("",!0),p(S,{color:"primary",onClick:I},{default:B(()=>[le(d(t(s)("common.done")),1)]),_:1})],64)):R("",!0)])]),_:1},8,["open","title"])}}}),$w={key:0,class:"fixed right-0 top-1/3"},Cw={class:"no-capture flex flex-col items-center gap-0.5 rounded-l-lg border border-r-0 border-gray-200/60 bg-white py-1.5 shadow-sm dark:border-white/5 dark:bg-page-dark"},Sw=["onClick"],Iw={class:"mb-2 flex items-center justify-between"},Tw={class:"px-0.5 text-[9px] font-bold uppercase tracking-widest text-gray-400 dark:text-gray-500"},Mw={class:"flex flex-col gap-1.5"},Aw=["onClick"],zw={class:"whitespace-nowrap"},o2=ue({__name:"ActionToolsPanel",emits:["openIncrementalImport","openSemanticIndex","openMemberManagement","openChatRecord","openMessageExport"],setup(i,{emit:l}){const{t:e}=we(),n=bt(),{isToolsPanelMini:s,toolsPanelPosition:u,isToolsPanelOpen:o}=ut(n),c=M(()=>u.value==="header"),g=M(()=>!c.value||o.value),h=z(null),f=l;function b(C){f(C),c.value&&(o.value=!1)}function y(C){if(!c.value||!o.value)return;const $=C.target;$ instanceof Element&&(h.value?.contains($)||$.closest("[data-tools-panel-trigger]")||(o.value=!1))}const k=[{event:"openIncrementalImport",icon:"i-heroicons-plus-circle",hoverColor:"group-hover:text-pink-500",miniHoverBg:"hover:text-pink-500",labelKey:"analysis.tooltip.incrementalImport"},{event:"openSemanticIndex",icon:"i-heroicons-circle-stack",hoverColor:"group-hover:text-indigo-500",miniHoverBg:"hover:text-indigo-500",labelKey:"analysis.tooltip.semanticIndex"},{event:"openMemberManagement",icon:"i-heroicons-user-group",hoverColor:"group-hover:text-purple-500",miniHoverBg:"hover:text-purple-500",labelKey:"analysis.tooltip.memberManagement"},{event:"openChatRecord",icon:"i-heroicons-chat-bubble-bottom-center-text",hoverColor:"group-hover:text-cyan-500",miniHoverBg:"hover:text-cyan-500",labelKey:"analysis.tooltip.viewChatRecord"},{event:"openMessageExport",icon:"i-heroicons-document-arrow-down",hoverColor:"group-hover:text-green-500",miniHoverBg:"hover:text-green-500",labelKey:"analysis.messageExport.title"}],x=[{event:"openSemanticIndex",icon:"i-heroicons-circle-stack",hoverColor:"group-hover:text-indigo-500",miniHoverBg:"hover:text-indigo-500",labelKey:"analysis.tooltip.semanticIndex"},{event:"openMessageExport",icon:"i-heroicons-document-arrow-down",hoverColor:"group-hover:text-green-500",miniHoverBg:"hover:text-green-500",labelKey:"analysis.messageExport.title"}],_=M(()=>c.value?x:k);return he(u,()=>{o.value=!1}),Re(()=>{document.addEventListener("mousedown",y)}),Xt(()=>{document.removeEventListener("mousedown",y)}),(C,$)=>{const I=_e,T=St;return!c.value&&t(s)?(r(),m("div",$w,[a("div",Cw,[(r(),m(ie,null,pe(k,v=>p(T,{key:v.event,text:t(e)(v.labelKey),popper:{placement:"left"}},{default:B(()=>[a("button",{class:X(["flex h-7 w-7 items-center justify-center rounded-md text-gray-400 transition-colors hover:bg-gray-100 dark:text-gray-500 dark:hover:bg-white/5",v.miniHoverBg]),onClick:w=>b(v.event)},[p(I,{name:v.icon,class:"h-3.5 w-3.5"},null,8,["name"])],10,Sw)]),_:2},1032,["text"])),64)),$[2]||($[2]=a("div",{class:"my-0.5 h-px w-4 bg-gray-200 dark:bg-gray-700"},null,-1)),p(T,{text:t(e)("analysis.toolsPanel.exitMini"),popper:{placement:"left"}},{default:B(()=>[a("button",{class:"flex h-7 w-7 items-center justify-center rounded-md text-gray-300 transition-colors hover:bg-gray-100 hover:text-gray-500 dark:text-gray-600 dark:hover:bg-white/5 dark:hover:text-gray-400",onClick:$[0]||($[0]=v=>t(n).toggleToolsPanelMini())},[p(I,{name:"i-heroicons-arrows-pointing-out",class:"h-3 w-3"})])]),_:1},8,["text"])])])):(r(),m("div",{key:1,class:X(["fixed right-0 z-40",c.value?"top-14":"top-1/3"])},[a("div",{class:X(["absolute right-0 top-0 transition-all duration-250 ease-in-out",g.value?"translate-x-0 opacity-100":"pointer-events-none translate-x-full opacity-0"])},[a("div",{ref_key:"panelRef",ref:h,class:"no-capture flex w-40 flex-col rounded-l-xl border border-r-0 border-gray-200/60 bg-white p-3 shadow-overlay dark:border-white/5 dark:bg-page-dark"},[a("div",Iw,[a("span",Tw,d(t(e)("analysis.overview.tools")),1),c.value?R("",!0):(r(),U(T,{key:0,text:t(e)("analysis.toolsPanel.miniMode"),popper:{placement:"left"}},{default:B(()=>[a("button",{class:"flex h-5 w-5 items-center justify-center rounded text-gray-300 transition-colors hover:text-gray-500 dark:text-gray-600 dark:hover:text-gray-400",onClick:$[1]||($[1]=v=>t(n).toggleToolsPanelMini())},[p(I,{name:"i-heroicons-arrows-pointing-in",class:"h-3 w-3"})])]),_:1},8,["text"]))]),a("div",Mw,[(r(!0),m(ie,null,pe(_.value,v=>(r(),m("button",{key:v.event,class:"group flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs font-medium text-gray-600 transition-all hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-white/5 dark:hover:text-white",onClick:w=>b(v.event)},[p(I,{name:v.icon,class:X(["h-3.5 w-3.5 text-gray-400 transition-colors dark:text-gray-500",v.hoverColor])},null,8,["name","class"]),a("span",zw,d(t(e)(v.labelKey)),1)],8,Aw))),128))])],512)],2)],2))}}});export{Yw as C,Kw as D,Ww as L,t2 as M,na as _,Uw as a,Ze as b,Zw as c,ya as d,e2 as e,zv as f,Gw as g,Qw as h,Jw as i,Nw as j,a2 as k,o2 as l,s2 as m,n2 as n,Hw as o,Xw as u};
|