Built motion from commit (unavailable).|2.5.23
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 9759d47..039a415 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x11f1=['getInteractions','Contact','User','Owner','internal','Tag','color','tag','timezone','interval','iftime\x20%s','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','Interval','Intervals','getProactiveActions','virtual','License','increment','push','all','some','server/files/chat/iframe.js','stringify','x-forwarded-for','x-real-ip','connection','alignment','verticalAlignment','addApplications','transaction','ChatApplication','bulkCreate','findAndCountAll','getApplications','chatProactiveAction','addProactiveActions','online','false','offlineForm','onlineForm','items','fromKey','ChatOfflineMessage','addAgents','emit','userChatWebsite:save','userChatWebsite:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','crypto','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./chatWebsite.socket','register','jayson/promise','client','http','test','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','sendStatus','status','end','json','offset','limit','set','Content-Range','apply','reject','save','update','destroy','get','ChatWebsites','stack','name','send','index','mandatoryDispositionPause','rawAttributes','fieldName','type','map','query','filters','model','attributes','length','nolimit','order','sort','where','pick','merge','VIRTUAL','ChatWebsite','count','includeAll','include','rows','catch','show','params','Pause','keys','intersection','fields','options','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','ChatWebsiteId','Disposition','getDispositions','hasOwnProperty','removeDispositions','ids','addAnswer','CannedAnswer','filter','findAll','removeAnswers','sitepic','file','filename','agentAvatar','addCustomerAvatar','customerAvatar','addSystemAvatar','systemAvatar','getLogo','join','server/files/images/logos/default_logo.png','../../config/license/util','getLicense','custom','isNil','existsSync','root','server/files/images/logos/','server/files/images/avatars/default_avatar.png','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','download','getSystemAvatar','notify','user-agent-parser','setUA','headers','user-agent','chat','CmContact','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','from','from\x20is\x20mandatory','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','Contacts','DESC','Applications','account','applications','priority','asc','cf-connecting-ip','first','x-real-port','referer','browser','version','format','%s\x20%s','unknown','device','%s\x20%s\x20%s','vendor','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','firstName','contact','messageId','created','autoclose','*,*,*,*','ChatMessage','UserId','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','defaults','findOrCreate','readFileSync','utf8','render','toPairs','offlineMessageBody','MailAccount','findOne','MailServerOut','Smtp','forwardOfflineAddress','service','host','port','secure','auth','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','addInteraction','omit'];(function(_0x5327da,_0xb7d219){var _0x46c142=function(_0x145cbc){while(--_0x145cbc){_0x5327da['push'](_0x5327da['shift']());}};_0x46c142(++_0xb7d219);}(_0x11f1,0x155));var _0x111f=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x11f1[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x111f('0x0'));var rimraf=require(_0x111f('0x1'));var zipdir=require(_0x111f('0x2'));var jsonpatch=require(_0x111f('0x3'));var rp=require(_0x111f('0x4'));var moment=require(_0x111f('0x5'));var BPromise=require(_0x111f('0x6'));var Mustache=require(_0x111f('0x7'));var util=require(_0x111f('0x8'));var path=require(_0x111f('0x9'));var sox=require(_0x111f('0xa'));var csv=require(_0x111f('0xb'));var ejs=require(_0x111f('0xc'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0x111f('0xd'));var jsforce=require(_0x111f('0xe'));var deskjs=require(_0x111f('0xf'));var toCsv=require(_0x111f('0xb'));var querystring=require('querystring');var Papa=require(_0x111f('0x10'));var Redis=require('ioredis');var authService=require(_0x111f('0x11'));var qs=require(_0x111f('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x111f('0x13'))(_0x111f('0x14'));var utils=require(_0x111f('0x15'));var config=require(_0x111f('0x16'));var db=require(_0x111f('0x17'))['db'];config[_0x111f('0x18')]=_['defaults'](config[_0x111f('0x18')],{'host':_0x111f('0x19'),'port':0x18eb});var socket=require(_0x111f('0x1a'))(new Redis(config[_0x111f('0x18')]));require(_0x111f('0x1b'))[_0x111f('0x1c')](socket);var jayson=require(_0x111f('0x1d'));var client=jayson[_0x111f('0x1e')][_0x111f('0x1f')]({'port':0x232c});var client9002=jayson['client'][_0x111f('0x1f')]({'port':0x232a});var client9003=jayson['client'][_0x111f('0x1f')]({'port':0x232b});function checkPasswordPattern(_0x4ef14e,_0x296e98,_0x411fd5){if(_0x411fd5){var _0x1e70d3=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x1e70d3[_0x111f('0x20')](_0x296e98)){return _0x4ef14e;}else{throw new db[(_0x111f('0x21'))][(_0x111f('0x22'))](_0x111f('0x23'));}}else{return _0x4ef14e;}}function respondWithRpcPromise(_0x357892,_0x2b9289,_0x12ab00,_0x27d3d6){return new BPromise(function(_0x2198c3,_0x15d0b3){var _0x293a31=_0x27d3d6||client;return _0x293a31[_0x111f('0x24')](_0x357892,_0x12ab00)[_0x111f('0x25')](function(_0x4433a5){logger[_0x111f('0x26')](_0x111f('0x27'),_0x2b9289,_0x111f('0x28'));logger[_0x111f('0x29')]('ChatWebsite,\x20%s,\x20%s,\x20%s',_0x2b9289,_0x111f('0x28'),JSON['stringify'](_0x4433a5));if(_0x4433a5['error']){if(_0x4433a5[_0x111f('0x2a')][_0x111f('0x2b')]===0x1f4){logger[_0x111f('0x2a')](_0x111f('0x27'),_0x2b9289,_0x4433a5[_0x111f('0x2a')]['message']);return _0x15d0b3(_0x4433a5['error'][_0x111f('0x2c')]);}logger[_0x111f('0x2a')](_0x111f('0x27'),_0x2b9289,_0x4433a5[_0x111f('0x2a')][_0x111f('0x2c')]);return _0x2198c3(_0x4433a5[_0x111f('0x2a')]['message']);}else{logger[_0x111f('0x26')]('ChatWebsite,\x20%s,\x20%s',_0x2b9289,_0x111f('0x28'));_0x2198c3(_0x4433a5[_0x111f('0x2d')][_0x111f('0x2c')]);}})['catch'](function(_0x131257){logger[_0x111f('0x2a')]('ChatWebsite,\x20%s,\x20%s',_0x2b9289,_0x131257);_0x15d0b3(_0x131257);});});}function respondWithStatusCode(_0x40f509,_0x3520bb){_0x3520bb=_0x3520bb||0xcc;return function(_0x37d261){if(_0x37d261){return _0x40f509[_0x111f('0x2e')](_0x3520bb);}return _0x40f509[_0x111f('0x2f')](_0x3520bb)[_0x111f('0x30')]();};}function respondWithResult(_0x5c86c2,_0x578a39){_0x578a39=_0x578a39||0xc8;return function(_0x35f4f9){if(_0x35f4f9){return _0x5c86c2[_0x111f('0x2f')](_0x578a39)[_0x111f('0x31')](_0x35f4f9);}};}function respondWithFilteredResult(_0x140cff,_0x5a3320){return function(_0x1e587e){if(_0x1e587e){var _0x320387=_0x1e587e['count'],_0xad0ee7=_0x5a3320[_0x111f('0x32')],_0x8c2cfe=_0x5a3320[_0x111f('0x32')]+_0x5a3320[_0x111f('0x33')],_0x4b4e7e;if(_0x8c2cfe>=_0x320387){_0x8c2cfe=_0x320387;_0x4b4e7e=0xc8;}else{_0x4b4e7e=0xce;}_0x140cff['status'](_0x4b4e7e);return _0x140cff[_0x111f('0x34')](_0x111f('0x35'),_0xad0ee7+'-'+_0x8c2cfe+'/'+_0x320387)['json'](_0x1e587e);}return null;};}function patchUpdates(_0x300d69){return function(_0x34698a){try{jsonpatch[_0x111f('0x36')](_0x34698a,_0x300d69,!![]);}catch(_0x279ad8){return BPromise[_0x111f('0x37')](_0x279ad8);}return _0x34698a[_0x111f('0x38')]();};}function saveUpdates(_0x4495d8,_0x564347){return function(_0xcc7d12){if(_0xcc7d12){return _0xcc7d12[_0x111f('0x39')](_0x4495d8)[_0x111f('0x25')](function(_0x209ae9){return _0x209ae9;});}return null;};}function removeEntity(_0x545abf,_0x1d60bd){return function(_0x3a6ded){if(_0x3a6ded){return _0x3a6ded[_0x111f('0x3a')]()[_0x111f('0x25')](function(){var _0x44d970=_0x3a6ded[_0x111f('0x3b')]({'plain':!![]});var _0xddb61a=_0x111f('0x3c');return db['UserProfileResource'][_0x111f('0x3a')]({'where':{'type':_0xddb61a,'resourceId':_0x44d970['id']}})[_0x111f('0x25')](function(){return _0x3a6ded;});})[_0x111f('0x25')](function(){_0x545abf[_0x111f('0x2f')](0xcc)[_0x111f('0x30')]();});}};}function handleEntityNotFound(_0x10d4cb,_0x34b493){return function(_0xfabe20){if(!_0xfabe20){_0x10d4cb[_0x111f('0x2e')](0x194);}return _0xfabe20;};}function handleError(_0x496be7,_0x1e5279){_0x1e5279=_0x1e5279||0x1f4;return function(_0x24faca){logger[_0x111f('0x2a')](_0x24faca[_0x111f('0x3d')]);if(_0x24faca[_0x111f('0x3e')]){delete _0x24faca['name'];}_0x496be7['status'](_0x1e5279)[_0x111f('0x3f')](_0x24faca);};}exports[_0x111f('0x40')]=function(_0xb8bfd7,_0x4f04a3){var _0x49f5e2={'include':[{'model':db['Pause'],'as':_0x111f('0x41')}]},_0x4e0209={},_0x4095b4={'count':0x0,'rows':[]};var _0x18e2b7=_['map'](db['ChatWebsite'][_0x111f('0x42')],function(_0x139b21){return{'name':_0x139b21[_0x111f('0x43')],'type':_0x139b21[_0x111f('0x44')]['key']};});_0x4e0209['model']=_[_0x111f('0x45')](_0x18e2b7,_0x111f('0x3e'));_0x4e0209['query']=_['keys'](_0xb8bfd7[_0x111f('0x46')]);_0x4e0209[_0x111f('0x47')]=_['intersection'](_0x4e0209[_0x111f('0x48')],_0x4e0209[_0x111f('0x46')]);_0x49f5e2[_0x111f('0x49')]=_['intersection'](_0x4e0209[_0x111f('0x48')],qs['fields'](_0xb8bfd7[_0x111f('0x46')]['fields']));_0x49f5e2[_0x111f('0x49')]=_0x49f5e2['attributes'][_0x111f('0x4a')]?_0x49f5e2['attributes']:_0x4e0209[_0x111f('0x48')];if(!_0xb8bfd7[_0x111f('0x46')]['hasOwnProperty'](_0x111f('0x4b'))){_0x49f5e2['limit']=qs[_0x111f('0x33')](_0xb8bfd7[_0x111f('0x46')][_0x111f('0x33')]);_0x49f5e2[_0x111f('0x32')]=qs[_0x111f('0x32')](_0xb8bfd7[_0x111f('0x46')]['offset']);}_0x49f5e2[_0x111f('0x4c')]=qs[_0x111f('0x4d')](_0xb8bfd7[_0x111f('0x46')][_0x111f('0x4d')]);_0x49f5e2[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0xb8bfd7[_0x111f('0x46')],_0x4e0209['filters']));if(_0xb8bfd7[_0x111f('0x46')]['filter']){_0x49f5e2['where']=_[_0x111f('0x50')](_0x49f5e2['where'],{'$or':_['map'](_0x18e2b7,function(_0x190ad7){if(_0x190ad7['type']!==_0x111f('0x51')){var _0x965192={};_0x965192[_0x190ad7[_0x111f('0x3e')]]={'$like':'%'+_0xb8bfd7['query']['filter']+'%'};return _0x965192;}})});}_0x49f5e2=_[_0x111f('0x50')]({},_0x49f5e2,_0xb8bfd7['options']);var _0x43a3a8={'where':_0x49f5e2[_0x111f('0x4e')]};return db[_0x111f('0x52')]['count'](_0x43a3a8)[_0x111f('0x25')](function(_0x1e008f){_0x4095b4[_0x111f('0x53')]=_0x1e008f;if(_0xb8bfd7[_0x111f('0x46')][_0x111f('0x54')]){_0x49f5e2[_0x111f('0x55')]=[{'all':!![]}];}return db[_0x111f('0x52')]['findAll'](_0x49f5e2);})[_0x111f('0x25')](function(_0x2c8b30){_0x4095b4[_0x111f('0x56')]=_0x2c8b30;return _0x4095b4;})['then'](respondWithFilteredResult(_0x4f04a3,_0x49f5e2))[_0x111f('0x57')](handleError(_0x4f04a3,null));};exports[_0x111f('0x58')]=function(_0x17a37a,_0x11dd5e){var _0xac4a93={'raw':![],'where':{'id':_0x17a37a[_0x111f('0x59')]['id']},'include':[{'model':db[_0x111f('0x5a')],'as':_0x111f('0x41')}]},_0x3ca6c8={};_0x3ca6c8[_0x111f('0x48')]=_[_0x111f('0x5b')](db['ChatWebsite'][_0x111f('0x42')]);_0x3ca6c8[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x17a37a[_0x111f('0x46')]);_0x3ca6c8[_0x111f('0x47')]=_['intersection'](_0x3ca6c8['model'],_0x3ca6c8[_0x111f('0x46')]);_0xac4a93['attributes']=_[_0x111f('0x5c')](_0x3ca6c8[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x17a37a[_0x111f('0x46')][_0x111f('0x5d')]));_0xac4a93[_0x111f('0x49')]=_0xac4a93[_0x111f('0x49')]['length']?_0xac4a93[_0x111f('0x49')]:_0x3ca6c8[_0x111f('0x48')];if(_0x17a37a[_0x111f('0x46')][_0x111f('0x54')]){_0xac4a93[_0x111f('0x55')]=[{'all':!![]}];}_0xac4a93=_[_0x111f('0x50')]({},_0xac4a93,_0x17a37a[_0x111f('0x5e')]);return db[_0x111f('0x52')]['find'](_0xac4a93)[_0x111f('0x25')](handleEntityNotFound(_0x11dd5e,null))[_0x111f('0x25')](respondWithResult(_0x11dd5e,null))[_0x111f('0x57')](handleError(_0x11dd5e,null));};exports[_0x111f('0x5f')]=function(_0x1be243,_0x102ce5){return db[_0x111f('0x52')][_0x111f('0x5f')](_0x1be243[_0x111f('0x60')],{})[_0x111f('0x25')](function(_0x7b6d2e){var _0x12b0d4=_0x1be243[_0x111f('0x61')][_0x111f('0x3b')]({'plain':!![]});if(!_0x12b0d4)throw new Error(_0x111f('0x62'));if(_0x12b0d4[_0x111f('0x63')]==='user'){var _0x4f1700=_0x7b6d2e[_0x111f('0x3b')]({'plain':!![]});var _0x5c0ba8=_0x111f('0x3c');return db[_0x111f('0x64')][_0x111f('0x65')]({'where':{'name':_0x5c0ba8,'userProfileId':_0x12b0d4[_0x111f('0x66')]},'raw':!![]})[_0x111f('0x25')](function(_0x14bf55){if(_0x14bf55&&_0x14bf55[_0x111f('0x67')]===0x0){return db[_0x111f('0x68')][_0x111f('0x5f')]({'name':_0x4f1700[_0x111f('0x3e')],'resourceId':_0x4f1700['id'],'type':_0x14bf55[_0x111f('0x3e')],'sectionId':_0x14bf55['id']},{})[_0x111f('0x25')](function(){return _0x7b6d2e;});}else{return _0x7b6d2e;}})[_0x111f('0x57')](function(_0x15e819){logger[_0x111f('0x2a')](_0x111f('0x69'),_0x15e819);throw _0x15e819;});}return _0x7b6d2e;})['then'](respondWithResult(_0x102ce5,0xc9))[_0x111f('0x57')](handleError(_0x102ce5,null));};exports['update']=function(_0xe193e,_0x501125){if(_0xe193e[_0x111f('0x60')]['id']){delete _0xe193e['body']['id'];}return db['ChatWebsite'][_0x111f('0x65')]({'where':{'id':_0xe193e[_0x111f('0x59')]['id']},'include':[{'model':db[_0x111f('0x5a')],'as':_0x111f('0x41')}]})['then'](handleEntityNotFound(_0x501125,null))[_0x111f('0x25')](saveUpdates(_0xe193e[_0x111f('0x60')],null))['then'](respondWithResult(_0x501125,null))[_0x111f('0x57')](handleError(_0x501125,null));};exports[_0x111f('0x3a')]=function(_0x4c9354,_0x1b82ef){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x4c9354[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x1b82ef,null))[_0x111f('0x25')](removeEntity(_0x1b82ef,null))[_0x111f('0x57')](handleError(_0x1b82ef,null));};exports[_0x111f('0x6a')]=function(_0x3c8b53,_0x1635ef){return db[_0x111f('0x52')][_0x111f('0x6a')]()[_0x111f('0x25')](respondWithResult(_0x1635ef,null))[_0x111f('0x57')](handleError(_0x1635ef,null));};exports['addDisposition']=function(_0x50ee6e,_0x41054a,_0x2b7f8c){if(_0x50ee6e[_0x111f('0x60')]['id']){delete _0x50ee6e['body']['id'];}return db['ChatWebsite']['find']({'where':{'id':_0x50ee6e['params']['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x41054a,null))[_0x111f('0x25')](function(_0x5b49fe){if(_0x5b49fe){_0x50ee6e[_0x111f('0x60')][_0x111f('0x6b')]=_0x5b49fe['id'];return db[_0x111f('0x6c')][_0x111f('0x5f')](_0x50ee6e[_0x111f('0x60')]);}})[_0x111f('0x25')](respondWithResult(_0x41054a,null))[_0x111f('0x57')](handleError(_0x41054a,null));};exports[_0x111f('0x6d')]=function(_0x8b6c13,_0x2ccec1,_0x3df3f2){var _0x1becd2={'raw':![],'where':{}};var _0x3af9a8={};var _0xeb9353={'count':0x0,'rows':[]};return db[_0x111f('0x52')]['findOne']({'where':{'id':_0x8b6c13[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x2ccec1,null))['then'](function(_0x40a8d5){if(_0x40a8d5){_0x3af9a8[_0x111f('0x48')]=_[_0x111f('0x5b')](db[_0x111f('0x6c')][_0x111f('0x42')]);_0x3af9a8['query']=_[_0x111f('0x5b')](_0x8b6c13[_0x111f('0x46')]);_0x3af9a8[_0x111f('0x47')]=_[_0x111f('0x5c')](_0x3af9a8[_0x111f('0x48')],_0x3af9a8['query']);_0x1becd2['attributes']=_['intersection'](_0x3af9a8[_0x111f('0x48')],qs['fields'](_0x8b6c13[_0x111f('0x46')][_0x111f('0x5d')]));_0x1becd2[_0x111f('0x49')]=_0x1becd2['attributes']['length']?_0x1becd2['attributes']:_0x3af9a8['model'];if(!_0x8b6c13[_0x111f('0x46')][_0x111f('0x6e')]('nolimit')){_0x1becd2['limit']=qs[_0x111f('0x33')](_0x8b6c13[_0x111f('0x46')][_0x111f('0x33')]);_0x1becd2[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x8b6c13[_0x111f('0x46')][_0x111f('0x32')]);}_0x1becd2[_0x111f('0x4c')]=qs['sort'](_0x8b6c13[_0x111f('0x46')][_0x111f('0x4d')]);_0x1becd2[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x8b6c13[_0x111f('0x46')],_0x3af9a8[_0x111f('0x47')]));_0x1becd2[_0x111f('0x4e')][_0x111f('0x6b')]=_0x40a8d5['id'];if(_0x8b6c13[_0x111f('0x46')]['filter']){_0x1becd2['where']=_[_0x111f('0x50')](_0x1becd2['where'],{'$or':_[_0x111f('0x45')](_0x1becd2[_0x111f('0x49')],function(_0x13ac34){var _0x4aae13={};_0x4aae13[_0x13ac34]={'$like':'%'+_0x8b6c13[_0x111f('0x46')]['filter']+'%'};return _0x4aae13;})});}_0x1becd2=_['merge']({},_0x1becd2,_0x8b6c13[_0x111f('0x5e')]);return db[_0x111f('0x6c')][_0x111f('0x53')]({'where':_0x1becd2[_0x111f('0x4e')]})[_0x111f('0x25')](function(_0x2e5102){_0xeb9353[_0x111f('0x53')]=_0x2e5102;if(_0x8b6c13[_0x111f('0x46')][_0x111f('0x54')]){_0x1becd2['include']=[{'all':!![]}];}return db[_0x111f('0x6c')]['findAll'](_0x1becd2);})['then'](function(_0x1254b4){_0xeb9353[_0x111f('0x56')]=_0x1254b4;return _0xeb9353;});}})[_0x111f('0x25')](respondWithFilteredResult(_0x2ccec1,_0x1becd2))['catch'](handleError(_0x2ccec1,null));};exports[_0x111f('0x6f')]=function(_0x5c4c0d,_0x25b3d6,_0x3ba80b){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x5c4c0d[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x25b3d6,null))[_0x111f('0x25')](function(_0x5699a4){if(_0x5699a4){return _0x5699a4[_0x111f('0x6f')](_0x5c4c0d['query'][_0x111f('0x70')]);}})[_0x111f('0x25')](respondWithStatusCode(_0x25b3d6,null))['catch'](handleError(_0x25b3d6,null));};exports[_0x111f('0x71')]=function(_0x229752,_0x333239,_0x582132){if(_0x229752[_0x111f('0x60')]['id']){delete _0x229752['body']['id'];}return db[_0x111f('0x52')]['find']({'where':{'id':_0x229752[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x333239,null))[_0x111f('0x25')](function(_0x5211f8){if(_0x5211f8){_0x229752[_0x111f('0x60')][_0x111f('0x6b')]=_0x5211f8['id'];return db[_0x111f('0x72')][_0x111f('0x5f')](_0x229752[_0x111f('0x60')]);}})[_0x111f('0x25')](respondWithResult(_0x333239,null))[_0x111f('0x57')](handleError(_0x333239,null));};exports['getAnswers']=function(_0x41a0f8,_0x22662b,_0x6942a){var _0x2c0869={'raw':![],'where':{}};var _0x21be68={};var _0x201528={'count':0x0,'rows':[]};return db[_0x111f('0x52')]['findOne']({'where':{'id':_0x41a0f8[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x22662b,null))[_0x111f('0x25')](function(_0x259870){if(_0x259870){_0x21be68[_0x111f('0x48')]=_['keys'](db[_0x111f('0x72')][_0x111f('0x42')]);_0x21be68['query']=_[_0x111f('0x5b')](_0x41a0f8[_0x111f('0x46')]);_0x21be68[_0x111f('0x47')]=_[_0x111f('0x5c')](_0x21be68[_0x111f('0x48')],_0x21be68[_0x111f('0x46')]);_0x2c0869[_0x111f('0x49')]=_['intersection'](_0x21be68[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x41a0f8[_0x111f('0x46')][_0x111f('0x5d')]));_0x2c0869[_0x111f('0x49')]=_0x2c0869['attributes'][_0x111f('0x4a')]?_0x2c0869[_0x111f('0x49')]:_0x21be68[_0x111f('0x48')];if(!_0x41a0f8['query'][_0x111f('0x6e')]('nolimit')){_0x2c0869[_0x111f('0x33')]=qs[_0x111f('0x33')](_0x41a0f8[_0x111f('0x46')][_0x111f('0x33')]);_0x2c0869[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x41a0f8['query']['offset']);}_0x2c0869[_0x111f('0x4c')]=qs[_0x111f('0x4d')](_0x41a0f8[_0x111f('0x46')][_0x111f('0x4d')]);_0x2c0869[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x41a0f8[_0x111f('0x46')],_0x21be68['filters']));_0x2c0869[_0x111f('0x4e')][_0x111f('0x6b')]=_0x259870['id'];if(_0x41a0f8[_0x111f('0x46')]['filter']){_0x2c0869[_0x111f('0x4e')]=_[_0x111f('0x50')](_0x2c0869[_0x111f('0x4e')],{'$or':_['map'](_0x2c0869['attributes'],function(_0x2f2744){var _0x3d6f9b={};_0x3d6f9b[_0x2f2744]={'$like':'%'+_0x41a0f8[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x3d6f9b;})});}_0x2c0869=_[_0x111f('0x50')]({},_0x2c0869,_0x41a0f8['options']);return db['CannedAnswer'][_0x111f('0x53')]({'where':_0x2c0869[_0x111f('0x4e')]})['then'](function(_0x444251){_0x201528['count']=_0x444251;if(_0x41a0f8[_0x111f('0x46')][_0x111f('0x54')]){_0x2c0869[_0x111f('0x55')]=[{'all':!![]}];}return db[_0x111f('0x72')][_0x111f('0x74')](_0x2c0869);})[_0x111f('0x25')](function(_0x426625){_0x201528[_0x111f('0x56')]=_0x426625;return _0x201528;});}})[_0x111f('0x25')](respondWithFilteredResult(_0x22662b,_0x2c0869))['catch'](handleError(_0x22662b,null));};exports[_0x111f('0x75')]=function(_0x1997c0,_0x4b45c2,_0x222c4b){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x1997c0[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x4b45c2,null))['then'](function(_0x392380){if(_0x392380){return _0x392380[_0x111f('0x75')](_0x1997c0[_0x111f('0x46')][_0x111f('0x70')]);}})[_0x111f('0x25')](respondWithStatusCode(_0x4b45c2,null))[_0x111f('0x57')](handleError(_0x4b45c2,null));};exports['addLogo']=function(_0x3caec3,_0x3aeef9,_0x587cd2){_0x3caec3['body'][_0x111f('0x76')]=_0x3caec3[_0x111f('0x77')][_0x111f('0x78')];return db['ChatWebsite'][_0x111f('0x65')]({'where':{'id':_0x3caec3[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x3aeef9,null))[_0x111f('0x25')](saveUpdates(_0x3caec3['body'],null))[_0x111f('0x25')](respondWithResult(_0x3aeef9,null))[_0x111f('0x57')](handleError(_0x3aeef9,null));};exports['addAvatar']=function(_0x5b1e6f,_0x58657f,_0x3874a9){_0x5b1e6f[_0x111f('0x60')][_0x111f('0x79')]=_0x5b1e6f[_0x111f('0x77')]['filename'];return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x5b1e6f['params']['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x58657f,null))[_0x111f('0x25')](saveUpdates(_0x5b1e6f['body'],null))[_0x111f('0x25')](respondWithResult(_0x58657f,null))[_0x111f('0x57')](handleError(_0x58657f,null));};exports[_0x111f('0x7a')]=function(_0x4d8cf2,_0x1eb294,_0xce005d){_0x4d8cf2[_0x111f('0x60')][_0x111f('0x7b')]=_0x4d8cf2['file'][_0x111f('0x78')];return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x4d8cf2['params']['id']}})['then'](handleEntityNotFound(_0x1eb294,null))[_0x111f('0x25')](saveUpdates(_0x4d8cf2[_0x111f('0x60')],null))[_0x111f('0x25')](respondWithResult(_0x1eb294,null))['catch'](handleError(_0x1eb294,null));};exports[_0x111f('0x7c')]=function(_0x202576,_0x428b40,_0x19ff3a){_0x202576[_0x111f('0x60')][_0x111f('0x7d')]=_0x202576[_0x111f('0x77')][_0x111f('0x78')];return db[_0x111f('0x52')]['find']({'where':{'id':_0x202576[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x428b40,null))[_0x111f('0x25')](saveUpdates(_0x202576['body'],null))['then'](respondWithResult(_0x428b40,null))['catch'](handleError(_0x428b40,null));};exports[_0x111f('0x7e')]=function(_0x25789a,_0x5444af,_0x1de9c0){var _0x19185e=path[_0x111f('0x7f')](config['root'],_0x111f('0x80'));var _0x4c0a14={'where':{'id':_0x25789a[_0x111f('0x59')]['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x3c4d18=![];return require(_0x111f('0x81'))[_0x111f('0x82')]()[_0x111f('0x25')](function(_0x19548c){if(_0x19548c){_0x3c4d18=_0x19548c[_0x111f('0x83')];}})[_0x111f('0x25')](function(){return db[_0x111f('0x52')][_0x111f('0x65')](_0x4c0a14);})[_0x111f('0x25')](handleEntityNotFound(_0x5444af,null))[_0x111f('0x25')](function(_0x5b2c07){if(_0x5b2c07){if(!_[_0x111f('0x84')](_0x5b2c07['sitepic'])){if(fs[_0x111f('0x85')](path[_0x111f('0x7f')](config[_0x111f('0x86')],'server/files/images/logos/',_0x5b2c07[_0x111f('0x76')]))&&_0x3c4d18){_0x19185e=path[_0x111f('0x7f')](config['root'],_0x111f('0x87'),_0x5b2c07['sitepic']);}}return _0x5444af['download'](_0x19185e);}})['catch'](handleError(_0x5444af,null));};exports['getAvatar']=function(_0x32ed7a,_0x4131f8,_0x54e6a1){var _0x142dcd=path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x88'));var _0x2d9475={'where':{'id':_0x32ed7a[_0x111f('0x59')]['id']},'attributes':['id',_0x111f('0x79')],'raw':!![]};return db[_0x111f('0x52')][_0x111f('0x65')](_0x2d9475)[_0x111f('0x25')](handleEntityNotFound(_0x4131f8,null))[_0x111f('0x25')](function(_0x513871){if(_0x513871){if(!_[_0x111f('0x84')](_0x513871[_0x111f('0x79')])){if(fs[_0x111f('0x85')](path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x513871['agentAvatar']))){_0x142dcd=path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x513871[_0x111f('0x79')]);}}return _0x4131f8['download'](_0x142dcd);}})[_0x111f('0x57')](handleError(_0x4131f8,null));};exports[_0x111f('0x8a')]=function(_0x18fdb9,_0xd3698f,_0x59d2a1){var _0x1a6a07=path[_0x111f('0x7f')](config['root'],_0x111f('0x8b'));var _0x594a3c={'where':{'id':_0x18fdb9[_0x111f('0x59')]['id']},'attributes':['id','customerAvatar',_0x111f('0x8c')],'raw':!![]};return db[_0x111f('0x52')][_0x111f('0x65')](_0x594a3c)[_0x111f('0x25')](handleEntityNotFound(_0xd3698f,null))[_0x111f('0x25')](function(_0x4af0f2){if(_0x4af0f2){if(!_[_0x111f('0x84')](_0x4af0f2[_0x111f('0x7b')])){if(fs[_0x111f('0x85')](path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x4af0f2[_0x111f('0x7b')]))&&_0x4af0f2[_0x111f('0x8c')]){_0x1a6a07=path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x4af0f2[_0x111f('0x7b')]);}}return _0xd3698f[_0x111f('0x8d')](_0x1a6a07);}})[_0x111f('0x57')](handleError(_0xd3698f,null));};exports[_0x111f('0x8e')]=function(_0x7d8ed8,_0x148fe3,_0x279862){var _0x8d2cbc=path[_0x111f('0x7f')](config['root'],'server/files/images/avatars/system_avatar.png');var _0x5579fc={'where':{'id':_0x7d8ed8[_0x111f('0x59')]['id']},'attributes':['id',_0x111f('0x7d')],'raw':!![]};return db[_0x111f('0x52')]['find'](_0x5579fc)[_0x111f('0x25')](handleEntityNotFound(_0x148fe3,null))[_0x111f('0x25')](function(_0x539089){if(_0x539089){if(!_[_0x111f('0x84')](_0x539089['systemAvatar'])){if(fs['existsSync'](path[_0x111f('0x7f')](config['root'],_0x111f('0x89'),_0x539089[_0x111f('0x7d')]))){_0x8d2cbc=path[_0x111f('0x7f')](config[_0x111f('0x86')],_0x111f('0x89'),_0x539089[_0x111f('0x7d')]);}}return _0x148fe3[_0x111f('0x8d')](_0x8d2cbc);}})[_0x111f('0x57')](handleError(_0x148fe3,null));};exports[_0x111f('0x8f')]=function(_0x500949,_0x36a51a,_0x2be27d){var _0x16aef9=require(_0x111f('0x90'));var _0x1aeab8=new _0x16aef9();var _0x1e78d6=_0x1aeab8[_0x111f('0x91')](_0x500949[_0x111f('0x92')][_0x111f('0x93')])['getResult']();var _0x213bc6={'body':_0x500949[_0x111f('0x60')],'channel':_0x111f('0x94')};var _0x442bab=[];var _0x483197=[];var _0x91ceb2={};var _0x16459c=![];return db[_0x111f('0x95')][_0x111f('0x6a')]()['then'](function(_0xcbe2e3){if(!_0xcbe2e3){throw new db[(_0x111f('0x21'))]['ValidationError'](_0x111f('0x96'));}_0x442bab=_[_0x111f('0x97')](_[_0x111f('0x5b')](_0xcbe2e3),[_0x111f('0x98'),_0x111f('0x99')]);_0x483197=_['difference'](_[_0x111f('0x5b')](_0xcbe2e3),[_0x111f('0x98'),_0x111f('0x99'),_0x111f('0x9a'),_0x111f('0x9b')]);if(_0x500949[_0x111f('0x60')]['id']){delete _0x500949[_0x111f('0x60')]['id'];}if(_[_0x111f('0x84')](_0x500949[_0x111f('0x60')][_0x111f('0x9c')])){throw new db[(_0x111f('0x21'))]['ValidationError'](_0x111f('0x9d'));}if(_[_0x111f('0x84')](_0x500949[_0x111f('0x60')][_0x111f('0x60')])||_0x500949[_0x111f('0x60')]['body']===''){throw new db[(_0x111f('0x21'))]['ValidationError']('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_['isNil'](_0x500949[_0x111f('0x60')][_0x111f('0x9e')])){throw new db[(_0x111f('0x21'))][(_0x111f('0x22'))](_0x111f('0x9f')+_0x483197);}if(!_[_0x111f('0xa0')](_0x483197,_0x500949['body'][_0x111f('0x9e')])){throw new db['Sequelize'][(_0x111f('0x22'))](_0x111f('0xa1')+_0x483197);}_0x91ceb2[_0x500949['body']['mapKey']]=_0x500949[_0x111f('0x60')]['from'];})[_0x111f('0x25')](function(){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x500949[_0x111f('0x59')]['id']},'include':[{'model':db[_0x111f('0xa2')],'as':_0x111f('0xa3'),'include':[{'model':db['CmContact'],'as':_0x111f('0xa4'),'where':_0x91ceb2,'limit':0x1,'order':[[_0x111f('0x99'),_0x111f('0xa5')]]}]},{'model':db['ChatApplication'],'as':_0x111f('0xa6')}]});})[_0x111f('0x25')](handleEntityNotFound(_0x36a51a,null))[_0x111f('0x25')](function(_0x54e24e){if(_0x54e24e&&_0x54e24e[_0x111f('0xa3')]){_0x213bc6[_0x111f('0xa7')]=_0x54e24e;_0x213bc6['applications']=_0x54e24e[_0x111f('0xa6')];_0x213bc6['list']=_0x54e24e[_0x111f('0xa3')];_0x213bc6[_0x111f('0xa8')]=_['orderBy'](_0x213bc6[_0x111f('0xa8')],[_0x111f('0xa9')],[_0x111f('0xaa')]);if(_0x213bc6['account'][_0x111f('0xa6')]){delete _0x213bc6['account']['Applications'];}if(_0x213bc6[_0x111f('0xa7')][_0x111f('0xa3')]&&_0x213bc6[_0x111f('0xa7')][_0x111f('0xa3')][_0x111f('0xa4')][_0x111f('0x4a')]){return _0x213bc6['account'][_0x111f('0xa3')][_0x111f('0xa4')][0x0];}var _0x43f798=_['defaults'](_0x500949[_0x111f('0x60')],{'firstName':_0x500949[_0x111f('0x60')][_0x111f('0x9c')],'ListId':_0x54e24e[_0x111f('0x9b')]});_0x43f798[_0x500949[_0x111f('0x60')][_0x111f('0x9e')]]=_0x500949[_0x111f('0x60')]['from'];return db['CmContact'][_0x111f('0x5f')](_0x43f798,{'fields':_0x442bab,'raw':!![]});}})[_0x111f('0x25')](handleEntityNotFound(_0x36a51a,null))[_0x111f('0x25')](function(_0x2ff9d1){_0x213bc6['contact']=_0x2ff9d1;var _0x2b6d8f=_0x500949['body']['customerIp'];if(_0x500949[_0x111f('0x92')][_0x111f('0xab')]){_0x2b6d8f=_0x500949[_0x111f('0x92')][_0x111f('0xab')];}else if(_0x500949['headers']['x-forwarded-for']){_0x2b6d8f=_[_0x111f('0xac')](_0x500949[_0x111f('0x92')]['x-forwarded-for']['split'](','));}if(_0x2ff9d1){var _0x29fd80={'ContactId':_0x2ff9d1['id'],'ChatWebsiteId':_0x500949[_0x111f('0x59')]['id'],'from':(_0x2ff9d1['firstName']||'')+'\x20'+(_0x2ff9d1['lastName']||''),'customerIp':_0x2b6d8f,'customerPort':_0x500949[_0x111f('0x92')][_0x111f('0xad')]?_0x500949[_0x111f('0x92')]['x-real-port']:null,'referer':_0x500949[_0x111f('0x60')][_0x111f('0xae')],'browserName':_0x1e78d6[_0x111f('0xaf')]['name']&&_0x1e78d6[_0x111f('0xaf')][_0x111f('0xb0')]?util[_0x111f('0xb1')](_0x111f('0xb2'),_0x1e78d6[_0x111f('0xaf')][_0x111f('0x3e')],_0x1e78d6[_0x111f('0xaf')]['version']):_0x111f('0xb3'),'browserVersion':_0x1e78d6[_0x111f('0xaf')]['version']||_0x111f('0xb3'),'osName':util[_0x111f('0xb1')](_0x111f('0xb2'),_0x1e78d6['os'][_0x111f('0x3e')],_0x1e78d6['os'][_0x111f('0xb0')]),'osVersion':_0x1e78d6['os']['version'],'deviceModel':_0x1e78d6[_0x111f('0xb4')]['model']&&_0x1e78d6[_0x111f('0xb4')]['vendor']?util[_0x111f('0xb1')](_0x111f('0xb5'),_0x1e78d6[_0x111f('0xb4')][_0x111f('0x48')],_0x1e78d6[_0x111f('0xb4')][_0x111f('0xb6')],_0x1e78d6[_0x111f('0xb4')][_0x111f('0x44')]):null,'deviceVendor':_0x1e78d6[_0x111f('0xb4')][_0x111f('0xb6')],'deviceType':_0x1e78d6[_0x111f('0xb4')]['type'],'formData':JSON['stringify'](_0x500949[_0x111f('0x60')])};var _0xbe839e={'ChatWebsiteId':_0x500949['params']['id'],'closed':![]};if(_0x500949[_0x111f('0x60')][_0x111f('0xb7')]){_0xbe839e[_0x111f('0xb7')]=_0x500949[_0x111f('0x60')][_0x111f('0xb7')];return db[_0x111f('0xb8')]['find']({'where':_0xbe839e})[_0x111f('0x25')](function(_0x2db594){if(_0x2db594){return[_0x2db594,![]];}_0x29fd80[_0x111f('0xb7')]=_0x500949[_0x111f('0x60')][_0x111f('0xb7')];_0x29fd80[_0x111f('0xb9')]=_0x500949[_0x111f('0x60')]['externalUrl'];return db[_0x111f('0xb8')][_0x111f('0x5f')](_0x29fd80)[_0x111f('0x25')](function(_0x573cf8){return[_0x573cf8,!![]];});});}_0xbe839e[_0x111f('0xba')]=_0x2ff9d1['id'];if(_0x500949[_0x111f('0x60')][_0x111f('0xbb')]&&_0x500949[_0x111f('0x60')]['interaction']['id']){_0xbe839e['id']=_0x500949[_0x111f('0x60')][_0x111f('0xbb')]['id'];return db[_0x111f('0xb8')][_0x111f('0x65')]({'where':_0xbe839e})['then'](function(_0x227391){if(_0x227391){return[_0x227391,![]];}return db['ChatInteraction'][_0x111f('0x5f')](_0x29fd80)[_0x111f('0x25')](function(_0x1ec50d){return[_0x1ec50d,!![]];});});}return db[_0x111f('0xb8')]['create'](_0x29fd80)[_0x111f('0x25')](function(_0x5db274){return[_0x5db274,!![]];});}})[_0x111f('0xbc')](function(_0x18d9a1,_0x2bddca){if(_0x18d9a1){_0x16459c=_0x2bddca;if(!_0x2bddca){var _0x4fc016={'from':(_0x213bc6['contact'][_0x111f('0xbd')]||'')+'\x20'+(_0x213bc6[_0x111f('0xbe')]['lastName']||'')};if(_0x500949[_0x111f('0x60')][_0x111f('0xb7')]&&_0x500949[_0x111f('0x60')][_0x111f('0xbf')]&&_0x500949['body']['threadId']!=_0x500949['body'][_0x111f('0xbf')]){_0x4fc016[_0x111f('0xb7')]=_0x500949[_0x111f('0x60')][_0x111f('0xbf')];}return _0x18d9a1[_0x111f('0x39')](_0x4fc016);}else{return _0x18d9a1;}}})[_0x111f('0x25')](function(_0x5ec6f4){_0x213bc6[_0x111f('0xbb')]=_0x5ec6f4[_0x111f('0x3b')]({'plain':!![]});_0x213bc6[_0x111f('0xbb')][_0x111f('0xc0')]=_0x16459c;if(_0x213bc6['interaction'][_0x111f('0xc0')]){if(_0x213bc6[_0x111f('0xa7')][_0x111f('0xc1')]){_0x213bc6['applications']['push']({'id':0x0,'priority':_0x213bc6['applications'][_0x111f('0x4a')]+0x1,'app':'close','appdata':'unmanaged','interval':_0x111f('0xc2')});}}return db[_0x111f('0xc3')][_0x111f('0x5f')]({'body':_0x500949[_0x111f('0x60')]['body'],'ChatWebsiteId':_0x500949[_0x111f('0x59')]['id'],'ChatInteractionId':_0x5ec6f4['id'],'direction':'in','ContactId':_0x213bc6[_0x111f('0xbe')]['id'],'AttachmentId':_0x500949[_0x111f('0x60')]['AttachmentId']});})[_0x111f('0x25')](function(_0xcfe194){_0x213bc6[_0x111f('0x2c')]=_0xcfe194;if(_0x213bc6['interaction']['UserId']){return db['User']['find']({'attributes':['id',_0x111f('0x3e')],'where':{'id':_0x213bc6[_0x111f('0xbb')][_0x111f('0xc4')]}})['then'](function(_0x1d4625){if(_0x1d4625){_0x213bc6[_0x111f('0xa8')][_0x111f('0xc5')]({'id':0x0,'priority':0x0,'app':_0x111f('0xc6'),'appdata':_0x1d4625[_0x111f('0x3e')]+','+(_0x213bc6[_0x111f('0xa7')][_0x111f('0xc7')]||0xa),'interval':_0x111f('0xc2')});_0x213bc6[_0x111f('0xc8')]=!![];}return respondWithRpcPromise(_0x111f('0xc9'),_0x111f('0xca'),_0x213bc6);});}return respondWithRpcPromise(_0x111f('0xc9'),'startRouting',_0x213bc6);})[_0x111f('0x25')](function(_0x1fca61){respondWithRpcPromise(_0x111f('0xcb'),_0x111f('0xcb'),{'event':_0x111f('0x8f'),'message':_0x1fca61},client9002);return _0x1fca61;})[_0x111f('0x25')](respondWithResult(_0x36a51a,null))['catch'](handleError(_0x36a51a,null));};exports['offline']=function(_0x1fdf5f,_0x103227,_0x2f1787){var _0x489f1f,_0x506099,_0x347b17;var _0x3dd51c=[];var _0x57c1c0=[];var _0x44445a={};return db[_0x111f('0x95')][_0x111f('0x6a')]()[_0x111f('0x25')](function(_0x5b5f5e){if(!_0x5b5f5e){throw new db[(_0x111f('0x21'))]['ValidationError']('no\x20available\x20attributes');}_0x57c1c0=_[_0x111f('0x97')](_['keys'](_0x5b5f5e),[_0x111f('0x98'),_0x111f('0x99')]);_0x3dd51c=_[_0x111f('0x97')](_[_0x111f('0x5b')](_0x5b5f5e),[_0x111f('0x98'),'updatedAt','CompanyId',_0x111f('0x9b')]);if(_0x1fdf5f[_0x111f('0x60')]['id']){delete _0x1fdf5f[_0x111f('0x60')]['id'];}if(_['isNil'](_0x1fdf5f['body'][_0x111f('0x9c')])){throw _0x103227[_0x111f('0x2f')](0x1f4)[_0x111f('0x3f')](new db[(_0x111f('0x21'))][(_0x111f('0x22'))](_0x111f('0x9d')));}if(_[_0x111f('0x84')](_0x1fdf5f[_0x111f('0x60')][_0x111f('0x60')])||_0x1fdf5f[_0x111f('0x60')][_0x111f('0x60')]===''){throw _0x103227[_0x111f('0x2f')](0x1f4)['send'](new db[(_0x111f('0x21'))][(_0x111f('0x22'))](_0x111f('0xcc')));}if(_[_0x111f('0x84')](_0x1fdf5f[_0x111f('0x60')][_0x111f('0xcd')])){throw _0x103227[_0x111f('0x2f')](0x1f4)[_0x111f('0x3f')](new db[(_0x111f('0x21'))]['ValidationError'](_0x111f('0xce')+_0x3dd51c));}if(!_[_0x111f('0xa0')](_0x3dd51c,_0x1fdf5f[_0x111f('0x60')][_0x111f('0xcd')])){throw _0x103227[_0x111f('0x2f')](0x1f4)[_0x111f('0x3f')](new db['Sequelize'][(_0x111f('0x22'))](_0x111f('0xcf')+_0x3dd51c));}_0x44445a[_0x1fdf5f['body'][_0x111f('0xcd')]]=_0x1fdf5f[_0x111f('0x60')][_0x111f('0x9c')];})[_0x111f('0x25')](function(){return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x1fdf5f[_0x111f('0x59')]['id']},'include':[{'model':db['CmList'],'as':_0x111f('0xa3')}]});})[_0x111f('0x25')](handleEntityNotFound(_0x103227,null))[_0x111f('0x25')](function(_0x11c478){if(_0x11c478&&_0x11c478[_0x111f('0xa3')]){_0x506099=_0x11c478;var _0x1bd0d6=_[_0x111f('0xd0')](_0x1fdf5f[_0x111f('0x60')],{'firstName':_0x1fdf5f[_0x111f('0x60')][_0x111f('0x9c')],'phone':_0x1fdf5f[_0x111f('0x60')]['from'],'ListId':_0x11c478[_0x111f('0x9b')]});_0x1bd0d6[_0x1fdf5f['body'][_0x111f('0xcd')]]=_0x1fdf5f[_0x111f('0x60')][_0x111f('0x9c')];return db[_0x111f('0x95')][_0x111f('0xd1')]({'where':_0x44445a,'defaults':_0x1bd0d6});}})[_0x111f('0xbc')](function(_0x3d03ec){if(_0x3d03ec){_0x347b17=_0x3d03ec;var _0x5e80a8=fs[_0x111f('0xd2')](path['join'](config['root'],'server/files/templates/chatOfflineMessage.ejs'),_0x111f('0xd3'));var _0x5a48f6=ejs[_0x111f('0xd4')](_0x5e80a8,{'body':_[_0x111f('0xd5')](_0x1fdf5f[_0x111f('0x60')]['body']),'bodyTitle':_0x506099[_0x111f('0xd6')]});return db['ChatOfflineMessage'][_0x111f('0x5f')]({'body':_0x5a48f6,'ContactId':_0x3d03ec['id'],'ChatWebsiteId':_0x506099['id']});}})['then'](function(_0xfa9928){if(_0xfa9928){_0x489f1f=_0xfa9928;return db[_0x111f('0xd7')][_0x111f('0xd8')]({'where':{'service':!![]},'include':[{'model':db[_0x111f('0xd9')],'as':_0x111f('0xda'),'raw':!![]}]});}})[_0x111f('0x25')](function(_0x37b61e){if(_0x37b61e&&_0x37b61e[_0x111f('0xda')]&&_0x506099[_0x111f('0xdb')]){var _0x36e810={'tls':{'rejectUnauthorized':![]}};if(_0x37b61e[_0x111f('0xda')]['service']){_0x36e810[_0x111f('0xdc')]=_0x37b61e[_0x111f('0xda')][_0x111f('0xdc')];}else{_0x36e810[_0x111f('0xdd')]=_0x37b61e[_0x111f('0xda')][_0x111f('0xdd')];_0x36e810[_0x111f('0xde')]=_0x37b61e[_0x111f('0xda')][_0x111f('0xde')];_0x36e810['secure']=_0x37b61e['Smtp'][_0x111f('0xdf')];}if(_0x37b61e[_0x111f('0xda')]['authentication']){_0x36e810[_0x111f('0xe0')]={'user':_0x37b61e[_0x111f('0xda')][_0x111f('0x61')],'pass':_0x37b61e[_0x111f('0xda')][_0x111f('0xe1')]};}return respondWithRpcPromise(_0x111f('0xe2'),_0x111f('0xe3'),{'account':_0x36e810,'message':{'from':util[_0x111f('0xb1')](_0x111f('0xe4'),_0x37b61e[_0x111f('0x3e')],_0x37b61e[_0x111f('0xe5')]||_0x37b61e[_0x111f('0xda')][_0x111f('0x61')]),'to':_0x506099[_0x111f('0xdb')],'subject':_0x506099[_0x111f('0xe6')],'text':_0x489f1f[_0x111f('0x60')]}},client9003)[_0x111f('0x25')](function(){return _0x489f1f;})[_0x111f('0x57')](function(_0x3036ae){console[_0x111f('0x2a')](_0x3036ae);});}})[_0x111f('0x25')](function(){if(_0x489f1f){return _0x489f1f;}})[_0x111f('0x25')](respondWithResult(_0x103227,null))[_0x111f('0x57')](handleError(_0x103227,null));};exports[_0x111f('0xe7')]=function(_0x14c2cd,_0x1a531d,_0xf7b1fc){return db['ChatInteraction']['find']({'where':{'id':_0x14c2cd[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x1a531d,null))[_0x111f('0x25')](function(_0x4c49e9){if(_0x4c49e9){return _0x4c49e9[_0x111f('0xe7')](_0x14c2cd[_0x111f('0x60')]['ids'],_[_0x111f('0xe8')](_0x14c2cd['body'],[_0x111f('0x70'),'id'])||{});}})[_0x111f('0x25')](respondWithResult(_0x1a531d,null))[_0x111f('0x57')](handleError(_0x1a531d,null));};exports[_0x111f('0xe9')]=function(_0x5a84a0,_0xa63817,_0x55028a){var _0x3a99e7={'raw':![],'where':{}};var _0xe8a28f={};var _0x4a08bd={'count':0x0,'rows':[]};return db[_0x111f('0x52')][_0x111f('0xd8')]({'where':{'id':_0x5a84a0[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0xa63817,null))[_0x111f('0x25')](function(_0x1960a2){if(_0x1960a2){_0xe8a28f[_0x111f('0x48')]=_['keys'](db['ChatInteraction'][_0x111f('0x42')]);_0xe8a28f[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x5a84a0[_0x111f('0x46')]);_0xe8a28f[_0x111f('0x47')]=_[_0x111f('0x5c')](_0xe8a28f['model'],_0xe8a28f['query']);_0x3a99e7[_0x111f('0x49')]=_['intersection'](_0xe8a28f[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x5a84a0[_0x111f('0x46')][_0x111f('0x5d')]));_0x3a99e7['attributes']=_0x3a99e7[_0x111f('0x49')]['length']?_0x3a99e7['attributes']:_0xe8a28f[_0x111f('0x48')];if(!_0x5a84a0[_0x111f('0x46')][_0x111f('0x6e')](_0x111f('0x4b'))){_0x3a99e7[_0x111f('0x33')]=qs[_0x111f('0x33')](_0x5a84a0[_0x111f('0x46')][_0x111f('0x33')]);_0x3a99e7[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x5a84a0[_0x111f('0x46')][_0x111f('0x32')]);}_0x3a99e7[_0x111f('0x4c')]=qs['sort'](_0x5a84a0[_0x111f('0x46')]['sort']);_0x3a99e7[_0x111f('0x4e')]=qs['filters'](_['pick'](_0x5a84a0['query'],_0xe8a28f[_0x111f('0x47')]));_0x3a99e7[_0x111f('0x4e')][_0x111f('0x6b')]=_0x1960a2['id'];if(_0x5a84a0[_0x111f('0x46')][_0x111f('0x73')]){_0x3a99e7[_0x111f('0x4e')]=_['merge'](_0x3a99e7[_0x111f('0x4e')],{'$or':_[_0x111f('0x45')](_0x3a99e7[_0x111f('0x49')],function(_0xb2762d){var _0x512fbb={};_0x512fbb[_0xb2762d]={'$like':'%'+_0x5a84a0[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x512fbb;})});}_0x3a99e7=_[_0x111f('0x50')]({},_0x3a99e7,_0x5a84a0['options']);return db[_0x111f('0xb8')][_0x111f('0x53')]({'where':_0x3a99e7[_0x111f('0x4e')]})['then'](function(_0x58a277){_0x4a08bd['count']=_0x58a277;if(_0x5a84a0[_0x111f('0x46')][_0x111f('0x54')]){_0x3a99e7[_0x111f('0x55')]=[{'model':db[_0x111f('0x95')],'as':_0x111f('0xea'),'required':![]},{'model':db[_0x111f('0xeb')],'as':_0x111f('0xec'),'attributes':[_0x111f('0x3e'),'fullname',_0x111f('0xed')],'required':![]},{'model':db[_0x111f('0xee')],'as':'Tags','attributes':['id','name',_0x111f('0xef')],'where':_0x5a84a0[_0x111f('0x46')]['tag']?{'id':_0x5a84a0['query'][_0x111f('0xf0')]}:undefined,'required':_0x5a84a0[_0x111f('0x46')]['tag']?!![]:![]}];}return db[_0x111f('0xb8')][_0x111f('0x74')](_0x3a99e7);})['then'](function(_0x20f724){_0x4a08bd[_0x111f('0x56')]=_0x20f724;return _0x4a08bd;});}})['then'](respondWithFilteredResult(_0xa63817,_0x3a99e7))[_0x111f('0x57')](handleError(_0xa63817,null));};function iftimePromise(_0x161139,_0x279c5b){return respondWithRpcPromise('Command','getSnippet',{'command':_0x279c5b[_0x111f('0xf1')]?util[_0x111f('0xb1')]('iftime\x20%s,%s',_0x161139[_0x111f('0xf2')],_0x279c5b[_0x111f('0xf1')]):util[_0x111f('0xb1')](_0x111f('0xf3'),_0x161139[_0x111f('0xf2')])},client9002)['then'](function(_0x13cbd4){var _0xca5f7=_0x13cbd4&&_0x13cbd4[_0x111f('0xf4')](_0x111f('0xf5'))>=0x0?!![]:![];logger[_0x111f('0x26')](_0x111f('0xf6'),_0x279c5b['id'],_0x161139['id'],_0x161139[_0x111f('0xf2')],_0xca5f7?_0x111f('0xf7'):_0x111f('0xf8'),_0x279c5b[_0x111f('0xf1')]?_0x279c5b[_0x111f('0xf1')]:_0x111f('0xf9'));return _0xca5f7;})[_0x111f('0x57')](function(_0x12408b){logger[_0x111f('0x2a')]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x279c5b['id'],_0x161139['id'],_0x161139[_0x111f('0xf2')],util[_0x111f('0xfa')](_0x12408b,{'showHidden':![],'depth':null}),_0x279c5b[_0x111f('0xf1')]?_0x279c5b[_0x111f('0xf1')]:_0x111f('0xf9'));return![];});}exports['getSnippet']=function(_0x4d5c65,_0x5603ba,_0xa528f8){var _0x39d2be=0x0;var _0x54c0b1=0x0;var _0x213570=![];var _0x317933;var _0xd4495e;return db[_0x111f('0x52')][_0x111f('0x65')]({'where':{'id':_0x4d5c65[_0x111f('0x59')]['id']},'include':[{'model':db[_0x111f('0xfb')],'as':_0x111f('0xfb'),'include':[{'model':db['Interval'],'as':_0x111f('0xfc'),'attributes':['id',_0x111f('0xf2')],'raw':!![]}]}]})[_0x111f('0x25')](handleEntityNotFound(_0x5603ba,null))['then'](function(_0x1e09e7){if(_0x1e09e7){_0x317933=_0x1e09e7;return _0x1e09e7[_0x111f('0xfd')]({'raw':!![]});}})[_0x111f('0x25')](function(_0x25a764){if(_0x317933){if(_0x25a764){_0xd4495e=_0x25a764;}}return require('../../config/license/util')[_0x111f('0x82')]();})['then'](function(_0x1b471a){if(_0x1b471a){_0x54c0b1=_0x1b471a[_0x111f('0xfe')];_0x213570=_0x1b471a[_0x111f('0x83')];}})[_0x111f('0x25')](function(){return db[_0x111f('0xb8')][_0x111f('0x53')]({'where':{'closed':![]}});})[_0x111f('0x25')](function(_0x968278){_0x39d2be=_0x968278;if(_0x54c0b1&&_0x968278>_0x54c0b1){return db[_0x111f('0xff')][_0x111f('0xd8')]({'where':{'id':0x1}})['then'](function(_0x4ee2b2){if(_0x4ee2b2){_0x4ee2b2[_0x111f('0x100')]('chatLicenseExceeded');}});}})[_0x111f('0x25')](function(){if(_0x317933[_0x111f('0xfb')]&&_0x317933[_0x111f('0xfb')][_0x111f('0xfc')]){var _0x2ac058=[];for(var _0x257020=0x0;_0x257020<_0x317933['Interval']['Intervals']['length'];_0x257020++){var _0x4a4687=_0x317933[_0x111f('0xfb')][_0x111f('0xfc')][_0x257020][_0x111f('0x3b')]({'plain':!![]});_0x2ac058[_0x111f('0x101')](iftimePromise(_0x4a4687,_0x317933));}return BPromise[_0x111f('0x102')](_0x2ac058)[_0x111f('0x25')](function(_0x3887dc){return _[_0x111f('0x103')](_0x3887dc);});}else{return!![];}})[_0x111f('0x25')](function(_0x5130e6){var _0x236140=fs['readFileSync'](path['join'](config[_0x111f('0x86')],_0x111f('0x104')),_0x111f('0xd3'));var _0x45cb99={'remote':_0x317933['remote'],'query':querystring[_0x111f('0x105')](_[_0x111f('0x50')](_0x317933[_0x111f('0x3b')]({'plain':!![]}),{'customerIp':_0x4d5c65[_0x111f('0x92')][_0x111f('0x106')]||_0x4d5c65[_0x111f('0x92')][_0x111f('0x107')]||_0x4d5c65[_0x111f('0x108')]['remoteAddress']||_0x4d5c65['ip'],'referer':_0x4d5c65[_0x111f('0x92')][_0x111f('0xae')],'openedInteractions':_0x39d2be,'maxInteractions':_0x54c0b1,'virtual':_0x213570['virtual'],'online':_0x5130e6,'custom':_0x213570}))['replace'](/'/g,'\x5c\x27')};_0x5603ba['send'](ejs['render'](Mustache['render'](_0x236140,_0x45cb99),{'proactiveActions':_0xd4495e,'alignment':_0x317933[_0x111f('0x109')],'verticalAlignment':_0x317933[_0x111f('0x10a')],'div_color':_0x317933[_0x111f('0xef')],'text_color':_0x317933['textColor']}));})[_0x111f('0x57')](handleError(_0x5603ba,null));};exports[_0x111f('0x10b')]=function(_0x14fba6,_0x363bfe,_0x38a347){return db['ChatWebsite'][_0x111f('0xd8')]({'where':{'id':_0x14fba6[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x363bfe,null))['then'](function(_0x5a46a2){if(_0x5a46a2){return db['sequelize'][_0x111f('0x10c')](function(_0x528038){return db['ChatApplication'][_0x111f('0x3a')]({'where':{'ChatWebsiteId':_0x14fba6[_0x111f('0x59')]['id']},'transaction':_0x528038})['then'](function(_0xb2fc2c){var _0x3a8f2f=_[_0x111f('0x45')](_0x14fba6['body'],function(_0x2030b0){_0x2030b0[_0x111f('0x6b')]=_0x14fba6[_0x111f('0x59')]['id'];return _0x2030b0;});return db[_0x111f('0x10d')][_0x111f('0x10e')](_0x3a8f2f,{'transaction':_0x528038});});})[_0x111f('0x25')](function(){return db[_0x111f('0x10d')][_0x111f('0x10f')]({'where':{'ChatWebsiteId':_0x14fba6['params']['id']},'order':_0x111f('0xa9')});});}})[_0x111f('0x25')](respondWithResult(_0x363bfe,null))[_0x111f('0x57')](handleError(_0x363bfe,null));};exports[_0x111f('0x110')]=function(_0x323ebf,_0x12e53f,_0x338ff5){var _0x50a4d4={};var _0xc38494={};var _0x53580d;var _0x127476;return db[_0x111f('0x52')][_0x111f('0xd8')]({'where':{'id':_0x323ebf[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x12e53f,null))[_0x111f('0x25')](function(_0x54f1a0){if(_0x54f1a0){_0x53580d=_0x54f1a0;_0xc38494[_0x111f('0x48')]=_['keys'](db['ChatApplication'][_0x111f('0x42')]);_0xc38494[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x323ebf[_0x111f('0x46')]);_0xc38494['filters']=_['intersection'](_0xc38494[_0x111f('0x48')],_0xc38494[_0x111f('0x46')]);_0x50a4d4[_0x111f('0x49')]=_[_0x111f('0x5c')](_0xc38494[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x323ebf['query']['fields']));_0x50a4d4['attributes']=_0x50a4d4[_0x111f('0x49')][_0x111f('0x4a')]?_0x50a4d4['attributes']:_0xc38494[_0x111f('0x48')];_0x50a4d4[_0x111f('0x4c')]=qs[_0x111f('0x4d')](_0x323ebf[_0x111f('0x46')][_0x111f('0x4d')]);_0x50a4d4['where']=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x323ebf[_0x111f('0x46')],_0xc38494[_0x111f('0x47')]));if(_0x323ebf[_0x111f('0x46')][_0x111f('0x73')]){_0x50a4d4[_0x111f('0x4e')]=_[_0x111f('0x50')](_0x50a4d4[_0x111f('0x4e')],{'$or':_[_0x111f('0x45')](_0x50a4d4['attributes'],function(_0x267901){var _0x4f1d99={};_0x4f1d99[_0x267901]={'$like':'%'+_0x323ebf['query'][_0x111f('0x73')]+'%'};return _0x4f1d99;})});}_0x50a4d4=_[_0x111f('0x50')]({},_0x50a4d4,_0x323ebf[_0x111f('0x5e')]);return _0x53580d['getApplications'](_0x50a4d4);}})[_0x111f('0x25')](function(_0x4e6ea6){if(_0x4e6ea6){_0x127476=_0x4e6ea6[_0x111f('0x4a')];if(!_0x323ebf['query'][_0x111f('0x6e')]('nolimit')){_0x50a4d4[_0x111f('0x33')]=qs[_0x111f('0x33')](_0x323ebf[_0x111f('0x46')]['limit']);_0x50a4d4[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x323ebf[_0x111f('0x46')]['offset']);}return _0x53580d['getApplications'](_0x50a4d4);}})[_0x111f('0x25')](function(_0x2ede1c){if(_0x2ede1c){return _0x2ede1c?{'count':_0x127476,'rows':_0x2ede1c}:null;}})[_0x111f('0x25')](respondWithResult(_0x12e53f,null))['catch'](handleError(_0x12e53f,null));};exports['addProactiveActions']=function(_0x36b00e,_0x281b77,_0x34bc51){return db[_0x111f('0x111')][_0x111f('0x65')]({'where':{'id':_0x36b00e[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x281b77,null))[_0x111f('0x25')](function(_0x5b9f56){if(_0x5b9f56){return _0x5b9f56[_0x111f('0x112')](_0x36b00e[_0x111f('0x60')]['ids'],_[_0x111f('0xe8')](_0x36b00e[_0x111f('0x60')],[_0x111f('0x70'),'id'])||{});}})[_0x111f('0x25')](respondWithResult(_0x281b77,null))['catch'](handleError(_0x281b77,null));};exports[_0x111f('0xfd')]=function(_0x2b7760,_0x171271,_0x2c1aec){var _0x5a6d6a={};var _0x5dbc0e={};var _0x111c11;var _0x47d1d5;return db[_0x111f('0x52')]['findOne']({'where':{'id':_0x2b7760[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x171271,null))[_0x111f('0x25')](function(_0x31112d){if(_0x31112d){_0x111c11=_0x31112d;_0x5dbc0e['model']=_[_0x111f('0x5b')](db['ChatProactiveAction']['rawAttributes']);_0x5dbc0e[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x2b7760[_0x111f('0x46')]);_0x5dbc0e['filters']=_['intersection'](_0x5dbc0e['model'],_0x5dbc0e[_0x111f('0x46')]);_0x5a6d6a[_0x111f('0x49')]=_[_0x111f('0x5c')](_0x5dbc0e['model'],qs['fields'](_0x2b7760['query'][_0x111f('0x5d')]));_0x5a6d6a['attributes']=_0x5a6d6a[_0x111f('0x49')]['length']?_0x5a6d6a[_0x111f('0x49')]:_0x5dbc0e[_0x111f('0x48')];_0x5a6d6a['order']=qs['sort'](_0x2b7760['query'][_0x111f('0x4d')]);_0x5a6d6a[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x2b7760[_0x111f('0x46')],_0x5dbc0e['filters']));if(_0x2b7760['query']['filter']){_0x5a6d6a[_0x111f('0x4e')]=_['merge'](_0x5a6d6a[_0x111f('0x4e')],{'$or':_[_0x111f('0x45')](_0x5a6d6a[_0x111f('0x49')],function(_0xadc0ae){var _0x2a0bd6={};_0x2a0bd6[_0xadc0ae]={'$like':'%'+_0x2b7760[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x2a0bd6;})});}_0x5a6d6a=_['merge']({},_0x5a6d6a,_0x2b7760[_0x111f('0x5e')]);return _0x111c11['getProactiveActions'](_0x5a6d6a);}})[_0x111f('0x25')](function(_0x2c7397){if(_0x2c7397){_0x47d1d5=_0x2c7397[_0x111f('0x4a')];if(!_0x2b7760[_0x111f('0x46')][_0x111f('0x6e')](_0x111f('0x4b'))){_0x5a6d6a['limit']=qs[_0x111f('0x33')](_0x2b7760[_0x111f('0x46')]['limit']);_0x5a6d6a[_0x111f('0x32')]=qs['offset'](_0x2b7760[_0x111f('0x46')][_0x111f('0x32')]);}return _0x111c11[_0x111f('0xfd')](_0x5a6d6a);}})[_0x111f('0x25')](function(_0x310ebd){if(_0x310ebd){return _0x310ebd?{'count':_0x47d1d5,'rows':_0x310ebd}:null;}})[_0x111f('0x25')](respondWithResult(_0x171271,null))[_0x111f('0x57')](handleError(_0x171271,null));};exports['getFields']=function(_0xc181d1,_0x5f4b15,_0x3cd12e){var _0x51ad5=_0xc181d1[_0x111f('0x46')][_0x111f('0x113')]===_0x111f('0x114')?_0x111f('0x115'):_0x111f('0x116');return db[_0x111f('0x52')]['find']({'attributes':['id',_0x51ad5],'where':{'id':_0xc181d1[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x5f4b15,null))[_0x111f('0x25')](function(_0x505398){if(_0x505398){var _0x232927=_0x505398[_0x51ad5];var _0x43348f=_0x232927&&_0x232927[_0x111f('0x117')]?_0x232927[_0x111f('0x117')]:[];_0x5f4b15[_0x111f('0x3f')]({'fromKey':_[_0x111f('0x84')](_0x232927[_0x111f('0x118')])?undefined:_0x232927['fromKey'],'count':_0x43348f[_0x111f('0x4a')],'rows':_0x43348f});}})[_0x111f('0x57')](handleError(_0x5f4b15,null));};exports['getOfflineMessages']=function(_0x5a79dd,_0x13f9e2,_0x1ff8e9){var _0x15fceb={'raw':![],'where':{}};var _0x177146={};var _0xd73d20={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x111f('0xd8')]({'where':{'id':_0x5a79dd['params']['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x13f9e2,null))['then'](function(_0x523a1e){if(_0x523a1e){_0x177146[_0x111f('0x48')]=_[_0x111f('0x5b')](db[_0x111f('0x119')][_0x111f('0x42')]);_0x177146[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x5a79dd[_0x111f('0x46')]);_0x177146[_0x111f('0x47')]=_[_0x111f('0x5c')](_0x177146[_0x111f('0x48')],_0x177146[_0x111f('0x46')]);_0x15fceb[_0x111f('0x49')]=_[_0x111f('0x5c')](_0x177146[_0x111f('0x48')],qs['fields'](_0x5a79dd[_0x111f('0x46')][_0x111f('0x5d')]));_0x15fceb[_0x111f('0x49')]=_0x15fceb['attributes']['length']?_0x15fceb['attributes']:_0x177146[_0x111f('0x48')];if(!_0x5a79dd[_0x111f('0x46')]['hasOwnProperty'](_0x111f('0x4b'))){_0x15fceb['limit']=qs[_0x111f('0x33')](_0x5a79dd['query'][_0x111f('0x33')]);_0x15fceb[_0x111f('0x32')]=qs[_0x111f('0x32')](_0x5a79dd['query'][_0x111f('0x32')]);}_0x15fceb[_0x111f('0x4c')]=qs[_0x111f('0x4d')](_0x5a79dd[_0x111f('0x46')][_0x111f('0x4d')]);_0x15fceb['where']=qs['filters'](_['pick'](_0x5a79dd['query'],_0x177146[_0x111f('0x47')]));_0x15fceb['where'][_0x111f('0x6b')]=_0x523a1e['id'];if(_0x5a79dd[_0x111f('0x46')]['filter']){_0x15fceb['where']=_[_0x111f('0x50')](_0x15fceb[_0x111f('0x4e')],{'$or':_[_0x111f('0x45')](_0x15fceb[_0x111f('0x49')],function(_0x5be102){var _0x218be9={};_0x218be9[_0x5be102]={'$like':'%'+_0x5a79dd[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x218be9;})});}_0x15fceb=_[_0x111f('0x50')]({},_0x15fceb,_0x5a79dd[_0x111f('0x5e')]);return db['ChatOfflineMessage'][_0x111f('0x53')]({'where':_0x15fceb[_0x111f('0x4e')]})[_0x111f('0x25')](function(_0x211421){_0xd73d20['count']=_0x211421;if(_0x5a79dd[_0x111f('0x46')][_0x111f('0x54')]){_0x15fceb[_0x111f('0x55')]=[{'all':!![]}];}else{_0x15fceb['include']=[{'model':db[_0x111f('0x95')],'as':_0x111f('0xea'),'required':![]}];}return db['ChatOfflineMessage'][_0x111f('0x74')](_0x15fceb);})[_0x111f('0x25')](function(_0x35f237){_0xd73d20[_0x111f('0x56')]=_0x35f237;return _0xd73d20;});}})['then'](respondWithFilteredResult(_0x13f9e2,_0x15fceb))[_0x111f('0x57')](handleError(_0x13f9e2,null));};exports[_0x111f('0x11a')]=function(_0x59f90f,_0x3fabb4,_0x55f535){return db[_0x111f('0x52')]['find']({'where':{'id':_0x59f90f[_0x111f('0x59')]['id']}})['then'](handleEntityNotFound(_0x3fabb4,null))['then'](function(_0x544e64){if(_0x544e64){return _0x544e64[_0x111f('0x11a')](_0x59f90f['body'][_0x111f('0x70')],_['omit'](_0x59f90f[_0x111f('0x60')],[_0x111f('0x70'),'id'])||{})[_0x111f('0xbc')](function(_0x4e31e8){for(var _0xf6b279=0x0;_0xf6b279<_0x59f90f[_0x111f('0x60')][_0x111f('0x70')][_0x111f('0x4a')];_0xf6b279+=0x1){socket[_0x111f('0x11b')](_0x111f('0x11c'),{'UserId':_0x59f90f[_0x111f('0x60')][_0x111f('0x70')][_0xf6b279],'ChatWebsiteId':_0x59f90f[_0x111f('0x59')]['id']});}return _0x4e31e8;});}})[_0x111f('0x25')](respondWithResult(_0x3fabb4,null))[_0x111f('0x57')](handleError(_0x3fabb4,null));};exports['removeAgents']=function(_0x20d9f5,_0x40e0ed,_0x7d61ab){return db['ChatWebsite']['find']({'where':{'id':_0x20d9f5[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x40e0ed,null))['then'](function(_0x3d0202){if(_0x3d0202){return _0x3d0202['removeAgents'](_0x20d9f5[_0x111f('0x46')][_0x111f('0x70')])[_0x111f('0x25')](function(){if(_['isArray'](_0x20d9f5[_0x111f('0x46')][_0x111f('0x70')])){for(var _0x3e460b=0x0;_0x3e460b<_0x20d9f5[_0x111f('0x46')][_0x111f('0x70')]['length'];_0x3e460b+=0x1){socket[_0x111f('0x11b')](_0x111f('0x11d'),{'UserId':Number(_0x20d9f5[_0x111f('0x46')]['ids'][_0x3e460b]),'ChatWebsiteId':Number(_0x20d9f5[_0x111f('0x59')]['id'])});}}else{socket[_0x111f('0x11b')](_0x111f('0x11d'),{'UserId':Number(_0x20d9f5[_0x111f('0x46')][_0x111f('0x70')]),'ChatWebsiteId':Number(_0x20d9f5[_0x111f('0x59')]['id'])});}});}})[_0x111f('0x25')](respondWithStatusCode(_0x40e0ed,null))[_0x111f('0x57')](handleError(_0x40e0ed,null));};exports[_0x111f('0x11e')]=function(_0x2134c8,_0x7e36f6,_0x4784b2){var _0x46bf50={};var _0x993fde={};var _0x4555be;var _0x5b2601;return db[_0x111f('0x52')]['findOne']({'where':{'id':_0x2134c8[_0x111f('0x59')]['id']}})[_0x111f('0x25')](handleEntityNotFound(_0x7e36f6,null))[_0x111f('0x25')](function(_0x5da68c){if(_0x5da68c){_0x4555be=_0x5da68c;_0x993fde['model']=_['keys'](db[_0x111f('0xeb')][_0x111f('0x42')]);_0x993fde[_0x111f('0x46')]=_[_0x111f('0x5b')](_0x2134c8[_0x111f('0x46')]);_0x993fde[_0x111f('0x47')]=_[_0x111f('0x5c')](_0x993fde[_0x111f('0x48')],_0x993fde[_0x111f('0x46')]);_0x46bf50[_0x111f('0x49')]=_[_0x111f('0x5c')](_0x993fde[_0x111f('0x48')],qs[_0x111f('0x5d')](_0x2134c8[_0x111f('0x46')][_0x111f('0x5d')]));_0x46bf50['attributes']=_0x46bf50[_0x111f('0x49')][_0x111f('0x4a')]?_0x46bf50['attributes']:_0x993fde[_0x111f('0x48')];_0x46bf50['order']=qs[_0x111f('0x4d')](_0x2134c8[_0x111f('0x46')][_0x111f('0x4d')]);_0x46bf50[_0x111f('0x4e')]=qs[_0x111f('0x47')](_[_0x111f('0x4f')](_0x2134c8[_0x111f('0x46')],_0x993fde['filters']));if(_0x2134c8['query'][_0x111f('0x73')]){_0x46bf50[_0x111f('0x4e')]=_['merge'](_0x46bf50[_0x111f('0x4e')],{'$or':_['map'](_0x46bf50[_0x111f('0x49')],function(_0x777234){var _0x397fc3={};_0x397fc3[_0x777234]={'$like':'%'+_0x2134c8[_0x111f('0x46')][_0x111f('0x73')]+'%'};return _0x397fc3;})});}_0x46bf50=_[_0x111f('0x50')]({},_0x46bf50,_0x2134c8[_0x111f('0x5e')]);return _0x4555be[_0x111f('0x11e')](_0x46bf50);}})[_0x111f('0x25')](function(_0x1f97c8){if(_0x1f97c8){_0x5b2601=_0x1f97c8[_0x111f('0x4a')];if(!_0x2134c8[_0x111f('0x46')][_0x111f('0x6e')](_0x111f('0x4b'))){_0x46bf50[_0x111f('0x33')]=qs[_0x111f('0x33')](_0x2134c8[_0x111f('0x46')]['limit']);_0x46bf50[_0x111f('0x32')]=qs['offset'](_0x2134c8[_0x111f('0x46')][_0x111f('0x32')]);}return _0x4555be[_0x111f('0x11e')](_0x46bf50);}})[_0x111f('0x25')](function(_0x4c1464){if(_0x4c1464){return _0x4c1464?{'count':_0x5b2601,'rows':_0x4c1464}:null;}})[_0x111f('0x25')](respondWithResult(_0x7e36f6,null))[_0x111f('0x57')](handleError(_0x7e36f6,null));};
\ No newline at end of file
+var _0xc158=['unshift','forcedOwnership','startRouting','Start','EventManager','from\x20is\x20mandatory','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','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','MailServerOut','forwardOffline','forwardOfflineAddress','service','Smtp','host','port','secure','authentication','auth','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','openNewInteraction','MailAccountId','firstName','Chat','NotifyMailAccount','notifyMail','addInteraction','getInteractions','Contact','Owner','internal','Tags','color','tag','Command','getSnippet','timezone','iftime\x20%s,%s','interval','iftime\x20%s','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','inspect','Interval','Intervals','getProactiveActions','virtual','chatLicenseExceeded','push','all','server/files/chat/iframe.js','x-real-ip','connection','remoteAddress','referer','replace','verticalAlignment','addApplications','sequelize','transaction','getApplications','addProactiveActions','chatProactiveAction','omit','ChatProactiveAction','online','offlineForm','items','getOfflineMessages','addAgents','removeAgents','isArray','userChatWebsite:remove','getAgents','html-pdf','rimraf','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./chatWebsite.socket','register','jayson/promise','client','http','request','then','debug','request\x20sent','stringify','error','ChatWebsite,\x20%s,\x20%s','message','info','result','catch','status','count','offset','limit','set','Content-Range','json','apply','reject','save','destroy','get','ChatWebsites','UserProfileResource','end','sendStatus','stack','name','send','index','Pause','mandatoryDispositionPause','map','ChatWebsite','rawAttributes','type','key','model','query','keys','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filters','filter','merge','VIRTUAL','options','includeAll','findAll','rows','show','params','include','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','find','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','removeDispositions','ids','addAnswer','getAnswers','findOne','CannedAnswer','removeAnswers','addLogo','sitepic','addAvatar','agentAvatar','file','addCustomerAvatar','customerAvatar','filename','addSystemAvatar','systemAvatar','getLogo','join','root','server/files/images/logos/default_logo.svg','getLicense','custom','existsSync','server/files/images/logos/','download','getAvatar','isNil','server/files/images/avatars/','getCustomerAvatar','showCustomerAvatar','server/files/images/avatars/system_avatar.png','user-agent-parser','setUA','headers','user-agent','getResult','Sequelize','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','from','ValidationError','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmContact','Contacts','ChatApplication','Applications','List','account','applications','list','orderBy','priority','contact','customerIp','cf-connecting-ip','first','x-forwarded-for','split','lastName','x-real-port','browser','version','format','%s\x20%s','unknown','device','%s\x20%s\x20%s','vendor','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','messageId','created','autoclose','close','unmanaged','*,*,*,*','ChatMessage','AttachmentId','UserId','User'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0xc158,0x187));var _0x8c15=function(_0x42bd0c,_0x5a1889){_0x42bd0c=_0x42bd0c-0x0;var _0x193468=_0xc158[_0x42bd0c];return _0x193468;};'use strict';var pdf=require(_0x8c15('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x8c15('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x8c15('0x2'));var rp=require(_0x8c15('0x3'));var moment=require(_0x8c15('0x4'));var BPromise=require(_0x8c15('0x5'));var Mustache=require('mustache');var util=require(_0x8c15('0x6'));var path=require(_0x8c15('0x7'));var sox=require('sox');var csv=require(_0x8c15('0x8'));var ejs=require(_0x8c15('0x9'));var fs=require('fs');var _=require(_0x8c15('0xa'));var squel=require(_0x8c15('0xb'));var crypto=require(_0x8c15('0xc'));var jsforce=require(_0x8c15('0xd'));var deskjs=require(_0x8c15('0xe'));var toCsv=require(_0x8c15('0x8'));var querystring=require(_0x8c15('0xf'));var Papa=require(_0x8c15('0x10'));var Redis=require('ioredis');var authService=require(_0x8c15('0x11'));var qs=require(_0x8c15('0x12'));var as=require(_0x8c15('0x13'));var hardwareService=require(_0x8c15('0x14'));var logger=require(_0x8c15('0x15'))(_0x8c15('0x16'));var utils=require('../../config/utils');var config=require(_0x8c15('0x17'));var licenseUtil=require(_0x8c15('0x18'));var db=require(_0x8c15('0x19'))['db'];config[_0x8c15('0x1a')]=_[_0x8c15('0x1b')](config[_0x8c15('0x1a')],{'host':'localhost','port':0x18eb});var socket=require(_0x8c15('0x1c'))(new Redis(config[_0x8c15('0x1a')]));require(_0x8c15('0x1d'))[_0x8c15('0x1e')](socket);var jayson=require(_0x8c15('0x1f'));var client=jayson[_0x8c15('0x20')][_0x8c15('0x21')]({'port':0x232c});var client9002=jayson[_0x8c15('0x20')][_0x8c15('0x21')]({'port':0x232a});var client9003=jayson[_0x8c15('0x20')]['http']({'port':0x232b});var client9001=jayson[_0x8c15('0x20')]['http']({'port':0x2329});function respondWithRpcPromise(_0x20c01e,_0x52f4c4,_0x5c6db8,_0x4223a1){return new BPromise(function(_0x5cffcb,_0x14f5a3){var _0x429ce4=_0x4223a1||client;return _0x429ce4[_0x8c15('0x22')](_0x20c01e,_0x5c6db8)[_0x8c15('0x23')](function(_0x4c53c8){logger['info']('ChatWebsite,\x20%s,\x20%s',_0x52f4c4,'request\x20sent');logger[_0x8c15('0x24')]('ChatWebsite,\x20%s,\x20%s,\x20%s',_0x52f4c4,_0x8c15('0x25'),JSON[_0x8c15('0x26')](_0x4c53c8));if(_0x4c53c8[_0x8c15('0x27')]){if(_0x4c53c8[_0x8c15('0x27')]['code']===0x1f4){logger['error'](_0x8c15('0x28'),_0x52f4c4,_0x4c53c8['error']['message']);return _0x14f5a3(_0x4c53c8[_0x8c15('0x27')][_0x8c15('0x29')]);}logger[_0x8c15('0x27')]('ChatWebsite,\x20%s,\x20%s',_0x52f4c4,_0x4c53c8['error'][_0x8c15('0x29')]);return _0x5cffcb(_0x4c53c8[_0x8c15('0x27')]['message']);}else{logger[_0x8c15('0x2a')](_0x8c15('0x28'),_0x52f4c4,_0x8c15('0x25'));_0x5cffcb(_0x4c53c8[_0x8c15('0x2b')][_0x8c15('0x29')]);}})[_0x8c15('0x2c')](function(_0x5dad9f){logger['error'](_0x8c15('0x28'),_0x52f4c4,_0x5dad9f);_0x14f5a3(_0x5dad9f);});});}function respondWithStatusCode(_0x2071e3,_0x54ac12){_0x54ac12=_0x54ac12||0xcc;return function(_0x2f351d){if(_0x2f351d){return _0x2071e3['sendStatus'](_0x54ac12);}return _0x2071e3[_0x8c15('0x2d')](_0x54ac12)['end']();};}function respondWithResult(_0x4889eb,_0xf61b){_0xf61b=_0xf61b||0xc8;return function(_0xf2a193){if(_0xf2a193){return _0x4889eb[_0x8c15('0x2d')](_0xf61b)['json'](_0xf2a193);}};}function respondWithFilteredResult(_0xaccce7,_0x1322b9){return function(_0x28cfa9){if(_0x28cfa9){var _0x3ebc3a=_0x28cfa9[_0x8c15('0x2e')],_0x194cd9=_0x1322b9[_0x8c15('0x2f')],_0x39e882=_0x1322b9[_0x8c15('0x2f')]+_0x1322b9[_0x8c15('0x30')],_0x30702e;if(_0x39e882>=_0x3ebc3a){_0x39e882=_0x3ebc3a;_0x30702e=0xc8;}else{_0x30702e=0xce;}_0xaccce7[_0x8c15('0x2d')](_0x30702e);return _0xaccce7[_0x8c15('0x31')](_0x8c15('0x32'),_0x194cd9+'-'+_0x39e882+'/'+_0x3ebc3a)[_0x8c15('0x33')](_0x28cfa9);}return null;};}function patchUpdates(_0x1421f4){return function(_0x8c1433){try{jsonpatch[_0x8c15('0x34')](_0x8c1433,_0x1421f4,!![]);}catch(_0x44eed5){return BPromise[_0x8c15('0x35')](_0x44eed5);}return _0x8c1433[_0x8c15('0x36')]();};}function saveUpdates(_0x43f99f,_0x1b815a){return function(_0x1f633e){if(_0x1f633e){return _0x1f633e['update'](_0x43f99f)[_0x8c15('0x23')](function(_0x4ff21c){return _0x4ff21c;});}return null;};}function removeEntity(_0x2d7039,_0xa301cb){return function(_0x1f131b){if(_0x1f131b){return _0x1f131b[_0x8c15('0x37')]()[_0x8c15('0x23')](function(){var _0x53f836=_0x1f131b[_0x8c15('0x38')]({'plain':!![]});var _0x2c6397=_0x8c15('0x39');return db[_0x8c15('0x3a')][_0x8c15('0x37')]({'where':{'type':_0x2c6397,'resourceId':_0x53f836['id']}})[_0x8c15('0x23')](function(){return _0x1f131b;});})[_0x8c15('0x23')](function(){_0x2d7039[_0x8c15('0x2d')](0xcc)[_0x8c15('0x3b')]();});}};}function handleEntityNotFound(_0x27a97b,_0x1dbc5a){return function(_0x4cd889){if(!_0x4cd889){_0x27a97b[_0x8c15('0x3c')](0x194);}return _0x4cd889;};}function handleError(_0x5eddd0,_0x4c708d){_0x4c708d=_0x4c708d||0x1f4;return function(_0x41f345){logger[_0x8c15('0x27')](_0x41f345[_0x8c15('0x3d')]);if(_0x41f345[_0x8c15('0x3e')]){delete _0x41f345[_0x8c15('0x3e')];}_0x5eddd0[_0x8c15('0x2d')](_0x4c708d)[_0x8c15('0x3f')](_0x41f345);};}exports[_0x8c15('0x40')]=function(_0x74ca31,_0x256ca5){var _0x39aefe={'include':[{'model':db[_0x8c15('0x41')],'as':_0x8c15('0x42')}]},_0x1d3326={},_0x8655a4={'count':0x0,'rows':[]};var _0x1f123c=_[_0x8c15('0x43')](db[_0x8c15('0x44')][_0x8c15('0x45')],function(_0x34ce82){return{'name':_0x34ce82['fieldName'],'type':_0x34ce82[_0x8c15('0x46')][_0x8c15('0x47')]};});_0x1d3326[_0x8c15('0x48')]=_[_0x8c15('0x43')](_0x1f123c,'name');_0x1d3326[_0x8c15('0x49')]=_[_0x8c15('0x4a')](_0x74ca31['query']);_0x1d3326['filters']=_['intersection'](_0x1d3326['model'],_0x1d3326['query']);_0x39aefe[_0x8c15('0x4b')]=_[_0x8c15('0x4c')](_0x1d3326['model'],qs[_0x8c15('0x4d')](_0x74ca31['query'][_0x8c15('0x4d')]));_0x39aefe[_0x8c15('0x4b')]=_0x39aefe[_0x8c15('0x4b')][_0x8c15('0x4e')]?_0x39aefe[_0x8c15('0x4b')]:_0x1d3326['model'];if(!_0x74ca31[_0x8c15('0x49')][_0x8c15('0x4f')](_0x8c15('0x50'))){_0x39aefe[_0x8c15('0x30')]=qs[_0x8c15('0x30')](_0x74ca31[_0x8c15('0x49')][_0x8c15('0x30')]);_0x39aefe[_0x8c15('0x2f')]=qs[_0x8c15('0x2f')](_0x74ca31[_0x8c15('0x49')][_0x8c15('0x2f')]);}_0x39aefe[_0x8c15('0x51')]=qs[_0x8c15('0x52')](_0x74ca31[_0x8c15('0x49')][_0x8c15('0x52')]);_0x39aefe[_0x8c15('0x53')]=qs['filters'](_[_0x8c15('0x54')](_0x74ca31[_0x8c15('0x49')],_0x1d3326[_0x8c15('0x55')]),_0x1f123c);if(_0x74ca31[_0x8c15('0x49')][_0x8c15('0x56')]){_0x39aefe[_0x8c15('0x53')]=_[_0x8c15('0x57')](_0x39aefe[_0x8c15('0x53')],{'$or':_[_0x8c15('0x43')](_0x1f123c,function(_0x5e5f33){if(_0x5e5f33[_0x8c15('0x46')]!==_0x8c15('0x58')){var _0x322a01={};_0x322a01[_0x5e5f33[_0x8c15('0x3e')]]={'$like':'%'+_0x74ca31[_0x8c15('0x49')][_0x8c15('0x56')]+'%'};return _0x322a01;}})});}_0x39aefe=_[_0x8c15('0x57')]({},_0x39aefe,_0x74ca31[_0x8c15('0x59')]);var _0x51d746={'where':_0x39aefe[_0x8c15('0x53')]};return db['ChatWebsite'][_0x8c15('0x2e')](_0x51d746)[_0x8c15('0x23')](function(_0x547ca7){_0x8655a4['count']=_0x547ca7;if(_0x74ca31[_0x8c15('0x49')][_0x8c15('0x5a')]){_0x39aefe['include']=[{'all':!![]}];}return db[_0x8c15('0x44')][_0x8c15('0x5b')](_0x39aefe);})[_0x8c15('0x23')](function(_0x47d269){_0x8655a4[_0x8c15('0x5c')]=_0x47d269;return _0x8655a4;})[_0x8c15('0x23')](respondWithFilteredResult(_0x256ca5,_0x39aefe))[_0x8c15('0x2c')](handleError(_0x256ca5,null));};exports[_0x8c15('0x5d')]=function(_0x54ad21,_0x202c44){var _0x193328={'raw':![],'where':{'id':_0x54ad21[_0x8c15('0x5e')]['id']},'include':[{'model':db[_0x8c15('0x41')],'as':'mandatoryDispositionPause'}]},_0x5ad8f6={};_0x5ad8f6['model']=_[_0x8c15('0x4a')](db[_0x8c15('0x44')][_0x8c15('0x45')]);_0x5ad8f6['query']=_[_0x8c15('0x4a')](_0x54ad21[_0x8c15('0x49')]);_0x5ad8f6['filters']=_[_0x8c15('0x4c')](_0x5ad8f6[_0x8c15('0x48')],_0x5ad8f6[_0x8c15('0x49')]);_0x193328['attributes']=_[_0x8c15('0x4c')](_0x5ad8f6[_0x8c15('0x48')],qs['fields'](_0x54ad21[_0x8c15('0x49')][_0x8c15('0x4d')]));_0x193328[_0x8c15('0x4b')]=_0x193328[_0x8c15('0x4b')][_0x8c15('0x4e')]?_0x193328[_0x8c15('0x4b')]:_0x5ad8f6[_0x8c15('0x48')];if(_0x54ad21[_0x8c15('0x49')][_0x8c15('0x5a')]){_0x193328[_0x8c15('0x5f')]=[{'all':!![]}];}_0x193328=_['merge']({},_0x193328,_0x54ad21[_0x8c15('0x59')]);return db['ChatWebsite']['find'](_0x193328)[_0x8c15('0x23')](handleEntityNotFound(_0x202c44,null))['then'](respondWithResult(_0x202c44,null))[_0x8c15('0x2c')](handleError(_0x202c44,null));};exports[_0x8c15('0x60')]=function(_0x3d1c13,_0x457020){return db[_0x8c15('0x44')][_0x8c15('0x60')](_0x3d1c13[_0x8c15('0x61')],{})[_0x8c15('0x23')](function(_0x172d0d){var _0x5db1ce=_0x3d1c13[_0x8c15('0x62')][_0x8c15('0x38')]({'plain':!![]});if(!_0x5db1ce)throw new Error(_0x8c15('0x63'));if(_0x5db1ce[_0x8c15('0x64')]===_0x8c15('0x62')){var _0x3892e9=_0x172d0d[_0x8c15('0x38')]({'plain':!![]});var _0x3a0464=_0x8c15('0x39');return db['UserProfileSection']['find']({'where':{'name':_0x3a0464,'userProfileId':_0x5db1ce[_0x8c15('0x65')]},'raw':!![]})['then'](function(_0x55a0dc){if(_0x55a0dc&&_0x55a0dc[_0x8c15('0x66')]===0x0){return db[_0x8c15('0x3a')][_0x8c15('0x60')]({'name':_0x3892e9[_0x8c15('0x3e')],'resourceId':_0x3892e9['id'],'type':_0x55a0dc[_0x8c15('0x3e')],'sectionId':_0x55a0dc['id']},{})['then'](function(){return _0x172d0d;});}else{return _0x172d0d;}})[_0x8c15('0x2c')](function(_0x117eac){logger['error'](_0x8c15('0x67'),_0x117eac);throw _0x117eac;});}return _0x172d0d;})[_0x8c15('0x23')](respondWithResult(_0x457020,0xc9))[_0x8c15('0x2c')](handleError(_0x457020,null));};exports[_0x8c15('0x68')]=function(_0x1359b9,_0x456f5d){if(_0x1359b9['body']['id']){delete _0x1359b9[_0x8c15('0x61')]['id'];}return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x1359b9[_0x8c15('0x5e')]['id']},'include':[{'model':db[_0x8c15('0x41')],'as':_0x8c15('0x42')}]})[_0x8c15('0x23')](handleEntityNotFound(_0x456f5d,null))[_0x8c15('0x23')](saveUpdates(_0x1359b9[_0x8c15('0x61')],null))['then'](respondWithResult(_0x456f5d,null))[_0x8c15('0x2c')](handleError(_0x456f5d,null));};exports[_0x8c15('0x37')]=function(_0x1ca577,_0x3d8388){return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x1ca577[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x3d8388,null))[_0x8c15('0x23')](removeEntity(_0x3d8388,null))[_0x8c15('0x2c')](handleError(_0x3d8388,null));};exports[_0x8c15('0x6a')]=function(_0x1d2718,_0x28ae74){return db[_0x8c15('0x44')][_0x8c15('0x6a')]()[_0x8c15('0x23')](respondWithResult(_0x28ae74,null))[_0x8c15('0x2c')](handleError(_0x28ae74,null));};exports[_0x8c15('0x6b')]=function(_0x112a4b,_0x155212,_0x2dbc6b){if(_0x112a4b[_0x8c15('0x61')]['id']){delete _0x112a4b[_0x8c15('0x61')]['id'];}return db['ChatWebsite'][_0x8c15('0x69')]({'where':{'id':_0x112a4b[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x155212,null))[_0x8c15('0x23')](function(_0x350d38){if(_0x350d38){_0x112a4b['body'][_0x8c15('0x6c')]=_0x350d38['id'];return db[_0x8c15('0x6d')][_0x8c15('0x60')](_0x112a4b[_0x8c15('0x61')]);}})['then'](respondWithResult(_0x155212,null))['catch'](handleError(_0x155212,null));};exports[_0x8c15('0x6e')]=function(_0x490d1d,_0x2ef35b,_0x1b3cc4){var _0x39b739={'raw':![],'where':{}};var _0x42cc3f={};var _0x200082={'count':0x0,'rows':[]};return db[_0x8c15('0x44')]['findOne']({'where':{'id':_0x490d1d['params']['id']}})['then'](handleEntityNotFound(_0x2ef35b,null))[_0x8c15('0x23')](function(_0x578d92){if(_0x578d92){_0x42cc3f['model']=_[_0x8c15('0x4a')](db[_0x8c15('0x6d')][_0x8c15('0x45')]);_0x42cc3f[_0x8c15('0x49')]=_[_0x8c15('0x4a')](_0x490d1d[_0x8c15('0x49')]);_0x42cc3f['filters']=_[_0x8c15('0x4c')](_0x42cc3f[_0x8c15('0x48')],_0x42cc3f[_0x8c15('0x49')]);_0x39b739[_0x8c15('0x4b')]=_['intersection'](_0x42cc3f[_0x8c15('0x48')],qs[_0x8c15('0x4d')](_0x490d1d[_0x8c15('0x49')][_0x8c15('0x4d')]));_0x39b739[_0x8c15('0x4b')]=_0x39b739[_0x8c15('0x4b')][_0x8c15('0x4e')]?_0x39b739[_0x8c15('0x4b')]:_0x42cc3f[_0x8c15('0x48')];if(!_0x490d1d[_0x8c15('0x49')][_0x8c15('0x4f')]('nolimit')){_0x39b739[_0x8c15('0x30')]=qs['limit'](_0x490d1d[_0x8c15('0x49')][_0x8c15('0x30')]);_0x39b739[_0x8c15('0x2f')]=qs[_0x8c15('0x2f')](_0x490d1d[_0x8c15('0x49')]['offset']);}_0x39b739['order']=qs[_0x8c15('0x52')](_0x490d1d['query'][_0x8c15('0x52')]);_0x39b739[_0x8c15('0x53')]=qs[_0x8c15('0x55')](_[_0x8c15('0x54')](_0x490d1d['query'],_0x42cc3f[_0x8c15('0x55')]));_0x39b739[_0x8c15('0x53')][_0x8c15('0x6c')]=_0x578d92['id'];if(_0x490d1d[_0x8c15('0x49')][_0x8c15('0x56')]){_0x39b739[_0x8c15('0x53')]=_['merge'](_0x39b739[_0x8c15('0x53')],{'$or':_[_0x8c15('0x43')](_0x39b739[_0x8c15('0x4b')],function(_0x1e4df1){var _0x5b3693={};_0x5b3693[_0x1e4df1]={'$like':'%'+_0x490d1d['query'][_0x8c15('0x56')]+'%'};return _0x5b3693;})});}_0x39b739=_['merge']({},_0x39b739,_0x490d1d[_0x8c15('0x59')]);return db[_0x8c15('0x6d')][_0x8c15('0x2e')]({'where':_0x39b739['where']})[_0x8c15('0x23')](function(_0x9ca1b6){_0x200082[_0x8c15('0x2e')]=_0x9ca1b6;if(_0x490d1d[_0x8c15('0x49')][_0x8c15('0x5a')]){_0x39b739[_0x8c15('0x5f')]=[{'all':!![]}];}return db[_0x8c15('0x6d')][_0x8c15('0x5b')](_0x39b739);})[_0x8c15('0x23')](function(_0x84f66d){_0x200082[_0x8c15('0x5c')]=_0x84f66d;return _0x200082;});}})['then'](respondWithFilteredResult(_0x2ef35b,_0x39b739))[_0x8c15('0x2c')](handleError(_0x2ef35b,null));};exports[_0x8c15('0x6f')]=function(_0x649164,_0x3083a1,_0x409ae0){return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x649164[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x3083a1,null))[_0x8c15('0x23')](function(_0x328079){if(_0x328079){return _0x328079['removeDispositions'](_0x649164['query'][_0x8c15('0x70')]);}})[_0x8c15('0x23')](respondWithStatusCode(_0x3083a1,null))['catch'](handleError(_0x3083a1,null));};exports[_0x8c15('0x71')]=function(_0x45398b,_0x1c9eb9,_0x5a4783){if(_0x45398b[_0x8c15('0x61')]['id']){delete _0x45398b[_0x8c15('0x61')]['id'];}return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x45398b[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x1c9eb9,null))[_0x8c15('0x23')](function(_0x1d2539){if(_0x1d2539){_0x45398b[_0x8c15('0x61')][_0x8c15('0x6c')]=_0x1d2539['id'];return db['CannedAnswer'][_0x8c15('0x60')](_0x45398b['body']);}})['then'](respondWithResult(_0x1c9eb9,null))['catch'](handleError(_0x1c9eb9,null));};exports[_0x8c15('0x72')]=function(_0xe3f980,_0x32924e,_0x45d14b){var _0x143835={'raw':![],'where':{}};var _0xf0e694={};var _0x2169df={'count':0x0,'rows':[]};return db[_0x8c15('0x44')][_0x8c15('0x73')]({'where':{'id':_0xe3f980['params']['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x32924e,null))[_0x8c15('0x23')](function(_0x545f69){if(_0x545f69){_0xf0e694[_0x8c15('0x48')]=_[_0x8c15('0x4a')](db[_0x8c15('0x74')]['rawAttributes']);_0xf0e694[_0x8c15('0x49')]=_[_0x8c15('0x4a')](_0xe3f980[_0x8c15('0x49')]);_0xf0e694['filters']=_[_0x8c15('0x4c')](_0xf0e694[_0x8c15('0x48')],_0xf0e694[_0x8c15('0x49')]);_0x143835[_0x8c15('0x4b')]=_[_0x8c15('0x4c')](_0xf0e694['model'],qs['fields'](_0xe3f980[_0x8c15('0x49')][_0x8c15('0x4d')]));_0x143835['attributes']=_0x143835[_0x8c15('0x4b')]['length']?_0x143835[_0x8c15('0x4b')]:_0xf0e694['model'];if(!_0xe3f980[_0x8c15('0x49')][_0x8c15('0x4f')](_0x8c15('0x50'))){_0x143835[_0x8c15('0x30')]=qs[_0x8c15('0x30')](_0xe3f980[_0x8c15('0x49')]['limit']);_0x143835[_0x8c15('0x2f')]=qs[_0x8c15('0x2f')](_0xe3f980[_0x8c15('0x49')][_0x8c15('0x2f')]);}_0x143835[_0x8c15('0x51')]=qs['sort'](_0xe3f980['query'][_0x8c15('0x52')]);_0x143835[_0x8c15('0x53')]=qs[_0x8c15('0x55')](_[_0x8c15('0x54')](_0xe3f980[_0x8c15('0x49')],_0xf0e694[_0x8c15('0x55')]));_0x143835[_0x8c15('0x53')][_0x8c15('0x6c')]=_0x545f69['id'];if(_0xe3f980[_0x8c15('0x49')][_0x8c15('0x56')]){_0x143835['where']=_[_0x8c15('0x57')](_0x143835[_0x8c15('0x53')],{'$or':_[_0x8c15('0x43')](_0x143835[_0x8c15('0x4b')],function(_0x551cdf){var _0xff2044={};_0xff2044[_0x551cdf]={'$like':'%'+_0xe3f980[_0x8c15('0x49')]['filter']+'%'};return _0xff2044;})});}_0x143835=_[_0x8c15('0x57')]({},_0x143835,_0xe3f980[_0x8c15('0x59')]);return db[_0x8c15('0x74')][_0x8c15('0x2e')]({'where':_0x143835[_0x8c15('0x53')]})['then'](function(_0x2c03cf){_0x2169df[_0x8c15('0x2e')]=_0x2c03cf;if(_0xe3f980['query'][_0x8c15('0x5a')]){_0x143835[_0x8c15('0x5f')]=[{'all':!![]}];}return db[_0x8c15('0x74')]['findAll'](_0x143835);})['then'](function(_0x24f347){_0x2169df['rows']=_0x24f347;return _0x2169df;});}})['then'](respondWithFilteredResult(_0x32924e,_0x143835))[_0x8c15('0x2c')](handleError(_0x32924e,null));};exports[_0x8c15('0x75')]=function(_0x4a7cda,_0x5ab0db,_0x9159b6){return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x4a7cda[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x5ab0db,null))[_0x8c15('0x23')](function(_0x26f180){if(_0x26f180){return _0x26f180['removeAnswers'](_0x4a7cda[_0x8c15('0x49')][_0x8c15('0x70')]);}})[_0x8c15('0x23')](respondWithStatusCode(_0x5ab0db,null))[_0x8c15('0x2c')](handleError(_0x5ab0db,null));};exports[_0x8c15('0x76')]=function(_0x2958c0,_0x2113d3,_0xbff0fe){_0x2958c0[_0x8c15('0x61')][_0x8c15('0x77')]=_0x2958c0['file']['filename'];return db[_0x8c15('0x44')]['find']({'where':{'id':_0x2958c0[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x2113d3,null))['then'](saveUpdates(_0x2958c0[_0x8c15('0x61')],null))['then'](respondWithResult(_0x2113d3,null))[_0x8c15('0x2c')](handleError(_0x2113d3,null));};exports[_0x8c15('0x78')]=function(_0x24d36f,_0x57e628,_0xa8d4e0){_0x24d36f['body'][_0x8c15('0x79')]=_0x24d36f[_0x8c15('0x7a')]['filename'];return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x24d36f['params']['id']}})['then'](handleEntityNotFound(_0x57e628,null))[_0x8c15('0x23')](saveUpdates(_0x24d36f['body'],null))[_0x8c15('0x23')](respondWithResult(_0x57e628,null))['catch'](handleError(_0x57e628,null));};exports[_0x8c15('0x7b')]=function(_0x5ad5d6,_0x1e07a3,_0x49dc35){_0x5ad5d6['body'][_0x8c15('0x7c')]=_0x5ad5d6[_0x8c15('0x7a')][_0x8c15('0x7d')];return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x5ad5d6[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x1e07a3,null))[_0x8c15('0x23')](saveUpdates(_0x5ad5d6['body'],null))[_0x8c15('0x23')](respondWithResult(_0x1e07a3,null))[_0x8c15('0x2c')](handleError(_0x1e07a3,null));};exports[_0x8c15('0x7e')]=function(_0x507353,_0x2ebe2d,_0x2742ea){_0x507353[_0x8c15('0x61')][_0x8c15('0x7f')]=_0x507353['file']['filename'];return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x507353[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x2ebe2d,null))[_0x8c15('0x23')](saveUpdates(_0x507353[_0x8c15('0x61')],null))[_0x8c15('0x23')](respondWithResult(_0x2ebe2d,null))[_0x8c15('0x2c')](handleError(_0x2ebe2d,null));};exports[_0x8c15('0x80')]=function(_0x1da958,_0x14f03e,_0x66c270){var _0x41aa01=path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x83'));var _0x14d2a6={'where':{'id':_0x1da958[_0x8c15('0x5e')]['id']},'attributes':['id','sitepic'],'raw':!![]};var _0x6f3461=![];return require('../../config/license/util')[_0x8c15('0x84')]()[_0x8c15('0x23')](function(_0xabba75){if(_0xabba75){_0x6f3461=_0xabba75[_0x8c15('0x85')];}})['then'](function(){return db[_0x8c15('0x44')][_0x8c15('0x69')](_0x14d2a6);})[_0x8c15('0x23')](handleEntityNotFound(_0x14f03e,null))[_0x8c15('0x23')](function(_0x3e9995){if(_0x3e9995){if(!_['isNil'](_0x3e9995[_0x8c15('0x77')])){if(fs[_0x8c15('0x86')](path[_0x8c15('0x81')](config['root'],_0x8c15('0x87'),_0x3e9995[_0x8c15('0x77')]))&&_0x6f3461){_0x41aa01=path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x87'),_0x3e9995[_0x8c15('0x77')]);}}return _0x14f03e[_0x8c15('0x88')](_0x41aa01);}})[_0x8c15('0x2c')](handleError(_0x14f03e,null));};exports[_0x8c15('0x89')]=function(_0x2e45d2,_0x1480a3,_0x33e600){var _0x5a6b00=path['join'](config['root'],'server/files/images/avatars/default_avatar.png');var _0xbdc379={'where':{'id':_0x2e45d2['params']['id']},'attributes':['id',_0x8c15('0x79')],'raw':!![]};return db[_0x8c15('0x44')][_0x8c15('0x69')](_0xbdc379)[_0x8c15('0x23')](handleEntityNotFound(_0x1480a3,null))[_0x8c15('0x23')](function(_0x1cddce){if(_0x1cddce){if(!_[_0x8c15('0x8a')](_0x1cddce['agentAvatar'])){if(fs[_0x8c15('0x86')](path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x8b'),_0x1cddce[_0x8c15('0x79')]))){_0x5a6b00=path[_0x8c15('0x81')](config['root'],_0x8c15('0x8b'),_0x1cddce['agentAvatar']);}}return _0x1480a3[_0x8c15('0x88')](_0x5a6b00);}})[_0x8c15('0x2c')](handleError(_0x1480a3,null));};exports[_0x8c15('0x8c')]=function(_0x1e3c7f,_0x32a36a,_0x7a9049){var _0xc342eb=path[_0x8c15('0x81')](config[_0x8c15('0x82')],'server/files/images/avatars/customer_avatar.png');var _0x3fe3d5={'where':{'id':_0x1e3c7f[_0x8c15('0x5e')]['id']},'attributes':['id',_0x8c15('0x7c'),'showCustomerAvatar'],'raw':!![]};return db[_0x8c15('0x44')][_0x8c15('0x69')](_0x3fe3d5)[_0x8c15('0x23')](handleEntityNotFound(_0x32a36a,null))['then'](function(_0x5281ef){if(_0x5281ef){if(!_[_0x8c15('0x8a')](_0x5281ef[_0x8c15('0x7c')])){if(fs['existsSync'](path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x8b'),_0x5281ef[_0x8c15('0x7c')]))&&_0x5281ef[_0x8c15('0x8d')]){_0xc342eb=path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x8b'),_0x5281ef[_0x8c15('0x7c')]);}}return _0x32a36a['download'](_0xc342eb);}})['catch'](handleError(_0x32a36a,null));};exports['getSystemAvatar']=function(_0x580af7,_0x439e7f,_0x32dc86){var _0x50063c=path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x8e'));var _0x10def5={'where':{'id':_0x580af7[_0x8c15('0x5e')]['id']},'attributes':['id',_0x8c15('0x7f')],'raw':!![]};return db[_0x8c15('0x44')][_0x8c15('0x69')](_0x10def5)[_0x8c15('0x23')](handleEntityNotFound(_0x439e7f,null))[_0x8c15('0x23')](function(_0x346a30){if(_0x346a30){if(!_[_0x8c15('0x8a')](_0x346a30[_0x8c15('0x7f')])){if(fs['existsSync'](path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x8b'),_0x346a30[_0x8c15('0x7f')]))){_0x50063c=path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x8b'),_0x346a30['systemAvatar']);}}return _0x439e7f[_0x8c15('0x88')](_0x50063c);}})[_0x8c15('0x2c')](handleError(_0x439e7f,null));};exports['notify']=function(_0x25832e,_0x414f6f,_0x4e2fc8){var _0xe066ee=require(_0x8c15('0x8f'));var _0x591822=new _0xe066ee();var _0x41bba5=_0x591822[_0x8c15('0x90')](_0x25832e[_0x8c15('0x91')][_0x8c15('0x92')])[_0x8c15('0x93')]();var _0x1f1f81={'body':_0x25832e[_0x8c15('0x61')],'channel':'chat'};var _0x322639=[];var _0x53aace=[];var _0x3436ce={};var _0x17a856=![];return db['CmContact']['describe']()[_0x8c15('0x23')](function(_0x2fa2d3){if(!_0x2fa2d3){throw new db[(_0x8c15('0x94'))]['ValidationError'](_0x8c15('0x95'));}_0x322639=_[_0x8c15('0x96')](_[_0x8c15('0x4a')](_0x2fa2d3),[_0x8c15('0x97'),_0x8c15('0x98')]);_0x53aace=_[_0x8c15('0x96')](_[_0x8c15('0x4a')](_0x2fa2d3),['createdAt',_0x8c15('0x98'),_0x8c15('0x99'),_0x8c15('0x9a')]);if(_0x25832e[_0x8c15('0x61')]['id']){delete _0x25832e[_0x8c15('0x61')]['id'];}if(_[_0x8c15('0x8a')](_0x25832e['body'][_0x8c15('0x9b')])){throw new db['Sequelize'][(_0x8c15('0x9c'))]('from\x20is\x20mandatory');}if(_[_0x8c15('0x8a')](_0x25832e[_0x8c15('0x61')][_0x8c15('0x61')])||_0x25832e[_0x8c15('0x61')][_0x8c15('0x61')]===''){throw new db[(_0x8c15('0x94'))]['ValidationError']('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0x8c15('0x8a')](_0x25832e[_0x8c15('0x61')][_0x8c15('0x9d')])){throw new db[(_0x8c15('0x94'))][(_0x8c15('0x9c'))](_0x8c15('0x9e')+_0x53aace);}if(!_[_0x8c15('0x9f')](_0x53aace,_0x25832e[_0x8c15('0x61')][_0x8c15('0x9d')])){throw new db[(_0x8c15('0x94'))][(_0x8c15('0x9c'))](_0x8c15('0xa0')+_0x53aace);}_0x3436ce[_0x25832e[_0x8c15('0x61')]['mapKey']]=_0x25832e['body']['from'];})[_0x8c15('0x23')](function(){return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x25832e[_0x8c15('0x5e')]['id']},'include':[{'model':db['CmList'],'as':'List','include':[{'model':db[_0x8c15('0xa1')],'as':_0x8c15('0xa2'),'where':_0x3436ce,'limit':0x1,'order':[['updatedAt','DESC']]}]},{'model':db[_0x8c15('0xa3')],'as':_0x8c15('0xa4')}]});})['then'](handleEntityNotFound(_0x414f6f,null))['then'](function(_0x58d6be){if(_0x58d6be&&_0x58d6be[_0x8c15('0xa5')]){_0x1f1f81[_0x8c15('0xa6')]=_0x58d6be;_0x1f1f81[_0x8c15('0xa7')]=_0x58d6be[_0x8c15('0xa4')];_0x1f1f81[_0x8c15('0xa8')]=_0x58d6be[_0x8c15('0xa5')];_0x1f1f81['applications']=_[_0x8c15('0xa9')](_0x1f1f81[_0x8c15('0xa7')],[_0x8c15('0xaa')],['asc']);if(_0x1f1f81[_0x8c15('0xa6')][_0x8c15('0xa4')]){delete _0x1f1f81[_0x8c15('0xa6')][_0x8c15('0xa4')];}if(_0x1f1f81[_0x8c15('0xa6')][_0x8c15('0xa5')]&&_0x1f1f81[_0x8c15('0xa6')][_0x8c15('0xa5')][_0x8c15('0xa2')][_0x8c15('0x4e')]){return _0x1f1f81[_0x8c15('0xa6')][_0x8c15('0xa5')][_0x8c15('0xa2')][0x0];}var _0x38028d=_[_0x8c15('0x1b')](_0x25832e['body'],{'firstName':_0x25832e['body'][_0x8c15('0x9b')],'ListId':_0x58d6be[_0x8c15('0x9a')]});_0x38028d[_0x25832e['body'][_0x8c15('0x9d')]]=_0x25832e[_0x8c15('0x61')][_0x8c15('0x9b')];return db['CmContact'][_0x8c15('0x60')](_0x38028d,{'fields':_0x322639,'raw':!![]});}})['then'](handleEntityNotFound(_0x414f6f,null))[_0x8c15('0x23')](function(_0x5ecb89){_0x1f1f81[_0x8c15('0xab')]=_0x5ecb89;var _0x23cce9=_0x25832e[_0x8c15('0x61')][_0x8c15('0xac')];if(_0x25832e[_0x8c15('0x91')][_0x8c15('0xad')]){_0x23cce9=_0x25832e[_0x8c15('0x91')][_0x8c15('0xad')];}else if(_0x25832e[_0x8c15('0x91')]['x-forwarded-for']){_0x23cce9=_[_0x8c15('0xae')](_0x25832e['headers'][_0x8c15('0xaf')][_0x8c15('0xb0')](','));}if(_0x5ecb89){var _0x234307={'ContactId':_0x5ecb89['id'],'ChatWebsiteId':_0x25832e[_0x8c15('0x5e')]['id'],'from':(_0x5ecb89['firstName']||'')+'\x20'+(_0x5ecb89[_0x8c15('0xb1')]||''),'customerIp':_0x23cce9,'customerPort':_0x25832e['headers'][_0x8c15('0xb2')]?_0x25832e[_0x8c15('0x91')]['x-real-port']:null,'referer':_0x25832e[_0x8c15('0x61')]['referer'],'browserName':_0x41bba5[_0x8c15('0xb3')][_0x8c15('0x3e')]&&_0x41bba5['browser'][_0x8c15('0xb4')]?util[_0x8c15('0xb5')](_0x8c15('0xb6'),_0x41bba5['browser']['name'],_0x41bba5['browser'][_0x8c15('0xb4')]):_0x8c15('0xb7'),'browserVersion':_0x41bba5['browser'][_0x8c15('0xb4')]||'unknown','osName':util[_0x8c15('0xb5')](_0x8c15('0xb6'),_0x41bba5['os'][_0x8c15('0x3e')],_0x41bba5['os'][_0x8c15('0xb4')]),'osVersion':_0x41bba5['os']['version'],'deviceModel':_0x41bba5[_0x8c15('0xb8')][_0x8c15('0x48')]&&_0x41bba5[_0x8c15('0xb8')]['vendor']?util[_0x8c15('0xb5')](_0x8c15('0xb9'),_0x41bba5[_0x8c15('0xb8')][_0x8c15('0x48')],_0x41bba5[_0x8c15('0xb8')][_0x8c15('0xba')],_0x41bba5[_0x8c15('0xb8')]['type']):null,'deviceVendor':_0x41bba5[_0x8c15('0xb8')][_0x8c15('0xba')],'deviceType':_0x41bba5[_0x8c15('0xb8')][_0x8c15('0x46')],'formData':JSON[_0x8c15('0x26')](_0x25832e[_0x8c15('0x61')])};var _0x51b3f7={'ChatWebsiteId':_0x25832e['params']['id'],'closed':![]};if(_0x25832e[_0x8c15('0x61')][_0x8c15('0xbb')]){_0x51b3f7[_0x8c15('0xbb')]=_0x25832e[_0x8c15('0x61')][_0x8c15('0xbb')];return db[_0x8c15('0xbc')][_0x8c15('0x69')]({'where':_0x51b3f7})['then'](function(_0x2645d9){if(_0x2645d9){return[_0x2645d9,![]];}_0x234307['threadId']=_0x25832e['body'][_0x8c15('0xbb')];_0x234307[_0x8c15('0xbd')]=_0x25832e['body']['externalUrl'];return db[_0x8c15('0xbc')][_0x8c15('0x60')](_0x234307)[_0x8c15('0x23')](function(_0x1b7725){return[_0x1b7725,!![]];});});}_0x51b3f7[_0x8c15('0xbe')]=_0x5ecb89['id'];if(_0x25832e['body'][_0x8c15('0xbf')]&&_0x25832e[_0x8c15('0x61')][_0x8c15('0xbf')]['id']){_0x51b3f7['id']=_0x25832e[_0x8c15('0x61')][_0x8c15('0xbf')]['id'];return db[_0x8c15('0xbc')][_0x8c15('0x69')]({'where':_0x51b3f7})[_0x8c15('0x23')](function(_0x2c1793){if(_0x2c1793){return[_0x2c1793,![]];}return db[_0x8c15('0xbc')][_0x8c15('0x60')](_0x234307)[_0x8c15('0x23')](function(_0x52d027){return[_0x52d027,!![]];});});}return db['ChatInteraction']['create'](_0x234307)['then'](function(_0x179431){return[_0x179431,!![]];});}})[_0x8c15('0xc0')](function(_0x5b2f3d,_0x71829a){if(_0x5b2f3d){_0x17a856=_0x71829a;if(!_0x71829a){var _0x4a0b3e={'from':(_0x1f1f81['contact']['firstName']||'')+'\x20'+(_0x1f1f81[_0x8c15('0xab')]['lastName']||'')};if(_0x25832e[_0x8c15('0x61')][_0x8c15('0xbb')]&&_0x25832e[_0x8c15('0x61')][_0x8c15('0xc1')]&&_0x25832e['body'][_0x8c15('0xbb')]!=_0x25832e['body'][_0x8c15('0xc1')]){_0x4a0b3e[_0x8c15('0xbb')]=_0x25832e[_0x8c15('0x61')]['messageId'];}return _0x5b2f3d[_0x8c15('0x68')](_0x4a0b3e);}else{return _0x5b2f3d;}}})[_0x8c15('0x23')](function(_0x1d29f9){_0x1f1f81[_0x8c15('0xbf')]=_0x1d29f9[_0x8c15('0x38')]({'plain':!![]});_0x1f1f81['interaction'][_0x8c15('0xc2')]=_0x17a856;if(_0x1f1f81[_0x8c15('0xbf')][_0x8c15('0xc2')]){if(_0x1f1f81[_0x8c15('0xa6')][_0x8c15('0xc3')]){_0x1f1f81[_0x8c15('0xa7')]['push']({'id':0x0,'priority':_0x1f1f81[_0x8c15('0xa7')][_0x8c15('0x4e')]+0x1,'app':_0x8c15('0xc4'),'appdata':_0x8c15('0xc5'),'interval':_0x8c15('0xc6')});}}return db[_0x8c15('0xc7')]['create']({'body':_0x25832e[_0x8c15('0x61')][_0x8c15('0x61')],'ChatWebsiteId':_0x25832e['params']['id'],'ChatInteractionId':_0x1d29f9['id'],'direction':'in','ContactId':_0x1f1f81['contact']['id'],'AttachmentId':_0x25832e[_0x8c15('0x61')][_0x8c15('0xc8')]});})['then'](function(_0x2aabec){_0x1f1f81[_0x8c15('0x29')]=_0x2aabec;if(_0x1f1f81['interaction'][_0x8c15('0xc9')]){return db[_0x8c15('0xca')][_0x8c15('0x69')]({'attributes':['id',_0x8c15('0x3e')],'where':{'id':_0x1f1f81['interaction'][_0x8c15('0xc9')]}})[_0x8c15('0x23')](function(_0x42db2d){if(_0x42db2d){_0x1f1f81[_0x8c15('0xa7')][_0x8c15('0xcb')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x42db2d[_0x8c15('0x3e')]+','+(_0x1f1f81[_0x8c15('0xa6')]['waitForTheAssignedAgent']||0xa),'interval':_0x8c15('0xc6')});_0x1f1f81[_0x8c15('0xcc')]=!![];}return respondWithRpcPromise('Start',_0x8c15('0xcd'),_0x1f1f81);});}return respondWithRpcPromise(_0x8c15('0xce'),_0x8c15('0xcd'),_0x1f1f81);})['then'](function(_0x3ad7c7){respondWithRpcPromise(_0x8c15('0xcf'),_0x8c15('0xcf'),{'event':'notify','message':_0x3ad7c7},client9002);return _0x3ad7c7;})[_0x8c15('0x23')](respondWithResult(_0x414f6f,null))[_0x8c15('0x2c')](handleError(_0x414f6f,null));};exports['offline']=function(_0x2f92e2,_0x4793de,_0xa94d82){var _0x53f4a0,_0x34bfe1,_0x1fa117;var _0x2c1974=[];var _0xe93cd0=[];var _0x588127={};return db[_0x8c15('0xa1')][_0x8c15('0x6a')]()[_0x8c15('0x23')](function(_0x205f0f){if(!_0x205f0f){throw new db[(_0x8c15('0x94'))]['ValidationError'](_0x8c15('0x95'));}_0xe93cd0=_[_0x8c15('0x96')](_[_0x8c15('0x4a')](_0x205f0f),[_0x8c15('0x97'),'updatedAt']);_0x2c1974=_['difference'](_['keys'](_0x205f0f),[_0x8c15('0x97'),_0x8c15('0x98'),_0x8c15('0x99'),_0x8c15('0x9a')]);if(_0x2f92e2[_0x8c15('0x61')]['id']){delete _0x2f92e2[_0x8c15('0x61')]['id'];}if(_[_0x8c15('0x8a')](_0x2f92e2[_0x8c15('0x61')][_0x8c15('0x9b')])){throw _0x4793de[_0x8c15('0x2d')](0x1f4)['send'](new db[(_0x8c15('0x94'))][(_0x8c15('0x9c'))](_0x8c15('0xd0')));}if(_[_0x8c15('0x8a')](_0x2f92e2['body'][_0x8c15('0x61')])||_0x2f92e2['body'][_0x8c15('0x61')]===''){throw _0x4793de[_0x8c15('0x2d')](0x1f4)['send'](new db[(_0x8c15('0x94'))][(_0x8c15('0x9c'))](_0x8c15('0xd1')));}if(_['isNil'](_0x2f92e2[_0x8c15('0x61')][_0x8c15('0xd2')])){throw _0x4793de[_0x8c15('0x2d')](0x1f4)[_0x8c15('0x3f')](new db[(_0x8c15('0x94'))]['ValidationError'](_0x8c15('0xd3')+_0x2c1974));}if(!_['includes'](_0x2c1974,_0x2f92e2[_0x8c15('0x61')][_0x8c15('0xd2')])){throw _0x4793de[_0x8c15('0x2d')](0x1f4)[_0x8c15('0x3f')](new db[(_0x8c15('0x94'))][(_0x8c15('0x9c'))](_0x8c15('0xd4')+_0x2c1974));}_0x588127[_0x2f92e2[_0x8c15('0x61')][_0x8c15('0xd2')]]=_0x2f92e2[_0x8c15('0x61')]['from'];})['then'](function(){return db['ChatWebsite'][_0x8c15('0x69')]({'where':{'id':_0x2f92e2[_0x8c15('0x5e')]['id']},'include':[{'model':db[_0x8c15('0xd5')],'as':_0x8c15('0xa5')},{'model':db[_0x8c15('0xd6')],'as':_0x8c15('0xd6')}]});})[_0x8c15('0x23')](handleEntityNotFound(_0x4793de,null))[_0x8c15('0x23')](function(_0x5c04b2){if(_0x5c04b2&&_0x5c04b2[_0x8c15('0xa5')]){_0x34bfe1=_0x5c04b2;var _0x4cc1ac=_['defaults'](_0x2f92e2[_0x8c15('0x61')],{'firstName':_0x2f92e2[_0x8c15('0x61')][_0x8c15('0x9b')],'phone':_0x2f92e2[_0x8c15('0x61')]['from'],'ListId':_0x5c04b2[_0x8c15('0x9a')]});_0x4cc1ac[_0x2f92e2[_0x8c15('0x61')][_0x8c15('0xd2')]]=_0x2f92e2['body']['from'];return db[_0x8c15('0xa1')][_0x8c15('0xd7')]({'where':_0x588127,'defaults':_0x4cc1ac});}})[_0x8c15('0xc0')](function(_0x405080){if(_0x405080){_0x1fa117=_0x405080;var _0xb011f0=fs[_0x8c15('0xd8')](path['join'](config['root'],_0x8c15('0xd9')),_0x8c15('0xda'));var _0x2eacb1=ejs[_0x8c15('0xdb')](_0xb011f0,{'body':_[_0x8c15('0xdc')](_0x2f92e2['body'][_0x8c15('0x61')]),'bodyTitle':_0x34bfe1[_0x8c15('0xdd')]});return db[_0x8c15('0xde')][_0x8c15('0x60')]({'body':_0x2eacb1,'ContactId':_0x405080['id'],'ChatWebsiteId':_0x34bfe1['id']});}})['then'](function(_0x2ff6b3){if(_0x2ff6b3){_0x53f4a0=_0x2ff6b3;return db[_0x8c15('0xd6')]['findOne']({'where':{'service':!![]},'include':[{'model':db[_0x8c15('0xdf')],'as':'Smtp','raw':!![]}]});}})[_0x8c15('0x23')](function(_0x375380){if(_0x375380&&_0x375380['Smtp']&&_0x34bfe1[_0x8c15('0xe0')]&&_0x34bfe1[_0x8c15('0xe1')]){var _0x8897df={'tls':{'rejectUnauthorized':![]}};if(_0x375380['Smtp'][_0x8c15('0xe2')]){_0x8897df[_0x8c15('0xe2')]=_0x375380[_0x8c15('0xe3')][_0x8c15('0xe2')];}else{_0x8897df[_0x8c15('0xe4')]=_0x375380[_0x8c15('0xe3')][_0x8c15('0xe4')];_0x8897df['port']=_0x375380[_0x8c15('0xe3')][_0x8c15('0xe5')];_0x8897df[_0x8c15('0xe6')]=_0x375380[_0x8c15('0xe3')]['secure'];}if(_0x375380['Smtp'][_0x8c15('0xe7')]){_0x8897df[_0x8c15('0xe8')]={'user':_0x375380[_0x8c15('0xe3')]['user'],'pass':_0x375380[_0x8c15('0xe3')][_0x8c15('0xe9')]};}return respondWithRpcPromise(_0x8c15('0xea'),_0x8c15('0xeb'),{'account':_0x8897df,'message':{'from':util['format'](_0x8c15('0xec'),_0x375380[_0x8c15('0x3e')],_0x375380[_0x8c15('0xed')]||_0x375380[_0x8c15('0xe3')][_0x8c15('0x62')]),'to':_0x34bfe1[_0x8c15('0xe1')],'subject':_0x34bfe1[_0x8c15('0xee')],'text':_0x53f4a0[_0x8c15('0x61')]}},client9003)[_0x8c15('0x23')](function(){return _0x53f4a0;})['catch'](function(_0x2f1da4){console[_0x8c15('0x27')](_0x2f1da4);});}})[_0x8c15('0x23')](function(){if(_0x34bfe1&&_0x34bfe1[_0x8c15('0xef')]&&_0x34bfe1[_0x8c15('0xf0')]){var _0x550c80={'from':_0x1fa117['email'],'firstName':_0x1fa117[_0x8c15('0xf1')],'lastName':_0x1fa117[_0x8c15('0xb1')],'mapKey':_0x8c15('0xed'),'message':{'from':_0x1fa117[_0x8c15('0xed')],'to':_0x34bfe1[_0x8c15('0xd6')]['email'],'cc':'','subject':_0x34bfe1[_0x8c15('0xee')],'messageId':'','sentAt':new Date(),'attach':![],'attachments':[],'originChannel':_0x8c15('0xf2'),'ChatWebsiteId':_0x34bfe1['id'],'ChatOfflineMessageId':_0x53f4a0['id'],'originTo':_0x34bfe1[_0x8c15('0xd6')][_0x8c15('0xed')]},'body':_0x53f4a0[_0x8c15('0x61')]};var _0xe82550={'account':{'id':_0x34bfe1[_0x8c15('0xf0')]},'body':_0x550c80,'log':'NotifyMailAccount'};return respondWithRpcPromise(_0x8c15('0xf3'),_0x8c15('0xf4'),_0xe82550,client9001)[_0x8c15('0x23')](function(){return _0x53f4a0;})[_0x8c15('0x2c')](function(_0x8d42dc){console[_0x8c15('0x27')](_0x8d42dc);});}return;})['then'](function(){if(_0x53f4a0){return _0x53f4a0;}})[_0x8c15('0x23')](respondWithResult(_0x4793de,null))[_0x8c15('0x2c')](handleError(_0x4793de,null));};exports[_0x8c15('0xf5')]=function(_0x35e490,_0x1c1bb4,_0x298b92){return db[_0x8c15('0xbc')][_0x8c15('0x69')]({'where':{'id':_0x35e490[_0x8c15('0x5e')]['id']}})['then'](handleEntityNotFound(_0x1c1bb4,null))[_0x8c15('0x23')](function(_0x1791a5){if(_0x1791a5){return _0x1791a5[_0x8c15('0xf5')](_0x35e490[_0x8c15('0x61')][_0x8c15('0x70')],_['omit'](_0x35e490[_0x8c15('0x61')],['ids','id'])||{});}})[_0x8c15('0x23')](respondWithResult(_0x1c1bb4,null))[_0x8c15('0x2c')](handleError(_0x1c1bb4,null));};exports[_0x8c15('0xf6')]=function(_0x10042d,_0x418718,_0x4e1e49){var _0x30b631={'raw':![],'where':{}};var _0x5aaceb={};var _0x184801={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x10042d[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x418718,null))[_0x8c15('0x23')](function(_0x1b91c6){if(_0x1b91c6){_0x5aaceb['model']=_['keys'](db['ChatInteraction'][_0x8c15('0x45')]);_0x5aaceb[_0x8c15('0x49')]=_['keys'](_0x10042d[_0x8c15('0x49')]);_0x5aaceb[_0x8c15('0x55')]=_[_0x8c15('0x4c')](_0x5aaceb[_0x8c15('0x48')],_0x5aaceb[_0x8c15('0x49')]);_0x30b631['attributes']=_[_0x8c15('0x4c')](_0x5aaceb[_0x8c15('0x48')],qs[_0x8c15('0x4d')](_0x10042d[_0x8c15('0x49')]['fields']));_0x30b631[_0x8c15('0x4b')]=_0x30b631[_0x8c15('0x4b')][_0x8c15('0x4e')]?_0x30b631[_0x8c15('0x4b')]:_0x5aaceb['model'];if(!_0x10042d['query'][_0x8c15('0x4f')]('nolimit')){_0x30b631[_0x8c15('0x30')]=qs[_0x8c15('0x30')](_0x10042d[_0x8c15('0x49')][_0x8c15('0x30')]);_0x30b631[_0x8c15('0x2f')]=qs[_0x8c15('0x2f')](_0x10042d[_0x8c15('0x49')][_0x8c15('0x2f')]);}_0x30b631[_0x8c15('0x51')]=qs[_0x8c15('0x52')](_0x10042d['query'][_0x8c15('0x52')]);_0x30b631[_0x8c15('0x53')]=qs[_0x8c15('0x55')](_[_0x8c15('0x54')](_0x10042d['query'],_0x5aaceb[_0x8c15('0x55')]));_0x30b631['where'][_0x8c15('0x6c')]=_0x1b91c6['id'];if(_0x10042d[_0x8c15('0x49')][_0x8c15('0x56')]){_0x30b631[_0x8c15('0x53')]=_['merge'](_0x30b631[_0x8c15('0x53')],{'$or':_[_0x8c15('0x43')](_0x30b631[_0x8c15('0x4b')],function(_0x245995){var _0x5b0170={};_0x5b0170[_0x245995]={'$like':'%'+_0x10042d[_0x8c15('0x49')][_0x8c15('0x56')]+'%'};return _0x5b0170;})});}_0x30b631=_[_0x8c15('0x57')]({},_0x30b631,_0x10042d[_0x8c15('0x59')]);return db[_0x8c15('0xbc')]['count']({'where':_0x30b631['where']})[_0x8c15('0x23')](function(_0x3c9ad0){_0x184801[_0x8c15('0x2e')]=_0x3c9ad0;if(_0x10042d[_0x8c15('0x49')][_0x8c15('0x5a')]){_0x30b631[_0x8c15('0x5f')]=[{'model':db['CmContact'],'as':_0x8c15('0xf7'),'required':![]},{'model':db[_0x8c15('0xca')],'as':_0x8c15('0xf8'),'attributes':[_0x8c15('0x3e'),'fullname',_0x8c15('0xf9')],'required':![]},{'model':db['Tag'],'as':_0x8c15('0xfa'),'attributes':['id',_0x8c15('0x3e'),_0x8c15('0xfb')],'where':_0x10042d['query']['tag']?{'id':_0x10042d[_0x8c15('0x49')][_0x8c15('0xfc')]}:undefined,'required':_0x10042d['query'][_0x8c15('0xfc')]?!![]:![]}];}return db[_0x8c15('0xbc')]['findAll'](_0x30b631);})[_0x8c15('0x23')](function(_0x32cbc2){_0x184801[_0x8c15('0x5c')]=_0x32cbc2;return _0x184801;});}})[_0x8c15('0x23')](respondWithFilteredResult(_0x418718,_0x30b631))[_0x8c15('0x2c')](handleError(_0x418718,null));};function iftimePromise(_0x50d2d1,_0x258212){return respondWithRpcPromise(_0x8c15('0xfd'),_0x8c15('0xfe'),{'command':_0x258212[_0x8c15('0xff')]?util['format'](_0x8c15('0x100'),_0x50d2d1[_0x8c15('0x101')],_0x258212['timezone']):util[_0x8c15('0xb5')](_0x8c15('0x102'),_0x50d2d1[_0x8c15('0x101')])},client9002)['then'](function(_0x169384){var _0xf9cbd7=_0x169384&&_0x169384[_0x8c15('0x103')](_0x8c15('0x104'))>=0x0?!![]:![];logger['info'](_0x8c15('0x105'),_0x258212['id'],_0x50d2d1['id'],_0x50d2d1[_0x8c15('0x101')],_0xf9cbd7?_0x8c15('0x106'):_0x8c15('0x107'),_0x258212['timezone']?_0x258212['timezone']:_0x8c15('0x108'));return _0xf9cbd7;})['catch'](function(_0x26a9a1){logger[_0x8c15('0x27')](_0x8c15('0x105'),_0x258212['id'],_0x50d2d1['id'],_0x50d2d1[_0x8c15('0x101')],util[_0x8c15('0x109')](_0x26a9a1,{'showHidden':![],'depth':null}),_0x258212[_0x8c15('0xff')]?_0x258212['timezone']:'No\x20timezone');return![];});}exports[_0x8c15('0xfe')]=function(_0x437738,_0x13509c,_0x3a96f8){var _0x175a71=0x0;var _0x37521d=0x0;var _0x4117fd=![];var _0xf9e44b;var _0x219619;return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x437738[_0x8c15('0x5e')]['id']},'include':[{'model':db[_0x8c15('0x10a')],'as':_0x8c15('0x10a'),'include':[{'model':db['Interval'],'as':_0x8c15('0x10b'),'attributes':['id',_0x8c15('0x101')],'raw':!![]}]}]})['then'](handleEntityNotFound(_0x13509c,null))[_0x8c15('0x23')](function(_0x527a45){if(_0x527a45){_0xf9e44b=_0x527a45;return _0x527a45[_0x8c15('0x10c')]({'raw':!![]});}})[_0x8c15('0x23')](function(_0x172cab){if(_0xf9e44b){if(_0x172cab){_0x219619=_0x172cab;}}return require(_0x8c15('0x18'))[_0x8c15('0x84')]();})[_0x8c15('0x23')](function(_0x340809){if(_0x340809){_0x37521d=_0x340809[_0x8c15('0x10d')];_0x4117fd=_0x340809[_0x8c15('0x85')];}})[_0x8c15('0x23')](function(){return db[_0x8c15('0xbc')][_0x8c15('0x2e')]({'where':{'closed':![]}});})[_0x8c15('0x23')](function(_0xadbc94){_0x175a71=_0xadbc94;if(_0x37521d&&_0xadbc94>_0x37521d){return db['License'][_0x8c15('0x73')]({'where':{'id':0x1}})[_0x8c15('0x23')](function(_0x19a81b){if(_0x19a81b){_0x19a81b['increment'](_0x8c15('0x10e'));}});}})[_0x8c15('0x23')](function(){if(_0xf9e44b['Interval']&&_0xf9e44b[_0x8c15('0x10a')]['Intervals']){var _0x235ce6=[];for(var _0x3070f7=0x0;_0x3070f7<_0xf9e44b['Interval'][_0x8c15('0x10b')][_0x8c15('0x4e')];_0x3070f7++){var _0x1e99d9=_0xf9e44b[_0x8c15('0x10a')][_0x8c15('0x10b')][_0x3070f7][_0x8c15('0x38')]({'plain':!![]});_0x235ce6[_0x8c15('0x10f')](iftimePromise(_0x1e99d9,_0xf9e44b));}return BPromise[_0x8c15('0x110')](_0x235ce6)[_0x8c15('0x23')](function(_0x15d34f){return _['some'](_0x15d34f);});}else{return!![];}})['then'](function(_0x42e4b6){var _0x1e02f6=fs[_0x8c15('0xd8')](path[_0x8c15('0x81')](config[_0x8c15('0x82')],_0x8c15('0x111')),_0x8c15('0xda'));var _0x39eec7={'remote':_0xf9e44b['remote'],'query':querystring[_0x8c15('0x26')](_[_0x8c15('0x57')](_0xf9e44b[_0x8c15('0x38')]({'plain':!![]}),{'customerIp':_0x437738[_0x8c15('0x91')][_0x8c15('0xaf')]||_0x437738['headers'][_0x8c15('0x112')]||_0x437738[_0x8c15('0x113')][_0x8c15('0x114')]||_0x437738['ip'],'referer':_0x437738[_0x8c15('0x91')][_0x8c15('0x115')],'openedInteractions':_0x175a71,'maxInteractions':_0x37521d,'virtual':_0x4117fd[_0x8c15('0x10d')],'online':_0x42e4b6,'custom':_0x4117fd}))[_0x8c15('0x116')](/'/g,'\x5c\x27')};_0x13509c[_0x8c15('0x3f')](ejs[_0x8c15('0xdb')](Mustache[_0x8c15('0xdb')](_0x1e02f6,_0x39eec7),{'proactiveActions':_0x219619,'alignment':_0xf9e44b['alignment'],'verticalAlignment':_0xf9e44b[_0x8c15('0x117')],'div_color':_0xf9e44b[_0x8c15('0xfb')],'text_color':_0xf9e44b['textColor']}));})[_0x8c15('0x2c')](handleError(_0x13509c,null));};exports[_0x8c15('0x118')]=function(_0x55925d,_0x3e5de6,_0x20c1ff){return db['ChatWebsite'][_0x8c15('0x73')]({'where':{'id':_0x55925d['params']['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x3e5de6,null))[_0x8c15('0x23')](function(_0x1c6f2f){if(_0x1c6f2f){return db[_0x8c15('0x119')][_0x8c15('0x11a')](function(_0x8600ed){return db[_0x8c15('0xa3')][_0x8c15('0x37')]({'where':{'ChatWebsiteId':_0x55925d[_0x8c15('0x5e')]['id']},'transaction':_0x8600ed})['then'](function(_0xe314bc){var _0x357025=_[_0x8c15('0x43')](_0x55925d[_0x8c15('0x61')],function(_0x1d63cb){_0x1d63cb[_0x8c15('0x6c')]=_0x55925d[_0x8c15('0x5e')]['id'];return _0x1d63cb;});return db[_0x8c15('0xa3')]['bulkCreate'](_0x357025,{'transaction':_0x8600ed});});})[_0x8c15('0x23')](function(){return db[_0x8c15('0xa3')]['findAndCountAll']({'where':{'ChatWebsiteId':_0x55925d['params']['id']},'order':_0x8c15('0xaa')});});}})[_0x8c15('0x23')](respondWithResult(_0x3e5de6,null))[_0x8c15('0x2c')](handleError(_0x3e5de6,null));};exports['getApplications']=function(_0x3fff75,_0x47a795,_0x42e143){var _0x22474a={};var _0x3de1dc={};var _0x1f0063;var _0x39a7c1;return db[_0x8c15('0x44')]['findOne']({'where':{'id':_0x3fff75[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x47a795,null))[_0x8c15('0x23')](function(_0x3b8a90){if(_0x3b8a90){_0x1f0063=_0x3b8a90;_0x3de1dc[_0x8c15('0x48')]=_[_0x8c15('0x4a')](db['ChatApplication'][_0x8c15('0x45')]);_0x3de1dc[_0x8c15('0x49')]=_[_0x8c15('0x4a')](_0x3fff75[_0x8c15('0x49')]);_0x3de1dc['filters']=_[_0x8c15('0x4c')](_0x3de1dc['model'],_0x3de1dc[_0x8c15('0x49')]);_0x22474a[_0x8c15('0x4b')]=_[_0x8c15('0x4c')](_0x3de1dc['model'],qs[_0x8c15('0x4d')](_0x3fff75[_0x8c15('0x49')][_0x8c15('0x4d')]));_0x22474a['attributes']=_0x22474a[_0x8c15('0x4b')]['length']?_0x22474a[_0x8c15('0x4b')]:_0x3de1dc['model'];_0x22474a[_0x8c15('0x51')]=qs[_0x8c15('0x52')](_0x3fff75[_0x8c15('0x49')][_0x8c15('0x52')]);_0x22474a[_0x8c15('0x53')]=qs[_0x8c15('0x55')](_[_0x8c15('0x54')](_0x3fff75[_0x8c15('0x49')],_0x3de1dc[_0x8c15('0x55')]));if(_0x3fff75[_0x8c15('0x49')][_0x8c15('0x56')]){_0x22474a[_0x8c15('0x53')]=_[_0x8c15('0x57')](_0x22474a['where'],{'$or':_['map'](_0x22474a[_0x8c15('0x4b')],function(_0x566258){var _0x26742b={};_0x26742b[_0x566258]={'$like':'%'+_0x3fff75[_0x8c15('0x49')]['filter']+'%'};return _0x26742b;})});}_0x22474a=_['merge']({},_0x22474a,_0x3fff75[_0x8c15('0x59')]);return _0x1f0063[_0x8c15('0x11b')](_0x22474a);}})[_0x8c15('0x23')](function(_0x33014f){if(_0x33014f){_0x39a7c1=_0x33014f[_0x8c15('0x4e')];if(!_0x3fff75['query']['hasOwnProperty'](_0x8c15('0x50'))){_0x22474a['limit']=qs[_0x8c15('0x30')](_0x3fff75['query']['limit']);_0x22474a[_0x8c15('0x2f')]=qs[_0x8c15('0x2f')](_0x3fff75[_0x8c15('0x49')][_0x8c15('0x2f')]);}return _0x1f0063[_0x8c15('0x11b')](_0x22474a);}})['then'](function(_0x2777b7){if(_0x2777b7){return _0x2777b7?{'count':_0x39a7c1,'rows':_0x2777b7}:null;}})['then'](respondWithResult(_0x47a795,null))[_0x8c15('0x2c')](handleError(_0x47a795,null));};exports[_0x8c15('0x11c')]=function(_0x3c2df0,_0xf33775,_0x37a4e2){return db[_0x8c15('0x11d')]['find']({'where':{'id':_0x3c2df0[_0x8c15('0x5e')]['id']}})['then'](handleEntityNotFound(_0xf33775,null))[_0x8c15('0x23')](function(_0x84e09f){if(_0x84e09f){return _0x84e09f[_0x8c15('0x11c')](_0x3c2df0[_0x8c15('0x61')][_0x8c15('0x70')],_[_0x8c15('0x11e')](_0x3c2df0[_0x8c15('0x61')],[_0x8c15('0x70'),'id'])||{});}})[_0x8c15('0x23')](respondWithResult(_0xf33775,null))[_0x8c15('0x2c')](handleError(_0xf33775,null));};exports[_0x8c15('0x10c')]=function(_0x1b18b8,_0x161557,_0x2a3a5b){var _0x127d6f={};var _0x587c14={};var _0x422aaa;var _0xd71248;return db[_0x8c15('0x44')][_0x8c15('0x73')]({'where':{'id':_0x1b18b8['params']['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x161557,null))['then'](function(_0x2ea789){if(_0x2ea789){_0x422aaa=_0x2ea789;_0x587c14[_0x8c15('0x48')]=_[_0x8c15('0x4a')](db[_0x8c15('0x11f')][_0x8c15('0x45')]);_0x587c14['query']=_['keys'](_0x1b18b8['query']);_0x587c14[_0x8c15('0x55')]=_[_0x8c15('0x4c')](_0x587c14['model'],_0x587c14[_0x8c15('0x49')]);_0x127d6f[_0x8c15('0x4b')]=_[_0x8c15('0x4c')](_0x587c14[_0x8c15('0x48')],qs[_0x8c15('0x4d')](_0x1b18b8[_0x8c15('0x49')]['fields']));_0x127d6f[_0x8c15('0x4b')]=_0x127d6f[_0x8c15('0x4b')][_0x8c15('0x4e')]?_0x127d6f[_0x8c15('0x4b')]:_0x587c14['model'];_0x127d6f['order']=qs['sort'](_0x1b18b8['query'][_0x8c15('0x52')]);_0x127d6f[_0x8c15('0x53')]=qs[_0x8c15('0x55')](_['pick'](_0x1b18b8[_0x8c15('0x49')],_0x587c14[_0x8c15('0x55')]));if(_0x1b18b8['query']['filter']){_0x127d6f[_0x8c15('0x53')]=_[_0x8c15('0x57')](_0x127d6f[_0x8c15('0x53')],{'$or':_[_0x8c15('0x43')](_0x127d6f[_0x8c15('0x4b')],function(_0x588083){var _0x579f1c={};_0x579f1c[_0x588083]={'$like':'%'+_0x1b18b8[_0x8c15('0x49')][_0x8c15('0x56')]+'%'};return _0x579f1c;})});}_0x127d6f=_[_0x8c15('0x57')]({},_0x127d6f,_0x1b18b8[_0x8c15('0x59')]);return _0x422aaa['getProactiveActions'](_0x127d6f);}})[_0x8c15('0x23')](function(_0x5d863a){if(_0x5d863a){_0xd71248=_0x5d863a['length'];if(!_0x1b18b8['query'][_0x8c15('0x4f')](_0x8c15('0x50'))){_0x127d6f['limit']=qs[_0x8c15('0x30')](_0x1b18b8['query'][_0x8c15('0x30')]);_0x127d6f[_0x8c15('0x2f')]=qs['offset'](_0x1b18b8[_0x8c15('0x49')][_0x8c15('0x2f')]);}return _0x422aaa['getProactiveActions'](_0x127d6f);}})[_0x8c15('0x23')](function(_0x444527){if(_0x444527){return _0x444527?{'count':_0xd71248,'rows':_0x444527}:null;}})[_0x8c15('0x23')](respondWithResult(_0x161557,null))['catch'](handleError(_0x161557,null));};exports['getFields']=function(_0x3b0618,_0x1b1d43,_0x594c79){var _0x22f5d4=_0x3b0618[_0x8c15('0x49')][_0x8c15('0x120')]==='false'?_0x8c15('0x121'):'onlineForm';return db[_0x8c15('0x44')][_0x8c15('0x69')]({'attributes':['id',_0x22f5d4],'where':{'id':_0x3b0618[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x1b1d43,null))['then'](function(_0x201298){if(_0x201298){var _0x26dc73=_0x201298[_0x22f5d4];var _0x6a6cb2=_0x26dc73&&_0x26dc73[_0x8c15('0x122')]?_0x26dc73['items']:[];_0x1b1d43['send']({'fromKey':_[_0x8c15('0x8a')](_0x26dc73['fromKey'])?undefined:_0x26dc73['fromKey'],'count':_0x6a6cb2[_0x8c15('0x4e')],'rows':_0x6a6cb2});}})['catch'](handleError(_0x1b1d43,null));};exports[_0x8c15('0x123')]=function(_0x1e9edf,_0x13df9f,_0x3f5b14){var _0x23dd70={'raw':![],'where':{}};var _0x4c1937={};var _0x23ec32={'count':0x0,'rows':[]};return db[_0x8c15('0x44')][_0x8c15('0x73')]({'where':{'id':_0x1e9edf[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x13df9f,null))['then'](function(_0x88fef8){if(_0x88fef8){_0x4c1937[_0x8c15('0x48')]=_[_0x8c15('0x4a')](db[_0x8c15('0xde')]['rawAttributes']);_0x4c1937[_0x8c15('0x49')]=_[_0x8c15('0x4a')](_0x1e9edf[_0x8c15('0x49')]);_0x4c1937[_0x8c15('0x55')]=_[_0x8c15('0x4c')](_0x4c1937[_0x8c15('0x48')],_0x4c1937[_0x8c15('0x49')]);_0x23dd70[_0x8c15('0x4b')]=_[_0x8c15('0x4c')](_0x4c1937[_0x8c15('0x48')],qs[_0x8c15('0x4d')](_0x1e9edf[_0x8c15('0x49')][_0x8c15('0x4d')]));_0x23dd70[_0x8c15('0x4b')]=_0x23dd70[_0x8c15('0x4b')][_0x8c15('0x4e')]?_0x23dd70[_0x8c15('0x4b')]:_0x4c1937[_0x8c15('0x48')];if(!_0x1e9edf[_0x8c15('0x49')]['hasOwnProperty'](_0x8c15('0x50'))){_0x23dd70[_0x8c15('0x30')]=qs[_0x8c15('0x30')](_0x1e9edf[_0x8c15('0x49')][_0x8c15('0x30')]);_0x23dd70[_0x8c15('0x2f')]=qs['offset'](_0x1e9edf[_0x8c15('0x49')]['offset']);}_0x23dd70[_0x8c15('0x51')]=qs[_0x8c15('0x52')](_0x1e9edf[_0x8c15('0x49')][_0x8c15('0x52')]);_0x23dd70[_0x8c15('0x53')]=qs['filters'](_[_0x8c15('0x54')](_0x1e9edf[_0x8c15('0x49')],_0x4c1937[_0x8c15('0x55')]));_0x23dd70['where'][_0x8c15('0x6c')]=_0x88fef8['id'];if(_0x1e9edf[_0x8c15('0x49')]['filter']){_0x23dd70[_0x8c15('0x53')]=_['merge'](_0x23dd70[_0x8c15('0x53')],{'$or':_['map'](_0x23dd70[_0x8c15('0x4b')],function(_0x472bcd){var _0xae5e74={};_0xae5e74[_0x472bcd]={'$like':'%'+_0x1e9edf[_0x8c15('0x49')][_0x8c15('0x56')]+'%'};return _0xae5e74;})});}_0x23dd70=_['merge']({},_0x23dd70,_0x1e9edf['options']);return db[_0x8c15('0xde')][_0x8c15('0x2e')]({'where':_0x23dd70[_0x8c15('0x53')]})[_0x8c15('0x23')](function(_0x18f6ae){_0x23ec32[_0x8c15('0x2e')]=_0x18f6ae;if(_0x1e9edf[_0x8c15('0x49')][_0x8c15('0x5a')]){_0x23dd70[_0x8c15('0x5f')]=[{'all':!![]}];}else{_0x23dd70['include']=[{'model':db[_0x8c15('0xa1')],'as':_0x8c15('0xf7'),'required':![]}];}return db[_0x8c15('0xde')][_0x8c15('0x5b')](_0x23dd70);})['then'](function(_0x4759ab){_0x23ec32[_0x8c15('0x5c')]=_0x4759ab;return _0x23ec32;});}})['then'](respondWithFilteredResult(_0x13df9f,_0x23dd70))[_0x8c15('0x2c')](handleError(_0x13df9f,null));};exports['addAgents']=function(_0x390e74,_0x227bc1,_0x52733b){return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x390e74[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x227bc1,null))[_0x8c15('0x23')](function(_0x239125){if(_0x239125){return _0x239125[_0x8c15('0x124')](_0x390e74['body'][_0x8c15('0x70')],_[_0x8c15('0x11e')](_0x390e74[_0x8c15('0x61')],[_0x8c15('0x70'),'id'])||{})[_0x8c15('0xc0')](function(_0x59d18a){for(var _0x4296c6=0x0;_0x4296c6<_0x390e74[_0x8c15('0x61')][_0x8c15('0x70')][_0x8c15('0x4e')];_0x4296c6+=0x1){socket['emit']('userChatWebsite:save',{'UserId':_0x390e74[_0x8c15('0x61')]['ids'][_0x4296c6],'ChatWebsiteId':_0x390e74[_0x8c15('0x5e')]['id']});}return _0x59d18a;});}})[_0x8c15('0x23')](respondWithResult(_0x227bc1,null))[_0x8c15('0x2c')](handleError(_0x227bc1,null));};exports[_0x8c15('0x125')]=function(_0x50af8a,_0x22c40c,_0x40fa93){return db[_0x8c15('0x44')][_0x8c15('0x69')]({'where':{'id':_0x50af8a[_0x8c15('0x5e')]['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x22c40c,null))[_0x8c15('0x23')](function(_0xb45048){if(_0xb45048){return _0xb45048[_0x8c15('0x125')](_0x50af8a[_0x8c15('0x49')][_0x8c15('0x70')])['then'](function(){if(_[_0x8c15('0x126')](_0x50af8a['query']['ids'])){for(var _0x13f464=0x0;_0x13f464<_0x50af8a[_0x8c15('0x49')]['ids'][_0x8c15('0x4e')];_0x13f464+=0x1){socket['emit']('userChatWebsite:remove',{'UserId':Number(_0x50af8a[_0x8c15('0x49')][_0x8c15('0x70')][_0x13f464]),'ChatWebsiteId':Number(_0x50af8a[_0x8c15('0x5e')]['id'])});}}else{socket['emit'](_0x8c15('0x127'),{'UserId':Number(_0x50af8a[_0x8c15('0x49')][_0x8c15('0x70')]),'ChatWebsiteId':Number(_0x50af8a['params']['id'])});}});}})[_0x8c15('0x23')](respondWithStatusCode(_0x22c40c,null))[_0x8c15('0x2c')](handleError(_0x22c40c,null));};exports[_0x8c15('0x128')]=function(_0xf2aec1,_0x33c63b,_0xa69415){var _0xb32708={};var _0x5c68cf={};var _0x2eb72a;var _0x1a71c2;return db[_0x8c15('0x44')][_0x8c15('0x73')]({'where':{'id':_0xf2aec1['params']['id']}})[_0x8c15('0x23')](handleEntityNotFound(_0x33c63b,null))['then'](function(_0xa331df){if(_0xa331df){_0x2eb72a=_0xa331df;_0x5c68cf[_0x8c15('0x48')]=_[_0x8c15('0x4a')](db[_0x8c15('0xca')][_0x8c15('0x45')]);_0x5c68cf['query']=_[_0x8c15('0x4a')](_0xf2aec1[_0x8c15('0x49')]);_0x5c68cf[_0x8c15('0x55')]=_[_0x8c15('0x4c')](_0x5c68cf[_0x8c15('0x48')],_0x5c68cf[_0x8c15('0x49')]);_0xb32708[_0x8c15('0x4b')]=_[_0x8c15('0x4c')](_0x5c68cf[_0x8c15('0x48')],qs[_0x8c15('0x4d')](_0xf2aec1[_0x8c15('0x49')][_0x8c15('0x4d')]));_0xb32708[_0x8c15('0x4b')]=_0xb32708['attributes'][_0x8c15('0x4e')]?_0xb32708[_0x8c15('0x4b')]:_0x5c68cf['model'];_0xb32708[_0x8c15('0x51')]=qs[_0x8c15('0x52')](_0xf2aec1[_0x8c15('0x49')]['sort']);_0xb32708[_0x8c15('0x53')]=qs['filters'](_['pick'](_0xf2aec1[_0x8c15('0x49')],_0x5c68cf[_0x8c15('0x55')]));if(_0xf2aec1[_0x8c15('0x49')]['filter']){_0xb32708[_0x8c15('0x53')]=_[_0x8c15('0x57')](_0xb32708[_0x8c15('0x53')],{'$or':_[_0x8c15('0x43')](_0xb32708['attributes'],function(_0x40676a){var _0x5f12c2={};_0x5f12c2[_0x40676a]={'$like':'%'+_0xf2aec1['query'][_0x8c15('0x56')]+'%'};return _0x5f12c2;})});}_0xb32708=_[_0x8c15('0x57')]({},_0xb32708,_0xf2aec1[_0x8c15('0x59')]);return _0x2eb72a[_0x8c15('0x128')](_0xb32708);}})[_0x8c15('0x23')](function(_0x54f897){if(_0x54f897){_0x1a71c2=_0x54f897['length'];if(!_0xf2aec1[_0x8c15('0x49')][_0x8c15('0x4f')](_0x8c15('0x50'))){_0xb32708[_0x8c15('0x30')]=qs[_0x8c15('0x30')](_0xf2aec1['query']['limit']);_0xb32708[_0x8c15('0x2f')]=qs[_0x8c15('0x2f')](_0xf2aec1['query'][_0x8c15('0x2f')]);}return _0x2eb72a[_0x8c15('0x128')](_0xb32708);}})[_0x8c15('0x23')](function(_0x43ee4a){if(_0x43ee4a){return _0x43ee4a?{'count':_0x1a71c2,'rows':_0x43ee4a}:null;}})[_0x8c15('0x23')](respondWithResult(_0x33c63b,null))[_0x8c15('0x2c')](handleError(_0x33c63b,null));};
\ No newline at end of file