18 var _0xef29=['rows','params','options','find','catch','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','eml-format','rimraf','zip-dir','fast-json-patch','moment','util','sox','to-csv','ejs','lodash','squel','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','json','undefined','limit','count','offset','status','set','apply','reject','save','update','then','Variables','UserProfileResource','destroy','end','error','stack','name','send','Variable','rawAttributes','fieldName','keys','filters','model','query','attributes','intersection','fields','length','nolimit','order','sort','pick','filter','merge','where','type','includeAll','include','findAll'];(function(_0x228547,_0x5e52a2){var _0x32eeab=function(_0x33b3aa){while(--_0x33b3aa){_0x228547['push'](_0x228547['shift']());}};_0x32eeab(++_0x5e52a2);}(_0xef29,0x199));var _0x9ef2=function(_0x178e48,_0x3c9509){_0x178e48=_0x178e48-0x0;var _0x440d7e=_0xef29[_0x178e48];return _0x440d7e;};'use strict';var emlformat=require(_0x9ef2('0x0'));var rimraf=require(_0x9ef2('0x1'));var zipdir=require(_0x9ef2('0x2'));var jsonpatch=require(_0x9ef2('0x3'));var rp=require('request-promise');var moment=require(_0x9ef2('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x9ef2('0x5'));var path=require('path');var sox=require(_0x9ef2('0x6'));var csv=require(_0x9ef2('0x7'));var ejs=require(_0x9ef2('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x9ef2('0x9'));var squel=require(_0x9ef2('0xa'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x9ef2('0xb'));var toCsv=require(_0x9ef2('0x7'));var querystring=require(_0x9ef2('0xc'));var Papa=require(_0x9ef2('0xd'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x9ef2('0xe'));var as=require(_0x9ef2('0xf'));var hardwareService=require(_0x9ef2('0x10'));var logger=require(_0x9ef2('0x11'))(_0x9ef2('0x12'));var utils=require('../../config/utils');var config=require(_0x9ef2('0x13'));var licenseUtil=require(_0x9ef2('0x14'));var db=require(_0x9ef2('0x15'))['db'];function respondWithStatusCode(_0x2e2b0d,_0x3c157e){_0x3c157e=_0x3c157e||0xcc;return function(_0x174c1b){if(_0x174c1b){return _0x2e2b0d[_0x9ef2('0x16')](_0x3c157e);}return _0x2e2b0d['status'](_0x3c157e)['end']();};}function respondWithResult(_0x576acf,_0x6ca838){_0x6ca838=_0x6ca838||0xc8;return function(_0x14cf5c){if(_0x14cf5c){return _0x576acf['status'](_0x6ca838)[_0x9ef2('0x17')](_0x14cf5c);}};}function respondWithFilteredResult(_0x5e42e8,_0x4182bc){return function(_0x1d3b62){if(_0x1d3b62){var _0x1479f2=typeof _0x4182bc['offset']===_0x9ef2('0x18')&&typeof _0x4182bc[_0x9ef2('0x19')]===_0x9ef2('0x18');var _0x29e839=_0x1d3b62[_0x9ef2('0x1a')];var _0x4a9387=_0x1479f2?0x0:_0x4182bc[_0x9ef2('0x1b')];var _0x347e04=_0x1479f2?_0x1d3b62[_0x9ef2('0x1a')]:_0x4182bc[_0x9ef2('0x1b')]+_0x4182bc['limit'];var _0x5e3114;if(_0x347e04>=_0x29e839){_0x347e04=_0x29e839;_0x5e3114=0xc8;}else{_0x5e3114=0xce;}_0x5e42e8[_0x9ef2('0x1c')](_0x5e3114);return _0x5e42e8[_0x9ef2('0x1d')]('Content-Range',_0x4a9387+'-'+_0x347e04+'/'+_0x29e839)[_0x9ef2('0x17')](_0x1d3b62);}return null;};}function patchUpdates(_0x5c8f84){return function(_0x80c20b){try{jsonpatch[_0x9ef2('0x1e')](_0x80c20b,_0x5c8f84,!![]);}catch(_0xb58d88){return BPromise[_0x9ef2('0x1f')](_0xb58d88);}return _0x80c20b[_0x9ef2('0x20')]();};}function saveUpdates(_0x459d44,_0x2c6fff){return function(_0x5a6d2a){if(_0x5a6d2a){return _0x5a6d2a[_0x9ef2('0x21')](_0x459d44)[_0x9ef2('0x22')](function(_0x14e9f0){return _0x14e9f0;});}return null;};}function removeEntity(_0x12487d,_0x2a987d){return function(_0x1d4657){if(_0x1d4657){return _0x1d4657['destroy']()[_0x9ef2('0x22')](function(){var _0x551400=_0x1d4657['get']({'plain':!![]});var _0x1bcb6f=_0x9ef2('0x23');return db[_0x9ef2('0x24')][_0x9ef2('0x25')]({'where':{'type':_0x1bcb6f,'resourceId':_0x551400['id']}})[_0x9ef2('0x22')](function(){return _0x1d4657;});})[_0x9ef2('0x22')](function(){_0x12487d[_0x9ef2('0x1c')](0xcc)[_0x9ef2('0x26')]();});}};}function handleEntityNotFound(_0x2d410c,_0x353f50){return function(_0x443291){if(!_0x443291){_0x2d410c[_0x9ef2('0x16')](0x194);}return _0x443291;};}function handleError(_0x558fc0,_0x219433){_0x219433=_0x219433||0x1f4;return function(_0x1179ea){logger[_0x9ef2('0x27')](_0x1179ea[_0x9ef2('0x28')]);if(_0x1179ea[_0x9ef2('0x29')]){delete _0x1179ea[_0x9ef2('0x29')];}_0x558fc0['status'](_0x219433)[_0x9ef2('0x2a')](_0x1179ea);};}exports['index']=function(_0x2d50dd,_0xa8b94c){var _0x17151a={},_0x1e4df7={},_0x51d5ed={'count':0x0,'rows':[]};var _0x326eb6=_['map'](db[_0x9ef2('0x2b')][_0x9ef2('0x2c')],function(_0x5b805a){return{'name':_0x5b805a[_0x9ef2('0x2d')],'type':_0x5b805a['type']['key']};});_0x1e4df7['model']=_['map'](_0x326eb6,_0x9ef2('0x29'));_0x1e4df7['query']=_[_0x9ef2('0x2e')](_0x2d50dd['query']);_0x1e4df7[_0x9ef2('0x2f')]=_['intersection'](_0x1e4df7[_0x9ef2('0x30')],_0x1e4df7[_0x9ef2('0x31')]);_0x17151a[_0x9ef2('0x32')]=_[_0x9ef2('0x33')](_0x1e4df7[_0x9ef2('0x30')],qs[_0x9ef2('0x34')](_0x2d50dd['query']['fields']));_0x17151a['attributes']=_0x17151a[_0x9ef2('0x32')][_0x9ef2('0x35')]?_0x17151a[_0x9ef2('0x32')]:_0x1e4df7['model'];if(!_0x2d50dd[_0x9ef2('0x31')]['hasOwnProperty'](_0x9ef2('0x36'))){_0x17151a[_0x9ef2('0x19')]=qs[_0x9ef2('0x19')](_0x2d50dd['query'][_0x9ef2('0x19')]);_0x17151a[_0x9ef2('0x1b')]=qs[_0x9ef2('0x1b')](_0x2d50dd[_0x9ef2('0x31')][_0x9ef2('0x1b')]);}_0x17151a[_0x9ef2('0x37')]=qs[_0x9ef2('0x38')](_0x2d50dd[_0x9ef2('0x31')][_0x9ef2('0x38')]);_0x17151a['where']=qs['filters'](_[_0x9ef2('0x39')](_0x2d50dd['query'],_0x1e4df7['filters']),_0x326eb6);if(_0x2d50dd[_0x9ef2('0x31')][_0x9ef2('0x3a')]){_0x17151a['where']=_[_0x9ef2('0x3b')](_0x17151a[_0x9ef2('0x3c')],{'$or':_['map'](_0x326eb6,function(_0xf940cc){if(_0xf940cc[_0x9ef2('0x3d')]!=='VIRTUAL'){var _0x56a66b={};_0x56a66b[_0xf940cc[_0x9ef2('0x29')]]={'$like':'%'+_0x2d50dd[_0x9ef2('0x31')][_0x9ef2('0x3a')]+'%'};return _0x56a66b;}})});}_0x17151a=_[_0x9ef2('0x3b')]({},_0x17151a,_0x2d50dd['options']);var _0x3853a0={'where':_0x17151a['where']};return db['Variable'][_0x9ef2('0x1a')](_0x3853a0)[_0x9ef2('0x22')](function(_0x548e60){_0x51d5ed['count']=_0x548e60;if(_0x2d50dd[_0x9ef2('0x31')][_0x9ef2('0x3e')]){_0x17151a[_0x9ef2('0x3f')]=[{'all':!![]}];}return db[_0x9ef2('0x2b')][_0x9ef2('0x40')](_0x17151a);})[_0x9ef2('0x22')](function(_0x82abe7){_0x51d5ed[_0x9ef2('0x41')]=_0x82abe7;return _0x51d5ed;})[_0x9ef2('0x22')](respondWithFilteredResult(_0xa8b94c,_0x17151a))['catch'](handleError(_0xa8b94c,null));};exports['show']=function(_0x5174e3,_0x346ab6){var _0x2810bd={'raw':!![],'where':{'id':_0x5174e3[_0x9ef2('0x42')]['id']}},_0x1d81d5={};_0x1d81d5[_0x9ef2('0x30')]=_['keys'](db[_0x9ef2('0x2b')][_0x9ef2('0x2c')]);_0x1d81d5[_0x9ef2('0x31')]=_['keys'](_0x5174e3[_0x9ef2('0x31')]);_0x1d81d5[_0x9ef2('0x2f')]=_[_0x9ef2('0x33')](_0x1d81d5[_0x9ef2('0x30')],_0x1d81d5[_0x9ef2('0x31')]);_0x2810bd[_0x9ef2('0x32')]=_['intersection'](_0x1d81d5[_0x9ef2('0x30')],qs[_0x9ef2('0x34')](_0x5174e3[_0x9ef2('0x31')][_0x9ef2('0x34')]));_0x2810bd[_0x9ef2('0x32')]=_0x2810bd['attributes'][_0x9ef2('0x35')]?_0x2810bd[_0x9ef2('0x32')]:_0x1d81d5[_0x9ef2('0x30')];if(_0x5174e3[_0x9ef2('0x31')][_0x9ef2('0x3e')]){_0x2810bd['include']=[{'all':!![]}];}_0x2810bd=_[_0x9ef2('0x3b')]({},_0x2810bd,_0x5174e3[_0x9ef2('0x43')]);return db[_0x9ef2('0x2b')][_0x9ef2('0x44')](_0x2810bd)[_0x9ef2('0x22')](handleEntityNotFound(_0x346ab6,null))['then'](respondWithResult(_0x346ab6,null))[_0x9ef2('0x45')](handleError(_0x346ab6,null));};exports[_0x9ef2('0x46')]=function(_0x22567e,_0x5c0c07){return db[_0x9ef2('0x2b')][_0x9ef2('0x46')](_0x22567e[_0x9ef2('0x47')],{})[_0x9ef2('0x22')](function(_0x52e7ca){var _0x4118bb=_0x22567e[_0x9ef2('0x48')][_0x9ef2('0x49')]({'plain':!![]});if(!_0x4118bb)throw new Error(_0x9ef2('0x4a'));if(_0x4118bb[_0x9ef2('0x4b')]===_0x9ef2('0x48')){var _0x518ec1=_0x52e7ca[_0x9ef2('0x49')]({'plain':!![]});var _0xe65583=_0x9ef2('0x23');return db[_0x9ef2('0x4c')][_0x9ef2('0x44')]({'where':{'name':_0xe65583,'userProfileId':_0x4118bb[_0x9ef2('0x4d')]},'raw':!![]})[_0x9ef2('0x22')](function(_0x124d52){if(_0x124d52&&_0x124d52[_0x9ef2('0x4e')]===0x0){return db[_0x9ef2('0x24')][_0x9ef2('0x46')]({'name':_0x518ec1[_0x9ef2('0x29')],'resourceId':_0x518ec1['id'],'type':_0x124d52[_0x9ef2('0x29')],'sectionId':_0x124d52['id']},{})[_0x9ef2('0x22')](function(){return _0x52e7ca;});}else{return _0x52e7ca;}})['catch'](function(_0xab37f4){logger[_0x9ef2('0x27')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xab37f4);throw _0xab37f4;});}return _0x52e7ca;})['then'](respondWithResult(_0x5c0c07,0xc9))[_0x9ef2('0x45')](handleError(_0x5c0c07,null));};exports[_0x9ef2('0x21')]=function(_0xb44984,_0x436e65){if(_0xb44984[_0x9ef2('0x47')]['id']){delete _0xb44984[_0x9ef2('0x47')]['id'];}return db[_0x9ef2('0x2b')][_0x9ef2('0x44')]({'where':{'id':_0xb44984[_0x9ef2('0x42')]['id']}})['then'](handleEntityNotFound(_0x436e65,null))[_0x9ef2('0x22')](saveUpdates(_0xb44984['body'],null))['then'](respondWithResult(_0x436e65,null))[_0x9ef2('0x45')](handleError(_0x436e65,null));};exports[_0x9ef2('0x25')]=function(_0x2a7a59,_0x166f42){return db[_0x9ef2('0x2b')][_0x9ef2('0x44')]({'where':{'id':_0x2a7a59[_0x9ef2('0x42')]['id']}})['then'](handleEntityNotFound(_0x166f42,null))['then'](removeEntity(_0x166f42,null))['catch'](handleError(_0x166f42,null));};