Built motion from commit 10af8726.|2.6.34
[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 _0x9267=['Answer','[callProgressDetectingCustomer][logAnswer]','talktime','sumBillable','[syncHangup][talking][decrement]','BUSY','outboundBusyCallsDay','countbusyretry','Busy','dialBusyRetryFrequency','[callProgressDetectingCustomer][logBusy]','verifyAdditionalPhones','additional','cloneAction','Global','[callProgressDetectingCustomer][logBusyGlobal]','dialBusyMaxRetry','outboundNoAnswerCallsDay','countnoanswerretry','NoAnswer','dialNoAnswerRetryFrequency','buildNoAnswerEventPayload','custom:agentnoanswer','dialNoAnswerMaxRetry','[callProgressDetectingCustomer][logNoAnswer]','rescheduleContact','CONGESTION','outboundCongestionCallsDay','countcongestionretry','Congestion','custom:agentcongestion','congestion','[callProgressDetectingCustomer][logCongestion]','[callProgressDetectingCustomer][logCongestionGlobal]','dialCongestionMaxRetry','CANCEL','outboundRejectCallsDay','custom:agentreject','agentreject','AgentReject','countagentrejectretry','dialAgentRejectMaxRetry','[callProgressDetectingCustomer][logAgentReject]','dialAgentRejectRetryFrequency','ABANDONED','outboundAbandonedCallsDay','countabandonedretry','[callProgressDetectingCustomer][logAbandoned]','countabandonedetry','dialAbandonedMaxRety','dialAbandonedRetryFrequency','outboundUnknownCallsDay','countmachineretry','cause-txt','dialstatus','custom:amd','amd','[callProgressDetectingCustomer][hangupInAMD]','[callProgressDetectingCustomer][machine]','[Dialer][decrementTalking][no\x20Hangup][Preview]','[callProgressDetectingCustomer][logUnknownGlobal]','[callProgressDetectingCustomer]','[originated][decrement][callProgressDetectingCustomer]','\x20Queue','originated:\x20','ANSWER','destlinkedid','callProgressDetectingAgent','isUndefined','object','reason','createAgentHistory','logAgent','[callProgressDetectingAgent][logNoAnswer]','[callProgressDetectingAgent][logBusy]','[callProgressDetectingAgent][logCongestion]','[callProgressDetectingAgent][logAnswerAGI]','[callProgressDetectingAgent]','[originated][decrement][callProgressDetectingAgent]','[verifyAdditionalPhone]\x20','resolve','checkInBlack','Contact','phone','Queue','lookAgent','isEmpty','execCall','\x20IdHopper:\x20','custom:agentcalled','called','Calling','[Preview][execCall][failure]','Call\x20failed','logBlacklist','Contact\x20in\x20black\x20List','active','SIP/%s','reachable','execRun','unlock','unlockContact','getContactPreview','recallme','validateContact','isValid','[Preview][checkIsBlackList]','Call\x20unsuccessful','[Preview][getContactPreview]','[Preview][validateContact][Empty\x20Contact]','Empty\x20Contact','[Preview][validateContact][Empty\x20Campaign]','Empty\x20Campaign','[Preview][validateContact][Trunk\x20not\x20working\x20correctly]','campaign\x20Name:\x20','\x20Trunk\x20is\x20not\x20active','\x20Trunk\x20Backup\x20is\x20not\x20active','Trunk\x20not\x20working\x20correctly','isActive','\x20Not\x20Active','Is\x20Valid','SIP/%s/%s%s','dialPrefix','trim','dialCutDigit','substring','dialOriginateCallerIdName','getCallerIdRandom','dialOriginateCallerIdNumber','dialRandomLastDigitCallerIdNumber','callerid','extractCalleridName','originatecalleridnum','extractCalleridNumber','setXMDContactVariables','assign','merge','toLowerVariables','variables','OriginateError','[originateFailure][logOriginateFailure]','syncNewExten','logLookAgent','isFailure','rejected','[callProgressDetectingAgent][logAnswer]','[syncHangup][talking]','cause','[syncHangup][talking][cause]','statedesc','transfer','[syncHangup][talking][transfer]','destuniqueid','filterKey','keys','variable','[syncVarSet][Preview]','inspect','transfererlinkedid','exports','util','uuid','moment','ioredis','../../../config/environment','../../../config/logger','preview','actionPreview','../ami','./rpcDb','../rpc/cmHopperAdditionalPhone','./action','./util/util','../dialer/utils','redis','defaults','localhost','socket.io-emitter','prototype','enqueue','tail','finally','campaignsPreview','voiceQueues','trunks','actions','agents','clockClearZombieChannels','originateresponse','bind','syncHangup','hanguprequest','syncHangupRequest','syncDialEnd','syncVarSet','attendedtransfer','syncAttendedTransfer','blindtransfer','syncBlindTransfer','loopCampaigns','emit','info','[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event','voice:queue:%s','name','voice_queue_channel:remove','originated','pTalking','available','paused','message','CAMPAIGN_STATUS','INACTIVE','logger','[CampaignPreview]\x20Campaign\x20Queue:\x20','\x20is\x20not\x20active','DEACTIVATED','\x20is\x20deactivated','syncCampaigns','dialMethod','booked','type','clearZombieChannels','outbound','setMessage','recallMe','clearZombieChannel','sequence','isNil','[clearZombieChannels][talking]','stringify','queue','pTalking:\x20','dialAnswer','pick','UserId','VoiceQueueId','ListId','status','channel','catch','No\x20such\x20channel','decrementOriginate','[clearZombieChannel]','loggerError','[Dialer][checkChannel][pTalking][Preview]','[Dialer][checkChannel][Preview]','[action]','hasOwnProperty','agentReadyId','length','getDiff','scheduledat','dialRecallMeTimeout','Agent','voicePause','run','then','logger2','[RecallMe]','disableContact','starttime','format','outboundReCallsDay','logCustomer','rescheduleContactInQueue','createCustomerHistory','[HistoryDialRecallInQueue][historyCatch]','[HistoryRecallClose]','createCustomerFinal','[getContactRecallMe]','IsNotLoggedIn','NO_AGENTS_LOGGED','dialActive','Trunk','isTrunkReachable','TrunkBackup','UNREACHABLE_TRUNK','ACTIVE','callProgressDetectingCustomer','outboundNoSuchCallsDay','countnosuchnumberretry','countglobal','totalGlobal','NoSuchNumber','custom:agentnosuchnumber','buildObj','nosuchnumber','dialNoSuchNumberRetryFrequency','callAdditionalPhoneAfterMin','dialGlobalMaxRetry','dialNoSuchNumberMaxRetry','[callProgressDetectingCustomer][logNoSuchGlobal]','scheduledAt','unlockAgent','activeContact','linkedid','actioncountonusuch','idContact','incrementPreviewCounters','swapAdditionalPhones','YYYY-MM-DD\x20HH:mm:ss','responsetime','answertime','[syncHangup][talking][increment]','uniqueid','custom:agentconnect','connect','mandatoryDisposition','custom:agentConnectPreview','channelAgent','custom:agentcomplete','complete','outboundAnswerCallsDay','answered','decrementTalking','[16]'];(function(_0x47411f,_0x5e0737){var _0x1fb64e=function(_0x47abd2){while(--_0x47abd2){_0x47411f['push'](_0x47411f['shift']());}};_0x1fb64e(++_0x5e0737);}(_0x9267,0x1dd));var _0x7926=function(_0x4416a4,_0x562fd6){_0x4416a4=_0x4416a4-0x0;var _0xadbdae=_0x9267[_0x4416a4];return _0xadbdae;};'use strict';var util=require(_0x7926('0x0'));var _=require('lodash');var uuid=require(_0x7926('0x1'));var moment=require(_0x7926('0x2'));var Redis=require(_0x7926('0x3'));var config=require(_0x7926('0x4'));var logger=require(_0x7926('0x5'))(_0x7926('0x6'));var loggerAction=require('../../../config/logger')(_0x7926('0x7'));var ami=require(_0x7926('0x8'));var rpcDb=require(_0x7926('0x9'));var cmHopperAdditionalPhone=require(_0x7926('0xa'));var Action=require(_0x7926('0xb'));var ut=require(_0x7926('0xc'));var utils=require(_0x7926('0xd'));config[_0x7926('0xe')]=_[_0x7926('0xf')](config[_0x7926('0xe')],{'host':_0x7926('0x10'),'port':0x18eb});var io=require(_0x7926('0x11'))(new Redis(config[_0x7926('0xe')]));var Sequence=function(){};Sequence[_0x7926('0x12')][_0x7926('0x13')]=function(_0x20db3){this[_0x7926('0x14')]=this['tail']?this[_0x7926('0x14')][_0x7926('0x15')](_0x20db3):_0x20db3();};function Preview(_0x3c0dcc){this['sequence']=new Sequence();this[_0x7926('0x16')]=_0x3c0dcc[_0x7926('0x17')];this[_0x7926('0x18')]=_0x3c0dcc[_0x7926('0x18')];this[_0x7926('0x19')]={};this[_0x7926('0x1a')]=_0x3c0dcc[_0x7926('0x1a')];this[_0x7926('0x1b')]=0x0;ami['on'](_0x7926('0x1c'),this['syncOriginateResponse'][_0x7926('0x1d')](this));ami['on']('hangup',this[_0x7926('0x1e')][_0x7926('0x1d')](this));ami['on'](_0x7926('0x1f'),this[_0x7926('0x20')][_0x7926('0x1d')](this));ami['on']('dialend',this[_0x7926('0x21')][_0x7926('0x1d')](this));ami['on']('newexten',this['syncNewExten']['bind'](this));ami['on']('varset',this[_0x7926('0x22')][_0x7926('0x1d')](this));ami['on'](_0x7926('0x23'),this[_0x7926('0x24')][_0x7926('0x1d')](this));ami['on'](_0x7926('0x25'),this[_0x7926('0x26')]['bind'](this));this[_0x7926('0x27')](this[_0x7926('0x16')]);}function emit(_0x266438,_0xe91c02,_0x21d4c4){io['to'](_0x266438)[_0x7926('0x28')](_0xe91c02,_0x21d4c4);}function emitVoiceQueueChannelRemove(_0x1d8d54){logger[_0x7926('0x29')](_0x7926('0x2a'),JSON['stringify'](_0x1d8d54));emit(util['format'](_0x7926('0x2b'),_0x1d8d54[_0x7926('0x2c')]),_0x7926('0x2d'),_0x1d8d54);io[_0x7926('0x28')]('voice_queue_presence:remove',_0x1d8d54);}function notSendMessagesQueue(_0x25c33c){if(_0x25c33c['sendMessageOneNotActive']){if(_0x25c33c[_0x7926('0x2e')]===0x0&&_0x25c33c[_0x7926('0x2f')]===0x0){_0x25c33c['sendMessageOneNotActive']=![];_0x25c33c[_0x7926('0x30')]=0x0;_0x25c33c[_0x7926('0x31')]=0x0;_0x25c33c[_0x7926('0x32')]=utils[_0x7926('0x33')][_0x7926('0x34')];ut[_0x7926('0x35')](_0x7926('0x36'),_0x25c33c[_0x7926('0x2c')]+_0x7926('0x37'));}else{_0x25c33c[_0x7926('0x32')]=utils[_0x7926('0x33')][_0x7926('0x38')];ut[_0x7926('0x35')](_0x7926('0x36'),_0x25c33c[_0x7926('0x2c')]+_0x7926('0x39'));}}}Preview[_0x7926('0x12')]['loopCampaigns']=function(){var _0x464a3a=this;setInterval(function(){_0x464a3a['syncCampaigns']();},0x7cf);};Preview[_0x7926('0x12')][_0x7926('0x3a')]=function(){var _0x1087e4=this[_0x7926('0x16')];this[_0x7926('0x1b')]+=0x1;for(var _0x278d60 in _0x1087e4){if(_0x1087e4['hasOwnProperty'](_0x278d60)&&(_0x1087e4[_0x278d60][_0x7926('0x3b')]===_0x7926('0x6')||_0x1087e4[_0x278d60][_0x7926('0x3b')]===_0x7926('0x3c'))&&_0x1087e4[_0x278d60][_0x7926('0x3d')]==='outbound'){if(this[_0x7926('0x1b')]>0x7){this[_0x7926('0x1b')]=0x0;this[_0x7926('0x3e')]();}}if(_0x1087e4['hasOwnProperty'](_0x278d60)&&_0x1087e4[_0x278d60]['dialMethod']===_0x7926('0x6')&&_0x1087e4[_0x278d60][_0x7926('0x3d')]===_0x7926('0x3f')){if(_0x1087e4[_0x278d60]['dialActive']){this[_0x7926('0x40')](_0x1087e4[_0x278d60]);if(_0x1087e4[_0x278d60]['dialPreviewAutoRecallMe'])this[_0x7926('0x41')](_0x1087e4[_0x278d60]);}else{notSendMessagesQueue(_0x1087e4[_0x278d60]);}}}};Preview[_0x7926('0x12')][_0x7926('0x42')]=function(_0x21671a){var _0x370599=this;this[_0x7926('0x43')]['enqueue'](function(){if(!_[_0x7926('0x44')](_0x370599[_0x7926('0x19')][_0x21671a])){loggerAction[_0x7926('0x29')](_0x7926('0x45'),_0x21671a,'Queue',_0x370599[_0x7926('0x19')][_0x21671a]['queue'],'originated:\x20',JSON[_0x7926('0x46')](_0x370599['campaignsPreview'][_0x370599[_0x7926('0x19')][_0x21671a][_0x7926('0x47')]][_0x7926('0x2e')]),_0x7926('0x48'),JSON[_0x7926('0x46')](_0x370599[_0x7926('0x16')][_0x370599[_0x7926('0x19')][_0x21671a][_0x7926('0x47')]][_0x7926('0x2f')]),JSON[_0x7926('0x46')](_0x370599[_0x7926('0x19')][_0x21671a][_0x7926('0x49')]),JSON['stringify'](_[_0x7926('0x4a')](_0x370599[_0x7926('0x19')][_0x21671a],['contactId',_0x7926('0x4b'),_0x7926('0x4c'),_0x7926('0x4d')])));return ami['Action']({'action':_0x7926('0x4e'),'channel':_0x370599[_0x7926('0x19')][_0x21671a][_0x7926('0x4f')]})[_0x7926('0x50')](function(_0x2c0cbf){if(_0x2c0cbf[_0x7926('0x32')]===_0x7926('0x51')){setTimeout(function(){if(_0x370599['actions'][_0x21671a]){utils[_0x7926('0x52')](_0x370599[_0x7926('0x16')][_0x370599['actions'][_0x21671a][_0x7926('0x47')]],_0x7926('0x53'));if(_0x370599[_0x7926('0x19')][_0x21671a][_0x7926('0x49')]===!![]){ut['decrementTalking'](_0x370599[_0x7926('0x16')][_0x370599[_0x7926('0x19')][_0x21671a][_0x7926('0x47')]],'[clearZombieChannel]');ut[_0x7926('0x54')](_0x7926('0x55')+_0x21671a,_0x370599[_0x7926('0x19')][_0x21671a][_0x7926('0x47')]);}ut[_0x7926('0x54')](_0x7926('0x56')+_0x21671a,_0x370599['actions'][_0x21671a][_0x7926('0x47')]);delete _0x370599[_0x7926('0x19')][_0x21671a];}},0x2328);}});}});};Preview[_0x7926('0x12')][_0x7926('0x3e')]=function(){var _0x1139a2=this;loggerAction[_0x7926('0x29')](_0x7926('0x57'),_['size'](this['actions']));for(var _0x44c9ef in this['actions']){if(_0x1139a2[_0x7926('0x19')][_0x7926('0x58')](_0x44c9ef)){_0x1139a2[_0x7926('0x42')](_0x44c9ef);}}};Preview[_0x7926('0x12')][_0x7926('0x41')]=function(_0x2a56c8){var _0x57f550=this;rpcDb['getContactRecallMe'](_0x2a56c8['id'],ut[_0x7926('0x59')](this[_0x7926('0x1a')]))['then'](function(_0x582290){if(!_[_0x7926('0x44')](_0x582290)){for(var _0x3dbb1c=0x0;_0x3dbb1c<_0x582290[_0x7926('0x5a')];_0x3dbb1c+=0x1){if(ut[_0x7926('0x5b')](_0x582290[_0x3dbb1c][_0x7926('0x5c')])<_0x2a56c8[_0x7926('0x5d')]*0x3c){if(_0x582290[_0x3dbb1c][_0x7926('0x5e')]&&!_0x582290[_0x3dbb1c][_0x7926('0x5e')][_0x7926('0x5f')]){_0x57f550[_0x7926('0x60')](_0x582290[_0x3dbb1c]['id'])[_0x7926('0x61')](ut[_0x7926('0x62')](_0x7926('0x63')))[_0x7926('0x50')](ut[_0x7926('0x62')]('[RecallMe]'));}else{rpcDb[_0x7926('0x64')](_0x582290[_0x3dbb1c]['id']);}}else{var _0x2e1a1d=new Action(_0x582290[_0x3dbb1c],_0x2a56c8);_0x2e1a1d[_0x7926('0x65')]=moment()[_0x7926('0x66')]('YYYY-MM-DD\x20HH:mm:ss');_0x2a56c8[_0x7926('0x67')]+=0x1;ut[_0x7926('0x68')](_0x2e1a1d,0x17,'RecallInQueue');if(_0x2a56c8['dialRecallInQueue']){rpcDb[_0x7926('0x69')](ut['createBody'](_0x582290[_0x3dbb1c]));rpcDb[_0x7926('0x6a')](_0x2e1a1d,_0x7926('0x6b'));}else{ut[_0x7926('0x68')](_0x2e1a1d,0x16,'RecallFailedTimeout');rpcDb[_0x7926('0x6a')](_0x2e1a1d,_0x7926('0x6c'));rpcDb[_0x7926('0x6d')](_0x2e1a1d,'[HistoryRecallClose]');}}}}})[_0x7926('0x50')](ut[_0x7926('0x62')](_0x7926('0x6e')));};Preview[_0x7926('0x12')][_0x7926('0x40')]=function(_0x4780ae){_0x4780ae['sendMessageOneNotActive']=!![];if(ut[_0x7926('0x6f')](_0x4780ae['loggedIn'])){_0x4780ae['message']=utils[_0x7926('0x33')][_0x7926('0x70')];}else if(!ut['isActive'](_0x4780ae[_0x7926('0x71')])){_0x4780ae['message']=utils[_0x7926('0x33')][_0x7926('0x34')];}else if(!this['isTrunkReachable'](_0x4780ae[_0x7926('0x72')])){if(!this[_0x7926('0x73')](_0x4780ae[_0x7926('0x74')])){_0x4780ae[_0x7926('0x32')]=utils[_0x7926('0x33')][_0x7926('0x75')];}else{_0x4780ae[_0x7926('0x32')]=utils[_0x7926('0x33')]['ACTIVE'];}}else{_0x4780ae[_0x7926('0x32')]=utils[_0x7926('0x33')][_0x7926('0x76')];}};Preview[_0x7926('0x12')][_0x7926('0x77')]=function(_0x3832e3,_0x42fc29,_0x2e1d2b){var _0x4a166f=this;var _0x4dd95b=this['actions'][_0x42fc29];var _0x30c59e=this[_0x7926('0x16')][_0x4dd95b['queue']];var _0x147aad;var _0x460a20=![];var _0x3a86a7=0x2;var _0x4900de=0x3;if(_0x30c59e){switch(_0x2e1d2b){case'1':_0x30c59e[_0x7926('0x78')]+=0x1;_0x4dd95b[_0x7926('0x79')]+=0x1;_0x4dd95b[_0x7926('0x7a')]=ut[_0x7926('0x7b')](_0x4dd95b);ut['logCustomer'](_0x4dd95b,0x0,_0x7926('0x7c'));ami[_0x7926('0x28')](_0x7926('0x7d'),ut[_0x7926('0x7e')](_0x4dd95b,_0x7926('0x7f')));rpcDb['createCustomerHistory'](_0x4dd95b,'[callProgressDetectingCustomer][logNoSuch]');_0x4a166f['verifyAdditionalPhones'](_0x4dd95b,'0',_0x30c59e)[_0x7926('0x61')](function(_0x301b7d){_0x460a20=_0x301b7d['additional']==0x1;_0x3a86a7=_0x30c59e[_0x7926('0x80')];_0x4900de=_0x30c59e[_0x7926('0x81')];if(!_0x460a20){if(ut[_0x7926('0x7b')](_0x4dd95b)>=_0x30c59e[_0x7926('0x82')]){_0x147aad=ut['cloneAction'](_0x4dd95b,0xf,'Global');rpcDb[_0x7926('0x6d')](_0x147aad,'[callProgressDetectingCustomer][logNoSuchGlobal]');}else{if(_0x4dd95b[_0x7926('0x79')]>=_0x30c59e[_0x7926('0x83')]){rpcDb[_0x7926('0x6d')](_0x4dd95b,_0x7926('0x84'));}else{rpcDb['rescheduleContact'](ut[_0x7926('0x85')](_0x4dd95b,'countnosuchnumberretry',_0x30c59e[_0x7926('0x80')]),_0x4dd95b[_0x7926('0x86')],_0x4dd95b[_0x7926('0x87')]);}}delete this[_0x7926('0x19')][_0x3832e3[_0x7926('0x88')]];}else{_0x4dd95b['countnosuchnumberretry']++;logger[_0x7926('0x29')](_0x7926('0x89'),_0x4dd95b[_0x7926('0x79')]);logger[_0x7926('0x29')]('id',_0x4dd95b[_0x7926('0x8a')]);_0x4a166f[_0x7926('0x8b')]({'id':_0x4dd95b['idContact'],'field':{'countnosuchnumberretry':_0x4dd95b['countnosuchnumberretry']}})[_0x7926('0x61')](function(){_0x4a166f[_0x7926('0x8c')](_0x4dd95b,_0x3a86a7,_0x4900de)[_0x7926('0x61')](function(){});});}});break;case'ANSWER':var _0x1c82cf=moment()['format'](_0x7926('0x8d'));_0x4dd95b[_0x7926('0x8e')]=_0x1c82cf;_0x4dd95b[_0x7926('0x8f')]=_0x1c82cf;_0x4dd95b[_0x7926('0x49')]=!![];_0x30c59e['pTalking']+=0x1;logger[_0x7926('0x29')](_0x7926('0x90'),_0x4dd95b[_0x7926('0x91')],'\x20Queue',_0x30c59e[_0x7926('0x2c')],_0x7926('0x48'),_0x30c59e[_0x7926('0x2f')]);ami[_0x7926('0x28')](_0x7926('0x92'),ut[_0x7926('0x7e')](_0x4dd95b,_0x7926('0x93'),this[_0x7926('0x16')][_0x4dd95b['queue']]));if(_0x30c59e['acw']||_0x30c59e[_0x7926('0x94')]){ami[_0x7926('0x28')](_0x7926('0x95'),{'queue':_0x4dd95b[_0x7926('0x47')],'interface':_0x4dd95b[_0x7926('0x96')],'uniqueid':_0x4dd95b[_0x7926('0x91')]});}break;case'16':ami[_0x7926('0x28')](_0x7926('0x97'),ut[_0x7926('0x7e')](_0x4dd95b,'complete',this[_0x7926('0x16')][_0x4dd95b['queue']]));emitVoiceQueueChannelRemove(ut['buildObj'](_0x4dd95b,_0x7926('0x98')));_0x30c59e[_0x7926('0x99')]+=0x1;_0x30c59e['total']+=0x1;_0x30c59e[_0x7926('0x9a')]+=0x1;ut[_0x7926('0x9b')](_0x30c59e,_0x7926('0x9c'));_0x4dd95b['countglobal']=ut[_0x7926('0x7b')](_0x4dd95b);ut['logCustomer'](_0x4dd95b,0x4,_0x7926('0x9d'));rpcDb[_0x7926('0x6a')](_0x4dd95b,_0x7926('0x9e'));rpcDb[_0x7926('0x6d')](_0x4dd95b,'[callProgressDetectingCustomer][logAnswerGlobal]');rpcDb['crateCustomerReportQueue'](_0x4dd95b);_0x30c59e['sumDuration']+=_0x4dd95b[_0x7926('0x9f')];_0x30c59e[_0x7926('0xa0')]+=_0x4dd95b[_0x7926('0x9f')];logger['info'](_0x7926('0xa1'),_0x4dd95b['uniqueid'],'\x20Queue',_0x30c59e[_0x7926('0x2c')],_0x7926('0x48'),_0x30c59e[_0x7926('0x2f')]);delete this[_0x7926('0x19')][_0x3832e3[_0x7926('0x88')]];break;case _0x7926('0xa2'):_0x30c59e[_0x7926('0xa3')]+=0x1;_0x4dd95b[_0x7926('0xa4')]+=0x1;_0x4dd95b['countglobal']=ut['totalGlobal'](_0x4dd95b);ut[_0x7926('0x68')](_0x4dd95b,0x5,_0x7926('0xa5'));_0x3a86a7=_0x30c59e[_0x7926('0xa6')];_0x4900de=_0x30c59e[_0x7926('0x81')];ami[_0x7926('0x28')]('custom:agentbusy',ut[_0x7926('0x7e')](_0x4dd95b,'busy'));rpcDb[_0x7926('0x6a')](_0x4dd95b,_0x7926('0xa7'));_0x4a166f[_0x7926('0xa8')](_0x4dd95b,'5',_0x30c59e)[_0x7926('0x61')](function(_0x457672){_0x460a20=_0x457672[_0x7926('0xa9')]==0x1;if(!_0x460a20){if(ut[_0x7926('0x7b')](_0x4dd95b)>=_0x30c59e['dialGlobalMaxRetry']){_0x147aad=ut[_0x7926('0xaa')](_0x4dd95b,0xf,_0x7926('0xab'));rpcDb[_0x7926('0x6d')](_0x147aad,_0x7926('0xac'));}else{if(_0x4dd95b[_0x7926('0xa4')]>=_0x30c59e[_0x7926('0xad')]){rpcDb['createCustomerFinal'](_0x4dd95b,_0x7926('0xa7'));}else{rpcDb['rescheduleContact'](ut[_0x7926('0x85')](_0x4dd95b,_0x7926('0xa4'),_0x30c59e[_0x7926('0xa6')]),_0x4dd95b[_0x7926('0x86')],_0x4dd95b[_0x7926('0x87')]);}}}else{_0x4dd95b['countbusyretry']++;_0x4a166f['incrementPreviewCounters']({'id':_0x4dd95b[_0x7926('0x8a')],'field':{'countbusyretry':_0x4dd95b[_0x7926('0xa4')]}})[_0x7926('0x61')](function(){_0x4a166f['swapAdditionalPhones'](_0x4dd95b,_0x3a86a7,_0x4900de)[_0x7926('0x61')](function(){});});}});break;case'NOANSWER':_0x30c59e[_0x7926('0xae')]+=0x1;_0x4dd95b[_0x7926('0xaf')]+=0x1;_0x4dd95b[_0x7926('0x7a')]=ut['totalGlobal'](_0x4dd95b);ut['logCustomer'](_0x4dd95b,0x3,_0x7926('0xb0'));_0x3a86a7=_0x30c59e[_0x7926('0xb1')];_0x4900de=_0x30c59e[_0x7926('0x81')];var _0x1440bd=ut[_0x7926('0xb2')](_0x4dd95b,_0x30c59e);ami[_0x7926('0x28')](_0x7926('0xb3'),_0x1440bd);rpcDb['createCustomerHistory'](_0x4dd95b,'[callProgressDetectingCustomer][logNoAnswer]');_0x4a166f[_0x7926('0xa8')](_0x4dd95b,'3',_0x30c59e)[_0x7926('0x61')](function(_0x4dbe95){_0x460a20=_0x4dbe95[_0x7926('0xa9')]==0x1;if(!_0x460a20){if(ut[_0x7926('0x7b')](_0x4dd95b)>=_0x30c59e[_0x7926('0x82')]){_0x147aad=ut['cloneAction'](_0x4dd95b,0xf,_0x7926('0xab'));rpcDb[_0x7926('0x6d')](_0x147aad,'[callProgressDetectingCustomer][logNoAnswerGlobal]');}else{if(_0x4dd95b[_0x7926('0xaf')]>=_0x30c59e[_0x7926('0xb4')]){rpcDb['createCustomerFinal'](_0x4dd95b,_0x7926('0xb5'));}else{rpcDb[_0x7926('0xb6')](ut[_0x7926('0x85')](_0x4dd95b,_0x7926('0xaf'),_0x30c59e[_0x7926('0xb1')]),_0x4dd95b['unlockAgent'],_0x4dd95b['activeContact']);}}}else{_0x4dd95b['countnoanswerretry']++;_0x4a166f[_0x7926('0x8b')]({'id':_0x4dd95b[_0x7926('0x8a')],'field':{'countnoanswerretry':_0x4dd95b[_0x7926('0xaf')]}})[_0x7926('0x61')](function(){_0x4a166f[_0x7926('0x8c')](_0x4dd95b,_0x3a86a7,_0x4900de)[_0x7926('0x61')](function(){});});}});break;case _0x7926('0xb7'):_0x30c59e[_0x7926('0xb8')]+=0x1;_0x4dd95b[_0x7926('0xb9')]+=0x1;_0x4dd95b[_0x7926('0x7a')]=ut[_0x7926('0x7b')](_0x4dd95b);ut[_0x7926('0x68')](_0x4dd95b,0x8,_0x7926('0xba'));_0x3a86a7=_0x30c59e['dialCongestionRetryFrequency'];_0x4900de=_0x30c59e['callAdditionalPhoneAfterMin'];ami['emit'](_0x7926('0xbb'),ut[_0x7926('0x7e')](_0x4dd95b,_0x7926('0xbc')));rpcDb[_0x7926('0x6a')](_0x4dd95b,_0x7926('0xbd'));_0x4a166f[_0x7926('0xa8')](_0x4dd95b,'8',_0x30c59e)[_0x7926('0x61')](function(_0x3fca6d){_0x460a20=_0x3fca6d[_0x7926('0xa9')]==0x1;if(!_0x460a20){if(ut[_0x7926('0x7b')](_0x4dd95b)>=_0x30c59e[_0x7926('0x82')]){_0x147aad=ut[_0x7926('0xaa')](_0x4dd95b,0xf,_0x7926('0xab'));rpcDb['createCustomerFinal'](_0x147aad,_0x7926('0xbe'));}else{if(_0x4dd95b[_0x7926('0xb9')]>=_0x30c59e[_0x7926('0xbf')]){rpcDb[_0x7926('0x6d')](_0x4dd95b,_0x7926('0xbd'));}else{rpcDb[_0x7926('0xb6')](ut[_0x7926('0x85')](_0x4dd95b,_0x7926('0xb9'),_0x30c59e[_0x7926('0xa6')]),_0x4dd95b[_0x7926('0x86')],_0x4dd95b['activeContact']);}}}else{_0x4dd95b[_0x7926('0xb9')]++;_0x4a166f['incrementPreviewCounters']({'id':_0x4dd95b['idContact'],'field':{'countcongestionretry':_0x4dd95b[_0x7926('0xb9')]}})[_0x7926('0x61')](function(){_0x4a166f[_0x7926('0x8c')](_0x4dd95b,_0x3a86a7,_0x4900de)[_0x7926('0x61')](function(){});});}});break;case _0x7926('0xc0'):_0x30c59e[_0x7926('0xc1')]+=0x1;_0x4dd95b['countagentrejectretry']+=0x1;_0x4dd95b['countglobal']=ut[_0x7926('0x7b')](_0x4dd95b);ut[_0x7926('0x68')](_0x4dd95b,0x14,'AgentReject');_0x3a86a7=_0x30c59e['dialAgentRejectRetryFrequency'];_0x4900de=_0x30c59e[_0x7926('0x81')];ami[_0x7926('0x28')](_0x7926('0xc2'),ut['buildObj'](_0x4dd95b,_0x7926('0xc3')));rpcDb[_0x7926('0x6a')](_0x4dd95b,'[syncHangupRequest][logAgentReject]');_0x4a166f[_0x7926('0xa8')](_0x4dd95b,'20',_0x30c59e)['then'](function(_0x50bdfb){_0x460a20=_0x50bdfb[_0x7926('0xa9')]==0x1;if(!_0x460a20){if(ut[_0x7926('0x7b')](_0x4dd95b)>=_0x30c59e[_0x7926('0x82')]){_0x147aad=ut['cloneAction'](_0x4dd95b,0x14,_0x7926('0xc4'));rpcDb[_0x7926('0x6d')](_0x147aad,'[callProgressDetectingCustomer][logAgentReject]');}else{if(_0x4dd95b[_0x7926('0xc5')]>=_0x30c59e[_0x7926('0xc6')]){rpcDb[_0x7926('0x6d')](_0x4dd95b,_0x7926('0xc7'));}else{rpcDb[_0x7926('0xb6')](ut['scheduledAt'](_0x4dd95b,_0x7926('0xc5'),_0x30c59e[_0x7926('0xc8')]),_0x4dd95b[_0x7926('0x86')],_0x4dd95b['activeContact']);}}}else{_0x4dd95b[_0x7926('0xaf')]++;_0x4a166f[_0x7926('0x8b')]({'id':_0x4dd95b['idContact'],'field':{'countnoanswerretry':_0x4dd95b[_0x7926('0xaf')]}})[_0x7926('0x61')](function(){_0x4a166f[_0x7926('0x8c')](_0x4dd95b,_0x3a86a7,_0x4900de)[_0x7926('0x61')](function(){});});}});break;case _0x7926('0xc9'):_0x30c59e[_0x7926('0xca')]+=0x1;_0x4dd95b[_0x7926('0xcb')]+=0x1;_0x4dd95b[_0x7926('0x7a')]=ut[_0x7926('0x7b')](_0x4dd95b);ut['logCustomer'](_0x4dd95b,0xb,'Abandoned');rpcDb[_0x7926('0x6a')](_0x4dd95b,_0x7926('0xcc'));_0x4a166f[_0x7926('0xa8')](_0x4dd95b,'11',_0x30c59e)[_0x7926('0x61')](function(_0x176bd9){_0x460a20=_0x176bd9[_0x7926('0xa9')]==0x1;if(!_0x460a20){if(ut['totalGlobal'](_0x4dd95b)>=_0x30c59e[_0x7926('0x82')]){_0x147aad=ut[_0x7926('0xaa')](_0x4dd95b,0xf,'Global');rpcDb[_0x7926('0x6d')](_0x147aad,_0x7926('0xcc'));}else{if(_0x4dd95b[_0x7926('0xcd')]>=_0x30c59e[_0x7926('0xce')]){rpcDb[_0x7926('0x6d')](_0x4dd95b,_0x7926('0xcc'));}else{rpcDb[_0x7926('0xb6')](ut[_0x7926('0x85')](_0x4dd95b,_0x7926('0xcb'),_0x30c59e[_0x7926('0xcf')]),_0x4dd95b[_0x7926('0x86')],_0x4dd95b[_0x7926('0x87')]);}}}else{_0x4dd95b[_0x7926('0xaf')]++;_0x4a166f[_0x7926('0x8b')]({'id':_0x4dd95b['idContact'],'field':{'countnoanswerretry':_0x4dd95b['countnoanswerretry']}})[_0x7926('0x61')](function(){_0x4a166f[_0x7926('0x8c')](_0x4dd95b,_0x3a86a7,_0x4900de)[_0x7926('0x61')](function(){});});}});break;case'18':_0x30c59e[_0x7926('0xd0')]+=0x1;_0x4dd95b[_0x7926('0xd1')]+=0x1;_0x4dd95b[_0x7926('0x7a')]=ut[_0x7926('0x7b')](_0x4dd95b);ut[_0x7926('0x68')](_0x4dd95b,0x12,_0x3832e3[_0x7926('0xd2')]||_0x3832e3[_0x7926('0xd3')]);ami[_0x7926('0x28')](_0x7926('0xd4'),ut[_0x7926('0x7e')](_0x4dd95b,_0x7926('0xd5')));rpcDb['createCustomerHistory'](_0x4dd95b,_0x7926('0xd6'));_0x4a166f[_0x7926('0xa8')](_0x4dd95b,'18',_0x30c59e)[_0x7926('0x61')](function(_0x2a15eb){_0x460a20=_0x2a15eb[_0x7926('0xa9')]==0x1;if(!_0x460a20){if(ut[_0x7926('0x7b')](_0x4dd95b)>=_0x30c59e[_0x7926('0x82')]){_0x147aad=ut[_0x7926('0xaa')](_0x4dd95b,0x12,'Global');rpcDb['createCustomerFinal'](_0x147aad,'[callProgressDetectingCustomer][hangupInAMD]');}else{rpcDb[_0x7926('0x6d')](_0x4dd95b,_0x7926('0xd6'));}}else{_0x4dd95b['countnoanswerretry']++;_0x4a166f[_0x7926('0x8b')]({'id':_0x4dd95b['idContact'],'field':{'countnoanswerretry':_0x4dd95b[_0x7926('0xaf')]}})[_0x7926('0x61')](function(){_0x4a166f[_0x7926('0x8c')](_0x4dd95b,_0x3a86a7,_0x4900de)[_0x7926('0x61')](function(){});});}});delete this[_0x7926('0x19')][_0x3832e3[_0x7926('0x88')]];break;case'19':_0x30c59e['outboundUnknownCallsDay']+=0x1;_0x4dd95b[_0x7926('0x7a')]=ut['totalGlobal'](_0x4dd95b);ut[_0x7926('0x68')](_0x4dd95b,0x13,_0x3832e3[_0x7926('0xd2')]||_0x3832e3['dialstatus']);ami[_0x7926('0x28')](_0x7926('0xd4'),ut[_0x7926('0x7e')](_0x4dd95b,_0x7926('0xd5')));rpcDb[_0x7926('0x6a')](_0x4dd95b,_0x7926('0xd7'));_0x4a166f[_0x7926('0xa8')](_0x4dd95b,'18',_0x30c59e)['then'](function(_0x414202){_0x460a20=_0x414202[_0x7926('0xa9')]==0x1;if(!_0x460a20){if(ut['totalGlobal'](_0x4dd95b)>=_0x30c59e[_0x7926('0x82')]){_0x147aad=ut[_0x7926('0xaa')](_0x4dd95b,0xf,_0x7926('0xab'));rpcDb[_0x7926('0x6d')](_0x147aad,_0x7926('0xd7'));}else{rpcDb[_0x7926('0x6d')](_0x4dd95b,_0x7926('0xd7'));}}else{_0x4dd95b['countnoanswerretry']++;_0x4a166f['incrementPreviewCounters']({'id':_0x4dd95b[_0x7926('0x8a')],'field':{'countnoanswerretry':_0x4dd95b[_0x7926('0xaf')]}})[_0x7926('0x61')](function(){_0x4a166f[_0x7926('0x8c')](_0x4dd95b,_0x3a86a7,_0x4900de)[_0x7926('0x61')](function(){});});}});delete this[_0x7926('0x19')][_0x3832e3[_0x7926('0x88')]];break;default:if(_0x4dd95b[_0x7926('0x49')]){ut[_0x7926('0x9b')](_0x30c59e,'[default]');ut[_0x7926('0x54')](_0x7926('0xd8')+_0x30c59e[_0x7926('0x2c')],_0x3832e3);}_0x30c59e['outboundUnknownCallsDay']+=0x1;_0x4dd95b[_0x7926('0x7a')]=ut[_0x7926('0x7b')](_0x4dd95b);ut['logCustomer'](_0x4dd95b,0xc,_0x3832e3['cause-txt']||_0x3832e3[_0x7926('0xd3')]);_0x3a86a7=_0x30c59e[_0x7926('0xc8')];_0x4900de=_0x30c59e['callAdditionalPhoneAfterMin'];rpcDb[_0x7926('0x6a')](_0x4dd95b,'[callProgressDetectingCustomer][logUnknown]');_0x4a166f[_0x7926('0xa8')](_0x4dd95b,'20',_0x30c59e)[_0x7926('0x61')](function(_0x13a0db){_0x460a20=_0x13a0db[_0x7926('0xa9')]==0x1;if(!_0x460a20){if(ut[_0x7926('0x7b')](_0x4dd95b)>=_0x30c59e[_0x7926('0x82')]){_0x147aad=ut[_0x7926('0xaa')](_0x4dd95b,0xf,'Global');rpcDb[_0x7926('0x6d')](_0x147aad,_0x7926('0xd9'));}else{rpcDb[_0x7926('0x6d')](_0x4dd95b,'[callProgressDetectingCustomer][logUnknownGlobal]');}delete this[_0x7926('0x19')][_0x3832e3[_0x7926('0x88')]];}else{_0x4a166f[_0x7926('0x8c')](_0x4dd95b,_0x3a86a7,_0x4900de)[_0x7926('0x61')](function(){});}});}if(!(_0x4dd95b['dialAnswer']&&_0x2e1d2b==='16')){utils[_0x7926('0x52')](_0x30c59e,_0x7926('0xda'));logger['info'](_0x7926('0xdb'),_0x4dd95b['uniqueid'],_0x7926('0xdc'),_0x30c59e['name'],_0x7926('0xdd'),_0x30c59e[_0x7926('0x2e')]);}if(_0x2e1d2b!==_0x7926('0xde')){delete this[_0x7926('0x19')][_0x3832e3[_0x7926('0x88')]];delete this['actions'][_0x3832e3[_0x7926('0xdf')]];}_0x30c59e['queueSummaryCountersUpdated']=!![];}};Preview[_0x7926('0x12')][_0x7926('0xe0')]=function(_0x3e9f43,_0x3dd1b8,_0x499e5a){if(_[_0x7926('0xe1')](_0x3dd1b8)&&_0x7926('0xe2')!==typeof _0x3dd1b8){return;}if(_[_0x7926('0xe1')](_0x499e5a)&&_0x7926('0xe2')!==typeof _0x499e5a){return;}switch(_0x499e5a[_0x7926('0xe3')]){case'0':ut['logAgent'](_0x3e9f43,0x0,_0x7926('0x7c'));rpcDb[_0x7926('0xe4')](_0x3e9f43,'[callProgressDetectingAgent][logNoSuch]');break;case'3':ut[_0x7926('0xe5')](_0x3e9f43,0x3,_0x7926('0xb0'));rpcDb[_0x7926('0xe4')](_0x3e9f43,_0x7926('0xe6'));break;case'5':ut[_0x7926('0xe5')](_0x3e9f43,0x5,_0x7926('0xa5'));rpcDb['createAgentHistory'](_0x3e9f43,_0x7926('0xe7'));break;case'8':ut[_0x7926('0xe5')](_0x3e9f43,0x8,'Congestion');rpcDb['createAgentHistory'](_0x3e9f43,_0x7926('0xe8'));break;case'22':ut[_0x7926('0xe5')](_0x3e9f43,0x16,'AnswerAGI');rpcDb[_0x7926('0xe4')](_0x3e9f43,_0x7926('0xe9'));break;default:ut[_0x7926('0xe5')](_0x3e9f43,0xc,_0x499e5a[_0x7926('0xe3')]);rpcDb[_0x7926('0xe4')](_0x3e9f43,_0x7926('0xe8'));}utils[_0x7926('0x52')](_0x3dd1b8,_0x7926('0xea'));logger[_0x7926('0x29')](_0x7926('0xeb'),_0x3e9f43['uniqueid'],_0x7926('0xdc'),_0x3dd1b8[_0x7926('0x2c')],_0x7926('0xdd'),_0x3dd1b8[_0x7926('0x2e')]);delete this['actions'][_0x3e9f43['uniqueid']];};Preview[_0x7926('0x12')][_0x7926('0xa8')]=function(_0x5e07a0,_0x235901,_0x53365f){return cmHopperAdditionalPhone[_0x7926('0xa8')](_0x5e07a0,_0x235901,_0x53365f)[_0x7926('0x50')](logger[_0x7926('0x29')](_0x7926('0xec')));};Preview[_0x7926('0x12')][_0x7926('0x8c')]=function(_0x4fe077,_0x31806c,_0x5e5d54){return cmHopperAdditionalPhone['swapAdditionalPhones'](_0x4fe077,_0x31806c,_0x5e5d54)[_0x7926('0x50')](logger['info']('[swapAdditionalPhone]\x20'));};Preview[_0x7926('0x12')][_0x7926('0x8b')]=function(_0x139a30){return Promise[_0x7926('0xed')]()['then'](cmHopperAdditionalPhone['incrementPreviewCounters'](_0x139a30))[_0x7926('0x50')](logger[_0x7926('0x29')]('[incrementPreviewCounters]\x20'));};Preview[_0x7926('0x12')][_0x7926('0xee')]=function(_0x50e63a,_0x153c08,_0x4c9603,_0x4a57ae,_0x34cf9d){var _0x77920e=this;return new Promise(function(_0x1cd32c,_0x4c7812){if(_[_0x7926('0x44')](_0x153c08)||_[_0x7926('0x44')](_0x153c08[_0x7926('0xef')])||_[_0x7926('0x44')](_0x153c08[_0x7926('0xf0')])||_[_0x7926('0x44')](_0x153c08[_0x7926('0x4c')])){_0x4c7812(ut[_0x7926('0x32')]('Contact\x20is\x20undefined',_0x4a57ae,_0x34cf9d));return;}var _0xc8bda6=uuid['v4']();var _0x38c84f=_0x77920e[_0x7926('0x16')][_0x153c08[_0x7926('0xf1')][_0x7926('0x2c')]];var _0x48a535=_0x4c9603?_0x77920e[_0x7926('0x1a')][_0x4c9603]['id']:undefined;_0x77920e['actions'][_0xc8bda6]=new Action(_0x153c08,_0x38c84f,_0xc8bda6,_0x4c9603,_0x48a535);var _0x39ffe9=_0x77920e['actions'][_0xc8bda6];_0x39ffe9[_0x7926('0x86')]=_0x4a57ae;_0x39ffe9[_0x7926('0x87')]=_0x34cf9d;_0x39ffe9[_0x7926('0xf2')]=_0x4c9603;if(_[_0x7926('0xf3')](_0x50e63a)){_0x77920e[_0x7926('0xf4')](_0x39ffe9,_0x38c84f,_0x153c08,_0x4c9603)[_0x7926('0x61')](function(_0x236779){logger[_0x7926('0x29')]('[Preview][execCall][success]','Queue:\x20'+_0x39ffe9[_0x7926('0x47')]+_0x7926('0xf5')+_0x39ffe9[_0x7926('0x8a')],JSON[_0x7926('0x46')](_0x236779));ami[_0x7926('0x28')](_0x7926('0xf6'),ut['buildObj'](_0x39ffe9,_0x7926('0xf7'),_0x77920e[_0x7926('0x16')][_0x39ffe9[_0x7926('0x47')]]));_0x1cd32c(ut['message'](_0x7926('0xf8')));})[_0x7926('0x50')](function(_0x4f43ab){ut[_0x7926('0x35')](_0x7926('0xf9'),_0x4f43ab);_0x4c7812(ut[_0x7926('0x32')](_0x7926('0xfa'),_0x4a57ae,_0x34cf9d));});}else{_0x38c84f['outboundBlacklistCallsDay']+=0x1;ut[_0x7926('0xfb')](_0x39ffe9);rpcDb['createHistory'](_0x39ffe9,'[Blacklist][error]');delete _0x77920e['actions'][_0xc8bda6];_0x4c7812(ut[_0x7926('0x32')](_0x7926('0xfc'),_0x4a57ae,_0x34cf9d));}});};Preview[_0x7926('0x12')][_0x7926('0x73')]=function(_0x1155a5){return!_['isNil'](_0x1155a5)&&!_['isNil'](_0x1155a5[_0x7926('0x2c')])&&!_['isNil'](_0x1155a5[_0x7926('0xfd')])&&_0x1155a5[_0x7926('0xfd')]&&!_[_0x7926('0x44')](this[_0x7926('0x18')][util[_0x7926('0x66')](_0x7926('0xfe'),_0x1155a5['name'])])&&!_['isNil'](this['trunks'][util['format']('SIP/%s',_0x1155a5[_0x7926('0x2c')])]['status'])&&(this[_0x7926('0x18')][util['format'](_0x7926('0xfe'),_0x1155a5['name'])]['status']===_0x7926('0xff')||this['trunks'][util[_0x7926('0x66')](_0x7926('0xfe'),_0x1155a5['name'])]['status']==='unmonitored');};Preview['prototype']['run']=function(_0x3d752b,_0x504d19){return this[_0x7926('0x100')](_0x3d752b,_0x504d19)[_0x7926('0x61')](function(_0x3aa4ef){return _[_0x7926('0x4a')](_0x3aa4ef,[_0x7926('0x32')]);})[_0x7926('0x50')](function(_0x1e1b95){if(_0x1e1b95[_0x7926('0x101')]){rpcDb[_0x7926('0x102')](_0x3d752b);}if(_0x1e1b95[_0x7926('0xfd')]){rpcDb['disableContact'](_0x3d752b);}throw _[_0x7926('0x4a')](_0x1e1b95,['message']);});};Preview[_0x7926('0x12')][_0x7926('0x100')]=function(_0x5b9111,_0x5309f0){var _0x6170f9=this;var _0x5856e4,_0x498352;return rpcDb[_0x7926('0x103')](_0x5b9111)[_0x7926('0x61')](function(_0x5edcf0){if(!_['isNil'](_0x5edcf0[0x0])){_0x498352=_0x5edcf0[0x0][_0x7926('0x104')]?![]:!![];_0x5856e4=_0x5edcf0[0x0][_0x7926('0x104')]?!![]:![];_0x5856e4=_0x5309f0?!![]:_0x5856e4;}var _0x460b6e=_0x6170f9[_0x7926('0x105')](_0x5edcf0);if(_0x460b6e[_0x7926('0x106')]){rpcDb['checkIsBlackList'](_[_0x7926('0x4a')](_0x5edcf0[0x0],[_0x7926('0x4c'),_0x7926('0xf0')]))[_0x7926('0x61')](function(_0xbe17a0){_0x6170f9[_0x7926('0xee')](_0xbe17a0,_0x5edcf0[0x0],_0x5309f0,_0x498352,_0x5856e4)[_0x7926('0x61')](function(_0x94ee22){return _0x94ee22;})[_0x7926('0x50')](function(_0x240fa9){throw _0x240fa9;});})[_0x7926('0x50')](function(_0x3fa6fc){ut[_0x7926('0x35')](_0x7926('0x107'),_0x3fa6fc);throw ut[_0x7926('0x32')](_0x7926('0x108'),_0x498352,_0x5856e4);});}else{throw ut[_0x7926('0x32')](_0x460b6e[_0x7926('0x32')],_0x498352,_0x5856e4);}})[_0x7926('0x50')](function(_0x3bdba2){ut['logger'](_0x7926('0x109'),_0x3bdba2);throw ut[_0x7926('0x32')](_0x7926('0x108'),![],!![]);});};Preview['prototype']['validateContact']=function(_0x34a498){if(_[_0x7926('0x44')](_0x34a498)||_[_0x7926('0xf3')](_0x34a498)||!_[_0x7926('0x44')](_0x34a498[0x0]['Agent'])&&_[_0x7926('0x44')](_0x34a498[0x0][_0x7926('0x5e')][_0x7926('0x2c')])){ut[_0x7926('0x35')](_0x7926('0x10a'),_0x34a498);return{'isValid':![],'message':_0x7926('0x10b')};}var _0x4cfaf4=this['campaignsPreview'][_0x34a498[0x0][_0x7926('0xf1')][_0x7926('0x2c')]];_0x4cfaf4[_0x7926('0x32')]=utils['CAMPAIGN_STATUS']['ACTIVE'];if(_[_0x7926('0x44')](_0x4cfaf4)){ut['logger'](_0x7926('0x10c'),_0x4cfaf4);return{'isValid':![],'message':_0x7926('0x10d')};}if(!this[_0x7926('0x73')](_0x4cfaf4[_0x7926('0x72')])){ut[_0x7926('0x35')](_0x7926('0x10e'),_0x7926('0x10f')+_0x4cfaf4[_0x7926('0x2c')]+_0x7926('0x110'));if(!this['isTrunkReachable'](_0x4cfaf4[_0x7926('0x74')])){ut['logger'](_0x7926('0x10e'),_0x4cfaf4[_0x7926('0x2c')]+_0x7926('0x111'));return{'isValid':![],'message':_0x7926('0x112')};}}if(!ut[_0x7926('0x113')](_0x4cfaf4['dialActive'])){ut[_0x7926('0x35')]('[Preview][validateContact][Campaign\x20Active]',_0x4cfaf4['name']+'\x20Not\x20Active');return{'isValid':![],'message':'campaign\x20Name:\x20'+_0x4cfaf4['name']+_0x7926('0x114')};}return{'isValid':!![],'message':_0x7926('0x115')};};Preview[_0x7926('0x12')][_0x7926('0xf4')]=function(_0x13e71c,_0x4cf65a,_0x27592a,_0x4521d1){var _0x34b315=this;return new Promise(function(_0x58609b,_0x1e34f2){var _0x47fe4a=_0x13e71c[_0x7926('0x91')];var _0x3bdc08=_0x34b315[_0x7926('0x73')](_0x4cf65a['Trunk'])?util[_0x7926('0x66')](_0x7926('0x116'),_0x4cf65a[_0x7926('0x72')]['name'],_['isNil'](_0x4cf65a[_0x7926('0x117')])?'':_0x4cf65a[_0x7926('0x117')][_0x7926('0x118')]()||'',_0x4cf65a[_0x7926('0x119')]>0x0?_0x27592a[_0x7926('0xf0')][_0x7926('0x11a')](_0x4cf65a[_0x7926('0x119')]):_0x27592a[_0x7926('0xf0')]):util[_0x7926('0x66')](_0x7926('0x116'),_[_0x7926('0x44')](_0x4cf65a[_0x7926('0x74')])?_0x4cf65a['Trunk']['name']:_0x4cf65a['TrunkBackup'][_0x7926('0x2c')],_[_0x7926('0x44')](_0x4cf65a[_0x7926('0x117')])?'':_0x4cf65a[_0x7926('0x117')][_0x7926('0x118')]()||'',_0x4cf65a[_0x7926('0x119')]>0x0?_0x27592a[_0x7926('0xf0')][_0x7926('0x11a')](_0x4cf65a[_0x7926('0x119')]):_0x27592a[_0x7926('0xf0')]);var _0x38daa2=_0x34b315[_0x7926('0x73')](_0x4cf65a[_0x7926('0x72')])?ut['getCallerId'](_0x4cf65a[_0x7926('0x72')]['callerid'],_0x4cf65a[_0x7926('0x11b')],_0x4cf65a['dialRandomLastDigitCallerIdNumber']>0x0?ut[_0x7926('0x11c')](_0x4cf65a[_0x7926('0x11d')],_0x4cf65a[_0x7926('0x11e')]):_0x4cf65a[_0x7926('0x11d')]):ut['getCallerId'](_[_0x7926('0x44')](_0x4cf65a[_0x7926('0x74')])?_0x4cf65a[_0x7926('0x72')][_0x7926('0x11f')]:_0x4cf65a[_0x7926('0x74')][_0x7926('0x11f')],_0x4cf65a[_0x7926('0x11b')],_0x4cf65a['dialRandomLastDigitCallerIdNumber']>0x0?ut[_0x7926('0x11c')](_0x4cf65a[_0x7926('0x11d')],_0x4cf65a['dialRandomLastDigitCallerIdNumber']):_0x4cf65a['dialOriginateCallerIdNumber']);if(_0x38daa2){_0x13e71c['originatecalleridname']=ut[_0x7926('0x120')](_0x38daa2);_0x13e71c[_0x7926('0x121')]=ut[_0x7926('0x122')](_0x38daa2);}var _0x3875c1=ut['addVariables'](_0x4cf65a,_0x27592a,_0x3bdc08,_0x38daa2,_0x47fe4a,_0x13e71c);var _0x5e3ad8=utils[_0x7926('0x123')](_0x27592a['Contact']);Object[_0x7926('0x124')](_0x3875c1,_0x5e3ad8);_[_0x7926('0x125')](_0x13e71c,ut[_0x7926('0x126')](_0x3875c1));_0x13e71c[_0x7926('0x65')]=moment()[_0x7926('0x66')](_0x7926('0x8d'));_0x4cf65a[_0x7926('0x127')]=_0x3875c1;var _0x2419f1=ut['variablesAction'](_0x13e71c,_0x4cf65a,_0x3875c1,_0x13e71c[_0x7926('0x87')],_0x4521d1);return ami['Action'](_0x2419f1)[_0x7926('0x61')](function(_0x3b5366){_0x4cf65a['originated']+=0x1;logger['info']('[originated][increment]',_0x47fe4a,_0x7926('0xdc'),_0x4cf65a[_0x7926('0x2c')],_0x7926('0xdd'),_0x4cf65a['originated']);_0x58609b(_0x3b5366);})[_0x7926('0x50')](function(_0xfb38ac){ut[_0x7926('0xe5')](_0x13e71c,0xe,_0x7926('0x128'));rpcDb[_0x7926('0xe4')](_0x13e71c,_0x7926('0x129'));_0x1e34f2(_0xfb38ac);});});};Preview['prototype'][_0x7926('0x12a')]=function(_0x5cbaec){if(this[_0x7926('0x19')][_0x5cbaec[_0x7926('0x88')]]){this[_0x7926('0x19')][_0x5cbaec['linkedid']][_0x7926('0x4f')]=_0x5cbaec['channel'];}};Preview[_0x7926('0x12')]['syncOriginateResponse']=function(_0x5d0359){var _0x5529df=this;var _0x500c24=this[_0x7926('0x19')][_0x5d0359['actionid']];if(_0x500c24){if(_0x500c24['lookAgent']&&this['agents'][_0x500c24[_0x7926('0xf2')]]){ut[_0x7926('0x12b')](_0x500c24,this['agents'][_0x500c24[_0x7926('0xf2')]][_0x7926('0x2c')],this[_0x7926('0x1a')][_0x500c24[_0x7926('0xf2')]]['id']);}var _0x1240ba=_['clone'](_0x500c24);_0x1240ba[_0x7926('0x8e')]=moment()[_0x7926('0x66')]('YYYY-MM-DD\x20HH:mm:ss');var _0x16b6ae=_0x5529df[_0x7926('0x16')][_0x500c24[_0x7926('0x47')]];if(ut[_0x7926('0x12c')](_0x5d0359['response'])){if(_0x500c24['unlockAgent']){rpcDb[_0x7926('0x102')](_0x500c24[_0x7926('0x8a')]);}if(_0x500c24[_0x7926('0x87')]){rpcDb[_0x7926('0x64')](_0x500c24[_0x7926('0x8a')]);}ami[_0x7926('0x28')]('custom:agentringnoanswer',ut[_0x7926('0x7e')](_0x500c24,_0x7926('0x12d'),this[_0x7926('0x16')][_0x500c24[_0x7926('0x47')]]));this['callProgressDetectingAgent'](_0x1240ba,_0x16b6ae,_0x5d0359);}else{_0x500c24['starttime']=moment()['format'](_0x7926('0x8d'));ut[_0x7926('0xe5')](_0x1240ba,0x4,_0x7926('0x9d'));rpcDb[_0x7926('0xe4')](_0x1240ba,_0x7926('0x12e'));}}};Preview['prototype'][_0x7926('0x1e')]=function(_0x13d65c){var _0x1aedf6=this[_0x7926('0x19')][_0x13d65c['linkedid']];var _0x3858d3;if(_0x1aedf6){_0x3858d3=this[_0x7926('0x16')][_0x1aedf6['queue']];logger[_0x7926('0x29')](_0x7926('0x12f'),_0x13d65c[_0x7926('0x88')],_0x7926('0xdc'),_0x3858d3['name'],_0x7926('0x48'),_0x3858d3[_0x7926('0x2f')]);}if(this['actions'][_0x13d65c[_0x7926('0x88')]]&&_0x13d65c[_0x7926('0x88')]!==_0x13d65c[_0x7926('0x91')]){if(_0x13d65c['cause']==='16'&&this[_0x7926('0x19')][_0x13d65c[_0x7926('0x88')]][_0x7926('0x49')]){this[_0x7926('0x77')](_0x13d65c,_0x13d65c[_0x7926('0x88')],_0x13d65c[_0x7926('0x130')]);}else if(this[_0x7926('0x19')][_0x13d65c[_0x7926('0x88')]][_0x7926('0x49')]){logger[_0x7926('0x29')](_0x7926('0x131'),_0x13d65c[_0x7926('0x88')],_0x13d65c[_0x7926('0x130')],_0x7926('0xdc'),_0x3858d3[_0x7926('0x2c')],_0x7926('0x48'),_0x3858d3['pTalking']);this[_0x7926('0x77')](_0x13d65c,_0x13d65c[_0x7926('0x88')],_0x13d65c['cause']);}}else if(_0x1aedf6&&_[_0x7926('0x44')](_0x1aedf6[_0x7926('0x132')])&&_0x3858d3['dialQueueProject']&&_0x13d65c[_0x7926('0x88')]===_0x13d65c['uniqueid']&&_[_0x7926('0x44')](_0x13d65c[_0x7926('0xe3')])&&_0x13d65c['cause']==='16'&&_0x13d65c['channelstate']==='6'&&_[_0x7926('0xe1')](_0x1aedf6[_0x7926('0x133')])){if(_0x1aedf6[_0x7926('0x86')]){rpcDb['unlockContact'](_0x1aedf6[_0x7926('0x8a')]);}if(_0x1aedf6['activeContact']){rpcDb[_0x7926('0x64')](_0x1aedf6[_0x7926('0x8a')]);}_0x13d65c[_0x7926('0xe3')]='22';this[_0x7926('0xe0')](_0x1aedf6,_0x3858d3,_0x13d65c);}else if(_0x1aedf6&&_0x1aedf6[_0x7926('0x133')]){if(_0x13d65c['cause']==='16'&&this['actions'][_0x13d65c[_0x7926('0x88')]][_0x7926('0x49')]){logger[_0x7926('0x29')](_0x7926('0x134'),_0x13d65c['linkedid'],_0x13d65c[_0x7926('0x130')],_0x7926('0xdc'),_0x3858d3[_0x7926('0x2c')],_0x7926('0x48'),_0x3858d3['pTalking']);this['callProgressDetectingCustomer'](_0x13d65c,_0x13d65c['linkedid'],_0x13d65c[_0x7926('0x130')]);}else if(this['actions'][_0x13d65c[_0x7926('0x88')]][_0x7926('0x49')]){logger[_0x7926('0x29')](_0x7926('0x131'),_0x13d65c['linkedid'],_0x13d65c[_0x7926('0x130')],_0x7926('0xdc'),_0x3858d3[_0x7926('0x2c')],_0x7926('0x48'),_0x3858d3[_0x7926('0x2f')]);this[_0x7926('0x77')](_0x13d65c,_0x13d65c[_0x7926('0x88')],_0x13d65c[_0x7926('0x130')]);}}};Preview[_0x7926('0x12')]['syncDialEnd']=function(_0x5369ef){if(this['actions'][_0x5369ef['destlinkedid']]&&_0x5369ef[_0x7926('0xdf')]!==_0x5369ef[_0x7926('0x135')]){this[_0x7926('0x77')](_0x5369ef,_0x5369ef['destlinkedid'],_0x5369ef[_0x7926('0xd3')]);}};Preview[_0x7926('0x12')][_0x7926('0x20')]=function(_0x21073d){if(this[_0x7926('0x19')][_0x21073d[_0x7926('0x88')]]&&_0x21073d[_0x7926('0x88')]!==_0x21073d[_0x7926('0x91')]&&!this[_0x7926('0x19')][_0x21073d['linkedid']][_0x7926('0x49')]){if(_0x21073d[_0x7926('0x130')]==='1'){this[_0x7926('0x77')](_0x21073d,_0x21073d[_0x7926('0x88')],_0x21073d[_0x7926('0x130')]);}}};Preview[_0x7926('0x12')]['addVariable']=function(_0x4896e4,_0x13a911,_0x3d5449){if(this[_0x7926('0x19')][_0x4896e4]){if(_[_0x7926('0x44')](this[_0x7926('0x19')][_0x4896e4]['variables'])){this['actions'][_0x4896e4][_0x7926('0x127')]={};}this[_0x7926('0x19')][_0x4896e4][_0x7926('0x127')][_0x13a911]=_0x3d5449;}};Preview[_0x7926('0x12')][_0x7926('0x22')]=function(_0x1970bc){try{if(!_[_0x7926('0x44')](_0x1970bc)){if(ut[_0x7926('0x136')](_[_0x7926('0x137')](_0x1970bc[_0x7926('0x138')])[0x0])){this['addVariable'](_0x1970bc[_0x7926('0x91')],_[_0x7926('0x137')](_0x1970bc[_0x7926('0x138')])[0x0],_0x1970bc['value']);}}}catch(_0x5e0d7a){logger['error'](_0x7926('0x139'),util[_0x7926('0x13a')](_0x5e0d7a,{'showHidden':![],'depth':null}));}};Preview[_0x7926('0x12')]['syncAttendedTransfer']=function(_0x400a32){if(_0x400a32){if(this['actions'][_0x400a32['transfertargetlinkedid']]){this[_0x7926('0x19')][_0x400a32['transfertargetlinkedid']]['transfer']=!![];}}};Preview[_0x7926('0x12')][_0x7926('0x26')]=function(_0x20ef9d){if(_0x20ef9d){if(this[_0x7926('0x19')][_0x20ef9d[_0x7926('0x13b')]]){this[_0x7926('0x19')][_0x20ef9d['transfererlinkedid']][_0x7926('0x133')]=!![];}}};module[_0x7926('0x13c')]=Preview;