1 var _0xb61b=["\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","\x2E\x2E\x2F\x2E\x2E\x2F\x72\x6F\x75\x74\x69\x6E\x67\x2F\x73\x63\x68\x65\x64\x75\x6C\x65\x72","\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","\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","\x66\x61\x78","\x25\x73\x2E\x25\x73","\x75\x6E\x69\x78","\x69\x64","\x6E\x61\x6D\x65","\x6C\x6F\x63\x61\x6C\x73\x74\x61\x74\x69\x6F\x6E\x69\x64","\x66\x72\x6F\x6D","\x69\x6E\x69\x74","\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","\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","\x70\x61\x72\x73\x65","\x2E\x70\x64\x66","\x72\x6F\x6F\x74","\x73\x65\x72\x76\x65\x72","\x66\x69\x6C\x65\x73","\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\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","\x74\x6F","\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","\x70\x61\x67\x65\x73\x74\x72\x61\x6E\x73\x66\x65\x72\x72\x65\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","\x73\x65\x6E\x64","\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"];_0xb61b[0];var BPromise=require(_0xb61b[1]);var moment=require(_0xb61b[2]);var util=require(_0xb61b[3]);var _=require(_0xb61b[4]);var path=require(_0xb61b[5]);var config=require(_0xb61b[6]);var exec=require(_0xb61b[8])[_0xb61b[7]];var Scheduler=require(_0xb61b[9]);var FaxMessage=require(_0xb61b[11])[_0xb61b[10]];var FaxRoom=require(_0xb61b[11])[_0xb61b[12]];var FaxAccount=require(_0xb61b[11])[_0xb61b[13]];var FaxAttachment=require(_0xb61b[11])[_0xb61b[14]];var Contact=require(_0xb61b[11])[_0xb61b[15]];module[_0xb61b[16]]= function(){return {receivefax:function(_0x29f1xe){return function(_0x29f1xf){console[_0xb61b[20]](util[_0xb61b[19]](_0xb61b[17],_0x29f1xe[_0xb61b[18]]));var _0x29f1x10=_[_0xb61b[21]](_0x29f1xe);var _0x29f1x11;var _0x29f1x12,_0x29f1x13;return FaxAccount[_0xb61b[77]]({where:{localstationid:_0x29f1xe[_0xb61b[35]]}})[_0xb61b[38]](function(_0x29f1x1e){if(!_0x29f1x1e){throw new Error(_0xb61b[73])};console[_0xb61b[20]](_0xb61b[74],_0x29f1xe[_0xb61b[35]]);_0x29f1x11= _0x29f1x1e;if(_0x29f1x11[_0xb61b[75]]){return Contact[_0xb61b[76]]({where:{ListId:_0x29f1x11[_0xb61b[75]],$or:[{phone:_0x29f1xe[_0xb61b[18]]},{fax:_0x29f1xe[_0xb61b[18]]}]},defaults:{phone:_0x29f1xe[_0xb61b[18]],fax:_0x29f1xe[_0xb61b[18]],firstName:_0x29f1xe[_0xb61b[18]],ListId:_0x29f1x11[_0xb61b[75]]}})}else {return []}})[_0xb61b[72]](function(_0x29f1x1c,_0x29f1x1d){if(_0x29f1x1d!== undefined&& !_0x29f1x1d){return _0x29f1x1c[_0xb61b[66]]({fax:_0x29f1xe[_0xb61b[18]]})};return})[_0xb61b[38]](function(){return FaxRoom[_0xb61b[71]]({limit:1,where:{contact:_0x29f1x10[_0xb61b[18]],FaxAccountId:_0x29f1x11[_0xb61b[33]],status:{$ne:_0xb61b[68]}},order:[[_0xb61b[69],_0xb61b[70]]]})})[_0xb61b[38]](function(_0x29f1x1b){if(_0x29f1x1b[_0xb61b[60]]){_0x29f1x1b= _[_0xb61b[61]](_0x29f1x1b);return _0x29f1x1b[_0xb61b[66]]({lastEvent:_0xb61b[58],lastEventAt:moment()[_0xb61b[19]](_0xb61b[62]),status:_0xb61b[63],openReason:_0xb61b[64],faxIn:++_0x29f1x1b[_0xb61b[65]]})}else {return FaxRoom[_0xb61b[53]]({contact:_0x29f1x10[_0xb61b[18]],account:_0x29f1x11[_0xb61b[34]],status:_0xb61b[67],lastEvent:_0xb61b[58],lastEventAt:moment()[_0xb61b[19]](_0xb61b[62]),FaxAccountId:_0x29f1x11[_0xb61b[33]],faxIn:1})}})[_0xb61b[38]](function(_0x29f1x1b){if(!_0x29f1x1b){throw new Error(_0xb61b[54])};console[_0xb61b[20]](_0xb61b[55],_0x29f1x1b[_0xb61b[33]]);_0x29f1x13= _0x29f1x1b;_0x29f1x10[_0xb61b[56]]= _0x29f1x1b[_0xb61b[33]];_0x29f1x10[_0xb61b[57]]= _0xb61b[58];_0x29f1x10[_0xb61b[36]]= _0x29f1x10[_0xb61b[18]];_0x29f1x10[_0xb61b[59]]= _0x29f1x10[_0xb61b[35]];return FaxMessage[_0xb61b[53]](_0x29f1x10)})[_0xb61b[38]](function(_0x29f1x17){if(!_0x29f1x17){throw new Error(_0xb61b[44])};_0x29f1x12= _0x29f1x17;console[_0xb61b[20]](_0xb61b[24],_0x29f1x17[_0xb61b[33]]);var _0x29f1x18=[];var _0x29f1x19=path[_0xb61b[45]](_0x29f1xe[_0xb61b[43]])[_0xb61b[34]];var _0x29f1x1a=_0x29f1x19+ _0xb61b[46];return FaxAttachment[_0xb61b[53]]({path:path[_0xb61b[52]](config[_0xb61b[47]],_0xb61b[48],_0xb61b[49],_0xb61b[30],_0xb61b[50],_0xb61b[51],_0x29f1x1a),basename:_0x29f1x1a,name:_0x29f1x19,FaxMessageId:_0x29f1x17[_0xb61b[33]]})})[_0xb61b[38]](function(_0x29f1x16){if(!_0x29f1x16){throw new Error(_0xb61b[39])};console[_0xb61b[20]](_0xb61b[40],_0x29f1x16[_0xb61b[33]]);return exec(_0xb61b[41]+ _0x29f1x16[_0xb61b[5]]+ _0xb61b[42]+ _0x29f1xe[_0xb61b[43]])})[_0xb61b[38]](function(){console[_0xb61b[20]](_0xb61b[29]);var _0x29f1x15= new Scheduler({channel:_0xb61b[30],uniqueid:util[_0xb61b[19]](_0xb61b[31],moment()[_0xb61b[32]](),_0x29f1x13[_0xb61b[33]]),messageid:_0x29f1x12[_0xb61b[33]],roomid:_0x29f1x13[_0xb61b[33]],accountid:_0x29f1x11[_0xb61b[33]],accountname:_0x29f1x11[_0xb61b[34]],accountphone:_0x29f1x11[_0xb61b[35]],from:_0x29f1x12[_0xb61b[36]]});_0x29f1x15[_0xb61b[37]]()})[_0xb61b[28]](function(_0x29f1x14){console[_0xb61b[23]](_0xb61b[22],_0x29f1x14);console[_0xb61b[23]](_0xb61b[24],_0x29f1x14[_0xb61b[25]]);console[_0xb61b[23]](_0xb61b[26],_0x29f1x14[_0xb61b[27]])})}},sendfax:function(_0x29f1xe){return function(_0x29f1xf){var _0x29f1x12;return FaxMessage[_0xb61b[77]]({where:{filename:_0x29f1xe[_0xb61b[43]],localstationid:_0x29f1xe[_0xb61b[35]]}})[_0xb61b[38]](function(_0x29f1x20){if(!_0x29f1x20){throw new Error(_0xb61b[84])};_0x29f1x12= _0x29f1x20;var _0x29f1x21=_0xb61b[81];if(_0x29f1xe[_0xb61b[85]]=== _0xb61b[86]){_0x29f1x21= _0xb61b[87]};return _0x29f1x12[_0xb61b[66]]({remotestationid:_0x29f1xe[_0xb61b[88]],pagestransferred:_0x29f1xe[_0xb61b[85]],resolution:_0x29f1xe[_0xb61b[89]],transferrate:_0x29f1xe[_0xb61b[90]],status:_0x29f1x21})})[_0xb61b[38]](function(_0x29f1x17){console[_0xb61b[20]](_0xb61b[82],_0x29f1x17[_0xb61b[33]]);return _0x29f1x12[_0xb61b[83]]()})[_0xb61b[38]](function(_0x29f1x1f){if(!_0x29f1x1f){throw new Error(_0xb61b[80])};return _0x29f1x1f[_0xb61b[66]]({lastEvent:_0xb61b[81]},{individualHooks:true})})[_0xb61b[38]](function(_0x29f1x1b){console[_0xb61b[20]](_0xb61b[79],_0x29f1x1b[_0xb61b[33]])})[_0xb61b[28]](function(_0x29f1x14){console[_0xb61b[23]](_0xb61b[78],_0x29f1x14);console[_0xb61b[23]](_0xb61b[24],_0x29f1x14[_0xb61b[25]]);console[_0xb61b[23]](_0xb61b[26],_0x29f1x14[_0xb61b[27]])})}},faxstatus:function(_0x29f1xe){return function(_0x29f1xf){if(_0x29f1xe[_0xb61b[91]]!== _0xb61b[92]){return BPromise[_0xb61b[93]]()};return FaxMessage[_0xb61b[77]]({where:{filename:_0x29f1xe[_0xb61b[43]],localstationid:_0x29f1xe[_0xb61b[35]]}})[_0xb61b[38]](function(_0x29f1x20){if(!_0x29f1x20){throw new Error(_0xb61b[84])};return _0x29f1x20[_0xb61b[66]]({channel:_0x29f1xe[_0xb61b[95]],channelstate:_0x29f1xe[_0xb61b[96]],channelstatedesc:_0x29f1xe[_0xb61b[97]],calleridnum:_0x29f1xe[_0xb61b[18]],calleridname:_0x29f1xe[_0xb61b[98]],connectedlinenum:_0x29f1xe[_0xb61b[99]],connectedlinename:_0x29f1xe[_0xb61b[100]],accountcode:_0x29f1xe[_0xb61b[101]],context:_0x29f1xe[_0xb61b[102]],exten:_0x29f1xe[_0xb61b[103]],priority:_0x29f1xe[_0xb61b[104]],uniqueid:_0x29f1xe[_0xb61b[105]],linkedid:_0x29f1xe[_0xb61b[106]],lastStatus:_0x29f1xe[_0xb61b[57]]})})[_0xb61b[28]](function(_0x29f1x14){console[_0xb61b[23]](_0xb61b[94],_0x29f1x14);console[_0xb61b[23]](_0xb61b[24],_0x29f1x14[_0xb61b[25]]);console[_0xb61b[23]](_0xb61b[26],_0x29f1x14[_0xb61b[27]])})}},faxerror:function(_0x29f1xe){return function(_0x29f1xf){if(!_0x29f1xe[_0xb61b[91]][_0xb61b[108]](_0xb61b[107])|| !_0x29f1xe[_0xb61b[109]]){return BPromise[_0xb61b[93]]()};return FaxMessage[_0xb61b[77]]({where:{channel:_0x29f1xe[_0xb61b[95]]}})[_0xb61b[38]](function(_0x29f1x20){if(_0x29f1x20){return _0x29f1x20[_0xb61b[66]]({error:_0x29f1xe[_0xb61b[109]]})};return})[_0xb61b[28]](function(_0x29f1x14){console[_0xb61b[23]](_0xb61b[110],_0x29f1x14)})}}}}