Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / cmContact / cmContact.controller.js
index 948c53e..93df52f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7d9c=['all','fieldType','query','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','limit','sort','select','field','color','tools_tags','left_join','cm_user_has_contacts','uc.CmContactId\x20=\x20c.id','cm_contact_has_tags','ct.CmContactId\x20=\x20c.id','t.id\x20=\x20ct.TagId','where','expr','search','parseSearch','sqlOperator','conditions','value','split','map','forEach','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','and','uc.UserId\x20=\x20?','dateOfBirth','datetime','castTo','DATE','buildExpression','end','Contact','isEmpty','ListId','c.ListId\x20IN\x20?','concat','CONCAT_WS(\x27\x20\x27,\x20c.firstName,\x20c.lastName,\x20c.email)\x20LIKE\x20?','\x20=\x20?','isArray','tag','filter','replace','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','getFullTextValue','isNumeric','c.phone\x20LIKE\x20?','c.mobile\x20LIKE\x20?','c.fax\x20LIKE\x20?','isEmail','c.email\x20LIKE\x20?','c.firstName\x20LIKE\x20?','c.lastName\x20LIKE\x20?','group','c.id','Sequelize','QueryTypes','SELECT','order','having','t.id\x20IN\x20?','resolve','user','role','agent','some','getLists','c.ListId\x20IS\x20NULL','sequelize','toString','c.lastName','c.phone','c.mobile','c.fax','c.email','c.ListId','c.CompanyId','GROUP_CONCAT(DISTINCT\x20t.id)','TagIds','Tags','rows','catch','destroy','find','tags','columnName','displayName','findAll','custom','type','values','merge','body','from','get','mergeWith','CmHopper','info','[CmContact][merge][destroy][CmHopper],\x20%s','CmHopperBlack','create','ChatMessage','ChatOfflineMessage','MailInteraction','MailMessage','SmsInteraction','SmsMessage','FaxInteraction','FaxMessage','OpenchannelInteraction','OpenchannelMessage','CmContactHasItem','CmHopperFinal','CmHopperHistory','VoiceCallReport','ChatQueueReport','MailQueueReport','OpenchannelQueueReport','SmsQueueReport','JscriptySessionReport','WhatsappInteraction','join','isNil','dialTimezone','timezones','utcOffset','additionalPhones','bulkCreate','each','duplicates','$or','findOrCreate','contact','params','Tag','Phones','ItemType','literal','Phones.OrderBy','$and','CmCustomField','omit','format','cf_%d','pickBy','table','setFields','toParam','text','phone','getTags','rawAttributes','setTags','ids','setAdditionalPhones','ContactItemType','OrderBy','items','item_types','ItemTypeId','description','contact\x20phone\x20exists','PHONE','CmHopperAdditionalPhone','item','`ItemType`.OrderBy','CmHopperId','ItemType.OrderBy','getAdditionalPhones','duplicateAdditionalPhones','fromContactId','CmContactId','toContactId','rescheduleAdditionalPhones','hopperId','getHoppers','pick','ContactId','includeAll','include','getHopperHistories','getHopperFinals','options','getJscriptySessions','uploadCsv','No\x20ListId\x20specified','No\x20association\x20keys\x20specified!','binding_values','No\x20association\x20values\x20specified!','socket_timestamp','Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed','Incorrect\x20binding\x20parameters\x20passed!','No\x20phone\x20column\x20specified','firstName','No\x20firstName\x20column\x20specified','server/files/tmp','file','filename','chmodSync','0777','child_process','fork','../../components/import/cm/csv','CompanyId','File\x20uploaded\x20correctly!','pid','send','upload','createReadStream','parse','meta','import','binding','../../components/import/cm/csv2','message','error\x20child\x20process','importUpdates','User','../../components/import/cm/csvUpdates','stringify','start\x20child\x20process\x20correctly!','exit','getJourney','mail','chat','sms','openchannel','fax','whatsapp','channel','includes','toLowerCase','Invalid\x20channel','range','isValid','Invalid\x20date\x20for\x20range\x20from\x20filter','voice','uniqueid','destination','callerid','starttime','endtime','duration','note','createdAt','userDisposition','userThirdDisposition','UserId','fullname','DESC','findAndCountAll','alias','startCase','closed','closedAt','disposition','thirdDisposition','Account','key','Owner','customerIp','customerPort','deviceModel','osName','ratingMessage','ratingType','ratingValue','referer','substatus','externalUrl','flatten','sortBy','reverse','slice','moment','bluebird','util','path','lodash','squel','papaparse','ioredis','../../components/parsers/qs','../../config/logger','../../config/environment','../../mysqldb','redis','defaults','localhost','register','status','json','offset','count','set','Content-Range','update','then','sendStatus','error','stack','name','CmContact','describe','keys','length','startsWith','cf_','push','findOne','trimStart'];(function(_0x4b055c,_0x4b870b){var _0x4b62bb=function(_0x4884c2){while(--_0x4884c2){_0x4b055c['push'](_0x4b055c['shift']());}};_0x4b62bb(++_0x4b870b);}(_0x7d9c,0x11c));var _0xc7d9=function(_0x5d1f0e,_0x14df7a){_0x5d1f0e=_0x5d1f0e-0x0;var _0x9991cb=_0x7d9c[_0x5d1f0e];return _0x9991cb;};'use strict';var moment=require(_0xc7d9('0x0'));var BPromise=require(_0xc7d9('0x1'));var util=require(_0xc7d9('0x2'));var path=require(_0xc7d9('0x3'));var fs=require('fs');var _=require(_0xc7d9('0x4'));var squel=require(_0xc7d9('0x5'));var Papa=require(_0xc7d9('0x6'));var Redis=require(_0xc7d9('0x7'));var qs=require(_0xc7d9('0x8'));var as=require('../../components/parsers/advancedSearch');var logger=require(_0xc7d9('0x9'))('api');var config=require(_0xc7d9('0xa'));var shared=require('../../config/environment/shared');var db=require(_0xc7d9('0xb'))['db'];config[_0xc7d9('0xc')]=_[_0xc7d9('0xd')](config['redis'],{'host':_0xc7d9('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xc7d9('0xc')]));require('./cmContact.socket')[_0xc7d9('0xf')](socket);function respondWithResult(_0x2b89d0,_0x40ab82){_0x40ab82=_0x40ab82||0xc8;return function(_0x1e3f3f){if(_0x1e3f3f){return _0x2b89d0[_0xc7d9('0x10')](_0x40ab82)[_0xc7d9('0x11')](_0x1e3f3f);}};}function respondWithFilteredResult(_0x273c8d,_0x47a19c){return function(_0x2b7e78){if(_0x2b7e78){var _0x291675=typeof _0x47a19c['offset']==='undefined'&&typeof _0x47a19c['limit']==='undefined';var _0x2a59b8=_0x2b7e78['count'];var _0x20372b=_0x291675?0x0:_0x47a19c[_0xc7d9('0x12')];var _0x4f3a6d=_0x291675?_0x2b7e78[_0xc7d9('0x13')]:_0x47a19c[_0xc7d9('0x12')]+_0x47a19c['limit'];var _0x2e9ef3;if(_0x4f3a6d>=_0x2a59b8){_0x4f3a6d=_0x2a59b8;_0x2e9ef3=0xc8;}else{_0x2e9ef3=0xce;}_0x273c8d[_0xc7d9('0x10')](_0x2e9ef3);return _0x273c8d[_0xc7d9('0x14')](_0xc7d9('0x15'),_0x20372b+'-'+_0x4f3a6d+'/'+_0x2a59b8)[_0xc7d9('0x11')](_0x2b7e78);}return null;};}function saveUpdates(_0x1d2349){return function(_0x536d60){if(_0x536d60){return _0x536d60[_0xc7d9('0x16')](_0x1d2349)[_0xc7d9('0x17')](function(_0x277fca){return _0x277fca;});}return null;};}function removeEntity(_0x4c2a57){return function(_0x5960c4){if(_0x5960c4){return _0x5960c4['destroy']()['then'](function(){_0x4c2a57['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x3b5ea9){return function(_0x317b35){if(!_0x317b35){_0x3b5ea9[_0xc7d9('0x18')](0x194);}return _0x317b35;};}function handleError(_0x5b4ce4,_0x2e9f7b){_0x2e9f7b=_0x2e9f7b||0x1f4;return function(_0x10e77e){logger[_0xc7d9('0x19')](_0x10e77e[_0xc7d9('0x1a')]);if(_0x10e77e[_0xc7d9('0x1b')]){delete _0x10e77e[_0xc7d9('0x1b')];}_0x5b4ce4['status'](_0x2e9f7b)['send'](_0x10e77e);};}exports['index']=function(_0x28724d,_0x1c8a18){var _0x3d32e4={},_0xbf7edf={},_0x576c84={'count':0x0,'rows':[]};return db[_0xc7d9('0x1c')][_0xc7d9('0x1d')]()[_0xc7d9('0x17')](function(_0x23800d){var _0x1c900f=[];for(var _0x4b7e18=0x0;_0x4b7e18<Object[_0xc7d9('0x1e')](_0x23800d)[_0xc7d9('0x1f')];_0x4b7e18++){var _0x599a51=Object[_0xc7d9('0x1e')](_0x23800d)[_0x4b7e18];if(_[_0xc7d9('0x20')](_0x599a51,_0xc7d9('0x21'))){_0x1c900f[_0xc7d9('0x22')](db['CmCustomField'][_0xc7d9('0x23')]({'where':{'id':_[_0xc7d9('0x24')](_0x599a51,'cf_')},'raw':!![]}));}}return BPromise[_0xc7d9('0x25')](_0x1c900f)[_0xc7d9('0x17')](function(_0x531ebc){for(var _0xc4ea43=0x0;_0xc4ea43<_0x531ebc[_0xc7d9('0x1f')];_0xc4ea43++){if(_0x531ebc[_0xc4ea43]){var _0x5d0511=_0xc7d9('0x21')+_0x531ebc[_0xc4ea43]['id'];var _0x1805ad=_0x23800d[_0x5d0511];_0x1805ad[_0xc7d9('0x26')]=_0x531ebc[_0xc4ea43]['type'];}}return _0x23800d;});})[_0xc7d9('0x17')](function(_0x31449a){_0xbf7edf['model']=_[_0xc7d9('0x1e')](_0x31449a);_0xbf7edf['query']=_[_0xc7d9('0x1e')](_0x28724d[_0xc7d9('0x27')]);_0xbf7edf[_0xc7d9('0x28')]=_[_0xc7d9('0x29')](_0xbf7edf[_0xc7d9('0x2a')],_0xbf7edf['query']);_0x3d32e4[_0xc7d9('0x2b')]=_[_0xc7d9('0x29')](_0xbf7edf['model'],qs['fields'](_0x28724d[_0xc7d9('0x27')][_0xc7d9('0x2c')]));_0x3d32e4[_0xc7d9('0x2b')]=_0x3d32e4[_0xc7d9('0x2b')][_0xc7d9('0x1f')]?_0x3d32e4[_0xc7d9('0x2b')]:_0xbf7edf[_0xc7d9('0x2a')];if(!_0x28724d['query'][_0xc7d9('0x2d')](_0xc7d9('0x2e'))){_0x3d32e4[_0xc7d9('0x2f')]=qs[_0xc7d9('0x2f')](_0x28724d[_0xc7d9('0x27')][_0xc7d9('0x2f')]);_0x3d32e4['offset']=qs[_0xc7d9('0x12')](_0x28724d[_0xc7d9('0x27')][_0xc7d9('0x12')]);}_0x3d32e4['order']=qs[_0xc7d9('0x30')](_0x28724d['query'][_0xc7d9('0x30')]);_0x3d32e4['where']=qs['filters'](_['pick'](_0x28724d[_0xc7d9('0x27')],_0xbf7edf[_0xc7d9('0x28')]),_0x31449a);var _0x9dd414=[];var _0x17d062=squel[_0xc7d9('0x31')]()['field']('id')[_0xc7d9('0x32')](_0xc7d9('0x1b'))[_0xc7d9('0x32')](_0xc7d9('0x33'))['from'](_0xc7d9('0x34'));var _0x42734d=squel[_0xc7d9('0x31')]()['from']('cm_contacts','c')[_0xc7d9('0x35')](_0xc7d9('0x36'),'uc',_0xc7d9('0x37'))[_0xc7d9('0x35')](_0xc7d9('0x38'),'ct',_0xc7d9('0x39'))[_0xc7d9('0x35')](_0xc7d9('0x34'),'t',_0xc7d9('0x3a'))[_0xc7d9('0x3b')]('c.deletedAt\x20IS\x20NULL');var _0x1a0de9=squel[_0xc7d9('0x3c')]();var _0x15a351=[];var _0x3dc5b9=squel[_0xc7d9('0x3c')]();var _0x8cc717;if(_0x28724d[_0xc7d9('0x27')][_0xc7d9('0x3d')]){_0x8cc717=as[_0xc7d9('0x3e')](_0x28724d[_0xc7d9('0x27')][_0xc7d9('0x3d')]);var _0x28c9d4=_0x8cc717[_0xc7d9('0x3f')];for(var _0x69f7c9=0x0;_0x69f7c9<_0x8cc717[_0xc7d9('0x40')][_0xc7d9('0x1f')];_0x69f7c9++){var _0x3bb217=_0x8cc717[_0xc7d9('0x40')][_0x69f7c9];var _0x39def7='c';var _0x13f3f7=_(_0x31449a)[_0xc7d9('0x1e')]()['find'](function(_0x4bb5bf){return _0x4bb5bf===_0x3bb217[_0xc7d9('0x32')];});if(_0x13f3f7)_0x13f3f7=_0x31449a[_0x3bb217[_0xc7d9('0x32')]];if(!_0x13f3f7){if(_0x3bb217[_0xc7d9('0x32')]==='Tag'){var _0x510747=_0x3bb217[_0xc7d9('0x41')][_0xc7d9('0x42')](',')[_0xc7d9('0x43')](function(_0x501196){return Number(_0x501196);});_0x510747[_0xc7d9('0x44')](function(_0x5cf50e){_0x3dc5b9['or'](_0xc7d9('0x45'),'%,'+_0x5cf50e+',%');});_0x15a351=_[_0xc7d9('0x46')](_0x15a351,_0x510747);}else if(_0x3bb217[_0xc7d9('0x32')]==='User'){_0x1a0de9[_0xc7d9('0x47')](_0xc7d9('0x48'),_0x3bb217[_0xc7d9('0x41')]);}}else{if(_0x3bb217[_0xc7d9('0x32')]===_0xc7d9('0x49')||_0x13f3f7['fieldType']===_0xc7d9('0x4a'))_0x3bb217[_0xc7d9('0x4b')]=_0xc7d9('0x4c');var _0x8a2677=as[_0xc7d9('0x4d')](_0x39def7,_0x13f3f7['type'],_0x3bb217);_0x1a0de9[_0x28c9d4](_0x8a2677['text'],_0x8a2677[_0xc7d9('0x41')]['start'],_0x8a2677[_0xc7d9('0x41')][_0xc7d9('0x4e')]);}}}else{var _0x460fea=_(Object[_0xc7d9('0x1e')](_0x28724d[_0xc7d9('0x27')]))[_0xc7d9('0x43')](function(_0x47ac7c){return _0x31449a[_0xc7d9('0x2d')](_0x47ac7c)?_0x47ac7c:undefined;})['filter'](function(_0x4b198d){return!_['isNil'](_0x4b198d);})[_0xc7d9('0x41')]();if(_0x28724d[_0xc7d9('0x27')][_0xc7d9('0x4f')])_0x460fea['push'](_0xc7d9('0x4f'));if(!_[_0xc7d9('0x50')](_0x460fea)){_0x460fea['forEach'](function(_0x1956bc){if(_0x1956bc===_0xc7d9('0x51')){_0x42734d[_0xc7d9('0x3b')](_0xc7d9('0x52'),[][_0xc7d9('0x53')](_0x28724d[_0xc7d9('0x27')][_0x1956bc]));}else if(_0x1956bc===_0xc7d9('0x4f')){var _0x5bb7d8='%'+_0x28724d['query'][_0x1956bc]+'%';_0x42734d['where'](_0xc7d9('0x54'),_0x5bb7d8);}else{_0x42734d[_0xc7d9('0x3b')]('c.'+_0x1956bc+_0xc7d9('0x55'),_0x28724d['query'][_0x1956bc]);}});}if(_0x28724d[_0xc7d9('0x27')]['tag']){_0x15a351=_[_0xc7d9('0x56')](_0x28724d[_0xc7d9('0x27')]['tag'])?_0x28724d['query'][_0xc7d9('0x57')]:new Array(_0x28724d[_0xc7d9('0x27')][_0xc7d9('0x57')]);_0x15a351['forEach'](function(_0x4cef73){_0x3dc5b9['or'](_0xc7d9('0x45'),'%,'+_0x4cef73+',%');});}if(_0x28724d[_0xc7d9('0x27')]['filter']){var _0x5f42cf=_0x28724d[_0xc7d9('0x27')][_0xc7d9('0x58')][_0xc7d9('0x59')]('\x5c','\x5c\x5c')[_0xc7d9('0x59')](/'/g,'\x27\x27');if(_0x5f42cf[_0xc7d9('0x42')]('\x20')[_0xc7d9('0x1f')]>0x1){_0x1a0de9['or'](_0xc7d9('0x5a'),qs[_0xc7d9('0x5b')](_0x5f42cf),null);}else{if(qs[_0xc7d9('0x5c')](_0x5f42cf)){_0x1a0de9['or']('c.id\x20LIKE\x20?',_0x5f42cf+'%');_0x1a0de9['or'](_0xc7d9('0x5d'),_0x5f42cf+'%');_0x1a0de9['or'](_0xc7d9('0x5e'),_0x5f42cf+'%');_0x1a0de9['or'](_0xc7d9('0x5f'),_0x5f42cf+'%');}else if(qs[_0xc7d9('0x60')](_0x5f42cf)){_0x1a0de9['or'](_0xc7d9('0x61'),_0x5f42cf+'%');}else{_0x1a0de9['or'](_0xc7d9('0x62'),'%'+_0x5f42cf+'%');_0x1a0de9['or'](_0xc7d9('0x63'),'%'+_0x5f42cf+'%');_0x1a0de9['or'](_0xc7d9('0x61'),'%'+_0x5f42cf+'%');}}}}_0x42734d['where'](_0x1a0de9);_0x42734d[_0xc7d9('0x64')](_0xc7d9('0x65'));var _0x2f30c7={'type':db[_0xc7d9('0x66')][_0xc7d9('0x67')][_0xc7d9('0x68')],'raw':!![]};var _0x171ce4=_0x42734d['clone']()['field'](_0xc7d9('0x65'));if(_0x3d32e4['order']){_0x3d32e4[_0xc7d9('0x69')][_0xc7d9('0x44')](function(_0x177800){_0x42734d[_0xc7d9('0x69')]('c.'+_0x177800[0x0],_0x177800[0x1]==='DESC'?![]:!![]);});}if(!_['isEmpty'](_0x15a351)){_0x42734d[_0xc7d9('0x6a')](_0x3dc5b9);_0x171ce4[_0xc7d9('0x3b')](_0xc7d9('0x6b'),_0x15a351);}BPromise[_0xc7d9('0x6c')]()[_0xc7d9('0x17')](function(){if(!_0x8cc717)return;if(_0x28724d[_0xc7d9('0x6d')][_0xc7d9('0x6e')]!==_0xc7d9('0x6f'))return;if(!_[_0xc7d9('0x70')](_0x8cc717[_0xc7d9('0x40')],['field','User'])){return _0x28724d[_0xc7d9('0x6d')][_0xc7d9('0x71')]({'attributes':['id'],'raw':!![]})[_0xc7d9('0x17')](function(_0x3c3db9){if(_[_0xc7d9('0x50')](_0x3c3db9)){_0x171ce4[_0xc7d9('0x3b')](_0xc7d9('0x72'));_0x42734d[_0xc7d9('0x3b')]('c.ListId\x20IS\x20NULL');}else{_0x171ce4[_0xc7d9('0x3b')](_0xc7d9('0x52'),_[_0xc7d9('0x43')](_0x3c3db9,'id'));_0x42734d[_0xc7d9('0x3b')](_0xc7d9('0x52'),_['map'](_0x3c3db9,'id'));}});}})[_0xc7d9('0x17')](function(){if(_0x28724d[_0xc7d9('0x6d')][_0xc7d9('0x6e')]==='agent'&&!_0x8cc717&&!_0x28724d[_0xc7d9('0x27')][_0xc7d9('0x51')])return[];return db[_0xc7d9('0x73')][_0xc7d9('0x27')](_0x171ce4[_0xc7d9('0x74')](),_0x2f30c7);})[_0xc7d9('0x17')](function(_0x30b05a){_0x576c84[_0xc7d9('0x13')]=_0x30b05a['length'];if(_0x576c84[_0xc7d9('0x13')]===0x0)return[];return db[_0xc7d9('0x73')][_0xc7d9('0x27')](_0x17d062[_0xc7d9('0x74')](),_0x2f30c7)['then'](function(_0x6905aa){_0x9dd414=_['keyBy'](_0x6905aa,'id');_0x2f30c7=_['merge'](_0x2f30c7,{'model':db['CmContact'],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x28724d[_0xc7d9('0x27')]['fields']){_0x3d32e4[_0xc7d9('0x2b')][_0xc7d9('0x44')](function(_0x52fc2b){_0x42734d['field']('c.'+_0x52fc2b);});}else{_0x42734d[_0xc7d9('0x32')](_0xc7d9('0x65'));_0x42734d['field']('c.firstName');_0x42734d[_0xc7d9('0x32')](_0xc7d9('0x75'));_0x42734d['field'](_0xc7d9('0x76'));_0x42734d[_0xc7d9('0x32')](_0xc7d9('0x77'));_0x42734d[_0xc7d9('0x32')](_0xc7d9('0x78'));_0x42734d[_0xc7d9('0x32')](_0xc7d9('0x79'));_0x42734d[_0xc7d9('0x32')](_0xc7d9('0x7a'));_0x42734d['field']('c.createdAt');_0x42734d[_0xc7d9('0x32')]('c.deletedAt');_0x42734d[_0xc7d9('0x32')](_0xc7d9('0x7b'));_0x42734d['field'](_0xc7d9('0x7c'),_0xc7d9('0x7d'));}if(_0x3d32e4[_0xc7d9('0x2f')])_0x42734d['limit'](_0x3d32e4[_0xc7d9('0x2f')]);if(_0x3d32e4[_0xc7d9('0x12')])_0x42734d[_0xc7d9('0x12')](_0x3d32e4[_0xc7d9('0x12')]);return db['sequelize'][_0xc7d9('0x27')](_0x42734d[_0xc7d9('0x74')](),_0x2f30c7);});})[_0xc7d9('0x17')](function(_0x54df56){_0x54df56[_0xc7d9('0x44')](function(_0x25402a){if(_0x25402a['TagIds']){_0x25402a[_0xc7d9('0x7e')]=[];_0x25402a[_0xc7d9('0x7d')]['split'](',')[_0xc7d9('0x44')](function(_0x54051c){_0x25402a[_0xc7d9('0x7e')][_0xc7d9('0x22')](_0x9dd414[_0x54051c]);});}delete _0x25402a[_0xc7d9('0x7d')];});_0x576c84[_0xc7d9('0x7f')]=_0x54df56;return _0x576c84;})[_0xc7d9('0x17')](respondWithFilteredResult(_0x1c8a18,_0x3d32e4));})[_0xc7d9('0x80')](handleError(_0x1c8a18,null));};exports[_0xc7d9('0x81')]=function(_0x168386,_0x19b729){return db[_0xc7d9('0x1c')][_0xc7d9('0x82')]({'where':{'id':_0x168386['params']['id']}})[_0xc7d9('0x17')](handleEntityNotFound(_0x19b729,null))[_0xc7d9('0x17')](removeEntity(_0x19b729,null))[_0xc7d9('0x80')](handleError(_0x19b729,null));};exports['describe']=function(_0x50a861,_0x448b10){return db['CmContact'][_0xc7d9('0x1d')]()[_0xc7d9('0x17')](function(_0x195770){delete _0x195770[_0xc7d9('0x83')];for(var _0x3396dc=0x0;_0x3396dc<Object[_0xc7d9('0x1e')](_0x195770)['length'];_0x3396dc++){var _0x19d2fd=Object[_0xc7d9('0x1e')](_0x195770)[_0x3396dc];if(!_[_0xc7d9('0x20')](_0x19d2fd,_0xc7d9('0x21'))){_0x195770[_0x19d2fd][_0xc7d9('0x84')]=_0x19d2fd;_0x195770[_0x19d2fd][_0xc7d9('0x85')]=_0x19d2fd;}}return _0x195770;})['then'](function(_0x48dc6f){var _0x302fea={'where':Boolean(_0x50a861[_0xc7d9('0x27')]['analytics'])===!![]?undefined:{'$or':[{'ListId':_0x50a861[_0xc7d9('0x27')]['id']},{'ListId':null}]},'raw':!![]};return db['CmCustomField'][_0xc7d9('0x86')](_0x302fea)['then'](function(_0x55efd6){for(var _0x4fc4d7=0x0;_0x4fc4d7<_0x55efd6[_0xc7d9('0x1f')];_0x4fc4d7++){var _0xf83540=_0xc7d9('0x21')+_0x55efd6[_0x4fc4d7]['id'];_0x48dc6f[_0xf83540][_0xc7d9('0x84')]=_0xf83540;_0x48dc6f[_0xf83540][_0xc7d9('0x85')]=_0x55efd6[_0x4fc4d7]['alias'];_0x48dc6f[_0xf83540][_0xc7d9('0x87')]={'type':_0x55efd6[_0x4fc4d7][_0xc7d9('0x88')],'values':_0x55efd6[_0x4fc4d7][_0xc7d9('0x89')]};}Object[_0xc7d9('0x1e')](_0x48dc6f)[_0xc7d9('0x44')](function(_0x30e98d){if(!_0x48dc6f[_0x30e98d][_0xc7d9('0x2d')](_0xc7d9('0x84'))){delete _0x48dc6f[_0x30e98d];}});return _0x48dc6f;});})[_0xc7d9('0x17')](respondWithResult(_0x448b10,null))[_0xc7d9('0x80')](handleError(_0x448b10,null));};exports[_0xc7d9('0x8a')]=function(_0x355429,_0x25c846){var _0x5eecd5;var _0x53e38f;var _0xc03b59;if(_0x355429['body']['id']){delete _0x355429['body']['id'];}return db[_0xc7d9('0x1c')]['findAll']({'where':{'id':[_0x355429['body']['to'],_0x355429[_0xc7d9('0x8b')][_0xc7d9('0x8c')]]}})[_0xc7d9('0x17')](function(_0x1512b7){if(_0x1512b7){if(_0x1512b7[_0xc7d9('0x1f')]!==0x2){return null;}_0x1512b7[0x0]=_0x1512b7[0x0][_0xc7d9('0x8d')]({'plain':!![]});_0x1512b7[0x1]=_0x1512b7[0x1][_0xc7d9('0x8d')]({'plain':!![]});delete _0x1512b7[0x0]['id'];delete _0x1512b7[0x1]['id'];return _[_0xc7d9('0x8e')](_0x1512b7[0x0],_0x1512b7[0x1],function(_0x4e7679,_0x534286){if(Array[_0xc7d9('0x56')](_0x534286)&&!_0x534286['length']){return _0x4e7679;}else if(!_0x534286){return _0x4e7679;}});}})[_0xc7d9('0x17')](handleEntityNotFound(_0x25c846,null))[_0xc7d9('0x17')](function(_0x48a14f){if(_0x48a14f){if(_0x48a14f[_0xc7d9('0x83')]&&_['isArray'](_0x48a14f[_0xc7d9('0x83')])){_0x48a14f[_0xc7d9('0x83')]=_0x48a14f[_0xc7d9('0x83')]['join']();}logger['info']('[CmContact][merge]\x20to\x20%s\x20from\x20%s',_0x355429[_0xc7d9('0x8b')]['to'],_0x355429[_0xc7d9('0x8b')]['from']);return db[_0xc7d9('0x8f')][_0xc7d9('0x81')]({'where':{'ContactId':[_0x355429[_0xc7d9('0x8b')]['to'],_0x355429['body'][_0xc7d9('0x8c')]]}})[_0xc7d9('0x17')](function(_0x1a3b34){logger[_0xc7d9('0x90')](_0xc7d9('0x91'),_0x1a3b34);return db[_0xc7d9('0x92')][_0xc7d9('0x81')]({'where':{'ContactId':[_0x355429[_0xc7d9('0x8b')]['to'],_0x355429['body'][_0xc7d9('0x8c')]]}})['then'](function(_0x2083b4){logger[_0xc7d9('0x90')]('[CmContact][merge][destroy][CmHopperBlack],\x20%s',_0x2083b4);return db[_0xc7d9('0x1c')][_0xc7d9('0x93')](_0x48a14f);});});}})[_0xc7d9('0x17')](function(_0x3b3b3b){if(_0x3b3b3b){_0x5eecd5=_0x3b3b3b;_0x53e38f={'ContactId':_0x5eecd5['id']};_0xc03b59={'where':{'ContactId':[_0x355429[_0xc7d9('0x8b')]['to'],_0x355429[_0xc7d9('0x8b')]['from']]}};return db['ChatInteraction']['update'](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db[_0xc7d9('0x94')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})['then'](function(){if(_0x5eecd5){return db[_0xc7d9('0x95')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db[_0xc7d9('0x96')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})['then'](function(){if(_0x5eecd5){return db[_0xc7d9('0x97')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})['then'](function(){if(_0x5eecd5){return db[_0xc7d9('0x96')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db['MailMessage'][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db[_0xc7d9('0x98')]['update'](_0x53e38f,_0xc03b59);}})['then'](function(){if(_0x5eecd5){return db[_0xc7d9('0x99')]['update'](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db[_0xc7d9('0x9a')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})['then'](function(){if(_0x5eecd5){return db[_0xc7d9('0x9b')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db[_0xc7d9('0x9c')]['update'](_0x53e38f,_0xc03b59);}})['then'](function(){if(_0x5eecd5){return db[_0xc7d9('0x9d')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db[_0xc7d9('0x9e')]['update']({'CmContactId':_0x5eecd5['id']},{'where':{'CmContactId':[_0x355429[_0xc7d9('0x8b')]['to'],_0x355429[_0xc7d9('0x8b')]['from']]}});}})['then'](function(){if(_0x5eecd5){return db[_0xc7d9('0x9f')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db[_0xc7d9('0xa0')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})['then'](function(){if(_0x5eecd5){return db['ReportAgentPreview']['update'](_0x53e38f,_0xc03b59);}})['then'](function(){if(_0x5eecd5){return db[_0xc7d9('0xa1')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db[_0xc7d9('0xa2')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db['FaxQueueReport']['update'](_0x53e38f,_0xc03b59);}})['then'](function(){if(_0x5eecd5){return db[_0xc7d9('0xa3')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db[_0xc7d9('0xa4')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db[_0xc7d9('0xa5')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db[_0xc7d9('0xa6')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db[_0xc7d9('0xa7')][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db['WhatsappMessage'][_0xc7d9('0x16')](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db['WhatsappQueueReport']['update'](_0x53e38f,_0xc03b59);}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return db[_0xc7d9('0x1c')][_0xc7d9('0x81')]({'where':{'id':[_0x355429['body']['to'],_0x355429[_0xc7d9('0x8b')][_0xc7d9('0x8c')]]}});}})[_0xc7d9('0x17')](function(){if(_0x5eecd5){return _0x5eecd5;}})[_0xc7d9('0x17')](respondWithResult(_0x25c846,null))['catch'](handleError(_0x25c846,null));};exports['create']=function(_0x295cfd,_0x328ba1){return db['CmContact'][_0xc7d9('0x1d')]()[_0xc7d9('0x17')](function(_0x1774ac){if(_0x295cfd[_0xc7d9('0x8b')]['tags']&&_[_0xc7d9('0x56')](_0x295cfd[_0xc7d9('0x8b')][_0xc7d9('0x83')])){if(_0x295cfd['body']['tags']['length']){_0x295cfd[_0xc7d9('0x8b')][_0xc7d9('0x83')]=_0x295cfd[_0xc7d9('0x8b')][_0xc7d9('0x83')][_0xc7d9('0xa8')](';')+';';}else{_0x295cfd[_0xc7d9('0x8b')][_0xc7d9('0x83')]=null;}}else{_0x295cfd[_0xc7d9('0x8b')][_0xc7d9('0x83')]=null;}if(!_[_0xc7d9('0xa9')](_0x295cfd[_0xc7d9('0x8b')][_0xc7d9('0xaa')])){var _0x5b5907=_0x295cfd[_0xc7d9('0x8b')][_0xc7d9('0xaa')];if(!_[_0xc7d9('0xa9')](shared[_0xc7d9('0xab')][_0x5b5907]))_0x295cfd[_0xc7d9('0x8b')][_0xc7d9('0xac')]=shared[_0xc7d9('0xab')][_0x5b5907][_0xc7d9('0xac')];}return db[_0xc7d9('0x1c')][_0xc7d9('0x93')](_0x295cfd['body'],{'fields':_[_0xc7d9('0x1e')](_0x1774ac),'raw':!![]});})[_0xc7d9('0x17')](function(_0x1d300e){if(_0x295cfd[_0xc7d9('0x8b')][_0xc7d9('0xad')]){return insertAdditionalPhones(_0x1d300e,_0x295cfd[_0xc7d9('0x8b')]['additionalPhones']);}else{return _0x1d300e;}})[_0xc7d9('0x17')](respondWithResult(_0x328ba1,0xc9))[_0xc7d9('0x80')](handleError(_0x328ba1,null));};exports[_0xc7d9('0xae')]=function(_0x1a44c8,_0xdf6120){var _0x50cd7d=0x0;var _0x282982=0x0;var _0x199c3b=0x0;var _0x391418=[];return db[_0xc7d9('0x1c')][_0xc7d9('0x1d')]()[_0xc7d9('0x17')](function(_0x7b7eb5){return BPromise[_0xc7d9('0xaf')](_0x1a44c8[_0xc7d9('0x8b')],function(_0x235953){var _0x3b64a0={'where':{'$or':[]},'defaults':_0x235953,'fields':_[_0xc7d9('0x1e')](_0x7b7eb5),'raw':!![]};if(_0x235953[_0xc7d9('0xb0')]){for(var _0x447db0=0x0;_0x447db0<_0x235953[_0xc7d9('0xb0')][_0xc7d9('0x1f')];_0x447db0++){var _0x10b245={};_0x10b245[_0x235953[_0xc7d9('0xb0')][_0x447db0]]=_0x235953[_0x235953[_0xc7d9('0xb0')][_0x447db0]];_0x3b64a0['where'][_0xc7d9('0xb1')]['push'](_0x10b245);}_0x3b64a0[_0xc7d9('0x3b')]['ListId']=_0x235953['ListId'];}return db[_0xc7d9('0x1c')][_0xc7d9('0xb2')](_0x3b64a0)['spread'](function(_0x5bc3ee,_0x291ee4){if(_0x291ee4){if(_0x235953[_0xc7d9('0x2d')](_0xc7d9('0xad'))){_0x391418[_0xc7d9('0x22')]({'contact':_0x5bc3ee,'additionalPhones':_0x235953[_0xc7d9('0xad')]});}_0x50cd7d++;}else{_0x199c3b++;}})[_0xc7d9('0x80')](function(){_0x282982++;});});})[_0xc7d9('0x17')](function(_0x5bd43c){if(_0x5bd43c){if(_0x391418[_0xc7d9('0x1f')]>0x0){return new Promise(function(_0x65169a,_0x2e9d1c){var _0x22f694=[];for(var _0x586a3e=0x0;_0x586a3e<_0x391418[_0xc7d9('0x1f')];_0x586a3e++){_0x22f694[_0xc7d9('0x22')](insertAdditionalPhones(_0x391418[_0x586a3e][_0xc7d9('0xb3')],_0x391418[_0x586a3e][_0xc7d9('0xad')]));}Promise['all'](_0x22f694)['then'](function(){_0x65169a(0x1);});})[_0xc7d9('0x17')](function(){return{'success':_0x50cd7d,'failure':_0x282982,'duplicates':_0x199c3b};});}else{return{'success':_0x50cd7d,'failure':_0x282982,'duplicates':_0x199c3b};}}})[_0xc7d9('0x17')](respondWithResult(_0xdf6120,0xc9))[_0xc7d9('0x80')](handleError(_0xdf6120,null));};exports['show']=function(_0x416cae,_0x533f7c){var _0x539797;return db[_0xc7d9('0x1c')][_0xc7d9('0x1d')]()[_0xc7d9('0x17')](function(_0x2395f9){return db[_0xc7d9('0x1c')]['find']({'where':{'id':_0x416cae[_0xc7d9('0xb4')]['id']},'include':[{'model':db[_0xc7d9('0xb5')],'as':'Tags','attributes':['id','name',_0xc7d9('0x33')],'required':_0x416cae[_0xc7d9('0x27')][_0xc7d9('0x57')]?!![]:![]},{'model':db['CmContactHasItem'],'as':_0xc7d9('0xb6'),'where':{'CmContactId':_0x416cae[_0xc7d9('0xb4')]['id']},'required':![],'include':[{'model':db['ContactItemType'],'as':_0xc7d9('0xb7')}]}],'order':[db['sequelize'][_0xc7d9('0xb8')](_0xc7d9('0xb9'))],'attributes':_[_0xc7d9('0x1e')](_0x2395f9)});})[_0xc7d9('0x17')](function(_0x55d498){if(!_[_0xc7d9('0xa9')](_0x55d498)){_0x539797=_0x55d498[_0xc7d9('0x8d')]({'plain':!![]});var _0x481866={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x55d498&&_0x55d498[_0xc7d9('0x51')]){if(_0x55d498['ListId']){_0x481866['where'][_0xc7d9('0xba')][_0xc7d9('0x22')]({'ListId':{'$ne':_0x55d498[_0xc7d9('0x51')]}});}}return db[_0xc7d9('0xbb')][_0xc7d9('0x86')](_0x481866);}})[_0xc7d9('0x17')](function(_0x5047c3){if(!_[_0xc7d9('0xa9')](_0x5047c3)){return _[_0xc7d9('0xbc')](_0x539797,_[_0xc7d9('0x43')](_0x5047c3,function(_0x46030b){return util[_0xc7d9('0xbd')](_0xc7d9('0xbe'),_0x46030b['id']);}));}})[_0xc7d9('0x17')](handleEntityNotFound(_0x533f7c,null))['then'](respondWithResult(_0x533f7c,null))[_0xc7d9('0x80')](handleError(_0x533f7c,null));};exports['update']=function(_0x1ad16a,_0x4ac14e){var _0x4dd824;if(_0x1ad16a[_0xc7d9('0x8b')]['id']){delete _0x1ad16a[_0xc7d9('0x8b')]['id'];}if(!_[_0xc7d9('0xa9')](_0x1ad16a[_0xc7d9('0x8b')]['dialTimezone'])){var _0x51a725=_0x1ad16a[_0xc7d9('0x8b')]['dialTimezone'];if(!_['isNil'](shared[_0xc7d9('0xab')][_0x51a725]))_0x1ad16a[_0xc7d9('0x8b')][_0xc7d9('0xac')]=shared['timezones'][_0x51a725]['utcOffset'];}return db[_0xc7d9('0x1c')][_0xc7d9('0x82')]({'where':{'id':_0x1ad16a[_0xc7d9('0xb4')]['id']}})['then'](handleEntityNotFound(_0x4ac14e,null))[_0xc7d9('0x17')](saveUpdates(_0x1ad16a['body'],null))[_0xc7d9('0x17')](function(_0x17def9){_0x4dd824=_0x17def9;var _0x27c77e={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x17def9&&_0x17def9[_0xc7d9('0x51')]){if(_0x17def9[_0xc7d9('0x51')]){_0x27c77e[_0xc7d9('0x3b')][_0xc7d9('0xba')][_0xc7d9('0x22')]({'ListId':{'$ne':_0x17def9[_0xc7d9('0x51')]}});}}return db[_0xc7d9('0xbb')][_0xc7d9('0x86')](_0x27c77e);})[_0xc7d9('0x17')](function(_0x3d2468){if(_0x3d2468){return _[_0xc7d9('0xbc')](_[_0xc7d9('0xbf')](_0x1ad16a['body'],function(_0x814096,_0x2ab398){return _[_0xc7d9('0x20')](_0x2ab398,_0xc7d9('0x21'));}),_[_0xc7d9('0x43')](_0x3d2468,function(_0x5392ea){return util[_0xc7d9('0xbd')](_0xc7d9('0xbe'),_0x5392ea['id']);}));}})[_0xc7d9('0x17')](function(_0x14d5a4){if(_0x14d5a4&&!_[_0xc7d9('0x50')](_0x14d5a4)){var _0x295825=squel[_0xc7d9('0x16')]()[_0xc7d9('0xc0')]('cm_contacts')[_0xc7d9('0xc1')](_0x14d5a4)[_0xc7d9('0x3b')]('id\x20=\x20?',_0x1ad16a[_0xc7d9('0xb4')]['id'])[_0xc7d9('0xc2')]();return db[_0xc7d9('0x73')][_0xc7d9('0x27')](_0x295825[_0xc7d9('0xc3')],{'replacements':_0x295825[_0xc7d9('0x89')]});}})[_0xc7d9('0x17')](function(){if(_0x1ad16a[_0xc7d9('0x8b')][_0xc7d9('0xc4')]&&_0x4dd824){return db[_0xc7d9('0x8f')][_0xc7d9('0x16')]({'phone':_0x1ad16a[_0xc7d9('0x8b')][_0xc7d9('0xc4')],'OrderBy':0x0},{'where':{'ContactId':_0x4dd824['id']}});}})[_0xc7d9('0x17')](function(){return _0x4dd824;})['then'](respondWithResult(_0x4ac14e,null))[_0xc7d9('0x80')](handleError(_0x4ac14e,null));};exports[_0xc7d9('0xc5')]=function(_0xf97332,_0xd5bfdc){var _0x119251={};var _0x435e76={};var _0x4a3a85;var _0x3f66df;return db[_0xc7d9('0x1c')][_0xc7d9('0x23')]({'where':{'id':_0xf97332['params']['id']}})[_0xc7d9('0x17')](handleEntityNotFound(_0xd5bfdc,null))[_0xc7d9('0x17')](function(_0x7b4e58){if(_0x7b4e58){_0x4a3a85=_0x7b4e58;_0x435e76['model']=_['keys'](db['Tag'][_0xc7d9('0xc6')]);_0x435e76['query']=_['keys'](_0xf97332['query']);_0x435e76[_0xc7d9('0x28')]=_[_0xc7d9('0x29')](_0x435e76[_0xc7d9('0x2a')],_0x435e76[_0xc7d9('0x27')]);_0x119251['attributes']=_[_0xc7d9('0x29')](_0x435e76['model'],qs[_0xc7d9('0x2c')](_0xf97332[_0xc7d9('0x27')]['fields']));_0x119251['attributes']=_0x119251['attributes'][_0xc7d9('0x1f')]?_0x119251['attributes']:_0x435e76[_0xc7d9('0x2a')];_0x119251[_0xc7d9('0x69')]=qs[_0xc7d9('0x30')](_0xf97332['query'][_0xc7d9('0x30')]);_0x119251[_0xc7d9('0x3b')]=qs['filters'](_['pick'](_0xf97332[_0xc7d9('0x27')],_0x435e76['filters']));if(_0xf97332[_0xc7d9('0x27')]['filter']){_0x119251[_0xc7d9('0x3b')]=_[_0xc7d9('0x8a')](_0x119251[_0xc7d9('0x3b')],{'$or':_[_0xc7d9('0x43')](_0x119251[_0xc7d9('0x2b')],function(_0x72f8e2){var _0x4a3a12={};_0x4a3a12[_0x72f8e2]={'$like':'%'+_0xf97332[_0xc7d9('0x27')][_0xc7d9('0x58')]+'%'};return _0x4a3a12;})});}_0x119251=_[_0xc7d9('0x8a')]({},_0x119251,_0xf97332['options']);return _0x4a3a85[_0xc7d9('0xc5')](_0x119251);}})[_0xc7d9('0x17')](function(_0x5545be){if(_0x5545be){_0x3f66df=_0x5545be['length'];if(!_0xf97332[_0xc7d9('0x27')][_0xc7d9('0x2d')](_0xc7d9('0x2e'))){_0x119251[_0xc7d9('0x2f')]=qs[_0xc7d9('0x2f')](_0xf97332[_0xc7d9('0x27')]['limit']);_0x119251[_0xc7d9('0x12')]=qs[_0xc7d9('0x12')](_0xf97332[_0xc7d9('0x27')][_0xc7d9('0x12')]);}return _0x4a3a85[_0xc7d9('0xc5')](_0x119251);}})[_0xc7d9('0x17')](function(_0x35cb1f){if(_0x35cb1f){return _0x35cb1f?{'count':_0x3f66df,'rows':_0x35cb1f}:null;}})[_0xc7d9('0x17')](respondWithResult(_0xd5bfdc,null))[_0xc7d9('0x80')](handleError(_0xd5bfdc,null));};exports[_0xc7d9('0xc7')]=function(_0x415202,_0x3cb92b){if(_0x415202[_0xc7d9('0x8b')]['id']){delete _0x415202[_0xc7d9('0x8b')]['id'];}return db[_0xc7d9('0x1c')][_0xc7d9('0x23')]({'where':{'id':_0x415202['params']['id']}})['then'](handleEntityNotFound(_0x3cb92b,null))[_0xc7d9('0x17')](function(_0x16e17a){if(_0x16e17a){return _0x16e17a['setTags'](_0x415202['body'][_0xc7d9('0xc8')]||[]);}return null;})['then'](respondWithResult(_0x3cb92b,null))[_0xc7d9('0x80')](handleError(_0x3cb92b,null));};exports[_0xc7d9('0xc9')]=function(_0x1109fb,_0x4fc4b1){var _0x27367d=[];_0x27367d['push'](addAdditionalPhones(_0x1109fb[_0xc7d9('0x8b')]));Promise[_0xc7d9('0x25')](_0x27367d)[_0xc7d9('0x17')](function(){_0x27367d=[];_0x27367d[_0xc7d9('0x22')](deleteCmHopperPhones(_0x1109fb[_0xc7d9('0x8b')]['id']));_0x27367d['push'](addCmHopperPhones(_0x1109fb['body']['id']));Promise[_0xc7d9('0x25')](_0x27367d)['then'](function(){return[0x1];})[_0xc7d9('0x17')](respondWithResult(_0x4fc4b1,null));});};function addAdditionalPhones(_0x5cf6aa){var _0x3bf26b;return new Promise(function(_0x28827b,_0x5ebc3c){return db[_0xc7d9('0x9e')][_0xc7d9('0x81')]({'where':{'CmContactId':_0x5cf6aa['id']}})[_0xc7d9('0x17')](function(){db[_0xc7d9('0xca')][_0xc7d9('0x86')]({'raw':!![],'attributes':['id',_0xc7d9('0xcb')]})[_0xc7d9('0x17')](function(_0x1dedb7){var _0x366b89=[];for(var _0x272f2b=0x0;_0x272f2b<_0x5cf6aa[_0xc7d9('0xcc')]['length'];_0x272f2b++){var _0x211bb0=_0x5cf6aa[_0xc7d9('0xcd')]?_[_0xc7d9('0xa9')](_0x5cf6aa[_0xc7d9('0xcd')][_0x272f2b])?'':_0x5cf6aa[_0xc7d9('0xcd')][_0x272f2b]:_0x5cf6aa['items'][_0x272f2b]['ItemTypeId']?_0x5cf6aa[_0xc7d9('0xcc')][_0x272f2b][_0xc7d9('0xce')]:'';var _0x29cb5a=_[_0xc7d9('0xa9')](_0x5cf6aa[_0xc7d9('0xcc')][_0x272f2b]['description'])?'':_0x5cf6aa[_0xc7d9('0xcc')][_0x272f2b][_0xc7d9('0xcf')];var _0x24b7db=_0x211bb0+':'+_0x5cf6aa[_0xc7d9('0xcc')][_0x272f2b][_0xc7d9('0xc4')]+'§'+_0x29cb5a;if(_[_0xc7d9('0xa9')](_0x3bf26b))_0x3bf26b=_0x24b7db;else _0x3bf26b+=';'+_0x24b7db;var _0x42804d=null;if(_0x5cf6aa[_0xc7d9('0xcd')]){if(!_['isNil'](_0x5cf6aa[_0xc7d9('0xcd')][_0x272f2b])){var _0x4f31be=_[_0xc7d9('0x82')](_0x1dedb7,function(_0x365901){return _0x365901['id']===_0x5cf6aa[_0xc7d9('0xcd')][_0x272f2b];});if(!_[_0xc7d9('0xa9')](_0x4f31be)){_0x42804d=_0x4f31be[_0xc7d9('0xcb')];}}}else{if(!_[_0xc7d9('0xa9')](_0x5cf6aa[_0xc7d9('0xcc')][_0x272f2b])){var _0x4f31be=_[_0xc7d9('0x82')](_0x1dedb7,function(_0x5732f5){return _0x5732f5['id']===_0x5cf6aa['items'][_0x272f2b]['ItemTypeId'];});if(!_['isNil'](_0x4f31be)){_0x42804d=_0x272f2b;}}}if(_[_0xc7d9('0xa9')](_0x42804d)){_0x42804d=0x64;}_0x366b89['push'](addAdditionalPhone(_0x5cf6aa['id'],_0x5cf6aa['items'][_0x272f2b]['phone'],_0x5cf6aa[_0xc7d9('0xcd')]?_['isNil'](_0x5cf6aa['item_types'][_0x272f2b])?null:_0x5cf6aa[_0xc7d9('0xcd')][_0x272f2b]:_0x5cf6aa[_0xc7d9('0xcc')][_0x272f2b][_0xc7d9('0xce')]?_0x5cf6aa[_0xc7d9('0xcc')][_0x272f2b][_0xc7d9('0xce')]:null,_0x42804d,_0x29cb5a));}Promise[_0xc7d9('0x25')](_0x366b89)[_0xc7d9('0x17')](function(){db[_0xc7d9('0x1c')][_0xc7d9('0x16')]({'AdditionalPhones':_0x3bf26b},{'where':{'id':_0x5cf6aa['id']}})[_0xc7d9('0x17')](function(){_0x28827b(0x1);});});});});});}function addAdditionalPhone(_0x3b4e61,_0x4e847c,_0x50519e,_0x42a428,_0x4e379f){return db['CmContactHasItem']['find']({'where':{'CmContactId':_0x3b4e61,'item':_0x4e847c}})[_0xc7d9('0x17')](function(_0x25d52c){if(_0x25d52c)logger[_0xc7d9('0x90')](_0xc7d9('0xd0'),_0x25d52c);else{db[_0xc7d9('0x9e')][_0xc7d9('0x93')]({'CmContactId':_0x3b4e61,'item':_0x4e847c,'ItemTypeId':_0x50519e,'OrderBy':_0x42a428,'ItemClass':_0xc7d9('0xd1'),'description':_0x4e379f});}});}function deletePhones(_0x4ec1f1){return db[_0xc7d9('0x9e')]['destroy']({'where':{'CmContactId':_0x4ec1f1}});}function deleteCmHopperPhones(_0x1d5341){return new Promise(function(_0x5505c7,_0x165000){return db[_0xc7d9('0x8f')][_0xc7d9('0x86')]({'raw':!![],'attributes':['id'],'where':{'ContactId':_0x1d5341}})['then'](function(_0xdad706){db[_0xc7d9('0xd2')][_0xc7d9('0x81')]({'where':{'CmHopperId':{'$in':_[_0xc7d9('0x43')](_0xdad706,'id')}}});})[_0xc7d9('0x17')](function(){_0x5505c7(0x1);});});}function addCmHopperPhones(_0x2b798d){return new Promise(function(_0x4ce9c5,_0x285a28){return db[_0xc7d9('0x8f')][_0xc7d9('0x86')]({'raw':!![],'attributes':['id'],'where':{'ContactId':_0x2b798d}})[_0xc7d9('0x17')](function(_0x5ec752){var _0x3fa4c8=[];_[_0xc7d9('0x43')](_0x5ec752,function(_0x112955){_0x3fa4c8[_0xc7d9('0x22')](createCmHopperPhone(_0x2b798d,_0x112955['id']));});Promise[_0xc7d9('0x25')](_0x3fa4c8)[_0xc7d9('0x17')](function(){_0x4ce9c5(0x1);});});});}function createCmHopperPhone(_0x175fec,_0x4d9178){return new Promise(function(_0x53581e,_0x52b28c){db[_0xc7d9('0x9e')][_0xc7d9('0x86')]({'raw':!![],'attributes':[_0xc7d9('0xd3'),_0xc7d9('0xcb')],'where':{'CmContactId':_0x175fec,'ItemClass':_0xc7d9('0xd1')},'include':[{'model':db[_0xc7d9('0xca')],'attributes':[_0xc7d9('0xcb')],'as':_0xc7d9('0xb7')}],'order':[_0xc7d9('0xcb'),db[_0xc7d9('0x73')][_0xc7d9('0xb8')](_0xc7d9('0xd4'))]})[_0xc7d9('0x17')](function(_0x4f8ae2){var _0x52be61=0x1;var _0x3ce84c=_[_0xc7d9('0x43')](_0x4f8ae2,function(_0x3902fd){_0x3902fd[_0xc7d9('0xd5')]=_0x4d9178;_0x3902fd['phone']=_0x3902fd['item'];_0x3902fd[_0xc7d9('0xcb')]=_0x52be61;delete _0x3902fd[_0xc7d9('0xd6')];_0x52be61=_0x52be61+0x1;return _0x3902fd;});return db[_0xc7d9('0xd2')][_0xc7d9('0xae')](_0x3ce84c,{});})[_0xc7d9('0x17')](function(){_0x53581e(0x1);});});}function insertAdditionalPhones(_0x184e3b,_0x1ce3d0){return new Promise(function(_0x23119c,_0x4cbfa4){var _0x1799b0=[];for(var _0x242549=0x0;_0x242549<_0x1ce3d0[_0xc7d9('0x1f')];_0x242549++){var _0x2f3f32=_0x1ce3d0[_0x242549];_0x1799b0[_0xc7d9('0x22')](parseContactItemType(_0x2f3f32));}Promise[_0xc7d9('0x25')](_0x1799b0)[_0xc7d9('0x17')](function(){var _0x1fe76f={'id':_0x184e3b['id'],'items':_0x1ce3d0};return addAdditionalPhones(_0x1fe76f)[_0xc7d9('0x17')](function(_0x163a8a){return addCmHopperPhones(_0x184e3b['id']);});})[_0xc7d9('0x17')](function(){_0x23119c(_0x184e3b);});});}function parseContactItemType(_0x418a26){return new Promise(function(_0x3e6b40,_0x34f361){if(_0x418a26[_0xc7d9('0x2d')](_0xc7d9('0xce'))){_0x3e6b40(_0x418a26);}else{return db[_0xc7d9('0xca')][_0xc7d9('0x82')]({'where':{'name':_0x418a26[_0xc7d9('0xb7')]}})[_0xc7d9('0x17')](function(_0x4db93){if(_[_0xc7d9('0xa9')](_0x4db93))_0x418a26['ItemTypeId']=null;else _0x418a26[_0xc7d9('0xce')]=_0x4db93['id'];_0x3e6b40(_0x418a26);});}});}exports[_0xc7d9('0xd7')]=function(_0x3ca341,_0x55e427){return db[_0xc7d9('0x9e')][_0xc7d9('0x86')]({'raw':!![],'where':{'CmContactId':_0x3ca341[_0xc7d9('0xb4')]['id'],'ItemClass':_0xc7d9('0xd1')},'include':[{'model':db[_0xc7d9('0xca')],'as':_0xc7d9('0xb7')}],'order':[['OrderBy'],[db[_0xc7d9('0x73')]['literal'](_0xc7d9('0xd4'))]]})['then'](function(_0x7418bd){return _0x7418bd;})[_0xc7d9('0x17')](respondWithResult(_0x55e427,null))[_0xc7d9('0x80')](handleError(_0x55e427,null));};exports[_0xc7d9('0xd8')]=function(_0x4b8091,_0x57f66b){return db['CmContactHasItem'][_0xc7d9('0x86')]({'raw':!![],'where':{'CmContactId':_0x4b8091[_0xc7d9('0x8b')][_0xc7d9('0xd9')]}})[_0xc7d9('0x17')](function(_0x54f598){var _0x1da863=_[_0xc7d9('0x43')](_0x54f598,function(_0x46bb2f){_0x46bb2f[_0xc7d9('0xda')]=_0x4b8091[_0xc7d9('0x8b')][_0xc7d9('0xdb')];return _0x46bb2f;});return db[_0xc7d9('0x9e')][_0xc7d9('0xae')](_0x1da863,{});})[_0xc7d9('0x17')](function(_0x69ba99){return addCmHopperPhones(_0x4b8091[_0xc7d9('0x8b')][_0xc7d9('0xdb')]);})[_0xc7d9('0x17')](function(_0x31e88f){return['ok'];})[_0xc7d9('0x17')](respondWithResult(_0x57f66b,null))['catch'](handleError(_0x57f66b,null));};exports[_0xc7d9('0xdc')]=function(_0x421a0e,_0x3dcd3a){var _0x23fd84=[];_0x23fd84[_0xc7d9('0x22')](createCmHopperPhone(_0x421a0e['body']['id'],_0x421a0e[_0xc7d9('0x8b')][_0xc7d9('0xdd')]));Promise[_0xc7d9('0x25')](_0x23fd84)['then'](function(){return[0x1];})[_0xc7d9('0x17')](respondWithResult(_0x3dcd3a,null));};exports[_0xc7d9('0xde')]=function(_0x3915dd,_0x516f55){var _0x1d1c38={'raw':![],'where':{}};var _0x1d1a88={};var _0x105482={'count':0x0,'rows':[]};return db['CmContact']['findOne']({'where':{'id':_0x3915dd['params']['id']}})['then'](handleEntityNotFound(_0x516f55,null))['then'](function(_0x1f922c){if(_0x1f922c){_0x1d1a88[_0xc7d9('0x2a')]=_[_0xc7d9('0x1e')](db['CmHopper'][_0xc7d9('0xc6')]);_0x1d1a88[_0xc7d9('0x27')]=_['keys'](_0x3915dd[_0xc7d9('0x27')]);_0x1d1a88['filters']=_[_0xc7d9('0x29')](_0x1d1a88[_0xc7d9('0x2a')],_0x1d1a88[_0xc7d9('0x27')]);_0x1d1c38['attributes']=_[_0xc7d9('0x29')](_0x1d1a88[_0xc7d9('0x2a')],qs['fields'](_0x3915dd[_0xc7d9('0x27')][_0xc7d9('0x2c')]));_0x1d1c38['attributes']=_0x1d1c38[_0xc7d9('0x2b')][_0xc7d9('0x1f')]?_0x1d1c38['attributes']:_0x1d1a88[_0xc7d9('0x2a')];if(!_0x3915dd[_0xc7d9('0x27')][_0xc7d9('0x2d')](_0xc7d9('0x2e'))){_0x1d1c38['limit']=qs['limit'](_0x3915dd[_0xc7d9('0x27')]['limit']);_0x1d1c38['offset']=qs[_0xc7d9('0x12')](_0x3915dd[_0xc7d9('0x27')]['offset']);}_0x1d1c38['order']=qs[_0xc7d9('0x30')](_0x3915dd[_0xc7d9('0x27')][_0xc7d9('0x30')]);_0x1d1c38[_0xc7d9('0x3b')]=qs[_0xc7d9('0x28')](_[_0xc7d9('0xdf')](_0x3915dd[_0xc7d9('0x27')],_0x1d1a88[_0xc7d9('0x28')]));_0x1d1c38[_0xc7d9('0x3b')][_0xc7d9('0xe0')]=_0x1f922c['id'];if(_0x3915dd[_0xc7d9('0x27')][_0xc7d9('0x58')]){_0x1d1c38[_0xc7d9('0x3b')]=_[_0xc7d9('0x8a')](_0x1d1c38[_0xc7d9('0x3b')],{'$or':_[_0xc7d9('0x43')](_0x1d1c38[_0xc7d9('0x2b')],function(_0x4bab52){var _0x5f2211={};_0x5f2211[_0x4bab52]={'$like':'%'+_0x3915dd[_0xc7d9('0x27')][_0xc7d9('0x58')]+'%'};return _0x5f2211;})});}_0x1d1c38=_['merge']({},_0x1d1c38,_0x3915dd['options']);return db[_0xc7d9('0x8f')][_0xc7d9('0x13')]({'where':_0x1d1c38[_0xc7d9('0x3b')]})[_0xc7d9('0x17')](function(_0x48a63f){_0x105482['count']=_0x48a63f;if(_0x3915dd[_0xc7d9('0x27')][_0xc7d9('0xe1')]){_0x1d1c38[_0xc7d9('0xe2')]=[{'all':!![]}];}return db['CmHopper'][_0xc7d9('0x86')](_0x1d1c38);})['then'](function(_0x35d00b){_0x105482[_0xc7d9('0x7f')]=_0x35d00b;return _0x105482;});}})[_0xc7d9('0x17')](respondWithFilteredResult(_0x516f55,_0x1d1c38))['catch'](handleError(_0x516f55,null));};exports[_0xc7d9('0xe3')]=function(_0x23ef09,_0x4f9797){var _0x41cb54={'raw':!![],'where':{}};var _0x5685f5={};var _0x291ea2={'count':0x0,'rows':[]};return db['CmContact'][_0xc7d9('0x23')]({'where':{'id':_0x23ef09[_0xc7d9('0xb4')]['id']}})[_0xc7d9('0x17')](handleEntityNotFound(_0x4f9797,null))[_0xc7d9('0x17')](function(_0x4b5131){if(_0x4b5131){_0x5685f5[_0xc7d9('0x2a')]=_['keys'](db['CmHopperHistory'][_0xc7d9('0xc6')]);_0x5685f5[_0xc7d9('0x27')]=_['keys'](_0x23ef09['query']);_0x5685f5[_0xc7d9('0x28')]=_[_0xc7d9('0x29')](_0x5685f5[_0xc7d9('0x2a')],_0x5685f5[_0xc7d9('0x27')]);_0x41cb54[_0xc7d9('0x2b')]=_[_0xc7d9('0x29')](_0x5685f5[_0xc7d9('0x2a')],qs[_0xc7d9('0x2c')](_0x23ef09[_0xc7d9('0x27')][_0xc7d9('0x2c')]));_0x41cb54[_0xc7d9('0x2b')]=_0x41cb54['attributes'][_0xc7d9('0x1f')]?_0x41cb54[_0xc7d9('0x2b')]:_0x5685f5[_0xc7d9('0x2a')];if(!_0x23ef09[_0xc7d9('0x27')][_0xc7d9('0x2d')](_0xc7d9('0x2e'))){_0x41cb54[_0xc7d9('0x2f')]=qs[_0xc7d9('0x2f')](_0x23ef09[_0xc7d9('0x27')][_0xc7d9('0x2f')]);_0x41cb54[_0xc7d9('0x12')]=qs['offset'](_0x23ef09['query'][_0xc7d9('0x12')]);}_0x41cb54[_0xc7d9('0x69')]=qs[_0xc7d9('0x30')](_0x23ef09[_0xc7d9('0x27')][_0xc7d9('0x30')]);_0x41cb54[_0xc7d9('0x3b')]=qs['filters'](_[_0xc7d9('0xdf')](_0x23ef09[_0xc7d9('0x27')],_0x5685f5[_0xc7d9('0x28')]));_0x41cb54['where'][_0xc7d9('0xe0')]=_0x4b5131['id'];if(_0x23ef09[_0xc7d9('0x27')][_0xc7d9('0x58')]){_0x41cb54['where']=_['merge'](_0x41cb54[_0xc7d9('0x3b')],{'$or':_['map'](_0x41cb54[_0xc7d9('0x2b')],function(_0x2063d7){var _0x3fb1fb={};_0x3fb1fb[_0x2063d7]={'$like':'%'+_0x23ef09[_0xc7d9('0x27')]['filter']+'%'};return _0x3fb1fb;})});}_0x41cb54=_[_0xc7d9('0x8a')]({},_0x41cb54,_0x23ef09['options']);return db[_0xc7d9('0xa0')][_0xc7d9('0x13')]({'where':_0x41cb54[_0xc7d9('0x3b')]})['then'](function(_0x52ae41){_0x291ea2[_0xc7d9('0x13')]=_0x52ae41;if(_0x23ef09[_0xc7d9('0x27')]['includeAll']){_0x41cb54['include']=[{'all':!![]}];}return db[_0xc7d9('0xa0')][_0xc7d9('0x86')](_0x41cb54);})[_0xc7d9('0x17')](function(_0x3ba01f){_0x291ea2[_0xc7d9('0x7f')]=_0x3ba01f;return _0x291ea2;});}})[_0xc7d9('0x17')](respondWithFilteredResult(_0x4f9797,_0x41cb54))[_0xc7d9('0x80')](handleError(_0x4f9797,null));};exports[_0xc7d9('0xe4')]=function(_0x3cc38c,_0x3be670){var _0x16a388={'raw':!![],'where':{}};var _0x1ef21c={};var _0x3b0977={'count':0x0,'rows':[]};return db[_0xc7d9('0x1c')][_0xc7d9('0x23')]({'where':{'id':_0x3cc38c[_0xc7d9('0xb4')]['id']}})[_0xc7d9('0x17')](handleEntityNotFound(_0x3be670,null))[_0xc7d9('0x17')](function(_0x5382e0){if(_0x5382e0){_0x1ef21c[_0xc7d9('0x2a')]=_[_0xc7d9('0x1e')](db['CmHopperFinal']['rawAttributes']);_0x1ef21c[_0xc7d9('0x27')]=_['keys'](_0x3cc38c[_0xc7d9('0x27')]);_0x1ef21c['filters']=_[_0xc7d9('0x29')](_0x1ef21c['model'],_0x1ef21c[_0xc7d9('0x27')]);_0x16a388[_0xc7d9('0x2b')]=_[_0xc7d9('0x29')](_0x1ef21c['model'],qs[_0xc7d9('0x2c')](_0x3cc38c[_0xc7d9('0x27')][_0xc7d9('0x2c')]));_0x16a388[_0xc7d9('0x2b')]=_0x16a388['attributes'][_0xc7d9('0x1f')]?_0x16a388[_0xc7d9('0x2b')]:_0x1ef21c['model'];if(!_0x3cc38c[_0xc7d9('0x27')][_0xc7d9('0x2d')](_0xc7d9('0x2e'))){_0x16a388[_0xc7d9('0x2f')]=qs[_0xc7d9('0x2f')](_0x3cc38c['query'][_0xc7d9('0x2f')]);_0x16a388['offset']=qs[_0xc7d9('0x12')](_0x3cc38c['query'][_0xc7d9('0x12')]);}_0x16a388['order']=qs['sort'](_0x3cc38c[_0xc7d9('0x27')][_0xc7d9('0x30')]);_0x16a388[_0xc7d9('0x3b')]=qs[_0xc7d9('0x28')](_[_0xc7d9('0xdf')](_0x3cc38c['query'],_0x1ef21c['filters']));_0x16a388[_0xc7d9('0x3b')][_0xc7d9('0xe0')]=_0x5382e0['id'];if(_0x3cc38c[_0xc7d9('0x27')][_0xc7d9('0x58')]){_0x16a388[_0xc7d9('0x3b')]=_[_0xc7d9('0x8a')](_0x16a388[_0xc7d9('0x3b')],{'$or':_['map'](_0x16a388[_0xc7d9('0x2b')],function(_0x342ca3){var _0x1785d9={};_0x1785d9[_0x342ca3]={'$like':'%'+_0x3cc38c[_0xc7d9('0x27')][_0xc7d9('0x58')]+'%'};return _0x1785d9;})});}_0x16a388=_[_0xc7d9('0x8a')]({},_0x16a388,_0x3cc38c[_0xc7d9('0xe5')]);return db['CmHopperFinal']['count']({'where':_0x16a388[_0xc7d9('0x3b')]})[_0xc7d9('0x17')](function(_0x5d1cc3){_0x3b0977[_0xc7d9('0x13')]=_0x5d1cc3;if(_0x3cc38c[_0xc7d9('0x27')][_0xc7d9('0xe1')]){_0x16a388[_0xc7d9('0xe2')]=[{'all':!![]}];}return db[_0xc7d9('0x9f')]['findAll'](_0x16a388);})['then'](function(_0x4ec370){_0x3b0977['rows']=_0x4ec370;return _0x3b0977;});}})['then'](respondWithFilteredResult(_0x3be670,_0x16a388))[_0xc7d9('0x80')](handleError(_0x3be670,null));};exports[_0xc7d9('0xe6')]=function(_0x1b6aec,_0x5be8a6){var _0x194e72={'raw':!![],'where':{}};var _0x27bcfe={};var _0x15ac17={'count':0x0,'rows':[]};return db[_0xc7d9('0x1c')][_0xc7d9('0x23')]({'where':{'id':_0x1b6aec[_0xc7d9('0xb4')]['id']}})['then'](handleEntityNotFound(_0x5be8a6,null))[_0xc7d9('0x17')](function(_0x352e94){if(_0x352e94){_0x27bcfe[_0xc7d9('0x2a')]=_[_0xc7d9('0x1e')](db['JscriptySessionReport'][_0xc7d9('0xc6')]);_0x27bcfe[_0xc7d9('0x27')]=_[_0xc7d9('0x1e')](_0x1b6aec[_0xc7d9('0x27')]);_0x27bcfe[_0xc7d9('0x28')]=_[_0xc7d9('0x29')](_0x27bcfe['model'],_0x27bcfe[_0xc7d9('0x27')]);_0x194e72[_0xc7d9('0x2b')]=_[_0xc7d9('0x29')](_0x27bcfe['model'],qs[_0xc7d9('0x2c')](_0x1b6aec[_0xc7d9('0x27')][_0xc7d9('0x2c')]));_0x194e72[_0xc7d9('0x2b')]=_0x194e72[_0xc7d9('0x2b')][_0xc7d9('0x1f')]?_0x194e72[_0xc7d9('0x2b')]:_0x27bcfe[_0xc7d9('0x2a')];if(!_0x1b6aec[_0xc7d9('0x27')][_0xc7d9('0x2d')]('nolimit')){_0x194e72[_0xc7d9('0x2f')]=qs[_0xc7d9('0x2f')](_0x1b6aec[_0xc7d9('0x27')][_0xc7d9('0x2f')]);_0x194e72['offset']=qs[_0xc7d9('0x12')](_0x1b6aec['query'][_0xc7d9('0x12')]);}_0x194e72[_0xc7d9('0x69')]=qs['sort'](_0x1b6aec[_0xc7d9('0x27')]['sort']);_0x194e72[_0xc7d9('0x3b')]=qs[_0xc7d9('0x28')](_[_0xc7d9('0xdf')](_0x1b6aec[_0xc7d9('0x27')],_0x27bcfe[_0xc7d9('0x28')]));_0x194e72[_0xc7d9('0x3b')][_0xc7d9('0xe0')]=_0x352e94['id'];if(_0x1b6aec[_0xc7d9('0x27')]['filter']){_0x194e72[_0xc7d9('0x3b')]=_[_0xc7d9('0x8a')](_0x194e72[_0xc7d9('0x3b')],{'$or':_[_0xc7d9('0x43')](_0x194e72['attributes'],function(_0x1d3553){var _0x3edf04={};_0x3edf04[_0x1d3553]={'$like':'%'+_0x1b6aec[_0xc7d9('0x27')][_0xc7d9('0x58')]+'%'};return _0x3edf04;})});}_0x194e72=_[_0xc7d9('0x8a')]({},_0x194e72,_0x1b6aec[_0xc7d9('0xe5')]);return db[_0xc7d9('0xa6')][_0xc7d9('0x13')]({'where':_0x194e72['where']})[_0xc7d9('0x17')](function(_0x17aec7){_0x15ac17[_0xc7d9('0x13')]=_0x17aec7;if(_0x1b6aec[_0xc7d9('0x27')][_0xc7d9('0xe1')]){_0x194e72['include']=[{'all':!![]}];}return db[_0xc7d9('0xa6')][_0xc7d9('0x86')](_0x194e72);})[_0xc7d9('0x17')](function(_0x39b8a3){_0x15ac17['rows']=_0x39b8a3;return _0x15ac17;});}})[_0xc7d9('0x17')](respondWithFilteredResult(_0x5be8a6,_0x194e72))['catch'](handleError(_0x5be8a6,null));};exports[_0xc7d9('0xe7')]=function(_0x12ef11,_0x125c01){try{if(!_0x12ef11[_0xc7d9('0x8b')][_0xc7d9('0x51')]){throw new Error(_0xc7d9('0xe8'));}if(!_0x12ef11['body']['binding_keys']){throw new Error(_0xc7d9('0xe9'));}if(!_0x12ef11[_0xc7d9('0x8b')][_0xc7d9('0xea')]){throw new Error(_0xc7d9('0xeb'));}if(!_0x12ef11[_0xc7d9('0x8b')][_0xc7d9('0xec')]){throw new Error(_0xc7d9('0xed'));}var _0x282442=_0x12ef11[_0xc7d9('0x8b')]['binding_keys'][_0xc7d9('0x42')](',');var _0x2b04bb=_0x12ef11[_0xc7d9('0x8b')][_0xc7d9('0xea')][_0xc7d9('0x42')](',');if(!_0x282442['length']||!_0x2b04bb[_0xc7d9('0x1f')]||_0x282442['length']!==_0x2b04bb[_0xc7d9('0x1f')]){throw new Error(_0xc7d9('0xee'));}_0x12ef11[_0xc7d9('0x8b')][_0xc7d9('0x2c')]=_['zipObject'](_0x282442,_0x2b04bb);if(!_0x12ef11['body'][_0xc7d9('0x2c')][_0xc7d9('0xc4')]){throw new Error(_0xc7d9('0xef'));}if(!_0x12ef11[_0xc7d9('0x8b')]['fields'][_0xc7d9('0xf0')]){throw new Error(_0xc7d9('0xf1'));}var _0x2859f2=path[_0xc7d9('0xa8')](config['root'],_0xc7d9('0xf2'),_0x12ef11[_0xc7d9('0xf3')][_0xc7d9('0xf4')]);fs[_0xc7d9('0xf5')](_0x2859f2,parseInt(_0xc7d9('0xf6'),0x8));var _0x2b9f04=require(_0xc7d9('0xf7'))[_0xc7d9('0xf8')](path['join'](__dirname,_0xc7d9('0xf9')),[_0x2859f2,_0x12ef11[_0xc7d9('0x8b')]['binding_keys'],_0x12ef11[_0xc7d9('0x8b')]['binding_values'],_0x12ef11[_0xc7d9('0x8b')]['ListId'],_0x12ef11[_0xc7d9('0x8b')][_0xc7d9('0xfa')],_0x12ef11[_0xc7d9('0x8b')]['duplicates'],_0x12ef11[_0xc7d9('0x8b')][_0xc7d9('0xec')]]);return _0x125c01[_0xc7d9('0x10')](0xc8)[_0xc7d9('0x11')]({'message':_0xc7d9('0xfb'),'pid':_0x2b9f04[_0xc7d9('0xfc')]});}catch(_0x5b6e52){return _0x125c01['status'](0x1f4)[_0xc7d9('0xfd')](_0x5b6e52);}};exports[_0xc7d9('0xfe')]=function(_0x380318,_0x386f28){var _0x4c242f=fs[_0xc7d9('0xff')](_0x380318[_0xc7d9('0xf3')]['path']);Papa[_0xc7d9('0x100')](_0x4c242f,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0xb8aa3e){return _0x386f28[_0xc7d9('0x10')](0xc8)[_0xc7d9('0x11')]({'file':_0x380318['file'],'fields':_0xb8aa3e[_0xc7d9('0x101')][_0xc7d9('0x2c')]});}});};exports[_0xc7d9('0x102')]=function(_0x2a0896,_0x53adf3){return db['User'][_0xc7d9('0x86')]({'raw':!![],'attributes':['id'],'where':{'role':_0xc7d9('0x6f')}})[_0xc7d9('0x17')](function(_0x21b1f6){var _0x6d9f4c=![];if(!_0x2a0896['body']['ListId']){throw new Error('No\x20ListId\x20specified');}if(!_0x2a0896[_0xc7d9('0x8b')][_0xc7d9('0x103')][_0xc7d9('0xc4')]){throw new Error(_0xc7d9('0xef'));}if(!_0x2a0896[_0xc7d9('0x8b')][_0xc7d9('0x103')][_0xc7d9('0xf0')]){throw new Error(_0xc7d9('0xf1'));}if(!_0x2a0896[_0xc7d9('0x8b')][_0xc7d9('0xec')]){throw new Error(_0xc7d9('0xed'));}var _0x1d1a7c=require(_0xc7d9('0xf7'))[_0xc7d9('0xf8')](path[_0xc7d9('0xa8')](__dirname,_0xc7d9('0x104')),[_0x2a0896['params']['id'],JSON['stringify'](_0x2a0896[_0xc7d9('0x8b')]),JSON['stringify'](_0x21b1f6)]);_0x1d1a7c['on'](_0xc7d9('0x105'),function(){_0x6d9f4c=!![];return _0x53adf3[_0xc7d9('0x10')](0xc8)[_0xc7d9('0x11')]({'message':'start\x20child\x20process\x20correctly!','pid':_0x1d1a7c[_0xc7d9('0xfc')]});});_0x1d1a7c['on']('exit',function(_0x4d0be9){if(_0x4d0be9&&!_0x6d9f4c){return _0x53adf3[_0xc7d9('0x10')](0x1f4)[_0xc7d9('0x11')]({'message':_0xc7d9('0x106'),'pid':_0x1d1a7c['pid']});}});})[_0xc7d9('0x80')](handleError(_0x53adf3,null));};exports[_0xc7d9('0x107')]=function(_0x5446af,_0x5b2c24,_0x1fb014){return db[_0xc7d9('0x108')]['findAll']({'raw':!![],'attributes':['id'],'where':{'role':'agent'}})[_0xc7d9('0x17')](function(_0x571860){var _0x5813b6=![];if(!_0x5446af[_0xc7d9('0x8b')]['ListId']){throw new Error(_0xc7d9('0xe8'));}if(!_0x5446af['body'][_0xc7d9('0x103')][_0xc7d9('0xc4')]){throw new Error(_0xc7d9('0xef'));}if(!_0x5446af['body'][_0xc7d9('0x103')]['firstName']){throw new Error(_0xc7d9('0xf1'));}if(!_0x5446af[_0xc7d9('0x8b')][_0xc7d9('0xec')]){throw new Error(_0xc7d9('0xed'));}var _0x44afb1=require(_0xc7d9('0xf7'))[_0xc7d9('0xf8')](path[_0xc7d9('0xa8')](__dirname,_0xc7d9('0x109')),[_0x5446af[_0xc7d9('0xb4')]['id'],JSON[_0xc7d9('0x10a')](_0x5446af[_0xc7d9('0x8b')]),JSON[_0xc7d9('0x10a')](_0x571860)]);_0x44afb1['on'](_0xc7d9('0x105'),function(_0x507544){_0x5813b6=!![];return _0x5b2c24[_0xc7d9('0x10')](0xc8)[_0xc7d9('0x11')]({'message':_0xc7d9('0x10b'),'pid':_0x44afb1[_0xc7d9('0xfc')]});});_0x44afb1['on'](_0xc7d9('0x10c'),function(_0xb1d560){if(_0xb1d560&&!_0x5813b6){return _0x5b2c24[_0xc7d9('0x10')](0x1f4)[_0xc7d9('0x11')]({'message':_0xc7d9('0x106'),'pid':_0x44afb1['pid']});}});})[_0xc7d9('0x80')](handleError(_0x5b2c24,null));};exports[_0xc7d9('0x10d')]=function(_0x34fd38,_0x25909a){var _0x1632e8=[_0xc7d9('0x10e'),_0xc7d9('0x10f'),_0xc7d9('0x110'),_0xc7d9('0x111'),_0xc7d9('0x112'),_0xc7d9('0x113'),'voice'];var _0x37436c={'offset':0x0,'order':qs[_0xc7d9('0x30')]('-createdAt')},_0x169f8d={'count':0x0,'rows':[]};Promise[_0xc7d9('0x6c')]()[_0xc7d9('0x17')](function(){if(_0x34fd38[_0xc7d9('0x27')][_0xc7d9('0x114')]){if(!_[_0xc7d9('0x115')](_0x1632e8,_0x34fd38[_0xc7d9('0x27')]['channel'][_0xc7d9('0x116')]())){throw new Error(_0xc7d9('0x117'));}_0x1632e8=[_0x34fd38[_0xc7d9('0x27')]['channel'][_0xc7d9('0x116')]()];}if(_0x34fd38[_0xc7d9('0x27')][_0xc7d9('0x118')]){try{var _0x2e34f5=JSON[_0xc7d9('0x100')](_0x34fd38['query'][_0xc7d9('0x118')]);if(!moment(_0x2e34f5[_0xc7d9('0x8c')])[_0xc7d9('0x119')]()){throw new Error(_0xc7d9('0x11a'));}if(!moment(_0x2e34f5['to'])['isValid']()){throw new Error('Invalid\x20date\x20for\x20range\x20to\x20filter');}}catch(_0x139834){throw new Error('Invalid\x20createdAt\x20filter');}}if(!_0x34fd38[_0xc7d9('0x27')][_0xc7d9('0x2d')](_0xc7d9('0x2e'))){_0x37436c['limit']=qs[_0xc7d9('0x2f')](_0x34fd38[_0xc7d9('0x27')][_0xc7d9('0x2f')]||0xa);_0x37436c[_0xc7d9('0x12')]=qs[_0xc7d9('0x12')](_0x34fd38[_0xc7d9('0x27')]['offset']);}var _0x23f3c5=_0x1632e8[_0xc7d9('0x43')](function(_0x1203b6){if(_0x1203b6===_0xc7d9('0x11b')){var _0x239c0d={'attributes':['id',_0xc7d9('0x11c'),_0xc7d9('0x88'),'source',_0xc7d9('0x11d'),_0xc7d9('0x11e'),_0xc7d9('0x11f'),_0xc7d9('0x120'),_0xc7d9('0x121'),_0xc7d9('0x122'),_0xc7d9('0x123'),_0xc7d9('0x124'),'userSecondDisposition',_0xc7d9('0x125'),_0xc7d9('0x126')],'where':{'ContactId':_0x34fd38[_0xc7d9('0xb4')]['id']},'include':[{'model':db['User'],'as':_0xc7d9('0x108'),'attributes':['id',_0xc7d9('0x1b'),_0xc7d9('0x127'),'alias']}],'order':[[_0xc7d9('0x123'),_0xc7d9('0x128')]]};if(_0x34fd38[_0xc7d9('0x27')]['range']){_0x239c0d[_0xc7d9('0x3b')][_0xc7d9('0x123')]={'$gte':_0x2e34f5['from'],'$lte':_0x2e34f5['to']};}return db[_0xc7d9('0xa1')][_0xc7d9('0x129')](_0x239c0d)[_0xc7d9('0x17')](function(_0x505445){_0x169f8d[_0xc7d9('0x13')]+=_0x505445['count'];return _[_0xc7d9('0x43')](_0x505445[_0xc7d9('0x7f')],function(_0x34d270){var _0x2e62d5=_0x34d270[_0xc7d9('0x8d')]({'plain':!![]});_0x2e62d5['channel']=_0x1203b6;if(_0x2e62d5[_0xc7d9('0x108')]){_0x2e62d5[_0xc7d9('0x108')]={'id':_0x2e62d5[_0xc7d9('0x108')]['id'],'name':_0x2e62d5[_0xc7d9('0x108')][_0xc7d9('0x1b')],'fullname':_0x2e62d5['User']['fullname'],'alias':_0x2e62d5[_0xc7d9('0x108')][_0xc7d9('0x12a')]};}return _0x2e62d5;});});}else{var _0x30cab3=_[_0xc7d9('0x12b')](_0x1203b6)+(_0x1203b6===_0xc7d9('0x10f')?'Website':'Account');var _0x7eeed0={'attributes':['id',_0xc7d9('0x12c'),_0xc7d9('0x12d'),_0xc7d9('0x123'),_0xc7d9('0x122'),_0xc7d9('0x12e'),'secondDisposition',_0xc7d9('0x12f'),_0xc7d9('0x126'),_0x30cab3+'Id'],'where':{'ContactId':_0x34fd38[_0xc7d9('0xb4')]['id']},'include':[{'model':db[_0x30cab3],'as':_0xc7d9('0x130'),'attributes':['id',_0xc7d9('0x1b'),_0xc7d9('0x131')]},{'model':db[_0xc7d9('0x108')],'as':_0xc7d9('0x132'),'attributes':['id','name',_0xc7d9('0x127')]},{'model':db['Tag'],'as':'Tags','attributes':['id',_0xc7d9('0x1b'),_0xc7d9('0x33')],'through':{'attributes':[]}}],'order':[[_0xc7d9('0x123'),_0xc7d9('0x128')]]};if(_0x34fd38[_0xc7d9('0x27')][_0xc7d9('0x118')]){_0x7eeed0[_0xc7d9('0x3b')][_0xc7d9('0x123')]={'$gte':_0x2e34f5[_0xc7d9('0x8c')],'$lte':_0x2e34f5['to']};}switch(_0x1203b6){case _0xc7d9('0x10f'):_0x7eeed0[_0xc7d9('0x2b')][_0xc7d9('0x22')]('browserName',_0xc7d9('0x133'),_0xc7d9('0x134'),_0xc7d9('0x135'),_0xc7d9('0x136'),_0xc7d9('0x137'),_0xc7d9('0x138'),_0xc7d9('0x139'),_0xc7d9('0x13a'));break;case _0xc7d9('0x10e'):_0x7eeed0['attributes'][_0xc7d9('0x22')]('subject',_0xc7d9('0x13b'));break;case _0xc7d9('0x111'):_0x7eeed0['attributes'][_0xc7d9('0x22')](_0xc7d9('0x13c'),'threadId');break;}return db[_['startCase'](_0x1203b6)+'Interaction'][_0xc7d9('0x129')](_0x7eeed0)['then'](function(_0xabd033){_0x169f8d[_0xc7d9('0x13')]+=_0xabd033[_0xc7d9('0x13')];return _['map'](_0xabd033['rows'],function(_0x1d4182){var _0x3eb9cd=_0x1d4182[_0xc7d9('0x8d')]({'plain':!![]});_0x3eb9cd[_0xc7d9('0x114')]=_0x1203b6;if(_0x3eb9cd[_0xc7d9('0x132')]){_0x3eb9cd[_0xc7d9('0x132')]={'id':_0x3eb9cd[_0xc7d9('0x132')]['id'],'name':_0x3eb9cd[_0xc7d9('0x132')][_0xc7d9('0x1b')],'fullname':_0x3eb9cd['Owner'][_0xc7d9('0x127')]};}return _0x3eb9cd;});});}});return Promise[_0xc7d9('0x25')](_0x23f3c5);})[_0xc7d9('0x17')](function(_0x2287b8){return _(_0x2287b8)[_0xc7d9('0x13d')]()[_0xc7d9('0x13e')](_0xc7d9('0x123'))[_0xc7d9('0x13f')]()[_0xc7d9('0x41')]();})[_0xc7d9('0x17')](function(_0x4c505c){_0x169f8d[_0xc7d9('0x7f')]=_0x37436c[_0xc7d9('0x2f')]?_0x4c505c[_0xc7d9('0x140')](_0x37436c[_0xc7d9('0x12')],_0x37436c['offset']+_0x37436c['limit']):_0x4c505c;return _0x169f8d;})[_0xc7d9('0x17')](respondWithFilteredResult(_0x25909a,_0x37436c))[_0xc7d9('0x80')](handleError(_0x25909a,null));};
\ No newline at end of file
+var _0xb94d=['where','$or','push','ListId','findOrCreate','spread','contact','all','show','find','Tags','name','ContactItemType','ItemType','sequelize','literal','Phones.OrderBy','isNil','$and','omit','map','format','cf_%d','pickBy','cf_','isEmpty','table','cm_contacts','setFields','id\x20=\x20?','text','phone','getTags','findOne','model','Tag','rawAttributes','filters','attributes','intersection','fields','order','sort','filter','nolimit','setTags','setAdditionalPhones','OrderBy','items','item_types','description','ItemTypeId','contact\x20phone\x20exists','PHONE','CmHopper','CmHopperAdditionalPhone','item','`ItemType`.OrderBy','CmHopperId','ItemType.OrderBy','getAdditionalPhones','duplicateAdditionalPhones','fromContactId','CmContactId','toContactId','hopperId','getHoppers','pick','ContactId','options','include','rows','getHopperHistories','includeAll','getHopperFinals','uploadCsv','binding_keys','binding_values','No\x20association\x20values\x20specified!','socket_timestamp','Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed','split','Incorrect\x20binding\x20parameters\x20passed!','No\x20phone\x20column\x20specified','firstName','No\x20firstName\x20column\x20specified','root','server/files/tmp','file','child_process','fork','../../components/import/cm/csv','CompanyId','File\x20uploaded\x20correctly!','pid','upload','meta','import','User','agent','No\x20ListId\x20specified','binding','../../components/import/cm/csv2','stringify','message','exit','error\x20child\x20process','importUpdates','../../components/import/cm/csvUpdates','getJourney','chat','openchannel','fax','voice','-createdAt','resolve','includes','channel','toLowerCase','Invalid\x20channel','range','isValid','Invalid\x20date\x20for\x20range\x20from\x20filter','Invalid\x20createdAt\x20filter','uniqueid','source','destination','callerid','starttime','endtime','duration','note','createdAt','userDisposition','userSecondDisposition','userThirdDisposition','VoiceCallReport','findAndCountAll','startCase','Website','closed','closedAt','disposition','secondDisposition','thirdDisposition','UserId','Account','key','Owner','color','DESC','browserName','customerIp','customerPort','deviceModel','ratingMessage','ratingType','mail','subject','externalUrl','threadId','fullname','flatten','sortBy','value','slice','moment','lodash','squel','ioredis','../../components/contacts','../../components/parsers/qs','../../config/logger','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./cmContact.socket','register','status','json','offset','undefined','limit','count','set','Content-Range','update','then','destroy','sendStatus','error','send','index','findAll','query','catch','params','describe','CmContact','tags','keys','length','startsWith','columnName','analytics','CmCustomField','displayName','alias','type','values','info','Custom\x20field\x20%s\x20not\x20found\x20on\x20cm_contacts\x20table','forEach','hasOwnProperty','merge','body','get','mergeWith','isArray','join','from','[CmContact][merge][destroy][CmHopper],\x20%s','CmHopperBlack','ChatOfflineMessage','MailInteraction','MailMessage','SmsInteraction','SmsMessage','FaxInteraction','OpenchannelInteraction','OpenchannelMessage','CmContactHasItem','CmHopperFinal','CmHopperHistory','FaxQueueReport','OpenchannelQueueReport','SmsQueueReport','JscriptySessionReport','WhatsappInteraction','WhatsappMessage','WhatsappQueueReport','create','dialTimezone','utcOffset','timezones','additionalPhones','bulkCreate','duplicates'];(function(_0x2576d7,_0x167624){var _0x16a08c=function(_0x19de1e){while(--_0x19de1e){_0x2576d7['push'](_0x2576d7['shift']());}};_0x16a08c(++_0x167624);}(_0xb94d,0xa6));var _0xdb94=function(_0x152121,_0x120c53){_0x152121=_0x152121-0x0;var _0x592a85=_0xb94d[_0x152121];return _0x592a85;};'use strict';var moment=require(_0xdb94('0x0'));var BPromise=require('bluebird');var util=require('util');var path=require('path');var fs=require('fs');var _=require(_0xdb94('0x1'));var squel=require(_0xdb94('0x2'));var Papa=require('papaparse');var Redis=require(_0xdb94('0x3'));var contacts=require(_0xdb94('0x4'));var qs=require(_0xdb94('0x5'));var logger=require(_0xdb94('0x6'))('api');var config=require(_0xdb94('0x7'));var shared=require('../../config/environment/shared');var db=require(_0xdb94('0x8'))['db'];config[_0xdb94('0x9')]=_[_0xdb94('0xa')](config[_0xdb94('0x9')],{'host':_0xdb94('0xb'),'port':0x18eb});var socket=require(_0xdb94('0xc'))(new Redis(config[_0xdb94('0x9')]));require(_0xdb94('0xd'))[_0xdb94('0xe')](socket);function respondWithResult(_0x3ffc6e,_0x2d7f4c){_0x2d7f4c=_0x2d7f4c||0xc8;return function(_0x31daeb){if(_0x31daeb){return _0x3ffc6e[_0xdb94('0xf')](_0x2d7f4c)[_0xdb94('0x10')](_0x31daeb);}};}function respondWithFilteredResult(_0x23b044,_0x329646){return function(_0x4650a9){if(_0x4650a9){var _0x34310c=typeof _0x329646[_0xdb94('0x11')]===_0xdb94('0x12')&&typeof _0x329646[_0xdb94('0x13')]===_0xdb94('0x12');var _0x59cbb3=_0x4650a9[_0xdb94('0x14')];var _0x4db975=_0x34310c?0x0:_0x329646[_0xdb94('0x11')];var _0x307725=_0x34310c?_0x4650a9[_0xdb94('0x14')]:_0x329646[_0xdb94('0x11')]+_0x329646[_0xdb94('0x13')];var _0x341c8c;if(_0x307725>=_0x59cbb3){_0x307725=_0x59cbb3;_0x341c8c=0xc8;}else{_0x341c8c=0xce;}_0x23b044[_0xdb94('0xf')](_0x341c8c);return _0x23b044[_0xdb94('0x15')](_0xdb94('0x16'),_0x4db975+'-'+_0x307725+'/'+_0x59cbb3)[_0xdb94('0x10')](_0x4650a9);}return null;};}function saveUpdates(_0x37e716){return function(_0x1dd952){if(_0x1dd952){return _0x1dd952[_0xdb94('0x17')](_0x37e716)[_0xdb94('0x18')](function(_0x4c5994){return _0x4c5994;});}return null;};}function removeEntity(_0x38fa25){return function(_0x512ccd){if(_0x512ccd){return _0x512ccd[_0xdb94('0x19')]()[_0xdb94('0x18')](function(){_0x38fa25[_0xdb94('0xf')](0xcc)['end']();});}};}function handleEntityNotFound(_0x39695c){return function(_0x5b12d5){if(!_0x5b12d5){_0x39695c[_0xdb94('0x1a')](0x194);}return _0x5b12d5;};}function handleError(_0xd074be,_0x3d7285){_0x3d7285=_0x3d7285||0x1f4;return function(_0x2be650){logger[_0xdb94('0x1b')](_0x2be650['stack']);if(_0x2be650['name']){delete _0x2be650['name'];}_0xd074be[_0xdb94('0xf')](_0x3d7285)[_0xdb94('0x1c')](_0x2be650);};}exports[_0xdb94('0x1d')]=function(_0x37ae65,_0x2ca1a9){var _0x5e4b61={};return contacts['describe']()['then'](function(_0xdab26){_0x5e4b61=qs['getOptions'](_0xdab26,_0x37ae65);return contacts[_0xdb94('0x1e')](_0x37ae65[_0xdb94('0x1f')],_0x37ae65['user'],_0x5e4b61,_0xdab26);})[_0xdb94('0x18')](respondWithFilteredResult(_0x2ca1a9,_0x5e4b61))[_0xdb94('0x20')](handleError(_0x2ca1a9,null));};exports[_0xdb94('0x19')]=function(_0x594b82,_0xb549aa){return db['CmContact']['find']({'where':{'id':_0x594b82[_0xdb94('0x21')]['id']}})['then'](handleEntityNotFound(_0xb549aa,null))[_0xdb94('0x18')](removeEntity(_0xb549aa,null))['catch'](handleError(_0xb549aa,null));};exports[_0xdb94('0x22')]=function(_0x34c70b,_0x5d4f28){return db[_0xdb94('0x23')][_0xdb94('0x22')]()[_0xdb94('0x18')](function(_0x5d9a22){delete _0x5d9a22[_0xdb94('0x24')];for(var _0xbc39a9=0x0;_0xbc39a9<Object[_0xdb94('0x25')](_0x5d9a22)[_0xdb94('0x26')];_0xbc39a9++){var _0x929d96=Object['keys'](_0x5d9a22)[_0xbc39a9];if(!_[_0xdb94('0x27')](_0x929d96,'cf_')){_0x5d9a22[_0x929d96][_0xdb94('0x28')]=_0x929d96;_0x5d9a22[_0x929d96]['displayName']=_0x929d96;}}return _0x5d9a22;})['then'](function(_0xffcbc3){var _0x1c6922={'where':Boolean(_0x34c70b[_0xdb94('0x1f')][_0xdb94('0x29')])===!![]?undefined:{'$or':[{'ListId':_0x34c70b[_0xdb94('0x1f')]['id']},{'ListId':null}]},'raw':!![]};return db[_0xdb94('0x2a')][_0xdb94('0x1e')](_0x1c6922)[_0xdb94('0x18')](function(_0x3d4895){for(var _0x35ea2f=0x0;_0x35ea2f<_0x3d4895['length'];_0x35ea2f++){var _0x3eacb4='cf_'+_0x3d4895[_0x35ea2f]['id'];if(_0xffcbc3[_0x3eacb4]){_0xffcbc3[_0x3eacb4][_0xdb94('0x28')]=_0x3eacb4;_0xffcbc3[_0x3eacb4][_0xdb94('0x2b')]=_0x3d4895[_0x35ea2f][_0xdb94('0x2c')];_0xffcbc3[_0x3eacb4]['custom']={'type':_0x3d4895[_0x35ea2f][_0xdb94('0x2d')],'values':_0x3d4895[_0x35ea2f][_0xdb94('0x2e')]};}else{logger[_0xdb94('0x2f')](_0xdb94('0x30'),_0x3eacb4);}}Object['keys'](_0xffcbc3)[_0xdb94('0x31')](function(_0x1549e3){if(!_0xffcbc3[_0x1549e3][_0xdb94('0x32')](_0xdb94('0x28'))){delete _0xffcbc3[_0x1549e3];}});return _0xffcbc3;});})[_0xdb94('0x18')](respondWithResult(_0x5d4f28,null))[_0xdb94('0x20')](handleError(_0x5d4f28,null));};exports[_0xdb94('0x33')]=function(_0x40998c,_0x5cb9d6){var _0x37fe6d;var _0x2e7ea9;var _0x236c55;if(_0x40998c[_0xdb94('0x34')]['id']){delete _0x40998c[_0xdb94('0x34')]['id'];}return db[_0xdb94('0x23')][_0xdb94('0x1e')]({'where':{'id':[_0x40998c[_0xdb94('0x34')]['to'],_0x40998c[_0xdb94('0x34')]['from']]}})[_0xdb94('0x18')](function(_0x5988d1){if(_0x5988d1){if(_0x5988d1[_0xdb94('0x26')]!==0x2){return null;}_0x5988d1[0x0]=_0x5988d1[0x0][_0xdb94('0x35')]({'plain':!![]});_0x5988d1[0x1]=_0x5988d1[0x1][_0xdb94('0x35')]({'plain':!![]});delete _0x5988d1[0x0]['id'];delete _0x5988d1[0x1]['id'];return _[_0xdb94('0x36')](_0x5988d1[0x0],_0x5988d1[0x1],function(_0x5a1196,_0x2dce74){if(Array['isArray'](_0x2dce74)&&!_0x2dce74[_0xdb94('0x26')]){return _0x5a1196;}else if(!_0x2dce74){return _0x5a1196;}});}})[_0xdb94('0x18')](handleEntityNotFound(_0x5cb9d6,null))[_0xdb94('0x18')](function(_0x1593de){if(_0x1593de){if(_0x1593de[_0xdb94('0x24')]&&_[_0xdb94('0x37')](_0x1593de['tags'])){_0x1593de[_0xdb94('0x24')]=_0x1593de['tags'][_0xdb94('0x38')]();}logger[_0xdb94('0x2f')]('[CmContact][merge]\x20to\x20%s\x20from\x20%s',_0x40998c[_0xdb94('0x34')]['to'],_0x40998c[_0xdb94('0x34')][_0xdb94('0x39')]);return db['CmHopper'][_0xdb94('0x19')]({'where':{'ContactId':[_0x40998c[_0xdb94('0x34')]['to'],_0x40998c[_0xdb94('0x34')][_0xdb94('0x39')]]}})[_0xdb94('0x18')](function(_0x4d789d){logger[_0xdb94('0x2f')](_0xdb94('0x3a'),_0x4d789d);return db[_0xdb94('0x3b')][_0xdb94('0x19')]({'where':{'ContactId':[_0x40998c[_0xdb94('0x34')]['to'],_0x40998c[_0xdb94('0x34')]['from']]}})[_0xdb94('0x18')](function(_0x1c46a7){logger[_0xdb94('0x2f')]('[CmContact][merge][destroy][CmHopperBlack],\x20%s',_0x1c46a7);return db[_0xdb94('0x23')]['create'](_0x1593de);});});}})[_0xdb94('0x18')](function(_0x4def80){if(_0x4def80){_0x37fe6d=_0x4def80;_0x2e7ea9={'ContactId':_0x37fe6d['id']};_0x236c55={'where':{'ContactId':[_0x40998c[_0xdb94('0x34')]['to'],_0x40998c[_0xdb94('0x34')][_0xdb94('0x39')]]}};return db['ChatInteraction'][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db['ChatMessage'][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x3c')][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x3d')][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db['MailMessage'][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x3d')][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x3e')]['update'](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x3f')][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x40')]['update'](_0x2e7ea9,_0x236c55);}})['then'](function(){if(_0x37fe6d){return db[_0xdb94('0x41')]['update'](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db['FaxMessage']['update'](_0x2e7ea9,_0x236c55);}})['then'](function(){if(_0x37fe6d){return db[_0xdb94('0x42')][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x43')]['update'](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x44')][_0xdb94('0x17')]({'CmContactId':_0x37fe6d['id']},{'where':{'CmContactId':[_0x40998c[_0xdb94('0x34')]['to'],_0x40998c[_0xdb94('0x34')]['from']]}});}})['then'](function(){if(_0x37fe6d){return db[_0xdb94('0x45')][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})['then'](function(){if(_0x37fe6d){return db[_0xdb94('0x46')][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db['ReportAgentPreview'][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})['then'](function(){if(_0x37fe6d){return db['VoiceCallReport'][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db['ChatQueueReport'][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x47')]['update'](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db['MailQueueReport']['update'](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x48')][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x49')]['update'](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x4a')][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x4b')][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x4c')]['update'](_0x2e7ea9,_0x236c55);}})['then'](function(){if(_0x37fe6d){return db[_0xdb94('0x4d')][_0xdb94('0x17')](_0x2e7ea9,_0x236c55);}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return db[_0xdb94('0x23')][_0xdb94('0x19')]({'where':{'id':[_0x40998c[_0xdb94('0x34')]['to'],_0x40998c['body']['from']]}});}})[_0xdb94('0x18')](function(){if(_0x37fe6d){return _0x37fe6d;}})[_0xdb94('0x18')](respondWithResult(_0x5cb9d6,null))[_0xdb94('0x20')](handleError(_0x5cb9d6,null));};exports[_0xdb94('0x4e')]=function(_0x5f5d6e,_0x53d900){return db[_0xdb94('0x23')][_0xdb94('0x22')]()[_0xdb94('0x18')](function(_0x1d54e3){if(_0x5f5d6e[_0xdb94('0x34')][_0xdb94('0x24')]&&_[_0xdb94('0x37')](_0x5f5d6e[_0xdb94('0x34')][_0xdb94('0x24')])){if(_0x5f5d6e[_0xdb94('0x34')]['tags'][_0xdb94('0x26')]){_0x5f5d6e['body'][_0xdb94('0x24')]=_0x5f5d6e['body'][_0xdb94('0x24')]['join'](';')+';';}else{_0x5f5d6e[_0xdb94('0x34')]['tags']=null;}}else{_0x5f5d6e[_0xdb94('0x34')][_0xdb94('0x24')]=null;}if(!_['isNil'](_0x5f5d6e['body']['dialTimezone'])){var _0x5d6baf=_0x5f5d6e[_0xdb94('0x34')][_0xdb94('0x4f')];if(!_['isNil'](shared['timezones'][_0x5d6baf]))_0x5f5d6e[_0xdb94('0x34')][_0xdb94('0x50')]=shared[_0xdb94('0x51')][_0x5d6baf][_0xdb94('0x50')];}return db[_0xdb94('0x23')][_0xdb94('0x4e')](_0x5f5d6e['body'],{'fields':_[_0xdb94('0x25')](_0x1d54e3),'raw':!![]});})[_0xdb94('0x18')](function(_0x472d97){if(_0x5f5d6e[_0xdb94('0x34')][_0xdb94('0x52')]){return insertAdditionalPhones(_0x472d97,_0x5f5d6e[_0xdb94('0x34')][_0xdb94('0x52')]);}else{return _0x472d97;}})['then'](respondWithResult(_0x53d900,0xc9))[_0xdb94('0x20')](handleError(_0x53d900,null));};exports[_0xdb94('0x53')]=function(_0x5894d4,_0x4cf70b){var _0x26dfda=0x0;var _0x20c72d=0x0;var _0x3656b2=0x0;var _0xe78a79=[];return db[_0xdb94('0x23')][_0xdb94('0x22')]()[_0xdb94('0x18')](function(_0x1700e0){return BPromise['each'](_0x5894d4[_0xdb94('0x34')],function(_0x3f6c70){var _0x322161={'where':{'$or':[]},'defaults':_0x3f6c70,'fields':_[_0xdb94('0x25')](_0x1700e0),'raw':!![]};if(_0x3f6c70[_0xdb94('0x54')]){for(var _0x15ef26=0x0;_0x15ef26<_0x3f6c70[_0xdb94('0x54')][_0xdb94('0x26')];_0x15ef26++){var _0x392ddb={};_0x392ddb[_0x3f6c70['duplicates'][_0x15ef26]]=_0x3f6c70[_0x3f6c70[_0xdb94('0x54')][_0x15ef26]];_0x322161[_0xdb94('0x55')][_0xdb94('0x56')][_0xdb94('0x57')](_0x392ddb);}_0x322161[_0xdb94('0x55')][_0xdb94('0x58')]=_0x3f6c70['ListId'];}return db['CmContact'][_0xdb94('0x59')](_0x322161)[_0xdb94('0x5a')](function(_0x192174,_0x25f195){if(_0x25f195){if(_0x3f6c70[_0xdb94('0x32')](_0xdb94('0x52'))){_0xe78a79[_0xdb94('0x57')]({'contact':_0x192174,'additionalPhones':_0x3f6c70['additionalPhones']});}_0x26dfda++;}else{_0x3656b2++;}})['catch'](function(){_0x20c72d++;});});})['then'](function(_0x4cfb39){if(_0x4cfb39){if(_0xe78a79[_0xdb94('0x26')]>0x0){return new Promise(function(_0x248bf3){var _0x22cd79=[];for(var _0x1ec6f9=0x0;_0x1ec6f9<_0xe78a79[_0xdb94('0x26')];_0x1ec6f9++){_0x22cd79[_0xdb94('0x57')](insertAdditionalPhones(_0xe78a79[_0x1ec6f9][_0xdb94('0x5b')],_0xe78a79[_0x1ec6f9][_0xdb94('0x52')]));}Promise[_0xdb94('0x5c')](_0x22cd79)[_0xdb94('0x18')](function(){_0x248bf3(0x1);});})['then'](function(){return{'success':_0x26dfda,'failure':_0x20c72d,'duplicates':_0x3656b2};});}else{return{'success':_0x26dfda,'failure':_0x20c72d,'duplicates':_0x3656b2};}}})['then'](respondWithResult(_0x4cf70b,0xc9))['catch'](handleError(_0x4cf70b,null));};exports[_0xdb94('0x5d')]=function(_0x371055,_0x32e173){var _0x3a6ee6;return db[_0xdb94('0x23')][_0xdb94('0x22')]()['then'](function(_0x228fb6){return db[_0xdb94('0x23')][_0xdb94('0x5e')]({'where':{'id':_0x371055['params']['id']},'include':[{'model':db['Tag'],'as':_0xdb94('0x5f'),'attributes':['id',_0xdb94('0x60'),'color'],'required':_0x371055[_0xdb94('0x1f')]['tag']?!![]:![]},{'model':db[_0xdb94('0x44')],'as':'Phones','where':{'CmContactId':_0x371055[_0xdb94('0x21')]['id']},'required':![],'include':[{'model':db[_0xdb94('0x61')],'as':_0xdb94('0x62')}]}],'order':[db[_0xdb94('0x63')][_0xdb94('0x64')](_0xdb94('0x65'))],'attributes':_['keys'](_0x228fb6)});})[_0xdb94('0x18')](function(_0x551e5a){if(!_[_0xdb94('0x66')](_0x551e5a)){_0x3a6ee6=_0x551e5a[_0xdb94('0x35')]({'plain':!![]});var _0x5f0291={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x551e5a&&_0x551e5a[_0xdb94('0x58')]){if(_0x551e5a[_0xdb94('0x58')]){_0x5f0291[_0xdb94('0x55')][_0xdb94('0x67')]['push']({'ListId':{'$ne':_0x551e5a['ListId']}});}}return db[_0xdb94('0x2a')][_0xdb94('0x1e')](_0x5f0291);}})[_0xdb94('0x18')](function(_0x3ffd48){if(!_[_0xdb94('0x66')](_0x3ffd48)){return _[_0xdb94('0x68')](_0x3a6ee6,_[_0xdb94('0x69')](_0x3ffd48,function(_0x683597){return util[_0xdb94('0x6a')](_0xdb94('0x6b'),_0x683597['id']);}));}})[_0xdb94('0x18')](handleEntityNotFound(_0x32e173,null))[_0xdb94('0x18')](respondWithResult(_0x32e173,null))[_0xdb94('0x20')](handleError(_0x32e173,null));};exports[_0xdb94('0x17')]=function(_0x31f2c1,_0x3bbe09){var _0x3e1df4;if(_0x31f2c1[_0xdb94('0x34')]['id']){delete _0x31f2c1[_0xdb94('0x34')]['id'];}if(!_[_0xdb94('0x66')](_0x31f2c1['body'][_0xdb94('0x4f')])){var _0x5a7e1f=_0x31f2c1[_0xdb94('0x34')][_0xdb94('0x4f')];if(!_[_0xdb94('0x66')](shared['timezones'][_0x5a7e1f]))_0x31f2c1[_0xdb94('0x34')][_0xdb94('0x50')]=shared['timezones'][_0x5a7e1f][_0xdb94('0x50')];}return db[_0xdb94('0x23')][_0xdb94('0x5e')]({'where':{'id':_0x31f2c1[_0xdb94('0x21')]['id']}})['then'](handleEntityNotFound(_0x3bbe09,null))['then'](saveUpdates(_0x31f2c1[_0xdb94('0x34')],null))[_0xdb94('0x18')](function(_0x2a3279){_0x3e1df4=_0x2a3279;var _0x333dac={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x2a3279&&_0x2a3279[_0xdb94('0x58')]){if(_0x2a3279[_0xdb94('0x58')]){_0x333dac[_0xdb94('0x55')]['$and']['push']({'ListId':{'$ne':_0x2a3279['ListId']}});}}return db[_0xdb94('0x2a')]['findAll'](_0x333dac);})[_0xdb94('0x18')](function(_0x1d1b4b){if(_0x1d1b4b){return _[_0xdb94('0x68')](_[_0xdb94('0x6c')](_0x31f2c1[_0xdb94('0x34')],function(_0xbf088c,_0x43f245){return _[_0xdb94('0x27')](_0x43f245,_0xdb94('0x6d'));}),_[_0xdb94('0x69')](_0x1d1b4b,function(_0x38a2ab){return util['format']('cf_%d',_0x38a2ab['id']);}));}})['then'](function(_0x1f9bf0){if(_0x1f9bf0&&!_[_0xdb94('0x6e')](_0x1f9bf0)){var _0x563559=squel[_0xdb94('0x17')]()[_0xdb94('0x6f')](_0xdb94('0x70'))[_0xdb94('0x71')](_0x1f9bf0)['where'](_0xdb94('0x72'),_0x31f2c1['params']['id'])['toParam']();return db[_0xdb94('0x63')][_0xdb94('0x1f')](_0x563559[_0xdb94('0x73')],{'replacements':_0x563559[_0xdb94('0x2e')]});}})['then'](function(){if(_0x31f2c1[_0xdb94('0x34')][_0xdb94('0x74')]&&_0x3e1df4){return db['CmHopper']['update']({'phone':_0x31f2c1[_0xdb94('0x34')][_0xdb94('0x74')],'OrderBy':0x0},{'where':{'ContactId':_0x3e1df4['id']}});}})[_0xdb94('0x18')](function(){return _0x3e1df4;})[_0xdb94('0x18')](respondWithResult(_0x3bbe09,null))[_0xdb94('0x20')](handleError(_0x3bbe09,null));};exports[_0xdb94('0x75')]=function(_0x416769,_0x3bca46){var _0xc8f95e={};var _0x58b06b={};var _0x8fc959;var _0x996f22;return db[_0xdb94('0x23')][_0xdb94('0x76')]({'where':{'id':_0x416769[_0xdb94('0x21')]['id']}})[_0xdb94('0x18')](handleEntityNotFound(_0x3bca46,null))[_0xdb94('0x18')](function(_0x1da82d){if(_0x1da82d){_0x8fc959=_0x1da82d;_0x58b06b[_0xdb94('0x77')]=_[_0xdb94('0x25')](db[_0xdb94('0x78')][_0xdb94('0x79')]);_0x58b06b[_0xdb94('0x1f')]=_[_0xdb94('0x25')](_0x416769[_0xdb94('0x1f')]);_0x58b06b[_0xdb94('0x7a')]=_['intersection'](_0x58b06b['model'],_0x58b06b[_0xdb94('0x1f')]);_0xc8f95e[_0xdb94('0x7b')]=_[_0xdb94('0x7c')](_0x58b06b[_0xdb94('0x77')],qs[_0xdb94('0x7d')](_0x416769[_0xdb94('0x1f')]['fields']));_0xc8f95e[_0xdb94('0x7b')]=_0xc8f95e[_0xdb94('0x7b')][_0xdb94('0x26')]?_0xc8f95e[_0xdb94('0x7b')]:_0x58b06b['model'];_0xc8f95e[_0xdb94('0x7e')]=qs[_0xdb94('0x7f')](_0x416769[_0xdb94('0x1f')][_0xdb94('0x7f')]);_0xc8f95e[_0xdb94('0x55')]=qs['filters'](_['pick'](_0x416769['query'],_0x58b06b[_0xdb94('0x7a')]));if(_0x416769[_0xdb94('0x1f')][_0xdb94('0x80')]){_0xc8f95e['where']=_[_0xdb94('0x33')](_0xc8f95e['where'],{'$or':_[_0xdb94('0x69')](_0xc8f95e[_0xdb94('0x7b')],function(_0x2674b1){var _0x46bb58={};_0x46bb58[_0x2674b1]={'$like':'%'+_0x416769[_0xdb94('0x1f')][_0xdb94('0x80')]+'%'};return _0x46bb58;})});}_0xc8f95e=_[_0xdb94('0x33')]({},_0xc8f95e,_0x416769['options']);return _0x8fc959[_0xdb94('0x75')](_0xc8f95e);}})[_0xdb94('0x18')](function(_0x44858c){if(_0x44858c){_0x996f22=_0x44858c[_0xdb94('0x26')];if(!_0x416769[_0xdb94('0x1f')][_0xdb94('0x32')](_0xdb94('0x81'))){_0xc8f95e[_0xdb94('0x13')]=qs[_0xdb94('0x13')](_0x416769[_0xdb94('0x1f')][_0xdb94('0x13')]);_0xc8f95e[_0xdb94('0x11')]=qs[_0xdb94('0x11')](_0x416769[_0xdb94('0x1f')]['offset']);}return _0x8fc959['getTags'](_0xc8f95e);}})[_0xdb94('0x18')](function(_0x3ba98d){if(_0x3ba98d){return _0x3ba98d?{'count':_0x996f22,'rows':_0x3ba98d}:null;}})[_0xdb94('0x18')](respondWithResult(_0x3bca46,null))[_0xdb94('0x20')](handleError(_0x3bca46,null));};exports['setTags']=function(_0x38a3c3,_0x128863){if(_0x38a3c3[_0xdb94('0x34')]['id']){delete _0x38a3c3['body']['id'];}return db[_0xdb94('0x23')][_0xdb94('0x76')]({'where':{'id':_0x38a3c3[_0xdb94('0x21')]['id']}})[_0xdb94('0x18')](handleEntityNotFound(_0x128863,null))[_0xdb94('0x18')](function(_0x1fab19){if(_0x1fab19){return _0x1fab19[_0xdb94('0x82')](_0x38a3c3[_0xdb94('0x34')]['ids']||[]);}return null;})[_0xdb94('0x18')](respondWithResult(_0x128863,null))['catch'](handleError(_0x128863,null));};exports[_0xdb94('0x83')]=function(_0x50f76f,_0x36e191){var _0x21a825=[];_0x21a825[_0xdb94('0x57')](addAdditionalPhones(_0x50f76f[_0xdb94('0x34')]));Promise['all'](_0x21a825)[_0xdb94('0x18')](function(){_0x21a825=[];_0x21a825[_0xdb94('0x57')](deleteCmHopperPhones(_0x50f76f[_0xdb94('0x34')]['id']));_0x21a825[_0xdb94('0x57')](addCmHopperPhones(_0x50f76f[_0xdb94('0x34')]['id']));Promise['all'](_0x21a825)[_0xdb94('0x18')](function(){return[0x1];})['then'](respondWithResult(_0x36e191,null));});};function addAdditionalPhones(_0x10b9db){var _0x4faecf;return new Promise(function(_0x3169a3){return db['CmContactHasItem'][_0xdb94('0x19')]({'where':{'CmContactId':_0x10b9db['id']}})[_0xdb94('0x18')](function(){db[_0xdb94('0x61')][_0xdb94('0x1e')]({'raw':!![],'attributes':['id',_0xdb94('0x84')]})['then'](function(_0x21b693){var _0x1e5bd3=[];for(var _0x21c234=0x0;_0x21c234<_0x10b9db[_0xdb94('0x85')][_0xdb94('0x26')];_0x21c234++){var _0x44d35c=_0x10b9db['item_types']?_['isNil'](_0x10b9db['item_types'][_0x21c234])?'':_0x10b9db[_0xdb94('0x86')][_0x21c234]:_0x10b9db[_0xdb94('0x85')][_0x21c234]['ItemTypeId']?_0x10b9db[_0xdb94('0x85')][_0x21c234]['ItemTypeId']:'';var _0x45747b=_['isNil'](_0x10b9db[_0xdb94('0x85')][_0x21c234]['description'])?'':_0x10b9db[_0xdb94('0x85')][_0x21c234][_0xdb94('0x87')];var _0x43359e=_0x44d35c+':'+_0x10b9db[_0xdb94('0x85')][_0x21c234][_0xdb94('0x74')]+'§'+_0x45747b;if(_[_0xdb94('0x66')](_0x4faecf))_0x4faecf=_0x43359e;else _0x4faecf+=';'+_0x43359e;var _0x24525a=null;var _0x196af6=null;if(_0x10b9db[_0xdb94('0x86')]){if(!_[_0xdb94('0x66')](_0x10b9db[_0xdb94('0x86')][_0x21c234])){_0x196af6=_[_0xdb94('0x5e')](_0x21b693,function(_0x9d863b){return _0x9d863b['id']===_0x10b9db['item_types'][_0x21c234];});if(!_[_0xdb94('0x66')](_0x196af6)){_0x24525a=_0x196af6['OrderBy'];}}}else{if(!_[_0xdb94('0x66')](_0x10b9db['items'][_0x21c234])){_0x196af6=_[_0xdb94('0x5e')](_0x21b693,function(_0x1b2071){return _0x1b2071['id']===_0x10b9db[_0xdb94('0x85')][_0x21c234][_0xdb94('0x88')];});if(!_[_0xdb94('0x66')](_0x196af6)){_0x24525a=_0x21c234;}}}if(_[_0xdb94('0x66')](_0x24525a)){_0x24525a=0x64;}_0x1e5bd3[_0xdb94('0x57')](addAdditionalPhone(_0x10b9db['id'],_0x10b9db[_0xdb94('0x85')][_0x21c234]['phone'],_0x10b9db[_0xdb94('0x86')]?_[_0xdb94('0x66')](_0x10b9db['item_types'][_0x21c234])?null:_0x10b9db[_0xdb94('0x86')][_0x21c234]:_0x10b9db[_0xdb94('0x85')][_0x21c234][_0xdb94('0x88')]?_0x10b9db[_0xdb94('0x85')][_0x21c234][_0xdb94('0x88')]:null,_0x24525a,_0x45747b));}Promise['all'](_0x1e5bd3)['then'](function(){db[_0xdb94('0x23')]['update']({'AdditionalPhones':_0x4faecf},{'where':{'id':_0x10b9db['id']}})[_0xdb94('0x18')](function(){_0x3169a3(0x1);});});});});});}function addAdditionalPhone(_0x4bd1cc,_0x549da3,_0x2c7920,_0x49ad0f,_0x4cc783){return db[_0xdb94('0x44')][_0xdb94('0x5e')]({'where':{'CmContactId':_0x4bd1cc,'item':_0x549da3}})[_0xdb94('0x18')](function(_0x1feae0){if(_0x1feae0)logger[_0xdb94('0x2f')](_0xdb94('0x89'),_0x1feae0);else{db[_0xdb94('0x44')][_0xdb94('0x4e')]({'CmContactId':_0x4bd1cc,'item':_0x549da3,'ItemTypeId':_0x2c7920,'OrderBy':_0x49ad0f,'ItemClass':_0xdb94('0x8a'),'description':_0x4cc783});}});}function deleteCmHopperPhones(_0x249924){return new Promise(function(_0x2de5fe){return db[_0xdb94('0x8b')]['findAll']({'raw':!![],'attributes':['id'],'where':{'ContactId':_0x249924}})[_0xdb94('0x18')](function(_0x5d683c){db[_0xdb94('0x8c')][_0xdb94('0x19')]({'where':{'CmHopperId':{'$in':_[_0xdb94('0x69')](_0x5d683c,'id')}}});})[_0xdb94('0x18')](function(){_0x2de5fe(0x1);});});}function addCmHopperPhones(_0xbcfeb6){return new Promise(function(_0x357d29){return db['CmHopper'][_0xdb94('0x1e')]({'raw':!![],'attributes':['id'],'where':{'ContactId':_0xbcfeb6}})[_0xdb94('0x18')](function(_0x359cf1){var _0x1f4771=[];_[_0xdb94('0x69')](_0x359cf1,function(_0x543185){_0x1f4771[_0xdb94('0x57')](createCmHopperPhone(_0xbcfeb6,_0x543185['id']));});Promise['all'](_0x1f4771)['then'](function(){_0x357d29(0x1);});});});}function createCmHopperPhone(_0x1c821b,_0x3f32ac){return new Promise(function(_0x101355){db[_0xdb94('0x44')]['findAll']({'raw':!![],'attributes':[_0xdb94('0x8d'),_0xdb94('0x84')],'where':{'CmContactId':_0x1c821b,'ItemClass':_0xdb94('0x8a')},'include':[{'model':db[_0xdb94('0x61')],'attributes':[_0xdb94('0x84')],'as':_0xdb94('0x62')}],'order':[_0xdb94('0x84'),db[_0xdb94('0x63')]['literal'](_0xdb94('0x8e'))]})['then'](function(_0x1ce70b){var _0x3c8dd8=0x1;var _0x1e5711=_[_0xdb94('0x69')](_0x1ce70b,function(_0x3324f4){_0x3324f4[_0xdb94('0x8f')]=_0x3f32ac;_0x3324f4['phone']=_0x3324f4[_0xdb94('0x8d')];_0x3324f4[_0xdb94('0x84')]=_0x3c8dd8;delete _0x3324f4[_0xdb94('0x90')];_0x3c8dd8=_0x3c8dd8+0x1;return _0x3324f4;});return db[_0xdb94('0x8c')]['bulkCreate'](_0x1e5711,{});})['then'](function(){_0x101355(0x1);});});}function insertAdditionalPhones(_0x5266a2,_0x448417){return new Promise(function(_0xf6465d){var _0xcb545=[];for(var _0x4c9e36=0x0;_0x4c9e36<_0x448417[_0xdb94('0x26')];_0x4c9e36++){var _0x5cbf1a=_0x448417[_0x4c9e36];_0xcb545['push'](parseContactItemType(_0x5cbf1a));}Promise['all'](_0xcb545)[_0xdb94('0x18')](function(){var _0x22169c={'id':_0x5266a2['id'],'items':_0x448417};return addAdditionalPhones(_0x22169c)['then'](function(){return addCmHopperPhones(_0x5266a2['id']);});})[_0xdb94('0x18')](function(){_0xf6465d(_0x5266a2);});});}function parseContactItemType(_0xcd661){return new Promise(function(_0x5b1069){if(_0xcd661['hasOwnProperty'](_0xdb94('0x88'))){_0x5b1069(_0xcd661);}else{return db[_0xdb94('0x61')][_0xdb94('0x5e')]({'where':{'name':_0xcd661[_0xdb94('0x62')]}})['then'](function(_0x6b6190){if(_[_0xdb94('0x66')](_0x6b6190))_0xcd661[_0xdb94('0x88')]=null;else _0xcd661['ItemTypeId']=_0x6b6190['id'];_0x5b1069(_0xcd661);});}});}exports[_0xdb94('0x91')]=function(_0x22ff73,_0x3218b7){return db[_0xdb94('0x44')][_0xdb94('0x1e')]({'raw':!![],'where':{'CmContactId':_0x22ff73[_0xdb94('0x21')]['id'],'ItemClass':_0xdb94('0x8a')},'include':[{'model':db[_0xdb94('0x61')],'as':'ItemType'}],'order':[['OrderBy'],[db['sequelize'][_0xdb94('0x64')](_0xdb94('0x8e'))]]})[_0xdb94('0x18')](function(_0x54ee3d){return _0x54ee3d;})[_0xdb94('0x18')](respondWithResult(_0x3218b7,null))['catch'](handleError(_0x3218b7,null));};exports[_0xdb94('0x92')]=function(_0x454bae,_0x5d3f66){return db['CmContactHasItem']['findAll']({'raw':!![],'where':{'CmContactId':_0x454bae[_0xdb94('0x34')][_0xdb94('0x93')]}})[_0xdb94('0x18')](function(_0x173f98){var _0x3487ce=_['map'](_0x173f98,function(_0x28742e){_0x28742e[_0xdb94('0x94')]=_0x454bae[_0xdb94('0x34')][_0xdb94('0x95')];return _0x28742e;});return db[_0xdb94('0x44')][_0xdb94('0x53')](_0x3487ce,{});})[_0xdb94('0x18')](function(){return addCmHopperPhones(_0x454bae[_0xdb94('0x34')][_0xdb94('0x95')]);})[_0xdb94('0x18')](function(){return['ok'];})[_0xdb94('0x18')](respondWithResult(_0x5d3f66,null))[_0xdb94('0x20')](handleError(_0x5d3f66,null));};exports['rescheduleAdditionalPhones']=function(_0x404fb6,_0x11ec5f){var _0x15f845=[];_0x15f845[_0xdb94('0x57')](createCmHopperPhone(_0x404fb6[_0xdb94('0x34')]['id'],_0x404fb6['body'][_0xdb94('0x96')]));Promise[_0xdb94('0x5c')](_0x15f845)[_0xdb94('0x18')](function(){return[0x1];})[_0xdb94('0x18')](respondWithResult(_0x11ec5f,null));};exports[_0xdb94('0x97')]=function(_0x39b8ba,_0x210343){var _0x215997={'raw':![],'where':{}};var _0x269cd4={};var _0x48c9da={'count':0x0,'rows':[]};return db[_0xdb94('0x23')]['findOne']({'where':{'id':_0x39b8ba[_0xdb94('0x21')]['id']}})[_0xdb94('0x18')](handleEntityNotFound(_0x210343,null))['then'](function(_0x23f35e){if(_0x23f35e){_0x269cd4[_0xdb94('0x77')]=_[_0xdb94('0x25')](db['CmHopper'][_0xdb94('0x79')]);_0x269cd4[_0xdb94('0x1f')]=_[_0xdb94('0x25')](_0x39b8ba[_0xdb94('0x1f')]);_0x269cd4[_0xdb94('0x7a')]=_[_0xdb94('0x7c')](_0x269cd4[_0xdb94('0x77')],_0x269cd4['query']);_0x215997[_0xdb94('0x7b')]=_[_0xdb94('0x7c')](_0x269cd4['model'],qs[_0xdb94('0x7d')](_0x39b8ba['query'][_0xdb94('0x7d')]));_0x215997[_0xdb94('0x7b')]=_0x215997[_0xdb94('0x7b')][_0xdb94('0x26')]?_0x215997[_0xdb94('0x7b')]:_0x269cd4[_0xdb94('0x77')];if(!_0x39b8ba[_0xdb94('0x1f')][_0xdb94('0x32')](_0xdb94('0x81'))){_0x215997['limit']=qs[_0xdb94('0x13')](_0x39b8ba['query'][_0xdb94('0x13')]);_0x215997['offset']=qs[_0xdb94('0x11')](_0x39b8ba[_0xdb94('0x1f')][_0xdb94('0x11')]);}_0x215997[_0xdb94('0x7e')]=qs[_0xdb94('0x7f')](_0x39b8ba[_0xdb94('0x1f')][_0xdb94('0x7f')]);_0x215997[_0xdb94('0x55')]=qs[_0xdb94('0x7a')](_[_0xdb94('0x98')](_0x39b8ba['query'],_0x269cd4[_0xdb94('0x7a')]));_0x215997[_0xdb94('0x55')][_0xdb94('0x99')]=_0x23f35e['id'];if(_0x39b8ba[_0xdb94('0x1f')][_0xdb94('0x80')]){_0x215997[_0xdb94('0x55')]=_[_0xdb94('0x33')](_0x215997[_0xdb94('0x55')],{'$or':_[_0xdb94('0x69')](_0x215997[_0xdb94('0x7b')],function(_0x350bf8){var _0x45821f={};_0x45821f[_0x350bf8]={'$like':'%'+_0x39b8ba[_0xdb94('0x1f')][_0xdb94('0x80')]+'%'};return _0x45821f;})});}_0x215997=_[_0xdb94('0x33')]({},_0x215997,_0x39b8ba[_0xdb94('0x9a')]);return db[_0xdb94('0x8b')][_0xdb94('0x14')]({'where':_0x215997['where']})[_0xdb94('0x18')](function(_0x5015f){_0x48c9da[_0xdb94('0x14')]=_0x5015f;if(_0x39b8ba[_0xdb94('0x1f')]['includeAll']){_0x215997[_0xdb94('0x9b')]=[{'all':!![]}];}return db[_0xdb94('0x8b')][_0xdb94('0x1e')](_0x215997);})[_0xdb94('0x18')](function(_0xc08a68){_0x48c9da[_0xdb94('0x9c')]=_0xc08a68;return _0x48c9da;});}})['then'](respondWithFilteredResult(_0x210343,_0x215997))[_0xdb94('0x20')](handleError(_0x210343,null));};exports[_0xdb94('0x9d')]=function(_0x2e04e3,_0xbe8234){var _0x350761={'raw':!![],'where':{}};var _0x4081a1={};var _0x195c90={'count':0x0,'rows':[]};return db[_0xdb94('0x23')][_0xdb94('0x76')]({'where':{'id':_0x2e04e3[_0xdb94('0x21')]['id']}})[_0xdb94('0x18')](handleEntityNotFound(_0xbe8234,null))['then'](function(_0x1a13b9){if(_0x1a13b9){_0x4081a1['model']=_['keys'](db[_0xdb94('0x46')][_0xdb94('0x79')]);_0x4081a1[_0xdb94('0x1f')]=_[_0xdb94('0x25')](_0x2e04e3[_0xdb94('0x1f')]);_0x4081a1[_0xdb94('0x7a')]=_['intersection'](_0x4081a1[_0xdb94('0x77')],_0x4081a1[_0xdb94('0x1f')]);_0x350761[_0xdb94('0x7b')]=_[_0xdb94('0x7c')](_0x4081a1[_0xdb94('0x77')],qs[_0xdb94('0x7d')](_0x2e04e3['query'][_0xdb94('0x7d')]));_0x350761[_0xdb94('0x7b')]=_0x350761[_0xdb94('0x7b')][_0xdb94('0x26')]?_0x350761[_0xdb94('0x7b')]:_0x4081a1[_0xdb94('0x77')];if(!_0x2e04e3[_0xdb94('0x1f')]['hasOwnProperty'](_0xdb94('0x81'))){_0x350761[_0xdb94('0x13')]=qs[_0xdb94('0x13')](_0x2e04e3[_0xdb94('0x1f')][_0xdb94('0x13')]);_0x350761[_0xdb94('0x11')]=qs[_0xdb94('0x11')](_0x2e04e3[_0xdb94('0x1f')][_0xdb94('0x11')]);}_0x350761['order']=qs[_0xdb94('0x7f')](_0x2e04e3[_0xdb94('0x1f')][_0xdb94('0x7f')]);_0x350761[_0xdb94('0x55')]=qs[_0xdb94('0x7a')](_['pick'](_0x2e04e3[_0xdb94('0x1f')],_0x4081a1['filters']));_0x350761[_0xdb94('0x55')]['ContactId']=_0x1a13b9['id'];if(_0x2e04e3[_0xdb94('0x1f')][_0xdb94('0x80')]){_0x350761['where']=_['merge'](_0x350761[_0xdb94('0x55')],{'$or':_[_0xdb94('0x69')](_0x350761[_0xdb94('0x7b')],function(_0x13b8fa){var _0x477a63={};_0x477a63[_0x13b8fa]={'$like':'%'+_0x2e04e3[_0xdb94('0x1f')]['filter']+'%'};return _0x477a63;})});}_0x350761=_[_0xdb94('0x33')]({},_0x350761,_0x2e04e3['options']);return db[_0xdb94('0x46')][_0xdb94('0x14')]({'where':_0x350761[_0xdb94('0x55')]})[_0xdb94('0x18')](function(_0x4f4109){_0x195c90[_0xdb94('0x14')]=_0x4f4109;if(_0x2e04e3[_0xdb94('0x1f')][_0xdb94('0x9e')]){_0x350761[_0xdb94('0x9b')]=[{'all':!![]}];}return db[_0xdb94('0x46')][_0xdb94('0x1e')](_0x350761);})[_0xdb94('0x18')](function(_0x791e36){_0x195c90[_0xdb94('0x9c')]=_0x791e36;return _0x195c90;});}})[_0xdb94('0x18')](respondWithFilteredResult(_0xbe8234,_0x350761))[_0xdb94('0x20')](handleError(_0xbe8234,null));};exports[_0xdb94('0x9f')]=function(_0x243de5,_0x14d124){var _0x40d014={'raw':!![],'where':{}};var _0x4ece04={};var _0x40054e={'count':0x0,'rows':[]};return db[_0xdb94('0x23')][_0xdb94('0x76')]({'where':{'id':_0x243de5[_0xdb94('0x21')]['id']}})[_0xdb94('0x18')](handleEntityNotFound(_0x14d124,null))[_0xdb94('0x18')](function(_0x4818f7){if(_0x4818f7){_0x4ece04[_0xdb94('0x77')]=_[_0xdb94('0x25')](db[_0xdb94('0x45')][_0xdb94('0x79')]);_0x4ece04['query']=_[_0xdb94('0x25')](_0x243de5[_0xdb94('0x1f')]);_0x4ece04[_0xdb94('0x7a')]=_[_0xdb94('0x7c')](_0x4ece04[_0xdb94('0x77')],_0x4ece04['query']);_0x40d014[_0xdb94('0x7b')]=_[_0xdb94('0x7c')](_0x4ece04[_0xdb94('0x77')],qs['fields'](_0x243de5[_0xdb94('0x1f')][_0xdb94('0x7d')]));_0x40d014[_0xdb94('0x7b')]=_0x40d014['attributes']['length']?_0x40d014['attributes']:_0x4ece04[_0xdb94('0x77')];if(!_0x243de5['query'][_0xdb94('0x32')](_0xdb94('0x81'))){_0x40d014['limit']=qs[_0xdb94('0x13')](_0x243de5[_0xdb94('0x1f')][_0xdb94('0x13')]);_0x40d014['offset']=qs['offset'](_0x243de5[_0xdb94('0x1f')][_0xdb94('0x11')]);}_0x40d014[_0xdb94('0x7e')]=qs['sort'](_0x243de5[_0xdb94('0x1f')][_0xdb94('0x7f')]);_0x40d014['where']=qs[_0xdb94('0x7a')](_[_0xdb94('0x98')](_0x243de5[_0xdb94('0x1f')],_0x4ece04['filters']));_0x40d014[_0xdb94('0x55')][_0xdb94('0x99')]=_0x4818f7['id'];if(_0x243de5[_0xdb94('0x1f')][_0xdb94('0x80')]){_0x40d014[_0xdb94('0x55')]=_[_0xdb94('0x33')](_0x40d014['where'],{'$or':_[_0xdb94('0x69')](_0x40d014[_0xdb94('0x7b')],function(_0x1f5328){var _0x5be65c={};_0x5be65c[_0x1f5328]={'$like':'%'+_0x243de5[_0xdb94('0x1f')][_0xdb94('0x80')]+'%'};return _0x5be65c;})});}_0x40d014=_[_0xdb94('0x33')]({},_0x40d014,_0x243de5[_0xdb94('0x9a')]);return db[_0xdb94('0x45')][_0xdb94('0x14')]({'where':_0x40d014[_0xdb94('0x55')]})['then'](function(_0x2f53d3){_0x40054e[_0xdb94('0x14')]=_0x2f53d3;if(_0x243de5['query']['includeAll']){_0x40d014['include']=[{'all':!![]}];}return db[_0xdb94('0x45')][_0xdb94('0x1e')](_0x40d014);})[_0xdb94('0x18')](function(_0x564abf){_0x40054e[_0xdb94('0x9c')]=_0x564abf;return _0x40054e;});}})[_0xdb94('0x18')](respondWithFilteredResult(_0x14d124,_0x40d014))[_0xdb94('0x20')](handleError(_0x14d124,null));};exports['getJscriptySessions']=function(_0x117e9f,_0xfb2007){var _0x2fea6d={'raw':!![],'where':{}};var _0x480790={};var _0x3c48f4={'count':0x0,'rows':[]};return db[_0xdb94('0x23')][_0xdb94('0x76')]({'where':{'id':_0x117e9f['params']['id']}})[_0xdb94('0x18')](handleEntityNotFound(_0xfb2007,null))['then'](function(_0x51d1ed){if(_0x51d1ed){_0x480790['model']=_['keys'](db[_0xdb94('0x4a')][_0xdb94('0x79')]);_0x480790[_0xdb94('0x1f')]=_[_0xdb94('0x25')](_0x117e9f[_0xdb94('0x1f')]);_0x480790[_0xdb94('0x7a')]=_[_0xdb94('0x7c')](_0x480790[_0xdb94('0x77')],_0x480790[_0xdb94('0x1f')]);_0x2fea6d['attributes']=_[_0xdb94('0x7c')](_0x480790['model'],qs[_0xdb94('0x7d')](_0x117e9f[_0xdb94('0x1f')][_0xdb94('0x7d')]));_0x2fea6d[_0xdb94('0x7b')]=_0x2fea6d[_0xdb94('0x7b')][_0xdb94('0x26')]?_0x2fea6d['attributes']:_0x480790['model'];if(!_0x117e9f[_0xdb94('0x1f')][_0xdb94('0x32')](_0xdb94('0x81'))){_0x2fea6d[_0xdb94('0x13')]=qs[_0xdb94('0x13')](_0x117e9f[_0xdb94('0x1f')]['limit']);_0x2fea6d[_0xdb94('0x11')]=qs[_0xdb94('0x11')](_0x117e9f[_0xdb94('0x1f')][_0xdb94('0x11')]);}_0x2fea6d[_0xdb94('0x7e')]=qs[_0xdb94('0x7f')](_0x117e9f['query'][_0xdb94('0x7f')]);_0x2fea6d[_0xdb94('0x55')]=qs[_0xdb94('0x7a')](_[_0xdb94('0x98')](_0x117e9f[_0xdb94('0x1f')],_0x480790[_0xdb94('0x7a')]));_0x2fea6d['where'][_0xdb94('0x99')]=_0x51d1ed['id'];if(_0x117e9f[_0xdb94('0x1f')][_0xdb94('0x80')]){_0x2fea6d[_0xdb94('0x55')]=_[_0xdb94('0x33')](_0x2fea6d[_0xdb94('0x55')],{'$or':_[_0xdb94('0x69')](_0x2fea6d['attributes'],function(_0x17f28c){var _0x32e32a={};_0x32e32a[_0x17f28c]={'$like':'%'+_0x117e9f[_0xdb94('0x1f')][_0xdb94('0x80')]+'%'};return _0x32e32a;})});}_0x2fea6d=_[_0xdb94('0x33')]({},_0x2fea6d,_0x117e9f[_0xdb94('0x9a')]);return db[_0xdb94('0x4a')][_0xdb94('0x14')]({'where':_0x2fea6d[_0xdb94('0x55')]})[_0xdb94('0x18')](function(_0x55d3ab){_0x3c48f4[_0xdb94('0x14')]=_0x55d3ab;if(_0x117e9f[_0xdb94('0x1f')][_0xdb94('0x9e')]){_0x2fea6d[_0xdb94('0x9b')]=[{'all':!![]}];}return db['JscriptySessionReport'][_0xdb94('0x1e')](_0x2fea6d);})['then'](function(_0x160178){_0x3c48f4['rows']=_0x160178;return _0x3c48f4;});}})[_0xdb94('0x18')](respondWithFilteredResult(_0xfb2007,_0x2fea6d))[_0xdb94('0x20')](handleError(_0xfb2007,null));};exports[_0xdb94('0xa0')]=function(_0x46661c,_0x30f04c){try{if(!_0x46661c[_0xdb94('0x34')][_0xdb94('0x58')]){throw new Error('No\x20ListId\x20specified');}if(!_0x46661c[_0xdb94('0x34')][_0xdb94('0xa1')]){throw new Error('No\x20association\x20keys\x20specified!');}if(!_0x46661c[_0xdb94('0x34')][_0xdb94('0xa2')]){throw new Error(_0xdb94('0xa3'));}if(!_0x46661c[_0xdb94('0x34')][_0xdb94('0xa4')]){throw new Error(_0xdb94('0xa5'));}var _0x20d0b0=_0x46661c['body'][_0xdb94('0xa1')][_0xdb94('0xa6')](',');var _0x4ce05e=_0x46661c[_0xdb94('0x34')][_0xdb94('0xa2')][_0xdb94('0xa6')](',');if(!_0x20d0b0[_0xdb94('0x26')]||!_0x4ce05e['length']||_0x20d0b0[_0xdb94('0x26')]!==_0x4ce05e[_0xdb94('0x26')]){throw new Error(_0xdb94('0xa7'));}_0x46661c[_0xdb94('0x34')]['fields']=_['zipObject'](_0x20d0b0,_0x4ce05e);if(!_0x46661c[_0xdb94('0x34')][_0xdb94('0x7d')][_0xdb94('0x74')]){throw new Error(_0xdb94('0xa8'));}if(!_0x46661c[_0xdb94('0x34')][_0xdb94('0x7d')][_0xdb94('0xa9')]){throw new Error(_0xdb94('0xaa'));}var _0x3c5db9=path[_0xdb94('0x38')](config[_0xdb94('0xab')],_0xdb94('0xac'),_0x46661c[_0xdb94('0xad')]['filename']);fs['chmodSync'](_0x3c5db9,parseInt('0777',0x8));var _0xe04dea=require(_0xdb94('0xae'))[_0xdb94('0xaf')](path['join'](__dirname,_0xdb94('0xb0')),[_0x3c5db9,_0x46661c[_0xdb94('0x34')][_0xdb94('0xa1')],_0x46661c[_0xdb94('0x34')][_0xdb94('0xa2')],_0x46661c['body'][_0xdb94('0x58')],_0x46661c['body'][_0xdb94('0xb1')],_0x46661c['body'][_0xdb94('0x54')],_0x46661c[_0xdb94('0x34')][_0xdb94('0xa4')]]);return _0x30f04c[_0xdb94('0xf')](0xc8)['json']({'message':_0xdb94('0xb2'),'pid':_0xe04dea[_0xdb94('0xb3')]});}catch(_0x40d6fd){return _0x30f04c[_0xdb94('0xf')](0x1f4)['send'](_0x40d6fd);}};exports[_0xdb94('0xb4')]=function(_0x357a12,_0x2b3d3f){var _0x1b8197=fs['createReadStream'](_0x357a12[_0xdb94('0xad')]['path']);Papa['parse'](_0x1b8197,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x5824cc){return _0x2b3d3f['status'](0xc8)[_0xdb94('0x10')]({'file':_0x357a12[_0xdb94('0xad')],'fields':_0x5824cc[_0xdb94('0xb5')]['fields']});}});};exports[_0xdb94('0xb6')]=function(_0x2cfab7,_0x497cf6){return db[_0xdb94('0xb7')][_0xdb94('0x1e')]({'raw':!![],'attributes':['id'],'where':{'role':_0xdb94('0xb8')}})[_0xdb94('0x18')](function(_0x2bb0d8){var _0x431f29=![];if(!_0x2cfab7[_0xdb94('0x34')][_0xdb94('0x58')]){throw new Error(_0xdb94('0xb9'));}if(!_0x2cfab7[_0xdb94('0x34')]['binding'][_0xdb94('0x74')]){throw new Error('No\x20phone\x20column\x20specified');}if(!_0x2cfab7[_0xdb94('0x34')][_0xdb94('0xba')][_0xdb94('0xa9')]){throw new Error(_0xdb94('0xaa'));}if(!_0x2cfab7['body'][_0xdb94('0xa4')]){throw new Error(_0xdb94('0xa5'));}var _0x3676ba=require(_0xdb94('0xae'))[_0xdb94('0xaf')](path[_0xdb94('0x38')](__dirname,_0xdb94('0xbb')),[_0x2cfab7[_0xdb94('0x21')]['id'],JSON['stringify'](_0x2cfab7[_0xdb94('0x34')]),JSON[_0xdb94('0xbc')](_0x2bb0d8)]);_0x3676ba['on'](_0xdb94('0xbd'),function(){_0x431f29=!![];return _0x497cf6[_0xdb94('0xf')](0xc8)[_0xdb94('0x10')]({'message':'start\x20child\x20process\x20correctly!','pid':_0x3676ba[_0xdb94('0xb3')]});});_0x3676ba['on'](_0xdb94('0xbe'),function(_0x2fb36c){if(_0x2fb36c&&!_0x431f29){return _0x497cf6[_0xdb94('0xf')](0x1f4)[_0xdb94('0x10')]({'message':_0xdb94('0xbf'),'pid':_0x3676ba['pid']});}});})[_0xdb94('0x20')](handleError(_0x497cf6,null));};exports[_0xdb94('0xc0')]=function(_0x39f7f6,_0x1ae6f4){return db['User']['findAll']({'raw':!![],'attributes':['id'],'where':{'role':_0xdb94('0xb8')}})[_0xdb94('0x18')](function(_0x30363f){var _0x5545cd=![];if(!_0x39f7f6['body'][_0xdb94('0x58')]){throw new Error(_0xdb94('0xb9'));}if(!_0x39f7f6[_0xdb94('0x34')][_0xdb94('0xba')][_0xdb94('0x74')]){throw new Error('No\x20phone\x20column\x20specified');}if(!_0x39f7f6[_0xdb94('0x34')][_0xdb94('0xba')][_0xdb94('0xa9')]){throw new Error(_0xdb94('0xaa'));}if(!_0x39f7f6[_0xdb94('0x34')][_0xdb94('0xa4')]){throw new Error(_0xdb94('0xa5'));}var _0x44bbf2=require(_0xdb94('0xae'))[_0xdb94('0xaf')](path[_0xdb94('0x38')](__dirname,_0xdb94('0xc1')),[_0x39f7f6[_0xdb94('0x21')]['id'],JSON[_0xdb94('0xbc')](_0x39f7f6[_0xdb94('0x34')]),JSON['stringify'](_0x30363f)]);_0x44bbf2['on'](_0xdb94('0xbd'),function(){_0x5545cd=!![];return _0x1ae6f4['status'](0xc8)[_0xdb94('0x10')]({'message':'start\x20child\x20process\x20correctly!','pid':_0x44bbf2[_0xdb94('0xb3')]});});_0x44bbf2['on'](_0xdb94('0xbe'),function(_0x4dc8a8){if(_0x4dc8a8&&!_0x5545cd){return _0x1ae6f4[_0xdb94('0xf')](0x1f4)[_0xdb94('0x10')]({'message':_0xdb94('0xbf'),'pid':_0x44bbf2[_0xdb94('0xb3')]});}});})[_0xdb94('0x20')](handleError(_0x1ae6f4,null));};exports[_0xdb94('0xc2')]=function(_0x1f1ea3,_0x2128f6){var _0x13e689=['mail',_0xdb94('0xc3'),'sms',_0xdb94('0xc4'),_0xdb94('0xc5'),'whatsapp',_0xdb94('0xc6')];var _0x6e0474={'offset':0x0,'order':qs['sort'](_0xdb94('0xc7'))},_0x265782={'count':0x0,'rows':[]};Promise[_0xdb94('0xc8')]()[_0xdb94('0x18')](function(){if(_0x1f1ea3[_0xdb94('0x1f')]['channel']){if(!_[_0xdb94('0xc9')](_0x13e689,_0x1f1ea3[_0xdb94('0x1f')][_0xdb94('0xca')][_0xdb94('0xcb')]())){throw new Error(_0xdb94('0xcc'));}_0x13e689=[_0x1f1ea3[_0xdb94('0x1f')][_0xdb94('0xca')][_0xdb94('0xcb')]()];}if(_0x1f1ea3[_0xdb94('0x1f')]['range']){try{var _0x4042e2=JSON['parse'](_0x1f1ea3[_0xdb94('0x1f')][_0xdb94('0xcd')]);if(!moment(_0x4042e2['from'])[_0xdb94('0xce')]()){throw new Error(_0xdb94('0xcf'));}if(!moment(_0x4042e2['to'])['isValid']()){throw new Error('Invalid\x20date\x20for\x20range\x20to\x20filter');}}catch(_0x5f599f){throw new Error(_0xdb94('0xd0'));}}if(!_0x1f1ea3[_0xdb94('0x1f')][_0xdb94('0x32')](_0xdb94('0x81'))){_0x6e0474[_0xdb94('0x13')]=qs[_0xdb94('0x13')](_0x1f1ea3[_0xdb94('0x1f')][_0xdb94('0x13')]||0xa);_0x6e0474[_0xdb94('0x11')]=qs[_0xdb94('0x11')](_0x1f1ea3[_0xdb94('0x1f')][_0xdb94('0x11')]);}var _0x254fb0=_0x13e689[_0xdb94('0x69')](function(_0x28c17c){if(_0x28c17c===_0xdb94('0xc6')){var _0x2b5eb1={'attributes':['id',_0xdb94('0xd1'),_0xdb94('0x2d'),_0xdb94('0xd2'),_0xdb94('0xd3'),_0xdb94('0xd4'),_0xdb94('0xd5'),_0xdb94('0xd6'),_0xdb94('0xd7'),_0xdb94('0xd8'),_0xdb94('0xd9'),_0xdb94('0xda'),_0xdb94('0xdb'),_0xdb94('0xdc'),'UserId'],'where':{'ContactId':_0x1f1ea3[_0xdb94('0x21')]['id']},'include':[{'model':db[_0xdb94('0xb7')],'as':'User','attributes':['id','name','fullname',_0xdb94('0x2c')]}],'order':[[_0xdb94('0xd9'),'DESC']]};if(_0x1f1ea3[_0xdb94('0x1f')]['range']){_0x2b5eb1['where'][_0xdb94('0xd9')]={'$gte':_0x4042e2['from'],'$lte':_0x4042e2['to']};}return db[_0xdb94('0xdd')][_0xdb94('0xde')](_0x2b5eb1)[_0xdb94('0x18')](function(_0x3aee7c){_0x265782['count']+=_0x3aee7c[_0xdb94('0x14')];return _[_0xdb94('0x69')](_0x3aee7c['rows'],function(_0x336902){var _0x4c8e62=_0x336902[_0xdb94('0x35')]({'plain':!![]});_0x4c8e62['channel']=_0x28c17c;if(_0x4c8e62[_0xdb94('0xb7')]){_0x4c8e62[_0xdb94('0xb7')]={'id':_0x4c8e62[_0xdb94('0xb7')]['id'],'name':_0x4c8e62[_0xdb94('0xb7')]['name'],'fullname':_0x4c8e62[_0xdb94('0xb7')]['fullname'],'alias':_0x4c8e62['User'][_0xdb94('0x2c')]};}return _0x4c8e62;});});}else{var _0x2fd3cf=_[_0xdb94('0xdf')](_0x28c17c)+(_0x28c17c===_0xdb94('0xc3')?_0xdb94('0xe0'):'Account');var _0x597af9={'attributes':['id',_0xdb94('0xe1'),_0xdb94('0xe2'),_0xdb94('0xd9'),_0xdb94('0xd8'),_0xdb94('0xe3'),_0xdb94('0xe4'),_0xdb94('0xe5'),_0xdb94('0xe6'),_0x2fd3cf+'Id'],'where':{'ContactId':_0x1f1ea3[_0xdb94('0x21')]['id']},'include':[{'model':db[_0x2fd3cf],'as':_0xdb94('0xe7'),'attributes':['id',_0xdb94('0x60'),_0xdb94('0xe8')]},{'model':db[_0xdb94('0xb7')],'as':_0xdb94('0xe9'),'attributes':['id','name','fullname']},{'model':db['Tag'],'as':'Tags','attributes':['id','name',_0xdb94('0xea')],'through':{'attributes':[]}}],'order':[[_0xdb94('0xd9'),_0xdb94('0xeb')]]};if(_0x1f1ea3[_0xdb94('0x1f')]['range']){_0x597af9[_0xdb94('0x55')][_0xdb94('0xd9')]={'$gte':_0x4042e2[_0xdb94('0x39')],'$lte':_0x4042e2['to']};}switch(_0x28c17c){case _0xdb94('0xc3'):_0x597af9[_0xdb94('0x7b')]['push'](_0xdb94('0xec'),_0xdb94('0xed'),_0xdb94('0xee'),_0xdb94('0xef'),'osName',_0xdb94('0xf0'),_0xdb94('0xf1'),'ratingValue','referer');break;case _0xdb94('0xf2'):_0x597af9[_0xdb94('0x7b')][_0xdb94('0x57')](_0xdb94('0xf3'),'substatus');break;case'openchannel':_0x597af9[_0xdb94('0x7b')]['push'](_0xdb94('0xf4'),_0xdb94('0xf5'));break;}return db[_[_0xdb94('0xdf')](_0x28c17c)+'Interaction'][_0xdb94('0xde')](_0x597af9)[_0xdb94('0x18')](function(_0x4ef47e){_0x265782['count']+=_0x4ef47e[_0xdb94('0x14')];return _[_0xdb94('0x69')](_0x4ef47e[_0xdb94('0x9c')],function(_0x303e39){var _0x114c1a=_0x303e39[_0xdb94('0x35')]({'plain':!![]});_0x114c1a[_0xdb94('0xca')]=_0x28c17c;if(_0x114c1a[_0xdb94('0xe9')]){_0x114c1a[_0xdb94('0xe9')]={'id':_0x114c1a[_0xdb94('0xe9')]['id'],'name':_0x114c1a[_0xdb94('0xe9')][_0xdb94('0x60')],'fullname':_0x114c1a[_0xdb94('0xe9')][_0xdb94('0xf6')]};}return _0x114c1a;});});}});return Promise['all'](_0x254fb0);})[_0xdb94('0x18')](function(_0x5220f8){return _(_0x5220f8)[_0xdb94('0xf7')]()[_0xdb94('0xf8')]('createdAt')['reverse']()[_0xdb94('0xf9')]();})[_0xdb94('0x18')](function(_0x19e647){_0x265782['rows']=_0x6e0474[_0xdb94('0x13')]?_0x19e647[_0xdb94('0xfa')](_0x6e0474[_0xdb94('0x11')],_0x6e0474[_0xdb94('0x11')]+_0x6e0474[_0xdb94('0x13')]):_0x19e647;return _0x265782;})[_0xdb94('0x18')](respondWithFilteredResult(_0x2128f6,_0x6e0474))[_0xdb94('0x20')](handleError(_0x2128f6,null));};
\ No newline at end of file