Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / cmContact / cmContact.controller.js
index 20a3481..e11f43e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa9e0=['id\x20=\x20?','toParam','values','CmHopper','phone','getTags','findOne','rawAttributes','options','nolimit','setTags','ids','getHoppers','ContactId','includeAll','getHopperHistories','include','getHopperFinals','getJscriptySessions','uploadCsv','binding_keys','No\x20association\x20keys\x20specified!','binding_values','No\x20association\x20values\x20specified!','Incorrect\x20binding\x20parameters\x20passed!','No\x20phone\x20column\x20specified','firstName','No\x20firstName\x20column\x20specified','server/files/tmp','filename','chmodSync','child_process','CompanyId','socket_timestamp','json','File\x20uploaded\x20correctly!','pid','upload','createReadStream','file','parse','meta','import','agent','No\x20ListId\x20specified','binding','Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed','fork','../../components/import/cm/csv2','stringify','message','start\x20child\x20process\x20correctly!','exit','error\x20child\x20process','html-pdf','eml-format','rimraf','request-promise','bluebird','mustache','util','path','sox','ejs','lodash','squel','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/license/util','../../mysqldb','redis','defaults','localhost','./cmContact.socket','register','status','count','offset','limit','set','Content-Range','update','destroy','then','sendStatus','stack','name','send','index','CmContact','describe','keys','length','startsWith','cf_','push','CmCustomField','trimStart','all','fieldType','type','model','filters','intersection','query','fields','attributes','hasOwnProperty','sort','where','pick','select','field','from','tools_tags','cm_contacts','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','expr','search','parseSearch','conditions','Tag','value','split','map','forEach','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','User','and','uc.UserId\x20=\x20?','dateOfBirth','datetime','DATE','start','end','isNil','Contact','ListId','c.ListId\x20IN\x20?','concat','\x20=\x20?','isArray','tag','filter','replace','\x27\x27\x27\x27','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?','isEmail','c.firstName\x20LIKE\x20?','group','Sequelize','QueryTypes','SELECT','clone','c.id','order','DESC','isEmpty','having','resolve','user','getLists','sequelize','toString','keyBy','merge','c.phone','c.mobile','c.fax','c.email','c.ListId','c.deletedAt','GROUP_CONCAT(DISTINCT\x20t.id)','TagIds','Tags','rows','catch','find','params','columnName','findAll','displayName','alias','body','get','mergeWith','tags','join','info','[CmContact][merge]\x20to\x20%s\x20from\x20%s','[CmContact][merge][destroy][CmHopper],\x20%s','[CmContact][merge][destroy][CmHopperBlack],\x20%s','create','ChatInteraction','ChatMessage','ChatOfflineMessage','MailInteraction','MailMessage','SmsInteraction','SmsMessage','FaxInteraction','FaxMessage','OpenchannelMessage','CmHopperFinal','CmHopperHistory','VoiceCallReport','FaxQueueReport','SmsQueueReport','JscriptySessionReport','bulkCreate','duplicates','$or','findOrCreate','spread','error','show','color','$and','omit','format','cf_%d','pickBy','setFields'];(function(_0x1078e7,_0x56c88e){var _0x1f3a1f=function(_0x3d95c4){while(--_0x3d95c4){_0x1078e7['push'](_0x1078e7['shift']());}};_0x1f3a1f(++_0x56c88e);}(_0xa9e0,0x123));var _0x0a9e=function(_0x4b7b62,_0x4920a9){_0x4b7b62=_0x4b7b62-0x0;var _0x2280df=_0xa9e0[_0x4b7b62];return _0x2280df;};'use strict';var pdf=require(_0x0a9e('0x0'));var emlformat=require(_0x0a9e('0x1'));var rimraf=require(_0x0a9e('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x0a9e('0x3'));var moment=require('moment');var BPromise=require(_0x0a9e('0x4'));var Mustache=require(_0x0a9e('0x5'));var util=require(_0x0a9e('0x6'));var path=require(_0x0a9e('0x7'));var sox=require(_0x0a9e('0x8'));var csv=require('to-csv');var ejs=require(_0x0a9e('0x9'));var fs=require('fs');var _=require(_0x0a9e('0xa'));var squel=require(_0x0a9e('0xb'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x0a9e('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x0a9e('0xd'));var Redis=require(_0x0a9e('0xe'));var authService=require(_0x0a9e('0xf'));var qs=require(_0x0a9e('0x10'));var as=require(_0x0a9e('0x11'));var hardwareService=require(_0x0a9e('0x12'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x0a9e('0x13'));var db=require(_0x0a9e('0x14'))['db'];config[_0x0a9e('0x15')]=_[_0x0a9e('0x16')](config[_0x0a9e('0x15')],{'host':_0x0a9e('0x17'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x0a9e('0x15')]));require(_0x0a9e('0x18'))[_0x0a9e('0x19')](socket);function respondWithStatusCode(_0x281129,_0x44dcfd){_0x44dcfd=_0x44dcfd||0xcc;return function(_0x4d5611){if(_0x4d5611){return _0x281129['sendStatus'](_0x44dcfd);}return _0x281129[_0x0a9e('0x1a')](_0x44dcfd)['end']();};}function respondWithResult(_0x1985b6,_0x519dfd){_0x519dfd=_0x519dfd||0xc8;return function(_0x16033c){if(_0x16033c){return _0x1985b6[_0x0a9e('0x1a')](_0x519dfd)['json'](_0x16033c);}};}function respondWithFilteredResult(_0x225616,_0x5a0a06){return function(_0x459eb1){if(_0x459eb1){var _0x478723=_0x459eb1[_0x0a9e('0x1b')],_0x106033=_0x5a0a06[_0x0a9e('0x1c')],_0x205fd6=_0x5a0a06[_0x0a9e('0x1c')]+_0x5a0a06[_0x0a9e('0x1d')],_0x31b1ca;if(_0x205fd6>=_0x478723){_0x205fd6=_0x478723;_0x31b1ca=0xc8;}else{_0x31b1ca=0xce;}_0x225616[_0x0a9e('0x1a')](_0x31b1ca);return _0x225616[_0x0a9e('0x1e')](_0x0a9e('0x1f'),_0x106033+'-'+_0x205fd6+'/'+_0x478723)['json'](_0x459eb1);}return null;};}function patchUpdates(_0x2c3407){return function(_0x155cce){try{jsonpatch['apply'](_0x155cce,_0x2c3407,!![]);}catch(_0x20f109){return BPromise['reject'](_0x20f109);}return _0x155cce['save']();};}function saveUpdates(_0x3a02e1,_0x432e56){return function(_0x38e7c4){if(_0x38e7c4){return _0x38e7c4[_0x0a9e('0x20')](_0x3a02e1)['then'](function(_0xfb6e48){return _0xfb6e48;});}return null;};}function removeEntity(_0x2fb0e4,_0x3b45bc){return function(_0x4d00e6){if(_0x4d00e6){return _0x4d00e6[_0x0a9e('0x21')]()[_0x0a9e('0x22')](function(){_0x2fb0e4[_0x0a9e('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x59181e,_0x197ec0){return function(_0x3a8e58){if(!_0x3a8e58){_0x59181e[_0x0a9e('0x23')](0x194);}return _0x3a8e58;};}function handleError(_0x33161b,_0x526cf3){_0x526cf3=_0x526cf3||0x1f4;return function(_0x384319){logger['error'](_0x384319[_0x0a9e('0x24')]);if(_0x384319['name']){delete _0x384319[_0x0a9e('0x25')];}_0x33161b[_0x0a9e('0x1a')](_0x526cf3)[_0x0a9e('0x26')](_0x384319);};}exports[_0x0a9e('0x27')]=function(_0x140511,_0x1538a4){var _0x11c3b6={},_0x14de77={},_0x5a101a={'count':0x0,'rows':[]};return db[_0x0a9e('0x28')][_0x0a9e('0x29')]()[_0x0a9e('0x22')](function(_0x2ec755){var _0x5c877d=[];for(var _0x15b200=0x0;_0x15b200<Object[_0x0a9e('0x2a')](_0x2ec755)[_0x0a9e('0x2b')];_0x15b200++){var _0x824a4f=Object[_0x0a9e('0x2a')](_0x2ec755)[_0x15b200];if(_[_0x0a9e('0x2c')](_0x824a4f,_0x0a9e('0x2d'))){_0x5c877d[_0x0a9e('0x2e')](db[_0x0a9e('0x2f')]['findOne']({'where':{'id':_[_0x0a9e('0x30')](_0x824a4f,'cf_')},'raw':!![]}));}}return BPromise[_0x0a9e('0x31')](_0x5c877d)[_0x0a9e('0x22')](function(_0x1122db){for(var _0x33bdb7=0x0;_0x33bdb7<_0x1122db[_0x0a9e('0x2b')];_0x33bdb7++){if(_0x1122db[_0x33bdb7]){var _0x5180f1=_0x0a9e('0x2d')+_0x1122db[_0x33bdb7]['id'];var _0x46f0a5=_0x2ec755[_0x5180f1];_0x46f0a5[_0x0a9e('0x32')]=_0x1122db[_0x33bdb7][_0x0a9e('0x33')];}}return _0x2ec755;});})[_0x0a9e('0x22')](function(_0x409319){_0x14de77[_0x0a9e('0x34')]=_[_0x0a9e('0x2a')](_0x409319);_0x14de77['query']=_[_0x0a9e('0x2a')](_0x140511['query']);_0x14de77[_0x0a9e('0x35')]=_[_0x0a9e('0x36')](_0x14de77[_0x0a9e('0x34')],_0x14de77[_0x0a9e('0x37')]);_0x11c3b6['attributes']=_[_0x0a9e('0x36')](_0x14de77[_0x0a9e('0x34')],qs[_0x0a9e('0x38')](_0x140511[_0x0a9e('0x37')]['fields']));_0x11c3b6['attributes']=_0x11c3b6[_0x0a9e('0x39')]['length']?_0x11c3b6[_0x0a9e('0x39')]:_0x14de77[_0x0a9e('0x34')];if(!_0x140511[_0x0a9e('0x37')][_0x0a9e('0x3a')]('nolimit')){_0x11c3b6[_0x0a9e('0x1d')]=qs[_0x0a9e('0x1d')](_0x140511[_0x0a9e('0x37')]['limit']);_0x11c3b6[_0x0a9e('0x1c')]=qs[_0x0a9e('0x1c')](_0x140511[_0x0a9e('0x37')]['offset']);}_0x11c3b6['order']=qs[_0x0a9e('0x3b')](_0x140511[_0x0a9e('0x37')]['sort']);_0x11c3b6[_0x0a9e('0x3c')]=qs[_0x0a9e('0x35')](_[_0x0a9e('0x3d')](_0x140511[_0x0a9e('0x37')],_0x14de77['filters']),_0x409319);var _0x5a594b=[];var _0x15e37d=squel[_0x0a9e('0x3e')]()['field']('id')[_0x0a9e('0x3f')](_0x0a9e('0x25'))[_0x0a9e('0x3f')]('color')[_0x0a9e('0x40')](_0x0a9e('0x41'));var _0x274e8e=squel[_0x0a9e('0x3e')]()[_0x0a9e('0x40')](_0x0a9e('0x42'),'c')[_0x0a9e('0x43')](_0x0a9e('0x44'),'uc',_0x0a9e('0x45'))[_0x0a9e('0x43')](_0x0a9e('0x46'),'ct',_0x0a9e('0x47'))[_0x0a9e('0x43')](_0x0a9e('0x41'),'t',_0x0a9e('0x48'))['where']('c.deletedAt\x20IS\x20NULL');var _0x473fdc=squel[_0x0a9e('0x49')]();var _0x405c8f=[];var _0x315881=squel[_0x0a9e('0x49')]();var _0xc9a702;if(_0x140511[_0x0a9e('0x37')][_0x0a9e('0x4a')]){_0xc9a702=as[_0x0a9e('0x4b')](_0x140511[_0x0a9e('0x37')][_0x0a9e('0x4a')]);var _0x35ed4a=_0xc9a702['sqlOperator'];for(var _0x117c99=0x0;_0x117c99<_0xc9a702[_0x0a9e('0x4c')][_0x0a9e('0x2b')];_0x117c99++){var _0xfbd5ad=_0xc9a702[_0x0a9e('0x4c')][_0x117c99];var _0xbe9d19='c';var _0x21eb86=_(_0x409319)[_0x0a9e('0x2a')]()['find'](function(_0x2e9d90){return _0x2e9d90===_0xfbd5ad['field'];});if(_0x21eb86)_0x21eb86=_0x409319[_0xfbd5ad[_0x0a9e('0x3f')]];if(!_0x21eb86){if(_0xfbd5ad[_0x0a9e('0x3f')]===_0x0a9e('0x4d')){var _0x562fb4=_0xfbd5ad[_0x0a9e('0x4e')][_0x0a9e('0x4f')](',')[_0x0a9e('0x50')](function(_0x34aa5a){return Number(_0x34aa5a);});_0x562fb4[_0x0a9e('0x51')](function(_0x37be73){_0x315881['or'](_0x0a9e('0x52'),'%,'+_0x37be73+',%');});_0x405c8f=_['union'](_0x405c8f,_0x562fb4);}else if(_0xfbd5ad[_0x0a9e('0x3f')]===_0x0a9e('0x53')){_0x473fdc[_0x0a9e('0x54')](_0x0a9e('0x55'),_0xfbd5ad[_0x0a9e('0x4e')]);}}else{if(_0xfbd5ad[_0x0a9e('0x3f')]===_0x0a9e('0x56')||_0x21eb86[_0x0a9e('0x32')]===_0x0a9e('0x57'))_0xfbd5ad['castTo']=_0x0a9e('0x58');var _0x3fe430=as['buildExpression'](_0xbe9d19,_0x21eb86['type'],_0xfbd5ad);_0x473fdc[_0x35ed4a](_0x3fe430['text'],_0x3fe430[_0x0a9e('0x4e')][_0x0a9e('0x59')],_0x3fe430[_0x0a9e('0x4e')][_0x0a9e('0x5a')]);}}}else{var _0x61bb17=_(Object[_0x0a9e('0x2a')](_0x140511[_0x0a9e('0x37')]))[_0x0a9e('0x50')](function(_0x5d38ae){return _0x409319['hasOwnProperty'](_0x5d38ae)?_0x5d38ae:undefined;})['filter'](function(_0x39d77d){return!_[_0x0a9e('0x5b')](_0x39d77d);})[_0x0a9e('0x4e')]();if(_0x140511['query'][_0x0a9e('0x5c')])_0x61bb17[_0x0a9e('0x2e')]('Contact');if(!_['isEmpty'](_0x61bb17)){_0x61bb17[_0x0a9e('0x51')](function(_0x59c6ff){if(_0x59c6ff===_0x0a9e('0x5d')){_0x274e8e['where'](_0x0a9e('0x5e'),[][_0x0a9e('0x5f')](_0x140511[_0x0a9e('0x37')][_0x59c6ff]));}else if(_0x59c6ff==='Contact'){var _0x2f82da='%'+_0x140511[_0x0a9e('0x37')][_0x59c6ff]+'%';_0x274e8e['where']('CONCAT_WS(\x27\x20\x27,\x20c.firstName,\x20c.lastName,\x20c.email)\x20LIKE\x20?',_0x2f82da);}else{_0x274e8e[_0x0a9e('0x3c')]('c.'+_0x59c6ff+_0x0a9e('0x60'),_0x140511['query'][_0x59c6ff]);}});}if(_0x140511[_0x0a9e('0x37')]['tag']){_0x405c8f=_[_0x0a9e('0x61')](_0x140511['query'][_0x0a9e('0x62')])?_0x140511['query']['tag']:new Array(_0x140511['query'][_0x0a9e('0x62')]);_0x405c8f['forEach'](function(_0x2f7092){_0x315881['or'](_0x0a9e('0x52'),'%,'+_0x2f7092+',%');});}if(_0x140511[_0x0a9e('0x37')][_0x0a9e('0x63')]){var _0x232830=_0x140511[_0x0a9e('0x37')][_0x0a9e('0x63')][_0x0a9e('0x64')]('\x5c','\x5c\x5c')['replace']('\x27\x27',_0x0a9e('0x65'));if(_0x232830[_0x0a9e('0x4f')]('\x20')[_0x0a9e('0x2b')]>0x1){_0x473fdc['or'](_0x0a9e('0x66'),qs[_0x0a9e('0x67')](_0x232830),null);}else{if(qs[_0x0a9e('0x68')](_0x232830)){_0x473fdc['or']('c.id\x20LIKE\x20?',_0x232830+'%');_0x473fdc['or'](_0x0a9e('0x69'),_0x232830+'%');_0x473fdc['or'](_0x0a9e('0x6a'),_0x232830+'%');_0x473fdc['or']('c.fax\x20LIKE\x20?',_0x232830+'%');}else if(qs[_0x0a9e('0x6b')](_0x232830)){_0x473fdc['or']('c.email\x20LIKE\x20?',_0x232830+'%');}else{_0x473fdc['or'](_0x0a9e('0x6c'),'%'+_0x232830+'%');_0x473fdc['or']('c.lastName\x20LIKE\x20?','%'+_0x232830+'%');_0x473fdc['or']('c.email\x20LIKE\x20?','%'+_0x232830+'%');}}}}_0x274e8e['where'](_0x473fdc);_0x274e8e[_0x0a9e('0x6d')]('c.id');var _0x2244d6={'type':db[_0x0a9e('0x6e')][_0x0a9e('0x6f')][_0x0a9e('0x70')],'raw':!![]};var _0x1cca9f=_0x274e8e[_0x0a9e('0x71')]()['field'](_0x0a9e('0x72'));if(_0x11c3b6['order']){_0x11c3b6[_0x0a9e('0x73')][_0x0a9e('0x51')](function(_0x51aaf7){_0x274e8e['order']('c.'+_0x51aaf7[0x0],_0x51aaf7[0x1]===_0x0a9e('0x74')?![]:!![]);});}if(!_[_0x0a9e('0x75')](_0x405c8f)){_0x274e8e[_0x0a9e('0x76')](_0x315881);_0x1cca9f[_0x0a9e('0x3c')]('t.id\x20IN\x20?',_0x405c8f);}BPromise[_0x0a9e('0x77')]()[_0x0a9e('0x22')](function(){if(_0xc9a702&&!_['some'](_0xc9a702[_0x0a9e('0x4c')],[_0x0a9e('0x3f'),_0x0a9e('0x53')])){return _0x140511[_0x0a9e('0x78')][_0x0a9e('0x79')]({'attributes':['id'],'raw':!![]})['then'](function(_0x176840){if(_[_0x0a9e('0x75')](_0x176840)){_0x1cca9f[_0x0a9e('0x3c')]('c.ListId\x20IS\x20NULL');_0x274e8e[_0x0a9e('0x3c')]('c.ListId\x20IS\x20NULL');}else{_0x1cca9f['where'](_0x0a9e('0x5e'),_[_0x0a9e('0x50')](_0x176840,'id'));_0x274e8e[_0x0a9e('0x3c')](_0x0a9e('0x5e'),_[_0x0a9e('0x50')](_0x176840,'id'));}});}else{return;}})[_0x0a9e('0x22')](function(){db[_0x0a9e('0x7a')][_0x0a9e('0x37')](_0x1cca9f[_0x0a9e('0x7b')](),_0x2244d6)[_0x0a9e('0x22')](function(_0x2e89b7){_0x5a101a[_0x0a9e('0x1b')]=_0x2e89b7[_0x0a9e('0x2b')];if(_0x5a101a[_0x0a9e('0x1b')]===0x0)return[];return db[_0x0a9e('0x7a')][_0x0a9e('0x37')](_0x15e37d[_0x0a9e('0x7b')](),_0x2244d6);})[_0x0a9e('0x22')](function(_0x5150a4){_0x5a594b=_[_0x0a9e('0x7c')](_0x5150a4,'id');_0x2244d6=_[_0x0a9e('0x7d')](_0x2244d6,{'model':db[_0x0a9e('0x28')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x140511['query'][_0x0a9e('0x38')]){_0x11c3b6[_0x0a9e('0x39')]['forEach'](function(_0x83f0b2){_0x274e8e[_0x0a9e('0x3f')]('c.'+_0x83f0b2);});}else{_0x274e8e[_0x0a9e('0x3f')](_0x0a9e('0x72'));_0x274e8e[_0x0a9e('0x3f')]('c.firstName');_0x274e8e['field']('c.lastName');_0x274e8e[_0x0a9e('0x3f')](_0x0a9e('0x7e'));_0x274e8e[_0x0a9e('0x3f')](_0x0a9e('0x7f'));_0x274e8e[_0x0a9e('0x3f')](_0x0a9e('0x80'));_0x274e8e[_0x0a9e('0x3f')](_0x0a9e('0x81'));_0x274e8e['field'](_0x0a9e('0x82'));_0x274e8e[_0x0a9e('0x3f')](_0x0a9e('0x83'));_0x274e8e['field'](_0x0a9e('0x84'),'TagIds');}if(_0x11c3b6[_0x0a9e('0x1d')])_0x274e8e[_0x0a9e('0x1d')](_0x11c3b6['limit']);if(_0x11c3b6[_0x0a9e('0x1c')])_0x274e8e[_0x0a9e('0x1c')](_0x11c3b6[_0x0a9e('0x1c')]);return db[_0x0a9e('0x7a')]['query'](_0x274e8e[_0x0a9e('0x7b')](),_0x2244d6);})[_0x0a9e('0x22')](function(_0x371533){_0x371533[_0x0a9e('0x51')](function(_0x5b7fc3){if(_0x5b7fc3[_0x0a9e('0x85')]){_0x5b7fc3[_0x0a9e('0x86')]=[];_0x5b7fc3[_0x0a9e('0x85')][_0x0a9e('0x4f')](',')['forEach'](function(_0x290d43){_0x5b7fc3[_0x0a9e('0x86')][_0x0a9e('0x2e')](_0x5a594b[_0x290d43]);});}delete _0x5b7fc3[_0x0a9e('0x85')];});_0x5a101a[_0x0a9e('0x87')]=_0x371533;return _0x5a101a;})[_0x0a9e('0x22')](respondWithFilteredResult(_0x1538a4,_0x11c3b6));});})[_0x0a9e('0x88')](handleError(_0x1538a4,null));};exports[_0x0a9e('0x21')]=function(_0x1a7b03,_0x336dc3){return db[_0x0a9e('0x28')][_0x0a9e('0x89')]({'where':{'id':_0x1a7b03[_0x0a9e('0x8a')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x336dc3,null))['then'](removeEntity(_0x336dc3,null))[_0x0a9e('0x88')](handleError(_0x336dc3,null));};exports[_0x0a9e('0x29')]=function(_0xc599b3,_0x563627){return db[_0x0a9e('0x28')][_0x0a9e('0x29')]()[_0x0a9e('0x22')](function(_0x2b9463){delete _0x2b9463['tags'];for(var _0x541e80=0x0;_0x541e80<Object[_0x0a9e('0x2a')](_0x2b9463)[_0x0a9e('0x2b')];_0x541e80++){var _0x4c54fa=Object[_0x0a9e('0x2a')](_0x2b9463)[_0x541e80];if(!_['startsWith'](_0x4c54fa,_0x0a9e('0x2d'))){_0x2b9463[_0x4c54fa][_0x0a9e('0x8b')]=_0x4c54fa;_0x2b9463[_0x4c54fa]['displayName']=_0x4c54fa;}}return _0x2b9463;})[_0x0a9e('0x22')](function(_0x41cf12){var _0x2d2286={'where':{'$or':[{'ListId':_0xc599b3[_0x0a9e('0x37')]['id']},{'ListId':null}]},'raw':!![]};return db[_0x0a9e('0x2f')][_0x0a9e('0x8c')](_0x2d2286)[_0x0a9e('0x22')](function(_0x482ca2){for(var _0x2973d3=0x0;_0x2973d3<_0x482ca2[_0x0a9e('0x2b')];_0x2973d3++){var _0x45c109=_0x0a9e('0x2d')+_0x482ca2[_0x2973d3]['id'];_0x41cf12[_0x45c109]['columnName']=_0x45c109;_0x41cf12[_0x45c109][_0x0a9e('0x8d')]=_0x482ca2[_0x2973d3][_0x0a9e('0x8e')];_0x41cf12[_0x45c109]['custom']={'type':_0x482ca2[_0x2973d3][_0x0a9e('0x33')],'values':_0x482ca2[_0x2973d3]['values']};}Object[_0x0a9e('0x2a')](_0x41cf12)[_0x0a9e('0x51')](function(_0x3003eb){if(!_0x41cf12[_0x3003eb][_0x0a9e('0x3a')]('columnName')){delete _0x41cf12[_0x3003eb];}});return _0x41cf12;});})['then'](respondWithResult(_0x563627,null))[_0x0a9e('0x88')](handleError(_0x563627,null));};exports[_0x0a9e('0x7d')]=function(_0x94dcf5,_0x5ac73d){var _0x3b4a9f;var _0x36e975;var _0x524e38;if(_0x94dcf5['body']['id']){delete _0x94dcf5[_0x0a9e('0x8f')]['id'];}return db['CmContact']['findAll']({'where':{'id':[_0x94dcf5['body']['to'],_0x94dcf5[_0x0a9e('0x8f')][_0x0a9e('0x40')]]}})[_0x0a9e('0x22')](function(_0x3bfadf){if(_0x3bfadf){if(_0x3bfadf[_0x0a9e('0x2b')]!==0x2){return null;}_0x3bfadf[0x0]=_0x3bfadf[0x0][_0x0a9e('0x90')]({'plain':!![]});_0x3bfadf[0x1]=_0x3bfadf[0x1]['get']({'plain':!![]});delete _0x3bfadf[0x0]['id'];delete _0x3bfadf[0x1]['id'];return _[_0x0a9e('0x91')](_0x3bfadf[0x0],_0x3bfadf[0x1],function(_0x5955f1,_0x2871c1){if(Array[_0x0a9e('0x61')](_0x2871c1)&&!_0x2871c1[_0x0a9e('0x2b')]){return _0x5955f1;}else if(!_0x2871c1){return _0x5955f1;}});}})[_0x0a9e('0x22')](handleEntityNotFound(_0x5ac73d,null))['then'](function(_0x46c9ac){if(_0x46c9ac){if(_0x46c9ac[_0x0a9e('0x92')]&&_[_0x0a9e('0x61')](_0x46c9ac['tags'])){_0x46c9ac[_0x0a9e('0x92')]=_0x46c9ac[_0x0a9e('0x92')][_0x0a9e('0x93')]();}logger[_0x0a9e('0x94')](_0x0a9e('0x95'),_0x94dcf5[_0x0a9e('0x8f')]['to'],_0x94dcf5[_0x0a9e('0x8f')][_0x0a9e('0x40')]);return db['CmHopper'][_0x0a9e('0x21')]({'where':{'ContactId':[_0x94dcf5[_0x0a9e('0x8f')]['to'],_0x94dcf5['body'][_0x0a9e('0x40')]]}})[_0x0a9e('0x22')](function(_0x3a1974){logger['info'](_0x0a9e('0x96'),_0x3a1974);return db['CmHopperBlack'][_0x0a9e('0x21')]({'where':{'ContactId':[_0x94dcf5[_0x0a9e('0x8f')]['to'],_0x94dcf5[_0x0a9e('0x8f')][_0x0a9e('0x40')]]}})[_0x0a9e('0x22')](function(_0x16341a){logger[_0x0a9e('0x94')](_0x0a9e('0x97'),_0x16341a);return db['CmContact'][_0x0a9e('0x98')](_0x46c9ac);});});}})[_0x0a9e('0x22')](function(_0x17f692){if(_0x17f692){_0x3b4a9f=_0x17f692;_0x36e975={'ContactId':_0x3b4a9f['id']};_0x524e38={'where':{'ContactId':[_0x94dcf5[_0x0a9e('0x8f')]['to'],_0x94dcf5[_0x0a9e('0x8f')][_0x0a9e('0x40')]]}};return db[_0x0a9e('0x99')][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0x9a')][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0x9b')]['update'](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0x9c')][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0x9d')]['update'](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0x9c')]['update'](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db['MailMessage'][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0x9e')][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})['then'](function(){if(_0x3b4a9f){return db[_0x0a9e('0x9f')]['update'](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0xa0')]['update'](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0xa1')][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})['then'](function(){if(_0x3b4a9f){return db['OpenchannelInteraction'][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0xa2')][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0xa3')][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0xa4')]['update'](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db['ReportAgentPreview'][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0xa5')][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db['ChatQueueReport'][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0xa6')][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db['MailQueueReport']['update'](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db['OpenchannelQueueReport'][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0xa7')][_0x0a9e('0x20')](_0x36e975,_0x524e38);}})[_0x0a9e('0x22')](function(){if(_0x3b4a9f){return db[_0x0a9e('0xa8')]['update'](_0x36e975,_0x524e38);}})['then'](function(){if(_0x3b4a9f){return db[_0x0a9e('0x28')]['destroy']({'where':{'id':[_0x94dcf5[_0x0a9e('0x8f')]['to'],_0x94dcf5['body'][_0x0a9e('0x40')]]}});}})['then'](function(){if(_0x3b4a9f){return _0x3b4a9f;}})['then'](respondWithResult(_0x5ac73d,null))[_0x0a9e('0x88')](handleError(_0x5ac73d,null));};exports[_0x0a9e('0x98')]=function(_0x5e9b0b,_0x170af6){return db[_0x0a9e('0x28')][_0x0a9e('0x29')]()[_0x0a9e('0x22')](function(_0x2eb028){if(_0x5e9b0b['body']['tags']&&_[_0x0a9e('0x61')](_0x5e9b0b[_0x0a9e('0x8f')][_0x0a9e('0x92')])){if(_0x5e9b0b[_0x0a9e('0x8f')][_0x0a9e('0x92')]['length']){_0x5e9b0b[_0x0a9e('0x8f')][_0x0a9e('0x92')]=_0x5e9b0b['body'][_0x0a9e('0x92')][_0x0a9e('0x93')](';')+';';}else{_0x5e9b0b[_0x0a9e('0x8f')][_0x0a9e('0x92')]=null;}}else{_0x5e9b0b[_0x0a9e('0x8f')][_0x0a9e('0x92')]=null;}return db[_0x0a9e('0x28')][_0x0a9e('0x98')](_0x5e9b0b[_0x0a9e('0x8f')],{'fields':_[_0x0a9e('0x2a')](_0x2eb028),'raw':!![]});})['then'](respondWithResult(_0x170af6,0xc9))[_0x0a9e('0x88')](handleError(_0x170af6,null));};exports[_0x0a9e('0xa9')]=function(_0x2ada60,_0x1c4232){var _0x1d0b02=[];var _0x547e37=0x0;var _0x500868=0x0;var _0x21902c=0x0;return db[_0x0a9e('0x28')][_0x0a9e('0x29')]()[_0x0a9e('0x22')](function(_0x34f7b5){return BPromise['each'](_0x2ada60[_0x0a9e('0x8f')],function(_0x3c775a){var _0x3450ae={'where':{'$or':[]},'defaults':_0x3c775a,'fields':_['keys'](_0x34f7b5),'raw':!![]};if(_0x3c775a[_0x0a9e('0xaa')]){for(var _0x59aa7b=0x0;_0x59aa7b<_0x3c775a[_0x0a9e('0xaa')]['length'];_0x59aa7b++){var _0x25b745={};_0x25b745[_0x3c775a[_0x0a9e('0xaa')][_0x59aa7b]]=_0x3c775a[_0x3c775a[_0x0a9e('0xaa')][_0x59aa7b]];_0x3450ae['where'][_0x0a9e('0xab')]['push'](_0x25b745);}_0x3450ae[_0x0a9e('0x3c')][_0x0a9e('0x5d')]=_0x3c775a[_0x0a9e('0x5d')];}return db[_0x0a9e('0x28')][_0x0a9e('0xac')](_0x3450ae)[_0x0a9e('0xad')](function(_0x4014c7,_0xe89aaa){if(_0xe89aaa){_0x547e37++;}else{_0x21902c++;}})[_0x0a9e('0x88')](function(_0x27d1f5){console[_0x0a9e('0xae')](_0x27d1f5);_0x500868++;});});})[_0x0a9e('0x22')](function(_0x2415fe){if(_0x2415fe){return{'success':_0x547e37,'failure':_0x500868,'duplicates':_0x21902c};}})[_0x0a9e('0x22')](respondWithResult(_0x1c4232,0xc9))[_0x0a9e('0x88')](handleError(_0x1c4232,null));};exports[_0x0a9e('0xaf')]=function(_0x5b93dd,_0x556443,_0x6eaaf0){var _0x5c4be0;return db[_0x0a9e('0x28')][_0x0a9e('0x29')]()['then'](function(_0x1a3754){return db[_0x0a9e('0x28')][_0x0a9e('0x89')]({'where':{'id':_0x5b93dd[_0x0a9e('0x8a')]['id']},'include':[{'model':db['Tag'],'as':_0x0a9e('0x86'),'attributes':['id',_0x0a9e('0x25'),_0x0a9e('0xb0')],'required':_0x5b93dd[_0x0a9e('0x37')]['tag']?!![]:![]}],'attributes':_[_0x0a9e('0x2a')](_0x1a3754)});})[_0x0a9e('0x22')](function(_0x2b7092){_0x5c4be0=_0x2b7092['get']({'plain':!![]});var _0x2650eb={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x2b7092&&_0x2b7092[_0x0a9e('0x5d')]){if(_0x2b7092[_0x0a9e('0x5d')]){_0x2650eb['where'][_0x0a9e('0xb1')][_0x0a9e('0x2e')]({'ListId':{'$ne':_0x2b7092[_0x0a9e('0x5d')]}});}}return db[_0x0a9e('0x2f')][_0x0a9e('0x8c')](_0x2650eb);})['then'](function(_0x3211d2){return _[_0x0a9e('0xb2')](_0x5c4be0,_['map'](_0x3211d2,function(_0x3bab3e){return util[_0x0a9e('0xb3')](_0x0a9e('0xb4'),_0x3bab3e['id']);}));})['then'](handleEntityNotFound(_0x556443,null))['then'](respondWithResult(_0x556443,null))['catch'](handleError(_0x556443,null));};exports[_0x0a9e('0x20')]=function(_0x4a70ce,_0x55f91a){var _0x183244;if(_0x4a70ce[_0x0a9e('0x8f')]['id']){delete _0x4a70ce[_0x0a9e('0x8f')]['id'];}return db['CmContact'][_0x0a9e('0x89')]({'where':{'id':_0x4a70ce[_0x0a9e('0x8a')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x55f91a,null))[_0x0a9e('0x22')](saveUpdates(_0x4a70ce[_0x0a9e('0x8f')],null))[_0x0a9e('0x22')](function(_0x40e6e7){_0x183244=_0x40e6e7;var _0x328ec5={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x40e6e7&&_0x40e6e7[_0x0a9e('0x5d')]){if(_0x40e6e7['ListId']){_0x328ec5[_0x0a9e('0x3c')]['$and'][_0x0a9e('0x2e')]({'ListId':{'$ne':_0x40e6e7[_0x0a9e('0x5d')]}});}}return db[_0x0a9e('0x2f')][_0x0a9e('0x8c')](_0x328ec5);})[_0x0a9e('0x22')](function(_0x344cd4){if(_0x344cd4){return _['omit'](_[_0x0a9e('0xb5')](_0x4a70ce[_0x0a9e('0x8f')],function(_0xe25eb5,_0x1af799){return _['startsWith'](_0x1af799,_0x0a9e('0x2d'));}),_[_0x0a9e('0x50')](_0x344cd4,function(_0x43beea){return util[_0x0a9e('0xb3')](_0x0a9e('0xb4'),_0x43beea['id']);}));}})[_0x0a9e('0x22')](function(_0x238c24){if(_0x238c24&&!_[_0x0a9e('0x75')](_0x238c24)){var _0x3299b7=squel[_0x0a9e('0x20')]()['table'](_0x0a9e('0x42'))[_0x0a9e('0xb6')](_0x238c24)[_0x0a9e('0x3c')](_0x0a9e('0xb7'),_0x4a70ce[_0x0a9e('0x8a')]['id'])[_0x0a9e('0xb8')]();return db[_0x0a9e('0x7a')][_0x0a9e('0x37')](_0x3299b7['text'],{'replacements':_0x3299b7[_0x0a9e('0xb9')]});}})[_0x0a9e('0x22')](function(){if(_0x4a70ce[_0x0a9e('0x8f')]['phone']&&_0x183244){return db[_0x0a9e('0xba')][_0x0a9e('0x20')]({'phone':_0x4a70ce[_0x0a9e('0x8f')][_0x0a9e('0xbb')]},{'where':{'ContactId':_0x183244['id']}});}})[_0x0a9e('0x22')](function(){return _0x183244;})[_0x0a9e('0x22')](respondWithResult(_0x55f91a,null))[_0x0a9e('0x88')](handleError(_0x55f91a,null));};exports[_0x0a9e('0xbc')]=function(_0x401601,_0x451010,_0x5a7dad){var _0x251753={};var _0x446e6={};var _0x15a9ed;var _0x3db98f;return db[_0x0a9e('0x28')][_0x0a9e('0xbd')]({'where':{'id':_0x401601['params']['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x451010,null))['then'](function(_0x5bd139){if(_0x5bd139){_0x15a9ed=_0x5bd139;_0x446e6['model']=_[_0x0a9e('0x2a')](db[_0x0a9e('0x4d')][_0x0a9e('0xbe')]);_0x446e6[_0x0a9e('0x37')]=_['keys'](_0x401601[_0x0a9e('0x37')]);_0x446e6[_0x0a9e('0x35')]=_[_0x0a9e('0x36')](_0x446e6[_0x0a9e('0x34')],_0x446e6[_0x0a9e('0x37')]);_0x251753['attributes']=_['intersection'](_0x446e6[_0x0a9e('0x34')],qs[_0x0a9e('0x38')](_0x401601[_0x0a9e('0x37')]['fields']));_0x251753[_0x0a9e('0x39')]=_0x251753[_0x0a9e('0x39')][_0x0a9e('0x2b')]?_0x251753['attributes']:_0x446e6[_0x0a9e('0x34')];_0x251753[_0x0a9e('0x73')]=qs[_0x0a9e('0x3b')](_0x401601['query'][_0x0a9e('0x3b')]);_0x251753[_0x0a9e('0x3c')]=qs[_0x0a9e('0x35')](_['pick'](_0x401601['query'],_0x446e6['filters']));if(_0x401601[_0x0a9e('0x37')][_0x0a9e('0x63')]){_0x251753[_0x0a9e('0x3c')]=_[_0x0a9e('0x7d')](_0x251753['where'],{'$or':_[_0x0a9e('0x50')](_0x251753['attributes'],function(_0x3b4af9){var _0x2ff2ab={};_0x2ff2ab[_0x3b4af9]={'$like':'%'+_0x401601[_0x0a9e('0x37')]['filter']+'%'};return _0x2ff2ab;})});}_0x251753=_[_0x0a9e('0x7d')]({},_0x251753,_0x401601[_0x0a9e('0xbf')]);return _0x15a9ed[_0x0a9e('0xbc')](_0x251753);}})['then'](function(_0x40eb5d){if(_0x40eb5d){_0x3db98f=_0x40eb5d['length'];if(!_0x401601[_0x0a9e('0x37')]['hasOwnProperty'](_0x0a9e('0xc0'))){_0x251753['limit']=qs[_0x0a9e('0x1d')](_0x401601[_0x0a9e('0x37')][_0x0a9e('0x1d')]);_0x251753[_0x0a9e('0x1c')]=qs[_0x0a9e('0x1c')](_0x401601[_0x0a9e('0x37')][_0x0a9e('0x1c')]);}return _0x15a9ed['getTags'](_0x251753);}})[_0x0a9e('0x22')](function(_0x1c9ea2){if(_0x1c9ea2){return _0x1c9ea2?{'count':_0x3db98f,'rows':_0x1c9ea2}:null;}})['then'](respondWithResult(_0x451010,null))[_0x0a9e('0x88')](handleError(_0x451010,null));};exports[_0x0a9e('0xc1')]=function(_0x548693,_0x39070b,_0x2a93a7){if(_0x548693[_0x0a9e('0x8f')]['id']){delete _0x548693['body']['id'];}return db[_0x0a9e('0x28')][_0x0a9e('0xbd')]({'where':{'id':_0x548693[_0x0a9e('0x8a')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x39070b,null))[_0x0a9e('0x22')](function(_0x29fdfe){if(_0x29fdfe){return _0x29fdfe[_0x0a9e('0xc1')](_0x548693[_0x0a9e('0x8f')][_0x0a9e('0xc2')]||[]);}return null;})[_0x0a9e('0x22')](respondWithResult(_0x39070b,null))['catch'](handleError(_0x39070b,null));};exports[_0x0a9e('0xc3')]=function(_0x53c7de,_0x3c9854,_0x2968e2){var _0x5b9c76={'raw':![],'where':{}};var _0x315e31={};var _0x5d577b={'count':0x0,'rows':[]};return db[_0x0a9e('0x28')]['findOne']({'where':{'id':_0x53c7de[_0x0a9e('0x8a')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x3c9854,null))[_0x0a9e('0x22')](function(_0x55a599){if(_0x55a599){_0x315e31[_0x0a9e('0x34')]=_[_0x0a9e('0x2a')](db[_0x0a9e('0xba')][_0x0a9e('0xbe')]);_0x315e31[_0x0a9e('0x37')]=_[_0x0a9e('0x2a')](_0x53c7de[_0x0a9e('0x37')]);_0x315e31['filters']=_[_0x0a9e('0x36')](_0x315e31[_0x0a9e('0x34')],_0x315e31[_0x0a9e('0x37')]);_0x5b9c76[_0x0a9e('0x39')]=_[_0x0a9e('0x36')](_0x315e31[_0x0a9e('0x34')],qs[_0x0a9e('0x38')](_0x53c7de['query']['fields']));_0x5b9c76[_0x0a9e('0x39')]=_0x5b9c76[_0x0a9e('0x39')][_0x0a9e('0x2b')]?_0x5b9c76[_0x0a9e('0x39')]:_0x315e31[_0x0a9e('0x34')];if(!_0x53c7de[_0x0a9e('0x37')][_0x0a9e('0x3a')]('nolimit')){_0x5b9c76[_0x0a9e('0x1d')]=qs[_0x0a9e('0x1d')](_0x53c7de[_0x0a9e('0x37')][_0x0a9e('0x1d')]);_0x5b9c76[_0x0a9e('0x1c')]=qs[_0x0a9e('0x1c')](_0x53c7de[_0x0a9e('0x37')]['offset']);}_0x5b9c76[_0x0a9e('0x73')]=qs[_0x0a9e('0x3b')](_0x53c7de[_0x0a9e('0x37')]['sort']);_0x5b9c76[_0x0a9e('0x3c')]=qs[_0x0a9e('0x35')](_[_0x0a9e('0x3d')](_0x53c7de[_0x0a9e('0x37')],_0x315e31['filters']));_0x5b9c76[_0x0a9e('0x3c')][_0x0a9e('0xc4')]=_0x55a599['id'];if(_0x53c7de[_0x0a9e('0x37')][_0x0a9e('0x63')]){_0x5b9c76[_0x0a9e('0x3c')]=_[_0x0a9e('0x7d')](_0x5b9c76[_0x0a9e('0x3c')],{'$or':_[_0x0a9e('0x50')](_0x5b9c76['attributes'],function(_0x3ede01){var _0x266aa1={};_0x266aa1[_0x3ede01]={'$like':'%'+_0x53c7de[_0x0a9e('0x37')][_0x0a9e('0x63')]+'%'};return _0x266aa1;})});}_0x5b9c76=_['merge']({},_0x5b9c76,_0x53c7de['options']);return db[_0x0a9e('0xba')][_0x0a9e('0x1b')]({'where':_0x5b9c76[_0x0a9e('0x3c')]})['then'](function(_0x3ccede){_0x5d577b[_0x0a9e('0x1b')]=_0x3ccede;if(_0x53c7de['query'][_0x0a9e('0xc5')]){_0x5b9c76['include']=[{'all':!![]}];}return db[_0x0a9e('0xba')]['findAll'](_0x5b9c76);})['then'](function(_0x48eaa3){_0x5d577b[_0x0a9e('0x87')]=_0x48eaa3;return _0x5d577b;});}})[_0x0a9e('0x22')](respondWithFilteredResult(_0x3c9854,_0x5b9c76))[_0x0a9e('0x88')](handleError(_0x3c9854,null));};exports[_0x0a9e('0xc6')]=function(_0x7d59a9,_0xe17af8,_0x48fbef){var _0x5fb7ce={'raw':!![],'where':{}};var _0x213e5f={};var _0x1713a7={'count':0x0,'rows':[]};return db[_0x0a9e('0x28')][_0x0a9e('0xbd')]({'where':{'id':_0x7d59a9[_0x0a9e('0x8a')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0xe17af8,null))['then'](function(_0x49baaa){if(_0x49baaa){_0x213e5f[_0x0a9e('0x34')]=_['keys'](db[_0x0a9e('0xa4')][_0x0a9e('0xbe')]);_0x213e5f[_0x0a9e('0x37')]=_[_0x0a9e('0x2a')](_0x7d59a9[_0x0a9e('0x37')]);_0x213e5f[_0x0a9e('0x35')]=_['intersection'](_0x213e5f[_0x0a9e('0x34')],_0x213e5f['query']);_0x5fb7ce['attributes']=_[_0x0a9e('0x36')](_0x213e5f['model'],qs[_0x0a9e('0x38')](_0x7d59a9['query']['fields']));_0x5fb7ce[_0x0a9e('0x39')]=_0x5fb7ce['attributes'][_0x0a9e('0x2b')]?_0x5fb7ce[_0x0a9e('0x39')]:_0x213e5f[_0x0a9e('0x34')];if(!_0x7d59a9['query'][_0x0a9e('0x3a')](_0x0a9e('0xc0'))){_0x5fb7ce[_0x0a9e('0x1d')]=qs['limit'](_0x7d59a9['query'][_0x0a9e('0x1d')]);_0x5fb7ce[_0x0a9e('0x1c')]=qs[_0x0a9e('0x1c')](_0x7d59a9[_0x0a9e('0x37')][_0x0a9e('0x1c')]);}_0x5fb7ce[_0x0a9e('0x73')]=qs[_0x0a9e('0x3b')](_0x7d59a9[_0x0a9e('0x37')][_0x0a9e('0x3b')]);_0x5fb7ce[_0x0a9e('0x3c')]=qs['filters'](_['pick'](_0x7d59a9['query'],_0x213e5f[_0x0a9e('0x35')]));_0x5fb7ce[_0x0a9e('0x3c')][_0x0a9e('0xc4')]=_0x49baaa['id'];if(_0x7d59a9[_0x0a9e('0x37')][_0x0a9e('0x63')]){_0x5fb7ce[_0x0a9e('0x3c')]=_[_0x0a9e('0x7d')](_0x5fb7ce[_0x0a9e('0x3c')],{'$or':_['map'](_0x5fb7ce['attributes'],function(_0x2869cc){var _0x98a973={};_0x98a973[_0x2869cc]={'$like':'%'+_0x7d59a9['query'][_0x0a9e('0x63')]+'%'};return _0x98a973;})});}_0x5fb7ce=_[_0x0a9e('0x7d')]({},_0x5fb7ce,_0x7d59a9[_0x0a9e('0xbf')]);return db[_0x0a9e('0xa4')][_0x0a9e('0x1b')]({'where':_0x5fb7ce[_0x0a9e('0x3c')]})[_0x0a9e('0x22')](function(_0x262281){_0x1713a7[_0x0a9e('0x1b')]=_0x262281;if(_0x7d59a9[_0x0a9e('0x37')][_0x0a9e('0xc5')]){_0x5fb7ce[_0x0a9e('0xc7')]=[{'all':!![]}];}return db['CmHopperHistory'][_0x0a9e('0x8c')](_0x5fb7ce);})[_0x0a9e('0x22')](function(_0x3cf607){_0x1713a7[_0x0a9e('0x87')]=_0x3cf607;return _0x1713a7;});}})[_0x0a9e('0x22')](respondWithFilteredResult(_0xe17af8,_0x5fb7ce))[_0x0a9e('0x88')](handleError(_0xe17af8,null));};exports[_0x0a9e('0xc8')]=function(_0x23bec3,_0x3a9c0f,_0x3f1959){var _0x6b048e={'raw':!![],'where':{}};var _0x3ba472={};var _0x4e6eb9={'count':0x0,'rows':[]};return db['CmContact'][_0x0a9e('0xbd')]({'where':{'id':_0x23bec3[_0x0a9e('0x8a')]['id']}})[_0x0a9e('0x22')](handleEntityNotFound(_0x3a9c0f,null))[_0x0a9e('0x22')](function(_0x33359a){if(_0x33359a){_0x3ba472[_0x0a9e('0x34')]=_[_0x0a9e('0x2a')](db['CmHopperFinal'][_0x0a9e('0xbe')]);_0x3ba472['query']=_[_0x0a9e('0x2a')](_0x23bec3[_0x0a9e('0x37')]);_0x3ba472[_0x0a9e('0x35')]=_[_0x0a9e('0x36')](_0x3ba472[_0x0a9e('0x34')],_0x3ba472[_0x0a9e('0x37')]);_0x6b048e[_0x0a9e('0x39')]=_[_0x0a9e('0x36')](_0x3ba472[_0x0a9e('0x34')],qs[_0x0a9e('0x38')](_0x23bec3[_0x0a9e('0x37')][_0x0a9e('0x38')]));_0x6b048e[_0x0a9e('0x39')]=_0x6b048e[_0x0a9e('0x39')][_0x0a9e('0x2b')]?_0x6b048e[_0x0a9e('0x39')]:_0x3ba472['model'];if(!_0x23bec3['query'][_0x0a9e('0x3a')](_0x0a9e('0xc0'))){_0x6b048e['limit']=qs['limit'](_0x23bec3[_0x0a9e('0x37')][_0x0a9e('0x1d')]);_0x6b048e[_0x0a9e('0x1c')]=qs['offset'](_0x23bec3[_0x0a9e('0x37')]['offset']);}_0x6b048e[_0x0a9e('0x73')]=qs['sort'](_0x23bec3[_0x0a9e('0x37')]['sort']);_0x6b048e[_0x0a9e('0x3c')]=qs[_0x0a9e('0x35')](_[_0x0a9e('0x3d')](_0x23bec3['query'],_0x3ba472[_0x0a9e('0x35')]));_0x6b048e['where']['ContactId']=_0x33359a['id'];if(_0x23bec3[_0x0a9e('0x37')][_0x0a9e('0x63')]){_0x6b048e[_0x0a9e('0x3c')]=_[_0x0a9e('0x7d')](_0x6b048e[_0x0a9e('0x3c')],{'$or':_[_0x0a9e('0x50')](_0x6b048e[_0x0a9e('0x39')],function(_0x82504f){var _0x1a3143={};_0x1a3143[_0x82504f]={'$like':'%'+_0x23bec3[_0x0a9e('0x37')][_0x0a9e('0x63')]+'%'};return _0x1a3143;})});}_0x6b048e=_[_0x0a9e('0x7d')]({},_0x6b048e,_0x23bec3[_0x0a9e('0xbf')]);return db[_0x0a9e('0xa3')][_0x0a9e('0x1b')]({'where':_0x6b048e[_0x0a9e('0x3c')]})[_0x0a9e('0x22')](function(_0x643f66){_0x4e6eb9[_0x0a9e('0x1b')]=_0x643f66;if(_0x23bec3['query'][_0x0a9e('0xc5')]){_0x6b048e[_0x0a9e('0xc7')]=[{'all':!![]}];}return db[_0x0a9e('0xa3')][_0x0a9e('0x8c')](_0x6b048e);})['then'](function(_0x49c3be){_0x4e6eb9['rows']=_0x49c3be;return _0x4e6eb9;});}})[_0x0a9e('0x22')](respondWithFilteredResult(_0x3a9c0f,_0x6b048e))['catch'](handleError(_0x3a9c0f,null));};exports[_0x0a9e('0xc9')]=function(_0x1fafc2,_0x130ae8,_0x43fe24){var _0x294c49={'raw':!![],'where':{}};var _0x28b8d2={};var _0x32617d={'count':0x0,'rows':[]};return db[_0x0a9e('0x28')][_0x0a9e('0xbd')]({'where':{'id':_0x1fafc2[_0x0a9e('0x8a')]['id']}})['then'](handleEntityNotFound(_0x130ae8,null))[_0x0a9e('0x22')](function(_0x47a018){if(_0x47a018){_0x28b8d2[_0x0a9e('0x34')]=_['keys'](db[_0x0a9e('0xa8')][_0x0a9e('0xbe')]);_0x28b8d2[_0x0a9e('0x37')]=_['keys'](_0x1fafc2[_0x0a9e('0x37')]);_0x28b8d2[_0x0a9e('0x35')]=_['intersection'](_0x28b8d2['model'],_0x28b8d2[_0x0a9e('0x37')]);_0x294c49[_0x0a9e('0x39')]=_[_0x0a9e('0x36')](_0x28b8d2['model'],qs['fields'](_0x1fafc2['query'][_0x0a9e('0x38')]));_0x294c49[_0x0a9e('0x39')]=_0x294c49[_0x0a9e('0x39')][_0x0a9e('0x2b')]?_0x294c49[_0x0a9e('0x39')]:_0x28b8d2[_0x0a9e('0x34')];if(!_0x1fafc2[_0x0a9e('0x37')][_0x0a9e('0x3a')](_0x0a9e('0xc0'))){_0x294c49[_0x0a9e('0x1d')]=qs[_0x0a9e('0x1d')](_0x1fafc2[_0x0a9e('0x37')][_0x0a9e('0x1d')]);_0x294c49[_0x0a9e('0x1c')]=qs[_0x0a9e('0x1c')](_0x1fafc2[_0x0a9e('0x37')][_0x0a9e('0x1c')]);}_0x294c49[_0x0a9e('0x73')]=qs['sort'](_0x1fafc2[_0x0a9e('0x37')][_0x0a9e('0x3b')]);_0x294c49[_0x0a9e('0x3c')]=qs[_0x0a9e('0x35')](_[_0x0a9e('0x3d')](_0x1fafc2[_0x0a9e('0x37')],_0x28b8d2['filters']));_0x294c49[_0x0a9e('0x3c')][_0x0a9e('0xc4')]=_0x47a018['id'];if(_0x1fafc2[_0x0a9e('0x37')][_0x0a9e('0x63')]){_0x294c49[_0x0a9e('0x3c')]=_[_0x0a9e('0x7d')](_0x294c49[_0x0a9e('0x3c')],{'$or':_[_0x0a9e('0x50')](_0x294c49[_0x0a9e('0x39')],function(_0x541af6){var _0x5d27c1={};_0x5d27c1[_0x541af6]={'$like':'%'+_0x1fafc2[_0x0a9e('0x37')][_0x0a9e('0x63')]+'%'};return _0x5d27c1;})});}_0x294c49=_['merge']({},_0x294c49,_0x1fafc2[_0x0a9e('0xbf')]);return db[_0x0a9e('0xa8')]['count']({'where':_0x294c49[_0x0a9e('0x3c')]})['then'](function(_0x3468a4){_0x32617d[_0x0a9e('0x1b')]=_0x3468a4;if(_0x1fafc2['query'][_0x0a9e('0xc5')]){_0x294c49[_0x0a9e('0xc7')]=[{'all':!![]}];}return db['JscriptySessionReport'][_0x0a9e('0x8c')](_0x294c49);})[_0x0a9e('0x22')](function(_0x53ad2b){_0x32617d[_0x0a9e('0x87')]=_0x53ad2b;return _0x32617d;});}})[_0x0a9e('0x22')](respondWithFilteredResult(_0x130ae8,_0x294c49))[_0x0a9e('0x88')](handleError(_0x130ae8,null));};exports[_0x0a9e('0xca')]=function(_0x8f68ec,_0x17a0d5,_0x5d525f){try{if(!_0x8f68ec[_0x0a9e('0x8f')][_0x0a9e('0x5d')]){throw new Error('No\x20ListId\x20specified');}if(!_0x8f68ec[_0x0a9e('0x8f')][_0x0a9e('0xcb')]){throw new Error(_0x0a9e('0xcc'));}if(!_0x8f68ec[_0x0a9e('0x8f')][_0x0a9e('0xcd')]){throw new Error(_0x0a9e('0xce'));}if(!_0x8f68ec[_0x0a9e('0x8f')]['socket_timestamp']){throw new Error('Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed');}var _0x5a2013=_0x8f68ec['body']['binding_keys'][_0x0a9e('0x4f')](',');var _0x23ef4e=_0x8f68ec['body']['binding_values'][_0x0a9e('0x4f')](',');if(!_0x5a2013['length']||!_0x23ef4e[_0x0a9e('0x2b')]||_0x5a2013[_0x0a9e('0x2b')]!==_0x23ef4e[_0x0a9e('0x2b')]){throw new Error(_0x0a9e('0xcf'));}_0x8f68ec[_0x0a9e('0x8f')][_0x0a9e('0x38')]=_['zipObject'](_0x5a2013,_0x23ef4e);if(!_0x8f68ec[_0x0a9e('0x8f')][_0x0a9e('0x38')]['phone']){throw new Error(_0x0a9e('0xd0'));}if(!_0x8f68ec[_0x0a9e('0x8f')][_0x0a9e('0x38')][_0x0a9e('0xd1')]){throw new Error(_0x0a9e('0xd2'));}var _0x2f1cc0=path[_0x0a9e('0x93')](config['root'],_0x0a9e('0xd3'),_0x8f68ec['file'][_0x0a9e('0xd4')]);fs[_0x0a9e('0xd5')](_0x2f1cc0,parseInt('0777',0x8));var _0x28b7de=require(_0x0a9e('0xd6'))['fork'](path[_0x0a9e('0x93')](__dirname,'../../components/import/cm/csv'),[_0x2f1cc0,_0x8f68ec[_0x0a9e('0x8f')][_0x0a9e('0xcb')],_0x8f68ec['body'][_0x0a9e('0xcd')],_0x8f68ec['body'][_0x0a9e('0x5d')],_0x8f68ec[_0x0a9e('0x8f')][_0x0a9e('0xd7')],_0x8f68ec[_0x0a9e('0x8f')][_0x0a9e('0xaa')],_0x8f68ec[_0x0a9e('0x8f')][_0x0a9e('0xd8')]]);return _0x17a0d5['status'](0xc8)[_0x0a9e('0xd9')]({'message':_0x0a9e('0xda'),'pid':_0x28b7de[_0x0a9e('0xdb')]});}catch(_0x1b1971){return _0x17a0d5[_0x0a9e('0x1a')](0x1f4)['send'](_0x1b1971);}};exports[_0x0a9e('0xdc')]=function(_0x49a6b2,_0x5d1159,_0x3a459c){var _0x58efc5=fs[_0x0a9e('0xdd')](_0x49a6b2[_0x0a9e('0xde')]['path']);Papa[_0x0a9e('0xdf')](_0x58efc5,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x4043e7){return _0x5d1159[_0x0a9e('0x1a')](0xc8)[_0x0a9e('0xd9')]({'file':_0x49a6b2[_0x0a9e('0xde')],'fields':_0x4043e7[_0x0a9e('0xe0')][_0x0a9e('0x38')]});}});};exports[_0x0a9e('0xe1')]=function(_0x3d02ae,_0x5871d7,_0x26f1c6){return db[_0x0a9e('0x53')][_0x0a9e('0x8c')]({'raw':!![],'attributes':['id'],'where':{'role':_0x0a9e('0xe2')}})['then'](function(_0x38d95a){var _0x439f25=![];if(!_0x3d02ae[_0x0a9e('0x8f')]['ListId']){throw new Error(_0x0a9e('0xe3'));}if(!_0x3d02ae[_0x0a9e('0x8f')][_0x0a9e('0xe4')]['phone']){throw new Error(_0x0a9e('0xd0'));}if(!_0x3d02ae['body'][_0x0a9e('0xe4')][_0x0a9e('0xd1')]){throw new Error(_0x0a9e('0xd2'));}if(!_0x3d02ae[_0x0a9e('0x8f')][_0x0a9e('0xd8')]){throw new Error(_0x0a9e('0xe5'));}var _0x81f0f5=require('child_process')[_0x0a9e('0xe6')](path[_0x0a9e('0x93')](__dirname,_0x0a9e('0xe7')),[_0x3d02ae[_0x0a9e('0x8a')]['id'],JSON[_0x0a9e('0xe8')](_0x3d02ae[_0x0a9e('0x8f')]),JSON[_0x0a9e('0xe8')](_0x38d95a)]);_0x81f0f5['on'](_0x0a9e('0xe9'),function(_0x2310ca){_0x439f25=!![];return _0x5871d7[_0x0a9e('0x1a')](0xc8)[_0x0a9e('0xd9')]({'message':_0x0a9e('0xea'),'pid':_0x81f0f5[_0x0a9e('0xdb')]});});_0x81f0f5['on'](_0x0a9e('0xeb'),function(_0xdce963){if(_0xdce963&&!_0x439f25){return _0x5871d7[_0x0a9e('0x1a')](0x1f4)[_0x0a9e('0xd9')]({'message':_0x0a9e('0xec'),'pid':_0x81f0f5[_0x0a9e('0xdb')]});}});})[_0x0a9e('0x88')](handleError(_0x5871d7,null));};
\ No newline at end of file
+var _0x3889=['Invalid\x20createdAt\x20filter','uniqueid','type','source','callerid','endtime','note','createdAt','UserId','fullname','DESC','findAndCountAll','Website','Account','closed','disposition','secondDisposition','thirdDisposition','key','Owner','browserName','customerIp','customerPort','deviceModel','osName','ratingMessage','ratingType','ratingValue','referer','subject','substatus','externalUrl','threadId','startCase','flatten','sortBy','value','moment','bluebird','util','path','lodash','squel','papaparse','../../components/contacts','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','socket.io-emitter','./cmContact.socket','register','status','offset','undefined','limit','count','set','then','destroy','end','sendStatus','error','name','send','index','describe','getOptions','findAll','user','catch','CmContact','find','params','tags','keys','length','startsWith','displayName','query','analytics','cf_','columnName','alias','custom','values','info','Custom\x20field\x20%s\x20not\x20found\x20on\x20cm_contacts\x20table','forEach','hasOwnProperty','merge','body','get','mergeWith','isArray','join','from','CmHopper','[CmContact][merge][destroy][CmHopper],\x20%s','CmHopperBlack','[CmContact][merge][destroy][CmHopperBlack],\x20%s','ChatInteraction','update','ChatMessage','MailInteraction','MailMessage','SmsInteraction','FaxMessage','OpenchannelInteraction','CmContactHasItem','CmHopperFinal','CmHopperHistory','ReportAgentPreview','ChatQueueReport','FaxQueueReport','MailQueueReport','OpenchannelQueueReport','JscriptySessionReport','WhatsappInteraction','WhatsappMessage','create','isNil','timezones','utcOffset','additionalPhones','each','duplicates','where','$or','push','ListId','findOrCreate','spread','contact','all','show','Tags','color','Phones','ItemType','sequelize','literal','Phones.OrderBy','$and','CmCustomField','omit','map','cf_%d','dialTimezone','format','table','cm_contacts','setFields','toParam','text','phone','getTags','Tag','intersection','model','attributes','fields','sort','filters','pick','filter','options','nolimit','findOne','ids','setAdditionalPhones','ContactItemType','OrderBy','items','item_types','ItemTypeId','description','PHONE','CmHopperAdditionalPhone','item','`ItemType`.OrderBy','CmHopperId','ItemType.OrderBy','getAdditionalPhones','duplicateAdditionalPhones','fromContactId','toContactId','rescheduleAdditionalPhones','hopperId','getHoppers','order','ContactId','includeAll','include','rows','getHopperHistories','rawAttributes','getHopperFinals','getJscriptySessions','uploadCsv','No\x20ListId\x20specified','binding_keys','No\x20association\x20keys\x20specified!','binding_values','No\x20association\x20values\x20specified!','Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed','split','Incorrect\x20binding\x20parameters\x20passed!','zipObject','No\x20phone\x20column\x20specified','firstName','No\x20firstName\x20column\x20specified','root','server/files/tmp','file','filename','chmodSync','0777','child_process','fork','../../components/import/cm/csv','CompanyId','socket_timestamp','json','File\x20uploaded\x20correctly!','pid','upload','createReadStream','parse','meta','User','agent','binding','../../components/import/cm/csv2','stringify','message','start\x20child\x20process\x20correctly!','exit','importUpdates','../../components/import/cm/csvUpdates','error\x20child\x20process','getJourney','mail','chat','sms','openchannel','fax','whatsapp','voice','-createdAt','includes','channel','toLowerCase','Invalid\x20channel','range','isValid','Invalid\x20date\x20for\x20range\x20from\x20filter','Invalid\x20date\x20for\x20range\x20to\x20filter'];(function(_0x5854a6,_0x4111dd){var _0x32c7ee=function(_0x4a28dd){while(--_0x4a28dd){_0x5854a6['push'](_0x5854a6['shift']());}};_0x32c7ee(++_0x4111dd);}(_0x3889,0x12a));var _0x9388=function(_0x461fa1,_0x5aa2cb){_0x461fa1=_0x461fa1-0x0;var _0x585156=_0x3889[_0x461fa1];return _0x585156;};'use strict';var moment=require(_0x9388('0x0'));var BPromise=require(_0x9388('0x1'));var util=require(_0x9388('0x2'));var path=require(_0x9388('0x3'));var fs=require('fs');var _=require(_0x9388('0x4'));var squel=require(_0x9388('0x5'));var Papa=require(_0x9388('0x6'));var Redis=require('ioredis');var contacts=require(_0x9388('0x7'));var qs=require(_0x9388('0x8'));var logger=require(_0x9388('0x9'))(_0x9388('0xa'));var config=require(_0x9388('0xb'));var shared=require('../../config/environment/shared');var db=require(_0x9388('0xc'))['db'];config[_0x9388('0xd')]=_[_0x9388('0xe')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x9388('0xf'))(new Redis(config[_0x9388('0xd')]));require(_0x9388('0x10'))[_0x9388('0x11')](socket);function respondWithResult(_0x5c8994,_0x54ab43){_0x54ab43=_0x54ab43||0xc8;return function(_0x472bd7){if(_0x472bd7){return _0x5c8994[_0x9388('0x12')](_0x54ab43)['json'](_0x472bd7);}};}function respondWithFilteredResult(_0x18c447,_0x4e2c7e){return function(_0x8851eb){if(_0x8851eb){var _0x215816=typeof _0x4e2c7e[_0x9388('0x13')]===_0x9388('0x14')&&typeof _0x4e2c7e[_0x9388('0x15')]===_0x9388('0x14');var _0x3308bd=_0x8851eb['count'];var _0x1fd462=_0x215816?0x0:_0x4e2c7e[_0x9388('0x13')];var _0x13c79c=_0x215816?_0x8851eb[_0x9388('0x16')]:_0x4e2c7e['offset']+_0x4e2c7e[_0x9388('0x15')];var _0x382028;if(_0x13c79c>=_0x3308bd){_0x13c79c=_0x3308bd;_0x382028=0xc8;}else{_0x382028=0xce;}_0x18c447[_0x9388('0x12')](_0x382028);return _0x18c447[_0x9388('0x17')]('Content-Range',_0x1fd462+'-'+_0x13c79c+'/'+_0x3308bd)['json'](_0x8851eb);}return null;};}function saveUpdates(_0x354781){return function(_0x56652d){if(_0x56652d){return _0x56652d['update'](_0x354781)[_0x9388('0x18')](function(_0x22ab7a){return _0x22ab7a;});}return null;};}function removeEntity(_0x57b03d){return function(_0x2c8090){if(_0x2c8090){return _0x2c8090[_0x9388('0x19')]()[_0x9388('0x18')](function(){_0x57b03d[_0x9388('0x12')](0xcc)[_0x9388('0x1a')]();});}};}function handleEntityNotFound(_0x53ef31){return function(_0x444451){if(!_0x444451){_0x53ef31[_0x9388('0x1b')](0x194);}return _0x444451;};}function handleError(_0x41a761,_0x753b5e){_0x753b5e=_0x753b5e||0x1f4;return function(_0x42d18c){logger[_0x9388('0x1c')](_0x42d18c['stack']);if(_0x42d18c['name']){delete _0x42d18c[_0x9388('0x1d')];}_0x41a761[_0x9388('0x12')](_0x753b5e)[_0x9388('0x1e')](_0x42d18c);};}exports[_0x9388('0x1f')]=function(_0x393005,_0xb87b4b){var _0xd964ec={};return contacts[_0x9388('0x20')]()[_0x9388('0x18')](function(_0x1d02de){_0xd964ec=qs[_0x9388('0x21')](_0x1d02de,_0x393005);return contacts[_0x9388('0x22')](_0x393005['query'],_0x393005[_0x9388('0x23')],_0xd964ec,_0x1d02de);})[_0x9388('0x18')](respondWithFilteredResult(_0xb87b4b,_0xd964ec))[_0x9388('0x24')](handleError(_0xb87b4b,null));};exports['destroy']=function(_0x5da19b,_0x3f8fc6){return db[_0x9388('0x25')][_0x9388('0x26')]({'where':{'id':_0x5da19b[_0x9388('0x27')]['id']}})[_0x9388('0x18')](handleEntityNotFound(_0x3f8fc6,null))[_0x9388('0x18')](removeEntity(_0x3f8fc6,null))[_0x9388('0x24')](handleError(_0x3f8fc6,null));};exports['describe']=function(_0x4e3477,_0x25264d){return db['CmContact'][_0x9388('0x20')]()['then'](function(_0x1af056){delete _0x1af056[_0x9388('0x28')];for(var _0x5bb429=0x0;_0x5bb429<Object[_0x9388('0x29')](_0x1af056)[_0x9388('0x2a')];_0x5bb429++){var _0x18c2d5=Object['keys'](_0x1af056)[_0x5bb429];if(!_[_0x9388('0x2b')](_0x18c2d5,'cf_')){_0x1af056[_0x18c2d5]['columnName']=_0x18c2d5;_0x1af056[_0x18c2d5][_0x9388('0x2c')]=_0x18c2d5;}}return _0x1af056;})[_0x9388('0x18')](function(_0x4750b8){var _0x48e86a={'where':Boolean(_0x4e3477[_0x9388('0x2d')][_0x9388('0x2e')])===!![]?undefined:{'$or':[{'ListId':_0x4e3477[_0x9388('0x2d')]['id']},{'ListId':null}]},'raw':!![]};return db['CmCustomField'][_0x9388('0x22')](_0x48e86a)[_0x9388('0x18')](function(_0x2452de){for(var _0x2a1ea0=0x0;_0x2a1ea0<_0x2452de[_0x9388('0x2a')];_0x2a1ea0++){var _0x2924b3=_0x9388('0x2f')+_0x2452de[_0x2a1ea0]['id'];if(_0x4750b8[_0x2924b3]){_0x4750b8[_0x2924b3][_0x9388('0x30')]=_0x2924b3;_0x4750b8[_0x2924b3]['displayName']=_0x2452de[_0x2a1ea0][_0x9388('0x31')];_0x4750b8[_0x2924b3][_0x9388('0x32')]={'type':_0x2452de[_0x2a1ea0]['type'],'values':_0x2452de[_0x2a1ea0][_0x9388('0x33')]};}else{logger[_0x9388('0x34')](_0x9388('0x35'),_0x2924b3);}}Object[_0x9388('0x29')](_0x4750b8)[_0x9388('0x36')](function(_0x11d61b){if(!_0x4750b8[_0x11d61b][_0x9388('0x37')](_0x9388('0x30'))){delete _0x4750b8[_0x11d61b];}});return _0x4750b8;});})[_0x9388('0x18')](respondWithResult(_0x25264d,null))[_0x9388('0x24')](handleError(_0x25264d,null));};exports[_0x9388('0x38')]=function(_0x43b219,_0x95ca92){var _0xaad210;var _0x4bf5bc;var _0x478f6c;if(_0x43b219['body']['id']){delete _0x43b219[_0x9388('0x39')]['id'];}return db['CmContact']['findAll']({'where':{'id':[_0x43b219[_0x9388('0x39')]['to'],_0x43b219[_0x9388('0x39')]['from']]}})[_0x9388('0x18')](function(_0x56c499){if(_0x56c499){if(_0x56c499[_0x9388('0x2a')]!==0x2){return null;}_0x56c499[0x0]=_0x56c499[0x0][_0x9388('0x3a')]({'plain':!![]});_0x56c499[0x1]=_0x56c499[0x1][_0x9388('0x3a')]({'plain':!![]});delete _0x56c499[0x0]['id'];delete _0x56c499[0x1]['id'];return _[_0x9388('0x3b')](_0x56c499[0x0],_0x56c499[0x1],function(_0x5e2233,_0x217371){if(Array[_0x9388('0x3c')](_0x217371)&&!_0x217371[_0x9388('0x2a')]){return _0x5e2233;}else if(!_0x217371){return _0x5e2233;}});}})[_0x9388('0x18')](handleEntityNotFound(_0x95ca92,null))[_0x9388('0x18')](function(_0x516d61){if(_0x516d61){if(_0x516d61[_0x9388('0x28')]&&_[_0x9388('0x3c')](_0x516d61['tags'])){_0x516d61[_0x9388('0x28')]=_0x516d61['tags'][_0x9388('0x3d')]();}logger['info']('[CmContact][merge]\x20to\x20%s\x20from\x20%s',_0x43b219[_0x9388('0x39')]['to'],_0x43b219[_0x9388('0x39')][_0x9388('0x3e')]);return db[_0x9388('0x3f')][_0x9388('0x19')]({'where':{'ContactId':[_0x43b219[_0x9388('0x39')]['to'],_0x43b219[_0x9388('0x39')][_0x9388('0x3e')]]}})['then'](function(_0x1ea181){logger[_0x9388('0x34')](_0x9388('0x40'),_0x1ea181);return db[_0x9388('0x41')][_0x9388('0x19')]({'where':{'ContactId':[_0x43b219[_0x9388('0x39')]['to'],_0x43b219[_0x9388('0x39')]['from']]}})[_0x9388('0x18')](function(_0x1e8ea1){logger[_0x9388('0x34')](_0x9388('0x42'),_0x1e8ea1);return db[_0x9388('0x25')]['create'](_0x516d61);});});}})[_0x9388('0x18')](function(_0x1b8601){if(_0x1b8601){_0xaad210=_0x1b8601;_0x4bf5bc={'ContactId':_0xaad210['id']};_0x478f6c={'where':{'ContactId':[_0x43b219[_0x9388('0x39')]['to'],_0x43b219[_0x9388('0x39')]['from']]}};return db[_0x9388('0x43')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db[_0x9388('0x45')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})['then'](function(){if(_0xaad210){return db['ChatOfflineMessage'][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db[_0x9388('0x46')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db[_0x9388('0x47')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db[_0x9388('0x46')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db['MailMessage'][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db[_0x9388('0x48')]['update'](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db['SmsMessage'][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db['FaxInteraction']['update'](_0x4bf5bc,_0x478f6c);}})['then'](function(){if(_0xaad210){return db[_0x9388('0x49')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db[_0x9388('0x4a')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db['OpenchannelMessage'][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db[_0x9388('0x4b')]['update']({'CmContactId':_0xaad210['id']},{'where':{'CmContactId':[_0x43b219[_0x9388('0x39')]['to'],_0x43b219[_0x9388('0x39')][_0x9388('0x3e')]]}});}})[_0x9388('0x18')](function(){if(_0xaad210){return db[_0x9388('0x4c')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})['then'](function(){if(_0xaad210){return db[_0x9388('0x4d')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db[_0x9388('0x4e')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db['VoiceCallReport'][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})['then'](function(){if(_0xaad210){return db[_0x9388('0x4f')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})['then'](function(){if(_0xaad210){return db[_0x9388('0x50')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db[_0x9388('0x51')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db[_0x9388('0x52')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db['SmsQueueReport'][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db[_0x9388('0x53')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db[_0x9388('0x54')][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})['then'](function(){if(_0xaad210){return db[_0x9388('0x55')]['update'](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db['WhatsappQueueReport'][_0x9388('0x44')](_0x4bf5bc,_0x478f6c);}})[_0x9388('0x18')](function(){if(_0xaad210){return db[_0x9388('0x25')]['destroy']({'where':{'id':[_0x43b219['body']['to'],_0x43b219[_0x9388('0x39')][_0x9388('0x3e')]]}});}})[_0x9388('0x18')](function(){if(_0xaad210){return _0xaad210;}})[_0x9388('0x18')](respondWithResult(_0x95ca92,null))[_0x9388('0x24')](handleError(_0x95ca92,null));};exports[_0x9388('0x56')]=function(_0x522650,_0x1772b8){return db['CmContact'][_0x9388('0x20')]()[_0x9388('0x18')](function(_0x1fcaf7){if(_0x522650['body'][_0x9388('0x28')]&&_[_0x9388('0x3c')](_0x522650['body'][_0x9388('0x28')])){if(_0x522650[_0x9388('0x39')]['tags'][_0x9388('0x2a')]){_0x522650[_0x9388('0x39')]['tags']=_0x522650['body']['tags']['join'](';')+';';}else{_0x522650[_0x9388('0x39')][_0x9388('0x28')]=null;}}else{_0x522650[_0x9388('0x39')]['tags']=null;}if(!_[_0x9388('0x57')](_0x522650[_0x9388('0x39')]['dialTimezone'])){var _0x1f9782=_0x522650['body']['dialTimezone'];if(!_[_0x9388('0x57')](shared[_0x9388('0x58')][_0x1f9782]))_0x522650['body'][_0x9388('0x59')]=shared[_0x9388('0x58')][_0x1f9782][_0x9388('0x59')];}return db[_0x9388('0x25')][_0x9388('0x56')](_0x522650[_0x9388('0x39')],{'fields':_['keys'](_0x1fcaf7),'raw':!![]});})[_0x9388('0x18')](function(_0x4c8021){if(_0x522650[_0x9388('0x39')][_0x9388('0x5a')]){return insertAdditionalPhones(_0x4c8021,_0x522650[_0x9388('0x39')][_0x9388('0x5a')]);}else{return _0x4c8021;}})[_0x9388('0x18')](respondWithResult(_0x1772b8,0xc9))[_0x9388('0x24')](handleError(_0x1772b8,null));};exports['bulkCreate']=function(_0x6eefb9,_0x48c82e){var _0x4f07ef=0x0;var _0x409019=0x0;var _0x1b9a11=0x0;var _0x2d4f39=[];return db[_0x9388('0x25')][_0x9388('0x20')]()[_0x9388('0x18')](function(_0x40e1d8){return BPromise[_0x9388('0x5b')](_0x6eefb9['body'],function(_0x2b4ff0){var _0x255593={'where':{'$or':[]},'defaults':_0x2b4ff0,'fields':_[_0x9388('0x29')](_0x40e1d8),'raw':!![]};if(_0x2b4ff0['duplicates']){for(var _0x10de5e=0x0;_0x10de5e<_0x2b4ff0[_0x9388('0x5c')][_0x9388('0x2a')];_0x10de5e++){var _0xf442c8={};_0xf442c8[_0x2b4ff0[_0x9388('0x5c')][_0x10de5e]]=_0x2b4ff0[_0x2b4ff0[_0x9388('0x5c')][_0x10de5e]];_0x255593[_0x9388('0x5d')][_0x9388('0x5e')][_0x9388('0x5f')](_0xf442c8);}_0x255593[_0x9388('0x5d')][_0x9388('0x60')]=_0x2b4ff0[_0x9388('0x60')];}return db[_0x9388('0x25')][_0x9388('0x61')](_0x255593)[_0x9388('0x62')](function(_0xd6fdaa,_0x42f9be){if(_0x42f9be){if(_0x2b4ff0[_0x9388('0x37')]('additionalPhones')){_0x2d4f39[_0x9388('0x5f')]({'contact':_0xd6fdaa,'additionalPhones':_0x2b4ff0[_0x9388('0x5a')]});}_0x4f07ef++;}else{_0x1b9a11++;}})[_0x9388('0x24')](function(){_0x409019++;});});})['then'](function(_0x465e70){if(_0x465e70){if(_0x2d4f39[_0x9388('0x2a')]>0x0){return new Promise(function(_0xe2b9dd){var _0xd7337f=[];for(var _0x22bc50=0x0;_0x22bc50<_0x2d4f39['length'];_0x22bc50++){_0xd7337f[_0x9388('0x5f')](insertAdditionalPhones(_0x2d4f39[_0x22bc50][_0x9388('0x63')],_0x2d4f39[_0x22bc50][_0x9388('0x5a')]));}Promise[_0x9388('0x64')](_0xd7337f)['then'](function(){_0xe2b9dd(0x1);});})[_0x9388('0x18')](function(){return{'success':_0x4f07ef,'failure':_0x409019,'duplicates':_0x1b9a11};});}else{return{'success':_0x4f07ef,'failure':_0x409019,'duplicates':_0x1b9a11};}}})['then'](respondWithResult(_0x48c82e,0xc9))[_0x9388('0x24')](handleError(_0x48c82e,null));};exports[_0x9388('0x65')]=function(_0x184fa3,_0x40c187){var _0xb93b76;return db[_0x9388('0x25')]['describe']()['then'](function(_0x93f006){return db['CmContact'][_0x9388('0x26')]({'where':{'id':_0x184fa3[_0x9388('0x27')]['id']},'include':[{'model':db['Tag'],'as':_0x9388('0x66'),'attributes':['id',_0x9388('0x1d'),_0x9388('0x67')],'required':_0x184fa3[_0x9388('0x2d')]['tag']?!![]:![]},{'model':db['CmContactHasItem'],'as':_0x9388('0x68'),'where':{'CmContactId':_0x184fa3[_0x9388('0x27')]['id']},'required':![],'include':[{'model':db['ContactItemType'],'as':_0x9388('0x69')}]}],'order':[db[_0x9388('0x6a')][_0x9388('0x6b')](_0x9388('0x6c'))],'attributes':_[_0x9388('0x29')](_0x93f006)});})[_0x9388('0x18')](function(_0x209104){if(!_['isNil'](_0x209104)){_0xb93b76=_0x209104[_0x9388('0x3a')]({'plain':!![]});var _0x54cb7d={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x209104&&_0x209104[_0x9388('0x60')]){if(_0x209104['ListId']){_0x54cb7d[_0x9388('0x5d')][_0x9388('0x6d')][_0x9388('0x5f')]({'ListId':{'$ne':_0x209104[_0x9388('0x60')]}});}}return db[_0x9388('0x6e')][_0x9388('0x22')](_0x54cb7d);}})['then'](function(_0x38e73f){if(!_[_0x9388('0x57')](_0x38e73f)){return _[_0x9388('0x6f')](_0xb93b76,_[_0x9388('0x70')](_0x38e73f,function(_0x187c09){return util['format'](_0x9388('0x71'),_0x187c09['id']);}));}})[_0x9388('0x18')](handleEntityNotFound(_0x40c187,null))[_0x9388('0x18')](respondWithResult(_0x40c187,null))[_0x9388('0x24')](handleError(_0x40c187,null));};exports[_0x9388('0x44')]=function(_0x30d16c,_0x26a5c4){var _0x42abaf;if(_0x30d16c[_0x9388('0x39')]['id']){delete _0x30d16c[_0x9388('0x39')]['id'];}if(!_[_0x9388('0x57')](_0x30d16c[_0x9388('0x39')]['dialTimezone'])){var _0x2b5765=_0x30d16c[_0x9388('0x39')][_0x9388('0x72')];if(!_['isNil'](shared[_0x9388('0x58')][_0x2b5765]))_0x30d16c[_0x9388('0x39')]['utcOffset']=shared[_0x9388('0x58')][_0x2b5765][_0x9388('0x59')];}return db[_0x9388('0x25')][_0x9388('0x26')]({'where':{'id':_0x30d16c['params']['id']}})[_0x9388('0x18')](handleEntityNotFound(_0x26a5c4,null))[_0x9388('0x18')](saveUpdates(_0x30d16c[_0x9388('0x39')],null))[_0x9388('0x18')](function(_0x1918a4){_0x42abaf=_0x1918a4;var _0x59282b={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x1918a4&&_0x1918a4[_0x9388('0x60')]){if(_0x1918a4[_0x9388('0x60')]){_0x59282b[_0x9388('0x5d')][_0x9388('0x6d')][_0x9388('0x5f')]({'ListId':{'$ne':_0x1918a4[_0x9388('0x60')]}});}}return db[_0x9388('0x6e')][_0x9388('0x22')](_0x59282b);})[_0x9388('0x18')](function(_0x43d92e){if(_0x43d92e){return _[_0x9388('0x6f')](_['pickBy'](_0x30d16c[_0x9388('0x39')],function(_0x4be75f,_0x380444){return _[_0x9388('0x2b')](_0x380444,'cf_');}),_[_0x9388('0x70')](_0x43d92e,function(_0x45f2eb){return util[_0x9388('0x73')](_0x9388('0x71'),_0x45f2eb['id']);}));}})[_0x9388('0x18')](function(_0xf73096){if(_0xf73096&&!_['isEmpty'](_0xf73096)){var _0x2f1906=squel[_0x9388('0x44')]()[_0x9388('0x74')](_0x9388('0x75'))[_0x9388('0x76')](_0xf73096)[_0x9388('0x5d')]('id\x20=\x20?',_0x30d16c[_0x9388('0x27')]['id'])[_0x9388('0x77')]();return db[_0x9388('0x6a')][_0x9388('0x2d')](_0x2f1906[_0x9388('0x78')],{'replacements':_0x2f1906[_0x9388('0x33')]});}})[_0x9388('0x18')](function(){if(_0x30d16c[_0x9388('0x39')][_0x9388('0x79')]&&_0x42abaf){return db[_0x9388('0x3f')]['update']({'phone':_0x30d16c[_0x9388('0x39')][_0x9388('0x79')],'OrderBy':0x0},{'where':{'ContactId':_0x42abaf['id']}});}})[_0x9388('0x18')](function(){return _0x42abaf;})[_0x9388('0x18')](respondWithResult(_0x26a5c4,null))[_0x9388('0x24')](handleError(_0x26a5c4,null));};exports[_0x9388('0x7a')]=function(_0x2fdd1e,_0xfa9822){var _0x17053a={};var _0xb054f8={};var _0xbf11db;var _0x58d9a3;return db[_0x9388('0x25')]['findOne']({'where':{'id':_0x2fdd1e[_0x9388('0x27')]['id']}})[_0x9388('0x18')](handleEntityNotFound(_0xfa9822,null))[_0x9388('0x18')](function(_0x321bc9){if(_0x321bc9){_0xbf11db=_0x321bc9;_0xb054f8['model']=_[_0x9388('0x29')](db[_0x9388('0x7b')]['rawAttributes']);_0xb054f8['query']=_[_0x9388('0x29')](_0x2fdd1e[_0x9388('0x2d')]);_0xb054f8['filters']=_[_0x9388('0x7c')](_0xb054f8[_0x9388('0x7d')],_0xb054f8[_0x9388('0x2d')]);_0x17053a[_0x9388('0x7e')]=_[_0x9388('0x7c')](_0xb054f8[_0x9388('0x7d')],qs[_0x9388('0x7f')](_0x2fdd1e[_0x9388('0x2d')][_0x9388('0x7f')]));_0x17053a['attributes']=_0x17053a['attributes'][_0x9388('0x2a')]?_0x17053a[_0x9388('0x7e')]:_0xb054f8[_0x9388('0x7d')];_0x17053a['order']=qs[_0x9388('0x80')](_0x2fdd1e[_0x9388('0x2d')]['sort']);_0x17053a[_0x9388('0x5d')]=qs[_0x9388('0x81')](_[_0x9388('0x82')](_0x2fdd1e[_0x9388('0x2d')],_0xb054f8['filters']));if(_0x2fdd1e[_0x9388('0x2d')][_0x9388('0x83')]){_0x17053a[_0x9388('0x5d')]=_[_0x9388('0x38')](_0x17053a[_0x9388('0x5d')],{'$or':_[_0x9388('0x70')](_0x17053a[_0x9388('0x7e')],function(_0x1598f4){var _0x30b519={};_0x30b519[_0x1598f4]={'$like':'%'+_0x2fdd1e[_0x9388('0x2d')][_0x9388('0x83')]+'%'};return _0x30b519;})});}_0x17053a=_['merge']({},_0x17053a,_0x2fdd1e[_0x9388('0x84')]);return _0xbf11db['getTags'](_0x17053a);}})[_0x9388('0x18')](function(_0x2b9cf3){if(_0x2b9cf3){_0x58d9a3=_0x2b9cf3[_0x9388('0x2a')];if(!_0x2fdd1e[_0x9388('0x2d')][_0x9388('0x37')](_0x9388('0x85'))){_0x17053a[_0x9388('0x15')]=qs[_0x9388('0x15')](_0x2fdd1e[_0x9388('0x2d')]['limit']);_0x17053a[_0x9388('0x13')]=qs[_0x9388('0x13')](_0x2fdd1e[_0x9388('0x2d')][_0x9388('0x13')]);}return _0xbf11db[_0x9388('0x7a')](_0x17053a);}})[_0x9388('0x18')](function(_0x389bf0){if(_0x389bf0){return _0x389bf0?{'count':_0x58d9a3,'rows':_0x389bf0}:null;}})[_0x9388('0x18')](respondWithResult(_0xfa9822,null))[_0x9388('0x24')](handleError(_0xfa9822,null));};exports['setTags']=function(_0xeae772,_0x95b872){if(_0xeae772[_0x9388('0x39')]['id']){delete _0xeae772[_0x9388('0x39')]['id'];}return db[_0x9388('0x25')][_0x9388('0x86')]({'where':{'id':_0xeae772['params']['id']}})['then'](handleEntityNotFound(_0x95b872,null))[_0x9388('0x18')](function(_0x434961){if(_0x434961){return _0x434961['setTags'](_0xeae772[_0x9388('0x39')][_0x9388('0x87')]||[]);}return null;})['then'](respondWithResult(_0x95b872,null))[_0x9388('0x24')](handleError(_0x95b872,null));};exports[_0x9388('0x88')]=function(_0x1c5a05,_0x322c11){var _0x2495f5=[];_0x2495f5[_0x9388('0x5f')](addAdditionalPhones(_0x1c5a05[_0x9388('0x39')]));Promise[_0x9388('0x64')](_0x2495f5)[_0x9388('0x18')](function(){_0x2495f5=[];_0x2495f5[_0x9388('0x5f')](deleteCmHopperPhones(_0x1c5a05[_0x9388('0x39')]['id']));_0x2495f5['push'](addCmHopperPhones(_0x1c5a05['body']['id']));Promise[_0x9388('0x64')](_0x2495f5)[_0x9388('0x18')](function(){return[0x1];})[_0x9388('0x18')](respondWithResult(_0x322c11,null));});};function addAdditionalPhones(_0x221b75){var _0xf4eb17;return new Promise(function(_0x2ed224){return db['CmContactHasItem']['destroy']({'where':{'CmContactId':_0x221b75['id']}})[_0x9388('0x18')](function(){db[_0x9388('0x89')][_0x9388('0x22')]({'raw':!![],'attributes':['id',_0x9388('0x8a')]})[_0x9388('0x18')](function(_0x2e66a7){var _0x17b060=[];for(var _0x2c1b98=0x0;_0x2c1b98<_0x221b75[_0x9388('0x8b')]['length'];_0x2c1b98++){var _0x4ede82=_0x221b75[_0x9388('0x8c')]?_[_0x9388('0x57')](_0x221b75['item_types'][_0x2c1b98])?'':_0x221b75[_0x9388('0x8c')][_0x2c1b98]:_0x221b75[_0x9388('0x8b')][_0x2c1b98][_0x9388('0x8d')]?_0x221b75['items'][_0x2c1b98][_0x9388('0x8d')]:'';var _0xdfeb0=_[_0x9388('0x57')](_0x221b75[_0x9388('0x8b')][_0x2c1b98]['description'])?'':_0x221b75[_0x9388('0x8b')][_0x2c1b98][_0x9388('0x8e')];var _0x1ebb38=_0x4ede82+':'+_0x221b75[_0x9388('0x8b')][_0x2c1b98][_0x9388('0x79')]+'ยง'+_0xdfeb0;if(_['isNil'](_0xf4eb17))_0xf4eb17=_0x1ebb38;else _0xf4eb17+=';'+_0x1ebb38;var _0x10738f=null;var _0x2b7aa1=null;if(_0x221b75[_0x9388('0x8c')]){if(!_[_0x9388('0x57')](_0x221b75[_0x9388('0x8c')][_0x2c1b98])){_0x2b7aa1=_[_0x9388('0x26')](_0x2e66a7,function(_0x51bb21){return _0x51bb21['id']===_0x221b75[_0x9388('0x8c')][_0x2c1b98];});if(!_[_0x9388('0x57')](_0x2b7aa1)){_0x10738f=_0x2b7aa1[_0x9388('0x8a')];}}}else{if(!_[_0x9388('0x57')](_0x221b75[_0x9388('0x8b')][_0x2c1b98])){_0x2b7aa1=_[_0x9388('0x26')](_0x2e66a7,function(_0x36a3cd){return _0x36a3cd['id']===_0x221b75[_0x9388('0x8b')][_0x2c1b98][_0x9388('0x8d')];});if(!_[_0x9388('0x57')](_0x2b7aa1)){_0x10738f=_0x2c1b98;}}}if(_[_0x9388('0x57')](_0x10738f)){_0x10738f=0x64;}_0x17b060['push'](addAdditionalPhone(_0x221b75['id'],_0x221b75[_0x9388('0x8b')][_0x2c1b98][_0x9388('0x79')],_0x221b75[_0x9388('0x8c')]?_[_0x9388('0x57')](_0x221b75[_0x9388('0x8c')][_0x2c1b98])?null:_0x221b75[_0x9388('0x8c')][_0x2c1b98]:_0x221b75['items'][_0x2c1b98][_0x9388('0x8d')]?_0x221b75[_0x9388('0x8b')][_0x2c1b98]['ItemTypeId']:null,_0x10738f,_0xdfeb0));}Promise['all'](_0x17b060)[_0x9388('0x18')](function(){db[_0x9388('0x25')]['update']({'AdditionalPhones':_0xf4eb17},{'where':{'id':_0x221b75['id']}})[_0x9388('0x18')](function(){_0x2ed224(0x1);});});});});});}function addAdditionalPhone(_0x273d04,_0x1a7deb,_0x18e6e3,_0x48455a,_0x23b8c9){return db['CmContactHasItem'][_0x9388('0x26')]({'where':{'CmContactId':_0x273d04,'item':_0x1a7deb}})[_0x9388('0x18')](function(_0x2457cc){if(_0x2457cc)logger['info']('contact\x20phone\x20exists',_0x2457cc);else{db[_0x9388('0x4b')][_0x9388('0x56')]({'CmContactId':_0x273d04,'item':_0x1a7deb,'ItemTypeId':_0x18e6e3,'OrderBy':_0x48455a,'ItemClass':_0x9388('0x8f'),'description':_0x23b8c9});}});}function deleteCmHopperPhones(_0x1df0b6){return new Promise(function(_0x39fc96){return db[_0x9388('0x3f')][_0x9388('0x22')]({'raw':!![],'attributes':['id'],'where':{'ContactId':_0x1df0b6}})[_0x9388('0x18')](function(_0x37c785){db[_0x9388('0x90')][_0x9388('0x19')]({'where':{'CmHopperId':{'$in':_['map'](_0x37c785,'id')}}});})['then'](function(){_0x39fc96(0x1);});});}function addCmHopperPhones(_0x29d42f){return new Promise(function(_0x514578){return db['CmHopper']['findAll']({'raw':!![],'attributes':['id'],'where':{'ContactId':_0x29d42f}})[_0x9388('0x18')](function(_0x356eaa){var _0xd72ca5=[];_[_0x9388('0x70')](_0x356eaa,function(_0x4ba2cd){_0xd72ca5[_0x9388('0x5f')](createCmHopperPhone(_0x29d42f,_0x4ba2cd['id']));});Promise[_0x9388('0x64')](_0xd72ca5)[_0x9388('0x18')](function(){_0x514578(0x1);});});});}function createCmHopperPhone(_0x25f4b2,_0x3c1124){return new Promise(function(_0x436f54){db[_0x9388('0x4b')][_0x9388('0x22')]({'raw':!![],'attributes':[_0x9388('0x91'),_0x9388('0x8a')],'where':{'CmContactId':_0x25f4b2,'ItemClass':'PHONE'},'include':[{'model':db[_0x9388('0x89')],'attributes':[_0x9388('0x8a')],'as':_0x9388('0x69')}],'order':[_0x9388('0x8a'),db[_0x9388('0x6a')][_0x9388('0x6b')](_0x9388('0x92'))]})['then'](function(_0xf1e348){var _0x1dadee=0x1;var _0x3bf2fb=_[_0x9388('0x70')](_0xf1e348,function(_0x58c2b8){_0x58c2b8[_0x9388('0x93')]=_0x3c1124;_0x58c2b8[_0x9388('0x79')]=_0x58c2b8[_0x9388('0x91')];_0x58c2b8[_0x9388('0x8a')]=_0x1dadee;delete _0x58c2b8[_0x9388('0x94')];_0x1dadee=_0x1dadee+0x1;return _0x58c2b8;});return db[_0x9388('0x90')]['bulkCreate'](_0x3bf2fb,{});})['then'](function(){_0x436f54(0x1);});});}function insertAdditionalPhones(_0x250400,_0x57e1a7){return new Promise(function(_0x330d58){var _0x49834=[];for(var _0x4944c8=0x0;_0x4944c8<_0x57e1a7[_0x9388('0x2a')];_0x4944c8++){var _0x42a153=_0x57e1a7[_0x4944c8];_0x49834['push'](parseContactItemType(_0x42a153));}Promise[_0x9388('0x64')](_0x49834)[_0x9388('0x18')](function(){var _0x520d90={'id':_0x250400['id'],'items':_0x57e1a7};return addAdditionalPhones(_0x520d90)[_0x9388('0x18')](function(){return addCmHopperPhones(_0x250400['id']);});})[_0x9388('0x18')](function(){_0x330d58(_0x250400);});});}function parseContactItemType(_0x3e9af5){return new Promise(function(_0x4c4a89){if(_0x3e9af5[_0x9388('0x37')](_0x9388('0x8d'))){_0x4c4a89(_0x3e9af5);}else{return db[_0x9388('0x89')][_0x9388('0x26')]({'where':{'name':_0x3e9af5[_0x9388('0x69')]}})[_0x9388('0x18')](function(_0x2fe205){if(_[_0x9388('0x57')](_0x2fe205))_0x3e9af5[_0x9388('0x8d')]=null;else _0x3e9af5[_0x9388('0x8d')]=_0x2fe205['id'];_0x4c4a89(_0x3e9af5);});}});}exports[_0x9388('0x95')]=function(_0xa6ab0f,_0x11457a){return db['CmContactHasItem'][_0x9388('0x22')]({'raw':!![],'where':{'CmContactId':_0xa6ab0f[_0x9388('0x27')]['id'],'ItemClass':_0x9388('0x8f')},'include':[{'model':db[_0x9388('0x89')],'as':_0x9388('0x69')}],'order':[[_0x9388('0x8a')],[db[_0x9388('0x6a')]['literal']('`ItemType`.OrderBy')]]})[_0x9388('0x18')](function(_0x46ad4f){return _0x46ad4f;})['then'](respondWithResult(_0x11457a,null))[_0x9388('0x24')](handleError(_0x11457a,null));};exports[_0x9388('0x96')]=function(_0x23a1fe,_0x432407){return db[_0x9388('0x4b')][_0x9388('0x22')]({'raw':!![],'where':{'CmContactId':_0x23a1fe[_0x9388('0x39')][_0x9388('0x97')]}})['then'](function(_0x45a310){var _0x4d51f9=_[_0x9388('0x70')](_0x45a310,function(_0x3235de){_0x3235de['CmContactId']=_0x23a1fe['body'][_0x9388('0x98')];return _0x3235de;});return db[_0x9388('0x4b')]['bulkCreate'](_0x4d51f9,{});})[_0x9388('0x18')](function(){return addCmHopperPhones(_0x23a1fe['body']['toContactId']);})[_0x9388('0x18')](function(){return['ok'];})[_0x9388('0x18')](respondWithResult(_0x432407,null))[_0x9388('0x24')](handleError(_0x432407,null));};exports[_0x9388('0x99')]=function(_0x59edfa,_0x3afcbb){var _0x4c1b39=[];_0x4c1b39['push'](createCmHopperPhone(_0x59edfa[_0x9388('0x39')]['id'],_0x59edfa['body'][_0x9388('0x9a')]));Promise['all'](_0x4c1b39)[_0x9388('0x18')](function(){return[0x1];})['then'](respondWithResult(_0x3afcbb,null));};exports[_0x9388('0x9b')]=function(_0x458b37,_0xd5d06e){var _0xe7e7c9={'raw':![],'where':{}};var _0x4ced15={};var _0x1639f3={'count':0x0,'rows':[]};return db[_0x9388('0x25')][_0x9388('0x86')]({'where':{'id':_0x458b37['params']['id']}})[_0x9388('0x18')](handleEntityNotFound(_0xd5d06e,null))[_0x9388('0x18')](function(_0x49b6fa){if(_0x49b6fa){_0x4ced15[_0x9388('0x7d')]=_['keys'](db['CmHopper']['rawAttributes']);_0x4ced15[_0x9388('0x2d')]=_['keys'](_0x458b37[_0x9388('0x2d')]);_0x4ced15[_0x9388('0x81')]=_[_0x9388('0x7c')](_0x4ced15[_0x9388('0x7d')],_0x4ced15[_0x9388('0x2d')]);_0xe7e7c9[_0x9388('0x7e')]=_[_0x9388('0x7c')](_0x4ced15['model'],qs['fields'](_0x458b37[_0x9388('0x2d')][_0x9388('0x7f')]));_0xe7e7c9['attributes']=_0xe7e7c9['attributes']['length']?_0xe7e7c9[_0x9388('0x7e')]:_0x4ced15[_0x9388('0x7d')];if(!_0x458b37[_0x9388('0x2d')][_0x9388('0x37')](_0x9388('0x85'))){_0xe7e7c9['limit']=qs[_0x9388('0x15')](_0x458b37[_0x9388('0x2d')][_0x9388('0x15')]);_0xe7e7c9['offset']=qs[_0x9388('0x13')](_0x458b37[_0x9388('0x2d')]['offset']);}_0xe7e7c9[_0x9388('0x9c')]=qs[_0x9388('0x80')](_0x458b37[_0x9388('0x2d')]['sort']);_0xe7e7c9['where']=qs[_0x9388('0x81')](_[_0x9388('0x82')](_0x458b37[_0x9388('0x2d')],_0x4ced15['filters']));_0xe7e7c9['where'][_0x9388('0x9d')]=_0x49b6fa['id'];if(_0x458b37[_0x9388('0x2d')][_0x9388('0x83')]){_0xe7e7c9[_0x9388('0x5d')]=_[_0x9388('0x38')](_0xe7e7c9[_0x9388('0x5d')],{'$or':_[_0x9388('0x70')](_0xe7e7c9[_0x9388('0x7e')],function(_0x487abe){var _0x103793={};_0x103793[_0x487abe]={'$like':'%'+_0x458b37[_0x9388('0x2d')][_0x9388('0x83')]+'%'};return _0x103793;})});}_0xe7e7c9=_[_0x9388('0x38')]({},_0xe7e7c9,_0x458b37[_0x9388('0x84')]);return db[_0x9388('0x3f')][_0x9388('0x16')]({'where':_0xe7e7c9['where']})[_0x9388('0x18')](function(_0x18d077){_0x1639f3[_0x9388('0x16')]=_0x18d077;if(_0x458b37[_0x9388('0x2d')][_0x9388('0x9e')]){_0xe7e7c9[_0x9388('0x9f')]=[{'all':!![]}];}return db[_0x9388('0x3f')][_0x9388('0x22')](_0xe7e7c9);})[_0x9388('0x18')](function(_0x47f324){_0x1639f3[_0x9388('0xa0')]=_0x47f324;return _0x1639f3;});}})[_0x9388('0x18')](respondWithFilteredResult(_0xd5d06e,_0xe7e7c9))[_0x9388('0x24')](handleError(_0xd5d06e,null));};exports[_0x9388('0xa1')]=function(_0x3593ae,_0x57667b){var _0x470571={'raw':!![],'where':{}};var _0x4e0475={};var _0xac6cc={'count':0x0,'rows':[]};return db[_0x9388('0x25')]['findOne']({'where':{'id':_0x3593ae[_0x9388('0x27')]['id']}})[_0x9388('0x18')](handleEntityNotFound(_0x57667b,null))[_0x9388('0x18')](function(_0x5ec3dd){if(_0x5ec3dd){_0x4e0475[_0x9388('0x7d')]=_['keys'](db['CmHopperHistory'][_0x9388('0xa2')]);_0x4e0475['query']=_[_0x9388('0x29')](_0x3593ae[_0x9388('0x2d')]);_0x4e0475[_0x9388('0x81')]=_[_0x9388('0x7c')](_0x4e0475[_0x9388('0x7d')],_0x4e0475['query']);_0x470571['attributes']=_['intersection'](_0x4e0475[_0x9388('0x7d')],qs[_0x9388('0x7f')](_0x3593ae[_0x9388('0x2d')]['fields']));_0x470571[_0x9388('0x7e')]=_0x470571[_0x9388('0x7e')][_0x9388('0x2a')]?_0x470571['attributes']:_0x4e0475[_0x9388('0x7d')];if(!_0x3593ae[_0x9388('0x2d')][_0x9388('0x37')]('nolimit')){_0x470571[_0x9388('0x15')]=qs[_0x9388('0x15')](_0x3593ae[_0x9388('0x2d')]['limit']);_0x470571[_0x9388('0x13')]=qs['offset'](_0x3593ae[_0x9388('0x2d')][_0x9388('0x13')]);}_0x470571[_0x9388('0x9c')]=qs[_0x9388('0x80')](_0x3593ae[_0x9388('0x2d')][_0x9388('0x80')]);_0x470571['where']=qs[_0x9388('0x81')](_[_0x9388('0x82')](_0x3593ae['query'],_0x4e0475[_0x9388('0x81')]));_0x470571['where'][_0x9388('0x9d')]=_0x5ec3dd['id'];if(_0x3593ae[_0x9388('0x2d')]['filter']){_0x470571['where']=_['merge'](_0x470571[_0x9388('0x5d')],{'$or':_[_0x9388('0x70')](_0x470571[_0x9388('0x7e')],function(_0x42d93b){var _0x4cdebf={};_0x4cdebf[_0x42d93b]={'$like':'%'+_0x3593ae[_0x9388('0x2d')][_0x9388('0x83')]+'%'};return _0x4cdebf;})});}_0x470571=_[_0x9388('0x38')]({},_0x470571,_0x3593ae[_0x9388('0x84')]);return db[_0x9388('0x4d')][_0x9388('0x16')]({'where':_0x470571[_0x9388('0x5d')]})[_0x9388('0x18')](function(_0x21de6c){_0xac6cc[_0x9388('0x16')]=_0x21de6c;if(_0x3593ae[_0x9388('0x2d')][_0x9388('0x9e')]){_0x470571[_0x9388('0x9f')]=[{'all':!![]}];}return db[_0x9388('0x4d')][_0x9388('0x22')](_0x470571);})[_0x9388('0x18')](function(_0x48ce0e){_0xac6cc[_0x9388('0xa0')]=_0x48ce0e;return _0xac6cc;});}})[_0x9388('0x18')](respondWithFilteredResult(_0x57667b,_0x470571))['catch'](handleError(_0x57667b,null));};exports[_0x9388('0xa3')]=function(_0x44117f,_0x21bad2){var _0x271a60={'raw':!![],'where':{}};var _0x25827b={};var _0x42ed44={'count':0x0,'rows':[]};return db['CmContact'][_0x9388('0x86')]({'where':{'id':_0x44117f[_0x9388('0x27')]['id']}})[_0x9388('0x18')](handleEntityNotFound(_0x21bad2,null))[_0x9388('0x18')](function(_0x4cee3d){if(_0x4cee3d){_0x25827b[_0x9388('0x7d')]=_[_0x9388('0x29')](db[_0x9388('0x4c')]['rawAttributes']);_0x25827b[_0x9388('0x2d')]=_[_0x9388('0x29')](_0x44117f[_0x9388('0x2d')]);_0x25827b['filters']=_[_0x9388('0x7c')](_0x25827b[_0x9388('0x7d')],_0x25827b['query']);_0x271a60[_0x9388('0x7e')]=_[_0x9388('0x7c')](_0x25827b['model'],qs[_0x9388('0x7f')](_0x44117f[_0x9388('0x2d')][_0x9388('0x7f')]));_0x271a60['attributes']=_0x271a60['attributes'][_0x9388('0x2a')]?_0x271a60[_0x9388('0x7e')]:_0x25827b[_0x9388('0x7d')];if(!_0x44117f['query']['hasOwnProperty']('nolimit')){_0x271a60['limit']=qs[_0x9388('0x15')](_0x44117f[_0x9388('0x2d')][_0x9388('0x15')]);_0x271a60['offset']=qs[_0x9388('0x13')](_0x44117f[_0x9388('0x2d')][_0x9388('0x13')]);}_0x271a60['order']=qs['sort'](_0x44117f['query']['sort']);_0x271a60[_0x9388('0x5d')]=qs[_0x9388('0x81')](_[_0x9388('0x82')](_0x44117f['query'],_0x25827b[_0x9388('0x81')]));_0x271a60['where']['ContactId']=_0x4cee3d['id'];if(_0x44117f[_0x9388('0x2d')][_0x9388('0x83')]){_0x271a60['where']=_[_0x9388('0x38')](_0x271a60[_0x9388('0x5d')],{'$or':_[_0x9388('0x70')](_0x271a60[_0x9388('0x7e')],function(_0x1a6900){var _0x5e582b={};_0x5e582b[_0x1a6900]={'$like':'%'+_0x44117f[_0x9388('0x2d')]['filter']+'%'};return _0x5e582b;})});}_0x271a60=_['merge']({},_0x271a60,_0x44117f[_0x9388('0x84')]);return db['CmHopperFinal']['count']({'where':_0x271a60[_0x9388('0x5d')]})[_0x9388('0x18')](function(_0x43f900){_0x42ed44['count']=_0x43f900;if(_0x44117f['query'][_0x9388('0x9e')]){_0x271a60[_0x9388('0x9f')]=[{'all':!![]}];}return db[_0x9388('0x4c')][_0x9388('0x22')](_0x271a60);})[_0x9388('0x18')](function(_0x4f8483){_0x42ed44[_0x9388('0xa0')]=_0x4f8483;return _0x42ed44;});}})[_0x9388('0x18')](respondWithFilteredResult(_0x21bad2,_0x271a60))[_0x9388('0x24')](handleError(_0x21bad2,null));};exports[_0x9388('0xa4')]=function(_0xb0792d,_0x16b53f){var _0x3bf2ab={'raw':!![],'where':{}};var _0x38a1b9={};var _0x5a9aa2={'count':0x0,'rows':[]};return db[_0x9388('0x25')][_0x9388('0x86')]({'where':{'id':_0xb0792d[_0x9388('0x27')]['id']}})[_0x9388('0x18')](handleEntityNotFound(_0x16b53f,null))['then'](function(_0x3b38bf){if(_0x3b38bf){_0x38a1b9[_0x9388('0x7d')]=_['keys'](db['JscriptySessionReport'][_0x9388('0xa2')]);_0x38a1b9[_0x9388('0x2d')]=_[_0x9388('0x29')](_0xb0792d[_0x9388('0x2d')]);_0x38a1b9[_0x9388('0x81')]=_[_0x9388('0x7c')](_0x38a1b9[_0x9388('0x7d')],_0x38a1b9[_0x9388('0x2d')]);_0x3bf2ab[_0x9388('0x7e')]=_[_0x9388('0x7c')](_0x38a1b9[_0x9388('0x7d')],qs['fields'](_0xb0792d[_0x9388('0x2d')][_0x9388('0x7f')]));_0x3bf2ab['attributes']=_0x3bf2ab[_0x9388('0x7e')][_0x9388('0x2a')]?_0x3bf2ab[_0x9388('0x7e')]:_0x38a1b9[_0x9388('0x7d')];if(!_0xb0792d[_0x9388('0x2d')][_0x9388('0x37')](_0x9388('0x85'))){_0x3bf2ab[_0x9388('0x15')]=qs[_0x9388('0x15')](_0xb0792d[_0x9388('0x2d')][_0x9388('0x15')]);_0x3bf2ab[_0x9388('0x13')]=qs[_0x9388('0x13')](_0xb0792d[_0x9388('0x2d')][_0x9388('0x13')]);}_0x3bf2ab['order']=qs['sort'](_0xb0792d[_0x9388('0x2d')][_0x9388('0x80')]);_0x3bf2ab[_0x9388('0x5d')]=qs[_0x9388('0x81')](_[_0x9388('0x82')](_0xb0792d[_0x9388('0x2d')],_0x38a1b9[_0x9388('0x81')]));_0x3bf2ab[_0x9388('0x5d')][_0x9388('0x9d')]=_0x3b38bf['id'];if(_0xb0792d['query'][_0x9388('0x83')]){_0x3bf2ab[_0x9388('0x5d')]=_[_0x9388('0x38')](_0x3bf2ab[_0x9388('0x5d')],{'$or':_['map'](_0x3bf2ab['attributes'],function(_0x204047){var _0x13d813={};_0x13d813[_0x204047]={'$like':'%'+_0xb0792d[_0x9388('0x2d')][_0x9388('0x83')]+'%'};return _0x13d813;})});}_0x3bf2ab=_[_0x9388('0x38')]({},_0x3bf2ab,_0xb0792d[_0x9388('0x84')]);return db[_0x9388('0x53')]['count']({'where':_0x3bf2ab[_0x9388('0x5d')]})[_0x9388('0x18')](function(_0x5472e5){_0x5a9aa2[_0x9388('0x16')]=_0x5472e5;if(_0xb0792d[_0x9388('0x2d')][_0x9388('0x9e')]){_0x3bf2ab['include']=[{'all':!![]}];}return db['JscriptySessionReport'][_0x9388('0x22')](_0x3bf2ab);})['then'](function(_0xe16379){_0x5a9aa2[_0x9388('0xa0')]=_0xe16379;return _0x5a9aa2;});}})[_0x9388('0x18')](respondWithFilteredResult(_0x16b53f,_0x3bf2ab))['catch'](handleError(_0x16b53f,null));};exports[_0x9388('0xa5')]=function(_0xe603a5,_0x244fa6){try{if(!_0xe603a5[_0x9388('0x39')][_0x9388('0x60')]){throw new Error(_0x9388('0xa6'));}if(!_0xe603a5[_0x9388('0x39')][_0x9388('0xa7')]){throw new Error(_0x9388('0xa8'));}if(!_0xe603a5['body'][_0x9388('0xa9')]){throw new Error(_0x9388('0xaa'));}if(!_0xe603a5['body']['socket_timestamp']){throw new Error(_0x9388('0xab'));}var _0x2aa5b6=_0xe603a5[_0x9388('0x39')]['binding_keys'][_0x9388('0xac')](',');var _0x1a993c=_0xe603a5[_0x9388('0x39')][_0x9388('0xa9')]['split'](',');if(!_0x2aa5b6['length']||!_0x1a993c[_0x9388('0x2a')]||_0x2aa5b6['length']!==_0x1a993c[_0x9388('0x2a')]){throw new Error(_0x9388('0xad'));}_0xe603a5[_0x9388('0x39')][_0x9388('0x7f')]=_[_0x9388('0xae')](_0x2aa5b6,_0x1a993c);if(!_0xe603a5['body'][_0x9388('0x7f')][_0x9388('0x79')]){throw new Error(_0x9388('0xaf'));}if(!_0xe603a5[_0x9388('0x39')]['fields'][_0x9388('0xb0')]){throw new Error(_0x9388('0xb1'));}var _0x558ac4=path[_0x9388('0x3d')](config[_0x9388('0xb2')],_0x9388('0xb3'),_0xe603a5[_0x9388('0xb4')][_0x9388('0xb5')]);fs[_0x9388('0xb6')](_0x558ac4,parseInt(_0x9388('0xb7'),0x8));var _0x14dc1f=require(_0x9388('0xb8'))[_0x9388('0xb9')](path[_0x9388('0x3d')](__dirname,_0x9388('0xba')),[_0x558ac4,_0xe603a5[_0x9388('0x39')][_0x9388('0xa7')],_0xe603a5[_0x9388('0x39')][_0x9388('0xa9')],_0xe603a5[_0x9388('0x39')]['ListId'],_0xe603a5[_0x9388('0x39')][_0x9388('0xbb')],_0xe603a5[_0x9388('0x39')]['duplicates'],_0xe603a5['body'][_0x9388('0xbc')]]);return _0x244fa6['status'](0xc8)[_0x9388('0xbd')]({'message':_0x9388('0xbe'),'pid':_0x14dc1f[_0x9388('0xbf')]});}catch(_0x1457c8){return _0x244fa6[_0x9388('0x12')](0x1f4)[_0x9388('0x1e')](_0x1457c8);}};exports[_0x9388('0xc0')]=function(_0x4506e0,_0x1cf9bc){var _0x2bf282=fs[_0x9388('0xc1')](_0x4506e0[_0x9388('0xb4')][_0x9388('0x3')]);Papa[_0x9388('0xc2')](_0x2bf282,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x512aee){return _0x1cf9bc[_0x9388('0x12')](0xc8)[_0x9388('0xbd')]({'file':_0x4506e0['file'],'fields':_0x512aee[_0x9388('0xc3')][_0x9388('0x7f')]});}});};exports['import']=function(_0x33c645,_0x2ffda4){return db[_0x9388('0xc4')]['findAll']({'raw':!![],'attributes':['id'],'where':{'role':_0x9388('0xc5')}})[_0x9388('0x18')](function(_0x6991b9){var _0x28f093=![];if(!_0x33c645[_0x9388('0x39')]['ListId']){throw new Error(_0x9388('0xa6'));}if(!_0x33c645[_0x9388('0x39')][_0x9388('0xc6')][_0x9388('0x79')]){throw new Error(_0x9388('0xaf'));}if(!_0x33c645[_0x9388('0x39')][_0x9388('0xc6')][_0x9388('0xb0')]){throw new Error(_0x9388('0xb1'));}if(!_0x33c645[_0x9388('0x39')][_0x9388('0xbc')]){throw new Error('Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed');}var _0x3c4144=require(_0x9388('0xb8'))[_0x9388('0xb9')](path[_0x9388('0x3d')](__dirname,_0x9388('0xc7')),[_0x33c645[_0x9388('0x27')]['id'],JSON[_0x9388('0xc8')](_0x33c645[_0x9388('0x39')]),JSON[_0x9388('0xc8')](_0x6991b9)]);_0x3c4144['on'](_0x9388('0xc9'),function(){_0x28f093=!![];return _0x2ffda4[_0x9388('0x12')](0xc8)[_0x9388('0xbd')]({'message':_0x9388('0xca'),'pid':_0x3c4144[_0x9388('0xbf')]});});_0x3c4144['on'](_0x9388('0xcb'),function(_0xf1dfc3){if(_0xf1dfc3&&!_0x28f093){return _0x2ffda4[_0x9388('0x12')](0x1f4)['json']({'message':'error\x20child\x20process','pid':_0x3c4144[_0x9388('0xbf')]});}});})[_0x9388('0x24')](handleError(_0x2ffda4,null));};exports[_0x9388('0xcc')]=function(_0x80e0a7,_0x4edf8c){return db[_0x9388('0xc4')][_0x9388('0x22')]({'raw':!![],'attributes':['id'],'where':{'role':_0x9388('0xc5')}})[_0x9388('0x18')](function(_0x2e0f38){var _0x30d2c7=![];if(!_0x80e0a7['body'][_0x9388('0x60')]){throw new Error(_0x9388('0xa6'));}if(!_0x80e0a7[_0x9388('0x39')][_0x9388('0xc6')]['phone']){throw new Error(_0x9388('0xaf'));}if(!_0x80e0a7[_0x9388('0x39')][_0x9388('0xc6')]['firstName']){throw new Error(_0x9388('0xb1'));}if(!_0x80e0a7[_0x9388('0x39')][_0x9388('0xbc')]){throw new Error(_0x9388('0xab'));}var _0x1f2daa=require('child_process')[_0x9388('0xb9')](path['join'](__dirname,_0x9388('0xcd')),[_0x80e0a7['params']['id'],JSON[_0x9388('0xc8')](_0x80e0a7[_0x9388('0x39')]),JSON[_0x9388('0xc8')](_0x2e0f38)]);_0x1f2daa['on'](_0x9388('0xc9'),function(){_0x30d2c7=!![];return _0x4edf8c['status'](0xc8)['json']({'message':_0x9388('0xca'),'pid':_0x1f2daa[_0x9388('0xbf')]});});_0x1f2daa['on']('exit',function(_0x31e143){if(_0x31e143&&!_0x30d2c7){return _0x4edf8c[_0x9388('0x12')](0x1f4)['json']({'message':_0x9388('0xce'),'pid':_0x1f2daa[_0x9388('0xbf')]});}});})[_0x9388('0x24')](handleError(_0x4edf8c,null));};exports[_0x9388('0xcf')]=function(_0xd9fd1b,_0x311739){var _0xbbcd65=[_0x9388('0xd0'),_0x9388('0xd1'),_0x9388('0xd2'),_0x9388('0xd3'),_0x9388('0xd4'),_0x9388('0xd5'),_0x9388('0xd6')];var _0x4d6fb1={'offset':0x0,'order':qs[_0x9388('0x80')](_0x9388('0xd7'))},_0x35807d={'count':0x0,'rows':[]};Promise['resolve']()[_0x9388('0x18')](function(){if(_0xd9fd1b[_0x9388('0x2d')]['channel']){if(!_[_0x9388('0xd8')](_0xbbcd65,_0xd9fd1b[_0x9388('0x2d')][_0x9388('0xd9')][_0x9388('0xda')]())){throw new Error(_0x9388('0xdb'));}_0xbbcd65=[_0xd9fd1b[_0x9388('0x2d')][_0x9388('0xd9')][_0x9388('0xda')]()];}if(_0xd9fd1b['query'][_0x9388('0xdc')]){try{var _0x3f6605=JSON[_0x9388('0xc2')](_0xd9fd1b[_0x9388('0x2d')][_0x9388('0xdc')]);if(!moment(_0x3f6605[_0x9388('0x3e')])[_0x9388('0xdd')]()){throw new Error(_0x9388('0xde'));}if(!moment(_0x3f6605['to'])['isValid']()){throw new Error(_0x9388('0xdf'));}}catch(_0x20f103){throw new Error(_0x9388('0xe0'));}}if(!_0xd9fd1b[_0x9388('0x2d')][_0x9388('0x37')](_0x9388('0x85'))){_0x4d6fb1[_0x9388('0x15')]=qs[_0x9388('0x15')](_0xd9fd1b[_0x9388('0x2d')][_0x9388('0x15')]||0xa);_0x4d6fb1['offset']=qs[_0x9388('0x13')](_0xd9fd1b['query']['offset']);}var _0x1a1d05=_0xbbcd65[_0x9388('0x70')](function(_0x364815){if(_0x364815===_0x9388('0xd6')){var _0x5d92cf={'attributes':['id',_0x9388('0xe1'),_0x9388('0xe2'),_0x9388('0xe3'),'destination',_0x9388('0xe4'),'starttime',_0x9388('0xe5'),'duration',_0x9388('0xe6'),_0x9388('0xe7'),'userDisposition','userSecondDisposition','userThirdDisposition',_0x9388('0xe8')],'where':{'ContactId':_0xd9fd1b[_0x9388('0x27')]['id']},'include':[{'model':db['User'],'as':'User','attributes':['id',_0x9388('0x1d'),_0x9388('0xe9'),_0x9388('0x31')]}],'order':[[_0x9388('0xe7'),_0x9388('0xea')]]};if(_0xd9fd1b[_0x9388('0x2d')][_0x9388('0xdc')]){_0x5d92cf[_0x9388('0x5d')][_0x9388('0xe7')]={'$gte':_0x3f6605[_0x9388('0x3e')],'$lte':_0x3f6605['to']};}return db['VoiceCallReport'][_0x9388('0xeb')](_0x5d92cf)[_0x9388('0x18')](function(_0x115529){_0x35807d[_0x9388('0x16')]+=_0x115529['count'];return _[_0x9388('0x70')](_0x115529[_0x9388('0xa0')],function(_0x58da11){var _0x16c082=_0x58da11[_0x9388('0x3a')]({'plain':!![]});_0x16c082[_0x9388('0xd9')]=_0x364815;if(_0x16c082[_0x9388('0xc4')]){_0x16c082[_0x9388('0xc4')]={'id':_0x16c082[_0x9388('0xc4')]['id'],'name':_0x16c082[_0x9388('0xc4')][_0x9388('0x1d')],'fullname':_0x16c082['User']['fullname'],'alias':_0x16c082['User'][_0x9388('0x31')]};}return _0x16c082;});});}else{var _0x588c1e=_['startCase'](_0x364815)+(_0x364815===_0x9388('0xd1')?_0x9388('0xec'):_0x9388('0xed'));var _0x520fe5={'attributes':['id',_0x9388('0xee'),'closedAt',_0x9388('0xe7'),_0x9388('0xe6'),_0x9388('0xef'),_0x9388('0xf0'),_0x9388('0xf1'),_0x9388('0xe8'),_0x588c1e+'Id'],'where':{'ContactId':_0xd9fd1b[_0x9388('0x27')]['id']},'include':[{'model':db[_0x588c1e],'as':_0x9388('0xed'),'attributes':['id','name',_0x9388('0xf2')]},{'model':db[_0x9388('0xc4')],'as':_0x9388('0xf3'),'attributes':['id','name',_0x9388('0xe9')]},{'model':db[_0x9388('0x7b')],'as':_0x9388('0x66'),'attributes':['id',_0x9388('0x1d'),_0x9388('0x67')],'through':{'attributes':[]}}],'order':[[_0x9388('0xe7'),_0x9388('0xea')]]};if(_0xd9fd1b['query']['range']){_0x520fe5[_0x9388('0x5d')]['createdAt']={'$gte':_0x3f6605[_0x9388('0x3e')],'$lte':_0x3f6605['to']};}switch(_0x364815){case _0x9388('0xd1'):_0x520fe5[_0x9388('0x7e')][_0x9388('0x5f')](_0x9388('0xf4'),_0x9388('0xf5'),_0x9388('0xf6'),_0x9388('0xf7'),_0x9388('0xf8'),_0x9388('0xf9'),_0x9388('0xfa'),_0x9388('0xfb'),_0x9388('0xfc'));break;case _0x9388('0xd0'):_0x520fe5[_0x9388('0x7e')][_0x9388('0x5f')](_0x9388('0xfd'),_0x9388('0xfe'));break;case _0x9388('0xd3'):_0x520fe5[_0x9388('0x7e')][_0x9388('0x5f')](_0x9388('0xff'),_0x9388('0x100'));break;}return db[_[_0x9388('0x101')](_0x364815)+'Interaction'][_0x9388('0xeb')](_0x520fe5)[_0x9388('0x18')](function(_0x4c866b){_0x35807d[_0x9388('0x16')]+=_0x4c866b[_0x9388('0x16')];return _[_0x9388('0x70')](_0x4c866b['rows'],function(_0x1c9c72){var _0x3a065d=_0x1c9c72[_0x9388('0x3a')]({'plain':!![]});_0x3a065d[_0x9388('0xd9')]=_0x364815;if(_0x3a065d[_0x9388('0xf3')]){_0x3a065d[_0x9388('0xf3')]={'id':_0x3a065d[_0x9388('0xf3')]['id'],'name':_0x3a065d[_0x9388('0xf3')][_0x9388('0x1d')],'fullname':_0x3a065d[_0x9388('0xf3')][_0x9388('0xe9')]};}return _0x3a065d;});});}});return Promise[_0x9388('0x64')](_0x1a1d05);})[_0x9388('0x18')](function(_0x3a254d){return _(_0x3a254d)[_0x9388('0x102')]()[_0x9388('0x103')](_0x9388('0xe7'))['reverse']()[_0x9388('0x104')]();})[_0x9388('0x18')](function(_0x5e3bc7){_0x35807d[_0x9388('0xa0')]=_0x4d6fb1[_0x9388('0x15')]?_0x5e3bc7['slice'](_0x4d6fb1[_0x9388('0x13')],_0x4d6fb1[_0x9388('0x13')]+_0x4d6fb1[_0x9388('0x15')]):_0x5e3bc7;return _0x35807d;})[_0x9388('0x18')](respondWithFilteredResult(_0x311739,_0x4d6fb1))[_0x9388('0x24')](handleError(_0x311739,null));};
\ No newline at end of file