Built motion from commit 85328c08.|2.5.50
[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 _0x8958=['Busy','custom:agentbusy','busy','dialGlobalMaxRetry','[callProgressDetectingCustomer][logBusyGlobal]','dialBusyMaxRetry','dialBusyRetryFrequency','NOANSWER','countglobal','NoAnswer','custom:agentnoanswer','noanswer','[callProgressDetectingCustomer][logNoAnswerGlobal]','[callProgressDetectingCustomer][logNoAnswer]','countnoanswerretry','dialNoAnswerRetryFrequency','activeContact','CONGESTION','outboundCongestionCallsDay','Congestion','custom:agentcongestion','congestion','[callProgressDetectingCustomer][logCongestionGlobal]','countcongestionretry','dialCongestionMaxRetry','[callProgressDetectingCustomer][logCongestion]','CANCEL','countagentrejectretry','AgentReject','custom:agentreject','agentreject','[syncHangupRequest][logAgentReject]','[callProgressDetectingCustomer][logAgentReject]','dialAgentRejectMaxRetry','countabandonedretry','Abandoned','[callProgressDetectingCustomer][logAbandoned]','countabandonedetry','dialAbandonedMaxRety','dialAbandonedRetryFrequency','countmachineretry','cause-txt','dialstatus','custom:amd','amd','[callProgressDetectingCustomer][hangupInAMD]','[callProgressDetectingCustomer][machine]','[default]','[Dialer][decrementTalkink][no\x20Hangup][Preview]','[callProgressDetectingCustomer][logUnknownGlobal]','[callProgressDetectingCustomer]','[originated][decrement][callProgressDetectingCustomer]','originated:\x20','callProgressDetectingAgent','isUndefined','object','reason','logAgent','createAgentHistory','[callProgressDetectingAgent][logNoSuch]','[callProgressDetectingAgent][logNoAnswer]','[callProgressDetectingAgent][logBusy]','[callProgressDetectingAgent][logCongestion]','[callProgressDetectingAgent]','[originated][decrement][callProgressDetectingAgent]','Contact','Contact\x20is\x20undefined','Queue','lookAgent','isEmpty','execCall','[Preview][execCall][success]','Queue:\x20','\x20IdHopper:\x20','idContact','Calling','[Preview][execCall][failure]','logBlacklist','createHistory','Contact\x20in\x20black\x20List','SIP/%s','status','reachable','unmonitored','getContactPreview','recallme','validateContact','isValid','checkIsBlackList','checkInBlack','[Preview][checkIsBlackList]','[Preview][getContactPreview]','Call\x20unsuccessful','[Preview][validateContact][Empty\x20Contact]','Empty\x20Contact','[Preview][validateContact][Empty\x20Campaign]','Empty\x20Campaign','[Preview][validateContact][Trunk\x20not\x20work]','\x20Trunk\x20is\x20not\x20active','\x20Trunk\x20Backup\x20is\x20not\x20active','Trunk\x20not\x20work','isActive','\x20Not\x20Active','Is\x20Valid','SIP/%s/%s%s','dialCutDigit','substring','phone','trim','getCallerId','callerid','dialOriginateCallerIdNumber','dialRandomLastDigitCallerIdNumber','getCallerIdRandom','originatecalleridnum','extractCalleridNumber','addVariables','variablesAction','[originated][increment]','OriginateError','syncOriginateResponse','actionid','logLookAgent','responsetime','response','unlockContact','custom:agentringnoanswer','[callProgressDetectingAgent][logAnswer]','[syncHangup][talking]','cause','[syncHangup][talking][cause]','statedesc','dialQueueProject','channelstate','transfer','[syncHangup][talking][transfer]','destlinkedid','destuniqueid','variables','filterKey','addVariable','keys','value','[syncVarSet][Preview]','inspect','transfererlinkedid','exports','lodash','ioredis','../../../config/logger','preview','../ami','./rpcDb','./action','./util/util','redis','localhost','socket.io-emitter','prototype','enqueue','tail','sequence','campaignsPreview','voiceQueues','trunks','agents','clockClearZombieChannels','bind','syncHangup','hanguprequest','syncHangupRequest','syncDialEnd','newexten','syncNewExten','varset','syncVarSet','attendedtransfer','syncAttendedTransfer','blindtransfer','syncBlindTransfer','emit','type','outbound','strategy','answered','available','loggedIn','pTalking','sumHoldTime','talking','total','abandoned','waiting','loggedInDb','dialOriginateCallerIdName','dialOriginateTimeout','dialPrefix','outboundAnswerAgiCallsDay','outboundAnswerCallsDay','outboundBlacklistCallsDay','outboundDropCallsDayACS','outboundDropCallsDayCallersExit','outboundDropCallsDayTimeout','outboundNoAnswerCallsDay','outboundNoSuchCallsDay','outboundRejectCallsDay','outboundUnknownCallsDay','outboundAbandonedCallsDay','predictiveIntervalAnsweredCalls','predictiveIntervalAvgHoldtime','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalErlangCalls','predictiveIntervalHitRate','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','originated','erlangCalls','erlangCallToSecond','erlangAbandonmentRate','erlangBusyFactor','startProgressive','Trunk','name','active','Interval','stringify','md5','format','voice:queue:%s','voice_queue:save','info','[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event','voice_queue_presence:remove','sendMessageOneNotActive','paused','message','NOT_ACTIVE','logger','IS_DISACTIVED','[CampaignPreview]\x20Campaign\x20Queue:\x20','\x20is\x20disactive','hasOwnProperty','dialMethod','booked','dialActive','setMessage','recallMe','clearZombieChannel','isNil','[clearZombieChannels][talking]','actions','queue','pick','UserId','Action','channel','catch','No\x20such\x20channel','updateOriginated','[clearZombieChannel]','dialAnswer','decrementTalkink','loggerError','[Dialer][checkChannel][pTalking][Preview]','[Dialer][checkChannel][Preview]','[action]','size','getContactRecallMe','agentReadyId','then','length','getDiff','scheduledat','Agent','voicePause','run','logger2','[RecallMe]','disableContact','starttime','YYYY-MM-DD\x20HH:mm:ss','RecallInQueue','dialRecallInQueue','createBody','createCustomerHistory','[HistoryDialRecallInQueue][historyCatch]','logCustomer','[HistoryRecallClose]','createCustomerFinal','[getContactRecallMe]','IsNotLoggedIn','AGENTS_NOT_LOGGED','isTrunkReachable','TrunkBackup','TRUNK_IS_NOT_REACHABLE','ACTIVE','callProgressDetectingCustomer','countnosuchnumberretry','totalGlobal','NoSuchNumber','custom:agentnosuchnumber','nosuchnumber','[callProgressDetectingCustomer][logNoSuch]','cloneAction','Global','[callProgressDetectingCustomer][logNoSuchGlobal]','dialNoSuchNumberMaxRetry','rescheduleContact','scheduledAt','unlockAgent','linkedid','ANSWER','answertime','uniqueid','\x20Queue','pTalking:\x20','custom:agentconnect','acw','custom:agentConnectPreview','buildAcw','complete','buildObj','[16]','Answer','[callProgressDetectingCustomer][logAnswer]','crateCustomerReportQueue','sumDuration','sumBillable','talktime','[syncHangup][talking][decrement]','BUSY','outboundBusyCallsDay','countbusyretry'];(function(_0x20311e,_0x8dbfe0){var _0x16281b=function(_0x230cfc){while(--_0x230cfc){_0x20311e['push'](_0x20311e['shift']());}};_0x16281b(++_0x8dbfe0);}(_0x8958,0x93));var _0x8895=function(_0x11e7c1,_0x56077c){_0x11e7c1=_0x11e7c1-0x0;var _0x4e4b69=_0x8958[_0x11e7c1];return _0x4e4b69;};'use strict';var util=require('util');var _=require(_0x8895('0x0'));var BPromise=require('bluebird');var uuid=require('uuid');var moment=require('moment');var md5=require('md5');var Redis=require(_0x8895('0x1'));var config=require('../../../config/environment');var logger=require(_0x8895('0x2'))(_0x8895('0x3'));var loggerAction=require(_0x8895('0x2'))('actionPreview');var ami=require(_0x8895('0x4'));var rpcDb=require(_0x8895('0x5'));var Action=require(_0x8895('0x6'));var ut=require(_0x8895('0x7'));config[_0x8895('0x8')]=_['defaults'](config[_0x8895('0x8')],{'host':_0x8895('0x9'),'port':0x18eb});var io=require(_0x8895('0xa'))(new Redis(config[_0x8895('0x8')]));var Sequence=function(){};Sequence[_0x8895('0xb')][_0x8895('0xc')]=function(_0x22a12b){this[_0x8895('0xd')]=this[_0x8895('0xd')]?this[_0x8895('0xd')]['finally'](_0x22a12b):_0x22a12b();};function Preview(_0x1cf600){this[_0x8895('0xe')]=new Sequence();this[_0x8895('0xf')]=_0x1cf600[_0x8895('0x10')];this[_0x8895('0x11')]=_0x1cf600[_0x8895('0x11')];this['actions']={};this[_0x8895('0x12')]=_0x1cf600[_0x8895('0x12')];this[_0x8895('0x13')]=0x0;ami['on']('originateresponse',this['syncOriginateResponse'][_0x8895('0x14')](this));ami['on']('hangup',this[_0x8895('0x15')][_0x8895('0x14')](this));ami['on'](_0x8895('0x16'),this[_0x8895('0x17')][_0x8895('0x14')](this));ami['on']('dialend',this[_0x8895('0x18')][_0x8895('0x14')](this));ami['on'](_0x8895('0x19'),this[_0x8895('0x1a')][_0x8895('0x14')](this));ami['on'](_0x8895('0x1b'),this[_0x8895('0x1c')][_0x8895('0x14')](this));ami['on'](_0x8895('0x1d'),this[_0x8895('0x1e')][_0x8895('0x14')](this));ami['on'](_0x8895('0x1f'),this[_0x8895('0x20')]['bind'](this));this['loopCampaigns'](this['campaignsPreview']);}function emit(_0x3daf43,_0x456282,_0x2d189c){io['to'](_0x3daf43)[_0x8895('0x21')](_0x456282,_0x2d189c);}function emitCampaignPreview(_0x3f7d5a){if(_0x3f7d5a[_0x8895('0x22')]===_0x8895('0x23')){var _0xc1ce17={'id':_0x3f7d5a['id'],'name':_0x3f7d5a['name'],'strategy':_0x3f7d5a[_0x8895('0x24')],'answered':_0x3f7d5a[_0x8895('0x25')],'available':_0x3f7d5a[_0x8895('0x26')],'loggedIn':_0x3f7d5a[_0x8895('0x27')],'pTalking':_0x3f7d5a[_0x8895('0x28')],'sumBillable':_0x3f7d5a['sumBillable'],'sumDuration':_0x3f7d5a['sumDuration'],'sumHoldTime':_0x3f7d5a[_0x8895('0x29')]||0x0,'talking':_0x3f7d5a[_0x8895('0x2a')],'total':_0x3f7d5a[_0x8895('0x2b')],'type':_0x3f7d5a[_0x8895('0x22')],'unmanaged':_0x3f7d5a['unmanaged'],'abandoned':_0x3f7d5a[_0x8895('0x2c')],'waiting':_0x3f7d5a[_0x8895('0x2d')],'loggedInDb':_0x3f7d5a[_0x8895('0x2e')],'dialActive':_0x3f7d5a['dialActive'],'dialMethod':_0x3f7d5a['dialMethod'],'dialOriginateCallerIdName':_0x3f7d5a[_0x8895('0x2f')],'dialOriginateCallerIdNumber':_0x3f7d5a['dialOriginateCallerIdNumber'],'dialOriginateTimeout':_0x3f7d5a[_0x8895('0x30')],'dialPrefix':_0x3f7d5a[_0x8895('0x31')],'outboundAnswerAgiCallsDay':_0x3f7d5a[_0x8895('0x32')],'outboundAnswerCallsDay':_0x3f7d5a[_0x8895('0x33')],'outboundBlacklistCallsDay':_0x3f7d5a[_0x8895('0x34')],'outboundBusyCallsDay':_0x3f7d5a['outboundBusyCallsDay'],'outboundCongestionCallsDay':_0x3f7d5a['outboundCongestionCallsDay'],'outboundDropCallsDayACS':_0x3f7d5a[_0x8895('0x35')],'outboundDropCallsDayCallersExit':_0x3f7d5a[_0x8895('0x36')],'outboundDropCallsDayTimeout':_0x3f7d5a[_0x8895('0x37')],'outboundNoAnswerCallsDay':_0x3f7d5a[_0x8895('0x38')],'outboundNoSuchCallsDay':_0x3f7d5a[_0x8895('0x39')],'outboundOriginateFailureCallsDay':_0x3f7d5a['outboundOriginateFailureCallsDay'],'outboundReCallsDay':_0x3f7d5a['outboundReCallsDay'],'outboundRejectCallsDay':_0x3f7d5a[_0x8895('0x3a')],'outboundUnknownCallsDay':_0x3f7d5a[_0x8895('0x3b')],'outboundAbandonedCallsDay':_0x3f7d5a[_0x8895('0x3c')],'predictiveIntervalAnsweredCalls':_0x3f7d5a[_0x8895('0x3d')],'predictiveIntervalAvgHoldtime':_0x3f7d5a[_0x8895('0x3e')],'predictiveIntervalAvgTalktime':_0x3f7d5a['predictiveIntervalAvgTalktime'],'predictiveIntervalDroppedCallsCallersExit':_0x3f7d5a[_0x8895('0x3f')],'predictiveIntervalDroppedCallsTimeout':_0x3f7d5a['predictiveIntervalDroppedCallsTimeout'],'predictiveIntervalErlangCalls':_0x3f7d5a[_0x8895('0x40')],'predictiveIntervalErlangCallsDroppedCalls':_0x3f7d5a['predictiveIntervalErlangCallsDroppedCalls'],'predictiveIntervalHitRate':_0x3f7d5a[_0x8895('0x41')],'predictiveIntervalMultiplicativeFactor':_0x3f7d5a[_0x8895('0x42')],'predictiveIntervalPauses':_0x3f7d5a[_0x8895('0x43')],'predictiveIntervalAvailable':_0x3f7d5a[_0x8895('0x44')],'predictiveIntervalTotalCalls':_0x3f7d5a[_0x8895('0x45')],'message':_0x3f7d5a['message'],'originated':_0x3f7d5a[_0x8895('0x46')],'erlangCalls':_0x3f7d5a[_0x8895('0x47')],'erlangCallToSecond':_0x3f7d5a[_0x8895('0x48')],'erlangAbandonmentRate':_0x3f7d5a[_0x8895('0x49')],'erlangBusyFactor':_0x3f7d5a[_0x8895('0x4a')],'startPredictive':_0x3f7d5a['startPredictive'],'startProgressive':_0x3f7d5a[_0x8895('0x4b')]};if(_0x3f7d5a['Trunk']){_0xc1ce17[_0x8895('0x4c')]={'id':_0x3f7d5a['Trunk']['id'],'name':_0x3f7d5a[_0x8895('0x4c')][_0x8895('0x4d')],'active':_0x3f7d5a[_0x8895('0x4c')][_0x8895('0x4e')],'callerid':_0x3f7d5a[_0x8895('0x4c')]['callerid']};}if(_0x3f7d5a[_0x8895('0x4f')]){_0xc1ce17['Interval']={'id':_0x3f7d5a[_0x8895('0x4f')]['id'],'name':_0x3f7d5a[_0x8895('0x4f')][_0x8895('0x4d')]};}var _0x9297ea=md5(JSON[_0x8895('0x50')](_0xc1ce17));if(_0x3f7d5a[_0x8895('0x51')]!==_0x9297ea){_0x3f7d5a['md5']=_0x9297ea;emit(util[_0x8895('0x52')](_0x8895('0x53'),_0xc1ce17['name']),_0x8895('0x54'),_0xc1ce17);}}}function emitVoiceQueueChannelRemove(_0x54ca09){logger[_0x8895('0x55')](_0x8895('0x56'),JSON['stringify'](_0x54ca09));emit(util[_0x8895('0x52')](_0x8895('0x53'),_0x54ca09['name']),'voice_queue_channel:remove',_0x54ca09);io[_0x8895('0x21')](_0x8895('0x57'),_0x54ca09);}function notSendMessagesQueue(_0x55aacc){if(_0x55aacc[_0x8895('0x58')]){if(_0x55aacc[_0x8895('0x46')]===0x0&&_0x55aacc['pTalking']===0x0){_0x55aacc[_0x8895('0x58')]=![];_0x55aacc[_0x8895('0x26')]=0x0;_0x55aacc[_0x8895('0x59')]=0x0;_0x55aacc[_0x8895('0x5a')]=_0x8895('0x5b');ut[_0x8895('0x5c')]('[CampaignPreview]\x20Campaign\x20Queue:\x20',_0x55aacc[_0x8895('0x4d')]+'\x20is\x20not\x20active');}else{_0x55aacc[_0x8895('0x5a')]=_0x8895('0x5d');ut['logger'](_0x8895('0x5e'),_0x55aacc['name']+_0x8895('0x5f'));}emitCampaignPreview(_0x55aacc);}}Preview['prototype']['loopCampaigns']=function(){var _0x51277b=this;setInterval(function(){_0x51277b['syncCampaigns']();},0x7cf);};Preview['prototype']['syncCampaigns']=function(){var _0x447ed6=this[_0x8895('0xf')];this['clockClearZombieChannels']+=0x1;for(var _0x4835d7 in _0x447ed6){if(_0x447ed6[_0x8895('0x60')](_0x4835d7)&&(_0x447ed6[_0x4835d7][_0x8895('0x61')]==='preview'||_0x447ed6[_0x4835d7][_0x8895('0x61')]===_0x8895('0x62'))&&_0x447ed6[_0x4835d7][_0x8895('0x22')]===_0x8895('0x23')){if(this[_0x8895('0x13')]>0x7){this['clockClearZombieChannels']=0x0;this['clearZombieChannels']();}}if(_0x447ed6['hasOwnProperty'](_0x4835d7)&&_0x447ed6[_0x4835d7][_0x8895('0x61')]==='preview'&&_0x447ed6[_0x4835d7][_0x8895('0x22')]===_0x8895('0x23')){if(_0x447ed6[_0x4835d7][_0x8895('0x63')]){this[_0x8895('0x64')](_0x447ed6[_0x4835d7]);if(_0x447ed6[_0x4835d7]['dialPreviewAutoRecallMe'])this[_0x8895('0x65')](_0x447ed6[_0x4835d7]);}else{notSendMessagesQueue(_0x447ed6[_0x4835d7]);}}}};Preview[_0x8895('0xb')][_0x8895('0x66')]=function(_0x167302){var _0x2d585c=this;this[_0x8895('0xe')][_0x8895('0xc')](function(){if(!_[_0x8895('0x67')](_0x2d585c['actions'][_0x167302])){loggerAction[_0x8895('0x55')](_0x8895('0x68'),_0x167302,'Queue',_0x2d585c[_0x8895('0x69')][_0x167302]['queue'],'originated:\x20',JSON[_0x8895('0x50')](_0x2d585c[_0x8895('0xf')][_0x2d585c[_0x8895('0x69')][_0x167302]['queue']][_0x8895('0x46')]),'pTalking:\x20',JSON[_0x8895('0x50')](_0x2d585c[_0x8895('0xf')][_0x2d585c[_0x8895('0x69')][_0x167302][_0x8895('0x6a')]][_0x8895('0x28')]),JSON[_0x8895('0x50')](_0x2d585c[_0x8895('0x69')][_0x167302]['dialAnswer']),JSON['stringify'](_[_0x8895('0x6b')](_0x2d585c[_0x8895('0x69')][_0x167302],['contactId',_0x8895('0x6c'),'VoiceQueueId','ListId'])));return ami[_0x8895('0x6d')]({'action':'status','channel':_0x2d585c[_0x8895('0x69')][_0x167302][_0x8895('0x6e')]})[_0x8895('0x6f')](function(_0x459e1a){if(_0x459e1a[_0x8895('0x5a')]===_0x8895('0x70')){setTimeout(function(){if(_0x2d585c[_0x8895('0x69')][_0x167302]){ut[_0x8895('0x71')](_0x2d585c['campaignsPreview'][_0x2d585c[_0x8895('0x69')][_0x167302][_0x8895('0x6a')]],_0x8895('0x72'));if(_0x2d585c['actions'][_0x167302][_0x8895('0x73')]===!![]){ut[_0x8895('0x74')](_0x2d585c[_0x8895('0xf')][_0x2d585c[_0x8895('0x69')][_0x167302][_0x8895('0x6a')]],_0x8895('0x72'));ut[_0x8895('0x75')](_0x8895('0x76')+_0x167302,_0x2d585c[_0x8895('0x69')][_0x167302][_0x8895('0x6a')]);}ut['loggerError'](_0x8895('0x77')+_0x167302,_0x2d585c[_0x8895('0x69')][_0x167302][_0x8895('0x6a')]);delete _0x2d585c[_0x8895('0x69')][_0x167302];}},0x2328);}});}});};Preview[_0x8895('0xb')]['clearZombieChannels']=function(){var _0x1b3c99=this;loggerAction[_0x8895('0x55')](_0x8895('0x78'),_[_0x8895('0x79')](this[_0x8895('0x69')]));for(var _0x58dd6c in this[_0x8895('0x69')]){if(_0x1b3c99[_0x8895('0x69')][_0x8895('0x60')](_0x58dd6c)){_0x1b3c99['clearZombieChannel'](_0x58dd6c);}}};Preview[_0x8895('0xb')][_0x8895('0x65')]=function(_0x2c777b){var _0x4ec8eb=this;rpcDb[_0x8895('0x7a')](_0x2c777b['id'],ut[_0x8895('0x7b')](this['agents']))[_0x8895('0x7c')](function(_0x26f68c){if(!_['isNil'](_0x26f68c)){for(var _0x2f990a=0x0;_0x2f990a<_0x26f68c[_0x8895('0x7d')];_0x2f990a+=0x1){if(ut[_0x8895('0x7e')](_0x26f68c[_0x2f990a][_0x8895('0x7f')])<_0x2c777b['dialRecallMeTimeout']*0x3c){if(_0x26f68c[_0x2f990a]['Agent']&&!_0x26f68c[_0x2f990a][_0x8895('0x80')][_0x8895('0x81')]){_0x4ec8eb[_0x8895('0x82')](_0x26f68c[_0x2f990a]['id'])['then'](ut[_0x8895('0x83')](_0x8895('0x84')))['catch'](ut[_0x8895('0x83')]('[RecallMe]'));}else{rpcDb[_0x8895('0x85')](_0x26f68c[_0x2f990a]['id']);}}else{var _0x2bd955=new Action(_0x26f68c[_0x2f990a],_0x2c777b);_0x2bd955[_0x8895('0x86')]=moment()[_0x8895('0x52')](_0x8895('0x87'));_0x2c777b['outboundReCallsDay']+=0x1;ut['logCustomer'](_0x2bd955,0x17,_0x8895('0x88'));if(_0x2c777b[_0x8895('0x89')]){rpcDb['rescheduleContactInQueue'](ut[_0x8895('0x8a')](_0x26f68c[_0x2f990a]));rpcDb[_0x8895('0x8b')](_0x2bd955,_0x8895('0x8c'));}else{ut[_0x8895('0x8d')](_0x2bd955,0x16,'RecallFailedTimeout');rpcDb[_0x8895('0x8b')](_0x2bd955,_0x8895('0x8e'));rpcDb[_0x8895('0x8f')](_0x2bd955,_0x8895('0x8e'));}}}}})[_0x8895('0x6f')](ut[_0x8895('0x83')](_0x8895('0x90')));};Preview[_0x8895('0xb')][_0x8895('0x64')]=function(_0x21c7bb){_0x21c7bb[_0x8895('0x58')]=!![];if(ut[_0x8895('0x91')](_0x21c7bb[_0x8895('0x27')])){_0x21c7bb[_0x8895('0x5a')]=_0x8895('0x92');}else if(!ut['isActive'](_0x21c7bb['dialActive'])){_0x21c7bb['message']=_0x8895('0x5b');}else if(!this[_0x8895('0x93')](_0x21c7bb[_0x8895('0x4c')])){if(!this[_0x8895('0x93')](_0x21c7bb[_0x8895('0x94')])){_0x21c7bb['message']=_0x8895('0x95');}else{_0x21c7bb[_0x8895('0x5a')]='ACTIVE';}}else{_0x21c7bb[_0x8895('0x5a')]=_0x8895('0x96');}emitCampaignPreview(_0x21c7bb);};Preview[_0x8895('0xb')][_0x8895('0x97')]=function(_0x3ee89e,_0x526ac9,_0x6440ea){var _0x3c318c=this;var _0x119624=this[_0x8895('0x69')][_0x526ac9];var _0x113ac4=this[_0x8895('0xf')][_0x119624[_0x8895('0x6a')]];var _0x5e7048;if(_0x113ac4){switch(_0x6440ea){case'1':_0x113ac4[_0x8895('0x39')]+=0x1;_0x119624[_0x8895('0x98')]+=0x1;_0x119624['countglobal']=ut[_0x8895('0x99')](_0x119624);ut[_0x8895('0x8d')](_0x119624,0x0,_0x8895('0x9a'));ami[_0x8895('0x21')](_0x8895('0x9b'),ut['buildObj'](_0x119624,_0x8895('0x9c')));rpcDb['createCustomerHistory'](_0x119624,_0x8895('0x9d'));if(ut[_0x8895('0x99')](_0x119624)>=_0x113ac4['dialGlobalMaxRetry']){_0x5e7048=ut[_0x8895('0x9e')](_0x119624,0xf,_0x8895('0x9f'));rpcDb[_0x8895('0x8f')](_0x5e7048,_0x8895('0xa0'));}else{if(_0x119624['countnosuchnumberretry']>=_0x113ac4[_0x8895('0xa1')]){rpcDb['createCustomerFinal'](_0x119624,'[callProgressDetectingCustomer][logNoSuchGlobal]');}else{rpcDb[_0x8895('0xa2')](ut[_0x8895('0xa3')](_0x119624,_0x8895('0x98'),_0x113ac4['dialNoSuchNumberRetryFrequency']),_0x119624[_0x8895('0xa4')],_0x119624['activeContact']);}}delete this[_0x8895('0x69')][_0x3ee89e[_0x8895('0xa5')]];break;case _0x8895('0xa6'):var _0x42d342=moment()[_0x8895('0x52')]('YYYY-MM-DD\x20HH:mm:ss');_0x119624['responsetime']=_0x42d342;_0x119624[_0x8895('0xa7')]=_0x42d342;_0x119624['dialAnswer']=!![];_0x113ac4[_0x8895('0x28')]+=0x1;logger[_0x8895('0x55')]('[syncHangup][talking][increment]',_0x119624[_0x8895('0xa8')],_0x8895('0xa9'),_0x113ac4[_0x8895('0x4d')],_0x8895('0xaa'),_0x113ac4[_0x8895('0x28')]);ami['emit'](_0x8895('0xab'),ut['buildObj'](_0x119624,'connect',this[_0x8895('0xf')][_0x119624['queue']]));if(_0x113ac4[_0x8895('0xac')]){ami[_0x8895('0x21')](_0x8895('0xad'),ut[_0x8895('0xae')](_0x119624));}break;case'16':ami['emit']('custom:agentcomplete',ut['buildObj'](_0x119624,_0x8895('0xaf'),this[_0x8895('0xf')][_0x119624[_0x8895('0x6a')]]));emitVoiceQueueChannelRemove(ut[_0x8895('0xb0')](_0x119624,_0x8895('0xaf')));_0x113ac4[_0x8895('0x33')]+=0x1;_0x113ac4['total']+=0x1;_0x113ac4[_0x8895('0x25')]+=0x1;ut[_0x8895('0x74')](_0x113ac4,_0x8895('0xb1'));_0x119624['countglobal']=ut[_0x8895('0x99')](_0x119624);ut['logCustomer'](_0x119624,0x4,_0x8895('0xb2'));rpcDb['createCustomerHistory'](_0x119624,_0x8895('0xb3'));rpcDb[_0x8895('0x8f')](_0x119624,'[callProgressDetectingCustomer][logAnswerGlobal]');rpcDb[_0x8895('0xb4')](_0x119624);_0x113ac4[_0x8895('0xb5')]+=_0x119624['talktime'];_0x113ac4[_0x8895('0xb6')]+=_0x119624[_0x8895('0xb7')];logger[_0x8895('0x55')](_0x8895('0xb8'),_0x119624[_0x8895('0xa8')],_0x8895('0xa9'),_0x113ac4[_0x8895('0x4d')],'pTalking:\x20',_0x113ac4[_0x8895('0x28')]);delete this['actions'][_0x3ee89e[_0x8895('0xa5')]];break;case _0x8895('0xb9'):_0x113ac4[_0x8895('0xba')]+=0x1;_0x119624[_0x8895('0xbb')]+=0x1;_0x119624['countglobal']=ut[_0x8895('0x99')](_0x119624);ut[_0x8895('0x8d')](_0x119624,0x5,_0x8895('0xbc'));ami[_0x8895('0x21')](_0x8895('0xbd'),ut[_0x8895('0xb0')](_0x119624,_0x8895('0xbe')));rpcDb[_0x8895('0x8b')](_0x119624,'[callProgressDetectingCustomer][logBusy]');if(ut[_0x8895('0x99')](_0x119624)>=_0x113ac4[_0x8895('0xbf')]){_0x5e7048=ut['cloneAction'](_0x119624,0xf,'Global');rpcDb[_0x8895('0x8f')](_0x5e7048,_0x8895('0xc0'));}else{if(_0x119624[_0x8895('0xbb')]>=_0x113ac4[_0x8895('0xc1')]){rpcDb['createCustomerFinal'](_0x119624,'[callProgressDetectingCustomer][logBusy]');}else{rpcDb[_0x8895('0xa2')](ut[_0x8895('0xa3')](_0x119624,_0x8895('0xbb'),_0x113ac4[_0x8895('0xc2')]),_0x119624[_0x8895('0xa4')],_0x119624['activeContact']);}}break;case _0x8895('0xc3'):_0x113ac4[_0x8895('0x38')]+=0x1;_0x119624['countnoanswerretry']+=0x1;_0x119624[_0x8895('0xc4')]=ut[_0x8895('0x99')](_0x119624);ut[_0x8895('0x8d')](_0x119624,0x3,_0x8895('0xc5'));ami[_0x8895('0x21')](_0x8895('0xc6'),ut['buildObj'](_0x119624,_0x8895('0xc7')));rpcDb[_0x8895('0x8b')](_0x119624,'[callProgressDetectingCustomer][logNoAnswer]');if(ut['totalGlobal'](_0x119624)>=_0x113ac4['dialGlobalMaxRetry']){_0x5e7048=ut[_0x8895('0x9e')](_0x119624,0xf,_0x8895('0x9f'));rpcDb['createCustomerFinal'](_0x5e7048,_0x8895('0xc8'));}else{if(_0x119624['countnoanswerretry']>=_0x113ac4['dialNoAnswerMaxRetry']){rpcDb['createCustomerFinal'](_0x119624,_0x8895('0xc9'));}else{rpcDb[_0x8895('0xa2')](ut[_0x8895('0xa3')](_0x119624,_0x8895('0xca'),_0x113ac4[_0x8895('0xcb')]),_0x119624['unlockAgent'],_0x119624[_0x8895('0xcc')]);}}break;case _0x8895('0xcd'):_0x113ac4[_0x8895('0xce')]+=0x1;_0x119624['countcongestionretry']+=0x1;_0x119624['countglobal']=ut['totalGlobal'](_0x119624);ut[_0x8895('0x8d')](_0x119624,0x8,_0x8895('0xcf'));ami[_0x8895('0x21')](_0x8895('0xd0'),ut[_0x8895('0xb0')](_0x119624,_0x8895('0xd1')));rpcDb[_0x8895('0x8b')](_0x119624,'[callProgressDetectingCustomer][logCongestion]');if(ut[_0x8895('0x99')](_0x119624)>=_0x113ac4['dialGlobalMaxRetry']){_0x5e7048=ut[_0x8895('0x9e')](_0x119624,0xf,'Global');rpcDb[_0x8895('0x8f')](_0x5e7048,_0x8895('0xd2'));}else{if(_0x119624[_0x8895('0xd3')]>=_0x113ac4[_0x8895('0xd4')]){rpcDb[_0x8895('0x8f')](_0x119624,_0x8895('0xd5'));}else{rpcDb[_0x8895('0xa2')](ut['scheduledAt'](_0x119624,_0x8895('0xd3'),_0x113ac4[_0x8895('0xc2')]),_0x119624[_0x8895('0xa4')],_0x119624[_0x8895('0xcc')]);}}break;case _0x8895('0xd6'):_0x113ac4['outboundRejectCallsDay']+=0x1;_0x119624[_0x8895('0xd7')]+=0x1;_0x119624['countglobal']=ut[_0x8895('0x99')](_0x119624);ut[_0x8895('0x8d')](_0x119624,0x14,_0x8895('0xd8'));ami[_0x8895('0x21')](_0x8895('0xd9'),ut[_0x8895('0xb0')](_0x119624,_0x8895('0xda')));rpcDb[_0x8895('0x8b')](_0x119624,_0x8895('0xdb'));if(ut['totalGlobal'](_0x119624)>=_0x113ac4[_0x8895('0xbf')]){_0x5e7048=ut['cloneAction'](_0x119624,0x14,_0x8895('0xd8'));rpcDb[_0x8895('0x8f')](_0x5e7048,_0x8895('0xdc'));}else{if(_0x119624['countagentrejectretry']>=_0x113ac4[_0x8895('0xdd')]){rpcDb['createCustomerFinal'](_0x119624,_0x8895('0xdc'));}else{rpcDb[_0x8895('0xa2')](ut[_0x8895('0xa3')](_0x119624,_0x8895('0xd7'),_0x113ac4['dialAgentRejectRetryFrequency']),_0x119624['unlockAgent'],_0x119624[_0x8895('0xcc')]);}}break;case'ABANDONED':_0x113ac4['outboundAbandonedCallsDay']+=0x1;_0x119624[_0x8895('0xde')]+=0x1;_0x119624['countglobal']=ut[_0x8895('0x99')](_0x119624);ut[_0x8895('0x8d')](_0x119624,0xb,_0x8895('0xdf'));rpcDb[_0x8895('0x8b')](_0x119624,_0x8895('0xe0'));if(ut[_0x8895('0x99')](_0x119624)>=_0x113ac4[_0x8895('0xbf')]){_0x5e7048=ut[_0x8895('0x9e')](_0x119624,0xf,_0x8895('0x9f'));rpcDb['createCustomerFinal'](_0x5e7048,_0x8895('0xe0'));}else{if(_0x119624[_0x8895('0xe1')]>=_0x113ac4[_0x8895('0xe2')]){rpcDb['createCustomerFinal'](_0x119624,_0x8895('0xe0'));}else{rpcDb[_0x8895('0xa2')](ut[_0x8895('0xa3')](_0x119624,'countabandonedretry',_0x113ac4[_0x8895('0xe3')]),_0x119624[_0x8895('0xa4')],_0x119624[_0x8895('0xcc')]);}}break;case'18':_0x113ac4[_0x8895('0x3b')]+=0x1;_0x119624[_0x8895('0xe4')]+=0x1;_0x119624[_0x8895('0xc4')]=ut[_0x8895('0x99')](_0x119624);ut['logCustomer'](_0x119624,0x12,_0x3ee89e[_0x8895('0xe5')]||_0x3ee89e[_0x8895('0xe6')]);ami[_0x8895('0x21')](_0x8895('0xe7'),ut[_0x8895('0xb0')](_0x119624,_0x8895('0xe8')));rpcDb['createCustomerHistory'](_0x119624,_0x8895('0xe9'));if(ut[_0x8895('0x99')](_0x119624)>=_0x113ac4['dialGlobalMaxRetry']){_0x5e7048=ut['cloneAction'](_0x119624,0xf,_0x8895('0x9f'));rpcDb[_0x8895('0x8f')](_0x5e7048,'[callProgressDetectingCustomer][hangupInAMD]');}else{rpcDb[_0x8895('0x8f')](_0x119624,_0x8895('0xe9'));}delete this[_0x8895('0x69')][_0x3ee89e[_0x8895('0xa5')]];break;case'19':_0x113ac4[_0x8895('0x3b')]+=0x1;_0x119624['countglobal']=ut[_0x8895('0x99')](_0x119624);ut[_0x8895('0x8d')](_0x119624,0x13,_0x3ee89e[_0x8895('0xe5')]||_0x3ee89e[_0x8895('0xe6')]);ami[_0x8895('0x21')](_0x8895('0xe7'),ut[_0x8895('0xb0')](_0x119624,_0x8895('0xe8')));rpcDb[_0x8895('0x8b')](_0x119624,_0x8895('0xea'));if(ut[_0x8895('0x99')](_0x119624)>=_0x113ac4[_0x8895('0xbf')]){_0x5e7048=ut['cloneAction'](_0x119624,0xf,_0x8895('0x9f'));rpcDb[_0x8895('0x8f')](_0x5e7048,_0x8895('0xea'));}else{rpcDb[_0x8895('0x8f')](_0x119624,'[callProgressDetectingCustomer][machine]');}delete this[_0x8895('0x69')][_0x3ee89e[_0x8895('0xa5')]];break;default:if(_0x119624['dialAnswer']){ut['decrementTalkink'](_0x113ac4,_0x8895('0xeb'));ut['loggerError'](_0x8895('0xec')+_0x113ac4['name'],_0x3ee89e);}_0x113ac4['outboundUnknownCallsDay']+=0x1;_0x119624[_0x8895('0xc4')]=ut['totalGlobal'](_0x119624);ut[_0x8895('0x8d')](_0x119624,0xc,_0x3ee89e['cause-txt']||_0x3ee89e[_0x8895('0xe6')]);rpcDb[_0x8895('0x8b')](_0x119624,'[callProgressDetectingCustomer][logUnknown]');if(ut[_0x8895('0x99')](_0x119624)>=_0x113ac4[_0x8895('0xbf')]){_0x5e7048=ut[_0x8895('0x9e')](_0x119624,0xf,'Global');rpcDb['createCustomerFinal'](_0x5e7048,_0x8895('0xed'));}else{rpcDb[_0x8895('0x8f')](_0x119624,_0x8895('0xed'));}delete this[_0x8895('0x69')][_0x3ee89e[_0x8895('0xa5')]];}if(!(_0x119624[_0x8895('0x73')]&&_0x6440ea==='16')){ut[_0x8895('0x71')](_0x113ac4,_0x8895('0xee'));logger[_0x8895('0x55')](_0x8895('0xef'),_0x119624[_0x8895('0xa8')],_0x8895('0xa9'),_0x113ac4[_0x8895('0x4d')],_0x8895('0xf0'),_0x113ac4['originated']);}if(_0x6440ea!==_0x8895('0xa6')){delete this[_0x8895('0x69')][_0x3ee89e[_0x8895('0xa5')]];delete this[_0x8895('0x69')][_0x3ee89e['destlinkedid']];}}};Preview[_0x8895('0xb')][_0x8895('0xf1')]=function(_0xf3b3e5,_0x20752d,_0x124e1b){if(_[_0x8895('0xf2')](_0x20752d)&&_0x8895('0xf3')!==typeof _0x20752d){return;}if(_[_0x8895('0xf2')](_0x124e1b)&&_0x8895('0xf3')!==typeof _0x124e1b){return;}switch(_0x124e1b[_0x8895('0xf4')]){case'0':ut[_0x8895('0xf5')](_0xf3b3e5,0x0,_0x8895('0x9a'));rpcDb[_0x8895('0xf6')](_0xf3b3e5,_0x8895('0xf7'));break;case'3':ut[_0x8895('0xf5')](_0xf3b3e5,0x3,_0x8895('0xc5'));rpcDb['createAgentHistory'](_0xf3b3e5,_0x8895('0xf8'));break;case'5':ut['logAgent'](_0xf3b3e5,0x5,_0x8895('0xbc'));rpcDb[_0x8895('0xf6')](_0xf3b3e5,_0x8895('0xf9'));break;case'8':ut['logAgent'](_0xf3b3e5,0x8,_0x8895('0xcf'));rpcDb[_0x8895('0xf6')](_0xf3b3e5,'[callProgressDetectingAgent][logCongestion]');break;case'22':ut[_0x8895('0xf5')](_0xf3b3e5,0x16,'AnswerAGI');rpcDb[_0x8895('0xf6')](_0xf3b3e5,'[callProgressDetectingAgent][logAnswerAGI]');break;default:ut['logAgent'](_0xf3b3e5,0xc,_0x124e1b[_0x8895('0xf4')]);rpcDb[_0x8895('0xf6')](_0xf3b3e5,_0x8895('0xfa'));}ut[_0x8895('0x71')](_0x20752d,_0x8895('0xfb'));logger['info'](_0x8895('0xfc'),_0xf3b3e5['uniqueid'],'\x20Queue',_0x20752d[_0x8895('0x4d')],_0x8895('0xf0'),_0x20752d['originated']);delete this[_0x8895('0x69')][_0xf3b3e5[_0x8895('0xa8')]];};Preview[_0x8895('0xb')]['checkInBlack']=function(_0x3816b4,_0x431b18,_0x114200,_0x54e1b5,_0x465c2b){var _0x34a3c9=this;return new BPromise(function(_0x87bfe4,_0x3a1882){if(_[_0x8895('0x67')](_0x431b18)||_[_0x8895('0x67')](_0x431b18[_0x8895('0xfd')])||_[_0x8895('0x67')](_0x431b18['Contact']['phone'])||_[_0x8895('0x67')](_0x431b18['VoiceQueueId'])){_0x3a1882(ut[_0x8895('0x5a')](_0x8895('0xfe'),_0x54e1b5,_0x465c2b));return;}var _0x270a6e=uuid['v4']();var _0x21d14b=_0x34a3c9[_0x8895('0xf')][_0x431b18[_0x8895('0xff')][_0x8895('0x4d')]];var _0x44951a=_0x114200?_0x34a3c9[_0x8895('0x12')][_0x114200]['id']:undefined;_0x34a3c9[_0x8895('0x69')][_0x270a6e]=new Action(_0x431b18,_0x21d14b,_0x270a6e,_0x114200,_0x44951a);var _0x119bf3=_0x34a3c9[_0x8895('0x69')][_0x270a6e];_0x119bf3['unlockAgent']=_0x54e1b5;_0x119bf3[_0x8895('0xcc')]=_0x465c2b;_0x119bf3[_0x8895('0x100')]=_0x114200;if(_[_0x8895('0x101')](_0x3816b4)){_0x34a3c9[_0x8895('0x102')](_0x119bf3,_0x21d14b,_0x431b18,_0x114200)[_0x8895('0x7c')](function(_0x3c68a9){logger[_0x8895('0x55')](_0x8895('0x103'),_0x8895('0x104')+_0x119bf3[_0x8895('0x6a')]+_0x8895('0x105')+_0x119bf3[_0x8895('0x106')],JSON[_0x8895('0x50')](_0x3c68a9));ami[_0x8895('0x21')]('custom:agentcalled',ut[_0x8895('0xb0')](_0x119bf3,'called',_0x34a3c9['campaignsPreview'][_0x119bf3['queue']]));_0x87bfe4(ut[_0x8895('0x5a')](_0x8895('0x107')));})[_0x8895('0x6f')](function(_0x560732){ut[_0x8895('0x5c')](_0x8895('0x108'),_0x560732);_0x3a1882(ut[_0x8895('0x5a')]('Call\x20failed',_0x54e1b5,_0x465c2b));});}else{_0x21d14b[_0x8895('0x34')]+=0x1;ut[_0x8895('0x109')](_0x119bf3);rpcDb[_0x8895('0x10a')](_0x119bf3,'[Blacklist][error]');delete _0x34a3c9[_0x8895('0x69')][_0x270a6e];_0x3a1882(ut[_0x8895('0x5a')](_0x8895('0x10b'),_0x54e1b5,_0x465c2b));}});};Preview[_0x8895('0xb')][_0x8895('0x93')]=function(_0x3273c1){return!_['isNil'](_0x3273c1)&&!_[_0x8895('0x67')](_0x3273c1[_0x8895('0x4d')])&&!_['isNil'](_0x3273c1[_0x8895('0x4e')])&&_0x3273c1[_0x8895('0x4e')]&&!_[_0x8895('0x67')](this[_0x8895('0x11')][util[_0x8895('0x52')](_0x8895('0x10c'),_0x3273c1[_0x8895('0x4d')])])&&!_[_0x8895('0x67')](this[_0x8895('0x11')][util[_0x8895('0x52')](_0x8895('0x10c'),_0x3273c1['name'])]['status'])&&(this[_0x8895('0x11')][util[_0x8895('0x52')](_0x8895('0x10c'),_0x3273c1[_0x8895('0x4d')])][_0x8895('0x10d')]===_0x8895('0x10e')||this[_0x8895('0x11')][util['format']('SIP/%s',_0x3273c1[_0x8895('0x4d')])][_0x8895('0x10d')]===_0x8895('0x10f'));};Preview[_0x8895('0xb')][_0x8895('0x82')]=function(_0x3b465c,_0x28aeb9){var _0x2ff7e6=this;return new BPromise(function(_0x1be275,_0x8f1f00){_0x2ff7e6['execRun'](_0x3b465c,_0x28aeb9)[_0x8895('0x7c')](function(_0x5033d6){_0x1be275(_[_0x8895('0x6b')](_0x5033d6,[_0x8895('0x5a')]));})[_0x8895('0x6f')](function(_0x5e109c){if(_0x5e109c['unlock']){rpcDb['unlockContact'](_0x3b465c);}if(_0x5e109c[_0x8895('0x4e')]){rpcDb['disableContact'](_0x3b465c);}_0x8f1f00(_[_0x8895('0x6b')](_0x5e109c,[_0x8895('0x5a')]));});});};Preview[_0x8895('0xb')]['execRun']=function(_0x3ccf2a,_0x3a348d){var _0x50136b=this;return new BPromise(function(_0x2bd804,_0x564234){var _0x9ce4f5,_0xa87a01;rpcDb[_0x8895('0x110')](_0x3ccf2a)[_0x8895('0x7c')](function(_0x1d5fd7){if(!_['isNil'](_0x1d5fd7[0x0])){_0xa87a01=_0x1d5fd7[0x0]['recallme']?![]:!![];_0x9ce4f5=_0x1d5fd7[0x0][_0x8895('0x111')]?!![]:![];_0x9ce4f5=_0x3a348d?!![]:_0x9ce4f5;}var _0x41d7f9=_0x50136b[_0x8895('0x112')](_0x1d5fd7);if(_0x41d7f9[_0x8895('0x113')]){rpcDb[_0x8895('0x114')](_[_0x8895('0x6b')](_0x1d5fd7[0x0],['VoiceQueueId','Contact.phone']))[_0x8895('0x7c')](function(_0x3a6226){_0x50136b[_0x8895('0x115')](_0x3a6226,_0x1d5fd7[0x0],_0x3a348d,_0xa87a01,_0x9ce4f5)[_0x8895('0x7c')](function(_0x448496){_0x2bd804(_0x448496);})['catch'](function(_0x50baed){_0x564234(_0x50baed);});})[_0x8895('0x6f')](function(_0x4f0a55){ut['logger'](_0x8895('0x116'),_0x4f0a55);_0x564234(ut[_0x8895('0x5a')]('Call\x20unsuccessful',_0xa87a01,_0x9ce4f5));});}else{_0x564234(ut[_0x8895('0x5a')](_0x41d7f9['message'],_0xa87a01,_0x9ce4f5));}})[_0x8895('0x6f')](function(_0x242a19){ut[_0x8895('0x5c')](_0x8895('0x117'),_0x242a19);_0x564234(ut[_0x8895('0x5a')](_0x8895('0x118'),![],!![]));});});};Preview['prototype'][_0x8895('0x112')]=function(_0x3ecc83){if(_[_0x8895('0x67')](_0x3ecc83)||_[_0x8895('0x101')](_0x3ecc83)||!_[_0x8895('0x67')](_0x3ecc83[0x0][_0x8895('0x80')])&&_['isNil'](_0x3ecc83[0x0][_0x8895('0x80')][_0x8895('0x4d')])){ut[_0x8895('0x5c')](_0x8895('0x119'),_0x3ecc83);return{'isValid':![],'message':_0x8895('0x11a')};}var _0x57230f=this['campaignsPreview'][_0x3ecc83[0x0]['Queue'][_0x8895('0x4d')]];_0x57230f[_0x8895('0x5a')]=_0x8895('0x96');if(_['isNil'](_0x57230f)){ut['logger'](_0x8895('0x11b'),_0x57230f);return{'isValid':![],'message':_0x8895('0x11c')};}if(!this[_0x8895('0x93')](_0x57230f[_0x8895('0x4c')])){ut[_0x8895('0x5c')](_0x8895('0x11d'),'campaign\x20Name:\x20'+_0x57230f['name']+_0x8895('0x11e'));if(!this[_0x8895('0x93')](_0x57230f['TrunkBackup'])){ut[_0x8895('0x5c')]('[Preview][validateContact][Trunk\x20not\x20work]',_0x57230f['name']+_0x8895('0x11f'));return{'isValid':![],'message':_0x8895('0x120')};}}if(!ut[_0x8895('0x121')](_0x57230f['dialActive'])){ut[_0x8895('0x5c')]('[Preview][validateContact][Campaign\x20Active]',_0x57230f[_0x8895('0x4d')]+_0x8895('0x122'));return{'isValid':![],'message':'campaign\x20Name:\x20'+_0x57230f[_0x8895('0x4d')]+'\x20Not\x20Active'};}return{'isValid':!![],'message':_0x8895('0x123')};};Preview[_0x8895('0xb')][_0x8895('0x102')]=function(_0x20f05c,_0x5eca7f,_0x4036ab,_0x4bf06a){var _0x2f2490=this;return new BPromise(function(_0x28506a,_0x30baea){var _0x2ecc8b=_0x20f05c[_0x8895('0xa8')];var _0x1f5eb7=_0x2f2490[_0x8895('0x93')](_0x5eca7f[_0x8895('0x4c')])?util[_0x8895('0x52')](_0x8895('0x124'),_0x5eca7f[_0x8895('0x4c')]['name'],_[_0x8895('0x67')](_0x5eca7f[_0x8895('0x31')])?'':_0x5eca7f[_0x8895('0x31')]['trim']()||'',_0x5eca7f[_0x8895('0x125')]>0x0?_0x4036ab[_0x8895('0xfd')]['phone'][_0x8895('0x126')](_0x5eca7f[_0x8895('0x125')]):_0x4036ab[_0x8895('0xfd')][_0x8895('0x127')]):util[_0x8895('0x52')](_0x8895('0x124'),_[_0x8895('0x67')](_0x5eca7f[_0x8895('0x94')])?_0x5eca7f[_0x8895('0x4c')]['name']:_0x5eca7f['TrunkBackup'][_0x8895('0x4d')],_['isNil'](_0x5eca7f[_0x8895('0x31')])?'':_0x5eca7f[_0x8895('0x31')][_0x8895('0x128')]()||'',_0x5eca7f['dialCutDigit']>0x0?_0x4036ab[_0x8895('0xfd')]['phone'][_0x8895('0x126')](_0x5eca7f[_0x8895('0x125')]):_0x4036ab['Contact'][_0x8895('0x127')]);var _0x30e5a2=_0x2f2490[_0x8895('0x93')](_0x5eca7f[_0x8895('0x4c')])?ut[_0x8895('0x129')](_0x5eca7f['Trunk'][_0x8895('0x12a')],_0x5eca7f[_0x8895('0x2f')],_0x5eca7f['dialRandomLastDigitCallerIdNumber']>0x0?ut['getCallerIdRandom'](_0x5eca7f[_0x8895('0x12b')],_0x5eca7f['dialRandomLastDigitCallerIdNumber']):_0x5eca7f[_0x8895('0x12b')]):ut[_0x8895('0x129')](_[_0x8895('0x67')](_0x5eca7f[_0x8895('0x94')])?_0x5eca7f[_0x8895('0x4c')][_0x8895('0x12a')]:_0x5eca7f['TrunkBackup'][_0x8895('0x12a')],_0x5eca7f[_0x8895('0x2f')],_0x5eca7f[_0x8895('0x12c')]>0x0?ut[_0x8895('0x12d')](_0x5eca7f[_0x8895('0x12b')],_0x5eca7f[_0x8895('0x12c')]):_0x5eca7f[_0x8895('0x12b')]);if(_0x30e5a2){_0x20f05c['originatecalleridname']=ut['extractCalleridName'](_0x30e5a2);_0x20f05c[_0x8895('0x12e')]=ut[_0x8895('0x12f')](_0x30e5a2);}var _0x43523c=ut[_0x8895('0x130')](_0x5eca7f,_0x4036ab,_0x1f5eb7,_0x30e5a2,_0x2ecc8b,_0x20f05c);_['merge'](_0x20f05c,ut['toLowerVariables'](_0x43523c));_0x20f05c[_0x8895('0x86')]=moment()[_0x8895('0x52')](_0x8895('0x87'));ami[_0x8895('0x6d')](ut[_0x8895('0x131')](_0x20f05c,_0x5eca7f,_0x43523c,_0x20f05c[_0x8895('0xcc')],_0x4bf06a))['then'](function(_0x4c4148){_0x5eca7f[_0x8895('0x46')]+=0x1;logger[_0x8895('0x55')](_0x8895('0x132'),_0x2ecc8b,_0x8895('0xa9'),_0x5eca7f[_0x8895('0x4d')],_0x8895('0xf0'),_0x5eca7f[_0x8895('0x46')]);_0x28506a(_0x4c4148);})[_0x8895('0x6f')](function(_0x18a523){ut['logAgent'](_0x20f05c,0xe,_0x8895('0x133'));rpcDb[_0x8895('0xf6')](_0x20f05c,'[originateFailure][logOriginateFailure]');_0x30baea(_0x18a523);});});};Preview[_0x8895('0xb')][_0x8895('0x1a')]=function(_0x3ff7fa){if(this[_0x8895('0x69')][_0x3ff7fa[_0x8895('0xa5')]]){this[_0x8895('0x69')][_0x3ff7fa[_0x8895('0xa5')]][_0x8895('0x6e')]=_0x3ff7fa['channel'];}};Preview['prototype'][_0x8895('0x134')]=function(_0xc93e09){var _0x398041=this;var _0xc35be9=this[_0x8895('0x69')][_0xc93e09[_0x8895('0x135')]];if(_0xc35be9){if(_0xc35be9['lookAgent']&&this[_0x8895('0x12')][_0xc35be9[_0x8895('0x100')]]){ut[_0x8895('0x136')](_0xc35be9,this['agents'][_0xc35be9[_0x8895('0x100')]][_0x8895('0x4d')],this[_0x8895('0x12')][_0xc35be9['lookAgent']]['id']);}var _0x1a62b4=_['clone'](_0xc35be9);_0x1a62b4[_0x8895('0x137')]=moment()[_0x8895('0x52')](_0x8895('0x87'));var _0x447dc0=_0x398041[_0x8895('0xf')][_0xc35be9['queue']];if(ut['isFailure'](_0xc93e09[_0x8895('0x138')])){if(_0xc35be9['unlockAgent']){rpcDb[_0x8895('0x139')](_0xc35be9[_0x8895('0x106')]);}if(_0xc35be9[_0x8895('0xcc')]){rpcDb[_0x8895('0x85')](_0xc35be9[_0x8895('0x106')]);}ami[_0x8895('0x21')](_0x8895('0x13a'),ut[_0x8895('0xb0')](_0xc35be9,'rejected',this[_0x8895('0xf')][_0xc35be9[_0x8895('0x6a')]]));this[_0x8895('0xf1')](_0x1a62b4,_0x447dc0,_0xc93e09);}else{_0xc35be9['starttime']=moment()[_0x8895('0x52')]('YYYY-MM-DD\x20HH:mm:ss');ut[_0x8895('0xf5')](_0x1a62b4,0x4,_0x8895('0xb2'));rpcDb[_0x8895('0xf6')](_0x1a62b4,_0x8895('0x13b'));}}};Preview[_0x8895('0xb')][_0x8895('0x15')]=function(_0x55d290){var _0x1186fa=this;var _0x466d3a=this[_0x8895('0x69')][_0x55d290['linkedid']];var _0x268d3c;if(_0x466d3a){_0x268d3c=this['campaignsPreview'][_0x466d3a[_0x8895('0x6a')]];logger[_0x8895('0x55')](_0x8895('0x13c'),_0x55d290[_0x8895('0xa5')],_0x8895('0xa9'),_0x268d3c[_0x8895('0x4d')],_0x8895('0xaa'),_0x268d3c[_0x8895('0x28')]);}if(this[_0x8895('0x69')][_0x55d290[_0x8895('0xa5')]]&&_0x55d290[_0x8895('0xa5')]!==_0x55d290['uniqueid']){if(_0x55d290['cause']==='16'&&this[_0x8895('0x69')][_0x55d290[_0x8895('0xa5')]][_0x8895('0x73')]){this['callProgressDetectingCustomer'](_0x55d290,_0x55d290[_0x8895('0xa5')],_0x55d290[_0x8895('0x13d')]);}else if(this['actions'][_0x55d290[_0x8895('0xa5')]]['dialAnswer']){logger[_0x8895('0x55')](_0x8895('0x13e'),_0x55d290[_0x8895('0xa5')],_0x55d290[_0x8895('0x13d')],_0x8895('0xa9'),_0x268d3c[_0x8895('0x4d')],'pTalking:\x20',_0x268d3c[_0x8895('0x28')]);this[_0x8895('0x97')](_0x55d290,_0x55d290[_0x8895('0xa5')],_0x55d290[_0x8895('0x13d')]);}}else if(_0x466d3a&&_[_0x8895('0x67')](_0x466d3a[_0x8895('0x13f')])&&_0x268d3c[_0x8895('0x140')]&&_0x55d290[_0x8895('0xa5')]===_0x55d290['uniqueid']&&_[_0x8895('0x67')](_0x55d290[_0x8895('0xf4')])&&_0x55d290[_0x8895('0x13d')]==='16'&&_0x55d290[_0x8895('0x141')]==='6'&&_[_0x8895('0xf2')](_0x466d3a[_0x8895('0x142')])){if(_0x466d3a['unlockAgent']){rpcDb['unlockContact'](_0x466d3a[_0x8895('0x106')]);}if(_0x466d3a[_0x8895('0xcc')]){rpcDb[_0x8895('0x85')](_0x466d3a[_0x8895('0x106')]);}_0x55d290[_0x8895('0xf4')]='22';this[_0x8895('0xf1')](_0x466d3a,_0x268d3c,_0x55d290);}else if(_0x466d3a&&_0x466d3a[_0x8895('0x142')]){if(_0x55d290['cause']==='16'&&this['actions'][_0x55d290[_0x8895('0xa5')]]['dialAnswer']){logger[_0x8895('0x55')](_0x8895('0x143'),_0x55d290[_0x8895('0xa5')],_0x55d290[_0x8895('0x13d')],'\x20Queue',_0x268d3c[_0x8895('0x4d')],_0x8895('0xaa'),_0x268d3c[_0x8895('0x28')]);this[_0x8895('0x97')](_0x55d290,_0x55d290['linkedid'],_0x55d290[_0x8895('0x13d')]);}else if(this[_0x8895('0x69')][_0x55d290['linkedid']][_0x8895('0x73')]){logger[_0x8895('0x55')](_0x8895('0x13e'),_0x55d290[_0x8895('0xa5')],_0x55d290[_0x8895('0x13d')],_0x8895('0xa9'),_0x268d3c[_0x8895('0x4d')],'pTalking:\x20',_0x268d3c[_0x8895('0x28')]);this[_0x8895('0x97')](_0x55d290,_0x55d290['linkedid'],_0x55d290[_0x8895('0x13d')]);}}};Preview[_0x8895('0xb')]['syncDialEnd']=function(_0x4c4240){if(this[_0x8895('0x69')][_0x4c4240[_0x8895('0x144')]]&&_0x4c4240[_0x8895('0x144')]!==_0x4c4240[_0x8895('0x145')]){this[_0x8895('0x97')](_0x4c4240,_0x4c4240[_0x8895('0x144')],_0x4c4240[_0x8895('0xe6')]);}};Preview[_0x8895('0xb')]['syncHangupRequest']=function(_0x28ec87){if(this['actions'][_0x28ec87[_0x8895('0xa5')]]&&_0x28ec87[_0x8895('0xa5')]!==_0x28ec87[_0x8895('0xa8')]&&!this[_0x8895('0x69')][_0x28ec87[_0x8895('0xa5')]]['dialAnswer']){if(_0x28ec87[_0x8895('0x13d')]==='1'){this[_0x8895('0x97')](_0x28ec87,_0x28ec87[_0x8895('0xa5')],_0x28ec87[_0x8895('0x13d')]);}}};Preview[_0x8895('0xb')]['addVariable']=function(_0x419702,_0x3a7d70,_0x4b937f){if(this['actions'][_0x419702]){if(_[_0x8895('0x67')](this[_0x8895('0x69')][_0x419702][_0x8895('0x146')])){this[_0x8895('0x69')][_0x419702][_0x8895('0x146')]={};}this[_0x8895('0x69')][_0x419702][_0x8895('0x146')][_0x3a7d70]=_0x4b937f;}};Preview['prototype'][_0x8895('0x1c')]=function(_0x49928b){try{if(!_[_0x8895('0x67')](_0x49928b)){if(ut[_0x8895('0x147')](_['keys'](_0x49928b['variable'])[0x0])){this[_0x8895('0x148')](_0x49928b[_0x8895('0xa8')],_[_0x8895('0x149')](_0x49928b['variable'])[0x0],_0x49928b[_0x8895('0x14a')]);}}}catch(_0x47837c){logger['error'](_0x8895('0x14b'),util[_0x8895('0x14c')](_0x47837c,{'showHidden':![],'depth':null}));}};Preview[_0x8895('0xb')][_0x8895('0x1e')]=function(_0x592e3b){if(_0x592e3b){if(this[_0x8895('0x69')][_0x592e3b['transfertargetlinkedid']]){this[_0x8895('0x69')][_0x592e3b['transfertargetlinkedid']][_0x8895('0x142')]=!![];}}};Preview['prototype']['syncBlindTransfer']=function(_0xe5a83a){if(_0xe5a83a){if(this[_0x8895('0x69')][_0xe5a83a[_0x8895('0x14d')]]){this[_0x8895('0x69')][_0xe5a83a[_0x8895('0x14d')]][_0x8895('0x142')]=!![];}}};module[_0x8895('0x14e')]=Preview;