text: "use strict";(self.webpackChunkLHCReactAPPAdmin=self.webpackChunkLHCReactAPPAdmin||[]).push([[707],{4707:(e,t,n)=>{n.r(t),n.d(t,{default:()=>f});var a=n(8152),c=n(4942),i=n(7294),r=n(9669),s=n.n(r),u=n(4478),o=n(9778);function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){(0,c.Z)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function m(e,t){switch(t.type){case"attr":return-1===(a=e.chats.findIndex((function(e){return e.id==t.id})))?e:(e.chats[a]=d(d({},e.chats[a]),t.value),e=d({},e));case"attr_remove":return-1===(a=e.chats.findIndex((function(e){return e[t.attr]==t.id})))?e:(e.chats[a]=d(d({},e.chats[a]),t.value),e=d({},e));case"update":return d(d({},e),t.value);case"add":return-1===(a=e.chats.findIndex((function(e){return e.id==t.value.id})))?e.chats.unshift(t.value):(e.chats[a].active=!0,e.chats[a].mn=0,e.chats[a].support_chat=!1),d({},e);case"remove":return-1===(a=e.chats.findIndex((function(e){return e.id==t.id})))?e:(e.chats.splice(a,1),d({},e));case"update_chat":return-1===(a=e.chats.findIndex((function(e){return e.id==t.id})))?e:(e.chats[a]=d(d({},e.chats[a]),t.value),d({},e));case"msg_received":if(-1===(a=e.chats.findIndex((function(e){return e.id==t.id}))))return e;e.chats[a].msg=t.value.msg;var n=document.getElementById("chat-tab-link-"+t.id);return null!==n&&n.classList.contains("active")?e.chats[a].active=!0:e.chats[a].active=!1,e.chats[a].mn=0==e.chats[a].active?e.chats[a].mn?e.chats[a].mn+t.value.mn:t.value.mn:0,e.chats.splice(0,0,e.chats.splice(a,1)[0]),d({},e);case"refocus":var a;if(-1!==(a=e.chats.findIndex((function(e){return 1==e.active})))){if(t.id==e.chats[a].id)return e;e.chats[a].active=!1}return-1!==(a=e.chats.findIndex((function(e){return e.id==t.id})))&&(e.chats[a].active=!0,e.chats[a].mn=0,e.chats[a].support_chat=!1),d({},e);case"group_offline":return e.group_offline=t.value,d({},e);default:throw new Error("Unknown action!")}}const f=function(e){var t=(0,i.useReducer)(m,{chats:[],group_offline:!1}),n=(0,a.Z)(t,2),c=n[0],r=n[1],l=(0,i.useRef)(c);(0,i.useEffect)((function(){l.current=c}),[c]);var d=function(){var e=[];return c.chats.map((function(t,n){return e.push(t.id)})),e},f=function(e){s().get(WWW_DIR_JAVASCRIPT+"front/tabs/(id)/"+(void 0!==e?e.join("/"):d().join("/"))).then((function(e){e.data.map((function(e,t){var n=document.getElementById("node-js-indicator-"+e.id);null!==n&&(e.live_status="wifi"==n.textContent),r({type:"update_chat",id:e.id,value:e})}))}))};document.getElementById("tabs")||(0,o.Z)((function(){c.chats&&0!=c.chats.length&&s().get(WWW_DIR_JAVASCRIPT+"front/tabs/(id)/"+d().join("/")).then((function(e){e.data.map((function(e,t){var n=document.getElementById("node-js-indicator-"+e.id);if(null!==n&&(e.live_status="wifi"==n.textContent),c.chats&&0!=c.chats.length){var a=c.chats.findIndex((function(t){return t.id==e.id}));-1!==a&&(c.chats[a].lmsg_id!==e.lmsg_id?e.mn=1:e.mn=c.chats[a].mn)}r({type:"update_chat",id:e.id,value:e})}))}))}),1e3),(0,i.useEffect)((function(){function e(e,t){t.focus&&r({type:"attr_remove",id:!0,attr:"active",value:{active:!1}}),r({type:"add",value:{id:e,active:t.focus}}),f([e])}function t(e,t){r({type:"add",value:{id:e,active:!1,mn:1}}),f([e])}function n(e){r({type:"remove",id:e})}function a(e){r({type:"refocus",id:e})}function c(e){r({type:"group_offline",value:lhinst.hidenicknamesstatus}),Object.keys(e.result_status).map((function(t){r({type:"update_chat",id:e.result_status[t].chat_id,value:e.result_status[t]})})),"false"!==e.result&&Object.keys(e.result).map((function(t){r({type:"msg_received",id:e.result[t].chat_id,value:{msg:e.result[t].msg,mn:e.result[t].mn}})}))}function i(e){r({type:"update_chat",id:e.id,value:{tp:"true",tx:e.txt}})}function s(e){r({type:"update_chat",id:e.id,value:{tp:"false"}})}function u(e){r({type:"update_chat",id:e.id,value:{live_status:e.status}})}function o(e,t){var n=l.current.chats.findIndex((function(e){return 1==e.active}));-1!==n&&(l.current.chats.length-1>n&&0==t?h(l.current.chats[n+1]):n>0&&1==t&&h(l.current.chats[n-1]))}if(ee.addListener("chatStartTab",e),ee.addListener("chatTabPreload",(function(t,n){l.current.chats&&0!=l.current.chats.length&&-1!==l.current.chats.findIndex((function(e){return e.id==t}))||e(t,n)})),ee.addListener("chatStartBackground",t),ee.addListener("removeSynchroChat",n),ee.addListener("chatTabClicked",a),ee.addListener("chatTabFocused",a),ee.addListener("chatAdminSync",c),ee.addListener("supportUnreadChat",(function(e){e.id&&1==e.unread&&r({type:"update_chat",id:e.id,value:{support_chat:!0}})})),ee.addListener("nodeJsTypingVisitor",i),ee.addListener("nodeJsTypingVisitorStopped",s),ee.addListener("nodeJsVisitorStatus",u),ee.addListener("activateNextTab",o),localStorage){var d=localStorage.getItem("achat_id");if(null!==d&&""!==d){var m=d.split(","),p=[];m.forEach((function(e){var t=document.getElementById("chat-tab-link-"+e);parseInt(e)>0&&p.push({id:parseInt(e),active:null!==t&&t.classList.contains("active")})})),r({type:"update",value:{chats:p}}),m.length>0&&f(m),setTimeout((function(){m.forEach((function(e){var t=document.getElementById("chat-tab-link-"+e);null!==t&&t.classList.contains("active")&&a(parseInt(e))}))}),1e3)}}return function(){ee.removeListener("chatStartTab",e),ee.removeListener("chatStartBackground",t),ee.removeListener("removeSynchroChat",n),ee.removeListener("chatTabClicked",a),ee.removeListener("chatTabFocused",a),ee.removeListener("chatAdminSync",c),ee.removeListener("supportUnreadChat",c),ee.removeListener("nodeJsTypingVisitor",i),ee.removeListener("nodeJsTypingVisitorStopped",s),ee.removeListener("nodeJsVisitorStatus",u),ee.removeListener("activateNextTab",o)}}),[]);var h=function(e){null!==document.getElementById("chat-tab-link-"+e.id)?$("#chat-tab-link-"+e.id).click():document.location=WWW_DIR_JAVASCRIPT+"front/default/(cid)/"+e.id+"/#!#chat-id-"+e.id},p=(0,u.$)("chat_tabs"),v=p.t;return p.i18n,i.createElement(i.Fragment,null,(!c.chats||0==c.chats.length)&&i.createElement("div",{className:"text-center text-muted p-2"},i.createElement("span",{className:"material-icons"},"chat"),v("chat_tabs.open_chats")),c.chats.map((function(e,t){return i.createElement("div",{title:e.id,onClick:function(){return h(e)},className:"p-1 action-image chat-tabs-row"+(e.active?" chat-tab-active":"")+(e.vwa?" long-response-chat":"")},i.createElement("div",{className:"fs12"},i.createElement("span",{className:"material-icons"+(1==e.pnd_rsp?" text-danger":" text-success")},1==e.pnd_rsp?"call_received":"call_made"),e.adicons&&e.adicons.map((function(t,n){return i.createElement("span",{onClick:function(n){return function(e,t,n){e.preventDefault(),e.stopPropagation(),t.has_popup&&lhc.revealModal({url:WWW_DIR_JAVASCRIPT+"chat/icondetailed/"+n.id+"/"+t.icon_id})}(n,t,e)},style:{color:t.color},className:"material-icons",title:t.title},t.icon)})),e.vwa&&i.createElement("span",{title:e.vwa,className:"material-icons text-danger"},"timer"),e.support_chat&&i.createElement("span",{className:"whatshot blink-ani text-warning material-icons"},"whatshot"),i.createElement("i",{className:"material-icons "+("boolean"==typeof e.live_status?!0===e.live_status?"icon-user-online":"icon-user-offline":2==e.us?"icon-user-away":0==e.us?"icon-user-online":"icon-user-offline")},"boolean"==typeof e.live_status?!0===e.live_status?"wifi":"wifi_off":2==e.us?"wifi_1_bar":0==e.us?"wifi":"wifi_off"),i.createElement("i",{className:"material-icons icon-user-online "+(1==e.um?"icon-user-offline":"icon-user-online")},"send"),e.cc&&i.createElement("img",{title:e.cn,src:e.cc,alt:""})," ",(0==c.group_offline||!(0!=e.us))&&i.createElement("span",{className:(e.mn>0||0==e.cs?"font-weight-bold ":"")+(0==e.cs?"text-danger":"")},e.nick||e.id),e.mn>0&&i.createElement("span",{className:"msg-nm pl-1"},"(",e.mn,")"),e.lmsg&&i.createElement("span",{className:"text-muted"}," ",e.lmsg),i.createElement("button",{type:"button",onClick:function(t){return function(e,t){e.preventDefault(),e.stopPropagation(),lhinst.removeDialogTab(t.id,$("#tabs"),!0)}(t,e)},className:"float-right btn-link m-0 ml-1 p-0 btn btn-xs"},i.createElement("i",{className:"material-icons mr-0"},"close")),e.dep&&i.createElement("span",{className:"float-right text-muted text-truncate mw-80px"},i.createElement("span",{className:"material-icons"},"home"),e.dep),e.co==confLH.user_id&&i.createElement("span",{className:"float-right text-muted"},i.createElement("span",{title:v("chat_tabs.chat_owner"),className:"material-icons"},"account_box"))),(e.msg||"true"==e.tp&&e.tx)&&i.createElement("div",{className:"fs13 text-muted pt-1"},i.createElement("span",{title:"true"==e.tp&&e.tx?e.tx:e.msg,className:"d-inline-block text-truncate mw-100 "+(e.mn>0?"font-weight-bold":"")+("true"==e.tp&&e.tx?" font-italic":"")},"true"==e.tp&&e.tx?e.tx:e.msg)))})))}},9778:(e,t,n)=>{n.d(t,{Z:()=>c});var a=n(7294);const c=function(e,t){var n=(0,a.useRef)();(0,a.useEffect)((function(){n.current=e}),[e]),(0,a.useEffect)((function(){if(null!==t){var e=setInterval((function(){n.current()}),t);return function(){return clearInterval(e)}}}),[t])}}}]);
  //# sourceMappingURL=707.0aa6735bc3f4b05d05e0.js.map