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AAA,OAAwB5C,SAAU+C,EAAO,EAAKK,0BAA2B,oBAAoBL,mB,EAxNvHpF","sources":["webpack://LiveHelperChat/./src/util/proactiveChat.js"],"sourcesContent":["import {helperFunctions} from '../lib/helperFunctions';\nimport {domEventsHandler} from '../util/domEventsHandler';\n\nclass _proactiveChat {\n\n constructor() {\n this.params = {};\n this.timeoutStatuscheck = null;\n this.timeoutActivity = null;\n this.attributes = null;\n this.chatEvents = null;\n this.dynamicInvitations = [];\n\n this.iddleTimeoutActivity = null;\n this.checkMessageTimeout = null;\n this.nextRescheduleTimeout = null;\n this.initCall = true;\n this.inProgress = false;\n }\n\n setParams(params, attributes, chatEvents) {\n this.params = params;\n this.attributes = attributes;\n this.chatEvents = chatEvents;\n\n if (this.attributes.events.length > 0) {\n this.storeEvents(this.attributes.events);\n } else {\n this.initInvitation();\n }\n\n // check invitaiton then tag is added\n this.attributes.eventEmitter.addListener('tagAdded', () => {\n this.initInvitation({init: 0});\n });\n\n this.attributes.eventEmitter.addListener('eventAdded', () => {\n this.storeEvents(this.attributes.events);\n });\n\n this.attributes.eventEmitter.addListener('checkMessageOperator', () => {\n this.initInvitation({init: 0});\n });\n\n this.attributes.eventEmitter.addListener('endChat', () => {\n this.initInvitation({init: 0});\n });\n\n this.attributes.onlineStatus.subscribe((data) => {\n if (data == true) {\n this.initInvitation({init: 0});\n } else {\n const chatParams = this.attributes['userSession'].getSessionAttributes();\n if (!chatParams['id'] && this.attributes.proactive.invitation) {\n this.attributes.proactive = {};\n if (this.attributes.mainWidget.isLoaded !== false) {\n this.chatEvents.sendChildEvent('proactive', [{}]);\n }\n this.attributes.mainWidget.hideInvitation();\n this.attributes.eventEmitter.emitEvent('closeWidget', [{'sender' : 'closeButton'}]);\n }\n }\n });\n }\n\n showInvitation(params, init) {\n const chatParams = this.attributes['userSession'].getSessionAttributes();\n\n // Show invitation only if widget is not open\n if ((init === 0 && (this.attributes.widgetStatus.value === true && !this.attributes.mode == 'embed')) || chatParams['id']) {\n return;\n }\n\n if (params.inject_html && params.invitation) {\n var th = document.getElementsByTagName('head')[0];\n var s = document.createElement('script');\n s.setAttribute('type','text/javascript');\n s.setAttribute('src', this.attributes.LHC_API.args.lhc_base_url + this.attributes['lang'] + 'chat/htmlsnippet/'+params.invitation+'/inv/0/?ts='+Date.now());\n th.appendChild(s);\n }\n\n if (!params.only_inject) {\n this.attributes.proactive = params;\n\n if (this.attributes.mainWidget.isLoaded === false) {\n this.attributes.mainWidget.bootstrap();\n } else {\n this.chatEvents.sendChildEvent('proactive', [params]);\n }\n\n clearTimeout(this.checkMessageTimeout);\n clearTimeout(this.nextRescheduleTimeout);\n }\n }\n\n storeEvents(events) {\n const chatParams = this.attributes['userSession'].getSessionAttributes();\n if (!chatParams['id'] && this.attributes['onlineStatus'].value == true) {\n helperFunctions.makeRequest(this.attributes.LHC_API.args.lhc_base_url + this.attributes['lang'] + 'chat/logevent/(vid)/' + this.attributes.userSession.getVID(), {params: {'data' : JSON.stringify(events)}}, (data) => {\n this.initInvitation({init: 0});\n })\n }\n }\n\n initInvitation(paramsExecution) {\n\n if (this.inProgress == true) {\n return ;\n }\n\n clearTimeout(this.checkMessageTimeout);\n\n const chatParams = this.attributes['userSession'].getSessionAttributes();\n\n const init = (paramsExecution && paramsExecution['init'] === 0) ? 0 : 1;\n\n if (!chatParams['id'] && this.attributes['onlineStatus'].value == true) {\n\n this.inProgress = true;\n\n let params = {\n 'vid': this.attributes.userSession.getVID(),\n 'dep': this.attributes.department.join(',')\n };\n\n if (this.attributes.LHC_API.args.priority) {\n params['priority'] = this.attributes.LHC_API.args.priority;\n }\n\n if (this.attributes.LHC_API.args.operator) {\n params['operator'] = this.attributes.LHC_API.args.operator;\n }\n\n if (this.attributes['identifier']) {\n params['idnt'] = this.attributes['identifier']\n }\n\n if (this.attributes['tag']) {\n params['tag'] = this.attributes['tag']\n }\n\n if (this.attributes['langOverride']) {\n params['lang'] = this.attributes['langOverride']\n }\n\n params['l'] = encodeURIComponent(window.location.href.substring(window.location.protocol.length));\n params['dt'] = encodeURIComponent(document.title);\n params['init'] = this.initCall == true ? 1 : init;\n\n this.initCall = false;\n\n helperFunctions.makeRequest(this.attributes.LHC_API.args.lhc_base_url + this.attributes['lang'] + 'widgetrestapi/checkinvitation', {params: params}, (data) => {\n\n this.inProgress = false;\n \n if (data.invitation) {\n const params = {'vid_id' : data.vid_id, 'invitation' : data.invitation, 'inject_html' : data.inject_html, 'qinv' : data.qinv};\n setTimeout(() => {\n this.showInvitation(params, init);\n }, this.attributes.widgetStatus.value === true ? 0 : (data.delay || 0));\n } else {\n if (this.attributes.LHC_API.args.check_messages) {\n this.checkMessageTimeout = setTimeout(() => {\n this.initInvitation({init: 0});\n },this.params['interval'] * 1000);\n }\n }\n\n if (data.next_reschedule) {\n this.nextRescheduleTimeout = setTimeout(() => {\n this.initInvitation({init: 0});\n }, data.next_reschedule);\n }\n\n if (data.dynamic) {\n data.dynamic.forEach((item) => {\n this.dynamicInvitations.push(item.id);\n if (item.type === 1) {\n domEventsHandler.listen(document, 'mouseout', (e) => {\n e = e ? e : window.event;\n var from = e.relatedTarget || e.toElement;\n if (!from || from.nodeName == \"HTML\") {\n this.showInvitation({'vid_id' : data.vid_id, 'invitation' : item.id, 'inject_html' : item.inject_html, 'qinv' : data.qinv, 'only_inject' : item.only_inject});\n if (!item.every_time) {\n domEventsHandler.unlisten('lhc_inv_mouse_out_'+item.id);\n }\n }\n }, 'lhc_inv_mouse_out_' + item.id);\n } else if (item.type === 2) {\n\n var iddleTimeout = () => {\n\n this.showInvitation({'vid_id' : data.vid_id, 'invitation' : item.id, 'inject_html' : item.inject_html, 'qinv' : data.qinv, 'only_inject' : item.only_inject});\n\n clearTimeout(this.iddleTimeoutActivity);\n\n if (!item.every_time) {\n ['mousemove','mousedown','click','scroll','keypress','load'].forEach((element) => {\n domEventsHandler.unlisten('lhc_inv_iddl_win_'+element);\n });\n\n ['mousemove','scroll','touchstart','touchend'].forEach((element) => {\n domEventsHandler.unlisten('lhc_inv_iddl_doc_'+element);\n });\n }\n };\n\n this.iddleTimeoutActivityReset = () => {\n clearTimeout(this.iddleTimeoutActivity);\n this.iddleTimeoutActivity = setTimeout( () => { iddleTimeout(); }, item.iddle_for *1000);\n }\n\n this.iddleTimeoutActivityReset();\n\n ['mousemove','mousedown','click','scroll','keypress','load'].forEach((event) => {\n domEventsHandler.listen(window, event, this.iddleTimeoutActivityReset, 'lhc_inv_iddl_win_'+event);\n });\n\n ['mousemove','scroll','touchstart','touchend'].forEach((event) => {\n domEventsHandler.listen(document, event, this.iddleTimeoutActivityReset, 'lhc_inv_iddl_doc_'+event);\n });\n }\n })\n }\n });\n }\n }\n}\n\nconst proactiveChat = new _proactiveChat();\nexport {proactiveChat};\n\n"],"names":["proactiveChat","_proactiveChat","this","params","timeoutStatuscheck","timeoutActivity","attributes","chatEvents","dynamicInvitations","iddleTimeoutActivity","checkMessageTimeout","nextRescheduleTimeout","initCall","inProgress","events","length","storeEvents","initInvitation","eventEmitter","addListener","init","onlineStatus","subscribe","data","getSessionAttributes","proactive","invitation","mainWidget","isLoaded","sendChildEvent","hideInvitation","emitEvent","chatParams","widgetStatus","value","mode","inject_html","th","document","getElementsByTagName","s","createElement","setAttribute","LHC_API","args","lhc_base_url","Date","now","appendChild","only_inject","bootstrap","clearTimeout","helperFunctions","userSession","getVID","JSON","stringify","paramsExecution","department","join","priority","operator","encodeURIComponent","window","location","href","substring","protocol","title","vid_id","qinv","setTimeout","showInvitation","delay","check_messages","next_reschedule","dynamic","forEach","item","push","id","type","domEventsHandler","e","from","event","relatedTarget","toElement","nodeName","every_time","iddleTimeoutActivityReset","element","iddle_for"],"sourceRoot":""}