ConversationHistory-aVM2enA8.js 21 KB

1
  1. import{c as H,o as $,a as b,I as V,f as C,e as B,m as dt,p as j,l as wt,C as I,A as Ht,a0 as Ct,b as _t,F as nt,H as lt,Y as yt,q as Q,L as Lt,v as gt,z as U,W as it,X as Yt}from"./vue-vendor-BKZgKMlr.js";import Tt from"./LayoutExperience-F6JBNiZj.js";import xt from"./ContentContainer-CoWbFZ9e.js";import{C as It}from"./ChatAsideMenu-DdilBSR1.js";/* empty css */import{R as Ot}from"./index-DwHXRCZX.js";/* empty css */import{S as $t}from"./index-Ki3dYdWD.js";import{_ as Z}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{h as At,E as ft,F as Nt,J as Mt,u as jt,M as zt,K as Et,L as Dt,N as Bt,B as Wt,O as Vt}from"./index-c7QdmXCD.js";/* empty css */import"./index-DRL4jHRa.js";import{M as ht}from"./index-BqWUlG-6.js";import"./index-CV1LzsAf.js";/* empty css *//* empty css */import{a as Ft}from"./api-conversation-board-DPLxvjRA.js";import{u as Rt}from"./use-all-agents-BguU-i5q.js";import{g as mt}from"./icon-map-MpRwWyE4.js";import{D as Ut,a as qt,E as Jt}from"./index-CMTWEm0A.js";import"./Header-D49gJLpB.js";import"./index-Ck4rsyxx.js";import"./use-logout-Cf2TtQAi.js";import"./use-current-user-iC2jqqSz.js";import"./login-DJL8pM86.js";/* empty css */import"./index-rsafArUu.js";import"./index-Dud6YwRX.js";var St={exports:{}};(function(s,l){(function(a,o){s.exports=o()})(ft,function(){var a=1e3,o=6e4,v=36e5,M="millisecond",d="second",m="minute",u="hour",i="day",g="week",D="month",k="quarter",f="year",L="date",x="Invalid Date",X=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,F=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,q={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(c){var n=["th","st","nd","rd"],t=c%100;return"["+c+(n[(t-20)%10]||n[t]||n[0])+"]"}},W=function(c,n,t){var r=String(c);return!r||r.length>=n?c:""+Array(n+1-r.length).join(t)+c},tt={s:W,z:function(c){var n=-c.utcOffset(),t=Math.abs(n),r=Math.floor(t/60),e=t%60;return(n<=0?"+":"-")+W(r,2,"0")+":"+W(e,2,"0")},m:function c(n,t){if(n.date()<t.date())return-c(t,n);var r=12*(t.year()-n.year())+(t.month()-n.month()),e=n.clone().add(r,D),_=t-e<0,h=n.clone().add(r+(_?-1:1),D);return+(-(r+(t-e)/(_?e-h:h-e))||0)},a:function(c){return c<0?Math.ceil(c)||0:Math.floor(c)},p:function(c){return{M:D,y:f,w:g,d:i,D:L,h:u,m,s:d,ms:M,Q:k}[c]||String(c||"").toLowerCase().replace(/s$/,"")},u:function(c){return c===void 0}},J="en",R={};R[J]=q;var ct="$isDayjsObject",ot=function(c){return c instanceof z||!(!c||!c[ct])},Y=function c(n,t,r){var e;if(!n)return J;if(typeof n=="string"){var _=n.toLowerCase();R[_]&&(e=_),t&&(R[_]=t,e=_);var h=n.split("-");if(!e&&h.length>1)return c(h[0])}else{var S=n.name;R[S]=n,e=S}return!r&&e&&(J=e),e||!r&&J},y=function(c,n){if(ot(c))return c.clone();var t=typeof n=="object"?n:{};return t.date=c,t.args=arguments,new z(t)},p=tt;p.l=Y,p.i=ot,p.w=function(c,n){return y(c,{locale:n.$L,utc:n.$u,x:n.$x,$offset:n.$offset})};var z=function(){function c(t){this.$L=Y(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[ct]=!0}var n=c.prototype;return n.parse=function(t){this.$d=function(r){var e=r.date,_=r.utc;if(e===null)return new Date(NaN);if(p.u(e))return new Date;if(e instanceof Date)return new Date(e);if(typeof e=="string"&&!/Z$/i.test(e)){var h=e.match(X);if(h){var S=h[2]-1||0,w=(h[7]||"0").substring(0,3);return _?new Date(Date.UTC(h[1],S,h[3]||1,h[4]||0,h[5]||0,h[6]||0,w)):new Date(h[1],S,h[3]||1,h[4]||0,h[5]||0,h[6]||0,w)}}return new Date(e)}(t),this.init()},n.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},n.$utils=function(){return p},n.isValid=function(){return this.$d.toString()!==x},n.isSame=function(t,r){var e=y(t);return this.startOf(r)<=e&&e<=this.endOf(r)},n.isAfter=function(t,r){return y(t)<this.startOf(r)},n.isBefore=function(t,r){return this.endOf(r)<y(t)},n.$g=function(t,r,e){return p.u(t)?this[r]:this.set(e,t)},n.unix=function(){return Math.floor(this.valueOf()/1e3)},n.valueOf=function(){return this.$d.getTime()},n.startOf=function(t,r){var e=this,_=!!p.u(r)||r,h=p.p(t),S=function(G,N){var P=p.w(e.$u?Date.UTC(e.$y,N,G):new Date(e.$y,N,G),e);return _?P:P.endOf(i)},w=function(G,N){return p.w(e.toDate()[G].apply(e.toDate("s"),(_?[0,0,0,0]:[23,59,59,999]).slice(N)),e)},T=this.$W,A=this.$M,E=this.$D,et="set"+(this.$u?"UTC":"");switch(h){case f:return _?S(1,0):S(31,11);case D:return _?S(1,A):S(0,A+1);case g:var K=this.$locale().weekStart||0,rt=(T<K?T+7:T)-K;return S(_?E-rt:E+(6-rt),A);case i:case L:return w(et+"Hours",0);case u:return w(et+"Minutes",1);case m:return w(et+"Seconds",2);case d:return w(et+"Milliseconds",3);default:return this.clone()}},n.endOf=function(t){return this.startOf(t,!1)},n.$set=function(t,r){var e,_=p.p(t),h="set"+(this.$u?"UTC":""),S=(e={},e[i]=h+"Date",e[L]=h+"Date",e[D]=h+"Month",e[f]=h+"FullYear",e[u]=h+"Hours",e[m]=h+"Minutes",e[d]=h+"Seconds",e[M]=h+"Milliseconds",e)[_],w=_===i?this.$D+(r-this.$W):r;if(_===D||_===f){var T=this.clone().set(L,1);T.$d[S](w),T.init(),this.$d=T.set(L,Math.min(this.$D,T.daysInMonth())).$d}else S&&this.$d[S](w);return this.init(),this},n.set=function(t,r){return this.clone().$set(t,r)},n.get=function(t){return this[p.p(t)]()},n.add=function(t,r){var e,_=this;t=Number(t);var h=p.p(r),S=function(A){var E=y(_);return p.w(E.date(E.date()+Math.round(A*t)),_)};if(h===D)return this.set(D,this.$M+t);if(h===f)return this.set(f,this.$y+t);if(h===i)return S(1);if(h===g)return S(7);var w=(e={},e[m]=o,e[u]=v,e[d]=a,e)[h]||1,T=this.$d.getTime()+t*w;return p.w(T,this)},n.subtract=function(t,r){return this.add(-1*t,r)},n.format=function(t){var r=this,e=this.$locale();if(!this.isValid())return e.invalidDate||x;var _=t||"YYYY-MM-DDTHH:mm:ssZ",h=p.z(this),S=this.$H,w=this.$m,T=this.$M,A=e.weekdays,E=e.months,et=e.meridiem,K=function(N,P,at,ut){return N&&(N[P]||N(r,_))||at[P].slice(0,ut)},rt=function(N){return p.s(S%12||12,N,"0")},G=et||function(N,P,at){var ut=N<12?"AM":"PM";return at?ut.toLowerCase():ut};return _.replace(F,function(N,P){return P||function(at){switch(at){case"YY":return String(r.$y).slice(-2);case"YYYY":return p.s(r.$y,4,"0");case"M":return T+1;case"MM":return p.s(T+1,2,"0");case"MMM":return K(e.monthsShort,T,E,3);case"MMMM":return K(E,T);case"D":return r.$D;case"DD":return p.s(r.$D,2,"0");case"d":return String(r.$W);case"dd":return K(e.weekdaysMin,r.$W,A,2);case"ddd":return K(e.weekdaysShort,r.$W,A,3);case"dddd":return A[r.$W];case"H":return String(S);case"HH":return p.s(S,2,"0");case"h":return rt(1);case"hh":return rt(2);case"a":return G(S,w,!0);case"A":return G(S,w,!1);case"m":return String(w);case"mm":return p.s(w,2,"0");case"s":return String(r.$s);case"ss":return p.s(r.$s,2,"0");case"SSS":return p.s(r.$ms,3,"0");case"Z":return h}return null}(N)||h.replace(":","")})},n.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},n.diff=function(t,r,e){var _,h=this,S=p.p(r),w=y(t),T=(w.utcOffset()-this.utcOffset())*o,A=this-w,E=function(){return p.m(h,w)};switch(S){case f:_=E()/12;break;case D:_=E();break;case k:_=E()/3;break;case g:_=(A-T)/6048e5;break;case i:_=(A-T)/864e5;break;case u:_=A/v;break;case m:_=A/o;break;case d:_=A/a;break;default:_=A}return e?_:p.a(_)},n.daysInMonth=function(){return this.endOf(D).$D},n.$locale=function(){return R[this.$L]},n.locale=function(t,r){if(!t)return this.$L;var e=this.clone(),_=Y(t,r,!0);return _&&(e.$L=_),e},n.clone=function(){return p.w(this.$d,this)},n.toDate=function(){return new Date(this.valueOf())},n.toJSON=function(){return this.isValid()?this.toISOString():null},n.toISOString=function(){return this.$d.toISOString()},n.toString=function(){return this.$d.toUTCString()},c}(),O=z.prototype;return y.prototype=O,[["$ms",M],["$s",d],["$m",m],["$H",u],["$W",i],["$M",D],["$y",f],["$D",L]].forEach(function(c){O[c[1]]=function(n){return this.$g(n,c[0],c[1])}}),y.extend=function(c,n){return c.$i||(c(n,z,y),c.$i=!0),y},y.locale=Y,y.isDayjs=ot,y.unix=function(c){return y(1e3*c)},y.en=R[J],y.Ls=R,y.p={},y})})(St);var kt=St.exports;const st=At(kt);var Pt={exports:{}};(function(s,l){(function(a,o){s.exports=o(kt)})(ft,function(a){function o(d){return d&&typeof d=="object"&&"default"in d?d:{default:d}}var v=o(a),M={name:"zh-cn",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(d,m){return m==="W"?d+"周":d+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s内",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(d,m){var u=100*d+m;return u<600?"凌晨":u<900?"早上":u<1100?"上午":u<1300?"中午":u<1800?"下午":"晚上"}};return v.default.locale(M,null,!0),M})})(Pt);const Zt={},Kt={class:"conversation-history-title"};function Gt(s,l){return $(),H("div",Kt,[b("div",null,V(s.$t("conversation.chat_history")),1)])}const Qt=Z(Zt,[["render",Gt],["__scopeId","data-v-eacdf319"]]),Xt={class:"conversation-search-input"},te={class:"search-input-content"},ee={class:"search-input-icon icon-search"},ne={class:"search-input-container"},se=["placeholder"],oe={__name:"HistorySearchInput",emits:["search"],setup(s,{emit:l}){const a=l,o=C(""),v=B(()=>o.value.length!==0),M=i=>{o.value=i.target.value},d=i=>{o.value=i.target.value},m=i=>{i.keyCode===13&&a("search",o.value)},u=()=>{o.value="",a("search",o.value)};return(i,g)=>{const D=dt("icon-search"),k=dt("icon-close");return $(),H("div",Xt,[b("div",te,[b("div",ee,[I(D)]),b("div",ne,[Ht(b("input",{type:"text",class:"search-input",placeholder:i.$t("conversation.search_history"),"onUpdate:modelValue":g[0]||(g[0]=f=>o.value=f),onInput:M,onChange:d,onKeyup:m},null,40,se),[[Ct,o.value]])]),v.value?($(),H("div",{key:0,class:"search-input-icon icon-clear",onClick:u},[I(k)])):j("",!0),wt(i.$slots,"default",{},void 0,!0)])])}}},re=Z(oe,[["__scopeId","data-v-f3dff79d"]]);var ae={exports:{}};(function(s,l){(function(a,o){s.exports=o()})(ft,function(){return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(a){var o=["th","st","nd","rd"],v=a%100;return"["+a+(o[(v-20)%10]||o[v]||o[0])+"]"}}})})(ae);const ie=1e3*60,ce=ie*60,bt=ce*24,ue=bt*30,le=()=>{const s=new Date;return s.setHours(0,0,0,0),s.getTime()},de=(s,l)=>{if(!l)return st(s).format("HH:mm");if(l==="zh")return st(s).locale("zh-cn").format("HH:mm");if(l==="en")return st(s).format("HH:mm")},pt=(s,l)=>l&&l==="zh"?st(s).locale("zh-cn").format("MM-DD"):st(s).format("MM-DD"),_e=s=>{const l=s.agent_id;if(!l)return Promise.reject(new Error("前端异常:Invalid Agent ID"));const a=`/api/agent/${l}/sessions`,o={};return"per_page"in s&&(o.limit=s.per_page/1),"page"in s&&(o.page=s.page/1),"search"in s&&s.search&&(o.keyword=s.search),Nt({url:a,method:"get",params:o})},he=s=>(Mt({conversation_ids:[s]}),new Promise((a,o)=>{setTimeout(()=>{a({code:200,data:!0,msg:""})},1e3)})),me={__name:"BtnHistoryItemDelete",props:{target_id:String},emits:["deleteSuccess"],setup(s,{emit:l}){const a=s,o=l,v=jt();C(1),C("");const M=()=>{const m=v.t("conversation.are_you_sure");v.t("conversation.btn_yes"),v.t("conversation.btn_no"),zt.warning({title:m,hideCancel:!1,"modal-class":"history-chat-remove-modal",onOk(u){},async onBeforeOk(){try{return await d()===200}catch{return!1}},onCancel(){}})},d=()=>new Promise((m,u)=>{he(a.target_id).then(i=>{if(i.code/1===200){const g=v.t("conversation.del_success");ht.success(g),o("deleteSuccess"),m(200)}else ht.warning(i.msg)}).catch(i=>{ht.warning(i.msg),u(i)})});return(m,u)=>{const i=dt("icon-delete");return $(),H("span",{onClick:M,class:"btn-delete"},[I(i)])}}},fe=Z(me,[["__scopeId","data-v-6d4c8119"]]),pe=["src"],ve={class:"history-item-intro"},ye={class:"history-item-actions"},ge={class:"history-item-time"},$e={class:"history-item-delete"},Me={__name:"HistoryItem",props:{history:Object,index:Number,agent_icon:String},emits:["active","delete"],setup(s,{emit:l}){const a=s,o=l,v=C(!1),M=Et(),d=B(()=>a.history.client_field_content_type==="label"),m=B(()=>a.history.client_field_content_type==="content"),u=B(()=>m.value&&!v.value),i=B(()=>{const f={"conversation-history-item":!0};return f[`item-${a.index}`]=!0,f[`item-${a.history.id}`]=!0,f[a.history.client_field_timestamp_type]=!0,d.value&&(f["conversation-history-section-title"]=!0),m.value&&(f["conversation-history-section-data"]=!0),f}),g=B(()=>{const f=a.history.client_field_timestamp_type,L=a.history.create_time,x=M.value;return f==="today"?de(L,x):f==="month"||f==="earlier"?pt(L,x):""}),D=()=>{o("active",a.history.id)},k=()=>{v.value=!0};return(f,L)=>($(),H(nt,null,[d.value?($(),H("div",{key:0,class:_t([i.value,"history-block-title"])},[s.history.client_field_timestamp_type==="today"?($(),H(nt,{key:0},[lt(V(f.$t("conversation.history_today")),1)],64)):j("",!0),s.history.client_field_timestamp_type==="month"?($(),H(nt,{key:1},[lt(V(f.$t("conversation.history_month")),1)],64)):j("",!0),s.history.client_field_timestamp_type==="earlier"?($(),H(nt,{key:2},[lt(V(f.$t("conversation.history_earlier")),1)],64)):j("",!0)],2)):j("",!0),u.value?($(),H("div",{key:1,class:_t(i.value)},[b("div",{class:"history-item-icon",onClick:D},[b("img",{src:s.agent_icon},null,8,pe)]),b("div",ve,[b("div",{class:"history-item-intro-title",onClick:D},V(s.history.name),1)]),b("div",ye,[b("span",ge,V(g.value),1),b("span",$e,[I(fe,{target_id:s.history.id,onDeleteSuccess:k},null,8,["target_id"])])])],2)):j("",!0)],64))}},De=Z(Me,[["__scopeId","data-v-f032bf4d"]]),Se={key:0,class:"history-item-icon can-loadmore"},ke={__name:"HistoryLoadMore",props:{can_loadmore:Boolean},emits:["loadmore"],setup(s,{emit:l}){const a=s,o=l,v=B(()=>{const d={"conversation-history-item":!0};return d["load-more"]=!0,d}),M=()=>{a.can_loadmore&&o("loadmore")};return(d,m)=>($(),H("div",{class:_t(v.value),onClick:M},[s.can_loadmore?($(),H("div",Se,V(d.$t("conversation.history_loadmore")),1)):j("",!0)],2))}},be=Z(ke,[["__scopeId","data-v-01b3fb14"]]),we={class:"conversation-history-list-section"},He={__name:"HistoryList",props:{list:Array,can_loadmore:Boolean,agent_icon:String},emits:["active","delete","loadmore"],setup(s,{emit:l}){const a=l,o=B(()=>"conversation-history-list"),v=m=>{a("active",m)},M=m=>{a("delete",m)},d=()=>{a("loadmore")};return(m,u)=>($(),H("div",we,[b("div",{class:_t(o.value)},[($(!0),H(nt,null,yt(s.list,(i,g)=>($(),Q(De,{key:i.id,history:i,index:g,agent_icon:s.agent_icon,onActive:v,onDelete:M},null,8,["history","index","agent_icon"]))),128)),I(be,{can_loadmore:s.can_loadmore,onLoadmore:d},null,8,["can_loadmore"])],2)]))}},Ce=Z(He,[["__scopeId","data-v-4bed9682"]]);function Le(s){const l=C(1),a=C(""),o=C([]),v=Rt(),M=()=>({});return{getAgentList:()=>{const m=v.agents;if(m.length!==0){typeof s=="function"&&s(m),o.value=m;return}const u=M();l.value=2,a.value="",Ft(u).then(i=>{if(i.code/1===200){const g=i.data;g.length!==0&&typeof s=="function"&&s(g),o.value=g,v.setList(g),l.value=3,a.value="success"}else l.value=4,a.value=err.message}).catch(i=>{console.log(i),l.value=5,a.value=i.msg})},api_status:l,api_message:a,list_agents:o}}function Ye(s){const l=Mt(s);Dt.setItem(l)}function vt(){const s=Dt.getItem(),l=Bt(s);return l===null?null:l}const Te=Lt("recent_history_search_type",{state:()=>({search_type:vt()}),actions:{getType(){return this.search_type.length===0?(this.search_type=vt(),this.search_type):this.search_type},setType(s){this.search_type=s,Ye(s)}}}),xe=["src"],Ie={class:"label-text"},Oe={class:"nav-item-icon arrow-down"},Ae={class:"dropdown-container"},Ne=["src"],je={class:"dropdown-item-text"},ze={__name:"HistoryTypeDropdown",props:{list_status:Number},emits:["typeSelected"],setup(s,{emit:l}){const a=s,o=Te(),{api_status:v,list_agents:M,getAgentList:d}=Le(k=>{var f;if(o.search_type){const L=((f=o.search_type)==null?void 0:f.id)||"";let x=null;const X=k.length;for(let F=0;F<X;F++){const q=k[F];if(q.id===L){x=q;break}}D(x||k[0])}else D(k[0])}),m=l,u=B(()=>{var k;return((k=o==null?void 0:o.search_type)==null?void 0:k.name)||""}),i=B(()=>o.search_type&&o.search_type.icon?mt(o.search_type.icon):""),g=B(()=>a.list_status===2),D=k=>{o.setType(k),m("typeSelected",k)};return gt(()=>{d()}),(k,f)=>{const L=dt("icon-down"),x=Wt,X=$t,F=Ut,q=qt;return $(),Q(q,{trigger:"hover",defaultValue:u.value},{content:U(()=>[($(!0),H(nt,null,yt(it(M),(W,tt)=>($(),Q(F,{key:W.id,disabled:g.value,value:W.name,onClick:J=>D(W)},{default:U(()=>[b("div",Ae,[b("img",{src:it(mt)(W.icon),class:"agent-icon-img"},null,8,Ne),b("span",je,V(W.name),1)])]),_:2},1032,["disabled","value","onClick"]))),128))]),default:U(()=>[it(v)===1||it(v)===3?($(),Q(x,{key:0,class:"history-type-btn",type:"text"},{default:U(()=>[b("img",{src:i.value,class:"agent-icon-img"},null,8,xe),b("span",Ie,V(u.value),1),b("span",Oe,[I(L,{class:"arrow-down"})])]),_:1})):j("",!0),it(v)===2?($(),Q(x,{key:1,class:"history-type-btn",type:"text"},{default:U(()=>[I(X,{size:16})]),_:1})):j("",!0)]),_:1},8,["defaultValue"])}}},Ee=Z(ze,[["__scopeId","data-v-7e0d55ff"]]),Be={class:"conversation-history-container"},We={class:"conversation-history-main"},Ve={key:1,class:"infomations-container"},Fe={key:2,class:"infomations-container"},Re={key:3,class:"infomations-container"},Ue={key:4,class:"infomations-container"},qe={__name:"ConversationHistoryContainer",emits:["historyActive"],setup(s,{emit:l}){const a=l,o=C(1),v=C(50),M=C(""),d=C(""),m=C(!0),u=C(1),i=C(""),g=C([]),D=C(0),k=C(0),f=C(0),L=C(""),x=le(),F=x-bt-ue;function q(Y){Y.forEach((y,p)=>{let z=null;const O=y,n=new Date(O.create_date).getTime();let t=null;if(isNaN(n)){const e=new Date(O.updated_time).getTime();isNaN(e)?t=Date.now():t=e}else t=n;O.create_time=t,t>=x?(D.value===0&&(z={client_field_content_type:"label",client_field_timestamp_type:"today",id:"today"}),O.client_field_timestamp_type="today",O.client_field_content_type="content",D.value=D.value+1):t<x&&t>F?(k.value===0&&(z={client_field_content_type:"label",client_field_timestamp_type:"month",id:"month"}),O.client_field_timestamp_type="month",O.client_field_content_type="content",k.value=k.value+1):(f.value===0&&(z={client_field_content_type:"label",client_field_timestamp_type:"earlier",id:"earlier"}),O.client_field_timestamp_type="earlier",O.client_field_content_type="content",f.value=f.value+1),z&&g.value.push(z),g.value.push(O)})}const W=()=>({search:M.value,page:o.value,per_page:v.value,agent_id:d.value}),tt=()=>{const Y=W();u.value=2,i.value="",_e(Y).then(y=>{if(y.code/1===200){const p=y.data;p.length<v.value?m.value=!1:m.value=!0,q(p),u.value=3,i.value="success"}else u.value=4,i.value=y.msg}).catch(y=>{u.value=5,i.value=y.message})},J=()=>{u.value!==2&&m.value&&(o.value=o.value+1,tt())},R=Y=>{a("historyActive",{agent_id:d.value,target_id:Y})},ct=Y=>{u.value!==2&&(M.value=Y,o.value=1,g.value=[],tt())},ot=Y=>{u.value!==2&&Y&&(D.value=0,k.value=0,f.value=0,L.value=mt(Y.icon),d.value=Y.id,o.value=1,g.value=[],tt())};return gt(()=>{}),(Y,y)=>{const p=$t,z=Jt,O=Ot;return $(),H("div",Be,[y[1]||(y[1]=b("div",{class:"conversation-history-left"},null,-1)),b("div",We,[I(Qt),I(re,{onSearch:ct},{default:U(()=>[I(Ee,{onTypeSelected:ot,list_status:u.value},null,8,["list_status"])]),_:1}),g.value.length!==0?($(),Q(Ce,{key:0,list:g.value,can_loadmore:m.value,agent_icon:L.value,onLoadmore:J,onActive:R},null,8,["list","can_loadmore","agent_icon"])):j("",!0),u.value===1||u.value===2?($(),H("div",Ve,[I(p,{size:32})])):j("",!0),u.value===3&&g.value.length===0?($(),H("div",Fe,[I(z,null,{default:U(()=>[lt(V(Y.$t("conversation.history_empty")),1)]),_:1})])):j("",!0),u.value===4?($(),H("div",Re,[I(O,{status:"warning",title:i.value},null,8,["title"])])):j("",!0),u.value===5?($(),H("div",Ue,[I(O,{status:"error",title:i.value},null,8,["title"])])):j("",!0),y[0]||(y[0]=b("div",{class:"conversation-history-placeholder"},null,-1))]),y[2]||(y[2]=b("div",{class:"conversation-history-right"},null,-1))])}}},Je=Z(qe,[["__scopeId","data-v-ad3d0ba8"]]),Pe="/assets/history-bg-Cuh6wzmt.png",kn={__name:"ConversationHistory",setup(s){const l=Yt(),a=Vt(),o=B(()=>a.value==="light"?{backgroundImage:`url(${Pe})`,backgroundRepeat:"no-repeat",backgroundSize:"cover"}:{}),v=({target_id:M,agent_id:d})=>{l.push({path:"/chat/qa",query:{session:M,agent:d}})};return(M,d)=>($(),Q(Tt,null,{default:U(()=>[I(xt,{containerStyle:o.value,id:"fjkdsdajfklgjsklfjskdlf"},{default:U(()=>[I(It),I(Je,{onHistoryActive:v})]),_:1},8,["containerStyle"])]),_:1}))}};export{kn as default};