51b7d8b2ce33b5814dedfeabad79ed343b84d258
[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 _0x6334=['outboundBusyCallsDay','outboundCongestionCallsDay','outboundDropCallsDayACS','outboundDropCallsDayTimeout','outboundNoAnswerCallsDay','outboundNoSuchCallsDay','outboundOriginateFailureCallsDay','outboundReCallsDay','outboundRejectCallsDay','outboundAbandonedCallsDay','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalDroppedCallsTimeout','predictiveIntervalErlangCalls','predictiveIntervalErlangCallsDroppedCalls','predictiveIntervalHitRate','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','message','originated','erlangCalls','erlangBusyFactor','startPredictive','Trunk','callerid','Interval','voice:queue:%s','voice_queue:save','stringify','voice_queue_presence:remove','sendMessageOneNotActive','available','NOT_ACTIVE','logger','[CampaignPreview]\x20Campaign\x20Queue:\x20','\x20is\x20not\x20active','IS_DISACTIVED','\x20is\x20disactive','syncCampaigns','hasOwnProperty','booked','clearZombieChannels','setMessage','dialPreviewAutoRecallMe','recallMe','clearZombieChannel','enqueue','info','queue','originated:\x20','campaignsPreview','actions','pTalking:\x20','pick','contactId','UserId','VoiceQueueId','status','channel','catch','No\x20such\x20channel','updateOriginated','[clearZombieChannel]','loggerError','[Dialer][checkChannel][Preview]','[action]','getContactRecallMe','agentReadyId','agents','isNil','length','getDiff','scheduledat','dialRecallMeTimeout','Agent','voicePause','run','[RecallMe]','logger2','starttime','format','YYYY-MM-DD\x20HH:mm:ss','RecallInQueue','dialRecallInQueue','rescheduleContactInQueue','createBody','createCustomerHistory','logCustomer','RecallFailedTimeout','createCustomerFinal','[HistoryRecallClose]','[getContactRecallMe]','IsNotLoggedIn','isActive','isTrunkReachable','TrunkBackup','TRUNK_IS_NOT_REACHABLE','ACTIVE','countnosuchnumberretry','countglobal','totalGlobal','custom:agentnosuchnumber','buildObj','nosuchnumber','cloneAction','[callProgressDetectingCustomer][logNoSuchGlobal]','rescheduleContact','scheduledAt','dialNoSuchNumberRetryFrequency','unlockAgent','activeContact','linkedid','responsetime','answertime','dialAnswer','uniqueid','\x20Queue','custom:agentconnect','connect','complete','decrementTalkink','[16]','[callProgressDetectingCustomer][logAnswer]','[callProgressDetectingCustomer][logAnswerGlobal]','crateCustomerReportQueue','talktime','BUSY','countbusyretry','Busy','custom:agentbusy','busy','[callProgressDetectingCustomer][logBusy]','dialGlobalMaxRetry','[callProgressDetectingCustomer][logBusyGlobal]','dialBusyMaxRetry','dialBusyRetryFrequency','NOANSWER','NoAnswer','custom:agentnoanswer','noanswer','Global','[callProgressDetectingCustomer][logNoAnswerGlobal]','countnoanswerretry','[callProgressDetectingCustomer][logNoAnswer]','dialNoAnswerRetryFrequency','CONGESTION','countcongestionretry','Congestion','custom:agentcongestion','congestion','[callProgressDetectingCustomer][logCongestion]','[callProgressDetectingCustomer][logCongestionGlobal]','CANCEL','countagentrejectretry','custom:agentreject','agentreject','[syncHangupRequest][logAgentReject]','AgentReject','[callProgressDetectingCustomer][logAgentReject]','dialAgentRejectMaxRetry','ABANDONED','countabandonedretry','Abandoned','[callProgressDetectingCustomer][logAbandoned]','dialAbandonedMaxRety','outboundUnknownCallsDay','custom:amd','amd','[callProgressDetectingCustomer][hangupInAMD]','cause-txt','dialstatus','[callProgressDetectingCustomer][machine]','[Dialer][decrementTalkink][no\x20Hangup][Preview]','[callProgressDetectingCustomer][logUnknown]','ANSWER','destlinkedid','isUndefined','object','reason','logAgent','NoSuchNumber','createAgentHistory','[callProgressDetectingAgent][logNoAnswer]','AnswerAGI','[callProgressDetectingAgent][logAnswerAGI]','[callProgressDetectingAgent][logCongestion]','[callProgressDetectingAgent]','[originated][decrement][callProgressDetectingAgent]','Queue','lookAgent','isEmpty','then','[Preview][execCall][success]','Queue:\x20','\x20IdHopper:\x20','custom:agentcalled','called','Call\x20failed','logBlacklist','createHistory','[Blacklist][error]','Contact\x20in\x20black\x20List','active','SIP/%s','reachable','unmonitored','execRun','unlockContact','disableContact','recallme','validateContact','isValid','checkInBlack','[Preview][checkIsBlackList]','Call\x20unsuccessful','[Preview][getContactPreview]','[Preview][validateContact][Empty\x20Contact]','Empty\x20Contact','Empty\x20Campaign','[Preview][validateContact][Trunk\x20not\x20work]','campaign\x20Name:\x20','\x20Trunk\x20is\x20not\x20active','\x20Trunk\x20Backup\x20is\x20not\x20active','Trunk\x20not\x20work','[Preview][validateContact][Campaign\x20Active]','\x20Not\x20Active','dialCutDigit','Contact','phone','substring','SIP/%s/%s%s','trim','getCallerId','dialRandomLastDigitCallerIdNumber','extractCalleridName','originatecalleridnum','extractCalleridNumber','addVariables','toLowerVariables','Action','variablesAction','[originated][increment]','OriginateError','[originateFailure][logOriginateFailure]','syncNewExten','syncOriginateResponse','actionid','logLookAgent','clone','idContact','custom:agentringnoanswer','rejected','Answer','syncHangup','[syncHangup][talking]','cause','callProgressDetectingCustomer','[syncHangup][talking][cause]','statedesc','dialQueueProject','channelstate','transfer','callProgressDetectingAgent','[syncHangup][talking][transfer]','destuniqueid','addVariable','variables','filterKey','keys','variable','value','[syncVarSet][Preview]','inspect','syncAttendedTransfer','transfertargetlinkedid','syncBlindTransfer','transfererlinkedid','exports','util','lodash','bluebird','uuid','moment','md5','../../../config/environment','../../../config/logger','preview','actionPreview','../ami','./rpcDb','./util/util','defaults','redis','socket.io-emitter','prototype','tail','finally','sequence','voiceQueues','trunks','clockClearZombieChannels','originateresponse','hangup','bind','hanguprequest','syncHangupRequest','syncDialEnd','newexten','varset','syncVarSet','attendedtransfer','blindtransfer','loopCampaigns','emit','type','outbound','name','answered','loggedIn','pTalking','sumBillable','sumDuration','sumHoldTime','total','unmanaged','abandoned','waiting','loggedInDb','dialActive','dialMethod','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialOriginateTimeout','dialPrefix','outboundAnswerAgiCallsDay','outboundAnswerCallsDay','outboundBlacklistCallsDay'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x6334,0x119));var _0x4633=function(_0x5651ef,_0x4fd99a){_0x5651ef=_0x5651ef-0x0;var _0x392fba=_0x6334[_0x5651ef];return _0x392fba;};'use strict';var util=require(_0x4633('0x0'));var _=require(_0x4633('0x1'));var BPromise=require(_0x4633('0x2'));var uuid=require(_0x4633('0x3'));var moment=require(_0x4633('0x4'));var md5=require(_0x4633('0x5'));var Redis=require('ioredis');var config=require(_0x4633('0x6'));var logger=require(_0x4633('0x7'))(_0x4633('0x8'));var loggerAction=require(_0x4633('0x7'))(_0x4633('0x9'));var ami=require(_0x4633('0xa'));var rpcDb=require(_0x4633('0xb'));var Action=require('./action');var ut=require(_0x4633('0xc'));config['redis']=_[_0x4633('0xd')](config[_0x4633('0xe')],{'host':'localhost','port':0x18eb});var io=require(_0x4633('0xf'))(new Redis(config[_0x4633('0xe')]));var Sequence=function(){};Sequence[_0x4633('0x10')]['enqueue']=function(_0x45a590){this[_0x4633('0x11')]=this['tail']?this[_0x4633('0x11')][_0x4633('0x12')](_0x45a590):_0x45a590();};function Preview(_0x42fe10){this[_0x4633('0x13')]=new Sequence();this['campaignsPreview']=_0x42fe10[_0x4633('0x14')];this[_0x4633('0x15')]=_0x42fe10[_0x4633('0x15')];this['actions']={};this['agents']=_0x42fe10['agents'];this[_0x4633('0x16')]=0x0;ami['on'](_0x4633('0x17'),this['syncOriginateResponse']['bind'](this));ami['on'](_0x4633('0x18'),this['syncHangup'][_0x4633('0x19')](this));ami['on'](_0x4633('0x1a'),this[_0x4633('0x1b')][_0x4633('0x19')](this));ami['on']('dialend',this[_0x4633('0x1c')][_0x4633('0x19')](this));ami['on'](_0x4633('0x1d'),this['syncNewExten'][_0x4633('0x19')](this));ami['on'](_0x4633('0x1e'),this[_0x4633('0x1f')][_0x4633('0x19')](this));ami['on'](_0x4633('0x20'),this['syncAttendedTransfer'][_0x4633('0x19')](this));ami['on'](_0x4633('0x21'),this['syncBlindTransfer']['bind'](this));this[_0x4633('0x22')](this['campaignsPreview']);}function emit(_0x35e2ad,_0x5b5011,_0x57dfb8){io['to'](_0x35e2ad)[_0x4633('0x23')](_0x5b5011,_0x57dfb8);}function emitCampaignPreview(_0x177b39){if(_0x177b39[_0x4633('0x24')]===_0x4633('0x25')){var _0xd1fcc6={'id':_0x177b39['id'],'name':_0x177b39[_0x4633('0x26')],'strategy':_0x177b39['strategy'],'answered':_0x177b39[_0x4633('0x27')],'available':_0x177b39['available'],'loggedIn':_0x177b39[_0x4633('0x28')],'pTalking':_0x177b39[_0x4633('0x29')],'sumBillable':_0x177b39[_0x4633('0x2a')],'sumDuration':_0x177b39[_0x4633('0x2b')],'sumHoldTime':_0x177b39[_0x4633('0x2c')]||0x0,'talking':_0x177b39['talking'],'total':_0x177b39[_0x4633('0x2d')],'type':_0x177b39[_0x4633('0x24')],'unmanaged':_0x177b39[_0x4633('0x2e')],'abandoned':_0x177b39[_0x4633('0x2f')],'waiting':_0x177b39[_0x4633('0x30')],'loggedInDb':_0x177b39[_0x4633('0x31')],'dialActive':_0x177b39[_0x4633('0x32')],'dialMethod':_0x177b39[_0x4633('0x33')],'dialOriginateCallerIdName':_0x177b39[_0x4633('0x34')],'dialOriginateCallerIdNumber':_0x177b39[_0x4633('0x35')],'dialOriginateTimeout':_0x177b39[_0x4633('0x36')],'dialPrefix':_0x177b39[_0x4633('0x37')],'outboundAnswerAgiCallsDay':_0x177b39[_0x4633('0x38')],'outboundAnswerCallsDay':_0x177b39[_0x4633('0x39')],'outboundBlacklistCallsDay':_0x177b39[_0x4633('0x3a')],'outboundBusyCallsDay':_0x177b39[_0x4633('0x3b')],'outboundCongestionCallsDay':_0x177b39[_0x4633('0x3c')],'outboundDropCallsDayACS':_0x177b39[_0x4633('0x3d')],'outboundDropCallsDayCallersExit':_0x177b39['outboundDropCallsDayCallersExit'],'outboundDropCallsDayTimeout':_0x177b39[_0x4633('0x3e')],'outboundNoAnswerCallsDay':_0x177b39[_0x4633('0x3f')],'outboundNoSuchCallsDay':_0x177b39[_0x4633('0x40')],'outboundOriginateFailureCallsDay':_0x177b39[_0x4633('0x41')],'outboundReCallsDay':_0x177b39[_0x4633('0x42')],'outboundRejectCallsDay':_0x177b39[_0x4633('0x43')],'outboundUnknownCallsDay':_0x177b39['outboundUnknownCallsDay'],'outboundAbandonedCallsDay':_0x177b39[_0x4633('0x44')],'predictiveIntervalAnsweredCalls':_0x177b39['predictiveIntervalAnsweredCalls'],'predictiveIntervalAvgHoldtime':_0x177b39[_0x4633('0x45')],'predictiveIntervalAvgTalktime':_0x177b39[_0x4633('0x46')],'predictiveIntervalDroppedCallsCallersExit':_0x177b39[_0x4633('0x47')],'predictiveIntervalDroppedCallsTimeout':_0x177b39[_0x4633('0x48')],'predictiveIntervalErlangCalls':_0x177b39[_0x4633('0x49')],'predictiveIntervalErlangCallsDroppedCalls':_0x177b39[_0x4633('0x4a')],'predictiveIntervalHitRate':_0x177b39[_0x4633('0x4b')],'predictiveIntervalMultiplicativeFactor':_0x177b39[_0x4633('0x4c')],'predictiveIntervalPauses':_0x177b39[_0x4633('0x4d')],'predictiveIntervalAvailable':_0x177b39[_0x4633('0x4e')],'predictiveIntervalTotalCalls':_0x177b39[_0x4633('0x4f')],'message':_0x177b39[_0x4633('0x50')],'originated':_0x177b39[_0x4633('0x51')],'erlangCalls':_0x177b39[_0x4633('0x52')],'erlangCallToSecond':_0x177b39['erlangCallToSecond'],'erlangAbandonmentRate':_0x177b39['erlangAbandonmentRate'],'erlangBusyFactor':_0x177b39[_0x4633('0x53')],'startPredictive':_0x177b39[_0x4633('0x54')],'startProgressive':_0x177b39['startProgressive']};if(_0x177b39[_0x4633('0x55')]){_0xd1fcc6[_0x4633('0x55')]={'id':_0x177b39[_0x4633('0x55')]['id'],'name':_0x177b39[_0x4633('0x55')]['name'],'active':_0x177b39[_0x4633('0x55')]['active'],'callerid':_0x177b39[_0x4633('0x55')][_0x4633('0x56')]};}if(_0x177b39[_0x4633('0x57')]){_0xd1fcc6[_0x4633('0x57')]={'id':_0x177b39[_0x4633('0x57')]['id'],'name':_0x177b39[_0x4633('0x57')][_0x4633('0x26')]};}var _0x439a04=md5(JSON['stringify'](_0xd1fcc6));if(_0x177b39[_0x4633('0x5')]!==_0x439a04){_0x177b39[_0x4633('0x5')]=_0x439a04;emit(util['format'](_0x4633('0x58'),_0xd1fcc6[_0x4633('0x26')]),_0x4633('0x59'),_0xd1fcc6);}}}function emitVoiceQueueChannelRemove(_0x468648){logger['info']('[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event',JSON[_0x4633('0x5a')](_0x468648));emit(util['format']('voice:queue:%s',_0x468648[_0x4633('0x26')]),'voice_queue_channel:remove',_0x468648);io['emit'](_0x4633('0x5b'),_0x468648);}function notSendMessagesQueue(_0x433d2d){if(_0x433d2d[_0x4633('0x5c')]){if(_0x433d2d[_0x4633('0x51')]===0x0&&_0x433d2d[_0x4633('0x29')]===0x0){_0x433d2d['sendMessageOneNotActive']=![];_0x433d2d[_0x4633('0x5d')]=0x0;_0x433d2d['paused']=0x0;_0x433d2d[_0x4633('0x50')]=_0x4633('0x5e');ut[_0x4633('0x5f')](_0x4633('0x60'),_0x433d2d['name']+_0x4633('0x61'));}else{_0x433d2d['message']=_0x4633('0x62');ut[_0x4633('0x5f')](_0x4633('0x60'),_0x433d2d[_0x4633('0x26')]+_0x4633('0x63'));}emitCampaignPreview(_0x433d2d);}}Preview['prototype']['loopCampaigns']=function(){var _0x2e071f=this;setInterval(function(){_0x2e071f[_0x4633('0x64')]();},0x7cf);};Preview[_0x4633('0x10')][_0x4633('0x64')]=function(){var _0x45fe39=this['campaignsPreview'];this[_0x4633('0x16')]+=0x1;for(var _0x5e443d in _0x45fe39){if(_0x45fe39[_0x4633('0x65')](_0x5e443d)&&(_0x45fe39[_0x5e443d]['dialMethod']===_0x4633('0x8')||_0x45fe39[_0x5e443d]['dialMethod']===_0x4633('0x66'))&&_0x45fe39[_0x5e443d][_0x4633('0x24')]===_0x4633('0x25')){if(this[_0x4633('0x16')]>0x7){this[_0x4633('0x16')]=0x0;this[_0x4633('0x67')]();}}if(_0x45fe39[_0x4633('0x65')](_0x5e443d)&&_0x45fe39[_0x5e443d][_0x4633('0x33')]===_0x4633('0x8')&&_0x45fe39[_0x5e443d][_0x4633('0x24')]===_0x4633('0x25')){if(_0x45fe39[_0x5e443d][_0x4633('0x32')]){this[_0x4633('0x68')](_0x45fe39[_0x5e443d]);if(_0x45fe39[_0x5e443d][_0x4633('0x69')])this[_0x4633('0x6a')](_0x45fe39[_0x5e443d]);}else{notSendMessagesQueue(_0x45fe39[_0x5e443d]);}}}};Preview[_0x4633('0x10')][_0x4633('0x6b')]=function(_0x1e533d){var _0x185647=this;this[_0x4633('0x13')][_0x4633('0x6c')](function(){if(!_['isNil'](_0x185647['actions'][_0x1e533d])){loggerAction[_0x4633('0x6d')]('[clearZombieChannels][talking]',_0x1e533d,'Queue',_0x185647['actions'][_0x1e533d][_0x4633('0x6e')],_0x4633('0x6f'),JSON['stringify'](_0x185647[_0x4633('0x70')][_0x185647[_0x4633('0x71')][_0x1e533d][_0x4633('0x6e')]][_0x4633('0x51')]),_0x4633('0x72'),JSON[_0x4633('0x5a')](_0x185647['campaignsPreview'][_0x185647['actions'][_0x1e533d]['queue']][_0x4633('0x29')]),JSON[_0x4633('0x5a')](_0x185647[_0x4633('0x71')][_0x1e533d]['dialAnswer']),JSON[_0x4633('0x5a')](_[_0x4633('0x73')](_0x185647['actions'][_0x1e533d],[_0x4633('0x74'),_0x4633('0x75'),_0x4633('0x76'),'ListId'])));return ami['Action']({'action':_0x4633('0x77'),'channel':_0x185647[_0x4633('0x71')][_0x1e533d][_0x4633('0x78')]})[_0x4633('0x79')](function(_0x129f87){if(_0x129f87['message']===_0x4633('0x7a')){setTimeout(function(){if(_0x185647[_0x4633('0x71')][_0x1e533d]){ut[_0x4633('0x7b')](_0x185647[_0x4633('0x70')][_0x185647[_0x4633('0x71')][_0x1e533d][_0x4633('0x6e')]],'[clearZombieChannel]');if(_0x185647[_0x4633('0x71')][_0x1e533d]['dialAnswer']===!![]){ut['decrementTalkink'](_0x185647['campaignsPreview'][_0x185647[_0x4633('0x71')][_0x1e533d][_0x4633('0x6e')]],_0x4633('0x7c'));ut[_0x4633('0x7d')]('[Dialer][checkChannel][pTalking][Preview]'+_0x1e533d,_0x185647[_0x4633('0x71')][_0x1e533d]['queue']);}ut[_0x4633('0x7d')](_0x4633('0x7e')+_0x1e533d,_0x185647[_0x4633('0x71')][_0x1e533d][_0x4633('0x6e')]);delete _0x185647[_0x4633('0x71')][_0x1e533d];}},0x2328);}});}});};Preview[_0x4633('0x10')][_0x4633('0x67')]=function(){var _0x28f083=this;loggerAction['info'](_0x4633('0x7f'),_['size'](this[_0x4633('0x71')]));for(var _0x22ed63 in this[_0x4633('0x71')]){if(_0x28f083[_0x4633('0x71')][_0x4633('0x65')](_0x22ed63)){_0x28f083[_0x4633('0x6b')](_0x22ed63);}}};Preview[_0x4633('0x10')][_0x4633('0x6a')]=function(_0x18163a){var _0x1e4c32=this;rpcDb[_0x4633('0x80')](_0x18163a['id'],ut[_0x4633('0x81')](this[_0x4633('0x82')]))['then'](function(_0x2c3c44){if(!_[_0x4633('0x83')](_0x2c3c44)){for(var _0xbc6448=0x0;_0xbc6448<_0x2c3c44[_0x4633('0x84')];_0xbc6448+=0x1){if(ut[_0x4633('0x85')](_0x2c3c44[_0xbc6448][_0x4633('0x86')])<_0x18163a[_0x4633('0x87')]*0x3c){if(_0x2c3c44[_0xbc6448][_0x4633('0x88')]&&!_0x2c3c44[_0xbc6448][_0x4633('0x88')][_0x4633('0x89')]){_0x1e4c32[_0x4633('0x8a')](_0x2c3c44[_0xbc6448]['id'])['then'](ut['logger2'](_0x4633('0x8b')))['catch'](ut[_0x4633('0x8c')](_0x4633('0x8b')));}else{rpcDb['disableContact'](_0x2c3c44[_0xbc6448]['id']);}}else{var _0x3fb667=new Action(_0x2c3c44[_0xbc6448],_0x18163a);_0x3fb667[_0x4633('0x8d')]=moment()[_0x4633('0x8e')](_0x4633('0x8f'));_0x18163a[_0x4633('0x42')]+=0x1;ut['logCustomer'](_0x3fb667,0x17,_0x4633('0x90'));if(_0x18163a[_0x4633('0x91')]){rpcDb[_0x4633('0x92')](ut[_0x4633('0x93')](_0x2c3c44[_0xbc6448]));rpcDb[_0x4633('0x94')](_0x3fb667,'[HistoryDialRecallInQueue][historyCatch]');}else{ut[_0x4633('0x95')](_0x3fb667,0x16,_0x4633('0x96'));rpcDb[_0x4633('0x94')](_0x3fb667,'[HistoryRecallClose]');rpcDb[_0x4633('0x97')](_0x3fb667,_0x4633('0x98'));}}}}})[_0x4633('0x79')](ut[_0x4633('0x8c')](_0x4633('0x99')));};Preview[_0x4633('0x10')][_0x4633('0x68')]=function(_0x2b4ff2){_0x2b4ff2[_0x4633('0x5c')]=!![];if(ut[_0x4633('0x9a')](_0x2b4ff2[_0x4633('0x28')])){_0x2b4ff2['message']='AGENTS_NOT_LOGGED';}else if(!ut[_0x4633('0x9b')](_0x2b4ff2[_0x4633('0x32')])){_0x2b4ff2[_0x4633('0x50')]='NOT_ACTIVE';}else if(!this['isTrunkReachable'](_0x2b4ff2[_0x4633('0x55')])){if(!this[_0x4633('0x9c')](_0x2b4ff2[_0x4633('0x9d')])){_0x2b4ff2['message']=_0x4633('0x9e');}else{_0x2b4ff2[_0x4633('0x50')]=_0x4633('0x9f');}}else{_0x2b4ff2['message']='ACTIVE';}emitCampaignPreview(_0x2b4ff2);};Preview[_0x4633('0x10')]['callProgressDetectingCustomer']=function(_0x239269,_0x89146e,_0x4bcb5c){var _0x158078=this;var _0x47108f=this[_0x4633('0x71')][_0x89146e];var _0x4040b8=this['campaignsPreview'][_0x47108f[_0x4633('0x6e')]];var _0x19758a;if(_0x4040b8){switch(_0x4bcb5c){case'1':_0x4040b8[_0x4633('0x40')]+=0x1;_0x47108f[_0x4633('0xa0')]+=0x1;_0x47108f[_0x4633('0xa1')]=ut[_0x4633('0xa2')](_0x47108f);ut[_0x4633('0x95')](_0x47108f,0x0,'NoSuchNumber');ami[_0x4633('0x23')](_0x4633('0xa3'),ut[_0x4633('0xa4')](_0x47108f,_0x4633('0xa5')));rpcDb['createCustomerHistory'](_0x47108f,'[callProgressDetectingCustomer][logNoSuch]');if(ut[_0x4633('0xa2')](_0x47108f)>=_0x4040b8['dialGlobalMaxRetry']){_0x19758a=ut[_0x4633('0xa6')](_0x47108f,0xf,'Global');rpcDb['createCustomerFinal'](_0x19758a,_0x4633('0xa7'));}else{if(_0x47108f[_0x4633('0xa0')]>=_0x4040b8['dialNoSuchNumberMaxRetry']){rpcDb[_0x4633('0x97')](_0x47108f,_0x4633('0xa7'));}else{rpcDb[_0x4633('0xa8')](ut[_0x4633('0xa9')](_0x47108f,_0x4633('0xa0'),_0x4040b8[_0x4633('0xaa')]),_0x47108f[_0x4633('0xab')],_0x47108f[_0x4633('0xac')]);}}delete this['actions'][_0x239269[_0x4633('0xad')]];break;case'ANSWER':var _0x1ba99d=moment()['format'](_0x4633('0x8f'));_0x47108f[_0x4633('0xae')]=_0x1ba99d;_0x47108f[_0x4633('0xaf')]=_0x1ba99d;_0x47108f[_0x4633('0xb0')]=!![];_0x4040b8[_0x4633('0x29')]+=0x1;logger[_0x4633('0x6d')]('[syncHangup][talking][increment]',_0x47108f[_0x4633('0xb1')],_0x4633('0xb2'),_0x4040b8[_0x4633('0x26')],'pTalking:\x20',_0x4040b8[_0x4633('0x29')]);ami[_0x4633('0x23')](_0x4633('0xb3'),ut[_0x4633('0xa4')](_0x47108f,_0x4633('0xb4'),this[_0x4633('0x70')][_0x47108f['queue']]));if(_0x4040b8['acw']){ami[_0x4633('0x23')]('custom:agentConnectPreview',ut['buildAcw'](_0x47108f));}break;case'16':ami['emit']('custom:agentcomplete',ut[_0x4633('0xa4')](_0x47108f,_0x4633('0xb5'),this[_0x4633('0x70')][_0x47108f[_0x4633('0x6e')]]));emitVoiceQueueChannelRemove(ut[_0x4633('0xa4')](_0x47108f,'complete'));_0x4040b8[_0x4633('0x39')]+=0x1;_0x4040b8[_0x4633('0x2d')]+=0x1;_0x4040b8[_0x4633('0x27')]+=0x1;ut[_0x4633('0xb6')](_0x4040b8,_0x4633('0xb7'));_0x47108f[_0x4633('0xa1')]=ut['totalGlobal'](_0x47108f);ut[_0x4633('0x95')](_0x47108f,0x4,'Answer');rpcDb[_0x4633('0x94')](_0x47108f,_0x4633('0xb8'));rpcDb['createCustomerFinal'](_0x47108f,_0x4633('0xb9'));rpcDb[_0x4633('0xba')](_0x47108f);_0x4040b8['sumDuration']+=_0x47108f[_0x4633('0xbb')];_0x4040b8[_0x4633('0x2a')]+=_0x47108f[_0x4633('0xbb')];logger['info']('[syncHangup][talking][decrement]',_0x47108f['uniqueid'],_0x4633('0xb2'),_0x4040b8['name'],_0x4633('0x72'),_0x4040b8['pTalking']);delete this[_0x4633('0x71')][_0x239269[_0x4633('0xad')]];break;case _0x4633('0xbc'):_0x4040b8[_0x4633('0x3b')]+=0x1;_0x47108f[_0x4633('0xbd')]+=0x1;_0x47108f[_0x4633('0xa1')]=ut[_0x4633('0xa2')](_0x47108f);ut[_0x4633('0x95')](_0x47108f,0x5,_0x4633('0xbe'));ami[_0x4633('0x23')](_0x4633('0xbf'),ut['buildObj'](_0x47108f,_0x4633('0xc0')));rpcDb[_0x4633('0x94')](_0x47108f,_0x4633('0xc1'));if(ut[_0x4633('0xa2')](_0x47108f)>=_0x4040b8[_0x4633('0xc2')]){_0x19758a=ut[_0x4633('0xa6')](_0x47108f,0xf,'Global');rpcDb[_0x4633('0x97')](_0x19758a,_0x4633('0xc3'));}else{if(_0x47108f[_0x4633('0xbd')]>=_0x4040b8[_0x4633('0xc4')]){rpcDb[_0x4633('0x97')](_0x47108f,_0x4633('0xc1'));}else{rpcDb[_0x4633('0xa8')](ut['scheduledAt'](_0x47108f,'countbusyretry',_0x4040b8[_0x4633('0xc5')]),_0x47108f['unlockAgent'],_0x47108f['activeContact']);}}break;case _0x4633('0xc6'):_0x4040b8['outboundNoAnswerCallsDay']+=0x1;_0x47108f['countnoanswerretry']+=0x1;_0x47108f[_0x4633('0xa1')]=ut[_0x4633('0xa2')](_0x47108f);ut[_0x4633('0x95')](_0x47108f,0x3,_0x4633('0xc7'));ami[_0x4633('0x23')](_0x4633('0xc8'),ut['buildObj'](_0x47108f,_0x4633('0xc9')));rpcDb[_0x4633('0x94')](_0x47108f,'[callProgressDetectingCustomer][logNoAnswer]');if(ut[_0x4633('0xa2')](_0x47108f)>=_0x4040b8[_0x4633('0xc2')]){_0x19758a=ut[_0x4633('0xa6')](_0x47108f,0xf,_0x4633('0xca'));rpcDb[_0x4633('0x97')](_0x19758a,_0x4633('0xcb'));}else{if(_0x47108f[_0x4633('0xcc')]>=_0x4040b8['dialNoAnswerMaxRetry']){rpcDb[_0x4633('0x97')](_0x47108f,_0x4633('0xcd'));}else{rpcDb['rescheduleContact'](ut[_0x4633('0xa9')](_0x47108f,_0x4633('0xcc'),_0x4040b8[_0x4633('0xce')]),_0x47108f[_0x4633('0xab')],_0x47108f['activeContact']);}}break;case _0x4633('0xcf'):_0x4040b8[_0x4633('0x3c')]+=0x1;_0x47108f[_0x4633('0xd0')]+=0x1;_0x47108f[_0x4633('0xa1')]=ut[_0x4633('0xa2')](_0x47108f);ut[_0x4633('0x95')](_0x47108f,0x8,_0x4633('0xd1'));ami['emit'](_0x4633('0xd2'),ut[_0x4633('0xa4')](_0x47108f,_0x4633('0xd3')));rpcDb[_0x4633('0x94')](_0x47108f,_0x4633('0xd4'));if(ut[_0x4633('0xa2')](_0x47108f)>=_0x4040b8[_0x4633('0xc2')]){_0x19758a=ut[_0x4633('0xa6')](_0x47108f,0xf,'Global');rpcDb['createCustomerFinal'](_0x19758a,_0x4633('0xd5'));}else{if(_0x47108f[_0x4633('0xd0')]>=_0x4040b8['dialCongestionMaxRetry']){rpcDb[_0x4633('0x97')](_0x47108f,_0x4633('0xd4'));}else{rpcDb[_0x4633('0xa8')](ut[_0x4633('0xa9')](_0x47108f,_0x4633('0xd0'),_0x4040b8[_0x4633('0xc5')]),_0x47108f[_0x4633('0xab')],_0x47108f[_0x4633('0xac')]);}}break;case _0x4633('0xd6'):_0x4040b8[_0x4633('0x43')]+=0x1;_0x47108f[_0x4633('0xd7')]+=0x1;_0x47108f[_0x4633('0xa1')]=ut['totalGlobal'](_0x47108f);ut[_0x4633('0x95')](_0x47108f,0x14,'AgentReject');ami[_0x4633('0x23')](_0x4633('0xd8'),ut[_0x4633('0xa4')](_0x47108f,_0x4633('0xd9')));rpcDb[_0x4633('0x94')](_0x47108f,_0x4633('0xda'));if(ut[_0x4633('0xa2')](_0x47108f)>=_0x4040b8['dialGlobalMaxRetry']){_0x19758a=ut[_0x4633('0xa6')](_0x47108f,0x14,_0x4633('0xdb'));rpcDb['createCustomerFinal'](_0x19758a,_0x4633('0xdc'));}else{if(_0x47108f[_0x4633('0xd7')]>=_0x4040b8[_0x4633('0xdd')]){rpcDb[_0x4633('0x97')](_0x47108f,_0x4633('0xdc'));}else{rpcDb[_0x4633('0xa8')](ut['scheduledAt'](_0x47108f,_0x4633('0xd7'),_0x4040b8['dialAgentRejectRetryFrequency']),_0x47108f['unlockAgent'],_0x47108f[_0x4633('0xac')]);}}break;case _0x4633('0xde'):_0x4040b8[_0x4633('0x44')]+=0x1;_0x47108f[_0x4633('0xdf')]+=0x1;_0x47108f[_0x4633('0xa1')]=ut[_0x4633('0xa2')](_0x47108f);ut[_0x4633('0x95')](_0x47108f,0xb,_0x4633('0xe0'));rpcDb[_0x4633('0x94')](_0x47108f,_0x4633('0xe1'));if(ut['totalGlobal'](_0x47108f)>=_0x4040b8[_0x4633('0xc2')]){_0x19758a=ut['cloneAction'](_0x47108f,0xf,_0x4633('0xca'));rpcDb[_0x4633('0x97')](_0x19758a,_0x4633('0xe1'));}else{if(_0x47108f['countabandonedetry']>=_0x4040b8[_0x4633('0xe2')]){rpcDb[_0x4633('0x97')](_0x47108f,_0x4633('0xe1'));}else{rpcDb[_0x4633('0xa8')](ut[_0x4633('0xa9')](_0x47108f,_0x4633('0xdf'),_0x4040b8['dialAbandonedRetryFrequency']),_0x47108f[_0x4633('0xab')],_0x47108f[_0x4633('0xac')]);}}break;case'18':_0x4040b8[_0x4633('0xe3')]+=0x1;_0x47108f['countmachineretry']+=0x1;_0x47108f['countglobal']=ut[_0x4633('0xa2')](_0x47108f);ut[_0x4633('0x95')](_0x47108f,0x12,_0x239269['cause-txt']||_0x239269['dialstatus']);ami[_0x4633('0x23')](_0x4633('0xe4'),ut[_0x4633('0xa4')](_0x47108f,_0x4633('0xe5')));rpcDb['createCustomerHistory'](_0x47108f,_0x4633('0xe6'));if(ut[_0x4633('0xa2')](_0x47108f)>=_0x4040b8[_0x4633('0xc2')]){_0x19758a=ut['cloneAction'](_0x47108f,0xf,_0x4633('0xca'));rpcDb[_0x4633('0x97')](_0x19758a,'[callProgressDetectingCustomer][hangupInAMD]');}else{rpcDb[_0x4633('0x97')](_0x47108f,_0x4633('0xe6'));}delete this[_0x4633('0x71')][_0x239269[_0x4633('0xad')]];break;case'19':_0x4040b8[_0x4633('0xe3')]+=0x1;_0x47108f[_0x4633('0xa1')]=ut[_0x4633('0xa2')](_0x47108f);ut[_0x4633('0x95')](_0x47108f,0x13,_0x239269[_0x4633('0xe7')]||_0x239269[_0x4633('0xe8')]);ami[_0x4633('0x23')](_0x4633('0xe4'),ut[_0x4633('0xa4')](_0x47108f,_0x4633('0xe5')));rpcDb[_0x4633('0x94')](_0x47108f,'[callProgressDetectingCustomer][machine]');if(ut[_0x4633('0xa2')](_0x47108f)>=_0x4040b8[_0x4633('0xc2')]){_0x19758a=ut[_0x4633('0xa6')](_0x47108f,0xf,_0x4633('0xca'));rpcDb[_0x4633('0x97')](_0x19758a,_0x4633('0xe9'));}else{rpcDb['createCustomerFinal'](_0x47108f,'[callProgressDetectingCustomer][machine]');}delete this[_0x4633('0x71')][_0x239269[_0x4633('0xad')]];break;default:if(_0x47108f['dialAnswer']){ut['decrementTalkink'](_0x4040b8,'[default]');ut[_0x4633('0x7d')](_0x4633('0xea')+_0x4040b8['name'],_0x239269);}_0x4040b8[_0x4633('0xe3')]+=0x1;_0x47108f[_0x4633('0xa1')]=ut['totalGlobal'](_0x47108f);ut[_0x4633('0x95')](_0x47108f,0xc,_0x239269[_0x4633('0xe7')]||_0x239269['dialstatus']);rpcDb['createCustomerHistory'](_0x47108f,_0x4633('0xeb'));if(ut[_0x4633('0xa2')](_0x47108f)>=_0x4040b8['dialGlobalMaxRetry']){_0x19758a=ut[_0x4633('0xa6')](_0x47108f,0xf,_0x4633('0xca'));rpcDb[_0x4633('0x97')](_0x19758a,'[callProgressDetectingCustomer][logUnknownGlobal]');}else{rpcDb['createCustomerFinal'](_0x47108f,'[callProgressDetectingCustomer][logUnknownGlobal]');}delete this[_0x4633('0x71')][_0x239269[_0x4633('0xad')]];}if(!(_0x47108f[_0x4633('0xb0')]&&_0x4bcb5c==='16')){ut[_0x4633('0x7b')](_0x4040b8,'[callProgressDetectingCustomer]');logger['info']('[originated][decrement][callProgressDetectingCustomer]',_0x47108f['uniqueid'],_0x4633('0xb2'),_0x4040b8['name'],_0x4633('0x6f'),_0x4040b8[_0x4633('0x51')]);}if(_0x4bcb5c!==_0x4633('0xec')){delete this['actions'][_0x239269[_0x4633('0xad')]];delete this[_0x4633('0x71')][_0x239269[_0x4633('0xed')]];}}};Preview[_0x4633('0x10')]['callProgressDetectingAgent']=function(_0x178e72,_0x4a77f1,_0x40a5f6){if(_[_0x4633('0xee')](_0x4a77f1)&&_0x4633('0xef')!==typeof _0x4a77f1){return;}if(_['isUndefined'](_0x40a5f6)&&'object'!==typeof _0x40a5f6){return;}switch(_0x40a5f6[_0x4633('0xf0')]){case'0':ut[_0x4633('0xf1')](_0x178e72,0x0,_0x4633('0xf2'));rpcDb['createAgentHistory'](_0x178e72,'[callProgressDetectingAgent][logNoSuch]');break;case'3':ut[_0x4633('0xf1')](_0x178e72,0x3,_0x4633('0xc7'));rpcDb[_0x4633('0xf3')](_0x178e72,_0x4633('0xf4'));break;case'5':ut[_0x4633('0xf1')](_0x178e72,0x5,'Busy');rpcDb[_0x4633('0xf3')](_0x178e72,'[callProgressDetectingAgent][logBusy]');break;case'8':ut[_0x4633('0xf1')](_0x178e72,0x8,_0x4633('0xd1'));rpcDb['createAgentHistory'](_0x178e72,'[callProgressDetectingAgent][logCongestion]');break;case'22':ut[_0x4633('0xf1')](_0x178e72,0x16,_0x4633('0xf5'));rpcDb['createAgentHistory'](_0x178e72,_0x4633('0xf6'));break;default:ut['logAgent'](_0x178e72,0xc,_0x40a5f6['reason']);rpcDb['createAgentHistory'](_0x178e72,_0x4633('0xf7'));}ut[_0x4633('0x7b')](_0x4a77f1,_0x4633('0xf8'));logger[_0x4633('0x6d')](_0x4633('0xf9'),_0x178e72['uniqueid'],_0x4633('0xb2'),_0x4a77f1[_0x4633('0x26')],_0x4633('0x6f'),_0x4a77f1[_0x4633('0x51')]);delete this[_0x4633('0x71')][_0x178e72['uniqueid']];};Preview['prototype']['checkInBlack']=function(_0x17cd2d,_0x4c7edb,_0x7357e1,_0x2b13da,_0x1a6f9f){var _0x501a29=this;return new BPromise(function(_0x45fac5,_0x29e38e){if(_[_0x4633('0x83')](_0x4c7edb)||_[_0x4633('0x83')](_0x4c7edb['Contact'])||_[_0x4633('0x83')](_0x4c7edb['Contact']['phone'])||_[_0x4633('0x83')](_0x4c7edb['VoiceQueueId'])){_0x29e38e(ut[_0x4633('0x50')]('Contact\x20is\x20undefined',_0x2b13da,_0x1a6f9f));return;}var _0x522641=uuid['v4']();var _0x5bce05=_0x501a29[_0x4633('0x70')][_0x4c7edb[_0x4633('0xfa')][_0x4633('0x26')]];var _0x402987=_0x7357e1?_0x501a29[_0x4633('0x82')][_0x7357e1]['id']:undefined;_0x501a29[_0x4633('0x71')][_0x522641]=new Action(_0x4c7edb,_0x5bce05,_0x522641,_0x7357e1,_0x402987);var _0xa96c20=_0x501a29[_0x4633('0x71')][_0x522641];_0xa96c20[_0x4633('0xab')]=_0x2b13da;_0xa96c20[_0x4633('0xac')]=_0x1a6f9f;_0xa96c20[_0x4633('0xfb')]=_0x7357e1;if(_[_0x4633('0xfc')](_0x17cd2d)){_0x501a29['execCall'](_0xa96c20,_0x5bce05,_0x4c7edb,_0x7357e1)[_0x4633('0xfd')](function(_0x1cf3a6){logger[_0x4633('0x6d')](_0x4633('0xfe'),_0x4633('0xff')+_0xa96c20[_0x4633('0x6e')]+_0x4633('0x100')+_0xa96c20['idContact'],JSON[_0x4633('0x5a')](_0x1cf3a6));ami['emit'](_0x4633('0x101'),ut[_0x4633('0xa4')](_0xa96c20,_0x4633('0x102'),_0x501a29['campaignsPreview'][_0xa96c20['queue']]));_0x45fac5(ut[_0x4633('0x50')]('Calling'));})['catch'](function(_0x2bb4e5){ut['logger']('[Preview][execCall][failure]',_0x2bb4e5);_0x29e38e(ut[_0x4633('0x50')](_0x4633('0x103'),_0x2b13da,_0x1a6f9f));});}else{_0x5bce05[_0x4633('0x3a')]+=0x1;ut[_0x4633('0x104')](_0xa96c20);rpcDb[_0x4633('0x105')](_0xa96c20,_0x4633('0x106'));delete _0x501a29['actions'][_0x522641];_0x29e38e(ut[_0x4633('0x50')](_0x4633('0x107'),_0x2b13da,_0x1a6f9f));}});};Preview[_0x4633('0x10')][_0x4633('0x9c')]=function(_0x4cd748){return!_[_0x4633('0x83')](_0x4cd748)&&!_[_0x4633('0x83')](_0x4cd748['name'])&&!_[_0x4633('0x83')](_0x4cd748[_0x4633('0x108')])&&_0x4cd748['active']&&!_[_0x4633('0x83')](this[_0x4633('0x15')][util[_0x4633('0x8e')]('SIP/%s',_0x4cd748[_0x4633('0x26')])])&&!_['isNil'](this[_0x4633('0x15')][util[_0x4633('0x8e')](_0x4633('0x109'),_0x4cd748[_0x4633('0x26')])][_0x4633('0x77')])&&(this['trunks'][util['format'](_0x4633('0x109'),_0x4cd748[_0x4633('0x26')])][_0x4633('0x77')]===_0x4633('0x10a')||this[_0x4633('0x15')][util[_0x4633('0x8e')](_0x4633('0x109'),_0x4cd748['name'])][_0x4633('0x77')]===_0x4633('0x10b'));};Preview[_0x4633('0x10')]['run']=function(_0x3b7d14,_0x127959){var _0x50eb10=this;return new BPromise(function(_0x17ab25,_0x26453f){_0x50eb10[_0x4633('0x10c')](_0x3b7d14,_0x127959)['then'](function(_0x2f147b){_0x17ab25(_[_0x4633('0x73')](_0x2f147b,[_0x4633('0x50')]));})['catch'](function(_0x3e02a4){if(_0x3e02a4['unlock']){rpcDb[_0x4633('0x10d')](_0x3b7d14);}if(_0x3e02a4['active']){rpcDb[_0x4633('0x10e')](_0x3b7d14);}_0x26453f(_[_0x4633('0x73')](_0x3e02a4,['message']));});});};Preview['prototype'][_0x4633('0x10c')]=function(_0x41ab0e,_0xd89306){var _0x42f3d2=this;return new BPromise(function(_0x32fdce,_0x4a3252){var _0x4ef161,_0x2ce641;rpcDb['getContactPreview'](_0x41ab0e)[_0x4633('0xfd')](function(_0x58a828){if(!_['isNil'](_0x58a828[0x0])){_0x2ce641=_0x58a828[0x0][_0x4633('0x10f')]?![]:!![];_0x4ef161=_0x58a828[0x0]['recallme']?!![]:![];_0x4ef161=_0xd89306?!![]:_0x4ef161;}var _0x290b4=_0x42f3d2[_0x4633('0x110')](_0x58a828);if(_0x290b4[_0x4633('0x111')]){rpcDb['checkIsBlackList'](_[_0x4633('0x73')](_0x58a828[0x0],[_0x4633('0x76'),'Contact.phone']))[_0x4633('0xfd')](function(_0x3fe347){_0x42f3d2[_0x4633('0x112')](_0x3fe347,_0x58a828[0x0],_0xd89306,_0x2ce641,_0x4ef161)[_0x4633('0xfd')](function(_0x547913){_0x32fdce(_0x547913);})[_0x4633('0x79')](function(_0x5601aa){_0x4a3252(_0x5601aa);});})['catch'](function(_0x5555f5){ut[_0x4633('0x5f')](_0x4633('0x113'),_0x5555f5);_0x4a3252(ut[_0x4633('0x50')](_0x4633('0x114'),_0x2ce641,_0x4ef161));});}else{_0x4a3252(ut['message'](_0x290b4[_0x4633('0x50')],_0x2ce641,_0x4ef161));}})[_0x4633('0x79')](function(_0xfab118){ut[_0x4633('0x5f')](_0x4633('0x115'),_0xfab118);_0x4a3252(ut['message'](_0x4633('0x114'),![],!![]));});});};Preview[_0x4633('0x10')]['validateContact']=function(_0x367ab5){if(_[_0x4633('0x83')](_0x367ab5)||_[_0x4633('0xfc')](_0x367ab5)||!_[_0x4633('0x83')](_0x367ab5[0x0][_0x4633('0x88')])&&_['isNil'](_0x367ab5[0x0][_0x4633('0x88')]['name'])){ut[_0x4633('0x5f')](_0x4633('0x116'),_0x367ab5);return{'isValid':![],'message':_0x4633('0x117')};}var _0x4a07d7=this[_0x4633('0x70')][_0x367ab5[0x0][_0x4633('0xfa')][_0x4633('0x26')]];_0x4a07d7[_0x4633('0x50')]=_0x4633('0x9f');if(_['isNil'](_0x4a07d7)){ut[_0x4633('0x5f')]('[Preview][validateContact][Empty\x20Campaign]',_0x4a07d7);return{'isValid':![],'message':_0x4633('0x118')};}if(!this[_0x4633('0x9c')](_0x4a07d7[_0x4633('0x55')])){ut[_0x4633('0x5f')](_0x4633('0x119'),_0x4633('0x11a')+_0x4a07d7[_0x4633('0x26')]+_0x4633('0x11b'));if(!this[_0x4633('0x9c')](_0x4a07d7[_0x4633('0x9d')])){ut[_0x4633('0x5f')]('[Preview][validateContact][Trunk\x20not\x20work]',_0x4a07d7['name']+_0x4633('0x11c'));return{'isValid':![],'message':_0x4633('0x11d')};}}if(!ut[_0x4633('0x9b')](_0x4a07d7['dialActive'])){ut[_0x4633('0x5f')](_0x4633('0x11e'),_0x4a07d7[_0x4633('0x26')]+'\x20Not\x20Active');return{'isValid':![],'message':'campaign\x20Name:\x20'+_0x4a07d7[_0x4633('0x26')]+_0x4633('0x11f')};}return{'isValid':!![],'message':'Is\x20Valid'};};Preview[_0x4633('0x10')]['execCall']=function(_0x2a4f0e,_0x442143,_0x5ca9c7,_0x243601){var _0x3af592=this;return new BPromise(function(_0x1e2563,_0x472a80){var _0x412d33=_0x2a4f0e[_0x4633('0xb1')];var _0x8d51ba=_0x3af592[_0x4633('0x9c')](_0x442143[_0x4633('0x55')])?util[_0x4633('0x8e')]('SIP/%s/%s%s',_0x442143[_0x4633('0x55')][_0x4633('0x26')],_[_0x4633('0x83')](_0x442143[_0x4633('0x37')])?'':_0x442143[_0x4633('0x37')]['trim']()||'',_0x442143[_0x4633('0x120')]>0x0?_0x5ca9c7[_0x4633('0x121')][_0x4633('0x122')][_0x4633('0x123')](_0x442143[_0x4633('0x120')]):_0x5ca9c7[_0x4633('0x121')]['phone']):util['format'](_0x4633('0x124'),_[_0x4633('0x83')](_0x442143[_0x4633('0x9d')])?_0x442143['Trunk'][_0x4633('0x26')]:_0x442143['TrunkBackup'][_0x4633('0x26')],_[_0x4633('0x83')](_0x442143[_0x4633('0x37')])?'':_0x442143[_0x4633('0x37')][_0x4633('0x125')]()||'',_0x442143[_0x4633('0x120')]>0x0?_0x5ca9c7[_0x4633('0x121')][_0x4633('0x122')]['substring'](_0x442143[_0x4633('0x120')]):_0x5ca9c7['Contact']['phone']);var _0x135d44=_0x3af592[_0x4633('0x9c')](_0x442143[_0x4633('0x55')])?ut[_0x4633('0x126')](_0x442143['Trunk'][_0x4633('0x56')],_0x442143['dialOriginateCallerIdName'],_0x442143[_0x4633('0x127')]>0x0?ut['getCallerIdRandom'](_0x442143[_0x4633('0x35')],_0x442143[_0x4633('0x127')]):_0x442143['dialOriginateCallerIdNumber']):ut[_0x4633('0x126')](_[_0x4633('0x83')](_0x442143[_0x4633('0x9d')])?_0x442143[_0x4633('0x55')][_0x4633('0x56')]:_0x442143[_0x4633('0x9d')][_0x4633('0x56')],_0x442143[_0x4633('0x34')],_0x442143['dialRandomLastDigitCallerIdNumber']>0x0?ut['getCallerIdRandom'](_0x442143[_0x4633('0x35')],_0x442143['dialRandomLastDigitCallerIdNumber']):_0x442143[_0x4633('0x35')]);if(_0x135d44){_0x2a4f0e['originatecalleridname']=ut[_0x4633('0x128')](_0x135d44);_0x2a4f0e[_0x4633('0x129')]=ut[_0x4633('0x12a')](_0x135d44);}var _0x3b28b8=ut[_0x4633('0x12b')](_0x442143,_0x5ca9c7,_0x8d51ba,_0x135d44,_0x412d33,_0x2a4f0e);_['merge'](_0x2a4f0e,ut[_0x4633('0x12c')](_0x3b28b8));_0x2a4f0e[_0x4633('0x8d')]=moment()[_0x4633('0x8e')]('YYYY-MM-DD\x20HH:mm:ss');ami[_0x4633('0x12d')](ut[_0x4633('0x12e')](_0x2a4f0e,_0x442143,_0x3b28b8,_0x2a4f0e[_0x4633('0xac')],_0x243601))[_0x4633('0xfd')](function(_0xbcb49d){_0x442143['originated']+=0x1;logger['info'](_0x4633('0x12f'),_0x412d33,_0x4633('0xb2'),_0x442143['name'],_0x4633('0x6f'),_0x442143[_0x4633('0x51')]);_0x1e2563(_0xbcb49d);})[_0x4633('0x79')](function(_0x2640c2){ut['logAgent'](_0x2a4f0e,0xe,_0x4633('0x130'));rpcDb[_0x4633('0xf3')](_0x2a4f0e,_0x4633('0x131'));_0x472a80(_0x2640c2);});});};Preview['prototype'][_0x4633('0x132')]=function(_0x527d48){if(this[_0x4633('0x71')][_0x527d48['linkedid']]){this['actions'][_0x527d48['linkedid']][_0x4633('0x78')]=_0x527d48[_0x4633('0x78')];}};Preview['prototype'][_0x4633('0x133')]=function(_0x52bb95){var _0x91841b=this;var _0x1e9c9c=this['actions'][_0x52bb95[_0x4633('0x134')]];if(_0x1e9c9c){if(_0x1e9c9c[_0x4633('0xfb')]&&this[_0x4633('0x82')][_0x1e9c9c['lookAgent']]){ut[_0x4633('0x135')](_0x1e9c9c,this[_0x4633('0x82')][_0x1e9c9c[_0x4633('0xfb')]]['name'],this['agents'][_0x1e9c9c[_0x4633('0xfb')]]['id']);}var _0x4b1f6a=_[_0x4633('0x136')](_0x1e9c9c);_0x4b1f6a[_0x4633('0xae')]=moment()[_0x4633('0x8e')](_0x4633('0x8f'));var _0x1a947b=_0x91841b[_0x4633('0x70')][_0x1e9c9c[_0x4633('0x6e')]];if(ut['isFailure'](_0x52bb95['response'])){if(_0x1e9c9c[_0x4633('0xab')]){rpcDb[_0x4633('0x10d')](_0x1e9c9c['idContact']);}if(_0x1e9c9c['activeContact']){rpcDb[_0x4633('0x10e')](_0x1e9c9c[_0x4633('0x137')]);}ami[_0x4633('0x23')](_0x4633('0x138'),ut['buildObj'](_0x1e9c9c,_0x4633('0x139'),this[_0x4633('0x70')][_0x1e9c9c[_0x4633('0x6e')]]));this['callProgressDetectingAgent'](_0x4b1f6a,_0x1a947b,_0x52bb95);}else{_0x1e9c9c[_0x4633('0x8d')]=moment()[_0x4633('0x8e')](_0x4633('0x8f'));ut[_0x4633('0xf1')](_0x4b1f6a,0x4,_0x4633('0x13a'));rpcDb[_0x4633('0xf3')](_0x4b1f6a,'[callProgressDetectingAgent][logAnswer]');}}};Preview[_0x4633('0x10')][_0x4633('0x13b')]=function(_0x4dbdf9){var _0x54767e=this;var _0x164950=this[_0x4633('0x71')][_0x4dbdf9['linkedid']];var _0x1de884;if(_0x164950){_0x1de884=this['campaignsPreview'][_0x164950[_0x4633('0x6e')]];logger['info'](_0x4633('0x13c'),_0x4dbdf9[_0x4633('0xad')],_0x4633('0xb2'),_0x1de884[_0x4633('0x26')],_0x4633('0x72'),_0x1de884[_0x4633('0x29')]);}if(this['actions'][_0x4dbdf9[_0x4633('0xad')]]&&_0x4dbdf9['linkedid']!==_0x4dbdf9[_0x4633('0xb1')]){if(_0x4dbdf9[_0x4633('0x13d')]==='16'&&this[_0x4633('0x71')][_0x4dbdf9['linkedid']][_0x4633('0xb0')]){this[_0x4633('0x13e')](_0x4dbdf9,_0x4dbdf9[_0x4633('0xad')],_0x4dbdf9[_0x4633('0x13d')]);}else if(this[_0x4633('0x71')][_0x4dbdf9[_0x4633('0xad')]][_0x4633('0xb0')]){logger[_0x4633('0x6d')](_0x4633('0x13f'),_0x4dbdf9[_0x4633('0xad')],_0x4dbdf9[_0x4633('0x13d')],_0x4633('0xb2'),_0x1de884[_0x4633('0x26')],_0x4633('0x72'),_0x1de884[_0x4633('0x29')]);this[_0x4633('0x13e')](_0x4dbdf9,_0x4dbdf9[_0x4633('0xad')],_0x4dbdf9[_0x4633('0x13d')]);}}else if(_0x164950&&_[_0x4633('0x83')](_0x164950[_0x4633('0x140')])&&_0x1de884[_0x4633('0x141')]&&_0x4dbdf9[_0x4633('0xad')]===_0x4dbdf9[_0x4633('0xb1')]&&_[_0x4633('0x83')](_0x4dbdf9[_0x4633('0xf0')])&&_0x4dbdf9['cause']==='16'&&_0x4dbdf9[_0x4633('0x142')]==='6'&&_[_0x4633('0xee')](_0x164950[_0x4633('0x143')])){if(_0x164950['unlockAgent']){rpcDb[_0x4633('0x10d')](_0x164950[_0x4633('0x137')]);}if(_0x164950[_0x4633('0xac')]){rpcDb['disableContact'](_0x164950[_0x4633('0x137')]);}_0x4dbdf9[_0x4633('0xf0')]='22';this[_0x4633('0x144')](_0x164950,_0x1de884,_0x4dbdf9);}else if(_0x164950&&_0x164950[_0x4633('0x143')]){if(_0x4dbdf9[_0x4633('0x13d')]==='16'&&this[_0x4633('0x71')][_0x4dbdf9['linkedid']][_0x4633('0xb0')]){logger[_0x4633('0x6d')](_0x4633('0x145'),_0x4dbdf9[_0x4633('0xad')],_0x4dbdf9[_0x4633('0x13d')],_0x4633('0xb2'),_0x1de884[_0x4633('0x26')],'pTalking:\x20',_0x1de884[_0x4633('0x29')]);this[_0x4633('0x13e')](_0x4dbdf9,_0x4dbdf9['linkedid'],_0x4dbdf9['cause']);}else if(this[_0x4633('0x71')][_0x4dbdf9['linkedid']]['dialAnswer']){logger[_0x4633('0x6d')](_0x4633('0x13f'),_0x4dbdf9[_0x4633('0xad')],_0x4dbdf9[_0x4633('0x13d')],_0x4633('0xb2'),_0x1de884[_0x4633('0x26')],'pTalking:\x20',_0x1de884['pTalking']);this['callProgressDetectingCustomer'](_0x4dbdf9,_0x4dbdf9[_0x4633('0xad')],_0x4dbdf9[_0x4633('0x13d')]);}}};Preview[_0x4633('0x10')][_0x4633('0x1c')]=function(_0x3a7a81){if(this[_0x4633('0x71')][_0x3a7a81[_0x4633('0xed')]]&&_0x3a7a81[_0x4633('0xed')]!==_0x3a7a81[_0x4633('0x146')]){this[_0x4633('0x13e')](_0x3a7a81,_0x3a7a81[_0x4633('0xed')],_0x3a7a81['dialstatus']);}};Preview['prototype'][_0x4633('0x1b')]=function(_0x18180e){if(this[_0x4633('0x71')][_0x18180e[_0x4633('0xad')]]&&_0x18180e['linkedid']!==_0x18180e[_0x4633('0xb1')]&&!this[_0x4633('0x71')][_0x18180e[_0x4633('0xad')]]['dialAnswer']){if(_0x18180e[_0x4633('0x13d')]==='1'){this[_0x4633('0x13e')](_0x18180e,_0x18180e[_0x4633('0xad')],_0x18180e[_0x4633('0x13d')]);}}};Preview[_0x4633('0x10')][_0x4633('0x147')]=function(_0x4733bd,_0x212692,_0x1adb26){if(this[_0x4633('0x71')][_0x4733bd]){if(_['isNil'](this[_0x4633('0x71')][_0x4733bd][_0x4633('0x148')])){this[_0x4633('0x71')][_0x4733bd][_0x4633('0x148')]={};}this['actions'][_0x4733bd][_0x4633('0x148')][_0x212692]=_0x1adb26;}};Preview['prototype']['syncVarSet']=function(_0x13d7af){try{if(!_['isNil'](_0x13d7af)){if(ut[_0x4633('0x149')](_[_0x4633('0x14a')](_0x13d7af[_0x4633('0x14b')])[0x0])){this['addVariable'](_0x13d7af[_0x4633('0xb1')],_[_0x4633('0x14a')](_0x13d7af['variable'])[0x0],_0x13d7af[_0x4633('0x14c')]);}}}catch(_0x2ed4bf){logger['error'](_0x4633('0x14d'),util[_0x4633('0x14e')](_0x2ed4bf,{'showHidden':![],'depth':null}));}};Preview[_0x4633('0x10')][_0x4633('0x14f')]=function(_0x2c4017){if(_0x2c4017){if(this[_0x4633('0x71')][_0x2c4017[_0x4633('0x150')]]){this[_0x4633('0x71')][_0x2c4017[_0x4633('0x150')]][_0x4633('0x143')]=!![];}}};Preview['prototype'][_0x4633('0x151')]=function(_0x54e96b){if(_0x54e96b){if(this['actions'][_0x54e96b[_0x4633('0x152')]]){this[_0x4633('0x71')][_0x54e96b[_0x4633('0x152')]][_0x4633('0x143')]=!![];}}};module[_0x4633('0x153')]=Preview;