Built motion from commit e6806ed6.|2.6.0
[motion2.git] / server / api / userProfile / userProfile.controller.js
index a97a5b9..21fe9db 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc86f=['length','hasOwnProperty','nolimit','limit','order','sort','filter','where','merge','options','includeAll','include','findAll','show','params','find','catch','create','body','clone','omit','updatedAt','crudPermissions','createdAt','transaction','UserProfileSection','each','autoAssociation','sectionId','userProfileId','Resources','UserProfileResource','update','describe','sequelize','removeSections','ids','getSections','enabled','isEmpty','includes','subsections','push','findOne','forEach','resourceId','Plugin','addResources','bulkCreate','get','removeResources','getResources','section','undefined','Sequelize','ValidationError','Unknown\x20section','mergeResources','Invalid\x20section\x20\x27','parentSections','all','ignore','union','childModel','pick','type','VIRTUAL','field','associatedResources','foreignKey','reportType','default','reportId','rows','Tag','Tags','color','tag','ThroughTags','value','toLowerCase','squareprojects','SquareProject','odbc','squarerecordings','projectName','JscriptyProject','contacts','CmContact','Lists','ListId','lists','CmList','companies','CmCompany','CmCustomField','ChatQueue','chatwebsites','ChatWebsite','faxqueues','faxaccounts','internalroutes','VoiceExtension','contexts','VoiceContext','VoiceMail','VoiceRecording','Agents','User','role','Telephones','membername','telephone','VoiceQueues','queue','VoiceQueue','inbound','QueueCampaigns','outbound','VoiceMusicOnHold','chanspies','VoiceChanSpy','voiceprefixes','VoicePrefix','ivrcampaigns','Campaign','mailqueues','MailQueue','MailAccount','mailsubstatuses','MailSubstatus','openchannelqueues','OpenchannelQueue','openchannelaccounts','SmsQueue','smsaccounts','SmsAccount','whatsappqueues','teams','Team','voicequeues','users','agents','admin','user','ZendeskAccount','salesforceaccounts','freshdeskaccounts','FreshdeskAccount','SugarcrmAccount','deskaccounts','zohoaccounts','ZohoAccount','vtigeraccounts','CannedAnswer','dispositions','Disposition','customdashboards','Dashboard','intervals','Interval','pauses','Pause','scheduler','Schedule','sounds','Sound','tags','templates','triggers','variables','Variable','plugins','extractedreports','AnalyticExtractedReport','metrics','AnalyticMetric','whatsappaccounts','WhatsappAccount','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','util','sox','to-csv','ejs','squel','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','register','sendStatus','status','end','json','count','offset','apply','save','then','destroy','error','stack','UserProfile','rawAttributes','key','model','map','name','query','keys','filters','intersection','attributes','fields'];(function(_0x3ecd68,_0x4930c4){var _0x1a39cc=function(_0x549817){while(--_0x549817){_0x3ecd68['push'](_0x3ecd68['shift']());}};_0x1a39cc(++_0x4930c4);}(_0xc86f,0xb3));var _0xfc86=function(_0x2713f5,_0x382adb){_0x2713f5=_0x2713f5-0x0;var _0x4e6249=_0xc86f[_0x2713f5];return _0x4e6249;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xfc86('0x0'));var rimraf=require(_0xfc86('0x1'));var zipdir=require(_0xfc86('0x2'));var jsonpatch=require(_0xfc86('0x3'));var rp=require(_0xfc86('0x4'));var moment=require('moment');var BPromise=require(_0xfc86('0x5'));var Mustache=require('mustache');var util=require(_0xfc86('0x6'));var path=require('path');var sox=require(_0xfc86('0x7'));var csv=require(_0xfc86('0x8'));var ejs=require(_0xfc86('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0xfc86('0xa'));var crypto=require(_0xfc86('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xfc86('0xc'));var toCsv=require(_0xfc86('0x8'));var querystring=require('querystring');var Papa=require(_0xfc86('0xd'));var Redis=require(_0xfc86('0xe'));var authService=require(_0xfc86('0xf'));var qs=require(_0xfc86('0x10'));var as=require(_0xfc86('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xfc86('0x12'))(_0xfc86('0x13'));var utils=require('../../config/utils');var config=require(_0xfc86('0x14'));var licenseUtil=require(_0xfc86('0x15'));var db=require(_0xfc86('0x16'))['db'];config[_0xfc86('0x17')]=_['defaults'](config[_0xfc86('0x17')],{'host':_0xfc86('0x18'),'port':0x18eb});var socket=require(_0xfc86('0x19'))(new Redis(config[_0xfc86('0x17')]));require('./userProfile.socket')[_0xfc86('0x1a')](socket);function respondWithStatusCode(_0x1098c3,_0x3085f7){_0x3085f7=_0x3085f7||0xcc;return function(_0x49d0ca){if(_0x49d0ca){return _0x1098c3[_0xfc86('0x1b')](_0x3085f7);}return _0x1098c3[_0xfc86('0x1c')](_0x3085f7)[_0xfc86('0x1d')]();};}function respondWithResult(_0x1a31e8,_0x18ee80){_0x18ee80=_0x18ee80||0xc8;return function(_0x1f1a5c){if(_0x1f1a5c){return _0x1a31e8['status'](_0x18ee80)[_0xfc86('0x1e')](_0x1f1a5c);}};}function respondWithFilteredResult(_0x653a36,_0x347d00){return function(_0x9d3f03){if(_0x9d3f03){var _0x917206=_0x9d3f03[_0xfc86('0x1f')],_0x2e3167=_0x347d00[_0xfc86('0x20')],_0xaa96f1=_0x347d00[_0xfc86('0x20')]+_0x347d00['limit'],_0x117004;if(_0xaa96f1>=_0x917206){_0xaa96f1=_0x917206;_0x117004=0xc8;}else{_0x117004=0xce;}_0x653a36[_0xfc86('0x1c')](_0x117004);return _0x653a36['set']('Content-Range',_0x2e3167+'-'+_0xaa96f1+'/'+_0x917206)[_0xfc86('0x1e')](_0x9d3f03);}return null;};}function patchUpdates(_0x44c867){return function(_0x5439de){try{jsonpatch[_0xfc86('0x21')](_0x5439de,_0x44c867,!![]);}catch(_0xea65d9){return BPromise['reject'](_0xea65d9);}return _0x5439de[_0xfc86('0x22')]();};}function saveUpdates(_0x1a7cc6,_0x11238a){return function(_0x55e81a){if(_0x55e81a){return _0x55e81a['update'](_0x1a7cc6)[_0xfc86('0x23')](function(_0x386b16){return _0x386b16;});}return null;};}function removeEntity(_0x1cec62,_0x579d8e){return function(_0x912a3d){if(_0x912a3d){return _0x912a3d[_0xfc86('0x24')]()[_0xfc86('0x23')](function(){_0x1cec62['status'](0xcc)[_0xfc86('0x1d')]();});}};}function handleEntityNotFound(_0xa3322f,_0x20d90f){return function(_0x33b875){if(!_0x33b875){_0xa3322f[_0xfc86('0x1b')](0x194);}return _0x33b875;};}function handleError(_0xa590fa,_0x579497){_0x579497=_0x579497||0x1f4;return function(_0x3131a8){logger[_0xfc86('0x25')](_0x3131a8[_0xfc86('0x26')]);if(_0x3131a8['name']){delete _0x3131a8['name'];}_0xa590fa[_0xfc86('0x1c')](_0x579497)['send'](_0x3131a8);};}exports['index']=function(_0xf914cf,_0x3ccfcc){var _0x200be0={},_0x3a8ed4={},_0x29e60a={'count':0x0,'rows':[]};var _0x926029=_['map'](db[_0xfc86('0x27')][_0xfc86('0x28')],function(_0x12b693){return{'name':_0x12b693['fieldName'],'type':_0x12b693['type'][_0xfc86('0x29')]};});_0x3a8ed4[_0xfc86('0x2a')]=_[_0xfc86('0x2b')](_0x926029,_0xfc86('0x2c'));_0x3a8ed4[_0xfc86('0x2d')]=_[_0xfc86('0x2e')](_0xf914cf['query']);_0x3a8ed4[_0xfc86('0x2f')]=_[_0xfc86('0x30')](_0x3a8ed4[_0xfc86('0x2a')],_0x3a8ed4[_0xfc86('0x2d')]);_0x200be0[_0xfc86('0x31')]=_['intersection'](_0x3a8ed4[_0xfc86('0x2a')],qs['fields'](_0xf914cf[_0xfc86('0x2d')][_0xfc86('0x32')]));_0x200be0['attributes']=_0x200be0['attributes'][_0xfc86('0x33')]?_0x200be0[_0xfc86('0x31')]:_0x3a8ed4[_0xfc86('0x2a')];if(!_0xf914cf[_0xfc86('0x2d')][_0xfc86('0x34')](_0xfc86('0x35'))){_0x200be0[_0xfc86('0x36')]=qs['limit'](_0xf914cf['query']['limit']);_0x200be0[_0xfc86('0x20')]=qs['offset'](_0xf914cf['query'][_0xfc86('0x20')]);}_0x200be0[_0xfc86('0x37')]=qs[_0xfc86('0x38')](_0xf914cf['query'][_0xfc86('0x38')]);_0x200be0['where']=qs[_0xfc86('0x2f')](_['pick'](_0xf914cf[_0xfc86('0x2d')],_0x3a8ed4['filters']),_0x926029);if(_0xf914cf[_0xfc86('0x2d')][_0xfc86('0x39')]){_0x200be0[_0xfc86('0x3a')]=_[_0xfc86('0x3b')](_0x200be0[_0xfc86('0x3a')],{'$or':_['map'](_0x926029,function(_0x27d8e9){if(_0x27d8e9['type']!=='VIRTUAL'){var _0x1cbdca={};_0x1cbdca[_0x27d8e9[_0xfc86('0x2c')]]={'$like':'%'+_0xf914cf[_0xfc86('0x2d')][_0xfc86('0x39')]+'%'};return _0x1cbdca;}})});}_0x200be0=_['merge']({},_0x200be0,_0xf914cf[_0xfc86('0x3c')]);var _0x20da03={'where':_0x200be0[_0xfc86('0x3a')]};return db[_0xfc86('0x27')][_0xfc86('0x1f')](_0x20da03)['then'](function(_0x4a2cbf){_0x29e60a[_0xfc86('0x1f')]=_0x4a2cbf;if(_0xf914cf[_0xfc86('0x2d')][_0xfc86('0x3d')]){_0x200be0[_0xfc86('0x3e')]=[{'all':!![]}];}return db[_0xfc86('0x27')][_0xfc86('0x3f')](_0x200be0);})['then'](function(_0x4971eb){_0x29e60a['rows']=_0x4971eb;return _0x29e60a;})['then'](respondWithFilteredResult(_0x3ccfcc,_0x200be0))['catch'](handleError(_0x3ccfcc,null));};exports[_0xfc86('0x40')]=function(_0x4074d9,_0x4c5463){var _0x45f069={'raw':![],'where':{'id':_0x4074d9[_0xfc86('0x41')]['id']}},_0x4c6616={};_0x4c6616['model']=_[_0xfc86('0x2e')](db[_0xfc86('0x27')][_0xfc86('0x28')]);_0x4c6616['query']=_[_0xfc86('0x2e')](_0x4074d9[_0xfc86('0x2d')]);_0x4c6616[_0xfc86('0x2f')]=_[_0xfc86('0x30')](_0x4c6616[_0xfc86('0x2a')],_0x4c6616['query']);_0x45f069[_0xfc86('0x31')]=_[_0xfc86('0x30')](_0x4c6616[_0xfc86('0x2a')],qs[_0xfc86('0x32')](_0x4074d9[_0xfc86('0x2d')][_0xfc86('0x32')]));_0x45f069[_0xfc86('0x31')]=_0x45f069[_0xfc86('0x31')][_0xfc86('0x33')]?_0x45f069[_0xfc86('0x31')]:_0x4c6616['model'];if(_0x4074d9[_0xfc86('0x2d')][_0xfc86('0x3d')]){_0x45f069[_0xfc86('0x3e')]=[{'all':!![]}];}_0x45f069=_[_0xfc86('0x3b')]({},_0x45f069,_0x4074d9[_0xfc86('0x3c')]);return db[_0xfc86('0x27')][_0xfc86('0x42')](_0x45f069)[_0xfc86('0x23')](handleEntityNotFound(_0x4c5463,null))[_0xfc86('0x23')](respondWithResult(_0x4c5463,null))[_0xfc86('0x43')](handleError(_0x4c5463,null));};exports[_0xfc86('0x44')]=function(_0x3c4f3d,_0xd880e0){return db[_0xfc86('0x27')]['create'](_0x3c4f3d[_0xfc86('0x45')],{})[_0xfc86('0x23')](respondWithResult(_0xd880e0,0xc9))[_0xfc86('0x43')](handleError(_0xd880e0,null));};exports[_0xfc86('0x46')]=function(_0x39a2e,_0x26b236){var _0x26e602={'where':{'id':_0x39a2e['params']['id']}},_0x1f6911={};_0x1f6911[_0xfc86('0x2a')]=_[_0xfc86('0x2e')](db['UserProfile']['rawAttributes']);_0x26e602[_0xfc86('0x31')]=_[_0xfc86('0x30')](_0x1f6911[_0xfc86('0x2a')],qs[_0xfc86('0x32')](_0x39a2e['query'][_0xfc86('0x32')]));_0x26e602[_0xfc86('0x31')]=_0x26e602[_0xfc86('0x31')][_0xfc86('0x33')]?_0x26e602['attributes']:_0x1f6911[_0xfc86('0x2a')];if(_0x39a2e['query'][_0xfc86('0x3d')]){_0x26e602[_0xfc86('0x3e')]=[{'all':!![]}];}_0x26e602=_[_0xfc86('0x3b')]({},_0x26e602,_0x39a2e['options']);return db[_0xfc86('0x27')][_0xfc86('0x42')](_0x26e602)['then'](handleEntityNotFound(_0x26b236,null))['then'](function(_0x30a07e){if(_0x30a07e){var _0x5ee6fe=_0x30a07e['get']({'plain':!![]});_0x5ee6fe=qs[_0xfc86('0x47')](_0x5ee6fe,['id','createdAt',_0xfc86('0x48'),_0xfc86('0x49')]);_0x39a2e[_0xfc86('0x45')]=_[_0xfc86('0x47')](_0x39a2e[_0xfc86('0x45')],['id',_0xfc86('0x4a'),_0xfc86('0x48')]);return db['sequelize'][_0xfc86('0x4b')](function(_0xbfa740){return db[_0xfc86('0x27')][_0xfc86('0x44')](_[_0xfc86('0x3b')](_0x5ee6fe,_0x39a2e[_0xfc86('0x45')]),{'include':_0x39a2e['query'][_0xfc86('0x3d')]?[{'all':!![]}]:undefined,'transaction':_0xbfa740})[_0xfc86('0x23')](function(_0x2570fc){var _0x5382e5=_0x2570fc['get']({'plain':!![]});return db[_0xfc86('0x4c')][_0xfc86('0x3f')]({'where':{'userProfileId':_0x39a2e[_0xfc86('0x41')]['id']},'raw':!![]})[_0xfc86('0x23')](function(_0x54b1f0){if(_0x54b1f0){return BPromise[_0xfc86('0x4d')](_0x54b1f0,function(_0x2acb34){return new BPromise(function(_0x43b6f6,_0x506ad7){if(_0x2acb34[_0xfc86('0x4e')]===null||_0x2acb34[_0xfc86('0x4e')]===0x1)_0x43b6f6(null);return db['UserProfileResource']['findAll']({'where':{'sectionId':_0x2acb34['id']},'raw':!![]})[_0xfc86('0x23')](function(_0x20f8d6){var _0x161a59=_[_0xfc86('0x2b')](_0x20f8d6,function(_0x49035c){return qs[_0xfc86('0x47')](_0x49035c,['id',_0xfc86('0x4a'),_0xfc86('0x48'),_0xfc86('0x4f')]);});_0x43b6f6(_0x161a59);})[_0xfc86('0x43')](function(_0x4ccf3c){_0x506ad7(_0x4ccf3c);});})['then'](function(_0x45e5ad){var _0x46f5c5=qs[_0xfc86('0x47')](_0x2acb34,['id',_0xfc86('0x4a'),'updatedAt']);_0x46f5c5[_0xfc86('0x50')]=_0x5382e5['id'];if(_0x45e5ad)_0x46f5c5[_0xfc86('0x51')]=_0x45e5ad;return _0x46f5c5;})[_0xfc86('0x23')](function(_0x2ce8e3){return db[_0xfc86('0x4c')]['create'](_0x2ce8e3,{'include':[{'model':db[_0xfc86('0x52')],'as':_0xfc86('0x51')}],'raw':!![],'transaction':_0xbfa740});});})[_0xfc86('0x23')](function(){return _0x5382e5;});}});});});}})[_0xfc86('0x23')](respondWithResult(_0x26b236,0xc9))[_0xfc86('0x43')](handleError(_0x26b236,null));};exports[_0xfc86('0x53')]=function(_0x252ecd,_0x3368ce){if(_0x252ecd[_0xfc86('0x45')]['id']){delete _0x252ecd[_0xfc86('0x45')]['id'];}return db[_0xfc86('0x27')][_0xfc86('0x42')]({'where':{'id':_0x252ecd['params']['id']}})[_0xfc86('0x23')](handleEntityNotFound(_0x3368ce,null))['then'](saveUpdates(_0x252ecd[_0xfc86('0x45')],null))[_0xfc86('0x23')](respondWithResult(_0x3368ce,null))['catch'](handleError(_0x3368ce,null));};exports['destroy']=function(_0x12ccf8,_0x3b76f4){return db['UserProfile'][_0xfc86('0x42')]({'where':{'id':_0x12ccf8[_0xfc86('0x41')]['id']}})[_0xfc86('0x23')](handleEntityNotFound(_0x3b76f4,null))[_0xfc86('0x23')](removeEntity(_0x3b76f4,null))[_0xfc86('0x43')](handleError(_0x3b76f4,null));};exports[_0xfc86('0x54')]=function(_0x511685,_0x2825aa){return db[_0xfc86('0x27')][_0xfc86('0x54')]()[_0xfc86('0x23')](respondWithResult(_0x2825aa,null))[_0xfc86('0x43')](handleError(_0x2825aa,null));};exports['addSections']=function(_0x200c88,_0x3bcb42){var _0x16188d=_0x200c88[_0xfc86('0x45')];return db[_0xfc86('0x27')][_0xfc86('0x42')]({'where':{'id':_0x200c88['params']['id']}})[_0xfc86('0x23')](handleEntityNotFound(_0x3bcb42,null))[_0xfc86('0x23')](function(_0x42a726){if(_0x42a726){return db[_0xfc86('0x55')]['transaction'](function(_0x3ff6ef){return db[_0xfc86('0x4c')][_0xfc86('0x24')]({'where':{'userProfileId':_0x200c88[_0xfc86('0x41')]['id'],'sectionId':_[_0xfc86('0x2b')](_0x16188d,function(_0x51d989){return _0x51d989[_0xfc86('0x4f')];})},'transaction':_0x3ff6ef})[_0xfc86('0x23')](function(){var _0x20292f=_['map'](_0x16188d,function(_0x396dfd){_0x396dfd[_0xfc86('0x50')]=_0x200c88[_0xfc86('0x41')]['id'];return _0x396dfd;});var _0x32c0b5=[];return BPromise[_0xfc86('0x4d')](_0x20292f,function(_0x505e34){return db[_0xfc86('0x4c')]['create'](_0x505e34,{'include':[{'model':db[_0xfc86('0x52')],'as':_0xfc86('0x51')}],'raw':!![],'transaction':_0x3ff6ef})[_0xfc86('0x23')](function(_0x4a9fd5){_0x32c0b5['push'](_0x4a9fd5['get']({'plain':!![]}));});})[_0xfc86('0x23')](function(){return _0x32c0b5;});});});}})[_0xfc86('0x23')](function(_0xbccff3){return _0xbccff3;})['then'](respondWithResult(_0x3bcb42,null))[_0xfc86('0x43')](handleError(_0x3bcb42,null));};exports[_0xfc86('0x56')]=function(_0x586a88,_0x27c2d2){var _0x20b96c;return db[_0xfc86('0x27')][_0xfc86('0x42')]({'where':{'id':_0x586a88[_0xfc86('0x41')]['id']},'attributes':['id',_0xfc86('0x2c')]})[_0xfc86('0x23')](handleEntityNotFound(_0x27c2d2,null))[_0xfc86('0x23')](function(_0x821fbc){if(_0x821fbc){_0x20b96c=_0x821fbc;return db[_0xfc86('0x4c')][_0xfc86('0x24')]({'where':{'userProfileId':_0x586a88[_0xfc86('0x41')]['id'],'sectionId':_0x586a88[_0xfc86('0x2d')][_0xfc86('0x57')]}});}})[_0xfc86('0x23')](function(){return _0x20b96c;})['then'](respondWithStatusCode(_0x27c2d2,null))[_0xfc86('0x43')](handleError(_0x27c2d2,null));};exports[_0xfc86('0x58')]=function(_0xedcfc3,_0x19d2a1){var _0x473694=[];var _0x12735e=[];return db['UserProfileSection'][_0xfc86('0x3f')]({'where':{'userProfileId':_0xedcfc3[_0xfc86('0x41')]['id']},'raw':!![]})[_0xfc86('0x23')](function(_0x1d2aff){_0x473694=_[_0xfc86('0x39')](_0x1d2aff,function(_0x3b0cf4){return _0x3b0cf4[_0xfc86('0x59')]===0x1||_['includes']([0x3eb,0x709],_0x3b0cf4[_0xfc86('0x4f')]);});if(!_[_0xfc86('0x5a')](_0x473694)){return _[_0xfc86('0x2b')](_0x473694,function(_0xc840ad){return _0xc840ad[_0xfc86('0x4f')];});}else{return;}})['then'](function(_0x2aeafc){if(_0x2aeafc)_0x12735e=_0x2aeafc;if(_[_0xfc86('0x5b')](_0x12735e,0x64)){var _0x103c31=_[_0xfc86('0x42')](_0x473694,{'sectionId':0x64});return hasDefaultDashboard(_0x103c31)[_0xfc86('0x23')](function(_0x2cb602){return _[_0xfc86('0x2b')](_0x473694,function(_0x364107){if(_0x364107[_0xfc86('0x4f')]===0x64){_0x364107[_0xfc86('0x5c')]=_0x2cb602;}return _0x364107;});});}else{return;}})[_0xfc86('0x23')](function(_0x118a91){if(_0x118a91)_0x473694=_0x118a91;if(_['includes'](_0x12735e,0x3eb)){var _0x4a41fa=_['find'](_0x473694,{'sectionId':0x3eb});return getCustomDashboards(_0x4a41fa)[_0xfc86('0x23')](function(_0x25dca6){return _[_0xfc86('0x2b')](_0x473694,function(_0x4348cb){if(_0x4a41fa[_0xfc86('0x59')]){if(_0x4348cb[_0xfc86('0x4f')]===0x3eb){_0x4348cb[_0xfc86('0x5c')]=_0x25dca6;}}else{if(_0x4348cb[_0xfc86('0x4f')]===0x64){_0x4348cb[_0xfc86('0x5c')]=_0x25dca6;}}return _0x4348cb;});});}else{return;}})[_0xfc86('0x23')](function(_0x3a0b03){if(_0x3a0b03)_0x473694=_0x3a0b03;if(_[_0xfc86('0x5b')](_0x12735e,0x709)){var _0x470420=_[_0xfc86('0x42')](_0x473694,{'sectionId':0x709});return getPlugins(_0x470420)[_0xfc86('0x23')](function(_0x31a4be){if(_0x470420[_0xfc86('0x59')]){return _[_0xfc86('0x2b')](_0x473694,function(_0x3d875a){if(_0x3d875a[_0xfc86('0x4f')]===0x709){_0x3d875a[_0xfc86('0x5c')]=_0x31a4be;}return _0x3d875a;});}else{var _0x2c629b={'sectionId':0x76c,'enabled':0x1,'subsections':_0x31a4be};var _0x16392f=_['map'](_0x473694);_0x16392f[_0xfc86('0x5d')](_0x2c629b);return _0x16392f;}});}else{return;}})[_0xfc86('0x23')](function(_0x1a31bb){if(_0x1a31bb)_0x473694=_0x1a31bb;return _[_0xfc86('0x39')](_0x473694,['enabled',0x1]);})['then'](respondWithResult(_0x19d2a1,null))[_0xfc86('0x43')](handleError(_0x19d2a1,null));};function hasDefaultDashboard(_0x38a363){var _0x21fe8c=[0x65];return new BPromise(function(_0x3158ed,_0x5f1078){try{if(_0x38a363[_0xfc86('0x4e')]){_0x3158ed(_0x21fe8c);}else{return db['UserProfileResource'][_0xfc86('0x5e')]({'where':{'sectionId':_0x38a363['id']},'raw':!![]})[_0xfc86('0x23')](function(_0x2ef5c5){_0x2ef5c5?_0x3158ed(_0x21fe8c):_0x3158ed();});}}catch(_0x27833d){_0x5f1078(_0x27833d);}});}function getCustomDashboards(_0x436052){var _0x377e37=[];return new BPromise(function(_0x5c8cff,_0x289f20){try{if(_0x436052[_0xfc86('0x4e')]){return db['Dashboard'][_0xfc86('0x3f')]({'raw':!![]})[_0xfc86('0x23')](function(_0x5ec156){_0x5ec156[_0xfc86('0x5f')](function(_0x57ec9b){_0x377e37[_0xfc86('0x5d')](_0x57ec9b['id']+0x1869f);});_0x5c8cff(_0x377e37);});}else{return db[_0xfc86('0x52')][_0xfc86('0x3f')]({'where':{'sectionId':_0x436052['id']},'raw':!![]})[_0xfc86('0x23')](function(_0x2035a5){_0x2035a5['forEach'](function(_0x1b8b71){_0x377e37[_0xfc86('0x5d')](_0x1b8b71[_0xfc86('0x60')]+0x1869f);});_0x5c8cff(_0x377e37);});}}catch(_0x31b90a){_0x289f20(_0x31b90a);}});}function getPlugins(_0x278046){var _0x35f4a5=[];return new BPromise(function(_0x7dfbc,_0x2a644a){try{if(_0x278046['autoAssociation']){return db[_0xfc86('0x61')][_0xfc86('0x3f')]({'raw':!![]})[_0xfc86('0x23')](function(_0x20a2ed){_0x20a2ed['forEach'](function(_0x3d6dfe){_0x35f4a5[_0xfc86('0x5d')](_0x3d6dfe['id']+0x15b38);});_0x7dfbc(_0x35f4a5);});}else{return db[_0xfc86('0x52')][_0xfc86('0x3f')]({'where':{'sectionId':_0x278046['id']},'raw':!![]})[_0xfc86('0x23')](function(_0x3f910f){_0x3f910f['forEach'](function(_0x1ee07e){_0x35f4a5[_0xfc86('0x5d')](_0x1ee07e[_0xfc86('0x60')]+0x15b38);});_0x7dfbc(_0x35f4a5);});}}catch(_0xf4b6f9){_0x2a644a(_0xf4b6f9);}});}exports[_0xfc86('0x62')]=function(_0x1149ee,_0x6b19e1){return db[_0xfc86('0x27')]['find']({'where':{'id':_0x1149ee[_0xfc86('0x41')]['id']}})[_0xfc86('0x23')](handleEntityNotFound(_0x6b19e1,null))[_0xfc86('0x23')](function(_0x7501d3){if(_0x7501d3){return db['sequelize'][_0xfc86('0x4b')](function(_0x4a082b){return db['UserProfileSection'][_0xfc86('0x3f')]({'where':{'userProfileId':_0x1149ee[_0xfc86('0x41')]['id']},'attributes':['id'],'raw':!![]})[_0xfc86('0x23')](function(_0xe02640){if(_0xe02640){return db[_0xfc86('0x4c')][_0xfc86('0x24')]({'where':{'userProfileId':_0x1149ee[_0xfc86('0x41')]['id'],'id':_[_0xfc86('0x2b')](_0xe02640,function(_0x209e0a){return _0x209e0a['id'];})},'transaction':_0x4a082b});}})['then'](function(_0x137c17){var _0x2c7dbb=_['map'](_0x1149ee[_0xfc86('0x45')],function(_0x1a7e5d){_0x1a7e5d[_0xfc86('0x50')]=_0x1149ee[_0xfc86('0x41')]['id'];return _0x1a7e5d;});return db[_0xfc86('0x4c')][_0xfc86('0x63')](_0x2c7dbb,{'raw':!![],'transaction':_0x4a082b});})[_0xfc86('0x23')](function(_0x1d24cc){var _0x59f1a6=_[_0xfc86('0x39')](_[_0xfc86('0x2b')](_0x1d24cc,function(_0x386988){return _0x386988['get']({'plain':!![]});}),{'includeAll':![]});if(_0x59f1a6){return db[_0xfc86('0x4c')][_0xfc86('0x3f')]({'where':{'userProfileId':_0x1149ee[_0xfc86('0x41')]['id'],'sectionId':_[_0xfc86('0x2b')](_0x59f1a6,function(_0x5a18eb){return _0x5a18eb[_0xfc86('0x4f')];})},'attributes':['id',_0xfc86('0x4f')],'raw':!![]})[_0xfc86('0x23')](function(_0x40482e){var _0x1b04c=_['map'](_0x1149ee[_0xfc86('0x45')],function(_0x5d429a){_0x5d429a['userProfileId']=_0x1149ee[_0xfc86('0x41')]['id'];return _0x5d429a;});return db[_0xfc86('0x52')][_0xfc86('0x63')](_0x1b04c,{'raw':!![],'transaction':_0x4a082b});});}})[_0xfc86('0x43')](handleError(_0x6b19e1,null));});}})[_0xfc86('0x23')](function(_0x4aac1e){var _0x35ec80=_[_0xfc86('0x2b')](_0x4aac1e,function(_0x31a244){return _0x31a244[_0xfc86('0x64')]({'plain':!![]});});})[_0xfc86('0x23')](respondWithResult(_0x6b19e1,null))[_0xfc86('0x43')](handleError(_0x6b19e1,null));};exports[_0xfc86('0x65')]=function(_0xb5d911,_0x355887,_0x58f41f){return db[_0xfc86('0x27')][_0xfc86('0x42')]({'where':{'id':_0xb5d911[_0xfc86('0x41')]['id']}})['then'](handleEntityNotFound(_0x355887,null))[_0xfc86('0x23')](function(_0x26639b){if(_0x26639b){return _0x26639b['removeResources'](_0xb5d911[_0xfc86('0x2d')][_0xfc86('0x57')]);}})[_0xfc86('0x23')](respondWithStatusCode(_0x355887,null))['catch'](handleError(_0x355887,null));};exports[_0xfc86('0x66')]=function(_0x5999de,_0xfa1a08){var _0x5a723d={'raw':![],'where':{}};var _0x1e3fab={};var _0x332444={'count':0x0,'rows':[]};var _0x4738d6=_0x5999de[_0xfc86('0x2d')][_0xfc86('0x67')];if(typeof _0x4738d6===_0xfc86('0x68')){throw new db[(_0xfc86('0x69'))][(_0xfc86('0x6a'))](_0xfc86('0x6b'));}var _0x3a7868=_0x5999de['query'][_0xfc86('0x6c')]||![];var _0x3cdbb2=getQueryModels(_0x4738d6,_0x3a7868);if(typeof _0x3cdbb2['childModel']==='undefined'){throw new db['Sequelize']['ValidationError'](_0xfc86('0x6d')+_0x4738d6+'\x27');}var _0x259e50=[];if(!_['isEmpty'](_0x3cdbb2[_0xfc86('0x6e')])){_0x259e50=_0x3cdbb2[_0xfc86('0x6e')];}else{_0x259e50=[{'name':_0x4738d6}];}return db['UserProfile'][_0xfc86('0x5e')]({'where':{'id':_0x5999de[_0xfc86('0x41')]['id']}})['then'](handleEntityNotFound(_0xfa1a08,null))[_0xfc86('0x23')](function(_0x1ad19d){if(_0x1ad19d){var _0x5e411e=[];for(var _0x22c8c3=0x0;_0x22c8c3<_0x259e50[_0xfc86('0x33')];_0x22c8c3++){_0x5e411e[_0xfc86('0x5d')](db['UserProfileSection'][_0xfc86('0x5e')]({'where':{'userProfileId':_0x1ad19d['id'],'name':_0x259e50[_0x22c8c3][_0xfc86('0x2c')]},'raw':!![]}));}return BPromise[_0xfc86('0x6f')](_0x5e411e);}})['then'](function(_0x9e1b68){var _0x5add7b=_[_0xfc86('0x39')](_0x9e1b68,function(_0x2e4af0){return _0x2e4af0?_0x2e4af0:undefined;});var _0x5c9b05=_['filter'](_0x259e50,[_0xfc86('0x70'),!![]]);var _0x494267=_[_0xfc86('0x5a')](_0x5add7b)&&_['isEmpty'](_0x5c9b05)?null:_[_0xfc86('0x71')](_0x5c9b05,_0x5add7b);if(_0x494267){var _0x6a4373=[];for(var _0x986ce7=0x0;_0x986ce7<_0x494267[_0xfc86('0x33')];_0x986ce7++){var _0x40f995=_[_0xfc86('0x42')](_0x259e50,function(_0x2a884d){return _0x494267[_0x986ce7]?_0x2a884d[_0xfc86('0x2c')]===_0x494267[_0x986ce7][_0xfc86('0x2c')]:null;});if(_0x40f995){if(_0x494267[_0x986ce7][_0xfc86('0x70')]){_0x6a4373['push'](getAllResources(_0x3cdbb2[_0xfc86('0x72')],_0x494267[_0x986ce7]));}else{if(!_0x494267[_0x986ce7]['autoAssociation']){_0x6a4373[_0xfc86('0x5d')](getAllowedResources(_0x40f995,_0x494267[_0x986ce7],_0x3cdbb2[_0xfc86('0x72')]));}else{if(_0x40f995[_0xfc86('0x2a')]){_0x6a4373['push'](getAllFilteredResources(_0x40f995,_0x494267[_0x986ce7]));}}}}}return BPromise['all'](_0x6a4373);}else{return null;}})[_0xfc86('0x23')](function(_0x57233b){var _0x450bac=_0x57233b;var _0x1b4b11=null;if(_0x450bac){_0x1b4b11=_0x450bac[_0xfc86('0x33')]===0x1?_0x450bac[0x0]:null;}if(_0x1b4b11||_0x450bac){var _0x13d6c5=db[_0x3cdbb2[_0xfc86('0x72')]][_0xfc86('0x28')];_0x1e3fab[_0xfc86('0x2a')]=_[_0xfc86('0x2e')](_0x13d6c5);_0x1e3fab['query']=_[_0xfc86('0x2e')](_0x5999de[_0xfc86('0x2d')]);_0x1e3fab['filters']=_[_0xfc86('0x30')](_0x1e3fab[_0xfc86('0x2a')],_0x1e3fab[_0xfc86('0x2d')]);_0x5a723d[_0xfc86('0x31')]=_['intersection'](_0x1e3fab[_0xfc86('0x2a')],qs[_0xfc86('0x32')](_0x5999de['query'][_0xfc86('0x32')]));_0x5a723d['attributes']=_0x5a723d['attributes'][_0xfc86('0x33')]?_0x5a723d['attributes']:_0x1e3fab['model'];if(!_0x5999de[_0xfc86('0x2d')][_0xfc86('0x34')]('nolimit')){_0x5a723d['limit']=qs[_0xfc86('0x36')](_0x5999de[_0xfc86('0x2d')]['limit']);_0x5a723d[_0xfc86('0x20')]=qs[_0xfc86('0x20')](_0x5999de[_0xfc86('0x2d')][_0xfc86('0x20')]);}_0x5a723d[_0xfc86('0x37')]=qs['sort'](_0x5999de[_0xfc86('0x2d')][_0xfc86('0x38')]);_0x5a723d[_0xfc86('0x3a')]=qs[_0xfc86('0x2f')](_[_0xfc86('0x73')](_0x5999de[_0xfc86('0x2d')],_0x1e3fab['filters']));if(_0x5999de['query']['filter']){_0x5a723d[_0xfc86('0x3a')]=_[_0xfc86('0x3b')](_0x5a723d[_0xfc86('0x3a')],{'$or':_['map'](_0x13d6c5,function(_0x4a5ef0){if(_0x4a5ef0[_0xfc86('0x74')][_0xfc86('0x29')]!==_0xfc86('0x75')){var _0x44abfc={};_0x44abfc[_0x4a5ef0[_0xfc86('0x76')]]={'$like':'%'+_0x5999de[_0xfc86('0x2d')][_0xfc86('0x39')]+'%'};return _0x44abfc;}})});}var _0x46d9b6=[];if(_0x1b4b11){var _0x48452c=_[_0xfc86('0x42')](_0x259e50,[_0xfc86('0x2c'),_0x1b4b11['name']]);if(_0x48452c['field']){var _0x28bad9={};if(_0x3cdbb2[_0xfc86('0x72')]==='AnalyticExtractedReport'){_0x28bad9[_0x48452c['foreignKey']]=_[_0xfc86('0x2b')](_0x1b4b11[_0xfc86('0x77')],'id');}else{_0x28bad9[_0x48452c['foreignKey']]=_0x1b4b11[_0xfc86('0x77')];}_0x46d9b6[_0xfc86('0x5d')](_0x28bad9);}else{_0x5a723d[_0xfc86('0x3a')]['id']=_0x1b4b11[_0xfc86('0x77')];}}else{for(var _0x310728=0x0;_0x310728<_0x450bac[_0xfc86('0x33')];_0x310728++){var _0x48452c=_[_0xfc86('0x42')](_0x259e50,['name',_0x450bac[_0x310728][_0xfc86('0x2c')]]);if(_0x48452c[_0xfc86('0x76')]){var _0x28bad9={};_0x28bad9[_0x48452c[_0xfc86('0x78')]]=_0x450bac[_0x310728]['associatedResources'];_0x46d9b6[_0xfc86('0x5d')](_0x28bad9);}else{if(!_0x5a723d[_0xfc86('0x3a')]['id'])_0x5a723d[_0xfc86('0x3a')]['id']=[];_0x450bac[_0x310728]['associatedResources']['forEach'](function(_0x3b837f){_0x5a723d[_0xfc86('0x3a')]['id'][_0xfc86('0x5d')](_0x3b837f);});}}}if(!_['isEmpty'](_0x46d9b6)){_0x5a723d[_0xfc86('0x3a')]=_[_0xfc86('0x3b')](_0x5a723d[_0xfc86('0x3a')],{'$and':{'$or':_0x46d9b6}});}_0x5a723d=_[_0xfc86('0x3b')]({},_0x5a723d,_0x5999de[_0xfc86('0x3c')]);if(_0x1b4b11&&!_0x1b4b11[_0xfc86('0x4e')]&&_0x3cdbb2[_0xfc86('0x72')]==='AnalyticExtractedReport'){if(_0x5999de['query'][_0xfc86('0x3d')]){_0x5a723d[_0xfc86('0x3e')]=[{'all':!![]}];}return db[_0x3cdbb2['childModel']][_0xfc86('0x3f')](_0x5a723d)[_0xfc86('0x23')](function(_0x1751ac){var _0x50d07a=[];_0x1751ac[_0xfc86('0x5f')](function(_0x338a47){var _0x38baf7;switch(_0x338a47[_0xfc86('0x79')]){case _0xfc86('0x7a'):_0x38baf7=_['find'](_0x1b4b11['associatedResources'],function(_0x414aaa){return _0x414aaa['id']===_0x338a47[_0xfc86('0x7b')]&&_0x414aaa[_0xfc86('0x74')]==='DefaultReports';});break;case'custom':_0x38baf7=_[_0xfc86('0x42')](_0x1b4b11[_0xfc86('0x77')],function(_0x451630){return _0x451630['id']===_0x338a47[_0xfc86('0x7b')]&&_0x451630[_0xfc86('0x74')]==='CustomReports';});break;}if(_0x38baf7)_0x50d07a[_0xfc86('0x5d')](_0x338a47);});_0x332444[_0xfc86('0x1f')]=_0x50d07a['length'];_0x332444[_0xfc86('0x7c')]=_0x50d07a;return _0x332444;});}else{return db[_0x3cdbb2[_0xfc86('0x72')]][_0xfc86('0x1f')]({'where':_0x5a723d[_0xfc86('0x3a')]})[_0xfc86('0x23')](function(_0x415601){_0x332444[_0xfc86('0x1f')]=_0x415601;if(_0x5999de[_0xfc86('0x2d')]['includeAll']){if(_0x3cdbb2[_0xfc86('0x72')]==='CmContact'){_0x5a723d[_0xfc86('0x3e')]=[{'model':db[_0xfc86('0x7d')],'as':_0xfc86('0x7e'),'attributes':['id',_0xfc86('0x2c'),_0xfc86('0x7f')],'required':_0x5999de[_0xfc86('0x2d')][_0xfc86('0x80')]?!![]:![]},{'model':db[_0xfc86('0x7d')],'as':_0xfc86('0x81'),'attributes':['id','name',_0xfc86('0x7f')],'through':_0x5999de[_0xfc86('0x2d')][_0xfc86('0x80')]?{'attributes':[],'where':{'TagId':_0x5999de[_0xfc86('0x2d')]['tag']||undefined}}:{},'required':_0x5999de[_0xfc86('0x2d')][_0xfc86('0x80')]?!![]:![]}];}else{_0x5a723d[_0xfc86('0x3e')]=[{'all':!![]}];}}return db[_0x3cdbb2[_0xfc86('0x72')]]['findAll'](_0x5a723d);})[_0xfc86('0x23')](function(_0x26352a){_0x332444[_0xfc86('0x7c')]=_0x26352a;return _0x332444;});}}else{return _0x332444;}})['then'](respondWithFilteredResult(_0xfa1a08,_0x5a723d))[_0xfc86('0x43')](handleError(_0xfa1a08,null));};function getAllResources(_0x325d0c,_0x55a15c){return new BPromise(function(_0xd647cb,_0x29dc1c){if(_0x55a15c){var _0x2c3708=_0x55a15c[_0xfc86('0x39')]?{[_0x55a15c['filter'][_0xfc86('0x76')]]:_0x55a15c[_0xfc86('0x39')][_0xfc86('0x82')]}:undefined;return db[_0x325d0c]['findAll']({'where':_0x2c3708,'raw':!![]})['then'](function(_0xd409bc){_0x55a15c['associatedResources']=_[_0xfc86('0x2b')](_0xd409bc,'id');_0xd647cb(_0x55a15c);})[_0xfc86('0x43')](function(_0x3a8d02){_0x29dc1c(_0x3a8d02);});}else{_0xd647cb(null);}});}function getAllFilteredResources(_0x1df586,_0x4d5f53){return new BPromise(function(_0x3f3fe0,_0xb2983b){var _0x26cea8=_0x1df586[_0xfc86('0x39')]?{[_0x1df586['filter'][_0xfc86('0x76')]]:_0x1df586[_0xfc86('0x39')][_0xfc86('0x82')]}:undefined;return db[_0x1df586[_0xfc86('0x2a')]][_0xfc86('0x3f')]({'where':_0x26cea8,'raw':!![]})[_0xfc86('0x23')](function(_0x3e8a10){_0x4d5f53[_0xfc86('0x77')]=_[_0xfc86('0x2b')](_0x3e8a10,function(_0x34b84f){return _0x34b84f[_0xfc86('0x2c')];});_0x3f3fe0(_0x4d5f53);})['catch'](function(_0x57b607){_0xb2983b(_0x57b607);});});}function getAllowedResources(_0x153b7d,_0x3d0399,_0x18a618){return new BPromise(function(_0x1eea63,_0x159405){if(_0x3d0399){return db[_0xfc86('0x52')]['findAll']({'where':{'sectionId':_0x3d0399['id']},'raw':!![]})[_0xfc86('0x23')](function(_0x44d6ff){if(_0x153b7d[_0xfc86('0x76')]&&_0x153b7d[_0xfc86('0x76')]!=='id'){_0x3d0399[_0xfc86('0x77')]=_['map'](_0x44d6ff,function(_0x796a48){return _0x796a48[_0x153b7d[_0xfc86('0x76')]];});}else{if(_0x18a618==='AnalyticExtractedReport'){_0x3d0399['associatedResources']=_[_0xfc86('0x2b')](_0x44d6ff,function(_0x996da8){return{'id':_0x996da8[_0xfc86('0x60')],'type':_0x996da8[_0xfc86('0x74')]};});}else{_0x3d0399['associatedResources']=_[_0xfc86('0x2b')](_0x44d6ff,function(_0x56c7bc){return _0x56c7bc[_0xfc86('0x60')];});}}_0x1eea63(_0x3d0399);})[_0xfc86('0x43')](function(_0x2cc39b){_0x159405(_0x2cc39b);});}else{_0x1eea63(null);}});}function getQueryModels(_0x1312fd,_0x4f79e1){var _0x4a5b51=_0x1312fd[_0xfc86('0x83')]();var _0x1fd847={'childModel':undefined,'parentSections':[]};switch(_0x4a5b51){case _0xfc86('0x84'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0x85');break;case _0xfc86('0x86'):_0x1fd847[_0xfc86('0x72')]='SquareOdbc';break;case _0xfc86('0x87'):_0x1fd847[_0xfc86('0x72')]='SquareRecording';_0x1fd847['parentSections']=[{'name':'SquareProjects','field':'name','foreignKey':_0xfc86('0x88')}];break;case'projects':_0x1fd847[_0xfc86('0x72')]=_0xfc86('0x89');break;case _0xfc86('0x8a'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0x8b');_0x1fd847[_0xfc86('0x6e')]=[{'name':_0xfc86('0x8c'),'field':'id','foreignKey':_0xfc86('0x8d')}];break;case _0xfc86('0x8e'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0x8f');break;case _0xfc86('0x90'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0x91');break;case'globalcustomfields':_0x1fd847['childModel']=_0xfc86('0x92');break;case'chatqueues':_0x1fd847[_0xfc86('0x72')]=_0xfc86('0x93');break;case _0xfc86('0x94'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0x95');break;case _0xfc86('0x96'):_0x1fd847[_0xfc86('0x72')]='FaxQueue';break;case _0xfc86('0x97'):_0x1fd847['childModel']='FaxAccount';break;case'inboundroutes':case _0xfc86('0x98'):case'outboundroutes':_0x1fd847[_0xfc86('0x72')]=_0xfc86('0x99');break;case _0xfc86('0x9a'):_0x1fd847['childModel']=_0xfc86('0x9b');break;case'voicemails':_0x1fd847[_0xfc86('0x72')]=_0xfc86('0x9c');break;case'voicerecordings':_0x1fd847['childModel']=_0xfc86('0x9d');_0x1fd847[_0xfc86('0x6e')]=[{'name':_0xfc86('0x9e'),'field':'name','foreignKey':'membername','model':_0xfc86('0x9f'),'filter':{'field':_0xfc86('0xa0'),'value':['agent']}},{'name':_0xfc86('0xa1'),'field':_0xfc86('0x2c'),'foreignKey':_0xfc86('0xa2'),'model':'User','filter':{'field':_0xfc86('0xa0'),'value':[_0xfc86('0xa3')]}},{'name':_0xfc86('0xa4'),'field':'name','foreignKey':_0xfc86('0xa5'),'model':_0xfc86('0xa6'),'filter':{'field':_0xfc86('0x74'),'value':[_0xfc86('0xa7')]}},{'name':_0xfc86('0xa8'),'field':_0xfc86('0x2c'),'foreignKey':_0xfc86('0xa5'),'model':'VoiceQueue','filter':{'field':_0xfc86('0x74'),'value':[_0xfc86('0xa9')]}}];break;case'musiconholds':_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xaa');break;case _0xfc86('0xab'):_0x1fd847['childModel']=_0xfc86('0xac');break;case _0xfc86('0xad'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xae');break;case _0xfc86('0xaf'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xb0');break;case _0xfc86('0xb1'):_0x1fd847['childModel']=_0xfc86('0xb2');break;case'mailaccounts':_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xb3');break;case _0xfc86('0xb4'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xb5');break;case _0xfc86('0xb6'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xb7');break;case _0xfc86('0xb8'):_0x1fd847[_0xfc86('0x72')]='OpenchannelAccount';break;case'smsqueues':_0x1fd847['childModel']=_0xfc86('0xb9');break;case _0xfc86('0xba'):_0x1fd847['childModel']=_0xfc86('0xbb');break;case _0xfc86('0xbc'):_0x1fd847[_0xfc86('0x72')]='WhatsappQueue';break;case'whatsappaccounts':_0x1fd847[_0xfc86('0x72')]='WhatsappAccount';break;case _0xfc86('0xbd'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xbe');break;case _0xfc86('0xbf'):case'queuecampaigns':_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xa6');if(_0x4f79e1){_0x1fd847[_0xfc86('0x6e')]=[{'name':_0xfc86('0xa4')},{'name':_0xfc86('0xa8')}];}break;case _0xfc86('0xc0'):case _0xfc86('0xc1'):case'telephones':_0x1fd847['childModel']=_0xfc86('0x9f');if(_0x4f79e1){_0x1fd847[_0xfc86('0x6e')]=[{'name':'Users','filter':{'field':_0xfc86('0xa0'),'value':[_0xfc86('0xc2'),_0xfc86('0xc3')]},'ignore':!![]},{'name':_0xfc86('0x9e')},{'name':'Telephones'}];}break;case'zendeskaccounts':_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xc4');break;case _0xfc86('0xc5'):_0x1fd847[_0xfc86('0x72')]='SalesforceAccount';break;case _0xfc86('0xc6'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xc7');break;case'sugarcrmaccounts':_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xc8');break;case _0xfc86('0xc9'):_0x1fd847[_0xfc86('0x72')]='DeskAccount';break;case _0xfc86('0xca'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xcb');break;case _0xfc86('0xcc'):_0x1fd847['childModel']=_0xfc86('0x9f');break;case'cannedanswers':_0x1fd847['childModel']=_0xfc86('0xcd');break;case _0xfc86('0xce'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xcf');break;case _0xfc86('0xd0'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xd1');break;case _0xfc86('0xd2'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xd3');break;case _0xfc86('0xd4'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xd5');break;case _0xfc86('0xd6'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xd7');break;case _0xfc86('0xd8'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xd9');break;case _0xfc86('0xda'):_0x1fd847[_0xfc86('0x72')]='Tag';break;case _0xfc86('0xdb'):_0x1fd847[_0xfc86('0x72')]='Template';break;case _0xfc86('0xdc'):_0x1fd847[_0xfc86('0x72')]='Trigger';break;case'trunks':_0x1fd847[_0xfc86('0x72')]='Trunk';break;case _0xfc86('0xdd'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xde');break;case _0xfc86('0xdf'):_0x1fd847['childModel']=_0xfc86('0x61');break;case _0xfc86('0xe0'):_0x1fd847['childModel']=_0xfc86('0xe1');_0x1fd847['parentSections']=[{'name':'Reports','field':'id','foreignKey':_0xfc86('0x7b')}];break;case _0xfc86('0xe2'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xe3');break;case _0xfc86('0xe4'):_0x1fd847[_0xfc86('0x72')]=_0xfc86('0xe5');break;default:return _0x1fd847;}return _0x1fd847;}
\ No newline at end of file
+var _0x14a0=['UserProfileSection','each','autoAssociation','UserProfileResource','sectionId','userProfileId','describe','addSections','sequelize','transaction','removeSections','ids','getSections','enabled','includes','isEmpty','subsections','Dashboard','forEach','push','resourceId','Plugin','addResources','bulkCreate','removeResources','getResources','section','No\x20User\x20Profile\x20found\x20for\x20id\x20','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','sox','to-csv','ejs','squel','crypto','jsforce','querystring','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./userProfile.socket','register','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','destroy','error','stack','send','index','map','UserProfile','rawAttributes','fieldName','type','key','name','query','keys','filters','intersection','attributes','model','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','find','create','body','clone','params','get','omit','createdAt','updatedAt','crudPermissions'];(function(_0x54e3b7,_0x1725db){var _0x1d9796=function(_0x4614d7){while(--_0x4614d7){_0x54e3b7['push'](_0x54e3b7['shift']());}};_0x1d9796(++_0x1725db);}(_0x14a0,0x8e));var _0x014a=function(_0x2f33db,_0x5ab33f){_0x2f33db=_0x2f33db-0x0;var _0x25cb50=_0x14a0[_0x2f33db];return _0x25cb50;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x014a('0x0'));var zipdir=require(_0x014a('0x1'));var jsonpatch=require(_0x014a('0x2'));var rp=require(_0x014a('0x3'));var moment=require(_0x014a('0x4'));var BPromise=require(_0x014a('0x5'));var Mustache=require(_0x014a('0x6'));var util=require('util');var path=require('path');var sox=require(_0x014a('0x7'));var csv=require(_0x014a('0x8'));var ejs=require(_0x014a('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x014a('0xa'));var crypto=require(_0x014a('0xb'));var jsforce=require(_0x014a('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x014a('0xd'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0x014a('0xe'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x014a('0xf'))(_0x014a('0x10'));var utils=require('../../config/utils');var config=require(_0x014a('0x11'));var licenseUtil=require(_0x014a('0x12'));var db=require(_0x014a('0x13'))['db'];config[_0x014a('0x14')]=_[_0x014a('0x15')](config[_0x014a('0x14')],{'host':_0x014a('0x16'),'port':0x18eb});var socket=require(_0x014a('0x17'))(new Redis(config[_0x014a('0x14')]));require(_0x014a('0x18'))[_0x014a('0x19')](socket);function respondWithStatusCode(_0x3c54c8,_0x4fe87c){_0x4fe87c=_0x4fe87c||0xcc;return function(_0x130d13){if(_0x130d13){return _0x3c54c8[_0x014a('0x1a')](_0x4fe87c);}return _0x3c54c8['status'](_0x4fe87c)[_0x014a('0x1b')]();};}function respondWithResult(_0x128c46,_0x59a4ea){_0x59a4ea=_0x59a4ea||0xc8;return function(_0x16e6fc){if(_0x16e6fc){return _0x128c46[_0x014a('0x1c')](_0x59a4ea)[_0x014a('0x1d')](_0x16e6fc);}};}function respondWithFilteredResult(_0x12da95,_0x2c26ac){return function(_0x12d339){if(_0x12d339){var _0x61ec9f=typeof _0x2c26ac[_0x014a('0x1e')]===_0x014a('0x1f')&&typeof _0x2c26ac[_0x014a('0x20')]===_0x014a('0x1f');var _0x89e132=_0x12d339[_0x014a('0x21')];var _0x34e5c3=_0x61ec9f?0x0:_0x2c26ac['offset'];var _0x359903=_0x61ec9f?_0x12d339[_0x014a('0x21')]:_0x2c26ac[_0x014a('0x1e')]+_0x2c26ac[_0x014a('0x20')];var _0xc9a563;if(_0x359903>=_0x89e132){_0x359903=_0x89e132;_0xc9a563=0xc8;}else{_0xc9a563=0xce;}_0x12da95[_0x014a('0x1c')](_0xc9a563);return _0x12da95[_0x014a('0x22')](_0x014a('0x23'),_0x34e5c3+'-'+_0x359903+'/'+_0x89e132)[_0x014a('0x1d')](_0x12d339);}return null;};}function patchUpdates(_0x486e66){return function(_0x3679ed){try{jsonpatch['apply'](_0x3679ed,_0x486e66,!![]);}catch(_0x1a1318){return BPromise[_0x014a('0x24')](_0x1a1318);}return _0x3679ed[_0x014a('0x25')]();};}function saveUpdates(_0x36d52b,_0x2b3c10){return function(_0x113b12){if(_0x113b12){return _0x113b12[_0x014a('0x26')](_0x36d52b)[_0x014a('0x27')](function(_0x165a42){return _0x165a42;});}return null;};}function removeEntity(_0x4c2627,_0x3b4b92){return function(_0x5358e9){if(_0x5358e9){return _0x5358e9[_0x014a('0x28')]()[_0x014a('0x27')](function(){_0x4c2627['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x9a901f,_0x3f9719){return function(_0x143346){if(!_0x143346){_0x9a901f['sendStatus'](0x194);}return _0x143346;};}function handleError(_0x183f19,_0x3c1fa4){_0x3c1fa4=_0x3c1fa4||0x1f4;return function(_0x598179){logger[_0x014a('0x29')](_0x598179[_0x014a('0x2a')]);if(_0x598179['name']){delete _0x598179['name'];}_0x183f19[_0x014a('0x1c')](_0x3c1fa4)[_0x014a('0x2b')](_0x598179);};}exports[_0x014a('0x2c')]=function(_0x29fce5,_0x4ea00c){var _0x434038={},_0x147e7e={},_0x15af07={'count':0x0,'rows':[]};var _0x402d3b=_[_0x014a('0x2d')](db[_0x014a('0x2e')][_0x014a('0x2f')],function(_0x1dae8e){return{'name':_0x1dae8e[_0x014a('0x30')],'type':_0x1dae8e[_0x014a('0x31')][_0x014a('0x32')]};});_0x147e7e['model']=_[_0x014a('0x2d')](_0x402d3b,_0x014a('0x33'));_0x147e7e[_0x014a('0x34')]=_[_0x014a('0x35')](_0x29fce5[_0x014a('0x34')]);_0x147e7e[_0x014a('0x36')]=_[_0x014a('0x37')](_0x147e7e['model'],_0x147e7e[_0x014a('0x34')]);_0x434038[_0x014a('0x38')]=_['intersection'](_0x147e7e[_0x014a('0x39')],qs[_0x014a('0x3a')](_0x29fce5[_0x014a('0x34')][_0x014a('0x3a')]));_0x434038[_0x014a('0x38')]=_0x434038[_0x014a('0x38')][_0x014a('0x3b')]?_0x434038[_0x014a('0x38')]:_0x147e7e['model'];if(!_0x29fce5[_0x014a('0x34')][_0x014a('0x3c')](_0x014a('0x3d'))){_0x434038[_0x014a('0x20')]=qs['limit'](_0x29fce5[_0x014a('0x34')][_0x014a('0x20')]);_0x434038[_0x014a('0x1e')]=qs[_0x014a('0x1e')](_0x29fce5[_0x014a('0x34')][_0x014a('0x1e')]);}_0x434038[_0x014a('0x3e')]=qs[_0x014a('0x3f')](_0x29fce5[_0x014a('0x34')]['sort']);_0x434038[_0x014a('0x40')]=qs['filters'](_[_0x014a('0x41')](_0x29fce5[_0x014a('0x34')],_0x147e7e[_0x014a('0x36')]),_0x402d3b);if(_0x29fce5[_0x014a('0x34')][_0x014a('0x42')]){_0x434038['where']=_[_0x014a('0x43')](_0x434038[_0x014a('0x40')],{'$or':_['map'](_0x402d3b,function(_0x9227b8){if(_0x9227b8[_0x014a('0x31')]!==_0x014a('0x44')){var _0x2e7a14={};_0x2e7a14[_0x9227b8[_0x014a('0x33')]]={'$like':'%'+_0x29fce5[_0x014a('0x34')][_0x014a('0x42')]+'%'};return _0x2e7a14;}})});}_0x434038=_[_0x014a('0x43')]({},_0x434038,_0x29fce5[_0x014a('0x45')]);var _0x537bde={'where':_0x434038[_0x014a('0x40')]};return db[_0x014a('0x2e')][_0x014a('0x21')](_0x537bde)[_0x014a('0x27')](function(_0x5f1a91){_0x15af07[_0x014a('0x21')]=_0x5f1a91;if(_0x29fce5[_0x014a('0x34')][_0x014a('0x46')]){_0x434038[_0x014a('0x47')]=[{'all':!![]}];}return db[_0x014a('0x2e')][_0x014a('0x48')](_0x434038);})['then'](function(_0x361866){_0x15af07[_0x014a('0x49')]=_0x361866;return _0x15af07;})['then'](respondWithFilteredResult(_0x4ea00c,_0x434038))[_0x014a('0x4a')](handleError(_0x4ea00c,null));};exports[_0x014a('0x4b')]=function(_0x2c45f1,_0x5dc092){var _0x5bcf8={'raw':![],'where':{'id':_0x2c45f1['params']['id']}},_0x50a8f0={};_0x50a8f0[_0x014a('0x39')]=_[_0x014a('0x35')](db['UserProfile'][_0x014a('0x2f')]);_0x50a8f0[_0x014a('0x34')]=_[_0x014a('0x35')](_0x2c45f1[_0x014a('0x34')]);_0x50a8f0[_0x014a('0x36')]=_[_0x014a('0x37')](_0x50a8f0['model'],_0x50a8f0[_0x014a('0x34')]);_0x5bcf8[_0x014a('0x38')]=_[_0x014a('0x37')](_0x50a8f0['model'],qs['fields'](_0x2c45f1[_0x014a('0x34')]['fields']));_0x5bcf8['attributes']=_0x5bcf8[_0x014a('0x38')]['length']?_0x5bcf8[_0x014a('0x38')]:_0x50a8f0[_0x014a('0x39')];if(_0x2c45f1[_0x014a('0x34')]['includeAll']){_0x5bcf8[_0x014a('0x47')]=[{'all':!![]}];}_0x5bcf8=_[_0x014a('0x43')]({},_0x5bcf8,_0x2c45f1[_0x014a('0x45')]);return db[_0x014a('0x2e')][_0x014a('0x4c')](_0x5bcf8)[_0x014a('0x27')](handleEntityNotFound(_0x5dc092,null))['then'](respondWithResult(_0x5dc092,null))[_0x014a('0x4a')](handleError(_0x5dc092,null));};exports[_0x014a('0x4d')]=function(_0x5a861c,_0x1a4df9){return db[_0x014a('0x2e')][_0x014a('0x4d')](_0x5a861c[_0x014a('0x4e')],{})[_0x014a('0x27')](respondWithResult(_0x1a4df9,0xc9))[_0x014a('0x4a')](handleError(_0x1a4df9,null));};exports[_0x014a('0x4f')]=function(_0x21680f,_0x4aa72b){var _0x423fb2={'where':{'id':_0x21680f[_0x014a('0x50')]['id']}},_0x16a4b5={};_0x16a4b5[_0x014a('0x39')]=_[_0x014a('0x35')](db['UserProfile'][_0x014a('0x2f')]);_0x423fb2['attributes']=_[_0x014a('0x37')](_0x16a4b5[_0x014a('0x39')],qs[_0x014a('0x3a')](_0x21680f[_0x014a('0x34')][_0x014a('0x3a')]));_0x423fb2['attributes']=_0x423fb2['attributes']['length']?_0x423fb2['attributes']:_0x16a4b5[_0x014a('0x39')];if(_0x21680f['query'][_0x014a('0x46')]){_0x423fb2['include']=[{'all':!![]}];}_0x423fb2=_['merge']({},_0x423fb2,_0x21680f[_0x014a('0x45')]);return db['UserProfile'][_0x014a('0x4c')](_0x423fb2)[_0x014a('0x27')](handleEntityNotFound(_0x4aa72b,null))[_0x014a('0x27')](function(_0x3c7e06){if(_0x3c7e06){var _0x21b16c=_0x3c7e06[_0x014a('0x51')]({'plain':!![]});_0x21b16c=qs[_0x014a('0x52')](_0x21b16c,['id',_0x014a('0x53'),_0x014a('0x54'),_0x014a('0x55')]);_0x21680f['body']=_['omit'](_0x21680f[_0x014a('0x4e')],['id',_0x014a('0x53'),_0x014a('0x54')]);return db['sequelize']['transaction'](function(_0x4591ad){return db['UserProfile'][_0x014a('0x4d')](_[_0x014a('0x43')](_0x21b16c,_0x21680f[_0x014a('0x4e')]),{'include':_0x21680f[_0x014a('0x34')]['includeAll']?[{'all':!![]}]:undefined,'transaction':_0x4591ad})[_0x014a('0x27')](function(_0x2ccc2f){var _0x3d1c9d=_0x2ccc2f['get']({'plain':!![]});return db[_0x014a('0x56')]['findAll']({'where':{'userProfileId':_0x21680f[_0x014a('0x50')]['id']},'raw':!![]})[_0x014a('0x27')](function(_0x34736b){if(_0x34736b){return BPromise[_0x014a('0x57')](_0x34736b,function(_0xd0334a){return new BPromise(function(_0x1a308b,_0x4e9260){if(_0xd0334a[_0x014a('0x58')]===null||_0xd0334a[_0x014a('0x58')]===0x1)_0x1a308b(null);return db[_0x014a('0x59')]['findAll']({'where':{'sectionId':_0xd0334a['id']},'raw':!![]})[_0x014a('0x27')](function(_0x17f9d7){var _0x2a9137=_[_0x014a('0x2d')](_0x17f9d7,function(_0x11bf5c){return qs['omit'](_0x11bf5c,['id',_0x014a('0x53'),_0x014a('0x54'),_0x014a('0x5a')]);});_0x1a308b(_0x2a9137);})[_0x014a('0x4a')](function(_0x3ca7e6){_0x4e9260(_0x3ca7e6);});})[_0x014a('0x27')](function(_0x477946){var _0x4039d1=qs[_0x014a('0x52')](_0xd0334a,['id',_0x014a('0x53'),_0x014a('0x54')]);_0x4039d1[_0x014a('0x5b')]=_0x3d1c9d['id'];if(_0x477946)_0x4039d1['Resources']=_0x477946;return _0x4039d1;})[_0x014a('0x27')](function(_0x5ac216){return db['UserProfileSection']['create'](_0x5ac216,{'include':[{'model':db['UserProfileResource'],'as':'Resources'}],'raw':!![],'transaction':_0x4591ad});});})[_0x014a('0x27')](function(){return _0x3d1c9d;});}});});});}})[_0x014a('0x27')](respondWithResult(_0x4aa72b,0xc9))[_0x014a('0x4a')](handleError(_0x4aa72b,null));};exports['update']=function(_0x3c6fc0,_0x2a5007){if(_0x3c6fc0[_0x014a('0x4e')]['id']){delete _0x3c6fc0[_0x014a('0x4e')]['id'];}return db['UserProfile']['find']({'where':{'id':_0x3c6fc0[_0x014a('0x50')]['id']}})[_0x014a('0x27')](handleEntityNotFound(_0x2a5007,null))[_0x014a('0x27')](saveUpdates(_0x3c6fc0[_0x014a('0x4e')],null))[_0x014a('0x27')](respondWithResult(_0x2a5007,null))[_0x014a('0x4a')](handleError(_0x2a5007,null));};exports[_0x014a('0x28')]=function(_0x1eee3e,_0x387d12){return db[_0x014a('0x2e')][_0x014a('0x4c')]({'where':{'id':_0x1eee3e['params']['id']}})[_0x014a('0x27')](handleEntityNotFound(_0x387d12,null))[_0x014a('0x27')](removeEntity(_0x387d12,null))['catch'](handleError(_0x387d12,null));};exports[_0x014a('0x5c')]=function(_0x3e39c9,_0x56f4b2){return db[_0x014a('0x2e')]['describe']()[_0x014a('0x27')](respondWithResult(_0x56f4b2,null))[_0x014a('0x4a')](handleError(_0x56f4b2,null));};exports[_0x014a('0x5d')]=function(_0x456d69,_0x37b8f){var _0x5e0f22=_0x456d69[_0x014a('0x4e')];return db[_0x014a('0x2e')][_0x014a('0x4c')]({'where':{'id':_0x456d69[_0x014a('0x50')]['id']}})[_0x014a('0x27')](handleEntityNotFound(_0x37b8f,null))['then'](function(_0x20cddc){if(_0x20cddc){return db[_0x014a('0x5e')][_0x014a('0x5f')](function(_0x5f3224){return db[_0x014a('0x56')]['destroy']({'where':{'userProfileId':_0x456d69[_0x014a('0x50')]['id'],'sectionId':_[_0x014a('0x2d')](_0x5e0f22,function(_0x267026){return _0x267026[_0x014a('0x5a')];})},'transaction':_0x5f3224})[_0x014a('0x27')](function(){var _0x465a8e=_[_0x014a('0x2d')](_0x5e0f22,function(_0x58e087){_0x58e087['userProfileId']=_0x456d69[_0x014a('0x50')]['id'];return _0x58e087;});var _0x5d077c=[];return BPromise[_0x014a('0x57')](_0x465a8e,function(_0x5966f0){return db[_0x014a('0x56')][_0x014a('0x4d')](_0x5966f0,{'include':[{'model':db['UserProfileResource'],'as':'Resources'}],'raw':!![],'transaction':_0x5f3224})[_0x014a('0x27')](function(_0x8234ee){_0x5d077c['push'](_0x8234ee[_0x014a('0x51')]({'plain':!![]}));});})[_0x014a('0x27')](function(){return _0x5d077c;});});});}})['then'](function(_0x4a1b65){return _0x4a1b65;})[_0x014a('0x27')](respondWithResult(_0x37b8f,null))[_0x014a('0x4a')](handleError(_0x37b8f,null));};exports[_0x014a('0x60')]=function(_0x33e383,_0x37ea2d){var _0x321329;return db['UserProfile'][_0x014a('0x4c')]({'where':{'id':_0x33e383['params']['id']},'attributes':['id','name']})[_0x014a('0x27')](handleEntityNotFound(_0x37ea2d,null))[_0x014a('0x27')](function(_0x523859){if(_0x523859){_0x321329=_0x523859;return db[_0x014a('0x56')][_0x014a('0x28')]({'where':{'userProfileId':_0x33e383[_0x014a('0x50')]['id'],'sectionId':_0x33e383[_0x014a('0x34')][_0x014a('0x61')]}});}})['then'](function(){return _0x321329;})[_0x014a('0x27')](respondWithStatusCode(_0x37ea2d,null))[_0x014a('0x4a')](handleError(_0x37ea2d,null));};exports[_0x014a('0x62')]=function(_0x163fa2,_0x4aefeb){var _0x8716b=[];var _0x4c568c=[];return db[_0x014a('0x56')][_0x014a('0x48')]({'where':{'userProfileId':_0x163fa2[_0x014a('0x50')]['id']},'raw':!![]})[_0x014a('0x27')](function(_0xf7c997){_0x8716b=_[_0x014a('0x42')](_0xf7c997,function(_0x5dd4b8){return _0x5dd4b8[_0x014a('0x63')]===0x1||_[_0x014a('0x64')]([0x3eb,0x709],_0x5dd4b8[_0x014a('0x5a')]);});if(!_[_0x014a('0x65')](_0x8716b)){return _[_0x014a('0x2d')](_0x8716b,function(_0x3802df){return _0x3802df[_0x014a('0x5a')];});}else{return;}})[_0x014a('0x27')](function(_0x55cfe7){if(_0x55cfe7)_0x4c568c=_0x55cfe7;if(_[_0x014a('0x64')](_0x4c568c,0x64)){var _0x37c69e=_[_0x014a('0x4c')](_0x8716b,{'sectionId':0x64});return hasDefaultDashboard(_0x37c69e)['then'](function(_0x2fbaf3){return _[_0x014a('0x2d')](_0x8716b,function(_0x1cdfa5){if(_0x1cdfa5[_0x014a('0x5a')]===0x64){_0x1cdfa5[_0x014a('0x66')]=_0x2fbaf3;}return _0x1cdfa5;});});}else{return;}})[_0x014a('0x27')](function(_0x29b061){if(_0x29b061)_0x8716b=_0x29b061;if(_['includes'](_0x4c568c,0x3eb)){var _0x5891cf=_['find'](_0x8716b,{'sectionId':0x3eb});return getCustomDashboards(_0x5891cf)['then'](function(_0x194c8d){return _[_0x014a('0x2d')](_0x8716b,function(_0x1810a8){if(_0x5891cf[_0x014a('0x63')]){if(_0x1810a8[_0x014a('0x5a')]===0x3eb){_0x1810a8[_0x014a('0x66')]=_0x194c8d;}}else{if(_0x1810a8[_0x014a('0x5a')]===0x64){_0x1810a8['subsections']=_0x194c8d;}}return _0x1810a8;});});}else{return;}})[_0x014a('0x27')](function(_0x2e3ccd){if(_0x2e3ccd)_0x8716b=_0x2e3ccd;if(_[_0x014a('0x64')](_0x4c568c,0x709)){var _0x28a8ec=_['find'](_0x8716b,{'sectionId':0x709});return getPlugins(_0x28a8ec)['then'](function(_0x13e2fc){if(_0x28a8ec[_0x014a('0x63')]){return _['map'](_0x8716b,function(_0x4aea1d){if(_0x4aea1d[_0x014a('0x5a')]===0x709){_0x4aea1d['subsections']=_0x13e2fc;}return _0x4aea1d;});}else{var _0x5d4099={'sectionId':0x76c,'enabled':0x1,'subsections':_0x13e2fc};var _0x403836=_[_0x014a('0x2d')](_0x8716b);_0x403836['push'](_0x5d4099);return _0x403836;}});}else{return;}})[_0x014a('0x27')](function(_0x3ac51b){if(_0x3ac51b)_0x8716b=_0x3ac51b;return _[_0x014a('0x42')](_0x8716b,[_0x014a('0x63'),0x1]);})[_0x014a('0x27')](respondWithResult(_0x4aefeb,null))[_0x014a('0x4a')](handleError(_0x4aefeb,null));};function hasDefaultDashboard(_0x13a545){var _0xc86f44=[0x65];return new BPromise(function(_0x5c3935,_0x5bae68){try{if(_0x13a545[_0x014a('0x58')]){_0x5c3935(_0xc86f44);}else{return db['UserProfileResource']['findOne']({'where':{'sectionId':_0x13a545['id']},'raw':!![]})['then'](function(_0x1ba1e0){_0x1ba1e0?_0x5c3935(_0xc86f44):_0x5c3935();});}}catch(_0x10144f){_0x5bae68(_0x10144f);}});}function getCustomDashboards(_0x2c527f){var _0x55408f=[];return new BPromise(function(_0x19e317,_0x387fd0){try{if(_0x2c527f[_0x014a('0x58')]){return db[_0x014a('0x67')]['findAll']({'raw':!![]})[_0x014a('0x27')](function(_0x3fa661){_0x3fa661[_0x014a('0x68')](function(_0x48617c){_0x55408f[_0x014a('0x69')](_0x48617c['id']+0x1869f);});_0x19e317(_0x55408f);});}else{return db[_0x014a('0x59')]['findAll']({'where':{'sectionId':_0x2c527f['id']},'raw':!![]})[_0x014a('0x27')](function(_0x3367cb){_0x3367cb[_0x014a('0x68')](function(_0x4b0d03){_0x55408f[_0x014a('0x69')](_0x4b0d03[_0x014a('0x6a')]+0x1869f);});_0x19e317(_0x55408f);});}}catch(_0x53c335){_0x387fd0(_0x53c335);}});}function getPlugins(_0x1e096b){var _0x293221=[];return new BPromise(function(_0x317df3,_0x368083){try{if(_0x1e096b[_0x014a('0x58')]){return db[_0x014a('0x6b')][_0x014a('0x48')]({'raw':!![]})[_0x014a('0x27')](function(_0x5d99a9){_0x5d99a9[_0x014a('0x68')](function(_0x1806d0){_0x293221['push'](_0x1806d0['id']+0x15b38);});_0x317df3(_0x293221);});}else{return db['UserProfileResource'][_0x014a('0x48')]({'where':{'sectionId':_0x1e096b['id']},'raw':!![]})[_0x014a('0x27')](function(_0x47f3c7){_0x47f3c7[_0x014a('0x68')](function(_0x440b9b){_0x293221[_0x014a('0x69')](_0x440b9b['resourceId']+0x15b38);});_0x317df3(_0x293221);});}}catch(_0x3a0012){_0x368083(_0x3a0012);}});}exports[_0x014a('0x6c')]=function(_0x5dedaf,_0x5baf80){return db[_0x014a('0x2e')]['find']({'where':{'id':_0x5dedaf[_0x014a('0x50')]['id']}})['then'](handleEntityNotFound(_0x5baf80,null))[_0x014a('0x27')](function(_0x25f4ef){if(_0x25f4ef){return db[_0x014a('0x5e')][_0x014a('0x5f')](function(_0x20b182){return db['UserProfileSection'][_0x014a('0x48')]({'where':{'userProfileId':_0x5dedaf[_0x014a('0x50')]['id']},'attributes':['id'],'raw':!![]})[_0x014a('0x27')](function(_0x41f999){if(_0x41f999){return db[_0x014a('0x56')][_0x014a('0x28')]({'where':{'userProfileId':_0x5dedaf[_0x014a('0x50')]['id'],'id':_[_0x014a('0x2d')](_0x41f999,function(_0x51c35f){return _0x51c35f['id'];})},'transaction':_0x20b182});}})[_0x014a('0x27')](function(_0x54645e){var _0xc1dcb9=_['map'](_0x5dedaf['body'],function(_0x47bad1){_0x47bad1['userProfileId']=_0x5dedaf[_0x014a('0x50')]['id'];return _0x47bad1;});return db[_0x014a('0x56')][_0x014a('0x6d')](_0xc1dcb9,{'raw':!![],'transaction':_0x20b182});})[_0x014a('0x27')](function(_0x28a692){var _0x27a899=_[_0x014a('0x42')](_[_0x014a('0x2d')](_0x28a692,function(_0x5327a6){return _0x5327a6['get']({'plain':!![]});}),{'includeAll':![]});if(_0x27a899){return db[_0x014a('0x56')][_0x014a('0x48')]({'where':{'userProfileId':_0x5dedaf[_0x014a('0x50')]['id'],'sectionId':_[_0x014a('0x2d')](_0x27a899,function(_0x45aef0){return _0x45aef0[_0x014a('0x5a')];})},'attributes':['id',_0x014a('0x5a')],'raw':!![]})[_0x014a('0x27')](function(_0x5342cc){var _0x27431c=_[_0x014a('0x2d')](_0x5dedaf[_0x014a('0x4e')],function(_0x2baee6){_0x2baee6[_0x014a('0x5b')]=_0x5dedaf['params']['id'];return _0x2baee6;});return db[_0x014a('0x59')][_0x014a('0x6d')](_0x27431c,{'raw':!![],'transaction':_0x20b182});});}})[_0x014a('0x4a')](handleError(_0x5baf80,null));});}})[_0x014a('0x27')](function(_0x3171d3){var _0x567357=_[_0x014a('0x2d')](_0x3171d3,function(_0x5ad83b){return _0x5ad83b[_0x014a('0x51')]({'plain':!![]});});})['then'](respondWithResult(_0x5baf80,null))['catch'](handleError(_0x5baf80,null));};exports[_0x014a('0x6e')]=function(_0xaf1b9f,_0x4af6d4,_0x129c22){return db[_0x014a('0x2e')][_0x014a('0x4c')]({'where':{'id':_0xaf1b9f['params']['id']}})[_0x014a('0x27')](handleEntityNotFound(_0x4af6d4,null))[_0x014a('0x27')](function(_0x2feb8a){if(_0x2feb8a){return _0x2feb8a[_0x014a('0x6e')](_0xaf1b9f[_0x014a('0x34')][_0x014a('0x61')]);}})[_0x014a('0x27')](respondWithStatusCode(_0x4af6d4,null))[_0x014a('0x4a')](handleError(_0x4af6d4,null));};exports[_0x014a('0x6f')]=function(_0x58341b,_0x597702){var _0x14b351={};if(!_0x58341b[_0x014a('0x34')][_0x014a('0x70')])throw new Error('Missing\x20section\x20parameter');if(!_0x58341b[_0x014a('0x34')][_0x014a('0x3c')](_0x014a('0x3d'))){_0x14b351[_0x014a('0x20')]=qs[_0x014a('0x20')](_0x58341b[_0x014a('0x34')]['limit']);_0x14b351[_0x014a('0x1e')]=qs[_0x014a('0x1e')](_0x58341b[_0x014a('0x34')][_0x014a('0x1e')]);}return db['UserProfile'][_0x014a('0x4c')]({'where':{'id':_0x58341b[_0x014a('0x50')]['id']}})[_0x014a('0x27')](function(_0x30999a){if(!_0x30999a)throw new Error(_0x014a('0x71')+_0x58341b['params']['id']);return db[_0x014a('0x2e')]['getResources'](_0x58341b);})['then'](respondWithFilteredResult(_0x597702,_0x14b351))[_0x014a('0x4a')](handleError(_0x597702,null));};
\ No newline at end of file