18 var _0x0760=['filter','where','merge','type','VIRTUAL','options','includeAll','findAll','rows','catch','show','params','keys','find','create','body','describe','eml-format','zip-dir','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','limit','undefined','count','set','Content-Range','json','apply','save','update','then','destroy','error','name','send','index','map','ChatQueueReport','rawAttributes','fieldName','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick'];(function(_0x19f9e6,_0x4f59a6){var _0x45c862=function(_0x3447fb){while(--_0x3447fb){_0x19f9e6['push'](_0x19f9e6['shift']());}};_0x45c862(++_0x4f59a6);}(_0x0760,0xa9));var _0x0076=function(_0xc7205a,_0x391d58){_0xc7205a=_0xc7205a-0x0;var _0x3d9c46=_0x0760[_0xc7205a];return _0x3d9c46;};'use strict';var emlformat=require(_0x0076('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x0076('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x0076('0x2'));var Mustache=require(_0x0076('0x3'));var util=require(_0x0076('0x4'));var path=require(_0x0076('0x5'));var sox=require(_0x0076('0x6'));var csv=require('to-csv');var ejs=require(_0x0076('0x7'));var fs=require('fs');var fs_extra=require(_0x0076('0x8'));var _=require(_0x0076('0x9'));var squel=require(_0x0076('0xa'));var crypto=require(_0x0076('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x0076('0xc'));var toCsv=require('to-csv');var querystring=require(_0x0076('0xd'));var Papa=require(_0x0076('0xe'));var Redis=require('ioredis');var authService=require(_0x0076('0xf'));var qs=require(_0x0076('0x10'));var as=require(_0x0076('0x11'));var hardwareService=require(_0x0076('0x12'));var logger=require(_0x0076('0x13'))(_0x0076('0x14'));var utils=require('../../config/utils');var config=require(_0x0076('0x15'));var licenseUtil=require(_0x0076('0x16'));var db=require(_0x0076('0x17'))['db'];function respondWithStatusCode(_0x328bbd,_0x3ecbde){_0x3ecbde=_0x3ecbde||0xcc;return function(_0x220e7d){if(_0x220e7d){return _0x328bbd[_0x0076('0x18')](_0x3ecbde);}return _0x328bbd[_0x0076('0x19')](_0x3ecbde)[_0x0076('0x1a')]();};}function respondWithResult(_0x3c790a,_0x379136){_0x379136=_0x379136||0xc8;return function(_0x5175c7){if(_0x5175c7){return _0x3c790a[_0x0076('0x19')](_0x379136)['json'](_0x5175c7);}};}function respondWithFilteredResult(_0x483ad0,_0x29915b){return function(_0x2a45c6){if(_0x2a45c6){var _0x4ce381=typeof _0x29915b[_0x0076('0x1b')]==='undefined'&&typeof _0x29915b[_0x0076('0x1c')]===_0x0076('0x1d');var _0x5a5623=_0x2a45c6['count'];var _0x5761a4=_0x4ce381?0x0:_0x29915b[_0x0076('0x1b')];var _0x30fb20=_0x4ce381?_0x2a45c6[_0x0076('0x1e')]:_0x29915b[_0x0076('0x1b')]+_0x29915b[_0x0076('0x1c')];var _0x371498;if(_0x30fb20>=_0x5a5623){_0x30fb20=_0x5a5623;_0x371498=0xc8;}else{_0x371498=0xce;}_0x483ad0[_0x0076('0x19')](_0x371498);return _0x483ad0[_0x0076('0x1f')](_0x0076('0x20'),_0x5761a4+'-'+_0x30fb20+'/'+_0x5a5623)[_0x0076('0x21')](_0x2a45c6);}return null;};}function patchUpdates(_0x274c52){return function(_0x1507d4){try{jsonpatch[_0x0076('0x22')](_0x1507d4,_0x274c52,!![]);}catch(_0x26b89c){return BPromise['reject'](_0x26b89c);}return _0x1507d4[_0x0076('0x23')]();};}function saveUpdates(_0x2a5619,_0x180391){return function(_0x58ee11){if(_0x58ee11){return _0x58ee11[_0x0076('0x24')](_0x2a5619)[_0x0076('0x25')](function(_0x2dd436){return _0x2dd436;});}return null;};}function removeEntity(_0x39bb13,_0x250f57){return function(_0x5b73ac){if(_0x5b73ac){return _0x5b73ac[_0x0076('0x26')]()[_0x0076('0x25')](function(){_0x39bb13[_0x0076('0x19')](0xcc)[_0x0076('0x1a')]();});}};}function handleEntityNotFound(_0x2c7def,_0x336661){return function(_0x59f20c){if(!_0x59f20c){_0x2c7def[_0x0076('0x18')](0x194);}return _0x59f20c;};}function handleError(_0x27c087,_0x1dbd77){_0x1dbd77=_0x1dbd77||0x1f4;return function(_0x187827){logger[_0x0076('0x27')](_0x187827['stack']);if(_0x187827[_0x0076('0x28')]){delete _0x187827[_0x0076('0x28')];}_0x27c087[_0x0076('0x19')](_0x1dbd77)[_0x0076('0x29')](_0x187827);};}exports[_0x0076('0x2a')]=function(_0xd4009d,_0x1635b7){var _0x332376={},_0x2bc8b7={},_0xca7c6c={'count':0x0,'rows':[]};var _0x4f6543=_[_0x0076('0x2b')](db[_0x0076('0x2c')][_0x0076('0x2d')],function(_0x1cfad4){return{'name':_0x1cfad4[_0x0076('0x2e')],'type':_0x1cfad4['type']['key']};});_0x2bc8b7[_0x0076('0x2f')]=_[_0x0076('0x2b')](_0x4f6543,_0x0076('0x28'));_0x2bc8b7[_0x0076('0x30')]=_['keys'](_0xd4009d['query']);_0x2bc8b7[_0x0076('0x31')]=_[_0x0076('0x32')](_0x2bc8b7[_0x0076('0x2f')],_0x2bc8b7['query']);_0x332376[_0x0076('0x33')]=_[_0x0076('0x32')](_0x2bc8b7[_0x0076('0x2f')],qs[_0x0076('0x34')](_0xd4009d[_0x0076('0x30')][_0x0076('0x34')]));_0x332376[_0x0076('0x33')]=_0x332376[_0x0076('0x33')][_0x0076('0x35')]?_0x332376[_0x0076('0x33')]:_0x2bc8b7[_0x0076('0x2f')];if(!_0xd4009d['query'][_0x0076('0x36')](_0x0076('0x37'))){_0x332376[_0x0076('0x1c')]=qs[_0x0076('0x1c')](_0xd4009d[_0x0076('0x30')][_0x0076('0x1c')]);_0x332376[_0x0076('0x1b')]=qs['offset'](_0xd4009d[_0x0076('0x30')][_0x0076('0x1b')]);}_0x332376[_0x0076('0x38')]=qs[_0x0076('0x39')](_0xd4009d['query'][_0x0076('0x39')]);_0x332376['where']=qs[_0x0076('0x31')](_[_0x0076('0x3a')](_0xd4009d[_0x0076('0x30')],_0x2bc8b7[_0x0076('0x31')]),_0x4f6543);if(_0xd4009d[_0x0076('0x30')][_0x0076('0x3b')]){_0x332376[_0x0076('0x3c')]=_[_0x0076('0x3d')](_0x332376[_0x0076('0x3c')],{'$or':_[_0x0076('0x2b')](_0x4f6543,function(_0x201366){if(_0x201366[_0x0076('0x3e')]!==_0x0076('0x3f')){var _0x5843e6={};_0x5843e6[_0x201366[_0x0076('0x28')]]={'$like':'%'+_0xd4009d[_0x0076('0x30')][_0x0076('0x3b')]+'%'};return _0x5843e6;}})});}_0x332376=_[_0x0076('0x3d')]({},_0x332376,_0xd4009d[_0x0076('0x40')]);var _0x3d2d82={'where':_0x332376['where']};return db[_0x0076('0x2c')]['count'](_0x3d2d82)[_0x0076('0x25')](function(_0x4f58d0){_0xca7c6c[_0x0076('0x1e')]=_0x4f58d0;if(_0xd4009d[_0x0076('0x30')][_0x0076('0x41')]){_0x332376['include']=[{'all':!![]}];}return db[_0x0076('0x2c')][_0x0076('0x42')](_0x332376);})['then'](function(_0x408b7b){_0xca7c6c[_0x0076('0x43')]=_0x408b7b;return _0xca7c6c;})[_0x0076('0x25')](respondWithFilteredResult(_0x1635b7,_0x332376))[_0x0076('0x44')](handleError(_0x1635b7,null));};exports[_0x0076('0x45')]=function(_0x382ae5,_0x1cefec){var _0xd40131={'raw':!![],'where':{'id':_0x382ae5[_0x0076('0x46')]['id']}},_0x157d6f={};_0x157d6f[_0x0076('0x2f')]=_[_0x0076('0x47')](db[_0x0076('0x2c')][_0x0076('0x2d')]);_0x157d6f[_0x0076('0x30')]=_['keys'](_0x382ae5[_0x0076('0x30')]);_0x157d6f[_0x0076('0x31')]=_[_0x0076('0x32')](_0x157d6f[_0x0076('0x2f')],_0x157d6f['query']);_0xd40131[_0x0076('0x33')]=_[_0x0076('0x32')](_0x157d6f[_0x0076('0x2f')],qs[_0x0076('0x34')](_0x382ae5['query']['fields']));_0xd40131[_0x0076('0x33')]=_0xd40131[_0x0076('0x33')]['length']?_0xd40131[_0x0076('0x33')]:_0x157d6f[_0x0076('0x2f')];if(_0x382ae5['query'][_0x0076('0x41')]){_0xd40131['include']=[{'all':!![]}];}_0xd40131=_[_0x0076('0x3d')]({},_0xd40131,_0x382ae5[_0x0076('0x40')]);return db[_0x0076('0x2c')][_0x0076('0x48')](_0xd40131)[_0x0076('0x25')](handleEntityNotFound(_0x1cefec,null))['then'](respondWithResult(_0x1cefec,null))[_0x0076('0x44')](handleError(_0x1cefec,null));};exports[_0x0076('0x49')]=function(_0x3087c7,_0x43b1dc){return db[_0x0076('0x2c')][_0x0076('0x49')](_0x3087c7['body'],{})[_0x0076('0x25')](respondWithResult(_0x43b1dc,0xc9))['catch'](handleError(_0x43b1dc,null));};exports[_0x0076('0x24')]=function(_0x5bfdf8,_0xb09053){if(_0x5bfdf8[_0x0076('0x4a')]['id']){delete _0x5bfdf8[_0x0076('0x4a')]['id'];}return db['ChatQueueReport'][_0x0076('0x48')]({'where':{'id':_0x5bfdf8[_0x0076('0x46')]['id']}})[_0x0076('0x25')](handleEntityNotFound(_0xb09053,null))['then'](saveUpdates(_0x5bfdf8[_0x0076('0x4a')],null))[_0x0076('0x25')](respondWithResult(_0xb09053,null))['catch'](handleError(_0xb09053,null));};exports[_0x0076('0x26')]=function(_0x129e5c,_0x3ad9c8){return db[_0x0076('0x2c')]['find']({'where':{'id':_0x129e5c[_0x0076('0x46')]['id']}})[_0x0076('0x25')](handleEntityNotFound(_0x3ad9c8,null))[_0x0076('0x25')](removeEntity(_0x3ad9c8,null))[_0x0076('0x44')](handleError(_0x3ad9c8,null));};exports[_0x0076('0x4b')]=function(_0x2163c6,_0x53a424){return db[_0x0076('0x2c')][_0x0076('0x4b')]()['then'](respondWithResult(_0x53a424,null))[_0x0076('0x44')](handleError(_0x53a424,null));};