8d7ee10fd485b0f8d32cb2097228773ce6c265e2
[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 _0xfd76=['custom:agentnoanswer','dialNoAnswerMaxRetry','[callProgressDetectingCustomer][logNoAnswer]','CONGESTION','outboundCongestionCallsDay','countcongestionretry','dialCongestionRetryFrequency','congestion','[callProgressDetectingCustomer][logCongestion]','[callProgressDetectingCustomer][logCongestionGlobal]','dialCongestionMaxRetry','CANCEL','outboundRejectCallsDay','countagentrejectretry','AgentReject','dialAgentRejectRetryFrequency','custom:agentreject','agentreject','[syncHangupRequest][logAgentReject]','dialAgentRejectMaxRetry','[callProgressDetectingCustomer][logAgentReject]','outboundAbandonedCallsDay','countabandonedretry','Abandoned','[callProgressDetectingCustomer][logAbandoned]','countabandonedetry','dialAbandonedMaxRety','outboundUnknownCallsDay','cause-txt','custom:amd','amd','[callProgressDetectingCustomer][hangupInAMD]','dialstatus','[callProgressDetectingCustomer][machine]','[default]','[Dialer][decrementTalking][no\x20Hangup][Preview]','[callProgressDetectingCustomer][logUnknown]','[callProgressDetectingCustomer][logUnknownGlobal]','[callProgressDetectingCustomer]','[originated][decrement][callProgressDetectingCustomer]','destlinkedid','isUndefined','object','reason','logAgent','createAgentHistory','[callProgressDetectingAgent][logNoSuch]','NoAnswer','[callProgressDetectingAgent][logNoAnswer]','[callProgressDetectingAgent][logBusy]','Congestion','[callProgressDetectingAgent][logCongestion]','AnswerAGI','[callProgressDetectingAgent][logAnswerAGI]','[originated][decrement][callProgressDetectingAgent]','[verifyAdditionalPhone]\x20','[swapAdditionalPhone]\x20','resolve','[incrementPreviewCounters]\x20','checkInBlack','Contact\x20is\x20undefined','lookAgent','isEmpty','Queue:\x20','\x20IdHopper:\x20','custom:agentcalled','called','Calling','[Preview][execCall][failure]','Call\x20failed','outboundBlacklistCallsDay','logBlacklist','createHistory','SIP/%s','status','reachable','unmonitored','run','unlock','unlockContact','active','pick','execRun','recallme','validateContact','isValid','checkIsBlackList','phone','[Preview][checkIsBlackList]','Call\x20unsuccessful','[Preview][getContactPreview]','[Preview][validateContact][Empty\x20Campaign]','Empty\x20Campaign','[Preview][validateContact][Trunk\x20not\x20working\x20correctly]','\x20Trunk\x20is\x20not\x20active','dialActive','[Preview][validateContact][Campaign\x20Active]','campaign\x20Name:\x20','\x20Not\x20Active','Is\x20Valid','SIP/%s/%s%s','dialPrefix','trim','dialCutDigit','substring','getCallerId','callerid','dialOriginateCallerIdName','getCallerIdRandom','dialRandomLastDigitCallerIdNumber','dialOriginateCallerIdNumber','originatecalleridname','extractCalleridName','originatecalleridnum','extractCalleridNumber','addVariables','Contact','merge','toLowerVariables','starttime','variablesAction','[originated][increment]','OriginateError','[originateFailure][logOriginateFailure]','actionid','isFailure','response','rejected','callProgressDetectingAgent','[syncHangup][talking]','cause','[syncHangup][talking][cause]','dialQueueProject','channelstate','transfer','syncDialEnd','destuniqueid','variables','filterKey','variable','keys','error','[syncVarSet][Preview]','inspect','transfertargetlinkedid','syncBlindTransfer','transfererlinkedid','exports','util','lodash','uuid','moment','ioredis','../../../config/environment','../../../config/logger','actionPreview','./rpcDb','../rpc/cmHopperAdditionalPhone','./action','./util/util','../dialer/utils','defaults','redis','socket.io-emitter','prototype','tail','campaignsPreview','voiceQueues','trunks','actions','agents','clockClearZombieChannels','originateresponse','syncOriginateResponse','bind','hangup','syncHangup','hanguprequest','syncHangupRequest','dialend','newexten','syncNewExten','syncVarSet','attendedtransfer','syncAttendedTransfer','blindtransfer','emit','info','[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event','voice:queue:%s','name','voice_queue_channel:remove','voice_queue_presence:remove','originated','pTalking','sendMessageOneNotActive','available','CAMPAIGN_STATUS','logger','\x20is\x20not\x20active','DEACTIVATED','[CampaignPreview]\x20Campaign\x20Queue:\x20','syncCampaigns','dialMethod','preview','booked','type','outbound','clearZombieChannels','recallMe','clearZombieChannel','enqueue','[clearZombieChannels][talking]','Queue','queue','originated:\x20','stringify','pTalking:\x20','contactId','UserId','VoiceQueueId','Action','channel','catch','message','decrementOriginate','[clearZombieChannel]','dialAnswer','decrementTalking','loggerError','[action]','size','hasOwnProperty','getContactRecallMe','agentReadyId','then','isNil','length','scheduledat','dialRecallMeTimeout','Agent','voicePause','logger2','[RecallMe]','disableContact','format','YYYY-MM-DD\x20HH:mm:ss','outboundReCallsDay','logCustomer','RecallInQueue','dialRecallInQueue','rescheduleContactInQueue','createBody','createCustomerHistory','[HistoryDialRecallInQueue][historyCatch]','RecallFailedTimeout','[HistoryRecallClose]','createCustomerFinal','[getContactRecallMe]','setMessage','IsNotLoggedIn','NO_AGENTS_LOGGED','isActive','isTrunkReachable','Trunk','TrunkBackup','UNREACHABLE_TRUNK','ACTIVE','callProgressDetectingCustomer','outboundNoSuchCallsDay','countnosuchnumberretry','NoSuchNumber','custom:agentnosuchnumber','nosuchnumber','[callProgressDetectingCustomer][logNoSuch]','verifyAdditionalPhones','additional','dialNoSuchNumberRetryFrequency','callAdditionalPhoneAfterMin','totalGlobal','dialGlobalMaxRetry','cloneAction','Global','[callProgressDetectingCustomer][logNoSuchGlobal]','rescheduleContact','scheduledAt','linkedid','idContact','ANSWER','responsetime','answertime','[syncHangup][talking][increment]','uniqueid','\x20Queue','custom:agentconnect','buildObj','acw','mandatoryDisposition','channelAgent','custom:agentcomplete','complete','outboundAnswerCallsDay','answered','[16]','countglobal','Answer','[callProgressDetectingCustomer][logAnswer]','[callProgressDetectingCustomer][logAnswerGlobal]','sumDuration','sumBillable','talktime','[syncHangup][talking][decrement]','BUSY','Busy','dialBusyRetryFrequency','custom:agentbusy','[callProgressDetectingCustomer][logBusy]','[callProgressDetectingCustomer][logBusyGlobal]','dialBusyMaxRetry','countbusyretry','unlockAgent','activeContact','incrementPreviewCounters','swapAdditionalPhones','outboundNoAnswerCallsDay','countnoanswerretry','dialNoAnswerRetryFrequency'];(function(_0x44924b,_0x43a341){var _0x3e0fc4=function(_0x5cd59e){while(--_0x5cd59e){_0x44924b['push'](_0x44924b['shift']());}};_0x3e0fc4(++_0x43a341);}(_0xfd76,0x1db));var _0x6fd7=function(_0x299979,_0x42a7fb){_0x299979=_0x299979-0x0;var _0x582310=_0xfd76[_0x299979];return _0x582310;};'use strict';var util=require(_0x6fd7('0x0'));var _=require(_0x6fd7('0x1'));var uuid=require(_0x6fd7('0x2'));var moment=require(_0x6fd7('0x3'));var Redis=require(_0x6fd7('0x4'));var config=require(_0x6fd7('0x5'));var logger=require(_0x6fd7('0x6'))('preview');var loggerAction=require(_0x6fd7('0x6'))(_0x6fd7('0x7'));var ami=require('../ami');var rpcDb=require(_0x6fd7('0x8'));var cmHopperAdditionalPhone=require(_0x6fd7('0x9'));var Action=require(_0x6fd7('0xa'));var ut=require(_0x6fd7('0xb'));var utils=require(_0x6fd7('0xc'));config['redis']=_[_0x6fd7('0xd')](config[_0x6fd7('0xe')],{'host':'localhost','port':0x18eb});var io=require(_0x6fd7('0xf'))(new Redis(config['redis']));var Sequence=function(){};Sequence[_0x6fd7('0x10')]['enqueue']=function(_0x2e03e0){this['tail']=this[_0x6fd7('0x11')]?this['tail']['finally'](_0x2e03e0):_0x2e03e0();};function Preview(_0x2cd189){this['sequence']=new Sequence();this[_0x6fd7('0x12')]=_0x2cd189[_0x6fd7('0x13')];this[_0x6fd7('0x14')]=_0x2cd189['trunks'];this[_0x6fd7('0x15')]={};this[_0x6fd7('0x16')]=_0x2cd189[_0x6fd7('0x16')];this[_0x6fd7('0x17')]=0x0;ami['on'](_0x6fd7('0x18'),this[_0x6fd7('0x19')][_0x6fd7('0x1a')](this));ami['on'](_0x6fd7('0x1b'),this[_0x6fd7('0x1c')][_0x6fd7('0x1a')](this));ami['on'](_0x6fd7('0x1d'),this[_0x6fd7('0x1e')][_0x6fd7('0x1a')](this));ami['on'](_0x6fd7('0x1f'),this['syncDialEnd'][_0x6fd7('0x1a')](this));ami['on'](_0x6fd7('0x20'),this[_0x6fd7('0x21')][_0x6fd7('0x1a')](this));ami['on']('varset',this[_0x6fd7('0x22')][_0x6fd7('0x1a')](this));ami['on'](_0x6fd7('0x23'),this[_0x6fd7('0x24')][_0x6fd7('0x1a')](this));ami['on'](_0x6fd7('0x25'),this['syncBlindTransfer']['bind'](this));this['loopCampaigns'](this[_0x6fd7('0x12')]);}function emit(_0x3d5008,_0x34288d,_0x22c2b0){io['to'](_0x3d5008)[_0x6fd7('0x26')](_0x34288d,_0x22c2b0);}function emitVoiceQueueChannelRemove(_0xa3fd7a){logger[_0x6fd7('0x27')](_0x6fd7('0x28'),JSON['stringify'](_0xa3fd7a));emit(util['format'](_0x6fd7('0x29'),_0xa3fd7a[_0x6fd7('0x2a')]),_0x6fd7('0x2b'),_0xa3fd7a);io['emit'](_0x6fd7('0x2c'),_0xa3fd7a);}function notSendMessagesQueue(_0x354961){if(_0x354961['sendMessageOneNotActive']){if(_0x354961[_0x6fd7('0x2d')]===0x0&&_0x354961[_0x6fd7('0x2e')]===0x0){_0x354961[_0x6fd7('0x2f')]=![];_0x354961[_0x6fd7('0x30')]=0x0;_0x354961['paused']=0x0;_0x354961['message']=utils[_0x6fd7('0x31')]['INACTIVE'];ut[_0x6fd7('0x32')]('[CampaignPreview]\x20Campaign\x20Queue:\x20',_0x354961[_0x6fd7('0x2a')]+_0x6fd7('0x33'));}else{_0x354961['message']=utils[_0x6fd7('0x31')][_0x6fd7('0x34')];ut[_0x6fd7('0x32')](_0x6fd7('0x35'),_0x354961[_0x6fd7('0x2a')]+'\x20is\x20deactivated');}}}Preview[_0x6fd7('0x10')]['loopCampaigns']=function(){var _0x45f097=this;setInterval(function(){_0x45f097[_0x6fd7('0x36')]();},0x7cf);};Preview[_0x6fd7('0x10')][_0x6fd7('0x36')]=function(){var _0x389ea5=this[_0x6fd7('0x12')];this[_0x6fd7('0x17')]+=0x1;for(var _0x18bc07 in _0x389ea5){if(_0x389ea5['hasOwnProperty'](_0x18bc07)&&(_0x389ea5[_0x18bc07][_0x6fd7('0x37')]===_0x6fd7('0x38')||_0x389ea5[_0x18bc07]['dialMethod']===_0x6fd7('0x39'))&&_0x389ea5[_0x18bc07][_0x6fd7('0x3a')]===_0x6fd7('0x3b')){if(this[_0x6fd7('0x17')]>0x7){this[_0x6fd7('0x17')]=0x0;this[_0x6fd7('0x3c')]();}}if(_0x389ea5['hasOwnProperty'](_0x18bc07)&&_0x389ea5[_0x18bc07]['dialMethod']===_0x6fd7('0x38')&&_0x389ea5[_0x18bc07][_0x6fd7('0x3a')]===_0x6fd7('0x3b')){if(_0x389ea5[_0x18bc07]['dialActive']){this['setMessage'](_0x389ea5[_0x18bc07]);if(_0x389ea5[_0x18bc07]['dialPreviewAutoRecallMe'])this[_0x6fd7('0x3d')](_0x389ea5[_0x18bc07]);}else{notSendMessagesQueue(_0x389ea5[_0x18bc07]);}}}};Preview['prototype'][_0x6fd7('0x3e')]=function(_0x2670c9){var _0x5e7b6f=this;this['sequence'][_0x6fd7('0x3f')](function(){if(!_['isNil'](_0x5e7b6f[_0x6fd7('0x15')][_0x2670c9])){loggerAction[_0x6fd7('0x27')](_0x6fd7('0x40'),_0x2670c9,_0x6fd7('0x41'),_0x5e7b6f[_0x6fd7('0x15')][_0x2670c9][_0x6fd7('0x42')],_0x6fd7('0x43'),JSON[_0x6fd7('0x44')](_0x5e7b6f[_0x6fd7('0x12')][_0x5e7b6f[_0x6fd7('0x15')][_0x2670c9][_0x6fd7('0x42')]]['originated']),_0x6fd7('0x45'),JSON[_0x6fd7('0x44')](_0x5e7b6f['campaignsPreview'][_0x5e7b6f[_0x6fd7('0x15')][_0x2670c9]['queue']][_0x6fd7('0x2e')]),JSON[_0x6fd7('0x44')](_0x5e7b6f['actions'][_0x2670c9]['dialAnswer']),JSON[_0x6fd7('0x44')](_['pick'](_0x5e7b6f[_0x6fd7('0x15')][_0x2670c9],[_0x6fd7('0x46'),_0x6fd7('0x47'),_0x6fd7('0x48'),'ListId'])));return ami[_0x6fd7('0x49')]({'action':'status','channel':_0x5e7b6f[_0x6fd7('0x15')][_0x2670c9][_0x6fd7('0x4a')]})[_0x6fd7('0x4b')](function(_0x22a906){if(_0x22a906[_0x6fd7('0x4c')]==='No\x20such\x20channel'){setTimeout(function(){if(_0x5e7b6f[_0x6fd7('0x15')][_0x2670c9]){utils[_0x6fd7('0x4d')](_0x5e7b6f['campaignsPreview'][_0x5e7b6f[_0x6fd7('0x15')][_0x2670c9][_0x6fd7('0x42')]],_0x6fd7('0x4e'));if(_0x5e7b6f[_0x6fd7('0x15')][_0x2670c9][_0x6fd7('0x4f')]===!![]){ut[_0x6fd7('0x50')](_0x5e7b6f[_0x6fd7('0x12')][_0x5e7b6f[_0x6fd7('0x15')][_0x2670c9][_0x6fd7('0x42')]],_0x6fd7('0x4e'));ut[_0x6fd7('0x51')]('[Dialer][checkChannel][pTalking][Preview]'+_0x2670c9,_0x5e7b6f[_0x6fd7('0x15')][_0x2670c9]['queue']);}ut[_0x6fd7('0x51')]('[Dialer][checkChannel][Preview]'+_0x2670c9,_0x5e7b6f['actions'][_0x2670c9][_0x6fd7('0x42')]);delete _0x5e7b6f['actions'][_0x2670c9];}},0x2328);}});}});};Preview['prototype'][_0x6fd7('0x3c')]=function(){var _0xe6a35d=this;loggerAction['info'](_0x6fd7('0x52'),_[_0x6fd7('0x53')](this[_0x6fd7('0x15')]));for(var _0x22d70a in this['actions']){if(_0xe6a35d[_0x6fd7('0x15')][_0x6fd7('0x54')](_0x22d70a)){_0xe6a35d[_0x6fd7('0x3e')](_0x22d70a);}}};Preview['prototype']['recallMe']=function(_0x289a55){var _0x4fda6e=this;rpcDb[_0x6fd7('0x55')](_0x289a55['id'],ut[_0x6fd7('0x56')](this[_0x6fd7('0x16')]))[_0x6fd7('0x57')](function(_0x285768){if(!_[_0x6fd7('0x58')](_0x285768)){for(var _0x35490a=0x0;_0x35490a<_0x285768[_0x6fd7('0x59')];_0x35490a+=0x1){if(ut['getDiff'](_0x285768[_0x35490a][_0x6fd7('0x5a')])<_0x289a55[_0x6fd7('0x5b')]*0x3c){if(_0x285768[_0x35490a]['Agent']&&!_0x285768[_0x35490a][_0x6fd7('0x5c')][_0x6fd7('0x5d')]){_0x4fda6e['run'](_0x285768[_0x35490a]['id'])[_0x6fd7('0x57')](ut[_0x6fd7('0x5e')](_0x6fd7('0x5f')))[_0x6fd7('0x4b')](ut[_0x6fd7('0x5e')](_0x6fd7('0x5f')));}else{rpcDb[_0x6fd7('0x60')](_0x285768[_0x35490a]['id']);}}else{var _0x6c55c3=new Action(_0x285768[_0x35490a],_0x289a55);_0x6c55c3['starttime']=moment()[_0x6fd7('0x61')](_0x6fd7('0x62'));_0x289a55[_0x6fd7('0x63')]+=0x1;ut[_0x6fd7('0x64')](_0x6c55c3,0x17,_0x6fd7('0x65'));if(_0x289a55[_0x6fd7('0x66')]){rpcDb[_0x6fd7('0x67')](ut[_0x6fd7('0x68')](_0x285768[_0x35490a]));rpcDb[_0x6fd7('0x69')](_0x6c55c3,_0x6fd7('0x6a'));}else{ut[_0x6fd7('0x64')](_0x6c55c3,0x16,_0x6fd7('0x6b'));rpcDb[_0x6fd7('0x69')](_0x6c55c3,_0x6fd7('0x6c'));rpcDb[_0x6fd7('0x6d')](_0x6c55c3,_0x6fd7('0x6c'));}}}}})[_0x6fd7('0x4b')](ut['logger2'](_0x6fd7('0x6e')));};Preview[_0x6fd7('0x10')][_0x6fd7('0x6f')]=function(_0x41093c){_0x41093c[_0x6fd7('0x2f')]=!![];if(ut[_0x6fd7('0x70')](_0x41093c['loggedIn'])){_0x41093c[_0x6fd7('0x4c')]=utils[_0x6fd7('0x31')][_0x6fd7('0x71')];}else if(!ut[_0x6fd7('0x72')](_0x41093c['dialActive'])){_0x41093c[_0x6fd7('0x4c')]=utils[_0x6fd7('0x31')]['INACTIVE'];}else if(!this[_0x6fd7('0x73')](_0x41093c[_0x6fd7('0x74')])){if(!this[_0x6fd7('0x73')](_0x41093c[_0x6fd7('0x75')])){_0x41093c[_0x6fd7('0x4c')]=utils['CAMPAIGN_STATUS'][_0x6fd7('0x76')];}else{_0x41093c[_0x6fd7('0x4c')]=utils[_0x6fd7('0x31')][_0x6fd7('0x77')];}}else{_0x41093c[_0x6fd7('0x4c')]=utils[_0x6fd7('0x31')][_0x6fd7('0x77')];}};Preview[_0x6fd7('0x10')][_0x6fd7('0x78')]=function(_0x3e1b41,_0x1975cc,_0x32a2ea){var _0x39c7ba=this;var _0xb2986a=this['actions'][_0x1975cc];var _0x22f773=this[_0x6fd7('0x12')][_0xb2986a[_0x6fd7('0x42')]];var _0x1b02ec;var _0x358526=![];var _0x4e7566=0x2;var _0xbb57e3=0x3;if(_0x22f773){switch(_0x32a2ea){case'1':_0x22f773[_0x6fd7('0x79')]+=0x1;_0xb2986a[_0x6fd7('0x7a')]+=0x1;_0xb2986a['countglobal']=ut['totalGlobal'](_0xb2986a);ut['logCustomer'](_0xb2986a,0x0,_0x6fd7('0x7b'));ami[_0x6fd7('0x26')](_0x6fd7('0x7c'),ut['buildObj'](_0xb2986a,_0x6fd7('0x7d')));rpcDb[_0x6fd7('0x69')](_0xb2986a,_0x6fd7('0x7e'));_0x39c7ba[_0x6fd7('0x7f')](_0xb2986a,'0',_0x22f773)[_0x6fd7('0x57')](function(_0x513ab3){_0x358526=_0x513ab3[_0x6fd7('0x80')]==0x1;_0x4e7566=_0x22f773[_0x6fd7('0x81')];_0xbb57e3=_0x22f773[_0x6fd7('0x82')];if(!_0x358526){if(ut[_0x6fd7('0x83')](_0xb2986a)>=_0x22f773[_0x6fd7('0x84')]){_0x1b02ec=ut[_0x6fd7('0x85')](_0xb2986a,0xf,_0x6fd7('0x86'));rpcDb[_0x6fd7('0x6d')](_0x1b02ec,_0x6fd7('0x87'));}else{if(_0xb2986a[_0x6fd7('0x7a')]>=_0x22f773['dialNoSuchNumberMaxRetry']){rpcDb['createCustomerFinal'](_0xb2986a,_0x6fd7('0x87'));}else{rpcDb[_0x6fd7('0x88')](ut[_0x6fd7('0x89')](_0xb2986a,_0x6fd7('0x7a'),_0x22f773[_0x6fd7('0x81')]),_0xb2986a['unlockAgent'],_0xb2986a['activeContact']);}}delete this[_0x6fd7('0x15')][_0x3e1b41[_0x6fd7('0x8a')]];}else{_0xb2986a[_0x6fd7('0x7a')]++;logger[_0x6fd7('0x27')]('actioncountonusuch',_0xb2986a[_0x6fd7('0x7a')]);logger['info']('id',_0xb2986a[_0x6fd7('0x8b')]);_0x39c7ba['incrementPreviewCounters']({'id':_0xb2986a['idContact'],'field':{'countnosuchnumberretry':_0xb2986a[_0x6fd7('0x7a')]}})[_0x6fd7('0x57')](function(){_0x39c7ba['swapAdditionalPhones'](_0xb2986a,_0x4e7566,_0xbb57e3)[_0x6fd7('0x57')](function(){});});}});break;case _0x6fd7('0x8c'):var _0xab02f=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');_0xb2986a[_0x6fd7('0x8d')]=_0xab02f;_0xb2986a[_0x6fd7('0x8e')]=_0xab02f;_0xb2986a[_0x6fd7('0x4f')]=!![];_0x22f773[_0x6fd7('0x2e')]+=0x1;logger[_0x6fd7('0x27')](_0x6fd7('0x8f'),_0xb2986a[_0x6fd7('0x90')],_0x6fd7('0x91'),_0x22f773[_0x6fd7('0x2a')],_0x6fd7('0x45'),_0x22f773[_0x6fd7('0x2e')]);ami[_0x6fd7('0x26')](_0x6fd7('0x92'),ut[_0x6fd7('0x93')](_0xb2986a,'connect',this[_0x6fd7('0x12')][_0xb2986a[_0x6fd7('0x42')]]));if(_0x22f773[_0x6fd7('0x94')]||_0x22f773[_0x6fd7('0x95')]){ami['emit']('custom:agentConnectPreview',{'queue':_0xb2986a['queue'],'interface':_0xb2986a[_0x6fd7('0x96')],'uniqueid':_0xb2986a['uniqueid']});}break;case'16':ami[_0x6fd7('0x26')](_0x6fd7('0x97'),ut[_0x6fd7('0x93')](_0xb2986a,_0x6fd7('0x98'),this[_0x6fd7('0x12')][_0xb2986a[_0x6fd7('0x42')]]));emitVoiceQueueChannelRemove(ut[_0x6fd7('0x93')](_0xb2986a,'complete'));_0x22f773[_0x6fd7('0x99')]+=0x1;_0x22f773['total']+=0x1;_0x22f773[_0x6fd7('0x9a')]+=0x1;ut[_0x6fd7('0x50')](_0x22f773,_0x6fd7('0x9b'));_0xb2986a[_0x6fd7('0x9c')]=ut[_0x6fd7('0x83')](_0xb2986a);ut['logCustomer'](_0xb2986a,0x4,_0x6fd7('0x9d'));rpcDb[_0x6fd7('0x69')](_0xb2986a,_0x6fd7('0x9e'));rpcDb[_0x6fd7('0x6d')](_0xb2986a,_0x6fd7('0x9f'));rpcDb['crateCustomerReportQueue'](_0xb2986a);_0x22f773[_0x6fd7('0xa0')]+=_0xb2986a['talktime'];_0x22f773[_0x6fd7('0xa1')]+=_0xb2986a[_0x6fd7('0xa2')];logger['info'](_0x6fd7('0xa3'),_0xb2986a['uniqueid'],_0x6fd7('0x91'),_0x22f773[_0x6fd7('0x2a')],_0x6fd7('0x45'),_0x22f773[_0x6fd7('0x2e')]);delete this['actions'][_0x3e1b41[_0x6fd7('0x8a')]];break;case _0x6fd7('0xa4'):_0x22f773['outboundBusyCallsDay']+=0x1;_0xb2986a['countbusyretry']+=0x1;_0xb2986a['countglobal']=ut['totalGlobal'](_0xb2986a);ut['logCustomer'](_0xb2986a,0x5,_0x6fd7('0xa5'));_0x4e7566=_0x22f773[_0x6fd7('0xa6')];_0xbb57e3=_0x22f773[_0x6fd7('0x82')];ami[_0x6fd7('0x26')](_0x6fd7('0xa7'),ut[_0x6fd7('0x93')](_0xb2986a,'busy'));rpcDb[_0x6fd7('0x69')](_0xb2986a,_0x6fd7('0xa8'));_0x39c7ba[_0x6fd7('0x7f')](_0xb2986a,'5',_0x22f773)[_0x6fd7('0x57')](function(_0x524f97){_0x358526=_0x524f97[_0x6fd7('0x80')]==0x1;if(!_0x358526){if(ut[_0x6fd7('0x83')](_0xb2986a)>=_0x22f773[_0x6fd7('0x84')]){_0x1b02ec=ut[_0x6fd7('0x85')](_0xb2986a,0xf,_0x6fd7('0x86'));rpcDb[_0x6fd7('0x6d')](_0x1b02ec,_0x6fd7('0xa9'));}else{if(_0xb2986a['countbusyretry']>=_0x22f773[_0x6fd7('0xaa')]){rpcDb[_0x6fd7('0x6d')](_0xb2986a,_0x6fd7('0xa8'));}else{rpcDb[_0x6fd7('0x88')](ut[_0x6fd7('0x89')](_0xb2986a,_0x6fd7('0xab'),_0x22f773['dialBusyRetryFrequency']),_0xb2986a[_0x6fd7('0xac')],_0xb2986a[_0x6fd7('0xad')]);}}}else{_0xb2986a[_0x6fd7('0xab')]++;_0x39c7ba[_0x6fd7('0xae')]({'id':_0xb2986a[_0x6fd7('0x8b')],'field':{'countbusyretry':_0xb2986a[_0x6fd7('0xab')]}})[_0x6fd7('0x57')](function(){_0x39c7ba[_0x6fd7('0xaf')](_0xb2986a,_0x4e7566,_0xbb57e3)[_0x6fd7('0x57')](function(){});});}});break;case'NOANSWER':_0x22f773[_0x6fd7('0xb0')]+=0x1;_0xb2986a[_0x6fd7('0xb1')]+=0x1;_0xb2986a[_0x6fd7('0x9c')]=ut[_0x6fd7('0x83')](_0xb2986a);ut['logCustomer'](_0xb2986a,0x3,'NoAnswer');_0x4e7566=_0x22f773[_0x6fd7('0xb2')];_0xbb57e3=_0x22f773[_0x6fd7('0x82')];var _0x477afe=ut['buildNoAnswerEventPayload'](_0xb2986a,_0x22f773);ami['emit'](_0x6fd7('0xb3'),_0x477afe);rpcDb[_0x6fd7('0x69')](_0xb2986a,'[callProgressDetectingCustomer][logNoAnswer]');_0x39c7ba[_0x6fd7('0x7f')](_0xb2986a,'3',_0x22f773)[_0x6fd7('0x57')](function(_0x22b52e){_0x358526=_0x22b52e[_0x6fd7('0x80')]==0x1;if(!_0x358526){if(ut[_0x6fd7('0x83')](_0xb2986a)>=_0x22f773[_0x6fd7('0x84')]){_0x1b02ec=ut[_0x6fd7('0x85')](_0xb2986a,0xf,_0x6fd7('0x86'));rpcDb['createCustomerFinal'](_0x1b02ec,'[callProgressDetectingCustomer][logNoAnswerGlobal]');}else{if(_0xb2986a[_0x6fd7('0xb1')]>=_0x22f773[_0x6fd7('0xb4')]){rpcDb[_0x6fd7('0x6d')](_0xb2986a,_0x6fd7('0xb5'));}else{rpcDb['rescheduleContact'](ut[_0x6fd7('0x89')](_0xb2986a,_0x6fd7('0xb1'),_0x22f773[_0x6fd7('0xb2')]),_0xb2986a[_0x6fd7('0xac')],_0xb2986a['activeContact']);}}}else{_0xb2986a[_0x6fd7('0xb1')]++;_0x39c7ba['incrementPreviewCounters']({'id':_0xb2986a[_0x6fd7('0x8b')],'field':{'countnoanswerretry':_0xb2986a[_0x6fd7('0xb1')]}})[_0x6fd7('0x57')](function(){_0x39c7ba['swapAdditionalPhones'](_0xb2986a,_0x4e7566,_0xbb57e3)[_0x6fd7('0x57')](function(){});});}});break;case _0x6fd7('0xb6'):_0x22f773[_0x6fd7('0xb7')]+=0x1;_0xb2986a[_0x6fd7('0xb8')]+=0x1;_0xb2986a[_0x6fd7('0x9c')]=ut[_0x6fd7('0x83')](_0xb2986a);ut[_0x6fd7('0x64')](_0xb2986a,0x8,'Congestion');_0x4e7566=_0x22f773[_0x6fd7('0xb9')];_0xbb57e3=_0x22f773[_0x6fd7('0x82')];ami[_0x6fd7('0x26')]('custom:agentcongestion',ut['buildObj'](_0xb2986a,_0x6fd7('0xba')));rpcDb[_0x6fd7('0x69')](_0xb2986a,_0x6fd7('0xbb'));_0x39c7ba[_0x6fd7('0x7f')](_0xb2986a,'8',_0x22f773)[_0x6fd7('0x57')](function(_0x1f5b23){_0x358526=_0x1f5b23[_0x6fd7('0x80')]==0x1;if(!_0x358526){if(ut[_0x6fd7('0x83')](_0xb2986a)>=_0x22f773[_0x6fd7('0x84')]){_0x1b02ec=ut[_0x6fd7('0x85')](_0xb2986a,0xf,_0x6fd7('0x86'));rpcDb['createCustomerFinal'](_0x1b02ec,_0x6fd7('0xbc'));}else{if(_0xb2986a['countcongestionretry']>=_0x22f773[_0x6fd7('0xbd')]){rpcDb[_0x6fd7('0x6d')](_0xb2986a,_0x6fd7('0xbb'));}else{rpcDb[_0x6fd7('0x88')](ut[_0x6fd7('0x89')](_0xb2986a,_0x6fd7('0xb8'),_0x22f773['dialBusyRetryFrequency']),_0xb2986a['unlockAgent'],_0xb2986a[_0x6fd7('0xad')]);}}}else{_0xb2986a[_0x6fd7('0xb8')]++;_0x39c7ba[_0x6fd7('0xae')]({'id':_0xb2986a['idContact'],'field':{'countcongestionretry':_0xb2986a[_0x6fd7('0xb8')]}})['then'](function(){_0x39c7ba[_0x6fd7('0xaf')](_0xb2986a,_0x4e7566,_0xbb57e3)[_0x6fd7('0x57')](function(){});});}});break;case _0x6fd7('0xbe'):_0x22f773[_0x6fd7('0xbf')]+=0x1;_0xb2986a[_0x6fd7('0xc0')]+=0x1;_0xb2986a[_0x6fd7('0x9c')]=ut[_0x6fd7('0x83')](_0xb2986a);ut[_0x6fd7('0x64')](_0xb2986a,0x14,_0x6fd7('0xc1'));_0x4e7566=_0x22f773[_0x6fd7('0xc2')];_0xbb57e3=_0x22f773[_0x6fd7('0x82')];ami[_0x6fd7('0x26')](_0x6fd7('0xc3'),ut[_0x6fd7('0x93')](_0xb2986a,_0x6fd7('0xc4')));rpcDb[_0x6fd7('0x69')](_0xb2986a,_0x6fd7('0xc5'));_0x39c7ba['verifyAdditionalPhones'](_0xb2986a,'20',_0x22f773)[_0x6fd7('0x57')](function(_0x1f4954){_0x358526=_0x1f4954[_0x6fd7('0x80')]==0x1;if(!_0x358526){if(ut[_0x6fd7('0x83')](_0xb2986a)>=_0x22f773[_0x6fd7('0x84')]){_0x1b02ec=ut[_0x6fd7('0x85')](_0xb2986a,0x14,_0x6fd7('0xc1'));rpcDb[_0x6fd7('0x6d')](_0x1b02ec,'[callProgressDetectingCustomer][logAgentReject]');}else{if(_0xb2986a['countagentrejectretry']>=_0x22f773[_0x6fd7('0xc6')]){rpcDb[_0x6fd7('0x6d')](_0xb2986a,_0x6fd7('0xc7'));}else{rpcDb['rescheduleContact'](ut[_0x6fd7('0x89')](_0xb2986a,_0x6fd7('0xc0'),_0x22f773[_0x6fd7('0xc2')]),_0xb2986a[_0x6fd7('0xac')],_0xb2986a[_0x6fd7('0xad')]);}}}else{_0xb2986a[_0x6fd7('0xb1')]++;_0x39c7ba[_0x6fd7('0xae')]({'id':_0xb2986a['idContact'],'field':{'countnoanswerretry':_0xb2986a['countnoanswerretry']}})[_0x6fd7('0x57')](function(){_0x39c7ba[_0x6fd7('0xaf')](_0xb2986a,_0x4e7566,_0xbb57e3)['then'](function(){});});}});break;case'ABANDONED':_0x22f773[_0x6fd7('0xc8')]+=0x1;_0xb2986a[_0x6fd7('0xc9')]+=0x1;_0xb2986a[_0x6fd7('0x9c')]=ut[_0x6fd7('0x83')](_0xb2986a);ut[_0x6fd7('0x64')](_0xb2986a,0xb,_0x6fd7('0xca'));rpcDb['createCustomerHistory'](_0xb2986a,_0x6fd7('0xcb'));_0x39c7ba[_0x6fd7('0x7f')](_0xb2986a,'11',_0x22f773)[_0x6fd7('0x57')](function(_0x21e702){_0x358526=_0x21e702[_0x6fd7('0x80')]==0x1;if(!_0x358526){if(ut['totalGlobal'](_0xb2986a)>=_0x22f773[_0x6fd7('0x84')]){_0x1b02ec=ut[_0x6fd7('0x85')](_0xb2986a,0xf,_0x6fd7('0x86'));rpcDb[_0x6fd7('0x6d')](_0x1b02ec,_0x6fd7('0xcb'));}else{if(_0xb2986a[_0x6fd7('0xcc')]>=_0x22f773[_0x6fd7('0xcd')]){rpcDb[_0x6fd7('0x6d')](_0xb2986a,_0x6fd7('0xcb'));}else{rpcDb[_0x6fd7('0x88')](ut[_0x6fd7('0x89')](_0xb2986a,_0x6fd7('0xc9'),_0x22f773['dialAbandonedRetryFrequency']),_0xb2986a[_0x6fd7('0xac')],_0xb2986a[_0x6fd7('0xad')]);}}}else{_0xb2986a[_0x6fd7('0xb1')]++;_0x39c7ba[_0x6fd7('0xae')]({'id':_0xb2986a[_0x6fd7('0x8b')],'field':{'countnoanswerretry':_0xb2986a[_0x6fd7('0xb1')]}})[_0x6fd7('0x57')](function(){_0x39c7ba[_0x6fd7('0xaf')](_0xb2986a,_0x4e7566,_0xbb57e3)['then'](function(){});});}});break;case'18':_0x22f773[_0x6fd7('0xce')]+=0x1;_0xb2986a['countmachineretry']+=0x1;_0xb2986a[_0x6fd7('0x9c')]=ut[_0x6fd7('0x83')](_0xb2986a);ut['logCustomer'](_0xb2986a,0x12,_0x3e1b41[_0x6fd7('0xcf')]||_0x3e1b41['dialstatus']);ami[_0x6fd7('0x26')](_0x6fd7('0xd0'),ut[_0x6fd7('0x93')](_0xb2986a,_0x6fd7('0xd1')));rpcDb[_0x6fd7('0x69')](_0xb2986a,_0x6fd7('0xd2'));_0x39c7ba[_0x6fd7('0x7f')](_0xb2986a,'18',_0x22f773)[_0x6fd7('0x57')](function(_0x113f19){_0x358526=_0x113f19[_0x6fd7('0x80')]==0x1;if(!_0x358526){if(ut[_0x6fd7('0x83')](_0xb2986a)>=_0x22f773[_0x6fd7('0x84')]){_0x1b02ec=ut[_0x6fd7('0x85')](_0xb2986a,0x12,_0x6fd7('0x86'));rpcDb[_0x6fd7('0x6d')](_0x1b02ec,'[callProgressDetectingCustomer][hangupInAMD]');}else{rpcDb['createCustomerFinal'](_0xb2986a,'[callProgressDetectingCustomer][hangupInAMD]');}}else{_0xb2986a[_0x6fd7('0xb1')]++;_0x39c7ba[_0x6fd7('0xae')]({'id':_0xb2986a[_0x6fd7('0x8b')],'field':{'countnoanswerretry':_0xb2986a[_0x6fd7('0xb1')]}})[_0x6fd7('0x57')](function(){_0x39c7ba[_0x6fd7('0xaf')](_0xb2986a,_0x4e7566,_0xbb57e3)['then'](function(){});});}});delete this['actions'][_0x3e1b41[_0x6fd7('0x8a')]];break;case'19':_0x22f773[_0x6fd7('0xce')]+=0x1;_0xb2986a['countglobal']=ut[_0x6fd7('0x83')](_0xb2986a);ut['logCustomer'](_0xb2986a,0x13,_0x3e1b41[_0x6fd7('0xcf')]||_0x3e1b41[_0x6fd7('0xd3')]);ami[_0x6fd7('0x26')](_0x6fd7('0xd0'),ut['buildObj'](_0xb2986a,'amd'));rpcDb[_0x6fd7('0x69')](_0xb2986a,_0x6fd7('0xd4'));_0x39c7ba[_0x6fd7('0x7f')](_0xb2986a,'18',_0x22f773)[_0x6fd7('0x57')](function(_0x100b42){_0x358526=_0x100b42[_0x6fd7('0x80')]==0x1;if(!_0x358526){if(ut['totalGlobal'](_0xb2986a)>=_0x22f773[_0x6fd7('0x84')]){_0x1b02ec=ut[_0x6fd7('0x85')](_0xb2986a,0xf,'Global');rpcDb['createCustomerFinal'](_0x1b02ec,_0x6fd7('0xd4'));}else{rpcDb[_0x6fd7('0x6d')](_0xb2986a,_0x6fd7('0xd4'));}}else{_0xb2986a[_0x6fd7('0xb1')]++;_0x39c7ba[_0x6fd7('0xae')]({'id':_0xb2986a[_0x6fd7('0x8b')],'field':{'countnoanswerretry':_0xb2986a[_0x6fd7('0xb1')]}})['then'](function(){_0x39c7ba[_0x6fd7('0xaf')](_0xb2986a,_0x4e7566,_0xbb57e3)[_0x6fd7('0x57')](function(){});});}});delete this[_0x6fd7('0x15')][_0x3e1b41['linkedid']];break;default:if(_0xb2986a[_0x6fd7('0x4f')]){ut['decrementTalking'](_0x22f773,_0x6fd7('0xd5'));ut['loggerError'](_0x6fd7('0xd6')+_0x22f773[_0x6fd7('0x2a')],_0x3e1b41);}_0x22f773[_0x6fd7('0xce')]+=0x1;_0xb2986a[_0x6fd7('0x9c')]=ut[_0x6fd7('0x83')](_0xb2986a);ut[_0x6fd7('0x64')](_0xb2986a,0xc,_0x3e1b41[_0x6fd7('0xcf')]||_0x3e1b41[_0x6fd7('0xd3')]);_0x4e7566=_0x22f773[_0x6fd7('0xc2')];_0xbb57e3=_0x22f773['callAdditionalPhoneAfterMin'];rpcDb[_0x6fd7('0x69')](_0xb2986a,_0x6fd7('0xd7'));_0x39c7ba[_0x6fd7('0x7f')](_0xb2986a,'20',_0x22f773)[_0x6fd7('0x57')](function(_0x21504f){_0x358526=_0x21504f[_0x6fd7('0x80')]==0x1;if(!_0x358526){if(ut['totalGlobal'](_0xb2986a)>=_0x22f773[_0x6fd7('0x84')]){_0x1b02ec=ut[_0x6fd7('0x85')](_0xb2986a,0xf,_0x6fd7('0x86'));rpcDb['createCustomerFinal'](_0x1b02ec,_0x6fd7('0xd8'));}else{rpcDb[_0x6fd7('0x6d')](_0xb2986a,'[callProgressDetectingCustomer][logUnknownGlobal]');}delete this[_0x6fd7('0x15')][_0x3e1b41[_0x6fd7('0x8a')]];}else{_0x39c7ba[_0x6fd7('0xaf')](_0xb2986a,_0x4e7566,_0xbb57e3)[_0x6fd7('0x57')](function(){});}});}if(!(_0xb2986a[_0x6fd7('0x4f')]&&_0x32a2ea==='16')){utils[_0x6fd7('0x4d')](_0x22f773,_0x6fd7('0xd9'));logger[_0x6fd7('0x27')](_0x6fd7('0xda'),_0xb2986a[_0x6fd7('0x90')],'\x20Queue',_0x22f773[_0x6fd7('0x2a')],'originated:\x20',_0x22f773[_0x6fd7('0x2d')]);}if(_0x32a2ea!==_0x6fd7('0x8c')){delete this['actions'][_0x3e1b41[_0x6fd7('0x8a')]];delete this[_0x6fd7('0x15')][_0x3e1b41[_0x6fd7('0xdb')]];}_0x22f773['queueSummaryCountersUpdated']=!![];}};Preview[_0x6fd7('0x10')]['callProgressDetectingAgent']=function(_0x3ebf92,_0x2b4a3c,_0xc5480a){if(_[_0x6fd7('0xdc')](_0x2b4a3c)&&_0x6fd7('0xdd')!==typeof _0x2b4a3c){return;}if(_[_0x6fd7('0xdc')](_0xc5480a)&&_0x6fd7('0xdd')!==typeof _0xc5480a){return;}switch(_0xc5480a[_0x6fd7('0xde')]){case'0':ut[_0x6fd7('0xdf')](_0x3ebf92,0x0,'NoSuchNumber');rpcDb[_0x6fd7('0xe0')](_0x3ebf92,_0x6fd7('0xe1'));break;case'3':ut[_0x6fd7('0xdf')](_0x3ebf92,0x3,_0x6fd7('0xe2'));rpcDb['createAgentHistory'](_0x3ebf92,_0x6fd7('0xe3'));break;case'5':ut[_0x6fd7('0xdf')](_0x3ebf92,0x5,_0x6fd7('0xa5'));rpcDb[_0x6fd7('0xe0')](_0x3ebf92,_0x6fd7('0xe4'));break;case'8':ut[_0x6fd7('0xdf')](_0x3ebf92,0x8,_0x6fd7('0xe5'));rpcDb[_0x6fd7('0xe0')](_0x3ebf92,_0x6fd7('0xe6'));break;case'22':ut[_0x6fd7('0xdf')](_0x3ebf92,0x16,_0x6fd7('0xe7'));rpcDb['createAgentHistory'](_0x3ebf92,_0x6fd7('0xe8'));break;default:ut[_0x6fd7('0xdf')](_0x3ebf92,0xc,_0xc5480a[_0x6fd7('0xde')]);rpcDb[_0x6fd7('0xe0')](_0x3ebf92,_0x6fd7('0xe6'));}utils['decrementOriginate'](_0x2b4a3c,'[callProgressDetectingAgent]');logger[_0x6fd7('0x27')](_0x6fd7('0xe9'),_0x3ebf92[_0x6fd7('0x90')],_0x6fd7('0x91'),_0x2b4a3c[_0x6fd7('0x2a')],_0x6fd7('0x43'),_0x2b4a3c['originated']);delete this[_0x6fd7('0x15')][_0x3ebf92[_0x6fd7('0x90')]];};Preview['prototype'][_0x6fd7('0x7f')]=function(_0x3d98ea,_0x219311,_0x4f025d){return cmHopperAdditionalPhone[_0x6fd7('0x7f')](_0x3d98ea,_0x219311,_0x4f025d)['catch'](logger[_0x6fd7('0x27')](_0x6fd7('0xea')));};Preview[_0x6fd7('0x10')][_0x6fd7('0xaf')]=function(_0x5391c7,_0x19cc17,_0x2590c3){return cmHopperAdditionalPhone[_0x6fd7('0xaf')](_0x5391c7,_0x19cc17,_0x2590c3)[_0x6fd7('0x4b')](logger[_0x6fd7('0x27')](_0x6fd7('0xeb')));};Preview[_0x6fd7('0x10')][_0x6fd7('0xae')]=function(_0x3f4d25){return Promise[_0x6fd7('0xec')]()[_0x6fd7('0x57')](cmHopperAdditionalPhone[_0x6fd7('0xae')](_0x3f4d25))[_0x6fd7('0x4b')](logger[_0x6fd7('0x27')](_0x6fd7('0xed')));};Preview[_0x6fd7('0x10')][_0x6fd7('0xee')]=function(_0x5f3e3d,_0x24f718,_0x2e4e19,_0x420b14,_0x50b9ea){var _0x961449=this;return new Promise(function(_0x12c005,_0x12045d){if(_['isNil'](_0x24f718)||_[_0x6fd7('0x58')](_0x24f718['Contact'])||_['isNil'](_0x24f718['phone'])||_[_0x6fd7('0x58')](_0x24f718['VoiceQueueId'])){_0x12045d(ut[_0x6fd7('0x4c')](_0x6fd7('0xef'),_0x420b14,_0x50b9ea));return;}var _0x774500=uuid['v4']();var _0x9054a3=_0x961449[_0x6fd7('0x12')][_0x24f718['Queue'][_0x6fd7('0x2a')]];var _0x2929f7=_0x2e4e19?_0x961449[_0x6fd7('0x16')][_0x2e4e19]['id']:undefined;_0x961449[_0x6fd7('0x15')][_0x774500]=new Action(_0x24f718,_0x9054a3,_0x774500,_0x2e4e19,_0x2929f7);var _0xd5606d=_0x961449[_0x6fd7('0x15')][_0x774500];_0xd5606d[_0x6fd7('0xac')]=_0x420b14;_0xd5606d['activeContact']=_0x50b9ea;_0xd5606d[_0x6fd7('0xf0')]=_0x2e4e19;if(_[_0x6fd7('0xf1')](_0x5f3e3d)){_0x961449['execCall'](_0xd5606d,_0x9054a3,_0x24f718,_0x2e4e19)[_0x6fd7('0x57')](function(_0x13a1ca){logger[_0x6fd7('0x27')]('[Preview][execCall][success]',_0x6fd7('0xf2')+_0xd5606d[_0x6fd7('0x42')]+_0x6fd7('0xf3')+_0xd5606d[_0x6fd7('0x8b')],JSON[_0x6fd7('0x44')](_0x13a1ca));ami[_0x6fd7('0x26')](_0x6fd7('0xf4'),ut[_0x6fd7('0x93')](_0xd5606d,_0x6fd7('0xf5'),_0x961449[_0x6fd7('0x12')][_0xd5606d[_0x6fd7('0x42')]]));_0x12c005(ut['message'](_0x6fd7('0xf6')));})['catch'](function(_0x581603){ut[_0x6fd7('0x32')](_0x6fd7('0xf7'),_0x581603);_0x12045d(ut['message'](_0x6fd7('0xf8'),_0x420b14,_0x50b9ea));});}else{_0x9054a3[_0x6fd7('0xf9')]+=0x1;ut[_0x6fd7('0xfa')](_0xd5606d);rpcDb[_0x6fd7('0xfb')](_0xd5606d,'[Blacklist][error]');delete _0x961449[_0x6fd7('0x15')][_0x774500];_0x12045d(ut[_0x6fd7('0x4c')]('Contact\x20in\x20black\x20List',_0x420b14,_0x50b9ea));}});};Preview[_0x6fd7('0x10')][_0x6fd7('0x73')]=function(_0x4908ea){return!_[_0x6fd7('0x58')](_0x4908ea)&&!_['isNil'](_0x4908ea[_0x6fd7('0x2a')])&&!_[_0x6fd7('0x58')](_0x4908ea['active'])&&_0x4908ea['active']&&!_[_0x6fd7('0x58')](this[_0x6fd7('0x14')][util['format'](_0x6fd7('0xfc'),_0x4908ea[_0x6fd7('0x2a')])])&&!_['isNil'](this[_0x6fd7('0x14')][util['format']('SIP/%s',_0x4908ea['name'])][_0x6fd7('0xfd')])&&(this[_0x6fd7('0x14')][util['format']('SIP/%s',_0x4908ea[_0x6fd7('0x2a')])][_0x6fd7('0xfd')]===_0x6fd7('0xfe')||this[_0x6fd7('0x14')][util['format']('SIP/%s',_0x4908ea['name'])][_0x6fd7('0xfd')]===_0x6fd7('0xff'));};Preview[_0x6fd7('0x10')][_0x6fd7('0x100')]=function(_0x871999,_0xc4e48e){return this['execRun'](_0x871999,_0xc4e48e)[_0x6fd7('0x57')](function(_0x2839cd){return _['pick'](_0x2839cd,[_0x6fd7('0x4c')]);})[_0x6fd7('0x4b')](function(_0x1720f7){if(_0x1720f7[_0x6fd7('0x101')]){rpcDb[_0x6fd7('0x102')](_0x871999);}if(_0x1720f7[_0x6fd7('0x103')]){rpcDb[_0x6fd7('0x60')](_0x871999);}throw _[_0x6fd7('0x104')](_0x1720f7,[_0x6fd7('0x4c')]);});};Preview[_0x6fd7('0x10')][_0x6fd7('0x105')]=function(_0x1593e7,_0x4684c9){var _0x29a7a8=this;var _0xe0b5ff,_0x59d96d;return rpcDb['getContactPreview'](_0x1593e7)[_0x6fd7('0x57')](function(_0x59a555){if(!_['isNil'](_0x59a555[0x0])){_0x59d96d=_0x59a555[0x0][_0x6fd7('0x106')]?![]:!![];_0xe0b5ff=_0x59a555[0x0][_0x6fd7('0x106')]?!![]:![];_0xe0b5ff=_0x4684c9?!![]:_0xe0b5ff;}var _0x4f598b=_0x29a7a8[_0x6fd7('0x107')](_0x59a555);if(_0x4f598b[_0x6fd7('0x108')]){rpcDb[_0x6fd7('0x109')](_[_0x6fd7('0x104')](_0x59a555[0x0],[_0x6fd7('0x48'),_0x6fd7('0x10a')]))[_0x6fd7('0x57')](function(_0x5cef29){_0x29a7a8[_0x6fd7('0xee')](_0x5cef29,_0x59a555[0x0],_0x4684c9,_0x59d96d,_0xe0b5ff)[_0x6fd7('0x57')](function(_0x50bee9){return _0x50bee9;})[_0x6fd7('0x4b')](function(_0x5f51da){throw _0x5f51da;});})[_0x6fd7('0x4b')](function(_0x433374){ut['logger'](_0x6fd7('0x10b'),_0x433374);throw ut[_0x6fd7('0x4c')](_0x6fd7('0x10c'),_0x59d96d,_0xe0b5ff);});}else{throw ut[_0x6fd7('0x4c')](_0x4f598b['message'],_0x59d96d,_0xe0b5ff);}})[_0x6fd7('0x4b')](function(_0x4e23b0){ut[_0x6fd7('0x32')](_0x6fd7('0x10d'),_0x4e23b0);throw ut[_0x6fd7('0x4c')](_0x6fd7('0x10c'),![],!![]);});};Preview['prototype'][_0x6fd7('0x107')]=function(_0x33cc9b){if(_[_0x6fd7('0x58')](_0x33cc9b)||_[_0x6fd7('0xf1')](_0x33cc9b)||!_[_0x6fd7('0x58')](_0x33cc9b[0x0]['Agent'])&&_[_0x6fd7('0x58')](_0x33cc9b[0x0][_0x6fd7('0x5c')]['name'])){ut['logger']('[Preview][validateContact][Empty\x20Contact]',_0x33cc9b);return{'isValid':![],'message':'Empty\x20Contact'};}var _0xba2b93=this[_0x6fd7('0x12')][_0x33cc9b[0x0]['Queue']['name']];_0xba2b93[_0x6fd7('0x4c')]=utils[_0x6fd7('0x31')][_0x6fd7('0x77')];if(_[_0x6fd7('0x58')](_0xba2b93)){ut['logger'](_0x6fd7('0x10e'),_0xba2b93);return{'isValid':![],'message':_0x6fd7('0x10f')};}if(!this[_0x6fd7('0x73')](_0xba2b93[_0x6fd7('0x74')])){ut[_0x6fd7('0x32')](_0x6fd7('0x110'),'campaign\x20Name:\x20'+_0xba2b93['name']+_0x6fd7('0x111'));if(!this[_0x6fd7('0x73')](_0xba2b93[_0x6fd7('0x75')])){ut[_0x6fd7('0x32')](_0x6fd7('0x110'),_0xba2b93[_0x6fd7('0x2a')]+'\x20Trunk\x20Backup\x20is\x20not\x20active');return{'isValid':![],'message':'Trunk\x20not\x20working\x20correctly'};}}if(!ut[_0x6fd7('0x72')](_0xba2b93[_0x6fd7('0x112')])){ut[_0x6fd7('0x32')](_0x6fd7('0x113'),_0xba2b93[_0x6fd7('0x2a')]+'\x20Not\x20Active');return{'isValid':![],'message':_0x6fd7('0x114')+_0xba2b93['name']+_0x6fd7('0x115')};}return{'isValid':!![],'message':_0x6fd7('0x116')};};Preview[_0x6fd7('0x10')]['execCall']=function(_0x3da30a,_0x19b016,_0x37de82,_0x2becea){var _0x36af30=this;return new Promise(function(_0x44f4c8,_0x387dc8){var _0x3b69bf=_0x3da30a['uniqueid'];var _0x3539dc=_0x36af30[_0x6fd7('0x73')](_0x19b016[_0x6fd7('0x74')])?util['format'](_0x6fd7('0x117'),_0x19b016[_0x6fd7('0x74')][_0x6fd7('0x2a')],_[_0x6fd7('0x58')](_0x19b016[_0x6fd7('0x118')])?'':_0x19b016[_0x6fd7('0x118')][_0x6fd7('0x119')]()||'',_0x19b016[_0x6fd7('0x11a')]>0x0?_0x37de82['phone']['substring'](_0x19b016['dialCutDigit']):_0x37de82[_0x6fd7('0x10a')]):util[_0x6fd7('0x61')](_0x6fd7('0x117'),_[_0x6fd7('0x58')](_0x19b016[_0x6fd7('0x75')])?_0x19b016[_0x6fd7('0x74')][_0x6fd7('0x2a')]:_0x19b016[_0x6fd7('0x75')][_0x6fd7('0x2a')],_['isNil'](_0x19b016['dialPrefix'])?'':_0x19b016[_0x6fd7('0x118')][_0x6fd7('0x119')]()||'',_0x19b016['dialCutDigit']>0x0?_0x37de82[_0x6fd7('0x10a')][_0x6fd7('0x11b')](_0x19b016[_0x6fd7('0x11a')]):_0x37de82['phone']);var _0x1d2d18=_0x36af30[_0x6fd7('0x73')](_0x19b016[_0x6fd7('0x74')])?ut[_0x6fd7('0x11c')](_0x19b016[_0x6fd7('0x74')][_0x6fd7('0x11d')],_0x19b016[_0x6fd7('0x11e')],_0x19b016['dialRandomLastDigitCallerIdNumber']>0x0?ut[_0x6fd7('0x11f')](_0x19b016['dialOriginateCallerIdNumber'],_0x19b016[_0x6fd7('0x120')]):_0x19b016[_0x6fd7('0x121')]):ut[_0x6fd7('0x11c')](_[_0x6fd7('0x58')](_0x19b016[_0x6fd7('0x75')])?_0x19b016[_0x6fd7('0x74')][_0x6fd7('0x11d')]:_0x19b016[_0x6fd7('0x75')][_0x6fd7('0x11d')],_0x19b016['dialOriginateCallerIdName'],_0x19b016[_0x6fd7('0x120')]>0x0?ut[_0x6fd7('0x11f')](_0x19b016[_0x6fd7('0x121')],_0x19b016[_0x6fd7('0x120')]):_0x19b016[_0x6fd7('0x121')]);if(_0x1d2d18){_0x3da30a[_0x6fd7('0x122')]=ut[_0x6fd7('0x123')](_0x1d2d18);_0x3da30a[_0x6fd7('0x124')]=ut[_0x6fd7('0x125')](_0x1d2d18);}var _0x4dd0d4=ut[_0x6fd7('0x126')](_0x19b016,_0x37de82,_0x3539dc,_0x1d2d18,_0x3b69bf,_0x3da30a);var _0x1cf04f=utils['setXMDContactVariables'](_0x37de82[_0x6fd7('0x127')]);Object['assign'](_0x4dd0d4,_0x1cf04f);_[_0x6fd7('0x128')](_0x3da30a,ut[_0x6fd7('0x129')](_0x4dd0d4));_0x3da30a[_0x6fd7('0x12a')]=moment()[_0x6fd7('0x61')]('YYYY-MM-DD\x20HH:mm:ss');_0x19b016['variables']=_0x4dd0d4;var _0x47c466=ut[_0x6fd7('0x12b')](_0x3da30a,_0x19b016,_0x4dd0d4,_0x3da30a[_0x6fd7('0xad')],_0x2becea);return ami[_0x6fd7('0x49')](_0x47c466)[_0x6fd7('0x57')](function(_0x356aad){_0x19b016['originated']+=0x1;logger[_0x6fd7('0x27')](_0x6fd7('0x12c'),_0x3b69bf,_0x6fd7('0x91'),_0x19b016[_0x6fd7('0x2a')],_0x6fd7('0x43'),_0x19b016['originated']);_0x44f4c8(_0x356aad);})['catch'](function(_0x59c526){ut['logAgent'](_0x3da30a,0xe,_0x6fd7('0x12d'));rpcDb['createAgentHistory'](_0x3da30a,_0x6fd7('0x12e'));_0x387dc8(_0x59c526);});});};Preview[_0x6fd7('0x10')][_0x6fd7('0x21')]=function(_0x49303c){if(this['actions'][_0x49303c[_0x6fd7('0x8a')]]){this[_0x6fd7('0x15')][_0x49303c[_0x6fd7('0x8a')]][_0x6fd7('0x4a')]=_0x49303c[_0x6fd7('0x4a')];}};Preview[_0x6fd7('0x10')][_0x6fd7('0x19')]=function(_0x122221){var _0xe44d32=this;var _0x15e5d9=this[_0x6fd7('0x15')][_0x122221[_0x6fd7('0x12f')]];if(_0x15e5d9){if(_0x15e5d9[_0x6fd7('0xf0')]&&this[_0x6fd7('0x16')][_0x15e5d9[_0x6fd7('0xf0')]]){ut['logLookAgent'](_0x15e5d9,this[_0x6fd7('0x16')][_0x15e5d9[_0x6fd7('0xf0')]]['name'],this[_0x6fd7('0x16')][_0x15e5d9[_0x6fd7('0xf0')]]['id']);}var _0x53d69c=_['clone'](_0x15e5d9);_0x53d69c[_0x6fd7('0x8d')]=moment()['format'](_0x6fd7('0x62'));var _0x3a6f76=_0xe44d32[_0x6fd7('0x12')][_0x15e5d9[_0x6fd7('0x42')]];if(ut[_0x6fd7('0x130')](_0x122221[_0x6fd7('0x131')])){if(_0x15e5d9[_0x6fd7('0xac')]){rpcDb[_0x6fd7('0x102')](_0x15e5d9[_0x6fd7('0x8b')]);}if(_0x15e5d9['activeContact']){rpcDb[_0x6fd7('0x60')](_0x15e5d9[_0x6fd7('0x8b')]);}ami[_0x6fd7('0x26')]('custom:agentringnoanswer',ut[_0x6fd7('0x93')](_0x15e5d9,_0x6fd7('0x132'),this[_0x6fd7('0x12')][_0x15e5d9['queue']]));this[_0x6fd7('0x133')](_0x53d69c,_0x3a6f76,_0x122221);}else{_0x15e5d9[_0x6fd7('0x12a')]=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');ut[_0x6fd7('0xdf')](_0x53d69c,0x4,_0x6fd7('0x9d'));rpcDb[_0x6fd7('0xe0')](_0x53d69c,'[callProgressDetectingAgent][logAnswer]');}}};Preview['prototype'][_0x6fd7('0x1c')]=function(_0x1f1ec7){var _0x58e68e=this[_0x6fd7('0x15')][_0x1f1ec7[_0x6fd7('0x8a')]];var _0x32801b;if(_0x58e68e){_0x32801b=this[_0x6fd7('0x12')][_0x58e68e['queue']];logger[_0x6fd7('0x27')](_0x6fd7('0x134'),_0x1f1ec7[_0x6fd7('0x8a')],'\x20Queue',_0x32801b['name'],'pTalking:\x20',_0x32801b[_0x6fd7('0x2e')]);}if(this[_0x6fd7('0x15')][_0x1f1ec7[_0x6fd7('0x8a')]]&&_0x1f1ec7[_0x6fd7('0x8a')]!==_0x1f1ec7[_0x6fd7('0x90')]){if(_0x1f1ec7['cause']==='16'&&this[_0x6fd7('0x15')][_0x1f1ec7[_0x6fd7('0x8a')]]['dialAnswer']){this[_0x6fd7('0x78')](_0x1f1ec7,_0x1f1ec7[_0x6fd7('0x8a')],_0x1f1ec7[_0x6fd7('0x135')]);}else if(this[_0x6fd7('0x15')][_0x1f1ec7[_0x6fd7('0x8a')]][_0x6fd7('0x4f')]){logger[_0x6fd7('0x27')](_0x6fd7('0x136'),_0x1f1ec7[_0x6fd7('0x8a')],_0x1f1ec7['cause'],_0x6fd7('0x91'),_0x32801b['name'],_0x6fd7('0x45'),_0x32801b[_0x6fd7('0x2e')]);this['callProgressDetectingCustomer'](_0x1f1ec7,_0x1f1ec7[_0x6fd7('0x8a')],_0x1f1ec7[_0x6fd7('0x135')]);}}else if(_0x58e68e&&_[_0x6fd7('0x58')](_0x58e68e['statedesc'])&&_0x32801b[_0x6fd7('0x137')]&&_0x1f1ec7['linkedid']===_0x1f1ec7['uniqueid']&&_[_0x6fd7('0x58')](_0x1f1ec7['reason'])&&_0x1f1ec7['cause']==='16'&&_0x1f1ec7[_0x6fd7('0x138')]==='6'&&_[_0x6fd7('0xdc')](_0x58e68e[_0x6fd7('0x139')])){if(_0x58e68e[_0x6fd7('0xac')]){rpcDb[_0x6fd7('0x102')](_0x58e68e[_0x6fd7('0x8b')]);}if(_0x58e68e[_0x6fd7('0xad')]){rpcDb[_0x6fd7('0x60')](_0x58e68e['idContact']);}_0x1f1ec7[_0x6fd7('0xde')]='22';this[_0x6fd7('0x133')](_0x58e68e,_0x32801b,_0x1f1ec7);}else if(_0x58e68e&&_0x58e68e[_0x6fd7('0x139')]){if(_0x1f1ec7[_0x6fd7('0x135')]==='16'&&this[_0x6fd7('0x15')][_0x1f1ec7[_0x6fd7('0x8a')]][_0x6fd7('0x4f')]){logger['info']('[syncHangup][talking][transfer]',_0x1f1ec7[_0x6fd7('0x8a')],_0x1f1ec7[_0x6fd7('0x135')],_0x6fd7('0x91'),_0x32801b[_0x6fd7('0x2a')],_0x6fd7('0x45'),_0x32801b[_0x6fd7('0x2e')]);this[_0x6fd7('0x78')](_0x1f1ec7,_0x1f1ec7[_0x6fd7('0x8a')],_0x1f1ec7[_0x6fd7('0x135')]);}else if(this[_0x6fd7('0x15')][_0x1f1ec7[_0x6fd7('0x8a')]][_0x6fd7('0x4f')]){logger['info'](_0x6fd7('0x136'),_0x1f1ec7[_0x6fd7('0x8a')],_0x1f1ec7[_0x6fd7('0x135')],_0x6fd7('0x91'),_0x32801b[_0x6fd7('0x2a')],_0x6fd7('0x45'),_0x32801b[_0x6fd7('0x2e')]);this[_0x6fd7('0x78')](_0x1f1ec7,_0x1f1ec7[_0x6fd7('0x8a')],_0x1f1ec7[_0x6fd7('0x135')]);}}};Preview[_0x6fd7('0x10')][_0x6fd7('0x13a')]=function(_0x3992c3){if(this[_0x6fd7('0x15')][_0x3992c3['destlinkedid']]&&_0x3992c3[_0x6fd7('0xdb')]!==_0x3992c3[_0x6fd7('0x13b')]){this[_0x6fd7('0x78')](_0x3992c3,_0x3992c3[_0x6fd7('0xdb')],_0x3992c3[_0x6fd7('0xd3')]);}};Preview[_0x6fd7('0x10')]['syncHangupRequest']=function(_0x470a27){if(this[_0x6fd7('0x15')][_0x470a27[_0x6fd7('0x8a')]]&&_0x470a27[_0x6fd7('0x8a')]!==_0x470a27['uniqueid']&&!this['actions'][_0x470a27[_0x6fd7('0x8a')]][_0x6fd7('0x4f')]){if(_0x470a27['cause']==='1'){this[_0x6fd7('0x78')](_0x470a27,_0x470a27['linkedid'],_0x470a27[_0x6fd7('0x135')]);}}};Preview[_0x6fd7('0x10')]['addVariable']=function(_0x121239,_0x2aa30d,_0x1dd2ca){if(this[_0x6fd7('0x15')][_0x121239]){if(_['isNil'](this['actions'][_0x121239][_0x6fd7('0x13c')])){this[_0x6fd7('0x15')][_0x121239]['variables']={};}this[_0x6fd7('0x15')][_0x121239][_0x6fd7('0x13c')][_0x2aa30d]=_0x1dd2ca;}};Preview[_0x6fd7('0x10')][_0x6fd7('0x22')]=function(_0x3a3f9d){try{if(!_[_0x6fd7('0x58')](_0x3a3f9d)){if(ut[_0x6fd7('0x13d')](_['keys'](_0x3a3f9d[_0x6fd7('0x13e')])[0x0])){this['addVariable'](_0x3a3f9d['uniqueid'],_[_0x6fd7('0x13f')](_0x3a3f9d[_0x6fd7('0x13e')])[0x0],_0x3a3f9d['value']);}}}catch(_0x34220e){logger[_0x6fd7('0x140')](_0x6fd7('0x141'),util[_0x6fd7('0x142')](_0x34220e,{'showHidden':![],'depth':null}));}};Preview['prototype'][_0x6fd7('0x24')]=function(_0x3e8dd1){if(_0x3e8dd1){if(this[_0x6fd7('0x15')][_0x3e8dd1[_0x6fd7('0x143')]]){this[_0x6fd7('0x15')][_0x3e8dd1[_0x6fd7('0x143')]][_0x6fd7('0x139')]=!![];}}};Preview['prototype'][_0x6fd7('0x144')]=function(_0x799ccf){if(_0x799ccf){if(this[_0x6fd7('0x15')][_0x799ccf[_0x6fd7('0x145')]]){this['actions'][_0x799ccf[_0x6fd7('0x145')]][_0x6fd7('0x139')]=!![];}}};module[_0x6fd7('0x146')]=Preview;