0f2a2a902057b7fa280d91b3243529582af790d9
[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 _0x0033=['connect','acw','buildAcw','custom:agentcomplete','complete','[16]','Answer','[callProgressDetectingCustomer][logAnswerGlobal]','crateCustomerReportQueue','talktime','[syncHangup][talking][decrement]','outboundBusyCallsDay','Busy','custom:agentbusy','[callProgressDetectingCustomer][logBusy]','[callProgressDetectingCustomer][logBusyGlobal]','countbusyretry','dialBusyMaxRetry','scheduledAt','NOANSWER','NoAnswer','custom:agentnoanswer','[callProgressDetectingCustomer][logNoAnswer]','[callProgressDetectingCustomer][logNoAnswerGlobal]','countnoanswerretry','dialNoAnswerMaxRetry','CONGESTION','countcongestionretry','Congestion','custom:agentcongestion','congestion','[callProgressDetectingCustomer][logCongestionGlobal]','dialCongestionMaxRetry','[callProgressDetectingCustomer][logCongestion]','CANCEL','outboundRejectCallsDay','countagentrejectretry','AgentReject','custom:agentreject','agentreject','[callProgressDetectingCustomer][logAgentReject]','dialAgentRejectMaxRetry','dialAgentRejectRetryFrequency','countabandonedretry','Abandoned','[callProgressDetectingCustomer][logAbandoned]','countabandonedetry','dialAbandonedMaxRety','dialAbandonedRetryFrequency','[Dialer][decrementTalkink][no\x20Hangup][Preview]','cause-txt','dialstatus','[callProgressDetectingCustomer][logUnknown]','updateOriginated','[originated][decrement][callProgressDetectingCustomer]','destlinkedid','callProgressDetectingAgent','isUndefined','object','reason','logAgent','createAgentHistory','[callProgressDetectingAgent][logNoAnswer]','[callProgressDetectingAgent][logBusy]','[callProgressDetectingAgent][logCongestion]','AnswerAGI','[callProgressDetectingAgent][logAnswerAGI]','[callProgressDetectingAgent]','[originated][decrement][callProgressDetectingAgent]','Contact','phone','Contact\x20is\x20undefined','lookAgent','isEmpty','execCall','[Preview][execCall][success]','\x20IdHopper:\x20','custom:agentcalled','called','Calling','[Preview][execCall][failure]','[Blacklist][error]','active','SIP/%s','reachable','unmonitored','execRun','unlock','getContactPreview','recallme','isValid','checkInBlack','[Preview][checkIsBlackList]','Call\x20unsuccessful','[Preview][getContactPreview]','[Preview][validateContact][Empty\x20Contact]','Empty\x20Contact','[Preview][validateContact][Empty\x20Campaign]','[Preview][validateContact][Trunk\x20not\x20work]','campaign\x20Name:\x20','\x20Trunk\x20is\x20not\x20active','\x20Trunk\x20Backup\x20is\x20not\x20active','Trunk\x20not\x20work','\x20Not\x20Active','Is\x20Valid','SIP/%s/%s%s','trim','dialCutDigit','dialRandomLastDigitCallerIdNumber','dialOriginateCallerIdName','getCallerIdRandom','originatecalleridname','extractCalleridName','originatecalleridnum','extractCalleridNumber','addVariables','merge','toLowerVariables','variablesAction','OriginateError','[originateFailure][logOriginateFailure]','actionid','logLookAgent','isFailure','response','unlockContact','idContact','custom:agentringnoanswer','[syncHangup][talking]','callProgressDetectingCustomer','cause','[syncHangup][talking][cause]','statedesc','channelstate','transfer','[syncHangup][talking][transfer]','destuniqueid','addVariable','variables','filterKey','keys','variable','value','error','[syncVarSet][Preview]','inspect','transfertargetlinkedid','transfererlinkedid','exports','util','lodash','bluebird','uuid','moment','md5','ioredis','../../../config/logger','actionPreview','../ami','./rpcDb','./util/util','defaults','localhost','socket.io-emitter','redis','prototype','enqueue','tail','finally','sequence','campaignsPreview','voiceQueues','trunks','actions','agents','clockClearZombieChannels','originateresponse','syncOriginateResponse','bind','hangup','syncHangup','hanguprequest','syncHangupRequest','dialend','syncDialEnd','newexten','syncNewExten','varset','syncVarSet','syncAttendedTransfer','syncBlindTransfer','loopCampaigns','emit','name','answered','available','loggedIn','pTalking','sumBillable','sumDuration','sumHoldTime','total','unmanaged','loggedInDb','dialOriginateCallerIdNumber','dialOriginateTimeout','dialPrefix','outboundAnswerAgiCallsDay','outboundAnswerCallsDay','outboundBlacklistCallsDay','outboundCongestionCallsDay','outboundDropCallsDayTimeout','outboundNoAnswerCallsDay','outboundNoSuchCallsDay','outboundOriginateFailureCallsDay','outboundReCallsDay','outboundUnknownCallsDay','outboundAbandonedCallsDay','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalDroppedCallsTimeout','predictiveIntervalErlangCalls','predictiveIntervalErlangCallsDroppedCalls','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalAvailable','predictiveIntervalTotalCalls','originated','erlangCalls','erlangAbandonmentRate','erlangBusyFactor','startPredictive','startProgressive','Trunk','callerid','Interval','format','voice:queue:%s','[DEBUG]\x20Emit\x20voice_queue_channel:remove\x20event','stringify','voice_queue_channel:remove','sendMessageOneNotActive','message','NOT_ACTIVE','logger','[CampaignPreview]\x20Campaign\x20Queue:\x20','\x20is\x20not\x20active','IS_DISACTIVED','\x20is\x20disactive','syncCampaigns','hasOwnProperty','preview','dialMethod','booked','type','outbound','clearZombieChannels','dialActive','setMessage','recallMe','isNil','info','[clearZombieChannels][talking]','Queue','originated:\x20','queue','dialAnswer','pick','UserId','VoiceQueueId','ListId','Action','status','channel','catch','No\x20such\x20channel','[clearZombieChannel]','loggerError','[Dialer][checkChannel][Preview]','size','agentReadyId','then','length','getDiff','scheduledat','Agent','voicePause','run','logger2','[RecallMe]','disableContact','starttime','logCustomer','RecallInQueue','rescheduleContactInQueue','createBody','createCustomerHistory','[HistoryDialRecallInQueue][historyCatch]','RecallFailedTimeout','[HistoryRecallClose]','createCustomerFinal','[getContactRecallMe]','isActive','isTrunkReachable','TrunkBackup','TRUNK_IS_NOT_REACHABLE','ACTIVE','countnosuchnumberretry','countglobal','NoSuchNumber','custom:agentnosuchnumber','buildObj','nosuchnumber','[callProgressDetectingCustomer][logNoSuch]','totalGlobal','dialGlobalMaxRetry','cloneAction','Global','[callProgressDetectingCustomer][logNoSuchGlobal]','dialNoSuchNumberMaxRetry','rescheduleContact','unlockAgent','activeContact','linkedid','ANSWER','YYYY-MM-DD\x20HH:mm:ss','responsetime','answertime','[syncHangup][talking][increment]','uniqueid','\x20Queue','pTalking:\x20'];(function(_0x156c3b,_0x1c2e76){var _0x39750c=function(_0x368b35){while(--_0x368b35){_0x156c3b['push'](_0x156c3b['shift']());}};_0x39750c(++_0x1c2e76);}(_0x0033,0x95));var _0x3003=function(_0x37fcda,_0x2f5aa1){_0x37fcda=_0x37fcda-0x0;var _0xf5ed91=_0x0033[_0x37fcda];return _0xf5ed91;};'use strict';var util=require(_0x3003('0x0'));var _=require(_0x3003('0x1'));var BPromise=require(_0x3003('0x2'));var uuid=require(_0x3003('0x3'));var moment=require(_0x3003('0x4'));var md5=require(_0x3003('0x5'));var Redis=require(_0x3003('0x6'));var config=require('../../../config/environment');var logger=require(_0x3003('0x7'))('preview');var loggerAction=require('../../../config/logger')(_0x3003('0x8'));var ami=require(_0x3003('0x9'));var rpcDb=require(_0x3003('0xa'));var Action=require('./action');var ut=require(_0x3003('0xb'));config['redis']=_[_0x3003('0xc')](config['redis'],{'host':_0x3003('0xd'),'port':0x18eb});var io=require(_0x3003('0xe'))(new Redis(config[_0x3003('0xf')]));var Sequence=function(){};Sequence[_0x3003('0x10')][_0x3003('0x11')]=function(_0x1abce5){this[_0x3003('0x12')]=this[_0x3003('0x12')]?this[_0x3003('0x12')][_0x3003('0x13')](_0x1abce5):_0x1abce5();};function Preview(_0x1d47c7){this[_0x3003('0x14')]=new Sequence();this[_0x3003('0x15')]=_0x1d47c7[_0x3003('0x16')];this['trunks']=_0x1d47c7[_0x3003('0x17')];this[_0x3003('0x18')]={};this[_0x3003('0x19')]=_0x1d47c7['agents'];this[_0x3003('0x1a')]=0x0;ami['on'](_0x3003('0x1b'),this[_0x3003('0x1c')][_0x3003('0x1d')](this));ami['on'](_0x3003('0x1e'),this[_0x3003('0x1f')][_0x3003('0x1d')](this));ami['on'](_0x3003('0x20'),this[_0x3003('0x21')][_0x3003('0x1d')](this));ami['on'](_0x3003('0x22'),this[_0x3003('0x23')]['bind'](this));ami['on'](_0x3003('0x24'),this[_0x3003('0x25')]['bind'](this));ami['on'](_0x3003('0x26'),this[_0x3003('0x27')]['bind'](this));ami['on']('attendedtransfer',this[_0x3003('0x28')]['bind'](this));ami['on']('blindtransfer',this[_0x3003('0x29')][_0x3003('0x1d')](this));this[_0x3003('0x2a')](this[_0x3003('0x15')]);}function emit(_0x22292f,_0x2da13d,_0xa79f96){io['to'](_0x22292f)[_0x3003('0x2b')](_0x2da13d,_0xa79f96);}function emitCampaignPreview(_0xed8dbe){if(_0xed8dbe['type']==='outbound'){var _0xaf4c97={'id':_0xed8dbe['id'],'name':_0xed8dbe[_0x3003('0x2c')],'strategy':_0xed8dbe['strategy'],'answered':_0xed8dbe[_0x3003('0x2d')],'available':_0xed8dbe[_0x3003('0x2e')],'loggedIn':_0xed8dbe[_0x3003('0x2f')],'pTalking':_0xed8dbe[_0x3003('0x30')],'sumBillable':_0xed8dbe[_0x3003('0x31')],'sumDuration':_0xed8dbe[_0x3003('0x32')],'sumHoldTime':_0xed8dbe[_0x3003('0x33')]||0x0,'talking':_0xed8dbe['talking'],'total':_0xed8dbe[_0x3003('0x34')],'type':_0xed8dbe['type'],'unmanaged':_0xed8dbe[_0x3003('0x35')],'abandoned':_0xed8dbe['abandoned'],'waiting':_0xed8dbe['waiting'],'loggedInDb':_0xed8dbe[_0x3003('0x36')],'dialActive':_0xed8dbe['dialActive'],'dialMethod':_0xed8dbe['dialMethod'],'dialOriginateCallerIdName':_0xed8dbe['dialOriginateCallerIdName'],'dialOriginateCallerIdNumber':_0xed8dbe[_0x3003('0x37')],'dialOriginateTimeout':_0xed8dbe[_0x3003('0x38')],'dialPrefix':_0xed8dbe[_0x3003('0x39')],'outboundAnswerAgiCallsDay':_0xed8dbe[_0x3003('0x3a')],'outboundAnswerCallsDay':_0xed8dbe[_0x3003('0x3b')],'outboundBlacklistCallsDay':_0xed8dbe[_0x3003('0x3c')],'outboundBusyCallsDay':_0xed8dbe['outboundBusyCallsDay'],'outboundCongestionCallsDay':_0xed8dbe[_0x3003('0x3d')],'outboundDropCallsDayACS':_0xed8dbe['outboundDropCallsDayACS'],'outboundDropCallsDayCallersExit':_0xed8dbe['outboundDropCallsDayCallersExit'],'outboundDropCallsDayTimeout':_0xed8dbe[_0x3003('0x3e')],'outboundNoAnswerCallsDay':_0xed8dbe[_0x3003('0x3f')],'outboundNoSuchCallsDay':_0xed8dbe[_0x3003('0x40')],'outboundOriginateFailureCallsDay':_0xed8dbe[_0x3003('0x41')],'outboundReCallsDay':_0xed8dbe[_0x3003('0x42')],'outboundRejectCallsDay':_0xed8dbe['outboundRejectCallsDay'],'outboundUnknownCallsDay':_0xed8dbe[_0x3003('0x43')],'outboundAbandonedCallsDay':_0xed8dbe[_0x3003('0x44')],'predictiveIntervalAnsweredCalls':_0xed8dbe['predictiveIntervalAnsweredCalls'],'predictiveIntervalAvgHoldtime':_0xed8dbe[_0x3003('0x45')],'predictiveIntervalAvgTalktime':_0xed8dbe[_0x3003('0x46')],'predictiveIntervalDroppedCallsCallersExit':_0xed8dbe[_0x3003('0x47')],'predictiveIntervalDroppedCallsTimeout':_0xed8dbe[_0x3003('0x48')],'predictiveIntervalErlangCalls':_0xed8dbe[_0x3003('0x49')],'predictiveIntervalErlangCallsDroppedCalls':_0xed8dbe[_0x3003('0x4a')],'predictiveIntervalHitRate':_0xed8dbe['predictiveIntervalHitRate'],'predictiveIntervalMultiplicativeFactor':_0xed8dbe[_0x3003('0x4b')],'predictiveIntervalPauses':_0xed8dbe[_0x3003('0x4c')],'predictiveIntervalAvailable':_0xed8dbe[_0x3003('0x4d')],'predictiveIntervalTotalCalls':_0xed8dbe[_0x3003('0x4e')],'message':_0xed8dbe['message'],'originated':_0xed8dbe[_0x3003('0x4f')],'erlangCalls':_0xed8dbe[_0x3003('0x50')],'erlangCallToSecond':_0xed8dbe['erlangCallToSecond'],'erlangAbandonmentRate':_0xed8dbe[_0x3003('0x51')],'erlangBusyFactor':_0xed8dbe[_0x3003('0x52')],'startPredictive':_0xed8dbe[_0x3003('0x53')],'startProgressive':_0xed8dbe[_0x3003('0x54')]};if(_0xed8dbe[_0x3003('0x55')]){_0xaf4c97[_0x3003('0x55')]={'id':_0xed8dbe[_0x3003('0x55')]['id'],'name':_0xed8dbe['Trunk'][_0x3003('0x2c')],'active':_0xed8dbe['Trunk']['active'],'callerid':_0xed8dbe[_0x3003('0x55')][_0x3003('0x56')]};}if(_0xed8dbe[_0x3003('0x57')]){_0xaf4c97[_0x3003('0x57')]={'id':_0xed8dbe[_0x3003('0x57')]['id'],'name':_0xed8dbe[_0x3003('0x57')][_0x3003('0x2c')]};}var _0x1d6ce2=md5(JSON['stringify'](_0xaf4c97));if(_0xed8dbe[_0x3003('0x5')]!==_0x1d6ce2){_0xed8dbe[_0x3003('0x5')]=_0x1d6ce2;emit(util[_0x3003('0x58')](_0x3003('0x59'),_0xaf4c97[_0x3003('0x2c')]),'voice_queue:save',_0xaf4c97);}}}function emitVoiceQueueChannelRemove(_0x5e6887){logger['info'](_0x3003('0x5a'),JSON[_0x3003('0x5b')](_0x5e6887));emit(util[_0x3003('0x58')](_0x3003('0x59'),_0x5e6887[_0x3003('0x2c')]),_0x3003('0x5c'),_0x5e6887);}function notSendMessagesQueue(_0x6c6e24){if(_0x6c6e24[_0x3003('0x5d')]){if(_0x6c6e24[_0x3003('0x4f')]===0x0&&_0x6c6e24[_0x3003('0x30')]===0x0){_0x6c6e24[_0x3003('0x5d')]=![];_0x6c6e24[_0x3003('0x2e')]=0x0;_0x6c6e24['paused']=0x0;_0x6c6e24[_0x3003('0x5e')]=_0x3003('0x5f');ut[_0x3003('0x60')](_0x3003('0x61'),_0x6c6e24[_0x3003('0x2c')]+_0x3003('0x62'));}else{_0x6c6e24[_0x3003('0x5e')]=_0x3003('0x63');ut['logger'](_0x3003('0x61'),_0x6c6e24[_0x3003('0x2c')]+_0x3003('0x64'));}emitCampaignPreview(_0x6c6e24);}}Preview[_0x3003('0x10')][_0x3003('0x2a')]=function(){var _0x47743f=this;setInterval(function(){_0x47743f['syncCampaigns']();},0x7cf);};Preview[_0x3003('0x10')][_0x3003('0x65')]=function(){var _0x17a821=this[_0x3003('0x15')];this[_0x3003('0x1a')]+=0x1;for(var _0x19482d in _0x17a821){if(_0x17a821[_0x3003('0x66')](_0x19482d)&&(_0x17a821[_0x19482d]['dialMethod']===_0x3003('0x67')||_0x17a821[_0x19482d][_0x3003('0x68')]===_0x3003('0x69'))&&_0x17a821[_0x19482d][_0x3003('0x6a')]===_0x3003('0x6b')){if(this[_0x3003('0x1a')]>0x7){this[_0x3003('0x1a')]=0x0;this[_0x3003('0x6c')]();}}if(_0x17a821['hasOwnProperty'](_0x19482d)&&_0x17a821[_0x19482d]['dialMethod']===_0x3003('0x67')&&_0x17a821[_0x19482d][_0x3003('0x6a')]===_0x3003('0x6b')){if(_0x17a821[_0x19482d][_0x3003('0x6d')]){this[_0x3003('0x6e')](_0x17a821[_0x19482d]);this[_0x3003('0x6f')](_0x17a821[_0x19482d]);}else{notSendMessagesQueue(_0x17a821[_0x19482d]);}}}};Preview[_0x3003('0x10')]['clearZombieChannel']=function(_0x5db645){var _0x2f6f5d=this;this[_0x3003('0x14')][_0x3003('0x11')](function(){if(!_[_0x3003('0x70')](_0x2f6f5d[_0x3003('0x18')][_0x5db645])){loggerAction[_0x3003('0x71')](_0x3003('0x72'),_0x5db645,_0x3003('0x73'),_0x2f6f5d['actions'][_0x5db645]['queue'],_0x3003('0x74'),JSON[_0x3003('0x5b')](_0x2f6f5d[_0x3003('0x15')][_0x2f6f5d[_0x3003('0x18')][_0x5db645][_0x3003('0x75')]]['originated']),'pTalking:\x20',JSON[_0x3003('0x5b')](_0x2f6f5d[_0x3003('0x15')][_0x2f6f5d[_0x3003('0x18')][_0x5db645][_0x3003('0x75')]][_0x3003('0x30')]),JSON[_0x3003('0x5b')](_0x2f6f5d[_0x3003('0x18')][_0x5db645][_0x3003('0x76')]),JSON[_0x3003('0x5b')](_[_0x3003('0x77')](_0x2f6f5d['actions'][_0x5db645],['contactId',_0x3003('0x78'),_0x3003('0x79'),_0x3003('0x7a')])));return ami[_0x3003('0x7b')]({'action':_0x3003('0x7c'),'channel':_0x2f6f5d[_0x3003('0x18')][_0x5db645][_0x3003('0x7d')]})[_0x3003('0x7e')](function(_0x427740){if(_0x427740[_0x3003('0x5e')]===_0x3003('0x7f')){setTimeout(function(){if(_0x2f6f5d[_0x3003('0x18')][_0x5db645]){ut['updateOriginated'](_0x2f6f5d[_0x3003('0x15')][_0x2f6f5d[_0x3003('0x18')][_0x5db645]['queue']],_0x3003('0x80'));if(_0x2f6f5d['actions'][_0x5db645][_0x3003('0x76')]===!![]){ut['decrementTalkink'](_0x2f6f5d['campaignsPreview'][_0x2f6f5d[_0x3003('0x18')][_0x5db645]['queue']],'[clearZombieChannel]');ut[_0x3003('0x81')]('[Dialer][checkChannel][pTalking][Preview]'+_0x5db645,_0x2f6f5d[_0x3003('0x18')][_0x5db645][_0x3003('0x75')]);}ut[_0x3003('0x81')](_0x3003('0x82')+_0x5db645,_0x2f6f5d[_0x3003('0x18')][_0x5db645]['queue']);delete _0x2f6f5d[_0x3003('0x18')][_0x5db645];}},0x2328);}});}});};Preview[_0x3003('0x10')]['clearZombieChannels']=function(){var _0x24b6c8=this;loggerAction[_0x3003('0x71')]('[action]',_[_0x3003('0x83')](this[_0x3003('0x18')]));for(var _0x35e804 in this[_0x3003('0x18')]){if(_0x24b6c8[_0x3003('0x18')]['hasOwnProperty'](_0x35e804)){_0x24b6c8['clearZombieChannel'](_0x35e804);}}};Preview['prototype'][_0x3003('0x6f')]=function(_0x3f15bd){var _0x4ab8d4=this;rpcDb['getContactRecallMe'](_0x3f15bd['id'],ut[_0x3003('0x84')](this[_0x3003('0x19')]))[_0x3003('0x85')](function(_0x11fc98){if(!_[_0x3003('0x70')](_0x11fc98)){for(var _0x5abcf7=0x0;_0x5abcf7<_0x11fc98[_0x3003('0x86')];_0x5abcf7+=0x1){if(ut[_0x3003('0x87')](_0x11fc98[_0x5abcf7][_0x3003('0x88')])<_0x3f15bd['dialRecallMeTimeout']*0x3c){if(_0x11fc98[_0x5abcf7][_0x3003('0x89')]&&!_0x11fc98[_0x5abcf7][_0x3003('0x89')][_0x3003('0x8a')]){_0x4ab8d4[_0x3003('0x8b')](_0x11fc98[_0x5abcf7]['id'])['then'](ut[_0x3003('0x8c')](_0x3003('0x8d')))['catch'](ut['logger2'](_0x3003('0x8d')));}else{rpcDb[_0x3003('0x8e')](_0x11fc98[_0x5abcf7]['id']);}}else{var _0x4c90e2=new Action(_0x11fc98[_0x5abcf7],_0x3f15bd);_0x4c90e2[_0x3003('0x8f')]=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');_0x3f15bd[_0x3003('0x42')]+=0x1;ut[_0x3003('0x90')](_0x4c90e2,0x17,_0x3003('0x91'));if(_0x3f15bd['dialRecallInQueue']){rpcDb[_0x3003('0x92')](ut[_0x3003('0x93')](_0x11fc98[_0x5abcf7]));rpcDb[_0x3003('0x94')](_0x4c90e2,_0x3003('0x95'));}else{ut['logCustomer'](_0x4c90e2,0x16,_0x3003('0x96'));rpcDb[_0x3003('0x94')](_0x4c90e2,_0x3003('0x97'));rpcDb[_0x3003('0x98')](_0x4c90e2,_0x3003('0x97'));}}}}})[_0x3003('0x7e')](ut[_0x3003('0x8c')](_0x3003('0x99')));};Preview[_0x3003('0x10')][_0x3003('0x6e')]=function(_0x91f1e7){_0x91f1e7['sendMessageOneNotActive']=!![];if(ut['IsNotLoggedIn'](_0x91f1e7[_0x3003('0x2f')])){_0x91f1e7[_0x3003('0x5e')]='AGENTS_NOT_LOGGED';}else if(!ut[_0x3003('0x9a')](_0x91f1e7[_0x3003('0x6d')])){_0x91f1e7['message']='NOT_ACTIVE';}else if(!this[_0x3003('0x9b')](_0x91f1e7[_0x3003('0x55')])){if(!this['isTrunkReachable'](_0x91f1e7[_0x3003('0x9c')])){_0x91f1e7[_0x3003('0x5e')]=_0x3003('0x9d');}else{_0x91f1e7[_0x3003('0x5e')]=_0x3003('0x9e');}}else{_0x91f1e7[_0x3003('0x5e')]=_0x3003('0x9e');}emitCampaignPreview(_0x91f1e7);};Preview[_0x3003('0x10')]['callProgressDetectingCustomer']=function(_0x229d61,_0x4d18db,_0x17f8ff){var _0x5dfaef=this;var _0x5121fd=this['actions'][_0x4d18db];var _0xec2b83=this[_0x3003('0x15')][_0x5121fd[_0x3003('0x75')]];var _0xe3434f;if(_0xec2b83){switch(_0x17f8ff){case'1':_0xec2b83['outboundNoSuchCallsDay']+=0x1;_0x5121fd[_0x3003('0x9f')]+=0x1;_0x5121fd[_0x3003('0xa0')]=ut['totalGlobal'](_0x5121fd);ut[_0x3003('0x90')](_0x5121fd,0x0,_0x3003('0xa1'));ami[_0x3003('0x2b')](_0x3003('0xa2'),ut[_0x3003('0xa3')](_0x5121fd,_0x3003('0xa4')));rpcDb[_0x3003('0x94')](_0x5121fd,_0x3003('0xa5'));if(ut[_0x3003('0xa6')](_0x5121fd)>=_0xec2b83[_0x3003('0xa7')]){_0xe3434f=ut[_0x3003('0xa8')](_0x5121fd,0xf,_0x3003('0xa9'));rpcDb['createCustomerFinal'](_0xe3434f,_0x3003('0xaa'));}else{if(_0x5121fd[_0x3003('0x9f')]>=_0xec2b83[_0x3003('0xab')]){rpcDb[_0x3003('0x98')](_0x5121fd,_0x3003('0xaa'));}else{rpcDb[_0x3003('0xac')](ut['scheduledAt'](_0x5121fd,'countnosuchnumberretry',_0xec2b83['dialNoSuchNumberRetryFrequency']),_0x5121fd[_0x3003('0xad')],_0x5121fd[_0x3003('0xae')]);}}delete this[_0x3003('0x18')][_0x229d61[_0x3003('0xaf')]];break;case _0x3003('0xb0'):var _0x106fbd=moment()[_0x3003('0x58')](_0x3003('0xb1'));_0x5121fd[_0x3003('0xb2')]=_0x106fbd;_0x5121fd[_0x3003('0xb3')]=_0x106fbd;_0x5121fd['dialAnswer']=!![];_0xec2b83['pTalking']+=0x1;logger[_0x3003('0x71')](_0x3003('0xb4'),_0x5121fd[_0x3003('0xb5')],_0x3003('0xb6'),_0xec2b83['name'],_0x3003('0xb7'),_0xec2b83[_0x3003('0x30')]);ami[_0x3003('0x2b')]('custom:agentconnect',ut['buildObj'](_0x5121fd,_0x3003('0xb8')));if(_0xec2b83[_0x3003('0xb9')]){ami[_0x3003('0x2b')]('custom:agentConnectPreview',ut[_0x3003('0xba')](_0x5121fd));}break;case'16':ami[_0x3003('0x2b')](_0x3003('0xbb'),ut[_0x3003('0xa3')](_0x5121fd,_0x3003('0xbc')));emitVoiceQueueChannelRemove(ut[_0x3003('0xa3')](_0x5121fd,_0x3003('0xbc')));_0xec2b83['outboundAnswerCallsDay']+=0x1;_0xec2b83['total']+=0x1;_0xec2b83['answered']+=0x1;ut['decrementTalkink'](_0xec2b83,_0x3003('0xbd'));_0x5121fd[_0x3003('0xa0')]=ut[_0x3003('0xa6')](_0x5121fd);ut['logCustomer'](_0x5121fd,0x4,_0x3003('0xbe'));rpcDb[_0x3003('0x94')](_0x5121fd,'[callProgressDetectingCustomer][logAnswer]');rpcDb[_0x3003('0x98')](_0x5121fd,_0x3003('0xbf'));rpcDb[_0x3003('0xc0')](_0x5121fd);_0xec2b83[_0x3003('0x32')]+=_0x5121fd[_0x3003('0xc1')];_0xec2b83[_0x3003('0x31')]+=_0x5121fd[_0x3003('0xc1')];logger[_0x3003('0x71')](_0x3003('0xc2'),_0x5121fd['uniqueid'],_0x3003('0xb6'),_0xec2b83[_0x3003('0x2c')],_0x3003('0xb7'),_0xec2b83[_0x3003('0x30')]);delete this[_0x3003('0x18')][_0x229d61['linkedid']];break;case'BUSY':_0xec2b83[_0x3003('0xc3')]+=0x1;_0x5121fd['countbusyretry']+=0x1;_0x5121fd[_0x3003('0xa0')]=ut[_0x3003('0xa6')](_0x5121fd);ut['logCustomer'](_0x5121fd,0x5,_0x3003('0xc4'));ami[_0x3003('0x2b')](_0x3003('0xc5'),ut[_0x3003('0xa3')](_0x5121fd,'busy'));rpcDb[_0x3003('0x94')](_0x5121fd,_0x3003('0xc6'));if(ut[_0x3003('0xa6')](_0x5121fd)>=_0xec2b83[_0x3003('0xa7')]){_0xe3434f=ut['cloneAction'](_0x5121fd,0xf,_0x3003('0xa9'));rpcDb[_0x3003('0x98')](_0xe3434f,_0x3003('0xc7'));}else{if(_0x5121fd[_0x3003('0xc8')]>=_0xec2b83[_0x3003('0xc9')]){rpcDb[_0x3003('0x98')](_0x5121fd,_0x3003('0xc6'));}else{rpcDb['rescheduleContact'](ut[_0x3003('0xca')](_0x5121fd,_0x3003('0xc8'),_0xec2b83['dialBusyRetryFrequency']),_0x5121fd[_0x3003('0xad')],_0x5121fd[_0x3003('0xae')]);}}break;case _0x3003('0xcb'):_0xec2b83[_0x3003('0x3f')]+=0x1;_0x5121fd['countnoanswerretry']+=0x1;_0x5121fd['countglobal']=ut[_0x3003('0xa6')](_0x5121fd);ut[_0x3003('0x90')](_0x5121fd,0x3,_0x3003('0xcc'));ami['emit'](_0x3003('0xcd'),ut[_0x3003('0xa3')](_0x5121fd,'noanswer'));rpcDb[_0x3003('0x94')](_0x5121fd,_0x3003('0xce'));if(ut[_0x3003('0xa6')](_0x5121fd)>=_0xec2b83[_0x3003('0xa7')]){_0xe3434f=ut[_0x3003('0xa8')](_0x5121fd,0xf,_0x3003('0xa9'));rpcDb['createCustomerFinal'](_0xe3434f,_0x3003('0xcf'));}else{if(_0x5121fd[_0x3003('0xd0')]>=_0xec2b83[_0x3003('0xd1')]){rpcDb[_0x3003('0x98')](_0x5121fd,_0x3003('0xce'));}else{rpcDb[_0x3003('0xac')](ut[_0x3003('0xca')](_0x5121fd,'countnoanswerretry',_0xec2b83['dialNoAnswerRetryFrequency']),_0x5121fd[_0x3003('0xad')],_0x5121fd[_0x3003('0xae')]);}}break;case _0x3003('0xd2'):_0xec2b83[_0x3003('0x3d')]+=0x1;_0x5121fd[_0x3003('0xd3')]+=0x1;_0x5121fd['countglobal']=ut['totalGlobal'](_0x5121fd);ut[_0x3003('0x90')](_0x5121fd,0x8,_0x3003('0xd4'));ami[_0x3003('0x2b')](_0x3003('0xd5'),ut[_0x3003('0xa3')](_0x5121fd,_0x3003('0xd6')));rpcDb[_0x3003('0x94')](_0x5121fd,'[callProgressDetectingCustomer][logCongestion]');if(ut[_0x3003('0xa6')](_0x5121fd)>=_0xec2b83[_0x3003('0xa7')]){_0xe3434f=ut['cloneAction'](_0x5121fd,0xf,_0x3003('0xa9'));rpcDb[_0x3003('0x98')](_0xe3434f,_0x3003('0xd7'));}else{if(_0x5121fd['countcongestionretry']>=_0xec2b83[_0x3003('0xd8')]){rpcDb[_0x3003('0x98')](_0x5121fd,_0x3003('0xd9'));}else{rpcDb[_0x3003('0xac')](ut[_0x3003('0xca')](_0x5121fd,_0x3003('0xd3'),_0xec2b83['dialBusyRetryFrequency']),_0x5121fd[_0x3003('0xad')],_0x5121fd['activeContact']);}}break;case _0x3003('0xda'):_0xec2b83[_0x3003('0xdb')]+=0x1;_0x5121fd[_0x3003('0xdc')]+=0x1;_0x5121fd[_0x3003('0xa0')]=ut[_0x3003('0xa6')](_0x5121fd);ut[_0x3003('0x90')](_0x5121fd,0x14,_0x3003('0xdd'));ami['emit'](_0x3003('0xde'),ut[_0x3003('0xa3')](_0x5121fd,_0x3003('0xdf')));rpcDb[_0x3003('0x94')](_0x5121fd,'[syncHangupRequest][logAgentReject]');if(ut[_0x3003('0xa6')](_0x5121fd)>=_0xec2b83[_0x3003('0xa7')]){_0xe3434f=ut['cloneAction'](_0x5121fd,0x14,_0x3003('0xdd'));rpcDb[_0x3003('0x98')](_0xe3434f,_0x3003('0xe0'));}else{if(_0x5121fd[_0x3003('0xdc')]>=_0xec2b83[_0x3003('0xe1')]){rpcDb['createCustomerFinal'](_0x5121fd,_0x3003('0xe0'));}else{rpcDb[_0x3003('0xac')](ut['scheduledAt'](_0x5121fd,'countagentrejectretry',_0xec2b83[_0x3003('0xe2')]),_0x5121fd[_0x3003('0xad')],_0x5121fd[_0x3003('0xae')]);}}break;case'ABANDONED':_0xec2b83[_0x3003('0x44')]+=0x1;_0x5121fd[_0x3003('0xe3')]+=0x1;_0x5121fd[_0x3003('0xa0')]=ut['totalGlobal'](_0x5121fd);ut[_0x3003('0x90')](_0x5121fd,0xb,_0x3003('0xe4'));rpcDb[_0x3003('0x94')](_0x5121fd,_0x3003('0xe5'));if(ut[_0x3003('0xa6')](_0x5121fd)>=_0xec2b83[_0x3003('0xa7')]){_0xe3434f=ut[_0x3003('0xa8')](_0x5121fd,0xf,_0x3003('0xa9'));rpcDb[_0x3003('0x98')](_0xe3434f,_0x3003('0xe5'));}else{if(_0x5121fd[_0x3003('0xe6')]>=_0xec2b83[_0x3003('0xe7')]){rpcDb['createCustomerFinal'](_0x5121fd,_0x3003('0xe5'));}else{rpcDb[_0x3003('0xac')](ut[_0x3003('0xca')](_0x5121fd,_0x3003('0xe3'),_0xec2b83[_0x3003('0xe8')]),_0x5121fd[_0x3003('0xad')],_0x5121fd[_0x3003('0xae')]);}}break;default:if(_0x5121fd['dialAnswer']){ut['decrementTalkink'](_0xec2b83,'[default]');ut[_0x3003('0x81')](_0x3003('0xe9')+_0xec2b83['name'],_0x229d61);}_0xec2b83['outboundUnknownCallsDay']+=0x1;_0x5121fd[_0x3003('0xa0')]=ut['totalGlobal'](_0x5121fd);ut[_0x3003('0x90')](_0x5121fd,0xc,_0x229d61[_0x3003('0xea')]||_0x229d61[_0x3003('0xeb')]);rpcDb[_0x3003('0x94')](_0x5121fd,_0x3003('0xec'));if(ut[_0x3003('0xa6')](_0x5121fd)>=_0xec2b83[_0x3003('0xa7')]){_0xe3434f=ut[_0x3003('0xa8')](_0x5121fd,0xf,_0x3003('0xa9'));rpcDb['createCustomerFinal'](_0xe3434f,'[callProgressDetectingCustomer][logUnknownGlobal]');}else{rpcDb[_0x3003('0x98')](_0x5121fd,'[callProgressDetectingCustomer][logUnknownGlobal]');}delete this['actions'][_0x229d61['linkedid']];}if(!(_0x5121fd[_0x3003('0x76')]&&_0x17f8ff==='16')){ut[_0x3003('0xed')](_0xec2b83,'[callProgressDetectingCustomer]');logger[_0x3003('0x71')](_0x3003('0xee'),_0x5121fd[_0x3003('0xb5')],'\x20Queue',_0xec2b83[_0x3003('0x2c')],_0x3003('0x74'),_0xec2b83[_0x3003('0x4f')]);}if(_0x17f8ff!=='ANSWER'){delete this['actions'][_0x229d61['linkedid']];delete this[_0x3003('0x18')][_0x229d61[_0x3003('0xef')]];}}};Preview[_0x3003('0x10')][_0x3003('0xf0')]=function(_0x486e00,_0xb94139,_0x5efe16){if(_['isUndefined'](_0xb94139)&&'object'!==typeof _0xb94139){return;}if(_[_0x3003('0xf1')](_0x5efe16)&&_0x3003('0xf2')!==typeof _0x5efe16){return;}switch(_0x5efe16[_0x3003('0xf3')]){case'0':ut[_0x3003('0xf4')](_0x486e00,0x0,_0x3003('0xa1'));rpcDb['createAgentHistory'](_0x486e00,'[callProgressDetectingAgent][logNoSuch]');break;case'3':ut[_0x3003('0xf4')](_0x486e00,0x3,_0x3003('0xcc'));rpcDb[_0x3003('0xf5')](_0x486e00,_0x3003('0xf6'));break;case'5':ut['logAgent'](_0x486e00,0x5,_0x3003('0xc4'));rpcDb[_0x3003('0xf5')](_0x486e00,_0x3003('0xf7'));break;case'8':ut[_0x3003('0xf4')](_0x486e00,0x8,_0x3003('0xd4'));rpcDb[_0x3003('0xf5')](_0x486e00,_0x3003('0xf8'));break;case'22':ut[_0x3003('0xf4')](_0x486e00,0x16,_0x3003('0xf9'));rpcDb['createAgentHistory'](_0x486e00,_0x3003('0xfa'));break;default:ut[_0x3003('0xf4')](_0x486e00,0xc,_0x5efe16[_0x3003('0xf3')]);rpcDb['createAgentHistory'](_0x486e00,_0x3003('0xf8'));}ut[_0x3003('0xed')](_0xb94139,_0x3003('0xfb'));logger[_0x3003('0x71')](_0x3003('0xfc'),_0x486e00[_0x3003('0xb5')],_0x3003('0xb6'),_0xb94139[_0x3003('0x2c')],_0x3003('0x74'),_0xb94139[_0x3003('0x4f')]);delete this[_0x3003('0x18')][_0x486e00[_0x3003('0xb5')]];};Preview[_0x3003('0x10')]['checkInBlack']=function(_0x1377c7,_0x45f15e,_0x2d5a83,_0x3e81cc,_0x36bb45){var _0x350f18=this;return new BPromise(function(_0x50fd66,_0x2e7b65){if(_['isNil'](_0x45f15e)||_[_0x3003('0x70')](_0x45f15e['Contact'])||_[_0x3003('0x70')](_0x45f15e[_0x3003('0xfd')][_0x3003('0xfe')])||_[_0x3003('0x70')](_0x45f15e[_0x3003('0x79')])){_0x2e7b65(ut['message'](_0x3003('0xff'),_0x3e81cc,_0x36bb45));return;}var _0x1e0893=uuid['v4']();var _0x3002bb=_0x350f18[_0x3003('0x15')][_0x45f15e[_0x3003('0x73')][_0x3003('0x2c')]];var _0x1bc42e=_0x2d5a83?_0x350f18[_0x3003('0x19')][_0x2d5a83]['id']:undefined;_0x350f18[_0x3003('0x18')][_0x1e0893]=new Action(_0x45f15e,_0x3002bb,_0x1e0893,_0x2d5a83,_0x1bc42e);var _0x471d94=_0x350f18[_0x3003('0x18')][_0x1e0893];_0x471d94[_0x3003('0xad')]=_0x3e81cc;_0x471d94[_0x3003('0xae')]=_0x36bb45;_0x471d94[_0x3003('0x100')]=_0x2d5a83;if(_[_0x3003('0x101')](_0x1377c7)){_0x350f18[_0x3003('0x102')](_0x471d94,_0x3002bb,_0x45f15e,_0x2d5a83)[_0x3003('0x85')](function(_0x2de0ba){logger[_0x3003('0x71')](_0x3003('0x103'),'Queue:\x20'+_0x471d94[_0x3003('0x75')]+_0x3003('0x104')+_0x471d94['idContact'],JSON[_0x3003('0x5b')](_0x2de0ba));ami[_0x3003('0x2b')](_0x3003('0x105'),ut[_0x3003('0xa3')](_0x471d94,_0x3003('0x106')));_0x50fd66(ut['message'](_0x3003('0x107')));})[_0x3003('0x7e')](function(_0x4e7e91){ut['logger'](_0x3003('0x108'),_0x4e7e91);_0x2e7b65(ut[_0x3003('0x5e')]('Call\x20failed',_0x3e81cc,_0x36bb45));});}else{_0x3002bb[_0x3003('0x3c')]+=0x1;ut['logBlacklist'](_0x471d94);rpcDb['createHistory'](_0x471d94,_0x3003('0x109'));delete _0x350f18[_0x3003('0x18')][_0x1e0893];_0x2e7b65(ut[_0x3003('0x5e')]('Contact\x20in\x20black\x20List',_0x3e81cc,_0x36bb45));}});};Preview[_0x3003('0x10')]['isTrunkReachable']=function(_0x521f24){return!_[_0x3003('0x70')](_0x521f24)&&!_['isNil'](_0x521f24[_0x3003('0x2c')])&&!_[_0x3003('0x70')](_0x521f24[_0x3003('0x10a')])&&_0x521f24[_0x3003('0x10a')]&&!_['isNil'](this[_0x3003('0x17')][util[_0x3003('0x58')](_0x3003('0x10b'),_0x521f24[_0x3003('0x2c')])])&&!_['isNil'](this[_0x3003('0x17')][util[_0x3003('0x58')](_0x3003('0x10b'),_0x521f24[_0x3003('0x2c')])][_0x3003('0x7c')])&&(this[_0x3003('0x17')][util[_0x3003('0x58')](_0x3003('0x10b'),_0x521f24[_0x3003('0x2c')])]['status']===_0x3003('0x10c')||this[_0x3003('0x17')][util[_0x3003('0x58')]('SIP/%s',_0x521f24[_0x3003('0x2c')])][_0x3003('0x7c')]===_0x3003('0x10d'));};Preview['prototype'][_0x3003('0x8b')]=function(_0x5dccfc,_0x39827d){var _0x3e3466=this;return new BPromise(function(_0xa780f9,_0x43fb06){_0x3e3466[_0x3003('0x10e')](_0x5dccfc,_0x39827d)[_0x3003('0x85')](function(_0x77d57b){_0xa780f9(_['pick'](_0x77d57b,[_0x3003('0x5e')]));})[_0x3003('0x7e')](function(_0x220cd5){if(_0x220cd5[_0x3003('0x10f')]){rpcDb['unlockContact'](_0x5dccfc);}if(_0x220cd5[_0x3003('0x10a')]){rpcDb['disableContact'](_0x5dccfc);}_0x43fb06(_[_0x3003('0x77')](_0x220cd5,['message']));});});};Preview['prototype'][_0x3003('0x10e')]=function(_0x12f035,_0x31a894){var _0x2f5b0e=this;return new BPromise(function(_0x4554ad,_0x28cb09){var _0x314eed,_0x17da0e;rpcDb[_0x3003('0x110')](_0x12f035)[_0x3003('0x85')](function(_0x533feb){if(!_['isNil'](_0x533feb[0x0])){_0x17da0e=_0x533feb[0x0][_0x3003('0x111')]?![]:!![];_0x314eed=_0x533feb[0x0][_0x3003('0x111')]?!![]:![];_0x314eed=_0x31a894?!![]:_0x314eed;}var _0x3bdf9c=_0x2f5b0e['validateContact'](_0x533feb);if(_0x3bdf9c[_0x3003('0x112')]){rpcDb['checkIsBlackList'](_[_0x3003('0x77')](_0x533feb[0x0],[_0x3003('0x79'),'Contact.phone']))['then'](function(_0xd27a3){_0x2f5b0e[_0x3003('0x113')](_0xd27a3,_0x533feb[0x0],_0x31a894,_0x17da0e,_0x314eed)['then'](function(_0x43d067){_0x4554ad(_0x43d067);})['catch'](function(_0x474c8c){_0x28cb09(_0x474c8c);});})[_0x3003('0x7e')](function(_0x8c9592){ut[_0x3003('0x60')](_0x3003('0x114'),_0x8c9592);_0x28cb09(ut[_0x3003('0x5e')](_0x3003('0x115'),_0x17da0e,_0x314eed));});}else{_0x28cb09(ut['message'](_0x3bdf9c[_0x3003('0x5e')],_0x17da0e,_0x314eed));}})[_0x3003('0x7e')](function(_0x19df5d){ut[_0x3003('0x60')](_0x3003('0x116'),_0x19df5d);_0x28cb09(ut[_0x3003('0x5e')](_0x3003('0x115'),![],!![]));});});};Preview[_0x3003('0x10')]['validateContact']=function(_0x1269f1){if(_[_0x3003('0x70')](_0x1269f1)||_[_0x3003('0x101')](_0x1269f1)||!_[_0x3003('0x70')](_0x1269f1[0x0][_0x3003('0x89')])&&_['isNil'](_0x1269f1[0x0][_0x3003('0x89')][_0x3003('0x2c')])){ut['logger'](_0x3003('0x117'),_0x1269f1);return{'isValid':![],'message':_0x3003('0x118')};}var _0x5d156b=this[_0x3003('0x15')][_0x1269f1[0x0][_0x3003('0x73')][_0x3003('0x2c')]];_0x5d156b[_0x3003('0x5e')]=_0x3003('0x9e');if(_['isNil'](_0x5d156b)){ut[_0x3003('0x60')](_0x3003('0x119'),_0x5d156b);return{'isValid':![],'message':'Empty\x20Campaign'};}if(!this['isTrunkReachable'](_0x5d156b[_0x3003('0x55')])){ut[_0x3003('0x60')](_0x3003('0x11a'),_0x3003('0x11b')+_0x5d156b[_0x3003('0x2c')]+_0x3003('0x11c'));if(!this[_0x3003('0x9b')](_0x5d156b[_0x3003('0x9c')])){ut[_0x3003('0x60')](_0x3003('0x11a'),_0x5d156b[_0x3003('0x2c')]+_0x3003('0x11d'));return{'isValid':![],'message':_0x3003('0x11e')};}}if(!ut['isActive'](_0x5d156b[_0x3003('0x6d')])){ut[_0x3003('0x60')]('[Preview][validateContact][Campaign\x20Active]',_0x5d156b['name']+_0x3003('0x11f'));return{'isValid':![],'message':_0x3003('0x11b')+_0x5d156b[_0x3003('0x2c')]+_0x3003('0x11f')};}return{'isValid':!![],'message':_0x3003('0x120')};};Preview[_0x3003('0x10')]['execCall']=function(_0x13856f,_0xa8a862,_0x47406d,_0x41dd82){var _0x1274e7=this;return new BPromise(function(_0x11d764,_0x49a383){var _0x566af2=_0x13856f['uniqueid'];var _0x2043e6=_0x1274e7[_0x3003('0x9b')](_0xa8a862['Trunk'])?util[_0x3003('0x58')](_0x3003('0x121'),_0xa8a862[_0x3003('0x55')]['name'],_['isNil'](_0xa8a862[_0x3003('0x39')])?'':_0xa8a862[_0x3003('0x39')][_0x3003('0x122')]()||'',_0xa8a862[_0x3003('0x123')]>0x0?_0x47406d['Contact']['phone']['substring'](_0xa8a862[_0x3003('0x123')]):_0x47406d['Contact'][_0x3003('0xfe')]):util[_0x3003('0x58')](_0x3003('0x121'),_[_0x3003('0x70')](_0xa8a862[_0x3003('0x9c')])?_0xa8a862['Trunk'][_0x3003('0x2c')]:_0xa8a862[_0x3003('0x9c')][_0x3003('0x2c')],_[_0x3003('0x70')](_0xa8a862['dialPrefix'])?'':_0xa8a862[_0x3003('0x39')][_0x3003('0x122')]()||'',_0xa8a862[_0x3003('0x123')]>0x0?_0x47406d['Contact'][_0x3003('0xfe')]['substring'](_0xa8a862[_0x3003('0x123')]):_0x47406d[_0x3003('0xfd')][_0x3003('0xfe')]);var _0x22d4cb=_0x1274e7[_0x3003('0x9b')](_0xa8a862['Trunk'])?ut['getCallerId'](_0xa8a862[_0x3003('0x55')][_0x3003('0x56')],_0xa8a862['dialOriginateCallerIdName'],_0xa8a862[_0x3003('0x124')]>0x0?ut['getCallerIdRandom'](_0xa8a862[_0x3003('0x37')],_0xa8a862[_0x3003('0x124')]):_0xa8a862['dialOriginateCallerIdNumber']):ut['getCallerId'](_[_0x3003('0x70')](_0xa8a862[_0x3003('0x9c')])?_0xa8a862[_0x3003('0x55')][_0x3003('0x56')]:_0xa8a862[_0x3003('0x9c')]['callerid'],_0xa8a862[_0x3003('0x125')],_0xa8a862['dialRandomLastDigitCallerIdNumber']>0x0?ut[_0x3003('0x126')](_0xa8a862['dialOriginateCallerIdNumber'],_0xa8a862[_0x3003('0x124')]):_0xa8a862[_0x3003('0x37')]);if(_0x22d4cb){_0x13856f[_0x3003('0x127')]=ut[_0x3003('0x128')](_0x22d4cb);_0x13856f[_0x3003('0x129')]=ut[_0x3003('0x12a')](_0x22d4cb);}var _0x49b9dd=ut[_0x3003('0x12b')](_0xa8a862,_0x47406d,_0x2043e6,_0x22d4cb,_0x566af2,_0x13856f);_[_0x3003('0x12c')](_0x13856f,ut[_0x3003('0x12d')](_0x49b9dd));_0x13856f[_0x3003('0x8f')]=moment()[_0x3003('0x58')](_0x3003('0xb1'));ami[_0x3003('0x7b')](ut[_0x3003('0x12e')](_0x13856f,_0xa8a862,_0x49b9dd,_0x13856f['activeContact'],_0x41dd82))[_0x3003('0x85')](function(_0x78978f){_0xa8a862[_0x3003('0x4f')]+=0x1;logger[_0x3003('0x71')]('[originated][increment]',_0x566af2,_0x3003('0xb6'),_0xa8a862['name'],_0x3003('0x74'),_0xa8a862[_0x3003('0x4f')]);_0x11d764(_0x78978f);})[_0x3003('0x7e')](function(_0x357edb){ut[_0x3003('0xf4')](_0x13856f,0xe,_0x3003('0x12f'));rpcDb[_0x3003('0xf5')](_0x13856f,_0x3003('0x130'));_0x49a383(_0x357edb);});});};Preview['prototype'][_0x3003('0x25')]=function(_0x51d0d3){if(this[_0x3003('0x18')][_0x51d0d3[_0x3003('0xaf')]]){this[_0x3003('0x18')][_0x51d0d3[_0x3003('0xaf')]]['channel']=_0x51d0d3[_0x3003('0x7d')];}};Preview[_0x3003('0x10')][_0x3003('0x1c')]=function(_0x35a89b){var _0x1c50c1=this;var _0x1ed89c=this['actions'][_0x35a89b[_0x3003('0x131')]];if(_0x1ed89c){if(_0x1ed89c['lookAgent']&&this['agents'][_0x1ed89c[_0x3003('0x100')]]){ut[_0x3003('0x132')](_0x1ed89c,this[_0x3003('0x19')][_0x1ed89c[_0x3003('0x100')]][_0x3003('0x2c')],this['agents'][_0x1ed89c['lookAgent']]['id']);}var _0x588b79=_['clone'](_0x1ed89c);_0x588b79[_0x3003('0xb2')]=moment()[_0x3003('0x58')](_0x3003('0xb1'));var _0xbebc98=_0x1c50c1[_0x3003('0x15')][_0x1ed89c[_0x3003('0x75')]];if(ut[_0x3003('0x133')](_0x35a89b[_0x3003('0x134')])){if(_0x1ed89c['unlockAgent']){rpcDb[_0x3003('0x135')](_0x1ed89c[_0x3003('0x136')]);}if(_0x1ed89c[_0x3003('0xae')]){rpcDb[_0x3003('0x8e')](_0x1ed89c[_0x3003('0x136')]);}ami[_0x3003('0x2b')](_0x3003('0x137'),ut[_0x3003('0xa3')](_0x1ed89c,'rejected'));this[_0x3003('0xf0')](_0x588b79,_0xbebc98,_0x35a89b);}else{_0x1ed89c[_0x3003('0x8f')]=moment()[_0x3003('0x58')](_0x3003('0xb1'));ut[_0x3003('0xf4')](_0x588b79,0x4,_0x3003('0xbe'));rpcDb['createAgentHistory'](_0x588b79,'[callProgressDetectingAgent][logAnswer]');}}};Preview[_0x3003('0x10')]['syncHangup']=function(_0x5d3181){var _0x5a9ee4=this;var _0x34a1b8=this[_0x3003('0x18')][_0x5d3181[_0x3003('0xaf')]];var _0x92d128;if(_0x34a1b8){_0x92d128=this[_0x3003('0x15')][_0x34a1b8[_0x3003('0x75')]];logger['info'](_0x3003('0x138'),_0x5d3181[_0x3003('0xaf')],'\x20Queue',_0x92d128[_0x3003('0x2c')],_0x3003('0xb7'),_0x92d128[_0x3003('0x30')]);}if(this['actions'][_0x5d3181[_0x3003('0xaf')]]&&_0x5d3181[_0x3003('0xaf')]!==_0x5d3181[_0x3003('0xb5')]){if(_0x5d3181['cause']==='16'&&this[_0x3003('0x18')][_0x5d3181['linkedid']][_0x3003('0x76')]){this[_0x3003('0x139')](_0x5d3181,_0x5d3181[_0x3003('0xaf')],_0x5d3181[_0x3003('0x13a')]);}else if(this[_0x3003('0x18')][_0x5d3181['linkedid']][_0x3003('0x76')]){logger['info'](_0x3003('0x13b'),_0x5d3181[_0x3003('0xaf')],_0x5d3181[_0x3003('0x13a')],_0x3003('0xb6'),_0x92d128[_0x3003('0x2c')],_0x3003('0xb7'),_0x92d128['pTalking']);this[_0x3003('0x139')](_0x5d3181,_0x5d3181[_0x3003('0xaf')],_0x5d3181[_0x3003('0x13a')]);}}else if(_0x34a1b8&&_[_0x3003('0x70')](_0x34a1b8[_0x3003('0x13c')])&&_0x92d128['dialQueueProject']&&_0x5d3181[_0x3003('0xaf')]===_0x5d3181['uniqueid']&&_['isNil'](_0x5d3181[_0x3003('0xf3')])&&_0x5d3181[_0x3003('0x13a')]==='16'&&_0x5d3181[_0x3003('0x13d')]==='6'&&_[_0x3003('0xf1')](_0x34a1b8[_0x3003('0x13e')])){if(_0x34a1b8['unlockAgent']){rpcDb[_0x3003('0x135')](_0x34a1b8[_0x3003('0x136')]);}if(_0x34a1b8[_0x3003('0xae')]){rpcDb[_0x3003('0x8e')](_0x34a1b8['idContact']);}_0x5d3181['reason']='22';this[_0x3003('0xf0')](_0x34a1b8,_0x92d128,_0x5d3181);}else if(_0x34a1b8&&_0x34a1b8[_0x3003('0x13e')]){if(_0x5d3181[_0x3003('0x13a')]==='16'&&this[_0x3003('0x18')][_0x5d3181['linkedid']][_0x3003('0x76')]){logger[_0x3003('0x71')](_0x3003('0x13f'),_0x5d3181['linkedid'],_0x5d3181[_0x3003('0x13a')],_0x3003('0xb6'),_0x92d128[_0x3003('0x2c')],_0x3003('0xb7'),_0x92d128['pTalking']);this[_0x3003('0x139')](_0x5d3181,_0x5d3181['linkedid'],_0x5d3181[_0x3003('0x13a')]);}else if(this[_0x3003('0x18')][_0x5d3181['linkedid']][_0x3003('0x76')]){logger[_0x3003('0x71')](_0x3003('0x13b'),_0x5d3181[_0x3003('0xaf')],_0x5d3181[_0x3003('0x13a')],_0x3003('0xb6'),_0x92d128['name'],_0x3003('0xb7'),_0x92d128[_0x3003('0x30')]);this['callProgressDetectingCustomer'](_0x5d3181,_0x5d3181['linkedid'],_0x5d3181[_0x3003('0x13a')]);}}};Preview['prototype'][_0x3003('0x23')]=function(_0xf5c4a1){if(this[_0x3003('0x18')][_0xf5c4a1[_0x3003('0xef')]]&&_0xf5c4a1['destlinkedid']!==_0xf5c4a1[_0x3003('0x140')]){this[_0x3003('0x139')](_0xf5c4a1,_0xf5c4a1[_0x3003('0xef')],_0xf5c4a1['dialstatus']);}};Preview['prototype'][_0x3003('0x21')]=function(_0x1a0cf0){if(this[_0x3003('0x18')][_0x1a0cf0[_0x3003('0xaf')]]&&_0x1a0cf0['linkedid']!==_0x1a0cf0[_0x3003('0xb5')]&&!this[_0x3003('0x18')][_0x1a0cf0['linkedid']][_0x3003('0x76')]){if(_0x1a0cf0['cause']==='1'){this['callProgressDetectingCustomer'](_0x1a0cf0,_0x1a0cf0[_0x3003('0xaf')],_0x1a0cf0['cause']);}}};Preview[_0x3003('0x10')][_0x3003('0x141')]=function(_0xf56f45,_0x3a6ba6,_0xa2ee55){if(this[_0x3003('0x18')][_0xf56f45]){if(_['isNil'](this['actions'][_0xf56f45]['variables'])){this[_0x3003('0x18')][_0xf56f45][_0x3003('0x142')]={};}this[_0x3003('0x18')][_0xf56f45][_0x3003('0x142')][_0x3a6ba6]=_0xa2ee55;}};Preview[_0x3003('0x10')][_0x3003('0x27')]=function(_0x4c63d3){try{if(!_[_0x3003('0x70')](_0x4c63d3)){if(ut[_0x3003('0x143')](_[_0x3003('0x144')](_0x4c63d3[_0x3003('0x145')])[0x0])){this[_0x3003('0x141')](_0x4c63d3[_0x3003('0xb5')],_[_0x3003('0x144')](_0x4c63d3[_0x3003('0x145')])[0x0],_0x4c63d3[_0x3003('0x146')]);}}}catch(_0x3413af){logger[_0x3003('0x147')](_0x3003('0x148'),util[_0x3003('0x149')](_0x3413af,{'showHidden':![],'depth':null}));}};Preview[_0x3003('0x10')]['syncAttendedTransfer']=function(_0x3c9777){if(_0x3c9777){if(this[_0x3003('0x18')][_0x3c9777[_0x3003('0x14a')]]){this['actions'][_0x3c9777['transfertargetlinkedid']]['transfer']=!![];}}};Preview[_0x3003('0x10')]['syncBlindTransfer']=function(_0x1bcf65){if(_0x1bcf65){if(this[_0x3003('0x18')][_0x1bcf65[_0x3003('0x14b')]]){this[_0x3003('0x18')][_0x1bcf65[_0x3003('0x14b')]][_0x3003('0x13e')]=!![];}}};module[_0x3003('0x14c')]=Preview;