Built motion from commit (unavailable).|2.3.4
[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 _0xac84=['loggedInDb','dialMethod','dialOriginateCallerIdName','dialOriginateCallerIdNumber','dialOriginateTimeout','outboundAnswerAgiCallsDay','outboundBlacklistCallsDay','outboundCongestionCallsDay','outboundDropCallsDayACS','outboundDropCallsDayCallersExit','outboundNoAnswerCallsDay','outboundNoSuchCallsDay','outboundReCallsDay','outboundRejectCallsDay','outboundUnknownCallsDay','predictiveIntervalAnsweredCalls','predictiveIntervalAvgHoldtime','predictiveIntervalAvgTalktime','predictiveIntervalDroppedCallsCallersExit','predictiveIntervalErlangCalls','predictiveIntervalErlangCallsDroppedCalls','predictiveIntervalMultiplicativeFactor','predictiveIntervalPauses','predictiveIntervalTotalCalls','Trunk','active','callerid','Interval','stringify','md5','format','voice_queue:save','voice:queue:%s','voice_queue_channel:remove','sendMessageOneNotActive','pTalking','paused','NOT_ACTIVE','logger','\x20is\x20not\x20active','message','IS_DISACTIVED','\x20is\x20disactive','syncCampaigns','hasOwnProperty','booked','outbound','dialActive','setMessage','recallMe','clearZombieChannel','sequence','isNil','[clearZombieChannels][talking]','Queue','queue','originated:\x20','originated','pTalking:\x20','dialAnswer','pick','contactId','UserId','VoiceQueueId','ListId','Action','status','catch','No\x20such\x20channel','updateOriginated','[clearZombieChannel]','decrementTalkink','loggerError','[Dialer][checkChannel][pTalking][Preview]','[Dialer][checkChannel][Preview]','clearZombieChannels','info','[action]','size','getContactRecallMe','agents','then','length','scheduledat','dialRecallMeTimeout','run','[RecallMe]','logger2','starttime','YYYY-MM-DD\x20HH:mm:ss','logCustomer','RecallInQueue','dialRecallInQueue','rescheduleContactInQueue','createBody','[HistoryDialRecallInQueue][historyCatch]','RecallFailedTimeout','createCustomerHistory','createCustomerFinal','[getContactRecallMe]','isActive','isTrunkReachable','TRUNK_IS_NOT_REACHABLE','ACTIVE','countglobal','totalGlobal','NoSuchNumber','[callProgressDetectingCustomer][logNoSuch]','cloneAction','Global','[callProgressDetectingCustomer][logNoSuchGlobal]','ANSWER','responsetime','[syncHangup][talking][increment]','uniqueid','\x20Queue','custom:agentconnect','connect','acw','custom:agentConnectPreview','buildAcw','buildObj','complete','outboundAnswerCallsDay','[16]','Answer','[callProgressDetectingCustomer][logAnswerGlobal]','crateCustomerReportQueue','talktime','linkedid','BUSY','outboundBusyCallsDay','countbusyretry','Busy','[callProgressDetectingCustomer][logBusy]','dialGlobalMaxRetry','[callProgressDetectingCustomer][logBusyGlobal]','dialBusyMaxRetry','rescheduleContact','scheduledAt','dialBusyRetryFrequency','unlockAgent','NOANSWER','countnoanswerretry','NoAnswer','[callProgressDetectingCustomer][logNoAnswer]','dialNoAnswerMaxRetry','dialNoAnswerRetryFrequency','activeContact','countcongestionretry','[callProgressDetectingCustomer][logCongestion]','dialCongestionMaxRetry','CANCEL','AgentReject','[syncHangupRequest][logAgentReject]','unlockContact','idContact','disableContact','[default]','[Dialer][decrementTalkink][no\x20Hangup][Preview]','dialstatus','[callProgressDetectingCustomer][logUnknownGlobal]','[callProgressDetectingCustomer]','[originated][decrement][callProgressDetectingCustomer]','destlinkedid','isUndefined','reason','logAgent','[callProgressDetectingAgent][logNoSuch]','createAgentHistory','[callProgressDetectingAgent][logBusy]','Congestion','AnswerAGI','[callProgressDetectingAgent][logAnswerAGI]','[callProgressDetectingAgent][logCongestion]','[callProgressDetectingAgent]','[originated][decrement][callProgressDetectingAgent]','checkInBlack','Contact','phone','lookAgent','execCall','[Preview][execCall][success]','Queue:\x20','\x20IdHopper:\x20','custom:agentcalled','Calling','Call\x20failed','createHistory','[Blacklist][error]','SIP/%s','unmonitored','execRun','unlock','getContactPreview','recallme','validateContact','Contact.phone','[Preview][checkIsBlackList]','Call\x20unsuccessful','[Preview][getContactPreview]','isEmpty','Agent','[Preview][validateContact][Empty\x20Contact]','[Preview][validateContact][Empty\x20Campaign]','[Preview][validateContact][Trunk\x20not\x20work]','\x20Trunk\x20is\x20not\x20active','TrunkBackup','\x20Trunk\x20Backup\x20is\x20not\x20active','Trunk\x20not\x20work','[Preview][validateContact][Campaign\x20Active]','\x20Not\x20Active','campaign\x20Name:\x20','dialPrefix','dialCutDigit','SIP/%s/%s%s','getCallerIdRandom','dialRandomLastDigitCallerIdNumber','originatecalleridname','extractCalleridName','originatecalleridnum','extractCalleridNumber','merge','toLowerVariables','variablesAction','[originated][increment]','[originateFailure][logOriginateFailure]','actionid','clone','response','custom:agentringnoanswer','callProgressDetectingAgent','[callProgressDetectingAgent][logAnswer]','cause','[syncHangup][talking][cause]','statedesc','dialQueueProject','transfer','[syncHangup][talking][transfer]','callProgressDetectingCustomer','destuniqueid','variables','filterKey','keys','variable','error','[syncVarSet][Preview]','inspect','transfertargetlinkedid','transfererlinkedid','exports','util','bluebird','uuid','moment','ioredis','../../../config/environment','../../../config/logger','preview','actionPreview','../ami','./rpcDb','./action','./util/util','redis','localhost','socket.io-emitter','prototype','enqueue','tail','finally','campaignsPreview','voiceQueues','trunks','actions','clockClearZombieChannels','originateresponse','syncOriginateResponse','bind','hangup','syncHangup','syncHangupRequest','syncDialEnd','newexten','syncNewExten','varset','attendedtransfer','blindtransfer','syncBlindTransfer','loopCampaigns','emit','type','name','strategy','answered','available','loggedIn','sumBillable','sumDuration','sumHoldTime','total','abandoned','waiting'];(function(_0x5b644e,_0x2e5e07){var _0x49c6bf=function(_0x3032d9){while(--_0x3032d9){_0x5b644e['push'](_0x5b644e['shift']());}};_0x49c6bf(++_0x2e5e07);}(_0xac84,0xfb));var _0x4ac8=function(_0x5150df,_0x19a3ec){_0x5150df=_0x5150df-0x0;var _0x14e718=_0xac84[_0x5150df];return _0x14e718;};'use strict';var util=require(_0x4ac8('0x0'));var _=require('lodash');var BPromise=require(_0x4ac8('0x1'));var uuid=require(_0x4ac8('0x2'));var moment=require(_0x4ac8('0x3'));var md5=require('md5');var Redis=require(_0x4ac8('0x4'));var config=require(_0x4ac8('0x5'));var logger=require(_0x4ac8('0x6'))(_0x4ac8('0x7'));var loggerAction=require(_0x4ac8('0x6'))(_0x4ac8('0x8'));var ami=require(_0x4ac8('0x9'));var rpcDb=require(_0x4ac8('0xa'));var Action=require(_0x4ac8('0xb'));var ut=require(_0x4ac8('0xc'));config[_0x4ac8('0xd')]=_['defaults'](config[_0x4ac8('0xd')],{'host':_0x4ac8('0xe'),'port':0x18eb});var io=require(_0x4ac8('0xf'))(new Redis(config[_0x4ac8('0xd')]));var Sequence=function(){};Sequence[_0x4ac8('0x10')][_0x4ac8('0x11')]=function(_0xba88ac){this[_0x4ac8('0x12')]=this[_0x4ac8('0x12')]?this[_0x4ac8('0x12')][_0x4ac8('0x13')](_0xba88ac):_0xba88ac();};function Preview(_0x4cdb76){this['sequence']=new Sequence();this[_0x4ac8('0x14')]=_0x4cdb76[_0x4ac8('0x15')];this[_0x4ac8('0x16')]=_0x4cdb76[_0x4ac8('0x16')];this[_0x4ac8('0x17')]={};this['agents']=_0x4cdb76['agents'];this[_0x4ac8('0x18')]=0x0;ami['on'](_0x4ac8('0x19'),this[_0x4ac8('0x1a')][_0x4ac8('0x1b')](this));ami['on'](_0x4ac8('0x1c'),this[_0x4ac8('0x1d')][_0x4ac8('0x1b')](this));ami['on']('hanguprequest',this[_0x4ac8('0x1e')][_0x4ac8('0x1b')](this));ami['on']('dialend',this[_0x4ac8('0x1f')][_0x4ac8('0x1b')](this));ami['on'](_0x4ac8('0x20'),this[_0x4ac8('0x21')]['bind'](this));ami['on'](_0x4ac8('0x22'),this['syncVarSet'][_0x4ac8('0x1b')](this));ami['on'](_0x4ac8('0x23'),this['syncAttendedTransfer'][_0x4ac8('0x1b')](this));ami['on'](_0x4ac8('0x24'),this[_0x4ac8('0x25')][_0x4ac8('0x1b')](this));this[_0x4ac8('0x26')](this[_0x4ac8('0x14')]);}function emit(_0x1c3724,_0x28756a,_0xe5a1b4){io['to'](_0x1c3724)[_0x4ac8('0x27')](_0x28756a,_0xe5a1b4);}function emitCampaignPreview(_0x32582a){if(_0x32582a[_0x4ac8('0x28')]==='outbound'){var _0xb6cf0={'id':_0x32582a['id'],'name':_0x32582a[_0x4ac8('0x29')],'strategy':_0x32582a[_0x4ac8('0x2a')],'answered':_0x32582a[_0x4ac8('0x2b')],'available':_0x32582a[_0x4ac8('0x2c')],'loggedIn':_0x32582a[_0x4ac8('0x2d')],'pTalking':_0x32582a['pTalking'],'sumBillable':_0x32582a[_0x4ac8('0x2e')],'sumDuration':_0x32582a[_0x4ac8('0x2f')],'sumHoldTime':_0x32582a[_0x4ac8('0x30')]||0x0,'talking':_0x32582a['talking'],'total':_0x32582a[_0x4ac8('0x31')],'type':_0x32582a['type'],'unmanaged':_0x32582a['unmanaged'],'abandoned':_0x32582a[_0x4ac8('0x32')],'waiting':_0x32582a[_0x4ac8('0x33')],'loggedInDb':_0x32582a[_0x4ac8('0x34')],'dialActive':_0x32582a['dialActive'],'dialMethod':_0x32582a[_0x4ac8('0x35')],'dialOriginateCallerIdName':_0x32582a[_0x4ac8('0x36')],'dialOriginateCallerIdNumber':_0x32582a[_0x4ac8('0x37')],'dialOriginateTimeout':_0x32582a[_0x4ac8('0x38')],'dialPrefix':_0x32582a['dialPrefix'],'outboundAnswerAgiCallsDay':_0x32582a[_0x4ac8('0x39')],'outboundAnswerCallsDay':_0x32582a['outboundAnswerCallsDay'],'outboundBlacklistCallsDay':_0x32582a[_0x4ac8('0x3a')],'outboundBusyCallsDay':_0x32582a['outboundBusyCallsDay'],'outboundCongestionCallsDay':_0x32582a[_0x4ac8('0x3b')],'outboundDropCallsDayACS':_0x32582a[_0x4ac8('0x3c')],'outboundDropCallsDayCallersExit':_0x32582a[_0x4ac8('0x3d')],'outboundDropCallsDayTimeout':_0x32582a['outboundDropCallsDayTimeout'],'outboundNoAnswerCallsDay':_0x32582a[_0x4ac8('0x3e')],'outboundNoSuchCallsDay':_0x32582a[_0x4ac8('0x3f')],'outboundOriginateFailureCallsDay':_0x32582a['outboundOriginateFailureCallsDay'],'outboundReCallsDay':_0x32582a[_0x4ac8('0x40')],'outboundRejectCallsDay':_0x32582a[_0x4ac8('0x41')],'outboundUnknownCallsDay':_0x32582a[_0x4ac8('0x42')],'predictiveIntervalAnsweredCalls':_0x32582a[_0x4ac8('0x43')],'predictiveIntervalAvgHoldtime':_0x32582a[_0x4ac8('0x44')],'predictiveIntervalAvgTalktime':_0x32582a[_0x4ac8('0x45')],'predictiveIntervalDroppedCallsCallersExit':_0x32582a[_0x4ac8('0x46')],'predictiveIntervalDroppedCallsTimeout':_0x32582a['predictiveIntervalDroppedCallsTimeout'],'predictiveIntervalErlangCalls':_0x32582a[_0x4ac8('0x47')],'predictiveIntervalErlangCallsDroppedCalls':_0x32582a[_0x4ac8('0x48')],'predictiveIntervalHitRate':_0x32582a['predictiveIntervalHitRate'],'predictiveIntervalLowerLimit':_0x32582a['predictiveIntervalLowerLimit'],'predictiveIntervalMultiplicativeFactor':_0x32582a[_0x4ac8('0x49')],'predictiveIntervalPauses':_0x32582a[_0x4ac8('0x4a')],'predictiveIntervalTotalCalls':_0x32582a[_0x4ac8('0x4b')],'message':_0x32582a['message'],'originated':_0x32582a['originated']};if(_0x32582a['Trunk']){_0xb6cf0['Trunk']={'id':_0x32582a[_0x4ac8('0x4c')]['id'],'name':_0x32582a[_0x4ac8('0x4c')][_0x4ac8('0x29')],'active':_0x32582a[_0x4ac8('0x4c')][_0x4ac8('0x4d')],'callerid':_0x32582a[_0x4ac8('0x4c')][_0x4ac8('0x4e')]};}if(_0x32582a['Interval']){_0xb6cf0['Interval']={'id':_0x32582a['Interval']['id'],'name':_0x32582a[_0x4ac8('0x4f')][_0x4ac8('0x29')]};}var _0x5758fe=md5(JSON[_0x4ac8('0x50')](_0xb6cf0));if(_0x32582a['md5']!==_0x5758fe){_0x32582a[_0x4ac8('0x51')]=_0x5758fe;emit(util[_0x4ac8('0x52')]('voice:queue:%s',_0xb6cf0['name']),_0x4ac8('0x53'),_0xb6cf0);}}}function emitVoiceQueueChannelRemove(_0x407f72){emit(util['format'](_0x4ac8('0x54'),_0x407f72['name']),_0x4ac8('0x55'),_0x407f72);}function notSendMessagesQueue(_0x48bef5){if(_0x48bef5[_0x4ac8('0x56')]){if(_0x48bef5['originated']===0x0&&_0x48bef5[_0x4ac8('0x57')]===0x0){_0x48bef5[_0x4ac8('0x56')]=![];_0x48bef5['available']=0x0;_0x48bef5[_0x4ac8('0x58')]=0x0;_0x48bef5['message']=_0x4ac8('0x59');ut[_0x4ac8('0x5a')]('[CampaignPreview]\x20Campaign\x20Queue:\x20',_0x48bef5[_0x4ac8('0x29')]+_0x4ac8('0x5b'));}else{_0x48bef5[_0x4ac8('0x5c')]=_0x4ac8('0x5d');ut[_0x4ac8('0x5a')]('[CampaignPreview]\x20Campaign\x20Queue:\x20',_0x48bef5[_0x4ac8('0x29')]+_0x4ac8('0x5e'));}emitCampaignPreview(_0x48bef5);}}Preview[_0x4ac8('0x10')][_0x4ac8('0x26')]=function(){var _0x214a2a=this;setInterval(function(){_0x214a2a[_0x4ac8('0x5f')]();},0x7cf);};Preview[_0x4ac8('0x10')][_0x4ac8('0x5f')]=function(){var _0x3f7161=this[_0x4ac8('0x14')];this['clockClearZombieChannels']+=0x1;for(var _0x580b68 in _0x3f7161){if(_0x3f7161[_0x4ac8('0x60')](_0x580b68)&&(_0x3f7161[_0x580b68][_0x4ac8('0x35')]===_0x4ac8('0x7')||_0x3f7161[_0x580b68][_0x4ac8('0x35')]===_0x4ac8('0x61'))&&_0x3f7161[_0x580b68][_0x4ac8('0x28')]==='outbound'){if(this[_0x4ac8('0x18')]>0x7){this[_0x4ac8('0x18')]=0x0;this['clearZombieChannels']();}}if(_0x3f7161[_0x4ac8('0x60')](_0x580b68)&&_0x3f7161[_0x580b68]['dialMethod']===_0x4ac8('0x7')&&_0x3f7161[_0x580b68]['type']===_0x4ac8('0x62')){if(_0x3f7161[_0x580b68][_0x4ac8('0x63')]){this[_0x4ac8('0x64')](_0x3f7161[_0x580b68]);this[_0x4ac8('0x65')](_0x3f7161[_0x580b68]);}else{notSendMessagesQueue(_0x3f7161[_0x580b68]);}}}};Preview[_0x4ac8('0x10')][_0x4ac8('0x66')]=function(_0x5f45b9){var _0xb9152b=this;this[_0x4ac8('0x67')][_0x4ac8('0x11')](function(){if(!_[_0x4ac8('0x68')](_0xb9152b['actions'][_0x5f45b9])){loggerAction['info'](_0x4ac8('0x69'),_0x5f45b9,_0x4ac8('0x6a'),_0xb9152b[_0x4ac8('0x17')][_0x5f45b9][_0x4ac8('0x6b')],_0x4ac8('0x6c'),JSON['stringify'](_0xb9152b[_0x4ac8('0x14')][_0xb9152b[_0x4ac8('0x17')][_0x5f45b9][_0x4ac8('0x6b')]][_0x4ac8('0x6d')]),_0x4ac8('0x6e'),JSON['stringify'](_0xb9152b[_0x4ac8('0x14')][_0xb9152b[_0x4ac8('0x17')][_0x5f45b9][_0x4ac8('0x6b')]][_0x4ac8('0x57')]),JSON[_0x4ac8('0x50')](_0xb9152b['actions'][_0x5f45b9][_0x4ac8('0x6f')]),JSON['stringify'](_[_0x4ac8('0x70')](_0xb9152b[_0x4ac8('0x17')][_0x5f45b9],[_0x4ac8('0x71'),_0x4ac8('0x72'),_0x4ac8('0x73'),_0x4ac8('0x74')])));return ami[_0x4ac8('0x75')]({'action':_0x4ac8('0x76'),'channel':_0xb9152b['actions'][_0x5f45b9]['channel']})[_0x4ac8('0x77')](function(_0x35e82f){if(_0x35e82f['message']===_0x4ac8('0x78')){setTimeout(function(){if(_0xb9152b[_0x4ac8('0x17')][_0x5f45b9]){ut[_0x4ac8('0x79')](_0xb9152b['campaignsPreview'][_0xb9152b[_0x4ac8('0x17')][_0x5f45b9][_0x4ac8('0x6b')]],_0x4ac8('0x7a'));if(_0xb9152b['actions'][_0x5f45b9][_0x4ac8('0x6f')]===!![]){ut[_0x4ac8('0x7b')](_0xb9152b[_0x4ac8('0x14')][_0xb9152b[_0x4ac8('0x17')][_0x5f45b9][_0x4ac8('0x6b')]],_0x4ac8('0x7a'));ut[_0x4ac8('0x7c')](_0x4ac8('0x7d')+_0x5f45b9,_0xb9152b[_0x4ac8('0x17')][_0x5f45b9][_0x4ac8('0x6b')]);}ut[_0x4ac8('0x7c')](_0x4ac8('0x7e')+_0x5f45b9,_0xb9152b['actions'][_0x5f45b9][_0x4ac8('0x6b')]);delete _0xb9152b[_0x4ac8('0x17')][_0x5f45b9];}},0x2328);}});}});};Preview[_0x4ac8('0x10')][_0x4ac8('0x7f')]=function(){var _0xa6d2d9=this;loggerAction[_0x4ac8('0x80')](_0x4ac8('0x81'),_[_0x4ac8('0x82')](this['actions']));for(var _0x366b20 in this[_0x4ac8('0x17')]){if(_0xa6d2d9[_0x4ac8('0x17')][_0x4ac8('0x60')](_0x366b20)){_0xa6d2d9[_0x4ac8('0x66')](_0x366b20);}}};Preview[_0x4ac8('0x10')][_0x4ac8('0x65')]=function(_0x6527ec){var _0x5d9541=this;rpcDb[_0x4ac8('0x83')](_0x6527ec['id'],ut['agentReadyId'](this[_0x4ac8('0x84')]))[_0x4ac8('0x85')](function(_0x177e14){if(!_[_0x4ac8('0x68')](_0x177e14)){for(var _0x1348f8=0x0;_0x1348f8<_0x177e14[_0x4ac8('0x86')];_0x1348f8+=0x1){if(ut['getDiff'](_0x177e14[_0x1348f8][_0x4ac8('0x87')])<_0x6527ec[_0x4ac8('0x88')]*0x3c){_0x5d9541[_0x4ac8('0x89')](_0x177e14[_0x1348f8]['id'])[_0x4ac8('0x85')](ut['logger2'](_0x4ac8('0x8a')))['catch'](ut[_0x4ac8('0x8b')](_0x4ac8('0x8a')));}else{var _0x145bd9=new Action(_0x177e14[_0x1348f8],_0x6527ec);_0x145bd9[_0x4ac8('0x8c')]=moment()['format'](_0x4ac8('0x8d'));_0x6527ec[_0x4ac8('0x40')]+=0x1;ut[_0x4ac8('0x8e')](_0x145bd9,0x17,_0x4ac8('0x8f'));if(_0x6527ec[_0x4ac8('0x90')]){rpcDb[_0x4ac8('0x91')](ut[_0x4ac8('0x92')](_0x177e14[_0x1348f8]));rpcDb['createCustomerHistory'](_0x145bd9,_0x4ac8('0x93'));}else{ut[_0x4ac8('0x8e')](_0x145bd9,0x16,_0x4ac8('0x94'));rpcDb[_0x4ac8('0x95')](_0x145bd9,'[HistoryRecallClose]');rpcDb[_0x4ac8('0x96')](_0x145bd9,'[HistoryRecallClose]');}}}}})[_0x4ac8('0x77')](ut[_0x4ac8('0x8b')](_0x4ac8('0x97')));};Preview[_0x4ac8('0x10')][_0x4ac8('0x64')]=function(_0x188818){_0x188818[_0x4ac8('0x56')]=!![];if(ut['IsNotLoggedIn'](_0x188818['loggedIn'])){_0x188818['message']='AGENTS_NOT_LOGGED';}else if(!ut[_0x4ac8('0x98')](_0x188818[_0x4ac8('0x63')])){_0x188818['message']='NOT_ACTIVE';}else if(!this[_0x4ac8('0x99')](_0x188818['Trunk'])){if(!this[_0x4ac8('0x99')](_0x188818['TrunkBackup'])){_0x188818['message']=_0x4ac8('0x9a');}else{_0x188818[_0x4ac8('0x5c')]=_0x4ac8('0x9b');}}else{_0x188818[_0x4ac8('0x5c')]=_0x4ac8('0x9b');}emitCampaignPreview(_0x188818);};Preview[_0x4ac8('0x10')]['callProgressDetectingCustomer']=function(_0x43818b,_0x4897c6,_0x59f7ed){var _0x53854c=this;var _0x37ed32=this['actions'][_0x4897c6];var _0x4a455e=this[_0x4ac8('0x14')][_0x37ed32[_0x4ac8('0x6b')]];var _0x299db7;if(_0x4a455e){switch(_0x59f7ed){case'1':_0x4a455e[_0x4ac8('0x3f')]+=0x1;_0x37ed32[_0x4ac8('0x9c')]=ut[_0x4ac8('0x9d')](_0x37ed32);ut[_0x4ac8('0x8e')](_0x37ed32,0x0,_0x4ac8('0x9e'));rpcDb[_0x4ac8('0x95')](_0x37ed32,_0x4ac8('0x9f'));if(ut[_0x4ac8('0x9d')](_0x37ed32)>=_0x4a455e['dialGlobalMaxRetry']){_0x299db7=ut[_0x4ac8('0xa0')](_0x37ed32,0xf,_0x4ac8('0xa1'));rpcDb[_0x4ac8('0x96')](_0x299db7,_0x4ac8('0xa2'));}else{rpcDb[_0x4ac8('0x96')](_0x37ed32,'[callProgressDetectingCustomer][logNoSuchGlobal]');}delete this['actions'][_0x43818b['linkedid']];break;case _0x4ac8('0xa3'):var _0x38dce5=moment()[_0x4ac8('0x52')](_0x4ac8('0x8d'));_0x37ed32[_0x4ac8('0xa4')]=_0x38dce5;_0x37ed32['answertime']=_0x38dce5;_0x37ed32[_0x4ac8('0x6f')]=!![];_0x4a455e[_0x4ac8('0x57')]+=0x1;logger[_0x4ac8('0x80')](_0x4ac8('0xa5'),_0x37ed32[_0x4ac8('0xa6')],_0x4ac8('0xa7'),_0x4a455e[_0x4ac8('0x29')],_0x4ac8('0x6e'),_0x4a455e[_0x4ac8('0x57')]);ami[_0x4ac8('0x27')](_0x4ac8('0xa8'),ut['buildObj'](_0x37ed32,_0x4ac8('0xa9')));if(_0x4a455e[_0x4ac8('0xaa')]){ami['emit'](_0x4ac8('0xab'),ut[_0x4ac8('0xac')](_0x37ed32));}break;case'16':ami[_0x4ac8('0x27')]('custom:agentcomplete',ut[_0x4ac8('0xad')](_0x37ed32,_0x4ac8('0xae')));emitVoiceQueueChannelRemove(ut[_0x4ac8('0xad')](_0x37ed32,_0x4ac8('0xae')));_0x4a455e[_0x4ac8('0xaf')]+=0x1;_0x4a455e[_0x4ac8('0x31')]+=0x1;_0x4a455e[_0x4ac8('0x2b')]+=0x1;ut[_0x4ac8('0x7b')](_0x4a455e,_0x4ac8('0xb0'));_0x37ed32[_0x4ac8('0x9c')]=ut[_0x4ac8('0x9d')](_0x37ed32);ut[_0x4ac8('0x8e')](_0x37ed32,0x4,_0x4ac8('0xb1'));rpcDb[_0x4ac8('0x95')](_0x37ed32,'[callProgressDetectingCustomer][logAnswer]');rpcDb[_0x4ac8('0x96')](_0x37ed32,_0x4ac8('0xb2'));rpcDb[_0x4ac8('0xb3')](_0x37ed32);_0x4a455e[_0x4ac8('0x2f')]+=_0x37ed32['talktime'];_0x4a455e[_0x4ac8('0x2e')]+=_0x37ed32[_0x4ac8('0xb4')];logger['info']('[syncHangup][talking][decrement]',_0x37ed32[_0x4ac8('0xa6')],_0x4ac8('0xa7'),_0x4a455e['name'],_0x4ac8('0x6e'),_0x4a455e[_0x4ac8('0x57')]);delete this[_0x4ac8('0x17')][_0x43818b[_0x4ac8('0xb5')]];break;case _0x4ac8('0xb6'):_0x4a455e[_0x4ac8('0xb7')]+=0x1;_0x37ed32[_0x4ac8('0xb8')]+=0x1;_0x37ed32[_0x4ac8('0x9c')]=ut[_0x4ac8('0x9d')](_0x37ed32);ut[_0x4ac8('0x8e')](_0x37ed32,0x5,_0x4ac8('0xb9'));rpcDb[_0x4ac8('0x95')](_0x37ed32,_0x4ac8('0xba'));if(ut[_0x4ac8('0x9d')](_0x37ed32)>=_0x4a455e[_0x4ac8('0xbb')]){_0x299db7=ut[_0x4ac8('0xa0')](_0x37ed32,0xf,'Global');rpcDb[_0x4ac8('0x96')](_0x299db7,_0x4ac8('0xbc'));}else{if(_0x37ed32['countbusyretry']>=_0x4a455e[_0x4ac8('0xbd')]){rpcDb[_0x4ac8('0x96')](_0x37ed32,_0x4ac8('0xba'));}else{rpcDb[_0x4ac8('0xbe')](ut[_0x4ac8('0xbf')](_0x37ed32,'countbusyretry',_0x4a455e[_0x4ac8('0xc0')]),_0x37ed32[_0x4ac8('0xc1')],_0x37ed32['activeContact']);}}break;case _0x4ac8('0xc2'):_0x4a455e[_0x4ac8('0x3e')]+=0x1;_0x37ed32[_0x4ac8('0xc3')]+=0x1;_0x37ed32[_0x4ac8('0x9c')]=ut[_0x4ac8('0x9d')](_0x37ed32);ut['logCustomer'](_0x37ed32,0x3,_0x4ac8('0xc4'));rpcDb['createCustomerHistory'](_0x37ed32,_0x4ac8('0xc5'));if(ut['totalGlobal'](_0x37ed32)>=_0x4a455e[_0x4ac8('0xbb')]){_0x299db7=ut[_0x4ac8('0xa0')](_0x37ed32,0xf,_0x4ac8('0xa1'));rpcDb[_0x4ac8('0x96')](_0x299db7,'[callProgressDetectingCustomer][logNoAnswerGlobal]');}else{if(_0x37ed32[_0x4ac8('0xc3')]>=_0x4a455e[_0x4ac8('0xc6')]){rpcDb[_0x4ac8('0x96')](_0x37ed32,_0x4ac8('0xc5'));}else{rpcDb['rescheduleContact'](ut[_0x4ac8('0xbf')](_0x37ed32,_0x4ac8('0xc3'),_0x4a455e[_0x4ac8('0xc7')]),_0x37ed32[_0x4ac8('0xc1')],_0x37ed32[_0x4ac8('0xc8')]);}}break;case'CONGESTION':_0x4a455e[_0x4ac8('0x3b')]+=0x1;_0x37ed32[_0x4ac8('0xc9')]+=0x1;_0x37ed32[_0x4ac8('0x9c')]=ut[_0x4ac8('0x9d')](_0x37ed32);ut['logCustomer'](_0x37ed32,0x8,'Congestion');rpcDb[_0x4ac8('0x95')](_0x37ed32,_0x4ac8('0xca'));if(ut[_0x4ac8('0x9d')](_0x37ed32)>=_0x4a455e[_0x4ac8('0xbb')]){_0x299db7=ut[_0x4ac8('0xa0')](_0x37ed32,0xf,'Global');rpcDb[_0x4ac8('0x96')](_0x299db7,'[callProgressDetectingCustomer][logCongestionGlobal]');}else{if(_0x37ed32['countcongestionretry']>=_0x4a455e[_0x4ac8('0xcb')]){rpcDb[_0x4ac8('0x96')](_0x37ed32,'[callProgressDetectingCustomer][logCongestion]');}else{rpcDb[_0x4ac8('0xbe')](ut[_0x4ac8('0xbf')](_0x37ed32,_0x4ac8('0xc9'),_0x4a455e[_0x4ac8('0xc0')]),_0x37ed32[_0x4ac8('0xc1')],_0x37ed32[_0x4ac8('0xc8')]);}}break;case _0x4ac8('0xcc'):_0x4a455e[_0x4ac8('0x41')]+=0x1;_0x37ed32['countglobal']=ut[_0x4ac8('0x9d')](_0x37ed32);ut[_0x4ac8('0x8e')](_0x37ed32,0x14,_0x4ac8('0xcd'));rpcDb[_0x4ac8('0x95')](_0x37ed32,_0x4ac8('0xce'));if(_0x37ed32[_0x4ac8('0xc1')]){rpcDb[_0x4ac8('0xcf')](_0x37ed32[_0x4ac8('0xd0')]);}if(_0x37ed32[_0x4ac8('0xc8')]){rpcDb[_0x4ac8('0xd1')](_0x37ed32['idContact']);}break;default:if(_0x37ed32['dialAnswer']){ut[_0x4ac8('0x7b')](_0x4a455e,_0x4ac8('0xd2'));ut['loggerError'](_0x4ac8('0xd3')+_0x4a455e[_0x4ac8('0x29')],_0x43818b);}_0x4a455e[_0x4ac8('0x42')]+=0x1;_0x37ed32[_0x4ac8('0x9c')]=ut['totalGlobal'](_0x37ed32);ut['logCustomer'](_0x37ed32,0xc,_0x43818b['cause-txt']||_0x43818b[_0x4ac8('0xd4')]);rpcDb[_0x4ac8('0x95')](_0x37ed32,'[callProgressDetectingCustomer][logUnknown]');if(ut[_0x4ac8('0x9d')](_0x37ed32)>=_0x4a455e['dialGlobalMaxRetry']){_0x299db7=ut[_0x4ac8('0xa0')](_0x37ed32,0xf,_0x4ac8('0xa1'));rpcDb[_0x4ac8('0x96')](_0x299db7,_0x4ac8('0xd5'));}else{rpcDb[_0x4ac8('0x96')](_0x37ed32,'[callProgressDetectingCustomer][logUnknownGlobal]');}delete this['actions'][_0x43818b['linkedid']];}if(!(_0x37ed32[_0x4ac8('0x6f')]&&_0x59f7ed==='16')){ut[_0x4ac8('0x79')](_0x4a455e,_0x4ac8('0xd6'));logger['info'](_0x4ac8('0xd7'),_0x37ed32[_0x4ac8('0xa6')],_0x4ac8('0xa7'),_0x4a455e['name'],_0x4ac8('0x6c'),_0x4a455e['originated']);}if(_0x59f7ed!=='ANSWER'){delete this[_0x4ac8('0x17')][_0x43818b[_0x4ac8('0xb5')]];delete this[_0x4ac8('0x17')][_0x43818b[_0x4ac8('0xd8')]];}}};Preview[_0x4ac8('0x10')]['callProgressDetectingAgent']=function(_0x31e17f,_0x3fe59b,_0x334867){if(_[_0x4ac8('0xd9')](_0x3fe59b)&&'object'!==typeof _0x3fe59b){return;}if(_[_0x4ac8('0xd9')](_0x334867)&&'object'!==typeof _0x334867){return;}switch(_0x334867[_0x4ac8('0xda')]){case'0':ut[_0x4ac8('0xdb')](_0x31e17f,0x0,'NoSuchNumber');rpcDb['createAgentHistory'](_0x31e17f,_0x4ac8('0xdc'));break;case'3':ut[_0x4ac8('0xdb')](_0x31e17f,0x3,_0x4ac8('0xc4'));rpcDb['createAgentHistory'](_0x31e17f,'[callProgressDetectingAgent][logNoAnswer]');break;case'5':ut['logAgent'](_0x31e17f,0x5,_0x4ac8('0xb9'));rpcDb[_0x4ac8('0xdd')](_0x31e17f,_0x4ac8('0xde'));break;case'8':ut[_0x4ac8('0xdb')](_0x31e17f,0x8,_0x4ac8('0xdf'));rpcDb[_0x4ac8('0xdd')](_0x31e17f,'[callProgressDetectingAgent][logCongestion]');break;case'22':ut[_0x4ac8('0xdb')](_0x31e17f,0x16,_0x4ac8('0xe0'));rpcDb[_0x4ac8('0xdd')](_0x31e17f,_0x4ac8('0xe1'));break;default:ut['logAgent'](_0x31e17f,0xc,_0x334867[_0x4ac8('0xda')]);rpcDb[_0x4ac8('0xdd')](_0x31e17f,_0x4ac8('0xe2'));}ut[_0x4ac8('0x79')](_0x3fe59b,_0x4ac8('0xe3'));logger['info'](_0x4ac8('0xe4'),_0x31e17f[_0x4ac8('0xa6')],_0x4ac8('0xa7'),_0x3fe59b[_0x4ac8('0x29')],_0x4ac8('0x6c'),_0x3fe59b[_0x4ac8('0x6d')]);delete this[_0x4ac8('0x17')][_0x31e17f['uniqueid']];};Preview[_0x4ac8('0x10')][_0x4ac8('0xe5')]=function(_0x385193,_0x3698df,_0x17a890,_0x2888e6,_0x354bf5){var _0x1dfb04=this;return new BPromise(function(_0x1ac949,_0x20037f){if(_[_0x4ac8('0x68')](_0x3698df)||_['isNil'](_0x3698df[_0x4ac8('0xe6')])||_[_0x4ac8('0x68')](_0x3698df['Contact'][_0x4ac8('0xe7')])||_[_0x4ac8('0x68')](_0x3698df[_0x4ac8('0x73')])){_0x20037f(ut['message']('Contact\x20is\x20undefined',_0x2888e6,_0x354bf5));return;}var _0x32b098=uuid['v4']();var _0x2465dc=_0x1dfb04[_0x4ac8('0x14')][_0x3698df[_0x4ac8('0x6a')]['name']];var _0xdcb02f=_0x17a890?_0x1dfb04['agents'][_0x17a890]['id']:undefined;_0x1dfb04['actions'][_0x32b098]=new Action(_0x3698df,_0x2465dc,_0x32b098,_0x17a890,_0xdcb02f);var _0x34934=_0x1dfb04[_0x4ac8('0x17')][_0x32b098];_0x34934['unlockAgent']=_0x2888e6;_0x34934[_0x4ac8('0xc8')]=_0x354bf5;_0x34934[_0x4ac8('0xe8')]=_0x17a890;if(_['isEmpty'](_0x385193)){_0x1dfb04[_0x4ac8('0xe9')](_0x34934,_0x2465dc,_0x3698df,_0x17a890)['then'](function(_0x333025){logger[_0x4ac8('0x80')](_0x4ac8('0xea'),_0x4ac8('0xeb')+_0x34934[_0x4ac8('0x6b')]+_0x4ac8('0xec')+_0x34934['idContact'],JSON[_0x4ac8('0x50')](_0x333025));ami['emit'](_0x4ac8('0xed'),ut['buildObj'](_0x34934,'called'));_0x1ac949(ut['message'](_0x4ac8('0xee')));})[_0x4ac8('0x77')](function(_0x171459){ut[_0x4ac8('0x5a')]('[Preview][execCall][failure]',_0x171459);_0x20037f(ut[_0x4ac8('0x5c')](_0x4ac8('0xef'),_0x2888e6,_0x354bf5));});}else{_0x2465dc['outboundBlacklistCallsDay']+=0x1;ut['logBlacklist'](_0x34934);rpcDb[_0x4ac8('0xf0')](_0x34934,_0x4ac8('0xf1'));delete _0x1dfb04[_0x4ac8('0x17')][_0x32b098];_0x20037f(ut[_0x4ac8('0x5c')]('Contact\x20in\x20black\x20List',_0x2888e6,_0x354bf5));}});};Preview[_0x4ac8('0x10')][_0x4ac8('0x99')]=function(_0x3e093c){return!_['isNil'](_0x3e093c)&&!_['isNil'](_0x3e093c['name'])&&!_['isNil'](_0x3e093c['active'])&&_0x3e093c[_0x4ac8('0x4d')]&&!_[_0x4ac8('0x68')](this[_0x4ac8('0x16')][util[_0x4ac8('0x52')](_0x4ac8('0xf2'),_0x3e093c[_0x4ac8('0x29')])])&&!_['isNil'](this[_0x4ac8('0x16')][util[_0x4ac8('0x52')]('SIP/%s',_0x3e093c[_0x4ac8('0x29')])][_0x4ac8('0x76')])&&(this['trunks'][util['format']('SIP/%s',_0x3e093c[_0x4ac8('0x29')])]['status']==='reachable'||this['trunks'][util[_0x4ac8('0x52')](_0x4ac8('0xf2'),_0x3e093c[_0x4ac8('0x29')])][_0x4ac8('0x76')]===_0x4ac8('0xf3'));};Preview[_0x4ac8('0x10')]['run']=function(_0x1738c5,_0x544832){var _0x5bbe74=this;return new BPromise(function(_0x6b2d1a,_0x51cd51){_0x5bbe74[_0x4ac8('0xf4')](_0x1738c5,_0x544832)[_0x4ac8('0x85')](function(_0x1033c4){_0x6b2d1a(_[_0x4ac8('0x70')](_0x1033c4,[_0x4ac8('0x5c')]));})[_0x4ac8('0x77')](function(_0x128572){if(_0x128572[_0x4ac8('0xf5')]){rpcDb[_0x4ac8('0xcf')](_0x1738c5);}if(_0x128572[_0x4ac8('0x4d')]){rpcDb[_0x4ac8('0xd1')](_0x1738c5);}_0x51cd51(_[_0x4ac8('0x70')](_0x128572,[_0x4ac8('0x5c')]));});});};Preview['prototype'][_0x4ac8('0xf4')]=function(_0x2f06d2,_0x4342ec){var _0x262e0f=this;return new BPromise(function(_0x4c0265,_0x47fb8b){var _0x335508,_0xd1f8ac;rpcDb[_0x4ac8('0xf6')](_0x2f06d2)[_0x4ac8('0x85')](function(_0x403fff){if(!_['isNil'](_0x403fff[0x0])){_0xd1f8ac=_0x403fff[0x0]['recallme']?![]:!![];_0x335508=_0x403fff[0x0][_0x4ac8('0xf7')]?!![]:![];_0x335508=_0x4342ec?!![]:_0x335508;}var _0x5b2d57=_0x262e0f[_0x4ac8('0xf8')](_0x403fff);if(_0x5b2d57['isValid']){rpcDb['checkIsBlackList'](_[_0x4ac8('0x70')](_0x403fff[0x0],[_0x4ac8('0x73'),_0x4ac8('0xf9')]))['then'](function(_0xe9b53){_0x262e0f['checkInBlack'](_0xe9b53,_0x403fff[0x0],_0x4342ec,_0xd1f8ac,_0x335508)[_0x4ac8('0x85')](function(_0x2dd481){_0x4c0265(_0x2dd481);})[_0x4ac8('0x77')](function(_0x40dc65){_0x47fb8b(_0x40dc65);});})['catch'](function(_0x265914){ut[_0x4ac8('0x5a')](_0x4ac8('0xfa'),_0x265914);_0x47fb8b(ut[_0x4ac8('0x5c')](_0x4ac8('0xfb'),_0xd1f8ac,_0x335508));});}else{_0x47fb8b(ut[_0x4ac8('0x5c')](_0x5b2d57['message'],_0xd1f8ac,_0x335508));}})[_0x4ac8('0x77')](function(_0x45a111){ut[_0x4ac8('0x5a')](_0x4ac8('0xfc'),_0x45a111);_0x47fb8b(ut[_0x4ac8('0x5c')](_0x4ac8('0xfb'),![],!![]));});});};Preview[_0x4ac8('0x10')]['validateContact']=function(_0x383615){if(_['isNil'](_0x383615)||_[_0x4ac8('0xfd')](_0x383615)||!_[_0x4ac8('0x68')](_0x383615[0x0][_0x4ac8('0xfe')])&&_[_0x4ac8('0x68')](_0x383615[0x0]['Agent']['name'])){ut['logger'](_0x4ac8('0xff'),_0x383615);return{'isValid':![],'message':'Empty\x20Contact'};}var _0x3aec36=this[_0x4ac8('0x14')][_0x383615[0x0][_0x4ac8('0x6a')][_0x4ac8('0x29')]];_0x3aec36[_0x4ac8('0x5c')]=_0x4ac8('0x9b');if(_[_0x4ac8('0x68')](_0x3aec36)){ut[_0x4ac8('0x5a')](_0x4ac8('0x100'),_0x3aec36);return{'isValid':![],'message':'Empty\x20Campaign'};}if(!this[_0x4ac8('0x99')](_0x3aec36[_0x4ac8('0x4c')])){ut[_0x4ac8('0x5a')](_0x4ac8('0x101'),'campaign\x20Name:\x20'+_0x3aec36[_0x4ac8('0x29')]+_0x4ac8('0x102'));if(!this[_0x4ac8('0x99')](_0x3aec36[_0x4ac8('0x103')])){ut['logger'](_0x4ac8('0x101'),_0x3aec36['name']+_0x4ac8('0x104'));return{'isValid':![],'message':_0x4ac8('0x105')};}}if(!ut[_0x4ac8('0x98')](_0x3aec36[_0x4ac8('0x63')])){ut[_0x4ac8('0x5a')](_0x4ac8('0x106'),_0x3aec36[_0x4ac8('0x29')]+_0x4ac8('0x107'));return{'isValid':![],'message':_0x4ac8('0x108')+_0x3aec36[_0x4ac8('0x29')]+_0x4ac8('0x107')};}return{'isValid':!![],'message':'Is\x20Valid'};};Preview[_0x4ac8('0x10')][_0x4ac8('0xe9')]=function(_0x40f60e,_0x1faa21,_0x2d1d68,_0x3847df){var _0x4ed10e=this;return new BPromise(function(_0x462426,_0x5b5f98){var _0x5cd3c6=_0x40f60e['uniqueid'];var _0x1609c8=_0x4ed10e[_0x4ac8('0x99')](_0x1faa21['Trunk'])?util[_0x4ac8('0x52')]('SIP/%s/%s%s',_0x1faa21['Trunk'][_0x4ac8('0x29')],_[_0x4ac8('0x68')](_0x1faa21[_0x4ac8('0x109')])?'':_0x1faa21[_0x4ac8('0x109')]['trim']()||'',_0x1faa21[_0x4ac8('0x10a')]>0x0?_0x2d1d68[_0x4ac8('0xe6')]['phone']['substring'](_0x1faa21['dialCutDigit']):_0x2d1d68[_0x4ac8('0xe6')][_0x4ac8('0xe7')]):util[_0x4ac8('0x52')](_0x4ac8('0x10b'),_[_0x4ac8('0x68')](_0x1faa21[_0x4ac8('0x103')])?_0x1faa21[_0x4ac8('0x4c')]['name']:_0x1faa21[_0x4ac8('0x103')][_0x4ac8('0x29')],_[_0x4ac8('0x68')](_0x1faa21[_0x4ac8('0x109')])?'':_0x1faa21[_0x4ac8('0x109')]['trim']()||'',_0x1faa21[_0x4ac8('0x10a')]>0x0?_0x2d1d68['Contact'][_0x4ac8('0xe7')]['substring'](_0x1faa21[_0x4ac8('0x10a')]):_0x2d1d68[_0x4ac8('0xe6')][_0x4ac8('0xe7')]);var _0xa628f5=_0x4ed10e[_0x4ac8('0x99')](_0x1faa21[_0x4ac8('0x4c')])?ut['getCallerId'](_0x1faa21[_0x4ac8('0x4c')]['callerid'],_0x1faa21[_0x4ac8('0x36')],_0x1faa21['dialRandomLastDigitCallerIdNumber']>0x0?ut[_0x4ac8('0x10c')](_0x1faa21[_0x4ac8('0x37')],_0x1faa21[_0x4ac8('0x10d')]):_0x1faa21[_0x4ac8('0x37')]):ut['getCallerId'](_[_0x4ac8('0x68')](_0x1faa21[_0x4ac8('0x103')])?_0x1faa21[_0x4ac8('0x4c')][_0x4ac8('0x4e')]:_0x1faa21['TrunkBackup'][_0x4ac8('0x4e')],_0x1faa21[_0x4ac8('0x36')],_0x1faa21[_0x4ac8('0x10d')]>0x0?ut['getCallerIdRandom'](_0x1faa21[_0x4ac8('0x37')],_0x1faa21[_0x4ac8('0x10d')]):_0x1faa21[_0x4ac8('0x37')]);if(_0xa628f5){_0x40f60e[_0x4ac8('0x10e')]=ut[_0x4ac8('0x10f')](_0xa628f5);_0x40f60e[_0x4ac8('0x110')]=ut[_0x4ac8('0x111')](_0xa628f5);}var _0x5986e8=ut['addVariables'](_0x1faa21,_0x2d1d68,_0x1609c8,_0xa628f5,_0x5cd3c6,_0x40f60e);_[_0x4ac8('0x112')](_0x40f60e,ut[_0x4ac8('0x113')](_0x5986e8));_0x40f60e[_0x4ac8('0x8c')]=moment()[_0x4ac8('0x52')]('YYYY-MM-DD\x20HH:mm:ss');ami[_0x4ac8('0x75')](ut[_0x4ac8('0x114')](_0x40f60e,_0x1faa21,_0x5986e8,_0x40f60e[_0x4ac8('0xc8')],_0x3847df))[_0x4ac8('0x85')](function(_0x1d9645){_0x1faa21[_0x4ac8('0x6d')]+=0x1;logger['info'](_0x4ac8('0x115'),_0x5cd3c6,_0x4ac8('0xa7'),_0x1faa21[_0x4ac8('0x29')],'originated:\x20',_0x1faa21[_0x4ac8('0x6d')]);_0x462426(_0x1d9645);})['catch'](function(_0x5a7bdd){ut[_0x4ac8('0xdb')](_0x40f60e,0xe,'OriginateError');rpcDb[_0x4ac8('0xdd')](_0x40f60e,_0x4ac8('0x116'));_0x5b5f98(_0x5a7bdd);});});};Preview[_0x4ac8('0x10')][_0x4ac8('0x21')]=function(_0x56f886){if(this[_0x4ac8('0x17')][_0x56f886[_0x4ac8('0xb5')]]){this['actions'][_0x56f886[_0x4ac8('0xb5')]]['channel']=_0x56f886['channel'];}};Preview[_0x4ac8('0x10')][_0x4ac8('0x1a')]=function(_0xff47d7){var _0xeb80ed=this;var _0x5ad876=this[_0x4ac8('0x17')][_0xff47d7[_0x4ac8('0x117')]];if(_0x5ad876){if(_0x5ad876[_0x4ac8('0xe8')]&&this[_0x4ac8('0x84')][_0x5ad876[_0x4ac8('0xe8')]]){ut['logLookAgent'](_0x5ad876,this['agents'][_0x5ad876['lookAgent']][_0x4ac8('0x29')],this[_0x4ac8('0x84')][_0x5ad876['lookAgent']]['id']);}var _0xef76b2=_[_0x4ac8('0x118')](_0x5ad876);_0xef76b2['responsetime']=moment()[_0x4ac8('0x52')](_0x4ac8('0x8d'));var _0x4153d1=_0xeb80ed[_0x4ac8('0x14')][_0x5ad876['queue']];if(ut['isFailure'](_0xff47d7[_0x4ac8('0x119')])){if(_0x5ad876[_0x4ac8('0xc1')]){rpcDb['unlockContact'](_0x5ad876[_0x4ac8('0xd0')]);}if(_0x5ad876[_0x4ac8('0xc8')]){rpcDb[_0x4ac8('0xd1')](_0x5ad876[_0x4ac8('0xd0')]);}ami['emit'](_0x4ac8('0x11a'),ut[_0x4ac8('0xad')](_0x5ad876,'rejected'));this[_0x4ac8('0x11b')](_0xef76b2,_0x4153d1,_0xff47d7);}else{_0x5ad876[_0x4ac8('0x8c')]=moment()[_0x4ac8('0x52')](_0x4ac8('0x8d'));ut[_0x4ac8('0xdb')](_0xef76b2,0x4,_0x4ac8('0xb1'));rpcDb[_0x4ac8('0xdd')](_0xef76b2,_0x4ac8('0x11c'));}}};Preview[_0x4ac8('0x10')]['syncHangup']=function(_0x462c12){var _0x3fa4aa=this;var _0x1252d1=this[_0x4ac8('0x17')][_0x462c12[_0x4ac8('0xb5')]];var _0x112e02;if(_0x1252d1){_0x112e02=this[_0x4ac8('0x14')][_0x1252d1[_0x4ac8('0x6b')]];logger[_0x4ac8('0x80')]('[syncHangup][talking]',_0x462c12['linkedid'],'\x20Queue',_0x112e02[_0x4ac8('0x29')],'pTalking:\x20',_0x112e02[_0x4ac8('0x57')]);}if(this[_0x4ac8('0x17')][_0x462c12[_0x4ac8('0xb5')]]&&_0x462c12[_0x4ac8('0xb5')]!==_0x462c12['uniqueid']){if(_0x462c12[_0x4ac8('0x11d')]==='16'&&this[_0x4ac8('0x17')][_0x462c12[_0x4ac8('0xb5')]][_0x4ac8('0x6f')]){this['callProgressDetectingCustomer'](_0x462c12,_0x462c12[_0x4ac8('0xb5')],_0x462c12[_0x4ac8('0x11d')]);}else if(this[_0x4ac8('0x17')][_0x462c12[_0x4ac8('0xb5')]][_0x4ac8('0x6f')]){logger[_0x4ac8('0x80')](_0x4ac8('0x11e'),_0x462c12[_0x4ac8('0xb5')],_0x462c12[_0x4ac8('0x11d')],_0x4ac8('0xa7'),_0x112e02[_0x4ac8('0x29')],'pTalking:\x20',_0x112e02[_0x4ac8('0x57')]);this['callProgressDetectingCustomer'](_0x462c12,_0x462c12[_0x4ac8('0xb5')],_0x462c12[_0x4ac8('0x11d')]);}}else if(_0x1252d1&&_[_0x4ac8('0x68')](_0x1252d1[_0x4ac8('0x11f')])&&_0x112e02[_0x4ac8('0x120')]&&_0x462c12[_0x4ac8('0xb5')]===_0x462c12[_0x4ac8('0xa6')]&&_[_0x4ac8('0x68')](_0x462c12[_0x4ac8('0xda')])&&_0x462c12[_0x4ac8('0x11d')]==='16'&&_0x462c12['channelstate']==='6'&&_[_0x4ac8('0xd9')](_0x1252d1[_0x4ac8('0x121')])){if(_0x1252d1[_0x4ac8('0xc1')]){rpcDb['unlockContact'](_0x1252d1['idContact']);}if(_0x1252d1[_0x4ac8('0xc8')]){rpcDb[_0x4ac8('0xd1')](_0x1252d1['idContact']);}_0x462c12[_0x4ac8('0xda')]='22';this[_0x4ac8('0x11b')](_0x1252d1,_0x112e02,_0x462c12);}else if(_0x1252d1&&_0x1252d1[_0x4ac8('0x121')]){if(_0x462c12[_0x4ac8('0x11d')]==='16'&&this['actions'][_0x462c12[_0x4ac8('0xb5')]][_0x4ac8('0x6f')]){logger['info'](_0x4ac8('0x122'),_0x462c12['linkedid'],_0x462c12['cause'],'\x20Queue',_0x112e02[_0x4ac8('0x29')],_0x4ac8('0x6e'),_0x112e02[_0x4ac8('0x57')]);this[_0x4ac8('0x123')](_0x462c12,_0x462c12[_0x4ac8('0xb5')],_0x462c12['cause']);}else if(this[_0x4ac8('0x17')][_0x462c12[_0x4ac8('0xb5')]][_0x4ac8('0x6f')]){logger['info']('[syncHangup][talking][cause]',_0x462c12[_0x4ac8('0xb5')],_0x462c12[_0x4ac8('0x11d')],_0x4ac8('0xa7'),_0x112e02[_0x4ac8('0x29')],_0x4ac8('0x6e'),_0x112e02['pTalking']);this[_0x4ac8('0x123')](_0x462c12,_0x462c12[_0x4ac8('0xb5')],_0x462c12[_0x4ac8('0x11d')]);}}};Preview[_0x4ac8('0x10')][_0x4ac8('0x1f')]=function(_0x2bb7c0){if(this[_0x4ac8('0x17')][_0x2bb7c0[_0x4ac8('0xd8')]]&&_0x2bb7c0[_0x4ac8('0xd8')]!==_0x2bb7c0[_0x4ac8('0x124')]){this[_0x4ac8('0x123')](_0x2bb7c0,_0x2bb7c0[_0x4ac8('0xd8')],_0x2bb7c0[_0x4ac8('0xd4')]);}};Preview['prototype'][_0x4ac8('0x1e')]=function(_0x2895e7){if(this[_0x4ac8('0x17')][_0x2895e7[_0x4ac8('0xb5')]]&&_0x2895e7[_0x4ac8('0xb5')]!==_0x2895e7[_0x4ac8('0xa6')]&&!this['actions'][_0x2895e7[_0x4ac8('0xb5')]][_0x4ac8('0x6f')]){if(_0x2895e7[_0x4ac8('0x11d')]==='1'){this[_0x4ac8('0x123')](_0x2895e7,_0x2895e7['linkedid'],_0x2895e7[_0x4ac8('0x11d')]);}}};Preview[_0x4ac8('0x10')]['addVariable']=function(_0x2c0635,_0x29c2dd,_0x1c629f){if(this[_0x4ac8('0x17')][_0x2c0635]){if(_['isNil'](this[_0x4ac8('0x17')][_0x2c0635][_0x4ac8('0x125')])){this['actions'][_0x2c0635]['variables']={};}this[_0x4ac8('0x17')][_0x2c0635][_0x4ac8('0x125')][_0x29c2dd]=_0x1c629f;}};Preview['prototype']['syncVarSet']=function(_0x4b16c6){try{if(!_[_0x4ac8('0x68')](_0x4b16c6)){if(ut[_0x4ac8('0x126')](_[_0x4ac8('0x127')](_0x4b16c6[_0x4ac8('0x128')])[0x0])){this['addVariable'](_0x4b16c6['uniqueid'],_['keys'](_0x4b16c6['variable'])[0x0],_0x4b16c6['value']);}}}catch(_0x36644c){logger[_0x4ac8('0x129')](_0x4ac8('0x12a'),util[_0x4ac8('0x12b')](_0x36644c,{'showHidden':![],'depth':null}));}};Preview[_0x4ac8('0x10')]['syncAttendedTransfer']=function(_0x307bcd){if(_0x307bcd){if(this['actions'][_0x307bcd['transfertargetlinkedid']]){this[_0x4ac8('0x17')][_0x307bcd[_0x4ac8('0x12c')]][_0x4ac8('0x121')]=!![];}}};Preview['prototype'][_0x4ac8('0x25')]=function(_0x3cd8c2){if(_0x3cd8c2){if(this[_0x4ac8('0x17')][_0x3cd8c2[_0x4ac8('0x12d')]]){this[_0x4ac8('0x17')][_0x3cd8c2[_0x4ac8('0x12d')]][_0x4ac8('0x121')]=!![];}}};module[_0x4ac8('0x12e')]=Preview;