Built motion from commit (unavailable).|2.2.0
[motion2.git] / server / services / ami / preview / index.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 _0x389d=['isUndefined','object','reason','logAgent','createAgentHistory','[callProgressDetectingAgent][logNoSuch]','[callProgressDetectingAgent][logNoAnswer]','Busy','[callProgressDetectingAgent][logBusy]','[callProgressDetectingAgent][logCongestion]','AnswerAGI','[callProgressDetectingAgent][logAnswerAGI]','[originated][decrement][callProgressDetectingAgent]','checkInBlack','phone','Contact\x20is\x20undefined','isEmpty','execCall','[Preview][execCall][success]','Queue:\x20','custom:agentcalled','called','Calling','[Preview][execCall][failure]','logBlacklist','createHistory','[Blacklist][error]','Contact\x20in\x20black\x20List','SIP/%s','reachable','unmonitored','execRun','getContactPreview','recallme','validateContact','isValid','checkIsBlackList','Contact.phone','[Preview][checkIsBlackList]','[Preview][getContactPreview]','Call\x20unsuccessful','Agent','[Preview][validateContact][Empty\x20Contact]','Empty\x20Contact','[Preview][validateContact][Empty\x20Campaign]','Empty\x20Campaign','[Preview][validateContact][Trunk\x20not\x20work]','campaign\x20Name:\x20','\x20Trunk\x20is\x20not\x20active','TrunkBackup','\x20Trunk\x20Backup\x20is\x20not\x20active','Trunk\x20not\x20work','[Preview][validateContact][Campaign\x20Active]','\x20Not\x20Active','dialCutDigit','substring','trim','Contact','getCallerId','dialRandomLastDigitCallerIdNumber','getCallerIdRandom','originatecalleridname','originatecalleridnum','addVariables','merge','toLowerVariables','Action','[originated][increment]','OriginateError','[originateFailure][logOriginateFailure]','syncNewExten','actionid','logLookAgent','lookAgent','clone','isFailure','response','custom:agentringnoanswer','rejected','[callProgressDetectingAgent][logAnswer]','[syncHangup][talking]','cause','callProgressDetectingCustomer','[syncHangup][talking][cause]','statedesc','dialQueueProject','channelstate','transfer','[syncHangup][talking][transfer]','destuniqueid','addVariable','variables','filterKey','keys','variable','value','error','inspect','syncAttendedTransfer','transfertargetlinkedid','transfererlinkedid','util','lodash','bluebird','moment','ioredis','../../../config/environment','../../../config/logger','actionPreview','../ami','./rpcDb','./action','./util/util','redis','defaults','localhost','prototype','enqueue','tail','finally','sequence','campaignsPreview','trunks','actions','agents','clockClearZombieChannels','originateresponse','syncOriginateResponse','hangup','syncHangup','bind','hanguprequest','dialend','syncDialEnd','varset','syncVarSet','blindtransfer','syncBlindTransfer','loopCampaigns','emit','type','outbound','name','available','loggedIn','pTalking','sumBillable','sumDuration','sumHoldTime','talking','unmanaged','abandoned','waiting','loggedInDb','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialPrefix','outboundAnswerAgiCallsDay','outboundAnswerCallsDay','outboundBlacklistCallsDay','outboundBusyCallsDay','outboundCongestionCallsDay','outboundDropCallsDayACS','outboundDropCallsDayCallersExit','outboundDropCallsDayTimeout','outboundNoAnswerCallsDay','outboundNoSuchCallsDay','outboundReCallsDay','outboundUnknownCallsDay','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalErlangCalls','predictiveIntervalErlangCallsDroppedCalls','predictiveIntervalHitRate','predictiveIntervalLowerLimit','predictiveIntervalMultiplicativeFactor','predictiveIntervalTotalCalls','originated','Trunk','active','callerid','Interval','stringify','md5','format','voice:queue:%s','voice_queue:save','voice_queue_channel:remove','sendMessageOneNotActive','paused','message','NOT_ACTIVE','logger','[CampaignPreview]\x20Campaign\x20Queue:\x20','IS_DISACTIVED','\x20is\x20disactive','syncCampaigns','dialMethod','preview','booked','clearZombieChannels','hasOwnProperty','dialActive','setMessage','recallMe','clearZombieChannel','isNil','info','[clearZombieChannels][talking]','Queue','queue','originated:\x20','pTalking:\x20','dialAnswer','pick','contactId','UserId','VoiceQueueId','status','channel','catch','No\x20such\x20channel','[clearZombieChannel]','decrementTalkink','loggerError','[Dialer][checkChannel][pTalking][Preview]','[action]','size','getContactRecallMe','agentReadyId','then','length','getDiff','dialRecallMeTimeout','run','logger2','[RecallMe]','starttime','YYYY-MM-DD\x20HH:mm:ss','RecallInQueue','dialRecallInQueue','createBody','[HistoryDialRecallInQueue][historyCatch]','logCustomer','RecallFailedTimeout','createCustomerHistory','[HistoryRecallClose]','IsNotLoggedIn','isActive','isTrunkReachable','ACTIVE','countglobal','NoSuchNumber','[callProgressDetectingCustomer][logNoSuch]','dialGlobalMaxRetry','cloneAction','createCustomerFinal','[callProgressDetectingCustomer][logNoSuchGlobal]','linkedid','ANSWER','responsetime','answertime','[syncHangup][talking][increment]','uniqueid','custom:agentconnect','buildObj','acw','custom:agentConnectPreview','buildAcw','custom:agentcomplete','complete','total','totalGlobal','Answer','[callProgressDetectingCustomer][logAnswerGlobal]','crateCustomerReportQueue','talktime','[syncHangup][talking][decrement]','\x20Queue','BUSY','countbusyretry','[callProgressDetectingCustomer][logBusy]','Global','[callProgressDetectingCustomer][logBusyGlobal]','dialBusyMaxRetry','rescheduleContact','scheduledAt','unlockAgent','activeContact','NOANSWER','countnoanswerretry','[callProgressDetectingCustomer][logNoAnswer]','dialNoAnswerMaxRetry','dialNoAnswerRetryFrequency','CONGESTION','countcongestionretry','Congestion','[callProgressDetectingCustomer][logCongestion]','[callProgressDetectingCustomer][logCongestionGlobal]','dialCongestionMaxRetry','outboundRejectCallsDay','AgentReject','unlockContact','idContact','disableContact','[default]','[Dialer][decrementTalkink][no\x20Hangup][Preview]','cause-txt','dialstatus','[callProgressDetectingCustomer][logUnknown]','updateOriginated','[originated][decrement][callProgressDetectingCustomer]','destlinkedid','callProgressDetectingAgent'];(function(_0x36ed48,_0x1ee0d4){var _0x51c63a=function(_0x2d0a40){while(--_0x2d0a40){_0x36ed48['push'](_0x36ed48['shift']());}};_0x51c63a(++_0x1ee0d4);}(_0x389d,0x1a0));var _0xd389=function(_0x129c27,_0x333c44){_0x129c27=_0x129c27-0x0;var _0x5a8017=_0x389d[_0x129c27];return _0x5a8017;};'use strict';var util=require(_0xd389('0x0'));var _=require(_0xd389('0x1'));var BPromise=require(_0xd389('0x2'));var uuid=require('uuid');var moment=require(_0xd389('0x3'));var md5=require('md5');var Redis=require(_0xd389('0x4'));var config=require(_0xd389('0x5'));var logger=require(_0xd389('0x6'))('preview');var loggerAction=require('../../../config/logger')(_0xd389('0x7'));var ami=require(_0xd389('0x8'));var rpcDb=require(_0xd389('0x9'));var Action=require(_0xd389('0xa'));var ut=require(_0xd389('0xb'));config[_0xd389('0xc')]=_[_0xd389('0xd')](config['redis'],{'host':_0xd389('0xe'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xd389('0xc')]));var Sequence=function(){};Sequence[_0xd389('0xf')][_0xd389('0x10')]=function(_0x21f760){this[_0xd389('0x11')]=this[_0xd389('0x11')]?this['tail'][_0xd389('0x12')](_0x21f760):_0x21f760();};function Preview(_0x56b2d8){this[_0xd389('0x13')]=new Sequence();this[_0xd389('0x14')]=_0x56b2d8['voiceQueues'];this[_0xd389('0x15')]=_0x56b2d8[_0xd389('0x15')];this[_0xd389('0x16')]={};this[_0xd389('0x17')]=_0x56b2d8[_0xd389('0x17')];this[_0xd389('0x18')]=0x0;ami['on'](_0xd389('0x19'),this[_0xd389('0x1a')]['bind'](this));ami['on'](_0xd389('0x1b'),this[_0xd389('0x1c')][_0xd389('0x1d')](this));ami['on'](_0xd389('0x1e'),this['syncHangupRequest']['bind'](this));ami['on'](_0xd389('0x1f'),this[_0xd389('0x20')][_0xd389('0x1d')](this));ami['on']('newexten',this['syncNewExten'][_0xd389('0x1d')](this));ami['on'](_0xd389('0x21'),this[_0xd389('0x22')][_0xd389('0x1d')](this));ami['on']('attendedtransfer',this['syncAttendedTransfer'][_0xd389('0x1d')](this));ami['on'](_0xd389('0x23'),this[_0xd389('0x24')]['bind'](this));this[_0xd389('0x25')](this[_0xd389('0x14')]);}function emit(_0x453eb8,_0x57f145,_0x5e66f0){io['to'](_0x453eb8)[_0xd389('0x26')](_0x57f145,_0x5e66f0);}function emitCampaignPreview(_0x34855b){if(_0x34855b[_0xd389('0x27')]===_0xd389('0x28')){var _0x3d26cc={'id':_0x34855b['id'],'name':_0x34855b[_0xd389('0x29')],'strategy':_0x34855b['strategy'],'answered':_0x34855b['answered'],'available':_0x34855b[_0xd389('0x2a')],'loggedIn':_0x34855b[_0xd389('0x2b')],'pTalking':_0x34855b[_0xd389('0x2c')],'sumBillable':_0x34855b[_0xd389('0x2d')],'sumDuration':_0x34855b[_0xd389('0x2e')],'sumHoldTime':_0x34855b[_0xd389('0x2f')]||0x0,'talking':_0x34855b[_0xd389('0x30')],'total':_0x34855b['total'],'type':_0x34855b[_0xd389('0x27')],'unmanaged':_0x34855b[_0xd389('0x31')],'abandoned':_0x34855b[_0xd389('0x32')],'waiting':_0x34855b[_0xd389('0x33')],'loggedInDb':_0x34855b[_0xd389('0x34')],'dialActive':_0x34855b['dialActive'],'dialMethod':_0x34855b['dialMethod'],'dialOriginateCallerIdName':_0x34855b[_0xd389('0x35')],'dialOriginateCallerIdNumber':_0x34855b[_0xd389('0x36')],'dialOriginateTimeout':_0x34855b['dialOriginateTimeout'],'dialPrefix':_0x34855b[_0xd389('0x37')],'outboundAnswerAgiCallsDay':_0x34855b[_0xd389('0x38')],'outboundAnswerCallsDay':_0x34855b[_0xd389('0x39')],'outboundBlacklistCallsDay':_0x34855b[_0xd389('0x3a')],'outboundBusyCallsDay':_0x34855b[_0xd389('0x3b')],'outboundCongestionCallsDay':_0x34855b[_0xd389('0x3c')],'outboundDropCallsDayACS':_0x34855b[_0xd389('0x3d')],'outboundDropCallsDayCallersExit':_0x34855b[_0xd389('0x3e')],'outboundDropCallsDayTimeout':_0x34855b[_0xd389('0x3f')],'outboundNoAnswerCallsDay':_0x34855b[_0xd389('0x40')],'outboundNoSuchCallsDay':_0x34855b[_0xd389('0x41')],'outboundOriginateFailureCallsDay':_0x34855b['outboundOriginateFailureCallsDay'],'outboundReCallsDay':_0x34855b[_0xd389('0x42')],'outboundRejectCallsDay':_0x34855b['outboundRejectCallsDay'],'outboundUnknownCallsDay':_0x34855b[_0xd389('0x43')],'predictiveIntervalAnsweredCalls':_0x34855b['predictiveIntervalAnsweredCalls'],'predictiveIntervalAvgHoldtime':_0x34855b[_0xd389('0x44')],'predictiveIntervalAvgTalktime':_0x34855b[_0xd389('0x45')],'predictiveIntervalDroppedCallsCallersExit':_0x34855b[_0xd389('0x46')],'predictiveIntervalDroppedCallsTimeout':_0x34855b['predictiveIntervalDroppedCallsTimeout'],'predictiveIntervalErlangCalls':_0x34855b[_0xd389('0x47')],'predictiveIntervalErlangCallsDroppedCalls':_0x34855b[_0xd389('0x48')],'predictiveIntervalHitRate':_0x34855b[_0xd389('0x49')],'predictiveIntervalLowerLimit':_0x34855b[_0xd389('0x4a')],'predictiveIntervalMultiplicativeFactor':_0x34855b[_0xd389('0x4b')],'predictiveIntervalPauses':_0x34855b['predictiveIntervalPauses'],'predictiveIntervalTotalCalls':_0x34855b[_0xd389('0x4c')],'message':_0x34855b['message'],'originated':_0x34855b[_0xd389('0x4d')]};if(_0x34855b[_0xd389('0x4e')]){_0x3d26cc[_0xd389('0x4e')]={'id':_0x34855b[_0xd389('0x4e')]['id'],'name':_0x34855b[_0xd389('0x4e')][_0xd389('0x29')],'active':_0x34855b[_0xd389('0x4e')][_0xd389('0x4f')],'callerid':_0x34855b[_0xd389('0x4e')][_0xd389('0x50')]};}if(_0x34855b[_0xd389('0x51')]){_0x3d26cc[_0xd389('0x51')]={'id':_0x34855b[_0xd389('0x51')]['id'],'name':_0x34855b[_0xd389('0x51')][_0xd389('0x29')]};}var _0x5c2d51=md5(JSON[_0xd389('0x52')](_0x3d26cc));if(_0x34855b[_0xd389('0x53')]!==_0x5c2d51){_0x34855b[_0xd389('0x53')]=_0x5c2d51;emit(util[_0xd389('0x54')](_0xd389('0x55'),_0x3d26cc[_0xd389('0x29')]),_0xd389('0x56'),_0x3d26cc);}}}function emitVoiceQueueChannelRemove(_0x22408e){emit(util[_0xd389('0x54')](_0xd389('0x55'),_0x22408e['name']),_0xd389('0x57'),_0x22408e);}function notSendMessagesQueue(_0x11d65b){if(_0x11d65b[_0xd389('0x58')]){if(_0x11d65b[_0xd389('0x4d')]===0x0&&_0x11d65b[_0xd389('0x2c')]===0x0){_0x11d65b[_0xd389('0x58')]=![];_0x11d65b['available']=0x0;_0x11d65b[_0xd389('0x59')]=0x0;_0x11d65b[_0xd389('0x5a')]=_0xd389('0x5b');ut[_0xd389('0x5c')](_0xd389('0x5d'),_0x11d65b[_0xd389('0x29')]+'\x20is\x20not\x20active');}else{_0x11d65b[_0xd389('0x5a')]=_0xd389('0x5e');ut[_0xd389('0x5c')](_0xd389('0x5d'),_0x11d65b[_0xd389('0x29')]+_0xd389('0x5f'));}emitCampaignPreview(_0x11d65b);}}Preview[_0xd389('0xf')][_0xd389('0x25')]=function(){var _0x55d6c6=this;setInterval(function(){_0x55d6c6['syncCampaigns']();},0x7cf);};Preview['prototype'][_0xd389('0x60')]=function(){var _0x38148e=this[_0xd389('0x14')];this[_0xd389('0x18')]+=0x1;for(var _0x454948 in _0x38148e){if(_0x38148e['hasOwnProperty'](_0x454948)&&(_0x38148e[_0x454948][_0xd389('0x61')]===_0xd389('0x62')||_0x38148e[_0x454948][_0xd389('0x61')]===_0xd389('0x63'))&&_0x38148e[_0x454948][_0xd389('0x27')]===_0xd389('0x28')){if(this[_0xd389('0x18')]>0x7){this['clockClearZombieChannels']=0x0;this[_0xd389('0x64')]();}}if(_0x38148e[_0xd389('0x65')](_0x454948)&&_0x38148e[_0x454948][_0xd389('0x61')]===_0xd389('0x62')&&_0x38148e[_0x454948][_0xd389('0x27')]===_0xd389('0x28')){if(_0x38148e[_0x454948][_0xd389('0x66')]){this[_0xd389('0x67')](_0x38148e[_0x454948]);this[_0xd389('0x68')](_0x38148e[_0x454948]);}else{notSendMessagesQueue(_0x38148e[_0x454948]);}}}};Preview[_0xd389('0xf')][_0xd389('0x69')]=function(_0xa81a85){var _0x17704a=this;this['sequence'][_0xd389('0x10')](function(){if(!_[_0xd389('0x6a')](_0x17704a[_0xd389('0x16')][_0xa81a85])){loggerAction[_0xd389('0x6b')](_0xd389('0x6c'),_0xa81a85,_0xd389('0x6d'),_0x17704a[_0xd389('0x16')][_0xa81a85][_0xd389('0x6e')],_0xd389('0x6f'),JSON[_0xd389('0x52')](_0x17704a['campaignsPreview'][_0x17704a[_0xd389('0x16')][_0xa81a85][_0xd389('0x6e')]][_0xd389('0x4d')]),_0xd389('0x70'),JSON[_0xd389('0x52')](_0x17704a[_0xd389('0x14')][_0x17704a[_0xd389('0x16')][_0xa81a85][_0xd389('0x6e')]][_0xd389('0x2c')]),JSON[_0xd389('0x52')](_0x17704a['actions'][_0xa81a85][_0xd389('0x71')]),JSON[_0xd389('0x52')](_[_0xd389('0x72')](_0x17704a['actions'][_0xa81a85],[_0xd389('0x73'),_0xd389('0x74'),_0xd389('0x75'),'ListId'])));return ami['Action']({'action':_0xd389('0x76'),'channel':_0x17704a[_0xd389('0x16')][_0xa81a85][_0xd389('0x77')]})[_0xd389('0x78')](function(_0x155290){if(_0x155290[_0xd389('0x5a')]===_0xd389('0x79')){setTimeout(function(){if(_0x17704a[_0xd389('0x16')][_0xa81a85]){ut['updateOriginated'](_0x17704a[_0xd389('0x14')][_0x17704a[_0xd389('0x16')][_0xa81a85]['queue']],_0xd389('0x7a'));if(_0x17704a[_0xd389('0x16')][_0xa81a85]['dialAnswer']===!![]){ut[_0xd389('0x7b')](_0x17704a[_0xd389('0x14')][_0x17704a[_0xd389('0x16')][_0xa81a85][_0xd389('0x6e')]],_0xd389('0x7a'));ut[_0xd389('0x7c')](_0xd389('0x7d')+_0xa81a85,_0x17704a['actions'][_0xa81a85][_0xd389('0x6e')]);}ut[_0xd389('0x7c')]('[Dialer][checkChannel][Preview]'+_0xa81a85,_0x17704a[_0xd389('0x16')][_0xa81a85]['queue']);delete _0x17704a['actions'][_0xa81a85];}},0x2328);}});}});};Preview[_0xd389('0xf')][_0xd389('0x64')]=function(){var _0x49331f=this;loggerAction[_0xd389('0x6b')](_0xd389('0x7e'),_[_0xd389('0x7f')](this[_0xd389('0x16')]));for(var _0x1bcd91 in this[_0xd389('0x16')]){if(_0x49331f[_0xd389('0x16')][_0xd389('0x65')](_0x1bcd91)){_0x49331f[_0xd389('0x69')](_0x1bcd91);}}};Preview[_0xd389('0xf')][_0xd389('0x68')]=function(_0x445909){var _0x2fe163=this;rpcDb[_0xd389('0x80')](_0x445909['id'],ut[_0xd389('0x81')](this[_0xd389('0x17')]))[_0xd389('0x82')](function(_0x240a5e){if(!_[_0xd389('0x6a')](_0x240a5e)){for(var _0x28ef6f=0x0;_0x28ef6f<_0x240a5e[_0xd389('0x83')];_0x28ef6f+=0x1){if(ut[_0xd389('0x84')](_0x240a5e[_0x28ef6f]['scheduledat'])<_0x445909[_0xd389('0x85')]*0x3c){_0x2fe163[_0xd389('0x86')](_0x240a5e[_0x28ef6f]['id'])['then'](ut[_0xd389('0x87')]('[RecallMe]'))['catch'](ut['logger2'](_0xd389('0x88')));}else{var _0x375a1c=new Action(_0x240a5e[_0x28ef6f],_0x445909);_0x375a1c[_0xd389('0x89')]=moment()[_0xd389('0x54')](_0xd389('0x8a'));_0x445909[_0xd389('0x42')]+=0x1;ut['logCustomer'](_0x375a1c,0x17,_0xd389('0x8b'));if(_0x445909[_0xd389('0x8c')]){rpcDb['rescheduleContactInQueue'](ut[_0xd389('0x8d')](_0x240a5e[_0x28ef6f]));rpcDb['createCustomerHistory'](_0x375a1c,_0xd389('0x8e'));}else{ut[_0xd389('0x8f')](_0x375a1c,0x16,_0xd389('0x90'));rpcDb[_0xd389('0x91')](_0x375a1c,_0xd389('0x92'));rpcDb['createCustomerFinal'](_0x375a1c,_0xd389('0x92'));}}}}})[_0xd389('0x78')](ut[_0xd389('0x87')]('[getContactRecallMe]'));};Preview[_0xd389('0xf')][_0xd389('0x67')]=function(_0xfa1f66){_0xfa1f66[_0xd389('0x58')]=!![];if(ut[_0xd389('0x93')](_0xfa1f66[_0xd389('0x2b')])){_0xfa1f66['message']='AGENTS_NOT_LOGGED';}else if(!ut[_0xd389('0x94')](_0xfa1f66[_0xd389('0x66')])){_0xfa1f66[_0xd389('0x5a')]=_0xd389('0x5b');}else if(!this[_0xd389('0x95')](_0xfa1f66['Trunk'])){if(!this['isTrunkReachable'](_0xfa1f66['TrunkBackup'])){_0xfa1f66[_0xd389('0x5a')]='TRUNK_IS_NOT_REACHABLE';}else{_0xfa1f66['message']='ACTIVE';}}else{_0xfa1f66[_0xd389('0x5a')]=_0xd389('0x96');}emitCampaignPreview(_0xfa1f66);};Preview[_0xd389('0xf')]['callProgressDetectingCustomer']=function(_0x119c0e,_0x476dd8,_0x1f167a){var _0x1a531d=this;var _0x50afcb=this['actions'][_0x476dd8];var _0x3c466d=this[_0xd389('0x14')][_0x50afcb[_0xd389('0x6e')]];var _0x5e82eb;if(_0x3c466d){switch(_0x1f167a){case'1':_0x3c466d[_0xd389('0x41')]+=0x1;_0x50afcb[_0xd389('0x97')]=ut['totalGlobal'](_0x50afcb);ut['logCustomer'](_0x50afcb,0x0,_0xd389('0x98'));rpcDb[_0xd389('0x91')](_0x50afcb,_0xd389('0x99'));if(ut['totalGlobal'](_0x50afcb)>=_0x3c466d[_0xd389('0x9a')]){_0x5e82eb=ut[_0xd389('0x9b')](_0x50afcb,0xf,'Global');rpcDb[_0xd389('0x9c')](_0x5e82eb,_0xd389('0x9d'));}else{rpcDb[_0xd389('0x9c')](_0x50afcb,_0xd389('0x9d'));}delete this[_0xd389('0x16')][_0x119c0e[_0xd389('0x9e')]];break;case _0xd389('0x9f'):var _0x521e7a=moment()['format'](_0xd389('0x8a'));_0x50afcb[_0xd389('0xa0')]=_0x521e7a;_0x50afcb[_0xd389('0xa1')]=_0x521e7a;_0x50afcb[_0xd389('0x71')]=!![];_0x3c466d['pTalking']+=0x1;logger[_0xd389('0x6b')](_0xd389('0xa2'),_0x50afcb[_0xd389('0xa3')],'\x20Queue',_0x3c466d[_0xd389('0x29')],_0xd389('0x70'),_0x3c466d['pTalking']);ami[_0xd389('0x26')](_0xd389('0xa4'),ut[_0xd389('0xa5')](_0x50afcb,'connect'));if(_0x3c466d[_0xd389('0xa6')]){ami[_0xd389('0x26')](_0xd389('0xa7'),ut[_0xd389('0xa8')](_0x50afcb));}break;case'16':ami['emit'](_0xd389('0xa9'),ut[_0xd389('0xa5')](_0x50afcb,_0xd389('0xaa')));emitVoiceQueueChannelRemove(ut[_0xd389('0xa5')](_0x50afcb,_0xd389('0xaa')));_0x3c466d['outboundAnswerCallsDay']+=0x1;_0x3c466d[_0xd389('0xab')]+=0x1;_0x3c466d['answered']+=0x1;ut[_0xd389('0x7b')](_0x3c466d,'[16]');_0x50afcb[_0xd389('0x97')]=ut[_0xd389('0xac')](_0x50afcb);ut[_0xd389('0x8f')](_0x50afcb,0x4,_0xd389('0xad'));rpcDb[_0xd389('0x91')](_0x50afcb,'[callProgressDetectingCustomer][logAnswer]');rpcDb[_0xd389('0x9c')](_0x50afcb,_0xd389('0xae'));rpcDb[_0xd389('0xaf')](_0x50afcb);_0x3c466d[_0xd389('0x2e')]+=_0x50afcb[_0xd389('0xb0')];_0x3c466d[_0xd389('0x2d')]+=_0x50afcb['talktime'];logger[_0xd389('0x6b')](_0xd389('0xb1'),_0x50afcb[_0xd389('0xa3')],_0xd389('0xb2'),_0x3c466d[_0xd389('0x29')],_0xd389('0x70'),_0x3c466d[_0xd389('0x2c')]);delete this[_0xd389('0x16')][_0x119c0e[_0xd389('0x9e')]];break;case _0xd389('0xb3'):_0x3c466d[_0xd389('0x3b')]+=0x1;_0x50afcb[_0xd389('0xb4')]+=0x1;_0x50afcb['countglobal']=ut[_0xd389('0xac')](_0x50afcb);ut[_0xd389('0x8f')](_0x50afcb,0x5,'Busy');rpcDb[_0xd389('0x91')](_0x50afcb,_0xd389('0xb5'));if(ut[_0xd389('0xac')](_0x50afcb)>=_0x3c466d[_0xd389('0x9a')]){_0x5e82eb=ut['cloneAction'](_0x50afcb,0xf,_0xd389('0xb6'));rpcDb[_0xd389('0x9c')](_0x5e82eb,_0xd389('0xb7'));}else{if(_0x50afcb[_0xd389('0xb4')]>=_0x3c466d[_0xd389('0xb8')]){rpcDb['createCustomerFinal'](_0x50afcb,_0xd389('0xb5'));}else{rpcDb[_0xd389('0xb9')](ut[_0xd389('0xba')](_0x50afcb,'countbusyretry',_0x3c466d['dialBusyRetryFrequency']),_0x50afcb[_0xd389('0xbb')],_0x50afcb[_0xd389('0xbc')]);}}break;case _0xd389('0xbd'):_0x3c466d[_0xd389('0x40')]+=0x1;_0x50afcb[_0xd389('0xbe')]+=0x1;_0x50afcb['countglobal']=ut[_0xd389('0xac')](_0x50afcb);ut[_0xd389('0x8f')](_0x50afcb,0x3,'NoAnswer');rpcDb[_0xd389('0x91')](_0x50afcb,_0xd389('0xbf'));if(ut[_0xd389('0xac')](_0x50afcb)>=_0x3c466d[_0xd389('0x9a')]){_0x5e82eb=ut[_0xd389('0x9b')](_0x50afcb,0xf,_0xd389('0xb6'));rpcDb[_0xd389('0x9c')](_0x5e82eb,'[callProgressDetectingCustomer][logNoAnswerGlobal]');}else{if(_0x50afcb[_0xd389('0xbe')]>=_0x3c466d[_0xd389('0xc0')]){rpcDb['createCustomerFinal'](_0x50afcb,_0xd389('0xbf'));}else{rpcDb[_0xd389('0xb9')](ut[_0xd389('0xba')](_0x50afcb,_0xd389('0xbe'),_0x3c466d[_0xd389('0xc1')]),_0x50afcb['unlockAgent'],_0x50afcb['activeContact']);}}break;case _0xd389('0xc2'):_0x3c466d['outboundCongestionCallsDay']+=0x1;_0x50afcb[_0xd389('0xc3')]+=0x1;_0x50afcb[_0xd389('0x97')]=ut[_0xd389('0xac')](_0x50afcb);ut['logCustomer'](_0x50afcb,0x8,_0xd389('0xc4'));rpcDb['createCustomerHistory'](_0x50afcb,_0xd389('0xc5'));if(ut[_0xd389('0xac')](_0x50afcb)>=_0x3c466d[_0xd389('0x9a')]){_0x5e82eb=ut['cloneAction'](_0x50afcb,0xf,_0xd389('0xb6'));rpcDb[_0xd389('0x9c')](_0x5e82eb,_0xd389('0xc6'));}else{if(_0x50afcb[_0xd389('0xc3')]>=_0x3c466d[_0xd389('0xc7')]){rpcDb[_0xd389('0x9c')](_0x50afcb,_0xd389('0xc5'));}else{rpcDb[_0xd389('0xb9')](ut[_0xd389('0xba')](_0x50afcb,'countcongestionretry',_0x3c466d['dialBusyRetryFrequency']),_0x50afcb[_0xd389('0xbb')],_0x50afcb['activeContact']);}}break;case'CANCEL':_0x3c466d[_0xd389('0xc8')]+=0x1;_0x50afcb['countglobal']=ut['totalGlobal'](_0x50afcb);ut[_0xd389('0x8f')](_0x50afcb,0x14,_0xd389('0xc9'));rpcDb['createCustomerHistory'](_0x50afcb,'[syncHangupRequest][logAgentReject]');if(_0x50afcb[_0xd389('0xbb')]){rpcDb[_0xd389('0xca')](_0x50afcb[_0xd389('0xcb')]);}if(_0x50afcb[_0xd389('0xbc')]){rpcDb[_0xd389('0xcc')](_0x50afcb[_0xd389('0xcb')]);}break;default:if(_0x50afcb[_0xd389('0x71')]){ut[_0xd389('0x7b')](_0x3c466d,_0xd389('0xcd'));ut['loggerError'](_0xd389('0xce')+_0x3c466d[_0xd389('0x29')],_0x119c0e);}_0x3c466d[_0xd389('0x43')]+=0x1;_0x50afcb['countglobal']=ut[_0xd389('0xac')](_0x50afcb);ut['logCustomer'](_0x50afcb,0xc,_0x119c0e[_0xd389('0xcf')]||_0x119c0e[_0xd389('0xd0')]);rpcDb['createCustomerHistory'](_0x50afcb,_0xd389('0xd1'));if(ut[_0xd389('0xac')](_0x50afcb)>=_0x3c466d['dialGlobalMaxRetry']){_0x5e82eb=ut['cloneAction'](_0x50afcb,0xf,'Global');rpcDb[_0xd389('0x9c')](_0x5e82eb,'[callProgressDetectingCustomer][logUnknownGlobal]');}else{rpcDb[_0xd389('0x9c')](_0x50afcb,'[callProgressDetectingCustomer][logUnknownGlobal]');}delete this[_0xd389('0x16')][_0x119c0e[_0xd389('0x9e')]];}if(!(_0x50afcb[_0xd389('0x71')]&&_0x1f167a==='16')){ut[_0xd389('0xd2')](_0x3c466d,'[callProgressDetectingCustomer]');logger[_0xd389('0x6b')](_0xd389('0xd3'),_0x50afcb[_0xd389('0xa3')],_0xd389('0xb2'),_0x3c466d['name'],_0xd389('0x6f'),_0x3c466d[_0xd389('0x4d')]);}if(_0x1f167a!=='ANSWER'){delete this[_0xd389('0x16')][_0x119c0e[_0xd389('0x9e')]];delete this[_0xd389('0x16')][_0x119c0e[_0xd389('0xd4')]];}}};Preview[_0xd389('0xf')][_0xd389('0xd5')]=function(_0xfe7054,_0x39a3c7,_0x1bdb38){if(_[_0xd389('0xd6')](_0x39a3c7)&&'object'!==typeof _0x39a3c7){return;}if(_[_0xd389('0xd6')](_0x1bdb38)&&_0xd389('0xd7')!==typeof _0x1bdb38){return;}switch(_0x1bdb38[_0xd389('0xd8')]){case'0':ut[_0xd389('0xd9')](_0xfe7054,0x0,_0xd389('0x98'));rpcDb[_0xd389('0xda')](_0xfe7054,_0xd389('0xdb'));break;case'3':ut[_0xd389('0xd9')](_0xfe7054,0x3,'NoAnswer');rpcDb[_0xd389('0xda')](_0xfe7054,_0xd389('0xdc'));break;case'5':ut[_0xd389('0xd9')](_0xfe7054,0x5,_0xd389('0xdd'));rpcDb[_0xd389('0xda')](_0xfe7054,_0xd389('0xde'));break;case'8':ut[_0xd389('0xd9')](_0xfe7054,0x8,_0xd389('0xc4'));rpcDb[_0xd389('0xda')](_0xfe7054,_0xd389('0xdf'));break;case'22':ut['logAgent'](_0xfe7054,0x16,_0xd389('0xe0'));rpcDb[_0xd389('0xda')](_0xfe7054,_0xd389('0xe1'));break;default:ut[_0xd389('0xd9')](_0xfe7054,0xc,_0x1bdb38[_0xd389('0xd8')]);rpcDb[_0xd389('0xda')](_0xfe7054,'[callProgressDetectingAgent][logCongestion]');}ut[_0xd389('0xd2')](_0x39a3c7,'[callProgressDetectingAgent]');logger[_0xd389('0x6b')](_0xd389('0xe2'),_0xfe7054[_0xd389('0xa3')],_0xd389('0xb2'),_0x39a3c7[_0xd389('0x29')],'originated:\x20',_0x39a3c7['originated']);delete this['actions'][_0xfe7054[_0xd389('0xa3')]];};Preview[_0xd389('0xf')][_0xd389('0xe3')]=function(_0xe1735a,_0x2bbdcd,_0x544be4,_0x5a6afd,_0x49650a){var _0x477b89=this;return new BPromise(function(_0xd2721c,_0x28287c){if(_[_0xd389('0x6a')](_0x2bbdcd)||_['isNil'](_0x2bbdcd['Contact'])||_[_0xd389('0x6a')](_0x2bbdcd['Contact'][_0xd389('0xe4')])||_['isNil'](_0x2bbdcd['VoiceQueueId'])){_0x28287c(ut[_0xd389('0x5a')](_0xd389('0xe5'),_0x5a6afd,_0x49650a));return;}var _0x2f7524=uuid['v4']();var _0x5cd5e3=_0x477b89[_0xd389('0x14')][_0x2bbdcd[_0xd389('0x6d')][_0xd389('0x29')]];var _0x408ebc=_0x544be4?_0x477b89[_0xd389('0x17')][_0x544be4]['id']:undefined;_0x477b89[_0xd389('0x16')][_0x2f7524]=new Action(_0x2bbdcd,_0x5cd5e3,_0x2f7524,_0x544be4,_0x408ebc);var _0x7c2b3d=_0x477b89[_0xd389('0x16')][_0x2f7524];_0x7c2b3d[_0xd389('0xbb')]=_0x5a6afd;_0x7c2b3d['activeContact']=_0x49650a;_0x7c2b3d['lookAgent']=_0x544be4;if(_[_0xd389('0xe6')](_0xe1735a)){_0x477b89[_0xd389('0xe7')](_0x7c2b3d,_0x5cd5e3,_0x2bbdcd,_0x544be4)[_0xd389('0x82')](function(_0x5127dc){logger[_0xd389('0x6b')](_0xd389('0xe8'),_0xd389('0xe9')+_0x7c2b3d[_0xd389('0x6e')]+'\x20IdHopper:\x20'+_0x7c2b3d['idContact'],JSON[_0xd389('0x52')](_0x5127dc));ami[_0xd389('0x26')](_0xd389('0xea'),ut['buildObj'](_0x7c2b3d,_0xd389('0xeb')));_0xd2721c(ut[_0xd389('0x5a')](_0xd389('0xec')));})[_0xd389('0x78')](function(_0x1911b5){ut[_0xd389('0x5c')](_0xd389('0xed'),_0x1911b5);_0x28287c(ut[_0xd389('0x5a')]('Call\x20failed',_0x5a6afd,_0x49650a));});}else{_0x5cd5e3[_0xd389('0x3a')]+=0x1;ut[_0xd389('0xee')](_0x7c2b3d);rpcDb[_0xd389('0xef')](_0x7c2b3d,_0xd389('0xf0'));delete _0x477b89[_0xd389('0x16')][_0x2f7524];_0x28287c(ut[_0xd389('0x5a')](_0xd389('0xf1'),_0x5a6afd,_0x49650a));}});};Preview[_0xd389('0xf')][_0xd389('0x95')]=function(_0x250e72){return!_[_0xd389('0x6a')](_0x250e72)&&!_[_0xd389('0x6a')](_0x250e72[_0xd389('0x29')])&&!_[_0xd389('0x6a')](_0x250e72[_0xd389('0x4f')])&&_0x250e72[_0xd389('0x4f')]&&!_['isNil'](this['trunks'][util['format'](_0xd389('0xf2'),_0x250e72['name'])])&&!_['isNil'](this[_0xd389('0x15')][util[_0xd389('0x54')](_0xd389('0xf2'),_0x250e72['name'])][_0xd389('0x76')])&&(this['trunks'][util[_0xd389('0x54')](_0xd389('0xf2'),_0x250e72[_0xd389('0x29')])][_0xd389('0x76')]===_0xd389('0xf3')||this['trunks'][util[_0xd389('0x54')]('SIP/%s',_0x250e72[_0xd389('0x29')])]['status']===_0xd389('0xf4'));};Preview['prototype']['run']=function(_0x278b39,_0x156154){var _0x3b7d02=this;return new BPromise(function(_0x160e26,_0x3af226){_0x3b7d02[_0xd389('0xf5')](_0x278b39,_0x156154)[_0xd389('0x82')](function(_0x53d95a){_0x160e26(_['pick'](_0x53d95a,[_0xd389('0x5a')]));})[_0xd389('0x78')](function(_0x3ada57){if(_0x3ada57['unlock']){rpcDb['unlockContact'](_0x278b39);}if(_0x3ada57['active']){rpcDb['disableContact'](_0x278b39);}_0x3af226(_[_0xd389('0x72')](_0x3ada57,[_0xd389('0x5a')]));});});};Preview[_0xd389('0xf')][_0xd389('0xf5')]=function(_0x16e5af,_0x3f0ace){var _0x4cdec1=this;return new BPromise(function(_0x349b79,_0x13fbf4){var _0x11643c,_0x58077f;rpcDb[_0xd389('0xf6')](_0x16e5af)[_0xd389('0x82')](function(_0x1a6b50){if(!_[_0xd389('0x6a')](_0x1a6b50[0x0])){_0x58077f=_0x1a6b50[0x0][_0xd389('0xf7')]?![]:!![];_0x11643c=_0x1a6b50[0x0][_0xd389('0xf7')]?!![]:![];_0x11643c=_0x3f0ace?!![]:_0x11643c;}var _0x441402=_0x4cdec1[_0xd389('0xf8')](_0x1a6b50);if(_0x441402[_0xd389('0xf9')]){rpcDb[_0xd389('0xfa')](_[_0xd389('0x72')](_0x1a6b50[0x0],[_0xd389('0x75'),_0xd389('0xfb')]))[_0xd389('0x82')](function(_0x57a8c3){_0x4cdec1[_0xd389('0xe3')](_0x57a8c3,_0x1a6b50[0x0],_0x3f0ace,_0x58077f,_0x11643c)[_0xd389('0x82')](function(_0x286784){_0x349b79(_0x286784);})['catch'](function(_0x5d2757){_0x13fbf4(_0x5d2757);});})[_0xd389('0x78')](function(_0x15cfe2){ut['logger'](_0xd389('0xfc'),_0x15cfe2);_0x13fbf4(ut[_0xd389('0x5a')]('Call\x20unsuccessful',_0x58077f,_0x11643c));});}else{_0x13fbf4(ut[_0xd389('0x5a')](_0x441402[_0xd389('0x5a')],_0x58077f,_0x11643c));}})[_0xd389('0x78')](function(_0x1db759){ut[_0xd389('0x5c')](_0xd389('0xfd'),_0x1db759);_0x13fbf4(ut[_0xd389('0x5a')](_0xd389('0xfe'),![],!![]));});});};Preview['prototype'][_0xd389('0xf8')]=function(_0x21a76d){if(_[_0xd389('0x6a')](_0x21a76d)||_['isEmpty'](_0x21a76d)||!_[_0xd389('0x6a')](_0x21a76d[0x0]['Agent'])&&_[_0xd389('0x6a')](_0x21a76d[0x0][_0xd389('0xff')][_0xd389('0x29')])){ut[_0xd389('0x5c')](_0xd389('0x100'),_0x21a76d);return{'isValid':![],'message':_0xd389('0x101')};}var _0x4c8a45=this['campaignsPreview'][_0x21a76d[0x0][_0xd389('0x6d')][_0xd389('0x29')]];_0x4c8a45[_0xd389('0x5a')]=_0xd389('0x96');if(_[_0xd389('0x6a')](_0x4c8a45)){ut[_0xd389('0x5c')](_0xd389('0x102'),_0x4c8a45);return{'isValid':![],'message':_0xd389('0x103')};}if(!this[_0xd389('0x95')](_0x4c8a45[_0xd389('0x4e')])){ut['logger'](_0xd389('0x104'),_0xd389('0x105')+_0x4c8a45[_0xd389('0x29')]+_0xd389('0x106'));if(!this[_0xd389('0x95')](_0x4c8a45[_0xd389('0x107')])){ut[_0xd389('0x5c')](_0xd389('0x104'),_0x4c8a45['name']+_0xd389('0x108'));return{'isValid':![],'message':_0xd389('0x109')};}}if(!ut['isActive'](_0x4c8a45['dialActive'])){ut[_0xd389('0x5c')](_0xd389('0x10a'),_0x4c8a45[_0xd389('0x29')]+_0xd389('0x10b'));return{'isValid':![],'message':_0xd389('0x105')+_0x4c8a45[_0xd389('0x29')]+_0xd389('0x10b')};}return{'isValid':!![],'message':'Is\x20Valid'};};Preview['prototype'][_0xd389('0xe7')]=function(_0x4e300e,_0x1657f9,_0x4ed3f0,_0x5be5ae){var _0x58dd19=this;return new BPromise(function(_0x9e0c01,_0x17b4cf){var _0x1bae2f=_0x4e300e['uniqueid'];var _0x2cc2d5=_0x58dd19[_0xd389('0x95')](_0x1657f9['Trunk'])?util[_0xd389('0x54')]('SIP/%s/%s%s',_0x1657f9['Trunk'][_0xd389('0x29')],_['isNil'](_0x1657f9['dialPrefix'])?'':_0x1657f9[_0xd389('0x37')]['trim']()||'',_0x1657f9[_0xd389('0x10c')]>0x0?_0x4ed3f0['Contact']['phone'][_0xd389('0x10d')](_0x1657f9[_0xd389('0x10c')]):_0x4ed3f0['Contact']['phone']):util[_0xd389('0x54')]('SIP/%s/%s%s',_[_0xd389('0x6a')](_0x1657f9[_0xd389('0x107')])?_0x1657f9[_0xd389('0x4e')]['name']:_0x1657f9['TrunkBackup']['name'],_[_0xd389('0x6a')](_0x1657f9[_0xd389('0x37')])?'':_0x1657f9['dialPrefix'][_0xd389('0x10e')]()||'',_0x1657f9[_0xd389('0x10c')]>0x0?_0x4ed3f0[_0xd389('0x10f')][_0xd389('0xe4')][_0xd389('0x10d')](_0x1657f9[_0xd389('0x10c')]):_0x4ed3f0['Contact'][_0xd389('0xe4')]);var _0x8bbc2f=_0x58dd19[_0xd389('0x95')](_0x1657f9[_0xd389('0x4e')])?ut[_0xd389('0x110')](_0x1657f9[_0xd389('0x4e')][_0xd389('0x50')],_0x1657f9[_0xd389('0x35')],_0x1657f9[_0xd389('0x111')]>0x0?ut[_0xd389('0x112')](_0x1657f9['dialOriginateCallerIdNumber'],_0x1657f9[_0xd389('0x111')]):_0x1657f9[_0xd389('0x36')]):ut[_0xd389('0x110')](_[_0xd389('0x6a')](_0x1657f9['TrunkBackup'])?_0x1657f9[_0xd389('0x4e')][_0xd389('0x50')]:_0x1657f9['TrunkBackup'][_0xd389('0x50')],_0x1657f9['dialOriginateCallerIdName'],_0x1657f9[_0xd389('0x111')]>0x0?ut[_0xd389('0x112')](_0x1657f9[_0xd389('0x36')],_0x1657f9['dialRandomLastDigitCallerIdNumber']):_0x1657f9[_0xd389('0x36')]);if(_0x8bbc2f){_0x4e300e[_0xd389('0x113')]=ut['extractCalleridName'](_0x8bbc2f);_0x4e300e[_0xd389('0x114')]=ut['extractCalleridNumber'](_0x8bbc2f);}var _0x122842=ut[_0xd389('0x115')](_0x1657f9,_0x4ed3f0,_0x2cc2d5,_0x8bbc2f,_0x1bae2f,_0x4e300e);_[_0xd389('0x116')](_0x4e300e,ut[_0xd389('0x117')](_0x122842));_0x4e300e[_0xd389('0x89')]=moment()['format'](_0xd389('0x8a'));ami[_0xd389('0x118')](ut['variablesAction'](_0x4e300e,_0x1657f9,_0x122842,_0x4e300e[_0xd389('0xbc')],_0x5be5ae))[_0xd389('0x82')](function(_0x575426){_0x1657f9[_0xd389('0x4d')]+=0x1;logger[_0xd389('0x6b')](_0xd389('0x119'),_0x1bae2f,_0xd389('0xb2'),_0x1657f9[_0xd389('0x29')],_0xd389('0x6f'),_0x1657f9[_0xd389('0x4d')]);_0x9e0c01(_0x575426);})[_0xd389('0x78')](function(_0x19550e){ut[_0xd389('0xd9')](_0x4e300e,0xe,_0xd389('0x11a'));rpcDb[_0xd389('0xda')](_0x4e300e,_0xd389('0x11b'));_0x17b4cf(_0x19550e);});});};Preview['prototype'][_0xd389('0x11c')]=function(_0x579812){if(this[_0xd389('0x16')][_0x579812[_0xd389('0x9e')]]){this[_0xd389('0x16')][_0x579812[_0xd389('0x9e')]][_0xd389('0x77')]=_0x579812[_0xd389('0x77')];}};Preview[_0xd389('0xf')][_0xd389('0x1a')]=function(_0x4e4914){var _0x52b224=this;var _0xb935cf=this[_0xd389('0x16')][_0x4e4914[_0xd389('0x11d')]];if(_0xb935cf){if(_0xb935cf['lookAgent']&&this[_0xd389('0x17')][_0xb935cf['lookAgent']]){ut[_0xd389('0x11e')](_0xb935cf,this[_0xd389('0x17')][_0xb935cf[_0xd389('0x11f')]][_0xd389('0x29')],this['agents'][_0xb935cf[_0xd389('0x11f')]]['id']);}var _0x408b73=_[_0xd389('0x120')](_0xb935cf);_0x408b73[_0xd389('0xa0')]=moment()[_0xd389('0x54')](_0xd389('0x8a'));var _0x3ab7ce=_0x52b224[_0xd389('0x14')][_0xb935cf['queue']];if(ut[_0xd389('0x121')](_0x4e4914[_0xd389('0x122')])){if(_0xb935cf[_0xd389('0xbb')]){rpcDb[_0xd389('0xca')](_0xb935cf[_0xd389('0xcb')]);}if(_0xb935cf['activeContact']){rpcDb[_0xd389('0xcc')](_0xb935cf[_0xd389('0xcb')]);}ami[_0xd389('0x26')](_0xd389('0x123'),ut[_0xd389('0xa5')](_0xb935cf,_0xd389('0x124')));this[_0xd389('0xd5')](_0x408b73,_0x3ab7ce,_0x4e4914);}else{_0xb935cf[_0xd389('0x89')]=moment()[_0xd389('0x54')](_0xd389('0x8a'));ut[_0xd389('0xd9')](_0x408b73,0x4,_0xd389('0xad'));rpcDb['createAgentHistory'](_0x408b73,_0xd389('0x125'));}}};Preview[_0xd389('0xf')][_0xd389('0x1c')]=function(_0x55510b){var _0x351b1e=this;var _0x2c276e=this[_0xd389('0x16')][_0x55510b[_0xd389('0x9e')]];var _0x3d8d41;if(_0x2c276e){_0x3d8d41=this[_0xd389('0x14')][_0x2c276e['queue']];logger[_0xd389('0x6b')](_0xd389('0x126'),_0x55510b[_0xd389('0x9e')],_0xd389('0xb2'),_0x3d8d41[_0xd389('0x29')],_0xd389('0x70'),_0x3d8d41[_0xd389('0x2c')]);}if(this[_0xd389('0x16')][_0x55510b[_0xd389('0x9e')]]&&_0x55510b[_0xd389('0x9e')]!==_0x55510b['uniqueid']){if(_0x55510b[_0xd389('0x127')]==='16'&&this[_0xd389('0x16')][_0x55510b['linkedid']][_0xd389('0x71')]){this[_0xd389('0x128')](_0x55510b,_0x55510b['linkedid'],_0x55510b[_0xd389('0x127')]);}else if(this['actions'][_0x55510b[_0xd389('0x9e')]][_0xd389('0x71')]){logger[_0xd389('0x6b')](_0xd389('0x129'),_0x55510b[_0xd389('0x9e')],_0x55510b[_0xd389('0x127')],_0xd389('0xb2'),_0x3d8d41[_0xd389('0x29')],_0xd389('0x70'),_0x3d8d41[_0xd389('0x2c')]);this[_0xd389('0x128')](_0x55510b,_0x55510b[_0xd389('0x9e')],_0x55510b['cause']);}}else if(_0x2c276e&&_[_0xd389('0x6a')](_0x2c276e[_0xd389('0x12a')])&&_0x3d8d41[_0xd389('0x12b')]&&_0x55510b[_0xd389('0x9e')]===_0x55510b['uniqueid']&&_[_0xd389('0x6a')](_0x55510b[_0xd389('0xd8')])&&_0x55510b[_0xd389('0x127')]==='16'&&_0x55510b[_0xd389('0x12c')]==='6'&&_[_0xd389('0xd6')](_0x2c276e[_0xd389('0x12d')])){if(_0x2c276e[_0xd389('0xbb')]){rpcDb[_0xd389('0xca')](_0x2c276e[_0xd389('0xcb')]);}if(_0x2c276e[_0xd389('0xbc')]){rpcDb['disableContact'](_0x2c276e[_0xd389('0xcb')]);}_0x55510b[_0xd389('0xd8')]='22';this['callProgressDetectingAgent'](_0x2c276e,_0x3d8d41,_0x55510b);}else if(_0x2c276e&&_0x2c276e[_0xd389('0x12d')]){if(_0x55510b[_0xd389('0x127')]==='16'&&this['actions'][_0x55510b[_0xd389('0x9e')]][_0xd389('0x71')]){logger['info'](_0xd389('0x12e'),_0x55510b[_0xd389('0x9e')],_0x55510b[_0xd389('0x127')],_0xd389('0xb2'),_0x3d8d41[_0xd389('0x29')],_0xd389('0x70'),_0x3d8d41[_0xd389('0x2c')]);this[_0xd389('0x128')](_0x55510b,_0x55510b[_0xd389('0x9e')],_0x55510b[_0xd389('0x127')]);}else if(this[_0xd389('0x16')][_0x55510b[_0xd389('0x9e')]]['dialAnswer']){logger[_0xd389('0x6b')]('[syncHangup][talking][cause]',_0x55510b[_0xd389('0x9e')],_0x55510b['cause'],'\x20Queue',_0x3d8d41[_0xd389('0x29')],_0xd389('0x70'),_0x3d8d41[_0xd389('0x2c')]);this[_0xd389('0x128')](_0x55510b,_0x55510b[_0xd389('0x9e')],_0x55510b[_0xd389('0x127')]);}}};Preview[_0xd389('0xf')][_0xd389('0x20')]=function(_0x35eabb){if(this[_0xd389('0x16')][_0x35eabb[_0xd389('0xd4')]]&&_0x35eabb[_0xd389('0xd4')]!==_0x35eabb[_0xd389('0x12f')]){this['callProgressDetectingCustomer'](_0x35eabb,_0x35eabb[_0xd389('0xd4')],_0x35eabb[_0xd389('0xd0')]);}};Preview['prototype']['syncHangupRequest']=function(_0x5a89fe){if(this['actions'][_0x5a89fe[_0xd389('0x9e')]]&&_0x5a89fe[_0xd389('0x9e')]!==_0x5a89fe['uniqueid']&&!this[_0xd389('0x16')][_0x5a89fe[_0xd389('0x9e')]][_0xd389('0x71')]){if(_0x5a89fe['cause']==='1'){this[_0xd389('0x128')](_0x5a89fe,_0x5a89fe[_0xd389('0x9e')],_0x5a89fe[_0xd389('0x127')]);}}};Preview[_0xd389('0xf')][_0xd389('0x130')]=function(_0x110046,_0x3e0dd7,_0xeb11e3){if(this[_0xd389('0x16')][_0x110046]){if(_['isNil'](this[_0xd389('0x16')][_0x110046][_0xd389('0x131')])){this[_0xd389('0x16')][_0x110046][_0xd389('0x131')]={};}this[_0xd389('0x16')][_0x110046]['variables'][_0x3e0dd7]=_0xeb11e3;}};Preview[_0xd389('0xf')][_0xd389('0x22')]=function(_0xbad1f7){try{if(!_['isNil'](_0xbad1f7)){if(ut[_0xd389('0x132')](_['keys'](_0xbad1f7['variable'])[0x0])){this[_0xd389('0x130')](_0xbad1f7[_0xd389('0xa3')],_[_0xd389('0x133')](_0xbad1f7[_0xd389('0x134')])[0x0],_0xbad1f7[_0xd389('0x135')]);}}}catch(_0x4f80be){logger[_0xd389('0x136')]('[syncVarSet][Preview]',util[_0xd389('0x137')](_0x4f80be,{'showHidden':![],'depth':null}));}};Preview['prototype'][_0xd389('0x138')]=function(_0x59195e){if(_0x59195e){if(this[_0xd389('0x16')][_0x59195e[_0xd389('0x139')]]){this[_0xd389('0x16')][_0x59195e[_0xd389('0x139')]][_0xd389('0x12d')]=!![];}}};Preview[_0xd389('0xf')]['syncBlindTransfer']=function(_0x3c019f){if(_0x3c019f){if(this[_0xd389('0x16')][_0x3c019f[_0xd389('0x13a')]]){this[_0xd389('0x16')][_0x3c019f[_0xd389('0x13a')]][_0xd389('0x12d')]=!![];}}};module['exports']=Preview;