7609072274d8d75e5988db7c911cd6f30b26f80d
[motion2.git] / server / api / userProfile / userProfile.model.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x3ac3=['whatsappaccounts','WhatsappAccount','teams','Team','voicequeues','users','Users','admin','user','zendeskaccounts','ZendeskAccount','salesforceaccounts','SalesforceAccount','freshdeskaccounts','sugarcrmaccounts','SugarcrmAccount','DeskAccount','ZohoAccount','cannedanswers','CannedAnswer','dispositions','Disposition','customdashboards','pauses','Pause','scheduler','Sound','tags','templates','Template','Trigger','trunks','Trunk','variables','Variable','plugins','Plugin','AnalyticExtractedReport','metrics','AnalyticMetric','charAt','slice','SELECT','select','ui.','InteractionId','ui.createdAt','from','user_has_','_interactions','where','ui.UserId\x20=\x20?','sequelize','query','toString','UserProfile','raw','mergeResources','Invalid\x20section\x20\x27','isEmpty','length','push','UserProfileSection','find','params','all','union','ignore','autoAssociation','rawAttributes','keys','intersection','attributes','fields','hasOwnProperty','nolimit','limit','offset','order','sort','pick','filters','merge','VIRTUAL','foreignKey','forEach','options','includeAll','include','reportId','custom','CustomReports','count','rows','Tags','color','Tag','ThroughTags','tag','openTabs','chat','sms','dataValues','fax','mail','openchannel','lodash','../../components/parsers/qs','squel','filter','value','findAll','then','field','model','associatedResources','map','name','catch','resolve','type','resourceId','toLowerCase','squareprojects','childModel','SquareProject','odbc','SquareOdbc','squarerecordings','parentSections','SquareProjects','projectName','projects','JscriptyProject','contacts','CmContact','ListId','CmCompany','globalcustomfields','CmCustomField','chatqueues','ChatQueue','chatwebsites','ChatWebsite','faxqueues','FaxQueue','FaxAccount','inboundroutes','internalroutes','outboundroutes','VoiceExtension','contexts','VoiceContext','voicemails','VoiceMail','VoiceRecording','Agents','membername','User','role','agent','Telephones','telephone','VoiceQueues','queue','VoiceQueue','QueueCampaigns','outbound','musiconholds','VoiceMusicOnHold','chanspies','voiceprefixes','VoicePrefix','ivrcampaigns','mailqueues','MailQueue','mailaccounts','mailsubstatuses','MailSubstatus','openchannelqueues','OpenchannelQueue','openchannelaccounts','OpenchannelAccount','smsqueues','SmsQueue','smsaccounts','SmsAccount','WhatsappQueue'];(function(_0x7d87d7,_0x2d782c){var _0x35a8d5=function(_0x4af6bb){while(--_0x4af6bb){_0x7d87d7['push'](_0x7d87d7['shift']());}};_0x35a8d5(++_0x2d782c);}(_0x3ac3,0x1e2));var _0x33ac=function(_0x4b4b0e,_0x6c674){_0x4b4b0e=_0x4b4b0e-0x0;var _0x4c2d91=_0x3ac3[_0x4b4b0e];return _0x4c2d91;};'use strict';var _=require(_0x33ac('0x0'));var attributes=require('./userProfile.attributes');var qs=require(_0x33ac('0x1'));var squel=require(_0x33ac('0x2'));module['exports']=function(_0xb86f31){var _0x218703=_0xb86f31['models'];function _0x6c2c6d(_0x280154,_0x58b0fc){return new Promise(function(_0x45efb4,_0x2ad63c){if(!_0x58b0fc)return _0x45efb4(null);var _0x2d55c8=_0x58b0fc[_0x33ac('0x3')]?{[_0x58b0fc['filter']['field']]:_0x58b0fc['filter'][_0x33ac('0x4')]}:undefined;return _0x218703[_0x280154][_0x33ac('0x5')]({'where':_0x2d55c8,'raw':!![]})[_0x33ac('0x6')](function(_0x4179ae){_0x58b0fc['associatedResources']=_['map'](_0x4179ae,'id');_0x45efb4(_0x58b0fc);})['catch'](function(_0x3b867c){_0x2ad63c(_0x3b867c);});});}function _0x599bdd(_0x2711f6,_0x569711){return new Promise(function(_0x5a2832,_0x4d58d2){var _0x476ac4=_0x2711f6['filter']?{[_0x2711f6[_0x33ac('0x3')][_0x33ac('0x7')]]:_0x2711f6[_0x33ac('0x3')][_0x33ac('0x4')]}:undefined;return _0x218703[_0x2711f6[_0x33ac('0x8')]][_0x33ac('0x5')]({'where':_0x476ac4,'raw':!![]})[_0x33ac('0x6')](function(_0x13dc83){_0x569711[_0x33ac('0x9')]=_[_0x33ac('0xa')](_0x13dc83,function(_0x3c0c4c){return _0x3c0c4c[_0x33ac('0xb')];});_0x5a2832(_0x569711);})[_0x33ac('0xc')](function(_0x572212){_0x4d58d2(_0x572212);});});}function _0x25c6ae(_0x1b9746,_0x3b9bc0,_0x34eeba){if(!_0x3b9bc0)return Promise[_0x33ac('0xd')](null);return new Promise(function(_0x705f02,_0x1fe5a1){return _0x218703['UserProfileResource'][_0x33ac('0x5')]({'where':{'sectionId':_0x3b9bc0['id']},'raw':!![]})['then'](function(_0x2d7f6f){if(_0x1b9746['field']&&_0x1b9746['field']!=='id'){_0x3b9bc0['associatedResources']=_[_0x33ac('0xa')](_0x2d7f6f,function(_0x2db39a){return _0x2db39a[_0x1b9746[_0x33ac('0x7')]];});}else{if(_0x34eeba==='AnalyticExtractedReport'){_0x3b9bc0[_0x33ac('0x9')]=_[_0x33ac('0xa')](_0x2d7f6f,function(_0x5ae3ef){return{'id':_0x5ae3ef['resourceId'],'type':_0x5ae3ef[_0x33ac('0xe')]};});}else{_0x3b9bc0[_0x33ac('0x9')]=_[_0x33ac('0xa')](_0x2d7f6f,function(_0x22769e){return _0x22769e[_0x33ac('0xf')];});}}_0x705f02(_0x3b9bc0);})[_0x33ac('0xc')](function(_0x28bf6e){_0x1fe5a1(_0x28bf6e);});});}function _0x239303(_0x2d8089,_0x1031a3){var _0x1cdbf4={'parentSections':[]};switch(_0x2d8089[_0x33ac('0x10')]()){case _0x33ac('0x11'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x13');break;case _0x33ac('0x14'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x15');break;case _0x33ac('0x16'):_0x1cdbf4[_0x33ac('0x12')]='SquareRecording';_0x1cdbf4[_0x33ac('0x17')]=[{'name':_0x33ac('0x18'),'field':_0x33ac('0xb'),'foreignKey':_0x33ac('0x19')}];break;case _0x33ac('0x1a'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x1b');break;case _0x33ac('0x1c'):_0x1cdbf4['childModel']=_0x33ac('0x1d');_0x1cdbf4[_0x33ac('0x17')]=[{'name':'Lists','field':'id','foreignKey':_0x33ac('0x1e')}];break;case'lists':_0x1cdbf4[_0x33ac('0x12')]='CmList';break;case'companies':_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x1f');break;case _0x33ac('0x20'):_0x1cdbf4['childModel']=_0x33ac('0x21');break;case _0x33ac('0x22'):_0x1cdbf4['childModel']=_0x33ac('0x23');break;case _0x33ac('0x24'):_0x1cdbf4['childModel']=_0x33ac('0x25');break;case _0x33ac('0x26'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x27');break;case'faxaccounts':_0x1cdbf4['childModel']=_0x33ac('0x28');break;case _0x33ac('0x29'):case _0x33ac('0x2a'):case _0x33ac('0x2b'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x2c');break;case _0x33ac('0x2d'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x2e');break;case _0x33ac('0x2f'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x30');break;case'voicerecordings':_0x1cdbf4['childModel']=_0x33ac('0x31');_0x1cdbf4['parentSections']=[{'name':_0x33ac('0x32'),'field':_0x33ac('0xb'),'foreignKey':_0x33ac('0x33'),'model':_0x33ac('0x34'),'filter':{'field':_0x33ac('0x35'),'value':[_0x33ac('0x36')]}},{'name':_0x33ac('0x37'),'field':_0x33ac('0xb'),'foreignKey':_0x33ac('0x33'),'model':_0x33ac('0x34'),'filter':{'field':_0x33ac('0x35'),'value':[_0x33ac('0x38')]}},{'name':_0x33ac('0x39'),'field':_0x33ac('0xb'),'foreignKey':_0x33ac('0x3a'),'model':_0x33ac('0x3b'),'filter':{'field':_0x33ac('0xe'),'value':['inbound']}},{'name':_0x33ac('0x3c'),'field':_0x33ac('0xb'),'foreignKey':_0x33ac('0x3a'),'model':_0x33ac('0x3b'),'filter':{'field':_0x33ac('0xe'),'value':[_0x33ac('0x3d')]}}];break;case _0x33ac('0x3e'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x3f');break;case _0x33ac('0x40'):_0x1cdbf4[_0x33ac('0x12')]='VoiceChanSpy';break;case _0x33ac('0x41'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x42');break;case _0x33ac('0x43'):_0x1cdbf4[_0x33ac('0x12')]='Campaign';break;case _0x33ac('0x44'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x45');break;case _0x33ac('0x46'):_0x1cdbf4[_0x33ac('0x12')]='MailAccount';break;case _0x33ac('0x47'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x48');break;case _0x33ac('0x49'):_0x1cdbf4['childModel']=_0x33ac('0x4a');break;case _0x33ac('0x4b'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x4c');break;case _0x33ac('0x4d'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x4e');break;case _0x33ac('0x4f'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x50');break;case'whatsappqueues':_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x51');break;case _0x33ac('0x52'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x53');break;case _0x33ac('0x54'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x55');break;case _0x33ac('0x56'):case'queuecampaigns':_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x3b');if(_0x1031a3){_0x1cdbf4[_0x33ac('0x17')]=[{'name':'VoiceQueues'},{'name':_0x33ac('0x3c')}];}break;case _0x33ac('0x57'):case'agents':case'telephones':_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x34');if(_0x1031a3){_0x1cdbf4[_0x33ac('0x17')]=[{'name':_0x33ac('0x58'),'filter':{'field':_0x33ac('0x35'),'value':[_0x33ac('0x59'),_0x33ac('0x5a')]},'ignore':!![]},{'name':'Agents'},{'name':_0x33ac('0x37')}];}break;case _0x33ac('0x5b'):_0x1cdbf4['childModel']=_0x33ac('0x5c');break;case _0x33ac('0x5d'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x5e');break;case _0x33ac('0x5f'):_0x1cdbf4[_0x33ac('0x12')]='FreshdeskAccount';break;case _0x33ac('0x60'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x61');break;case'deskaccounts':_0x1cdbf4['childModel']=_0x33ac('0x62');break;case'zohoaccounts':_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x63');break;case'vtigeraccounts':_0x1cdbf4['childModel']=_0x33ac('0x34');break;case _0x33ac('0x64'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x65');break;case _0x33ac('0x66'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x67');break;case _0x33ac('0x68'):_0x1cdbf4['childModel']='Dashboard';break;case'intervals':_0x1cdbf4['childModel']='Interval';break;case _0x33ac('0x69'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x6a');break;case _0x33ac('0x6b'):_0x1cdbf4[_0x33ac('0x12')]='Schedule';break;case'sounds':_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x6c');break;case _0x33ac('0x6d'):_0x1cdbf4[_0x33ac('0x12')]='Tag';break;case _0x33ac('0x6e'):_0x1cdbf4['childModel']=_0x33ac('0x6f');break;case'triggers':_0x1cdbf4['childModel']=_0x33ac('0x70');break;case _0x33ac('0x71'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x72');break;case _0x33ac('0x73'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x74');break;case _0x33ac('0x75'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x76');break;case'extractedreports':_0x1cdbf4['childModel']=_0x33ac('0x77');_0x1cdbf4[_0x33ac('0x17')]=[{'name':'Reports','field':'id','foreignKey':'reportId'}];break;case _0x33ac('0x78'):_0x1cdbf4[_0x33ac('0x12')]=_0x33ac('0x79');break;}return _0x1cdbf4;}function _0x1856db(_0x5ed8fe,_0x5b6fb4){var _0x30d61e=_0x5ed8fe[_0x33ac('0x7a')](0x0)['toUpperCase']()+_0x5ed8fe[_0x33ac('0x7b')](0x1);var _0xad8552={'type':_0x218703['Sequelize']['QueryTypes'][_0x33ac('0x7c')],'raw':!![]};return new Promise(function(_0x289b5f,_0x469c61){var _0x2b1f47=squel[_0x33ac('0x7d')]()['field'](_0x33ac('0x7e')+_0x30d61e+_0x33ac('0x7f'),'id')['field'](_0x33ac('0x80'))[_0x33ac('0x81')](_0x33ac('0x82')+_0x5ed8fe+_0x33ac('0x83'),'ui')[_0x33ac('0x84')](_0x33ac('0x85'),_0x5b6fb4['id']);return _0x218703[_0x33ac('0x86')][_0x33ac('0x87')](_0x2b1f47[_0x33ac('0x88')](),_0xad8552)[_0x33ac('0x6')](function(_0x42a727){_0x5b6fb4[_0x30d61e+'OpenTabs']=_0x42a727;_0x289b5f(_0x42a727);})['catch'](function(_0x1751ab){_0x469c61(_0x1751ab);});});}return _0xb86f31['define'](_0x33ac('0x89'),attributes,{'tableName':'user_profiles','paranoid':![],'indexes':[],'timestamps':!![],'classMethods':{'getResources':function(_0x2f475f){var _0x389570={'raw':_0x2f475f['query'][_0x33ac('0x8a')],'where':{}};var _0x1ac3cd={};var _0x4bb9d0={'count':0x0,'rows':[]};var _0x5a1264=_0x2f475f[_0x33ac('0x87')]['section'];var _0xba5280=_0x2f475f[_0x33ac('0x87')][_0x33ac('0x8b')]||![];var _0x371526=_0x239303(_0x5a1264,_0xba5280);if(!_0x371526['childModel'])throw new Error(_0x33ac('0x8c')+_0x5a1264+'\x27');var _0x2fdff4=[{'name':_0x5a1264}];if(!_[_0x33ac('0x8d')](_0x371526[_0x33ac('0x17')]))_0x2fdff4=_0x371526[_0x33ac('0x17')];var _0x5c4cce=[];for(var _0x66dfe=0x0;_0x66dfe<_0x2fdff4[_0x33ac('0x8e')];_0x66dfe++){_0x5c4cce[_0x33ac('0x8f')](_0x218703[_0x33ac('0x90')][_0x33ac('0x91')]({'where':{'userProfileId':_0x2f475f[_0x33ac('0x92')]['id'],'name':_0x2fdff4[_0x66dfe]['name']},'raw':!![]}));}return Promise[_0x33ac('0x93')](_0x5c4cce)[_0x33ac('0x6')](function(_0x59764a){var _0x281cd7=_[_0x33ac('0x3')](_0x59764a,function(_0x528fa6){return _0x528fa6?_0x528fa6:undefined;});var _0xa268bc=_[_0x33ac('0x3')](_0x2fdff4,['ignore',!![]]);var _0x3d8a13=_['isEmpty'](_0x281cd7)&&_[_0x33ac('0x8d')](_0xa268bc)?null:_[_0x33ac('0x94')](_0xa268bc,_0x281cd7);if(!_0x3d8a13)return null;var _0x49de9c=[];for(var _0x47240b=0x0;_0x47240b<_0x3d8a13[_0x33ac('0x8e')];_0x47240b++){var _0x18de60=_[_0x33ac('0x91')](_0x2fdff4,function(_0x3763b3){return _0x3d8a13[_0x47240b]?_0x3763b3[_0x33ac('0xb')]===_0x3d8a13[_0x47240b][_0x33ac('0xb')]:null;});if(_0x18de60){if(_0x3d8a13[_0x47240b][_0x33ac('0x95')]){_0x49de9c[_0x33ac('0x8f')](_0x6c2c6d(_0x371526[_0x33ac('0x12')],_0x3d8a13[_0x47240b]));}else{if(!_0x3d8a13[_0x47240b][_0x33ac('0x96')]){_0x49de9c[_0x33ac('0x8f')](_0x25c6ae(_0x18de60,_0x3d8a13[_0x47240b],_0x371526['childModel']));}else{if(_0x18de60[_0x33ac('0x8')]){_0x49de9c[_0x33ac('0x8f')](_0x599bdd(_0x18de60,_0x3d8a13[_0x47240b]));}}}}}return Promise[_0x33ac('0x93')](_0x49de9c);})[_0x33ac('0x6')](function(_0x3b6d97){var _0xf331a0=_0x3b6d97;var _0x2d81de=null;if(_0xf331a0){_0x2d81de=_0xf331a0[_0x33ac('0x8e')]===0x1?_0xf331a0[0x0]:null;}if(!_0x2d81de&&!_0xf331a0)return _0x4bb9d0;var _0x1ad3d4=_0x218703[_0x371526[_0x33ac('0x12')]][_0x33ac('0x97')];_0x1ac3cd['model']=_['keys'](_0x1ad3d4);_0x1ac3cd['query']=_[_0x33ac('0x98')](_0x2f475f[_0x33ac('0x87')]);_0x1ac3cd['filters']=_[_0x33ac('0x99')](_0x1ac3cd[_0x33ac('0x8')],_0x1ac3cd[_0x33ac('0x87')]);_0x389570[_0x33ac('0x9a')]=_[_0x33ac('0x99')](_0x1ac3cd['model'],qs['fields'](_0x2f475f[_0x33ac('0x87')][_0x33ac('0x9b')]));_0x389570[_0x33ac('0x9a')]=_0x389570['attributes'][_0x33ac('0x8e')]?_0x389570[_0x33ac('0x9a')]:_0x1ac3cd['model'];if(!_0x2f475f[_0x33ac('0x87')][_0x33ac('0x9c')](_0x33ac('0x9d'))){_0x389570[_0x33ac('0x9e')]=qs['limit'](_0x2f475f[_0x33ac('0x87')][_0x33ac('0x9e')]);_0x389570[_0x33ac('0x9f')]=qs[_0x33ac('0x9f')](_0x2f475f[_0x33ac('0x87')][_0x33ac('0x9f')]);}_0x389570[_0x33ac('0xa0')]=qs['sort'](_0x2f475f['query'][_0x33ac('0xa1')]);_0x389570[_0x33ac('0x84')]=qs['filters'](_[_0x33ac('0xa2')](_0x2f475f[_0x33ac('0x87')],_0x1ac3cd[_0x33ac('0xa3')]));if(_0x2f475f['query'][_0x33ac('0x3')]){_0x389570['where']=_[_0x33ac('0xa4')](_0x389570[_0x33ac('0x84')],{'$or':_[_0x33ac('0xa')](_0x1ad3d4,function(_0x51c66b){if(_0x51c66b[_0x33ac('0xe')]['key']!==_0x33ac('0xa5')){var _0x4b885d={};_0x4b885d[_0x51c66b[_0x33ac('0x7')]]={'$like':'%'+_0x2f475f[_0x33ac('0x87')][_0x33ac('0x3')]+'%'};return _0x4b885d;}})});}var _0x3c5451=[];var _0x2e249c=null;var _0x445265={};if(_0x2d81de){_0x2e249c=_[_0x33ac('0x91')](_0x2fdff4,[_0x33ac('0xb'),_0x2d81de[_0x33ac('0xb')]]);if(_0x2e249c['field']){_0x445265={};if(_0x371526[_0x33ac('0x12')]===_0x33ac('0x77')){_0x445265[_0x2e249c[_0x33ac('0xa6')]]=_[_0x33ac('0xa')](_0x2d81de['associatedResources'],'id');}else{_0x445265[_0x2e249c[_0x33ac('0xa6')]]=_0x2d81de[_0x33ac('0x9')];}_0x3c5451['push'](_0x445265);}else{_0x389570[_0x33ac('0x84')]['id']=_0x2d81de[_0x33ac('0x9')];}}else{for(var _0x56feea=0x0;_0x56feea<_0xf331a0[_0x33ac('0x8e')];_0x56feea++){_0x2e249c=_[_0x33ac('0x91')](_0x2fdff4,[_0x33ac('0xb'),_0xf331a0[_0x56feea]['name']]);if(_0x2e249c['field']){_0x445265={};_0x445265[_0x2e249c[_0x33ac('0xa6')]]=_0xf331a0[_0x56feea][_0x33ac('0x9')];_0x3c5451['push'](_0x445265);}else{if(!_0x389570[_0x33ac('0x84')]['id'])_0x389570['where']['id']=[];_0xf331a0[_0x56feea][_0x33ac('0x9')][_0x33ac('0xa7')](function(_0x495496){_0x389570[_0x33ac('0x84')]['id']['push'](_0x495496);});}}}if(!_['isEmpty'](_0x3c5451)){_0x389570[_0x33ac('0x84')]=_[_0x33ac('0xa4')](_0x389570[_0x33ac('0x84')],{'$and':{'$or':_0x3c5451}});}_0x389570=_['merge']({},_0x389570,_0x2f475f[_0x33ac('0xa8')]);if(_0x2d81de&&!_0x2d81de[_0x33ac('0x96')]&&_0x371526[_0x33ac('0x12')]===_0x33ac('0x77')){if(_0x2f475f[_0x33ac('0x87')][_0x33ac('0xa9')]){_0x389570[_0x33ac('0xaa')]=[{'all':!![]}];}return _0x218703[_0x371526[_0x33ac('0x12')]][_0x33ac('0x5')](_0x389570)[_0x33ac('0x6')](function(_0x3be928){var _0x1db0d5=[];_0x3be928[_0x33ac('0xa7')](function(_0x2041be){var _0x328a47;switch(_0x2041be['reportType']){case'default':_0x328a47=_['find'](_0x2d81de[_0x33ac('0x9')],function(_0x5784bb){return _0x5784bb['id']===_0x2041be[_0x33ac('0xab')]&&_0x5784bb[_0x33ac('0xe')]==='DefaultReports';});break;case _0x33ac('0xac'):_0x328a47=_[_0x33ac('0x91')](_0x2d81de['associatedResources'],function(_0x4de9a6){return _0x4de9a6['id']===_0x2041be['reportId']&&_0x4de9a6[_0x33ac('0xe')]===_0x33ac('0xad');});break;}if(_0x328a47)_0x1db0d5[_0x33ac('0x8f')](_0x2041be);});_0x4bb9d0[_0x33ac('0xae')]=_0x1db0d5[_0x33ac('0x8e')];_0x4bb9d0[_0x33ac('0xaf')]=_0x1db0d5;return _0x4bb9d0;});}else{return _0x218703[_0x371526[_0x33ac('0x12')]][_0x33ac('0xae')]({'where':_0x389570[_0x33ac('0x84')]})['then'](function(_0x4a74a7){_0x4bb9d0[_0x33ac('0xae')]=_0x4a74a7;if(_0x2f475f[_0x33ac('0x87')]['includeAll']){if(_0x371526['childModel']==='CmContact'){_0x389570[_0x33ac('0xaa')]=[{'model':_0x218703['Tag'],'as':_0x33ac('0xb0'),'attributes':['id','name',_0x33ac('0xb1')],'required':_0x2f475f[_0x33ac('0x87')]['tag']?!![]:![]},{'model':_0x218703[_0x33ac('0xb2')],'as':_0x33ac('0xb3'),'attributes':['id',_0x33ac('0xb'),_0x33ac('0xb1')],'through':_0x2f475f[_0x33ac('0x87')][_0x33ac('0xb4')]?{'attributes':[],'where':{'TagId':_0x2f475f[_0x33ac('0x87')]['tag']||undefined}}:{},'required':_0x2f475f[_0x33ac('0x87')][_0x33ac('0xb4')]?!![]:![]}];}else{_0x389570[_0x33ac('0xaa')]=[{'all':!![]}];}}return _0x218703[_0x371526[_0x33ac('0x12')]]['findAll'](_0x389570);})[_0x33ac('0x6')](function(_0x3dcdfb){_0x4bb9d0[_0x33ac('0xaf')]=_0x3dcdfb;if(_0x5a1264===_0x33ac('0x32')&&_0x2f475f[_0x33ac('0x87')][_0x33ac('0xb5')]==='true'){var _0x4da624=[];for(var _0x2bf658=0x0;_0x2bf658<_0x4bb9d0[_0x33ac('0xaf')][_0x33ac('0x8e')];_0x2bf658++){_0x4da624[_0x33ac('0x8f')](_0x1856db(_0x33ac('0xb6'),_0x4bb9d0[_0x33ac('0xaf')][_0x2bf658]['dataValues']));_0x4da624[_0x33ac('0x8f')](_0x1856db(_0x33ac('0xb7'),_0x4bb9d0[_0x33ac('0xaf')][_0x2bf658][_0x33ac('0xb8')]));_0x4da624['push'](_0x1856db(_0x33ac('0xb9'),_0x4bb9d0[_0x33ac('0xaf')][_0x2bf658][_0x33ac('0xb8')]));_0x4da624[_0x33ac('0x8f')](_0x1856db(_0x33ac('0xba'),_0x4bb9d0[_0x33ac('0xaf')][_0x2bf658][_0x33ac('0xb8')]));_0x4da624[_0x33ac('0x8f')](_0x1856db(_0x33ac('0xbb'),_0x4bb9d0[_0x33ac('0xaf')][_0x2bf658]['dataValues']));_0x4da624[_0x33ac('0x8f')](_0x1856db('whatsapp',_0x4bb9d0[_0x33ac('0xaf')][_0x2bf658]['dataValues']));}return Promise[_0x33ac('0x93')](_0x4da624)['then'](function(){return _0x4bb9d0;});}return _0x4bb9d0;});}});}}});};