d3bbbaa5b8c82609aaf22f6dd0b4b2a2d5a8d8d2
[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 _0xf3cd=['dialPreviewAutoRecallMe','recallMe','clearZombieChannel','enqueue','queue','originated:\x20','pTalking:\x20','dialAnswer','pick','UserId','ListId','status','channel','catch','No\x20such\x20channel','updateOriginated','[clearZombieChannel]','loggerError','[action]','size','getContactRecallMe','agentReadyId','isNil','length','getDiff','scheduledat','dialRecallMeTimeout','Agent','run','then','logger2','[RecallMe]','outboundReCallsDay','logCustomer','RecallInQueue','dialRecallInQueue','[HistoryDialRecallInQueue][historyCatch]','RecallFailedTimeout','createCustomerHistory','[HistoryRecallClose]','createCustomerFinal','[getContactRecallMe]','IsNotLoggedIn','loggedIn','CAMPAIGN_STATUS','NO_AGENTS_LOGGED','isTrunkReachable','Trunk','TrunkBackup','UNREACHABLE_TRUNK','ACTIVE','outboundNoSuchCallsDay','countnosuchnumberretry','countglobal','totalGlobal','NoSuchNumber','custom:agentnosuchnumber','nosuchnumber','[callProgressDetectingCustomer][logNoSuch]','dialNoSuchNumberRetryFrequency','dialGlobalMaxRetry','cloneAction','Global','[callProgressDetectingCustomer][logNoSuchGlobal]','dialNoSuchNumberMaxRetry','rescheduleContact','scheduledAt','unlockAgent','activeContact','actioncountonusuch','idContact','swapAdditionalPhones','ANSWER','YYYY-MM-DD\x20HH:mm:ss','responsetime','answertime','uniqueid','\x20Queue','custom:agentconnect','buildObj','connect','acw','custom:agentConnectPreview','buildAcw','complete','outboundAnswerCallsDay','answered','decrementTalkink','Answer','[callProgressDetectingCustomer][logAnswer]','[callProgressDetectingCustomer][logAnswerGlobal]','crateCustomerReportQueue','talktime','sumBillable','[syncHangup][talking][decrement]','linkedid','BUSY','outboundBusyCallsDay','dialBusyRetryFrequency','callAdditionalPhoneAfterMin','busy','additional','dialBusyMaxRetry','[callProgressDetectingCustomer][logBusy]','countbusyretry','incrementPreviewCounters','NOANSWER','outboundNoAnswerCallsDay','NoAnswer','dialNoAnswerRetryFrequency','buildNoAnswerEventPayload','verifyAdditionalPhones','[callProgressDetectingCustomer][logNoAnswerGlobal]','countnoanswerretry','dialNoAnswerMaxRetry','[callProgressDetectingCustomer][logNoAnswer]','CONGESTION','outboundCongestionCallsDay','Congestion','dialCongestionRetryFrequency','custom:agentcongestion','congestion','[callProgressDetectingCustomer][logCongestion]','[callProgressDetectingCustomer][logCongestionGlobal]','countcongestionretry','outboundRejectCallsDay','countagentrejectretry','AgentReject','custom:agentreject','agentreject','[syncHangupRequest][logAgentReject]','[callProgressDetectingCustomer][logAgentReject]','dialAgentRejectRetryFrequency','ABANDONED','outboundAbandonedCallsDay','countabandonedretry','Abandoned','[callProgressDetectingCustomer][logAbandoned]','dialAbandonedMaxRety','dialAbandonedRetryFrequency','outboundUnknownCallsDay','countmachineretry','cause-txt','dialstatus','custom:amd','amd','[callProgressDetectingCustomer][machine]','[default]','[callProgressDetectingCustomer][logUnknown]','[originated][decrement][callProgressDetectingCustomer]','destlinkedid','queueSummaryCountersUpdated','callProgressDetectingAgent','isUndefined','object','reason','logAgent','createAgentHistory','[callProgressDetectingAgent][logNoSuch]','[callProgressDetectingAgent][logBusy]','[callProgressDetectingAgent][logAnswerAGI]','[originated][decrement][callProgressDetectingAgent]','[verifyAdditionalPhone]\x20','[swapAdditionalPhone]\x20','resolve','[incrementPreviewCounters]\x20','checkInBlack','VoiceQueueId','Contact\x20is\x20undefined','Queue','lookAgent','isEmpty','execCall','[Preview][execCall][success]','custom:agentcalled','called','Calling','[Preview][execCall][failure]','Call\x20failed','outboundBlacklistCallsDay','createHistory','[Blacklist][error]','Contact\x20in\x20black\x20List','active','SIP/%s','unmonitored','execRun','unlockContact','disableContact','getContactPreview','recallme','validateContact','isValid','phone','[Preview][checkIsBlackList]','[Preview][getContactPreview]','Call\x20unsuccessful','Empty\x20Contact','[Preview][validateContact][Empty\x20Campaign]','Empty\x20Campaign','[Preview][validateContact][Trunk\x20not\x20working\x20correctly]','campaign\x20Name:\x20','\x20Trunk\x20is\x20not\x20active','Trunk\x20not\x20working\x20correctly','isActive','[Preview][validateContact][Campaign\x20Active]','\x20Not\x20Active','Is\x20Valid','SIP/%s/%s%s','dialPrefix','trim','dialCutDigit','substring','getCallerId','callerid','dialOriginateCallerIdName','dialRandomLastDigitCallerIdNumber','getCallerIdRandom','dialOriginateCallerIdNumber','originatecalleridname','extractCalleridName','addVariables','toLowerVariables','variables','variablesAction','[originated][increment]','OriginateError','syncNewExten','actionid','clone','response','rejected','starttime','[callProgressDetectingAgent][logAnswer]','[syncHangup][talking]','cause','callProgressDetectingCustomer','[syncHangup][talking][cause]','statedesc','dialQueueProject','channelstate','transfer','[syncHangup][talking][transfer]','destuniqueid','addVariable','filterKey','keys','variable','value','error','[syncVarSet][Preview]','transfertargetlinkedid','transfererlinkedid','exports','util','lodash','uuid','moment','ioredis','../../../config/environment','preview','../../../config/logger','actionPreview','./rpcDb','../rpc/cmHopperAdditionalPhone','./action','./util/util','../dialer/utils','redis','prototype','tail','finally','sequence','campaignsPreview','trunks','actions','agents','clockClearZombieChannels','originateresponse','syncOriginateResponse','hangup','syncHangup','bind','hanguprequest','syncHangupRequest','dialend','syncDialEnd','newexten','varset','syncVarSet','attendedtransfer','syncAttendedTransfer','blindtransfer','syncBlindTransfer','loopCampaigns','emit','info','[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event','stringify','format','voice:queue:%s','name','voice_queue_presence:remove','sendMessageOneNotActive','originated','pTalking','available','paused','message','INACTIVE','logger','DEACTIVATED','\x20is\x20deactivated','syncCampaigns','hasOwnProperty','dialMethod','booked','type','dialActive','setMessage'];(function(_0x5774af,_0x411c94){var _0x480589=function(_0x414114){while(--_0x414114){_0x5774af['push'](_0x5774af['shift']());}};_0x480589(++_0x411c94);}(_0xf3cd,0xfe));var _0xdf3c=function(_0x5b8685,_0x1a1c28){_0x5b8685=_0x5b8685-0x0;var _0xa3ef57=_0xf3cd[_0x5b8685];return _0xa3ef57;};'use strict';var util=require(_0xdf3c('0x0'));var _=require(_0xdf3c('0x1'));var uuid=require(_0xdf3c('0x2'));var moment=require(_0xdf3c('0x3'));var Redis=require(_0xdf3c('0x4'));var config=require(_0xdf3c('0x5'));var logger=require('../../../config/logger')(_0xdf3c('0x6'));var loggerAction=require(_0xdf3c('0x7'))(_0xdf3c('0x8'));var ami=require('../ami');var rpcDb=require(_0xdf3c('0x9'));var cmHopperAdditionalPhone=require(_0xdf3c('0xa'));var Action=require(_0xdf3c('0xb'));var ut=require(_0xdf3c('0xc'));var utils=require(_0xdf3c('0xd'));config[_0xdf3c('0xe')]=_['defaults'](config[_0xdf3c('0xe')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xdf3c('0xe')]));var Sequence=function(){};Sequence[_0xdf3c('0xf')]['enqueue']=function(_0x1dba4c){this[_0xdf3c('0x10')]=this[_0xdf3c('0x10')]?this[_0xdf3c('0x10')][_0xdf3c('0x11')](_0x1dba4c):_0x1dba4c();};function Preview(_0x1c456b){this[_0xdf3c('0x12')]=new Sequence();this[_0xdf3c('0x13')]=_0x1c456b['voiceQueues'];this[_0xdf3c('0x14')]=_0x1c456b[_0xdf3c('0x14')];this[_0xdf3c('0x15')]={};this[_0xdf3c('0x16')]=_0x1c456b['agents'];this[_0xdf3c('0x17')]=0x0;ami['on'](_0xdf3c('0x18'),this[_0xdf3c('0x19')]['bind'](this));ami['on'](_0xdf3c('0x1a'),this[_0xdf3c('0x1b')][_0xdf3c('0x1c')](this));ami['on'](_0xdf3c('0x1d'),this[_0xdf3c('0x1e')][_0xdf3c('0x1c')](this));ami['on'](_0xdf3c('0x1f'),this[_0xdf3c('0x20')][_0xdf3c('0x1c')](this));ami['on'](_0xdf3c('0x21'),this['syncNewExten'][_0xdf3c('0x1c')](this));ami['on'](_0xdf3c('0x22'),this[_0xdf3c('0x23')][_0xdf3c('0x1c')](this));ami['on'](_0xdf3c('0x24'),this[_0xdf3c('0x25')][_0xdf3c('0x1c')](this));ami['on'](_0xdf3c('0x26'),this[_0xdf3c('0x27')][_0xdf3c('0x1c')](this));this[_0xdf3c('0x28')](this[_0xdf3c('0x13')]);}function emit(_0x25487c,_0x5d2390,_0x4d620f){io['to'](_0x25487c)[_0xdf3c('0x29')](_0x5d2390,_0x4d620f);}function emitVoiceQueueChannelRemove(_0x583ce4){logger[_0xdf3c('0x2a')](_0xdf3c('0x2b'),JSON[_0xdf3c('0x2c')](_0x583ce4));emit(util[_0xdf3c('0x2d')](_0xdf3c('0x2e'),_0x583ce4[_0xdf3c('0x2f')]),'voice_queue_channel:remove',_0x583ce4);io[_0xdf3c('0x29')](_0xdf3c('0x30'),_0x583ce4);}function notSendMessagesQueue(_0x13e3ca){if(_0x13e3ca[_0xdf3c('0x31')]){if(_0x13e3ca[_0xdf3c('0x32')]===0x0&&_0x13e3ca[_0xdf3c('0x33')]===0x0){_0x13e3ca[_0xdf3c('0x31')]=![];_0x13e3ca[_0xdf3c('0x34')]=0x0;_0x13e3ca[_0xdf3c('0x35')]=0x0;_0x13e3ca[_0xdf3c('0x36')]=utils['CAMPAIGN_STATUS'][_0xdf3c('0x37')];ut[_0xdf3c('0x38')]('[CampaignPreview]\x20Campaign\x20Queue:\x20',_0x13e3ca[_0xdf3c('0x2f')]+'\x20is\x20not\x20active');}else{_0x13e3ca['message']=utils['CAMPAIGN_STATUS'][_0xdf3c('0x39')];ut[_0xdf3c('0x38')]('[CampaignPreview]\x20Campaign\x20Queue:\x20',_0x13e3ca['name']+_0xdf3c('0x3a'));}}}Preview[_0xdf3c('0xf')][_0xdf3c('0x28')]=function(){var _0x1ccdd4=this;setInterval(function(){_0x1ccdd4['syncCampaigns']();},0x7cf);};Preview[_0xdf3c('0xf')][_0xdf3c('0x3b')]=function(){var _0x5386bf=this['campaignsPreview'];this[_0xdf3c('0x17')]+=0x1;for(var _0x46f0e3 in _0x5386bf){if(_0x5386bf[_0xdf3c('0x3c')](_0x46f0e3)&&(_0x5386bf[_0x46f0e3]['dialMethod']===_0xdf3c('0x6')||_0x5386bf[_0x46f0e3][_0xdf3c('0x3d')]===_0xdf3c('0x3e'))&&_0x5386bf[_0x46f0e3][_0xdf3c('0x3f')]==='outbound'){if(this[_0xdf3c('0x17')]>0x7){this[_0xdf3c('0x17')]=0x0;this['clearZombieChannels']();}}if(_0x5386bf[_0xdf3c('0x3c')](_0x46f0e3)&&_0x5386bf[_0x46f0e3][_0xdf3c('0x3d')]===_0xdf3c('0x6')&&_0x5386bf[_0x46f0e3][_0xdf3c('0x3f')]==='outbound'){if(_0x5386bf[_0x46f0e3][_0xdf3c('0x40')]){this[_0xdf3c('0x41')](_0x5386bf[_0x46f0e3]);if(_0x5386bf[_0x46f0e3][_0xdf3c('0x42')])this[_0xdf3c('0x43')](_0x5386bf[_0x46f0e3]);}else{notSendMessagesQueue(_0x5386bf[_0x46f0e3]);}}}};Preview['prototype'][_0xdf3c('0x44')]=function(_0x3e7a4b){var _0x5ddd21=this;this['sequence'][_0xdf3c('0x45')](function(){if(!_['isNil'](_0x5ddd21[_0xdf3c('0x15')][_0x3e7a4b])){loggerAction['info']('[clearZombieChannels][talking]',_0x3e7a4b,'Queue',_0x5ddd21[_0xdf3c('0x15')][_0x3e7a4b][_0xdf3c('0x46')],_0xdf3c('0x47'),JSON[_0xdf3c('0x2c')](_0x5ddd21['campaignsPreview'][_0x5ddd21['actions'][_0x3e7a4b][_0xdf3c('0x46')]]['originated']),_0xdf3c('0x48'),JSON[_0xdf3c('0x2c')](_0x5ddd21[_0xdf3c('0x13')][_0x5ddd21[_0xdf3c('0x15')][_0x3e7a4b][_0xdf3c('0x46')]][_0xdf3c('0x33')]),JSON[_0xdf3c('0x2c')](_0x5ddd21[_0xdf3c('0x15')][_0x3e7a4b][_0xdf3c('0x49')]),JSON['stringify'](_[_0xdf3c('0x4a')](_0x5ddd21['actions'][_0x3e7a4b],['contactId',_0xdf3c('0x4b'),'VoiceQueueId',_0xdf3c('0x4c')])));return ami['Action']({'action':_0xdf3c('0x4d'),'channel':_0x5ddd21[_0xdf3c('0x15')][_0x3e7a4b][_0xdf3c('0x4e')]})[_0xdf3c('0x4f')](function(_0x3098cb){if(_0x3098cb[_0xdf3c('0x36')]===_0xdf3c('0x50')){setTimeout(function(){if(_0x5ddd21[_0xdf3c('0x15')][_0x3e7a4b]){ut[_0xdf3c('0x51')](_0x5ddd21[_0xdf3c('0x13')][_0x5ddd21[_0xdf3c('0x15')][_0x3e7a4b][_0xdf3c('0x46')]],'[clearZombieChannel]');if(_0x5ddd21['actions'][_0x3e7a4b][_0xdf3c('0x49')]===!![]){ut['decrementTalkink'](_0x5ddd21[_0xdf3c('0x13')][_0x5ddd21[_0xdf3c('0x15')][_0x3e7a4b][_0xdf3c('0x46')]],_0xdf3c('0x52'));ut['loggerError']('[Dialer][checkChannel][pTalking][Preview]'+_0x3e7a4b,_0x5ddd21[_0xdf3c('0x15')][_0x3e7a4b][_0xdf3c('0x46')]);}ut[_0xdf3c('0x53')]('[Dialer][checkChannel][Preview]'+_0x3e7a4b,_0x5ddd21[_0xdf3c('0x15')][_0x3e7a4b][_0xdf3c('0x46')]);delete _0x5ddd21[_0xdf3c('0x15')][_0x3e7a4b];}},0x2328);}});}});};Preview[_0xdf3c('0xf')]['clearZombieChannels']=function(){var _0x127685=this;loggerAction[_0xdf3c('0x2a')](_0xdf3c('0x54'),_[_0xdf3c('0x55')](this[_0xdf3c('0x15')]));for(var _0x55849e in this[_0xdf3c('0x15')]){if(_0x127685[_0xdf3c('0x15')][_0xdf3c('0x3c')](_0x55849e)){_0x127685[_0xdf3c('0x44')](_0x55849e);}}};Preview[_0xdf3c('0xf')][_0xdf3c('0x43')]=function(_0x555389){var _0x4d6349=this;rpcDb[_0xdf3c('0x56')](_0x555389['id'],ut[_0xdf3c('0x57')](this['agents']))['then'](function(_0x269723){if(!_[_0xdf3c('0x58')](_0x269723)){for(var _0x46b2bd=0x0;_0x46b2bd<_0x269723[_0xdf3c('0x59')];_0x46b2bd+=0x1){if(ut[_0xdf3c('0x5a')](_0x269723[_0x46b2bd][_0xdf3c('0x5b')])<_0x555389[_0xdf3c('0x5c')]*0x3c){if(_0x269723[_0x46b2bd][_0xdf3c('0x5d')]&&!_0x269723[_0x46b2bd][_0xdf3c('0x5d')]['voicePause']){_0x4d6349[_0xdf3c('0x5e')](_0x269723[_0x46b2bd]['id'])[_0xdf3c('0x5f')](ut[_0xdf3c('0x60')](_0xdf3c('0x61')))[_0xdf3c('0x4f')](ut[_0xdf3c('0x60')](_0xdf3c('0x61')));}else{rpcDb['disableContact'](_0x269723[_0x46b2bd]['id']);}}else{var _0x1751a8=new Action(_0x269723[_0x46b2bd],_0x555389);_0x1751a8['starttime']=moment()[_0xdf3c('0x2d')]('YYYY-MM-DD\x20HH:mm:ss');_0x555389[_0xdf3c('0x62')]+=0x1;ut[_0xdf3c('0x63')](_0x1751a8,0x17,_0xdf3c('0x64'));if(_0x555389[_0xdf3c('0x65')]){rpcDb['rescheduleContactInQueue'](ut['createBody'](_0x269723[_0x46b2bd]));rpcDb['createCustomerHistory'](_0x1751a8,_0xdf3c('0x66'));}else{ut['logCustomer'](_0x1751a8,0x16,_0xdf3c('0x67'));rpcDb[_0xdf3c('0x68')](_0x1751a8,_0xdf3c('0x69'));rpcDb[_0xdf3c('0x6a')](_0x1751a8,_0xdf3c('0x69'));}}}}})['catch'](ut['logger2'](_0xdf3c('0x6b')));};Preview[_0xdf3c('0xf')]['setMessage']=function(_0x3b215d){_0x3b215d[_0xdf3c('0x31')]=!![];if(ut[_0xdf3c('0x6c')](_0x3b215d[_0xdf3c('0x6d')])){_0x3b215d[_0xdf3c('0x36')]=utils[_0xdf3c('0x6e')][_0xdf3c('0x6f')];}else if(!ut['isActive'](_0x3b215d['dialActive'])){_0x3b215d[_0xdf3c('0x36')]=utils[_0xdf3c('0x6e')][_0xdf3c('0x37')];}else if(!this[_0xdf3c('0x70')](_0x3b215d[_0xdf3c('0x71')])){if(!this[_0xdf3c('0x70')](_0x3b215d[_0xdf3c('0x72')])){_0x3b215d[_0xdf3c('0x36')]=utils[_0xdf3c('0x6e')][_0xdf3c('0x73')];}else{_0x3b215d[_0xdf3c('0x36')]=utils['CAMPAIGN_STATUS'][_0xdf3c('0x74')];}}else{_0x3b215d['message']=utils['CAMPAIGN_STATUS']['ACTIVE'];}};Preview['prototype']['callProgressDetectingCustomer']=function(_0x1afc6c,_0x1c18a9,_0x5c53cd){var _0x4257c4=this;var _0x32427e=this['actions'][_0x1c18a9];var _0xa8dddb=this[_0xdf3c('0x13')][_0x32427e[_0xdf3c('0x46')]];var _0x1389e0;var _0x396461=![];var _0x28f387=0x2;var _0xb54629=0x3;if(_0xa8dddb){switch(_0x5c53cd){case'1':_0xa8dddb[_0xdf3c('0x75')]+=0x1;_0x32427e[_0xdf3c('0x76')]+=0x1;_0x32427e[_0xdf3c('0x77')]=ut[_0xdf3c('0x78')](_0x32427e);ut['logCustomer'](_0x32427e,0x0,_0xdf3c('0x79'));ami[_0xdf3c('0x29')](_0xdf3c('0x7a'),ut['buildObj'](_0x32427e,_0xdf3c('0x7b')));rpcDb[_0xdf3c('0x68')](_0x32427e,_0xdf3c('0x7c'));_0x4257c4['verifyAdditionalPhones'](_0x32427e,'0',_0xa8dddb)[_0xdf3c('0x5f')](function(_0x13bf69){_0x396461=_0x13bf69['additional']==0x1;_0x28f387=_0xa8dddb[_0xdf3c('0x7d')];_0xb54629=_0xa8dddb['callAdditionalPhoneAfterMin'];if(!_0x396461){if(ut[_0xdf3c('0x78')](_0x32427e)>=_0xa8dddb[_0xdf3c('0x7e')]){_0x1389e0=ut[_0xdf3c('0x7f')](_0x32427e,0xf,_0xdf3c('0x80'));rpcDb[_0xdf3c('0x6a')](_0x1389e0,_0xdf3c('0x81'));}else{if(_0x32427e[_0xdf3c('0x76')]>=_0xa8dddb[_0xdf3c('0x82')]){rpcDb[_0xdf3c('0x6a')](_0x32427e,_0xdf3c('0x81'));}else{rpcDb[_0xdf3c('0x83')](ut[_0xdf3c('0x84')](_0x32427e,_0xdf3c('0x76'),_0xa8dddb[_0xdf3c('0x7d')]),_0x32427e[_0xdf3c('0x85')],_0x32427e[_0xdf3c('0x86')]);}}delete this[_0xdf3c('0x15')][_0x1afc6c['linkedid']];}else{_0x32427e['countnosuchnumberretry']++;logger[_0xdf3c('0x2a')](_0xdf3c('0x87'),_0x32427e[_0xdf3c('0x76')]);logger['info']('id',_0x32427e[_0xdf3c('0x88')]);_0x4257c4['incrementPreviewCounters']({'id':_0x32427e['idContact'],'field':{'countnosuchnumberretry':_0x32427e[_0xdf3c('0x76')]}})[_0xdf3c('0x5f')](function(){_0x4257c4[_0xdf3c('0x89')](_0x32427e,_0x28f387,_0xb54629)[_0xdf3c('0x5f')](function(){});});}});break;case _0xdf3c('0x8a'):var _0x9b7034=moment()[_0xdf3c('0x2d')](_0xdf3c('0x8b'));_0x32427e[_0xdf3c('0x8c')]=_0x9b7034;_0x32427e[_0xdf3c('0x8d')]=_0x9b7034;_0x32427e[_0xdf3c('0x49')]=!![];_0xa8dddb[_0xdf3c('0x33')]+=0x1;logger[_0xdf3c('0x2a')]('[syncHangup][talking][increment]',_0x32427e[_0xdf3c('0x8e')],_0xdf3c('0x8f'),_0xa8dddb[_0xdf3c('0x2f')],_0xdf3c('0x48'),_0xa8dddb[_0xdf3c('0x33')]);ami['emit'](_0xdf3c('0x90'),ut[_0xdf3c('0x91')](_0x32427e,_0xdf3c('0x92'),this[_0xdf3c('0x13')][_0x32427e[_0xdf3c('0x46')]]));if(_0xa8dddb[_0xdf3c('0x93')]){ami[_0xdf3c('0x29')](_0xdf3c('0x94'),ut[_0xdf3c('0x95')](_0x32427e));}break;case'16':ami[_0xdf3c('0x29')]('custom:agentcomplete',ut[_0xdf3c('0x91')](_0x32427e,_0xdf3c('0x96'),this[_0xdf3c('0x13')][_0x32427e[_0xdf3c('0x46')]]));emitVoiceQueueChannelRemove(ut[_0xdf3c('0x91')](_0x32427e,_0xdf3c('0x96')));_0xa8dddb[_0xdf3c('0x97')]+=0x1;_0xa8dddb['total']+=0x1;_0xa8dddb[_0xdf3c('0x98')]+=0x1;ut[_0xdf3c('0x99')](_0xa8dddb,'[16]');_0x32427e['countglobal']=ut[_0xdf3c('0x78')](_0x32427e);ut[_0xdf3c('0x63')](_0x32427e,0x4,_0xdf3c('0x9a'));rpcDb[_0xdf3c('0x68')](_0x32427e,_0xdf3c('0x9b'));rpcDb[_0xdf3c('0x6a')](_0x32427e,_0xdf3c('0x9c'));rpcDb[_0xdf3c('0x9d')](_0x32427e);_0xa8dddb['sumDuration']+=_0x32427e[_0xdf3c('0x9e')];_0xa8dddb[_0xdf3c('0x9f')]+=_0x32427e[_0xdf3c('0x9e')];logger['info'](_0xdf3c('0xa0'),_0x32427e[_0xdf3c('0x8e')],_0xdf3c('0x8f'),_0xa8dddb['name'],_0xdf3c('0x48'),_0xa8dddb[_0xdf3c('0x33')]);delete this[_0xdf3c('0x15')][_0x1afc6c[_0xdf3c('0xa1')]];break;case _0xdf3c('0xa2'):_0xa8dddb[_0xdf3c('0xa3')]+=0x1;_0x32427e['countbusyretry']+=0x1;_0x32427e['countglobal']=ut['totalGlobal'](_0x32427e);ut['logCustomer'](_0x32427e,0x5,'Busy');_0x28f387=_0xa8dddb[_0xdf3c('0xa4')];_0xb54629=_0xa8dddb[_0xdf3c('0xa5')];ami[_0xdf3c('0x29')]('custom:agentbusy',ut[_0xdf3c('0x91')](_0x32427e,_0xdf3c('0xa6')));rpcDb[_0xdf3c('0x68')](_0x32427e,'[callProgressDetectingCustomer][logBusy]');_0x4257c4['verifyAdditionalPhones'](_0x32427e,'5',_0xa8dddb)[_0xdf3c('0x5f')](function(_0x4e3517){_0x396461=_0x4e3517[_0xdf3c('0xa7')]==0x1;if(!_0x396461){if(ut['totalGlobal'](_0x32427e)>=_0xa8dddb[_0xdf3c('0x7e')]){_0x1389e0=ut[_0xdf3c('0x7f')](_0x32427e,0xf,_0xdf3c('0x80'));rpcDb[_0xdf3c('0x6a')](_0x1389e0,'[callProgressDetectingCustomer][logBusyGlobal]');}else{if(_0x32427e['countbusyretry']>=_0xa8dddb[_0xdf3c('0xa8')]){rpcDb[_0xdf3c('0x6a')](_0x32427e,_0xdf3c('0xa9'));}else{rpcDb[_0xdf3c('0x83')](ut[_0xdf3c('0x84')](_0x32427e,_0xdf3c('0xaa'),_0xa8dddb['dialBusyRetryFrequency']),_0x32427e[_0xdf3c('0x85')],_0x32427e['activeContact']);}}}else{_0x32427e[_0xdf3c('0xaa')]++;_0x4257c4[_0xdf3c('0xab')]({'id':_0x32427e[_0xdf3c('0x88')],'field':{'countbusyretry':_0x32427e[_0xdf3c('0xaa')]}})[_0xdf3c('0x5f')](function(){_0x4257c4['swapAdditionalPhones'](_0x32427e,_0x28f387,_0xb54629)[_0xdf3c('0x5f')](function(){});});}});break;case _0xdf3c('0xac'):_0xa8dddb[_0xdf3c('0xad')]+=0x1;_0x32427e['countnoanswerretry']+=0x1;_0x32427e['countglobal']=ut['totalGlobal'](_0x32427e);ut['logCustomer'](_0x32427e,0x3,_0xdf3c('0xae'));_0x28f387=_0xa8dddb[_0xdf3c('0xaf')];_0xb54629=_0xa8dddb[_0xdf3c('0xa5')];var _0x391042=ut[_0xdf3c('0xb0')](_0x32427e,_0xa8dddb);ami[_0xdf3c('0x29')]('custom:agentnoanswer',_0x391042);rpcDb[_0xdf3c('0x68')](_0x32427e,'[callProgressDetectingCustomer][logNoAnswer]');_0x4257c4[_0xdf3c('0xb1')](_0x32427e,'3',_0xa8dddb)[_0xdf3c('0x5f')](function(_0x2e5f82){_0x396461=_0x2e5f82[_0xdf3c('0xa7')]==0x1;if(!_0x396461){if(ut[_0xdf3c('0x78')](_0x32427e)>=_0xa8dddb[_0xdf3c('0x7e')]){_0x1389e0=ut[_0xdf3c('0x7f')](_0x32427e,0xf,_0xdf3c('0x80'));rpcDb[_0xdf3c('0x6a')](_0x1389e0,_0xdf3c('0xb2'));}else{if(_0x32427e[_0xdf3c('0xb3')]>=_0xa8dddb[_0xdf3c('0xb4')]){rpcDb[_0xdf3c('0x6a')](_0x32427e,_0xdf3c('0xb5'));}else{rpcDb['rescheduleContact'](ut[_0xdf3c('0x84')](_0x32427e,_0xdf3c('0xb3'),_0xa8dddb[_0xdf3c('0xaf')]),_0x32427e[_0xdf3c('0x85')],_0x32427e['activeContact']);}}}else{_0x32427e[_0xdf3c('0xb3')]++;_0x4257c4[_0xdf3c('0xab')]({'id':_0x32427e['idContact'],'field':{'countnoanswerretry':_0x32427e['countnoanswerretry']}})[_0xdf3c('0x5f')](function(){_0x4257c4[_0xdf3c('0x89')](_0x32427e,_0x28f387,_0xb54629)[_0xdf3c('0x5f')](function(){});});}});break;case _0xdf3c('0xb6'):_0xa8dddb[_0xdf3c('0xb7')]+=0x1;_0x32427e['countcongestionretry']+=0x1;_0x32427e[_0xdf3c('0x77')]=ut[_0xdf3c('0x78')](_0x32427e);ut[_0xdf3c('0x63')](_0x32427e,0x8,_0xdf3c('0xb8'));_0x28f387=_0xa8dddb[_0xdf3c('0xb9')];_0xb54629=_0xa8dddb[_0xdf3c('0xa5')];ami['emit'](_0xdf3c('0xba'),ut[_0xdf3c('0x91')](_0x32427e,_0xdf3c('0xbb')));rpcDb[_0xdf3c('0x68')](_0x32427e,_0xdf3c('0xbc'));_0x4257c4['verifyAdditionalPhones'](_0x32427e,'8',_0xa8dddb)['then'](function(_0x5c99f2){_0x396461=_0x5c99f2[_0xdf3c('0xa7')]==0x1;if(!_0x396461){if(ut[_0xdf3c('0x78')](_0x32427e)>=_0xa8dddb[_0xdf3c('0x7e')]){_0x1389e0=ut[_0xdf3c('0x7f')](_0x32427e,0xf,_0xdf3c('0x80'));rpcDb[_0xdf3c('0x6a')](_0x1389e0,_0xdf3c('0xbd'));}else{if(_0x32427e[_0xdf3c('0xbe')]>=_0xa8dddb['dialCongestionMaxRetry']){rpcDb[_0xdf3c('0x6a')](_0x32427e,_0xdf3c('0xbc'));}else{rpcDb[_0xdf3c('0x83')](ut[_0xdf3c('0x84')](_0x32427e,_0xdf3c('0xbe'),_0xa8dddb[_0xdf3c('0xa4')]),_0x32427e['unlockAgent'],_0x32427e[_0xdf3c('0x86')]);}}}else{_0x32427e[_0xdf3c('0xbe')]++;_0x4257c4['incrementPreviewCounters']({'id':_0x32427e['idContact'],'field':{'countcongestionretry':_0x32427e[_0xdf3c('0xbe')]}})['then'](function(){_0x4257c4[_0xdf3c('0x89')](_0x32427e,_0x28f387,_0xb54629)[_0xdf3c('0x5f')](function(){});});}});break;case'CANCEL':_0xa8dddb[_0xdf3c('0xbf')]+=0x1;_0x32427e[_0xdf3c('0xc0')]+=0x1;_0x32427e[_0xdf3c('0x77')]=ut[_0xdf3c('0x78')](_0x32427e);ut[_0xdf3c('0x63')](_0x32427e,0x14,_0xdf3c('0xc1'));_0x28f387=_0xa8dddb['dialAgentRejectRetryFrequency'];_0xb54629=_0xa8dddb[_0xdf3c('0xa5')];ami[_0xdf3c('0x29')](_0xdf3c('0xc2'),ut[_0xdf3c('0x91')](_0x32427e,_0xdf3c('0xc3')));rpcDb[_0xdf3c('0x68')](_0x32427e,_0xdf3c('0xc4'));_0x4257c4['verifyAdditionalPhones'](_0x32427e,'20',_0xa8dddb)['then'](function(_0x1745fd){_0x396461=_0x1745fd[_0xdf3c('0xa7')]==0x1;if(!_0x396461){if(ut[_0xdf3c('0x78')](_0x32427e)>=_0xa8dddb['dialGlobalMaxRetry']){_0x1389e0=ut[_0xdf3c('0x7f')](_0x32427e,0x14,'AgentReject');rpcDb['createCustomerFinal'](_0x1389e0,_0xdf3c('0xc5'));}else{if(_0x32427e[_0xdf3c('0xc0')]>=_0xa8dddb['dialAgentRejectMaxRetry']){rpcDb[_0xdf3c('0x6a')](_0x32427e,'[callProgressDetectingCustomer][logAgentReject]');}else{rpcDb[_0xdf3c('0x83')](ut['scheduledAt'](_0x32427e,_0xdf3c('0xc0'),_0xa8dddb[_0xdf3c('0xc6')]),_0x32427e[_0xdf3c('0x85')],_0x32427e[_0xdf3c('0x86')]);}}}else{_0x32427e[_0xdf3c('0xb3')]++;_0x4257c4[_0xdf3c('0xab')]({'id':_0x32427e[_0xdf3c('0x88')],'field':{'countnoanswerretry':_0x32427e[_0xdf3c('0xb3')]}})[_0xdf3c('0x5f')](function(){_0x4257c4[_0xdf3c('0x89')](_0x32427e,_0x28f387,_0xb54629)[_0xdf3c('0x5f')](function(){});});}});break;case _0xdf3c('0xc7'):_0xa8dddb[_0xdf3c('0xc8')]+=0x1;_0x32427e[_0xdf3c('0xc9')]+=0x1;_0x32427e['countglobal']=ut[_0xdf3c('0x78')](_0x32427e);ut[_0xdf3c('0x63')](_0x32427e,0xb,_0xdf3c('0xca'));rpcDb['createCustomerHistory'](_0x32427e,_0xdf3c('0xcb'));_0x4257c4[_0xdf3c('0xb1')](_0x32427e,'11',_0xa8dddb)[_0xdf3c('0x5f')](function(_0x6e1899){_0x396461=_0x6e1899[_0xdf3c('0xa7')]==0x1;if(!_0x396461){if(ut[_0xdf3c('0x78')](_0x32427e)>=_0xa8dddb[_0xdf3c('0x7e')]){_0x1389e0=ut[_0xdf3c('0x7f')](_0x32427e,0xf,_0xdf3c('0x80'));rpcDb[_0xdf3c('0x6a')](_0x1389e0,_0xdf3c('0xcb'));}else{if(_0x32427e['countabandonedetry']>=_0xa8dddb[_0xdf3c('0xcc')]){rpcDb[_0xdf3c('0x6a')](_0x32427e,_0xdf3c('0xcb'));}else{rpcDb[_0xdf3c('0x83')](ut[_0xdf3c('0x84')](_0x32427e,_0xdf3c('0xc9'),_0xa8dddb[_0xdf3c('0xcd')]),_0x32427e[_0xdf3c('0x85')],_0x32427e[_0xdf3c('0x86')]);}}}else{_0x32427e[_0xdf3c('0xb3')]++;_0x4257c4[_0xdf3c('0xab')]({'id':_0x32427e[_0xdf3c('0x88')],'field':{'countnoanswerretry':_0x32427e['countnoanswerretry']}})[_0xdf3c('0x5f')](function(){_0x4257c4[_0xdf3c('0x89')](_0x32427e,_0x28f387,_0xb54629)[_0xdf3c('0x5f')](function(){});});}});break;case'18':_0xa8dddb[_0xdf3c('0xce')]+=0x1;_0x32427e[_0xdf3c('0xcf')]+=0x1;_0x32427e[_0xdf3c('0x77')]=ut[_0xdf3c('0x78')](_0x32427e);ut['logCustomer'](_0x32427e,0x12,_0x1afc6c[_0xdf3c('0xd0')]||_0x1afc6c[_0xdf3c('0xd1')]);ami[_0xdf3c('0x29')](_0xdf3c('0xd2'),ut['buildObj'](_0x32427e,_0xdf3c('0xd3')));rpcDb[_0xdf3c('0x68')](_0x32427e,'[callProgressDetectingCustomer][hangupInAMD]');_0x4257c4[_0xdf3c('0xb1')](_0x32427e,'18',_0xa8dddb)['then'](function(_0x418021){_0x396461=_0x418021[_0xdf3c('0xa7')]==0x1;if(!_0x396461){if(ut['totalGlobal'](_0x32427e)>=_0xa8dddb[_0xdf3c('0x7e')]){_0x1389e0=ut[_0xdf3c('0x7f')](_0x32427e,0x12,_0xdf3c('0x80'));rpcDb['createCustomerFinal'](_0x1389e0,'[callProgressDetectingCustomer][hangupInAMD]');}else{rpcDb[_0xdf3c('0x6a')](_0x32427e,'[callProgressDetectingCustomer][hangupInAMD]');}}else{_0x32427e[_0xdf3c('0xb3')]++;_0x4257c4[_0xdf3c('0xab')]({'id':_0x32427e[_0xdf3c('0x88')],'field':{'countnoanswerretry':_0x32427e[_0xdf3c('0xb3')]}})['then'](function(){_0x4257c4[_0xdf3c('0x89')](_0x32427e,_0x28f387,_0xb54629)[_0xdf3c('0x5f')](function(){});});}});delete this['actions'][_0x1afc6c[_0xdf3c('0xa1')]];break;case'19':_0xa8dddb['outboundUnknownCallsDay']+=0x1;_0x32427e[_0xdf3c('0x77')]=ut[_0xdf3c('0x78')](_0x32427e);ut['logCustomer'](_0x32427e,0x13,_0x1afc6c['cause-txt']||_0x1afc6c[_0xdf3c('0xd1')]);ami['emit'](_0xdf3c('0xd2'),ut[_0xdf3c('0x91')](_0x32427e,_0xdf3c('0xd3')));rpcDb[_0xdf3c('0x68')](_0x32427e,_0xdf3c('0xd4'));_0x4257c4[_0xdf3c('0xb1')](_0x32427e,'18',_0xa8dddb)[_0xdf3c('0x5f')](function(_0x1d95d9){_0x396461=_0x1d95d9[_0xdf3c('0xa7')]==0x1;if(!_0x396461){if(ut[_0xdf3c('0x78')](_0x32427e)>=_0xa8dddb[_0xdf3c('0x7e')]){_0x1389e0=ut['cloneAction'](_0x32427e,0xf,_0xdf3c('0x80'));rpcDb[_0xdf3c('0x6a')](_0x1389e0,'[callProgressDetectingCustomer][machine]');}else{rpcDb[_0xdf3c('0x6a')](_0x32427e,_0xdf3c('0xd4'));}}else{_0x32427e[_0xdf3c('0xb3')]++;_0x4257c4[_0xdf3c('0xab')]({'id':_0x32427e[_0xdf3c('0x88')],'field':{'countnoanswerretry':_0x32427e[_0xdf3c('0xb3')]}})['then'](function(){_0x4257c4[_0xdf3c('0x89')](_0x32427e,_0x28f387,_0xb54629)['then'](function(){});});}});delete this[_0xdf3c('0x15')][_0x1afc6c[_0xdf3c('0xa1')]];break;default:if(_0x32427e[_0xdf3c('0x49')]){ut[_0xdf3c('0x99')](_0xa8dddb,_0xdf3c('0xd5'));ut[_0xdf3c('0x53')]('[Dialer][decrementTalkink][no\x20Hangup][Preview]'+_0xa8dddb[_0xdf3c('0x2f')],_0x1afc6c);}_0xa8dddb[_0xdf3c('0xce')]+=0x1;_0x32427e['countglobal']=ut[_0xdf3c('0x78')](_0x32427e);ut[_0xdf3c('0x63')](_0x32427e,0xc,_0x1afc6c[_0xdf3c('0xd0')]||_0x1afc6c[_0xdf3c('0xd1')]);_0x28f387=_0xa8dddb[_0xdf3c('0xc6')];_0xb54629=_0xa8dddb[_0xdf3c('0xa5')];rpcDb[_0xdf3c('0x68')](_0x32427e,_0xdf3c('0xd6'));_0x4257c4['verifyAdditionalPhones'](_0x32427e,'20',_0xa8dddb)['then'](function(_0x44dc52){_0x396461=_0x44dc52[_0xdf3c('0xa7')]==0x1;if(!_0x396461){if(ut[_0xdf3c('0x78')](_0x32427e)>=_0xa8dddb[_0xdf3c('0x7e')]){_0x1389e0=ut['cloneAction'](_0x32427e,0xf,'Global');rpcDb[_0xdf3c('0x6a')](_0x1389e0,'[callProgressDetectingCustomer][logUnknownGlobal]');}else{rpcDb[_0xdf3c('0x6a')](_0x32427e,'[callProgressDetectingCustomer][logUnknownGlobal]');}delete this[_0xdf3c('0x15')][_0x1afc6c[_0xdf3c('0xa1')]];}else{_0x4257c4[_0xdf3c('0x89')](_0x32427e,_0x28f387,_0xb54629)['then'](function(){});}});}if(!(_0x32427e[_0xdf3c('0x49')]&&_0x5c53cd==='16')){ut[_0xdf3c('0x51')](_0xa8dddb,'[callProgressDetectingCustomer]');logger['info'](_0xdf3c('0xd7'),_0x32427e[_0xdf3c('0x8e')],_0xdf3c('0x8f'),_0xa8dddb[_0xdf3c('0x2f')],_0xdf3c('0x47'),_0xa8dddb[_0xdf3c('0x32')]);}if(_0x5c53cd!==_0xdf3c('0x8a')){delete this['actions'][_0x1afc6c['linkedid']];delete this[_0xdf3c('0x15')][_0x1afc6c[_0xdf3c('0xd8')]];}_0xa8dddb[_0xdf3c('0xd9')]=!![];}};Preview[_0xdf3c('0xf')][_0xdf3c('0xda')]=function(_0x268aa9,_0xa10e73,_0x828c9c){if(_[_0xdf3c('0xdb')](_0xa10e73)&&_0xdf3c('0xdc')!==typeof _0xa10e73){return;}if(_[_0xdf3c('0xdb')](_0x828c9c)&&_0xdf3c('0xdc')!==typeof _0x828c9c){return;}switch(_0x828c9c[_0xdf3c('0xdd')]){case'0':ut[_0xdf3c('0xde')](_0x268aa9,0x0,_0xdf3c('0x79'));rpcDb[_0xdf3c('0xdf')](_0x268aa9,_0xdf3c('0xe0'));break;case'3':ut[_0xdf3c('0xde')](_0x268aa9,0x3,_0xdf3c('0xae'));rpcDb['createAgentHistory'](_0x268aa9,'[callProgressDetectingAgent][logNoAnswer]');break;case'5':ut[_0xdf3c('0xde')](_0x268aa9,0x5,'Busy');rpcDb['createAgentHistory'](_0x268aa9,_0xdf3c('0xe1'));break;case'8':ut['logAgent'](_0x268aa9,0x8,_0xdf3c('0xb8'));rpcDb[_0xdf3c('0xdf')](_0x268aa9,'[callProgressDetectingAgent][logCongestion]');break;case'22':ut['logAgent'](_0x268aa9,0x16,'AnswerAGI');rpcDb[_0xdf3c('0xdf')](_0x268aa9,_0xdf3c('0xe2'));break;default:ut[_0xdf3c('0xde')](_0x268aa9,0xc,_0x828c9c['reason']);rpcDb[_0xdf3c('0xdf')](_0x268aa9,'[callProgressDetectingAgent][logCongestion]');}ut[_0xdf3c('0x51')](_0xa10e73,'[callProgressDetectingAgent]');logger['info'](_0xdf3c('0xe3'),_0x268aa9[_0xdf3c('0x8e')],_0xdf3c('0x8f'),_0xa10e73[_0xdf3c('0x2f')],_0xdf3c('0x47'),_0xa10e73[_0xdf3c('0x32')]);delete this['actions'][_0x268aa9['uniqueid']];};Preview[_0xdf3c('0xf')]['verifyAdditionalPhones']=function(_0x1a5e31,_0x14244a,_0x18e639){return cmHopperAdditionalPhone[_0xdf3c('0xb1')](_0x1a5e31,_0x14244a,_0x18e639)[_0xdf3c('0x4f')](logger[_0xdf3c('0x2a')](_0xdf3c('0xe4')));};Preview['prototype']['swapAdditionalPhones']=function(_0x40fdd4,_0x1446af,_0x3fa455){return cmHopperAdditionalPhone[_0xdf3c('0x89')](_0x40fdd4,_0x1446af,_0x3fa455)['catch'](logger[_0xdf3c('0x2a')](_0xdf3c('0xe5')));};Preview[_0xdf3c('0xf')][_0xdf3c('0xab')]=function(_0x33ef58){return Promise[_0xdf3c('0xe6')]()['then'](cmHopperAdditionalPhone[_0xdf3c('0xab')](_0x33ef58))[_0xdf3c('0x4f')](logger['info'](_0xdf3c('0xe7')));};Preview[_0xdf3c('0xf')][_0xdf3c('0xe8')]=function(_0x511a40,_0x87ec92,_0x1ebfff,_0x3487cf,_0xb1c08d){var _0x3100fa=this;return new Promise(function(_0x147769,_0x3c91ba){if(_[_0xdf3c('0x58')](_0x87ec92)||_[_0xdf3c('0x58')](_0x87ec92['Contact'])||_[_0xdf3c('0x58')](_0x87ec92['phone'])||_[_0xdf3c('0x58')](_0x87ec92[_0xdf3c('0xe9')])){_0x3c91ba(ut[_0xdf3c('0x36')](_0xdf3c('0xea'),_0x3487cf,_0xb1c08d));return;}var _0x90c66=uuid['v4']();var _0x34344b=_0x3100fa[_0xdf3c('0x13')][_0x87ec92[_0xdf3c('0xeb')][_0xdf3c('0x2f')]];var _0x36a8c7=_0x1ebfff?_0x3100fa[_0xdf3c('0x16')][_0x1ebfff]['id']:undefined;_0x3100fa['actions'][_0x90c66]=new Action(_0x87ec92,_0x34344b,_0x90c66,_0x1ebfff,_0x36a8c7);var _0x379996=_0x3100fa[_0xdf3c('0x15')][_0x90c66];_0x379996['unlockAgent']=_0x3487cf;_0x379996[_0xdf3c('0x86')]=_0xb1c08d;_0x379996[_0xdf3c('0xec')]=_0x1ebfff;if(_[_0xdf3c('0xed')](_0x511a40)){_0x3100fa[_0xdf3c('0xee')](_0x379996,_0x34344b,_0x87ec92,_0x1ebfff)['then'](function(_0x2670ef){logger[_0xdf3c('0x2a')](_0xdf3c('0xef'),'Queue:\x20'+_0x379996['queue']+'\x20IdHopper:\x20'+_0x379996[_0xdf3c('0x88')],JSON[_0xdf3c('0x2c')](_0x2670ef));ami[_0xdf3c('0x29')](_0xdf3c('0xf0'),ut[_0xdf3c('0x91')](_0x379996,_0xdf3c('0xf1'),_0x3100fa[_0xdf3c('0x13')][_0x379996[_0xdf3c('0x46')]]));_0x147769(ut['message'](_0xdf3c('0xf2')));})['catch'](function(_0x359366){ut[_0xdf3c('0x38')](_0xdf3c('0xf3'),_0x359366);_0x3c91ba(ut[_0xdf3c('0x36')](_0xdf3c('0xf4'),_0x3487cf,_0xb1c08d));});}else{_0x34344b[_0xdf3c('0xf5')]+=0x1;ut['logBlacklist'](_0x379996);rpcDb[_0xdf3c('0xf6')](_0x379996,_0xdf3c('0xf7'));delete _0x3100fa['actions'][_0x90c66];_0x3c91ba(ut[_0xdf3c('0x36')](_0xdf3c('0xf8'),_0x3487cf,_0xb1c08d));}});};Preview[_0xdf3c('0xf')][_0xdf3c('0x70')]=function(_0x4e66a3){return!_[_0xdf3c('0x58')](_0x4e66a3)&&!_['isNil'](_0x4e66a3[_0xdf3c('0x2f')])&&!_[_0xdf3c('0x58')](_0x4e66a3[_0xdf3c('0xf9')])&&_0x4e66a3[_0xdf3c('0xf9')]&&!_[_0xdf3c('0x58')](this[_0xdf3c('0x14')][util['format']('SIP/%s',_0x4e66a3['name'])])&&!_[_0xdf3c('0x58')](this[_0xdf3c('0x14')][util['format']('SIP/%s',_0x4e66a3[_0xdf3c('0x2f')])]['status'])&&(this['trunks'][util['format'](_0xdf3c('0xfa'),_0x4e66a3[_0xdf3c('0x2f')])][_0xdf3c('0x4d')]==='reachable'||this[_0xdf3c('0x14')][util['format'](_0xdf3c('0xfa'),_0x4e66a3[_0xdf3c('0x2f')])][_0xdf3c('0x4d')]===_0xdf3c('0xfb'));};Preview[_0xdf3c('0xf')][_0xdf3c('0x5e')]=function(_0xd5aa90,_0x2eef6f){return this[_0xdf3c('0xfc')](_0xd5aa90,_0x2eef6f)['then'](function(_0x17add4){return _[_0xdf3c('0x4a')](_0x17add4,['message']);})[_0xdf3c('0x4f')](function(_0x1e8646){if(_0x1e8646['unlock']){rpcDb[_0xdf3c('0xfd')](_0xd5aa90);}if(_0x1e8646['active']){rpcDb[_0xdf3c('0xfe')](_0xd5aa90);}throw _[_0xdf3c('0x4a')](_0x1e8646,[_0xdf3c('0x36')]);});};Preview[_0xdf3c('0xf')][_0xdf3c('0xfc')]=function(_0x1086a3,_0x232b34){var _0x41b5f4=this;var _0x171231,_0x2b27de;return rpcDb[_0xdf3c('0xff')](_0x1086a3)[_0xdf3c('0x5f')](function(_0x2a4dbf){if(!_[_0xdf3c('0x58')](_0x2a4dbf[0x0])){_0x2b27de=_0x2a4dbf[0x0][_0xdf3c('0x100')]?![]:!![];_0x171231=_0x2a4dbf[0x0][_0xdf3c('0x100')]?!![]:![];_0x171231=_0x232b34?!![]:_0x171231;}var _0x542a02=_0x41b5f4[_0xdf3c('0x101')](_0x2a4dbf);if(_0x542a02[_0xdf3c('0x102')]){rpcDb['checkIsBlackList'](_[_0xdf3c('0x4a')](_0x2a4dbf[0x0],[_0xdf3c('0xe9'),_0xdf3c('0x103')]))[_0xdf3c('0x5f')](function(_0x518290){_0x41b5f4[_0xdf3c('0xe8')](_0x518290,_0x2a4dbf[0x0],_0x232b34,_0x2b27de,_0x171231)[_0xdf3c('0x5f')](function(_0x5b25d7){return _0x5b25d7;})[_0xdf3c('0x4f')](function(_0x37b1a6){throw _0x37b1a6;});})['catch'](function(_0x59c8f9){ut[_0xdf3c('0x38')](_0xdf3c('0x104'),_0x59c8f9);throw ut[_0xdf3c('0x36')]('Call\x20unsuccessful',_0x2b27de,_0x171231);});}else{throw ut[_0xdf3c('0x36')](_0x542a02['message'],_0x2b27de,_0x171231);}})[_0xdf3c('0x4f')](function(_0x246958){ut[_0xdf3c('0x38')](_0xdf3c('0x105'),_0x246958);throw ut[_0xdf3c('0x36')](_0xdf3c('0x106'),![],!![]);});};Preview['prototype'][_0xdf3c('0x101')]=function(_0x47f9d1){if(_[_0xdf3c('0x58')](_0x47f9d1)||_[_0xdf3c('0xed')](_0x47f9d1)||!_[_0xdf3c('0x58')](_0x47f9d1[0x0]['Agent'])&&_[_0xdf3c('0x58')](_0x47f9d1[0x0]['Agent'][_0xdf3c('0x2f')])){ut[_0xdf3c('0x38')]('[Preview][validateContact][Empty\x20Contact]',_0x47f9d1);return{'isValid':![],'message':_0xdf3c('0x107')};}var _0x4185f0=this[_0xdf3c('0x13')][_0x47f9d1[0x0][_0xdf3c('0xeb')]['name']];_0x4185f0[_0xdf3c('0x36')]=utils[_0xdf3c('0x6e')][_0xdf3c('0x74')];if(_[_0xdf3c('0x58')](_0x4185f0)){ut[_0xdf3c('0x38')](_0xdf3c('0x108'),_0x4185f0);return{'isValid':![],'message':_0xdf3c('0x109')};}if(!this['isTrunkReachable'](_0x4185f0[_0xdf3c('0x71')])){ut[_0xdf3c('0x38')](_0xdf3c('0x10a'),_0xdf3c('0x10b')+_0x4185f0[_0xdf3c('0x2f')]+_0xdf3c('0x10c'));if(!this[_0xdf3c('0x70')](_0x4185f0[_0xdf3c('0x72')])){ut[_0xdf3c('0x38')](_0xdf3c('0x10a'),_0x4185f0[_0xdf3c('0x2f')]+'\x20Trunk\x20Backup\x20is\x20not\x20active');return{'isValid':![],'message':_0xdf3c('0x10d')};}}if(!ut[_0xdf3c('0x10e')](_0x4185f0[_0xdf3c('0x40')])){ut['logger'](_0xdf3c('0x10f'),_0x4185f0[_0xdf3c('0x2f')]+_0xdf3c('0x110'));return{'isValid':![],'message':_0xdf3c('0x10b')+_0x4185f0[_0xdf3c('0x2f')]+'\x20Not\x20Active'};}return{'isValid':!![],'message':_0xdf3c('0x111')};};Preview[_0xdf3c('0xf')]['execCall']=function(_0x2a0943,_0x3d4dc5,_0x38c6f3,_0xb39cc){var _0xcc2f18=this;return new Promise(function(_0x13ee9b,_0x8d7c0c){var _0x3d9041=_0x2a0943[_0xdf3c('0x8e')];var _0x4f8990=_0xcc2f18[_0xdf3c('0x70')](_0x3d4dc5[_0xdf3c('0x71')])?util['format'](_0xdf3c('0x112'),_0x3d4dc5[_0xdf3c('0x71')]['name'],_['isNil'](_0x3d4dc5[_0xdf3c('0x113')])?'':_0x3d4dc5[_0xdf3c('0x113')][_0xdf3c('0x114')]()||'',_0x3d4dc5[_0xdf3c('0x115')]>0x0?_0x38c6f3[_0xdf3c('0x103')][_0xdf3c('0x116')](_0x3d4dc5[_0xdf3c('0x115')]):_0x38c6f3[_0xdf3c('0x103')]):util['format'](_0xdf3c('0x112'),_[_0xdf3c('0x58')](_0x3d4dc5[_0xdf3c('0x72')])?_0x3d4dc5[_0xdf3c('0x71')]['name']:_0x3d4dc5[_0xdf3c('0x72')][_0xdf3c('0x2f')],_[_0xdf3c('0x58')](_0x3d4dc5[_0xdf3c('0x113')])?'':_0x3d4dc5['dialPrefix'][_0xdf3c('0x114')]()||'',_0x3d4dc5[_0xdf3c('0x115')]>0x0?_0x38c6f3[_0xdf3c('0x103')]['substring'](_0x3d4dc5['dialCutDigit']):_0x38c6f3[_0xdf3c('0x103')]);var _0xcaea00=_0xcc2f18[_0xdf3c('0x70')](_0x3d4dc5['Trunk'])?ut[_0xdf3c('0x117')](_0x3d4dc5[_0xdf3c('0x71')][_0xdf3c('0x118')],_0x3d4dc5[_0xdf3c('0x119')],_0x3d4dc5[_0xdf3c('0x11a')]>0x0?ut['getCallerIdRandom'](_0x3d4dc5['dialOriginateCallerIdNumber'],_0x3d4dc5[_0xdf3c('0x11a')]):_0x3d4dc5['dialOriginateCallerIdNumber']):ut[_0xdf3c('0x117')](_[_0xdf3c('0x58')](_0x3d4dc5[_0xdf3c('0x72')])?_0x3d4dc5[_0xdf3c('0x71')][_0xdf3c('0x118')]:_0x3d4dc5[_0xdf3c('0x72')]['callerid'],_0x3d4dc5[_0xdf3c('0x119')],_0x3d4dc5[_0xdf3c('0x11a')]>0x0?ut[_0xdf3c('0x11b')](_0x3d4dc5[_0xdf3c('0x11c')],_0x3d4dc5['dialRandomLastDigitCallerIdNumber']):_0x3d4dc5[_0xdf3c('0x11c')]);if(_0xcaea00){_0x2a0943[_0xdf3c('0x11d')]=ut[_0xdf3c('0x11e')](_0xcaea00);_0x2a0943['originatecalleridnum']=ut['extractCalleridNumber'](_0xcaea00);}var _0x1617d8=ut[_0xdf3c('0x11f')](_0x3d4dc5,_0x38c6f3,_0x4f8990,_0xcaea00,_0x3d9041,_0x2a0943);_['merge'](_0x2a0943,ut[_0xdf3c('0x120')](_0x1617d8));_0x2a0943['starttime']=moment()[_0xdf3c('0x2d')](_0xdf3c('0x8b'));_0x3d4dc5[_0xdf3c('0x121')]=_0x1617d8;var _0x1961cd=ut[_0xdf3c('0x122')](_0x2a0943,_0x3d4dc5,_0x1617d8,_0x2a0943[_0xdf3c('0x86')],_0xb39cc);return ami['Action'](_0x1961cd)[_0xdf3c('0x5f')](function(_0x2c24b7){_0x3d4dc5[_0xdf3c('0x32')]+=0x1;logger[_0xdf3c('0x2a')](_0xdf3c('0x123'),_0x3d9041,_0xdf3c('0x8f'),_0x3d4dc5[_0xdf3c('0x2f')],_0xdf3c('0x47'),_0x3d4dc5[_0xdf3c('0x32')]);_0x13ee9b(_0x2c24b7);})[_0xdf3c('0x4f')](function(_0x340107){ut['logAgent'](_0x2a0943,0xe,_0xdf3c('0x124'));rpcDb[_0xdf3c('0xdf')](_0x2a0943,'[originateFailure][logOriginateFailure]');_0x8d7c0c(_0x340107);});});};Preview[_0xdf3c('0xf')][_0xdf3c('0x125')]=function(_0x2accb4){if(this[_0xdf3c('0x15')][_0x2accb4[_0xdf3c('0xa1')]]){this['actions'][_0x2accb4[_0xdf3c('0xa1')]][_0xdf3c('0x4e')]=_0x2accb4[_0xdf3c('0x4e')];}};Preview[_0xdf3c('0xf')][_0xdf3c('0x19')]=function(_0x31391d){var _0x158c75=this;var _0x7554e2=this[_0xdf3c('0x15')][_0x31391d[_0xdf3c('0x126')]];if(_0x7554e2){if(_0x7554e2[_0xdf3c('0xec')]&&this[_0xdf3c('0x16')][_0x7554e2[_0xdf3c('0xec')]]){ut['logLookAgent'](_0x7554e2,this[_0xdf3c('0x16')][_0x7554e2[_0xdf3c('0xec')]]['name'],this[_0xdf3c('0x16')][_0x7554e2[_0xdf3c('0xec')]]['id']);}var _0x44388c=_[_0xdf3c('0x127')](_0x7554e2);_0x44388c[_0xdf3c('0x8c')]=moment()[_0xdf3c('0x2d')](_0xdf3c('0x8b'));var _0x15322a=_0x158c75[_0xdf3c('0x13')][_0x7554e2[_0xdf3c('0x46')]];if(ut['isFailure'](_0x31391d[_0xdf3c('0x128')])){if(_0x7554e2[_0xdf3c('0x85')]){rpcDb['unlockContact'](_0x7554e2[_0xdf3c('0x88')]);}if(_0x7554e2['activeContact']){rpcDb[_0xdf3c('0xfe')](_0x7554e2['idContact']);}ami[_0xdf3c('0x29')]('custom:agentringnoanswer',ut[_0xdf3c('0x91')](_0x7554e2,_0xdf3c('0x129'),this[_0xdf3c('0x13')][_0x7554e2[_0xdf3c('0x46')]]));this[_0xdf3c('0xda')](_0x44388c,_0x15322a,_0x31391d);}else{_0x7554e2[_0xdf3c('0x12a')]=moment()[_0xdf3c('0x2d')](_0xdf3c('0x8b'));ut['logAgent'](_0x44388c,0x4,_0xdf3c('0x9a'));rpcDb[_0xdf3c('0xdf')](_0x44388c,_0xdf3c('0x12b'));}}};Preview['prototype'][_0xdf3c('0x1b')]=function(_0x30b5c8){var _0x30e5ab=this[_0xdf3c('0x15')][_0x30b5c8['linkedid']];var _0x55a4fa;if(_0x30e5ab){_0x55a4fa=this['campaignsPreview'][_0x30e5ab['queue']];logger[_0xdf3c('0x2a')](_0xdf3c('0x12c'),_0x30b5c8[_0xdf3c('0xa1')],_0xdf3c('0x8f'),_0x55a4fa[_0xdf3c('0x2f')],_0xdf3c('0x48'),_0x55a4fa[_0xdf3c('0x33')]);}if(this['actions'][_0x30b5c8[_0xdf3c('0xa1')]]&&_0x30b5c8['linkedid']!==_0x30b5c8[_0xdf3c('0x8e')]){if(_0x30b5c8[_0xdf3c('0x12d')]==='16'&&this[_0xdf3c('0x15')][_0x30b5c8[_0xdf3c('0xa1')]][_0xdf3c('0x49')]){this[_0xdf3c('0x12e')](_0x30b5c8,_0x30b5c8[_0xdf3c('0xa1')],_0x30b5c8[_0xdf3c('0x12d')]);}else if(this['actions'][_0x30b5c8[_0xdf3c('0xa1')]][_0xdf3c('0x49')]){logger[_0xdf3c('0x2a')](_0xdf3c('0x12f'),_0x30b5c8[_0xdf3c('0xa1')],_0x30b5c8['cause'],'\x20Queue',_0x55a4fa[_0xdf3c('0x2f')],_0xdf3c('0x48'),_0x55a4fa[_0xdf3c('0x33')]);this[_0xdf3c('0x12e')](_0x30b5c8,_0x30b5c8[_0xdf3c('0xa1')],_0x30b5c8[_0xdf3c('0x12d')]);}}else if(_0x30e5ab&&_[_0xdf3c('0x58')](_0x30e5ab[_0xdf3c('0x130')])&&_0x55a4fa[_0xdf3c('0x131')]&&_0x30b5c8[_0xdf3c('0xa1')]===_0x30b5c8[_0xdf3c('0x8e')]&&_['isNil'](_0x30b5c8[_0xdf3c('0xdd')])&&_0x30b5c8[_0xdf3c('0x12d')]==='16'&&_0x30b5c8[_0xdf3c('0x132')]==='6'&&_[_0xdf3c('0xdb')](_0x30e5ab[_0xdf3c('0x133')])){if(_0x30e5ab[_0xdf3c('0x85')]){rpcDb[_0xdf3c('0xfd')](_0x30e5ab['idContact']);}if(_0x30e5ab[_0xdf3c('0x86')]){rpcDb['disableContact'](_0x30e5ab[_0xdf3c('0x88')]);}_0x30b5c8['reason']='22';this[_0xdf3c('0xda')](_0x30e5ab,_0x55a4fa,_0x30b5c8);}else if(_0x30e5ab&&_0x30e5ab[_0xdf3c('0x133')]){if(_0x30b5c8['cause']==='16'&&this['actions'][_0x30b5c8[_0xdf3c('0xa1')]][_0xdf3c('0x49')]){logger[_0xdf3c('0x2a')](_0xdf3c('0x134'),_0x30b5c8[_0xdf3c('0xa1')],_0x30b5c8['cause'],_0xdf3c('0x8f'),_0x55a4fa[_0xdf3c('0x2f')],_0xdf3c('0x48'),_0x55a4fa[_0xdf3c('0x33')]);this[_0xdf3c('0x12e')](_0x30b5c8,_0x30b5c8['linkedid'],_0x30b5c8[_0xdf3c('0x12d')]);}else if(this['actions'][_0x30b5c8[_0xdf3c('0xa1')]]['dialAnswer']){logger['info'](_0xdf3c('0x12f'),_0x30b5c8[_0xdf3c('0xa1')],_0x30b5c8[_0xdf3c('0x12d')],_0xdf3c('0x8f'),_0x55a4fa[_0xdf3c('0x2f')],'pTalking:\x20',_0x55a4fa[_0xdf3c('0x33')]);this[_0xdf3c('0x12e')](_0x30b5c8,_0x30b5c8['linkedid'],_0x30b5c8[_0xdf3c('0x12d')]);}}};Preview[_0xdf3c('0xf')][_0xdf3c('0x20')]=function(_0x386a3b){if(this[_0xdf3c('0x15')][_0x386a3b['destlinkedid']]&&_0x386a3b[_0xdf3c('0xd8')]!==_0x386a3b[_0xdf3c('0x135')]){this[_0xdf3c('0x12e')](_0x386a3b,_0x386a3b[_0xdf3c('0xd8')],_0x386a3b[_0xdf3c('0xd1')]);}};Preview['prototype'][_0xdf3c('0x1e')]=function(_0x43fc55){if(this[_0xdf3c('0x15')][_0x43fc55[_0xdf3c('0xa1')]]&&_0x43fc55[_0xdf3c('0xa1')]!==_0x43fc55[_0xdf3c('0x8e')]&&!this[_0xdf3c('0x15')][_0x43fc55[_0xdf3c('0xa1')]][_0xdf3c('0x49')]){if(_0x43fc55[_0xdf3c('0x12d')]==='1'){this[_0xdf3c('0x12e')](_0x43fc55,_0x43fc55[_0xdf3c('0xa1')],_0x43fc55[_0xdf3c('0x12d')]);}}};Preview[_0xdf3c('0xf')][_0xdf3c('0x136')]=function(_0x2be6c7,_0x18bbe0,_0x174e96){if(this['actions'][_0x2be6c7]){if(_[_0xdf3c('0x58')](this[_0xdf3c('0x15')][_0x2be6c7][_0xdf3c('0x121')])){this['actions'][_0x2be6c7][_0xdf3c('0x121')]={};}this['actions'][_0x2be6c7][_0xdf3c('0x121')][_0x18bbe0]=_0x174e96;}};Preview['prototype'][_0xdf3c('0x23')]=function(_0xd721b1){try{if(!_[_0xdf3c('0x58')](_0xd721b1)){if(ut[_0xdf3c('0x137')](_[_0xdf3c('0x138')](_0xd721b1[_0xdf3c('0x139')])[0x0])){this[_0xdf3c('0x136')](_0xd721b1[_0xdf3c('0x8e')],_[_0xdf3c('0x138')](_0xd721b1['variable'])[0x0],_0xd721b1[_0xdf3c('0x13a')]);}}}catch(_0x3e3d63){logger[_0xdf3c('0x13b')](_0xdf3c('0x13c'),util['inspect'](_0x3e3d63,{'showHidden':![],'depth':null}));}};Preview['prototype'][_0xdf3c('0x25')]=function(_0x2d412f){if(_0x2d412f){if(this[_0xdf3c('0x15')][_0x2d412f[_0xdf3c('0x13d')]]){this['actions'][_0x2d412f[_0xdf3c('0x13d')]]['transfer']=!![];}}};Preview['prototype'][_0xdf3c('0x27')]=function(_0x4255cd){if(_0x4255cd){if(this['actions'][_0x4255cd[_0xdf3c('0x13e')]]){this[_0xdf3c('0x15')][_0x4255cd['transfererlinkedid']][_0xdf3c('0x133')]=!![];}}};module[_0xdf3c('0x13f')]=Preview;