text: try{var phonecatApp=angular.module("lhcApp",["lhcAppServices","lhcAppControllers"]),services=angular.module("lhcAppServices",[]),lhcAppControllers=angular.module("lhcAppControllers",["checklist-model"]);lhcAppControllers.config(["$compileProvider",function(t){t.debugInfoEnabled(!1)}]),lhcAppControllers.run(["$http",function(t){t.defaults.headers.common["X-CSRFToken"]=confLH.csrf_token}]),angular.element(document).ready((function(){angular.element(document.querySelector("form")).triggerHandler("$destroy")})),services.factory("LiveHelperChatFactory",["$http","$q",function(t,e){return this.loadChatList=function(i){var o=e.defer();return t.get(WWW_DIR_JAVASCRIPT+"chat/syncadmininterface"+i).then((function(t){void 0!==t.error_url?document.location=t.error_url:o.resolve(t.data)}),(function(t){o.reject(void 0!==t.status?"["+t.status+"]":"[0]")})),o.promise},this.loadInitialData=function(i){var o=e.defer();return t.get(WWW_DIR_JAVASCRIPT+"chat/loadinitialdata"+i).then((function(t){void 0!==t.error_url?document.location=t.data.error_url:o.resolve(t.data)}),(function(t){o.reject(void 0!==t.status?"["+t.status+"]":"[0]")})),o.promise},this.loadActiveChats=function(){var i=e.defer();return t.get(WWW_DIR_JAVASCRIPT+"chat/loadactivechats").then((function(t){void 0!==t.error_url?document.location=t.error_url:i.resolve(t.data)}),(function(t){i.reject(void 0!==t.status?"["+t.status+"]":"[0]")})),i.promise},this.getNotificationsData=function(i){var o=e.defer();return t.get(WWW_DIR_JAVASCRIPT+"chat/getnotificationsdata/(id)/"+i).then((function(t){void 0!==t.error_url?document.location=t.data.error_url:o.resolve(t.data)}),(function(t){o.reject(void 0!==t.status?"["+t.status+"]":"[0]")})),o.promise},this.getChatData=function(i){var o=e.defer();return t.get(WWW_DIR_JAVASCRIPT+"chat/getchatdata/"+i).then((function(t){o.resolve(t.data)}),(function(t){o.reject(void 0!==t.status?"["+t.status+"]":"[0]")})),o.promise},this.setInactive=function(i){var o=e.defer();return t.get(WWW_DIR_JAVASCRIPT+"user/setinactive/"+i).then((function(t){o.resolve(t.data)}),(function(t){o.reject(void 0!==t.status?"["+t.status+"]":"[0]")})),o.promise},this.setOnlineMode=function(i){var o=e.defer();return t.get(WWW_DIR_JAVASCRIPT+"user/setoffline/"+i).then((function(t){o.resolve(t.data)}),(function(t){o.reject(void 0!==t.status?"["+t.status+"]":"[0]")})),o.promise},this.setAlwaysOnlineMode=function(i){var o=e.defer();return t.get(WWW_DIR_JAVASCRIPT+"user/setalwaysonline/"+i).then((function(t){o.resolve(t.data)}),(function(t){o.reject(void 0!==t.status?"["+t.status+"]":"[0]")})),o.promise},this.changeVisibility=function(i){var o=e.defer();return t.get(WWW_DIR_JAVASCRIPT+"user/setinvisible/"+i).then((function(t){o.resolve(t.data)}),(function(t){o.reject(void 0!==t.status?"["+t.status+"]":"[0]")})),o.promise},this.getActiveOperatorChat=function(i){var o=e.defer();return t.get(WWW_DIR_JAVASCRIPT+"groupchat/startchatwithoperator/"+i).then((function(t){o.resolve(t.data)}),(function(t){o.reject(void 0!==t.status?"["+t.status+"]":"[0]")})),o.promise},this.rejectGroupChat=function(i){var o=e.defer();return t.get(WWW_DIR_JAVASCRIPT+"groupchat/leave/"+i).then((function(t){o.resolve(t.data)}),(function(t){o.reject(void 0!==t.status?"["+t.status+"]":"[0]")})),o.promise},this.newGroupChat=function(i,o){var n=e.defer();return t.post(WWW_DIR_JAVASCRIPT+"groupchat/newgroupajax/",{name:i,public:o}).then((function(t){n.resolve(t.data)}),(function(t){n.reject(void 0!==t.status?"["+t.status+"]":"[0]")})),n.promise},this.searchProvider=function(i,o){var n=e.defer();return t.post(WWW_DIR_JAVASCRIPT+"chat/searchprovider/"+i+"/?exclude_disabled=1&q="+o).then((function(t){n.resolve(t.data)}),(function(t){n.reject(void 0!==t.status?"["+t.status+"]":"[0]")})),n.promise},this.truncate=function(t,e,i){return isNaN(e)&&(e=10),void 0===i&&(i="..."),t.length<=e||t.length-i.length<=e?t:String(t).substring(0,e-i.length)+i},this}]);var $_LHC_API={};lhcAppControllers.controller("LiveHelperChatCtrl",["$scope","$http","$location","$rootScope","$log","$interval","LiveHelperChatFactory",function(t,e,i,o,n,a,s){t.predicate="last_visit",t.pending_chats={},t.pending_chats_expanded=!0,t.active_chats={},t.active_chats_expanded=!0,t.my_active_chats_expanded=!0,t.closed_chats={},t.closed_chats_expanded=!0,t.unread_chats={},t.unread_chats_expanded=!0,t.transfer_dep_chats={},t.transfer_chats={},t.timeoutControl=null,t.setTimeoutEnabled=!0,t.lmtoggle=!1,t.lmtoggler=!1,t.custom_list_1_expanded=!0,t.custom_list_2_expanded=!0,t.custom_list_3_expanded=!0,t.custom_list_4_expanded=!0,t.current_user_id=confLH.user_id;var r=this;this.restoreLocalSetting=function(t,e,i){try{if(localStorage){var o=localStorage.getItem(t);if(null!==o){if(1==i){var n=o.split("/"),a=new Array;return angular.forEach(n,(function(t){a.push(parseInt(t))})),a}return o}return e}}catch(t){}return e},this.custom_extension_filter="",this.limitb=this.restoreLocalSetting("limitb","10",!1),this.limita=this.restoreLocalSetting("limita","10",!1),this.limitu=this.restoreLocalSetting("limitu","10",!1),this.limitp=this.restoreLocalSetting("limitp","10",!1),this.limito=this.restoreLocalSetting("limito",confLH.dlist.op_n,!1),this.limitc=this.restoreLocalSetting("limitc","10",!1),this.limitd=this.restoreLocalSetting("limitd","10",!1),this.limitmc=this.restoreLocalSetting("limitmc","10",!1),this.limitgc=this.restoreLocalSetting("limitgc","10",!1),this.limits=this.restoreLocalSetting("limits","10",!1),this.activeu=this.restoreLocalSetting("activeu",[],!0),this.pendingu=this.restoreLocalSetting("pendingu",[],!0),this.subjectu=this.restoreLocalSetting("subjectu",[],!0),t.lmtoggle="false"!=this.restoreLocalSetting("lmtoggle","false",!1),t.lmtoggler="false"!=this.restoreLocalSetting("lmtoggler","false",!1),this.lhcVersion=0,this.lhcVersionCounter=8,this.lhcPendingRefresh=!1,this.lhcConnectivityProblem=!1,this.lhcConnectivityProblemExplain="",this.lastd_activity=Math.round((new Date).getTime()/1e3),this.lastidEvent=0,this.userDepartments=[],this.userProductNames=[],this.userDepartmentsGroups=[],this.userGroups=[],this.userList=[],this.widgets=[],this.additionalColumns=[],this.excludeIcons=[],this.notifIcons=[],this.departmentd=this.restoreLocalSetting("departmentd",[],!0),this.departmentd_dpgroups=this.restoreLocalSetting("departmentd_dpgroups",[],!0),this.departmentdNames=[],this.operatord=this.restoreLocalSetting("operatord",[],!0),this.operatord_dpgroups=this.restoreLocalSetting("operatord_dpgroups",[],!0),this.operatordNames=[],this.actived=this.restoreLocalSetting("actived",[],!0),this.actived_products=this.restoreLocalSetting("actived_products",[],!0),this.actived_dpgroups=this.restoreLocalSetting("actived_dpgroups",[],!0),this.actived_ugroups=this.restoreLocalSetting("actived_ugroups",[],!0),this.activedNames=[],this.mcd=this.restoreLocalSetting("mcd",[],!0),this.mcd_products=this.restoreLocalSetting("mcd_products",[],!0),this.mcd_dpgroups=this.restoreLocalSetting("mcd_dpgroups",[],!0),this.mcdNames=[],this.unreadd=this.restoreLocalSetting("unreadd",[],!0),this.unreadd_products=this.restoreLocalSetting("unreadd_products",[],!0),this.unreadd_dpgroups=this.restoreLocalSetting("unreadd_dpgroups",[],!0),this.unreaddNames=[],this.pendingd=this.restoreLocalSetting("pendingd",[],!0),this.pendingd_products=this.restoreLocalSetting("pendingd_products",[],!0),this.pendingd_dpgroups=this.restoreLocalSetting("pendingd_dpgroups",[],!0),this.pendingd_ugroups=this.restoreLocalSetting("pendingd_ugroups",[],!0),this.pendingdNames=[],this.botd=this.restoreLocalSetting("botd",[],!0),this.botd_products=this.restoreLocalSetting("botd_products",[],!0),this.botd_dpgroups=this.restoreLocalSetting("botd_dpgroups",[],!0),this.botd_ugroups=this.restoreLocalSetting("botd_ugroups",[],!0),this.botdNames=[],this.subjectd=this.restoreLocalSetting("subjectd",[],!0),this.subjectd_products=this.restoreLocalSetting("subjectd_products",[],!0),this.subjectd_dpgroups=this.restoreLocalSetting("subjectd_dpgroups",[],!0),this.subjectd_ugroups=this.restoreLocalSetting("subjectd_ugroups",[],!0),this.subjectdNames=[],this.closedd=this.restoreLocalSetting("closedd",[],!0),this.closedd_products=this.restoreLocalSetting("closedd_products",[],!0),this.closedd_dpgroups=this.restoreLocalSetting("closedd_dpgroups",[],!0),this.closeddNames=[],this.statusNotifications=[],this.isListLoaded=!1,this.widgetsItems=new Array,this.widgetsItems.push("actived"),this.widgetsItems.push("departmentd"),this.widgetsItems.push("unreadd"),this.widgetsItems.push("pendingd"),this.widgetsItems.push("operatord"),this.widgetsItems.push("closedd"),this.widgetsItems.push("mcd"),this.widgetsItems.push("botd"),this.widgetsItems.push("subjectd"),r.departmentd_hide_dep="false"!=r.restoreLocalSetting("departmentd_hide_dep","false",!1),r.departmentd_hide_dgroup="false"!=r.restoreLocalSetting("departmentd_hide_dgroup","false",!1),this.timeoutActivity=null,this.timeoutActivityTime=300,this.blockSync=!1,this.hideOnline=!1,this.hideInvisible=!1,this.alwaysOnline=!1,this.inActive=!1,this.bot_st={},ee.addListener("angularSyncDisabled",(function(e){t.syncDisabled(e)})),ee.addListener("angularLoadChatList",(function(){t.loadChatList()})),ee.addListener("angularStartChatOperatorPublic",(function(e){t.startChatOperatorPublic(e)})),ee.addListener("angularStartChatbyId",(function(t){r.startChatByID(t)})),this.changeVisibility=function(t){t&&(t.stopPropagation(),t.preventDefault()),s.changeVisibility(1==!r.hideInvisible?"true":"false").then((function(t){!1===t.error?r.hideInvisible=!r.hideInvisible:void 0!==t.msg?alert(t.msg):alert(t)}),(function(t){alert("We could not change your status!")}))},this.changeAlwaysOnline=function(t){t&&(t.stopPropagation(),t.preventDefault()),s.setAlwaysOnlineMode(1==!r.alwaysOnline?"true":"false").then((function(t){!1===t.error?r.alwaysOnline=!r.alwaysOnline:void 0!==t.msg?alert(t.msg):alert(t)}),(function(t){alert("We could not change your status! "+t)}))},this.changeOnline=function(t){t&&(t.stopPropagation(),t.preventDefault()),s.setOnlineMode(1==!r.hideOnline?"true":"false").then((function(t){!1===t.error?r.hideOnline=!r.hideOnline:void 0!==t.msg?alert(t.msg):alert(t)}),(function(t){alert("We could not change your status! "+t)}))},angular.forEach(this.widgetsItems,(function(t){r[t+"_all_departments"]="false"!=r.restoreLocalSetting(t+"_all_departments","false",!1),r[t+"_hide_hidden"]="false"!=r.restoreLocalSetting(t+"_hide_hidden","false",!1),r[t+"_hide_disabled"]="false"!=r.restoreLocalSetting(t+"_hide_disabled","false",!1),r[t+"_only_online"]="false"!=r.restoreLocalSetting(t+"_only_online","false",!1),r[t+"_only_explicit_online"]="false"!=r.restoreLocalSetting(t+"_only_explicit_online","false",!1)})),this.storeLocalSetting=function(t,e){if(localStorage)try{e=localStorage.setItem(t,e)}catch(t){}},this.removeLocalSetting=function(t){if(localStorage)try{localStorage.removeItem(t)}catch(t){}},this.toggleList=function(e){if(t[e]=!t[e],localStorage)try{localStorage.setItem(e,t[e])}catch(t){}},this.toggleWidgetData=[],this.toggleWidget=function(e,i){if(r.toggleWidgetData[e]=void 0===r.toggleWidgetData[e]||!r.toggleWidgetData[e],localStorage)try{localStorage.setItem(e,r.toggleWidgetData[e])}catch(t){}void 0!==i&&1==i&&(r.isListLoaded=!1,t.loadChatList())},this.toggleWidgetSort=function(e,i,o,n){if(r.toggleWidgetData[e]=void 0===r.toggleWidgetData[e]?i:r.toggleWidgetData[e]==i?o:i,localStorage)try{localStorage.setItem(e,r.toggleWidgetData[e])}catch(t){}void 0!==n&&1==n&&(r.isListLoaded=!1,t.loadChatList())},this.getToggleWidget=function(t,e){this.toggleWidgetData[t]="false"!=this.restoreLocalSetting(t,void 0===e?"false":e,!1)},this.getToggleWidgetSort=function(t){this.toggleWidgetData[t]=this.restoreLocalSetting(t,"",!1)},t.getSyncFilter=function(){r.custom_extension_filter="";var e="/(limita)/"+parseInt(r.limita);if(e+="/(limitu)/"+parseInt(r.limitu),e+="/(limitp)/"+parseInt(r.limitp),e+="/(limito)/"+parseInt(r.limito),e+="/(limitc)/"+parseInt(r.limitc),e+="/(limitd)/"+parseInt(r.limitd),e+="/(limits)/"+parseInt(r.limits),e+="/(limitmc)/"+parseInt(r.limitmc),e+="/(limitb)/"+parseInt(r.limitb),e+="/(limitgc)/"+parseInt(r.limitgc),"object"==typeof r.widgetsActive&&r.widgetsActive.length>0){var i={my_chats:0,online_operators:1,group_chats:2,pending_chats:3,online_visitors:4,unread_chats:5,active_chats:6,bot_chats:7,transfered_chats:8,departments_stats:9,subject_chats:20},o=[];angular.forEach(r.widgetsActive,(function(t){i[t]&&o.push(i[t])})),e+="/(w)/"+o.join("/")}("object"==typeof r.activeu&&r.activeu.length>0&&(e+="/(activeu)/"+r.activeu.join("/")),"object"==typeof r.pendingu&&r.pendingu.length>0&&(e+="/(pendingu)/"+r.pendingu.join("/")),"object"==typeof r.subjectu&&r.subjectu.length>0&&(e+="/(subjectu)/"+r.subjectu.join("/")),"object"==typeof r.actived_dpgroups&&r.actived_dpgroups.length>0&&(e+="/(adgroups)/"+r.actived_dpgroups.join("/")),"object"==typeof r.pendingd_dpgroups&&r.pendingd_dpgroups.length>0&&(e+="/(pdgroups)/"+r.pendingd_dpgroups.join("/")),"object"==typeof r.subjectd_dpgroups&&r.subjectd_dpgroups.length>0&&(e+="/(sdgroups)/"+r.subjectd_dpgroups.join("/")),"object"==typeof r.closedd_dpgroups&&r.closedd_dpgroups.length>0&&(e+="/(cdgroups)/"+r.closedd_dpgroups.join("/")),"object"==typeof r.botd_dpgroups&&r.botd_dpgroups.length>0&&(e+="/(bdgroups)/"+r.botd_dpgroups.join("/")),"object"==typeof r.mcd_dpgroups&&r.mcd_dpgroups.length>0&&(e+="/(mdgroups)/"+r.mcd_dpgroups.join("/")),"object"==typeof r.unreadd_dpgroups&&r.unreadd_dpgroups.length>0&&(e+="/(udgroups)/"+r.unreadd_dpgroups.join("/")),"object"==typeof r.departmentd_dpgroups&&r.departmentd_dpgroups.length>0&&(e+="/(ddgroups)/"+r.departmentd_dpgroups.join("/")),"object"==typeof r.operatord_dpgroups&&r.operatord_dpgroups.length>0&&(e+="/(odpgroups)/"+r.operatord_dpgroups.join("/")),"object"==typeof r.actived)&&(r.actived.length>0?e+="/(actived)/"+r.actived.join("/"):(n=r.manualFilterByFilter("actived")).length>0&&(e+="/(actived)/"+n.join("/")));"object"==typeof r.subjectd&&(r.subjectd.length>0?e+="/(subjectd)/"+r.subjectd.join("/"):(n=r.manualFilterByFilter("subjectd")).length>0&&(e+="/(subjectd)/"+n.join("/")));"object"==typeof r.mcd&&(r.mcd.length>0?e+="/(mcd)/"+r.mcd.join("/"):(n=r.manualFilterByFilter("mcd")).length>0&&(e+="/(mcd)/"+n.join("/")));"object"==typeof r.unreadd&&(r.unreadd.length>0?e+="/(unreadd)/"+r.unreadd.join("/"):(n=r.manualFilterByFilter("unreadd")).length>0&&(e+="/(unreadd)/"+n.join("/")));"object"==typeof r.botd&&(r.botd.length>0?e+="/(botd)/"+r.botd.join("/"):(n=r.manualFilterByFilter("botd")).length>0&&(e+="/(botd)/"+n.join("/")));if("object"==typeof r.pendingd){var n;if(r.pendingd.length>0)e+="/(pendingd)/"+r.pendingd.join("/");else(n=r.manualFilterByFilter("pendingd")).length>0&&(e+="/(pendingd)/"+n.join("/"));void 0!==r.toggleWidgetData.pending_chats_sort&&1==r.toggleWidgetData.pending_chats_sort&&(e+="/(psort)/asc")}"object"==typeof r.operatord&&(r.operatord.length>0?e+="/(operatord)/"+r.operatord.join("/"):(n=r.manualFilterByFilter("operatord")).length>0&&(e+="/(operatord)/"+n.join("/")));("object"==typeof r.closedd&&r.closedd.length>0&&(e+="/(closedd)/"+r.closedd.join("/")),"object"==typeof r.departmentd)&&(r.departmentd.length>0?e+="/(departmentd)/"+r.departmentd.join("/"):(n=r.manualFilterByFilter("departmentd")).length>0&&(e+="/(departmentd)/"+n.join("/")));"object"==typeof r.actived_products&&r.actived_products.length>0&&(e+="/(activedprod)/"+r.actived_products.join("/")),"object"==typeof r.pendingd_ugroups&&r.pendingd_ugroups.length>0&&(e+="/(pugroups)/"+r.pendingd_ugroups.join("/")),"object"==typeof r.subjectd_ugroups&&r.subjectd_ugroups.length>0&&(e+="/(sugroups)/"+r.subjectd_ugroups.join("/")),"object"==typeof r.actived_ugroups&&r.actived_ugroups.length>0&&(e+="/(augroups)/"+r.actived_ugroups.join("/")),"object"==typeof r.mcd_products&&r.mcd_products.length>0&&(e+="/(mcdprod)/"+r.mcd_products.join("/")),"object"==typeof r.unreadd_products&&r.unreadd_products.length>0&&(e+="/(unreaddprod)/"+r.unreadd_products.join("/")),"object"==typeof r.pendingd_products&&r.pendingd_products.length>0&&(e+="/(pendingdprod)/"+r.pendingd_products.join("/")),"object"==typeof r.subjectd_products&&r.subjectd_products.length>0&&(e+="/(subjectdprod)/"+r.subjectd_products.join("/")),"object"==typeof r.botd_products&&r.botd_products.length>0&&(e+="/(botdprod)/"+r.botd_products.join("/")),"object"==typeof r.closedd_products&&r.closedd_products.length>0&&(e+="/(closeddprod)/"+r.closedd_products.join("/")),void 0!==r.toggleWidgetData.track_open_chats&&1==r.toggleWidgetData.track_open_chats&&(e+="/(topen)/true"),void 0!==r.toggleWidgetData.active_chats_sort&&""!==r.toggleWidgetData.active_chats_sort&&(e+="/(acs)/"+r.toggleWidgetData.active_chats_sort),void 0!==r.toggleWidgetData.closed_chats_sort&&""!==r.toggleWidgetData.closed_chats_sort&&(e+="/(clcs)/"+r.toggleWidgetData.closed_chats_sort),void 0!==r.toggleWidgetData.onop_sort&&""!==r.toggleWidgetData.onop_sort&&(e+="/(onop)/"+r.toggleWidgetData.onop_sort);var a=[];return!0===r.departmentd_hide_dep&&a.push("dhdep"),!0===r.departmentd_hide_dgroup&&a.push("dhdepg"),a.length>0&&(e+="/(hsub)/"+a.join("/")),r.lastd_activity>0&&(e+="/(lda)/"+r.lastd_activity),r.lastd_activity=0,ee.emitEvent("eventGetSyncFilter",[r,t]),e+=r.custom_extension_filter},t.$watch("lhc.limita",(function(e,i){e!=i&&(r.storeLocalSetting("limita",e),r.isListLoaded=!1,t.loadChatList())})),this.manualFilterByFilter=function(t){if((1==r[t+"_only_explicit_online"]||1==r[t+"_hide_hidden"]||1==r[t+"_hide_disabled"]||1==r[t+"_only_online"])&&r.userDepartments.length>0){var e=[];return angular.forEach(r.userDepartments,(function(i){(0==r[t+"_only_explicit_online"]||1==r[t+"_only_explicit_online"]&&1==i.oexp)&&(0==r[t+"_hide_hidden"]||1==r[t+"_hide_hidden"]&&0==i.hidden)&&(0==r[t+"_hide_disabled"]||1==r[t+"_hide_disabled"]&&0==i.disabled)&&(0==r[t+"_only_online"]||1==r[t+"_only_online"]&&1==i.ogen)&&e.push(i.id)})),0==e.length&&e.push(-1),e}return[]},this.setDepartmentNames=function(t){r[t+"Names"]=[],angular.forEach(r[t],(function(e){void 0!==r.userDepartmentsNames&&void 0!==r.userDepartmentsNames[e]?r[t+"Names"].push(r.userDepartmentsNames[e]):void 0!==r.userDepartmentsNames&&(r[t].splice(r[t].indexOf(e),1),r.departmentChanged(t))}))},this.departmentChanged=function(e){if(r[e].length>0){r[e+"_all_departments"]=!1,r.allDepartmentsChanged(e,!1);var i=r[e].join("/");""!=i&&(r.storeLocalSetting(e,i),r.setDepartmentNames(e))}else if(localStorage)try{localStorage.removeItem(e)}catch(t){}r.isListLoaded=!1,t.loadChatList()},this.productChanged=function(e){if(r[e].length>0){var i=r[e].join("/");""!=i&&r.storeLocalSetting(e,i)}else if(localStorage)try{localStorage.removeItem(e)}catch(t){}r.isListLoaded=!1,t.loadChatList()},this.allDepartmentsChanged=function(e,i){1==r[e+"_all_departments"]?r.storeLocalSetting(e+"_all_departments",!0):r.removeLocalSetting(e+"_all_departments"),1==r[e+"_hide_hidden"]?r.storeLocalSetting(e+"_hide_hidden",!0):r.removeLocalSetting(e+"_hide_hidden"),1==r[e+"_hide_disabled"]?r.storeLocalSetting(e+"_hide_disabled",!0):r.removeLocalSetting(e+"_hide_disabled"),1==r[e+"_only_online"]?r.storeLocalSetting(e+"_only_online",!0):r.removeLocalSetting(e+"_only_online"),void 0!==r[e+"_hide_dep"]&&(1==r[e+"_hide_dep"]?r.storeLocalSetting(e+"_hide_dep",!0):r.removeLocalSetting(e+"_hide_dep")),void 0!==r[e+"_hide_dgroup"]&&(1==r[e+"_hide_dgroup"]?r.storeLocalSetting(e+"_hide_dgroup",!0):r.removeLocalSetting(e+"_hide_dgroup")),1==r[e+"_all_departments"]?(r[e]=[],angular.forEach(r.userDepartments,(function(t){(0==r[e+"_only_explicit_online"]||1==r[e+"_only_explicit_online"]&&1==t.oexp)&&(0==r[e+"_hide_hidden"]||1==r[e+"_hide_hidden"]&&0==t.hidden)&&(0==r[e+"_hide_disabled"]||1==r[e+"_hide_disabled"]&&0==t.disabled)&&(0==r[e+"_only_online"]||1==r[e+"_only_online"]&&1==t.ogen)&&r[e].push(t.id)})),0==r[e].length&&r[e].push(-1)):1==i&&(r[e]=[]),1==i&&(r.isListLoaded=!1,t.loadChatList())},t.$watch("lhc.limitu",(function(e,i){e!=i&&(r.storeLocalSetting("limitu",e),t.loadChatList())})),t.$watch("lhc.limitc",(function(e,i){e!=i&&(r.storeLocalSetting("limitc",e),t.loadChatList())})),t.$watch("lhc.limitp",(function(e,i){e!=i&&(r.storeLocalSetting("limitp",e),t.loadChatList())})),t.$watch("lhc.limito",(function(e,i){e!=i&&(r.storeLocalSetting("limito",e),t.loadChatList())})),t.$watch("lhc.limitmc",(function(e,i){e!=i&&(r.storeLocalSetting("limitmc",e),t.loadChatList())})),t.$watch("lhc.limitgc",(function(e,i){e!=i&&(r.storeLocalSetting("limitgc",e),t.loadChatList())})),t.$watch("lhc.limitd",(function(e,i){e!=i&&(r.storeLocalSetting("limitd",e),t.loadChatList())})),t.$watch("lhc.activeu",(function(e,i){e!=i&&(r.storeLocalSetting("activeu",e),r.isListLoaded=!1,t.loadChatList())})),t.$watch("lhc.pendingu",(function(e,i){e!=i&&(r.storeLocalSetting("pendingu",e),r.isListLoaded=!1,t.loadChatList())})),t.$watch("lhc.subjectu",(function(e,i){e!=i&&(r.storeLocalSetting("subjectu",e),r.isListLoaded=!1,t.loadChatList())})),t.syncDisabled=function(t){r.blockSync=t},t.loadChatList=function(){if(localStorage)try{t.pending_chats_expanded="false"!=localStorage.getItem("pending_chats_expanded"),t.active_chats_expanded="false"!=localStorage.getItem("active_chats_expanded"),t.my_active_chats_expanded="false"!=localStorage.getItem("my_active_chats_expanded"),t.closed_chats_expanded="false"!=localStorage.getItem("closed_chats_expanded"),t.unread_chats_expanded="false"!=localStorage.getItem("unread_chats_expanded"),t.my_chats_expanded="false"!=localStorage.getItem("my_chats_expanded"),t.custom_list_1_expanded="false"!=localStorage.getItem("custom_list_1_expanded"),t.custom_list_2_expanded="false"!=localStorage.getItem("custom_list_2_expanded"),t.custom_list_3_expanded="false"!=localStorage.getItem("custom_list_3_expanded"),t.custom_list_4_expanded="false"!=localStorage.getItem("custom_list_4_expanded")}catch(t){}if(1==r.blockSync)return clearTimeout(t.timeoutControl),void(t.timeoutControl=setTimeout((function(){r.isListLoaded=!1,t.loadChatList()}),confLH.back_office_sinterval));clearTimeout(t.timeoutControl),s.loadChatList(t.getSyncFilter()).then((function(e){if(e.logout||e.error_url)document.location.reload();else{if(1==r.blockSync)return clearTimeout(t.timeoutControl),void(t.timeoutControl=setTimeout((function(){r.isListLoaded=!1,t.loadChatList()}),confLH.back_office_sinterval));if(1==r.lhcConnectivityProblem&&(r.lhcConnectivityProblem=!1),ee.emitEvent("eventLoadChatList",[e,t,r]),void 0===e.items_processed){var i=[],o=[],n=[],a=[],d=$("#tabs");angular.forEach(e.result,(function(e,c){if(t[c]=e,d.length>0&&("pending_chat"==c||"my_chats"==c?e.list.forEach((function(t){void 0!==t.user_id&&t.user_id==confLH.user_id&&1==confLH.accept_chats&&(1!==t.status||1===t.status&&!0===t.hum)&&0==$("#chat-tab-link-"+t.id).length&&(d.length>0&&0==lhinst.disableremember&&(lhinst.removeSynchroChat(t.id),lhinst.startChatBackground(t.id,d,s.truncate(t.nick||"Visitor",10))),0==lhinst.disableremember&&a.push(t.id))})):"group_chats"==c?d.length>0&&1==confLH.auto_join_private&&e.list.forEach((function(t){1==t.type&&0==t.jtime&&0==$("#chat-tab-link-gc"+t.id).length&&lhinst.startGroupChat(t.id,d,s.truncate(t.name,10),!0)})):"support_chats"==c&&d.length>0&&1==confLH.auto_join_private&&e.list.forEach((function(t){null===document.getElementById("chat-tab-li-"+t.chat_id)?r.startChatByID(t.chat_id,!0):$("#private-chat-tab-link-"+t.chat_id).attr("private-loaded")?$("#chat-tab-link-"+t.chat_id).hasClass("active")?$("#private-chat-tab-link-"+t.chat_id).hasClass("active")||$("#private-chat-tab-link-"+t.chat_id+" > .whatshot").removeClass("d-none"):$("#chat-tab-link-"+t.chat_id+" > .whatshot").removeClass("d-none"):($("#private-chat-tab-link-"+t.chat_id).attr("private-loaded",!0),ee.emitEvent("privateChatStart",[t.chat_id,{unread:!0}]))}))),e.last_id_identifier){o=[],i=[];var l=0,u=e.list;"pending_chat"==e.last_id_identifier&&void 0!==r.toggleWidgetData.pending_chats_sort&&1==r.toggleWidgetData.pending_chats_sort&&(u=e.list.slice().reverse()),angular.forEach(u,(function(t,n){var a=void 0!==t.user_id?t.user_id:0,s=t.id+"_"+a;if(("bot_chats"!=e.last_id_identifier||t.msg_v&&t.msg_v>r.bot_st.msg_nm&&1==r.bot_st.bot_notifications||t.aalert)&&"transfer_chat_dep"!=e.last_id_identifier){var d=[];if("active_chats"==e.last_id_identifier&&t.aicons&&(s+="_"+(d=Object.keys(t.aicons)).join("_")),i.push(s),void 0===r.statusNotifications[e.last_id_identifier]&&(r.statusNotifications[e.last_id_identifier]=new Array),1==r.isListLoaded&&"active_chats"==e.last_id_identifier){if(-1==r.statusNotifications[e.last_id_identifier].indexOf(s)&&d.length>0&&r.notifIcons.length>0){var c=r.notifIcons.filter((function(t){return-1===r.excludeIcons.indexOf(t)&&-1!==d.indexOf(t)}));c.length>0&&o.push(t.id+"__"+c.join("__"))}}else 1!=r.isListLoaded||0!=l&&2!==t.status_sub_sub||!(-1==r.statusNotifications[e.last_id_identifier].indexOf(s)&&0==a&&0==confLH.ownntfonly||-1==r.statusNotifications[e.last_id_identifier].indexOf(s)&&a==confLH.user_id)?l++:-1===lhinst.chatsSynchronising.indexOf(parseInt(t.id))&&o.push(t.id)}})),o.length>0&&(o.unshift(e.last_id_identifier),n.push(o.join("/"))),1==r.isListLoaded&&r.compareNotificationsAndHide(r.statusNotifications[e.last_id_identifier],i),r.statusNotifications[e.last_id_identifier]=i}})),a.length>0&&(a.unshift("active_chat"),s.getNotificationsData(a.join("/")).then((function(t){angular.forEach(t,(function(t,e){lhinst.removeBackgroundChat(parseInt(t.last_id)),lhinst.playSoundNewAction(t.last_id_identifier,parseInt(t.last_id),t.nick?t.nick:"Live Help",t.msg?t.msg:confLH.transLation.new_chat,t.nt),lhinst.backgroundChats.push(parseInt(t.last_id))}))}))),n.length>0&&s.getNotificationsData(n.join("/")).then((function(t){angular.forEach(t,(function(t,e){lhinst.playSoundNewAction(t.last_id_identifier,parseInt(t.last_id),t.nick?t.nick:"Live Help",t.msg?t.msg:confLH.transLation.new_chat,t.nt)}))}))}if(void 0!==e.ou&&1==e.ou){$("#lhc_op_operation").remove();var c=document.getElementsByTagName("head")[0],l=document.createElement("script");l.setAttribute("id","lhc_op_operation"),l.setAttribute("type","text/javascript"),l.setAttribute("src",WWW_DIR_JAVASCRIPT+"chat/loadoperatorjs"),c.appendChild(l)}if(void 0!==e.fs&&e.fs.length>0&&angular.forEach(e.fs,(function(t,e){lhinst.playSoundNewAction("pending_transfered",parseInt(t.id),t.nick?t.nick:"Live Help",confLH.transLation.transfered,t.nt,t.uid)})),void 0!==e.mac&&e.mac.length>0)(d=$("#tabs")).length>0&&0==lhinst.disableremember&&angular.forEach(e.mac,(function(t,e){lhinst.startChatBackground(t.id,d,s.truncate(t.nick||"Visitor",10),!1)}));r.hideOnline=1==e.ho,r.hideInvisible=1==e.im,r.alwaysOnline=1==e.a_on,r.inActive=1==e.ina,r.lhcVersion!=e.v&&(r.lhcVersion=e.v,r.lhcPendingRefresh=!0,r.versionChanged()),1==t.setTimeoutEnabled&&(t.timeoutControl=setTimeout((function(){t.loadChatList()}),confLH.back_office_sinterval)),r.isListLoaded=!0}}),(function(e){r.lhcConnectivityProblem=!0,r.lhcConnectivityProblemExplain=e,t.timeoutControl=setTimeout((function(){t.loadChatList()}),confLH.back_office_sinterval)}))},this.versionChanged=function(){var t=this;a((function(){t.lhcVersionCounter=t.lhcVersionCounter-1,console.log(t.lhcVersionCounter),0==t.lhcVersionCounter&&document.location.reload(!0)}),1e3)},this.compareNotificationsAndHide=function(t,e){if(void 0!==t)for(var i=t.length-1;i>=0;i--){var o=t[i];-1===e.indexOf(o)&&lhinst.hideNotification(o.split("_")[0])}},this.appendActiveChats=function(){s.loadActiveChats().then((function(t){var e=$("#tabs");angular.forEach(t.result,(function(t,i){lhinst.startChatBackground(t.id,e,s.truncate(t.nick||"Visitor",10))})),setTimeout((function(){lhinst.syncadmininterfacestatic()}),1e3)}))},this.previewChat=function(t,e){e&&e.stopPropagation(),lhc.previewChat(t)},this.previewChatArchive=function(t,e,i){i&&i.stopPropagation(),lhc.previewChatArchive(t,e)},this.redirectContact=function(t,e,i){return i&&i.stopPropagation(),lhinst.redirectContact(t,e)},this.startChatNewWindow=function(t,e,i){return i&&i.stopPropagation(),lhinst.startChatNewWindow(t,e)},this.deleteChat=function(t,e,i){return lhinst.deleteChat(t,e,i)},this.startGroupChat=function(t,e){if($("#tabs").length>0)return lhinst.startGroupChat(t,$("#tabs"),s.truncate(e,10))},this.startChatByID=function(t,e){if(!isNaN(t)&&$("#tabs").length>0){$("#menu-chat-options").dropdown("toggle");var i=this;s.getChatData(t).then((function(o){e?lhinst.startChatBackground(parseInt(t),$("#tabs"),s.truncate(o.nick||"Visitor",10),"backgroundid"):i.startChat(parseInt(t),s.truncate(o.nick||"Visitor",10))}))}},this.startChat=function(t,e){if($("#tabs").length>0)return lhinst.startChat(t,$("#tabs"),s.truncate(e||"Visitor",10));lhinst.startChatNewWindow(t,e)},this.startChatNewWindowTransfer=function(t,e,i){return lhinst.startChatNewWindowTransfer(t,e,i)},this.startChatTransfer=function(t,e,i){return lhinst.startChatTransfer(t,$("#tabs"),e,i)},t.startChatOperatorPublic=function(t){r.startChatOperator(t)},this.startChatOperator=function(t){s.getActiveOperatorChat(t).then((function(t){lhinst.startGroupChat(t.id,$("#tabs"),s.truncate(t.name,10))}))},this.openModal=function(e){lhc.revealModal({url:WWW_DIR_JAVASCRIPT+e,hidecallback:function(){t.loadChatList()}})},this.addEvent=function(){var t=this;return document.addEventListener?function(e,i,o){if(e&&e.nodeName||e===window)e.addEventListener(i,o,!1);else if(e&&e.length)for(var n=0;n<e.length;n++)t.addEvent(e[n],i,o)}:function(e,i,o){if(e&&e.nodeName||e===window)e.attachEvent("on"+i,(function(){return o.call(e,window.event)}));else if(e&&e.length)for(var n=0;n<e.length;n++)t.addEvent(e[n],i,o)}}(),this.setupActivityMonitoring=function(){var t=this,e=function(){t.resetTimeoutActivity()};this.addEvent(window,"mousemove",e),this.addEvent(document,"mousemove",e),this.addEvent(window,"mousedown",e),this.addEvent(window,"click",e),this.addEvent(window,"scroll",e),this.addEvent(window,"keypress",e),this.addEvent(window,"load",e),this.addEvent(document,"scroll",e),this.addEvent(document,"touchstart",e),this.addEvent(document,"touchend",e),this.resetTimeoutActivity()},t.resetActivityFromChild=function(){r.resetTimeoutActivity()},this.resetTimeoutActivity=function(){var e=window.opener;if(e)try{e.angular.element("body").scope().resetActivityFromChild()}catch(t){console.log(t)}else if(0==this.blockSync){this.lastd_activity=Math.round((new Date).getTime()/1e3),clearTimeout(this.timeoutActivity);var i=this;this.timeoutActivity=setTimeout((function(){s.setInactive("true").then((function(e){if(1==e.active)return i.resetTimeoutActivity(),void(i.lastd_activity=0);i.blockSync=!0,lhinst.disableSync=!0,lhc.revealModal({url:WWW_DIR_JAVASCRIPT+"user/wentinactive/false",backdrop:!0,hidecallback:function(){s.setInactive("false"),i.isListLoaded=!1,i.blockSync=!1,i.resetTimeoutActivity(),lhinst.disableSync=!1,t.loadChatList(),i.inActive=!1}})}))}),1e3*i.timeoutActivityTime)}},this.getOpenedChatIds=function(t){if(localStorage)try{var e=localStorage.getItem(t);if(null!==e&&""!==e)return achat_id_array=e.split(",")}catch(t){}return[]},t.loadchatMessagesScope=function(){lhinst.syncadmincall()},this.verifyFilters=function(){var t=[],e=[],i=[],o=[];angular.forEach(r.userGroups,(function(t){e.push(t.id)})),angular.forEach(r.userDepartmentsGroups,(function(t){i.push(t.id)})),angular.forEach(r.userProductNames,(function(t){o.push(t.id)})),s.searchProvider("users_ids",r.pendingu.join(",")+","+r.activeu.join(",")).then((function(n){r.userList=n.items,angular.forEach(r.userList,(function(e){t.push(e.id)}));var a={activeu:t,actived_products:o,actived_ugroups:e,actived_dpgroups:i,pendingu:t,pendingd_ugroups:e,pendingd_dpgroups:i,pendingd_products:o,botd_dpgroups:i,botd_products:o,departmentd_dpgroups:i,closedd_products:o,closedd_dpgroups:i,unreadd_dpgroups:i,unreadd_products:o,mcd_products:o,mcd_dpgroups:i};angular.forEach(a,(function(t,e){var i=[...r[e]];angular.forEach(i,(function(i){-1===t.indexOf(i)&&(r[e].splice(r[e].indexOf(i),1),r.productChanged(e))}))}))}))},this.rejectGroupChat=function(e){s.rejectGroupChat(e).then((function(e){t.loadChatList()}))},this.startNewGroupChat=function(e,i){s.newGroupChat(e,i).then((function(e){lhinst.startGroupChat(e.id,$("#tabs"),s.truncate(e.name,10)),t.loadChatList(),r.new_group_name="",r.new_group_type=""}))},t.$watch("lhc.userFilterText",(function(t,e){t!=e&&s.searchProvider("users",t).then((function(t){r.userList=t.items}))})),this.initLHCData=function(){var e="",i=this.getOpenedChatIds("achat_id"),o=this.getOpenedChatIds("gachat_id"),n=0,a=window.location.hash;if(""!=a){var d=a.match(/\d+$/);null!==d&&d[0]&&(n=parseInt(d[0]),-1===i.indexOf(n)&&i.push(n))}var c=document.getElementById("load_chat_id");c&&-1===i.indexOf(c.value)&&(n=c.value,i.push(c.value),window.location.hash="#!#chat-id-"+c.value),$("#tabs").length>0&&0==lhinst.disableremember&&i.length>0&&(e="/(chatopen)/"+i.join("/")),$("#tabs").length>0&&0==lhinst.disableremember&&o.length>0&&(e+="/(chatgopen)/"+o.join("/")),s.loadInitialData(e).then((function(e){e.logout||e.error_url?document.location.reload():(r.userDepartmentsNames=e.dp_names,r.userDepartments=e.dep_list,r.userProductNames=e.pr_names,r.userDepartmentsGroups=e.dp_groups,r.userGroups=e.user_groups,r.hideInvisible=e.im,r.hideOnline=e.ho,r.lhcVersion=e.v,r.alwaysOnline=e.a_on,r.additionalColumns=e.col,r.widgetsActive=e.widgets,r.bot_st=e.bot_st,r.excludeIcons=e.exc_ic,r.notifIcons=e.not_ic,angular.forEach(r.widgetsItems,(function(t){r.setDepartmentNames(t)})),1==e.track_activity&&(r.timeoutActivityTime=e.timeout_activity,r.setupActivityMonitoring()),angular.forEach(e.copen,(function(t){lhinst.startChat(t.id,$("#tabs"),s.truncate(t.nick||"Visitor",10),t.id==n,0,t.status)})),angular.forEach(e.cgopen,(function(t){lhinst.startGroupChat(t.id,$("#tabs"),s.truncate(t.nick||"Visitor",10),!0)})),angular.forEach(e.cdel,(function(t){lhinst.forgetChat(t,"achat_id")})),angular.forEach(e.cgdel,(function(t){lhinst.forgetChat(t,"gachat_id")})),ee.emitEvent("eventLoadInitialData",[e,t,r]),$_LHC_API.initial_data=e,r.verifyFilters(),t.loadChatList())}))},this.initLHCData()}])}catch(t){if(!lhcError)throw Error("lhc : "+t.message);lhcError.log(t.message,"angular.lhc.js",t.lineNumber||t.line,t.stack)}