Built motion from commit df3e9871f6bcc3432fec345b2f4facbd4dba8b5c. Version 3.0.0...
[motion-next.git] / server / api / cmContact / cmContact.controller.js
index cc92c1a..0633136 100644 (file)
@@ -1 +1 @@
-const a126_0x53ad=['rows','t.id\x20IN\x20?','CmCustomField','field','undefined','startsWith','Sequelize','CmHopperHistory','toString','MailInteraction','findOrCreate','isArray','c.firstName\x20LIKE\x20?','File\x20uploaded\x20correctly!','c.ListId\x20IN\x20?','QueryTypes','DESC','displayName','ReportAgentPreview','text','format','limit','stringify','FaxMessage','getTags','No\x20phone\x20column\x20specified','where','group','show','ids','includeAll','t.id\x20=\x20ct.TagId','ListId','create','../../components/parsers/advancedSearch','color','c.fax','parseSearch','status','No\x20firstName\x20column\x20specified','json','\x27\x27\x27\x27','CmHopper','Contact','trimStart','sequelize','binding_values','c.fax\x20LIKE\x20?','user','import','isNil','chmodSync','FaxQueueReport','path','c.mobile','c.lastName','getHopperHistories','catch','cf_%d','GROUP_CONCAT(DISTINCT\x20t.id)','forEach','error','intersection','message','../../components/parsers/qs','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','isNumeric','../../mysqldb','Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed','../../components/import/cm/csv','getFullTextValue','conditions','send','child_process','info','name','c.ListId\x20IS\x20NULL','../../config/logger','No\x20association\x20values\x20specified!','update','[CmContact][merge][destroy][CmHopperBlack],\x20%s','Tags','parse','set','CmHopperBlack','binding_keys','OpenchannelQueueReport','[CmContact][merge]\x20to\x20%s\x20from\x20%s','firstName','../../config/environment','file','get','isEmail','SmsMessage','buildExpression','CmContact','dateOfBirth','../../rediscache','table','c.email','attributes','register','./cmContact.socket','pid','alias','filters','ChatOfflineMessage','query','c.email\x20LIKE\x20?','describe','setTags','filter','fieldType','binding','count','socket_timestamp','options','pick','OpenchannelMessage','and','cm_contact_has_tags','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','uploadCsv','MailQueueReport','datetime','clone','error\x20child\x20process','params','offset','CONCAT_WS(\x27\x20\x27,\x20c.firstName,\x20c.lastName,\x20c.email)\x20LIKE\x20?','papaparse','zipObject','replace','pickBy','findOne','nolimit','select','cf_','cm_contacts','some','value','then','isEmpty','FaxInteraction','exit','fork','body','stack','each','omit','JscriptySessionReport','order','keyBy','DATE','castTo','VoiceCallReport','having','CmHopperFinal','TagIds','Incorrect\x20binding\x20parameters\x20passed!','phone','start','duplicates','destroy','fields','MailMessage','include','getLists','0777','c.deletedAt','c.phone\x20LIKE\x20?','left_join','split','start\x20child\x20process\x20correctly!','union','tools_tags','merge','length','sort','search','uc.UserId\x20=\x20?','meta','join','tags','ContactId','expr','type','push','$and','keys','model','c.id','filename','User','values','concat','Content-Range','find','Tag','SmsQueueReport','tag','upload','sqlOperator','[CmContact][merge][destroy][CmHopper],\x20%s','from','map','cm_user_has_contacts','rawAttributes','end','createReadStream','like','findAll'];(function(_0x51316a,_0x53ad86){const _0x3b48b6=function(_0x302568){while(--_0x302568){_0x51316a['push'](_0x51316a['shift']());}};_0x3b48b6(++_0x53ad86);}(a126_0x53ad,0x1cf));const a126_0x3b48=function(_0x51316a,_0x53ad86){_0x51316a=_0x51316a-0x0;let _0x3b48b6=a126_0x53ad[_0x51316a];return _0x3b48b6;};const _0x11bae0=a126_0x3b48;'use strict';const util=require('util'),path=require(_0x11bae0('0xe')),fs=require('fs'),_=require('lodash'),squel=require('squel'),Papa=require(_0x11bae0('0x5b')),{getSocket}=require(_0x11bae0('0x3a')),socket=getSocket(),qs=require(_0x11bae0('0x19')),as=require(_0x11bae0('0xcf')),logger=require(_0x11bae0('0x26'))('api'),config=require(_0x11bae0('0x32')),db=require(_0x11bae0('0x1c'))['db'],{Op}=require('sequelize');require(_0x11bae0('0x3f'))[_0x11bae0('0x3e')](socket);function respondWithResult(_0x302568,_0x2653ad){return _0x2653ad=_0x2653ad||0xc8,function(_0x525513){const _0x36eb2b=a126_0x3b48;if(_0x525513)return _0x302568[_0x36eb2b('0xd3')](_0x2653ad)[_0x36eb2b('0x1')](_0x525513);};}function respondWithFilteredResult(_0x406130,_0x2c1e10){return function(_0x2051f4){const _0x5bc17e=a126_0x3b48;if(_0x2051f4){const _0x8482aa=_0x2051f4['count'],_0x28790a=_0x2c1e10[_0x5bc17e('0x59')];let _0x11a522=_0x2c1e10['offset']+_0x2c1e10[_0x5bc17e('0xc2')],_0x586926;return _0x11a522>=_0x8482aa?(_0x11a522=_0x8482aa,_0x586926=0xc8):_0x586926=0xce,_0x406130[_0x5bc17e('0xd3')](_0x586926),_0x406130[_0x5bc17e('0x2c')](_0x5bc17e('0x9d'),_0x28790a+'-'+_0x11a522+'/'+_0x8482aa)[_0x5bc17e('0x1')](_0x2051f4);}return null;};}function saveUpdates(_0x29ea91){return function(_0x130e58){if(_0x130e58)return _0x130e58['update'](_0x29ea91)['then'](function(_0x3d4311){return _0x3d4311;});return null;};}function removeEntity(_0x54ee47){return function(_0x390c89){const _0x34a88=a126_0x3b48;if(_0x390c89)return _0x390c89[_0x34a88('0x7c')]()['then'](function(){const _0x3ce983=_0x34a88;_0x54ee47[_0x3ce983('0xd3')](0xcc)['end']();});};}function handleEntityNotFound(_0x56ef65){return function(_0x3b7ec1){return!_0x3b7ec1&&_0x56ef65['sendStatus'](0x194),_0x3b7ec1;};}function handleError(_0x589953,_0x56a122){return _0x56a122=_0x56a122||0x1f4,function(_0x56d265){const _0x3f102d=a126_0x3b48;logger[_0x3f102d('0x16')](_0x56d265[_0x3f102d('0x6c')]),_0x56d265['name']&&delete _0x56d265[_0x3f102d('0x24')],_0x589953[_0x3f102d('0xd3')](_0x56a122)[_0x3f102d('0x21')](_0x56d265);};}exports['index']=function(_0x236517,_0x2600d4){const _0x4564a6=_0x11bae0,_0x589089={},_0x2aa05e={},_0x5a0a60={'count':0x0,'rows':[]};return db[_0x4564a6('0x38')]['describe']()[_0x4564a6('0x66')](function(_0x719057){const _0x4142a4=_0x4564a6,_0x4ba7d5=[];for(let _0x3b182d=0x0;_0x3b182d<Object[_0x4142a4('0x96')](_0x719057)['length'];_0x3b182d++){const _0x21faf4=Object[_0x4142a4('0x96')](_0x719057)[_0x3b182d];_['startsWith'](_0x21faf4,_0x4142a4('0x62'))&&_0x4ba7d5[_0x4142a4('0x94')](db[_0x4142a4('0xaf')]['findOne']({'where':{'id':_[_0x4142a4('0x5')](_0x21faf4,_0x4142a4('0x62'))},'raw':!![]}));}return Promise['all'](_0x4ba7d5)['then'](function(_0x4f03d5){const _0x1878b7=_0x4142a4;for(let _0x184990=0x0;_0x184990<_0x4f03d5[_0x1878b7('0x8a')];_0x184990++){if(_0x4f03d5[_0x184990]){const _0x2b64ac=_0x1878b7('0x62')+_0x4f03d5[_0x184990]['id'],_0x55ed33=_0x719057[_0x2b64ac];_0x55ed33[_0x1878b7('0x49')]=_0x4f03d5[_0x184990]['type'];}}return _0x719057;});})[_0x4564a6('0x66')](function(_0x142831){const _0x10965f=_0x4564a6;_0x2aa05e[_0x10965f('0x97')]=_[_0x10965f('0x96')](_0x142831),_0x2aa05e[_0x10965f('0x44')]=_['keys'](_0x236517[_0x10965f('0x44')]),_0x2aa05e[_0x10965f('0x42')]=_[_0x10965f('0x17')](_0x2aa05e[_0x10965f('0x97')],_0x2aa05e[_0x10965f('0x44')]),_0x589089['attributes']=_[_0x10965f('0x17')](_0x2aa05e[_0x10965f('0x97')],qs[_0x10965f('0x7d')](_0x236517[_0x10965f('0x44')]['fields'])),_0x589089[_0x10965f('0x3d')]=_0x589089[_0x10965f('0x3d')][_0x10965f('0x8a')]?_0x589089[_0x10965f('0x3d')]:_0x2aa05e['model'];typeof _0x236517['query'][_0x10965f('0x60')]==='undefined'&&(_0x589089[_0x10965f('0xc2')]=qs[_0x10965f('0xc2')](_0x236517['query'][_0x10965f('0xc2')]),_0x589089[_0x10965f('0x59')]=qs[_0x10965f('0x59')](_0x236517[_0x10965f('0x44')][_0x10965f('0x59')]));_0x589089['order']=qs[_0x10965f('0x8b')](_0x236517[_0x10965f('0x44')][_0x10965f('0x8b')]),_0x589089[_0x10965f('0xc7')]=qs[_0x10965f('0x42')](_[_0x10965f('0x4e')](_0x236517['query'],_0x2aa05e[_0x10965f('0x42')]),_0x142831);let _0x296870=[];const _0x120be6=squel[_0x10965f('0x61')]()[_0x10965f('0xb0')]('id')[_0x10965f('0xb0')](_0x10965f('0x24'))[_0x10965f('0xb0')](_0x10965f('0xd0'))[_0x10965f('0xa5')](_0x10965f('0x88')),_0x1d84b4=squel[_0x10965f('0x61')]()['from'](_0x10965f('0x63'),'c')['left_join'](_0x10965f('0xa7'),'uc','uc.CmContactId\x20=\x20c.id')[_0x10965f('0x84')](_0x10965f('0x51'),'ct','ct.CmContactId\x20=\x20c.id')[_0x10965f('0x84')](_0x10965f('0x88'),'t',_0x10965f('0xcc'))[_0x10965f('0xc7')]('c.deletedAt\x20IS\x20NULL'),_0x38c4cf=squel['expr']();let _0x8fe575=[];const _0x247dd0=squel[_0x10965f('0x92')]();let _0x569a32;if(_0x236517[_0x10965f('0x44')][_0x10965f('0x8c')]){_0x569a32=as[_0x10965f('0xd2')](_0x236517[_0x10965f('0x44')][_0x10965f('0x8c')]);const _0x4e4ee2=_0x569a32[_0x10965f('0xa3')];for(let _0x2b76e2=0x0;_0x2b76e2<_0x569a32[_0x10965f('0x20')]['length'];_0x2b76e2++){const _0x432ad1=_0x569a32[_0x10965f('0x20')][_0x2b76e2],_0x1a02ff='c';let _0x4dda1b=_(_0x142831)[_0x10965f('0x96')]()[_0x10965f('0x9e')](function(_0x369907){return _0x369907===_0x432ad1['field'];});if(_0x4dda1b)_0x4dda1b=_0x142831[_0x432ad1[_0x10965f('0xb0')]];if(!_0x4dda1b){if(_0x432ad1[_0x10965f('0xb0')]==='Tag'){const _0x128f7a=_0x432ad1[_0x10965f('0x65')]['split'](',')[_0x10965f('0xa6')](function(_0x37c4c6){return Number(_0x37c4c6);});_0x128f7a[_0x10965f('0x15')](function(_0x19c68e){const _0xa4ec43=_0x10965f;_0x247dd0['or'](_0xa4ec43('0x52'),'%,'+_0x19c68e+',%');}),_0x8fe575=_[_0x10965f('0x87')](_0x8fe575,_0x128f7a);}else _0x432ad1['field']==='User'&&_0x38c4cf[_0x10965f('0x50')](_0x10965f('0x8d'),_0x432ad1[_0x10965f('0x65')]);}else{if(_0x432ad1[_0x10965f('0xb0')]===_0x10965f('0x39')||_0x4dda1b['fieldType']===_0x10965f('0x55'))_0x432ad1[_0x10965f('0x73')]=_0x10965f('0x72');const _0x59ff31=as[_0x10965f('0x37')](_0x1a02ff,_0x4dda1b['type'],_0x432ad1);_0x38c4cf[_0x4e4ee2](_0x59ff31['text'],_0x59ff31[_0x10965f('0x65')][_0x10965f('0x7a')],_0x59ff31[_0x10965f('0x65')][_0x10965f('0xa9')]);}}}else{const _0x1e61cf=_(Object['keys'](_0x236517[_0x10965f('0x44')]))[_0x10965f('0xa6')](function(_0x54ae3b){const _0x450095=_0x10965f;return typeof _0x142831[_0x54ae3b]===_0x450095('0xb1')?undefined:_0x54ae3b;})[_0x10965f('0x48')](function(_0x3ed67c){const _0x41d8bf=_0x10965f;return!_[_0x41d8bf('0xb')](_0x3ed67c);})[_0x10965f('0x65')]();if(_0x236517[_0x10965f('0x44')][_0x10965f('0x4')])_0x1e61cf['push'](_0x10965f('0x4'));!_[_0x10965f('0x67')](_0x1e61cf)&&_0x1e61cf[_0x10965f('0x15')](function(_0x2fb67f){const _0x4b3296=_0x10965f;if(_0x2fb67f===_0x4b3296('0xcd'))_0x1d84b4[_0x4b3296('0xc7')](_0x4b3296('0xbb'),[][_0x4b3296('0x9c')](_0x236517[_0x4b3296('0x44')][_0x2fb67f]));else{if(_0x2fb67f===_0x4b3296('0x4')){const _0x232fb5='%'+_0x236517[_0x4b3296('0x44')][_0x2fb67f]+'%';_0x1d84b4[_0x4b3296('0xc7')](_0x4b3296('0x5a'),_0x232fb5);}else _0x1d84b4['where']('c.'+_0x2fb67f+'\x20=\x20?',_0x236517[_0x4b3296('0x44')][_0x2fb67f]);}});_0x236517['query']['tag']&&(_0x8fe575=_['isArray'](_0x236517[_0x10965f('0x44')][_0x10965f('0xa1')])?_0x236517[_0x10965f('0x44')]['tag']:new Array(_0x236517[_0x10965f('0x44')][_0x10965f('0xa1')]),_0x8fe575[_0x10965f('0x15')](function(_0x36a1cd){const _0x2e01de=_0x10965f;_0x247dd0['or'](_0x2e01de('0x52'),'%,'+_0x36a1cd+',%');}));if(_0x236517['query'][_0x10965f('0x48')]){const _0x553366=_0x236517['query']['filter'][_0x10965f('0x5d')]('\x5c','\x5c\x5c')[_0x10965f('0x5d')]('\x27\x27',_0x10965f('0x2'));if(_0x553366['split']('\x20')[_0x10965f('0x8a')]>0x1)_0x38c4cf['or'](_0x10965f('0x1a'),qs[_0x10965f('0x1f')](_0x553366),null);else{if(qs[_0x10965f('0x1b')](_0x553366))_0x38c4cf['or']('c.id\x20LIKE\x20?',_0x553366+'%'),_0x38c4cf['or'](_0x10965f('0x83'),_0x553366+'%'),_0x38c4cf['or']('c.mobile\x20LIKE\x20?',_0x553366+'%'),_0x38c4cf['or'](_0x10965f('0x8'),_0x553366+'%');else qs[_0x10965f('0x35')](_0x553366)?_0x38c4cf['or'](_0x10965f('0x45'),_0x553366+'%'):(_0x38c4cf['or'](_0x10965f('0xb9'),'%'+_0x553366+'%'),_0x38c4cf['or']('c.lastName\x20LIKE\x20?','%'+_0x553366+'%'),_0x38c4cf['or'](_0x10965f('0x45'),'%'+_0x553366+'%'));}}}_0x1d84b4[_0x10965f('0xc7')](_0x38c4cf),_0x1d84b4[_0x10965f('0xc8')](_0x10965f('0x98'));let _0x2abf3f={'type':db[_0x10965f('0xb3')][_0x10965f('0xbc')]['SELECT'],'raw':!![]};const _0x199b43=_0x1d84b4[_0x10965f('0x56')]()[_0x10965f('0xb0')](_0x10965f('0x98'));_0x589089[_0x10965f('0x70')]&&_0x589089[_0x10965f('0x70')][_0x10965f('0x15')](function(_0x40a779){const _0xc63b7c=_0x10965f;_0x1d84b4[_0xc63b7c('0x70')]('c.'+_0x40a779[0x0],_0x40a779[0x1]===_0xc63b7c('0xbd')?![]:!![]);}),!_[_0x10965f('0x67')](_0x8fe575)&&(_0x1d84b4[_0x10965f('0x75')](_0x247dd0),_0x199b43[_0x10965f('0xc7')](_0x10965f('0xae'),_0x8fe575)),Promise['resolve']()['then'](function(){const _0x171580=_0x10965f;if(_0x569a32&&!_[_0x171580('0x64')](_0x569a32[_0x171580('0x20')],[_0x171580('0xb0'),_0x171580('0x9a')]))return _0x236517[_0x171580('0x9')][_0x171580('0x80')]({'attributes':['id'],'raw':!![]})[_0x171580('0x66')](function(_0x153a13){const _0x5b27cb=_0x171580;_[_0x5b27cb('0x67')](_0x153a13)?(_0x199b43[_0x5b27cb('0xc7')](_0x5b27cb('0x25')),_0x1d84b4[_0x5b27cb('0xc7')](_0x5b27cb('0x25'))):(_0x199b43[_0x5b27cb('0xc7')](_0x5b27cb('0xbb'),_[_0x5b27cb('0xa6')](_0x153a13,'id')),_0x1d84b4[_0x5b27cb('0xc7')](_0x5b27cb('0xbb'),_['map'](_0x153a13,'id')));});else return;})['then'](function(){const _0x38e100=_0x10965f;db['sequelize'][_0x38e100('0x44')](_0x199b43[_0x38e100('0xb5')](),_0x2abf3f)[_0x38e100('0x66')](function(_0x5e4f52){const _0x49fd70=_0x38e100;_0x5a0a60[_0x49fd70('0x4b')]=_0x5e4f52[_0x49fd70('0x8a')];if(_0x5a0a60[_0x49fd70('0x4b')]===0x0)return[];return db[_0x49fd70('0x6')][_0x49fd70('0x44')](_0x120be6[_0x49fd70('0xb5')](),_0x2abf3f);})[_0x38e100('0x66')](function(_0x2cdcf6){const _0x450958=_0x38e100;_0x296870=_[_0x450958('0x71')](_0x2cdcf6,'id'),_0x2abf3f=_[_0x450958('0x89')](_0x2abf3f,{'model':db['CmContact'],'mapToModel':!![],'raw':!![],'nest':!![]});_0x236517[_0x450958('0x44')][_0x450958('0x7d')]?_0x589089[_0x450958('0x3d')][_0x450958('0x15')](function(_0xcbef4){_0x1d84b4['field']('c.'+_0xcbef4);}):(_0x1d84b4['field'](_0x450958('0x98')),_0x1d84b4[_0x450958('0xb0')]('c.firstName'),_0x1d84b4[_0x450958('0xb0')](_0x450958('0x10')),_0x1d84b4[_0x450958('0xb0')]('c.phone'),_0x1d84b4[_0x450958('0xb0')](_0x450958('0xf')),_0x1d84b4['field'](_0x450958('0xd1')),_0x1d84b4[_0x450958('0xb0')](_0x450958('0x3c')),_0x1d84b4[_0x450958('0xb0')]('c.ListId'),_0x1d84b4['field'](_0x450958('0x82')),_0x1d84b4[_0x450958('0xb0')](_0x450958('0x14'),'TagIds'));if(_0x589089[_0x450958('0xc2')])_0x1d84b4['limit'](_0x589089[_0x450958('0xc2')]);if(_0x589089[_0x450958('0x59')])_0x1d84b4['offset'](_0x589089[_0x450958('0x59')]);return db[_0x450958('0x6')][_0x450958('0x44')](_0x1d84b4['toString'](),_0x2abf3f);})[_0x38e100('0x66')](function(_0xd4a5d2){return _0xd4a5d2['forEach'](function(_0x5cebe0){const _0x45636f=a126_0x3b48;_0x5cebe0[_0x45636f('0x77')]&&(_0x5cebe0['Tags']=[],_0x5cebe0[_0x45636f('0x77')][_0x45636f('0x85')](',')[_0x45636f('0x15')](function(_0x178a95){const _0x14460d=_0x45636f;_0x5cebe0[_0x14460d('0x2a')][_0x14460d('0x94')](_0x296870[_0x178a95]);})),delete _0x5cebe0[_0x45636f('0x77')];}),_0x5a0a60['rows']=_0xd4a5d2,_0x5a0a60;})[_0x38e100('0x66')](respondWithFilteredResult(_0x2600d4,_0x589089));});})['catch'](handleError(_0x2600d4,null));},exports[_0x11bae0('0x7c')]=function(_0x313302,_0x246a31){const _0x4c332b=_0x11bae0;return db[_0x4c332b('0x38')][_0x4c332b('0x5f')]({'where':{'id':_0x313302[_0x4c332b('0x58')]['id']}})[_0x4c332b('0x66')](handleEntityNotFound(_0x246a31,null))[_0x4c332b('0x66')](removeEntity(_0x246a31,null))[_0x4c332b('0x12')](handleError(_0x246a31,null));},exports['describe']=function(_0x499686,_0x2514a){const _0x1ea297=_0x11bae0;return db['CmContact'][_0x1ea297('0x46')]()[_0x1ea297('0x66')](function(_0x5285dc){const _0x9efaa0=_0x1ea297;delete _0x5285dc[_0x9efaa0('0x90')];for(let _0x3e2642=0x0;_0x3e2642<Object[_0x9efaa0('0x96')](_0x5285dc)[_0x9efaa0('0x8a')];_0x3e2642++){const _0x1f187c=Object['keys'](_0x5285dc)[_0x3e2642];!_[_0x9efaa0('0xb2')](_0x1f187c,_0x9efaa0('0x62'))&&(_0x5285dc[_0x1f187c]['columnName']=_0x1f187c,_0x5285dc[_0x1f187c][_0x9efaa0('0xbe')]=_0x1f187c);}return _0x5285dc;})[_0x1ea297('0x66')](function(_0x44b2e4){const _0x273099=_0x1ea297,_0x91c3b3={'where':{[Op['or']]:[{'ListId':_0x499686[_0x273099('0x44')]['id']},{'ListId':null}]},'raw':!![]};return db['CmCustomField'][_0x273099('0xac')](_0x91c3b3)[_0x273099('0x66')](function(_0x12fc2e){const _0x314e38=_0x273099;for(let _0x203e74=0x0;_0x203e74<_0x12fc2e[_0x314e38('0x8a')];_0x203e74++){const _0x201991=_0x314e38('0x62')+_0x12fc2e[_0x203e74]['id'];_0x44b2e4[_0x201991]['columnName']=_0x201991,_0x44b2e4[_0x201991][_0x314e38('0xbe')]=_0x12fc2e[_0x203e74][_0x314e38('0x41')],_0x44b2e4[_0x201991]['custom']={'type':_0x12fc2e[_0x203e74][_0x314e38('0x93')],'values':_0x12fc2e[_0x203e74][_0x314e38('0x9b')]};}return Object[_0x314e38('0x96')](_0x44b2e4)[_0x314e38('0x15')](function(_0x1d66b3){const _0x217879=_0x314e38;typeof _0x44b2e4[_0x1d66b3]['columnName']===_0x217879('0xb1')&&delete _0x44b2e4[_0x1d66b3];}),_0x44b2e4;});})['then'](respondWithResult(_0x2514a,null))[_0x1ea297('0x12')](handleError(_0x2514a,null));},exports[_0x11bae0('0x89')]=function(_0x5e2d35,_0x8ca4fa){const _0x569f2a=_0x11bae0;let _0x582e87,_0xfd3338,_0x45fefa;return _0x5e2d35[_0x569f2a('0x6b')]['id']&&delete _0x5e2d35[_0x569f2a('0x6b')]['id'],db['CmContact']['findAll']({'where':{'id':[_0x5e2d35[_0x569f2a('0x6b')]['to'],_0x5e2d35['body'][_0x569f2a('0xa5')]]}})['then'](function(_0x900d40){const _0x533890=_0x569f2a;if(_0x900d40){if(_0x900d40['length']!==0x2)return null;return _0x900d40[0x0]=_0x900d40[0x0]['get']({'plain':!![]}),_0x900d40[0x1]=_0x900d40[0x1][_0x533890('0x34')]({'plain':!![]}),delete _0x900d40[0x0]['id'],delete _0x900d40[0x1]['id'],_['mergeWith'](_0x900d40[0x0],_0x900d40[0x1],function(_0x30db82,_0x4db9dd){const _0x12d73c=_0x533890;if(Array[_0x12d73c('0xb8')](_0x4db9dd)&&!_0x4db9dd['length'])return _0x30db82;else{if(!_0x4db9dd)return _0x30db82;}});}})['then'](handleEntityNotFound(_0x8ca4fa,null))['then'](function(_0x59f315){const _0x2f822c=_0x569f2a;if(_0x59f315)return _0x59f315[_0x2f822c('0x90')]&&_[_0x2f822c('0xb8')](_0x59f315[_0x2f822c('0x90')])&&(_0x59f315['tags']=_0x59f315[_0x2f822c('0x90')][_0x2f822c('0x8f')]()),logger[_0x2f822c('0x23')](_0x2f822c('0x30'),_0x5e2d35[_0x2f822c('0x6b')]['to'],_0x5e2d35[_0x2f822c('0x6b')][_0x2f822c('0xa5')]),db[_0x2f822c('0x3')][_0x2f822c('0x7c')]({'where':{'ContactId':[_0x5e2d35[_0x2f822c('0x6b')]['to'],_0x5e2d35[_0x2f822c('0x6b')]['from']]}})['then'](function(_0x5e7327){const _0x2932c3=_0x2f822c;return logger[_0x2932c3('0x23')](_0x2932c3('0xa4'),_0x5e7327),db[_0x2932c3('0x2d')]['destroy']({'where':{'ContactId':[_0x5e2d35[_0x2932c3('0x6b')]['to'],_0x5e2d35[_0x2932c3('0x6b')]['from']]}})[_0x2932c3('0x66')](function(_0x13550f){const _0xd703b9=_0x2932c3;return logger[_0xd703b9('0x23')](_0xd703b9('0x29'),_0x13550f),db[_0xd703b9('0x38')][_0xd703b9('0xce')](_0x59f315);});});})[_0x569f2a('0x66')](function(_0x39e8a4){const _0xbab552=_0x569f2a;if(_0x39e8a4)return _0x582e87=_0x39e8a4,_0xfd3338={'ContactId':_0x582e87['id']},_0x45fefa={'where':{'ContactId':[_0x5e2d35[_0xbab552('0x6b')]['to'],_0x5e2d35['body'][_0xbab552('0xa5')]]}},db['ChatInteraction'][_0xbab552('0x28')](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){if(_0x582e87)return db['ChatMessage']['update'](_0xfd3338,_0x45fefa);})['then'](function(){const _0x28c4dc=_0x569f2a;if(_0x582e87)return db[_0x28c4dc('0x43')][_0x28c4dc('0x28')](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){const _0x4c6dc5=_0x569f2a;if(_0x582e87)return db['MailInteraction'][_0x4c6dc5('0x28')](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){const _0x556847=_0x569f2a;if(_0x582e87)return db[_0x556847('0x7e')][_0x556847('0x28')](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){const _0x4c70fe=_0x569f2a;if(_0x582e87)return db[_0x4c70fe('0xb6')]['update'](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){const _0xf78c42=_0x569f2a;if(_0x582e87)return db['MailMessage'][_0xf78c42('0x28')](_0xfd3338,_0x45fefa);})['then'](function(){const _0xabdbe2=_0x569f2a;if(_0x582e87)return db['SmsInteraction'][_0xabdbe2('0x28')](_0xfd3338,_0x45fefa);})['then'](function(){const _0x25725e=_0x569f2a;if(_0x582e87)return db[_0x25725e('0x36')][_0x25725e('0x28')](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){const _0x4fefb2=_0x569f2a;if(_0x582e87)return db[_0x4fefb2('0x68')]['update'](_0xfd3338,_0x45fefa);})['then'](function(){const _0x2dd485=_0x569f2a;if(_0x582e87)return db[_0x2dd485('0xc4')][_0x2dd485('0x28')](_0xfd3338,_0x45fefa);})['then'](function(){const _0x54d7e8=_0x569f2a;if(_0x582e87)return db['OpenchannelInteraction'][_0x54d7e8('0x28')](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){const _0x40bbe0=_0x569f2a;if(_0x582e87)return db[_0x40bbe0('0x4f')]['update'](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){const _0x2e9f42=_0x569f2a;if(_0x582e87)return db[_0x2e9f42('0x76')][_0x2e9f42('0x28')](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){const _0x166a83=_0x569f2a;if(_0x582e87)return db[_0x166a83('0xb4')][_0x166a83('0x28')](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){const _0x399a3f=_0x569f2a;if(_0x582e87)return db[_0x399a3f('0xbf')][_0x399a3f('0x28')](_0xfd3338,_0x45fefa);})['then'](function(){const _0x3c0766=_0x569f2a;if(_0x582e87)return db[_0x3c0766('0x74')][_0x3c0766('0x28')](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){if(_0x582e87)return db['ChatQueueReport']['update'](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){const _0x2a4a90=_0x569f2a;if(_0x582e87)return db[_0x2a4a90('0xd')][_0x2a4a90('0x28')](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){const _0x19cb95=_0x569f2a;if(_0x582e87)return db[_0x19cb95('0x54')][_0x19cb95('0x28')](_0xfd3338,_0x45fefa);})['then'](function(){const _0x32680a=_0x569f2a;if(_0x582e87)return db[_0x32680a('0x2f')]['update'](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){const _0x52e7da=_0x569f2a;if(_0x582e87)return db[_0x52e7da('0xa0')][_0x52e7da('0x28')](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){const _0x2c6db1=_0x569f2a;if(_0x582e87)return db[_0x2c6db1('0x6f')][_0x2c6db1('0x28')](_0xfd3338,_0x45fefa);})[_0x569f2a('0x66')](function(){const _0x1ad752=_0x569f2a;if(_0x582e87)return db[_0x1ad752('0x38')][_0x1ad752('0x7c')]({'where':{'id':[_0x5e2d35[_0x1ad752('0x6b')]['to'],_0x5e2d35[_0x1ad752('0x6b')][_0x1ad752('0xa5')]]}});})[_0x569f2a('0x66')](function(){if(_0x582e87)return _0x582e87;})[_0x569f2a('0x66')](respondWithResult(_0x8ca4fa,null))['catch'](handleError(_0x8ca4fa,null));},exports['create']=function(_0x2826a2,_0x9a8464){const _0x28ca70=_0x11bae0;return db[_0x28ca70('0x38')]['describe']()[_0x28ca70('0x66')](function(_0xa11222){const _0x409e47=_0x28ca70;return _0x2826a2[_0x409e47('0x6b')][_0x409e47('0x90')]&&_['isArray'](_0x2826a2['body'][_0x409e47('0x90')])?_0x2826a2['body'][_0x409e47('0x90')][_0x409e47('0x8a')]?_0x2826a2[_0x409e47('0x6b')]['tags']=_0x2826a2[_0x409e47('0x6b')][_0x409e47('0x90')][_0x409e47('0x8f')](';')+';':_0x2826a2[_0x409e47('0x6b')][_0x409e47('0x90')]=null:_0x2826a2[_0x409e47('0x6b')]['tags']=null,db[_0x409e47('0x38')][_0x409e47('0xce')](_0x2826a2[_0x409e47('0x6b')],{'fields':_[_0x409e47('0x96')](_0xa11222),'raw':!![]});})[_0x28ca70('0x66')](respondWithResult(_0x9a8464,0xc9))[_0x28ca70('0x12')](handleError(_0x9a8464,null));},exports['bulkCreate']=function(_0x331c59,_0x44a829){const _0x272013=_0x11bae0;let _0x493931=0x0,_0x2b8947=0x0,_0x3f2149=0x0;return db['CmContact'][_0x272013('0x46')]()[_0x272013('0x66')](function(_0x59467d){const _0x3bf975=_0x272013;return Promise[_0x3bf975('0x6d')](_0x331c59['body'],function(_0x1b71fa){const _0x1ad9c4=_0x3bf975,_0x3633d3={'where':{[Op['or']]:[]},'defaults':_0x1b71fa,'fields':_['keys'](_0x59467d),'raw':!![]};if(_0x1b71fa['duplicates']){for(let _0x189877=0x0;_0x189877<_0x1b71fa['duplicates'][_0x1ad9c4('0x8a')];_0x189877++){const _0x1aca29={};_0x1aca29[_0x1b71fa[_0x1ad9c4('0x7b')][_0x189877]]=_0x1b71fa[_0x1b71fa[_0x1ad9c4('0x7b')][_0x189877]],_0x3633d3[_0x1ad9c4('0xc7')][Op['or']][_0x1ad9c4('0x94')](_0x1aca29);}_0x3633d3['where'][_0x1ad9c4('0xcd')]=_0x1b71fa[_0x1ad9c4('0xcd')];}return db[_0x1ad9c4('0x38')][_0x1ad9c4('0xb7')](_0x3633d3)[_0x1ad9c4('0x66')](function([,_0x42327d]){_0x42327d?_0x493931++:_0x3f2149++;})['catch'](function(_0x4eeec5){const _0x3d74e7=_0x1ad9c4;console[_0x3d74e7('0x16')](_0x4eeec5),_0x2b8947++;});});})[_0x272013('0x66')](function(_0x181598){if(_0x181598)return{'success':_0x493931,'failure':_0x2b8947,'duplicates':_0x3f2149};})[_0x272013('0x66')](respondWithResult(_0x44a829,0xc9))['catch'](handleError(_0x44a829,null));},exports[_0x11bae0('0xc9')]=function(_0x188148,_0x522176){const _0x1cb675=_0x11bae0;let _0x18502e;return db[_0x1cb675('0x38')][_0x1cb675('0x46')]()['then'](function(_0x45b21d){const _0x5c5e8b=_0x1cb675;return db['CmContact'][_0x5c5e8b('0x5f')]({'where':{'id':_0x188148['params']['id']},'include':[{'model':db[_0x5c5e8b('0x9f')],'as':'Tags','attributes':['id',_0x5c5e8b('0x24'),_0x5c5e8b('0xd0')],'required':_0x188148['query'][_0x5c5e8b('0xa1')]?!![]:![]}],'attributes':_[_0x5c5e8b('0x96')](_0x45b21d)});})[_0x1cb675('0x66')](function(_0x18a288){const _0x569a1a=_0x1cb675;_0x18502e=_0x18a288['get']({'plain':!![]});const _0x198ae8={'where':{[Op[_0x569a1a('0x50')]]:[{'ListId':{[Op['ne']]:null}}]}};return _0x18a288&&_0x18a288[_0x569a1a('0xcd')]&&(_0x18a288[_0x569a1a('0xcd')]&&_0x198ae8['where'][_0x569a1a('0x95')]['push']({'ListId':{[Op['ne']]:_0x18a288[_0x569a1a('0xcd')]}})),db['CmCustomField']['findAll'](_0x198ae8);})['then'](function(_0x4d9da3){const _0x48ad7f=_0x1cb675;return _[_0x48ad7f('0x6e')](_0x18502e,_[_0x48ad7f('0xa6')](_0x4d9da3,function(_0x15954f){const _0x1cdfc3=_0x48ad7f;return util[_0x1cdfc3('0xc1')](_0x1cdfc3('0x13'),_0x15954f['id']);}));})['then'](handleEntityNotFound(_0x522176,null))[_0x1cb675('0x66')](respondWithResult(_0x522176,null))[_0x1cb675('0x12')](handleError(_0x522176,null));},exports[_0x11bae0('0x28')]=function(_0x4edc8f,_0x2fa76b){const _0x53aa2e=_0x11bae0;let _0xe1ed60;return _0x4edc8f[_0x53aa2e('0x6b')]['id']&&delete _0x4edc8f[_0x53aa2e('0x6b')]['id'],db['CmContact'][_0x53aa2e('0x5f')]({'where':{'id':_0x4edc8f[_0x53aa2e('0x58')]['id']}})[_0x53aa2e('0x66')](handleEntityNotFound(_0x2fa76b,null))[_0x53aa2e('0x66')](saveUpdates(_0x4edc8f[_0x53aa2e('0x6b')],null))[_0x53aa2e('0x66')](function(_0x464ff3){const _0x96f8cc=_0x53aa2e;_0xe1ed60=_0x464ff3;const _0x44a562={'where':{[Op[_0x96f8cc('0x50')]]:[{'ListId':{[Op['ne']]:null}}]}};return _0x464ff3&&_0x464ff3['ListId']&&(_0x464ff3[_0x96f8cc('0xcd')]&&_0x44a562[_0x96f8cc('0xc7')][_0x96f8cc('0x95')][_0x96f8cc('0x94')]({'ListId':{[Op['ne']]:_0x464ff3[_0x96f8cc('0xcd')]}})),db[_0x96f8cc('0xaf')]['findAll'](_0x44a562);})[_0x53aa2e('0x66')](function(_0x3f0c2f){const _0x404196=_0x53aa2e;if(_0x3f0c2f)return _[_0x404196('0x6e')](_[_0x404196('0x5e')](_0x4edc8f[_0x404196('0x6b')],function(_0x21279c,_0x437c9a){const _0x25c2a2=_0x404196;return _[_0x25c2a2('0xb2')](_0x437c9a,_0x25c2a2('0x62'));}),_[_0x404196('0xa6')](_0x3f0c2f,function(_0x804238){const _0x3fc167=_0x404196;return util['format'](_0x3fc167('0x13'),_0x804238['id']);}));})['then'](function(_0x33939d){const _0x41df8a=_0x53aa2e;if(_0x33939d&&!_['isEmpty'](_0x33939d)){const _0x1951a8=squel[_0x41df8a('0x28')]()[_0x41df8a('0x3b')](_0x41df8a('0x63'))['setFields'](_0x33939d)[_0x41df8a('0xc7')]('id\x20=\x20?',_0x4edc8f[_0x41df8a('0x58')]['id'])['toParam']();return db['sequelize'][_0x41df8a('0x44')](_0x1951a8[_0x41df8a('0xc0')],{'replacements':_0x1951a8[_0x41df8a('0x9b')]});}})[_0x53aa2e('0x66')](function(){const _0x14c5bf=_0x53aa2e;if(_0x4edc8f[_0x14c5bf('0x6b')][_0x14c5bf('0x79')]&&_0xe1ed60)return db[_0x14c5bf('0x3')]['update']({'phone':_0x4edc8f['body'][_0x14c5bf('0x79')]},{'where':{'ContactId':_0xe1ed60['id']}});})[_0x53aa2e('0x66')](function(){return _0xe1ed60;})[_0x53aa2e('0x66')](respondWithResult(_0x2fa76b,null))[_0x53aa2e('0x12')](handleError(_0x2fa76b,null));},exports[_0x11bae0('0xc5')]=function(_0x46cd3c,_0x6e2565){const _0x39c0ec=_0x11bae0;let _0xb7a7a2={};const _0x4f7eaa={};let _0x9910e,_0x3ad690;return db['CmContact'][_0x39c0ec('0x5f')]({'where':{'id':_0x46cd3c['params']['id']}})[_0x39c0ec('0x66')](handleEntityNotFound(_0x6e2565,null))['then'](function(_0x1e610f){const _0x54c7e1=_0x39c0ec;if(_0x1e610f)return _0x9910e=_0x1e610f,_0x4f7eaa[_0x54c7e1('0x97')]=_[_0x54c7e1('0x96')](db[_0x54c7e1('0x9f')][_0x54c7e1('0xa8')]),_0x4f7eaa[_0x54c7e1('0x44')]=_['keys'](_0x46cd3c[_0x54c7e1('0x44')]),_0x4f7eaa[_0x54c7e1('0x42')]=_['intersection'](_0x4f7eaa[_0x54c7e1('0x97')],_0x4f7eaa['query']),_0xb7a7a2[_0x54c7e1('0x3d')]=_[_0x54c7e1('0x17')](_0x4f7eaa[_0x54c7e1('0x97')],qs[_0x54c7e1('0x7d')](_0x46cd3c[_0x54c7e1('0x44')][_0x54c7e1('0x7d')])),_0xb7a7a2[_0x54c7e1('0x3d')]=_0xb7a7a2[_0x54c7e1('0x3d')]['length']?_0xb7a7a2[_0x54c7e1('0x3d')]:_0x4f7eaa[_0x54c7e1('0x97')],_0xb7a7a2[_0x54c7e1('0x70')]=qs[_0x54c7e1('0x8b')](_0x46cd3c[_0x54c7e1('0x44')][_0x54c7e1('0x8b')]),_0xb7a7a2['where']=qs['filters'](_['pick'](_0x46cd3c['query'],_0x4f7eaa['filters'])),_0x46cd3c[_0x54c7e1('0x44')][_0x54c7e1('0x48')]&&(_0xb7a7a2[_0x54c7e1('0xc7')]=_['merge'](_0xb7a7a2[_0x54c7e1('0xc7')],{[Op['or']]:_[_0x54c7e1('0xa6')](_0xb7a7a2['attributes'],function(_0x2d85b1){const _0x46f006=_0x54c7e1,_0x13b67f={};return _0x13b67f[_0x2d85b1]={[Op['like']]:'%'+_0x46cd3c[_0x46f006('0x44')][_0x46f006('0x48')]+'%'},_0x13b67f;})})),_0xb7a7a2=_[_0x54c7e1('0x89')]({},_0xb7a7a2,_0x46cd3c['options']),_0x9910e[_0x54c7e1('0xc5')](_0xb7a7a2);})['then'](function(_0x342b98){const _0x503bfe=_0x39c0ec;if(_0x342b98)return _0x3ad690=_0x342b98[_0x503bfe('0x8a')],typeof _0x46cd3c[_0x503bfe('0x44')][_0x503bfe('0x60')]==='undefined'&&(_0xb7a7a2[_0x503bfe('0xc2')]=qs[_0x503bfe('0xc2')](_0x46cd3c[_0x503bfe('0x44')][_0x503bfe('0xc2')]),_0xb7a7a2['offset']=qs[_0x503bfe('0x59')](_0x46cd3c['query'][_0x503bfe('0x59')])),_0x9910e['getTags'](_0xb7a7a2);})[_0x39c0ec('0x66')](function(_0x4c1323){if(_0x4c1323)return _0x4c1323?{'count':_0x3ad690,'rows':_0x4c1323}:null;})[_0x39c0ec('0x66')](respondWithResult(_0x6e2565,null))['catch'](handleError(_0x6e2565,null));},exports[_0x11bae0('0x47')]=function(_0x311abe,_0x1c940f){const _0x32360f=_0x11bae0;return _0x311abe[_0x32360f('0x6b')]['id']&&delete _0x311abe['body']['id'],db[_0x32360f('0x38')][_0x32360f('0x5f')]({'where':{'id':_0x311abe[_0x32360f('0x58')]['id']}})[_0x32360f('0x66')](handleEntityNotFound(_0x1c940f,null))[_0x32360f('0x66')](function(_0xe4967d){const _0x52c524=_0x32360f;if(_0xe4967d)return _0xe4967d['setTags'](_0x311abe[_0x52c524('0x6b')][_0x52c524('0xca')]||[]);return null;})['then'](respondWithResult(_0x1c940f,null))['catch'](handleError(_0x1c940f,null));},exports['getHoppers']=function(_0x4d14fe,_0x4b2f5e){const _0x112804=_0x11bae0;let _0x244705={'raw':![],'where':{}};const _0x5d514d={},_0x11c47d={'count':0x0,'rows':[]};return db[_0x112804('0x38')][_0x112804('0x5f')]({'where':{'id':_0x4d14fe['params']['id']}})[_0x112804('0x66')](handleEntityNotFound(_0x4b2f5e,null))[_0x112804('0x66')](function(_0x128281){const _0x11e3b0=_0x112804;if(_0x128281)return _0x5d514d[_0x11e3b0('0x97')]=_['keys'](db['CmHopper']['rawAttributes']),_0x5d514d[_0x11e3b0('0x44')]=_[_0x11e3b0('0x96')](_0x4d14fe[_0x11e3b0('0x44')]),_0x5d514d[_0x11e3b0('0x42')]=_[_0x11e3b0('0x17')](_0x5d514d['model'],_0x5d514d[_0x11e3b0('0x44')]),_0x244705[_0x11e3b0('0x3d')]=_[_0x11e3b0('0x17')](_0x5d514d[_0x11e3b0('0x97')],qs[_0x11e3b0('0x7d')](_0x4d14fe[_0x11e3b0('0x44')]['fields'])),_0x244705['attributes']=_0x244705[_0x11e3b0('0x3d')][_0x11e3b0('0x8a')]?_0x244705[_0x11e3b0('0x3d')]:_0x5d514d[_0x11e3b0('0x97')],typeof _0x4d14fe['query'][_0x11e3b0('0x60')]===_0x11e3b0('0xb1')&&(_0x244705[_0x11e3b0('0xc2')]=qs[_0x11e3b0('0xc2')](_0x4d14fe[_0x11e3b0('0x44')][_0x11e3b0('0xc2')]),_0x244705['offset']=qs[_0x11e3b0('0x59')](_0x4d14fe[_0x11e3b0('0x44')][_0x11e3b0('0x59')])),_0x244705[_0x11e3b0('0x70')]=qs[_0x11e3b0('0x8b')](_0x4d14fe[_0x11e3b0('0x44')][_0x11e3b0('0x8b')]),_0x244705[_0x11e3b0('0xc7')]=qs[_0x11e3b0('0x42')](_[_0x11e3b0('0x4e')](_0x4d14fe[_0x11e3b0('0x44')],_0x5d514d[_0x11e3b0('0x42')])),_0x244705[_0x11e3b0('0xc7')]['ContactId']=_0x128281['id'],_0x4d14fe['query']['filter']&&(_0x244705[_0x11e3b0('0xc7')]=_[_0x11e3b0('0x89')](_0x244705['where'],{[Op['or']]:_['map'](_0x244705[_0x11e3b0('0x3d')],function(_0x2424c7){const _0xef7a41=_0x11e3b0,_0x417c4e={};return _0x417c4e[_0x2424c7]={[Op[_0xef7a41('0xab')]]:'%'+_0x4d14fe[_0xef7a41('0x44')]['filter']+'%'},_0x417c4e;})})),_0x244705=_[_0x11e3b0('0x89')]({},_0x244705,_0x4d14fe[_0x11e3b0('0x4d')]),db['CmHopper'][_0x11e3b0('0x4b')]({'where':_0x244705['where']})[_0x11e3b0('0x66')](function(_0x23c9f1){const _0x2dff7e=_0x11e3b0;return _0x11c47d[_0x2dff7e('0x4b')]=_0x23c9f1,_0x4d14fe['query'][_0x2dff7e('0xcb')]&&(_0x244705[_0x2dff7e('0x7f')]=[{'all':!![]}]),db[_0x2dff7e('0x3')][_0x2dff7e('0xac')](_0x244705);})[_0x11e3b0('0x66')](function(_0xd67de4){const _0x55379e=_0x11e3b0;return _0x11c47d[_0x55379e('0xad')]=_0xd67de4,_0x11c47d;});})[_0x112804('0x66')](respondWithFilteredResult(_0x4b2f5e,_0x244705))[_0x112804('0x12')](handleError(_0x4b2f5e,null));},exports[_0x11bae0('0x11')]=function(_0x492d7d,_0x191927){const _0x2aa488=_0x11bae0;let _0x3ccc03={'raw':!![],'where':{}};const _0x11c2b5={},_0x1c3c23={'count':0x0,'rows':[]};return db[_0x2aa488('0x38')][_0x2aa488('0x5f')]({'where':{'id':_0x492d7d['params']['id']}})['then'](handleEntityNotFound(_0x191927,null))[_0x2aa488('0x66')](function(_0x143fae){const _0x1f8953=_0x2aa488;if(_0x143fae)return _0x11c2b5['model']=_[_0x1f8953('0x96')](db['CmHopperHistory'][_0x1f8953('0xa8')]),_0x11c2b5['query']=_[_0x1f8953('0x96')](_0x492d7d[_0x1f8953('0x44')]),_0x11c2b5[_0x1f8953('0x42')]=_[_0x1f8953('0x17')](_0x11c2b5[_0x1f8953('0x97')],_0x11c2b5['query']),_0x3ccc03[_0x1f8953('0x3d')]=_['intersection'](_0x11c2b5['model'],qs['fields'](_0x492d7d[_0x1f8953('0x44')][_0x1f8953('0x7d')])),_0x3ccc03['attributes']=_0x3ccc03[_0x1f8953('0x3d')]['length']?_0x3ccc03['attributes']:_0x11c2b5[_0x1f8953('0x97')],typeof _0x492d7d['query'][_0x1f8953('0x60')]==='undefined'&&(_0x3ccc03[_0x1f8953('0xc2')]=qs[_0x1f8953('0xc2')](_0x492d7d[_0x1f8953('0x44')]['limit']),_0x3ccc03[_0x1f8953('0x59')]=qs[_0x1f8953('0x59')](_0x492d7d['query'][_0x1f8953('0x59')])),_0x3ccc03[_0x1f8953('0x70')]=qs[_0x1f8953('0x8b')](_0x492d7d[_0x1f8953('0x44')]['sort']),_0x3ccc03[_0x1f8953('0xc7')]=qs['filters'](_[_0x1f8953('0x4e')](_0x492d7d['query'],_0x11c2b5[_0x1f8953('0x42')])),_0x3ccc03[_0x1f8953('0xc7')][_0x1f8953('0x91')]=_0x143fae['id'],_0x492d7d[_0x1f8953('0x44')]['filter']&&(_0x3ccc03[_0x1f8953('0xc7')]=_[_0x1f8953('0x89')](_0x3ccc03[_0x1f8953('0xc7')],{[Op['or']]:_['map'](_0x3ccc03[_0x1f8953('0x3d')],function(_0xf5d64e){const _0x442816=_0x1f8953,_0x42d5dc={};return _0x42d5dc[_0xf5d64e]={[Op[_0x442816('0xab')]]:'%'+_0x492d7d[_0x442816('0x44')][_0x442816('0x48')]+'%'},_0x42d5dc;})})),_0x3ccc03=_[_0x1f8953('0x89')]({},_0x3ccc03,_0x492d7d[_0x1f8953('0x4d')]),db[_0x1f8953('0xb4')]['count']({'where':_0x3ccc03[_0x1f8953('0xc7')]})[_0x1f8953('0x66')](function(_0x24ff52){const _0x438b0a=_0x1f8953;return _0x1c3c23[_0x438b0a('0x4b')]=_0x24ff52,_0x492d7d[_0x438b0a('0x44')][_0x438b0a('0xcb')]&&(_0x3ccc03[_0x438b0a('0x7f')]=[{'all':!![]}]),db[_0x438b0a('0xb4')][_0x438b0a('0xac')](_0x3ccc03);})[_0x1f8953('0x66')](function(_0x1115ae){const _0x1bc4d5=_0x1f8953;return _0x1c3c23[_0x1bc4d5('0xad')]=_0x1115ae,_0x1c3c23;});})[_0x2aa488('0x66')](respondWithFilteredResult(_0x191927,_0x3ccc03))['catch'](handleError(_0x191927,null));},exports['getHopperFinals']=function(_0x3daf60,_0x18fbf0){const _0x4d2329=_0x11bae0;let _0x553e35={'raw':!![],'where':{}};const _0x50a9f9={},_0x203e70={'count':0x0,'rows':[]};return db[_0x4d2329('0x38')][_0x4d2329('0x5f')]({'where':{'id':_0x3daf60[_0x4d2329('0x58')]['id']}})[_0x4d2329('0x66')](handleEntityNotFound(_0x18fbf0,null))[_0x4d2329('0x66')](function(_0x169fff){const _0x1c4516=_0x4d2329;if(_0x169fff)return _0x50a9f9[_0x1c4516('0x97')]=_[_0x1c4516('0x96')](db[_0x1c4516('0x76')][_0x1c4516('0xa8')]),_0x50a9f9[_0x1c4516('0x44')]=_[_0x1c4516('0x96')](_0x3daf60[_0x1c4516('0x44')]),_0x50a9f9[_0x1c4516('0x42')]=_[_0x1c4516('0x17')](_0x50a9f9['model'],_0x50a9f9[_0x1c4516('0x44')]),_0x553e35['attributes']=_[_0x1c4516('0x17')](_0x50a9f9[_0x1c4516('0x97')],qs[_0x1c4516('0x7d')](_0x3daf60[_0x1c4516('0x44')][_0x1c4516('0x7d')])),_0x553e35[_0x1c4516('0x3d')]=_0x553e35[_0x1c4516('0x3d')][_0x1c4516('0x8a')]?_0x553e35[_0x1c4516('0x3d')]:_0x50a9f9[_0x1c4516('0x97')],typeof _0x3daf60[_0x1c4516('0x44')][_0x1c4516('0x60')]===_0x1c4516('0xb1')&&(_0x553e35[_0x1c4516('0xc2')]=qs[_0x1c4516('0xc2')](_0x3daf60[_0x1c4516('0x44')][_0x1c4516('0xc2')]),_0x553e35[_0x1c4516('0x59')]=qs['offset'](_0x3daf60['query'][_0x1c4516('0x59')])),_0x553e35[_0x1c4516('0x70')]=qs[_0x1c4516('0x8b')](_0x3daf60[_0x1c4516('0x44')][_0x1c4516('0x8b')]),_0x553e35[_0x1c4516('0xc7')]=qs[_0x1c4516('0x42')](_['pick'](_0x3daf60[_0x1c4516('0x44')],_0x50a9f9[_0x1c4516('0x42')])),_0x553e35[_0x1c4516('0xc7')][_0x1c4516('0x91')]=_0x169fff['id'],_0x3daf60[_0x1c4516('0x44')][_0x1c4516('0x48')]&&(_0x553e35[_0x1c4516('0xc7')]=_[_0x1c4516('0x89')](_0x553e35[_0x1c4516('0xc7')],{[Op['or']]:_[_0x1c4516('0xa6')](_0x553e35[_0x1c4516('0x3d')],function(_0x55ed8e){const _0x44ea37=_0x1c4516,_0x186171={};return _0x186171[_0x55ed8e]={[Op[_0x44ea37('0xab')]]:'%'+_0x3daf60['query'][_0x44ea37('0x48')]+'%'},_0x186171;})})),_0x553e35=_[_0x1c4516('0x89')]({},_0x553e35,_0x3daf60[_0x1c4516('0x4d')]),db[_0x1c4516('0x76')][_0x1c4516('0x4b')]({'where':_0x553e35[_0x1c4516('0xc7')]})[_0x1c4516('0x66')](function(_0x19e931){const _0x2ac4ce=_0x1c4516;return _0x203e70[_0x2ac4ce('0x4b')]=_0x19e931,_0x3daf60[_0x2ac4ce('0x44')][_0x2ac4ce('0xcb')]&&(_0x553e35[_0x2ac4ce('0x7f')]=[{'all':!![]}]),db[_0x2ac4ce('0x76')]['findAll'](_0x553e35);})['then'](function(_0x34035c){const _0x5b6500=_0x1c4516;return _0x203e70[_0x5b6500('0xad')]=_0x34035c,_0x203e70;});})['then'](respondWithFilteredResult(_0x18fbf0,_0x553e35))[_0x4d2329('0x12')](handleError(_0x18fbf0,null));},exports['getJscriptySessions']=function(_0x5ab83e,_0x322c54){const _0x3da101=_0x11bae0;let _0x158efe={'raw':!![],'where':{}};const _0x411e12={},_0x3234e8={'count':0x0,'rows':[]};return db[_0x3da101('0x38')]['findOne']({'where':{'id':_0x5ab83e['params']['id']}})[_0x3da101('0x66')](handleEntityNotFound(_0x322c54,null))[_0x3da101('0x66')](function(_0x5419ca){const _0x1cf8b8=_0x3da101;if(_0x5419ca)return _0x411e12[_0x1cf8b8('0x97')]=_[_0x1cf8b8('0x96')](db['JscriptySessionReport']['rawAttributes']),_0x411e12[_0x1cf8b8('0x44')]=_['keys'](_0x5ab83e['query']),_0x411e12[_0x1cf8b8('0x42')]=_[_0x1cf8b8('0x17')](_0x411e12[_0x1cf8b8('0x97')],_0x411e12[_0x1cf8b8('0x44')]),_0x158efe['attributes']=_['intersection'](_0x411e12[_0x1cf8b8('0x97')],qs[_0x1cf8b8('0x7d')](_0x5ab83e[_0x1cf8b8('0x44')]['fields'])),_0x158efe['attributes']=_0x158efe[_0x1cf8b8('0x3d')][_0x1cf8b8('0x8a')]?_0x158efe[_0x1cf8b8('0x3d')]:_0x411e12[_0x1cf8b8('0x97')],typeof _0x5ab83e['query'][_0x1cf8b8('0x60')]==='undefined'&&(_0x158efe[_0x1cf8b8('0xc2')]=qs[_0x1cf8b8('0xc2')](_0x5ab83e['query']['limit']),_0x158efe[_0x1cf8b8('0x59')]=qs[_0x1cf8b8('0x59')](_0x5ab83e['query'][_0x1cf8b8('0x59')])),_0x158efe[_0x1cf8b8('0x70')]=qs[_0x1cf8b8('0x8b')](_0x5ab83e['query'][_0x1cf8b8('0x8b')]),_0x158efe[_0x1cf8b8('0xc7')]=qs['filters'](_[_0x1cf8b8('0x4e')](_0x5ab83e[_0x1cf8b8('0x44')],_0x411e12[_0x1cf8b8('0x42')])),_0x158efe[_0x1cf8b8('0xc7')]['ContactId']=_0x5419ca['id'],_0x5ab83e[_0x1cf8b8('0x44')]['filter']&&(_0x158efe[_0x1cf8b8('0xc7')]=_[_0x1cf8b8('0x89')](_0x158efe[_0x1cf8b8('0xc7')],{[Op['or']]:_[_0x1cf8b8('0xa6')](_0x158efe[_0x1cf8b8('0x3d')],function(_0x5295c9){const _0x337b84=_0x1cf8b8,_0x3cb7a6={};return _0x3cb7a6[_0x5295c9]={[Op[_0x337b84('0xab')]]:'%'+_0x5ab83e[_0x337b84('0x44')][_0x337b84('0x48')]+'%'},_0x3cb7a6;})})),_0x158efe=_[_0x1cf8b8('0x89')]({},_0x158efe,_0x5ab83e[_0x1cf8b8('0x4d')]),db['JscriptySessionReport'][_0x1cf8b8('0x4b')]({'where':_0x158efe[_0x1cf8b8('0xc7')]})[_0x1cf8b8('0x66')](function(_0x57089f){const _0x34383f=_0x1cf8b8;return _0x3234e8[_0x34383f('0x4b')]=_0x57089f,_0x5ab83e[_0x34383f('0x44')][_0x34383f('0xcb')]&&(_0x158efe[_0x34383f('0x7f')]=[{'all':!![]}]),db['JscriptySessionReport'][_0x34383f('0xac')](_0x158efe);})[_0x1cf8b8('0x66')](function(_0x36bc16){const _0x1a65a4=_0x1cf8b8;return _0x3234e8[_0x1a65a4('0xad')]=_0x36bc16,_0x3234e8;});})[_0x3da101('0x66')](respondWithFilteredResult(_0x322c54,_0x158efe))[_0x3da101('0x12')](handleError(_0x322c54,null));},exports[_0x11bae0('0x53')]=function(_0x462682,_0x261c53){const _0x5880a3=_0x11bae0;try{if(!_0x462682[_0x5880a3('0x6b')]['ListId'])throw new Error('No\x20ListId\x20specified');if(!_0x462682['body'][_0x5880a3('0x2e')])throw new Error('No\x20association\x20keys\x20specified!');if(!_0x462682['body']['binding_values'])throw new Error(_0x5880a3('0x27'));if(!_0x462682[_0x5880a3('0x6b')]['socket_timestamp'])throw new Error('Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed');const _0x1bcd72=_0x462682[_0x5880a3('0x6b')][_0x5880a3('0x2e')][_0x5880a3('0x85')](','),_0x479929=_0x462682['body'][_0x5880a3('0x7')][_0x5880a3('0x85')](',');if(!_0x1bcd72[_0x5880a3('0x8a')]||!_0x479929['length']||_0x1bcd72[_0x5880a3('0x8a')]!==_0x479929['length'])throw new Error(_0x5880a3('0x78'));_0x462682[_0x5880a3('0x6b')][_0x5880a3('0x7d')]=_[_0x5880a3('0x5c')](_0x1bcd72,_0x479929);if(!_0x462682[_0x5880a3('0x6b')][_0x5880a3('0x7d')]['phone'])throw new Error('No\x20phone\x20column\x20specified');if(!_0x462682[_0x5880a3('0x6b')][_0x5880a3('0x7d')][_0x5880a3('0x31')])throw new Error(_0x5880a3('0x0'));const _0x49fea5=path['join'](config['root'],'server/files/tmp',_0x462682[_0x5880a3('0x33')][_0x5880a3('0x99')]);fs[_0x5880a3('0xc')](_0x49fea5,parseInt(_0x5880a3('0x81'),0x8));const _0x3a1a65=require('child_process')[_0x5880a3('0x6a')](path[_0x5880a3('0x8f')](__dirname,_0x5880a3('0x1e')),[_0x49fea5,_0x462682[_0x5880a3('0x6b')][_0x5880a3('0x2e')],_0x462682['body'][_0x5880a3('0x7')],_0x462682[_0x5880a3('0x6b')]['ListId'],_0x462682[_0x5880a3('0x6b')]['CompanyId'],_0x462682[_0x5880a3('0x6b')][_0x5880a3('0x7b')],_0x462682[_0x5880a3('0x6b')][_0x5880a3('0x4c')]]);return _0x261c53['status'](0xc8)[_0x5880a3('0x1')]({'message':_0x5880a3('0xba'),'pid':_0x3a1a65['pid']});}catch(_0x45888c){return _0x261c53[_0x5880a3('0xd3')](0x1f4)[_0x5880a3('0x21')](_0x45888c);}},exports[_0x11bae0('0xa2')]=function(_0x1ae86d,_0x1b3f91){const _0x589b9=_0x11bae0,_0x59d9b1=fs[_0x589b9('0xaa')](_0x1ae86d['file']['path']);Papa[_0x589b9('0x2b')](_0x59d9b1,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x1b47f2){const _0x3811e8=_0x589b9;return _0x1b3f91[_0x3811e8('0xd3')](0xc8)[_0x3811e8('0x1')]({'file':_0x1ae86d['file'],'fields':_0x1b47f2[_0x3811e8('0x8e')]['fields']});}});},exports[_0x11bae0('0xa')]=function(_0x40534f,_0x563c09){const _0x4bf988=_0x11bae0;return db[_0x4bf988('0x9a')][_0x4bf988('0xac')]({'raw':!![],'attributes':['id'],'where':{'role':'agent'}})[_0x4bf988('0x66')](function(_0x49357e){const _0x40b7c2=_0x4bf988;let _0x1b34bb=![];if(!_0x40534f[_0x40b7c2('0x6b')][_0x40b7c2('0xcd')])throw new Error('No\x20ListId\x20specified');if(!_0x40534f['body'][_0x40b7c2('0x4a')][_0x40b7c2('0x79')])throw new Error(_0x40b7c2('0xc6'));if(!_0x40534f[_0x40b7c2('0x6b')][_0x40b7c2('0x4a')][_0x40b7c2('0x31')])throw new Error(_0x40b7c2('0x0'));if(!_0x40534f['body'][_0x40b7c2('0x4c')])throw new Error(_0x40b7c2('0x1d'));const _0x419abc=require(_0x40b7c2('0x22'))[_0x40b7c2('0x6a')](path[_0x40b7c2('0x8f')](__dirname,'../../components/import/cm/csv2'),[_0x40534f['params']['id'],JSON[_0x40b7c2('0xc3')](_0x40534f[_0x40b7c2('0x6b')]),JSON[_0x40b7c2('0xc3')](_0x49357e)]);_0x419abc['on'](_0x40b7c2('0x18'),function(){const _0x62eb95=_0x40b7c2;return _0x1b34bb=!![],_0x563c09[_0x62eb95('0xd3')](0xc8)[_0x62eb95('0x1')]({'message':_0x62eb95('0x86'),'pid':_0x419abc[_0x62eb95('0x40')]});}),_0x419abc['on'](_0x40b7c2('0x69'),function(_0x506a46){const _0x2a0369=_0x40b7c2;if(_0x506a46&&!_0x1b34bb)return _0x563c09[_0x2a0369('0xd3')](0x1f4)[_0x2a0369('0x1')]({'message':_0x2a0369('0x57'),'pid':_0x419abc[_0x2a0369('0x40')]});});})['catch'](handleError(_0x563c09,null));};
\ No newline at end of file
+const a126_0x3b08=['../../config/environment','model','body','getHopperFinals','ids','GROUP_CONCAT(DISTINCT\x20t.id)','firstName','bulkCreate','uc.UserId\x20=\x20?','c.id','cm_user_has_contacts','c.email\x20LIKE\x20?','ChatOfflineMessage','getHoppers','text','end','filter','CmHopper','register','CmHopperFinal','error\x20child\x20process','from','squel','send','papaparse','index','Contact','cm_contacts','cf_%d','SELECT','search','create','FaxQueueReport','concat','t.id\x20IN\x20?','setTags','isNumeric','TagIds','Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed','start','tags','$and','binding_values','field','c.mobile\x20LIKE\x20?','left_join','OpenchannelInteraction','update','MailQueueReport','child_process','stack','pick','c.firstName\x20LIKE\x20?','type','custom','expr','CmCustomField','../../rediscache','filename','Incorrect\x20binding\x20parameters\x20passed!','mergeWith','DESC','length','c.ListId','[CmContact][merge][destroy][CmHopperBlack],\x20%s','c.fax','then','No\x20association\x20values\x20specified!','color','fields','trimStart','root','../../components/import/cm/csv','c.ListId\x20IS\x20NULL','id\x20=\x20?','CmHopperHistory','intersection','path','isEmpty','name','options','resolve','push','\x27\x27\x27\x27','cf_','file','zipObject','FaxMessage','ct.CmContactId\x20=\x20c.id','filters','JscriptySessionReport','displayName','map','cm_contact_has_tags','isEmail','tools_tags','../../components/parsers/advancedSearch','c.phone','conditions','MailMessage','datetime','attributes','tag','Sequelize','alias','No\x20ListId\x20specified','format','replace','user','get','sort','some','c.fax\x20LIKE\x20?','CmContact','c.deletedAt\x20IS\x20NULL','findAll','server/files/tmp','find','sendStatus','having','merge','getLists','SmsQueueReport','includeAll','c.deletedAt','stringify','error','include','like','params','values','Tag','No\x20association\x20keys\x20specified!','nolimit','value','agent','pickBy','MailInteraction','ListId','User','set','sequelize','columnName','select','binding','../../config/logger','\x20=\x20?','query','status','message','rows','findOrCreate','No\x20phone\x20column\x20specified','forEach','c.lastName\x20LIKE\x20?','castTo','upload','t.id\x20=\x20ct.TagId','info','OpenchannelMessage','VoiceCallReport','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','limit','../../mysqldb','No\x20firstName\x20column\x20specified','c.email','keys','count','c.mobile','getTags','socket_timestamp','createReadStream','setFields','union','isArray','api','where','c.lastName','isNil','getFullTextValue','rawAttributes','show','catch','SmsMessage','fork','phone','and','parseSearch','describe','join','duplicates','order','binding_keys','getHopperHistories','startsWith','start\x20child\x20process\x20correctly!','ContactId','toString','json','getJscriptySessions','findOne','split','c.phone\x20LIKE\x20?','omit','c.firstName','offset','c.ListId\x20IN\x20?','File\x20uploaded\x20correctly!','ChatMessage','ChatQueueReport','pid','destroy','undefined','table','Tags'];(function(_0x4fd35a,_0x3b0877){const _0x3b4a5a=function(_0x4f453b){while(--_0x4f453b){_0x4fd35a['push'](_0x4fd35a['shift']());}};_0x3b4a5a(++_0x3b0877);}(a126_0x3b08,0x120));const a126_0x3b4a=function(_0x4fd35a,_0x3b0877){_0x4fd35a=_0x4fd35a-0x0;let _0x3b4a5a=a126_0x3b08[_0x4fd35a];return _0x3b4a5a;};const _0x4bdbaa=a126_0x3b4a;'use strict';const util=require('util'),path=require(_0x4bdbaa('0x4')),fs=require('fs'),_=require('lodash'),squel=require(_0x4bdbaa('0xa4')),Papa=require(_0x4bdbaa('0xa6')),{getSocket}=require(_0x4bdbaa('0xc7')),socket=getSocket(),qs=require('../../components/parsers/qs'),as=require(_0x4bdbaa('0x17')),logger=require(_0x4bdbaa('0x48'))(_0x4bdbaa('0x66')),config=require(_0x4bdbaa('0x8e')),db=require(_0x4bdbaa('0x5a'))['db'],{Op}=require(_0x4bdbaa('0x44'));require('./cmContact.socket')[_0x4bdbaa('0xa0')](socket);function respondWithResult(_0x4f453b,_0x2c328f){return _0x2c328f=_0x2c328f||0xc8,function(_0x7b0047){const _0x57d0df=a126_0x3b4a;if(_0x7b0047)return _0x4f453b[_0x57d0df('0x4b')](_0x2c328f)['json'](_0x7b0047);};}function respondWithFilteredResult(_0x499181,_0x564b1d){return function(_0x113cf4){const _0x24541b=a126_0x3b4a;if(_0x113cf4){const _0x49ce68=_0x113cf4[_0x24541b('0x5e')],_0x5314ea=_0x564b1d[_0x24541b('0x84')];let _0x3591f0=_0x564b1d['offset']+_0x564b1d[_0x24541b('0x59')],_0x54fa9a;return _0x3591f0>=_0x49ce68?(_0x3591f0=_0x49ce68,_0x54fa9a=0xc8):_0x54fa9a=0xce,_0x499181[_0x24541b('0x4b')](_0x54fa9a),_0x499181[_0x24541b('0x43')]('Content-Range',_0x5314ea+'-'+_0x3591f0+'/'+_0x49ce68)['json'](_0x113cf4);}return null;};}function saveUpdates(_0x613283){return function(_0x184715){const _0x3264e7=a126_0x3b4a;if(_0x184715)return _0x184715[_0x3264e7('0xbd')](_0x613283)[_0x3264e7('0xd0')](function(_0x58c63c){return _0x58c63c;});return null;};}function removeEntity(_0x21b760){return function(_0x1a7970){const _0x421fbd=a126_0x3b4a;if(_0x1a7970)return _0x1a7970[_0x421fbd('0x8a')]()[_0x421fbd('0xd0')](function(){const _0x3c5442=_0x421fbd;_0x21b760[_0x3c5442('0x4b')](0xcc)[_0x3c5442('0x9d')]();});};}function handleEntityNotFound(_0xf3d29f){return function(_0xf466a3){const _0x34c446=a126_0x3b4a;return!_0xf466a3&&_0xf3d29f[_0x34c446('0x2d')](0x194),_0xf466a3;};}function handleError(_0x1d6847,_0x377727){return _0x377727=_0x377727||0x1f4,function(_0x250398){const _0x29c18c=a126_0x3b4a;logger[_0x29c18c('0x35')](_0x250398[_0x29c18c('0xc0')]),_0x250398[_0x29c18c('0x6')]&&delete _0x250398[_0x29c18c('0x6')],_0x1d6847[_0x29c18c('0x4b')](_0x377727)['send'](_0x250398);};}exports[_0x4bdbaa('0xa7')]=function(_0x3d07ea,_0x40fabd){const _0x3bce5e=_0x4bdbaa,_0x533082={},_0x110101={},_0x5f53aa={'count':0x0,'rows':[]};return db[_0x3bce5e('0x28')]['describe']()['then'](function(_0x419fc6){const _0x5f11ef=_0x3bce5e,_0x24df32=[];for(let _0x5597e7=0x0;_0x5597e7<Object['keys'](_0x419fc6)['length'];_0x5597e7++){const _0x5e71ff=Object[_0x5f11ef('0x5d')](_0x419fc6)[_0x5597e7];_[_0x5f11ef('0x79')](_0x5e71ff,_0x5f11ef('0xb'))&&_0x24df32['push'](db[_0x5f11ef('0xc6')][_0x5f11ef('0x7f')]({'where':{'id':_[_0x5f11ef('0xd4')](_0x5e71ff,_0x5f11ef('0xb'))},'raw':!![]}));}return Promise['all'](_0x24df32)[_0x5f11ef('0xd0')](function(_0x6e3578){const _0x12d8b5=_0x5f11ef;for(let _0x3a91de=0x0;_0x3a91de<_0x6e3578[_0x12d8b5('0xcc')];_0x3a91de++){if(_0x6e3578[_0x3a91de]){const _0x1ae44b=_0x12d8b5('0xb')+_0x6e3578[_0x3a91de]['id'],_0x47ec4b=_0x419fc6[_0x1ae44b];_0x47ec4b['fieldType']=_0x6e3578[_0x3a91de][_0x12d8b5('0xc3')];}}return _0x419fc6;});})[_0x3bce5e('0xd0')](function(_0x55dc36){const _0x3185e6=_0x3bce5e;_0x110101[_0x3185e6('0x8f')]=_[_0x3185e6('0x5d')](_0x55dc36),_0x110101[_0x3185e6('0x4a')]=_[_0x3185e6('0x5d')](_0x3d07ea[_0x3185e6('0x4a')]),_0x110101[_0x3185e6('0x10')]=_[_0x3185e6('0x3')](_0x110101[_0x3185e6('0x8f')],_0x110101[_0x3185e6('0x4a')]),_0x533082[_0x3185e6('0x1c')]=_[_0x3185e6('0x3')](_0x110101[_0x3185e6('0x8f')],qs[_0x3185e6('0xd3')](_0x3d07ea['query'][_0x3185e6('0xd3')])),_0x533082['attributes']=_0x533082[_0x3185e6('0x1c')][_0x3185e6('0xcc')]?_0x533082[_0x3185e6('0x1c')]:_0x110101['model'];typeof _0x3d07ea[_0x3185e6('0x4a')][_0x3185e6('0x3c')]==='undefined'&&(_0x533082[_0x3185e6('0x59')]=qs[_0x3185e6('0x59')](_0x3d07ea[_0x3185e6('0x4a')]['limit']),_0x533082[_0x3185e6('0x84')]=qs[_0x3185e6('0x84')](_0x3d07ea[_0x3185e6('0x4a')][_0x3185e6('0x84')]));_0x533082[_0x3185e6('0x76')]=qs['sort'](_0x3d07ea[_0x3185e6('0x4a')]['sort']),_0x533082[_0x3185e6('0x67')]=qs[_0x3185e6('0x10')](_[_0x3185e6('0xc1')](_0x3d07ea[_0x3185e6('0x4a')],_0x110101[_0x3185e6('0x10')]),_0x55dc36);let _0x2d7f78=[];const _0x3d3b51=squel[_0x3185e6('0x46')]()[_0x3185e6('0xb9')]('id')[_0x3185e6('0xb9')](_0x3185e6('0x6'))[_0x3185e6('0xb9')](_0x3185e6('0xd2'))[_0x3185e6('0xa3')](_0x3185e6('0x16')),_0x636c4a=squel['select']()[_0x3185e6('0xa3')](_0x3185e6('0xa9'),'c')['left_join'](_0x3185e6('0x98'),'uc','uc.CmContactId\x20=\x20c.id')[_0x3185e6('0xbb')](_0x3185e6('0x14'),'ct',_0x3185e6('0xf'))[_0x3185e6('0xbb')](_0x3185e6('0x16'),'t',_0x3185e6('0x54'))[_0x3185e6('0x67')](_0x3185e6('0x29')),_0x1aa6d5=squel[_0x3185e6('0xc5')]();let _0x2b7087=[];const _0x17ff23=squel[_0x3185e6('0xc5')]();let _0x60ce71;if(_0x3d07ea['query'][_0x3185e6('0xac')]){_0x60ce71=as[_0x3185e6('0x72')](_0x3d07ea[_0x3185e6('0x4a')][_0x3185e6('0xac')]);const _0x3b9987=_0x60ce71['sqlOperator'];for(let _0x27ec92=0x0;_0x27ec92<_0x60ce71['conditions'][_0x3185e6('0xcc')];_0x27ec92++){const _0x455672=_0x60ce71[_0x3185e6('0x19')][_0x27ec92],_0x2e7317='c';let _0x1ef3db=_(_0x55dc36)[_0x3185e6('0x5d')]()[_0x3185e6('0x2c')](function(_0x478369){const _0x37d9b0=_0x3185e6;return _0x478369===_0x455672[_0x37d9b0('0xb9')];});if(_0x1ef3db)_0x1ef3db=_0x55dc36[_0x455672[_0x3185e6('0xb9')]];if(!_0x1ef3db){if(_0x455672['field']==='Tag'){const _0x58c1fa=_0x455672[_0x3185e6('0x3d')][_0x3185e6('0x80')](',')[_0x3185e6('0x13')](function(_0x5ec7d9){return Number(_0x5ec7d9);});_0x58c1fa['forEach'](function(_0x1f0829){_0x17ff23['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x1f0829+',%');}),_0x2b7087=_[_0x3185e6('0x64')](_0x2b7087,_0x58c1fa);}else _0x455672[_0x3185e6('0xb9')]===_0x3185e6('0x42')&&_0x1aa6d5[_0x3185e6('0x71')](_0x3185e6('0x96'),_0x455672['value']);}else{if(_0x455672[_0x3185e6('0xb9')]==='dateOfBirth'||_0x1ef3db['fieldType']===_0x3185e6('0x1b'))_0x455672[_0x3185e6('0x52')]='DATE';const _0x30f308=as['buildExpression'](_0x2e7317,_0x1ef3db[_0x3185e6('0xc3')],_0x455672);_0x1aa6d5[_0x3b9987](_0x30f308[_0x3185e6('0x9c')],_0x30f308['value'][_0x3185e6('0xb5')],_0x30f308[_0x3185e6('0x3d')][_0x3185e6('0x9d')]);}}}else{const _0x2d90dc=_(Object[_0x3185e6('0x5d')](_0x3d07ea['query']))[_0x3185e6('0x13')](function(_0x635004){const _0x4428f4=_0x3185e6;return typeof _0x55dc36[_0x635004]===_0x4428f4('0x8b')?undefined:_0x635004;})['filter'](function(_0x2b4435){const _0x587095=_0x3185e6;return!_[_0x587095('0x69')](_0x2b4435);})[_0x3185e6('0x3d')]();if(_0x3d07ea[_0x3185e6('0x4a')][_0x3185e6('0xa8')])_0x2d90dc[_0x3185e6('0x9')]('Contact');!_[_0x3185e6('0x5')](_0x2d90dc)&&_0x2d90dc['forEach'](function(_0x5edaef){const _0x57feba=_0x3185e6;if(_0x5edaef==='ListId')_0x636c4a[_0x57feba('0x67')]('c.ListId\x20IN\x20?',[][_0x57feba('0xaf')](_0x3d07ea[_0x57feba('0x4a')][_0x5edaef]));else{if(_0x5edaef==='Contact'){const _0x2f405d='%'+_0x3d07ea[_0x57feba('0x4a')][_0x5edaef]+'%';_0x636c4a[_0x57feba('0x67')]('CONCAT_WS(\x27\x20\x27,\x20c.firstName,\x20c.lastName,\x20c.email)\x20LIKE\x20?',_0x2f405d);}else _0x636c4a[_0x57feba('0x67')]('c.'+_0x5edaef+_0x57feba('0x49'),_0x3d07ea[_0x57feba('0x4a')][_0x5edaef]);}});_0x3d07ea[_0x3185e6('0x4a')][_0x3185e6('0x1d')]&&(_0x2b7087=_[_0x3185e6('0x65')](_0x3d07ea['query'][_0x3185e6('0x1d')])?_0x3d07ea[_0x3185e6('0x4a')]['tag']:new Array(_0x3d07ea[_0x3185e6('0x4a')][_0x3185e6('0x1d')]),_0x2b7087['forEach'](function(_0x555559){_0x17ff23['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x555559+',%');}));if(_0x3d07ea['query'][_0x3185e6('0x9e')]){const _0x6234d3=_0x3d07ea['query'][_0x3185e6('0x9e')][_0x3185e6('0x22')]('\x5c','\x5c\x5c')[_0x3185e6('0x22')]('\x27\x27',_0x3185e6('0xa'));if(_0x6234d3[_0x3185e6('0x80')]('\x20')[_0x3185e6('0xcc')]>0x1)_0x1aa6d5['or'](_0x3185e6('0x58'),qs[_0x3185e6('0x6a')](_0x6234d3),null);else{if(qs[_0x3185e6('0xb2')](_0x6234d3))_0x1aa6d5['or']('c.id\x20LIKE\x20?',_0x6234d3+'%'),_0x1aa6d5['or'](_0x3185e6('0x81'),_0x6234d3+'%'),_0x1aa6d5['or'](_0x3185e6('0xba'),_0x6234d3+'%'),_0x1aa6d5['or'](_0x3185e6('0x27'),_0x6234d3+'%');else qs[_0x3185e6('0x15')](_0x6234d3)?_0x1aa6d5['or'](_0x3185e6('0x99'),_0x6234d3+'%'):(_0x1aa6d5['or'](_0x3185e6('0xc2'),'%'+_0x6234d3+'%'),_0x1aa6d5['or'](_0x3185e6('0x51'),'%'+_0x6234d3+'%'),_0x1aa6d5['or']('c.email\x20LIKE\x20?','%'+_0x6234d3+'%'));}}}_0x636c4a[_0x3185e6('0x67')](_0x1aa6d5),_0x636c4a['group']('c.id');let _0x456a0a={'type':db[_0x3185e6('0x1e')]['QueryTypes'][_0x3185e6('0xab')],'raw':!![]};const _0x4ee203=_0x636c4a['clone']()[_0x3185e6('0xb9')](_0x3185e6('0x97'));_0x533082[_0x3185e6('0x76')]&&_0x533082[_0x3185e6('0x76')]['forEach'](function(_0x3a60d8){const _0x42d129=_0x3185e6;_0x636c4a['order']('c.'+_0x3a60d8[0x0],_0x3a60d8[0x1]===_0x42d129('0xcb')?![]:!![]);}),!_[_0x3185e6('0x5')](_0x2b7087)&&(_0x636c4a[_0x3185e6('0x2e')](_0x17ff23),_0x4ee203[_0x3185e6('0x67')](_0x3185e6('0xb0'),_0x2b7087)),Promise[_0x3185e6('0x8')]()['then'](function(){const _0x26246c=_0x3185e6;if(_0x60ce71&&!_[_0x26246c('0x26')](_0x60ce71[_0x26246c('0x19')],[_0x26246c('0xb9'),_0x26246c('0x42')]))return _0x3d07ea[_0x26246c('0x23')][_0x26246c('0x30')]({'attributes':['id'],'raw':!![]})[_0x26246c('0xd0')](function(_0x5f3bab){const _0x2c5647=_0x26246c;_[_0x2c5647('0x5')](_0x5f3bab)?(_0x4ee203[_0x2c5647('0x67')](_0x2c5647('0x0')),_0x636c4a['where'](_0x2c5647('0x0'))):(_0x4ee203[_0x2c5647('0x67')](_0x2c5647('0x85'),_[_0x2c5647('0x13')](_0x5f3bab,'id')),_0x636c4a[_0x2c5647('0x67')](_0x2c5647('0x85'),_[_0x2c5647('0x13')](_0x5f3bab,'id')));});else return;})['then'](function(){const _0x144222=_0x3185e6;db[_0x144222('0x44')][_0x144222('0x4a')](_0x4ee203[_0x144222('0x7c')](),_0x456a0a)[_0x144222('0xd0')](function(_0x42d218){const _0x21b8bd=_0x144222;_0x5f53aa[_0x21b8bd('0x5e')]=_0x42d218['length'];if(_0x5f53aa['count']===0x0)return[];return db[_0x21b8bd('0x44')][_0x21b8bd('0x4a')](_0x3d3b51[_0x21b8bd('0x7c')](),_0x456a0a);})[_0x144222('0xd0')](function(_0xcabe00){const _0x1f1440=_0x144222;_0x2d7f78=_['keyBy'](_0xcabe00,'id'),_0x456a0a=_[_0x1f1440('0x2f')](_0x456a0a,{'model':db[_0x1f1440('0x28')],'mapToModel':!![],'raw':!![],'nest':!![]});_0x3d07ea[_0x1f1440('0x4a')][_0x1f1440('0xd3')]?_0x533082[_0x1f1440('0x1c')][_0x1f1440('0x50')](function(_0xd6b7ce){const _0x4a3530=_0x1f1440;_0x636c4a[_0x4a3530('0xb9')]('c.'+_0xd6b7ce);}):(_0x636c4a[_0x1f1440('0xb9')](_0x1f1440('0x97')),_0x636c4a['field'](_0x1f1440('0x83')),_0x636c4a['field'](_0x1f1440('0x68')),_0x636c4a[_0x1f1440('0xb9')](_0x1f1440('0x18')),_0x636c4a['field'](_0x1f1440('0x5f')),_0x636c4a[_0x1f1440('0xb9')](_0x1f1440('0xcf')),_0x636c4a[_0x1f1440('0xb9')](_0x1f1440('0x5c')),_0x636c4a[_0x1f1440('0xb9')](_0x1f1440('0xcd')),_0x636c4a[_0x1f1440('0xb9')](_0x1f1440('0x33')),_0x636c4a['field'](_0x1f1440('0x93'),'TagIds'));if(_0x533082['limit'])_0x636c4a['limit'](_0x533082[_0x1f1440('0x59')]);if(_0x533082[_0x1f1440('0x84')])_0x636c4a[_0x1f1440('0x84')](_0x533082[_0x1f1440('0x84')]);return db[_0x1f1440('0x44')][_0x1f1440('0x4a')](_0x636c4a[_0x1f1440('0x7c')](),_0x456a0a);})['then'](function(_0x20354b){const _0x552d9a=_0x144222;return _0x20354b[_0x552d9a('0x50')](function(_0x281c4c){const _0x144ec3=_0x552d9a;_0x281c4c['TagIds']&&(_0x281c4c[_0x144ec3('0x8d')]=[],_0x281c4c[_0x144ec3('0xb3')]['split'](',')[_0x144ec3('0x50')](function(_0x5a6975){const _0x29a0be=_0x144ec3;_0x281c4c['Tags'][_0x29a0be('0x9')](_0x2d7f78[_0x5a6975]);})),delete _0x281c4c[_0x144ec3('0xb3')];}),_0x5f53aa[_0x552d9a('0x4d')]=_0x20354b,_0x5f53aa;})[_0x144222('0xd0')](respondWithFilteredResult(_0x40fabd,_0x533082));});})[_0x3bce5e('0x6d')](handleError(_0x40fabd,null));},exports[_0x4bdbaa('0x8a')]=function(_0x3206e6,_0x29e7a0){const _0x56c321=_0x4bdbaa;return db[_0x56c321('0x28')][_0x56c321('0x7f')]({'where':{'id':_0x3206e6[_0x56c321('0x38')]['id']}})[_0x56c321('0xd0')](handleEntityNotFound(_0x29e7a0,null))[_0x56c321('0xd0')](removeEntity(_0x29e7a0,null))[_0x56c321('0x6d')](handleError(_0x29e7a0,null));},exports['describe']=function(_0x26aa33,_0x21c16c){const _0x21e2ef=_0x4bdbaa;return db[_0x21e2ef('0x28')][_0x21e2ef('0x73')]()['then'](function(_0x53bb7c){const _0x4881e1=_0x21e2ef;delete _0x53bb7c[_0x4881e1('0xb6')];for(let _0x28818b=0x0;_0x28818b<Object[_0x4881e1('0x5d')](_0x53bb7c)[_0x4881e1('0xcc')];_0x28818b++){const _0x180c65=Object[_0x4881e1('0x5d')](_0x53bb7c)[_0x28818b];!_[_0x4881e1('0x79')](_0x180c65,_0x4881e1('0xb'))&&(_0x53bb7c[_0x180c65][_0x4881e1('0x45')]=_0x180c65,_0x53bb7c[_0x180c65][_0x4881e1('0x12')]=_0x180c65);}return _0x53bb7c;})[_0x21e2ef('0xd0')](function(_0x1062f4){const _0x5aeb8b=_0x21e2ef,_0x451063={'where':{[Op['or']]:[{'ListId':_0x26aa33['query']['id']},{'ListId':null}]},'raw':!![]};return db[_0x5aeb8b('0xc6')][_0x5aeb8b('0x2a')](_0x451063)[_0x5aeb8b('0xd0')](function(_0x22593b){const _0x236fb7=_0x5aeb8b;for(let _0x306d37=0x0;_0x306d37<_0x22593b[_0x236fb7('0xcc')];_0x306d37++){const _0x307b79=_0x236fb7('0xb')+_0x22593b[_0x306d37]['id'];_0x1062f4[_0x307b79][_0x236fb7('0x45')]=_0x307b79,_0x1062f4[_0x307b79][_0x236fb7('0x12')]=_0x22593b[_0x306d37][_0x236fb7('0x1f')],_0x1062f4[_0x307b79][_0x236fb7('0xc4')]={'type':_0x22593b[_0x306d37][_0x236fb7('0xc3')],'values':_0x22593b[_0x306d37][_0x236fb7('0x39')]};}return Object['keys'](_0x1062f4)['forEach'](function(_0x30eed4){const _0x5266de=_0x236fb7;typeof _0x1062f4[_0x30eed4][_0x5266de('0x45')]===_0x5266de('0x8b')&&delete _0x1062f4[_0x30eed4];}),_0x1062f4;});})[_0x21e2ef('0xd0')](respondWithResult(_0x21c16c,null))[_0x21e2ef('0x6d')](handleError(_0x21c16c,null));},exports[_0x4bdbaa('0x2f')]=function(_0x1cdd64,_0x52b2cd){const _0x417c59=_0x4bdbaa;let _0x1282aa,_0x4977c8,_0x3f9f13;return _0x1cdd64[_0x417c59('0x90')]['id']&&delete _0x1cdd64[_0x417c59('0x90')]['id'],db[_0x417c59('0x28')][_0x417c59('0x2a')]({'where':{'id':[_0x1cdd64[_0x417c59('0x90')]['to'],_0x1cdd64[_0x417c59('0x90')][_0x417c59('0xa3')]]}})[_0x417c59('0xd0')](function(_0x50fe39){const _0x55293f=_0x417c59;if(_0x50fe39){if(_0x50fe39[_0x55293f('0xcc')]!==0x2)return null;return _0x50fe39[0x0]=_0x50fe39[0x0]['get']({'plain':!![]}),_0x50fe39[0x1]=_0x50fe39[0x1][_0x55293f('0x24')]({'plain':!![]}),delete _0x50fe39[0x0]['id'],delete _0x50fe39[0x1]['id'],_[_0x55293f('0xca')](_0x50fe39[0x0],_0x50fe39[0x1],function(_0x5379e5,_0x4bfea8){const _0x1e18a9=_0x55293f;if(Array[_0x1e18a9('0x65')](_0x4bfea8)&&!_0x4bfea8[_0x1e18a9('0xcc')])return _0x5379e5;else{if(!_0x4bfea8)return _0x5379e5;}});}})[_0x417c59('0xd0')](handleEntityNotFound(_0x52b2cd,null))[_0x417c59('0xd0')](function(_0x250425){const _0x2b3189=_0x417c59;if(_0x250425)return _0x250425['tags']&&_[_0x2b3189('0x65')](_0x250425['tags'])&&(_0x250425[_0x2b3189('0xb6')]=_0x250425['tags']['join']()),logger['info']('[CmContact][merge]\x20to\x20%s\x20from\x20%s',_0x1cdd64[_0x2b3189('0x90')]['to'],_0x1cdd64[_0x2b3189('0x90')][_0x2b3189('0xa3')]),db[_0x2b3189('0x9f')]['destroy']({'where':{'ContactId':[_0x1cdd64[_0x2b3189('0x90')]['to'],_0x1cdd64[_0x2b3189('0x90')][_0x2b3189('0xa3')]]}})[_0x2b3189('0xd0')](function(_0x2efa5d){const _0x61642b=_0x2b3189;return logger['info']('[CmContact][merge][destroy][CmHopper],\x20%s',_0x2efa5d),db['CmHopperBlack'][_0x61642b('0x8a')]({'where':{'ContactId':[_0x1cdd64[_0x61642b('0x90')]['to'],_0x1cdd64[_0x61642b('0x90')][_0x61642b('0xa3')]]}})[_0x61642b('0xd0')](function(_0xcf9ea7){const _0x222c54=_0x61642b;return logger[_0x222c54('0x55')](_0x222c54('0xce'),_0xcf9ea7),db[_0x222c54('0x28')][_0x222c54('0xad')](_0x250425);});});})[_0x417c59('0xd0')](function(_0x4caa16){const _0x2d4fc9=_0x417c59;if(_0x4caa16)return _0x1282aa=_0x4caa16,_0x4977c8={'ContactId':_0x1282aa['id']},_0x3f9f13={'where':{'ContactId':[_0x1cdd64['body']['to'],_0x1cdd64[_0x2d4fc9('0x90')][_0x2d4fc9('0xa3')]]}},db['ChatInteraction'][_0x2d4fc9('0xbd')](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){const _0x2179c9=_0x417c59;if(_0x1282aa)return db[_0x2179c9('0x87')][_0x2179c9('0xbd')](_0x4977c8,_0x3f9f13);})['then'](function(){const _0x57fece=_0x417c59;if(_0x1282aa)return db[_0x57fece('0x9a')][_0x57fece('0xbd')](_0x4977c8,_0x3f9f13);})['then'](function(){const _0x4e72af=_0x417c59;if(_0x1282aa)return db[_0x4e72af('0x40')][_0x4e72af('0xbd')](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){const _0x300ae9=_0x417c59;if(_0x1282aa)return db[_0x300ae9('0x1a')][_0x300ae9('0xbd')](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){const _0x4ea8c3=_0x417c59;if(_0x1282aa)return db[_0x4ea8c3('0x40')][_0x4ea8c3('0xbd')](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){const _0x36395e=_0x417c59;if(_0x1282aa)return db['MailMessage'][_0x36395e('0xbd')](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){const _0x3b2c2d=_0x417c59;if(_0x1282aa)return db['SmsInteraction'][_0x3b2c2d('0xbd')](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){const _0xb8afc4=_0x417c59;if(_0x1282aa)return db[_0xb8afc4('0x6e')]['update'](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){const _0xcc8399=_0x417c59;if(_0x1282aa)return db['FaxInteraction'][_0xcc8399('0xbd')](_0x4977c8,_0x3f9f13);})['then'](function(){const _0x2f1ed8=_0x417c59;if(_0x1282aa)return db[_0x2f1ed8('0xe')][_0x2f1ed8('0xbd')](_0x4977c8,_0x3f9f13);})['then'](function(){const _0x22676f=_0x417c59;if(_0x1282aa)return db[_0x22676f('0xbc')][_0x22676f('0xbd')](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){const _0x2718b6=_0x417c59;if(_0x1282aa)return db[_0x2718b6('0x56')]['update'](_0x4977c8,_0x3f9f13);})['then'](function(){const _0x23a288=_0x417c59;if(_0x1282aa)return db[_0x23a288('0xa1')][_0x23a288('0xbd')](_0x4977c8,_0x3f9f13);})['then'](function(){const _0x2a67eb=_0x417c59;if(_0x1282aa)return db[_0x2a67eb('0x2')][_0x2a67eb('0xbd')](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){if(_0x1282aa)return db['ReportAgentPreview']['update'](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){const _0x392faf=_0x417c59;if(_0x1282aa)return db[_0x392faf('0x57')][_0x392faf('0xbd')](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){const _0x25eef9=_0x417c59;if(_0x1282aa)return db[_0x25eef9('0x88')][_0x25eef9('0xbd')](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){const _0x39ded2=_0x417c59;if(_0x1282aa)return db[_0x39ded2('0xae')]['update'](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){const _0x12e597=_0x417c59;if(_0x1282aa)return db[_0x12e597('0xbe')][_0x12e597('0xbd')](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){if(_0x1282aa)return db['OpenchannelQueueReport']['update'](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){const _0x16f7bc=_0x417c59;if(_0x1282aa)return db[_0x16f7bc('0x31')][_0x16f7bc('0xbd')](_0x4977c8,_0x3f9f13);})['then'](function(){const _0x187251=_0x417c59;if(_0x1282aa)return db[_0x187251('0x11')][_0x187251('0xbd')](_0x4977c8,_0x3f9f13);})[_0x417c59('0xd0')](function(){const _0x20e89b=_0x417c59;if(_0x1282aa)return db[_0x20e89b('0x28')][_0x20e89b('0x8a')]({'where':{'id':[_0x1cdd64['body']['to'],_0x1cdd64['body']['from']]}});})['then'](function(){if(_0x1282aa)return _0x1282aa;})[_0x417c59('0xd0')](respondWithResult(_0x52b2cd,null))[_0x417c59('0x6d')](handleError(_0x52b2cd,null));},exports[_0x4bdbaa('0xad')]=function(_0x2e12dd,_0x2bee82){const _0x38475c=_0x4bdbaa;return db['CmContact'][_0x38475c('0x73')]()[_0x38475c('0xd0')](function(_0x4270db){const _0x4ef83a=_0x38475c;return _0x2e12dd['body'][_0x4ef83a('0xb6')]&&_['isArray'](_0x2e12dd['body'][_0x4ef83a('0xb6')])?_0x2e12dd[_0x4ef83a('0x90')][_0x4ef83a('0xb6')][_0x4ef83a('0xcc')]?_0x2e12dd[_0x4ef83a('0x90')][_0x4ef83a('0xb6')]=_0x2e12dd[_0x4ef83a('0x90')][_0x4ef83a('0xb6')][_0x4ef83a('0x74')](';')+';':_0x2e12dd[_0x4ef83a('0x90')]['tags']=null:_0x2e12dd[_0x4ef83a('0x90')]['tags']=null,db[_0x4ef83a('0x28')][_0x4ef83a('0xad')](_0x2e12dd[_0x4ef83a('0x90')],{'fields':_[_0x4ef83a('0x5d')](_0x4270db),'raw':!![]});})[_0x38475c('0xd0')](respondWithResult(_0x2bee82,0xc9))[_0x38475c('0x6d')](handleError(_0x2bee82,null));},exports[_0x4bdbaa('0x95')]=function(_0x50991d,_0x47ea28){const _0x139aad=_0x4bdbaa;let _0xe536bd=0x0,_0x3ab6da=0x0,_0x32d13f=0x0;return db[_0x139aad('0x28')][_0x139aad('0x73')]()[_0x139aad('0xd0')](function(_0x28d557){const _0x511513=_0x139aad;return Promise['each'](_0x50991d[_0x511513('0x90')],function(_0x2e3386){const _0x101bf8=_0x511513,_0x1244f6={'where':{[Op['or']]:[]},'defaults':_0x2e3386,'fields':_[_0x101bf8('0x5d')](_0x28d557),'raw':!![]};if(_0x2e3386[_0x101bf8('0x75')]){for(let _0x386d13=0x0;_0x386d13<_0x2e3386[_0x101bf8('0x75')]['length'];_0x386d13++){const _0x2f805a={};_0x2f805a[_0x2e3386[_0x101bf8('0x75')][_0x386d13]]=_0x2e3386[_0x2e3386[_0x101bf8('0x75')][_0x386d13]],_0x1244f6[_0x101bf8('0x67')][Op['or']][_0x101bf8('0x9')](_0x2f805a);}_0x1244f6[_0x101bf8('0x67')][_0x101bf8('0x41')]=_0x2e3386[_0x101bf8('0x41')];}return db[_0x101bf8('0x28')][_0x101bf8('0x4e')](_0x1244f6)['then'](function([,_0x5d953f]){_0x5d953f?_0xe536bd++:_0x32d13f++;})['catch'](function(_0x382174){const _0x373863=_0x101bf8;console[_0x373863('0x35')](_0x382174),_0x3ab6da++;});});})[_0x139aad('0xd0')](function(_0x3cc1f8){if(_0x3cc1f8)return{'success':_0xe536bd,'failure':_0x3ab6da,'duplicates':_0x32d13f};})['then'](respondWithResult(_0x47ea28,0xc9))[_0x139aad('0x6d')](handleError(_0x47ea28,null));},exports[_0x4bdbaa('0x6c')]=function(_0xfa6c4a,_0x193aec){const _0x5511a1=_0x4bdbaa;let _0x5e3a3e;return db[_0x5511a1('0x28')][_0x5511a1('0x73')]()[_0x5511a1('0xd0')](function(_0xf05d04){const _0x531590=_0x5511a1;return db['CmContact'][_0x531590('0x7f')]({'where':{'id':_0xfa6c4a[_0x531590('0x38')]['id']},'include':[{'model':db[_0x531590('0x3a')],'as':'Tags','attributes':['id','name','color'],'required':_0xfa6c4a[_0x531590('0x4a')]['tag']?!![]:![]}],'attributes':_['keys'](_0xf05d04)});})[_0x5511a1('0xd0')](function(_0x2a6962){const _0x2f2cd1=_0x5511a1;_0x5e3a3e=_0x2a6962[_0x2f2cd1('0x24')]({'plain':!![]});const _0x50c779={'where':{[Op[_0x2f2cd1('0x71')]]:[{'ListId':{[Op['ne']]:null}}]}};return _0x2a6962&&_0x2a6962[_0x2f2cd1('0x41')]&&(_0x2a6962[_0x2f2cd1('0x41')]&&_0x50c779[_0x2f2cd1('0x67')][_0x2f2cd1('0xb7')][_0x2f2cd1('0x9')]({'ListId':{[Op['ne']]:_0x2a6962[_0x2f2cd1('0x41')]}})),db[_0x2f2cd1('0xc6')]['findAll'](_0x50c779);})[_0x5511a1('0xd0')](function(_0x831785){const _0xbc5992=_0x5511a1;return _[_0xbc5992('0x82')](_0x5e3a3e,_[_0xbc5992('0x13')](_0x831785,function(_0x5960d9){const _0x271796=_0xbc5992;return util[_0x271796('0x21')](_0x271796('0xaa'),_0x5960d9['id']);}));})['then'](handleEntityNotFound(_0x193aec,null))[_0x5511a1('0xd0')](respondWithResult(_0x193aec,null))[_0x5511a1('0x6d')](handleError(_0x193aec,null));},exports[_0x4bdbaa('0xbd')]=function(_0xc545d9,_0x5a2eae){const _0x232406=_0x4bdbaa;let _0xa535b5;return _0xc545d9[_0x232406('0x90')]['id']&&delete _0xc545d9[_0x232406('0x90')]['id'],db['CmContact'][_0x232406('0x7f')]({'where':{'id':_0xc545d9['params']['id']}})[_0x232406('0xd0')](handleEntityNotFound(_0x5a2eae,null))['then'](saveUpdates(_0xc545d9['body'],null))[_0x232406('0xd0')](function(_0x520e65){const _0x5ebc81=_0x232406;_0xa535b5=_0x520e65;const _0x4aea98={'where':{[Op[_0x5ebc81('0x71')]]:[{'ListId':{[Op['ne']]:null}}]}};return _0x520e65&&_0x520e65[_0x5ebc81('0x41')]&&(_0x520e65[_0x5ebc81('0x41')]&&_0x4aea98[_0x5ebc81('0x67')][_0x5ebc81('0xb7')][_0x5ebc81('0x9')]({'ListId':{[Op['ne']]:_0x520e65[_0x5ebc81('0x41')]}})),db[_0x5ebc81('0xc6')]['findAll'](_0x4aea98);})['then'](function(_0x21fb6d){const _0x31cdbf=_0x232406;if(_0x21fb6d)return _[_0x31cdbf('0x82')](_[_0x31cdbf('0x3f')](_0xc545d9[_0x31cdbf('0x90')],function(_0x171d46,_0x1378d3){const _0xc54237=_0x31cdbf;return _[_0xc54237('0x79')](_0x1378d3,'cf_');}),_['map'](_0x21fb6d,function(_0x1155c3){return util['format']('cf_%d',_0x1155c3['id']);}));})[_0x232406('0xd0')](function(_0x43160f){const _0x2653cb=_0x232406;if(_0x43160f&&!_[_0x2653cb('0x5')](_0x43160f)){const _0x150c8b=squel[_0x2653cb('0xbd')]()[_0x2653cb('0x8c')]('cm_contacts')[_0x2653cb('0x63')](_0x43160f)[_0x2653cb('0x67')](_0x2653cb('0x1'),_0xc545d9['params']['id'])['toParam']();return db[_0x2653cb('0x44')][_0x2653cb('0x4a')](_0x150c8b[_0x2653cb('0x9c')],{'replacements':_0x150c8b['values']});}})[_0x232406('0xd0')](function(){const _0x3fe104=_0x232406;if(_0xc545d9['body'][_0x3fe104('0x70')]&&_0xa535b5)return db[_0x3fe104('0x9f')][_0x3fe104('0xbd')]({'phone':_0xc545d9[_0x3fe104('0x90')][_0x3fe104('0x70')]},{'where':{'ContactId':_0xa535b5['id']}});})[_0x232406('0xd0')](function(){return _0xa535b5;})['then'](respondWithResult(_0x5a2eae,null))[_0x232406('0x6d')](handleError(_0x5a2eae,null));},exports['getTags']=function(_0x40c7ce,_0x3de686){const _0x28a936=_0x4bdbaa;let _0x31c97f={};const _0x2b66b1={};let _0x50ee68,_0x4cc881;return db[_0x28a936('0x28')][_0x28a936('0x7f')]({'where':{'id':_0x40c7ce['params']['id']}})[_0x28a936('0xd0')](handleEntityNotFound(_0x3de686,null))['then'](function(_0x3cbd24){const _0x2ded96=_0x28a936;if(_0x3cbd24)return _0x50ee68=_0x3cbd24,_0x2b66b1[_0x2ded96('0x8f')]=_[_0x2ded96('0x5d')](db[_0x2ded96('0x3a')][_0x2ded96('0x6b')]),_0x2b66b1['query']=_[_0x2ded96('0x5d')](_0x40c7ce[_0x2ded96('0x4a')]),_0x2b66b1[_0x2ded96('0x10')]=_['intersection'](_0x2b66b1[_0x2ded96('0x8f')],_0x2b66b1[_0x2ded96('0x4a')]),_0x31c97f[_0x2ded96('0x1c')]=_['intersection'](_0x2b66b1[_0x2ded96('0x8f')],qs[_0x2ded96('0xd3')](_0x40c7ce[_0x2ded96('0x4a')][_0x2ded96('0xd3')])),_0x31c97f[_0x2ded96('0x1c')]=_0x31c97f[_0x2ded96('0x1c')]['length']?_0x31c97f[_0x2ded96('0x1c')]:_0x2b66b1[_0x2ded96('0x8f')],_0x31c97f[_0x2ded96('0x76')]=qs['sort'](_0x40c7ce['query']['sort']),_0x31c97f[_0x2ded96('0x67')]=qs[_0x2ded96('0x10')](_[_0x2ded96('0xc1')](_0x40c7ce[_0x2ded96('0x4a')],_0x2b66b1[_0x2ded96('0x10')])),_0x40c7ce['query']['filter']&&(_0x31c97f['where']=_['merge'](_0x31c97f[_0x2ded96('0x67')],{[Op['or']]:_[_0x2ded96('0x13')](_0x31c97f[_0x2ded96('0x1c')],function(_0x20ad25){const _0x503f33=_0x2ded96,_0x1460bf={};return _0x1460bf[_0x20ad25]={[Op['like']]:'%'+_0x40c7ce[_0x503f33('0x4a')]['filter']+'%'},_0x1460bf;})})),_0x31c97f=_[_0x2ded96('0x2f')]({},_0x31c97f,_0x40c7ce[_0x2ded96('0x7')]),_0x50ee68[_0x2ded96('0x60')](_0x31c97f);})['then'](function(_0x540e7c){const _0x5d5b72=_0x28a936;if(_0x540e7c)return _0x4cc881=_0x540e7c[_0x5d5b72('0xcc')],typeof _0x40c7ce['query'][_0x5d5b72('0x3c')]===_0x5d5b72('0x8b')&&(_0x31c97f['limit']=qs[_0x5d5b72('0x59')](_0x40c7ce[_0x5d5b72('0x4a')][_0x5d5b72('0x59')]),_0x31c97f['offset']=qs['offset'](_0x40c7ce[_0x5d5b72('0x4a')][_0x5d5b72('0x84')])),_0x50ee68[_0x5d5b72('0x60')](_0x31c97f);})[_0x28a936('0xd0')](function(_0x1b1532){if(_0x1b1532)return _0x1b1532?{'count':_0x4cc881,'rows':_0x1b1532}:null;})[_0x28a936('0xd0')](respondWithResult(_0x3de686,null))[_0x28a936('0x6d')](handleError(_0x3de686,null));},exports[_0x4bdbaa('0xb1')]=function(_0x3d02df,_0x2271af){const _0x299fe7=_0x4bdbaa;return _0x3d02df[_0x299fe7('0x90')]['id']&&delete _0x3d02df['body']['id'],db['CmContact'][_0x299fe7('0x7f')]({'where':{'id':_0x3d02df[_0x299fe7('0x38')]['id']}})['then'](handleEntityNotFound(_0x2271af,null))[_0x299fe7('0xd0')](function(_0x3efd67){const _0x5d40ec=_0x299fe7;if(_0x3efd67)return _0x3efd67['setTags'](_0x3d02df['body'][_0x5d40ec('0x92')]||[]);return null;})[_0x299fe7('0xd0')](respondWithResult(_0x2271af,null))[_0x299fe7('0x6d')](handleError(_0x2271af,null));},exports[_0x4bdbaa('0x9b')]=function(_0x40de08,_0x3e368b){const _0x266698=_0x4bdbaa;let _0x201b8f={'raw':![],'where':{}};const _0x1086a1={},_0x44893a={'count':0x0,'rows':[]};return db[_0x266698('0x28')]['findOne']({'where':{'id':_0x40de08[_0x266698('0x38')]['id']}})[_0x266698('0xd0')](handleEntityNotFound(_0x3e368b,null))[_0x266698('0xd0')](function(_0x5da512){const _0x5c77a9=_0x266698;if(_0x5da512)return _0x1086a1[_0x5c77a9('0x8f')]=_[_0x5c77a9('0x5d')](db[_0x5c77a9('0x9f')][_0x5c77a9('0x6b')]),_0x1086a1[_0x5c77a9('0x4a')]=_['keys'](_0x40de08[_0x5c77a9('0x4a')]),_0x1086a1[_0x5c77a9('0x10')]=_['intersection'](_0x1086a1[_0x5c77a9('0x8f')],_0x1086a1[_0x5c77a9('0x4a')]),_0x201b8f['attributes']=_['intersection'](_0x1086a1['model'],qs[_0x5c77a9('0xd3')](_0x40de08[_0x5c77a9('0x4a')][_0x5c77a9('0xd3')])),_0x201b8f['attributes']=_0x201b8f[_0x5c77a9('0x1c')][_0x5c77a9('0xcc')]?_0x201b8f[_0x5c77a9('0x1c')]:_0x1086a1[_0x5c77a9('0x8f')],typeof _0x40de08[_0x5c77a9('0x4a')][_0x5c77a9('0x3c')]==='undefined'&&(_0x201b8f[_0x5c77a9('0x59')]=qs[_0x5c77a9('0x59')](_0x40de08['query'][_0x5c77a9('0x59')]),_0x201b8f[_0x5c77a9('0x84')]=qs['offset'](_0x40de08['query'][_0x5c77a9('0x84')])),_0x201b8f[_0x5c77a9('0x76')]=qs[_0x5c77a9('0x25')](_0x40de08[_0x5c77a9('0x4a')][_0x5c77a9('0x25')]),_0x201b8f[_0x5c77a9('0x67')]=qs[_0x5c77a9('0x10')](_[_0x5c77a9('0xc1')](_0x40de08['query'],_0x1086a1[_0x5c77a9('0x10')])),_0x201b8f[_0x5c77a9('0x67')][_0x5c77a9('0x7b')]=_0x5da512['id'],_0x40de08[_0x5c77a9('0x4a')][_0x5c77a9('0x9e')]&&(_0x201b8f[_0x5c77a9('0x67')]=_[_0x5c77a9('0x2f')](_0x201b8f['where'],{[Op['or']]:_[_0x5c77a9('0x13')](_0x201b8f[_0x5c77a9('0x1c')],function(_0x1dca83){const _0x43c607=_0x5c77a9,_0xeabbec={};return _0xeabbec[_0x1dca83]={[Op['like']]:'%'+_0x40de08[_0x43c607('0x4a')][_0x43c607('0x9e')]+'%'},_0xeabbec;})})),_0x201b8f=_[_0x5c77a9('0x2f')]({},_0x201b8f,_0x40de08[_0x5c77a9('0x7')]),db[_0x5c77a9('0x9f')][_0x5c77a9('0x5e')]({'where':_0x201b8f[_0x5c77a9('0x67')]})[_0x5c77a9('0xd0')](function(_0xf30b9b){const _0x4e5742=_0x5c77a9;return _0x44893a['count']=_0xf30b9b,_0x40de08[_0x4e5742('0x4a')][_0x4e5742('0x32')]&&(_0x201b8f[_0x4e5742('0x36')]=[{'all':!![]}]),db[_0x4e5742('0x9f')][_0x4e5742('0x2a')](_0x201b8f);})['then'](function(_0x3bbfa4){const _0x47a029=_0x5c77a9;return _0x44893a[_0x47a029('0x4d')]=_0x3bbfa4,_0x44893a;});})[_0x266698('0xd0')](respondWithFilteredResult(_0x3e368b,_0x201b8f))[_0x266698('0x6d')](handleError(_0x3e368b,null));},exports[_0x4bdbaa('0x78')]=function(_0x11993d,_0x59dd90){const _0x41fabb=_0x4bdbaa;let _0x39f194={'raw':!![],'where':{}};const _0xa104cf={},_0x2d727c={'count':0x0,'rows':[]};return db[_0x41fabb('0x28')][_0x41fabb('0x7f')]({'where':{'id':_0x11993d[_0x41fabb('0x38')]['id']}})['then'](handleEntityNotFound(_0x59dd90,null))['then'](function(_0x1d9f08){const _0x10f38f=_0x41fabb;if(_0x1d9f08)return _0xa104cf['model']=_[_0x10f38f('0x5d')](db[_0x10f38f('0x2')][_0x10f38f('0x6b')]),_0xa104cf[_0x10f38f('0x4a')]=_[_0x10f38f('0x5d')](_0x11993d[_0x10f38f('0x4a')]),_0xa104cf['filters']=_[_0x10f38f('0x3')](_0xa104cf['model'],_0xa104cf[_0x10f38f('0x4a')]),_0x39f194[_0x10f38f('0x1c')]=_[_0x10f38f('0x3')](_0xa104cf[_0x10f38f('0x8f')],qs[_0x10f38f('0xd3')](_0x11993d[_0x10f38f('0x4a')]['fields'])),_0x39f194[_0x10f38f('0x1c')]=_0x39f194['attributes'][_0x10f38f('0xcc')]?_0x39f194[_0x10f38f('0x1c')]:_0xa104cf[_0x10f38f('0x8f')],typeof _0x11993d[_0x10f38f('0x4a')][_0x10f38f('0x3c')]===_0x10f38f('0x8b')&&(_0x39f194[_0x10f38f('0x59')]=qs[_0x10f38f('0x59')](_0x11993d[_0x10f38f('0x4a')][_0x10f38f('0x59')]),_0x39f194[_0x10f38f('0x84')]=qs['offset'](_0x11993d[_0x10f38f('0x4a')][_0x10f38f('0x84')])),_0x39f194[_0x10f38f('0x76')]=qs['sort'](_0x11993d[_0x10f38f('0x4a')][_0x10f38f('0x25')]),_0x39f194[_0x10f38f('0x67')]=qs[_0x10f38f('0x10')](_['pick'](_0x11993d['query'],_0xa104cf[_0x10f38f('0x10')])),_0x39f194[_0x10f38f('0x67')][_0x10f38f('0x7b')]=_0x1d9f08['id'],_0x11993d['query'][_0x10f38f('0x9e')]&&(_0x39f194['where']=_[_0x10f38f('0x2f')](_0x39f194[_0x10f38f('0x67')],{[Op['or']]:_['map'](_0x39f194[_0x10f38f('0x1c')],function(_0x374a9c){const _0x51e0f5=_0x10f38f,_0x231f47={};return _0x231f47[_0x374a9c]={[Op[_0x51e0f5('0x37')]]:'%'+_0x11993d[_0x51e0f5('0x4a')][_0x51e0f5('0x9e')]+'%'},_0x231f47;})})),_0x39f194=_[_0x10f38f('0x2f')]({},_0x39f194,_0x11993d[_0x10f38f('0x7')]),db[_0x10f38f('0x2')][_0x10f38f('0x5e')]({'where':_0x39f194['where']})[_0x10f38f('0xd0')](function(_0x2dbd55){const _0x1c3b42=_0x10f38f;return _0x2d727c[_0x1c3b42('0x5e')]=_0x2dbd55,_0x11993d[_0x1c3b42('0x4a')][_0x1c3b42('0x32')]&&(_0x39f194[_0x1c3b42('0x36')]=[{'all':!![]}]),db['CmHopperHistory'][_0x1c3b42('0x2a')](_0x39f194);})[_0x10f38f('0xd0')](function(_0x1acf7f){const _0x3cc089=_0x10f38f;return _0x2d727c[_0x3cc089('0x4d')]=_0x1acf7f,_0x2d727c;});})[_0x41fabb('0xd0')](respondWithFilteredResult(_0x59dd90,_0x39f194))['catch'](handleError(_0x59dd90,null));},exports[_0x4bdbaa('0x91')]=function(_0x47eed9,_0x44036d){const _0x39dfb6=_0x4bdbaa;let _0x3bfe7c={'raw':!![],'where':{}};const _0x283e92={},_0x16201a={'count':0x0,'rows':[]};return db[_0x39dfb6('0x28')][_0x39dfb6('0x7f')]({'where':{'id':_0x47eed9[_0x39dfb6('0x38')]['id']}})[_0x39dfb6('0xd0')](handleEntityNotFound(_0x44036d,null))[_0x39dfb6('0xd0')](function(_0x48732f){const _0x441322=_0x39dfb6;if(_0x48732f)return _0x283e92[_0x441322('0x8f')]=_[_0x441322('0x5d')](db[_0x441322('0xa1')][_0x441322('0x6b')]),_0x283e92[_0x441322('0x4a')]=_['keys'](_0x47eed9['query']),_0x283e92[_0x441322('0x10')]=_[_0x441322('0x3')](_0x283e92['model'],_0x283e92[_0x441322('0x4a')]),_0x3bfe7c[_0x441322('0x1c')]=_['intersection'](_0x283e92[_0x441322('0x8f')],qs['fields'](_0x47eed9[_0x441322('0x4a')]['fields'])),_0x3bfe7c[_0x441322('0x1c')]=_0x3bfe7c[_0x441322('0x1c')][_0x441322('0xcc')]?_0x3bfe7c[_0x441322('0x1c')]:_0x283e92[_0x441322('0x8f')],typeof _0x47eed9[_0x441322('0x4a')][_0x441322('0x3c')]===_0x441322('0x8b')&&(_0x3bfe7c['limit']=qs[_0x441322('0x59')](_0x47eed9[_0x441322('0x4a')][_0x441322('0x59')]),_0x3bfe7c[_0x441322('0x84')]=qs[_0x441322('0x84')](_0x47eed9['query'][_0x441322('0x84')])),_0x3bfe7c[_0x441322('0x76')]=qs[_0x441322('0x25')](_0x47eed9['query'][_0x441322('0x25')]),_0x3bfe7c[_0x441322('0x67')]=qs[_0x441322('0x10')](_[_0x441322('0xc1')](_0x47eed9[_0x441322('0x4a')],_0x283e92[_0x441322('0x10')])),_0x3bfe7c['where']['ContactId']=_0x48732f['id'],_0x47eed9['query'][_0x441322('0x9e')]&&(_0x3bfe7c[_0x441322('0x67')]=_['merge'](_0x3bfe7c[_0x441322('0x67')],{[Op['or']]:_[_0x441322('0x13')](_0x3bfe7c[_0x441322('0x1c')],function(_0x406aa2){const _0x319a6c=_0x441322,_0x22ae17={};return _0x22ae17[_0x406aa2]={[Op[_0x319a6c('0x37')]]:'%'+_0x47eed9[_0x319a6c('0x4a')][_0x319a6c('0x9e')]+'%'},_0x22ae17;})})),_0x3bfe7c=_[_0x441322('0x2f')]({},_0x3bfe7c,_0x47eed9['options']),db[_0x441322('0xa1')][_0x441322('0x5e')]({'where':_0x3bfe7c[_0x441322('0x67')]})[_0x441322('0xd0')](function(_0x237062){const _0x50227b=_0x441322;return _0x16201a['count']=_0x237062,_0x47eed9[_0x50227b('0x4a')][_0x50227b('0x32')]&&(_0x3bfe7c[_0x50227b('0x36')]=[{'all':!![]}]),db[_0x50227b('0xa1')][_0x50227b('0x2a')](_0x3bfe7c);})[_0x441322('0xd0')](function(_0x2b8d9b){const _0x39cc94=_0x441322;return _0x16201a[_0x39cc94('0x4d')]=_0x2b8d9b,_0x16201a;});})[_0x39dfb6('0xd0')](respondWithFilteredResult(_0x44036d,_0x3bfe7c))[_0x39dfb6('0x6d')](handleError(_0x44036d,null));},exports[_0x4bdbaa('0x7e')]=function(_0x4b01f2,_0x350b64){const _0xdec774=_0x4bdbaa;let _0x4366c8={'raw':!![],'where':{}};const _0x46a1a2={},_0x2f4a03={'count':0x0,'rows':[]};return db[_0xdec774('0x28')][_0xdec774('0x7f')]({'where':{'id':_0x4b01f2['params']['id']}})[_0xdec774('0xd0')](handleEntityNotFound(_0x350b64,null))[_0xdec774('0xd0')](function(_0x380db7){const _0xee7d54=_0xdec774;if(_0x380db7)return _0x46a1a2[_0xee7d54('0x8f')]=_['keys'](db['JscriptySessionReport']['rawAttributes']),_0x46a1a2[_0xee7d54('0x4a')]=_['keys'](_0x4b01f2[_0xee7d54('0x4a')]),_0x46a1a2[_0xee7d54('0x10')]=_[_0xee7d54('0x3')](_0x46a1a2[_0xee7d54('0x8f')],_0x46a1a2['query']),_0x4366c8[_0xee7d54('0x1c')]=_[_0xee7d54('0x3')](_0x46a1a2['model'],qs[_0xee7d54('0xd3')](_0x4b01f2[_0xee7d54('0x4a')]['fields'])),_0x4366c8[_0xee7d54('0x1c')]=_0x4366c8[_0xee7d54('0x1c')][_0xee7d54('0xcc')]?_0x4366c8[_0xee7d54('0x1c')]:_0x46a1a2['model'],typeof _0x4b01f2['query'][_0xee7d54('0x3c')]==='undefined'&&(_0x4366c8[_0xee7d54('0x59')]=qs[_0xee7d54('0x59')](_0x4b01f2['query'][_0xee7d54('0x59')]),_0x4366c8[_0xee7d54('0x84')]=qs['offset'](_0x4b01f2['query']['offset'])),_0x4366c8[_0xee7d54('0x76')]=qs[_0xee7d54('0x25')](_0x4b01f2[_0xee7d54('0x4a')]['sort']),_0x4366c8[_0xee7d54('0x67')]=qs['filters'](_[_0xee7d54('0xc1')](_0x4b01f2[_0xee7d54('0x4a')],_0x46a1a2[_0xee7d54('0x10')])),_0x4366c8[_0xee7d54('0x67')][_0xee7d54('0x7b')]=_0x380db7['id'],_0x4b01f2[_0xee7d54('0x4a')][_0xee7d54('0x9e')]&&(_0x4366c8[_0xee7d54('0x67')]=_[_0xee7d54('0x2f')](_0x4366c8[_0xee7d54('0x67')],{[Op['or']]:_[_0xee7d54('0x13')](_0x4366c8[_0xee7d54('0x1c')],function(_0x61947e){const _0x18af00=_0xee7d54,_0x134885={};return _0x134885[_0x61947e]={[Op['like']]:'%'+_0x4b01f2['query'][_0x18af00('0x9e')]+'%'},_0x134885;})})),_0x4366c8=_[_0xee7d54('0x2f')]({},_0x4366c8,_0x4b01f2[_0xee7d54('0x7')]),db[_0xee7d54('0x11')]['count']({'where':_0x4366c8[_0xee7d54('0x67')]})[_0xee7d54('0xd0')](function(_0x5022ad){const _0x28a558=_0xee7d54;return _0x2f4a03[_0x28a558('0x5e')]=_0x5022ad,_0x4b01f2[_0x28a558('0x4a')][_0x28a558('0x32')]&&(_0x4366c8[_0x28a558('0x36')]=[{'all':!![]}]),db[_0x28a558('0x11')][_0x28a558('0x2a')](_0x4366c8);})[_0xee7d54('0xd0')](function(_0x41b175){return _0x2f4a03['rows']=_0x41b175,_0x2f4a03;});})[_0xdec774('0xd0')](respondWithFilteredResult(_0x350b64,_0x4366c8))[_0xdec774('0x6d')](handleError(_0x350b64,null));},exports['uploadCsv']=function(_0x45a0d4,_0x3d4596){const _0x10fd7d=_0x4bdbaa;try{if(!_0x45a0d4[_0x10fd7d('0x90')][_0x10fd7d('0x41')])throw new Error(_0x10fd7d('0x20'));if(!_0x45a0d4[_0x10fd7d('0x90')][_0x10fd7d('0x77')])throw new Error(_0x10fd7d('0x3b'));if(!_0x45a0d4['body'][_0x10fd7d('0xb8')])throw new Error(_0x10fd7d('0xd1'));if(!_0x45a0d4['body'][_0x10fd7d('0x61')])throw new Error('Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed');const _0x2d32de=_0x45a0d4[_0x10fd7d('0x90')][_0x10fd7d('0x77')][_0x10fd7d('0x80')](','),_0x10a5b4=_0x45a0d4[_0x10fd7d('0x90')][_0x10fd7d('0xb8')][_0x10fd7d('0x80')](',');if(!_0x2d32de['length']||!_0x10a5b4[_0x10fd7d('0xcc')]||_0x2d32de['length']!==_0x10a5b4[_0x10fd7d('0xcc')])throw new Error(_0x10fd7d('0xc9'));_0x45a0d4[_0x10fd7d('0x90')][_0x10fd7d('0xd3')]=_[_0x10fd7d('0xd')](_0x2d32de,_0x10a5b4);if(!_0x45a0d4[_0x10fd7d('0x90')]['fields']['phone'])throw new Error(_0x10fd7d('0x4f'));if(!_0x45a0d4[_0x10fd7d('0x90')][_0x10fd7d('0xd3')][_0x10fd7d('0x94')])throw new Error(_0x10fd7d('0x5b'));const _0x2922af=path[_0x10fd7d('0x74')](config[_0x10fd7d('0xd5')],_0x10fd7d('0x2b'),_0x45a0d4[_0x10fd7d('0xc')][_0x10fd7d('0xc8')]);fs['chmodSync'](_0x2922af,parseInt('0777',0x8));const _0x1439de=require(_0x10fd7d('0xbf'))[_0x10fd7d('0x6f')](path[_0x10fd7d('0x74')](__dirname,_0x10fd7d('0xd6')),[_0x2922af,_0x45a0d4[_0x10fd7d('0x90')][_0x10fd7d('0x77')],_0x45a0d4['body'][_0x10fd7d('0xb8')],_0x45a0d4['body']['ListId'],_0x45a0d4[_0x10fd7d('0x90')]['CompanyId'],_0x45a0d4[_0x10fd7d('0x90')][_0x10fd7d('0x75')],_0x45a0d4[_0x10fd7d('0x90')]['socket_timestamp']]);return _0x3d4596[_0x10fd7d('0x4b')](0xc8)['json']({'message':_0x10fd7d('0x86'),'pid':_0x1439de[_0x10fd7d('0x89')]});}catch(_0x4936cf){return _0x3d4596[_0x10fd7d('0x4b')](0x1f4)[_0x10fd7d('0xa5')](_0x4936cf);}},exports[_0x4bdbaa('0x53')]=function(_0x19ffd6,_0x46cf27){const _0xa7e7a=_0x4bdbaa,_0x5a1eda=fs[_0xa7e7a('0x62')](_0x19ffd6[_0xa7e7a('0xc')][_0xa7e7a('0x4')]);Papa['parse'](_0x5a1eda,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x7d144b){const _0x46b126=_0xa7e7a;return _0x46cf27[_0x46b126('0x4b')](0xc8)[_0x46b126('0x7d')]({'file':_0x19ffd6[_0x46b126('0xc')],'fields':_0x7d144b['meta'][_0x46b126('0xd3')]});}});},exports['import']=function(_0x15ca52,_0x1fb97b){const _0x597e70=_0x4bdbaa;return db[_0x597e70('0x42')][_0x597e70('0x2a')]({'raw':!![],'attributes':['id'],'where':{'role':_0x597e70('0x3e')}})[_0x597e70('0xd0')](function(_0x58c4bd){const _0x1f58b0=_0x597e70;let _0x519381=![];if(!_0x15ca52[_0x1f58b0('0x90')]['ListId'])throw new Error(_0x1f58b0('0x20'));if(!_0x15ca52[_0x1f58b0('0x90')][_0x1f58b0('0x47')]['phone'])throw new Error(_0x1f58b0('0x4f'));if(!_0x15ca52[_0x1f58b0('0x90')][_0x1f58b0('0x47')][_0x1f58b0('0x94')])throw new Error('No\x20firstName\x20column\x20specified');if(!_0x15ca52['body'][_0x1f58b0('0x61')])throw new Error(_0x1f58b0('0xb4'));const _0x5601b8=require(_0x1f58b0('0xbf'))[_0x1f58b0('0x6f')](path[_0x1f58b0('0x74')](__dirname,'../../components/import/cm/csv2'),[_0x15ca52['params']['id'],JSON['stringify'](_0x15ca52[_0x1f58b0('0x90')]),JSON[_0x1f58b0('0x34')](_0x58c4bd)]);_0x5601b8['on'](_0x1f58b0('0x4c'),function(){const _0x5fe108=_0x1f58b0;return _0x519381=!![],_0x1fb97b[_0x5fe108('0x4b')](0xc8)[_0x5fe108('0x7d')]({'message':_0x5fe108('0x7a'),'pid':_0x5601b8['pid']});}),_0x5601b8['on']('exit',function(_0x5adefa){const _0x2f2a0e=_0x1f58b0;if(_0x5adefa&&!_0x519381)return _0x1fb97b['status'](0x1f4)[_0x2f2a0e('0x7d')]({'message':_0x2f2a0e('0xa2'),'pid':_0x5601b8[_0x2f2a0e('0x89')]});});})['catch'](handleError(_0x1fb97b,null));};
\ No newline at end of file