f3f2d9d5ff94bd9179fb31cbab76484e0a48481d
[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 _0xe83f=['syncDialEnd','newexten','varset','syncVarSet','syncAttendedTransfer','blindtransfer','loopCampaigns','emit','[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event','format','name','voice_queue_channel:remove','voice_queue_presence:remove','sendMessageOneNotActive','originated','pTalking','paused','CAMPAIGN_STATUS','INACTIVE','logger','\x20is\x20not\x20active','DEACTIVATED','[CampaignPreview]\x20Campaign\x20Queue:\x20','\x20is\x20deactivated','syncCampaigns','clockClearZombieChannels','hasOwnProperty','dialMethod','preview','booked','type','outbound','dialActive','setMessage','dialPreviewAutoRecallMe','recallMe','clearZombieChannel','isNil','info','[clearZombieChannels][talking]','Queue','stringify','queue','pick','contactId','UserId','VoiceQueueId','Action','status','channel','message','decrementOriginate','dialAnswer','decrementTalking','[clearZombieChannel]','loggerError','[Dialer][checkChannel][pTalking][Preview]','[Dialer][checkChannel][Preview]','clearZombieChannels','[action]','size','getContactRecallMe','agentReadyId','then','length','getDiff','dialRecallMeTimeout','Agent','voicePause','run','logger2','[RecallMe]','catch','disableContact','starttime','YYYY-MM-DD\x20HH:mm:ss','outboundReCallsDay','logCustomer','RecallInQueue','createCustomerHistory','[HistoryDialRecallInQueue][historyCatch]','RecallFailedTimeout','[HistoryRecallClose]','[getContactRecallMe]','IsNotLoggedIn','loggedIn','NO_AGENTS_LOGGED','isActive','isTrunkReachable','TrunkBackup','ACTIVE','callProgressDetectingCustomer','outboundNoSuchCallsDay','countnosuchnumberretry','countglobal','NoSuchNumber','custom:agentnosuchnumber','buildObj','nosuchnumber','[callProgressDetectingCustomer][logNoSuch]','verifyAdditionalPhones','additional','dialNoSuchNumberRetryFrequency','totalGlobal','dialGlobalMaxRetry','cloneAction','Global','dialNoSuchNumberMaxRetry','[callProgressDetectingCustomer][logNoSuchGlobal]','rescheduleContact','scheduledAt','activeContact','linkedid','actioncountonusuch','idContact','swapAdditionalPhones','ANSWER','responsetime','answertime','uniqueid','pTalking:\x20','custom:agentconnect','connect','acw','mandatoryDisposition','custom:agentConnectPreview','channelAgent','complete','outboundAnswerCallsDay','total','answered','[16]','[callProgressDetectingCustomer][logAnswer]','createCustomerFinal','sumDuration','talktime','sumBillable','[syncHangup][talking][decrement]','\x20Queue','countbusyretry','Busy','dialBusyRetryFrequency','callAdditionalPhoneAfterMin','custom:agentbusy','busy','[callProgressDetectingCustomer][logBusy]','[callProgressDetectingCustomer][logBusyGlobal]','dialBusyMaxRetry','unlockAgent','incrementPreviewCounters','NOANSWER','outboundNoAnswerCallsDay','buildNoAnswerEventPayload','[callProgressDetectingCustomer][logNoAnswerGlobal]','countnoanswerretry','dialNoAnswerMaxRetry','[callProgressDetectingCustomer][logNoAnswer]','dialNoAnswerRetryFrequency','CONGESTION','outboundCongestionCallsDay','countcongestionretry','Congestion','custom:agentcongestion','[callProgressDetectingCustomer][logCongestion]','[callProgressDetectingCustomer][logCongestionGlobal]','dialCongestionMaxRetry','CANCEL','outboundRejectCallsDay','countagentrejectretry','[syncHangupRequest][logAgentReject]','AgentReject','[callProgressDetectingCustomer][logAgentReject]','dialAgentRejectMaxRetry','dialAgentRejectRetryFrequency','ABANDONED','outboundAbandonedCallsDay','Abandoned','[callProgressDetectingCustomer][logAbandoned]','countabandonedretry','dialAbandonedRetryFrequency','countmachineretry','cause-txt','custom:amd','[callProgressDetectingCustomer][hangupInAMD]','outboundUnknownCallsDay','dialstatus','amd','[callProgressDetectingCustomer][machine]','[default]','[Dialer][decrementTalking][no\x20Hangup][Preview]','[callProgressDetectingCustomer][logUnknown]','[callProgressDetectingCustomer][logUnknownGlobal]','[callProgressDetectingCustomer]','destlinkedid','queueSummaryCountersUpdated','callProgressDetectingAgent','object','isUndefined','createAgentHistory','[callProgressDetectingAgent][logNoSuch]','logAgent','NoAnswer','[callProgressDetectingAgent][logBusy]','[callProgressDetectingAgent][logCongestion]','AnswerAGI','reason','[callProgressDetectingAgent]','[originated][decrement][callProgressDetectingAgent]','[verifyAdditionalPhone]\x20','[swapAdditionalPhone]\x20','resolve','[incrementPreviewCounters]\x20','phone','isEmpty','execCall','[Preview][execCall][success]','Queue:\x20','custom:agentcalled','called','[Preview][execCall][failure]','Call\x20failed','outboundBlacklistCallsDay','logBlacklist','createHistory','[Blacklist][error]','Contact\x20in\x20black\x20List','active','SIP/%s','reachable','unmonitored','unlock','unlockContact','getContactPreview','recallme','isValid','checkIsBlackList','checkInBlack','[Preview][checkIsBlackList]','Call\x20unsuccessful','[Preview][getContactPreview]','validateContact','[Preview][validateContact][Empty\x20Contact]','Empty\x20Contact','[Preview][validateContact][Empty\x20Campaign]','Empty\x20Campaign','Trunk','[Preview][validateContact][Trunk\x20not\x20working\x20correctly]','campaign\x20Name:\x20','\x20Trunk\x20is\x20not\x20active','Trunk\x20not\x20working\x20correctly','[Preview][validateContact][Campaign\x20Active]','\x20Not\x20Active','SIP/%s/%s%s','dialCutDigit','dialPrefix','trim','substring','getCallerId','callerid','dialRandomLastDigitCallerIdNumber','getCallerIdRandom','dialOriginateCallerIdNumber','originatecalleridname','originatecalleridnum','extractCalleridNumber','setXMDContactVariables','Contact','merge','toLowerVariables','variables','variablesAction','[originated][increment]','originated:\x20','OriginateError','[originateFailure][logOriginateFailure]','syncNewExten','syncOriginateResponse','actionid','lookAgent','logLookAgent','isFailure','response','custom:agentringnoanswer','rejected','Answer','[callProgressDetectingAgent][logAnswer]','syncHangup','[syncHangup][talking]','cause','[syncHangup][talking][cause]','statedesc','dialQueueProject','channelstate','transfer','filterKey','variable','addVariable','keys','value','[syncVarSet][Preview]','inspect','syncBlindTransfer','transfererlinkedid','exports','lodash','uuid','moment','ioredis','../../../config/environment','actionPreview','./rpcDb','../rpc/cmHopperAdditionalPhone','./action','../dialer/utils','defaults','redis','localhost','prototype','tail','sequence','campaignsPreview','voiceQueues','trunks','actions','agents','originateresponse','bind','hangup','hanguprequest','syncHangupRequest','dialend'];(function(_0x15615a,_0x3abf94){var _0x220ab1=function(_0x49f590){while(--_0x49f590){_0x15615a['push'](_0x15615a['shift']());}};_0x220ab1(++_0x3abf94);}(_0xe83f,0x130));var _0xfe83=function(_0x1faae7,_0x1c1ec8){_0x1faae7=_0x1faae7-0x0;var _0x3630be=_0xe83f[_0x1faae7];return _0x3630be;};'use strict';var util=require('util');var _=require(_0xfe83('0x0'));var uuid=require(_0xfe83('0x1'));var moment=require(_0xfe83('0x2'));var Redis=require(_0xfe83('0x3'));var config=require(_0xfe83('0x4'));var logger=require('../../../config/logger')('preview');var loggerAction=require('../../../config/logger')(_0xfe83('0x5'));var ami=require('../ami');var rpcDb=require(_0xfe83('0x6'));var cmHopperAdditionalPhone=require(_0xfe83('0x7'));var Action=require(_0xfe83('0x8'));var ut=require('./util/util');var utils=require(_0xfe83('0x9'));config['redis']=_[_0xfe83('0xa')](config[_0xfe83('0xb')],{'host':_0xfe83('0xc'),'port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xfe83('0xb')]));var Sequence=function(){};Sequence[_0xfe83('0xd')]['enqueue']=function(_0x4b9db0){this['tail']=this[_0xfe83('0xe')]?this[_0xfe83('0xe')]['finally'](_0x4b9db0):_0x4b9db0();};function Preview(_0x59cd17){this[_0xfe83('0xf')]=new Sequence();this[_0xfe83('0x10')]=_0x59cd17[_0xfe83('0x11')];this[_0xfe83('0x12')]=_0x59cd17[_0xfe83('0x12')];this[_0xfe83('0x13')]={};this['agents']=_0x59cd17[_0xfe83('0x14')];this['clockClearZombieChannels']=0x0;ami['on'](_0xfe83('0x15'),this['syncOriginateResponse'][_0xfe83('0x16')](this));ami['on'](_0xfe83('0x17'),this['syncHangup'][_0xfe83('0x16')](this));ami['on'](_0xfe83('0x18'),this[_0xfe83('0x19')][_0xfe83('0x16')](this));ami['on'](_0xfe83('0x1a'),this[_0xfe83('0x1b')][_0xfe83('0x16')](this));ami['on'](_0xfe83('0x1c'),this['syncNewExten'][_0xfe83('0x16')](this));ami['on'](_0xfe83('0x1d'),this[_0xfe83('0x1e')][_0xfe83('0x16')](this));ami['on']('attendedtransfer',this[_0xfe83('0x1f')][_0xfe83('0x16')](this));ami['on'](_0xfe83('0x20'),this['syncBlindTransfer'][_0xfe83('0x16')](this));this[_0xfe83('0x21')](this[_0xfe83('0x10')]);}function emit(_0x4b0d08,_0x20f45d,_0x554a50){io['to'](_0x4b0d08)[_0xfe83('0x22')](_0x20f45d,_0x554a50);}function emitVoiceQueueChannelRemove(_0x5019fb){logger['info'](_0xfe83('0x23'),JSON['stringify'](_0x5019fb));emit(util[_0xfe83('0x24')]('voice:queue:%s',_0x5019fb[_0xfe83('0x25')]),_0xfe83('0x26'),_0x5019fb);io[_0xfe83('0x22')](_0xfe83('0x27'),_0x5019fb);}function notSendMessagesQueue(_0x59a785){if(_0x59a785[_0xfe83('0x28')]){if(_0x59a785[_0xfe83('0x29')]===0x0&&_0x59a785[_0xfe83('0x2a')]===0x0){_0x59a785['sendMessageOneNotActive']=![];_0x59a785['available']=0x0;_0x59a785[_0xfe83('0x2b')]=0x0;_0x59a785['message']=utils[_0xfe83('0x2c')][_0xfe83('0x2d')];ut[_0xfe83('0x2e')]('[CampaignPreview]\x20Campaign\x20Queue:\x20',_0x59a785[_0xfe83('0x25')]+_0xfe83('0x2f'));}else{_0x59a785['message']=utils[_0xfe83('0x2c')][_0xfe83('0x30')];ut[_0xfe83('0x2e')](_0xfe83('0x31'),_0x59a785[_0xfe83('0x25')]+_0xfe83('0x32'));}}}Preview['prototype'][_0xfe83('0x21')]=function(){var _0x46c859=this;setInterval(function(){_0x46c859[_0xfe83('0x33')]();},0x7cf);};Preview['prototype'][_0xfe83('0x33')]=function(){var _0x177abc=this[_0xfe83('0x10')];this[_0xfe83('0x34')]+=0x1;for(var _0x4322d1 in _0x177abc){if(_0x177abc[_0xfe83('0x35')](_0x4322d1)&&(_0x177abc[_0x4322d1][_0xfe83('0x36')]===_0xfe83('0x37')||_0x177abc[_0x4322d1][_0xfe83('0x36')]===_0xfe83('0x38'))&&_0x177abc[_0x4322d1][_0xfe83('0x39')]===_0xfe83('0x3a')){if(this[_0xfe83('0x34')]>0x7){this['clockClearZombieChannels']=0x0;this['clearZombieChannels']();}}if(_0x177abc[_0xfe83('0x35')](_0x4322d1)&&_0x177abc[_0x4322d1][_0xfe83('0x36')]===_0xfe83('0x37')&&_0x177abc[_0x4322d1]['type']===_0xfe83('0x3a')){if(_0x177abc[_0x4322d1][_0xfe83('0x3b')]){this[_0xfe83('0x3c')](_0x177abc[_0x4322d1]);if(_0x177abc[_0x4322d1][_0xfe83('0x3d')])this[_0xfe83('0x3e')](_0x177abc[_0x4322d1]);}else{notSendMessagesQueue(_0x177abc[_0x4322d1]);}}}};Preview[_0xfe83('0xd')][_0xfe83('0x3f')]=function(_0x3e6d1c){var _0x39b15b=this;this[_0xfe83('0xf')]['enqueue'](function(){if(!_[_0xfe83('0x40')](_0x39b15b['actions'][_0x3e6d1c])){loggerAction[_0xfe83('0x41')](_0xfe83('0x42'),_0x3e6d1c,_0xfe83('0x43'),_0x39b15b[_0xfe83('0x13')][_0x3e6d1c]['queue'],'originated:\x20',JSON[_0xfe83('0x44')](_0x39b15b[_0xfe83('0x10')][_0x39b15b['actions'][_0x3e6d1c][_0xfe83('0x45')]][_0xfe83('0x29')]),'pTalking:\x20',JSON[_0xfe83('0x44')](_0x39b15b[_0xfe83('0x10')][_0x39b15b[_0xfe83('0x13')][_0x3e6d1c][_0xfe83('0x45')]][_0xfe83('0x2a')]),JSON[_0xfe83('0x44')](_0x39b15b[_0xfe83('0x13')][_0x3e6d1c]['dialAnswer']),JSON[_0xfe83('0x44')](_[_0xfe83('0x46')](_0x39b15b[_0xfe83('0x13')][_0x3e6d1c],[_0xfe83('0x47'),_0xfe83('0x48'),_0xfe83('0x49'),'ListId'])));return ami[_0xfe83('0x4a')]({'action':_0xfe83('0x4b'),'channel':_0x39b15b[_0xfe83('0x13')][_0x3e6d1c][_0xfe83('0x4c')]})['catch'](function(_0x2ce0a8){if(_0x2ce0a8[_0xfe83('0x4d')]==='No\x20such\x20channel'){setTimeout(function(){if(_0x39b15b[_0xfe83('0x13')][_0x3e6d1c]){utils[_0xfe83('0x4e')](_0x39b15b[_0xfe83('0x10')][_0x39b15b['actions'][_0x3e6d1c][_0xfe83('0x45')]],'[clearZombieChannel]');if(_0x39b15b[_0xfe83('0x13')][_0x3e6d1c][_0xfe83('0x4f')]===!![]){ut[_0xfe83('0x50')](_0x39b15b[_0xfe83('0x10')][_0x39b15b[_0xfe83('0x13')][_0x3e6d1c][_0xfe83('0x45')]],_0xfe83('0x51'));ut[_0xfe83('0x52')](_0xfe83('0x53')+_0x3e6d1c,_0x39b15b[_0xfe83('0x13')][_0x3e6d1c][_0xfe83('0x45')]);}ut['loggerError'](_0xfe83('0x54')+_0x3e6d1c,_0x39b15b[_0xfe83('0x13')][_0x3e6d1c][_0xfe83('0x45')]);delete _0x39b15b[_0xfe83('0x13')][_0x3e6d1c];}},0x2328);}});}});};Preview[_0xfe83('0xd')][_0xfe83('0x55')]=function(){var _0x113ca8=this;loggerAction['info'](_0xfe83('0x56'),_[_0xfe83('0x57')](this[_0xfe83('0x13')]));for(var _0x42fa2f in this[_0xfe83('0x13')]){if(_0x113ca8[_0xfe83('0x13')][_0xfe83('0x35')](_0x42fa2f)){_0x113ca8[_0xfe83('0x3f')](_0x42fa2f);}}};Preview[_0xfe83('0xd')][_0xfe83('0x3e')]=function(_0x2a52d1){var _0x57dc37=this;rpcDb[_0xfe83('0x58')](_0x2a52d1['id'],ut[_0xfe83('0x59')](this[_0xfe83('0x14')]))[_0xfe83('0x5a')](function(_0x15a34d){if(!_[_0xfe83('0x40')](_0x15a34d)){for(var _0x47bc3b=0x0;_0x47bc3b<_0x15a34d[_0xfe83('0x5b')];_0x47bc3b+=0x1){if(ut[_0xfe83('0x5c')](_0x15a34d[_0x47bc3b]['scheduledat'])<_0x2a52d1[_0xfe83('0x5d')]*0x3c){if(_0x15a34d[_0x47bc3b][_0xfe83('0x5e')]&&!_0x15a34d[_0x47bc3b][_0xfe83('0x5e')][_0xfe83('0x5f')]){_0x57dc37[_0xfe83('0x60')](_0x15a34d[_0x47bc3b]['id'])['then'](ut[_0xfe83('0x61')](_0xfe83('0x62')))[_0xfe83('0x63')](ut[_0xfe83('0x61')]('[RecallMe]'));}else{rpcDb[_0xfe83('0x64')](_0x15a34d[_0x47bc3b]['id']);}}else{var _0x37c5bd=new Action(_0x15a34d[_0x47bc3b],_0x2a52d1);_0x37c5bd[_0xfe83('0x65')]=moment()[_0xfe83('0x24')](_0xfe83('0x66'));_0x2a52d1[_0xfe83('0x67')]+=0x1;ut[_0xfe83('0x68')](_0x37c5bd,0x17,_0xfe83('0x69'));if(_0x2a52d1['dialRecallInQueue']){rpcDb['rescheduleContactInQueue'](ut['createBody'](_0x15a34d[_0x47bc3b]));rpcDb[_0xfe83('0x6a')](_0x37c5bd,_0xfe83('0x6b'));}else{ut[_0xfe83('0x68')](_0x37c5bd,0x16,_0xfe83('0x6c'));rpcDb[_0xfe83('0x6a')](_0x37c5bd,_0xfe83('0x6d'));rpcDb['createCustomerFinal'](_0x37c5bd,_0xfe83('0x6d'));}}}}})[_0xfe83('0x63')](ut['logger2'](_0xfe83('0x6e')));};Preview[_0xfe83('0xd')][_0xfe83('0x3c')]=function(_0x161b4b){_0x161b4b[_0xfe83('0x28')]=!![];if(ut[_0xfe83('0x6f')](_0x161b4b[_0xfe83('0x70')])){_0x161b4b[_0xfe83('0x4d')]=utils[_0xfe83('0x2c')][_0xfe83('0x71')];}else if(!ut[_0xfe83('0x72')](_0x161b4b[_0xfe83('0x3b')])){_0x161b4b[_0xfe83('0x4d')]=utils['CAMPAIGN_STATUS'][_0xfe83('0x2d')];}else if(!this[_0xfe83('0x73')](_0x161b4b['Trunk'])){if(!this[_0xfe83('0x73')](_0x161b4b[_0xfe83('0x74')])){_0x161b4b[_0xfe83('0x4d')]=utils[_0xfe83('0x2c')]['UNREACHABLE_TRUNK'];}else{_0x161b4b[_0xfe83('0x4d')]=utils[_0xfe83('0x2c')][_0xfe83('0x75')];}}else{_0x161b4b['message']=utils[_0xfe83('0x2c')][_0xfe83('0x75')];}};Preview['prototype'][_0xfe83('0x76')]=function(_0x56467b,_0x2dfc71,_0x174d89){var _0x13f50b=this;var _0x282410=this[_0xfe83('0x13')][_0x2dfc71];var _0x323935=this[_0xfe83('0x10')][_0x282410[_0xfe83('0x45')]];var _0x22772f;var _0x2e7078=![];var _0x8788dc=0x2;var _0x234216=0x3;if(_0x323935){switch(_0x174d89){case'1':_0x323935[_0xfe83('0x77')]+=0x1;_0x282410[_0xfe83('0x78')]+=0x1;_0x282410[_0xfe83('0x79')]=ut['totalGlobal'](_0x282410);ut[_0xfe83('0x68')](_0x282410,0x0,_0xfe83('0x7a'));ami['emit'](_0xfe83('0x7b'),ut[_0xfe83('0x7c')](_0x282410,_0xfe83('0x7d')));rpcDb[_0xfe83('0x6a')](_0x282410,_0xfe83('0x7e'));_0x13f50b[_0xfe83('0x7f')](_0x282410,'0',_0x323935)[_0xfe83('0x5a')](function(_0x287f02){_0x2e7078=_0x287f02[_0xfe83('0x80')]==0x1;_0x8788dc=_0x323935[_0xfe83('0x81')];_0x234216=_0x323935['callAdditionalPhoneAfterMin'];if(!_0x2e7078){if(ut[_0xfe83('0x82')](_0x282410)>=_0x323935[_0xfe83('0x83')]){_0x22772f=ut[_0xfe83('0x84')](_0x282410,0xf,_0xfe83('0x85'));rpcDb['createCustomerFinal'](_0x22772f,'[callProgressDetectingCustomer][logNoSuchGlobal]');}else{if(_0x282410[_0xfe83('0x78')]>=_0x323935[_0xfe83('0x86')]){rpcDb['createCustomerFinal'](_0x282410,_0xfe83('0x87'));}else{rpcDb[_0xfe83('0x88')](ut[_0xfe83('0x89')](_0x282410,_0xfe83('0x78'),_0x323935[_0xfe83('0x81')]),_0x282410['unlockAgent'],_0x282410[_0xfe83('0x8a')]);}}delete this[_0xfe83('0x13')][_0x56467b[_0xfe83('0x8b')]];}else{_0x282410[_0xfe83('0x78')]++;logger[_0xfe83('0x41')](_0xfe83('0x8c'),_0x282410[_0xfe83('0x78')]);logger[_0xfe83('0x41')]('id',_0x282410['idContact']);_0x13f50b['incrementPreviewCounters']({'id':_0x282410[_0xfe83('0x8d')],'field':{'countnosuchnumberretry':_0x282410[_0xfe83('0x78')]}})[_0xfe83('0x5a')](function(){_0x13f50b[_0xfe83('0x8e')](_0x282410,_0x8788dc,_0x234216)[_0xfe83('0x5a')](function(){});});}});break;case _0xfe83('0x8f'):var _0x1bb14f=moment()[_0xfe83('0x24')](_0xfe83('0x66'));_0x282410[_0xfe83('0x90')]=_0x1bb14f;_0x282410[_0xfe83('0x91')]=_0x1bb14f;_0x282410['dialAnswer']=!![];_0x323935['pTalking']+=0x1;logger['info']('[syncHangup][talking][increment]',_0x282410[_0xfe83('0x92')],'\x20Queue',_0x323935['name'],_0xfe83('0x93'),_0x323935[_0xfe83('0x2a')]);ami['emit'](_0xfe83('0x94'),ut[_0xfe83('0x7c')](_0x282410,_0xfe83('0x95'),this['campaignsPreview'][_0x282410[_0xfe83('0x45')]]));if(_0x323935[_0xfe83('0x96')]||_0x323935[_0xfe83('0x97')]){ami[_0xfe83('0x22')](_0xfe83('0x98'),{'queue':_0x282410[_0xfe83('0x45')],'interface':_0x282410[_0xfe83('0x99')],'uniqueid':_0x282410[_0xfe83('0x92')]});}break;case'16':ami['emit']('custom:agentcomplete',ut[_0xfe83('0x7c')](_0x282410,_0xfe83('0x9a'),this[_0xfe83('0x10')][_0x282410['queue']]));emitVoiceQueueChannelRemove(ut['buildObj'](_0x282410,_0xfe83('0x9a')));_0x323935[_0xfe83('0x9b')]+=0x1;_0x323935[_0xfe83('0x9c')]+=0x1;_0x323935[_0xfe83('0x9d')]+=0x1;ut[_0xfe83('0x50')](_0x323935,_0xfe83('0x9e'));_0x282410['countglobal']=ut[_0xfe83('0x82')](_0x282410);ut[_0xfe83('0x68')](_0x282410,0x4,'Answer');rpcDb[_0xfe83('0x6a')](_0x282410,_0xfe83('0x9f'));rpcDb[_0xfe83('0xa0')](_0x282410,'[callProgressDetectingCustomer][logAnswerGlobal]');rpcDb['crateCustomerReportQueue'](_0x282410);_0x323935[_0xfe83('0xa1')]+=_0x282410[_0xfe83('0xa2')];_0x323935[_0xfe83('0xa3')]+=_0x282410[_0xfe83('0xa2')];logger[_0xfe83('0x41')](_0xfe83('0xa4'),_0x282410[_0xfe83('0x92')],_0xfe83('0xa5'),_0x323935[_0xfe83('0x25')],_0xfe83('0x93'),_0x323935[_0xfe83('0x2a')]);delete this['actions'][_0x56467b[_0xfe83('0x8b')]];break;case'BUSY':_0x323935['outboundBusyCallsDay']+=0x1;_0x282410[_0xfe83('0xa6')]+=0x1;_0x282410[_0xfe83('0x79')]=ut['totalGlobal'](_0x282410);ut['logCustomer'](_0x282410,0x5,_0xfe83('0xa7'));_0x8788dc=_0x323935[_0xfe83('0xa8')];_0x234216=_0x323935[_0xfe83('0xa9')];ami[_0xfe83('0x22')](_0xfe83('0xaa'),ut[_0xfe83('0x7c')](_0x282410,_0xfe83('0xab')));rpcDb['createCustomerHistory'](_0x282410,_0xfe83('0xac'));_0x13f50b[_0xfe83('0x7f')](_0x282410,'5',_0x323935)[_0xfe83('0x5a')](function(_0x3d86e4){_0x2e7078=_0x3d86e4[_0xfe83('0x80')]==0x1;if(!_0x2e7078){if(ut[_0xfe83('0x82')](_0x282410)>=_0x323935[_0xfe83('0x83')]){_0x22772f=ut[_0xfe83('0x84')](_0x282410,0xf,'Global');rpcDb['createCustomerFinal'](_0x22772f,_0xfe83('0xad'));}else{if(_0x282410[_0xfe83('0xa6')]>=_0x323935[_0xfe83('0xae')]){rpcDb[_0xfe83('0xa0')](_0x282410,_0xfe83('0xac'));}else{rpcDb[_0xfe83('0x88')](ut['scheduledAt'](_0x282410,_0xfe83('0xa6'),_0x323935[_0xfe83('0xa8')]),_0x282410[_0xfe83('0xaf')],_0x282410['activeContact']);}}}else{_0x282410[_0xfe83('0xa6')]++;_0x13f50b[_0xfe83('0xb0')]({'id':_0x282410[_0xfe83('0x8d')],'field':{'countbusyretry':_0x282410[_0xfe83('0xa6')]}})['then'](function(){_0x13f50b[_0xfe83('0x8e')](_0x282410,_0x8788dc,_0x234216)[_0xfe83('0x5a')](function(){});});}});break;case _0xfe83('0xb1'):_0x323935[_0xfe83('0xb2')]+=0x1;_0x282410['countnoanswerretry']+=0x1;_0x282410[_0xfe83('0x79')]=ut[_0xfe83('0x82')](_0x282410);ut[_0xfe83('0x68')](_0x282410,0x3,'NoAnswer');_0x8788dc=_0x323935['dialNoAnswerRetryFrequency'];_0x234216=_0x323935[_0xfe83('0xa9')];var _0x248959=ut[_0xfe83('0xb3')](_0x282410,_0x323935);ami['emit']('custom:agentnoanswer',_0x248959);rpcDb[_0xfe83('0x6a')](_0x282410,'[callProgressDetectingCustomer][logNoAnswer]');_0x13f50b[_0xfe83('0x7f')](_0x282410,'3',_0x323935)[_0xfe83('0x5a')](function(_0xff150a){_0x2e7078=_0xff150a[_0xfe83('0x80')]==0x1;if(!_0x2e7078){if(ut[_0xfe83('0x82')](_0x282410)>=_0x323935[_0xfe83('0x83')]){_0x22772f=ut['cloneAction'](_0x282410,0xf,_0xfe83('0x85'));rpcDb[_0xfe83('0xa0')](_0x22772f,_0xfe83('0xb4'));}else{if(_0x282410[_0xfe83('0xb5')]>=_0x323935[_0xfe83('0xb6')]){rpcDb[_0xfe83('0xa0')](_0x282410,_0xfe83('0xb7'));}else{rpcDb['rescheduleContact'](ut[_0xfe83('0x89')](_0x282410,_0xfe83('0xb5'),_0x323935[_0xfe83('0xb8')]),_0x282410[_0xfe83('0xaf')],_0x282410[_0xfe83('0x8a')]);}}}else{_0x282410[_0xfe83('0xb5')]++;_0x13f50b[_0xfe83('0xb0')]({'id':_0x282410[_0xfe83('0x8d')],'field':{'countnoanswerretry':_0x282410[_0xfe83('0xb5')]}})['then'](function(){_0x13f50b[_0xfe83('0x8e')](_0x282410,_0x8788dc,_0x234216)[_0xfe83('0x5a')](function(){});});}});break;case _0xfe83('0xb9'):_0x323935[_0xfe83('0xba')]+=0x1;_0x282410[_0xfe83('0xbb')]+=0x1;_0x282410[_0xfe83('0x79')]=ut['totalGlobal'](_0x282410);ut['logCustomer'](_0x282410,0x8,_0xfe83('0xbc'));_0x8788dc=_0x323935['dialCongestionRetryFrequency'];_0x234216=_0x323935[_0xfe83('0xa9')];ami['emit'](_0xfe83('0xbd'),ut[_0xfe83('0x7c')](_0x282410,'congestion'));rpcDb[_0xfe83('0x6a')](_0x282410,_0xfe83('0xbe'));_0x13f50b[_0xfe83('0x7f')](_0x282410,'8',_0x323935)[_0xfe83('0x5a')](function(_0x41bd35){_0x2e7078=_0x41bd35[_0xfe83('0x80')]==0x1;if(!_0x2e7078){if(ut[_0xfe83('0x82')](_0x282410)>=_0x323935[_0xfe83('0x83')]){_0x22772f=ut['cloneAction'](_0x282410,0xf,_0xfe83('0x85'));rpcDb[_0xfe83('0xa0')](_0x22772f,_0xfe83('0xbf'));}else{if(_0x282410[_0xfe83('0xbb')]>=_0x323935[_0xfe83('0xc0')]){rpcDb[_0xfe83('0xa0')](_0x282410,_0xfe83('0xbe'));}else{rpcDb['rescheduleContact'](ut[_0xfe83('0x89')](_0x282410,_0xfe83('0xbb'),_0x323935[_0xfe83('0xa8')]),_0x282410[_0xfe83('0xaf')],_0x282410[_0xfe83('0x8a')]);}}}else{_0x282410[_0xfe83('0xbb')]++;_0x13f50b[_0xfe83('0xb0')]({'id':_0x282410[_0xfe83('0x8d')],'field':{'countcongestionretry':_0x282410[_0xfe83('0xbb')]}})['then'](function(){_0x13f50b[_0xfe83('0x8e')](_0x282410,_0x8788dc,_0x234216)[_0xfe83('0x5a')](function(){});});}});break;case _0xfe83('0xc1'):_0x323935[_0xfe83('0xc2')]+=0x1;_0x282410[_0xfe83('0xc3')]+=0x1;_0x282410[_0xfe83('0x79')]=ut[_0xfe83('0x82')](_0x282410);ut[_0xfe83('0x68')](_0x282410,0x14,'AgentReject');_0x8788dc=_0x323935['dialAgentRejectRetryFrequency'];_0x234216=_0x323935[_0xfe83('0xa9')];ami[_0xfe83('0x22')]('custom:agentreject',ut[_0xfe83('0x7c')](_0x282410,'agentreject'));rpcDb[_0xfe83('0x6a')](_0x282410,_0xfe83('0xc4'));_0x13f50b[_0xfe83('0x7f')](_0x282410,'20',_0x323935)[_0xfe83('0x5a')](function(_0xc4a2e4){_0x2e7078=_0xc4a2e4[_0xfe83('0x80')]==0x1;if(!_0x2e7078){if(ut['totalGlobal'](_0x282410)>=_0x323935[_0xfe83('0x83')]){_0x22772f=ut[_0xfe83('0x84')](_0x282410,0x14,_0xfe83('0xc5'));rpcDb[_0xfe83('0xa0')](_0x22772f,_0xfe83('0xc6'));}else{if(_0x282410['countagentrejectretry']>=_0x323935[_0xfe83('0xc7')]){rpcDb['createCustomerFinal'](_0x282410,_0xfe83('0xc6'));}else{rpcDb[_0xfe83('0x88')](ut[_0xfe83('0x89')](_0x282410,_0xfe83('0xc3'),_0x323935[_0xfe83('0xc8')]),_0x282410['unlockAgent'],_0x282410['activeContact']);}}}else{_0x282410[_0xfe83('0xb5')]++;_0x13f50b['incrementPreviewCounters']({'id':_0x282410[_0xfe83('0x8d')],'field':{'countnoanswerretry':_0x282410[_0xfe83('0xb5')]}})[_0xfe83('0x5a')](function(){_0x13f50b['swapAdditionalPhones'](_0x282410,_0x8788dc,_0x234216)[_0xfe83('0x5a')](function(){});});}});break;case _0xfe83('0xc9'):_0x323935[_0xfe83('0xca')]+=0x1;_0x282410['countabandonedretry']+=0x1;_0x282410[_0xfe83('0x79')]=ut[_0xfe83('0x82')](_0x282410);ut[_0xfe83('0x68')](_0x282410,0xb,_0xfe83('0xcb'));rpcDb[_0xfe83('0x6a')](_0x282410,_0xfe83('0xcc'));_0x13f50b[_0xfe83('0x7f')](_0x282410,'11',_0x323935)[_0xfe83('0x5a')](function(_0x44cc7c){_0x2e7078=_0x44cc7c['additional']==0x1;if(!_0x2e7078){if(ut[_0xfe83('0x82')](_0x282410)>=_0x323935[_0xfe83('0x83')]){_0x22772f=ut['cloneAction'](_0x282410,0xf,_0xfe83('0x85'));rpcDb[_0xfe83('0xa0')](_0x22772f,_0xfe83('0xcc'));}else{if(_0x282410['countabandonedetry']>=_0x323935['dialAbandonedMaxRety']){rpcDb[_0xfe83('0xa0')](_0x282410,_0xfe83('0xcc'));}else{rpcDb[_0xfe83('0x88')](ut[_0xfe83('0x89')](_0x282410,_0xfe83('0xcd'),_0x323935[_0xfe83('0xce')]),_0x282410[_0xfe83('0xaf')],_0x282410['activeContact']);}}}else{_0x282410[_0xfe83('0xb5')]++;_0x13f50b[_0xfe83('0xb0')]({'id':_0x282410['idContact'],'field':{'countnoanswerretry':_0x282410[_0xfe83('0xb5')]}})[_0xfe83('0x5a')](function(){_0x13f50b[_0xfe83('0x8e')](_0x282410,_0x8788dc,_0x234216)[_0xfe83('0x5a')](function(){});});}});break;case'18':_0x323935['outboundUnknownCallsDay']+=0x1;_0x282410[_0xfe83('0xcf')]+=0x1;_0x282410[_0xfe83('0x79')]=ut['totalGlobal'](_0x282410);ut[_0xfe83('0x68')](_0x282410,0x12,_0x56467b[_0xfe83('0xd0')]||_0x56467b['dialstatus']);ami[_0xfe83('0x22')](_0xfe83('0xd1'),ut[_0xfe83('0x7c')](_0x282410,'amd'));rpcDb[_0xfe83('0x6a')](_0x282410,_0xfe83('0xd2'));_0x13f50b[_0xfe83('0x7f')](_0x282410,'18',_0x323935)[_0xfe83('0x5a')](function(_0x47d8f1){_0x2e7078=_0x47d8f1[_0xfe83('0x80')]==0x1;if(!_0x2e7078){if(ut[_0xfe83('0x82')](_0x282410)>=_0x323935[_0xfe83('0x83')]){_0x22772f=ut[_0xfe83('0x84')](_0x282410,0x12,'Global');rpcDb[_0xfe83('0xa0')](_0x22772f,_0xfe83('0xd2'));}else{rpcDb[_0xfe83('0xa0')](_0x282410,_0xfe83('0xd2'));}}else{_0x282410[_0xfe83('0xb5')]++;_0x13f50b['incrementPreviewCounters']({'id':_0x282410[_0xfe83('0x8d')],'field':{'countnoanswerretry':_0x282410['countnoanswerretry']}})[_0xfe83('0x5a')](function(){_0x13f50b[_0xfe83('0x8e')](_0x282410,_0x8788dc,_0x234216)[_0xfe83('0x5a')](function(){});});}});delete this[_0xfe83('0x13')][_0x56467b[_0xfe83('0x8b')]];break;case'19':_0x323935[_0xfe83('0xd3')]+=0x1;_0x282410['countglobal']=ut[_0xfe83('0x82')](_0x282410);ut[_0xfe83('0x68')](_0x282410,0x13,_0x56467b[_0xfe83('0xd0')]||_0x56467b[_0xfe83('0xd4')]);ami[_0xfe83('0x22')](_0xfe83('0xd1'),ut[_0xfe83('0x7c')](_0x282410,_0xfe83('0xd5')));rpcDb['createCustomerHistory'](_0x282410,_0xfe83('0xd6'));_0x13f50b[_0xfe83('0x7f')](_0x282410,'18',_0x323935)[_0xfe83('0x5a')](function(_0x3f692a){_0x2e7078=_0x3f692a['additional']==0x1;if(!_0x2e7078){if(ut[_0xfe83('0x82')](_0x282410)>=_0x323935[_0xfe83('0x83')]){_0x22772f=ut[_0xfe83('0x84')](_0x282410,0xf,_0xfe83('0x85'));rpcDb[_0xfe83('0xa0')](_0x22772f,_0xfe83('0xd6'));}else{rpcDb[_0xfe83('0xa0')](_0x282410,_0xfe83('0xd6'));}}else{_0x282410[_0xfe83('0xb5')]++;_0x13f50b[_0xfe83('0xb0')]({'id':_0x282410[_0xfe83('0x8d')],'field':{'countnoanswerretry':_0x282410[_0xfe83('0xb5')]}})['then'](function(){_0x13f50b[_0xfe83('0x8e')](_0x282410,_0x8788dc,_0x234216)[_0xfe83('0x5a')](function(){});});}});delete this[_0xfe83('0x13')][_0x56467b[_0xfe83('0x8b')]];break;default:if(_0x282410[_0xfe83('0x4f')]){ut[_0xfe83('0x50')](_0x323935,_0xfe83('0xd7'));ut[_0xfe83('0x52')](_0xfe83('0xd8')+_0x323935[_0xfe83('0x25')],_0x56467b);}_0x323935[_0xfe83('0xd3')]+=0x1;_0x282410['countglobal']=ut[_0xfe83('0x82')](_0x282410);ut[_0xfe83('0x68')](_0x282410,0xc,_0x56467b[_0xfe83('0xd0')]||_0x56467b[_0xfe83('0xd4')]);_0x8788dc=_0x323935['dialAgentRejectRetryFrequency'];_0x234216=_0x323935[_0xfe83('0xa9')];rpcDb[_0xfe83('0x6a')](_0x282410,_0xfe83('0xd9'));_0x13f50b[_0xfe83('0x7f')](_0x282410,'20',_0x323935)['then'](function(_0x3398a9){_0x2e7078=_0x3398a9[_0xfe83('0x80')]==0x1;if(!_0x2e7078){if(ut[_0xfe83('0x82')](_0x282410)>=_0x323935[_0xfe83('0x83')]){_0x22772f=ut[_0xfe83('0x84')](_0x282410,0xf,'Global');rpcDb[_0xfe83('0xa0')](_0x22772f,_0xfe83('0xda'));}else{rpcDb['createCustomerFinal'](_0x282410,_0xfe83('0xda'));}delete this['actions'][_0x56467b[_0xfe83('0x8b')]];}else{_0x13f50b['swapAdditionalPhones'](_0x282410,_0x8788dc,_0x234216)['then'](function(){});}});}if(!(_0x282410[_0xfe83('0x4f')]&&_0x174d89==='16')){utils[_0xfe83('0x4e')](_0x323935,_0xfe83('0xdb'));logger[_0xfe83('0x41')]('[originated][decrement][callProgressDetectingCustomer]',_0x282410[_0xfe83('0x92')],'\x20Queue',_0x323935['name'],'originated:\x20',_0x323935[_0xfe83('0x29')]);}if(_0x174d89!==_0xfe83('0x8f')){delete this[_0xfe83('0x13')][_0x56467b[_0xfe83('0x8b')]];delete this[_0xfe83('0x13')][_0x56467b[_0xfe83('0xdc')]];}_0x323935[_0xfe83('0xdd')]=!![];}};Preview[_0xfe83('0xd')][_0xfe83('0xde')]=function(_0x3102a6,_0x464a08,_0x675d3b){if(_['isUndefined'](_0x464a08)&&_0xfe83('0xdf')!==typeof _0x464a08){return;}if(_[_0xfe83('0xe0')](_0x675d3b)&&'object'!==typeof _0x675d3b){return;}switch(_0x675d3b['reason']){case'0':ut['logAgent'](_0x3102a6,0x0,_0xfe83('0x7a'));rpcDb[_0xfe83('0xe1')](_0x3102a6,_0xfe83('0xe2'));break;case'3':ut[_0xfe83('0xe3')](_0x3102a6,0x3,_0xfe83('0xe4'));rpcDb[_0xfe83('0xe1')](_0x3102a6,'[callProgressDetectingAgent][logNoAnswer]');break;case'5':ut[_0xfe83('0xe3')](_0x3102a6,0x5,_0xfe83('0xa7'));rpcDb[_0xfe83('0xe1')](_0x3102a6,_0xfe83('0xe5'));break;case'8':ut[_0xfe83('0xe3')](_0x3102a6,0x8,_0xfe83('0xbc'));rpcDb['createAgentHistory'](_0x3102a6,_0xfe83('0xe6'));break;case'22':ut[_0xfe83('0xe3')](_0x3102a6,0x16,_0xfe83('0xe7'));rpcDb['createAgentHistory'](_0x3102a6,'[callProgressDetectingAgent][logAnswerAGI]');break;default:ut[_0xfe83('0xe3')](_0x3102a6,0xc,_0x675d3b[_0xfe83('0xe8')]);rpcDb[_0xfe83('0xe1')](_0x3102a6,_0xfe83('0xe6'));}utils[_0xfe83('0x4e')](_0x464a08,_0xfe83('0xe9'));logger[_0xfe83('0x41')](_0xfe83('0xea'),_0x3102a6[_0xfe83('0x92')],'\x20Queue',_0x464a08[_0xfe83('0x25')],'originated:\x20',_0x464a08['originated']);delete this[_0xfe83('0x13')][_0x3102a6[_0xfe83('0x92')]];};Preview[_0xfe83('0xd')][_0xfe83('0x7f')]=function(_0x2e9e4f,_0xec054a,_0x2f837f){return cmHopperAdditionalPhone['verifyAdditionalPhones'](_0x2e9e4f,_0xec054a,_0x2f837f)['catch'](logger[_0xfe83('0x41')](_0xfe83('0xeb')));};Preview[_0xfe83('0xd')]['swapAdditionalPhones']=function(_0x1336d6,_0xbff95d,_0x16193f){return cmHopperAdditionalPhone[_0xfe83('0x8e')](_0x1336d6,_0xbff95d,_0x16193f)[_0xfe83('0x63')](logger[_0xfe83('0x41')](_0xfe83('0xec')));};Preview[_0xfe83('0xd')][_0xfe83('0xb0')]=function(_0x367deb){return Promise[_0xfe83('0xed')]()[_0xfe83('0x5a')](cmHopperAdditionalPhone[_0xfe83('0xb0')](_0x367deb))[_0xfe83('0x63')](logger['info'](_0xfe83('0xee')));};Preview['prototype']['checkInBlack']=function(_0x28130c,_0x5eb5c4,_0x5bfc49,_0x2966e2,_0xa51e84){var _0x2588ce=this;return new Promise(function(_0x4688ac,_0x5a8e7d){if(_[_0xfe83('0x40')](_0x5eb5c4)||_[_0xfe83('0x40')](_0x5eb5c4['Contact'])||_[_0xfe83('0x40')](_0x5eb5c4[_0xfe83('0xef')])||_[_0xfe83('0x40')](_0x5eb5c4[_0xfe83('0x49')])){_0x5a8e7d(ut[_0xfe83('0x4d')]('Contact\x20is\x20undefined',_0x2966e2,_0xa51e84));return;}var _0x5bca66=uuid['v4']();var _0x357c14=_0x2588ce[_0xfe83('0x10')][_0x5eb5c4[_0xfe83('0x43')][_0xfe83('0x25')]];var _0xc9b3a5=_0x5bfc49?_0x2588ce[_0xfe83('0x14')][_0x5bfc49]['id']:undefined;_0x2588ce['actions'][_0x5bca66]=new Action(_0x5eb5c4,_0x357c14,_0x5bca66,_0x5bfc49,_0xc9b3a5);var _0x58647e=_0x2588ce[_0xfe83('0x13')][_0x5bca66];_0x58647e[_0xfe83('0xaf')]=_0x2966e2;_0x58647e[_0xfe83('0x8a')]=_0xa51e84;_0x58647e['lookAgent']=_0x5bfc49;if(_[_0xfe83('0xf0')](_0x28130c)){_0x2588ce[_0xfe83('0xf1')](_0x58647e,_0x357c14,_0x5eb5c4,_0x5bfc49)[_0xfe83('0x5a')](function(_0x3d289a){logger[_0xfe83('0x41')](_0xfe83('0xf2'),_0xfe83('0xf3')+_0x58647e[_0xfe83('0x45')]+'\x20IdHopper:\x20'+_0x58647e[_0xfe83('0x8d')],JSON[_0xfe83('0x44')](_0x3d289a));ami[_0xfe83('0x22')](_0xfe83('0xf4'),ut[_0xfe83('0x7c')](_0x58647e,_0xfe83('0xf5'),_0x2588ce['campaignsPreview'][_0x58647e[_0xfe83('0x45')]]));_0x4688ac(ut[_0xfe83('0x4d')]('Calling'));})[_0xfe83('0x63')](function(_0x2aa9cd){ut[_0xfe83('0x2e')](_0xfe83('0xf6'),_0x2aa9cd);_0x5a8e7d(ut[_0xfe83('0x4d')](_0xfe83('0xf7'),_0x2966e2,_0xa51e84));});}else{_0x357c14[_0xfe83('0xf8')]+=0x1;ut[_0xfe83('0xf9')](_0x58647e);rpcDb[_0xfe83('0xfa')](_0x58647e,_0xfe83('0xfb'));delete _0x2588ce['actions'][_0x5bca66];_0x5a8e7d(ut[_0xfe83('0x4d')](_0xfe83('0xfc'),_0x2966e2,_0xa51e84));}});};Preview['prototype'][_0xfe83('0x73')]=function(_0x4e75c1){return!_['isNil'](_0x4e75c1)&&!_[_0xfe83('0x40')](_0x4e75c1[_0xfe83('0x25')])&&!_[_0xfe83('0x40')](_0x4e75c1[_0xfe83('0xfd')])&&_0x4e75c1[_0xfe83('0xfd')]&&!_[_0xfe83('0x40')](this[_0xfe83('0x12')][util[_0xfe83('0x24')]('SIP/%s',_0x4e75c1[_0xfe83('0x25')])])&&!_[_0xfe83('0x40')](this['trunks'][util[_0xfe83('0x24')](_0xfe83('0xfe'),_0x4e75c1['name'])][_0xfe83('0x4b')])&&(this[_0xfe83('0x12')][util[_0xfe83('0x24')](_0xfe83('0xfe'),_0x4e75c1[_0xfe83('0x25')])]['status']===_0xfe83('0xff')||this[_0xfe83('0x12')][util['format'](_0xfe83('0xfe'),_0x4e75c1[_0xfe83('0x25')])]['status']===_0xfe83('0x100'));};Preview['prototype']['run']=function(_0x5864ac,_0x197009){return this['execRun'](_0x5864ac,_0x197009)[_0xfe83('0x5a')](function(_0x29df56){return _[_0xfe83('0x46')](_0x29df56,['message']);})['catch'](function(_0x29c7fc){if(_0x29c7fc[_0xfe83('0x101')]){rpcDb[_0xfe83('0x102')](_0x5864ac);}if(_0x29c7fc[_0xfe83('0xfd')]){rpcDb['disableContact'](_0x5864ac);}throw _[_0xfe83('0x46')](_0x29c7fc,[_0xfe83('0x4d')]);});};Preview['prototype']['execRun']=function(_0x3a1a5b,_0x1c854a){var _0x2cd14f=this;var _0x1c7d9e,_0x48ea73;return rpcDb[_0xfe83('0x103')](_0x3a1a5b)[_0xfe83('0x5a')](function(_0x3868aa){if(!_[_0xfe83('0x40')](_0x3868aa[0x0])){_0x48ea73=_0x3868aa[0x0][_0xfe83('0x104')]?![]:!![];_0x1c7d9e=_0x3868aa[0x0][_0xfe83('0x104')]?!![]:![];_0x1c7d9e=_0x1c854a?!![]:_0x1c7d9e;}var _0x3a8519=_0x2cd14f['validateContact'](_0x3868aa);if(_0x3a8519[_0xfe83('0x105')]){rpcDb[_0xfe83('0x106')](_[_0xfe83('0x46')](_0x3868aa[0x0],[_0xfe83('0x49'),_0xfe83('0xef')]))[_0xfe83('0x5a')](function(_0x2564b0){_0x2cd14f[_0xfe83('0x107')](_0x2564b0,_0x3868aa[0x0],_0x1c854a,_0x48ea73,_0x1c7d9e)['then'](function(_0x1971aa){return _0x1971aa;})[_0xfe83('0x63')](function(_0x3f1722){throw _0x3f1722;});})[_0xfe83('0x63')](function(_0x21b82f){ut[_0xfe83('0x2e')](_0xfe83('0x108'),_0x21b82f);throw ut[_0xfe83('0x4d')](_0xfe83('0x109'),_0x48ea73,_0x1c7d9e);});}else{throw ut[_0xfe83('0x4d')](_0x3a8519[_0xfe83('0x4d')],_0x48ea73,_0x1c7d9e);}})['catch'](function(_0x24c5b1){ut['logger'](_0xfe83('0x10a'),_0x24c5b1);throw ut[_0xfe83('0x4d')](_0xfe83('0x109'),![],!![]);});};Preview[_0xfe83('0xd')][_0xfe83('0x10b')]=function(_0x16ff31){if(_[_0xfe83('0x40')](_0x16ff31)||_[_0xfe83('0xf0')](_0x16ff31)||!_[_0xfe83('0x40')](_0x16ff31[0x0][_0xfe83('0x5e')])&&_[_0xfe83('0x40')](_0x16ff31[0x0]['Agent'][_0xfe83('0x25')])){ut[_0xfe83('0x2e')](_0xfe83('0x10c'),_0x16ff31);return{'isValid':![],'message':_0xfe83('0x10d')};}var _0x963e74=this[_0xfe83('0x10')][_0x16ff31[0x0][_0xfe83('0x43')]['name']];_0x963e74['message']=utils[_0xfe83('0x2c')][_0xfe83('0x75')];if(_[_0xfe83('0x40')](_0x963e74)){ut[_0xfe83('0x2e')](_0xfe83('0x10e'),_0x963e74);return{'isValid':![],'message':_0xfe83('0x10f')};}if(!this[_0xfe83('0x73')](_0x963e74[_0xfe83('0x110')])){ut[_0xfe83('0x2e')](_0xfe83('0x111'),_0xfe83('0x112')+_0x963e74[_0xfe83('0x25')]+_0xfe83('0x113'));if(!this[_0xfe83('0x73')](_0x963e74['TrunkBackup'])){ut['logger'](_0xfe83('0x111'),_0x963e74[_0xfe83('0x25')]+'\x20Trunk\x20Backup\x20is\x20not\x20active');return{'isValid':![],'message':_0xfe83('0x114')};}}if(!ut['isActive'](_0x963e74['dialActive'])){ut[_0xfe83('0x2e')](_0xfe83('0x115'),_0x963e74[_0xfe83('0x25')]+_0xfe83('0x116'));return{'isValid':![],'message':_0xfe83('0x112')+_0x963e74['name']+_0xfe83('0x116')};}return{'isValid':!![],'message':'Is\x20Valid'};};Preview[_0xfe83('0xd')][_0xfe83('0xf1')]=function(_0x407c7f,_0x26670f,_0x440b03,_0x32481e){var _0xb9109b=this;return new Promise(function(_0x5a2b04,_0x35192c){var _0x4d7729=_0x407c7f[_0xfe83('0x92')];var _0x20440a=_0xb9109b[_0xfe83('0x73')](_0x26670f[_0xfe83('0x110')])?util['format'](_0xfe83('0x117'),_0x26670f['Trunk'][_0xfe83('0x25')],_[_0xfe83('0x40')](_0x26670f['dialPrefix'])?'':_0x26670f['dialPrefix']['trim']()||'',_0x26670f[_0xfe83('0x118')]>0x0?_0x440b03[_0xfe83('0xef')]['substring'](_0x26670f['dialCutDigit']):_0x440b03[_0xfe83('0xef')]):util[_0xfe83('0x24')](_0xfe83('0x117'),_[_0xfe83('0x40')](_0x26670f[_0xfe83('0x74')])?_0x26670f[_0xfe83('0x110')]['name']:_0x26670f[_0xfe83('0x74')][_0xfe83('0x25')],_[_0xfe83('0x40')](_0x26670f['dialPrefix'])?'':_0x26670f[_0xfe83('0x119')][_0xfe83('0x11a')]()||'',_0x26670f[_0xfe83('0x118')]>0x0?_0x440b03[_0xfe83('0xef')][_0xfe83('0x11b')](_0x26670f['dialCutDigit']):_0x440b03[_0xfe83('0xef')]);var _0x32b9f7=_0xb9109b[_0xfe83('0x73')](_0x26670f[_0xfe83('0x110')])?ut[_0xfe83('0x11c')](_0x26670f[_0xfe83('0x110')][_0xfe83('0x11d')],_0x26670f['dialOriginateCallerIdName'],_0x26670f[_0xfe83('0x11e')]>0x0?ut[_0xfe83('0x11f')](_0x26670f[_0xfe83('0x120')],_0x26670f['dialRandomLastDigitCallerIdNumber']):_0x26670f[_0xfe83('0x120')]):ut[_0xfe83('0x11c')](_[_0xfe83('0x40')](_0x26670f['TrunkBackup'])?_0x26670f[_0xfe83('0x110')][_0xfe83('0x11d')]:_0x26670f[_0xfe83('0x74')]['callerid'],_0x26670f['dialOriginateCallerIdName'],_0x26670f[_0xfe83('0x11e')]>0x0?ut[_0xfe83('0x11f')](_0x26670f[_0xfe83('0x120')],_0x26670f['dialRandomLastDigitCallerIdNumber']):_0x26670f[_0xfe83('0x120')]);if(_0x32b9f7){_0x407c7f[_0xfe83('0x121')]=ut['extractCalleridName'](_0x32b9f7);_0x407c7f[_0xfe83('0x122')]=ut[_0xfe83('0x123')](_0x32b9f7);}var _0x40aa2b=ut['addVariables'](_0x26670f,_0x440b03,_0x20440a,_0x32b9f7,_0x4d7729,_0x407c7f);var _0xbf9a3f=utils[_0xfe83('0x124')](_0x440b03[_0xfe83('0x125')]);Object['assign'](_0x40aa2b,_0xbf9a3f);_[_0xfe83('0x126')](_0x407c7f,ut[_0xfe83('0x127')](_0x40aa2b));_0x407c7f[_0xfe83('0x65')]=moment()[_0xfe83('0x24')]('YYYY-MM-DD\x20HH:mm:ss');_0x26670f[_0xfe83('0x128')]=_0x40aa2b;var _0x3ae50a=ut[_0xfe83('0x129')](_0x407c7f,_0x26670f,_0x40aa2b,_0x407c7f[_0xfe83('0x8a')],_0x32481e);return ami[_0xfe83('0x4a')](_0x3ae50a)[_0xfe83('0x5a')](function(_0x41ee07){_0x26670f[_0xfe83('0x29')]+=0x1;logger[_0xfe83('0x41')](_0xfe83('0x12a'),_0x4d7729,_0xfe83('0xa5'),_0x26670f['name'],_0xfe83('0x12b'),_0x26670f[_0xfe83('0x29')]);_0x5a2b04(_0x41ee07);})['catch'](function(_0x403a23){ut[_0xfe83('0xe3')](_0x407c7f,0xe,_0xfe83('0x12c'));rpcDb[_0xfe83('0xe1')](_0x407c7f,_0xfe83('0x12d'));_0x35192c(_0x403a23);});});};Preview[_0xfe83('0xd')][_0xfe83('0x12e')]=function(_0x2553d4){if(this[_0xfe83('0x13')][_0x2553d4['linkedid']]){this[_0xfe83('0x13')][_0x2553d4[_0xfe83('0x8b')]][_0xfe83('0x4c')]=_0x2553d4[_0xfe83('0x4c')];}};Preview[_0xfe83('0xd')][_0xfe83('0x12f')]=function(_0x144627){var _0xba816d=this;var _0x1c4774=this[_0xfe83('0x13')][_0x144627[_0xfe83('0x130')]];if(_0x1c4774){if(_0x1c4774[_0xfe83('0x131')]&&this['agents'][_0x1c4774[_0xfe83('0x131')]]){ut[_0xfe83('0x132')](_0x1c4774,this['agents'][_0x1c4774['lookAgent']][_0xfe83('0x25')],this[_0xfe83('0x14')][_0x1c4774[_0xfe83('0x131')]]['id']);}var _0x29b434=_['clone'](_0x1c4774);_0x29b434[_0xfe83('0x90')]=moment()[_0xfe83('0x24')](_0xfe83('0x66'));var _0x541c5d=_0xba816d[_0xfe83('0x10')][_0x1c4774[_0xfe83('0x45')]];if(ut[_0xfe83('0x133')](_0x144627[_0xfe83('0x134')])){if(_0x1c4774[_0xfe83('0xaf')]){rpcDb[_0xfe83('0x102')](_0x1c4774[_0xfe83('0x8d')]);}if(_0x1c4774[_0xfe83('0x8a')]){rpcDb[_0xfe83('0x64')](_0x1c4774[_0xfe83('0x8d')]);}ami[_0xfe83('0x22')](_0xfe83('0x135'),ut[_0xfe83('0x7c')](_0x1c4774,_0xfe83('0x136'),this[_0xfe83('0x10')][_0x1c4774['queue']]));this[_0xfe83('0xde')](_0x29b434,_0x541c5d,_0x144627);}else{_0x1c4774['starttime']=moment()['format'](_0xfe83('0x66'));ut['logAgent'](_0x29b434,0x4,_0xfe83('0x137'));rpcDb[_0xfe83('0xe1')](_0x29b434,_0xfe83('0x138'));}}};Preview[_0xfe83('0xd')][_0xfe83('0x139')]=function(_0x449fdb){var _0x2c3c32=this[_0xfe83('0x13')][_0x449fdb[_0xfe83('0x8b')]];var _0x2b9e4a;if(_0x2c3c32){_0x2b9e4a=this[_0xfe83('0x10')][_0x2c3c32[_0xfe83('0x45')]];logger[_0xfe83('0x41')](_0xfe83('0x13a'),_0x449fdb[_0xfe83('0x8b')],_0xfe83('0xa5'),_0x2b9e4a['name'],_0xfe83('0x93'),_0x2b9e4a['pTalking']);}if(this[_0xfe83('0x13')][_0x449fdb[_0xfe83('0x8b')]]&&_0x449fdb[_0xfe83('0x8b')]!==_0x449fdb[_0xfe83('0x92')]){if(_0x449fdb['cause']==='16'&&this[_0xfe83('0x13')][_0x449fdb['linkedid']]['dialAnswer']){this[_0xfe83('0x76')](_0x449fdb,_0x449fdb[_0xfe83('0x8b')],_0x449fdb[_0xfe83('0x13b')]);}else if(this[_0xfe83('0x13')][_0x449fdb[_0xfe83('0x8b')]]['dialAnswer']){logger[_0xfe83('0x41')](_0xfe83('0x13c'),_0x449fdb[_0xfe83('0x8b')],_0x449fdb[_0xfe83('0x13b')],_0xfe83('0xa5'),_0x2b9e4a[_0xfe83('0x25')],_0xfe83('0x93'),_0x2b9e4a[_0xfe83('0x2a')]);this[_0xfe83('0x76')](_0x449fdb,_0x449fdb[_0xfe83('0x8b')],_0x449fdb['cause']);}}else if(_0x2c3c32&&_[_0xfe83('0x40')](_0x2c3c32[_0xfe83('0x13d')])&&_0x2b9e4a[_0xfe83('0x13e')]&&_0x449fdb[_0xfe83('0x8b')]===_0x449fdb[_0xfe83('0x92')]&&_['isNil'](_0x449fdb[_0xfe83('0xe8')])&&_0x449fdb['cause']==='16'&&_0x449fdb[_0xfe83('0x13f')]==='6'&&_['isUndefined'](_0x2c3c32[_0xfe83('0x140')])){if(_0x2c3c32[_0xfe83('0xaf')]){rpcDb[_0xfe83('0x102')](_0x2c3c32[_0xfe83('0x8d')]);}if(_0x2c3c32[_0xfe83('0x8a')]){rpcDb[_0xfe83('0x64')](_0x2c3c32[_0xfe83('0x8d')]);}_0x449fdb[_0xfe83('0xe8')]='22';this[_0xfe83('0xde')](_0x2c3c32,_0x2b9e4a,_0x449fdb);}else if(_0x2c3c32&&_0x2c3c32['transfer']){if(_0x449fdb[_0xfe83('0x13b')]==='16'&&this[_0xfe83('0x13')][_0x449fdb[_0xfe83('0x8b')]][_0xfe83('0x4f')]){logger[_0xfe83('0x41')]('[syncHangup][talking][transfer]',_0x449fdb[_0xfe83('0x8b')],_0x449fdb[_0xfe83('0x13b')],_0xfe83('0xa5'),_0x2b9e4a[_0xfe83('0x25')],'pTalking:\x20',_0x2b9e4a[_0xfe83('0x2a')]);this['callProgressDetectingCustomer'](_0x449fdb,_0x449fdb[_0xfe83('0x8b')],_0x449fdb[_0xfe83('0x13b')]);}else if(this[_0xfe83('0x13')][_0x449fdb['linkedid']]['dialAnswer']){logger[_0xfe83('0x41')](_0xfe83('0x13c'),_0x449fdb[_0xfe83('0x8b')],_0x449fdb[_0xfe83('0x13b')],'\x20Queue',_0x2b9e4a[_0xfe83('0x25')],_0xfe83('0x93'),_0x2b9e4a[_0xfe83('0x2a')]);this[_0xfe83('0x76')](_0x449fdb,_0x449fdb[_0xfe83('0x8b')],_0x449fdb[_0xfe83('0x13b')]);}}};Preview[_0xfe83('0xd')][_0xfe83('0x1b')]=function(_0x3da189){if(this[_0xfe83('0x13')][_0x3da189[_0xfe83('0xdc')]]&&_0x3da189[_0xfe83('0xdc')]!==_0x3da189['destuniqueid']){this[_0xfe83('0x76')](_0x3da189,_0x3da189['destlinkedid'],_0x3da189[_0xfe83('0xd4')]);}};Preview['prototype'][_0xfe83('0x19')]=function(_0x23e9d8){if(this[_0xfe83('0x13')][_0x23e9d8['linkedid']]&&_0x23e9d8['linkedid']!==_0x23e9d8[_0xfe83('0x92')]&&!this[_0xfe83('0x13')][_0x23e9d8[_0xfe83('0x8b')]][_0xfe83('0x4f')]){if(_0x23e9d8[_0xfe83('0x13b')]==='1'){this['callProgressDetectingCustomer'](_0x23e9d8,_0x23e9d8['linkedid'],_0x23e9d8[_0xfe83('0x13b')]);}}};Preview[_0xfe83('0xd')]['addVariable']=function(_0x42fb78,_0x5b8ce7,_0x1d0006){if(this[_0xfe83('0x13')][_0x42fb78]){if(_['isNil'](this[_0xfe83('0x13')][_0x42fb78][_0xfe83('0x128')])){this['actions'][_0x42fb78]['variables']={};}this['actions'][_0x42fb78][_0xfe83('0x128')][_0x5b8ce7]=_0x1d0006;}};Preview[_0xfe83('0xd')][_0xfe83('0x1e')]=function(_0x48021e){try{if(!_[_0xfe83('0x40')](_0x48021e)){if(ut[_0xfe83('0x141')](_['keys'](_0x48021e[_0xfe83('0x142')])[0x0])){this[_0xfe83('0x143')](_0x48021e['uniqueid'],_[_0xfe83('0x144')](_0x48021e[_0xfe83('0x142')])[0x0],_0x48021e[_0xfe83('0x145')]);}}}catch(_0x3b8f70){logger['error'](_0xfe83('0x146'),util[_0xfe83('0x147')](_0x3b8f70,{'showHidden':![],'depth':null}));}};Preview['prototype']['syncAttendedTransfer']=function(_0x4982cc){if(_0x4982cc){if(this[_0xfe83('0x13')][_0x4982cc['transfertargetlinkedid']]){this['actions'][_0x4982cc['transfertargetlinkedid']][_0xfe83('0x140')]=!![];}}};Preview[_0xfe83('0xd')][_0xfe83('0x148')]=function(_0x5f3ef2){if(_0x5f3ef2){if(this[_0xfe83('0x13')][_0x5f3ef2[_0xfe83('0x149')]]){this[_0xfe83('0x13')][_0x5f3ef2['transfererlinkedid']][_0xfe83('0x140')]=!![];}}};module[_0xfe83('0x14a')]=Preview;