Built motion from commit (unavailable).|2.5.11
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 7b644da..3eadb98 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x93d4=['offlineMessageBody','ChatOfflineMessage','MailAccount','findOne','MailServerOut','Smtp','forwardOfflineAddress','service','host','port','secure','auth','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','addInteraction','Contact','fullname','internal','Tag','Tags','color','tag','rows','Command','getSnippet','timezone','iftime\x20%s,%s','interval','indexOf','true','ONLINE','No\x20timezone','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','inspect','Interval','Intervals','getProactiveActions','getLicense','virtual','custom','License','increment','chatLicenseExceeded','all','some','server/files/chat/iframe.js','remote','connection','remoteAddress','alignment','verticalAlignment','sequelize','transaction','ChatApplication','findAndCountAll','getApplications','addProactiveActions','omit','ChatProactiveAction','getFields','online','false','offlineForm','onlineForm','items','fromKey','getOfflineMessages','addAgents','emit','userChatWebsite:save','removeAgents','userChatWebsite:remove','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','redis','defaults','localhost','socket.io-emitter','./chatWebsite.socket','register','jayson/promise','client','http','request','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','error','code','message','sendStatus','status','json','count','offset','set','Content-Range','reject','save','then','destroy','get','ChatWebsites','UserProfileResource','end','stack','name','send','Pause','mandatoryDispositionPause','map','rawAttributes','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','limit','order','sort','pick','where','merge','type','VIRTUAL','filter','options','ChatWebsite','findAll','catch','show','params','include','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','addDisposition','ChatWebsiteId','Disposition','includeAll','removeDispositions','addAnswer','CannedAnswer','getAnswers','nolimit','removeAnswers','ids','addLogo','sitepic','file','addAvatar','agentAvatar','filename','addCustomerAvatar','customerAvatar','addSystemAvatar','systemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','isNil','server/files/images/logos/','download','getAvatar','server/files/images/avatars/default_avatar.png','existsSync','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','server/files/images/avatars/system_avatar.png','notify','setUA','headers','user-agent','chat','describe','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','from\x20is\x20mandatory','mapKey','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','from','CmList','List','Contacts','DESC','Applications','applications','orderBy','priority','asc','account','contact','customerIp','cf-connecting-ip','x-forwarded-for','split','firstName','lastName','x-real-port','referer','browser','version','%s\x20%s','unknown','format','device','vendor','%s\x20%s\x20%s','stringify','threadId','externalUrl','ContactId','interaction','ChatInteraction','spread','messageId','update','created','autoclose','push','close','*,*,*,*','AttachmentId','User','UserId','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','offline','mapKeyOffline','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmContact','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs'];(function(_0x46e363,_0x45d7e2){var _0x3fb059=function(_0x5e6274){while(--_0x5e6274){_0x46e363['push'](_0x46e363['shift']());}};_0x3fb059(++_0x45d7e2);}(_0x93d4,0x171));var _0x493d=function(_0x60bf8f,_0x4ea084){_0x60bf8f=_0x60bf8f-0x0;var _0x48c82f=_0x93d4[_0x60bf8f];return _0x48c82f;};'use strict';var pdf=require(_0x493d('0x0'));var emlformat=require(_0x493d('0x1'));var rimraf=require(_0x493d('0x2'));var zipdir=require(_0x493d('0x3'));var jsonpatch=require(_0x493d('0x4'));var rp=require(_0x493d('0x5'));var moment=require(_0x493d('0x6'));var BPromise=require(_0x493d('0x7'));var Mustache=require(_0x493d('0x8'));var util=require(_0x493d('0x9'));var path=require(_0x493d('0xa'));var sox=require('sox');var csv=require(_0x493d('0xb'));var ejs=require(_0x493d('0xc'));var fs=require('fs');var _=require(_0x493d('0xd'));var squel=require(_0x493d('0xe'));var crypto=require('crypto');var jsforce=require(_0x493d('0xf'));var deskjs=require(_0x493d('0x10'));var toCsv=require(_0x493d('0xb'));var querystring=require(_0x493d('0x11'));var Papa=require(_0x493d('0x12'));var Redis=require(_0x493d('0x13'));var authService=require(_0x493d('0x14'));var qs=require(_0x493d('0x15'));var as=require(_0x493d('0x16'));var hardwareService=require(_0x493d('0x17'));var logger=require('../../config/logger')(_0x493d('0x18'));var utils=require(_0x493d('0x19'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0x493d('0x1a')]=_[_0x493d('0x1b')](config[_0x493d('0x1a')],{'host':_0x493d('0x1c'),'port':0x18eb});var socket=require(_0x493d('0x1d'))(new Redis(config[_0x493d('0x1a')]));require(_0x493d('0x1e'))[_0x493d('0x1f')](socket);var jayson=require(_0x493d('0x20'));var client=jayson[_0x493d('0x21')]['http']({'port':0x232c});var client9002=jayson[_0x493d('0x21')]['http']({'port':0x232a});var client9003=jayson[_0x493d('0x21')][_0x493d('0x22')]({'port':0x232b});function respondWithRpcPromise(_0x3cb1c0,_0x2c24c2,_0x44008b,_0x4fd02c){return new BPromise(function(_0x58a63a,_0x5ad71d){var _0x589bab=_0x4fd02c||client;return _0x589bab[_0x493d('0x23')](_0x3cb1c0,_0x44008b)['then'](function(_0x58dab0){logger[_0x493d('0x24')](_0x493d('0x25'),_0x2c24c2,_0x493d('0x26'));logger[_0x493d('0x27')]('ChatWebsite,\x20%s,\x20%s,\x20%s',_0x2c24c2,_0x493d('0x26'),JSON['stringify'](_0x58dab0));if(_0x58dab0['error']){if(_0x58dab0[_0x493d('0x28')][_0x493d('0x29')]===0x1f4){logger['error'](_0x493d('0x25'),_0x2c24c2,_0x58dab0['error'][_0x493d('0x2a')]);return _0x5ad71d(_0x58dab0[_0x493d('0x28')][_0x493d('0x2a')]);}logger[_0x493d('0x28')](_0x493d('0x25'),_0x2c24c2,_0x58dab0[_0x493d('0x28')]['message']);return _0x58a63a(_0x58dab0[_0x493d('0x28')][_0x493d('0x2a')]);}else{logger[_0x493d('0x24')]('ChatWebsite,\x20%s,\x20%s',_0x2c24c2,'request\x20sent');_0x58a63a(_0x58dab0['result']['message']);}})['catch'](function(_0x167a01){logger[_0x493d('0x28')]('ChatWebsite,\x20%s,\x20%s',_0x2c24c2,_0x167a01);_0x5ad71d(_0x167a01);});});}function respondWithStatusCode(_0x505855,_0x3b3603){_0x3b3603=_0x3b3603||0xcc;return function(_0x51e737){if(_0x51e737){return _0x505855[_0x493d('0x2b')](_0x3b3603);}return _0x505855[_0x493d('0x2c')](_0x3b3603)['end']();};}function respondWithResult(_0x5a89e4,_0xfaa282){_0xfaa282=_0xfaa282||0xc8;return function(_0x5c2ae2){if(_0x5c2ae2){return _0x5a89e4[_0x493d('0x2c')](_0xfaa282)[_0x493d('0x2d')](_0x5c2ae2);}};}function respondWithFilteredResult(_0x50d4ed,_0x20487d){return function(_0x3f6593){if(_0x3f6593){var _0x868246=_0x3f6593[_0x493d('0x2e')],_0x1a3824=_0x20487d[_0x493d('0x2f')],_0x122297=_0x20487d[_0x493d('0x2f')]+_0x20487d['limit'],_0x2c3e93;if(_0x122297>=_0x868246){_0x122297=_0x868246;_0x2c3e93=0xc8;}else{_0x2c3e93=0xce;}_0x50d4ed[_0x493d('0x2c')](_0x2c3e93);return _0x50d4ed[_0x493d('0x30')](_0x493d('0x31'),_0x1a3824+'-'+_0x122297+'/'+_0x868246)[_0x493d('0x2d')](_0x3f6593);}return null;};}function patchUpdates(_0x43f16b){return function(_0x2b0b66){try{jsonpatch['apply'](_0x2b0b66,_0x43f16b,!![]);}catch(_0x1c026a){return BPromise[_0x493d('0x32')](_0x1c026a);}return _0x2b0b66[_0x493d('0x33')]();};}function saveUpdates(_0x1be088,_0x1b05a2){return function(_0x49c7c5){if(_0x49c7c5){return _0x49c7c5['update'](_0x1be088)[_0x493d('0x34')](function(_0xcb5e1c){return _0xcb5e1c;});}return null;};}function removeEntity(_0x568c59,_0x2de197){return function(_0x42662d){if(_0x42662d){return _0x42662d[_0x493d('0x35')]()[_0x493d('0x34')](function(){var _0x898354=_0x42662d[_0x493d('0x36')]({'plain':!![]});var _0x3d3f04=_0x493d('0x37');return db[_0x493d('0x38')][_0x493d('0x35')]({'where':{'type':_0x3d3f04,'resourceId':_0x898354['id']}})[_0x493d('0x34')](function(){return _0x42662d;});})[_0x493d('0x34')](function(){_0x568c59[_0x493d('0x2c')](0xcc)[_0x493d('0x39')]();});}};}function handleEntityNotFound(_0x3b20d4,_0x42e294){return function(_0x3a9911){if(!_0x3a9911){_0x3b20d4['sendStatus'](0x194);}return _0x3a9911;};}function handleError(_0xfde20f,_0x2e6bba){_0x2e6bba=_0x2e6bba||0x1f4;return function(_0x3ca0d1){logger[_0x493d('0x28')](_0x3ca0d1[_0x493d('0x3a')]);if(_0x3ca0d1[_0x493d('0x3b')]){delete _0x3ca0d1[_0x493d('0x3b')];}_0xfde20f['status'](_0x2e6bba)[_0x493d('0x3c')](_0x3ca0d1);};}exports['index']=function(_0x133f70,_0x5b9e05){var _0x44e1d7={'include':[{'model':db[_0x493d('0x3d')],'as':_0x493d('0x3e')}]},_0x3bdbc2={},_0x36ef17={'count':0x0,'rows':[]};var _0x3ea9e2=_[_0x493d('0x3f')](db['ChatWebsite'][_0x493d('0x40')],function(_0x44253c){return{'name':_0x44253c['fieldName'],'type':_0x44253c['type']['key']};});_0x3bdbc2[_0x493d('0x41')]=_[_0x493d('0x3f')](_0x3ea9e2,'name');_0x3bdbc2[_0x493d('0x42')]=_[_0x493d('0x43')](_0x133f70[_0x493d('0x42')]);_0x3bdbc2[_0x493d('0x44')]=_[_0x493d('0x45')](_0x3bdbc2['model'],_0x3bdbc2[_0x493d('0x42')]);_0x44e1d7['attributes']=_[_0x493d('0x45')](_0x3bdbc2[_0x493d('0x41')],qs[_0x493d('0x46')](_0x133f70[_0x493d('0x42')]['fields']));_0x44e1d7[_0x493d('0x47')]=_0x44e1d7[_0x493d('0x47')][_0x493d('0x48')]?_0x44e1d7[_0x493d('0x47')]:_0x3bdbc2['model'];if(!_0x133f70[_0x493d('0x42')][_0x493d('0x49')]('nolimit')){_0x44e1d7[_0x493d('0x4a')]=qs['limit'](_0x133f70['query'][_0x493d('0x4a')]);_0x44e1d7[_0x493d('0x2f')]=qs[_0x493d('0x2f')](_0x133f70[_0x493d('0x42')][_0x493d('0x2f')]);}_0x44e1d7[_0x493d('0x4b')]=qs[_0x493d('0x4c')](_0x133f70[_0x493d('0x42')][_0x493d('0x4c')]);_0x44e1d7['where']=qs['filters'](_[_0x493d('0x4d')](_0x133f70[_0x493d('0x42')],_0x3bdbc2['filters']),_0x3ea9e2);if(_0x133f70[_0x493d('0x42')]['filter']){_0x44e1d7[_0x493d('0x4e')]=_[_0x493d('0x4f')](_0x44e1d7[_0x493d('0x4e')],{'$or':_[_0x493d('0x3f')](_0x3ea9e2,function(_0x3416a7){if(_0x3416a7[_0x493d('0x50')]!==_0x493d('0x51')){var _0x1dd75a={};_0x1dd75a[_0x3416a7[_0x493d('0x3b')]]={'$like':'%'+_0x133f70[_0x493d('0x42')][_0x493d('0x52')]+'%'};return _0x1dd75a;}})});}_0x44e1d7=_[_0x493d('0x4f')]({},_0x44e1d7,_0x133f70[_0x493d('0x53')]);var _0x17a45b={'where':_0x44e1d7[_0x493d('0x4e')]};return db[_0x493d('0x54')][_0x493d('0x2e')](_0x17a45b)['then'](function(_0x29438f){_0x36ef17['count']=_0x29438f;if(_0x133f70[_0x493d('0x42')]['includeAll']){_0x44e1d7['include']=[{'all':!![]}];}return db[_0x493d('0x54')][_0x493d('0x55')](_0x44e1d7);})['then'](function(_0xae380b){_0x36ef17['rows']=_0xae380b;return _0x36ef17;})[_0x493d('0x34')](respondWithFilteredResult(_0x5b9e05,_0x44e1d7))[_0x493d('0x56')](handleError(_0x5b9e05,null));};exports[_0x493d('0x57')]=function(_0x6959bf,_0x234de8){var _0x6685e6={'raw':![],'where':{'id':_0x6959bf[_0x493d('0x58')]['id']},'include':[{'model':db[_0x493d('0x3d')],'as':_0x493d('0x3e')}]},_0x271807={};_0x271807[_0x493d('0x41')]=_[_0x493d('0x43')](db[_0x493d('0x54')][_0x493d('0x40')]);_0x271807['query']=_[_0x493d('0x43')](_0x6959bf[_0x493d('0x42')]);_0x271807[_0x493d('0x44')]=_[_0x493d('0x45')](_0x271807[_0x493d('0x41')],_0x271807[_0x493d('0x42')]);_0x6685e6[_0x493d('0x47')]=_[_0x493d('0x45')](_0x271807['model'],qs[_0x493d('0x46')](_0x6959bf[_0x493d('0x42')]['fields']));_0x6685e6[_0x493d('0x47')]=_0x6685e6[_0x493d('0x47')][_0x493d('0x48')]?_0x6685e6[_0x493d('0x47')]:_0x271807[_0x493d('0x41')];if(_0x6959bf['query']['includeAll']){_0x6685e6[_0x493d('0x59')]=[{'all':!![]}];}_0x6685e6=_[_0x493d('0x4f')]({},_0x6685e6,_0x6959bf[_0x493d('0x53')]);return db[_0x493d('0x54')][_0x493d('0x5a')](_0x6685e6)[_0x493d('0x34')](handleEntityNotFound(_0x234de8,null))['then'](respondWithResult(_0x234de8,null))[_0x493d('0x56')](handleError(_0x234de8,null));};exports[_0x493d('0x5b')]=function(_0x5bfc6f,_0x3b1032){return db['ChatWebsite']['create'](_0x5bfc6f['body'],{})[_0x493d('0x34')](function(_0x3ac20c){var _0x10ac1f=_0x5bfc6f[_0x493d('0x5c')][_0x493d('0x36')]({'plain':!![]});if(!_0x10ac1f)throw new Error(_0x493d('0x5d'));if(_0x10ac1f[_0x493d('0x5e')]===_0x493d('0x5c')){var _0xd6d1a2=_0x3ac20c[_0x493d('0x36')]({'plain':!![]});var _0x316032=_0x493d('0x37');return db[_0x493d('0x5f')][_0x493d('0x5a')]({'where':{'name':_0x316032,'userProfileId':_0x10ac1f[_0x493d('0x60')]},'raw':!![]})[_0x493d('0x34')](function(_0x2347b7){if(_0x2347b7&&_0x2347b7[_0x493d('0x61')]===0x0){return db[_0x493d('0x38')][_0x493d('0x5b')]({'name':_0xd6d1a2['name'],'resourceId':_0xd6d1a2['id'],'type':_0x2347b7[_0x493d('0x3b')],'sectionId':_0x2347b7['id']},{})[_0x493d('0x34')](function(){return _0x3ac20c;});}else{return _0x3ac20c;}})[_0x493d('0x56')](function(_0x20c65c){logger['error'](_0x493d('0x62'),_0x20c65c);throw _0x20c65c;});}return _0x3ac20c;})['then'](respondWithResult(_0x3b1032,0xc9))[_0x493d('0x56')](handleError(_0x3b1032,null));};exports['update']=function(_0x352a34,_0x1177eb){if(_0x352a34[_0x493d('0x63')]['id']){delete _0x352a34[_0x493d('0x63')]['id'];}return db[_0x493d('0x54')]['find']({'where':{'id':_0x352a34[_0x493d('0x58')]['id']},'include':[{'model':db[_0x493d('0x3d')],'as':_0x493d('0x3e')}]})[_0x493d('0x34')](handleEntityNotFound(_0x1177eb,null))['then'](saveUpdates(_0x352a34[_0x493d('0x63')],null))[_0x493d('0x34')](respondWithResult(_0x1177eb,null))[_0x493d('0x56')](handleError(_0x1177eb,null));};exports[_0x493d('0x35')]=function(_0x58d3f5,_0x3c844b){return db[_0x493d('0x54')]['find']({'where':{'id':_0x58d3f5[_0x493d('0x58')]['id']}})['then'](handleEntityNotFound(_0x3c844b,null))[_0x493d('0x34')](removeEntity(_0x3c844b,null))['catch'](handleError(_0x3c844b,null));};exports['describe']=function(_0xcede7c,_0x15e369){return db[_0x493d('0x54')]['describe']()[_0x493d('0x34')](respondWithResult(_0x15e369,null))[_0x493d('0x56')](handleError(_0x15e369,null));};exports[_0x493d('0x64')]=function(_0x2d5992,_0x537e7f,_0x889d9){if(_0x2d5992[_0x493d('0x63')]['id']){delete _0x2d5992['body']['id'];}return db['ChatWebsite'][_0x493d('0x5a')]({'where':{'id':_0x2d5992[_0x493d('0x58')]['id']}})[_0x493d('0x34')](handleEntityNotFound(_0x537e7f,null))[_0x493d('0x34')](function(_0x40bb92){if(_0x40bb92){_0x2d5992[_0x493d('0x63')][_0x493d('0x65')]=_0x40bb92['id'];return db[_0x493d('0x66')][_0x493d('0x5b')](_0x2d5992[_0x493d('0x63')]);}})[_0x493d('0x34')](respondWithResult(_0x537e7f,null))['catch'](handleError(_0x537e7f,null));};exports['getDispositions']=function(_0x462aef,_0x15f0fb,_0x33965c){var _0x45839f={'raw':![],'where':{}};var _0x52f139={};var _0x421669={'count':0x0,'rows':[]};return db[_0x493d('0x54')]['findOne']({'where':{'id':_0x462aef[_0x493d('0x58')]['id']}})[_0x493d('0x34')](handleEntityNotFound(_0x15f0fb,null))[_0x493d('0x34')](function(_0x3c5d27){if(_0x3c5d27){_0x52f139[_0x493d('0x41')]=_[_0x493d('0x43')](db['Disposition'][_0x493d('0x40')]);_0x52f139['query']=_[_0x493d('0x43')](_0x462aef[_0x493d('0x42')]);_0x52f139[_0x493d('0x44')]=_[_0x493d('0x45')](_0x52f139[_0x493d('0x41')],_0x52f139[_0x493d('0x42')]);_0x45839f[_0x493d('0x47')]=_[_0x493d('0x45')](_0x52f139[_0x493d('0x41')],qs[_0x493d('0x46')](_0x462aef[_0x493d('0x42')][_0x493d('0x46')]));_0x45839f[_0x493d('0x47')]=_0x45839f[_0x493d('0x47')][_0x493d('0x48')]?_0x45839f[_0x493d('0x47')]:_0x52f139[_0x493d('0x41')];if(!_0x462aef[_0x493d('0x42')][_0x493d('0x49')]('nolimit')){_0x45839f['limit']=qs[_0x493d('0x4a')](_0x462aef[_0x493d('0x42')][_0x493d('0x4a')]);_0x45839f[_0x493d('0x2f')]=qs[_0x493d('0x2f')](_0x462aef[_0x493d('0x42')][_0x493d('0x2f')]);}_0x45839f[_0x493d('0x4b')]=qs[_0x493d('0x4c')](_0x462aef['query']['sort']);_0x45839f['where']=qs['filters'](_[_0x493d('0x4d')](_0x462aef['query'],_0x52f139[_0x493d('0x44')]));_0x45839f[_0x493d('0x4e')]['ChatWebsiteId']=_0x3c5d27['id'];if(_0x462aef[_0x493d('0x42')][_0x493d('0x52')]){_0x45839f['where']=_[_0x493d('0x4f')](_0x45839f[_0x493d('0x4e')],{'$or':_[_0x493d('0x3f')](_0x45839f[_0x493d('0x47')],function(_0x26a3fa){var _0x586d1c={};_0x586d1c[_0x26a3fa]={'$like':'%'+_0x462aef[_0x493d('0x42')][_0x493d('0x52')]+'%'};return _0x586d1c;})});}_0x45839f=_['merge']({},_0x45839f,_0x462aef[_0x493d('0x53')]);return db[_0x493d('0x66')][_0x493d('0x2e')]({'where':_0x45839f[_0x493d('0x4e')]})[_0x493d('0x34')](function(_0x4f0141){_0x421669[_0x493d('0x2e')]=_0x4f0141;if(_0x462aef[_0x493d('0x42')][_0x493d('0x67')]){_0x45839f['include']=[{'all':!![]}];}return db[_0x493d('0x66')][_0x493d('0x55')](_0x45839f);})[_0x493d('0x34')](function(_0x240511){_0x421669['rows']=_0x240511;return _0x421669;});}})[_0x493d('0x34')](respondWithFilteredResult(_0x15f0fb,_0x45839f))['catch'](handleError(_0x15f0fb,null));};exports[_0x493d('0x68')]=function(_0x9e16d3,_0x2569dc,_0x32f996){return db['ChatWebsite'][_0x493d('0x5a')]({'where':{'id':_0x9e16d3[_0x493d('0x58')]['id']}})[_0x493d('0x34')](handleEntityNotFound(_0x2569dc,null))[_0x493d('0x34')](function(_0x658ffa){if(_0x658ffa){return _0x658ffa[_0x493d('0x68')](_0x9e16d3[_0x493d('0x42')]['ids']);}})['then'](respondWithStatusCode(_0x2569dc,null))[_0x493d('0x56')](handleError(_0x2569dc,null));};exports[_0x493d('0x69')]=function(_0xbd3e63,_0x20d4ea,_0x5d85a7){if(_0xbd3e63['body']['id']){delete _0xbd3e63[_0x493d('0x63')]['id'];}return db[_0x493d('0x54')]['find']({'where':{'id':_0xbd3e63[_0x493d('0x58')]['id']}})[_0x493d('0x34')](handleEntityNotFound(_0x20d4ea,null))['then'](function(_0x276cc2){if(_0x276cc2){_0xbd3e63[_0x493d('0x63')][_0x493d('0x65')]=_0x276cc2['id'];return db[_0x493d('0x6a')][_0x493d('0x5b')](_0xbd3e63[_0x493d('0x63')]);}})[_0x493d('0x34')](respondWithResult(_0x20d4ea,null))[_0x493d('0x56')](handleError(_0x20d4ea,null));};exports[_0x493d('0x6b')]=function(_0x2f3531,_0xcb07a6,_0x342253){var _0xc473fe={'raw':![],'where':{}};var _0xa54195={};var _0x55c5be={'count':0x0,'rows':[]};return db[_0x493d('0x54')]['findOne']({'where':{'id':_0x2f3531[_0x493d('0x58')]['id']}})[_0x493d('0x34')](handleEntityNotFound(_0xcb07a6,null))['then'](function(_0x366fb0){if(_0x366fb0){_0xa54195[_0x493d('0x41')]=_[_0x493d('0x43')](db['CannedAnswer']['rawAttributes']);_0xa54195[_0x493d('0x42')]=_['keys'](_0x2f3531[_0x493d('0x42')]);_0xa54195['filters']=_['intersection'](_0xa54195['model'],_0xa54195[_0x493d('0x42')]);_0xc473fe[_0x493d('0x47')]=_['intersection'](_0xa54195['model'],qs[_0x493d('0x46')](_0x2f3531[_0x493d('0x42')][_0x493d('0x46')]));_0xc473fe['attributes']=_0xc473fe[_0x493d('0x47')][_0x493d('0x48')]?_0xc473fe[_0x493d('0x47')]:_0xa54195['model'];if(!_0x2f3531['query'][_0x493d('0x49')](_0x493d('0x6c'))){_0xc473fe['limit']=qs[_0x493d('0x4a')](_0x2f3531[_0x493d('0x42')][_0x493d('0x4a')]);_0xc473fe['offset']=qs[_0x493d('0x2f')](_0x2f3531[_0x493d('0x42')][_0x493d('0x2f')]);}_0xc473fe[_0x493d('0x4b')]=qs[_0x493d('0x4c')](_0x2f3531[_0x493d('0x42')]['sort']);_0xc473fe[_0x493d('0x4e')]=qs['filters'](_[_0x493d('0x4d')](_0x2f3531[_0x493d('0x42')],_0xa54195[_0x493d('0x44')]));_0xc473fe[_0x493d('0x4e')][_0x493d('0x65')]=_0x366fb0['id'];if(_0x2f3531[_0x493d('0x42')][_0x493d('0x52')]){_0xc473fe[_0x493d('0x4e')]=_[_0x493d('0x4f')](_0xc473fe[_0x493d('0x4e')],{'$or':_['map'](_0xc473fe['attributes'],function(_0x546071){var _0x367c13={};_0x367c13[_0x546071]={'$like':'%'+_0x2f3531[_0x493d('0x42')][_0x493d('0x52')]+'%'};return _0x367c13;})});}_0xc473fe=_['merge']({},_0xc473fe,_0x2f3531[_0x493d('0x53')]);return db[_0x493d('0x6a')][_0x493d('0x2e')]({'where':_0xc473fe[_0x493d('0x4e')]})[_0x493d('0x34')](function(_0x36816c){_0x55c5be['count']=_0x36816c;if(_0x2f3531[_0x493d('0x42')][_0x493d('0x67')]){_0xc473fe[_0x493d('0x59')]=[{'all':!![]}];}return db[_0x493d('0x6a')]['findAll'](_0xc473fe);})[_0x493d('0x34')](function(_0x5392cb){_0x55c5be['rows']=_0x5392cb;return _0x55c5be;});}})[_0x493d('0x34')](respondWithFilteredResult(_0xcb07a6,_0xc473fe))['catch'](handleError(_0xcb07a6,null));};exports[_0x493d('0x6d')]=function(_0x3b2497,_0x4f0570,_0xcce531){return db[_0x493d('0x54')][_0x493d('0x5a')]({'where':{'id':_0x3b2497[_0x493d('0x58')]['id']}})[_0x493d('0x34')](handleEntityNotFound(_0x4f0570,null))['then'](function(_0x32cc84){if(_0x32cc84){return _0x32cc84['removeAnswers'](_0x3b2497[_0x493d('0x42')][_0x493d('0x6e')]);}})[_0x493d('0x34')](respondWithStatusCode(_0x4f0570,null))[_0x493d('0x56')](handleError(_0x4f0570,null));};exports[_0x493d('0x6f')]=function(_0x31551e,_0x341a9f,_0x162229){_0x31551e[_0x493d('0x63')][_0x493d('0x70')]=_0x31551e[_0x493d('0x71')]['filename'];return db[_0x493d('0x54')][_0x493d('0x5a')]({'where':{'id':_0x31551e[_0x493d('0x58')]['id']}})[_0x493d('0x34')](handleEntityNotFound(_0x341a9f,null))[_0x493d('0x34')](saveUpdates(_0x31551e[_0x493d('0x63')],null))['then'](respondWithResult(_0x341a9f,null))[_0x493d('0x56')](handleError(_0x341a9f,null));};exports[_0x493d('0x72')]=function(_0x21db59,_0x5b0671,_0x20c42c){_0x21db59['body'][_0x493d('0x73')]=_0x21db59[_0x493d('0x71')][_0x493d('0x74')];return db[_0x493d('0x54')][_0x493d('0x5a')]({'where':{'id':_0x21db59[_0x493d('0x58')]['id']}})['then'](handleEntityNotFound(_0x5b0671,null))[_0x493d('0x34')](saveUpdates(_0x21db59[_0x493d('0x63')],null))[_0x493d('0x34')](respondWithResult(_0x5b0671,null))[_0x493d('0x56')](handleError(_0x5b0671,null));};exports[_0x493d('0x75')]=function(_0x2bb333,_0x2e5894,_0x8fa20e){_0x2bb333['body'][_0x493d('0x76')]=_0x2bb333['file'][_0x493d('0x74')];return db['ChatWebsite']['find']({'where':{'id':_0x2bb333[_0x493d('0x58')]['id']}})['then'](handleEntityNotFound(_0x2e5894,null))[_0x493d('0x34')](saveUpdates(_0x2bb333['body'],null))[_0x493d('0x34')](respondWithResult(_0x2e5894,null))[_0x493d('0x56')](handleError(_0x2e5894,null));};exports[_0x493d('0x77')]=function(_0x20415a,_0x3aa13e,_0x3f0c22){_0x20415a[_0x493d('0x63')][_0x493d('0x78')]=_0x20415a[_0x493d('0x71')][_0x493d('0x74')];return db['ChatWebsite']['find']({'where':{'id':_0x20415a['params']['id']}})[_0x493d('0x34')](handleEntityNotFound(_0x3aa13e,null))[_0x493d('0x34')](saveUpdates(_0x20415a[_0x493d('0x63')],null))[_0x493d('0x34')](respondWithResult(_0x3aa13e,null))[_0x493d('0x56')](handleError(_0x3aa13e,null));};exports[_0x493d('0x79')]=function(_0x22b8d3,_0x4399ce,_0x1b0cd8){var _0x569982=path[_0x493d('0x7a')](config[_0x493d('0x7b')],_0x493d('0x7c'));var _0x33c0f5={'where':{'id':_0x22b8d3[_0x493d('0x58')]['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x814b35=![];return require('../../config/license/util')['getLicense']()[_0x493d('0x34')](function(_0x19e062){if(_0x19e062){_0x814b35=_0x19e062['custom'];}})[_0x493d('0x34')](function(){return db['ChatWebsite'][_0x493d('0x5a')](_0x33c0f5);})[_0x493d('0x34')](handleEntityNotFound(_0x4399ce,null))[_0x493d('0x34')](function(_0xd35849){if(_0xd35849){if(!_[_0x493d('0x7d')](_0xd35849[_0x493d('0x70')])){if(fs['existsSync'](path['join'](config[_0x493d('0x7b')],_0x493d('0x7e'),_0xd35849['sitepic']))&&_0x814b35){_0x569982=path[_0x493d('0x7a')](config['root'],'server/files/images/logos/',_0xd35849[_0x493d('0x70')]);}}return _0x4399ce[_0x493d('0x7f')](_0x569982);}})[_0x493d('0x56')](handleError(_0x4399ce,null));};exports[_0x493d('0x80')]=function(_0x495fc6,_0x6f8484,_0x1adb18){var _0x3685fa=path['join'](config['root'],_0x493d('0x81'));var _0x1086d3={'where':{'id':_0x495fc6[_0x493d('0x58')]['id']},'attributes':['id',_0x493d('0x73')],'raw':!![]};return db['ChatWebsite'][_0x493d('0x5a')](_0x1086d3)[_0x493d('0x34')](handleEntityNotFound(_0x6f8484,null))[_0x493d('0x34')](function(_0x5e842d){if(_0x5e842d){if(!_[_0x493d('0x7d')](_0x5e842d[_0x493d('0x73')])){if(fs[_0x493d('0x82')](path['join'](config[_0x493d('0x7b')],_0x493d('0x83'),_0x5e842d[_0x493d('0x73')]))){_0x3685fa=path['join'](config['root'],_0x493d('0x83'),_0x5e842d[_0x493d('0x73')]);}}return _0x6f8484['download'](_0x3685fa);}})['catch'](handleError(_0x6f8484,null));};exports[_0x493d('0x84')]=function(_0xe6869c,_0x4db20d,_0x240e28){var _0x443cbe=path[_0x493d('0x7a')](config['root'],_0x493d('0x85'));var _0x1acebf={'where':{'id':_0xe6869c[_0x493d('0x58')]['id']},'attributes':['id',_0x493d('0x76'),_0x493d('0x86')],'raw':!![]};return db[_0x493d('0x54')][_0x493d('0x5a')](_0x1acebf)['then'](handleEntityNotFound(_0x4db20d,null))[_0x493d('0x34')](function(_0x5a89f8){if(_0x5a89f8){if(!_[_0x493d('0x7d')](_0x5a89f8[_0x493d('0x76')])){if(fs[_0x493d('0x82')](path[_0x493d('0x7a')](config['root'],_0x493d('0x83'),_0x5a89f8[_0x493d('0x76')]))&&_0x5a89f8['showCustomerAvatar']){_0x443cbe=path['join'](config[_0x493d('0x7b')],_0x493d('0x83'),_0x5a89f8['customerAvatar']);}}return _0x4db20d['download'](_0x443cbe);}})[_0x493d('0x56')](handleError(_0x4db20d,null));};exports['getSystemAvatar']=function(_0x113d13,_0x3eef13,_0x414adc){var _0x51d1a3=path[_0x493d('0x7a')](config[_0x493d('0x7b')],_0x493d('0x87'));var _0x5e31c2={'where':{'id':_0x113d13[_0x493d('0x58')]['id']},'attributes':['id',_0x493d('0x78')],'raw':!![]};return db[_0x493d('0x54')][_0x493d('0x5a')](_0x5e31c2)[_0x493d('0x34')](handleEntityNotFound(_0x3eef13,null))[_0x493d('0x34')](function(_0x1ea5a7){if(_0x1ea5a7){if(!_[_0x493d('0x7d')](_0x1ea5a7[_0x493d('0x78')])){if(fs['existsSync'](path[_0x493d('0x7a')](config['root'],_0x493d('0x83'),_0x1ea5a7['systemAvatar']))){_0x51d1a3=path[_0x493d('0x7a')](config[_0x493d('0x7b')],_0x493d('0x83'),_0x1ea5a7[_0x493d('0x78')]);}}return _0x3eef13[_0x493d('0x7f')](_0x51d1a3);}})[_0x493d('0x56')](handleError(_0x3eef13,null));};exports[_0x493d('0x88')]=function(_0x4cd4da,_0x11e03d,_0x1ecd15){var _0x11d703=require('user-agent-parser');var _0xe4e341=new _0x11d703();var _0x4e7352=_0xe4e341[_0x493d('0x89')](_0x4cd4da[_0x493d('0x8a')][_0x493d('0x8b')])['getResult']();var _0x37e170={'body':_0x4cd4da[_0x493d('0x63')],'channel':_0x493d('0x8c')};var _0x7fd037=[];var _0x24826c=[];var _0x3767c3={};var _0x499fbd=![];return db['CmContact'][_0x493d('0x8d')]()['then'](function(_0x295d87){if(!_0x295d87){throw new db[(_0x493d('0x8e'))][(_0x493d('0x8f'))](_0x493d('0x90'));}_0x7fd037=_[_0x493d('0x91')](_['keys'](_0x295d87),[_0x493d('0x92'),_0x493d('0x93')]);_0x24826c=_[_0x493d('0x91')](_['keys'](_0x295d87),[_0x493d('0x92'),_0x493d('0x93'),_0x493d('0x94'),_0x493d('0x95')]);if(_0x4cd4da[_0x493d('0x63')]['id']){delete _0x4cd4da['body']['id'];}if(_[_0x493d('0x7d')](_0x4cd4da['body']['from'])){throw new db[(_0x493d('0x8e'))][(_0x493d('0x8f'))](_0x493d('0x96'));}if(_[_0x493d('0x7d')](_0x4cd4da[_0x493d('0x63')][_0x493d('0x63')])||_0x4cd4da[_0x493d('0x63')][_0x493d('0x63')]===''){throw new db['Sequelize'][(_0x493d('0x8f'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0x493d('0x7d')](_0x4cd4da['body'][_0x493d('0x97')])){throw new db[(_0x493d('0x8e'))][(_0x493d('0x8f'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x24826c);}if(!_[_0x493d('0x98')](_0x24826c,_0x4cd4da['body']['mapKey'])){throw new db[(_0x493d('0x8e'))]['ValidationError'](_0x493d('0x99')+_0x24826c);}_0x3767c3[_0x4cd4da[_0x493d('0x63')][_0x493d('0x97')]]=_0x4cd4da['body'][_0x493d('0x9a')];})[_0x493d('0x34')](function(){return db[_0x493d('0x54')][_0x493d('0x5a')]({'where':{'id':_0x4cd4da[_0x493d('0x58')]['id']},'include':[{'model':db[_0x493d('0x9b')],'as':_0x493d('0x9c'),'include':[{'model':db['CmContact'],'as':_0x493d('0x9d'),'where':_0x3767c3,'limit':0x1,'order':[[_0x493d('0x93'),_0x493d('0x9e')]]}]},{'model':db['ChatApplication'],'as':_0x493d('0x9f')}]});})[_0x493d('0x34')](handleEntityNotFound(_0x11e03d,null))[_0x493d('0x34')](function(_0x2b709d){if(_0x2b709d&&_0x2b709d[_0x493d('0x9c')]){_0x37e170['account']=_0x2b709d;_0x37e170[_0x493d('0xa0')]=_0x2b709d[_0x493d('0x9f')];_0x37e170['list']=_0x2b709d[_0x493d('0x9c')];_0x37e170[_0x493d('0xa0')]=_[_0x493d('0xa1')](_0x37e170[_0x493d('0xa0')],[_0x493d('0xa2')],[_0x493d('0xa3')]);if(_0x37e170['account']['Applications']){delete _0x37e170[_0x493d('0xa4')][_0x493d('0x9f')];}if(_0x37e170[_0x493d('0xa4')][_0x493d('0x9c')]&&_0x37e170[_0x493d('0xa4')][_0x493d('0x9c')][_0x493d('0x9d')][_0x493d('0x48')]){return _0x37e170[_0x493d('0xa4')][_0x493d('0x9c')][_0x493d('0x9d')][0x0];}var _0x554723=_[_0x493d('0x1b')](_0x4cd4da[_0x493d('0x63')],{'firstName':_0x4cd4da[_0x493d('0x63')][_0x493d('0x9a')],'ListId':_0x2b709d[_0x493d('0x95')]});_0x554723[_0x4cd4da['body'][_0x493d('0x97')]]=_0x4cd4da[_0x493d('0x63')][_0x493d('0x9a')];return db['CmContact']['create'](_0x554723,{'fields':_0x7fd037,'raw':!![]});}})[_0x493d('0x34')](handleEntityNotFound(_0x11e03d,null))[_0x493d('0x34')](function(_0x4e3f1a){_0x37e170[_0x493d('0xa5')]=_0x4e3f1a;var _0x4a3ffc=_0x4cd4da[_0x493d('0x63')][_0x493d('0xa6')];if(_0x4cd4da[_0x493d('0x8a')]['cf-connecting-ip']){_0x4a3ffc=_0x4cd4da['headers'][_0x493d('0xa7')];}else if(_0x4cd4da[_0x493d('0x8a')][_0x493d('0xa8')]){_0x4a3ffc=_['first'](_0x4cd4da[_0x493d('0x8a')][_0x493d('0xa8')][_0x493d('0xa9')](','));}if(_0x4e3f1a){var _0x55942f={'ContactId':_0x4e3f1a['id'],'ChatWebsiteId':_0x4cd4da[_0x493d('0x58')]['id'],'from':(_0x4e3f1a[_0x493d('0xaa')]||'')+'\x20'+(_0x4e3f1a[_0x493d('0xab')]||''),'customerIp':_0x4a3ffc,'customerPort':_0x4cd4da[_0x493d('0x8a')][_0x493d('0xac')]?_0x4cd4da[_0x493d('0x8a')]['x-real-port']:null,'referer':_0x4cd4da[_0x493d('0x63')][_0x493d('0xad')],'browserName':_0x4e7352[_0x493d('0xae')][_0x493d('0x3b')]&&_0x4e7352['browser'][_0x493d('0xaf')]?util['format'](_0x493d('0xb0'),_0x4e7352[_0x493d('0xae')]['name'],_0x4e7352[_0x493d('0xae')][_0x493d('0xaf')]):'unknown','browserVersion':_0x4e7352[_0x493d('0xae')][_0x493d('0xaf')]||_0x493d('0xb1'),'osName':util[_0x493d('0xb2')](_0x493d('0xb0'),_0x4e7352['os'][_0x493d('0x3b')],_0x4e7352['os'][_0x493d('0xaf')]),'osVersion':_0x4e7352['os'][_0x493d('0xaf')],'deviceModel':_0x4e7352[_0x493d('0xb3')][_0x493d('0x41')]&&_0x4e7352['device'][_0x493d('0xb4')]?util[_0x493d('0xb2')](_0x493d('0xb5'),_0x4e7352[_0x493d('0xb3')]['model'],_0x4e7352['device'][_0x493d('0xb4')],_0x4e7352[_0x493d('0xb3')][_0x493d('0x50')]):null,'deviceVendor':_0x4e7352[_0x493d('0xb3')][_0x493d('0xb4')],'deviceType':_0x4e7352[_0x493d('0xb3')][_0x493d('0x50')],'formData':JSON[_0x493d('0xb6')](_0x4cd4da['body'])};var _0x6afb7={'ChatWebsiteId':_0x4cd4da['params']['id'],'closed':![]};if(_0x4cd4da['body'][_0x493d('0xb7')]){_0x6afb7[_0x493d('0xb7')]=_0x4cd4da[_0x493d('0x63')][_0x493d('0xb7')];return db['ChatInteraction'][_0x493d('0x5a')]({'where':_0x6afb7})['then'](function(_0x2d6e98){if(_0x2d6e98){return[_0x2d6e98,![]];}_0x55942f[_0x493d('0xb7')]=_0x4cd4da['body']['threadId'];_0x55942f['externalUrl']=_0x4cd4da[_0x493d('0x63')][_0x493d('0xb8')];return db['ChatInteraction'][_0x493d('0x5b')](_0x55942f)[_0x493d('0x34')](function(_0x3c2be5){return[_0x3c2be5,!![]];});});}_0x6afb7[_0x493d('0xb9')]=_0x4e3f1a['id'];if(_0x4cd4da[_0x493d('0x63')][_0x493d('0xba')]&&_0x4cd4da['body'][_0x493d('0xba')]['id']){_0x6afb7['id']=_0x4cd4da[_0x493d('0x63')][_0x493d('0xba')]['id'];return db[_0x493d('0xbb')][_0x493d('0x5a')]({'where':_0x6afb7})[_0x493d('0x34')](function(_0x2180dd){if(_0x2180dd){return[_0x2180dd,![]];}return db[_0x493d('0xbb')][_0x493d('0x5b')](_0x55942f)[_0x493d('0x34')](function(_0x5e0d34){return[_0x5e0d34,!![]];});});}return db['ChatInteraction'][_0x493d('0x5b')](_0x55942f)[_0x493d('0x34')](function(_0x34b22c){return[_0x34b22c,!![]];});}})[_0x493d('0xbc')](function(_0x16b024,_0x413d9b){if(_0x16b024){_0x499fbd=_0x413d9b;if(!_0x413d9b){var _0xc7cceb={'from':(_0x37e170[_0x493d('0xa5')][_0x493d('0xaa')]||'')+'\x20'+(_0x37e170[_0x493d('0xa5')][_0x493d('0xab')]||'')};if(_0x4cd4da[_0x493d('0x63')][_0x493d('0xb7')]&&_0x4cd4da[_0x493d('0x63')]['messageId']&&_0x4cd4da[_0x493d('0x63')][_0x493d('0xb7')]!=_0x4cd4da[_0x493d('0x63')][_0x493d('0xbd')]){_0xc7cceb['threadId']=_0x4cd4da[_0x493d('0x63')][_0x493d('0xbd')];}return _0x16b024[_0x493d('0xbe')](_0xc7cceb);}else{return _0x16b024;}}})[_0x493d('0x34')](function(_0x15be98){_0x37e170[_0x493d('0xba')]=_0x15be98[_0x493d('0x36')]({'plain':!![]});_0x37e170[_0x493d('0xba')][_0x493d('0xbf')]=_0x499fbd;if(_0x37e170[_0x493d('0xba')][_0x493d('0xbf')]){if(_0x37e170[_0x493d('0xa4')][_0x493d('0xc0')]){_0x37e170['applications'][_0x493d('0xc1')]({'id':0x0,'priority':_0x37e170[_0x493d('0xa0')][_0x493d('0x48')]+0x1,'app':_0x493d('0xc2'),'appdata':'unmanaged','interval':_0x493d('0xc3')});}}return db['ChatMessage'][_0x493d('0x5b')]({'body':_0x4cd4da['body'][_0x493d('0x63')],'ChatWebsiteId':_0x4cd4da[_0x493d('0x58')]['id'],'ChatInteractionId':_0x15be98['id'],'direction':'in','ContactId':_0x37e170['contact']['id'],'AttachmentId':_0x4cd4da['body'][_0x493d('0xc4')]});})[_0x493d('0x34')](function(_0x2cdbe1){_0x37e170['message']=_0x2cdbe1;if(_0x37e170[_0x493d('0xba')]['UserId']){return db[_0x493d('0xc5')][_0x493d('0x5a')]({'attributes':['id',_0x493d('0x3b')],'where':{'id':_0x37e170[_0x493d('0xba')][_0x493d('0xc6')]}})[_0x493d('0x34')](function(_0x381bd3){if(_0x381bd3){_0x37e170['applications'][_0x493d('0xc7')]({'id':0x0,'priority':0x0,'app':_0x493d('0xc8'),'appdata':_0x381bd3[_0x493d('0x3b')]+','+(_0x37e170[_0x493d('0xa4')][_0x493d('0xc9')]||0xa),'interval':'*,*,*,*'});_0x37e170[_0x493d('0xca')]=!![];}return respondWithRpcPromise(_0x493d('0xcb'),'startRouting',_0x37e170);});}return respondWithRpcPromise(_0x493d('0xcb'),_0x493d('0xcc'),_0x37e170);})[_0x493d('0x34')](function(_0x4e51d1){respondWithRpcPromise(_0x493d('0xcd'),'EventManager',{'event':_0x493d('0x88'),'message':_0x4e51d1},client9002);return _0x4e51d1;})[_0x493d('0x34')](respondWithResult(_0x11e03d,null))[_0x493d('0x56')](handleError(_0x11e03d,null));};exports[_0x493d('0xce')]=function(_0x85421d,_0x44c1c4,_0x316614){var _0x5403e8,_0x24651f,_0xa3f34f;var _0x4e9ec4=[];var _0x1b9aed=[];var _0x10a642={};return db['CmContact']['describe']()['then'](function(_0xe9f74d){if(!_0xe9f74d){throw new db['Sequelize']['ValidationError'](_0x493d('0x90'));}_0x1b9aed=_[_0x493d('0x91')](_[_0x493d('0x43')](_0xe9f74d),[_0x493d('0x92'),_0x493d('0x93')]);_0x4e9ec4=_[_0x493d('0x91')](_[_0x493d('0x43')](_0xe9f74d),['createdAt',_0x493d('0x93'),'CompanyId',_0x493d('0x95')]);if(_0x85421d[_0x493d('0x63')]['id']){delete _0x85421d[_0x493d('0x63')]['id'];}if(_[_0x493d('0x7d')](_0x85421d[_0x493d('0x63')][_0x493d('0x9a')])){throw _0x44c1c4[_0x493d('0x2c')](0x1f4)[_0x493d('0x3c')](new db[(_0x493d('0x8e'))][(_0x493d('0x8f'))](_0x493d('0x96')));}if(_[_0x493d('0x7d')](_0x85421d[_0x493d('0x63')][_0x493d('0x63')])||_0x85421d[_0x493d('0x63')][_0x493d('0x63')]===''){throw _0x44c1c4[_0x493d('0x2c')](0x1f4)[_0x493d('0x3c')](new db[(_0x493d('0x8e'))][(_0x493d('0x8f'))]('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0x493d('0x7d')](_0x85421d[_0x493d('0x63')][_0x493d('0xcf')])){throw _0x44c1c4['status'](0x1f4)[_0x493d('0x3c')](new db['Sequelize'][(_0x493d('0x8f'))]('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4e9ec4));}if(!_[_0x493d('0x98')](_0x4e9ec4,_0x85421d[_0x493d('0x63')]['mapKeyOffline'])){throw _0x44c1c4[_0x493d('0x2c')](0x1f4)['send'](new db[(_0x493d('0x8e'))]['ValidationError'](_0x493d('0xd0')+_0x4e9ec4));}_0x10a642[_0x85421d[_0x493d('0x63')][_0x493d('0xcf')]]=_0x85421d[_0x493d('0x63')]['from'];})['then'](function(){return db['ChatWebsite']['find']({'where':{'id':_0x85421d[_0x493d('0x58')]['id']},'include':[{'model':db[_0x493d('0x9b')],'as':_0x493d('0x9c')}]});})['then'](handleEntityNotFound(_0x44c1c4,null))[_0x493d('0x34')](function(_0x511f48){if(_0x511f48&&_0x511f48[_0x493d('0x9c')]){_0x24651f=_0x511f48;var _0xdeac5b=_[_0x493d('0x1b')](_0x85421d[_0x493d('0x63')],{'firstName':_0x85421d[_0x493d('0x63')][_0x493d('0x9a')],'phone':_0x85421d[_0x493d('0x63')][_0x493d('0x9a')],'ListId':_0x511f48[_0x493d('0x95')]});_0xdeac5b[_0x85421d[_0x493d('0x63')]['mapKeyOffline']]=_0x85421d[_0x493d('0x63')][_0x493d('0x9a')];return db[_0x493d('0xd1')]['findOrCreate']({'where':_0x10a642,'defaults':_0xdeac5b});}})[_0x493d('0xbc')](function(_0x46f801){if(_0x46f801){_0xa3f34f=_0x46f801;var _0xe49457=fs[_0x493d('0xd2')](path[_0x493d('0x7a')](config[_0x493d('0x7b')],_0x493d('0xd3')),_0x493d('0xd4'));var _0x5cfe9b=ejs[_0x493d('0xd5')](_0xe49457,{'body':_[_0x493d('0xd6')](_0x85421d['body'][_0x493d('0x63')]),'bodyTitle':_0x24651f[_0x493d('0xd7')]});return db[_0x493d('0xd8')][_0x493d('0x5b')]({'body':_0x5cfe9b,'ContactId':_0x46f801['id'],'ChatWebsiteId':_0x24651f['id']});}})[_0x493d('0x34')](function(_0x4ea4d5){if(_0x4ea4d5){_0x5403e8=_0x4ea4d5;return db[_0x493d('0xd9')][_0x493d('0xda')]({'where':{'service':!![]},'include':[{'model':db[_0x493d('0xdb')],'as':_0x493d('0xdc'),'raw':!![]}]});}})[_0x493d('0x34')](function(_0x305edd){if(_0x305edd&&_0x305edd[_0x493d('0xdc')]&&_0x24651f[_0x493d('0xdd')]){var _0x345916={'tls':{'rejectUnauthorized':![]}};if(_0x305edd[_0x493d('0xdc')][_0x493d('0xde')]){_0x345916[_0x493d('0xde')]=_0x305edd[_0x493d('0xdc')][_0x493d('0xde')];}else{_0x345916[_0x493d('0xdf')]=_0x305edd[_0x493d('0xdc')]['host'];_0x345916[_0x493d('0xe0')]=_0x305edd['Smtp']['port'];_0x345916['secure']=_0x305edd[_0x493d('0xdc')][_0x493d('0xe1')];}if(_0x305edd[_0x493d('0xdc')]['authentication']){_0x345916[_0x493d('0xe2')]={'user':_0x305edd[_0x493d('0xdc')][_0x493d('0x5c')],'pass':_0x305edd[_0x493d('0xdc')][_0x493d('0xe3')]};}return respondWithRpcPromise(_0x493d('0xe4'),_0x493d('0xe5'),{'account':_0x345916,'message':{'from':util[_0x493d('0xb2')](_0x493d('0xe6'),_0x305edd[_0x493d('0x3b')],_0x305edd[_0x493d('0xe7')]||_0x305edd[_0x493d('0xdc')][_0x493d('0x5c')]),'to':_0x24651f[_0x493d('0xdd')],'subject':_0x24651f[_0x493d('0xe8')],'text':_0x5403e8[_0x493d('0x63')]}},client9003)['then'](function(){return _0x5403e8;})[_0x493d('0x56')](function(_0x43c396){console[_0x493d('0x28')](_0x43c396);});}})[_0x493d('0x34')](function(){if(_0x5403e8){return _0x5403e8;}})[_0x493d('0x34')](respondWithResult(_0x44c1c4,null))[_0x493d('0x56')](handleError(_0x44c1c4,null));};exports[_0x493d('0xe9')]=function(_0x47955c,_0x1e61a7,_0x26b34b){return db['ChatInteraction'][_0x493d('0x5a')]({'where':{'id':_0x47955c[_0x493d('0x58')]['id']}})[_0x493d('0x34')](handleEntityNotFound(_0x1e61a7,null))[_0x493d('0x34')](function(_0x4d3ff5){if(_0x4d3ff5){return _0x4d3ff5[_0x493d('0xe9')](_0x47955c[_0x493d('0x63')][_0x493d('0x6e')],_['omit'](_0x47955c[_0x493d('0x63')],[_0x493d('0x6e'),'id'])||{});}})['then'](respondWithResult(_0x1e61a7,null))[_0x493d('0x56')](handleError(_0x1e61a7,null));};exports['getInteractions']=function(_0x36675d,_0x19a7b3,_0x4cae0e){var _0x4c6fd6={'raw':![],'where':{}};var _0x37d0d7={};var _0x19694e={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x493d('0xda')]({'where':{'id':_0x36675d[_0x493d('0x58')]['id']}})['then'](handleEntityNotFound(_0x19a7b3,null))[_0x493d('0x34')](function(_0x3d3b72){if(_0x3d3b72){_0x37d0d7[_0x493d('0x41')]=_[_0x493d('0x43')](db['ChatInteraction'][_0x493d('0x40')]);_0x37d0d7[_0x493d('0x42')]=_[_0x493d('0x43')](_0x36675d[_0x493d('0x42')]);_0x37d0d7[_0x493d('0x44')]=_[_0x493d('0x45')](_0x37d0d7[_0x493d('0x41')],_0x37d0d7[_0x493d('0x42')]);_0x4c6fd6[_0x493d('0x47')]=_['intersection'](_0x37d0d7[_0x493d('0x41')],qs[_0x493d('0x46')](_0x36675d[_0x493d('0x42')][_0x493d('0x46')]));_0x4c6fd6['attributes']=_0x4c6fd6[_0x493d('0x47')]['length']?_0x4c6fd6[_0x493d('0x47')]:_0x37d0d7['model'];if(!_0x36675d[_0x493d('0x42')]['hasOwnProperty'](_0x493d('0x6c'))){_0x4c6fd6['limit']=qs[_0x493d('0x4a')](_0x36675d[_0x493d('0x42')]['limit']);_0x4c6fd6[_0x493d('0x2f')]=qs[_0x493d('0x2f')](_0x36675d['query'][_0x493d('0x2f')]);}_0x4c6fd6[_0x493d('0x4b')]=qs[_0x493d('0x4c')](_0x36675d['query']['sort']);_0x4c6fd6['where']=qs[_0x493d('0x44')](_[_0x493d('0x4d')](_0x36675d[_0x493d('0x42')],_0x37d0d7[_0x493d('0x44')]));_0x4c6fd6['where'][_0x493d('0x65')]=_0x3d3b72['id'];if(_0x36675d['query'][_0x493d('0x52')]){_0x4c6fd6[_0x493d('0x4e')]=_[_0x493d('0x4f')](_0x4c6fd6[_0x493d('0x4e')],{'$or':_[_0x493d('0x3f')](_0x4c6fd6[_0x493d('0x47')],function(_0x2974b4){var _0x50bcee={};_0x50bcee[_0x2974b4]={'$like':'%'+_0x36675d[_0x493d('0x42')][_0x493d('0x52')]+'%'};return _0x50bcee;})});}_0x4c6fd6=_['merge']({},_0x4c6fd6,_0x36675d[_0x493d('0x53')]);return db[_0x493d('0xbb')]['count']({'where':_0x4c6fd6['where']})['then'](function(_0x35693d){_0x19694e[_0x493d('0x2e')]=_0x35693d;if(_0x36675d['query'][_0x493d('0x67')]){_0x4c6fd6[_0x493d('0x59')]=[{'model':db[_0x493d('0xd1')],'as':_0x493d('0xea'),'required':![]},{'model':db[_0x493d('0xc5')],'as':'Owner','attributes':[_0x493d('0x3b'),_0x493d('0xeb'),_0x493d('0xec')],'required':![]},{'model':db[_0x493d('0xed')],'as':_0x493d('0xee'),'attributes':['id',_0x493d('0x3b'),_0x493d('0xef')],'where':_0x36675d[_0x493d('0x42')][_0x493d('0xf0')]?{'id':_0x36675d[_0x493d('0x42')][_0x493d('0xf0')]}:undefined,'required':_0x36675d[_0x493d('0x42')][_0x493d('0xf0')]?!![]:![]}];}return db[_0x493d('0xbb')][_0x493d('0x55')](_0x4c6fd6);})[_0x493d('0x34')](function(_0x42cf2b){_0x19694e[_0x493d('0xf1')]=_0x42cf2b;return _0x19694e;});}})[_0x493d('0x34')](respondWithFilteredResult(_0x19a7b3,_0x4c6fd6))[_0x493d('0x56')](handleError(_0x19a7b3,null));};function iftimePromise(_0x1ce3b6,_0x3bf2d6){return respondWithRpcPromise(_0x493d('0xf2'),_0x493d('0xf3'),{'command':_0x3bf2d6[_0x493d('0xf4')]?util['format'](_0x493d('0xf5'),_0x1ce3b6[_0x493d('0xf6')],_0x3bf2d6[_0x493d('0xf4')]):util['format']('iftime\x20%s',_0x1ce3b6[_0x493d('0xf6')])},client9002)[_0x493d('0x34')](function(_0x13b255){var _0xa9763a=_0x13b255&&_0x13b255[_0x493d('0xf7')](_0x493d('0xf8'))>=0x0?!![]:![];logger[_0x493d('0x24')]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x3bf2d6['id'],_0x1ce3b6['id'],_0x1ce3b6[_0x493d('0xf6')],_0xa9763a?_0x493d('0xf9'):'OFFLINE',_0x3bf2d6[_0x493d('0xf4')]?_0x3bf2d6[_0x493d('0xf4')]:_0x493d('0xfa'));return _0xa9763a;})['catch'](function(_0x44be48){logger['error'](_0x493d('0xfb'),_0x3bf2d6['id'],_0x1ce3b6['id'],_0x1ce3b6['interval'],util[_0x493d('0xfc')](_0x44be48,{'showHidden':![],'depth':null}),_0x3bf2d6[_0x493d('0xf4')]?_0x3bf2d6[_0x493d('0xf4')]:_0x493d('0xfa'));return![];});}exports['getSnippet']=function(_0x504bce,_0x169609,_0x58817b){var _0x4916d1=0x0;var _0x28a528=0x0;var _0x5bc42b=![];var _0x54ff9b;var _0x573767;return db[_0x493d('0x54')][_0x493d('0x5a')]({'where':{'id':_0x504bce[_0x493d('0x58')]['id']},'include':[{'model':db[_0x493d('0xfd')],'as':_0x493d('0xfd'),'include':[{'model':db[_0x493d('0xfd')],'as':_0x493d('0xfe'),'attributes':['id',_0x493d('0xf6')],'raw':!![]}]}]})[_0x493d('0x34')](handleEntityNotFound(_0x169609,null))['then'](function(_0x32de7b){if(_0x32de7b){_0x54ff9b=_0x32de7b;return _0x32de7b[_0x493d('0xff')]({'raw':!![]});}})[_0x493d('0x34')](function(_0x416739){if(_0x54ff9b){if(_0x416739){_0x573767=_0x416739;}}return require('../../config/license/util')[_0x493d('0x100')]();})['then'](function(_0x5ed3d7){if(_0x5ed3d7){_0x28a528=_0x5ed3d7[_0x493d('0x101')];_0x5bc42b=_0x5ed3d7[_0x493d('0x102')];}})[_0x493d('0x34')](function(){return db[_0x493d('0xbb')][_0x493d('0x2e')]({'where':{'closed':![]}});})[_0x493d('0x34')](function(_0x1d76bd){_0x4916d1=_0x1d76bd;if(_0x28a528&&_0x1d76bd>_0x28a528){return db[_0x493d('0x103')]['findOne']({'where':{'id':0x1}})['then'](function(_0x26eb69){if(_0x26eb69){_0x26eb69[_0x493d('0x104')](_0x493d('0x105'));}});}})[_0x493d('0x34')](function(){if(_0x54ff9b[_0x493d('0xfd')]&&_0x54ff9b['Interval'][_0x493d('0xfe')]){var _0x55870e=[];for(var _0x5268dd=0x0;_0x5268dd<_0x54ff9b[_0x493d('0xfd')][_0x493d('0xfe')][_0x493d('0x48')];_0x5268dd++){var _0x268641=_0x54ff9b[_0x493d('0xfd')]['Intervals'][_0x5268dd][_0x493d('0x36')]({'plain':!![]});_0x55870e[_0x493d('0xc1')](iftimePromise(_0x268641,_0x54ff9b));}return BPromise[_0x493d('0x106')](_0x55870e)[_0x493d('0x34')](function(_0x34a902){return _[_0x493d('0x107')](_0x34a902);});}else{return!![];}})[_0x493d('0x34')](function(_0x15201a){var _0x4817cd=fs[_0x493d('0xd2')](path[_0x493d('0x7a')](config[_0x493d('0x7b')],_0x493d('0x108')),_0x493d('0xd4'));var _0x2272a1={'remote':_0x54ff9b[_0x493d('0x109')],'query':querystring['stringify'](_[_0x493d('0x4f')](_0x54ff9b[_0x493d('0x36')]({'plain':!![]}),{'customerIp':_0x504bce[_0x493d('0x8a')]['x-forwarded-for']||_0x504bce[_0x493d('0x8a')]['x-real-ip']||_0x504bce[_0x493d('0x10a')][_0x493d('0x10b')]||_0x504bce['ip'],'referer':_0x504bce[_0x493d('0x8a')][_0x493d('0xad')],'openedInteractions':_0x4916d1,'maxInteractions':_0x28a528,'virtual':_0x5bc42b['virtual'],'online':_0x15201a,'custom':_0x5bc42b}))['replace'](/'/g,'\x5c\x27')};_0x169609[_0x493d('0x3c')](ejs[_0x493d('0xd5')](Mustache[_0x493d('0xd5')](_0x4817cd,_0x2272a1),{'proactiveActions':_0x573767,'alignment':_0x54ff9b[_0x493d('0x10c')],'verticalAlignment':_0x54ff9b[_0x493d('0x10d')],'div_color':_0x54ff9b['color'],'text_color':_0x54ff9b['textColor']}));})[_0x493d('0x56')](handleError(_0x169609,null));};exports['addApplications']=function(_0xf41a25,_0x4ab408,_0x40f07e){return db[_0x493d('0x54')][_0x493d('0xda')]({'where':{'id':_0xf41a25[_0x493d('0x58')]['id']}})[_0x493d('0x34')](handleEntityNotFound(_0x4ab408,null))[_0x493d('0x34')](function(_0x18650f){if(_0x18650f){return db[_0x493d('0x10e')][_0x493d('0x10f')](function(_0x1a7872){return db[_0x493d('0x110')][_0x493d('0x35')]({'where':{'ChatWebsiteId':_0xf41a25[_0x493d('0x58')]['id']},'transaction':_0x1a7872})[_0x493d('0x34')](function(_0x89b6d6){var _0x6594a9=_['map'](_0xf41a25['body'],function(_0x5420c9){_0x5420c9[_0x493d('0x65')]=_0xf41a25[_0x493d('0x58')]['id'];return _0x5420c9;});return db[_0x493d('0x110')]['bulkCreate'](_0x6594a9,{'transaction':_0x1a7872});});})[_0x493d('0x34')](function(){return db['ChatApplication'][_0x493d('0x111')]({'where':{'ChatWebsiteId':_0xf41a25[_0x493d('0x58')]['id']},'order':'priority'});});}})[_0x493d('0x34')](respondWithResult(_0x4ab408,null))[_0x493d('0x56')](handleError(_0x4ab408,null));};exports[_0x493d('0x112')]=function(_0x586887,_0x5ea278,_0x2af3c7){var _0x1aa4e3={};var _0x9fada2={};var _0x4d5f58;var _0x565cec;return db[_0x493d('0x54')]['findOne']({'where':{'id':_0x586887[_0x493d('0x58')]['id']}})[_0x493d('0x34')](handleEntityNotFound(_0x5ea278,null))['then'](function(_0x28c5d9){if(_0x28c5d9){_0x4d5f58=_0x28c5d9;_0x9fada2['model']=_[_0x493d('0x43')](db[_0x493d('0x110')]['rawAttributes']);_0x9fada2['query']=_['keys'](_0x586887['query']);_0x9fada2[_0x493d('0x44')]=_[_0x493d('0x45')](_0x9fada2[_0x493d('0x41')],_0x9fada2['query']);_0x1aa4e3[_0x493d('0x47')]=_[_0x493d('0x45')](_0x9fada2[_0x493d('0x41')],qs[_0x493d('0x46')](_0x586887[_0x493d('0x42')]['fields']));_0x1aa4e3[_0x493d('0x47')]=_0x1aa4e3['attributes'][_0x493d('0x48')]?_0x1aa4e3[_0x493d('0x47')]:_0x9fada2[_0x493d('0x41')];_0x1aa4e3[_0x493d('0x4b')]=qs['sort'](_0x586887[_0x493d('0x42')][_0x493d('0x4c')]);_0x1aa4e3['where']=qs['filters'](_[_0x493d('0x4d')](_0x586887['query'],_0x9fada2['filters']));if(_0x586887[_0x493d('0x42')]['filter']){_0x1aa4e3[_0x493d('0x4e')]=_[_0x493d('0x4f')](_0x1aa4e3['where'],{'$or':_[_0x493d('0x3f')](_0x1aa4e3[_0x493d('0x47')],function(_0x249925){var _0x3e5014={};_0x3e5014[_0x249925]={'$like':'%'+_0x586887[_0x493d('0x42')][_0x493d('0x52')]+'%'};return _0x3e5014;})});}_0x1aa4e3=_[_0x493d('0x4f')]({},_0x1aa4e3,_0x586887[_0x493d('0x53')]);return _0x4d5f58[_0x493d('0x112')](_0x1aa4e3);}})[_0x493d('0x34')](function(_0x121bdc){if(_0x121bdc){_0x565cec=_0x121bdc[_0x493d('0x48')];if(!_0x586887['query'][_0x493d('0x49')](_0x493d('0x6c'))){_0x1aa4e3[_0x493d('0x4a')]=qs[_0x493d('0x4a')](_0x586887[_0x493d('0x42')][_0x493d('0x4a')]);_0x1aa4e3[_0x493d('0x2f')]=qs[_0x493d('0x2f')](_0x586887['query'][_0x493d('0x2f')]);}return _0x4d5f58[_0x493d('0x112')](_0x1aa4e3);}})['then'](function(_0x2f8ffa){if(_0x2f8ffa){return _0x2f8ffa?{'count':_0x565cec,'rows':_0x2f8ffa}:null;}})['then'](respondWithResult(_0x5ea278,null))[_0x493d('0x56')](handleError(_0x5ea278,null));};exports[_0x493d('0x113')]=function(_0x47c700,_0x571967,_0x5196fe){return db['chatProactiveAction'][_0x493d('0x5a')]({'where':{'id':_0x47c700[_0x493d('0x58')]['id']}})[_0x493d('0x34')](handleEntityNotFound(_0x571967,null))[_0x493d('0x34')](function(_0x12cf14){if(_0x12cf14){return _0x12cf14[_0x493d('0x113')](_0x47c700[_0x493d('0x63')][_0x493d('0x6e')],_[_0x493d('0x114')](_0x47c700[_0x493d('0x63')],[_0x493d('0x6e'),'id'])||{});}})['then'](respondWithResult(_0x571967,null))[_0x493d('0x56')](handleError(_0x571967,null));};exports[_0x493d('0xff')]=function(_0x1b6c46,_0x4aba75,_0x3c1122){var _0x233213={};var _0x28e4aa={};var _0x20b58a;var _0x3e0723;return db[_0x493d('0x54')][_0x493d('0xda')]({'where':{'id':_0x1b6c46['params']['id']}})[_0x493d('0x34')](handleEntityNotFound(_0x4aba75,null))['then'](function(_0x4625f7){if(_0x4625f7){_0x20b58a=_0x4625f7;_0x28e4aa[_0x493d('0x41')]=_[_0x493d('0x43')](db[_0x493d('0x115')][_0x493d('0x40')]);_0x28e4aa[_0x493d('0x42')]=_[_0x493d('0x43')](_0x1b6c46[_0x493d('0x42')]);_0x28e4aa['filters']=_[_0x493d('0x45')](_0x28e4aa['model'],_0x28e4aa[_0x493d('0x42')]);_0x233213['attributes']=_[_0x493d('0x45')](_0x28e4aa[_0x493d('0x41')],qs[_0x493d('0x46')](_0x1b6c46['query'][_0x493d('0x46')]));_0x233213[_0x493d('0x47')]=_0x233213['attributes'][_0x493d('0x48')]?_0x233213['attributes']:_0x28e4aa[_0x493d('0x41')];_0x233213[_0x493d('0x4b')]=qs[_0x493d('0x4c')](_0x1b6c46[_0x493d('0x42')][_0x493d('0x4c')]);_0x233213['where']=qs[_0x493d('0x44')](_[_0x493d('0x4d')](_0x1b6c46[_0x493d('0x42')],_0x28e4aa[_0x493d('0x44')]));if(_0x1b6c46[_0x493d('0x42')][_0x493d('0x52')]){_0x233213[_0x493d('0x4e')]=_[_0x493d('0x4f')](_0x233213['where'],{'$or':_[_0x493d('0x3f')](_0x233213[_0x493d('0x47')],function(_0x1f6596){var _0x4663a0={};_0x4663a0[_0x1f6596]={'$like':'%'+_0x1b6c46[_0x493d('0x42')][_0x493d('0x52')]+'%'};return _0x4663a0;})});}_0x233213=_[_0x493d('0x4f')]({},_0x233213,_0x1b6c46[_0x493d('0x53')]);return _0x20b58a[_0x493d('0xff')](_0x233213);}})['then'](function(_0x1fea32){if(_0x1fea32){_0x3e0723=_0x1fea32[_0x493d('0x48')];if(!_0x1b6c46['query'][_0x493d('0x49')](_0x493d('0x6c'))){_0x233213['limit']=qs[_0x493d('0x4a')](_0x1b6c46['query']['limit']);_0x233213['offset']=qs[_0x493d('0x2f')](_0x1b6c46[_0x493d('0x42')][_0x493d('0x2f')]);}return _0x20b58a['getProactiveActions'](_0x233213);}})[_0x493d('0x34')](function(_0x52d89a){if(_0x52d89a){return _0x52d89a?{'count':_0x3e0723,'rows':_0x52d89a}:null;}})[_0x493d('0x34')](respondWithResult(_0x4aba75,null))[_0x493d('0x56')](handleError(_0x4aba75,null));};exports[_0x493d('0x116')]=function(_0x399e9a,_0x12fc3a,_0x494950){var _0x18afd8=_0x399e9a['query'][_0x493d('0x117')]===_0x493d('0x118')?_0x493d('0x119'):_0x493d('0x11a');return db[_0x493d('0x54')][_0x493d('0x5a')]({'attributes':['id',_0x18afd8],'where':{'id':_0x399e9a[_0x493d('0x58')]['id']}})['then'](handleEntityNotFound(_0x12fc3a,null))[_0x493d('0x34')](function(_0x4e4511){if(_0x4e4511){var _0x56908e=_0x4e4511[_0x18afd8];var _0x649b83=_0x56908e&&_0x56908e[_0x493d('0x11b')]?_0x56908e[_0x493d('0x11b')]:[];_0x12fc3a['send']({'fromKey':_['isNil'](_0x56908e['fromKey'])?undefined:_0x56908e[_0x493d('0x11c')],'count':_0x649b83[_0x493d('0x48')],'rows':_0x649b83});}})['catch'](handleError(_0x12fc3a,null));};exports[_0x493d('0x11d')]=function(_0x328a41,_0x56a26f,_0x40a9ba){var _0x34d8c7={'raw':![],'where':{}};var _0x17a709={};var _0x67cae={'count':0x0,'rows':[]};return db[_0x493d('0x54')][_0x493d('0xda')]({'where':{'id':_0x328a41['params']['id']}})['then'](handleEntityNotFound(_0x56a26f,null))[_0x493d('0x34')](function(_0x266744){if(_0x266744){_0x17a709[_0x493d('0x41')]=_[_0x493d('0x43')](db[_0x493d('0xd8')][_0x493d('0x40')]);_0x17a709['query']=_[_0x493d('0x43')](_0x328a41['query']);_0x17a709[_0x493d('0x44')]=_[_0x493d('0x45')](_0x17a709[_0x493d('0x41')],_0x17a709[_0x493d('0x42')]);_0x34d8c7['attributes']=_[_0x493d('0x45')](_0x17a709[_0x493d('0x41')],qs[_0x493d('0x46')](_0x328a41['query']['fields']));_0x34d8c7[_0x493d('0x47')]=_0x34d8c7[_0x493d('0x47')][_0x493d('0x48')]?_0x34d8c7['attributes']:_0x17a709['model'];if(!_0x328a41[_0x493d('0x42')][_0x493d('0x49')](_0x493d('0x6c'))){_0x34d8c7[_0x493d('0x4a')]=qs[_0x493d('0x4a')](_0x328a41['query']['limit']);_0x34d8c7[_0x493d('0x2f')]=qs[_0x493d('0x2f')](_0x328a41[_0x493d('0x42')][_0x493d('0x2f')]);}_0x34d8c7[_0x493d('0x4b')]=qs[_0x493d('0x4c')](_0x328a41['query']['sort']);_0x34d8c7[_0x493d('0x4e')]=qs[_0x493d('0x44')](_[_0x493d('0x4d')](_0x328a41[_0x493d('0x42')],_0x17a709['filters']));_0x34d8c7['where']['ChatWebsiteId']=_0x266744['id'];if(_0x328a41[_0x493d('0x42')][_0x493d('0x52')]){_0x34d8c7[_0x493d('0x4e')]=_['merge'](_0x34d8c7['where'],{'$or':_[_0x493d('0x3f')](_0x34d8c7[_0x493d('0x47')],function(_0x24f141){var _0x2e40c1={};_0x2e40c1[_0x24f141]={'$like':'%'+_0x328a41[_0x493d('0x42')]['filter']+'%'};return _0x2e40c1;})});}_0x34d8c7=_[_0x493d('0x4f')]({},_0x34d8c7,_0x328a41[_0x493d('0x53')]);return db[_0x493d('0xd8')]['count']({'where':_0x34d8c7[_0x493d('0x4e')]})['then'](function(_0x1c90cf){_0x67cae['count']=_0x1c90cf;if(_0x328a41[_0x493d('0x42')][_0x493d('0x67')]){_0x34d8c7['include']=[{'all':!![]}];}else{_0x34d8c7[_0x493d('0x59')]=[{'model':db[_0x493d('0xd1')],'as':_0x493d('0xea'),'required':![]}];}return db[_0x493d('0xd8')][_0x493d('0x55')](_0x34d8c7);})[_0x493d('0x34')](function(_0x394f51){_0x67cae['rows']=_0x394f51;return _0x67cae;});}})['then'](respondWithFilteredResult(_0x56a26f,_0x34d8c7))['catch'](handleError(_0x56a26f,null));};exports['addAgents']=function(_0x1978fa,_0x2debbc,_0x23efa3){return db[_0x493d('0x54')][_0x493d('0x5a')]({'where':{'id':_0x1978fa[_0x493d('0x58')]['id']}})[_0x493d('0x34')](handleEntityNotFound(_0x2debbc,null))['then'](function(_0x53b314){if(_0x53b314){return _0x53b314[_0x493d('0x11e')](_0x1978fa['body'][_0x493d('0x6e')],_[_0x493d('0x114')](_0x1978fa[_0x493d('0x63')],[_0x493d('0x6e'),'id'])||{})[_0x493d('0xbc')](function(_0x40f4a1){for(var _0x329d05=0x0;_0x329d05<_0x1978fa['body'][_0x493d('0x6e')][_0x493d('0x48')];_0x329d05+=0x1){socket[_0x493d('0x11f')](_0x493d('0x120'),{'UserId':_0x1978fa[_0x493d('0x63')][_0x493d('0x6e')][_0x329d05],'ChatWebsiteId':_0x1978fa['params']['id']});}return _0x40f4a1;});}})['then'](respondWithResult(_0x2debbc,null))[_0x493d('0x56')](handleError(_0x2debbc,null));};exports['removeAgents']=function(_0x2f0028,_0x3857c1,_0x40efb5){return db['ChatWebsite'][_0x493d('0x5a')]({'where':{'id':_0x2f0028[_0x493d('0x58')]['id']}})[_0x493d('0x34')](handleEntityNotFound(_0x3857c1,null))[_0x493d('0x34')](function(_0x5c4668){if(_0x5c4668){return _0x5c4668[_0x493d('0x121')](_0x2f0028[_0x493d('0x42')]['ids'])[_0x493d('0x34')](function(){if(_['isArray'](_0x2f0028['query'][_0x493d('0x6e')])){for(var _0x32ae2a=0x0;_0x32ae2a<_0x2f0028['query']['ids'][_0x493d('0x48')];_0x32ae2a+=0x1){socket['emit'](_0x493d('0x122'),{'UserId':Number(_0x2f0028['query'][_0x493d('0x6e')][_0x32ae2a]),'ChatWebsiteId':Number(_0x2f0028['params']['id'])});}}else{socket[_0x493d('0x11f')]('userChatWebsite:remove',{'UserId':Number(_0x2f0028[_0x493d('0x42')][_0x493d('0x6e')]),'ChatWebsiteId':Number(_0x2f0028[_0x493d('0x58')]['id'])});}});}})[_0x493d('0x34')](respondWithStatusCode(_0x3857c1,null))[_0x493d('0x56')](handleError(_0x3857c1,null));};exports['getAgents']=function(_0x26385e,_0x54d152,_0x575ecc){var _0x51d413={};var _0x22b6e5={};var _0x12b684;var _0x47b84b;return db[_0x493d('0x54')][_0x493d('0xda')]({'where':{'id':_0x26385e[_0x493d('0x58')]['id']}})['then'](handleEntityNotFound(_0x54d152,null))[_0x493d('0x34')](function(_0x518d66){if(_0x518d66){_0x12b684=_0x518d66;_0x22b6e5[_0x493d('0x41')]=_[_0x493d('0x43')](db[_0x493d('0xc5')][_0x493d('0x40')]);_0x22b6e5[_0x493d('0x42')]=_['keys'](_0x26385e[_0x493d('0x42')]);_0x22b6e5[_0x493d('0x44')]=_[_0x493d('0x45')](_0x22b6e5[_0x493d('0x41')],_0x22b6e5[_0x493d('0x42')]);_0x51d413[_0x493d('0x47')]=_[_0x493d('0x45')](_0x22b6e5[_0x493d('0x41')],qs[_0x493d('0x46')](_0x26385e[_0x493d('0x42')]['fields']));_0x51d413['attributes']=_0x51d413[_0x493d('0x47')][_0x493d('0x48')]?_0x51d413['attributes']:_0x22b6e5['model'];_0x51d413[_0x493d('0x4b')]=qs[_0x493d('0x4c')](_0x26385e['query'][_0x493d('0x4c')]);_0x51d413[_0x493d('0x4e')]=qs[_0x493d('0x44')](_[_0x493d('0x4d')](_0x26385e[_0x493d('0x42')],_0x22b6e5[_0x493d('0x44')]));if(_0x26385e[_0x493d('0x42')][_0x493d('0x52')]){_0x51d413['where']=_[_0x493d('0x4f')](_0x51d413[_0x493d('0x4e')],{'$or':_[_0x493d('0x3f')](_0x51d413['attributes'],function(_0x27db34){var _0xbd5864={};_0xbd5864[_0x27db34]={'$like':'%'+_0x26385e[_0x493d('0x42')][_0x493d('0x52')]+'%'};return _0xbd5864;})});}_0x51d413=_[_0x493d('0x4f')]({},_0x51d413,_0x26385e[_0x493d('0x53')]);return _0x12b684[_0x493d('0x123')](_0x51d413);}})[_0x493d('0x34')](function(_0x15a60e){if(_0x15a60e){_0x47b84b=_0x15a60e[_0x493d('0x48')];if(!_0x26385e[_0x493d('0x42')][_0x493d('0x49')](_0x493d('0x6c'))){_0x51d413[_0x493d('0x4a')]=qs['limit'](_0x26385e[_0x493d('0x42')][_0x493d('0x4a')]);_0x51d413[_0x493d('0x2f')]=qs[_0x493d('0x2f')](_0x26385e[_0x493d('0x42')]['offset']);}return _0x12b684['getAgents'](_0x51d413);}})[_0x493d('0x34')](function(_0x5e232a){if(_0x5e232a){return _0x5e232a?{'count':_0x47b84b,'rows':_0x5e232a}:null;}})[_0x493d('0x34')](respondWithResult(_0x54d152,null))[_0x493d('0x56')](handleError(_0x54d152,null));};
\ No newline at end of file
+var _0x5d1b=['user-agent','getResult','chat','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','ListId','from','from\x20is\x20mandatory','includes','mapKey','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','List','Contacts','DESC','ChatApplication','Applications','account','applications','list','orderBy','asc','customerIp','headers','cf-connecting-ip','x-forwarded-for','first','lastName','browser','format','%s\x20%s','version','unknown','device','vendor','%s\x20%s\x20%s','threadId','externalUrl','ChatInteraction','ContactId','interaction','spread','contact','messageId','created','autoclose','push','unmanaged','ChatMessage','AttachmentId','User','UserId','agent','waitForTheAssignedAgent','forcedOwnership','Start','EventManager','offline','CompanyId','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','render','ChatOfflineMessage','MailAccount','MailServerOut','Smtp','service','host','port','secure','authentication','auth','SendMail','sendMail','\x22%s\x22\x20<%s>','forwardOfflineAddress','offlineMessageSubject','addInteraction','ids','Contact','Owner','fullname','internal','Tag','color','tag','timezone','iftime\x20%s,%s','interval','iftime\x20%s','indexOf','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','getSnippet','Interval','Intervals','getProactiveActions','virtual','custom','increment','chatLicenseExceeded','all','some','server/files/chat/iframe.js','utf8','remote','x-real-ip','connection','referer','alignment','verticalAlignment','textColor','transaction','bulkCreate','findAndCountAll','getApplications','chatProactiveAction','omit','ChatProactiveAction','online','offlineForm','onlineForm','items','fromKey','getOfflineMessages','addAgents','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','html-pdf','eml-format','zip-dir','moment','bluebird','mustache','to-csv','ejs','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','./chatWebsite.socket','jayson/promise','client','http','info','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','ChatWebsite,\x20%s,\x20%s','message','result','status','end','json','count','offset','limit','set','Content-Range','save','update','then','destroy','UserProfileResource','sendStatus','stack','name','send','index','Pause','mandatoryDispositionPause','map','ChatWebsite','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','nolimit','order','sort','filter','where','options','includeAll','findAll','rows','catch','show','params','keys','include','find','create','body','user','get','role','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','ChatWebsiteId','getDispositions','findOne','Disposition','rawAttributes','hasOwnProperty','pick','merge','removeDispositions','CannedAnswer','getAnswers','removeAnswers','addLogo','file','filename','addAvatar','agentAvatar','addCustomerAvatar','customerAvatar','addSystemAvatar','systemAvatar','getLogo','root','server/files/images/logos/default_logo.svg','sitepic','../../config/license/util','getLicense','isNil','existsSync','join','server/files/images/logos/','download','getAvatar','server/files/images/avatars/default_avatar.png','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','server/files/images/avatars/','getSystemAvatar','notify','user-agent-parser','setUA'];(function(_0x56c3eb,_0x5230c6){var _0x518779=function(_0x383c91){while(--_0x383c91){_0x56c3eb['push'](_0x56c3eb['shift']());}};_0x518779(++_0x5230c6);}(_0x5d1b,0x91));var _0xb5d1=function(_0x183a26,_0x19e750){_0x183a26=_0x183a26-0x0;var _0xd92d3e=_0x5d1b[_0x183a26];return _0xd92d3e;};'use strict';var pdf=require(_0xb5d1('0x0'));var emlformat=require(_0xb5d1('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xb5d1('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xb5d1('0x3'));var BPromise=require(_0xb5d1('0x4'));var Mustache=require(_0xb5d1('0x5'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0xb5d1('0x6'));var ejs=require(_0xb5d1('0x7'));var fs=require('fs');var _=require('lodash');var squel=require(_0xb5d1('0x8'));var crypto=require('crypto');var jsforce=require(_0xb5d1('0x9'));var deskjs=require(_0xb5d1('0xa'));var toCsv=require('to-csv');var querystring=require(_0xb5d1('0xb'));var Papa=require(_0xb5d1('0xc'));var Redis=require(_0xb5d1('0xd'));var authService=require(_0xb5d1('0xe'));var qs=require(_0xb5d1('0xf'));var as=require(_0xb5d1('0x10'));var hardwareService=require(_0xb5d1('0x11'));var logger=require(_0xb5d1('0x12'))(_0xb5d1('0x13'));var utils=require(_0xb5d1('0x14'));var config=require(_0xb5d1('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0xb5d1('0x16'))['db'];config[_0xb5d1('0x17')]=_[_0xb5d1('0x18')](config[_0xb5d1('0x17')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb5d1('0x17')]));require(_0xb5d1('0x19'))['register'](socket);var jayson=require(_0xb5d1('0x1a'));var client=jayson[_0xb5d1('0x1b')]['http']({'port':0x232c});var client9002=jayson['client'][_0xb5d1('0x1c')]({'port':0x232a});var client9003=jayson['client'][_0xb5d1('0x1c')]({'port':0x232b});function respondWithRpcPromise(_0x1aa60b,_0x229864,_0x1523f8,_0x468f87){return new BPromise(function(_0x3fafaf,_0x5af7e3){var _0x3061cb=_0x468f87||client;return _0x3061cb['request'](_0x1aa60b,_0x1523f8)['then'](function(_0x496515){logger[_0xb5d1('0x1d')]('ChatWebsite,\x20%s,\x20%s',_0x229864,_0xb5d1('0x1e'));logger[_0xb5d1('0x1f')](_0xb5d1('0x20'),_0x229864,'request\x20sent',JSON[_0xb5d1('0x21')](_0x496515));if(_0x496515[_0xb5d1('0x22')]){if(_0x496515['error'][_0xb5d1('0x23')]===0x1f4){logger[_0xb5d1('0x22')](_0xb5d1('0x24'),_0x229864,_0x496515[_0xb5d1('0x22')]['message']);return _0x5af7e3(_0x496515[_0xb5d1('0x22')][_0xb5d1('0x25')]);}logger[_0xb5d1('0x22')](_0xb5d1('0x24'),_0x229864,_0x496515['error'][_0xb5d1('0x25')]);return _0x3fafaf(_0x496515[_0xb5d1('0x22')][_0xb5d1('0x25')]);}else{logger[_0xb5d1('0x1d')]('ChatWebsite,\x20%s,\x20%s',_0x229864,_0xb5d1('0x1e'));_0x3fafaf(_0x496515[_0xb5d1('0x26')]['message']);}})['catch'](function(_0xc7377b){logger[_0xb5d1('0x22')](_0xb5d1('0x24'),_0x229864,_0xc7377b);_0x5af7e3(_0xc7377b);});});}function respondWithStatusCode(_0x3ac67a,_0x36ddc3){_0x36ddc3=_0x36ddc3||0xcc;return function(_0x4d5bb1){if(_0x4d5bb1){return _0x3ac67a['sendStatus'](_0x36ddc3);}return _0x3ac67a[_0xb5d1('0x27')](_0x36ddc3)[_0xb5d1('0x28')]();};}function respondWithResult(_0x1dcb0c,_0x5b35ee){_0x5b35ee=_0x5b35ee||0xc8;return function(_0x4a36ae){if(_0x4a36ae){return _0x1dcb0c[_0xb5d1('0x27')](_0x5b35ee)[_0xb5d1('0x29')](_0x4a36ae);}};}function respondWithFilteredResult(_0x55cd8e,_0x4d9a68){return function(_0x6cebde){if(_0x6cebde){var _0x386d01=_0x6cebde[_0xb5d1('0x2a')],_0x39d118=_0x4d9a68[_0xb5d1('0x2b')],_0x2231f7=_0x4d9a68[_0xb5d1('0x2b')]+_0x4d9a68[_0xb5d1('0x2c')],_0x2d4631;if(_0x2231f7>=_0x386d01){_0x2231f7=_0x386d01;_0x2d4631=0xc8;}else{_0x2d4631=0xce;}_0x55cd8e['status'](_0x2d4631);return _0x55cd8e[_0xb5d1('0x2d')](_0xb5d1('0x2e'),_0x39d118+'-'+_0x2231f7+'/'+_0x386d01)[_0xb5d1('0x29')](_0x6cebde);}return null;};}function patchUpdates(_0x4e58da){return function(_0x5d6ca7){try{jsonpatch['apply'](_0x5d6ca7,_0x4e58da,!![]);}catch(_0x5aa1b4){return BPromise['reject'](_0x5aa1b4);}return _0x5d6ca7[_0xb5d1('0x2f')]();};}function saveUpdates(_0x4eb712,_0x58f301){return function(_0x493598){if(_0x493598){return _0x493598[_0xb5d1('0x30')](_0x4eb712)[_0xb5d1('0x31')](function(_0x30f53d){return _0x30f53d;});}return null;};}function removeEntity(_0x42c89b,_0x1687ce){return function(_0x3541d7){if(_0x3541d7){return _0x3541d7[_0xb5d1('0x32')]()[_0xb5d1('0x31')](function(){var _0x1cd88b=_0x3541d7['get']({'plain':!![]});var _0x19140b='ChatWebsites';return db[_0xb5d1('0x33')][_0xb5d1('0x32')]({'where':{'type':_0x19140b,'resourceId':_0x1cd88b['id']}})['then'](function(){return _0x3541d7;});})[_0xb5d1('0x31')](function(){_0x42c89b[_0xb5d1('0x27')](0xcc)['end']();});}};}function handleEntityNotFound(_0x343630,_0x20445c){return function(_0x1b13f9){if(!_0x1b13f9){_0x343630[_0xb5d1('0x34')](0x194);}return _0x1b13f9;};}function handleError(_0x5aa386,_0xc4a7c){_0xc4a7c=_0xc4a7c||0x1f4;return function(_0x13b1a4){logger['error'](_0x13b1a4[_0xb5d1('0x35')]);if(_0x13b1a4[_0xb5d1('0x36')]){delete _0x13b1a4[_0xb5d1('0x36')];}_0x5aa386['status'](_0xc4a7c)[_0xb5d1('0x37')](_0x13b1a4);};}exports[_0xb5d1('0x38')]=function(_0x2cd1fc,_0x571f48){var _0x207f29={'include':[{'model':db[_0xb5d1('0x39')],'as':_0xb5d1('0x3a')}]},_0x44eb1a={},_0xec42c={'count':0x0,'rows':[]};var _0x338d45=_[_0xb5d1('0x3b')](db[_0xb5d1('0x3c')]['rawAttributes'],function(_0x3d875a){return{'name':_0x3d875a[_0xb5d1('0x3d')],'type':_0x3d875a[_0xb5d1('0x3e')][_0xb5d1('0x3f')]};});_0x44eb1a[_0xb5d1('0x40')]=_[_0xb5d1('0x3b')](_0x338d45,'name');_0x44eb1a['query']=_['keys'](_0x2cd1fc[_0xb5d1('0x41')]);_0x44eb1a[_0xb5d1('0x42')]=_[_0xb5d1('0x43')](_0x44eb1a[_0xb5d1('0x40')],_0x44eb1a[_0xb5d1('0x41')]);_0x207f29[_0xb5d1('0x44')]=_['intersection'](_0x44eb1a[_0xb5d1('0x40')],qs[_0xb5d1('0x45')](_0x2cd1fc[_0xb5d1('0x41')][_0xb5d1('0x45')]));_0x207f29['attributes']=_0x207f29[_0xb5d1('0x44')][_0xb5d1('0x46')]?_0x207f29[_0xb5d1('0x44')]:_0x44eb1a[_0xb5d1('0x40')];if(!_0x2cd1fc['query']['hasOwnProperty'](_0xb5d1('0x47'))){_0x207f29[_0xb5d1('0x2c')]=qs[_0xb5d1('0x2c')](_0x2cd1fc[_0xb5d1('0x41')][_0xb5d1('0x2c')]);_0x207f29[_0xb5d1('0x2b')]=qs[_0xb5d1('0x2b')](_0x2cd1fc[_0xb5d1('0x41')][_0xb5d1('0x2b')]);}_0x207f29[_0xb5d1('0x48')]=qs['sort'](_0x2cd1fc['query'][_0xb5d1('0x49')]);_0x207f29['where']=qs[_0xb5d1('0x42')](_['pick'](_0x2cd1fc[_0xb5d1('0x41')],_0x44eb1a[_0xb5d1('0x42')]),_0x338d45);if(_0x2cd1fc[_0xb5d1('0x41')][_0xb5d1('0x4a')]){_0x207f29[_0xb5d1('0x4b')]=_['merge'](_0x207f29[_0xb5d1('0x4b')],{'$or':_[_0xb5d1('0x3b')](_0x338d45,function(_0x52dc31){if(_0x52dc31['type']!=='VIRTUAL'){var _0x40d5a6={};_0x40d5a6[_0x52dc31[_0xb5d1('0x36')]]={'$like':'%'+_0x2cd1fc[_0xb5d1('0x41')][_0xb5d1('0x4a')]+'%'};return _0x40d5a6;}})});}_0x207f29=_['merge']({},_0x207f29,_0x2cd1fc[_0xb5d1('0x4c')]);var _0xe40f68={'where':_0x207f29[_0xb5d1('0x4b')]};return db['ChatWebsite']['count'](_0xe40f68)['then'](function(_0x332048){_0xec42c['count']=_0x332048;if(_0x2cd1fc[_0xb5d1('0x41')][_0xb5d1('0x4d')]){_0x207f29['include']=[{'all':!![]}];}return db[_0xb5d1('0x3c')][_0xb5d1('0x4e')](_0x207f29);})[_0xb5d1('0x31')](function(_0x2a2a51){_0xec42c[_0xb5d1('0x4f')]=_0x2a2a51;return _0xec42c;})['then'](respondWithFilteredResult(_0x571f48,_0x207f29))[_0xb5d1('0x50')](handleError(_0x571f48,null));};exports[_0xb5d1('0x51')]=function(_0x2681e7,_0x551601){var _0x38463e={'raw':![],'where':{'id':_0x2681e7[_0xb5d1('0x52')]['id']},'include':[{'model':db[_0xb5d1('0x39')],'as':_0xb5d1('0x3a')}]},_0x2f9af0={};_0x2f9af0['model']=_[_0xb5d1('0x53')](db[_0xb5d1('0x3c')]['rawAttributes']);_0x2f9af0['query']=_[_0xb5d1('0x53')](_0x2681e7[_0xb5d1('0x41')]);_0x2f9af0[_0xb5d1('0x42')]=_[_0xb5d1('0x43')](_0x2f9af0[_0xb5d1('0x40')],_0x2f9af0[_0xb5d1('0x41')]);_0x38463e[_0xb5d1('0x44')]=_[_0xb5d1('0x43')](_0x2f9af0[_0xb5d1('0x40')],qs[_0xb5d1('0x45')](_0x2681e7[_0xb5d1('0x41')][_0xb5d1('0x45')]));_0x38463e[_0xb5d1('0x44')]=_0x38463e[_0xb5d1('0x44')][_0xb5d1('0x46')]?_0x38463e[_0xb5d1('0x44')]:_0x2f9af0[_0xb5d1('0x40')];if(_0x2681e7[_0xb5d1('0x41')][_0xb5d1('0x4d')]){_0x38463e[_0xb5d1('0x54')]=[{'all':!![]}];}_0x38463e=_['merge']({},_0x38463e,_0x2681e7[_0xb5d1('0x4c')]);return db['ChatWebsite'][_0xb5d1('0x55')](_0x38463e)['then'](handleEntityNotFound(_0x551601,null))['then'](respondWithResult(_0x551601,null))[_0xb5d1('0x50')](handleError(_0x551601,null));};exports[_0xb5d1('0x56')]=function(_0x1438ad,_0x15234c){return db[_0xb5d1('0x3c')]['create'](_0x1438ad[_0xb5d1('0x57')],{})[_0xb5d1('0x31')](function(_0x4b62a4){var _0x2c5556=_0x1438ad[_0xb5d1('0x58')][_0xb5d1('0x59')]({'plain':!![]});if(!_0x2c5556)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2c5556[_0xb5d1('0x5a')]===_0xb5d1('0x58')){var _0xcb6175=_0x4b62a4[_0xb5d1('0x59')]({'plain':!![]});var _0x4870bb='ChatWebsites';return db[_0xb5d1('0x5b')][_0xb5d1('0x55')]({'where':{'name':_0x4870bb,'userProfileId':_0x2c5556[_0xb5d1('0x5c')]},'raw':!![]})['then'](function(_0x198719){if(_0x198719&&_0x198719['autoAssociation']===0x0){return db[_0xb5d1('0x33')][_0xb5d1('0x56')]({'name':_0xcb6175[_0xb5d1('0x36')],'resourceId':_0xcb6175['id'],'type':_0x198719[_0xb5d1('0x36')],'sectionId':_0x198719['id']},{})['then'](function(){return _0x4b62a4;});}else{return _0x4b62a4;}})[_0xb5d1('0x50')](function(_0x436106){logger[_0xb5d1('0x22')](_0xb5d1('0x5d'),_0x436106);throw _0x436106;});}return _0x4b62a4;})[_0xb5d1('0x31')](respondWithResult(_0x15234c,0xc9))[_0xb5d1('0x50')](handleError(_0x15234c,null));};exports[_0xb5d1('0x30')]=function(_0x47fefb,_0x4714d6){if(_0x47fefb[_0xb5d1('0x57')]['id']){delete _0x47fefb[_0xb5d1('0x57')]['id'];}return db[_0xb5d1('0x3c')][_0xb5d1('0x55')]({'where':{'id':_0x47fefb[_0xb5d1('0x52')]['id']},'include':[{'model':db[_0xb5d1('0x39')],'as':_0xb5d1('0x3a')}]})['then'](handleEntityNotFound(_0x4714d6,null))[_0xb5d1('0x31')](saveUpdates(_0x47fefb[_0xb5d1('0x57')],null))[_0xb5d1('0x31')](respondWithResult(_0x4714d6,null))[_0xb5d1('0x50')](handleError(_0x4714d6,null));};exports[_0xb5d1('0x32')]=function(_0xa84d23,_0x269a73){return db[_0xb5d1('0x3c')]['find']({'where':{'id':_0xa84d23['params']['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x269a73,null))[_0xb5d1('0x31')](removeEntity(_0x269a73,null))[_0xb5d1('0x50')](handleError(_0x269a73,null));};exports[_0xb5d1('0x5e')]=function(_0x99722d,_0x1468c6){return db[_0xb5d1('0x3c')]['describe']()[_0xb5d1('0x31')](respondWithResult(_0x1468c6,null))[_0xb5d1('0x50')](handleError(_0x1468c6,null));};exports['addDisposition']=function(_0xc2fb7b,_0x1a99ca,_0x598890){if(_0xc2fb7b['body']['id']){delete _0xc2fb7b[_0xb5d1('0x57')]['id'];}return db[_0xb5d1('0x3c')][_0xb5d1('0x55')]({'where':{'id':_0xc2fb7b[_0xb5d1('0x52')]['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x1a99ca,null))[_0xb5d1('0x31')](function(_0xb9e359){if(_0xb9e359){_0xc2fb7b['body'][_0xb5d1('0x5f')]=_0xb9e359['id'];return db['Disposition']['create'](_0xc2fb7b['body']);}})[_0xb5d1('0x31')](respondWithResult(_0x1a99ca,null))['catch'](handleError(_0x1a99ca,null));};exports[_0xb5d1('0x60')]=function(_0x1a96a5,_0x2b1bb4,_0x563bf4){var _0x3c9a53={'raw':![],'where':{}};var _0x1ad100={};var _0xd585d2={'count':0x0,'rows':[]};return db[_0xb5d1('0x3c')][_0xb5d1('0x61')]({'where':{'id':_0x1a96a5[_0xb5d1('0x52')]['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x2b1bb4,null))[_0xb5d1('0x31')](function(_0x31eed9){if(_0x31eed9){_0x1ad100[_0xb5d1('0x40')]=_[_0xb5d1('0x53')](db[_0xb5d1('0x62')][_0xb5d1('0x63')]);_0x1ad100[_0xb5d1('0x41')]=_[_0xb5d1('0x53')](_0x1a96a5[_0xb5d1('0x41')]);_0x1ad100[_0xb5d1('0x42')]=_['intersection'](_0x1ad100[_0xb5d1('0x40')],_0x1ad100[_0xb5d1('0x41')]);_0x3c9a53['attributes']=_[_0xb5d1('0x43')](_0x1ad100[_0xb5d1('0x40')],qs[_0xb5d1('0x45')](_0x1a96a5[_0xb5d1('0x41')][_0xb5d1('0x45')]));_0x3c9a53[_0xb5d1('0x44')]=_0x3c9a53[_0xb5d1('0x44')][_0xb5d1('0x46')]?_0x3c9a53['attributes']:_0x1ad100[_0xb5d1('0x40')];if(!_0x1a96a5['query'][_0xb5d1('0x64')](_0xb5d1('0x47'))){_0x3c9a53[_0xb5d1('0x2c')]=qs['limit'](_0x1a96a5['query'][_0xb5d1('0x2c')]);_0x3c9a53[_0xb5d1('0x2b')]=qs['offset'](_0x1a96a5[_0xb5d1('0x41')][_0xb5d1('0x2b')]);}_0x3c9a53[_0xb5d1('0x48')]=qs[_0xb5d1('0x49')](_0x1a96a5[_0xb5d1('0x41')][_0xb5d1('0x49')]);_0x3c9a53[_0xb5d1('0x4b')]=qs[_0xb5d1('0x42')](_[_0xb5d1('0x65')](_0x1a96a5[_0xb5d1('0x41')],_0x1ad100[_0xb5d1('0x42')]));_0x3c9a53[_0xb5d1('0x4b')][_0xb5d1('0x5f')]=_0x31eed9['id'];if(_0x1a96a5[_0xb5d1('0x41')][_0xb5d1('0x4a')]){_0x3c9a53[_0xb5d1('0x4b')]=_[_0xb5d1('0x66')](_0x3c9a53[_0xb5d1('0x4b')],{'$or':_[_0xb5d1('0x3b')](_0x3c9a53[_0xb5d1('0x44')],function(_0x25c2cb){var _0x4b9ef5={};_0x4b9ef5[_0x25c2cb]={'$like':'%'+_0x1a96a5[_0xb5d1('0x41')][_0xb5d1('0x4a')]+'%'};return _0x4b9ef5;})});}_0x3c9a53=_[_0xb5d1('0x66')]({},_0x3c9a53,_0x1a96a5[_0xb5d1('0x4c')]);return db[_0xb5d1('0x62')][_0xb5d1('0x2a')]({'where':_0x3c9a53[_0xb5d1('0x4b')]})['then'](function(_0xa89bb0){_0xd585d2[_0xb5d1('0x2a')]=_0xa89bb0;if(_0x1a96a5['query'][_0xb5d1('0x4d')]){_0x3c9a53[_0xb5d1('0x54')]=[{'all':!![]}];}return db['Disposition'][_0xb5d1('0x4e')](_0x3c9a53);})[_0xb5d1('0x31')](function(_0x50ac77){_0xd585d2[_0xb5d1('0x4f')]=_0x50ac77;return _0xd585d2;});}})[_0xb5d1('0x31')](respondWithFilteredResult(_0x2b1bb4,_0x3c9a53))[_0xb5d1('0x50')](handleError(_0x2b1bb4,null));};exports[_0xb5d1('0x67')]=function(_0x3786fb,_0x53cfd3,_0x4bc178){return db[_0xb5d1('0x3c')][_0xb5d1('0x55')]({'where':{'id':_0x3786fb[_0xb5d1('0x52')]['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x53cfd3,null))[_0xb5d1('0x31')](function(_0x75a697){if(_0x75a697){return _0x75a697['removeDispositions'](_0x3786fb[_0xb5d1('0x41')]['ids']);}})[_0xb5d1('0x31')](respondWithStatusCode(_0x53cfd3,null))[_0xb5d1('0x50')](handleError(_0x53cfd3,null));};exports['addAnswer']=function(_0x4befc4,_0x390cd5,_0x3a0451){if(_0x4befc4[_0xb5d1('0x57')]['id']){delete _0x4befc4[_0xb5d1('0x57')]['id'];}return db[_0xb5d1('0x3c')]['find']({'where':{'id':_0x4befc4['params']['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x390cd5,null))[_0xb5d1('0x31')](function(_0x4c658f){if(_0x4c658f){_0x4befc4[_0xb5d1('0x57')]['ChatWebsiteId']=_0x4c658f['id'];return db[_0xb5d1('0x68')][_0xb5d1('0x56')](_0x4befc4[_0xb5d1('0x57')]);}})['then'](respondWithResult(_0x390cd5,null))[_0xb5d1('0x50')](handleError(_0x390cd5,null));};exports[_0xb5d1('0x69')]=function(_0x1e2266,_0x60059f,_0x40e909){var _0x5c21c1={'raw':![],'where':{}};var _0x303d08={};var _0x2b3e7d={'count':0x0,'rows':[]};return db[_0xb5d1('0x3c')]['findOne']({'where':{'id':_0x1e2266[_0xb5d1('0x52')]['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x60059f,null))[_0xb5d1('0x31')](function(_0x5c3550){if(_0x5c3550){_0x303d08['model']=_['keys'](db['CannedAnswer'][_0xb5d1('0x63')]);_0x303d08['query']=_['keys'](_0x1e2266[_0xb5d1('0x41')]);_0x303d08[_0xb5d1('0x42')]=_[_0xb5d1('0x43')](_0x303d08[_0xb5d1('0x40')],_0x303d08[_0xb5d1('0x41')]);_0x5c21c1[_0xb5d1('0x44')]=_[_0xb5d1('0x43')](_0x303d08[_0xb5d1('0x40')],qs[_0xb5d1('0x45')](_0x1e2266[_0xb5d1('0x41')]['fields']));_0x5c21c1['attributes']=_0x5c21c1[_0xb5d1('0x44')]['length']?_0x5c21c1[_0xb5d1('0x44')]:_0x303d08['model'];if(!_0x1e2266[_0xb5d1('0x41')]['hasOwnProperty']('nolimit')){_0x5c21c1[_0xb5d1('0x2c')]=qs[_0xb5d1('0x2c')](_0x1e2266[_0xb5d1('0x41')][_0xb5d1('0x2c')]);_0x5c21c1[_0xb5d1('0x2b')]=qs[_0xb5d1('0x2b')](_0x1e2266[_0xb5d1('0x41')][_0xb5d1('0x2b')]);}_0x5c21c1[_0xb5d1('0x48')]=qs['sort'](_0x1e2266['query'][_0xb5d1('0x49')]);_0x5c21c1[_0xb5d1('0x4b')]=qs[_0xb5d1('0x42')](_[_0xb5d1('0x65')](_0x1e2266[_0xb5d1('0x41')],_0x303d08[_0xb5d1('0x42')]));_0x5c21c1[_0xb5d1('0x4b')][_0xb5d1('0x5f')]=_0x5c3550['id'];if(_0x1e2266[_0xb5d1('0x41')][_0xb5d1('0x4a')]){_0x5c21c1[_0xb5d1('0x4b')]=_['merge'](_0x5c21c1[_0xb5d1('0x4b')],{'$or':_[_0xb5d1('0x3b')](_0x5c21c1[_0xb5d1('0x44')],function(_0xfffaec){var _0x527512={};_0x527512[_0xfffaec]={'$like':'%'+_0x1e2266[_0xb5d1('0x41')][_0xb5d1('0x4a')]+'%'};return _0x527512;})});}_0x5c21c1=_[_0xb5d1('0x66')]({},_0x5c21c1,_0x1e2266[_0xb5d1('0x4c')]);return db[_0xb5d1('0x68')]['count']({'where':_0x5c21c1['where']})[_0xb5d1('0x31')](function(_0x2cef42){_0x2b3e7d['count']=_0x2cef42;if(_0x1e2266[_0xb5d1('0x41')]['includeAll']){_0x5c21c1[_0xb5d1('0x54')]=[{'all':!![]}];}return db[_0xb5d1('0x68')][_0xb5d1('0x4e')](_0x5c21c1);})['then'](function(_0x8b4bf7){_0x2b3e7d[_0xb5d1('0x4f')]=_0x8b4bf7;return _0x2b3e7d;});}})['then'](respondWithFilteredResult(_0x60059f,_0x5c21c1))[_0xb5d1('0x50')](handleError(_0x60059f,null));};exports[_0xb5d1('0x6a')]=function(_0x2c82f3,_0x36953f,_0x16c894){return db[_0xb5d1('0x3c')]['find']({'where':{'id':_0x2c82f3['params']['id']}})['then'](handleEntityNotFound(_0x36953f,null))[_0xb5d1('0x31')](function(_0xf411cf){if(_0xf411cf){return _0xf411cf[_0xb5d1('0x6a')](_0x2c82f3[_0xb5d1('0x41')]['ids']);}})[_0xb5d1('0x31')](respondWithStatusCode(_0x36953f,null))[_0xb5d1('0x50')](handleError(_0x36953f,null));};exports[_0xb5d1('0x6b')]=function(_0x874a02,_0x42a2ba,_0x4254a2){_0x874a02[_0xb5d1('0x57')]['sitepic']=_0x874a02[_0xb5d1('0x6c')][_0xb5d1('0x6d')];return db[_0xb5d1('0x3c')][_0xb5d1('0x55')]({'where':{'id':_0x874a02[_0xb5d1('0x52')]['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x42a2ba,null))['then'](saveUpdates(_0x874a02['body'],null))[_0xb5d1('0x31')](respondWithResult(_0x42a2ba,null))[_0xb5d1('0x50')](handleError(_0x42a2ba,null));};exports[_0xb5d1('0x6e')]=function(_0x229192,_0x40f7a4,_0x53e985){_0x229192[_0xb5d1('0x57')][_0xb5d1('0x6f')]=_0x229192[_0xb5d1('0x6c')][_0xb5d1('0x6d')];return db[_0xb5d1('0x3c')][_0xb5d1('0x55')]({'where':{'id':_0x229192[_0xb5d1('0x52')]['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x40f7a4,null))['then'](saveUpdates(_0x229192['body'],null))['then'](respondWithResult(_0x40f7a4,null))['catch'](handleError(_0x40f7a4,null));};exports[_0xb5d1('0x70')]=function(_0xf32f,_0x62c697,_0x3204d3){_0xf32f['body'][_0xb5d1('0x71')]=_0xf32f['file'][_0xb5d1('0x6d')];return db['ChatWebsite'][_0xb5d1('0x55')]({'where':{'id':_0xf32f['params']['id']}})['then'](handleEntityNotFound(_0x62c697,null))[_0xb5d1('0x31')](saveUpdates(_0xf32f[_0xb5d1('0x57')],null))['then'](respondWithResult(_0x62c697,null))['catch'](handleError(_0x62c697,null));};exports[_0xb5d1('0x72')]=function(_0x4b4bf8,_0x130668,_0xee5d9f){_0x4b4bf8[_0xb5d1('0x57')][_0xb5d1('0x73')]=_0x4b4bf8[_0xb5d1('0x6c')][_0xb5d1('0x6d')];return db[_0xb5d1('0x3c')][_0xb5d1('0x55')]({'where':{'id':_0x4b4bf8[_0xb5d1('0x52')]['id']}})['then'](handleEntityNotFound(_0x130668,null))['then'](saveUpdates(_0x4b4bf8['body'],null))[_0xb5d1('0x31')](respondWithResult(_0x130668,null))['catch'](handleError(_0x130668,null));};exports[_0xb5d1('0x74')]=function(_0x175f72,_0x30a85f,_0x51bd07){var _0x34a112=path['join'](config[_0xb5d1('0x75')],_0xb5d1('0x76'));var _0x10bded={'where':{'id':_0x175f72[_0xb5d1('0x52')]['id']},'attributes':['id',_0xb5d1('0x77')],'raw':!![]};var _0x2b6bd4=![];return require(_0xb5d1('0x78'))[_0xb5d1('0x79')]()[_0xb5d1('0x31')](function(_0x49d2cc){if(_0x49d2cc){_0x2b6bd4=_0x49d2cc['custom'];}})[_0xb5d1('0x31')](function(){return db[_0xb5d1('0x3c')][_0xb5d1('0x55')](_0x10bded);})[_0xb5d1('0x31')](handleEntityNotFound(_0x30a85f,null))['then'](function(_0x32e8b9){if(_0x32e8b9){if(!_[_0xb5d1('0x7a')](_0x32e8b9[_0xb5d1('0x77')])){if(fs[_0xb5d1('0x7b')](path[_0xb5d1('0x7c')](config[_0xb5d1('0x75')],'server/files/images/logos/',_0x32e8b9['sitepic']))&&_0x2b6bd4){_0x34a112=path[_0xb5d1('0x7c')](config[_0xb5d1('0x75')],_0xb5d1('0x7d'),_0x32e8b9['sitepic']);}}return _0x30a85f[_0xb5d1('0x7e')](_0x34a112);}})[_0xb5d1('0x50')](handleError(_0x30a85f,null));};exports[_0xb5d1('0x7f')]=function(_0x23e361,_0x4e8b6d,_0x227e72){var _0x36990e=path[_0xb5d1('0x7c')](config[_0xb5d1('0x75')],_0xb5d1('0x80'));var _0x60259c={'where':{'id':_0x23e361['params']['id']},'attributes':['id',_0xb5d1('0x6f')],'raw':!![]};return db[_0xb5d1('0x3c')]['find'](_0x60259c)[_0xb5d1('0x31')](handleEntityNotFound(_0x4e8b6d,null))['then'](function(_0x2092f2){if(_0x2092f2){if(!_[_0xb5d1('0x7a')](_0x2092f2['agentAvatar'])){if(fs[_0xb5d1('0x7b')](path['join'](config[_0xb5d1('0x75')],'server/files/images/avatars/',_0x2092f2[_0xb5d1('0x6f')]))){_0x36990e=path[_0xb5d1('0x7c')](config[_0xb5d1('0x75')],'server/files/images/avatars/',_0x2092f2[_0xb5d1('0x6f')]);}}return _0x4e8b6d[_0xb5d1('0x7e')](_0x36990e);}})[_0xb5d1('0x50')](handleError(_0x4e8b6d,null));};exports['getCustomerAvatar']=function(_0x1fa7f8,_0x1ecc7c,_0x1971b6){var _0x44f3c8=path['join'](config[_0xb5d1('0x75')],_0xb5d1('0x81'));var _0x2b8dd1={'where':{'id':_0x1fa7f8[_0xb5d1('0x52')]['id']},'attributes':['id',_0xb5d1('0x71'),_0xb5d1('0x82')],'raw':!![]};return db[_0xb5d1('0x3c')]['find'](_0x2b8dd1)[_0xb5d1('0x31')](handleEntityNotFound(_0x1ecc7c,null))[_0xb5d1('0x31')](function(_0x13371f){if(_0x13371f){if(!_['isNil'](_0x13371f[_0xb5d1('0x71')])){if(fs['existsSync'](path[_0xb5d1('0x7c')](config[_0xb5d1('0x75')],_0xb5d1('0x83'),_0x13371f[_0xb5d1('0x71')]))&&_0x13371f[_0xb5d1('0x82')]){_0x44f3c8=path[_0xb5d1('0x7c')](config[_0xb5d1('0x75')],_0xb5d1('0x83'),_0x13371f[_0xb5d1('0x71')]);}}return _0x1ecc7c[_0xb5d1('0x7e')](_0x44f3c8);}})[_0xb5d1('0x50')](handleError(_0x1ecc7c,null));};exports[_0xb5d1('0x84')]=function(_0x411bd9,_0x161db8,_0x44b417){var _0x2ac0e9=path[_0xb5d1('0x7c')](config[_0xb5d1('0x75')],'server/files/images/avatars/system_avatar.png');var _0x358044={'where':{'id':_0x411bd9[_0xb5d1('0x52')]['id']},'attributes':['id',_0xb5d1('0x73')],'raw':!![]};return db['ChatWebsite'][_0xb5d1('0x55')](_0x358044)[_0xb5d1('0x31')](handleEntityNotFound(_0x161db8,null))[_0xb5d1('0x31')](function(_0x20647c){if(_0x20647c){if(!_['isNil'](_0x20647c[_0xb5d1('0x73')])){if(fs['existsSync'](path['join'](config[_0xb5d1('0x75')],_0xb5d1('0x83'),_0x20647c[_0xb5d1('0x73')]))){_0x2ac0e9=path[_0xb5d1('0x7c')](config[_0xb5d1('0x75')],_0xb5d1('0x83'),_0x20647c[_0xb5d1('0x73')]);}}return _0x161db8[_0xb5d1('0x7e')](_0x2ac0e9);}})[_0xb5d1('0x50')](handleError(_0x161db8,null));};exports[_0xb5d1('0x85')]=function(_0x5870b4,_0x4d3ee9,_0x3e1921){var _0x3febb2=require(_0xb5d1('0x86'));var _0x27a7ac=new _0x3febb2();var _0x2e5f30=_0x27a7ac[_0xb5d1('0x87')](_0x5870b4['headers'][_0xb5d1('0x88')])[_0xb5d1('0x89')]();var _0x24afba={'body':_0x5870b4[_0xb5d1('0x57')],'channel':_0xb5d1('0x8a')};var _0x3b1b63=[];var _0x384b88=[];var _0x79f748={};var _0x464daa=![];return db[_0xb5d1('0x8b')][_0xb5d1('0x5e')]()[_0xb5d1('0x31')](function(_0x3f5e0e){if(!_0x3f5e0e){throw new db[(_0xb5d1('0x8c'))][(_0xb5d1('0x8d'))](_0xb5d1('0x8e'));}_0x3b1b63=_[_0xb5d1('0x8f')](_['keys'](_0x3f5e0e),[_0xb5d1('0x90'),'updatedAt']);_0x384b88=_[_0xb5d1('0x8f')](_['keys'](_0x3f5e0e),[_0xb5d1('0x90'),_0xb5d1('0x91'),'CompanyId',_0xb5d1('0x92')]);if(_0x5870b4['body']['id']){delete _0x5870b4[_0xb5d1('0x57')]['id'];}if(_[_0xb5d1('0x7a')](_0x5870b4['body'][_0xb5d1('0x93')])){throw new db[(_0xb5d1('0x8c'))][(_0xb5d1('0x8d'))](_0xb5d1('0x94'));}if(_[_0xb5d1('0x7a')](_0x5870b4['body'][_0xb5d1('0x57')])||_0x5870b4['body'][_0xb5d1('0x57')]===''){throw new db['Sequelize'][(_0xb5d1('0x8d'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0xb5d1('0x7a')](_0x5870b4[_0xb5d1('0x57')]['mapKey'])){throw new db[(_0xb5d1('0x8c'))][(_0xb5d1('0x8d'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x384b88);}if(!_[_0xb5d1('0x95')](_0x384b88,_0x5870b4[_0xb5d1('0x57')][_0xb5d1('0x96')])){throw new db['Sequelize'][(_0xb5d1('0x8d'))](_0xb5d1('0x97')+_0x384b88);}_0x79f748[_0x5870b4[_0xb5d1('0x57')][_0xb5d1('0x96')]]=_0x5870b4['body'][_0xb5d1('0x93')];})[_0xb5d1('0x31')](function(){return db[_0xb5d1('0x3c')][_0xb5d1('0x55')]({'where':{'id':_0x5870b4[_0xb5d1('0x52')]['id']},'include':[{'model':db['CmList'],'as':_0xb5d1('0x98'),'include':[{'model':db[_0xb5d1('0x8b')],'as':_0xb5d1('0x99'),'where':_0x79f748,'limit':0x1,'order':[[_0xb5d1('0x91'),_0xb5d1('0x9a')]]}]},{'model':db[_0xb5d1('0x9b')],'as':_0xb5d1('0x9c')}]});})[_0xb5d1('0x31')](handleEntityNotFound(_0x4d3ee9,null))[_0xb5d1('0x31')](function(_0x2f9fd7){if(_0x2f9fd7&&_0x2f9fd7['List']){_0x24afba[_0xb5d1('0x9d')]=_0x2f9fd7;_0x24afba[_0xb5d1('0x9e')]=_0x2f9fd7[_0xb5d1('0x9c')];_0x24afba[_0xb5d1('0x9f')]=_0x2f9fd7['List'];_0x24afba['applications']=_[_0xb5d1('0xa0')](_0x24afba[_0xb5d1('0x9e')],['priority'],[_0xb5d1('0xa1')]);if(_0x24afba['account'][_0xb5d1('0x9c')]){delete _0x24afba[_0xb5d1('0x9d')][_0xb5d1('0x9c')];}if(_0x24afba[_0xb5d1('0x9d')][_0xb5d1('0x98')]&&_0x24afba[_0xb5d1('0x9d')][_0xb5d1('0x98')][_0xb5d1('0x99')][_0xb5d1('0x46')]){return _0x24afba[_0xb5d1('0x9d')][_0xb5d1('0x98')][_0xb5d1('0x99')][0x0];}var _0x2c23bd=_[_0xb5d1('0x18')](_0x5870b4['body'],{'firstName':_0x5870b4[_0xb5d1('0x57')][_0xb5d1('0x93')],'ListId':_0x2f9fd7[_0xb5d1('0x92')]});_0x2c23bd[_0x5870b4[_0xb5d1('0x57')][_0xb5d1('0x96')]]=_0x5870b4[_0xb5d1('0x57')][_0xb5d1('0x93')];return db['CmContact']['create'](_0x2c23bd,{'fields':_0x3b1b63,'raw':!![]});}})[_0xb5d1('0x31')](handleEntityNotFound(_0x4d3ee9,null))[_0xb5d1('0x31')](function(_0x4a6736){_0x24afba['contact']=_0x4a6736;var _0x5187c0=_0x5870b4[_0xb5d1('0x57')][_0xb5d1('0xa2')];if(_0x5870b4['headers']['cf-connecting-ip']){_0x5187c0=_0x5870b4[_0xb5d1('0xa3')][_0xb5d1('0xa4')];}else if(_0x5870b4[_0xb5d1('0xa3')][_0xb5d1('0xa5')]){_0x5187c0=_[_0xb5d1('0xa6')](_0x5870b4[_0xb5d1('0xa3')][_0xb5d1('0xa5')]['split'](','));}if(_0x4a6736){var _0x5a3a7a={'ContactId':_0x4a6736['id'],'ChatWebsiteId':_0x5870b4[_0xb5d1('0x52')]['id'],'from':(_0x4a6736['firstName']||'')+'\x20'+(_0x4a6736[_0xb5d1('0xa7')]||''),'customerIp':_0x5187c0,'customerPort':_0x5870b4[_0xb5d1('0xa3')]['x-real-port']?_0x5870b4['headers']['x-real-port']:null,'referer':_0x5870b4[_0xb5d1('0x57')]['referer'],'browserName':_0x2e5f30[_0xb5d1('0xa8')][_0xb5d1('0x36')]&&_0x2e5f30[_0xb5d1('0xa8')]['version']?util[_0xb5d1('0xa9')](_0xb5d1('0xaa'),_0x2e5f30[_0xb5d1('0xa8')][_0xb5d1('0x36')],_0x2e5f30[_0xb5d1('0xa8')][_0xb5d1('0xab')]):_0xb5d1('0xac'),'browserVersion':_0x2e5f30['browser'][_0xb5d1('0xab')]||_0xb5d1('0xac'),'osName':util[_0xb5d1('0xa9')](_0xb5d1('0xaa'),_0x2e5f30['os'][_0xb5d1('0x36')],_0x2e5f30['os'][_0xb5d1('0xab')]),'osVersion':_0x2e5f30['os'][_0xb5d1('0xab')],'deviceModel':_0x2e5f30['device'][_0xb5d1('0x40')]&&_0x2e5f30[_0xb5d1('0xad')][_0xb5d1('0xae')]?util[_0xb5d1('0xa9')](_0xb5d1('0xaf'),_0x2e5f30['device'][_0xb5d1('0x40')],_0x2e5f30[_0xb5d1('0xad')][_0xb5d1('0xae')],_0x2e5f30[_0xb5d1('0xad')][_0xb5d1('0x3e')]):null,'deviceVendor':_0x2e5f30[_0xb5d1('0xad')][_0xb5d1('0xae')],'deviceType':_0x2e5f30['device'][_0xb5d1('0x3e')],'formData':JSON[_0xb5d1('0x21')](_0x5870b4[_0xb5d1('0x57')])};var _0x3af070={'ChatWebsiteId':_0x5870b4[_0xb5d1('0x52')]['id'],'closed':![]};if(_0x5870b4['body'][_0xb5d1('0xb0')]){_0x3af070[_0xb5d1('0xb0')]=_0x5870b4[_0xb5d1('0x57')]['threadId'];return db['ChatInteraction'][_0xb5d1('0x55')]({'where':_0x3af070})[_0xb5d1('0x31')](function(_0x567513){if(_0x567513){return[_0x567513,![]];}_0x5a3a7a[_0xb5d1('0xb0')]=_0x5870b4['body'][_0xb5d1('0xb0')];_0x5a3a7a[_0xb5d1('0xb1')]=_0x5870b4[_0xb5d1('0x57')]['externalUrl'];return db[_0xb5d1('0xb2')][_0xb5d1('0x56')](_0x5a3a7a)[_0xb5d1('0x31')](function(_0x28dce2){return[_0x28dce2,!![]];});});}_0x3af070[_0xb5d1('0xb3')]=_0x4a6736['id'];if(_0x5870b4[_0xb5d1('0x57')][_0xb5d1('0xb4')]&&_0x5870b4[_0xb5d1('0x57')][_0xb5d1('0xb4')]['id']){_0x3af070['id']=_0x5870b4[_0xb5d1('0x57')]['interaction']['id'];return db[_0xb5d1('0xb2')][_0xb5d1('0x55')]({'where':_0x3af070})[_0xb5d1('0x31')](function(_0x57f913){if(_0x57f913){return[_0x57f913,![]];}return db[_0xb5d1('0xb2')][_0xb5d1('0x56')](_0x5a3a7a)[_0xb5d1('0x31')](function(_0x2180ca){return[_0x2180ca,!![]];});});}return db[_0xb5d1('0xb2')][_0xb5d1('0x56')](_0x5a3a7a)[_0xb5d1('0x31')](function(_0x590bd5){return[_0x590bd5,!![]];});}})[_0xb5d1('0xb5')](function(_0x1c8658,_0x26fb32){if(_0x1c8658){_0x464daa=_0x26fb32;if(!_0x26fb32){var _0x3e6ba2={'from':(_0x24afba[_0xb5d1('0xb6')]['firstName']||'')+'\x20'+(_0x24afba[_0xb5d1('0xb6')][_0xb5d1('0xa7')]||'')};if(_0x5870b4[_0xb5d1('0x57')][_0xb5d1('0xb0')]&&_0x5870b4[_0xb5d1('0x57')]['messageId']&&_0x5870b4[_0xb5d1('0x57')][_0xb5d1('0xb0')]!=_0x5870b4[_0xb5d1('0x57')][_0xb5d1('0xb7')]){_0x3e6ba2[_0xb5d1('0xb0')]=_0x5870b4[_0xb5d1('0x57')][_0xb5d1('0xb7')];}return _0x1c8658[_0xb5d1('0x30')](_0x3e6ba2);}else{return _0x1c8658;}}})[_0xb5d1('0x31')](function(_0x46ccc5){_0x24afba['interaction']=_0x46ccc5['get']({'plain':!![]});_0x24afba[_0xb5d1('0xb4')][_0xb5d1('0xb8')]=_0x464daa;if(_0x24afba[_0xb5d1('0xb4')][_0xb5d1('0xb8')]){if(_0x24afba[_0xb5d1('0x9d')][_0xb5d1('0xb9')]){_0x24afba[_0xb5d1('0x9e')][_0xb5d1('0xba')]({'id':0x0,'priority':_0x24afba[_0xb5d1('0x9e')][_0xb5d1('0x46')]+0x1,'app':'close','appdata':_0xb5d1('0xbb'),'interval':'*,*,*,*'});}}return db[_0xb5d1('0xbc')][_0xb5d1('0x56')]({'body':_0x5870b4[_0xb5d1('0x57')][_0xb5d1('0x57')],'ChatWebsiteId':_0x5870b4['params']['id'],'ChatInteractionId':_0x46ccc5['id'],'direction':'in','ContactId':_0x24afba[_0xb5d1('0xb6')]['id'],'AttachmentId':_0x5870b4[_0xb5d1('0x57')][_0xb5d1('0xbd')]});})[_0xb5d1('0x31')](function(_0x151eaf){_0x24afba[_0xb5d1('0x25')]=_0x151eaf;if(_0x24afba[_0xb5d1('0xb4')]['UserId']){return db[_0xb5d1('0xbe')][_0xb5d1('0x55')]({'attributes':['id',_0xb5d1('0x36')],'where':{'id':_0x24afba[_0xb5d1('0xb4')][_0xb5d1('0xbf')]}})[_0xb5d1('0x31')](function(_0x2137c2){if(_0x2137c2){_0x24afba[_0xb5d1('0x9e')]['unshift']({'id':0x0,'priority':0x0,'app':_0xb5d1('0xc0'),'appdata':_0x2137c2[_0xb5d1('0x36')]+','+(_0x24afba[_0xb5d1('0x9d')][_0xb5d1('0xc1')]||0xa),'interval':'*,*,*,*'});_0x24afba[_0xb5d1('0xc2')]=!![];}return respondWithRpcPromise(_0xb5d1('0xc3'),'startRouting',_0x24afba);});}return respondWithRpcPromise(_0xb5d1('0xc3'),'startRouting',_0x24afba);})['then'](function(_0x473897){respondWithRpcPromise(_0xb5d1('0xc4'),_0xb5d1('0xc4'),{'event':_0xb5d1('0x85'),'message':_0x473897},client9002);return _0x473897;})[_0xb5d1('0x31')](respondWithResult(_0x4d3ee9,null))[_0xb5d1('0x50')](handleError(_0x4d3ee9,null));};exports[_0xb5d1('0xc5')]=function(_0x4064e4,_0x44fffd,_0x502eae){var _0x4887ea,_0x7760ed,_0x4c7bba;var _0xf9af7=[];var _0x3aa158=[];var _0x4fc295={};return db[_0xb5d1('0x8b')][_0xb5d1('0x5e')]()[_0xb5d1('0x31')](function(_0x4228c2){if(!_0x4228c2){throw new db[(_0xb5d1('0x8c'))][(_0xb5d1('0x8d'))](_0xb5d1('0x8e'));}_0x3aa158=_[_0xb5d1('0x8f')](_[_0xb5d1('0x53')](_0x4228c2),[_0xb5d1('0x90'),_0xb5d1('0x91')]);_0xf9af7=_[_0xb5d1('0x8f')](_[_0xb5d1('0x53')](_0x4228c2),[_0xb5d1('0x90'),_0xb5d1('0x91'),_0xb5d1('0xc6'),_0xb5d1('0x92')]);if(_0x4064e4[_0xb5d1('0x57')]['id']){delete _0x4064e4[_0xb5d1('0x57')]['id'];}if(_[_0xb5d1('0x7a')](_0x4064e4[_0xb5d1('0x57')][_0xb5d1('0x93')])){throw _0x44fffd['status'](0x1f4)['send'](new db[(_0xb5d1('0x8c'))][(_0xb5d1('0x8d'))](_0xb5d1('0x94')));}if(_[_0xb5d1('0x7a')](_0x4064e4[_0xb5d1('0x57')][_0xb5d1('0x57')])||_0x4064e4['body'][_0xb5d1('0x57')]===''){throw _0x44fffd[_0xb5d1('0x27')](0x1f4)[_0xb5d1('0x37')](new db[(_0xb5d1('0x8c'))][(_0xb5d1('0x8d'))](_0xb5d1('0xc7')));}if(_[_0xb5d1('0x7a')](_0x4064e4[_0xb5d1('0x57')][_0xb5d1('0xc8')])){throw _0x44fffd['status'](0x1f4)[_0xb5d1('0x37')](new db[(_0xb5d1('0x8c'))][(_0xb5d1('0x8d'))](_0xb5d1('0xc9')+_0xf9af7));}if(!_['includes'](_0xf9af7,_0x4064e4['body'][_0xb5d1('0xc8')])){throw _0x44fffd[_0xb5d1('0x27')](0x1f4)[_0xb5d1('0x37')](new db[(_0xb5d1('0x8c'))]['ValidationError'](_0xb5d1('0xca')+_0xf9af7));}_0x4fc295[_0x4064e4['body'][_0xb5d1('0xc8')]]=_0x4064e4[_0xb5d1('0x57')][_0xb5d1('0x93')];})[_0xb5d1('0x31')](function(){return db[_0xb5d1('0x3c')][_0xb5d1('0x55')]({'where':{'id':_0x4064e4[_0xb5d1('0x52')]['id']},'include':[{'model':db[_0xb5d1('0xcb')],'as':_0xb5d1('0x98')}]});})[_0xb5d1('0x31')](handleEntityNotFound(_0x44fffd,null))[_0xb5d1('0x31')](function(_0x1bdf0f){if(_0x1bdf0f&&_0x1bdf0f[_0xb5d1('0x98')]){_0x7760ed=_0x1bdf0f;var _0x281d8d=_[_0xb5d1('0x18')](_0x4064e4[_0xb5d1('0x57')],{'firstName':_0x4064e4[_0xb5d1('0x57')][_0xb5d1('0x93')],'phone':_0x4064e4[_0xb5d1('0x57')]['from'],'ListId':_0x1bdf0f[_0xb5d1('0x92')]});_0x281d8d[_0x4064e4[_0xb5d1('0x57')][_0xb5d1('0xc8')]]=_0x4064e4[_0xb5d1('0x57')]['from'];return db[_0xb5d1('0x8b')][_0xb5d1('0xcc')]({'where':_0x4fc295,'defaults':_0x281d8d});}})[_0xb5d1('0xb5')](function(_0x4497c1){if(_0x4497c1){_0x4c7bba=_0x4497c1;var _0x2acecd=fs[_0xb5d1('0xcd')](path[_0xb5d1('0x7c')](config['root'],_0xb5d1('0xce')),'utf8');var _0x2e3e80=ejs[_0xb5d1('0xcf')](_0x2acecd,{'body':_['toPairs'](_0x4064e4[_0xb5d1('0x57')]['body']),'bodyTitle':_0x7760ed['offlineMessageBody']});return db[_0xb5d1('0xd0')][_0xb5d1('0x56')]({'body':_0x2e3e80,'ContactId':_0x4497c1['id'],'ChatWebsiteId':_0x7760ed['id']});}})['then'](function(_0x41f9f8){if(_0x41f9f8){_0x4887ea=_0x41f9f8;return db[_0xb5d1('0xd1')][_0xb5d1('0x61')]({'where':{'service':!![]},'include':[{'model':db[_0xb5d1('0xd2')],'as':_0xb5d1('0xd3'),'raw':!![]}]});}})[_0xb5d1('0x31')](function(_0x5ca92d){if(_0x5ca92d&&_0x5ca92d['Smtp']&&_0x7760ed['forwardOfflineAddress']){var _0x14e60b={'tls':{'rejectUnauthorized':![]}};if(_0x5ca92d[_0xb5d1('0xd3')][_0xb5d1('0xd4')]){_0x14e60b[_0xb5d1('0xd4')]=_0x5ca92d[_0xb5d1('0xd3')]['service'];}else{_0x14e60b[_0xb5d1('0xd5')]=_0x5ca92d[_0xb5d1('0xd3')][_0xb5d1('0xd5')];_0x14e60b[_0xb5d1('0xd6')]=_0x5ca92d[_0xb5d1('0xd3')][_0xb5d1('0xd6')];_0x14e60b['secure']=_0x5ca92d['Smtp'][_0xb5d1('0xd7')];}if(_0x5ca92d[_0xb5d1('0xd3')][_0xb5d1('0xd8')]){_0x14e60b[_0xb5d1('0xd9')]={'user':_0x5ca92d[_0xb5d1('0xd3')][_0xb5d1('0x58')],'pass':_0x5ca92d[_0xb5d1('0xd3')]['pass']};}return respondWithRpcPromise(_0xb5d1('0xda'),_0xb5d1('0xdb'),{'account':_0x14e60b,'message':{'from':util[_0xb5d1('0xa9')](_0xb5d1('0xdc'),_0x5ca92d['name'],_0x5ca92d['email']||_0x5ca92d['Smtp'][_0xb5d1('0x58')]),'to':_0x7760ed[_0xb5d1('0xdd')],'subject':_0x7760ed[_0xb5d1('0xde')],'text':_0x4887ea[_0xb5d1('0x57')]}},client9003)[_0xb5d1('0x31')](function(){return _0x4887ea;})[_0xb5d1('0x50')](function(_0x26bbbc){console[_0xb5d1('0x22')](_0x26bbbc);});}})[_0xb5d1('0x31')](function(){if(_0x4887ea){return _0x4887ea;}})[_0xb5d1('0x31')](respondWithResult(_0x44fffd,null))[_0xb5d1('0x50')](handleError(_0x44fffd,null));};exports[_0xb5d1('0xdf')]=function(_0x121958,_0x5a3b3b,_0x51e1ec){return db[_0xb5d1('0xb2')][_0xb5d1('0x55')]({'where':{'id':_0x121958[_0xb5d1('0x52')]['id']}})['then'](handleEntityNotFound(_0x5a3b3b,null))['then'](function(_0x2b08c0){if(_0x2b08c0){return _0x2b08c0[_0xb5d1('0xdf')](_0x121958[_0xb5d1('0x57')]['ids'],_['omit'](_0x121958['body'],[_0xb5d1('0xe0'),'id'])||{});}})['then'](respondWithResult(_0x5a3b3b,null))[_0xb5d1('0x50')](handleError(_0x5a3b3b,null));};exports['getInteractions']=function(_0x43d0eb,_0x396d24,_0x12bdd8){var _0x1e7693={'raw':![],'where':{}};var _0x1f0bcb={};var _0x1471db={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x43d0eb[_0xb5d1('0x52')]['id']}})['then'](handleEntityNotFound(_0x396d24,null))[_0xb5d1('0x31')](function(_0x54a041){if(_0x54a041){_0x1f0bcb[_0xb5d1('0x40')]=_['keys'](db['ChatInteraction'][_0xb5d1('0x63')]);_0x1f0bcb[_0xb5d1('0x41')]=_['keys'](_0x43d0eb[_0xb5d1('0x41')]);_0x1f0bcb[_0xb5d1('0x42')]=_['intersection'](_0x1f0bcb[_0xb5d1('0x40')],_0x1f0bcb[_0xb5d1('0x41')]);_0x1e7693[_0xb5d1('0x44')]=_[_0xb5d1('0x43')](_0x1f0bcb[_0xb5d1('0x40')],qs[_0xb5d1('0x45')](_0x43d0eb[_0xb5d1('0x41')][_0xb5d1('0x45')]));_0x1e7693[_0xb5d1('0x44')]=_0x1e7693[_0xb5d1('0x44')][_0xb5d1('0x46')]?_0x1e7693[_0xb5d1('0x44')]:_0x1f0bcb[_0xb5d1('0x40')];if(!_0x43d0eb[_0xb5d1('0x41')][_0xb5d1('0x64')]('nolimit')){_0x1e7693['limit']=qs[_0xb5d1('0x2c')](_0x43d0eb['query']['limit']);_0x1e7693[_0xb5d1('0x2b')]=qs[_0xb5d1('0x2b')](_0x43d0eb[_0xb5d1('0x41')][_0xb5d1('0x2b')]);}_0x1e7693[_0xb5d1('0x48')]=qs[_0xb5d1('0x49')](_0x43d0eb[_0xb5d1('0x41')][_0xb5d1('0x49')]);_0x1e7693[_0xb5d1('0x4b')]=qs[_0xb5d1('0x42')](_[_0xb5d1('0x65')](_0x43d0eb[_0xb5d1('0x41')],_0x1f0bcb[_0xb5d1('0x42')]));_0x1e7693[_0xb5d1('0x4b')][_0xb5d1('0x5f')]=_0x54a041['id'];if(_0x43d0eb[_0xb5d1('0x41')][_0xb5d1('0x4a')]){_0x1e7693[_0xb5d1('0x4b')]=_[_0xb5d1('0x66')](_0x1e7693[_0xb5d1('0x4b')],{'$or':_[_0xb5d1('0x3b')](_0x1e7693['attributes'],function(_0x203bc8){var _0x3653c5={};_0x3653c5[_0x203bc8]={'$like':'%'+_0x43d0eb[_0xb5d1('0x41')][_0xb5d1('0x4a')]+'%'};return _0x3653c5;})});}_0x1e7693=_['merge']({},_0x1e7693,_0x43d0eb[_0xb5d1('0x4c')]);return db['ChatInteraction'][_0xb5d1('0x2a')]({'where':_0x1e7693[_0xb5d1('0x4b')]})[_0xb5d1('0x31')](function(_0x1fee13){_0x1471db[_0xb5d1('0x2a')]=_0x1fee13;if(_0x43d0eb[_0xb5d1('0x41')][_0xb5d1('0x4d')]){_0x1e7693['include']=[{'model':db[_0xb5d1('0x8b')],'as':_0xb5d1('0xe1'),'required':![]},{'model':db[_0xb5d1('0xbe')],'as':_0xb5d1('0xe2'),'attributes':[_0xb5d1('0x36'),_0xb5d1('0xe3'),_0xb5d1('0xe4')],'required':![]},{'model':db[_0xb5d1('0xe5')],'as':'Tags','attributes':['id','name',_0xb5d1('0xe6')],'where':_0x43d0eb[_0xb5d1('0x41')][_0xb5d1('0xe7')]?{'id':_0x43d0eb[_0xb5d1('0x41')][_0xb5d1('0xe7')]}:undefined,'required':_0x43d0eb['query'][_0xb5d1('0xe7')]?!![]:![]}];}return db['ChatInteraction'][_0xb5d1('0x4e')](_0x1e7693);})['then'](function(_0x3c3f6b){_0x1471db[_0xb5d1('0x4f')]=_0x3c3f6b;return _0x1471db;});}})[_0xb5d1('0x31')](respondWithFilteredResult(_0x396d24,_0x1e7693))[_0xb5d1('0x50')](handleError(_0x396d24,null));};function iftimePromise(_0x416e47,_0xe1844a){return respondWithRpcPromise('Command','getSnippet',{'command':_0xe1844a[_0xb5d1('0xe8')]?util[_0xb5d1('0xa9')](_0xb5d1('0xe9'),_0x416e47[_0xb5d1('0xea')],_0xe1844a[_0xb5d1('0xe8')]):util['format'](_0xb5d1('0xeb'),_0x416e47[_0xb5d1('0xea')])},client9002)['then'](function(_0x211e91){var _0x2f3f48=_0x211e91&&_0x211e91[_0xb5d1('0xec')]('true')>=0x0?!![]:![];logger['info'](_0xb5d1('0xed'),_0xe1844a['id'],_0x416e47['id'],_0x416e47[_0xb5d1('0xea')],_0x2f3f48?_0xb5d1('0xee'):_0xb5d1('0xef'),_0xe1844a['timezone']?_0xe1844a[_0xb5d1('0xe8')]:_0xb5d1('0xf0'));return _0x2f3f48;})[_0xb5d1('0x50')](function(_0x427acf){logger['error']('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0xe1844a['id'],_0x416e47['id'],_0x416e47[_0xb5d1('0xea')],util[_0xb5d1('0xf1')](_0x427acf,{'showHidden':![],'depth':null}),_0xe1844a[_0xb5d1('0xe8')]?_0xe1844a['timezone']:_0xb5d1('0xf0'));return![];});}exports[_0xb5d1('0xf2')]=function(_0x249a51,_0x1d909c,_0x595ce5){var _0xd224bb=0x0;var _0x1f67e9=0x0;var _0x4d17c2=![];var _0x25ed1f;var _0x318f02;return db[_0xb5d1('0x3c')][_0xb5d1('0x55')]({'where':{'id':_0x249a51[_0xb5d1('0x52')]['id']},'include':[{'model':db['Interval'],'as':'Interval','include':[{'model':db[_0xb5d1('0xf3')],'as':_0xb5d1('0xf4'),'attributes':['id',_0xb5d1('0xea')],'raw':!![]}]}]})['then'](handleEntityNotFound(_0x1d909c,null))[_0xb5d1('0x31')](function(_0x48260f){if(_0x48260f){_0x25ed1f=_0x48260f;return _0x48260f[_0xb5d1('0xf5')]({'raw':!![]});}})[_0xb5d1('0x31')](function(_0xa06a88){if(_0x25ed1f){if(_0xa06a88){_0x318f02=_0xa06a88;}}return require(_0xb5d1('0x78'))[_0xb5d1('0x79')]();})[_0xb5d1('0x31')](function(_0x5afb26){if(_0x5afb26){_0x1f67e9=_0x5afb26[_0xb5d1('0xf6')];_0x4d17c2=_0x5afb26[_0xb5d1('0xf7')];}})[_0xb5d1('0x31')](function(){return db[_0xb5d1('0xb2')][_0xb5d1('0x2a')]({'where':{'closed':![]}});})[_0xb5d1('0x31')](function(_0x23afe5){_0xd224bb=_0x23afe5;if(_0x1f67e9&&_0x23afe5>_0x1f67e9){return db['License'][_0xb5d1('0x61')]({'where':{'id':0x1}})['then'](function(_0x317feb){if(_0x317feb){_0x317feb[_0xb5d1('0xf8')](_0xb5d1('0xf9'));}});}})[_0xb5d1('0x31')](function(){if(_0x25ed1f[_0xb5d1('0xf3')]&&_0x25ed1f[_0xb5d1('0xf3')][_0xb5d1('0xf4')]){var _0x674a7d=[];for(var _0x4794f3=0x0;_0x4794f3<_0x25ed1f['Interval'][_0xb5d1('0xf4')][_0xb5d1('0x46')];_0x4794f3++){var _0x34cefa=_0x25ed1f[_0xb5d1('0xf3')][_0xb5d1('0xf4')][_0x4794f3]['get']({'plain':!![]});_0x674a7d[_0xb5d1('0xba')](iftimePromise(_0x34cefa,_0x25ed1f));}return BPromise[_0xb5d1('0xfa')](_0x674a7d)[_0xb5d1('0x31')](function(_0x401c21){return _[_0xb5d1('0xfb')](_0x401c21);});}else{return!![];}})[_0xb5d1('0x31')](function(_0x46733a){var _0x4ec414=fs[_0xb5d1('0xcd')](path[_0xb5d1('0x7c')](config['root'],_0xb5d1('0xfc')),_0xb5d1('0xfd'));var _0xed5ec9={'remote':_0x25ed1f[_0xb5d1('0xfe')],'query':querystring[_0xb5d1('0x21')](_['merge'](_0x25ed1f[_0xb5d1('0x59')]({'plain':!![]}),{'customerIp':_0x249a51[_0xb5d1('0xa3')][_0xb5d1('0xa5')]||_0x249a51[_0xb5d1('0xa3')][_0xb5d1('0xff')]||_0x249a51[_0xb5d1('0x100')]['remoteAddress']||_0x249a51['ip'],'referer':_0x249a51[_0xb5d1('0xa3')][_0xb5d1('0x101')],'openedInteractions':_0xd224bb,'maxInteractions':_0x1f67e9,'virtual':_0x4d17c2[_0xb5d1('0xf6')],'online':_0x46733a,'custom':_0x4d17c2}))['replace'](/'/g,'\x5c\x27')};_0x1d909c[_0xb5d1('0x37')](ejs[_0xb5d1('0xcf')](Mustache['render'](_0x4ec414,_0xed5ec9),{'proactiveActions':_0x318f02,'alignment':_0x25ed1f[_0xb5d1('0x102')],'verticalAlignment':_0x25ed1f[_0xb5d1('0x103')],'div_color':_0x25ed1f[_0xb5d1('0xe6')],'text_color':_0x25ed1f[_0xb5d1('0x104')]}));})['catch'](handleError(_0x1d909c,null));};exports['addApplications']=function(_0x6547f4,_0x32e6c6,_0x469a7d){return db[_0xb5d1('0x3c')][_0xb5d1('0x61')]({'where':{'id':_0x6547f4[_0xb5d1('0x52')]['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x32e6c6,null))[_0xb5d1('0x31')](function(_0x16a5ba){if(_0x16a5ba){return db['sequelize'][_0xb5d1('0x105')](function(_0x34f46a){return db[_0xb5d1('0x9b')][_0xb5d1('0x32')]({'where':{'ChatWebsiteId':_0x6547f4['params']['id']},'transaction':_0x34f46a})['then'](function(_0x43988a){var _0xd886f0=_[_0xb5d1('0x3b')](_0x6547f4[_0xb5d1('0x57')],function(_0x41d26f){_0x41d26f[_0xb5d1('0x5f')]=_0x6547f4[_0xb5d1('0x52')]['id'];return _0x41d26f;});return db[_0xb5d1('0x9b')][_0xb5d1('0x106')](_0xd886f0,{'transaction':_0x34f46a});});})[_0xb5d1('0x31')](function(){return db[_0xb5d1('0x9b')][_0xb5d1('0x107')]({'where':{'ChatWebsiteId':_0x6547f4[_0xb5d1('0x52')]['id']},'order':'priority'});});}})[_0xb5d1('0x31')](respondWithResult(_0x32e6c6,null))[_0xb5d1('0x50')](handleError(_0x32e6c6,null));};exports[_0xb5d1('0x108')]=function(_0x333de6,_0x222661,_0x553a74){var _0x1d3433={};var _0x4315de={};var _0x146642;var _0xd8d952;return db['ChatWebsite'][_0xb5d1('0x61')]({'where':{'id':_0x333de6['params']['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x222661,null))['then'](function(_0x362582){if(_0x362582){_0x146642=_0x362582;_0x4315de[_0xb5d1('0x40')]=_[_0xb5d1('0x53')](db[_0xb5d1('0x9b')]['rawAttributes']);_0x4315de['query']=_[_0xb5d1('0x53')](_0x333de6[_0xb5d1('0x41')]);_0x4315de['filters']=_[_0xb5d1('0x43')](_0x4315de[_0xb5d1('0x40')],_0x4315de[_0xb5d1('0x41')]);_0x1d3433[_0xb5d1('0x44')]=_['intersection'](_0x4315de[_0xb5d1('0x40')],qs['fields'](_0x333de6[_0xb5d1('0x41')]['fields']));_0x1d3433[_0xb5d1('0x44')]=_0x1d3433['attributes'][_0xb5d1('0x46')]?_0x1d3433['attributes']:_0x4315de['model'];_0x1d3433[_0xb5d1('0x48')]=qs['sort'](_0x333de6[_0xb5d1('0x41')]['sort']);_0x1d3433[_0xb5d1('0x4b')]=qs[_0xb5d1('0x42')](_[_0xb5d1('0x65')](_0x333de6['query'],_0x4315de[_0xb5d1('0x42')]));if(_0x333de6['query']['filter']){_0x1d3433[_0xb5d1('0x4b')]=_[_0xb5d1('0x66')](_0x1d3433[_0xb5d1('0x4b')],{'$or':_[_0xb5d1('0x3b')](_0x1d3433[_0xb5d1('0x44')],function(_0x211449){var _0x85ddce={};_0x85ddce[_0x211449]={'$like':'%'+_0x333de6[_0xb5d1('0x41')][_0xb5d1('0x4a')]+'%'};return _0x85ddce;})});}_0x1d3433=_[_0xb5d1('0x66')]({},_0x1d3433,_0x333de6[_0xb5d1('0x4c')]);return _0x146642[_0xb5d1('0x108')](_0x1d3433);}})[_0xb5d1('0x31')](function(_0x56762c){if(_0x56762c){_0xd8d952=_0x56762c[_0xb5d1('0x46')];if(!_0x333de6[_0xb5d1('0x41')][_0xb5d1('0x64')](_0xb5d1('0x47'))){_0x1d3433[_0xb5d1('0x2c')]=qs[_0xb5d1('0x2c')](_0x333de6[_0xb5d1('0x41')][_0xb5d1('0x2c')]);_0x1d3433[_0xb5d1('0x2b')]=qs[_0xb5d1('0x2b')](_0x333de6[_0xb5d1('0x41')][_0xb5d1('0x2b')]);}return _0x146642[_0xb5d1('0x108')](_0x1d3433);}})[_0xb5d1('0x31')](function(_0x106d49){if(_0x106d49){return _0x106d49?{'count':_0xd8d952,'rows':_0x106d49}:null;}})['then'](respondWithResult(_0x222661,null))[_0xb5d1('0x50')](handleError(_0x222661,null));};exports['addProactiveActions']=function(_0x5c261b,_0x307096,_0x3f271d){return db[_0xb5d1('0x109')][_0xb5d1('0x55')]({'where':{'id':_0x5c261b[_0xb5d1('0x52')]['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x307096,null))['then'](function(_0x242406){if(_0x242406){return _0x242406['addProactiveActions'](_0x5c261b[_0xb5d1('0x57')][_0xb5d1('0xe0')],_[_0xb5d1('0x10a')](_0x5c261b[_0xb5d1('0x57')],[_0xb5d1('0xe0'),'id'])||{});}})[_0xb5d1('0x31')](respondWithResult(_0x307096,null))['catch'](handleError(_0x307096,null));};exports[_0xb5d1('0xf5')]=function(_0x20689e,_0x11fdba,_0x4ce89a){var _0x2b44d1={};var _0x56ee1a={};var _0x2de698;var _0x4c5bf6;return db[_0xb5d1('0x3c')][_0xb5d1('0x61')]({'where':{'id':_0x20689e[_0xb5d1('0x52')]['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x11fdba,null))[_0xb5d1('0x31')](function(_0x45250c){if(_0x45250c){_0x2de698=_0x45250c;_0x56ee1a[_0xb5d1('0x40')]=_[_0xb5d1('0x53')](db[_0xb5d1('0x10b')][_0xb5d1('0x63')]);_0x56ee1a[_0xb5d1('0x41')]=_[_0xb5d1('0x53')](_0x20689e[_0xb5d1('0x41')]);_0x56ee1a[_0xb5d1('0x42')]=_[_0xb5d1('0x43')](_0x56ee1a[_0xb5d1('0x40')],_0x56ee1a['query']);_0x2b44d1[_0xb5d1('0x44')]=_[_0xb5d1('0x43')](_0x56ee1a[_0xb5d1('0x40')],qs[_0xb5d1('0x45')](_0x20689e[_0xb5d1('0x41')]['fields']));_0x2b44d1['attributes']=_0x2b44d1[_0xb5d1('0x44')][_0xb5d1('0x46')]?_0x2b44d1[_0xb5d1('0x44')]:_0x56ee1a[_0xb5d1('0x40')];_0x2b44d1[_0xb5d1('0x48')]=qs['sort'](_0x20689e[_0xb5d1('0x41')][_0xb5d1('0x49')]);_0x2b44d1[_0xb5d1('0x4b')]=qs[_0xb5d1('0x42')](_[_0xb5d1('0x65')](_0x20689e[_0xb5d1('0x41')],_0x56ee1a[_0xb5d1('0x42')]));if(_0x20689e[_0xb5d1('0x41')][_0xb5d1('0x4a')]){_0x2b44d1[_0xb5d1('0x4b')]=_['merge'](_0x2b44d1['where'],{'$or':_[_0xb5d1('0x3b')](_0x2b44d1['attributes'],function(_0x23f2a4){var _0x19be5b={};_0x19be5b[_0x23f2a4]={'$like':'%'+_0x20689e['query'][_0xb5d1('0x4a')]+'%'};return _0x19be5b;})});}_0x2b44d1=_[_0xb5d1('0x66')]({},_0x2b44d1,_0x20689e[_0xb5d1('0x4c')]);return _0x2de698['getProactiveActions'](_0x2b44d1);}})[_0xb5d1('0x31')](function(_0x32bfbe){if(_0x32bfbe){_0x4c5bf6=_0x32bfbe['length'];if(!_0x20689e[_0xb5d1('0x41')][_0xb5d1('0x64')](_0xb5d1('0x47'))){_0x2b44d1['limit']=qs[_0xb5d1('0x2c')](_0x20689e[_0xb5d1('0x41')][_0xb5d1('0x2c')]);_0x2b44d1[_0xb5d1('0x2b')]=qs[_0xb5d1('0x2b')](_0x20689e['query']['offset']);}return _0x2de698[_0xb5d1('0xf5')](_0x2b44d1);}})[_0xb5d1('0x31')](function(_0x26ea1c){if(_0x26ea1c){return _0x26ea1c?{'count':_0x4c5bf6,'rows':_0x26ea1c}:null;}})[_0xb5d1('0x31')](respondWithResult(_0x11fdba,null))[_0xb5d1('0x50')](handleError(_0x11fdba,null));};exports['getFields']=function(_0x1315e2,_0x3761cc,_0x2ddda4){var _0x59806d=_0x1315e2[_0xb5d1('0x41')][_0xb5d1('0x10c')]==='false'?_0xb5d1('0x10d'):_0xb5d1('0x10e');return db[_0xb5d1('0x3c')]['find']({'attributes':['id',_0x59806d],'where':{'id':_0x1315e2[_0xb5d1('0x52')]['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x3761cc,null))[_0xb5d1('0x31')](function(_0x2e4df0){if(_0x2e4df0){var _0x3a76e7=_0x2e4df0[_0x59806d];var _0x50f769=_0x3a76e7&&_0x3a76e7['items']?_0x3a76e7[_0xb5d1('0x10f')]:[];_0x3761cc['send']({'fromKey':_[_0xb5d1('0x7a')](_0x3a76e7[_0xb5d1('0x110')])?undefined:_0x3a76e7['fromKey'],'count':_0x50f769[_0xb5d1('0x46')],'rows':_0x50f769});}})[_0xb5d1('0x50')](handleError(_0x3761cc,null));};exports[_0xb5d1('0x111')]=function(_0xcbaf02,_0x210654,_0x3306eb){var _0x37d91d={'raw':![],'where':{}};var _0xe2e775={};var _0x42719a={'count':0x0,'rows':[]};return db[_0xb5d1('0x3c')][_0xb5d1('0x61')]({'where':{'id':_0xcbaf02[_0xb5d1('0x52')]['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x210654,null))[_0xb5d1('0x31')](function(_0x406ca0){if(_0x406ca0){_0xe2e775['model']=_[_0xb5d1('0x53')](db[_0xb5d1('0xd0')][_0xb5d1('0x63')]);_0xe2e775[_0xb5d1('0x41')]=_[_0xb5d1('0x53')](_0xcbaf02[_0xb5d1('0x41')]);_0xe2e775['filters']=_['intersection'](_0xe2e775['model'],_0xe2e775[_0xb5d1('0x41')]);_0x37d91d[_0xb5d1('0x44')]=_[_0xb5d1('0x43')](_0xe2e775[_0xb5d1('0x40')],qs[_0xb5d1('0x45')](_0xcbaf02['query'][_0xb5d1('0x45')]));_0x37d91d[_0xb5d1('0x44')]=_0x37d91d[_0xb5d1('0x44')][_0xb5d1('0x46')]?_0x37d91d[_0xb5d1('0x44')]:_0xe2e775['model'];if(!_0xcbaf02['query'][_0xb5d1('0x64')](_0xb5d1('0x47'))){_0x37d91d[_0xb5d1('0x2c')]=qs['limit'](_0xcbaf02[_0xb5d1('0x41')]['limit']);_0x37d91d[_0xb5d1('0x2b')]=qs[_0xb5d1('0x2b')](_0xcbaf02['query'][_0xb5d1('0x2b')]);}_0x37d91d[_0xb5d1('0x48')]=qs[_0xb5d1('0x49')](_0xcbaf02[_0xb5d1('0x41')][_0xb5d1('0x49')]);_0x37d91d[_0xb5d1('0x4b')]=qs[_0xb5d1('0x42')](_['pick'](_0xcbaf02[_0xb5d1('0x41')],_0xe2e775[_0xb5d1('0x42')]));_0x37d91d[_0xb5d1('0x4b')][_0xb5d1('0x5f')]=_0x406ca0['id'];if(_0xcbaf02[_0xb5d1('0x41')][_0xb5d1('0x4a')]){_0x37d91d[_0xb5d1('0x4b')]=_[_0xb5d1('0x66')](_0x37d91d[_0xb5d1('0x4b')],{'$or':_['map'](_0x37d91d[_0xb5d1('0x44')],function(_0x1002e4){var _0x3ac23b={};_0x3ac23b[_0x1002e4]={'$like':'%'+_0xcbaf02[_0xb5d1('0x41')]['filter']+'%'};return _0x3ac23b;})});}_0x37d91d=_[_0xb5d1('0x66')]({},_0x37d91d,_0xcbaf02[_0xb5d1('0x4c')]);return db['ChatOfflineMessage'][_0xb5d1('0x2a')]({'where':_0x37d91d['where']})[_0xb5d1('0x31')](function(_0x1cecd4){_0x42719a[_0xb5d1('0x2a')]=_0x1cecd4;if(_0xcbaf02[_0xb5d1('0x41')][_0xb5d1('0x4d')]){_0x37d91d[_0xb5d1('0x54')]=[{'all':!![]}];}else{_0x37d91d[_0xb5d1('0x54')]=[{'model':db[_0xb5d1('0x8b')],'as':_0xb5d1('0xe1'),'required':![]}];}return db['ChatOfflineMessage'][_0xb5d1('0x4e')](_0x37d91d);})[_0xb5d1('0x31')](function(_0x348a24){_0x42719a['rows']=_0x348a24;return _0x42719a;});}})[_0xb5d1('0x31')](respondWithFilteredResult(_0x210654,_0x37d91d))[_0xb5d1('0x50')](handleError(_0x210654,null));};exports[_0xb5d1('0x112')]=function(_0x5480ef,_0x3347ec,_0x309c48){return db['ChatWebsite']['find']({'where':{'id':_0x5480ef[_0xb5d1('0x52')]['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x3347ec,null))[_0xb5d1('0x31')](function(_0x5c508b){if(_0x5c508b){return _0x5c508b[_0xb5d1('0x112')](_0x5480ef[_0xb5d1('0x57')]['ids'],_[_0xb5d1('0x10a')](_0x5480ef[_0xb5d1('0x57')],[_0xb5d1('0xe0'),'id'])||{})[_0xb5d1('0xb5')](function(_0x49f8a4){for(var _0x5dc153=0x0;_0x5dc153<_0x5480ef['body'][_0xb5d1('0xe0')][_0xb5d1('0x46')];_0x5dc153+=0x1){socket[_0xb5d1('0x113')](_0xb5d1('0x114'),{'UserId':_0x5480ef[_0xb5d1('0x57')]['ids'][_0x5dc153],'ChatWebsiteId':_0x5480ef[_0xb5d1('0x52')]['id']});}return _0x49f8a4;});}})[_0xb5d1('0x31')](respondWithResult(_0x3347ec,null))[_0xb5d1('0x50')](handleError(_0x3347ec,null));};exports[_0xb5d1('0x115')]=function(_0x3bd029,_0x4b6511,_0xb7d71){return db[_0xb5d1('0x3c')][_0xb5d1('0x55')]({'where':{'id':_0x3bd029[_0xb5d1('0x52')]['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x4b6511,null))['then'](function(_0x349e04){if(_0x349e04){return _0x349e04['removeAgents'](_0x3bd029[_0xb5d1('0x41')][_0xb5d1('0xe0')])[_0xb5d1('0x31')](function(){if(_[_0xb5d1('0x116')](_0x3bd029[_0xb5d1('0x41')][_0xb5d1('0xe0')])){for(var _0x196b69=0x0;_0x196b69<_0x3bd029['query'][_0xb5d1('0xe0')][_0xb5d1('0x46')];_0x196b69+=0x1){socket[_0xb5d1('0x113')](_0xb5d1('0x117'),{'UserId':Number(_0x3bd029[_0xb5d1('0x41')]['ids'][_0x196b69]),'ChatWebsiteId':Number(_0x3bd029[_0xb5d1('0x52')]['id'])});}}else{socket[_0xb5d1('0x113')]('userChatWebsite:remove',{'UserId':Number(_0x3bd029[_0xb5d1('0x41')][_0xb5d1('0xe0')]),'ChatWebsiteId':Number(_0x3bd029['params']['id'])});}});}})[_0xb5d1('0x31')](respondWithStatusCode(_0x4b6511,null))[_0xb5d1('0x50')](handleError(_0x4b6511,null));};exports[_0xb5d1('0x118')]=function(_0x27b224,_0x3048ba,_0x207dce){var _0x588173={};var _0x17fe61={};var _0x18abe6;var _0x5116fc;return db[_0xb5d1('0x3c')][_0xb5d1('0x61')]({'where':{'id':_0x27b224[_0xb5d1('0x52')]['id']}})[_0xb5d1('0x31')](handleEntityNotFound(_0x3048ba,null))[_0xb5d1('0x31')](function(_0x4f3e25){if(_0x4f3e25){_0x18abe6=_0x4f3e25;_0x17fe61[_0xb5d1('0x40')]=_[_0xb5d1('0x53')](db[_0xb5d1('0xbe')][_0xb5d1('0x63')]);_0x17fe61['query']=_['keys'](_0x27b224[_0xb5d1('0x41')]);_0x17fe61['filters']=_[_0xb5d1('0x43')](_0x17fe61['model'],_0x17fe61[_0xb5d1('0x41')]);_0x588173['attributes']=_[_0xb5d1('0x43')](_0x17fe61[_0xb5d1('0x40')],qs[_0xb5d1('0x45')](_0x27b224[_0xb5d1('0x41')][_0xb5d1('0x45')]));_0x588173[_0xb5d1('0x44')]=_0x588173[_0xb5d1('0x44')][_0xb5d1('0x46')]?_0x588173[_0xb5d1('0x44')]:_0x17fe61['model'];_0x588173[_0xb5d1('0x48')]=qs['sort'](_0x27b224['query'][_0xb5d1('0x49')]);_0x588173[_0xb5d1('0x4b')]=qs[_0xb5d1('0x42')](_[_0xb5d1('0x65')](_0x27b224['query'],_0x17fe61[_0xb5d1('0x42')]));if(_0x27b224['query'][_0xb5d1('0x4a')]){_0x588173['where']=_[_0xb5d1('0x66')](_0x588173[_0xb5d1('0x4b')],{'$or':_[_0xb5d1('0x3b')](_0x588173[_0xb5d1('0x44')],function(_0x329172){var _0x4a0115={};_0x4a0115[_0x329172]={'$like':'%'+_0x27b224['query'][_0xb5d1('0x4a')]+'%'};return _0x4a0115;})});}_0x588173=_[_0xb5d1('0x66')]({},_0x588173,_0x27b224[_0xb5d1('0x4c')]);return _0x18abe6[_0xb5d1('0x118')](_0x588173);}})['then'](function(_0x4fea11){if(_0x4fea11){_0x5116fc=_0x4fea11[_0xb5d1('0x46')];if(!_0x27b224['query']['hasOwnProperty']('nolimit')){_0x588173[_0xb5d1('0x2c')]=qs['limit'](_0x27b224[_0xb5d1('0x41')][_0xb5d1('0x2c')]);_0x588173['offset']=qs['offset'](_0x27b224[_0xb5d1('0x41')][_0xb5d1('0x2b')]);}return _0x18abe6[_0xb5d1('0x118')](_0x588173);}})['then'](function(_0x590407){if(_0x590407){return _0x590407?{'count':_0x5116fc,'rows':_0x590407}:null;}})['then'](respondWithResult(_0x3048ba,null))[_0xb5d1('0x50')](handleError(_0x3048ba,null));};
\ No newline at end of file