Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / services / ami / report / voiceAgentReport.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xaf3a=['[%s][voiceAgentReport][musiconholdstop]\x20interface:%s','[%s][voiceAgentReport][musiconholdstop]','lodash','moment','../../../config/environment','../../../config/logger','ami','../ami','redis','defaults','localhost','socket.io-emitter','channels','voiceQueues','agents','variables','agentcalled','syncAgentCalled','bind','agentconnect','syncAgentConnect','agentringnoanswer','syncAgentRingNoAnswer','queuecallerabandon','agentcomplete','syncAgentComplete','varset','syncVarSet','hangup','musiconholdstart','syncMusicOnHoldStart','musiconholdstop','syncMusicOnHoldStop','attendedtransfer','syncBlindTransfer','prototype','emit','isNotNull','isUndefined','info','[%s][voiceAgentReport][agentcalled]\x20agent:%s\x20destuniqueid:%s\x20lastevent:called','membername','debug','[%s][voiceAgentReport][agentcalled]\x20event:','uniqueid','inspect','interface','destuniqueid','queue','format','YYYY-MM-DD\x20HH:mm:ss','called','mandatoryDisposition','type','inbound','voice','assign','omit','event','privilege','[%s][voiceAgentReport][agentcalled]\x20sending\x20agentcalled\x20event:','[%s][voiceAgentReport][agentcalled]\x20sending\x20user:called\x20event:','user:%s','user:called','error','[%s][voiceAgentReport][agentcalled]','hasOwnProperty','[%s][voiceAgentReport][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:connect','agentconnectAt','connectedlinename','destchannelstate','destchannelstatedesc','holdtime','lastevent','connect','merge','name','accountcode','exten','custom:agentconnect','user:agentconnect','answeredelsewheredestinationuniqueid','answeredelsewheremembername','[%s][voiceAgentReport][agentconnect]\x20sending\x20agentansweredelsewhere\x20event:','custom:agentansweredelsewhere','[%s][voiceAgentReport][agentconnect]\x20Else\x20path\x20should\x20never\x20be\x20taken','[%s][voiceAgentReport][agentconnect]','[%s][voiceAgentReport][agentringnoanswer]\x20event:','[%s][voiceAgentReport][agentringnoanswer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:rejected','agentringnoanswerAt','rejected','[%s][voiceAgentReport][agentringnoanswer]\x20sending\x20agentringnoanswer\x20event:','[%s][voiceAgentReport][agentringnoanswer]','syncQueueCallerAbandon','[%s][voiceAgentReport][queuecallerabandon]\x20event:','[%s][voiceAgentReport][queuecallerabandon]\x20agent:%s\x20destuniqueid:%s\x20lastevent:abandoned','reason','[%s][voiceAgentReport][queuecallerabandon]\x20sending\x20agentqueuecallerabandon\x20event:','[%s][voiceAgentReport][queuecallerabandon]','[%s][voiceAgentReport][agentcomplete]\x20event:','[%s][voiceAgentReport][agentcomplete]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','agentcompleteAt','complete','transfer','agent','talktime','acw','acwtime','acwTimeout','destconnectedlinenum','[%s][voiceAgentReport][agentcomplete]\x20sending\x20user:agentcomplete\x20event:','destaccountcode','[%s][voiceAgentReport][agentcomplete]','[%s][voiceAgentReport][varset]\x20event:','addVariable','keys','variable','value','[%s][voiceAgentReport][varset]\x20destuniqueid:%s\x20variable:%s\x20value:%s','[%s][voiceAgentReport][varset]','rtpaudioqos','rtpaudioqosbridged','rtpaudioqosjitter','rtpaudioqosjitterbridged','rtpaudioqosrttbridged','sipcallid','bridgepeer','bridgepvtcallid','memberdynamic','memberinterface','memberlastcall','memberpenalty','isNil','includes','syncHangup','[%s][voiceAgentReport][hangup]\x20event:','[%s][voiceAgentReport][hangup]\x20destuniqueid:%s','[%s][voiceAgentReport][hangup]\x20sending\x20voiceAgentReport\x20event:','values','custom:voiceAgentReport','deleteChannelAfterTimeout','[%s][voiceAgentReport][hangup]','syncAttendedTransfer','transfereeuniqueid','origtransfereruniqueid','diff','secondtransfereruniqueid','[%s][voiceAgentReport][attendedtransfer]','[%s][voiceAgentReport][blindtransfer]\x20event:','transfereruniqueid','[%s][voiceAgentReport][blindtransfer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete','seconds','[%s][voiceAgentReport][blindtransfer]','[%s][voiceAgentReport][musiconholdstart]\x20event:','channel','substring','lastIndexOf','[%s][voiceAgentReport][musiconholdstart]\x20interface:%s','onhold','[%s][voiceAgentReport][musiconholdstart]'];(function(_0x429efc,_0x1859d2){var _0x3681c9=function(_0x5c77a7){while(--_0x5c77a7){_0x429efc['push'](_0x429efc['shift']());}};_0x3681c9(++_0x1859d2);}(_0xaf3a,0x1e2));var _0xaaf3=function(_0x58afd5,_0x534a48){_0x58afd5=_0x58afd5-0x0;var _0x3e503b=_0xaf3a[_0x58afd5];return _0x3e503b;};'use strict';var _=require(_0xaaf3('0x0'));var moment=require(_0xaaf3('0x1'));var util=require('util');var Redis=require('ioredis');var config=require(_0xaaf3('0x2'));var logger=require(_0xaaf3('0x3'))(_0xaaf3('0x4'));var ami=require(_0xaaf3('0x5'));config[_0xaaf3('0x6')]=_[_0xaaf3('0x7')](config['redis'],{'host':_0xaaf3('0x8'),'port':0x18eb});var io=require(_0xaaf3('0x9'))(new Redis(config[_0xaaf3('0x6')]));function VoiceAgentReport(_0x2e9565){this[_0xaaf3('0xa')]={};this['voiceChannels']=_0x2e9565[_0xaaf3('0xa')];this[_0xaaf3('0xb')]=_0x2e9565[_0xaaf3('0xb')];this[_0xaaf3('0xc')]=_0x2e9565[_0xaaf3('0xc')];this[_0xaaf3('0xd')]={};ami['on'](_0xaaf3('0xe'),this[_0xaaf3('0xf')][_0xaaf3('0x10')](this));ami['on'](_0xaaf3('0x11'),this[_0xaaf3('0x12')][_0xaaf3('0x10')](this));ami['on'](_0xaaf3('0x13'),this[_0xaaf3('0x14')]['bind'](this));ami['on'](_0xaaf3('0x15'),this['syncQueueCallerAbandon'][_0xaaf3('0x10')](this));ami['on'](_0xaaf3('0x16'),this[_0xaaf3('0x17')][_0xaaf3('0x10')](this));ami['on'](_0xaaf3('0x18'),this[_0xaaf3('0x19')]['bind'](this));ami['on'](_0xaaf3('0x1a'),this['syncHangup']['bind'](this));ami['on'](_0xaaf3('0x1b'),this[_0xaaf3('0x1c')][_0xaaf3('0x10')](this));ami['on'](_0xaaf3('0x1d'),this[_0xaaf3('0x1e')]['bind'](this));ami['on'](_0xaaf3('0x1f'),this['syncAttendedTransfer'][_0xaaf3('0x10')](this));ami['on']('blindtransfer',this[_0xaaf3('0x20')][_0xaaf3('0x10')](this));}VoiceAgentReport[_0xaaf3('0x21')]['emit']=function(_0x16d7c2,_0x24f74e,_0x4dbc23){io['to'](_0x16d7c2)[_0xaaf3('0x22')](_0x24f74e,_0x4dbc23);};VoiceAgentReport['prototype'][_0xaaf3('0x23')]=function(_0x3bf865){return _0x3bf865!==null&&!_[_0xaaf3('0x24')](_0x3bf865);};VoiceAgentReport[_0xaaf3('0x21')][_0xaaf3('0xf')]=function(_0x1c89da){try{if(this['isNotNull'](_0x1c89da)){logger[_0xaaf3('0x25')](_0xaaf3('0x26'),_0x1c89da['uniqueid'],_0x1c89da[_0xaaf3('0x27')],_0x1c89da['destuniqueid']);logger[_0xaaf3('0x28')](_0xaaf3('0x29'),_0x1c89da[_0xaaf3('0x2a')],util[_0xaaf3('0x2b')](_0x1c89da,{'showHidden':![],'depth':null}));if(_[_0xaaf3('0x24')](this[_0xaaf3('0xa')][_0x1c89da[_0xaaf3('0x2a')]])){this['channels'][_0x1c89da[_0xaaf3('0x2a')]]={};}var _0x23e926=this['agents'][_0x1c89da[_0xaaf3('0x2c')]];var _0xffde91=this[_0xaaf3('0xa')][_0x1c89da['uniqueid']][_0x1c89da[_0xaaf3('0x2d')]];var _0x64ba9=this[_0xaaf3('0xb')][_0x1c89da[_0xaaf3('0x2e')]];var _0x824c5b=this[_0xaaf3('0xd')][_0x1c89da['uniqueid']];if(_['isUndefined'](_0xffde91)){_0xffde91={'agentcalledAt':moment()[_0xaaf3('0x2f')](_0xaaf3('0x30')),'lastevent':_0xaaf3('0x31'),'mandatoryDisposition':_0x64ba9&&_0x64ba9[_0xaaf3('0x32')]?_0x64ba9[_0xaaf3('0x32')]:![],'type':_0x64ba9&&_0x64ba9[_0xaaf3('0x33')]?_0x64ba9[_0xaaf3('0x33')]:_0xaaf3('0x34'),'variables':_0x824c5b,'motionChannel':_0xaaf3('0x35')};}Object[_0xaaf3('0x36')](_0xffde91,_[_0xaaf3('0x37')](_0x1c89da,[_0xaaf3('0x38'),_0xaaf3('0x39')]));this[_0xaaf3('0xa')][_0x1c89da['uniqueid']][_0x1c89da[_0xaaf3('0x2d')]]=_0xffde91;logger[_0xaaf3('0x28')](_0xaaf3('0x3a'),_0x1c89da['uniqueid'],util['inspect'](_0xffde91,{'showHidden':![],'depth':null}));ami[_0xaaf3('0x22')]('custom:agentcalled',_0xffde91);var _0x1f0a91={'id':_0x23e926['id'],'calleridnum':_0xffde91['calleridnum'],'queue':_0xffde91[_0xaaf3('0x2e')],'variables':_0xffde91['variables'],'uniqueid':_0x1c89da[_0xaaf3('0x2a')]};logger['debug'](_0xaaf3('0x3b'),_0x1c89da[_0xaaf3('0x2a')],util['inspect'](_0x1f0a91,{'showHidden':![],'depth':null}));this['emit'](util[_0xaaf3('0x2f')](_0xaaf3('0x3c'),_0x1c89da['membername']),_0xaaf3('0x3d'),_0x1f0a91);}}catch(_0x4a871d){logger[_0xaaf3('0x3e')](_0xaaf3('0x3f'),_0x1c89da['uniqueid'],util[_0xaaf3('0x2b')](_0x4a871d,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xaaf3('0x21')][_0xaaf3('0x12')]=function(_0x368c40){try{if(this[_0xaaf3('0x23')](_0x368c40)){if(this[_0xaaf3('0xa')][_0x368c40[_0xaaf3('0x2a')]]){for(var _0x5aac78 in this['channels'][_0x368c40[_0xaaf3('0x2a')]]){if(this[_0xaaf3('0xa')][_0x368c40[_0xaaf3('0x2a')]][_0xaaf3('0x40')](_0x5aac78)){if(_0x368c40[_0xaaf3('0x2d')]===_0x5aac78){logger[_0xaaf3('0x25')](_0xaaf3('0x41'),_0x368c40[_0xaaf3('0x2a')],_0x368c40[_0xaaf3('0x27')],_0x368c40['destuniqueid']);this['channels'][_0x368c40['uniqueid']][_0x5aac78][_0xaaf3('0x42')]=moment()[_0xaaf3('0x2f')](_0xaaf3('0x30'));this[_0xaaf3('0xa')][_0x368c40[_0xaaf3('0x2a')]][_0x5aac78]['connectedlinename']=_0x368c40[_0xaaf3('0x43')];this[_0xaaf3('0xa')][_0x368c40[_0xaaf3('0x2a')]][_0x5aac78]['connectedlinenum']=_0x368c40['connectedlinenum'];this[_0xaaf3('0xa')][_0x368c40[_0xaaf3('0x2a')]][_0x5aac78][_0xaaf3('0x44')]=_0x368c40['destchannelstate'];this['channels'][_0x368c40[_0xaaf3('0x2a')]][_0x5aac78][_0xaaf3('0x45')]=_0x368c40['destchannelstatedesc'];this[_0xaaf3('0xa')][_0x368c40[_0xaaf3('0x2a')]][_0x5aac78][_0xaaf3('0x46')]=_0x368c40['holdtime'];this['channels'][_0x368c40['uniqueid']][_0x5aac78][_0xaaf3('0x47')]=_0xaaf3('0x48');_[_0xaaf3('0x49')](this[_0xaaf3('0xc')][_0x368c40[_0xaaf3('0x2c')]],_['pick'](_0x368c40,['queue','destconnectedlinenum']));var _0xa512da=this['agents'][_0x368c40[_0xaaf3('0x2c')]];var _0x5b99ae={'id':_0xa512da['id'],'name':_0xa512da[_0xaaf3('0x4a')],'agentconnected':!![],'destaccountcode':_0xa512da[_0xaaf3('0x4b')],'destconnectedlinenum':this['channels'][_0x368c40[_0xaaf3('0x2a')]][_0x368c40['destuniqueid']][_0xaaf3('0x4c')],'queue':this['channels'][_0x368c40[_0xaaf3('0x2a')]][_0x368c40[_0xaaf3('0x2d')]]['queue'],'uniqueid':this['channels'][_0x368c40['uniqueid']][_0x368c40[_0xaaf3('0x2d')]]['uniqueid']};ami[_0xaaf3('0x22')](_0xaaf3('0x4d'),this[_0xaaf3('0xa')][_0x368c40[_0xaaf3('0x2a')]][_0x368c40[_0xaaf3('0x2d')]]);this[_0xaaf3('0x22')](util['format'](_0xaaf3('0x3c'),_0x368c40['membername']),_0xaaf3('0x4e'),_0x5b99ae);}else if(!this[_0xaaf3('0xa')][_0x368c40[_0xaaf3('0x2a')]][_0x5aac78]['agentringnoanswer']&&!this[_0xaaf3('0xa')][_0x368c40['uniqueid']][_0x5aac78]['agentcomplete']){logger[_0xaaf3('0x25')]('[%s][voiceAgentReport][agentconnect]\x20agent:%s\x20destuniqueid:%s\x20lastevent:answered_elsewhere',_0x368c40[_0xaaf3('0x2a')],this[_0xaaf3('0xa')][_0x368c40['uniqueid']][_0x5aac78]['membername'],_0x5aac78);this[_0xaaf3('0xa')][_0x368c40['uniqueid']][_0x5aac78][_0xaaf3('0x13')]=!![];this['channels'][_0x368c40[_0xaaf3('0x2a')]][_0x5aac78]['agentringnoanswerAt']=moment()['format'](_0xaaf3('0x30'));this[_0xaaf3('0xa')][_0x368c40[_0xaaf3('0x2a')]][_0x5aac78][_0xaaf3('0x4f')]=_0x368c40[_0xaaf3('0x2d')];this[_0xaaf3('0xa')][_0x368c40[_0xaaf3('0x2a')]][_0x5aac78][_0xaaf3('0x50')]=_0x368c40[_0xaaf3('0x27')];this[_0xaaf3('0xa')][_0x368c40[_0xaaf3('0x2a')]][_0x5aac78]['lastevent']='answered_elsewhere';this[_0xaaf3('0xa')][_0x368c40[_0xaaf3('0x2a')]][_0x5aac78]['reason']='answered_elsewhere';logger[_0xaaf3('0x28')](_0xaaf3('0x51'),_0x368c40[_0xaaf3('0x2a')],util['inspect'](this['channels'][_0x368c40[_0xaaf3('0x2a')]][_0x5aac78],{'showHidden':![],'depth':null}));ami[_0xaaf3('0x22')](_0xaaf3('0x52'),this['channels'][_0x368c40[_0xaaf3('0x2a')]][_0x5aac78]);}else{logger[_0xaaf3('0x28')](_0xaaf3('0x53'),_0x368c40[_0xaaf3('0x2a')]);}}}}}}catch(_0x5b295f){logger[_0xaaf3('0x3e')](_0xaaf3('0x54'),_0x368c40[_0xaaf3('0x2a')],util['inspect'](_0x5b295f,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xaaf3('0x21')][_0xaaf3('0x14')]=function(_0xe87eb4){try{if(this[_0xaaf3('0x23')](_0xe87eb4)){logger[_0xaaf3('0x28')](_0xaaf3('0x55'),_0xe87eb4['uniqueid'],util[_0xaaf3('0x2b')](_0xe87eb4,{'showHidden':![],'depth':null}));if(this[_0xaaf3('0xa')][_0xe87eb4[_0xaaf3('0x2a')]]&&this[_0xaaf3('0xa')][_0xe87eb4['uniqueid']][_0xe87eb4[_0xaaf3('0x2d')]]){logger['info'](_0xaaf3('0x56'),_0xe87eb4['uniqueid'],_0xe87eb4[_0xaaf3('0x27')],_0xe87eb4[_0xaaf3('0x2d')]);var _0x46a433=this[_0xaaf3('0xc')][_0xe87eb4[_0xaaf3('0x2c')]];var _0x16390c=this['channels'][_0xe87eb4[_0xaaf3('0x2a')]][_0xe87eb4[_0xaaf3('0x2d')]];_0x16390c[_0xaaf3('0x13')]=!![];_0x16390c[_0xaaf3('0x57')]=moment()['format'](_0xaaf3('0x30'));_0x16390c['lastevent']=_0xaaf3('0x58');_0x16390c['reason']='rejected';var _0x35fd35={'id':_0x46a433['id'],'name':_0x46a433[_0xaaf3('0x4a')],'queue':_0x16390c['queue'],'uniqueid':_0x16390c[_0xaaf3('0x2a')]};logger[_0xaaf3('0x28')](_0xaaf3('0x59'),_0xe87eb4[_0xaaf3('0x2a')],util[_0xaaf3('0x2b')](_0x35fd35,{'showHidden':![],'depth':null}));this[_0xaaf3('0x22')](util['format'](_0xaaf3('0x3c'),_0x46a433[_0xaaf3('0x4a')]),'user:agentringnoanswer',_0x35fd35);ami[_0xaaf3('0x22')]('custom:agentringnoanswer',_0x16390c);this[_0xaaf3('0xa')][_0xe87eb4[_0xaaf3('0x2a')]][_0xe87eb4[_0xaaf3('0x2d')]]=Object[_0xaaf3('0x36')]({},_0x16390c);}}}catch(_0x1bf00a){logger[_0xaaf3('0x3e')](_0xaaf3('0x5a'),_0xe87eb4[_0xaaf3('0x2a')],util[_0xaaf3('0x2b')](_0x1bf00a,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xaaf3('0x21')][_0xaaf3('0x5b')]=function(_0x38dca9){try{if(this[_0xaaf3('0x23')](_0x38dca9)){logger[_0xaaf3('0x28')](_0xaaf3('0x5c'),_0x38dca9[_0xaaf3('0x2a')],util[_0xaaf3('0x2b')](_0x38dca9,{'showHidden':![],'depth':null}));if(this[_0xaaf3('0xa')][_0x38dca9[_0xaaf3('0x2a')]]){for(var _0x2d8eca in this[_0xaaf3('0xa')][_0x38dca9['uniqueid']]){if(this[_0xaaf3('0xa')][_0x38dca9[_0xaaf3('0x2a')]][_0xaaf3('0x40')](_0x2d8eca)&&!this[_0xaaf3('0xa')][_0x38dca9[_0xaaf3('0x2a')]][_0x2d8eca][_0xaaf3('0x13')]&&!this[_0xaaf3('0xa')][_0x38dca9[_0xaaf3('0x2a')]][_0x2d8eca][_0xaaf3('0x16')]){logger[_0xaaf3('0x25')](_0xaaf3('0x5d'),_0x38dca9[_0xaaf3('0x2a')],this[_0xaaf3('0xa')][_0x38dca9['uniqueid']][_0x2d8eca][_0xaaf3('0x27')],_0x2d8eca);this[_0xaaf3('0xa')][_0x38dca9[_0xaaf3('0x2a')]][_0x2d8eca][_0xaaf3('0x13')]=!![];this['channels'][_0x38dca9[_0xaaf3('0x2a')]][_0x2d8eca]['agentringnoanswerAt']=moment()[_0xaaf3('0x2f')](_0xaaf3('0x30'));this[_0xaaf3('0xa')][_0x38dca9[_0xaaf3('0x2a')]][_0x2d8eca]['lastevent']='abandoned';this[_0xaaf3('0xa')][_0x38dca9[_0xaaf3('0x2a')]][_0x2d8eca][_0xaaf3('0x5e')]='abandoned';logger[_0xaaf3('0x28')](_0xaaf3('0x5f'),_0x38dca9['uniqueid'],util[_0xaaf3('0x2b')](this[_0xaaf3('0xa')][_0x38dca9['uniqueid']][_0x2d8eca],{'showHidden':![],'depth':null}));ami[_0xaaf3('0x22')]('custom:agentqueuecallerabandon',this[_0xaaf3('0xa')][_0x38dca9['uniqueid']][_0x2d8eca]);}}}}}catch(_0x4fc120){logger[_0xaaf3('0x3e')](_0xaaf3('0x60'),_0x38dca9[_0xaaf3('0x2a')],util[_0xaaf3('0x2b')](_0x4fc120,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xaaf3('0x21')][_0xaaf3('0x17')]=function(_0x3e4c94){try{if(this['isNotNull'](_0x3e4c94)){logger[_0xaaf3('0x28')](_0xaaf3('0x61'),_0x3e4c94[_0xaaf3('0x2a')],util[_0xaaf3('0x2b')](_0x3e4c94,{'showHidden':![],'depth':null}));if(this[_0xaaf3('0xa')][_0x3e4c94[_0xaaf3('0x2a')]]){for(var _0x1dc7eb in this[_0xaaf3('0xa')][_0x3e4c94[_0xaaf3('0x2a')]]){if(this[_0xaaf3('0xa')][_0x3e4c94[_0xaaf3('0x2a')]][_0xaaf3('0x40')](_0x1dc7eb)){if(this[_0xaaf3('0xa')][_0x3e4c94[_0xaaf3('0x2a')]][_0x1dc7eb][_0xaaf3('0x42')]&&!this[_0xaaf3('0xa')][_0x3e4c94[_0xaaf3('0x2a')]][_0x1dc7eb][_0xaaf3('0x16')]){logger[_0xaaf3('0x25')](_0xaaf3('0x62'),_0x3e4c94[_0xaaf3('0x2a')],this[_0xaaf3('0xa')][_0x3e4c94[_0xaaf3('0x2a')]][_0x1dc7eb][_0xaaf3('0x27')],_0x1dc7eb);this[_0xaaf3('0xa')][_0x3e4c94['uniqueid']][_0x1dc7eb][_0xaaf3('0x16')]=!![];this['channels'][_0x3e4c94['uniqueid']][_0x1dc7eb][_0xaaf3('0x63')]=moment()[_0xaaf3('0x2f')](_0xaaf3('0x30'));this[_0xaaf3('0xa')][_0x3e4c94[_0xaaf3('0x2a')]][_0x1dc7eb][_0xaaf3('0x47')]=_0xaaf3('0x64');this[_0xaaf3('0xa')][_0x3e4c94['uniqueid']][_0x1dc7eb]['reason']=_0x3e4c94['reason']==_0xaaf3('0x65')?_0xaaf3('0x66'):_0x3e4c94[_0xaaf3('0x5e')];this[_0xaaf3('0xa')][_0x3e4c94[_0xaaf3('0x2a')]][_0x1dc7eb][_0xaaf3('0x67')]=_0x3e4c94[_0xaaf3('0x67')];if(this['voiceQueues'][_0x3e4c94[_0xaaf3('0x2e')]]&&this[_0xaaf3('0xb')][_0x3e4c94[_0xaaf3('0x2e')]][_0xaaf3('0x68')]){this[_0xaaf3('0xa')][_0x3e4c94[_0xaaf3('0x2a')]][_0x1dc7eb][_0xaaf3('0x69')]=this['voiceQueues'][_0x3e4c94['queue']][_0xaaf3('0x6a')];this[_0xaaf3('0xa')][_0x3e4c94['uniqueid']][_0x1dc7eb]['agentacw']=!![];}this[_0xaaf3('0xc')][_0x3e4c94[_0xaaf3('0x2c')]]=_[_0xaaf3('0x37')](this[_0xaaf3('0xc')][_0x3e4c94[_0xaaf3('0x2c')]],[_0xaaf3('0x2e'),_0xaaf3('0x6b')]);logger[_0xaaf3('0x28')]('[%s][voiceAgentReport][agentcomplete]\x20sending\x20agentcomplete\x20event:',_0x3e4c94[_0xaaf3('0x2a')],util[_0xaaf3('0x2b')](this['channels'][_0x3e4c94[_0xaaf3('0x2a')]][_0x1dc7eb],{'showHidden':![],'depth':null}));ami['emit']('custom:agentcomplete',this[_0xaaf3('0xa')][_0x3e4c94[_0xaaf3('0x2a')]][_0x1dc7eb]);logger[_0xaaf3('0x28')](_0xaaf3('0x6c'),_0x3e4c94[_0xaaf3('0x2a')],util['inspect']({'id':this['agents'][_0x3e4c94[_0xaaf3('0x2c')]]['id'],'destaccountcode':_0x3e4c94[_0xaaf3('0x6d')]},{'showHidden':![],'depth':null}));this[_0xaaf3('0x22')](util[_0xaaf3('0x2f')]('user:%s',_0x3e4c94[_0xaaf3('0x27')]),'user:agentcomplete',{'id':this[_0xaaf3('0xc')][_0x3e4c94[_0xaaf3('0x2c')]]['id'],'destaccountcode':Number(_0x3e4c94['destaccountcode'])});}}}}}}catch(_0xcf34b0){logger['error'](_0xaaf3('0x6e'),_0x3e4c94[_0xaaf3('0x2a')],util['inspect'](_0xcf34b0,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xaaf3('0x21')][_0xaaf3('0x19')]=function(_0x3f2409){try{if(this[_0xaaf3('0x23')](_0x3f2409)){logger[_0xaaf3('0x28')](_0xaaf3('0x6f'),_0x3f2409[_0xaaf3('0x2a')],util['inspect'](_0x3f2409,{'showHidden':![],'depth':null}));this[_0xaaf3('0x70')](_0x3f2409['uniqueid'],_[_0xaaf3('0x71')](_0x3f2409[_0xaaf3('0x72')])[0x0],_0x3f2409[_0xaaf3('0x73')]);if(this[_0xaaf3('0xa')][_0x3f2409['uniqueid']]){for(var _0x27f12c in this[_0xaaf3('0xa')][_0x3f2409['uniqueid']]){if(this[_0xaaf3('0xa')][_0x3f2409[_0xaaf3('0x2a')]][_0xaaf3('0x40')](_0x27f12c)){logger[_0xaaf3('0x25')](_0xaaf3('0x74'),_0x3f2409[_0xaaf3('0x2a')],_0x27f12c,_[_0xaaf3('0x71')](_0x3f2409['variable'])[0x0],_0x3f2409[_0xaaf3('0x73')]);if(_['isUndefined'](this[_0xaaf3('0xa')][_0x3f2409[_0xaaf3('0x2a')]][_0x27f12c][_0xaaf3('0xd')])){this[_0xaaf3('0xa')][_0x3f2409[_0xaaf3('0x2a')]][_0x27f12c][_0xaaf3('0xd')]={};}this['channels'][_0x3f2409[_0xaaf3('0x2a')]][_0x27f12c]['variables']=this['variables'][_0x3f2409[_0xaaf3('0x2a')]];}}}}}catch(_0x5ca562){logger[_0xaaf3('0x3e')](_0xaaf3('0x75'),_0x3f2409[_0xaaf3('0x2a')],util[_0xaaf3('0x2b')](_0x5ca562,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype']['addVariable']=function(_0x4bf17e,_0x143c8f,_0x45632e){var _0xb5dc46=[_0xaaf3('0x76'),_0xaaf3('0x77'),_0xaaf3('0x78'),_0xaaf3('0x79'),'rtpaudioqosloss','rtpaudioqoslossbridged','rtpaudioqosrtt',_0xaaf3('0x7a'),_0xaaf3('0x7b'),'sipuri',_0xaaf3('0x7c'),_0xaaf3('0x7d'),'membercalls',_0xaaf3('0x7e'),_0xaaf3('0x7f'),_0xaaf3('0x80'),_0xaaf3('0x27'),_0xaaf3('0x81'),'memberrealtime'];if(!_[_0xaaf3('0x82')](_0x143c8f)&&!_[_0xaaf3('0x83')](_0xb5dc46,_0x143c8f)){if(_[_0xaaf3('0x24')](this['variables'][_0x4bf17e])){this[_0xaaf3('0xd')][_0x4bf17e]={};}this[_0xaaf3('0xd')][_0x4bf17e][_0x143c8f]=_0x45632e;}};VoiceAgentReport[_0xaaf3('0x21')][_0xaaf3('0x84')]=function(_0xa8c002){try{if(this[_0xaaf3('0x23')](_0xa8c002)){logger[_0xaaf3('0x28')](_0xaaf3('0x85'),_0xa8c002[_0xaaf3('0x2a')],util[_0xaaf3('0x2b')](_0xa8c002,{'showHidden':![],'depth':null}));if(this[_0xaaf3('0xa')][_0xa8c002[_0xaaf3('0x2a')]]){for(var _0x2a9e57 in this['channels'][_0xa8c002[_0xaaf3('0x2a')]]){if(this[_0xaaf3('0xa')][_0xa8c002[_0xaaf3('0x2a')]]['hasOwnProperty'](_0x2a9e57)){if(this['channels'][_0xa8c002['uniqueid']][_0x2a9e57][_0xaaf3('0x5e')]==_0xaaf3('0x65')&&this[_0xaaf3('0xa')][_0xa8c002['uniqueid']][_0x2a9e57][_0xaaf3('0x16')]){logger[_0xaaf3('0x25')](_0xaaf3('0x86'),_0xa8c002['uniqueid'],_0x2a9e57);this[_0xaaf3('0xa')][_0xa8c002[_0xaaf3('0x2a')]][_0x2a9e57]['agentcompleteAt']=moment()['format'](_0xaaf3('0x30'));}}}logger['debug'](_0xaaf3('0x87'),_0xa8c002[_0xaaf3('0x2a')],util['inspect'](_[_0xaaf3('0x88')](this[_0xaaf3('0xa')][_0xa8c002[_0xaaf3('0x2a')]]),{'showHidden':![],'depth':null}));ami[_0xaaf3('0x22')](_0xaaf3('0x89'),_['values'](this[_0xaaf3('0xa')][_0xa8c002[_0xaaf3('0x2a')]]));this[_0xaaf3('0x8a')](_0xa8c002[_0xaaf3('0x2a')]);}if(this['variables'][_0xa8c002[_0xaaf3('0x2a')]]){delete this[_0xaaf3('0xd')][_0xa8c002[_0xaaf3('0x2a')]];}}}catch(_0x233ffd){logger[_0xaaf3('0x3e')](_0xaaf3('0x8b'),_0xa8c002[_0xaaf3('0x2a')],util['inspect'](_0x233ffd,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0xaaf3('0x8c')]=function(_0x4a63ff){try{if(this[_0xaaf3('0x23')](_0x4a63ff)){logger[_0xaaf3('0x28')]('[%s][voiceAgentReport][attendedtransfer]\x20event:',_0x4a63ff[_0xaaf3('0x2a')],util[_0xaaf3('0x2b')](_0x4a63ff,{'showHidden':![],'depth':null}));if(this[_0xaaf3('0xa')][_0x4a63ff['transfereeuniqueid']]){for(var _0x381349 in this[_0xaaf3('0xa')][_0x4a63ff[_0xaaf3('0x8d')]]){if(this[_0xaaf3('0xa')][_0x4a63ff[_0xaaf3('0x8d')]][_0xaaf3('0x40')](_0x381349)){if(_0x4a63ff[_0xaaf3('0x8e')]===_0x381349){logger[_0xaaf3('0x25')]('[%s][voiceAgentReport][attendedtransfer]\x20agent:%s\x20destuniqueid:%s\x20lastevent:complete',_0x4a63ff['uniqueid'],this['channels'][_0x4a63ff[_0xaaf3('0x8d')]][_0x381349][_0xaaf3('0x27')],_0x381349);var _0x59e05d=moment();this[_0xaaf3('0xa')][_0x4a63ff['transfereeuniqueid']][_0x381349][_0xaaf3('0x16')]=!![];this[_0xaaf3('0xa')][_0x4a63ff[_0xaaf3('0x8d')]][_0x381349][_0xaaf3('0x63')]=moment()[_0xaaf3('0x2f')]('YYYY-MM-DD\x20HH:mm:ss');this[_0xaaf3('0xa')][_0x4a63ff['transfereeuniqueid']][_0x381349][_0xaaf3('0x47')]='complete';this[_0xaaf3('0xa')][_0x4a63ff[_0xaaf3('0x8d')]][_0x381349][_0xaaf3('0x5e')]=_0xaaf3('0x65');this[_0xaaf3('0xa')][_0x4a63ff[_0xaaf3('0x8d')]][_0x381349][_0xaaf3('0x67')]=_0x59e05d[_0xaaf3('0x8f')](this[_0xaaf3('0xa')][_0x4a63ff[_0xaaf3('0x8d')]][_0x381349]['agentconnectAt'],'seconds');}}}}if(this['channels'][_0x4a63ff['secondtransfereruniqueid']]){var _0x21f4aa=this[_0xaaf3('0xa')][_0x4a63ff[_0xaaf3('0x90')]];this[_0xaaf3('0xa')][_0x4a63ff[_0xaaf3('0x90')]]=this['channels'][_0x4a63ff[_0xaaf3('0x8d')]];this['channels'][_0x4a63ff['transfereeuniqueid']]=_0x21f4aa;}}}catch(_0x58e49b){logger[_0xaaf3('0x3e')](_0xaaf3('0x91'),_0x4a63ff['uniqueid'],util[_0xaaf3('0x2b')](_0x58e49b,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xaaf3('0x21')]['syncBlindTransfer']=function(_0x1e1c37){try{if(this['isNotNull'](_0x1e1c37)){logger['debug'](_0xaaf3('0x92'),_0x1e1c37['uniqueid'],util[_0xaaf3('0x2b')](_0x1e1c37,{'showHidden':![],'depth':null}));if(this[_0xaaf3('0xa')][_0x1e1c37[_0xaaf3('0x8d')]]){for(var _0x24598b in this[_0xaaf3('0xa')][_0x1e1c37[_0xaaf3('0x8d')]]){if(this[_0xaaf3('0xa')][_0x1e1c37[_0xaaf3('0x8d')]][_0xaaf3('0x40')](_0x24598b)){if(_0x1e1c37[_0xaaf3('0x93')]===_0x24598b){logger['info'](_0xaaf3('0x94'),_0x1e1c37[_0xaaf3('0x2a')],this[_0xaaf3('0xa')][_0x1e1c37['transfereeuniqueid']][_0x24598b][_0xaaf3('0x27')],_0x24598b);var _0x14f08e=moment();this['channels'][_0x1e1c37['transfereeuniqueid']][_0x24598b][_0xaaf3('0x16')]=!![];this[_0xaaf3('0xa')][_0x1e1c37['transfereeuniqueid']][_0x24598b][_0xaaf3('0x63')]=_0x14f08e;this[_0xaaf3('0xa')][_0x1e1c37[_0xaaf3('0x8d')]][_0x24598b][_0xaaf3('0x47')]='complete';this[_0xaaf3('0xa')][_0x1e1c37['transfereeuniqueid']][_0x24598b][_0xaaf3('0x5e')]='transfer';this['channels'][_0x1e1c37[_0xaaf3('0x8d')]][_0x24598b][_0xaaf3('0x67')]=_0x14f08e[_0xaaf3('0x8f')](this[_0xaaf3('0xa')][_0x1e1c37['transfereeuniqueid']][_0x24598b][_0xaaf3('0x42')],_0xaaf3('0x95'));}}}}}}catch(_0x21c713){logger[_0xaaf3('0x3e')](_0xaaf3('0x96'),_0x1e1c37[_0xaaf3('0x2a')],util[_0xaaf3('0x2b')](_0x21c713,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0xaaf3('0x1c')]=function(_0x378bd0){var _0xa168b3='';try{if(this[_0xaaf3('0x23')](_0x378bd0)){logger[_0xaaf3('0x28')](_0xaaf3('0x97'),_0x378bd0[_0xaaf3('0x2a')],util[_0xaaf3('0x2b')](_0x378bd0,{'showHidden':![],'depth':null}));if(_0x378bd0['channel']){_0xa168b3=_0x378bd0[_0xaaf3('0x98')][_0xaaf3('0x99')](0x0,_0x378bd0[_0xaaf3('0x98')][_0xaaf3('0x9a')]('-'));if(this[_0xaaf3('0xc')][_0xa168b3]){logger[_0xaaf3('0x25')](_0xaaf3('0x9b'),_0x378bd0['uniqueid'],_0xa168b3);this[_0xaaf3('0xc')][_0xa168b3][_0xaaf3('0x9c')]=!![];}}}}catch(_0x4c3c16){logger[_0xaaf3('0x3e')](_0xaaf3('0x9d'),_0x378bd0[_0xaaf3('0x2a')],util['inspect'](_0x4c3c16,{'showHidden':![],'depth':null}));}};VoiceAgentReport[_0xaaf3('0x21')][_0xaaf3('0x1e')]=function(_0xc0f59e){var _0x2e4bc7='';try{if(this[_0xaaf3('0x23')](_0xc0f59e)){logger['debug']('[%s][voiceAgentReport][musiconholdstop]\x20event:',_0xc0f59e[_0xaaf3('0x2a')],util[_0xaaf3('0x2b')](_0xc0f59e,{'showHidden':![],'depth':null}));if(_0xc0f59e[_0xaaf3('0x98')]){_0x2e4bc7=_0xc0f59e[_0xaaf3('0x98')]['substring'](0x0,_0xc0f59e[_0xaaf3('0x98')]['lastIndexOf']('-'));if(this['agents'][_0x2e4bc7]){logger[_0xaaf3('0x25')](_0xaaf3('0x9e'),_0xc0f59e[_0xaaf3('0x2a')],_0x2e4bc7);this[_0xaaf3('0xc')][_0x2e4bc7]['onhold']=![];}}}}catch(_0x3f34f5){logger['error'](_0xaaf3('0x9f'),_0xc0f59e[_0xaaf3('0x2a')],util[_0xaaf3('0x2b')](_0x3f34f5,{'showHidden':![],'depth':null}));}};VoiceAgentReport['prototype'][_0xaaf3('0x8a')]=function(_0x9d2cc3,_0xe94743=0x2710){if(this['channels'][_0x9d2cc3]){setTimeout(()=>{delete this[_0xaaf3('0xa')][_0x9d2cc3];},_0xe94743);}};module['exports']=VoiceAgentReport;