import{c as H,o as $,a as b,J as W,j as Y,e as E,p as dt,q as z,m as wt,D as I,B as Ht,a1 as Yt,b as _t,F as nt,I as lt,Z as vt,s as Q,M as Ct,x as gt,A as U,X as it,Y as Lt}from"./vue-vendor-BdC0yijC.js";import Tt from"./LayoutExperience-6xU79BkX.js";import xt from"./ContentContainer-D6x71VtJ.js";import{C as It}from"./ChatAsideMenu-LvlRzrKT.js";/* empty css */import{R as Ot}from"./index-BoSfQS0R.js";/* empty css *//* empty css */import{k as At,G as ft,_ as Z,H as Nt,K as $t,u as jt,M as zt,L as Bt,N as Mt,O as Et,B as Vt,P as Wt}from"./index-h-JKU4Nj.js";/* empty css */import"./index-C01Wp_Qp.js";import{M as ht}from"./index-yUNGsRBX.js";import"./index-CKrjqYdd.js";/* empty css *//* empty css */import{a as Ft}from"./api-conversation-board-DF2j02i1.js";import{u as Rt}from"./use-all-agents-CrTDpnvC.js";import{g as mt}from"./icon-map-D83d39Ln.js";import{S as Dt}from"./index-iskbd4uP.js";import{D as Ut,a as qt,E as Jt}from"./index-CKaxmMJS.js";import"./Header-DqEFDg8Y.js";import"./index-VSP4qxHb.js";import"./use-platform-information-CCFvVYoR.js";import"./use-logout-LlEvK0q5.js";import"./use-current-user-B_reGFTv.js";import"./login-T2wGHZQQ.js";/* empty css */import"./index-dPpvPy7n.js";import"./index-DZDMbtkj.js";var St={exports:{}};(function(s,h){(function(i,o){s.exports=o()})(ft,function(){var i=1e3,o=6e4,f=36e5,g="millisecond",a="second",l="minute",c="hour",m="day",S="week",M="month",k="quarter",p="year",C="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(_[0])}else{var D=n.name;R[D]=n,e=D}return!r&&e&&(J=e),e||!r&&J},y=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)},v=tt;v.l=L,v.i=ot,v.w=function(u,n){return y(u,{locale:n.$L,utc:n.$u,x:n.$x,$offset:n.$offset})};var N=function(){function u(t){this.$L=L(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,d=r.utc;if(e===null)return new Date(NaN);if(v.u(e))return new Date;if(e instanceof Date)return new Date(e);if(typeof e=="string"&&!/Z$/i.test(e)){var _=e.match(X);if(_){var D=_[2]-1||0,w=(_[7]||"0").substring(0,3);return d?new Date(Date.UTC(_[1],D,_[3]||1,_[4]||0,_[5]||0,_[6]||0,w)):new Date(_[1],D,_[3]||1,_[4]||0,_[5]||0,_[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 v},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)o.value.length!==0),g=m=>{o.value=m.target.value},a=m=>{o.value=m.target.value},l=m=>{m.keyCode===13&&i("search",o.value)},c=()=>{o.value="",i("search",o.value)};return(m,S)=>{const M=dt("icon-search"),k=dt("icon-close");return $(),H("div",Xt,[b("div",te,[b("div",ee,[I(M)]),b("div",ne,[Ht(b("input",{type:"text",class:"search-input",placeholder:m.$t("conversation.search_history"),"onUpdate:modelValue":S[0]||(S[0]=p=>o.value=p),onInput:g,onChange:a,onKeyup:l},null,40,se),[[Yt,o.value]])]),f.value?($(),H("div",{key:0,class:"search-input-icon icon-clear",onClick:c},[I(k)])):z("",!0),wt(m.$slots,"default",{},void 0,!0)])])}}},re=Z(oe,[["__scopeId","data-v-f3dff79d"]]);var ae={exports:{}};(function(s,h){(function(i,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(i){var o=["th","st","nd","rd"],f=i%100;return"["+i+(o[(f-20)%10]||o[f]||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,h)=>{if(!h)return st(s).format("HH:mm");if(h==="zh")return st(s).locale("zh-cn").format("HH:mm");if(h==="en")return st(s).format("HH:mm")},pt=(s,h)=>h&&h==="zh"?st(s).locale("zh-cn").format("MM-DD"):st(s).format("MM-DD"),_e=s=>{const h=s.agent_id,i="/api/v1/chat/sessions",o={chatId:h};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)=>{Nt({url:i,method:"get",params:o}).then(a=>{f({code:200,data:a})}).catch(a=>{g(a)})})},he=s=>($t({conversation_ids:[s]}),new Promise((i,o)=>{setTimeout(()=>{i({code:200,data:!0,msg:""})},1e3)})),me={__name:"BtnHistoryItemDelete",props:{target_id:String},emits:["deleteSuccess"],setup(s,{emit:h}){const i=s,o=h,f=jt();Y(1),Y("");const g=()=>{const l=f.t("conversation.are_you_sure");f.t("conversation.btn_yes"),f.t("conversation.btn_no"),zt.warning({title:l,hideCancel:!1,"modal-class":"history-chat-remove-modal",onOk(c){},async onBeforeOk(){try{return await a()===200}catch{return!1}},onCancel(){}})},a=()=>new Promise((l,c)=>{he(i.target_id).then(m=>{if(m.code/1===200){const S=f.t("conversation.del_success");ht.success(S),o("deleteSuccess"),l(200)}else ht.warning(m.msg)}).catch(m=>{ht.warning(m.msg),c(m)})});return(l,c)=>{const m=dt("icon-delete");return $(),H("span",{onClick:g,class:"btn-delete"},[I(m)])}}},fe=Z(me,[["__scopeId","data-v-f9e9d87d"]]),pe=["src"],ye={class:"history-item-intro"},ve={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:h}){const i=s,o=h,f=Y(!1),g=Bt(),a=E(()=>i.history.client_field_content_type==="label"),l=E(()=>i.history.client_field_content_type==="content"),c=E(()=>l.value&&!f.value),m=E(()=>{const p={"conversation-history-item":!0};return p[`item-${i.index}`]=!0,p[`item-${i.history.session_id}`]=!0,p[i.history.client_field_timestamp_type]=!0,a.value&&(p["conversation-history-section-title"]=!0),l.value&&(p["conversation-history-section-data"]=!0),p}),S=E(()=>{const p=i.history.client_field_timestamp_type,C=i.history.create_time,x=g.value;return p==="today"?de(C,x):p==="month"||p==="earlier"?pt(C,x):""}),M=()=>{o("active",i.history.session_id)},k=()=>{f.value=!0};return(p,C)=>($(),H(nt,null,[a.value?($(),H("div",{key:0,class:_t([m.value,"history-block-title"])},[s.history.client_field_timestamp_type==="today"?($(),H(nt,{key:0},[lt(W(p.$t("conversation.history_today")),1)],64)):z("",!0),s.history.client_field_timestamp_type==="month"?($(),H(nt,{key:1},[lt(W(p.$t("conversation.history_month")),1)],64)):z("",!0),s.history.client_field_timestamp_type==="earlier"?($(),H(nt,{key:2},[lt(W(p.$t("conversation.history_earlier")),1)],64)):z("",!0)],2)):z("",!0),c.value?($(),H("div",{key:1,class:_t(m.value)},[b("div",{class:"history-item-icon",onClick:M},[b("img",{src:s.agent_icon},null,8,pe)]),b("div",ye,[b("div",{class:"history-item-intro-title",onClick:M},W(s.history.name),1)]),b("div",ve,[b("span",ge,W(S.value),1),b("span",$e,[I(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:h}){const i=s,o=h,f=E(()=>{const a={"conversation-history-item":!0};return a["load-more"]=!0,a}),g=()=>{i.can_loadmore&&o("loadmore")};return(a,l)=>($(),H("div",{class:_t(f.value),onClick:g},[s.can_loadmore?($(),H("div",Se,W(a.$t("conversation.history_loadmore")),1)):z("",!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:h}){const i=h,o=E(()=>"conversation-history-list"),f=l=>{i("active",l)},g=l=>{i("delete",l)},a=()=>{i("loadmore")};return(l,c)=>($(),H("div",we,[b("div",{class:_t(o.value)},[($(!0),H(nt,null,vt(s.list,(m,S)=>($(),Q(De,{key:m.id,history:m,index:S,agent_icon:s.agent_icon,onActive:f,onDelete:g},null,8,["history","index","agent_icon"]))),128)),I(be,{can_loadmore:s.can_loadmore,onLoadmore:a},null,8,["can_loadmore"])],2)]))}},Ye=Z(He,[["__scopeId","data-v-4bed9682"]]);function Ce(s){const h=Y(1),i=Y(""),o=Y([]);Rt();const f=()=>({});return{getAgentList:()=>{const a=f();h.value=2,i.value="",Ft(a).then(l=>{if(l.code/1===200){const c=l.data;c.length!==0&&(c.unshift({id:"",name:"全部",icon:"intelligentFrame1"}),typeof s=="function"&&s(c)),o.value=c,h.value=3,i.value="success"}else h.value=4,i.value=err.message}).catch(l=>{console.log(l),h.value=5,i.value=l.msg})},api_status:h,api_message:i,list_agents:o}}function Le(s){const h=$t(s);Mt.setItem(h)}function yt(){const s=Mt.getItem(),h=Et(s);return h===null?null:h}const Te=Ct("recent_history_search_type",{state:()=>({search_type:yt()}),actions:{getType(){return this.search_type.length===0?(this.search_type=yt(),this.search_type):this.search_type},setType(s){this.search_type=s,Le(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:h}){const i=s,o=Te(),{api_status:f,list_agents:g,getAgentList:a}=Ce(k=>{var p;if(o.search_type){const C=((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)||""}),m=E(()=>o.search_type&&o.search_type.icon?mt(o.search_type.icon):""),S=E(()=>i.list_status===2),M=k=>{o.setType(k),l("typeSelected",k)};return gt(()=>{a()}),(k,p)=>{const C=dt("icon-down"),x=Vt,X=Dt,F=Ut,q=qt;return $(),Q(q,{trigger:"hover",defaultValue:c.value},{content:U(()=>[($(!0),H(nt,null,vt(it(g),(V,tt)=>($(),Q(F,{key:V.id,disabled:S.value,value:V.name,onClick:J=>M(V)},{default:U(()=>[b("div",Ae,[b("img",{src:it(mt)(V.icon),class:"agent-icon-img"},null,8,Ne),b("span",je,W(V.name),1)])]),_:2},1032,["disabled","value","onClick"]))),128))]),default:U(()=>[it(f)===1||it(f)===3?($(),Q(x,{key:0,class:"history-type-btn",type:"text"},{default:U(()=>[b("img",{src:m.value,class:"agent-icon-img"},null,8,xe),b("span",Ie,W(c.value),1),b("span",Oe,[I(C,{class:"arrow-down"})])]),_:1})):z("",!0),it(f)===2?($(),Q(x,{key:1,class:"history-type-btn",type:"text"},{default:U(()=>[I(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:h}){const i=h,o=Y(1),f=Y(50),g=Y(""),a=Y(""),l=Y(!0),c=Y(1),m=Y(""),S=Y([]),M=Y(0),k=Y(0),p=Y(0),C=Y(""),x=le(),F=x-bt-ue;function q(L){L.forEach((y,v)=>{let N=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?(M.value===0&&(N={client_field_content_type:"label",client_field_timestamp_type:"today",id:"today"}),O.client_field_timestamp_type="today",O.client_field_content_type="content",M.value=M.value+1):tF?(k.value===0&&(N={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):(p.value===0&&(N={client_field_content_type:"label",client_field_timestamp_type:"earlier",id:"earlier"}),O.client_field_timestamp_type="earlier",O.client_field_content_type="content",p.value=p.value+1),N&&S.value.push(N),S.value.push(O)})}const V=()=>({search:g.value,page:o.value,per_page:f.value,agent_id:a.value}),tt=()=>{const L=V();c.value=2,m.value="",_e(L).then(y=>{if(y.code/1===200){const N=y.data.rows;N.length{c.value=5,m.value=y.message})},J=()=>{c.value!==2&&l.value&&(o.value=o.value+1,tt())},R=L=>{i("historyActive",{agent_id:a.value,target_id:L})},ct=L=>{c.value!==2&&(g.value=L,o.value=1,S.value=[],tt())},ot=L=>{c.value!==2&&L&&(M.value=0,k.value=0,p.value=0,C.value=mt(L.icon),a.value=L.id,o.value=1,S.value=[],tt())};return gt(()=>{}),(L,y)=>{const v=Dt,N=Jt,O=Ot;return $(),H("div",Ee,[y[1]||(y[1]=b("div",{class:"conversation-history-left"},null,-1)),b("div",Ve,[I(Qt),I(re,{onSearch:ct},{default:U(()=>[I(Be,{onTypeSelected:ot,list_status:c.value},null,8,["list_status"])]),_:1}),S.value.length!==0?($(),Q(Ye,{key:0,list:S.value,can_loadmore:l.value,agent_icon:C.value,onLoadmore:J,onActive:R},null,8,["list","can_loadmore","agent_icon"])):z("",!0),c.value===1||c.value===2?($(),H("div",We,[I(v,{size:32})])):z("",!0),c.value===3&&S.value.length===0?($(),H("div",Fe,[I(N,null,{default:U(()=>[lt(W(L.$t("conversation.history_empty")),1)]),_:1})])):z("",!0),c.value===4?($(),H("div",Re,[I(O,{status:"warning",title:m.value},null,8,["title"])])):z("",!0),c.value===5?($(),H("div",Ue,[I(O,{status:"error",title:m.value},null,8,["title"])])):z("",!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-f10b2a3a"]]),Pe="/assets/history-bg-Cuh6wzmt.png",bn={__name:"ConversationHistory",setup(s){const h=Lt(),i=Wt(),o=E(()=>i.value==="light"?{backgroundImage:`url(${Pe})`,backgroundRepeat:"no-repeat",backgroundSize:"cover"}:{}),f=({target_id:g,agent_id:a})=>{const l={session:g,history:"history"};a&&(l.agent=a),h.push({path:"/chat/qa",query:l})};return(g,a)=>($(),Q(Tt,null,{default:U(()=>[I(xt,{containerStyle:o.value,id:"fjkdsdajfklgjsklfjskdlf"},{default:U(()=>[I(It),I(Je,{onHistoryActive:f})]),_:1},8,["containerStyle"])]),_:1}))}};export{bn as default};