1 var _0x1368=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x62\x6C\x75\x65\x62\x69\x72\x64","\x6D\x6F\x6D\x65\x6E\x74","\x75\x74\x69\x6C","\x6C\x6F\x64\x61\x73\x68","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x65\x78\x65\x63","\x63\x68\x69\x6C\x64\x2D\x70\x72\x6F\x63\x65\x73\x73\x2D\x70\x72\x6F\x6D\x69\x73\x65","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x46\x61\x78\x52\x6F\x6F\x6D","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x46\x61\x78\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74","\x43\x6F\x6E\x74\x61\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x5B\x46\x61\x78\x5D\x20\x4E\x65\x77\x20\x6D\x65\x73\x73\x61\x67\x65\x20\x66\x72\x6F\x6D\x20\x25\x73","\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x75\x6D","\x66\x6F\x72\x6D\x61\x74","\x6C\x6F\x67","\x63\x6C\x6F\x6E\x65","\x5B\x46\x61\x78\x5D\x20\x45\x72\x72\x6F\x72\x20\x72\x65\x63\x65\x69\x76\x69\x6E\x67\x20\x6D\x65\x73\x73\x61\x67\x65\x3A","\x65\x72\x72\x6F\x72","\x5B\x46\x61\x78\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x3A","\x6D\x65\x73\x73\x61\x67\x65","\x5B\x46\x61\x78\x5D\x20\x53\x74\x61\x63\x6B\x3A","\x73\x74\x61\x63\x6B","\x63\x61\x74\x63\x68","\x70\x61\x67\x65\x73\x74\x72\x61\x6E\x73\x66\x65\x72\x72\x65\x64","\x5B\x46\x61\x78\x5D\x20\x46\x69\x6C\x65\x20\x63\x6F\x72\x72\x65\x63\x74\x6C\x79\x20\x63\x6F\x6E\x76\x65\x72\x74\x65\x64","\x69\x6E\x69\x74\x46\x61\x78\x52\x6F\x75\x74\x69\x6E\x67","\x73\x65\x6E\x64","\x74\x68\x65\x6E","\x5B\x46\x61\x78\x5D\x20\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x20\x6E\x6F\x74\x20\x63\x72\x65\x61\x74\x65\x64","\x5B\x46\x61\x78\x5D\x20\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x3A","\x69\x64","\x74\x69\x66\x66\x32\x70\x64\x66\x20\x2D\x6F\x20","\x20","\x66\x69\x6C\x65\x6E\x61\x6D\x65","\x5B\x46\x61\x78\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x20\x6E\x6F\x74\x20\x63\x72\x65\x61\x74\x65\x64","\x6E\x61\x6D\x65","\x70\x61\x72\x73\x65","\x2E\x70\x64\x66","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72","\x66\x69\x6C\x65\x73","\x66\x61\x78","\x69\x6E\x62\x6F\x75\x6E\x64","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64","\x6A\x6F\x69\x6E","\x63\x72\x65\x61\x74\x65","\x5B\x46\x61\x78\x5D\x20\x54\x72\x61\x6E\x73\x66\x65\x72\x72\x65\x64\x20\x66\x69\x6C\x65\x20\x69\x73\x20\x65\x6D\x70\x74\x79\x20\x28\x70\x61\x67\x65\x73\x74\x72\x61\x6E\x73\x66\x65\x72\x72\x65\x64\x3A\x25\x73\x29","\x5B\x46\x61\x78\x5D\x20\x52\x6F\x6F\x6D\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64\x2F\x63\x72\x65\x61\x74\x65\x64","\x5B\x46\x61\x78\x5D\x20\x52\x6F\x6F\x6D\x3A","\x46\x61\x78\x52\x6F\x6F\x6D\x49\x64","\x73\x74\x61\x74\x75\x73","\x52\x45\x43\x45\x49\x56\x45\x44","\x66\x72\x6F\x6D","\x74\x6F","\x6C\x6F\x63\x61\x6C\x73\x74\x61\x74\x69\x6F\x6E\x69\x64","","\x54\x72\x61\x6E\x73\x66\x65\x72\x72\x65\x64\x20\x66\x69\x6C\x65\x20\x69\x73\x20\x65\x6D\x70\x74\x79","\x6C\x65\x6E\x67\x74\x68","\x66\x69\x72\x73\x74","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x4F\x50\x45\x4E","\x73\x79\x73\x74\x65\x6D","\x66\x61\x78\x49\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x4E\x45\x57","\x43\x4C\x4F\x53\x45\x44","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x44\x45\x53\x43","\x66\x69\x6E\x64\x41\x6C\x6C","\x73\x70\x72\x65\x61\x64","\x5B\x46\x61\x78\x5D\x20\x41\x63\x63\x6F\x75\x6E\x74\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x5B\x46\x61\x78\x5D\x20\x41\x63\x63\x6F\x75\x6E\x74\x20\x66\x6F\x75\x6E\x64\x3A","\x4C\x69\x73\x74\x49\x64","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x66\x69\x6E\x64\x4F\x6E\x65","\x5B\x46\x61\x78\x5D\x20\x45\x72\x72\x6F\x72\x20\x75\x70\x64\x61\x74\x69\x6E\x67\x20\x73\x65\x6E\x64\x69\x6E\x67\x20\x6D\x65\x73\x73\x61\x67\x65\x3A","\x5B\x46\x61\x78\x5D\x20\x52\x6F\x6F\x6D\x20\x75\x70\x64\x61\x74\x65\x20\x66\x6F\x72\x20\x53\x65\x6E\x64\x46\x61\x78\x20\x65\x76\x65\x6E\x74","\x5B\x46\x61\x78\x5D\x20\x52\x6F\x6F\x6D\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x53\x45\x4E\x54","\x5B\x46\x61\x78\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x20\x75\x70\x64\x61\x74\x65\x20\x66\x6F\x72\x20\x53\x65\x6E\x64\x46\x61\x78\x20\x65\x76\x65\x6E\x74","\x67\x65\x74\x46\x61\x78\x52\x6F\x6F\x6D","\x5B\x46\x61\x78\x5D\x20\x4D\x65\x73\x73\x61\x67\x65\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x30","\x46\x41\x49\x4C\x45\x44","\x72\x65\x6D\x6F\x74\x65\x73\x74\x61\x74\x69\x6F\x6E\x69\x64","\x72\x65\x73\x6F\x6C\x75\x74\x69\x6F\x6E","\x74\x72\x61\x6E\x73\x66\x65\x72\x72\x61\x74\x65","\x76\x61\x72\x69\x61\x62\x6C\x65","\x72\x65\x73\x6F\x6C\x76\x65","\x5B\x46\x61\x78\x5D\x20\x45\x72\x72\x6F\x72\x20\x75\x70\x64\x61\x74\x69\x6E\x67\x20\x6D\x65\x73\x73\x61\x67\x65\x3A","\x63\x68\x61\x6E\x6E\x65\x6C","\x63\x68\x61\x6E\x6E\x65\x6C\x73\x74\x61\x74\x65","\x63\x68\x61\x6E\x6E\x65\x6C\x73\x74\x61\x74\x65\x64\x65\x73\x63","\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x61\x6D\x65","\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x6C\x69\x6E\x65\x6E\x75\x6D","\x63\x6F\x6E\x6E\x65\x63\x74\x65\x64\x6C\x69\x6E\x65\x6E\x61\x6D\x65","\x61\x63\x63\x6F\x75\x6E\x74\x63\x6F\x64\x65","\x63\x6F\x6E\x74\x65\x78\x74","\x65\x78\x74\x65\x6E","\x70\x72\x69\x6F\x72\x69\x74\x79","\x75\x6E\x69\x71\x75\x65\x69\x64","\x6C\x69\x6E\x6B\x65\x64\x69\x64","\x66\x61\x78\x65\x72\x72\x6F\x72","\x68\x61\x73\x4F\x77\x6E\x50\x72\x6F\x70\x65\x72\x74\x79","\x76\x61\x6C\x75\x65","\x5B\x46\x61\x78\x5D\x20\x45\x72\x72\x6F\x72\x20\x75\x70\x64\x61\x74\x69\x6E\x67\x20\x65\x72\x72\x6F\x72\x3A"];_0x1368[0];var BPromise=require(_0x1368[1]);var moment=require(_0x1368[2]);var util=require(_0x1368[3]);var _=require(_0x1368[4]);var path=require(_0x1368[5]);var config=require(_0x1368[6]);var exec=require(_0x1368[8])[_0x1368[7]];var FaxMessage=require(_0x1368[10])[_0x1368[9]];var FaxRoom=require(_0x1368[10])[_0x1368[11]];var FaxAccount=require(_0x1368[10])[_0x1368[12]];var FaxAttachment=require(_0x1368[10])[_0x1368[13]];var Contact=require(_0x1368[10])[_0x1368[14]];module[_0x1368[15]]= function(){return {receivefax:function(_0x724exd){return function(_0x724exe){console[_0x1368[19]](util[_0x1368[18]](_0x1368[16],_0x724exd[_0x1368[17]]));var _0x724exf=_[_0x1368[20]](_0x724exd);var _0x724ex10;var _0x724ex11,_0x724ex12;return FaxAccount[_0x1368[79]]({where:{localstationid:_0x724exd[_0x1368[59]]}})[_0x1368[32]](function(_0x724ex1b){if(!_0x724ex1b){throw new Error(_0x1368[75])};console[_0x1368[19]](_0x1368[76],_0x724exd[_0x1368[59]]);_0x724ex10= _0x724ex1b;if(_0x724ex10[_0x1368[77]]){return Contact[_0x1368[78]]({where:{ListId:_0x724ex10[_0x1368[77]],$or:[{phone:_0x724exd[_0x1368[17]]},{fax:_0x724exd[_0x1368[17]]}]},defaults:{phone:_0x724exd[_0x1368[17]],fax:_0x724exd[_0x1368[17]],firstName:_0x724exd[_0x1368[17]],ListId:_0x724ex10[_0x1368[77]]}})}else {return []}})[_0x1368[74]](function(_0x724ex19,_0x724ex1a){if(_0x724ex1a!== undefined&& !_0x724ex1a){return _0x724ex19[_0x1368[68]]({fax:_0x724exd[_0x1368[17]]})};return})[_0x1368[32]](function(){return FaxRoom[_0x1368[73]]({limit:1,where:{contact:_0x724exf[_0x1368[17]],FaxAccountId:_0x724ex10[_0x1368[35]],status:{$ne:_0x1368[70]}},order:[[_0x1368[71],_0x1368[72]]]})})[_0x1368[32]](function(_0x724ex18){if(_0x724ex18[_0x1368[62]]){_0x724ex18= _[_0x1368[63]](_0x724ex18);return _0x724ex18[_0x1368[68]]({lastEvent:_0x1368[56],lastEventAt:moment()[_0x1368[18]](_0x1368[64]),status:_0x1368[65],openReason:_0x1368[66],faxIn:++_0x724ex18[_0x1368[67]]})}else {return FaxRoom[_0x1368[50]]({contact:_0x724exf[_0x1368[17]],account:_0x724ex10[_0x1368[40]],status:_0x1368[69],lastEvent:_0x1368[56],lastEventAt:moment()[_0x1368[18]](_0x1368[64]),FaxAccountId:_0x724ex10[_0x1368[35]],faxIn:1})}})[_0x1368[32]](function(_0x724ex18){if(!_0x724ex18){throw new Error(_0x1368[52])};console[_0x1368[19]](_0x1368[53],_0x724ex18[_0x1368[35]]);_0x724ex12= _0x724ex18;_0x724exf[_0x1368[54]]= _0x724ex18[_0x1368[35]];_0x724exf[_0x1368[55]]= _0x1368[56];_0x724exf[_0x1368[57]]= _0x724exf[_0x1368[17]];_0x724exf[_0x1368[58]]= _0x724exf[_0x1368[59]];_0x724exf[_0x1368[22]]= parseInt(_0x724exf[_0x1368[28]])> 0?_0x1368[60]:_0x1368[61];return FaxMessage[_0x1368[50]](_0x724exf)})[_0x1368[32]](function(_0x724ex15){if(!_0x724ex15){throw new Error(_0x1368[39])};_0x724ex11= _0x724ex15;console[_0x1368[19]](_0x1368[23],_0x724ex15[_0x1368[35]]);if(parseInt(_0x724exd[_0x1368[28]])> 0){var _0x724ex16=path[_0x1368[41]](_0x724exd[_0x1368[38]])[_0x1368[40]];var _0x724ex17=_0x724ex16+ _0x1368[42];return FaxAttachment[_0x1368[50]]({path:path[_0x1368[49]](config[_0x1368[43]],_0x1368[44],_0x1368[45],_0x1368[46],_0x1368[47],_0x1368[48],_0x724ex17),basename:_0x724ex17,name:_0x724ex16,FaxMessageId:_0x724ex15[_0x1368[35]]})};console[_0x1368[19]](util[_0x1368[18]](_0x1368[51],_0x724exd[_0x1368[28]]));return})[_0x1368[32]](function(_0x724ex14){if(!_0x724ex14){console[_0x1368[19]](_0x1368[33]);return};console[_0x1368[19]](_0x1368[34],_0x724ex14[_0x1368[35]]);return exec(_0x1368[36]+ _0x724ex14[_0x1368[5]]+ _0x1368[37]+ _0x724exd[_0x1368[38]])})[_0x1368[32]](function(){if(parseInt(_0x724exd[_0x1368[28]])> 0){console[_0x1368[19]](_0x1368[29]);process[_0x1368[31]]({message:_0x1368[30],doc:{message:_0x724ex11,account:_0x724ex10}})}})[_0x1368[27]](function(_0x724ex13){console[_0x1368[22]](_0x1368[21],_0x724ex13);console[_0x1368[22]](_0x1368[23],_0x724ex13[_0x1368[24]]);console[_0x1368[22]](_0x1368[25],_0x724ex13[_0x1368[26]])})}},sendfax:function(_0x724exd){return function(_0x724exe){var _0x724ex11;return FaxMessage[_0x1368[79]]({where:{filename:_0x724exd[_0x1368[38]],localstationid:_0x724exd[_0x1368[59]]}})[_0x1368[32]](function(_0x724ex1d){if(!_0x724ex1d){throw new Error(_0x1368[86])};_0x724ex11= _0x724ex1d;var _0x724ex1e=_0x1368[83];if(_0x724exd[_0x1368[28]]=== _0x1368[87]){_0x724ex1e= _0x1368[88]};return _0x724ex11[_0x1368[68]]({remotestationid:_0x724exd[_0x1368[89]],pagestransferred:_0x724exd[_0x1368[28]],resolution:_0x724exd[_0x1368[90]],transferrate:_0x724exd[_0x1368[91]],status:_0x724ex1e})})[_0x1368[32]](function(_0x724ex15){console[_0x1368[19]](_0x1368[84],_0x724ex15[_0x1368[35]]);return _0x724ex11[_0x1368[85]]()})[_0x1368[32]](function(_0x724ex1c){if(!_0x724ex1c){throw new Error(_0x1368[82])};return _0x724ex1c[_0x1368[68]]({lastEvent:_0x1368[83]},{individualHooks:true})})[_0x1368[32]](function(_0x724ex18){console[_0x1368[19]](_0x1368[81],_0x724ex18[_0x1368[35]])})[_0x1368[27]](function(_0x724ex13){console[_0x1368[22]](_0x1368[80],_0x724ex13);console[_0x1368[22]](_0x1368[23],_0x724ex13[_0x1368[24]]);console[_0x1368[22]](_0x1368[25],_0x724ex13[_0x1368[26]])})}},faxstatus:function(_0x724exd){return function(_0x724exe){if(_0x724exd[_0x1368[92]]!== _0x1368[31]){return BPromise[_0x1368[93]]()};return FaxMessage[_0x1368[79]]({where:{filename:_0x724exd[_0x1368[38]],localstationid:_0x724exd[_0x1368[59]]}})[_0x1368[32]](function(_0x724ex1d){if(!_0x724ex1d){throw new Error(_0x1368[86])};return _0x724ex1d[_0x1368[68]]({channel:_0x724exd[_0x1368[95]],channelstate:_0x724exd[_0x1368[96]],channelstatedesc:_0x724exd[_0x1368[97]],calleridnum:_0x724exd[_0x1368[17]],calleridname:_0x724exd[_0x1368[98]],connectedlinenum:_0x724exd[_0x1368[99]],connectedlinename:_0x724exd[_0x1368[100]],accountcode:_0x724exd[_0x1368[101]],context:_0x724exd[_0x1368[102]],exten:_0x724exd[_0x1368[103]],priority:_0x724exd[_0x1368[104]],uniqueid:_0x724exd[_0x1368[105]],linkedid:_0x724exd[_0x1368[106]],lastStatus:_0x724exd[_0x1368[55]]})})[_0x1368[27]](function(_0x724ex13){console[_0x1368[22]](_0x1368[94],_0x724ex13);console[_0x1368[22]](_0x1368[23],_0x724ex13[_0x1368[24]]);console[_0x1368[22]](_0x1368[25],_0x724ex13[_0x1368[26]])})}},faxerror:function(_0x724exd){return function(_0x724exe){if(!_0x724exd[_0x1368[92]][_0x1368[108]](_0x1368[107])|| !_0x724exd[_0x1368[109]]){return BPromise[_0x1368[93]]()};return FaxMessage[_0x1368[79]]({where:{channel:_0x724exd[_0x1368[95]]}})[_0x1368[32]](function(_0x724ex1d){if(_0x724ex1d){return _0x724ex1d[_0x1368[68]]({error:_0x724exd[_0x1368[109]]})};return})[_0x1368[27]](function(_0x724ex13){console[_0x1368[22]](_0x1368[110],_0x724ex13)})}}}}