Built motion from commit 7ab0e143.|2.5.49
[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 _0xe0ae=['activeContact','linkedid','ANSWER','answertime','uniqueid','\x20Queue','connect','acw','custom:agentConnectPreview','buildAcw','custom:agentcomplete','complete','[16]','[callProgressDetectingCustomer][logAnswerGlobal]','talktime','[syncHangup][talking][decrement]','BUSY','countbusyretry','Busy','busy','[callProgressDetectingCustomer][logBusy]','[callProgressDetectingCustomer][logBusyGlobal]','dialBusyMaxRetry','dialBusyRetryFrequency','unlockAgent','NOANSWER','countnoanswerretry','NoAnswer','custom:agentnoanswer','noanswer','dialNoAnswerMaxRetry','[callProgressDetectingCustomer][logNoAnswer]','dialNoAnswerRetryFrequency','CONGESTION','countcongestionretry','Congestion','custom:agentcongestion','congestion','cloneAction','[callProgressDetectingCustomer][logCongestionGlobal]','dialCongestionMaxRetry','[callProgressDetectingCustomer][logCongestion]','CANCEL','countagentrejectretry','AgentReject','custom:agentreject','[syncHangupRequest][logAgentReject]','dialAgentRejectMaxRetry','[callProgressDetectingCustomer][logAgentReject]','dialAgentRejectRetryFrequency','ABANDONED','Abandoned','[callProgressDetectingCustomer][logAbandoned]','countabandonedetry','dialAbandonedMaxRety','countabandonedretry','countmachineretry','cause-txt','dialstatus','amd','[callProgressDetectingCustomer][hangupInAMD]','custom:amd','[callProgressDetectingCustomer][machine]','[Dialer][decrementTalkink][no\x20Hangup][Preview]','[callProgressDetectingCustomer][logUnknown]','[callProgressDetectingCustomer][logUnknownGlobal]','[originated][decrement][callProgressDetectingCustomer]','originated:\x20','callProgressDetectingAgent','object','isUndefined','logAgent','createAgentHistory','[callProgressDetectingAgent][logBusy]','[callProgressDetectingAgent][logCongestion]','AnswerAGI','[callProgressDetectingAgent][logAnswerAGI]','[callProgressDetectingAgent]','checkInBlack','Contact','phone','lookAgent','isEmpty','execCall','[Preview][execCall][success]','Queue:\x20','\x20IdHopper:\x20','idContact','custom:agentcalled','called','Calling','[Preview][execCall][failure]','Call\x20failed','logBlacklist','Contact\x20in\x20black\x20List','SIP/%s','reachable','unmonitored','execRun','unlock','unlockContact','recallme','validateContact','isValid','checkIsBlackList','Contact.phone','[Preview][checkIsBlackList]','Call\x20unsuccessful','[Preview][getContactPreview]','Empty\x20Contact','[Preview][validateContact][Empty\x20Campaign]','[Preview][validateContact][Trunk\x20not\x20work]','campaign\x20Name:\x20','\x20Trunk\x20is\x20not\x20active','Trunk\x20not\x20work','isActive','[Preview][validateContact][Campaign\x20Active]','\x20Not\x20Active','Is\x20Valid','SIP/%s/%s%s','trim','dialCutDigit','substring','callerid','getCallerIdRandom','getCallerId','dialRandomLastDigitCallerIdNumber','originatecalleridname','originatecalleridnum','extractCalleridNumber','addVariables','variablesAction','[originated][increment]','OriginateError','[originateFailure][logOriginateFailure]','syncNewExten','actionid','logLookAgent','clone','responsetime','custom:agentringnoanswer','rejected','[callProgressDetectingAgent][logAnswer]','[syncHangup][talking]','cause','[syncHangup][talking][cause]','statedesc','transfer','disableContact','[syncHangup][talking][transfer]','destlinkedid','variables','filterKey','keys','variable','value','error','[syncVarSet][Preview]','transfertargetlinkedid','transfererlinkedid','exports','bluebird','uuid','md5','../../../config/environment','../../../config/logger','./rpcDb','./action','./util/util','redis','prototype','enqueue','tail','finally','sequence','campaignsPreview','trunks','actions','agents','originateresponse','syncOriginateResponse','bind','hangup','syncHangup','hanguprequest','syncHangupRequest','dialend','syncDialEnd','newexten','varset','syncVarSet','attendedtransfer','syncAttendedTransfer','blindtransfer','loopCampaigns','emit','type','outbound','name','answered','available','loggedIn','pTalking','sumDuration','sumHoldTime','talking','total','waiting','dialMethod','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialPrefix','outboundAnswerAgiCallsDay','outboundAnswerCallsDay','outboundBlacklistCallsDay','outboundBusyCallsDay','outboundCongestionCallsDay','outboundDropCallsDayACS','outboundDropCallsDayCallersExit','outboundDropCallsDayTimeout','outboundNoAnswerCallsDay','outboundOriginateFailureCallsDay','outboundReCallsDay','outboundRejectCallsDay','outboundUnknownCallsDay','outboundAbandonedCallsDay','predictiveIntervalAnsweredCalls','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalDroppedCallsTimeout','predictiveIntervalErlangCalls','predictiveIntervalHitRate','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','message','originated','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','startPredictive','startProgressive','Trunk','active','Interval','stringify','format','voice:queue:%s','voice_queue:save','[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event','voice_queue_presence:remove','sendMessageOneNotActive','paused','NOT_ACTIVE','logger','[CampaignPreview]\x20Campaign\x20Queue:\x20','IS_DISACTIVED','\x20is\x20disactive','syncCampaigns','clockClearZombieChannels','hasOwnProperty','preview','booked','clearZombieChannels','clearZombieChannel','[clearZombieChannels][talking]','Queue','queue','pTalking:\x20','dialAnswer','pick','contactId','UserId','VoiceQueueId','ListId','status','channel','catch','No\x20such\x20channel','updateOriginated','[clearZombieChannel]','decrementTalkink','loggerError','[Dialer][checkChannel][pTalking][Preview]','[Dialer][checkChannel][Preview]','info','[action]','size','getContactRecallMe','agentReadyId','then','isNil','length','getDiff','scheduledat','dialRecallMeTimeout','Agent','voicePause','run','logger2','[RecallMe]','starttime','YYYY-MM-DD\x20HH:mm:ss','logCustomer','createBody','createCustomerHistory','[HistoryDialRecallInQueue][historyCatch]','RecallFailedTimeout','[HistoryRecallClose]','createCustomerFinal','setMessage','IsNotLoggedIn','AGENTS_NOT_LOGGED','dialActive','isTrunkReachable','TrunkBackup','ACTIVE','callProgressDetectingCustomer','outboundNoSuchCallsDay','countnosuchnumberretry','countglobal','totalGlobal','NoSuchNumber','custom:agentnosuchnumber','buildObj','nosuchnumber','[callProgressDetectingCustomer][logNoSuch]','dialGlobalMaxRetry','Global','dialNoSuchNumberMaxRetry','[callProgressDetectingCustomer][logNoSuchGlobal]','rescheduleContact','scheduledAt','dialNoSuchNumberRetryFrequency'];(function(_0x32b3aa,_0x3af2b2){var _0x4719cd=function(_0x2586db){while(--_0x2586db){_0x32b3aa['push'](_0x32b3aa['shift']());}};_0x4719cd(++_0x3af2b2);}(_0xe0ae,0xa1));var _0xee0a=function(_0x1304c6,_0x6bb485){_0x1304c6=_0x1304c6-0x0;var _0x2e6654=_0xe0ae[_0x1304c6];return _0x2e6654;};'use strict';var util=require('util');var _=require('lodash');var BPromise=require(_0xee0a('0x0'));var uuid=require(_0xee0a('0x1'));var moment=require('moment');var md5=require(_0xee0a('0x2'));var Redis=require('ioredis');var config=require(_0xee0a('0x3'));var logger=require(_0xee0a('0x4'))('preview');var loggerAction=require(_0xee0a('0x4'))('actionPreview');var ami=require('../ami');var rpcDb=require(_0xee0a('0x5'));var Action=require(_0xee0a('0x6'));var ut=require(_0xee0a('0x7'));config[_0xee0a('0x8')]=_['defaults'](config[_0xee0a('0x8')],{'host':'localhost','port':0x18eb});var io=require('socket.io-emitter')(new Redis(config[_0xee0a('0x8')]));var Sequence=function(){};Sequence[_0xee0a('0x9')][_0xee0a('0xa')]=function(_0x57d190){this[_0xee0a('0xb')]=this[_0xee0a('0xb')]?this['tail'][_0xee0a('0xc')](_0x57d190):_0x57d190();};function Preview(_0x4b3e49){this[_0xee0a('0xd')]=new Sequence();this[_0xee0a('0xe')]=_0x4b3e49['voiceQueues'];this[_0xee0a('0xf')]=_0x4b3e49['trunks'];this[_0xee0a('0x10')]={};this[_0xee0a('0x11')]=_0x4b3e49['agents'];this['clockClearZombieChannels']=0x0;ami['on'](_0xee0a('0x12'),this[_0xee0a('0x13')][_0xee0a('0x14')](this));ami['on'](_0xee0a('0x15'),this[_0xee0a('0x16')]['bind'](this));ami['on'](_0xee0a('0x17'),this[_0xee0a('0x18')]['bind'](this));ami['on'](_0xee0a('0x19'),this[_0xee0a('0x1a')][_0xee0a('0x14')](this));ami['on'](_0xee0a('0x1b'),this['syncNewExten'][_0xee0a('0x14')](this));ami['on'](_0xee0a('0x1c'),this[_0xee0a('0x1d')]['bind'](this));ami['on'](_0xee0a('0x1e'),this[_0xee0a('0x1f')][_0xee0a('0x14')](this));ami['on'](_0xee0a('0x20'),this['syncBlindTransfer'][_0xee0a('0x14')](this));this[_0xee0a('0x21')](this[_0xee0a('0xe')]);}function emit(_0x201d32,_0x5c981e,_0x2abfbd){io['to'](_0x201d32)[_0xee0a('0x22')](_0x5c981e,_0x2abfbd);}function emitCampaignPreview(_0x31e98a){if(_0x31e98a[_0xee0a('0x23')]===_0xee0a('0x24')){var _0x1eb176={'id':_0x31e98a['id'],'name':_0x31e98a[_0xee0a('0x25')],'strategy':_0x31e98a['strategy'],'answered':_0x31e98a[_0xee0a('0x26')],'available':_0x31e98a[_0xee0a('0x27')],'loggedIn':_0x31e98a[_0xee0a('0x28')],'pTalking':_0x31e98a[_0xee0a('0x29')],'sumBillable':_0x31e98a['sumBillable'],'sumDuration':_0x31e98a[_0xee0a('0x2a')],'sumHoldTime':_0x31e98a[_0xee0a('0x2b')]||0x0,'talking':_0x31e98a[_0xee0a('0x2c')],'total':_0x31e98a[_0xee0a('0x2d')],'type':_0x31e98a['type'],'unmanaged':_0x31e98a['unmanaged'],'abandoned':_0x31e98a['abandoned'],'waiting':_0x31e98a[_0xee0a('0x2e')],'loggedInDb':_0x31e98a['loggedInDb'],'dialActive':_0x31e98a['dialActive'],'dialMethod':_0x31e98a[_0xee0a('0x2f')],'dialOriginateCallerIdName':_0x31e98a[_0xee0a('0x30')],'dialOriginateCallerIdNumber':_0x31e98a[_0xee0a('0x31')],'dialOriginateTimeout':_0x31e98a['dialOriginateTimeout'],'dialPrefix':_0x31e98a[_0xee0a('0x32')],'outboundAnswerAgiCallsDay':_0x31e98a[_0xee0a('0x33')],'outboundAnswerCallsDay':_0x31e98a[_0xee0a('0x34')],'outboundBlacklistCallsDay':_0x31e98a[_0xee0a('0x35')],'outboundBusyCallsDay':_0x31e98a[_0xee0a('0x36')],'outboundCongestionCallsDay':_0x31e98a[_0xee0a('0x37')],'outboundDropCallsDayACS':_0x31e98a[_0xee0a('0x38')],'outboundDropCallsDayCallersExit':_0x31e98a[_0xee0a('0x39')],'outboundDropCallsDayTimeout':_0x31e98a[_0xee0a('0x3a')],'outboundNoAnswerCallsDay':_0x31e98a[_0xee0a('0x3b')],'outboundNoSuchCallsDay':_0x31e98a['outboundNoSuchCallsDay'],'outboundOriginateFailureCallsDay':_0x31e98a[_0xee0a('0x3c')],'outboundReCallsDay':_0x31e98a[_0xee0a('0x3d')],'outboundRejectCallsDay':_0x31e98a[_0xee0a('0x3e')],'outboundUnknownCallsDay':_0x31e98a[_0xee0a('0x3f')],'outboundAbandonedCallsDay':_0x31e98a[_0xee0a('0x40')],'predictiveIntervalAnsweredCalls':_0x31e98a[_0xee0a('0x41')],'predictiveIntervalAvgHoldtime':_0x31e98a['predictiveIntervalAvgHoldtime'],'predictiveIntervalAvgTalktime':_0x31e98a[_0xee0a('0x42')],'predictiveIntervalDroppedCallsCallersExit':_0x31e98a[_0xee0a('0x43')],'predictiveIntervalDroppedCallsTimeout':_0x31e98a[_0xee0a('0x44')],'predictiveIntervalErlangCalls':_0x31e98a[_0xee0a('0x45')],'predictiveIntervalErlangCallsDroppedCalls':_0x31e98a['predictiveIntervalErlangCallsDroppedCalls'],'predictiveIntervalHitRate':_0x31e98a[_0xee0a('0x46')],'predictiveIntervalMultiplicativeFactor':_0x31e98a['predictiveIntervalMultiplicativeFactor'],'predictiveIntervalPauses':_0x31e98a[_0xee0a('0x47')],'predictiveIntervalAvailable':_0x31e98a[_0xee0a('0x48')],'predictiveIntervalTotalCalls':_0x31e98a[_0xee0a('0x49')],'message':_0x31e98a[_0xee0a('0x4a')],'originated':_0x31e98a[_0xee0a('0x4b')],'erlangCalls':_0x31e98a[_0xee0a('0x4c')],'erlangCallToSecond':_0x31e98a[_0xee0a('0x4d')],'erlangAbandonmentRate':_0x31e98a[_0xee0a('0x4e')],'erlangBusyFactor':_0x31e98a['erlangBusyFactor'],'startPredictive':_0x31e98a[_0xee0a('0x4f')],'startProgressive':_0x31e98a[_0xee0a('0x50')]};if(_0x31e98a['Trunk']){_0x1eb176[_0xee0a('0x51')]={'id':_0x31e98a[_0xee0a('0x51')]['id'],'name':_0x31e98a[_0xee0a('0x51')]['name'],'active':_0x31e98a[_0xee0a('0x51')][_0xee0a('0x52')],'callerid':_0x31e98a[_0xee0a('0x51')]['callerid']};}if(_0x31e98a[_0xee0a('0x53')]){_0x1eb176[_0xee0a('0x53')]={'id':_0x31e98a[_0xee0a('0x53')]['id'],'name':_0x31e98a['Interval']['name']};}var _0x7db483=md5(JSON[_0xee0a('0x54')](_0x1eb176));if(_0x31e98a[_0xee0a('0x2')]!==_0x7db483){_0x31e98a[_0xee0a('0x2')]=_0x7db483;emit(util[_0xee0a('0x55')](_0xee0a('0x56'),_0x1eb176[_0xee0a('0x25')]),_0xee0a('0x57'),_0x1eb176);}}}function emitVoiceQueueChannelRemove(_0x22d505){logger['info'](_0xee0a('0x58'),JSON[_0xee0a('0x54')](_0x22d505));emit(util['format'](_0xee0a('0x56'),_0x22d505[_0xee0a('0x25')]),'voice_queue_channel:remove',_0x22d505);io[_0xee0a('0x22')](_0xee0a('0x59'),_0x22d505);}function notSendMessagesQueue(_0x3a825e){if(_0x3a825e[_0xee0a('0x5a')]){if(_0x3a825e[_0xee0a('0x4b')]===0x0&&_0x3a825e[_0xee0a('0x29')]===0x0){_0x3a825e[_0xee0a('0x5a')]=![];_0x3a825e[_0xee0a('0x27')]=0x0;_0x3a825e[_0xee0a('0x5b')]=0x0;_0x3a825e['message']=_0xee0a('0x5c');ut[_0xee0a('0x5d')](_0xee0a('0x5e'),_0x3a825e[_0xee0a('0x25')]+'\x20is\x20not\x20active');}else{_0x3a825e['message']=_0xee0a('0x5f');ut[_0xee0a('0x5d')](_0xee0a('0x5e'),_0x3a825e[_0xee0a('0x25')]+_0xee0a('0x60'));}emitCampaignPreview(_0x3a825e);}}Preview[_0xee0a('0x9')][_0xee0a('0x21')]=function(){var _0x4c398c=this;setInterval(function(){_0x4c398c['syncCampaigns']();},0x7cf);};Preview[_0xee0a('0x9')][_0xee0a('0x61')]=function(){var _0x587ee3=this[_0xee0a('0xe')];this[_0xee0a('0x62')]+=0x1;for(var _0x5f2071 in _0x587ee3){if(_0x587ee3[_0xee0a('0x63')](_0x5f2071)&&(_0x587ee3[_0x5f2071][_0xee0a('0x2f')]===_0xee0a('0x64')||_0x587ee3[_0x5f2071][_0xee0a('0x2f')]===_0xee0a('0x65'))&&_0x587ee3[_0x5f2071][_0xee0a('0x23')]===_0xee0a('0x24')){if(this['clockClearZombieChannels']>0x7){this['clockClearZombieChannels']=0x0;this[_0xee0a('0x66')]();}}if(_0x587ee3['hasOwnProperty'](_0x5f2071)&&_0x587ee3[_0x5f2071]['dialMethod']==='preview'&&_0x587ee3[_0x5f2071][_0xee0a('0x23')]===_0xee0a('0x24')){if(_0x587ee3[_0x5f2071]['dialActive']){this['setMessage'](_0x587ee3[_0x5f2071]);if(_0x587ee3[_0x5f2071]['dialPreviewAutoRecallMe'])this['recallMe'](_0x587ee3[_0x5f2071]);}else{notSendMessagesQueue(_0x587ee3[_0x5f2071]);}}}};Preview[_0xee0a('0x9')][_0xee0a('0x67')]=function(_0x32fd2d){var _0x384986=this;this[_0xee0a('0xd')][_0xee0a('0xa')](function(){if(!_['isNil'](_0x384986[_0xee0a('0x10')][_0x32fd2d])){loggerAction['info'](_0xee0a('0x68'),_0x32fd2d,_0xee0a('0x69'),_0x384986[_0xee0a('0x10')][_0x32fd2d][_0xee0a('0x6a')],'originated:\x20',JSON[_0xee0a('0x54')](_0x384986[_0xee0a('0xe')][_0x384986[_0xee0a('0x10')][_0x32fd2d][_0xee0a('0x6a')]][_0xee0a('0x4b')]),_0xee0a('0x6b'),JSON[_0xee0a('0x54')](_0x384986['campaignsPreview'][_0x384986['actions'][_0x32fd2d][_0xee0a('0x6a')]][_0xee0a('0x29')]),JSON[_0xee0a('0x54')](_0x384986[_0xee0a('0x10')][_0x32fd2d][_0xee0a('0x6c')]),JSON[_0xee0a('0x54')](_[_0xee0a('0x6d')](_0x384986[_0xee0a('0x10')][_0x32fd2d],[_0xee0a('0x6e'),_0xee0a('0x6f'),_0xee0a('0x70'),_0xee0a('0x71')])));return ami['Action']({'action':_0xee0a('0x72'),'channel':_0x384986[_0xee0a('0x10')][_0x32fd2d][_0xee0a('0x73')]})[_0xee0a('0x74')](function(_0x29e137){if(_0x29e137['message']===_0xee0a('0x75')){setTimeout(function(){if(_0x384986[_0xee0a('0x10')][_0x32fd2d]){ut[_0xee0a('0x76')](_0x384986[_0xee0a('0xe')][_0x384986[_0xee0a('0x10')][_0x32fd2d]['queue']],_0xee0a('0x77'));if(_0x384986[_0xee0a('0x10')][_0x32fd2d][_0xee0a('0x6c')]===!![]){ut[_0xee0a('0x78')](_0x384986[_0xee0a('0xe')][_0x384986['actions'][_0x32fd2d][_0xee0a('0x6a')]],_0xee0a('0x77'));ut[_0xee0a('0x79')](_0xee0a('0x7a')+_0x32fd2d,_0x384986[_0xee0a('0x10')][_0x32fd2d][_0xee0a('0x6a')]);}ut[_0xee0a('0x79')](_0xee0a('0x7b')+_0x32fd2d,_0x384986[_0xee0a('0x10')][_0x32fd2d][_0xee0a('0x6a')]);delete _0x384986[_0xee0a('0x10')][_0x32fd2d];}},0x2328);}});}});};Preview[_0xee0a('0x9')][_0xee0a('0x66')]=function(){var _0x341f43=this;loggerAction[_0xee0a('0x7c')](_0xee0a('0x7d'),_[_0xee0a('0x7e')](this[_0xee0a('0x10')]));for(var _0x20d44a in this[_0xee0a('0x10')]){if(_0x341f43[_0xee0a('0x10')][_0xee0a('0x63')](_0x20d44a)){_0x341f43['clearZombieChannel'](_0x20d44a);}}};Preview['prototype']['recallMe']=function(_0x35eb93){var _0x557690=this;rpcDb[_0xee0a('0x7f')](_0x35eb93['id'],ut[_0xee0a('0x80')](this[_0xee0a('0x11')]))[_0xee0a('0x81')](function(_0x5d3b09){if(!_[_0xee0a('0x82')](_0x5d3b09)){for(var _0x27ae33=0x0;_0x27ae33<_0x5d3b09[_0xee0a('0x83')];_0x27ae33+=0x1){if(ut[_0xee0a('0x84')](_0x5d3b09[_0x27ae33][_0xee0a('0x85')])<_0x35eb93[_0xee0a('0x86')]*0x3c){if(_0x5d3b09[_0x27ae33][_0xee0a('0x87')]&&!_0x5d3b09[_0x27ae33][_0xee0a('0x87')][_0xee0a('0x88')]){_0x557690[_0xee0a('0x89')](_0x5d3b09[_0x27ae33]['id'])[_0xee0a('0x81')](ut[_0xee0a('0x8a')](_0xee0a('0x8b')))[_0xee0a('0x74')](ut['logger2'](_0xee0a('0x8b')));}else{rpcDb['disableContact'](_0x5d3b09[_0x27ae33]['id']);}}else{var _0x2dcfc5=new Action(_0x5d3b09[_0x27ae33],_0x35eb93);_0x2dcfc5[_0xee0a('0x8c')]=moment()['format'](_0xee0a('0x8d'));_0x35eb93['outboundReCallsDay']+=0x1;ut[_0xee0a('0x8e')](_0x2dcfc5,0x17,'RecallInQueue');if(_0x35eb93['dialRecallInQueue']){rpcDb['rescheduleContactInQueue'](ut[_0xee0a('0x8f')](_0x5d3b09[_0x27ae33]));rpcDb[_0xee0a('0x90')](_0x2dcfc5,_0xee0a('0x91'));}else{ut[_0xee0a('0x8e')](_0x2dcfc5,0x16,_0xee0a('0x92'));rpcDb[_0xee0a('0x90')](_0x2dcfc5,_0xee0a('0x93'));rpcDb[_0xee0a('0x94')](_0x2dcfc5,'[HistoryRecallClose]');}}}}})[_0xee0a('0x74')](ut['logger2']('[getContactRecallMe]'));};Preview[_0xee0a('0x9')][_0xee0a('0x95')]=function(_0x2aa5d3){_0x2aa5d3[_0xee0a('0x5a')]=!![];if(ut[_0xee0a('0x96')](_0x2aa5d3[_0xee0a('0x28')])){_0x2aa5d3[_0xee0a('0x4a')]=_0xee0a('0x97');}else if(!ut['isActive'](_0x2aa5d3[_0xee0a('0x98')])){_0x2aa5d3['message']=_0xee0a('0x5c');}else if(!this[_0xee0a('0x99')](_0x2aa5d3[_0xee0a('0x51')])){if(!this[_0xee0a('0x99')](_0x2aa5d3[_0xee0a('0x9a')])){_0x2aa5d3[_0xee0a('0x4a')]='TRUNK_IS_NOT_REACHABLE';}else{_0x2aa5d3[_0xee0a('0x4a')]=_0xee0a('0x9b');}}else{_0x2aa5d3[_0xee0a('0x4a')]='ACTIVE';}emitCampaignPreview(_0x2aa5d3);};Preview[_0xee0a('0x9')][_0xee0a('0x9c')]=function(_0x4d5c5b,_0x46e0b1,_0x4b76b9){var _0x491ea3=this;var _0x4d6583=this['actions'][_0x46e0b1];var _0x35e9f1=this['campaignsPreview'][_0x4d6583[_0xee0a('0x6a')]];var _0x5caa55;if(_0x35e9f1){switch(_0x4b76b9){case'1':_0x35e9f1[_0xee0a('0x9d')]+=0x1;_0x4d6583[_0xee0a('0x9e')]+=0x1;_0x4d6583[_0xee0a('0x9f')]=ut[_0xee0a('0xa0')](_0x4d6583);ut['logCustomer'](_0x4d6583,0x0,_0xee0a('0xa1'));ami[_0xee0a('0x22')](_0xee0a('0xa2'),ut[_0xee0a('0xa3')](_0x4d6583,_0xee0a('0xa4')));rpcDb['createCustomerHistory'](_0x4d6583,_0xee0a('0xa5'));if(ut[_0xee0a('0xa0')](_0x4d6583)>=_0x35e9f1[_0xee0a('0xa6')]){_0x5caa55=ut['cloneAction'](_0x4d6583,0xf,_0xee0a('0xa7'));rpcDb[_0xee0a('0x94')](_0x5caa55,'[callProgressDetectingCustomer][logNoSuchGlobal]');}else{if(_0x4d6583[_0xee0a('0x9e')]>=_0x35e9f1[_0xee0a('0xa8')]){rpcDb[_0xee0a('0x94')](_0x4d6583,_0xee0a('0xa9'));}else{rpcDb[_0xee0a('0xaa')](ut[_0xee0a('0xab')](_0x4d6583,_0xee0a('0x9e'),_0x35e9f1[_0xee0a('0xac')]),_0x4d6583['unlockAgent'],_0x4d6583[_0xee0a('0xad')]);}}delete this[_0xee0a('0x10')][_0x4d5c5b[_0xee0a('0xae')]];break;case _0xee0a('0xaf'):var _0x8da3af=moment()[_0xee0a('0x55')](_0xee0a('0x8d'));_0x4d6583['responsetime']=_0x8da3af;_0x4d6583[_0xee0a('0xb0')]=_0x8da3af;_0x4d6583[_0xee0a('0x6c')]=!![];_0x35e9f1[_0xee0a('0x29')]+=0x1;logger[_0xee0a('0x7c')]('[syncHangup][talking][increment]',_0x4d6583[_0xee0a('0xb1')],_0xee0a('0xb2'),_0x35e9f1[_0xee0a('0x25')],_0xee0a('0x6b'),_0x35e9f1[_0xee0a('0x29')]);ami['emit']('custom:agentconnect',ut[_0xee0a('0xa3')](_0x4d6583,_0xee0a('0xb3'),this[_0xee0a('0xe')][_0x4d6583['queue']]));if(_0x35e9f1[_0xee0a('0xb4')]){ami[_0xee0a('0x22')](_0xee0a('0xb5'),ut[_0xee0a('0xb6')](_0x4d6583));}break;case'16':ami[_0xee0a('0x22')](_0xee0a('0xb7'),ut[_0xee0a('0xa3')](_0x4d6583,_0xee0a('0xb8'),this['campaignsPreview'][_0x4d6583[_0xee0a('0x6a')]]));emitVoiceQueueChannelRemove(ut[_0xee0a('0xa3')](_0x4d6583,_0xee0a('0xb8')));_0x35e9f1[_0xee0a('0x34')]+=0x1;_0x35e9f1[_0xee0a('0x2d')]+=0x1;_0x35e9f1['answered']+=0x1;ut[_0xee0a('0x78')](_0x35e9f1,_0xee0a('0xb9'));_0x4d6583[_0xee0a('0x9f')]=ut[_0xee0a('0xa0')](_0x4d6583);ut[_0xee0a('0x8e')](_0x4d6583,0x4,'Answer');rpcDb['createCustomerHistory'](_0x4d6583,'[callProgressDetectingCustomer][logAnswer]');rpcDb['createCustomerFinal'](_0x4d6583,_0xee0a('0xba'));rpcDb['crateCustomerReportQueue'](_0x4d6583);_0x35e9f1[_0xee0a('0x2a')]+=_0x4d6583[_0xee0a('0xbb')];_0x35e9f1['sumBillable']+=_0x4d6583[_0xee0a('0xbb')];logger['info'](_0xee0a('0xbc'),_0x4d6583[_0xee0a('0xb1')],_0xee0a('0xb2'),_0x35e9f1[_0xee0a('0x25')],'pTalking:\x20',_0x35e9f1[_0xee0a('0x29')]);delete this[_0xee0a('0x10')][_0x4d5c5b[_0xee0a('0xae')]];break;case _0xee0a('0xbd'):_0x35e9f1['outboundBusyCallsDay']+=0x1;_0x4d6583[_0xee0a('0xbe')]+=0x1;_0x4d6583[_0xee0a('0x9f')]=ut[_0xee0a('0xa0')](_0x4d6583);ut[_0xee0a('0x8e')](_0x4d6583,0x5,_0xee0a('0xbf'));ami[_0xee0a('0x22')]('custom:agentbusy',ut[_0xee0a('0xa3')](_0x4d6583,_0xee0a('0xc0')));rpcDb[_0xee0a('0x90')](_0x4d6583,_0xee0a('0xc1'));if(ut[_0xee0a('0xa0')](_0x4d6583)>=_0x35e9f1[_0xee0a('0xa6')]){_0x5caa55=ut['cloneAction'](_0x4d6583,0xf,_0xee0a('0xa7'));rpcDb[_0xee0a('0x94')](_0x5caa55,_0xee0a('0xc2'));}else{if(_0x4d6583[_0xee0a('0xbe')]>=_0x35e9f1[_0xee0a('0xc3')]){rpcDb[_0xee0a('0x94')](_0x4d6583,'[callProgressDetectingCustomer][logBusy]');}else{rpcDb[_0xee0a('0xaa')](ut[_0xee0a('0xab')](_0x4d6583,_0xee0a('0xbe'),_0x35e9f1[_0xee0a('0xc4')]),_0x4d6583[_0xee0a('0xc5')],_0x4d6583[_0xee0a('0xad')]);}}break;case _0xee0a('0xc6'):_0x35e9f1[_0xee0a('0x3b')]+=0x1;_0x4d6583[_0xee0a('0xc7')]+=0x1;_0x4d6583[_0xee0a('0x9f')]=ut[_0xee0a('0xa0')](_0x4d6583);ut[_0xee0a('0x8e')](_0x4d6583,0x3,_0xee0a('0xc8'));ami[_0xee0a('0x22')](_0xee0a('0xc9'),ut['buildObj'](_0x4d6583,_0xee0a('0xca')));rpcDb[_0xee0a('0x90')](_0x4d6583,'[callProgressDetectingCustomer][logNoAnswer]');if(ut[_0xee0a('0xa0')](_0x4d6583)>=_0x35e9f1[_0xee0a('0xa6')]){_0x5caa55=ut['cloneAction'](_0x4d6583,0xf,'Global');rpcDb[_0xee0a('0x94')](_0x5caa55,'[callProgressDetectingCustomer][logNoAnswerGlobal]');}else{if(_0x4d6583[_0xee0a('0xc7')]>=_0x35e9f1[_0xee0a('0xcb')]){rpcDb['createCustomerFinal'](_0x4d6583,_0xee0a('0xcc'));}else{rpcDb[_0xee0a('0xaa')](ut[_0xee0a('0xab')](_0x4d6583,_0xee0a('0xc7'),_0x35e9f1[_0xee0a('0xcd')]),_0x4d6583['unlockAgent'],_0x4d6583[_0xee0a('0xad')]);}}break;case _0xee0a('0xce'):_0x35e9f1[_0xee0a('0x37')]+=0x1;_0x4d6583[_0xee0a('0xcf')]+=0x1;_0x4d6583[_0xee0a('0x9f')]=ut[_0xee0a('0xa0')](_0x4d6583);ut[_0xee0a('0x8e')](_0x4d6583,0x8,_0xee0a('0xd0'));ami[_0xee0a('0x22')](_0xee0a('0xd1'),ut[_0xee0a('0xa3')](_0x4d6583,_0xee0a('0xd2')));rpcDb[_0xee0a('0x90')](_0x4d6583,'[callProgressDetectingCustomer][logCongestion]');if(ut[_0xee0a('0xa0')](_0x4d6583)>=_0x35e9f1['dialGlobalMaxRetry']){_0x5caa55=ut[_0xee0a('0xd3')](_0x4d6583,0xf,_0xee0a('0xa7'));rpcDb[_0xee0a('0x94')](_0x5caa55,_0xee0a('0xd4'));}else{if(_0x4d6583['countcongestionretry']>=_0x35e9f1[_0xee0a('0xd5')]){rpcDb['createCustomerFinal'](_0x4d6583,_0xee0a('0xd6'));}else{rpcDb[_0xee0a('0xaa')](ut['scheduledAt'](_0x4d6583,_0xee0a('0xcf'),_0x35e9f1[_0xee0a('0xc4')]),_0x4d6583[_0xee0a('0xc5')],_0x4d6583[_0xee0a('0xad')]);}}break;case _0xee0a('0xd7'):_0x35e9f1[_0xee0a('0x3e')]+=0x1;_0x4d6583[_0xee0a('0xd8')]+=0x1;_0x4d6583[_0xee0a('0x9f')]=ut['totalGlobal'](_0x4d6583);ut['logCustomer'](_0x4d6583,0x14,_0xee0a('0xd9'));ami[_0xee0a('0x22')](_0xee0a('0xda'),ut[_0xee0a('0xa3')](_0x4d6583,'agentreject'));rpcDb[_0xee0a('0x90')](_0x4d6583,_0xee0a('0xdb'));if(ut[_0xee0a('0xa0')](_0x4d6583)>=_0x35e9f1[_0xee0a('0xa6')]){_0x5caa55=ut[_0xee0a('0xd3')](_0x4d6583,0x14,_0xee0a('0xd9'));rpcDb['createCustomerFinal'](_0x5caa55,'[callProgressDetectingCustomer][logAgentReject]');}else{if(_0x4d6583[_0xee0a('0xd8')]>=_0x35e9f1[_0xee0a('0xdc')]){rpcDb[_0xee0a('0x94')](_0x4d6583,_0xee0a('0xdd'));}else{rpcDb[_0xee0a('0xaa')](ut[_0xee0a('0xab')](_0x4d6583,_0xee0a('0xd8'),_0x35e9f1[_0xee0a('0xde')]),_0x4d6583['unlockAgent'],_0x4d6583[_0xee0a('0xad')]);}}break;case _0xee0a('0xdf'):_0x35e9f1['outboundAbandonedCallsDay']+=0x1;_0x4d6583['countabandonedretry']+=0x1;_0x4d6583[_0xee0a('0x9f')]=ut[_0xee0a('0xa0')](_0x4d6583);ut[_0xee0a('0x8e')](_0x4d6583,0xb,_0xee0a('0xe0'));rpcDb[_0xee0a('0x90')](_0x4d6583,'[callProgressDetectingCustomer][logAbandoned]');if(ut[_0xee0a('0xa0')](_0x4d6583)>=_0x35e9f1[_0xee0a('0xa6')]){_0x5caa55=ut['cloneAction'](_0x4d6583,0xf,_0xee0a('0xa7'));rpcDb['createCustomerFinal'](_0x5caa55,_0xee0a('0xe1'));}else{if(_0x4d6583[_0xee0a('0xe2')]>=_0x35e9f1[_0xee0a('0xe3')]){rpcDb['createCustomerFinal'](_0x4d6583,_0xee0a('0xe1'));}else{rpcDb[_0xee0a('0xaa')](ut[_0xee0a('0xab')](_0x4d6583,_0xee0a('0xe4'),_0x35e9f1['dialAbandonedRetryFrequency']),_0x4d6583['unlockAgent'],_0x4d6583['activeContact']);}}break;case'18':_0x35e9f1[_0xee0a('0x3f')]+=0x1;_0x4d6583[_0xee0a('0xe5')]+=0x1;_0x4d6583[_0xee0a('0x9f')]=ut['totalGlobal'](_0x4d6583);ut['logCustomer'](_0x4d6583,0x12,_0x4d5c5b[_0xee0a('0xe6')]||_0x4d5c5b[_0xee0a('0xe7')]);ami[_0xee0a('0x22')]('custom:amd',ut['buildObj'](_0x4d6583,_0xee0a('0xe8')));rpcDb['createCustomerHistory'](_0x4d6583,_0xee0a('0xe9'));if(ut[_0xee0a('0xa0')](_0x4d6583)>=_0x35e9f1[_0xee0a('0xa6')]){_0x5caa55=ut[_0xee0a('0xd3')](_0x4d6583,0xf,'Global');rpcDb[_0xee0a('0x94')](_0x5caa55,_0xee0a('0xe9'));}else{rpcDb[_0xee0a('0x94')](_0x4d6583,_0xee0a('0xe9'));}delete this[_0xee0a('0x10')][_0x4d5c5b[_0xee0a('0xae')]];break;case'19':_0x35e9f1[_0xee0a('0x3f')]+=0x1;_0x4d6583[_0xee0a('0x9f')]=ut[_0xee0a('0xa0')](_0x4d6583);ut[_0xee0a('0x8e')](_0x4d6583,0x13,_0x4d5c5b[_0xee0a('0xe6')]||_0x4d5c5b[_0xee0a('0xe7')]);ami['emit'](_0xee0a('0xea'),ut['buildObj'](_0x4d6583,_0xee0a('0xe8')));rpcDb[_0xee0a('0x90')](_0x4d6583,_0xee0a('0xeb'));if(ut[_0xee0a('0xa0')](_0x4d6583)>=_0x35e9f1[_0xee0a('0xa6')]){_0x5caa55=ut['cloneAction'](_0x4d6583,0xf,_0xee0a('0xa7'));rpcDb[_0xee0a('0x94')](_0x5caa55,'[callProgressDetectingCustomer][machine]');}else{rpcDb[_0xee0a('0x94')](_0x4d6583,_0xee0a('0xeb'));}delete this[_0xee0a('0x10')][_0x4d5c5b[_0xee0a('0xae')]];break;default:if(_0x4d6583[_0xee0a('0x6c')]){ut[_0xee0a('0x78')](_0x35e9f1,'[default]');ut[_0xee0a('0x79')](_0xee0a('0xec')+_0x35e9f1[_0xee0a('0x25')],_0x4d5c5b);}_0x35e9f1[_0xee0a('0x3f')]+=0x1;_0x4d6583[_0xee0a('0x9f')]=ut['totalGlobal'](_0x4d6583);ut[_0xee0a('0x8e')](_0x4d6583,0xc,_0x4d5c5b[_0xee0a('0xe6')]||_0x4d5c5b[_0xee0a('0xe7')]);rpcDb[_0xee0a('0x90')](_0x4d6583,_0xee0a('0xed'));if(ut[_0xee0a('0xa0')](_0x4d6583)>=_0x35e9f1['dialGlobalMaxRetry']){_0x5caa55=ut['cloneAction'](_0x4d6583,0xf,_0xee0a('0xa7'));rpcDb['createCustomerFinal'](_0x5caa55,_0xee0a('0xee'));}else{rpcDb[_0xee0a('0x94')](_0x4d6583,_0xee0a('0xee'));}delete this[_0xee0a('0x10')][_0x4d5c5b[_0xee0a('0xae')]];}if(!(_0x4d6583['dialAnswer']&&_0x4b76b9==='16')){ut[_0xee0a('0x76')](_0x35e9f1,'[callProgressDetectingCustomer]');logger[_0xee0a('0x7c')](_0xee0a('0xef'),_0x4d6583['uniqueid'],_0xee0a('0xb2'),_0x35e9f1[_0xee0a('0x25')],_0xee0a('0xf0'),_0x35e9f1['originated']);}if(_0x4b76b9!==_0xee0a('0xaf')){delete this[_0xee0a('0x10')][_0x4d5c5b[_0xee0a('0xae')]];delete this[_0xee0a('0x10')][_0x4d5c5b['destlinkedid']];}}};Preview[_0xee0a('0x9')][_0xee0a('0xf1')]=function(_0x5d64e4,_0x4f8c4e,_0x1991a3){if(_['isUndefined'](_0x4f8c4e)&&_0xee0a('0xf2')!==typeof _0x4f8c4e){return;}if(_[_0xee0a('0xf3')](_0x1991a3)&&_0xee0a('0xf2')!==typeof _0x1991a3){return;}switch(_0x1991a3['reason']){case'0':ut[_0xee0a('0xf4')](_0x5d64e4,0x0,_0xee0a('0xa1'));rpcDb[_0xee0a('0xf5')](_0x5d64e4,'[callProgressDetectingAgent][logNoSuch]');break;case'3':ut['logAgent'](_0x5d64e4,0x3,_0xee0a('0xc8'));rpcDb[_0xee0a('0xf5')](_0x5d64e4,'[callProgressDetectingAgent][logNoAnswer]');break;case'5':ut[_0xee0a('0xf4')](_0x5d64e4,0x5,_0xee0a('0xbf'));rpcDb[_0xee0a('0xf5')](_0x5d64e4,_0xee0a('0xf6'));break;case'8':ut['logAgent'](_0x5d64e4,0x8,'Congestion');rpcDb[_0xee0a('0xf5')](_0x5d64e4,_0xee0a('0xf7'));break;case'22':ut[_0xee0a('0xf4')](_0x5d64e4,0x16,_0xee0a('0xf8'));rpcDb[_0xee0a('0xf5')](_0x5d64e4,_0xee0a('0xf9'));break;default:ut[_0xee0a('0xf4')](_0x5d64e4,0xc,_0x1991a3['reason']);rpcDb[_0xee0a('0xf5')](_0x5d64e4,'[callProgressDetectingAgent][logCongestion]');}ut[_0xee0a('0x76')](_0x4f8c4e,_0xee0a('0xfa'));logger[_0xee0a('0x7c')]('[originated][decrement][callProgressDetectingAgent]',_0x5d64e4[_0xee0a('0xb1')],_0xee0a('0xb2'),_0x4f8c4e[_0xee0a('0x25')],_0xee0a('0xf0'),_0x4f8c4e['originated']);delete this[_0xee0a('0x10')][_0x5d64e4[_0xee0a('0xb1')]];};Preview['prototype'][_0xee0a('0xfb')]=function(_0x42785e,_0x43eee5,_0x5afce7,_0x310487,_0x2c546f){var _0x27c900=this;return new BPromise(function(_0x323dca,_0x168ac6){if(_[_0xee0a('0x82')](_0x43eee5)||_[_0xee0a('0x82')](_0x43eee5[_0xee0a('0xfc')])||_[_0xee0a('0x82')](_0x43eee5[_0xee0a('0xfc')][_0xee0a('0xfd')])||_[_0xee0a('0x82')](_0x43eee5[_0xee0a('0x70')])){_0x168ac6(ut[_0xee0a('0x4a')]('Contact\x20is\x20undefined',_0x310487,_0x2c546f));return;}var _0x94eb26=uuid['v4']();var _0x33d0ad=_0x27c900['campaignsPreview'][_0x43eee5[_0xee0a('0x69')][_0xee0a('0x25')]];var _0x368678=_0x5afce7?_0x27c900['agents'][_0x5afce7]['id']:undefined;_0x27c900[_0xee0a('0x10')][_0x94eb26]=new Action(_0x43eee5,_0x33d0ad,_0x94eb26,_0x5afce7,_0x368678);var _0x15a09a=_0x27c900[_0xee0a('0x10')][_0x94eb26];_0x15a09a[_0xee0a('0xc5')]=_0x310487;_0x15a09a['activeContact']=_0x2c546f;_0x15a09a[_0xee0a('0xfe')]=_0x5afce7;if(_[_0xee0a('0xff')](_0x42785e)){_0x27c900[_0xee0a('0x100')](_0x15a09a,_0x33d0ad,_0x43eee5,_0x5afce7)['then'](function(_0x48d951){logger[_0xee0a('0x7c')](_0xee0a('0x101'),_0xee0a('0x102')+_0x15a09a[_0xee0a('0x6a')]+_0xee0a('0x103')+_0x15a09a[_0xee0a('0x104')],JSON[_0xee0a('0x54')](_0x48d951));ami[_0xee0a('0x22')](_0xee0a('0x105'),ut[_0xee0a('0xa3')](_0x15a09a,_0xee0a('0x106'),_0x27c900[_0xee0a('0xe')][_0x15a09a[_0xee0a('0x6a')]]));_0x323dca(ut[_0xee0a('0x4a')](_0xee0a('0x107')));})['catch'](function(_0x4db028){ut['logger'](_0xee0a('0x108'),_0x4db028);_0x168ac6(ut[_0xee0a('0x4a')](_0xee0a('0x109'),_0x310487,_0x2c546f));});}else{_0x33d0ad[_0xee0a('0x35')]+=0x1;ut[_0xee0a('0x10a')](_0x15a09a);rpcDb['createHistory'](_0x15a09a,'[Blacklist][error]');delete _0x27c900[_0xee0a('0x10')][_0x94eb26];_0x168ac6(ut['message'](_0xee0a('0x10b'),_0x310487,_0x2c546f));}});};Preview['prototype'][_0xee0a('0x99')]=function(_0x49cf8a){return!_[_0xee0a('0x82')](_0x49cf8a)&&!_[_0xee0a('0x82')](_0x49cf8a[_0xee0a('0x25')])&&!_[_0xee0a('0x82')](_0x49cf8a[_0xee0a('0x52')])&&_0x49cf8a[_0xee0a('0x52')]&&!_[_0xee0a('0x82')](this['trunks'][util[_0xee0a('0x55')](_0xee0a('0x10c'),_0x49cf8a[_0xee0a('0x25')])])&&!_[_0xee0a('0x82')](this[_0xee0a('0xf')][util['format'](_0xee0a('0x10c'),_0x49cf8a['name'])]['status'])&&(this[_0xee0a('0xf')][util[_0xee0a('0x55')]('SIP/%s',_0x49cf8a[_0xee0a('0x25')])][_0xee0a('0x72')]===_0xee0a('0x10d')||this['trunks'][util[_0xee0a('0x55')](_0xee0a('0x10c'),_0x49cf8a[_0xee0a('0x25')])]['status']===_0xee0a('0x10e'));};Preview[_0xee0a('0x9')]['run']=function(_0x55536a,_0x1ebc56){var _0x5c6b26=this;return new BPromise(function(_0x10f7c6,_0xbb16c5){_0x5c6b26[_0xee0a('0x10f')](_0x55536a,_0x1ebc56)[_0xee0a('0x81')](function(_0xc5c619){_0x10f7c6(_[_0xee0a('0x6d')](_0xc5c619,[_0xee0a('0x4a')]));})[_0xee0a('0x74')](function(_0x343ee3){if(_0x343ee3[_0xee0a('0x110')]){rpcDb[_0xee0a('0x111')](_0x55536a);}if(_0x343ee3[_0xee0a('0x52')]){rpcDb['disableContact'](_0x55536a);}_0xbb16c5(_[_0xee0a('0x6d')](_0x343ee3,[_0xee0a('0x4a')]));});});};Preview[_0xee0a('0x9')][_0xee0a('0x10f')]=function(_0x5ed20b,_0x2b330e){var _0x4379ad=this;return new BPromise(function(_0x10c3f4,_0x1b8053){var _0x1ce389,_0xc27a48;rpcDb['getContactPreview'](_0x5ed20b)['then'](function(_0x325c16){if(!_['isNil'](_0x325c16[0x0])){_0xc27a48=_0x325c16[0x0][_0xee0a('0x112')]?![]:!![];_0x1ce389=_0x325c16[0x0][_0xee0a('0x112')]?!![]:![];_0x1ce389=_0x2b330e?!![]:_0x1ce389;}var _0x2d6018=_0x4379ad[_0xee0a('0x113')](_0x325c16);if(_0x2d6018[_0xee0a('0x114')]){rpcDb[_0xee0a('0x115')](_[_0xee0a('0x6d')](_0x325c16[0x0],['VoiceQueueId',_0xee0a('0x116')]))[_0xee0a('0x81')](function(_0x2a1075){_0x4379ad[_0xee0a('0xfb')](_0x2a1075,_0x325c16[0x0],_0x2b330e,_0xc27a48,_0x1ce389)[_0xee0a('0x81')](function(_0x3d72f5){_0x10c3f4(_0x3d72f5);})['catch'](function(_0x435f72){_0x1b8053(_0x435f72);});})['catch'](function(_0x5ec2c7){ut[_0xee0a('0x5d')](_0xee0a('0x117'),_0x5ec2c7);_0x1b8053(ut[_0xee0a('0x4a')](_0xee0a('0x118'),_0xc27a48,_0x1ce389));});}else{_0x1b8053(ut[_0xee0a('0x4a')](_0x2d6018['message'],_0xc27a48,_0x1ce389));}})[_0xee0a('0x74')](function(_0x44b3eb){ut[_0xee0a('0x5d')](_0xee0a('0x119'),_0x44b3eb);_0x1b8053(ut[_0xee0a('0x4a')]('Call\x20unsuccessful',![],!![]));});});};Preview[_0xee0a('0x9')][_0xee0a('0x113')]=function(_0x150b6f){if(_['isNil'](_0x150b6f)||_['isEmpty'](_0x150b6f)||!_[_0xee0a('0x82')](_0x150b6f[0x0][_0xee0a('0x87')])&&_[_0xee0a('0x82')](_0x150b6f[0x0][_0xee0a('0x87')][_0xee0a('0x25')])){ut[_0xee0a('0x5d')]('[Preview][validateContact][Empty\x20Contact]',_0x150b6f);return{'isValid':![],'message':_0xee0a('0x11a')};}var _0x746b58=this[_0xee0a('0xe')][_0x150b6f[0x0]['Queue'][_0xee0a('0x25')]];_0x746b58[_0xee0a('0x4a')]=_0xee0a('0x9b');if(_['isNil'](_0x746b58)){ut[_0xee0a('0x5d')](_0xee0a('0x11b'),_0x746b58);return{'isValid':![],'message':'Empty\x20Campaign'};}if(!this[_0xee0a('0x99')](_0x746b58[_0xee0a('0x51')])){ut['logger'](_0xee0a('0x11c'),_0xee0a('0x11d')+_0x746b58[_0xee0a('0x25')]+_0xee0a('0x11e'));if(!this['isTrunkReachable'](_0x746b58[_0xee0a('0x9a')])){ut['logger'](_0xee0a('0x11c'),_0x746b58[_0xee0a('0x25')]+'\x20Trunk\x20Backup\x20is\x20not\x20active');return{'isValid':![],'message':_0xee0a('0x11f')};}}if(!ut[_0xee0a('0x120')](_0x746b58[_0xee0a('0x98')])){ut[_0xee0a('0x5d')](_0xee0a('0x121'),_0x746b58[_0xee0a('0x25')]+_0xee0a('0x122'));return{'isValid':![],'message':_0xee0a('0x11d')+_0x746b58[_0xee0a('0x25')]+_0xee0a('0x122')};}return{'isValid':!![],'message':_0xee0a('0x123')};};Preview['prototype'][_0xee0a('0x100')]=function(_0x384edc,_0x59b741,_0x15bb10,_0x509e7b){var _0xb7969d=this;return new BPromise(function(_0x314337,_0x5bf973){var _0x2277af=_0x384edc[_0xee0a('0xb1')];var _0x2d9c2e=_0xb7969d[_0xee0a('0x99')](_0x59b741[_0xee0a('0x51')])?util[_0xee0a('0x55')](_0xee0a('0x124'),_0x59b741[_0xee0a('0x51')][_0xee0a('0x25')],_[_0xee0a('0x82')](_0x59b741[_0xee0a('0x32')])?'':_0x59b741['dialPrefix'][_0xee0a('0x125')]()||'',_0x59b741[_0xee0a('0x126')]>0x0?_0x15bb10[_0xee0a('0xfc')][_0xee0a('0xfd')]['substring'](_0x59b741[_0xee0a('0x126')]):_0x15bb10[_0xee0a('0xfc')]['phone']):util[_0xee0a('0x55')](_0xee0a('0x124'),_[_0xee0a('0x82')](_0x59b741[_0xee0a('0x9a')])?_0x59b741['Trunk'][_0xee0a('0x25')]:_0x59b741[_0xee0a('0x9a')][_0xee0a('0x25')],_['isNil'](_0x59b741[_0xee0a('0x32')])?'':_0x59b741[_0xee0a('0x32')][_0xee0a('0x125')]()||'',_0x59b741['dialCutDigit']>0x0?_0x15bb10[_0xee0a('0xfc')]['phone'][_0xee0a('0x127')](_0x59b741[_0xee0a('0x126')]):_0x15bb10[_0xee0a('0xfc')][_0xee0a('0xfd')]);var _0x196a40=_0xb7969d[_0xee0a('0x99')](_0x59b741['Trunk'])?ut['getCallerId'](_0x59b741['Trunk'][_0xee0a('0x128')],_0x59b741[_0xee0a('0x30')],_0x59b741['dialRandomLastDigitCallerIdNumber']>0x0?ut[_0xee0a('0x129')](_0x59b741[_0xee0a('0x31')],_0x59b741['dialRandomLastDigitCallerIdNumber']):_0x59b741[_0xee0a('0x31')]):ut[_0xee0a('0x12a')](_[_0xee0a('0x82')](_0x59b741[_0xee0a('0x9a')])?_0x59b741['Trunk'][_0xee0a('0x128')]:_0x59b741[_0xee0a('0x9a')][_0xee0a('0x128')],_0x59b741[_0xee0a('0x30')],_0x59b741[_0xee0a('0x12b')]>0x0?ut[_0xee0a('0x129')](_0x59b741['dialOriginateCallerIdNumber'],_0x59b741['dialRandomLastDigitCallerIdNumber']):_0x59b741[_0xee0a('0x31')]);if(_0x196a40){_0x384edc[_0xee0a('0x12c')]=ut['extractCalleridName'](_0x196a40);_0x384edc[_0xee0a('0x12d')]=ut[_0xee0a('0x12e')](_0x196a40);}var _0x23ad5f=ut[_0xee0a('0x12f')](_0x59b741,_0x15bb10,_0x2d9c2e,_0x196a40,_0x2277af,_0x384edc);_['merge'](_0x384edc,ut['toLowerVariables'](_0x23ad5f));_0x384edc[_0xee0a('0x8c')]=moment()[_0xee0a('0x55')](_0xee0a('0x8d'));ami['Action'](ut[_0xee0a('0x130')](_0x384edc,_0x59b741,_0x23ad5f,_0x384edc['activeContact'],_0x509e7b))[_0xee0a('0x81')](function(_0x2dada9){_0x59b741[_0xee0a('0x4b')]+=0x1;logger[_0xee0a('0x7c')](_0xee0a('0x131'),_0x2277af,_0xee0a('0xb2'),_0x59b741[_0xee0a('0x25')],_0xee0a('0xf0'),_0x59b741[_0xee0a('0x4b')]);_0x314337(_0x2dada9);})[_0xee0a('0x74')](function(_0x5e3794){ut[_0xee0a('0xf4')](_0x384edc,0xe,_0xee0a('0x132'));rpcDb['createAgentHistory'](_0x384edc,_0xee0a('0x133'));_0x5bf973(_0x5e3794);});});};Preview[_0xee0a('0x9')][_0xee0a('0x134')]=function(_0x1ab4b6){if(this[_0xee0a('0x10')][_0x1ab4b6[_0xee0a('0xae')]]){this[_0xee0a('0x10')][_0x1ab4b6['linkedid']][_0xee0a('0x73')]=_0x1ab4b6[_0xee0a('0x73')];}};Preview[_0xee0a('0x9')]['syncOriginateResponse']=function(_0x5d430f){var _0x15308d=this;var _0x309582=this[_0xee0a('0x10')][_0x5d430f[_0xee0a('0x135')]];if(_0x309582){if(_0x309582['lookAgent']&&this[_0xee0a('0x11')][_0x309582[_0xee0a('0xfe')]]){ut[_0xee0a('0x136')](_0x309582,this[_0xee0a('0x11')][_0x309582['lookAgent']][_0xee0a('0x25')],this[_0xee0a('0x11')][_0x309582[_0xee0a('0xfe')]]['id']);}var _0xe89b7f=_[_0xee0a('0x137')](_0x309582);_0xe89b7f[_0xee0a('0x138')]=moment()[_0xee0a('0x55')]('YYYY-MM-DD\x20HH:mm:ss');var _0x532c59=_0x15308d[_0xee0a('0xe')][_0x309582['queue']];if(ut['isFailure'](_0x5d430f['response'])){if(_0x309582[_0xee0a('0xc5')]){rpcDb[_0xee0a('0x111')](_0x309582['idContact']);}if(_0x309582[_0xee0a('0xad')]){rpcDb['disableContact'](_0x309582['idContact']);}ami['emit'](_0xee0a('0x139'),ut[_0xee0a('0xa3')](_0x309582,_0xee0a('0x13a'),this[_0xee0a('0xe')][_0x309582[_0xee0a('0x6a')]]));this[_0xee0a('0xf1')](_0xe89b7f,_0x532c59,_0x5d430f);}else{_0x309582['starttime']=moment()[_0xee0a('0x55')](_0xee0a('0x8d'));ut[_0xee0a('0xf4')](_0xe89b7f,0x4,'Answer');rpcDb[_0xee0a('0xf5')](_0xe89b7f,_0xee0a('0x13b'));}}};Preview[_0xee0a('0x9')]['syncHangup']=function(_0x3e9cc7){var _0x54f144=this;var _0x31c277=this['actions'][_0x3e9cc7[_0xee0a('0xae')]];var _0x32d8c5;if(_0x31c277){_0x32d8c5=this['campaignsPreview'][_0x31c277[_0xee0a('0x6a')]];logger[_0xee0a('0x7c')](_0xee0a('0x13c'),_0x3e9cc7[_0xee0a('0xae')],'\x20Queue',_0x32d8c5[_0xee0a('0x25')],_0xee0a('0x6b'),_0x32d8c5['pTalking']);}if(this[_0xee0a('0x10')][_0x3e9cc7[_0xee0a('0xae')]]&&_0x3e9cc7[_0xee0a('0xae')]!==_0x3e9cc7[_0xee0a('0xb1')]){if(_0x3e9cc7[_0xee0a('0x13d')]==='16'&&this['actions'][_0x3e9cc7['linkedid']][_0xee0a('0x6c')]){this[_0xee0a('0x9c')](_0x3e9cc7,_0x3e9cc7[_0xee0a('0xae')],_0x3e9cc7[_0xee0a('0x13d')]);}else if(this[_0xee0a('0x10')][_0x3e9cc7[_0xee0a('0xae')]]['dialAnswer']){logger[_0xee0a('0x7c')](_0xee0a('0x13e'),_0x3e9cc7[_0xee0a('0xae')],_0x3e9cc7['cause'],_0xee0a('0xb2'),_0x32d8c5[_0xee0a('0x25')],_0xee0a('0x6b'),_0x32d8c5[_0xee0a('0x29')]);this['callProgressDetectingCustomer'](_0x3e9cc7,_0x3e9cc7[_0xee0a('0xae')],_0x3e9cc7[_0xee0a('0x13d')]);}}else if(_0x31c277&&_['isNil'](_0x31c277[_0xee0a('0x13f')])&&_0x32d8c5['dialQueueProject']&&_0x3e9cc7['linkedid']===_0x3e9cc7[_0xee0a('0xb1')]&&_['isNil'](_0x3e9cc7['reason'])&&_0x3e9cc7[_0xee0a('0x13d')]==='16'&&_0x3e9cc7['channelstate']==='6'&&_[_0xee0a('0xf3')](_0x31c277[_0xee0a('0x140')])){if(_0x31c277[_0xee0a('0xc5')]){rpcDb[_0xee0a('0x111')](_0x31c277[_0xee0a('0x104')]);}if(_0x31c277[_0xee0a('0xad')]){rpcDb[_0xee0a('0x141')](_0x31c277[_0xee0a('0x104')]);}_0x3e9cc7['reason']='22';this['callProgressDetectingAgent'](_0x31c277,_0x32d8c5,_0x3e9cc7);}else if(_0x31c277&&_0x31c277['transfer']){if(_0x3e9cc7[_0xee0a('0x13d')]==='16'&&this[_0xee0a('0x10')][_0x3e9cc7[_0xee0a('0xae')]][_0xee0a('0x6c')]){logger[_0xee0a('0x7c')](_0xee0a('0x142'),_0x3e9cc7[_0xee0a('0xae')],_0x3e9cc7[_0xee0a('0x13d')],_0xee0a('0xb2'),_0x32d8c5[_0xee0a('0x25')],_0xee0a('0x6b'),_0x32d8c5['pTalking']);this['callProgressDetectingCustomer'](_0x3e9cc7,_0x3e9cc7[_0xee0a('0xae')],_0x3e9cc7[_0xee0a('0x13d')]);}else if(this[_0xee0a('0x10')][_0x3e9cc7[_0xee0a('0xae')]][_0xee0a('0x6c')]){logger['info']('[syncHangup][talking][cause]',_0x3e9cc7[_0xee0a('0xae')],_0x3e9cc7['cause'],_0xee0a('0xb2'),_0x32d8c5[_0xee0a('0x25')],_0xee0a('0x6b'),_0x32d8c5[_0xee0a('0x29')]);this['callProgressDetectingCustomer'](_0x3e9cc7,_0x3e9cc7[_0xee0a('0xae')],_0x3e9cc7['cause']);}}};Preview[_0xee0a('0x9')][_0xee0a('0x1a')]=function(_0xd0001e){if(this[_0xee0a('0x10')][_0xd0001e[_0xee0a('0x143')]]&&_0xd0001e[_0xee0a('0x143')]!==_0xd0001e['destuniqueid']){this[_0xee0a('0x9c')](_0xd0001e,_0xd0001e[_0xee0a('0x143')],_0xd0001e[_0xee0a('0xe7')]);}};Preview['prototype'][_0xee0a('0x18')]=function(_0x5bebad){if(this[_0xee0a('0x10')][_0x5bebad[_0xee0a('0xae')]]&&_0x5bebad[_0xee0a('0xae')]!==_0x5bebad['uniqueid']&&!this[_0xee0a('0x10')][_0x5bebad[_0xee0a('0xae')]][_0xee0a('0x6c')]){if(_0x5bebad[_0xee0a('0x13d')]==='1'){this[_0xee0a('0x9c')](_0x5bebad,_0x5bebad[_0xee0a('0xae')],_0x5bebad[_0xee0a('0x13d')]);}}};Preview[_0xee0a('0x9')]['addVariable']=function(_0xcd80be,_0x4a00dd,_0x3faf3e){if(this['actions'][_0xcd80be]){if(_['isNil'](this[_0xee0a('0x10')][_0xcd80be]['variables'])){this[_0xee0a('0x10')][_0xcd80be][_0xee0a('0x144')]={};}this[_0xee0a('0x10')][_0xcd80be][_0xee0a('0x144')][_0x4a00dd]=_0x3faf3e;}};Preview[_0xee0a('0x9')][_0xee0a('0x1d')]=function(_0x339bd3){try{if(!_[_0xee0a('0x82')](_0x339bd3)){if(ut[_0xee0a('0x145')](_[_0xee0a('0x146')](_0x339bd3['variable'])[0x0])){this['addVariable'](_0x339bd3[_0xee0a('0xb1')],_[_0xee0a('0x146')](_0x339bd3[_0xee0a('0x147')])[0x0],_0x339bd3[_0xee0a('0x148')]);}}}catch(_0x1247ea){logger[_0xee0a('0x149')](_0xee0a('0x14a'),util['inspect'](_0x1247ea,{'showHidden':![],'depth':null}));}};Preview[_0xee0a('0x9')]['syncAttendedTransfer']=function(_0x560016){if(_0x560016){if(this[_0xee0a('0x10')][_0x560016[_0xee0a('0x14b')]]){this[_0xee0a('0x10')][_0x560016[_0xee0a('0x14b')]][_0xee0a('0x140')]=!![];}}};Preview[_0xee0a('0x9')]['syncBlindTransfer']=function(_0x200cd2){if(_0x200cd2){if(this['actions'][_0x200cd2[_0xee0a('0x14c')]]){this[_0xee0a('0x10')][_0x200cd2[_0xee0a('0x14c')]][_0xee0a('0x140')]=!![];}}};module[_0xee0a('0x14d')]=Preview;