18 var _0x9516=['set','Content-Range','apply','reject','save','update','then','destroy','get','Templates','UserProfileResource','sendStatus','error','name','send','index','map','Template','rawAttributes','query','filters','intersection','model','attributes','length','nolimit','sort','where','pick','filter','type','merge','options','includeAll','include','findAll','show','params','keys','fields','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','catch','body','eml-format','zip-dir','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','end','status','json','offset','undefined','limit','count'];(function(_0x5916c5,_0x381e41){var _0x12ed1c=function(_0x532e92){while(--_0x532e92){_0x5916c5['push'](_0x5916c5['shift']());}};_0x12ed1c(++_0x381e41);}(_0x9516,0x82));var _0x6951=function(_0x411b75,_0x4de4ca){_0x411b75=_0x411b75-0x0;var _0x5a9239=_0x9516[_0x411b75];return _0x5a9239;};'use strict';var emlformat=require(_0x6951('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x6951('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x6951('0x2'));var path=require(_0x6951('0x3'));var sox=require(_0x6951('0x4'));var csv=require(_0x6951('0x5'));var ejs=require(_0x6951('0x6'));var fs=require('fs');var fs_extra=require(_0x6951('0x7'));var _=require(_0x6951('0x8'));var squel=require('squel');var crypto=require(_0x6951('0x9'));var jsforce=require(_0x6951('0xa'));var deskjs=require(_0x6951('0xb'));var toCsv=require('to-csv');var querystring=require(_0x6951('0xc'));var Papa=require(_0x6951('0xd'));var Redis=require('ioredis');var authService=require(_0x6951('0xe'));var qs=require(_0x6951('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x6951('0x10'));var logger=require(_0x6951('0x11'))(_0x6951('0x12'));var utils=require(_0x6951('0x13'));var config=require(_0x6951('0x14'));var licenseUtil=require(_0x6951('0x15'));var db=require(_0x6951('0x16'))['db'];function respondWithStatusCode(_0x5af56b,_0x32ed4d){_0x32ed4d=_0x32ed4d||0xcc;return function(_0x2e2cf8){if(_0x2e2cf8){return _0x5af56b['sendStatus'](_0x32ed4d);}return _0x5af56b['status'](_0x32ed4d)[_0x6951('0x17')]();};}function respondWithResult(_0x31b27f,_0x185441){_0x185441=_0x185441||0xc8;return function(_0xe43032){if(_0xe43032){return _0x31b27f[_0x6951('0x18')](_0x185441)[_0x6951('0x19')](_0xe43032);}};}function respondWithFilteredResult(_0x2e9bd1,_0x92bbb8){return function(_0x181d72){if(_0x181d72){var _0xb23081=typeof _0x92bbb8[_0x6951('0x1a')]===_0x6951('0x1b')&&typeof _0x92bbb8[_0x6951('0x1c')]===_0x6951('0x1b');var _0x4f1591=_0x181d72[_0x6951('0x1d')];var _0x2e6977=_0xb23081?0x0:_0x92bbb8[_0x6951('0x1a')];var _0x40900b=_0xb23081?_0x181d72[_0x6951('0x1d')]:_0x92bbb8[_0x6951('0x1a')]+_0x92bbb8['limit'];var _0x301199;if(_0x40900b>=_0x4f1591){_0x40900b=_0x4f1591;_0x301199=0xc8;}else{_0x301199=0xce;}_0x2e9bd1[_0x6951('0x18')](_0x301199);return _0x2e9bd1[_0x6951('0x1e')](_0x6951('0x1f'),_0x2e6977+'-'+_0x40900b+'/'+_0x4f1591)[_0x6951('0x19')](_0x181d72);}return null;};}function patchUpdates(_0x2c819f){return function(_0x125468){try{jsonpatch[_0x6951('0x20')](_0x125468,_0x2c819f,!![]);}catch(_0x74aa6b){return BPromise[_0x6951('0x21')](_0x74aa6b);}return _0x125468[_0x6951('0x22')]();};}function saveUpdates(_0xb1f0e5,_0x519b09){return function(_0x34219f){if(_0x34219f){return _0x34219f[_0x6951('0x23')](_0xb1f0e5)[_0x6951('0x24')](function(_0xc09d4f){return _0xc09d4f;});}return null;};}function removeEntity(_0x1716ef,_0x573aa4){return function(_0x18c576){if(_0x18c576){return _0x18c576[_0x6951('0x25')]()[_0x6951('0x24')](function(){var _0x6a885a=_0x18c576[_0x6951('0x26')]({'plain':!![]});var _0x457415=_0x6951('0x27');return db[_0x6951('0x28')][_0x6951('0x25')]({'where':{'type':_0x457415,'resourceId':_0x6a885a['id']}})[_0x6951('0x24')](function(){return _0x18c576;});})[_0x6951('0x24')](function(){_0x1716ef[_0x6951('0x18')](0xcc)[_0x6951('0x17')]();});}};}function handleEntityNotFound(_0x493052,_0x2ba698){return function(_0x198f51){if(!_0x198f51){_0x493052[_0x6951('0x29')](0x194);}return _0x198f51;};}function handleError(_0xf5e640,_0x2884f3){_0x2884f3=_0x2884f3||0x1f4;return function(_0x5bcd38){logger[_0x6951('0x2a')](_0x5bcd38['stack']);if(_0x5bcd38[_0x6951('0x2b')]){delete _0x5bcd38[_0x6951('0x2b')];}_0xf5e640[_0x6951('0x18')](_0x2884f3)[_0x6951('0x2c')](_0x5bcd38);};}exports[_0x6951('0x2d')]=function(_0x3dc022,_0x49d16f){var _0x6df540={},_0xd78307={},_0x521687={'count':0x0,'rows':[]};var _0x5ee63b=_[_0x6951('0x2e')](db[_0x6951('0x2f')][_0x6951('0x30')],function(_0x3a9d3e){return{'name':_0x3a9d3e['fieldName'],'type':_0x3a9d3e['type']['key']};});_0xd78307['model']=_['map'](_0x5ee63b,_0x6951('0x2b'));_0xd78307['query']=_['keys'](_0x3dc022[_0x6951('0x31')]);_0xd78307[_0x6951('0x32')]=_[_0x6951('0x33')](_0xd78307[_0x6951('0x34')],_0xd78307[_0x6951('0x31')]);_0x6df540[_0x6951('0x35')]=_[_0x6951('0x33')](_0xd78307[_0x6951('0x34')],qs['fields'](_0x3dc022['query']['fields']));_0x6df540[_0x6951('0x35')]=_0x6df540[_0x6951('0x35')][_0x6951('0x36')]?_0x6df540[_0x6951('0x35')]:_0xd78307['model'];if(!_0x3dc022[_0x6951('0x31')]['hasOwnProperty'](_0x6951('0x37'))){_0x6df540[_0x6951('0x1c')]=qs['limit'](_0x3dc022[_0x6951('0x31')]['limit']);_0x6df540[_0x6951('0x1a')]=qs[_0x6951('0x1a')](_0x3dc022[_0x6951('0x31')][_0x6951('0x1a')]);}_0x6df540['order']=qs['sort'](_0x3dc022['query'][_0x6951('0x38')]);_0x6df540[_0x6951('0x39')]=qs[_0x6951('0x32')](_[_0x6951('0x3a')](_0x3dc022['query'],_0xd78307[_0x6951('0x32')]),_0x5ee63b);if(_0x3dc022[_0x6951('0x31')][_0x6951('0x3b')]){_0x6df540['where']=_['merge'](_0x6df540[_0x6951('0x39')],{'$or':_['map'](_0x5ee63b,function(_0x510dd8){if(_0x510dd8[_0x6951('0x3c')]!=='VIRTUAL'){var _0x5e2938={};_0x5e2938[_0x510dd8[_0x6951('0x2b')]]={'$like':'%'+_0x3dc022['query'][_0x6951('0x3b')]+'%'};return _0x5e2938;}})});}_0x6df540=_[_0x6951('0x3d')]({},_0x6df540,_0x3dc022[_0x6951('0x3e')]);var _0x5696f2={'where':_0x6df540['where']};return db[_0x6951('0x2f')][_0x6951('0x1d')](_0x5696f2)['then'](function(_0x194921){_0x521687['count']=_0x194921;if(_0x3dc022[_0x6951('0x31')][_0x6951('0x3f')]){_0x6df540[_0x6951('0x40')]=[{'all':!![]}];}return db[_0x6951('0x2f')][_0x6951('0x41')](_0x6df540);})[_0x6951('0x24')](function(_0x30dae8){_0x521687['rows']=_0x30dae8;return _0x521687;})[_0x6951('0x24')](respondWithFilteredResult(_0x49d16f,_0x6df540))['catch'](handleError(_0x49d16f,null));};exports[_0x6951('0x42')]=function(_0x112dbe,_0x583b23){var _0x25e244={'raw':!![],'where':{'id':_0x112dbe[_0x6951('0x43')]['id']}},_0x5a9b39={};_0x5a9b39['model']=_['keys'](db[_0x6951('0x2f')][_0x6951('0x30')]);_0x5a9b39[_0x6951('0x31')]=_[_0x6951('0x44')](_0x112dbe[_0x6951('0x31')]);_0x5a9b39['filters']=_[_0x6951('0x33')](_0x5a9b39[_0x6951('0x34')],_0x5a9b39[_0x6951('0x31')]);_0x25e244['attributes']=_[_0x6951('0x33')](_0x5a9b39[_0x6951('0x34')],qs[_0x6951('0x45')](_0x112dbe[_0x6951('0x31')]['fields']));_0x25e244[_0x6951('0x35')]=_0x25e244[_0x6951('0x35')][_0x6951('0x36')]?_0x25e244[_0x6951('0x35')]:_0x5a9b39[_0x6951('0x34')];if(_0x112dbe[_0x6951('0x31')]['includeAll']){_0x25e244[_0x6951('0x40')]=[{'all':!![]}];}_0x25e244=_[_0x6951('0x3d')]({},_0x25e244,_0x112dbe[_0x6951('0x3e')]);return db[_0x6951('0x2f')][_0x6951('0x46')](_0x25e244)[_0x6951('0x24')](handleEntityNotFound(_0x583b23,null))[_0x6951('0x24')](respondWithResult(_0x583b23,null))['catch'](handleError(_0x583b23,null));};exports['create']=function(_0x2f858d,_0x326f41){return db[_0x6951('0x2f')][_0x6951('0x47')](_0x2f858d['body'],{})[_0x6951('0x24')](function(_0x595b69){var _0x2a8c1c=_0x2f858d[_0x6951('0x48')][_0x6951('0x26')]({'plain':!![]});if(!_0x2a8c1c)throw new Error(_0x6951('0x49'));if(_0x2a8c1c[_0x6951('0x4a')]==='user'){var _0x3124ac=_0x595b69[_0x6951('0x26')]({'plain':!![]});var _0x5073ac=_0x6951('0x27');return db[_0x6951('0x4b')]['find']({'where':{'name':_0x5073ac,'userProfileId':_0x2a8c1c[_0x6951('0x4c')]},'raw':!![]})[_0x6951('0x24')](function(_0x5936c2){if(_0x5936c2&&_0x5936c2[_0x6951('0x4d')]===0x0){return db[_0x6951('0x28')][_0x6951('0x47')]({'name':_0x3124ac[_0x6951('0x2b')],'resourceId':_0x3124ac['id'],'type':_0x5936c2[_0x6951('0x2b')],'sectionId':_0x5936c2['id']},{})[_0x6951('0x24')](function(){return _0x595b69;});}else{return _0x595b69;}})[_0x6951('0x4e')](function(_0x1011c9){logger[_0x6951('0x2a')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1011c9);throw _0x1011c9;});}return _0x595b69;})['then'](respondWithResult(_0x326f41,0xc9))[_0x6951('0x4e')](handleError(_0x326f41,null));};exports['update']=function(_0x1a1ab1,_0x442296){if(_0x1a1ab1[_0x6951('0x4f')]['id']){delete _0x1a1ab1[_0x6951('0x4f')]['id'];}return db[_0x6951('0x2f')][_0x6951('0x46')]({'where':{'id':_0x1a1ab1[_0x6951('0x43')]['id']}})[_0x6951('0x24')](handleEntityNotFound(_0x442296,null))[_0x6951('0x24')](saveUpdates(_0x1a1ab1[_0x6951('0x4f')],null))['then'](respondWithResult(_0x442296,null))['catch'](handleError(_0x442296,null));};exports[_0x6951('0x25')]=function(_0x5f0d39,_0x1578dd){return db[_0x6951('0x2f')]['find']({'where':{'id':_0x5f0d39['params']['id']}})[_0x6951('0x24')](handleEntityNotFound(_0x1578dd,null))[_0x6951('0x24')](removeEntity(_0x1578dd,null))[_0x6951('0x4e')](handleError(_0x1578dd,null));};