import{c as Y,o as M,a as w,u as W,j as C,e as E,p as dt,s as z,m as bt,v as O,G as Ht,a1 as Yt,b as _t,F as nt,t as lt,Z as yt,q as Q,M as Ct,B as gt,w as U,Y as it,N as Lt}from"./vue-vendor-CBGUFTsF.js";import Tt from"./LayoutExperience-CR3QnEuP.js";import xt from"./ContentContainer-Dst4bqY3.js";import{C as Ot}from"./ChatAsideMenu-DS9T5hq9.js";import{k as It,H as ft,_ as Z,J as At,L as $t,u as Nt,M as jt,N as zt,O as Mt,P as Bt,B as Et,Q as Vt}from"./index-CVDyAB5E.js";import{R as Wt}from"./index-mYeLtivx.js";/* empty css *//* empty css *//* empty css *//* empty css */import"./index-DogcpJwz.js";import{M as ht}from"./index-CmhLXlYR.js";/* empty css *//* empty css *//* empty css */import{a as Ft}from"./api-conversation-board-CBTi01TP.js";import{u as Rt}from"./use-all-agents-XHS-a0Oc.js";import{g as mt}from"./icon-map-D83d39Ln.js";import{S as Dt}from"./index-91EZoapZ.js";import{D as Ut,a as qt,E as Jt}from"./index-BNRgXl_1.js";import"./Header-BFxxGGUL.js";import"./index-2XQQv03h.js";import"./logo-CxXS7KxG.js";import"./use-platform-information-BwI-Z1kC.js";import"./use-logout-CKeIp0jA.js";import"./use-current-user-CdQObYyO.js";import"./login-CXnkx0pX.js";/* empty css */import"./index-CfpSx18r.js";import"./index-BbumWpdU.js";import"./index-B6BdE4l3.js";var St={exports:{}};(function(s,m){(function(c,o){s.exports=o()})(ft,function(){var c=1e3,o=6e4,f=36e5,g="millisecond",i="second",l="minute",a="hour",d="day",S="week",$="month",k="quarter",p="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(u){var n=["th","st","nd","rd"],t=u%100;return"["+u+(n[(t-20)%10]||n[t]||n[0])+"]"}},V=function(u,n,t){var r=String(u);return!r||r.length>=n?u:""+Array(n+1-r.length).join(t)+u},tt={s:V,z:function(u){var n=-u.utcOffset(),t=Math.abs(n),r=Math.floor(t/60),e=t%60;return(n<=0?"+":"-")+V(r,2,"0")+":"+V(e,2,"0")},m:function u(n,t){if(n.date()1)return u(h[0])}else{var D=n.name;R[D]=n,e=D}return!r&&e&&(J=e),e||!r&&J},v=function(u,n){if(ot(u))return u.clone();var t=typeof n=="object"?n:{};return t.date=u,t.args=arguments,new N(t)},y=tt;y.l=b,y.i=ot,y.w=function(u,n){return v(u,{locale:n.$L,utc:n.$u,x:n.$x,$offset:n.$offset})};var N=function(){function u(t){this.$L=b(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[ct]=!0}var n=u.prototype;return n.parse=function(t){this.$d=function(r){var e=r.date,_=r.utc;if(e===null)return new Date(NaN);if(y.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 D=h[2]-1||0,H=(h[7]||"0").substring(0,3);return _?new Date(Date.UTC(h[1],D,h[3]||1,h[4]||0,h[5]||0,h[6]||0,H)):new Date(h[1],D,h[3]||1,h[4]||0,h[5]||0,h[6]||0,H)}}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 y},n.isValid=function(){return this.$d.toString()!==x},n.isSame=function(t,r){var e=v(t);return this.startOf(r)<=e&&e<=this.endOf(r)},n.isAfter=function(t,r){return v(t)o.value.length!==0),g=d=>{o.value=d.target.value},i=d=>{o.value=d.target.value},l=d=>{d.keyCode===13&&c("search",o.value)},a=()=>{o.value="",c("search",o.value)};return(d,S)=>{const $=dt("icon-search"),k=dt("icon-close");return M(),Y("div",Xt,[w("div",te,[w("div",ee,[O($)]),w("div",ne,[Ht(w("input",{type:"text",class:"search-input",placeholder:d.$t("conversation.search_history"),"onUpdate:modelValue":S[0]||(S[0]=p=>o.value=p),onInput:g,onChange:i,onKeyup:l},null,40,se),[[Yt,o.value]])]),f.value?(M(),Y("div",{key:0,class:"search-input-icon icon-clear",onClick:a},[O(k)])):z("",!0),bt(d.$slots,"default",{},void 0,!0)])])}}},re=Z(oe,[["__scopeId","data-v-f3dff79d"]]);var ae={exports:{}};(function(s,m){(function(c,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(c){var o=["th","st","nd","rd"],f=c%100;return"["+c+(o[(f-20)%10]||o[f]||o[0])+"]"}}})})(ae);const ie=1e3*60,ce=ie*60,wt=ce*24,ue=wt*30,le=()=>{const s=new Date;return s.setHours(0,0,0,0),s.getTime()},de=(s,m)=>{if(!m)return st(s).format("HH:mm");if(m==="zh")return st(s).locale("zh-cn").format("HH:mm");if(m==="en")return st(s).format("HH:mm")},pt=(s,m)=>m&&m==="zh"?st(s).locale("zh-cn").format("MM-DD"):st(s).format("MM-DD"),_e=s=>{const m=s.agent_id,c="/api/v1/chat/sessions",o={chatId:m};return"per_page"in s&&(o.pageSize=s.per_page/1),"page"in s&&(o.current=s.page/1),"search"in s&&s.search&&(o.keyword=s.search),new Promise((f,g)=>{At({url:c,method:"get",params:o}).then(i=>{f({code:200,data:i})}).catch(i=>{g(i)})})},he=s=>($t({conversation_ids:[s]}),new Promise((c,o)=>{setTimeout(()=>{c({code:200,data:!0,msg:""})},1e3)})),me={__name:"BtnHistoryItemDelete",props:{target_id:String},emits:["deleteSuccess"],setup(s,{emit:m}){const c=s,o=m,f=Nt();C(1),C("");const g=()=>{const l=f.t("conversation.are_you_sure");f.t("conversation.btn_yes"),f.t("conversation.btn_no"),jt.warning({title:l,hideCancel:!1,"modal-class":"history-chat-remove-modal",onOk(a){},async onBeforeOk(){try{return await i()===200}catch{return!1}},onCancel(){}})},i=()=>new Promise((l,a)=>{he(c.target_id).then(d=>{if(d.code/1===200){const S=f.t("conversation.del_success");ht.success(S),o("deleteSuccess"),l(200)}else ht.warning(d.msg)}).catch(d=>{ht.warning(d.msg),a(d)})});return(l,a)=>{const d=dt("icon-delete");return M(),Y("span",{onClick:g,class:"btn-delete"},[O(d)])}}},fe=Z(me,[["__scopeId","data-v-f9e9d87d"]]),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:m}){const c=s,o=m,f=C(!1),g=zt(),i=E(()=>c.history.client_field_content_type==="label"),l=E(()=>c.history.client_field_content_type==="content"),a=E(()=>l.value&&!f.value),d=E(()=>{const p={"conversation-history-item":!0};return p[`item-${c.index}`]=!0,p[`item-${c.history.session_id}`]=!0,p[c.history.client_field_timestamp_type]=!0,i.value&&(p["conversation-history-section-title"]=!0),l.value&&(p["conversation-history-section-data"]=!0),p}),S=E(()=>{const p=c.history.client_field_timestamp_type,L=c.history.create_time,x=g.value;return p==="today"?de(L,x):p==="month"||p==="earlier"?pt(L,x):""}),$=()=>{o("active",c.history.session_id)},k=()=>{f.value=!0};return(p,L)=>(M(),Y(nt,null,[i.value?(M(),Y("div",{key:0,class:_t([d.value,"history-block-title"])},[s.history.client_field_timestamp_type==="today"?(M(),Y(nt,{key:0},[lt(W(p.$t("conversation.history_today")),1)],64)):z("",!0),s.history.client_field_timestamp_type==="month"?(M(),Y(nt,{key:1},[lt(W(p.$t("conversation.history_month")),1)],64)):z("",!0),s.history.client_field_timestamp_type==="earlier"?(M(),Y(nt,{key:2},[lt(W(p.$t("conversation.history_earlier")),1)],64)):z("",!0)],2)):z("",!0),a.value?(M(),Y("div",{key:1,class:_t(d.value)},[w("div",{class:"history-item-icon",onClick:$},[w("img",{src:s.agent_icon},null,8,pe)]),w("div",ve,[w("div",{class:"history-item-intro-title",onClick:$},W(s.history.name),1)]),w("div",ye,[w("span",ge,W(S.value),1),w("span",$e,[O(fe,{target_id:s.history.id,onDeleteSuccess:k},null,8,["target_id"])])])],2)):z("",!0)],64))}},De=Z(Me,[["__scopeId","data-v-9c2477a8"]]),Se={key:0,class:"history-item-icon can-loadmore"},ke={__name:"HistoryLoadMore",props:{can_loadmore:Boolean},emits:["loadmore"],setup(s,{emit:m}){const c=s,o=m,f=E(()=>{const i={"conversation-history-item":!0};return i["load-more"]=!0,i}),g=()=>{c.can_loadmore&&o("loadmore")};return(i,l)=>(M(),Y("div",{class:_t(f.value),onClick:g},[s.can_loadmore?(M(),Y("div",Se,W(i.$t("conversation.history_loadmore")),1)):z("",!0)],2))}},we=Z(ke,[["__scopeId","data-v-01b3fb14"]]),be={class:"conversation-history-list-section"},He={__name:"HistoryList",props:{list:Array,can_loadmore:Boolean,agent_icon:String},emits:["active","delete","loadmore"],setup(s,{emit:m}){const c=m,o=E(()=>"conversation-history-list"),f=l=>{c("active",l)},g=l=>{c("delete",l)},i=()=>{c("loadmore")};return(l,a)=>(M(),Y("div",be,[w("div",{class:_t(o.value)},[(M(!0),Y(nt,null,yt(s.list,(d,S)=>(M(),Q(De,{key:d.id,history:d,index:S,agent_icon:s.agent_icon,onActive:$=>f(d),onDelete:g},null,8,["history","index","agent_icon","onActive"]))),128)),O(we,{can_loadmore:s.can_loadmore,onLoadmore:i},null,8,["can_loadmore"])],2)]))}},Ye=Z(He,[["__scopeId","data-v-8e81d4c3"]]);function Ce(s){const m=C(1),c=C(""),o=C([]);Rt();const f=()=>({});return{getAgentList:()=>{const i=f();m.value=2,c.value="",Ft(i).then(l=>{if(l.code/1===200){const a=l.data;a.length!==0&&(a.unshift({id:"",name:"全部",icon:"intelligentFrame1"}),typeof s=="function"&&s(a)),o.value=a,m.value=3,c.value="success"}else m.value=4,c.value=err.message}).catch(l=>{console.log(l),m.value=5,c.value=l.msg})},api_status:m,api_message:c,list_agents:o}}function Le(s){const m=$t(s);Mt.setItem(m)}function vt(){const s=Mt.getItem(),m=Bt(s);return m===null?null:m}const Te=Ct("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,Le(s)}}}),xe=["src"],Oe={class:"label-text"},Ie={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:m}){const c=s,o=Te(),{api_status:f,list_agents:g,getAgentList:i}=Ce(k=>{var p;if(o.search_type){const L=((p=o.search_type)==null?void 0:p.id)||"";let x=null;const X=k.length;for(let F=0;F{var k;return((k=o==null?void 0:o.search_type)==null?void 0:k.name)||""}),d=E(()=>o.search_type&&o.search_type.icon?mt(o.search_type.icon):""),S=E(()=>c.list_status===2),$=k=>{o.setType(k),l("typeSelected",k)};return gt(()=>{i()}),(k,p)=>{const L=dt("icon-down"),x=Et,X=Dt,F=Ut,q=qt;return M(),Q(q,{trigger:"hover",defaultValue:a.value},{content:U(()=>[(M(!0),Y(nt,null,yt(it(g),(V,tt)=>(M(),Q(F,{key:V.id,disabled:S.value,value:V.name,onClick:J=>$(V)},{default:U(()=>[w("div",Ae,[w("img",{src:it(mt)(V.icon),class:"agent-icon-img"},null,8,Ne),w("span",je,W(V.name),1)])]),_:2},1032,["disabled","value","onClick"]))),128))]),default:U(()=>[it(f)===1||it(f)===3?(M(),Q(x,{key:0,class:"history-type-btn",type:"text"},{default:U(()=>[w("img",{src:d.value,class:"agent-icon-img"},null,8,xe),w("span",Oe,W(a.value),1),w("span",Ie,[O(L,{class:"arrow-down"})])]),_:1})):z("",!0),it(f)===2?(M(),Q(x,{key:1,class:"history-type-btn",type:"text"},{default:U(()=>[O(X,{size:16})]),_:1})):z("",!0)]),_:1},8,["defaultValue"])}}},Be=Z(ze,[["__scopeId","data-v-167b3b63"]]),Ee={class:"conversation-history-container"},Ve={class:"conversation-history-main"},We={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:m}){const c=m,o=C(1),f=C(50),g=C(""),i=C(""),l=C(!0),a=C(1),d=C(""),S=C([]),$=C(0),k=C(0),p=C(0),L=C(""),x=le(),F=x-wt-ue;function q(b){b.forEach((v,y)=>{let N=null;const I=v,n=new Date(I.create_date).getTime();let t=null;if(isNaN(n)){const e=new Date(I.updated_time).getTime();isNaN(e)?t=Date.now():t=e}else t=n;I.create_time=t,t>=x?($.value===0&&(N={client_field_content_type:"label",client_field_timestamp_type:"today",id:"today"}),I.client_field_timestamp_type="today",I.client_field_content_type="content",$.value=$.value+1):tF?(k.value===0&&(N={client_field_content_type:"label",client_field_timestamp_type:"month",id:"month"}),I.client_field_timestamp_type="month",I.client_field_content_type="content",k.value=k.value+1):(p.value===0&&(N={client_field_content_type:"label",client_field_timestamp_type:"earlier",id:"earlier"}),I.client_field_timestamp_type="earlier",I.client_field_content_type="content",p.value=p.value+1),N&&S.value.push(N),S.value.push(I)})}const V=()=>({search:g.value,page:o.value,per_page:f.value,agent_id:i.value}),tt=()=>{const b=V();a.value=2,d.value="",_e(b).then(v=>{if(v.code/1===200){const N=v.data.rows;N.length{a.value=5,d.value=v.message})},J=()=>{a.value!==2&&l.value&&(o.value=o.value+1,tt())},R=b=>{console.log(b),b.event_type!=="complex-chat"&&(i.value=b.chat_id),c("historyActive",{agent_id:i.value,target_id:b.session_id,mode:b.event_type})},ct=b=>{a.value!==2&&(g.value=b,o.value=1,S.value=[],tt())},ot=b=>{a.value!==2&&b&&($.value=0,k.value=0,p.value=0,L.value=mt(b.icon),i.value=b.id,o.value=1,S.value=[],tt())};return gt(()=>{}),(b,v)=>{const y=Dt,N=Jt,I=Wt;return M(),Y("div",Ee,[v[1]||(v[1]=w("div",{class:"conversation-history-left"},null,-1)),w("div",Ve,[O(Qt),O(re,{onSearch:ct},{default:U(()=>[O(Be,{onTypeSelected:ot,list_status:a.value},null,8,["list_status"])]),_:1}),S.value.length!==0?(M(),Q(Ye,{key:0,list:S.value,can_loadmore:l.value,agent_icon:L.value,onLoadmore:J,onActive:R},null,8,["list","can_loadmore","agent_icon"])):z("",!0),a.value===1||a.value===2?(M(),Y("div",We,[O(y,{size:32})])):z("",!0),a.value===3&&S.value.length===0?(M(),Y("div",Fe,[O(N,null,{default:U(()=>[lt(W(b.$t("conversation.history_empty")),1)]),_:1})])):z("",!0),a.value===4?(M(),Y("div",Re,[O(I,{status:"warning",title:d.value},null,8,["title"])])):z("",!0),a.value===5?(M(),Y("div",Ue,[O(I,{status:"error",title:d.value},null,8,["title"])])):z("",!0),v[0]||(v[0]=w("div",{class:"conversation-history-placeholder"},null,-1))]),v[2]||(v[2]=w("div",{class:"conversation-history-right"},null,-1))])}}},Je=Z(qe,[["__scopeId","data-v-8e31c3b5"]]),Pe="/assets/history-bg-Cuh6wzmt.png",Hn={__name:"ConversationHistory",setup(s){const m=Lt(),c=Vt(),o=E(()=>c.value==="light"?{backgroundImage:`url(${Pe})`,backgroundRepeat:"no-repeat",backgroundSize:"cover"}:{}),f=({target_id:g,agent_id:i,mode:l})=>{const a={session:g,history:"history"};i&&(a.agent=i),l&&(a.mode=l),m.push({path:"/chat/qa",query:a})};return(g,i)=>(M(),Q(Tt,null,{default:U(()=>[O(xt,{containerStyle:o.value,id:"fjkdsdajfklgjsklfjskdlf"},{default:U(()=>[O(Ot),O(Je,{onHistoryActive:f})]),_:1},8,["containerStyle"])]),_:1}))}};export{Hn as default};