Built motion from commit b5996064.|2.6.21
[motion2.git] / server / services / ami / preview / util / util.js
index 6c0d078..44b94c9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf922=['name','calleridnum','ContactId','dialer','VoiceQueueId','dialOriginateTimeout','\x22rtTxX%s%s\x22','dialQueueProject2','monitor_format','U(xcally-mixmonitor-context)','dialQueueProject','\x22agi://%s/square,%s\x22','NONE','originatecalleridnum','originatecalleridname','xcally-motion-preview','Call-Type:\x20PREVIEW','_XCALLY_MIXMONITOR_FORMAT','Contact','hasOwnProperty','tags','createdAt','updatedAt','%s%s','toLowerVariables','toLower','updateOriginated','originated','[updateOriginated]\x20object\x20originated\x20is\x20negative','YYYY-MM-DD\x20HH:mm:ss','state','statedesc','Blacklist','starttime','responsetime','endtime','logAgent','ringtime','logLookAgent','UserId','logCustomer','talktime','answertime','isFailure','Failure','variablesAction','RECALL','calleridname','BOOKED','uniqueid','originate','channelAgent','from-sip','totalGlobal','countnoanswerretry','countnosuchnumberretry','clone','Global','minutes','ListId','decrementTalkink','pTalking','[decrementTalkink]\x20is\x20null\x20or\x20undefined','IsNotLoggedIn','buildObj','lastevent','queue','interface','voice','mandatoryDisposition','buildAcw','agentReadyId','not_inuse','reachable','push','getDiff','CampaignId','filterKey','idContact','campaigntype','dialAnswer','membername','scheduledat','countbusyretry','countcongestionretry','callback','callbackuniqueid','callbackat','recallme','xmd-phone','xmd-listid','xmd-dialurl','xmd-dialtimeout','xmd-dialoptions','xmd-dialid','xmd-contactid','xmd-cdrtype','xmd-callerid','xmd-agi','rtpaudioqos','rtpaudioqosbridged','rtpaudioqosjitter','rtpaudioqosrtt','rtpaudioqosrttbridged','rtpaudioqosloss','rtpaudioqoslossbridged','bridgepeer','bridgepvtcallid','getCallerIdRandom','\x5cw{0,','pow','replace','random','extractCalleridNumber','util','moment','../../../../config/logger','preview','env','XCALLY_IP_AGI','127.0.0.1','milliseconds','diff','seconds','loggerCatch','error','inspect','logger','loggerError','logger2','info','message','getCallerId','string','isEmpty','isUndefined','format','\x22%s\x22\x20<%s>','isActive','isNil','Queue'];(function(_0x4c03c3,_0x1c7bc1){var _0x5925e1=function(_0x7a2283){while(--_0x7a2283){_0x4c03c3['push'](_0x4c03c3['shift']());}};_0x5925e1(++_0x1c7bc1);}(_0xf922,0x18c));var _0x2f92=function(_0x3aab7f,_0x18d72c){_0x3aab7f=_0x3aab7f-0x0;var _0x3c2be6=_0xf922[_0x3aab7f];return _0x3c2be6;};'use strict';var util=require(_0x2f92('0x0'));var _=require('lodash');var moment=require(_0x2f92('0x1'));var logger=require(_0x2f92('0x2'))(_0x2f92('0x3'));var ipAgi=process[_0x2f92('0x4')][_0x2f92('0x5')]||_0x2f92('0x6');function getSeconds(_0xb6ff02,_0xe2f9a6){var _0xb76ba2=moment(_0xb6ff02)[_0x2f92('0x7')](0x0);var _0x5859dc=moment(_0xe2f9a6)[_0x2f92('0x7')](0x0);return _0xb76ba2[_0x2f92('0x8')](_0x5859dc,_0x2f92('0x9'));}exports[_0x2f92('0xa')]=function(_0x16e941){return function(_0xe35f46){logger[_0x2f92('0xb')](_0x16e941,util[_0x2f92('0xc')](_0xe35f46,{'showHidden':![],'depth':null}));};};exports[_0x2f92('0xd')]=function(_0x41fea4,_0x5075a0){logger['info'](_0x41fea4,util[_0x2f92('0xc')](_0x5075a0,{'showHidden':![],'depth':null}));};exports[_0x2f92('0xe')]=function(_0x4f8668,_0x74725e){logger[_0x2f92('0xb')](_0x4f8668,util[_0x2f92('0xc')](_0x74725e,{'showHidden':![],'depth':null}));};exports[_0x2f92('0xf')]=function(_0x1f29a7){return function(_0x166b90){logger[_0x2f92('0x10')](_0x1f29a7,util[_0x2f92('0xc')](_0x166b90,{'showHidden':![],'depth':null}));};};exports[_0x2f92('0x11')]=function(_0x41a26b,_0x3835bc,_0x14120b){return{'message':_0x41a26b,'unlock':_0x3835bc,'active':_0x14120b};};exports[_0x2f92('0x12')]=function(_0x37675a,_0x379213,_0x6cc798){if(!_['isUndefined'](_0x6cc798)&&_0x2f92('0x13')===typeof _0x6cc798&&!_[_0x2f92('0x14')](_0x6cc798)){if(!_[_0x2f92('0x15')](_0x379213)&&_0x2f92('0x13')===typeof _0x379213&&!_[_0x2f92('0x14')](_0x379213)){return util[_0x2f92('0x16')](_0x2f92('0x17'),_0x379213,_0x6cc798);}return util[_0x2f92('0x16')](_0x2f92('0x17'),_0x6cc798,_0x6cc798);}if(!_[_0x2f92('0x15')](_0x37675a)&&_0x2f92('0x13')===typeof _0x37675a&&!_[_0x2f92('0x14')](_0x37675a)){return _0x37675a;}return'\x22\x22\x20<>';};exports[_0x2f92('0x18')]=function(_0x5d927e){if(_[_0x2f92('0x19')](_0x5d927e)){return![];}return _0x5d927e;};exports['addVariables']=function(_0x5a10aa,_0x256b92,_0x175d2d,_0x13cb61,_0x340151,_0x23662c){var _0x207f1e={'XMD-QUEUE':_0x256b92[_0x2f92('0x1a')]?_0x256b92['Queue'][_0x2f92('0x1b')]:'','XMD-CALLERID':_0x13cb61,'XMD-CALLERID-PREVIEW':_0x23662c?util[_0x2f92('0x16')]('\x22%s\x22\x20<%s>',_0x23662c['calleridname'],_0x23662c[_0x2f92('0x1c')]):_0x13cb61,'XMD-DIALID':_0x340151,'XMD-CONTACTID':_0x256b92[_0x2f92('0x1d')],'XMD-CDRTYPE':_0x2f92('0x1e'),'CALLERID(all)':_0x13cb61,'XMD-VOICEQUEUEID':_0x256b92[_0x2f92('0x1f')],'XMD-DIALCHANNEL':_0x175d2d,'XMD-DIALTIMEOUT':_0x5a10aa[_0x2f92('0x20')]||0x1e,'XMD-DIALOPTIONS':util['format'](_0x2f92('0x21'),_0x5a10aa[_0x2f92('0x22')]?'g':'',_['isEmpty'](_0x5a10aa[_0x2f92('0x23')])?'':_0x2f92('0x24')),'XMD-DIALURL':_0x5a10aa['dialPreviewUrl']||'','XMD-AGI':_0x5a10aa[_0x2f92('0x25')]?util[_0x2f92('0x16')](_0x2f92('0x26'),ipAgi,_0x5a10aa[_0x2f92('0x25')]):'NONE','XMD-AGIAFTER':_0x5a10aa[_0x2f92('0x22')]?util['format']('\x22agi://%s/square,%s\x22',ipAgi,_0x5a10aa[_0x2f92('0x22')]):_0x2f92('0x27'),'XMD-ORIGINATECALLERIDNUM':_0x23662c?_0x23662c[_0x2f92('0x28')]:'','XMD-ORIGINATECALLERIDNAME':_0x23662c?_0x23662c[_0x2f92('0x29')]:'','XMD-DESTINATION':_0x2f92('0x2a'),'SIPADDHEADER':_0x2f92('0x2b')};if(!_['isEmpty'](_0x5a10aa['monitor_format'])){_0x207f1e[util[_0x2f92('0x16')]('%s',_0x2f92('0x2c'))]=_0x5a10aa['monitor_format'];_0x207f1e[util['format']('%s','_XCALLY_MIXMONITOR_UNIQUEID')]=_0x340151;}if(_0x256b92&&_0x256b92[_0x2f92('0x2d')]){for(var _0x7aa153 in _0x256b92['Contact']){if(_0x256b92[_0x2f92('0x2d')][_0x2f92('0x2e')](_0x7aa153)){if(!_['isNil'](_0x256b92[_0x2f92('0x2d')][_0x7aa153])&&_0x7aa153!=='id'&&_0x7aa153!==_0x2f92('0x2f')&&_0x7aa153!==_0x2f92('0x30')&&_0x7aa153!==_0x2f92('0x31')){_0x207f1e[util[_0x2f92('0x16')](_0x2f92('0x32'),'XMD-',_['toUpper'](_0x7aa153))]=_0x256b92[_0x2f92('0x2d')][_0x7aa153];}}}}return _0x207f1e;};exports[_0x2f92('0x33')]=function(_0x556ff7){var _0x18ad9d={};for(var _0xa86c8 in _0x556ff7){if(_0x556ff7[_0x2f92('0x2e')](_0xa86c8)){_0x18ad9d[util['format']('%s',_[_0x2f92('0x34')](_0xa86c8))]=_0x556ff7[_0xa86c8];}}return{'variables':_0x18ad9d};};exports[_0x2f92('0x35')]=function(_0x3807ce,_0x2f3486){if(!_['isNil'](_0x3807ce)){if(_0x3807ce[_0x2f92('0x2e')](_0x2f92('0x36'))){if(_0x3807ce['originated']>0x0){_0x3807ce['originated']-=0x1;}else{logger[_0x2f92('0xb')](_0x2f92('0x37'),_0x2f3486);}}}else{logger[_0x2f92('0xb')]('[updateOriginated]\x20is\x20null\x20or\x20undefined',_0x2f3486);}};exports['logBlacklist']=function(_0x21bf19){var _0xec03ea=moment()[_0x2f92('0x16')](_0x2f92('0x38'));_0x21bf19[_0x2f92('0x39')]=0xd;_0x21bf19[_0x2f92('0x3a')]=_0x2f92('0x3b');_0x21bf19[_0x2f92('0x3c')]=_0xec03ea;_0x21bf19[_0x2f92('0x3d')]=_0xec03ea;_0x21bf19[_0x2f92('0x3e')]=_0xec03ea;};exports[_0x2f92('0x3f')]=function(_0x27b28c,_0x50740c,_0x1caaa6){var _0x3f8154=moment()['format'](_0x2f92('0x38'));_0x27b28c['state']=_0x50740c;_0x27b28c['statedesc']=_0x1caaa6;_0x27b28c[_0x2f92('0x3d')]=_0x3f8154;_0x27b28c[_0x2f92('0x40')]=getSeconds(_0x27b28c[_0x2f92('0x3d')],_0x27b28c[_0x2f92('0x3c')]);};exports[_0x2f92('0x41')]=function(_0x24f01d,_0xa3d52a,_0x182002){_0x24f01d['membername']=_0xa3d52a;_0x24f01d[_0x2f92('0x42')]=_0x182002;};exports[_0x2f92('0x43')]=function(_0xf5ff90,_0x39dd10,_0x3ebda3){var _0x133e0c=moment()[_0x2f92('0x16')]('YYYY-MM-DD\x20HH:mm:ss');_0xf5ff90[_0x2f92('0x39')]=_0x39dd10;_0xf5ff90[_0x2f92('0x3a')]=_0x3ebda3;_0xf5ff90[_0x2f92('0x3d')]=_0xf5ff90['responsetime']?_0xf5ff90[_0x2f92('0x3d')]:_0x133e0c;_0xf5ff90[_0x2f92('0x3e')]=_0xf5ff90[_0x2f92('0x3e')]?_0xf5ff90[_0x2f92('0x3e')]:_0x133e0c;_0xf5ff90['ringtime']=getSeconds(_0xf5ff90[_0x2f92('0x3d')]||0x0,_0xf5ff90[_0x2f92('0x3c')]||0x0);_0xf5ff90[_0x2f92('0x44')]=_0xf5ff90[_0x2f92('0x45')]?getSeconds(_0xf5ff90[_0x2f92('0x3e')],_0xf5ff90[_0x2f92('0x45')]):0x0;};exports[_0x2f92('0x46')]=function(_0x40c406){return _0x40c406===_0x2f92('0x47');};exports[_0x2f92('0x48')]=function(_0x2274f5,_0x28bbdd,_0x47dc8a,_0x32ef5c,_0x9481f7){var _0x3abf04=_0x32ef5c?_0x2f92('0x49'):_0x2274f5[_0x2f92('0x4a')];_0x3abf04=_0x9481f7?_0x2f92('0x4b'):_0x3abf04;return{'actionid':_0x2274f5[_0x2f92('0x4c')],'action':_0x2f92('0x4d'),'channel':_0x2274f5[_0x2f92('0x4e')],'callerid':util[_0x2f92('0x16')]('\x22%s\x22\x20<%s>',_0x3abf04,_0x2274f5[_0x2f92('0x1c')]),'Exten':_0x2f92('0x2a'),'Context':_0x2f92('0x4f'),'Priority':'1','variable':_0x47dc8a,'timeout':(_0x28bbdd['timeout']||0x1e)*0x3e8,'async':!![],'channelid':_0x2274f5[_0x2f92('0x4c')]};};exports[_0x2f92('0x50')]=function(_0xa12ef0){return _0xa12ef0['countbusyretry']+_0xa12ef0['countcongestionretry']+_0xa12ef0[_0x2f92('0x51')]+_0xa12ef0['countagentrejectretry']+_0xa12ef0[_0x2f92('0x52')];};exports['cloneAction']=function(_0x33fcf7){var _0x5eb083=_[_0x2f92('0x53')](_0x33fcf7);_0x5eb083['state']=0xf;_0x5eb083[_0x2f92('0x3a')]=_0x2f92('0x54');return _0x5eb083;};exports['scheduledAt']=function(_0x3b693e,_0x281407,_0x575bbb){var _0x5d8b8f={};_0x5d8b8f[_0x281407]=_0x3b693e[_0x281407];_0x5d8b8f['active']=![];_0x5d8b8f['scheduledat']=moment()['add'](_0x575bbb,_0x2f92('0x55'))[_0x2f92('0x16')](_0x2f92('0x38'));_0x5d8b8f[_0x2f92('0x1d')]=_0x3b693e['ContactId'];_0x5d8b8f[_0x2f92('0x56')]=_0x3b693e[_0x2f92('0x56')];_0x5d8b8f[_0x2f92('0x1f')]=_0x3b693e[_0x2f92('0x1f')]||undefined;return _0x5d8b8f;};exports[_0x2f92('0x57')]=function(_0x5aaba3,_0x27f15c){if(!_[_0x2f92('0x19')](_0x5aaba3)){if(_0x5aaba3['pTalking']>0x0){_0x5aaba3[_0x2f92('0x58')]-=0x1;}else{logger[_0x2f92('0xb')](_0x27f15c,'[decrementTalkink]\x20object\x20talking\x20is\x20negative');}}else{logger[_0x2f92('0xb')](_0x27f15c,_0x2f92('0x59'));}};exports[_0x2f92('0x5a')]=function(_0x7b52d0){if(_0x7b52d0<=0x0){return!![];}return![];};exports[_0x2f92('0x5b')]=function(_0x46f280,_0x5549aa,_0x7f0133){_0x46f280[_0x2f92('0x5c')]=_0x5549aa;_0x46f280[_0x2f92('0x1b')]=_0x46f280[_0x2f92('0x5d')];_0x46f280[_0x2f92('0x5e')]=_0x46f280[_0x2f92('0x4e')];_0x46f280['motionChannel']=_0x2f92('0x5f');if(_0x7f0133){_0x46f280[_0x2f92('0x60')]=_0x7f0133[_0x2f92('0x60')];}return _0x46f280;};exports[_0x2f92('0x61')]=function(_0x350545){var _0x5a89ed={};_0x5a89ed[_0x2f92('0x5d')]=_0x350545['queue'];_0x5a89ed['interface']=_0x350545[_0x2f92('0x4e')];_0x5a89ed[_0x2f92('0x4c')]=_0x350545[_0x2f92('0x4c')];return _0x5a89ed;};exports[_0x2f92('0x62')]=function(_0x5612e1){var _0x5591e5=[];for(var _0x32b640 in _0x5612e1){if(_0x5612e1[_0x2f92('0x2e')](_0x32b640)){if(!_[_0x2f92('0x19')](_0x5612e1[_0x32b640])&&_0x5612e1[_0x32b640][_0x2f92('0x39')]===_0x2f92('0x63')&&_0x5612e1[_0x32b640]['status']===_0x2f92('0x64')){_0x5591e5[_0x2f92('0x65')](_0x5612e1[_0x32b640]['id']);}}}return _0x5591e5;};exports[_0x2f92('0x66')]=function(_0x2dcf65){var _0x38c7a7=moment()[_0x2f92('0x7')](0x0);var _0x18cca6=moment(_0x2dcf65)[_0x2f92('0x7')](0x0);return _0x38c7a7['diff'](_0x18cca6,_0x2f92('0x9'));};exports['createBody']=function(_0x115fef){return{'active':![],'recallme':![],'UserId':null,'ContactId':_0x115fef[_0x2f92('0x1d')],'ListId':_0x115fef[_0x2f92('0x56')],'VoiceQueueId':_0x115fef[_0x2f92('0x1f')]||undefined,'CampaignId':_0x115fef[_0x2f92('0x67')]||undefined};};exports[_0x2f92('0x68')]=function(_0x4d602e){if(_0x4d602e===_0x2f92('0x4c')||_0x4d602e===_0x2f92('0x69')||_0x4d602e===_0x2f92('0x5d')||_0x4d602e==='type'||_0x4d602e===_0x2f92('0x6a')||_0x4d602e===_0x2f92('0x6b')||_0x4d602e===_0x2f92('0x6c')||_0x4d602e==='channelAgent'||_0x4d602e===_0x2f92('0x4a')||_0x4d602e==='active'||_0x4d602e==='calleridnum'||_0x4d602e===_0x2f92('0x6d')||_0x4d602e===_0x2f92('0x6e')||_0x4d602e===_0x2f92('0x6f')||_0x4d602e===_0x2f92('0x51')||_0x4d602e==='countglobal'||_0x4d602e===_0x2f92('0x70')||_0x4d602e===_0x2f92('0x71')||_0x4d602e===_0x2f92('0x72')||_0x4d602e===_0x2f92('0x73')||_0x4d602e===_0x2f92('0x1d')||_0x4d602e===_0x2f92('0x56')||_0x4d602e===_0x2f92('0x42')||_0x4d602e==='VoiceQueueId'||_0x4d602e==='sipcallid'||_0x4d602e==='xmd-voicequeueid'||_0x4d602e==='xmd-queue'||_0x4d602e===_0x2f92('0x74')||_0x4d602e===_0x2f92('0x75')||_0x4d602e===_0x2f92('0x76')||_0x4d602e===_0x2f92('0x77')||_0x4d602e===_0x2f92('0x78')||_0x4d602e===_0x2f92('0x79')||_0x4d602e==='xmd-dialchannel'||_0x4d602e===_0x2f92('0x7a')||_0x4d602e===_0x2f92('0x7b')||_0x4d602e===_0x2f92('0x7c')||_0x4d602e==='xmd-agiafter'||_0x4d602e===_0x2f92('0x7d')||_0x4d602e===_0x2f92('0x7e')||_0x4d602e===_0x2f92('0x7f')||_0x4d602e===_0x2f92('0x80')||_0x4d602e==='rtpaudioqosjitterbridged'||_0x4d602e==='rtpaudioqosloss'||_0x4d602e==='rtpaudioqoslossbridged'||_0x4d602e===_0x2f92('0x81')||_0x4d602e===_0x2f92('0x82')||_0x4d602e==='rtpaudioqos'||_0x4d602e===_0x2f92('0x7f')||_0x4d602e===_0x2f92('0x80')||_0x4d602e==='rtpaudioqosjitterbridged'||_0x4d602e===_0x2f92('0x83')||_0x4d602e===_0x2f92('0x84')||_0x4d602e==='rtpaudioqosrtt'||_0x4d602e===_0x2f92('0x82')||_0x4d602e===_0x2f92('0x85')||_0x4d602e===_0x2f92('0x86')||_0x4d602e===_0x2f92('0x39')||_0x4d602e==='statedesc'){return![];}return!![];};exports[_0x2f92('0x87')]=function(_0x59beac,_0x3e147a){var _0x159cad,_0xe8a9bf,_0x57f837;if(_0x3e147a<=0x0){_0x3e147a=0x1;}_0x159cad=new RegExp(_0x2f92('0x88')+_0x3e147a+'}$');_0xe8a9bf=Math[_0x2f92('0x89')](0xa,_0x3e147a-0x1);_0x57f837=Math[_0x2f92('0x89')](0xa,_0x3e147a)-0x1;return util[_0x2f92('0x16')]('%s',_[_0x2f92('0x8a')](_0x59beac,_0x159cad,_[_0x2f92('0x8b')](_0xe8a9bf,_0x57f837)));};exports['extractCalleridName']=function(_0x288a3f){var _0x2deab5=_0x288a3f['match'](/"(.*?)"/);return _0x2deab5?_0x2deab5[0x1]:_0x288a3f;};exports[_0x2f92('0x8c')]=function(_0x8620e9){var _0x1feb21=_0x8620e9['match'](/<(.*?)>/);return _0x1feb21?_0x1feb21[0x1]:_0x8620e9;};
\ No newline at end of file
+var _0x1340=['toLowerCase','util','lodash','moment','../../../../config/logger','env','XCALLY_IP_AGI','127.0.0.1','../../dialer/utils','error','logger','info','inspect','getCallerId','isUndefined','isEmpty','format','\x22\x22\x20<>','isActive','isNil','addVariables','Queue','name','\x22%s\x22\x20<%s>','calleridname','calleridnum','ContactId','dialer','VoiceQueueId','dialOriginateTimeout','\x22rtTxX%s%s\x22','dialQueueProject2','U(xcally-mixmonitor-context)','dialPreviewUrl','dialQueueProject','\x22agi://%s/square,%s\x22','NONE','originatecalleridnum','originatecalleridname','xcally-motion-preview','Call-Type:\x20PREVIEW','_XCALLY_MIXMONITOR_FORMAT','monitor_format','_XCALLY_MIXMONITOR_UNIQUEID','toLowerVariables','toLower','updateOriginated','hasOwnProperty','originated','[updateOriginated]\x20is\x20null\x20or\x20undefined','logBlacklist','YYYY-MM-DD\x20HH:mm:ss','state','statedesc','Blacklist','starttime','responsetime','logAgent','ringtime','getSeconds','logLookAgent','membername','UserId','logCustomer','endtime','answertime','isFailure','variablesAction','RECALL','uniqueid','timeout','totalGlobal','countbusyretry','countcongestionretry','countnoanswerretry','countnosuchnumberretry','cloneAction','clone','Global','active','scheduledat','add','ListId','decrementTalkink','pTalking','[decrementTalkink]\x20object\x20talking\x20is\x20negative','[decrementTalkink]\x20is\x20null\x20or\x20undefined','IsNotLoggedIn','lastevent','queue','interface','motionChannel','voice','mandatoryDisposition','buildObj','buildAcw','push','milliseconds','seconds','createBody','CampaignId','filterKey','idContact','type','campaigntype','dialAnswer','callbackat','recallme','sipcallid','xmd-voicequeueid','xmd-queue','xmd-phone','xmd-listid','xmd-dialurl','xmd-dialtimeout','xmd-dialid','xmd-dialchannel','xmd-contactid','xmd-callerid','xmd-agiafter','xmd-agi','rtpaudioqosjitter','rtpaudioqosjitterbridged','rtpaudioqoslossbridged','rtpaudioqosrttbridged','rtpaudioqosbridged','rtpaudioqosrtt','bridgepvtcallid','getCallerIdRandom','\x5cw{0,','pow','replace','random','extractCalleridName','match','extractCalleridNumber','noanswer','variables','keys','forEach'];(function(_0x24a4af,_0x2593af){var _0x1b59d8=function(_0x4d16c4){while(--_0x4d16c4){_0x24a4af['push'](_0x24a4af['shift']());}};_0x1b59d8(++_0x2593af);}(_0x1340,0x119));var _0x0134=function(_0x6f9e6c,_0x5ef730){_0x6f9e6c=_0x6f9e6c-0x0;var _0x20a1a0=_0x1340[_0x6f9e6c];return _0x20a1a0;};'use strict';var util=require(_0x0134('0x0'));var _=require(_0x0134('0x1'));var moment=require(_0x0134('0x2'));var logger=require(_0x0134('0x3'))('preview');var ipAgi=process[_0x0134('0x4')][_0x0134('0x5')]||_0x0134('0x6');var utils=require(_0x0134('0x7'));exports['loggerCatch']=function(_0x22f415){return function(_0x442b00){logger[_0x0134('0x8')](_0x22f415,util['inspect'](_0x442b00,{'showHidden':![],'depth':null}));};};exports[_0x0134('0x9')]=function(_0x4b4719,_0x398813){logger[_0x0134('0xa')](_0x4b4719,util['inspect'](_0x398813,{'showHidden':![],'depth':null}));};exports['loggerError']=function(_0x37a128,_0x1c1f36){logger[_0x0134('0x8')](_0x37a128,util[_0x0134('0xb')](_0x1c1f36,{'showHidden':![],'depth':null}));};exports['logger2']=function(_0x4463f5){return function(_0x3dfc42){logger['info'](_0x4463f5,util[_0x0134('0xb')](_0x3dfc42,{'showHidden':![],'depth':null}));};};exports['message']=function(_0x556a8d,_0x15316f,_0x13ff73){return{'message':_0x556a8d,'unlock':_0x15316f,'active':_0x13ff73};};exports[_0x0134('0xc')]=function(_0x16eb0e,_0xe2efd3,_0x40b845){if(!_[_0x0134('0xd')](_0x40b845)&&'string'===typeof _0x40b845&&!_['isEmpty'](_0x40b845)){if(!_[_0x0134('0xd')](_0xe2efd3)&&'string'===typeof _0xe2efd3&&!_[_0x0134('0xe')](_0xe2efd3)){return util[_0x0134('0xf')]('\x22%s\x22\x20<%s>',_0xe2efd3,_0x40b845);}return util['format']('\x22%s\x22\x20<%s>',_0x40b845,_0x40b845);}if(!_[_0x0134('0xd')](_0x16eb0e)&&'string'===typeof _0x16eb0e&&!_[_0x0134('0xe')](_0x16eb0e)){return _0x16eb0e;}return _0x0134('0x10');};exports[_0x0134('0x11')]=function(_0x3ae22c){if(_[_0x0134('0x12')](_0x3ae22c)){return![];}return _0x3ae22c;};exports[_0x0134('0x13')]=function(_0x433099,_0x415088,_0x46f989,_0x10bdbe,_0x961bea,_0x419ecf){var _0x1c33aa={'XMD-QUEUE':_0x415088[_0x0134('0x14')]?_0x415088[_0x0134('0x14')][_0x0134('0x15')]:'','XMD-CALLERID':_0x10bdbe,'XMD-CALLERID-PREVIEW':_0x419ecf?util[_0x0134('0xf')](_0x0134('0x16'),_0x419ecf[_0x0134('0x17')],_0x419ecf[_0x0134('0x18')]):_0x10bdbe,'XMD-DIALID':_0x961bea,'XMD-CONTACTID':_0x415088[_0x0134('0x19')],'XMD-CDRTYPE':_0x0134('0x1a'),'CALLERID(all)':_0x10bdbe,'XMD-VOICEQUEUEID':_0x415088[_0x0134('0x1b')],'XMD-DIALCHANNEL':_0x46f989,'XMD-DIALTIMEOUT':_0x433099[_0x0134('0x1c')]||0x1e,'XMD-DIALOPTIONS':util[_0x0134('0xf')](_0x0134('0x1d'),_0x433099[_0x0134('0x1e')]?'g':'',_[_0x0134('0xe')](_0x433099['monitor_format'])?'':_0x0134('0x1f')),'XMD-DIALURL':_0x433099[_0x0134('0x20')]||'','XMD-AGI':_0x433099[_0x0134('0x21')]?util['format'](_0x0134('0x22'),ipAgi,_0x433099[_0x0134('0x21')]):_0x0134('0x23'),'XMD-AGIAFTER':_0x433099[_0x0134('0x1e')]?util[_0x0134('0xf')]('\x22agi://%s/square,%s\x22',ipAgi,_0x433099[_0x0134('0x1e')]):_0x0134('0x23'),'XMD-ORIGINATECALLERIDNUM':_0x419ecf?_0x419ecf[_0x0134('0x24')]:'','XMD-ORIGINATECALLERIDNAME':_0x419ecf?_0x419ecf[_0x0134('0x25')]:'','XMD-DESTINATION':_0x0134('0x26'),'SIPADDHEADER':_0x0134('0x27')};if(!_['isEmpty'](_0x433099['monitor_format'])){_0x1c33aa[util[_0x0134('0xf')]('%s',_0x0134('0x28'))]=_0x433099[_0x0134('0x29')];_0x1c33aa[util['format']('%s',_0x0134('0x2a'))]=_0x961bea;}return _0x1c33aa;};exports[_0x0134('0x2b')]=function(_0x1c89a6){var _0x4fdf94={};for(var _0x437fdf in _0x1c89a6){if(_0x1c89a6['hasOwnProperty'](_0x437fdf)){_0x4fdf94[util[_0x0134('0xf')]('%s',_[_0x0134('0x2c')](_0x437fdf))]=_0x1c89a6[_0x437fdf];}}return{'variables':_0x4fdf94};};exports[_0x0134('0x2d')]=function(_0xa3990b,_0x363ae6){if(!_[_0x0134('0x12')](_0xa3990b)){if(_0xa3990b[_0x0134('0x2e')](_0x0134('0x2f'))){if(_0xa3990b[_0x0134('0x2f')]>0x0){_0xa3990b[_0x0134('0x2f')]-=0x1;}else{logger[_0x0134('0x8')]('[updateOriginated]\x20object\x20originated\x20is\x20negative',_0x363ae6);}}}else{logger[_0x0134('0x8')](_0x0134('0x30'),_0x363ae6);}};exports[_0x0134('0x31')]=function(_0x5e576d){var _0x52fd61=moment()['format'](_0x0134('0x32'));_0x5e576d[_0x0134('0x33')]=0xd;_0x5e576d[_0x0134('0x34')]=_0x0134('0x35');_0x5e576d[_0x0134('0x36')]=_0x52fd61;_0x5e576d[_0x0134('0x37')]=_0x52fd61;_0x5e576d['endtime']=_0x52fd61;};exports[_0x0134('0x38')]=function(_0x410916,_0x346e9e,_0x79a62){var _0x555716=moment()[_0x0134('0xf')](_0x0134('0x32'));_0x410916[_0x0134('0x33')]=_0x346e9e;_0x410916['statedesc']=_0x79a62;_0x410916[_0x0134('0x37')]=_0x555716;_0x410916[_0x0134('0x39')]=utils[_0x0134('0x3a')](_0x410916[_0x0134('0x37')],_0x410916[_0x0134('0x36')]);};exports[_0x0134('0x3b')]=function(_0x173b05,_0x2e489b,_0x2a8642){_0x173b05[_0x0134('0x3c')]=_0x2e489b;_0x173b05[_0x0134('0x3d')]=_0x2a8642;};exports[_0x0134('0x3e')]=function(_0x1a86ef,_0x218f50,_0x2f3541){var _0x2caf2f=moment()[_0x0134('0xf')](_0x0134('0x32'));_0x1a86ef[_0x0134('0x33')]=_0x218f50;_0x1a86ef['statedesc']=_0x2f3541;_0x1a86ef[_0x0134('0x37')]=_0x1a86ef[_0x0134('0x37')]?_0x1a86ef[_0x0134('0x37')]:_0x2caf2f;_0x1a86ef['endtime']=_0x1a86ef['endtime']?_0x1a86ef[_0x0134('0x3f')]:_0x2caf2f;_0x1a86ef['ringtime']=utils[_0x0134('0x3a')](_0x1a86ef[_0x0134('0x37')]||0x0,_0x1a86ef[_0x0134('0x36')]||0x0);_0x1a86ef['talktime']=_0x1a86ef[_0x0134('0x40')]?utils[_0x0134('0x3a')](_0x1a86ef[_0x0134('0x3f')],_0x1a86ef[_0x0134('0x40')]):0x0;};exports[_0x0134('0x41')]=function(_0x558619){return _0x558619==='Failure';};exports[_0x0134('0x42')]=function(_0x88594b,_0x3da708,_0x5a92ed,_0x5e7f63,_0x3b2b4c){var _0x26adbe=_0x5e7f63?_0x0134('0x43'):_0x88594b[_0x0134('0x17')];_0x26adbe=_0x3b2b4c?'BOOKED':_0x26adbe;return{'actionid':_0x88594b[_0x0134('0x44')],'action':'originate','channel':_0x88594b['channelAgent'],'callerid':util[_0x0134('0xf')](_0x0134('0x16'),_0x26adbe,_0x88594b[_0x0134('0x18')]),'Exten':_0x0134('0x26'),'Context':'from-sip','Priority':'1','variable':_0x5a92ed,'timeout':(_0x3da708[_0x0134('0x45')]||0x1e)*0x3e8,'async':!![],'channelid':_0x88594b[_0x0134('0x44')]};};exports[_0x0134('0x46')]=function(_0x295449){return _0x295449[_0x0134('0x47')]+_0x295449[_0x0134('0x48')]+_0x295449[_0x0134('0x49')]+_0x295449['countagentrejectretry']+_0x295449[_0x0134('0x4a')];};exports[_0x0134('0x4b')]=function(_0x3b5ce8){var _0x3b54bc=_[_0x0134('0x4c')](_0x3b5ce8);_0x3b54bc[_0x0134('0x33')]=0xf;_0x3b54bc[_0x0134('0x34')]=_0x0134('0x4d');return _0x3b54bc;};exports['scheduledAt']=function(_0x599095,_0x1a2fb1,_0x5ace57){var _0x2b89e8={};_0x2b89e8[_0x1a2fb1]=_0x599095[_0x1a2fb1];_0x2b89e8[_0x0134('0x4e')]=![];_0x2b89e8[_0x0134('0x4f')]=moment()[_0x0134('0x50')](_0x5ace57,'minutes')['format'](_0x0134('0x32'));_0x2b89e8['ContactId']=_0x599095[_0x0134('0x19')];_0x2b89e8[_0x0134('0x51')]=_0x599095['ListId'];_0x2b89e8['VoiceQueueId']=_0x599095[_0x0134('0x1b')]||undefined;return _0x2b89e8;};exports[_0x0134('0x52')]=function(_0x54847a,_0x4fb6f3){if(!_[_0x0134('0x12')](_0x54847a)){if(_0x54847a[_0x0134('0x53')]>0x0){_0x54847a[_0x0134('0x53')]-=0x1;}else{logger[_0x0134('0x8')](_0x4fb6f3,_0x0134('0x54'));}}else{logger['error'](_0x4fb6f3,_0x0134('0x55'));}};exports[_0x0134('0x56')]=function(_0x58b83c){if(_0x58b83c<=0x0){return!![];}return![];};function buildObj(_0x4deebe,_0x5e5bda,_0x2bf9b8){_0x4deebe[_0x0134('0x57')]=_0x5e5bda;_0x4deebe[_0x0134('0x15')]=_0x4deebe[_0x0134('0x58')];_0x4deebe[_0x0134('0x59')]=_0x4deebe['channelAgent'];_0x4deebe[_0x0134('0x5a')]=_0x0134('0x5b');if(_0x2bf9b8){_0x4deebe[_0x0134('0x5c')]=_0x2bf9b8[_0x0134('0x5c')];}return _0x4deebe;}exports[_0x0134('0x5d')]=buildObj;exports[_0x0134('0x5e')]=function(_0x409c8e){var _0xadbcba={};_0xadbcba[_0x0134('0x58')]=_0x409c8e[_0x0134('0x58')];_0xadbcba['interface']=_0x409c8e['channelAgent'];_0xadbcba[_0x0134('0x44')]=_0x409c8e['uniqueid'];return _0xadbcba;};exports['agentReadyId']=function(_0xdf82f7){var _0x614688=[];for(var _0x13a17a in _0xdf82f7){if(_0xdf82f7['hasOwnProperty'](_0x13a17a)){if(!_[_0x0134('0x12')](_0xdf82f7[_0x13a17a])&&_0xdf82f7[_0x13a17a][_0x0134('0x33')]==='not_inuse'&&_0xdf82f7[_0x13a17a]['status']==='reachable'){_0x614688[_0x0134('0x5f')](_0xdf82f7[_0x13a17a]['id']);}}}return _0x614688;};exports['getDiff']=function(_0x55055d){var _0x5aefe1=moment()[_0x0134('0x60')](0x0);var _0x50ed44=moment(_0x55055d)[_0x0134('0x60')](0x0);return _0x5aefe1['diff'](_0x50ed44,_0x0134('0x61'));};exports[_0x0134('0x62')]=function(_0x513e95){return{'active':![],'recallme':![],'UserId':null,'ContactId':_0x513e95[_0x0134('0x19')],'ListId':_0x513e95[_0x0134('0x51')],'VoiceQueueId':_0x513e95[_0x0134('0x1b')]||undefined,'CampaignId':_0x513e95[_0x0134('0x63')]||undefined};};exports[_0x0134('0x64')]=function(_0x1ac7f1){if(_0x1ac7f1==='uniqueid'||_0x1ac7f1===_0x0134('0x65')||_0x1ac7f1===_0x0134('0x58')||_0x1ac7f1===_0x0134('0x66')||_0x1ac7f1===_0x0134('0x67')||_0x1ac7f1===_0x0134('0x68')||_0x1ac7f1===_0x0134('0x3c')||_0x1ac7f1==='channelAgent'||_0x1ac7f1==='calleridname'||_0x1ac7f1===_0x0134('0x4e')||_0x1ac7f1===_0x0134('0x18')||_0x1ac7f1===_0x0134('0x4f')||_0x1ac7f1==='countbusyretry'||_0x1ac7f1==='countcongestionretry'||_0x1ac7f1===_0x0134('0x49')||_0x1ac7f1==='countglobal'||_0x1ac7f1==='callback'||_0x1ac7f1==='callbackuniqueid'||_0x1ac7f1===_0x0134('0x69')||_0x1ac7f1===_0x0134('0x6a')||_0x1ac7f1==='ContactId'||_0x1ac7f1===_0x0134('0x51')||_0x1ac7f1==='UserId'||_0x1ac7f1===_0x0134('0x1b')||_0x1ac7f1===_0x0134('0x6b')||_0x1ac7f1===_0x0134('0x6c')||_0x1ac7f1===_0x0134('0x6d')||_0x1ac7f1===_0x0134('0x6e')||_0x1ac7f1===_0x0134('0x6f')||_0x1ac7f1===_0x0134('0x70')||_0x1ac7f1===_0x0134('0x71')||_0x1ac7f1==='xmd-dialoptions'||_0x1ac7f1===_0x0134('0x72')||_0x1ac7f1===_0x0134('0x73')||_0x1ac7f1===_0x0134('0x74')||_0x1ac7f1==='xmd-cdrtype'||_0x1ac7f1===_0x0134('0x75')||_0x1ac7f1===_0x0134('0x76')||_0x1ac7f1===_0x0134('0x77')||_0x1ac7f1==='rtpaudioqos'||_0x1ac7f1==='rtpaudioqosbridged'||_0x1ac7f1===_0x0134('0x78')||_0x1ac7f1===_0x0134('0x79')||_0x1ac7f1==='rtpaudioqosloss'||_0x1ac7f1===_0x0134('0x7a')||_0x1ac7f1==='rtpaudioqosrtt'||_0x1ac7f1===_0x0134('0x7b')||_0x1ac7f1==='rtpaudioqos'||_0x1ac7f1===_0x0134('0x7c')||_0x1ac7f1==='rtpaudioqosjitter'||_0x1ac7f1===_0x0134('0x79')||_0x1ac7f1==='rtpaudioqosloss'||_0x1ac7f1===_0x0134('0x7a')||_0x1ac7f1===_0x0134('0x7d')||_0x1ac7f1==='rtpaudioqosrttbridged'||_0x1ac7f1==='bridgepeer'||_0x1ac7f1===_0x0134('0x7e')||_0x1ac7f1==='state'||_0x1ac7f1===_0x0134('0x34')){return![];}return!![];};exports[_0x0134('0x7f')]=function(_0x7133ac,_0x14ebd2){var _0x78fd9e,_0x2b4b0d,_0x5ea8a4;if(_0x14ebd2<=0x0){_0x14ebd2=0x1;}_0x78fd9e=new RegExp(_0x0134('0x80')+_0x14ebd2+'}$');_0x2b4b0d=Math['pow'](0xa,_0x14ebd2-0x1);_0x5ea8a4=Math[_0x0134('0x81')](0xa,_0x14ebd2)-0x1;return util[_0x0134('0xf')]('%s',_[_0x0134('0x82')](_0x7133ac,_0x78fd9e,_[_0x0134('0x83')](_0x2b4b0d,_0x5ea8a4)));};exports[_0x0134('0x84')]=function(_0x4ce127){var _0x4094d8=_0x4ce127[_0x0134('0x85')](/"(.*?)"/);return _0x4094d8?_0x4094d8[0x1]:_0x4ce127;};exports[_0x0134('0x86')]=function(_0xaee420){var _0x508a2c=_0xaee420[_0x0134('0x85')](/<(.*?)>/);return _0x508a2c?_0x508a2c[0x1]:_0xaee420;};function buildNoAnswerEventPayload(_0x311b53,_0x3c25d0){var _0x54f24e=buildObj(_0x311b53,_0x0134('0x87'));if(!_[_0x0134('0xe')](_0x3c25d0[_0x0134('0x88')])){Object[_0x0134('0x89')](_0x3c25d0[_0x0134('0x88')])[_0x0134('0x8a')](function(_0x2748b3){_0x54f24e[_0x2748b3[_0x0134('0x8b')]()]=_0x3c25d0['variables'][_0x2748b3];});}return _0x54f24e;}exports['buildNoAnswerEventPayload']=buildNoAnswerEventPayload;
\ No newline at end of file