Built motion from commit (unavailable).|2.2.0
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index 27624af..002fb39 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe9d6=['ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','addLogo','sitepic','filename','addAvatar','agentAvatar','file','addCustomerAvatar','customerAvatar','addSystemAvatar','systemAvatar','join','server/files/images/logos/default_logo.png','../../config/license/util','getLicense','custom','isNil','existsSync','root','server/files/images/logos/','download','getAvatar','server/files/images/avatars/default_avatar.png','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','getSystemAvatar','notify','user-agent-parser','setUA','user-agent','getResult','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','createdAt','updatedAt','difference','ListId','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','Contacts','DESC','ChatApplication','Applications','account','list','applications','orderBy','priority','asc','contact','firstName','lastName','customerIp','referer','browser','version','format','%s\x20%s','unknown','vendor','device','type','threadId','ChatInteraction','interaction','spread','messageId','created','autoclose','push','unmanaged','*,*,*,*','ChatMessage','AttachmentId','UserId','User','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','offline','CompanyId','mapKeyOffline','includes','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','toPairs','ChatOfflineMessage','MailAccount','MailServerOut','Smtp','forwardOfflineAddress','service','host','secure','authentication','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','omit','getInteractions','Owner','fullname','internal','Tag','Tags','color','tag','Command','getSnippet','timezone','iftime\x20%s,%s','iftime\x20%s','interval','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','No\x20timezone','Interval','getProactiveActions','License','chatLicenseExceeded','Intervals','some','server/files/chat/iframe.js','headers','x-forwarded-for','x-real-ip','connection','remoteAddress','virtual','replace','render','alignment','verticalAlignment','addApplications','transaction','findAndCountAll','getApplications','addProactiveActions','chatProactiveAction','ChatProactiveAction','getFields','online','false','onlineForm','items','fromKey','addAgents','emit','removeAgents','userChatWebsite:remove','getAgents','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','./chatWebsite.socket','register','jayson/promise','client','http','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','status','json','count','offset','limit','Content-Range','apply','save','update','destroy','get','ChatWebsites','UserProfileResource','end','sendStatus','stack','name','send','rawAttributes','keys','query','dateEnd','filters','model','attributes','intersection','fields','hasOwnProperty','nolimit','order','sort','pick','add','day','dateStart','where','merge','map','filter','options','includeAll','include','ChatWebsite','findAll','rows','show','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','Disposition','getDispositions','findOne','length','ChatWebsiteId'];(function(_0x51ed62,_0x574379){var _0x34aee3=function(_0x2958bc){while(--_0x2958bc){_0x51ed62['push'](_0x51ed62['shift']());}};_0x34aee3(++_0x574379);}(_0xe9d6,0x1c7));var _0x6e9d=function(_0x3ce51e,_0x3789d7){_0x3ce51e=_0x3ce51e-0x0;var _0x45c999=_0xe9d6[_0x3ce51e];return _0x45c999;};'use strict';var pdf=require(_0x6e9d('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x6e9d('0x1'));var zipdir=require(_0x6e9d('0x2'));var jsonpatch=require(_0x6e9d('0x3'));var rp=require(_0x6e9d('0x4'));var moment=require(_0x6e9d('0x5'));var BPromise=require(_0x6e9d('0x6'));var Mustache=require(_0x6e9d('0x7'));var util=require(_0x6e9d('0x8'));var path=require('path');var sox=require(_0x6e9d('0x9'));var csv=require(_0x6e9d('0xa'));var ejs=require(_0x6e9d('0xb'));var fs=require('fs');var _=require(_0x6e9d('0xc'));var squel=require(_0x6e9d('0xd'));var crypto=require('crypto');var jsforce=require(_0x6e9d('0xe'));var deskjs=require(_0x6e9d('0xf'));var toCsv=require(_0x6e9d('0xa'));var querystring=require(_0x6e9d('0x10'));var Papa=require(_0x6e9d('0x11'));var Redis=require(_0x6e9d('0x12'));var qs=require('../../components/parsers/qs');var logger=require('../../config/logger')('api');var utils=require(_0x6e9d('0x13'));var config=require(_0x6e9d('0x14'));var db=require(_0x6e9d('0x15'))['db'];config[_0x6e9d('0x16')]=_[_0x6e9d('0x17')](config[_0x6e9d('0x16')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x6e9d('0x16')]));require(_0x6e9d('0x18'))[_0x6e9d('0x19')](socket);var jayson=require(_0x6e9d('0x1a'));var client=jayson[_0x6e9d('0x1b')]['http']({'port':0x232c});var client9002=jayson[_0x6e9d('0x1b')]['http']({'port':0x232a});var client9003=jayson[_0x6e9d('0x1b')][_0x6e9d('0x1c')]({'port':0x232b});function respondWithRpcPromise(_0x442a7e,_0x596eec,_0x429012,_0x5531b7){return new BPromise(function(_0x537459,_0x2bfdbc){var _0x87ae3d=_0x5531b7||client;return _0x87ae3d[_0x6e9d('0x1d')](_0x442a7e,_0x429012)[_0x6e9d('0x1e')](function(_0x2091c6){logger[_0x6e9d('0x1f')](_0x6e9d('0x20'),_0x596eec,_0x6e9d('0x21'));logger[_0x6e9d('0x22')](_0x6e9d('0x23'),_0x596eec,_0x6e9d('0x21'),JSON[_0x6e9d('0x24')](_0x2091c6));if(_0x2091c6[_0x6e9d('0x25')]){if(_0x2091c6[_0x6e9d('0x25')]['code']===0x1f4){logger['error'](_0x6e9d('0x20'),_0x596eec,_0x2091c6[_0x6e9d('0x25')][_0x6e9d('0x26')]);return _0x2bfdbc(_0x2091c6[_0x6e9d('0x25')][_0x6e9d('0x26')]);}logger[_0x6e9d('0x25')](_0x6e9d('0x20'),_0x596eec,_0x2091c6[_0x6e9d('0x25')][_0x6e9d('0x26')]);return _0x537459(_0x2091c6['error'][_0x6e9d('0x26')]);}else{logger[_0x6e9d('0x1f')](_0x6e9d('0x20'),_0x596eec,_0x6e9d('0x21'));_0x537459(_0x2091c6[_0x6e9d('0x27')][_0x6e9d('0x26')]);}})[_0x6e9d('0x28')](function(_0x31c2ea){logger[_0x6e9d('0x25')](_0x6e9d('0x20'),_0x596eec,_0x31c2ea);_0x2bfdbc(_0x31c2ea);});});}function respondWithStatusCode(_0x5ca0b8,_0x30ebf1){_0x30ebf1=_0x30ebf1||0xcc;return function(_0x36fca6){if(_0x36fca6){return _0x5ca0b8['sendStatus'](_0x30ebf1);}return _0x5ca0b8['status'](_0x30ebf1)['end']();};}function respondWithResult(_0x49a5d9,_0x421f9a){_0x421f9a=_0x421f9a||0xc8;return function(_0x892610){if(_0x892610){return _0x49a5d9[_0x6e9d('0x29')](_0x421f9a)[_0x6e9d('0x2a')](_0x892610);}};}function respondWithFilteredResult(_0x43d09e,_0x1eec53){return function(_0x4b6421){if(_0x4b6421){var _0x24911f=_0x4b6421[_0x6e9d('0x2b')],_0x3dba1=_0x1eec53[_0x6e9d('0x2c')],_0x3cb52b=_0x1eec53[_0x6e9d('0x2c')]+_0x1eec53[_0x6e9d('0x2d')],_0x71c525;if(_0x3cb52b>=_0x24911f){_0x3cb52b=_0x24911f;_0x71c525=0xc8;}else{_0x71c525=0xce;}_0x43d09e[_0x6e9d('0x29')](_0x71c525);return _0x43d09e['set'](_0x6e9d('0x2e'),_0x3dba1+'-'+_0x3cb52b+'/'+_0x24911f)[_0x6e9d('0x2a')](_0x4b6421);}return null;};}function patchUpdates(_0x4624c3){return function(_0x21556a){try{jsonpatch[_0x6e9d('0x2f')](_0x21556a,_0x4624c3,!![]);}catch(_0x47292c){return BPromise['reject'](_0x47292c);}return _0x21556a[_0x6e9d('0x30')]();};}function saveUpdates(_0x37ce45,_0x2d68eb){return function(_0x2a6d6b){if(_0x2a6d6b){return _0x2a6d6b[_0x6e9d('0x31')](_0x37ce45)['then'](function(_0x3ce96e){return _0x3ce96e;});}return null;};}function removeEntity(_0x2857cd,_0x2d8b38){return function(_0x48d91a){if(_0x48d91a){return _0x48d91a[_0x6e9d('0x32')]()[_0x6e9d('0x1e')](function(){var _0x4f928a=_0x48d91a[_0x6e9d('0x33')]({'plain':!![]});var _0x266cde=_0x6e9d('0x34');return db[_0x6e9d('0x35')]['destroy']({'where':{'type':_0x266cde,'resourceId':_0x4f928a['id']}})[_0x6e9d('0x1e')](function(){return _0x48d91a;});})[_0x6e9d('0x1e')](function(){_0x2857cd['status'](0xcc)[_0x6e9d('0x36')]();});}};}function handleEntityNotFound(_0x132534,_0x4e4286){return function(_0x1b79ea){if(!_0x1b79ea){_0x132534[_0x6e9d('0x37')](0x194);}return _0x1b79ea;};}function handleError(_0x4c08be,_0x813028){_0x813028=_0x813028||0x1f4;return function(_0x39bd69){logger[_0x6e9d('0x25')](_0x39bd69[_0x6e9d('0x38')]);if(_0x39bd69[_0x6e9d('0x39')]){delete _0x39bd69['name'];}_0x4c08be[_0x6e9d('0x29')](_0x813028)[_0x6e9d('0x3a')](_0x39bd69);};}exports['index']=function(_0x2d1539,_0x280859){var _0x3ebdb1={},_0x549486={},_0x25f8bd={'count':0x0,'rows':[]};var _0x203484=db['ChatWebsite'][_0x6e9d('0x3b')];_0x549486['model']=_[_0x6e9d('0x3c')](_0x203484);var _0x30acb1={'dateStart':_0x2d1539[_0x6e9d('0x3d')]['dateStart'],'dateEnd':_0x2d1539[_0x6e9d('0x3d')][_0x6e9d('0x3e')]};delete _0x2d1539[_0x6e9d('0x3d')]['dateStart'];delete _0x2d1539[_0x6e9d('0x3d')]['dateEnd'];_0x549486[_0x6e9d('0x3d')]=_[_0x6e9d('0x3c')](_0x2d1539[_0x6e9d('0x3d')]);_0x549486[_0x6e9d('0x3f')]=_['intersection'](_0x549486[_0x6e9d('0x40')],_0x549486[_0x6e9d('0x3d')]);_0x3ebdb1[_0x6e9d('0x41')]=_[_0x6e9d('0x42')](_0x549486[_0x6e9d('0x40')],qs[_0x6e9d('0x43')](_0x2d1539[_0x6e9d('0x3d')]['fields']));_0x3ebdb1['attributes']=_0x3ebdb1['attributes']['length']?_0x3ebdb1[_0x6e9d('0x41')]:_0x549486['model'];if(!_0x2d1539[_0x6e9d('0x3d')][_0x6e9d('0x44')](_0x6e9d('0x45'))){_0x3ebdb1[_0x6e9d('0x2d')]=qs[_0x6e9d('0x2d')](_0x2d1539[_0x6e9d('0x3d')][_0x6e9d('0x2d')]);_0x3ebdb1[_0x6e9d('0x2c')]=qs['offset'](_0x2d1539[_0x6e9d('0x3d')][_0x6e9d('0x2c')]);}_0x3ebdb1[_0x6e9d('0x46')]=qs[_0x6e9d('0x47')](_0x2d1539[_0x6e9d('0x3d')]['sort']);_0x3ebdb1['where']=qs[_0x6e9d('0x3f')](_[_0x6e9d('0x48')](_0x2d1539[_0x6e9d('0x3d')],_0x549486[_0x6e9d('0x3f')]));if(_0x30acb1['dateStart']){if(_0x30acb1[_0x6e9d('0x3e')]){_0x30acb1[_0x6e9d('0x3e')]=moment(_0x30acb1[_0x6e9d('0x3e')])[_0x6e9d('0x49')](0x1,_0x6e9d('0x4a'));}else{_0x30acb1['dateEnd']=moment(_0x30acb1[_0x6e9d('0x4b')])['add'](0x1,'day');}_['merge'](_0x3ebdb1['where'],{'createdAt':{'$gte':_0x30acb1[_0x6e9d('0x4b')],'$lte':_0x30acb1[_0x6e9d('0x3e')]}});}if(_0x2d1539[_0x6e9d('0x3d')]['filter']){_0x3ebdb1[_0x6e9d('0x4c')]=_[_0x6e9d('0x4d')](_0x3ebdb1['where'],{'$or':_[_0x6e9d('0x4e')](_0x3ebdb1[_0x6e9d('0x41')],function(_0x8ae44d){var _0x25c60f={};_0x25c60f[_0x8ae44d]={'$like':'%'+_0x2d1539[_0x6e9d('0x3d')][_0x6e9d('0x4f')]+'%'};return _0x25c60f;})});}_0x3ebdb1=_[_0x6e9d('0x4d')]({},_0x3ebdb1,_0x2d1539[_0x6e9d('0x50')]);var _0x3977f8={'where':_0x3ebdb1[_0x6e9d('0x4c')]};return db['ChatWebsite'][_0x6e9d('0x2b')](_0x3977f8)['then'](function(_0x52142c){_0x25f8bd[_0x6e9d('0x2b')]=_0x52142c;if(_0x2d1539[_0x6e9d('0x3d')][_0x6e9d('0x51')]){_0x3ebdb1[_0x6e9d('0x52')]=[{'all':!![]}];}return db[_0x6e9d('0x53')][_0x6e9d('0x54')](_0x3ebdb1);})[_0x6e9d('0x1e')](function(_0x2e6f88){_0x25f8bd[_0x6e9d('0x55')]=_0x2e6f88;return _0x25f8bd;})[_0x6e9d('0x1e')](respondWithFilteredResult(_0x280859,_0x3ebdb1))[_0x6e9d('0x28')](handleError(_0x280859,null));};exports[_0x6e9d('0x56')]=function(_0x33c063,_0x336ab9){var _0x9409e2={'raw':![],'where':{'id':_0x33c063['params']['id']}},_0x1f8564={};_0x1f8564[_0x6e9d('0x40')]=_[_0x6e9d('0x3c')](db['ChatWebsite'][_0x6e9d('0x3b')]);_0x1f8564['query']=_[_0x6e9d('0x3c')](_0x33c063[_0x6e9d('0x3d')]);_0x1f8564[_0x6e9d('0x3f')]=_['intersection'](_0x1f8564['model'],_0x1f8564[_0x6e9d('0x3d')]);_0x9409e2[_0x6e9d('0x41')]=_[_0x6e9d('0x42')](_0x1f8564[_0x6e9d('0x40')],qs[_0x6e9d('0x43')](_0x33c063[_0x6e9d('0x3d')]['fields']));_0x9409e2['attributes']=_0x9409e2[_0x6e9d('0x41')]['length']?_0x9409e2[_0x6e9d('0x41')]:_0x1f8564['model'];if(_0x33c063['query']['includeAll']){_0x9409e2[_0x6e9d('0x52')]=[{'all':!![]}];}_0x9409e2=_[_0x6e9d('0x4d')]({},_0x9409e2,_0x33c063[_0x6e9d('0x50')]);return db['ChatWebsite'][_0x6e9d('0x57')](_0x9409e2)[_0x6e9d('0x1e')](handleEntityNotFound(_0x336ab9,null))['then'](respondWithResult(_0x336ab9,null))[_0x6e9d('0x28')](handleError(_0x336ab9,null));};exports[_0x6e9d('0x58')]=function(_0x5becd3,_0x5bbde6){return db['ChatWebsite']['create'](_0x5becd3[_0x6e9d('0x59')],{})[_0x6e9d('0x1e')](function(_0x2eb767){var _0x1c5109=_0x5becd3[_0x6e9d('0x5a')]['get']({'plain':!![]});if(!_0x1c5109)throw new Error(_0x6e9d('0x5b'));if(_0x1c5109[_0x6e9d('0x5c')]===_0x6e9d('0x5a')){var _0x114857=_0x2eb767[_0x6e9d('0x33')]({'plain':!![]});var _0x547e33=_0x6e9d('0x34');return db[_0x6e9d('0x5d')][_0x6e9d('0x57')]({'where':{'name':_0x547e33,'userProfileId':_0x1c5109['userProfileId']},'raw':!![]})[_0x6e9d('0x1e')](function(_0x19b26b){if(_0x19b26b&&_0x19b26b[_0x6e9d('0x5e')]===0x0){return db[_0x6e9d('0x35')][_0x6e9d('0x58')]({'name':_0x114857[_0x6e9d('0x39')],'resourceId':_0x114857['id'],'type':_0x19b26b[_0x6e9d('0x39')],'sectionId':_0x19b26b['id']},{})[_0x6e9d('0x1e')](function(){return _0x2eb767;});}else{return _0x2eb767;}})['catch'](function(_0x2779a3){logger['error'](_0x6e9d('0x5f'),_0x2779a3);throw _0x2779a3;});}return _0x2eb767;})['then'](respondWithResult(_0x5bbde6,0xc9))[_0x6e9d('0x28')](handleError(_0x5bbde6,null));};exports[_0x6e9d('0x31')]=function(_0x2cf001,_0x962127){if(_0x2cf001[_0x6e9d('0x59')]['id']){delete _0x2cf001[_0x6e9d('0x59')]['id'];}return db['ChatWebsite']['find']({'where':{'id':_0x2cf001[_0x6e9d('0x60')]['id']}})['then'](handleEntityNotFound(_0x962127,null))['then'](saveUpdates(_0x2cf001[_0x6e9d('0x59')],null))['then'](respondWithResult(_0x962127,null))[_0x6e9d('0x28')](handleError(_0x962127,null));};exports[_0x6e9d('0x32')]=function(_0x4ea38b,_0x44975d){return db['ChatWebsite'][_0x6e9d('0x57')]({'where':{'id':_0x4ea38b[_0x6e9d('0x60')]['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x44975d,null))[_0x6e9d('0x1e')](removeEntity(_0x44975d,null))[_0x6e9d('0x28')](handleError(_0x44975d,null));};exports[_0x6e9d('0x61')]=function(_0x3a85ef,_0x5d2d48){return db[_0x6e9d('0x53')][_0x6e9d('0x61')]()[_0x6e9d('0x1e')](respondWithResult(_0x5d2d48,null))['catch'](handleError(_0x5d2d48,null));};exports['addDisposition']=function(_0x20bb54,_0x2ed2ff,_0x1ec84f){if(_0x20bb54[_0x6e9d('0x59')]['id']){delete _0x20bb54['body']['id'];}return db['ChatWebsite'][_0x6e9d('0x57')]({'where':{'id':_0x20bb54['params']['id']}})['then'](handleEntityNotFound(_0x2ed2ff,null))['then'](function(_0x5e2d21){if(_0x5e2d21){_0x20bb54['body']['ChatWebsiteId']=_0x5e2d21['id'];return db[_0x6e9d('0x62')][_0x6e9d('0x58')](_0x20bb54[_0x6e9d('0x59')]);}})[_0x6e9d('0x1e')](respondWithResult(_0x2ed2ff,null))[_0x6e9d('0x28')](handleError(_0x2ed2ff,null));};exports[_0x6e9d('0x63')]=function(_0x4f29f3,_0x2ba07f,_0x595d39){var _0x31b19a={'raw':![],'where':{}};var _0x367f7e={};var _0x194f58={'count':0x0,'rows':[]};return db[_0x6e9d('0x53')][_0x6e9d('0x64')]({'where':{'id':_0x4f29f3[_0x6e9d('0x60')]['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x2ba07f,null))['then'](function(_0x39969a){if(_0x39969a){_0x367f7e[_0x6e9d('0x40')]=_[_0x6e9d('0x3c')](db[_0x6e9d('0x62')]['rawAttributes']);_0x367f7e[_0x6e9d('0x3d')]=_[_0x6e9d('0x3c')](_0x4f29f3[_0x6e9d('0x3d')]);_0x367f7e[_0x6e9d('0x3f')]=_[_0x6e9d('0x42')](_0x367f7e[_0x6e9d('0x40')],_0x367f7e[_0x6e9d('0x3d')]);_0x31b19a[_0x6e9d('0x41')]=_[_0x6e9d('0x42')](_0x367f7e[_0x6e9d('0x40')],qs[_0x6e9d('0x43')](_0x4f29f3[_0x6e9d('0x3d')][_0x6e9d('0x43')]));_0x31b19a['attributes']=_0x31b19a[_0x6e9d('0x41')][_0x6e9d('0x65')]?_0x31b19a[_0x6e9d('0x41')]:_0x367f7e[_0x6e9d('0x40')];if(!_0x4f29f3['query'][_0x6e9d('0x44')](_0x6e9d('0x45'))){_0x31b19a[_0x6e9d('0x2d')]=qs[_0x6e9d('0x2d')](_0x4f29f3[_0x6e9d('0x3d')][_0x6e9d('0x2d')]);_0x31b19a[_0x6e9d('0x2c')]=qs[_0x6e9d('0x2c')](_0x4f29f3['query'][_0x6e9d('0x2c')]);}_0x31b19a['order']=qs['sort'](_0x4f29f3[_0x6e9d('0x3d')][_0x6e9d('0x47')]);_0x31b19a[_0x6e9d('0x4c')]=qs[_0x6e9d('0x3f')](_[_0x6e9d('0x48')](_0x4f29f3[_0x6e9d('0x3d')],_0x367f7e[_0x6e9d('0x3f')]));_0x31b19a[_0x6e9d('0x4c')][_0x6e9d('0x66')]=_0x39969a['id'];if(_0x4f29f3[_0x6e9d('0x3d')][_0x6e9d('0x4f')]){_0x31b19a['where']=_[_0x6e9d('0x4d')](_0x31b19a[_0x6e9d('0x4c')],{'$or':_[_0x6e9d('0x4e')](_0x31b19a[_0x6e9d('0x41')],function(_0x3a88e7){var _0x1c9953={};_0x1c9953[_0x3a88e7]={'$like':'%'+_0x4f29f3[_0x6e9d('0x3d')][_0x6e9d('0x4f')]+'%'};return _0x1c9953;})});}_0x31b19a=_[_0x6e9d('0x4d')]({},_0x31b19a,_0x4f29f3[_0x6e9d('0x50')]);return db[_0x6e9d('0x62')][_0x6e9d('0x2b')]({'where':_0x31b19a['where']})[_0x6e9d('0x1e')](function(_0x1e94ce){_0x194f58[_0x6e9d('0x2b')]=_0x1e94ce;if(_0x4f29f3[_0x6e9d('0x3d')][_0x6e9d('0x51')]){_0x31b19a['include']=[{'all':!![]}];}return db['Disposition'][_0x6e9d('0x54')](_0x31b19a);})['then'](function(_0xbe7f5b){_0x194f58['rows']=_0xbe7f5b;return _0x194f58;});}})['then'](respondWithFilteredResult(_0x2ba07f,_0x31b19a))[_0x6e9d('0x28')](handleError(_0x2ba07f,null));};exports['removeDispositions']=function(_0x5e6aff,_0x149915,_0x1c55e0){var _0x50e72a;return db['ChatWebsite'][_0x6e9d('0x57')]({'where':{'id':_0x5e6aff[_0x6e9d('0x60')]['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x149915,null))[_0x6e9d('0x1e')](function(_0x38f0b4){if(_0x38f0b4){return _0x38f0b4['removeDispositions'](_0x5e6aff[_0x6e9d('0x3d')][_0x6e9d('0x67')]);}})[_0x6e9d('0x1e')](respondWithStatusCode(_0x149915,null))[_0x6e9d('0x28')](handleError(_0x149915,null));};exports[_0x6e9d('0x68')]=function(_0x39ba51,_0x393370,_0x3f5740){if(_0x39ba51[_0x6e9d('0x59')]['id']){delete _0x39ba51[_0x6e9d('0x59')]['id'];}return db[_0x6e9d('0x53')]['find']({'where':{'id':_0x39ba51[_0x6e9d('0x60')]['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x393370,null))['then'](function(_0x489353){if(_0x489353){_0x39ba51[_0x6e9d('0x59')][_0x6e9d('0x66')]=_0x489353['id'];return db[_0x6e9d('0x69')][_0x6e9d('0x58')](_0x39ba51[_0x6e9d('0x59')]);}})[_0x6e9d('0x1e')](respondWithResult(_0x393370,null))[_0x6e9d('0x28')](handleError(_0x393370,null));};exports[_0x6e9d('0x6a')]=function(_0x2de5a1,_0x4234ed,_0x409567){var _0x242b33={'raw':![],'where':{}};var _0xc44d77={};var _0x213eda={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x2de5a1[_0x6e9d('0x60')]['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x4234ed,null))[_0x6e9d('0x1e')](function(_0x14a554){if(_0x14a554){_0xc44d77[_0x6e9d('0x40')]=_[_0x6e9d('0x3c')](db[_0x6e9d('0x69')]['rawAttributes']);_0xc44d77['query']=_['keys'](_0x2de5a1['query']);_0xc44d77[_0x6e9d('0x3f')]=_[_0x6e9d('0x42')](_0xc44d77[_0x6e9d('0x40')],_0xc44d77[_0x6e9d('0x3d')]);_0x242b33[_0x6e9d('0x41')]=_[_0x6e9d('0x42')](_0xc44d77[_0x6e9d('0x40')],qs[_0x6e9d('0x43')](_0x2de5a1[_0x6e9d('0x3d')]['fields']));_0x242b33['attributes']=_0x242b33['attributes']['length']?_0x242b33['attributes']:_0xc44d77[_0x6e9d('0x40')];if(!_0x2de5a1[_0x6e9d('0x3d')][_0x6e9d('0x44')](_0x6e9d('0x45'))){_0x242b33[_0x6e9d('0x2d')]=qs['limit'](_0x2de5a1[_0x6e9d('0x3d')][_0x6e9d('0x2d')]);_0x242b33[_0x6e9d('0x2c')]=qs[_0x6e9d('0x2c')](_0x2de5a1[_0x6e9d('0x3d')][_0x6e9d('0x2c')]);}_0x242b33[_0x6e9d('0x46')]=qs[_0x6e9d('0x47')](_0x2de5a1[_0x6e9d('0x3d')]['sort']);_0x242b33[_0x6e9d('0x4c')]=qs['filters'](_[_0x6e9d('0x48')](_0x2de5a1[_0x6e9d('0x3d')],_0xc44d77['filters']));_0x242b33[_0x6e9d('0x4c')][_0x6e9d('0x66')]=_0x14a554['id'];if(_0x2de5a1[_0x6e9d('0x3d')]['filter']){_0x242b33[_0x6e9d('0x4c')]=_[_0x6e9d('0x4d')](_0x242b33['where'],{'$or':_['map'](_0x242b33[_0x6e9d('0x41')],function(_0x29ae21){var _0x32e6c0={};_0x32e6c0[_0x29ae21]={'$like':'%'+_0x2de5a1['query'][_0x6e9d('0x4f')]+'%'};return _0x32e6c0;})});}_0x242b33=_[_0x6e9d('0x4d')]({},_0x242b33,_0x2de5a1[_0x6e9d('0x50')]);return db[_0x6e9d('0x69')]['count']({'where':_0x242b33['where']})['then'](function(_0x560aa1){_0x213eda['count']=_0x560aa1;if(_0x2de5a1[_0x6e9d('0x3d')]['includeAll']){_0x242b33[_0x6e9d('0x52')]=[{'all':!![]}];}return db[_0x6e9d('0x69')]['findAll'](_0x242b33);})['then'](function(_0x36ad72){_0x213eda[_0x6e9d('0x55')]=_0x36ad72;return _0x213eda;});}})[_0x6e9d('0x1e')](respondWithFilteredResult(_0x4234ed,_0x242b33))[_0x6e9d('0x28')](handleError(_0x4234ed,null));};exports[_0x6e9d('0x6b')]=function(_0x4607b6,_0x5446b2,_0x31d81a){var _0x3b6934;return db['ChatWebsite']['find']({'where':{'id':_0x4607b6['params']['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x5446b2,null))['then'](function(_0xf687c0){if(_0xf687c0){return _0xf687c0[_0x6e9d('0x6b')](_0x4607b6['query'][_0x6e9d('0x67')]);}})[_0x6e9d('0x1e')](respondWithStatusCode(_0x5446b2,null))[_0x6e9d('0x28')](handleError(_0x5446b2,null));};exports[_0x6e9d('0x6c')]=function(_0xbc3632,_0x4e4dcd,_0x124737){_0xbc3632[_0x6e9d('0x59')][_0x6e9d('0x6d')]=_0xbc3632['file'][_0x6e9d('0x6e')];return db[_0x6e9d('0x53')]['find']({'where':{'id':_0xbc3632['params']['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x4e4dcd,null))[_0x6e9d('0x1e')](saveUpdates(_0xbc3632[_0x6e9d('0x59')],null))[_0x6e9d('0x1e')](respondWithResult(_0x4e4dcd,null))[_0x6e9d('0x28')](handleError(_0x4e4dcd,null));};exports[_0x6e9d('0x6f')]=function(_0x3c7a86,_0x2575b1,_0x593895){_0x3c7a86[_0x6e9d('0x59')][_0x6e9d('0x70')]=_0x3c7a86[_0x6e9d('0x71')]['filename'];return db[_0x6e9d('0x53')][_0x6e9d('0x57')]({'where':{'id':_0x3c7a86[_0x6e9d('0x60')]['id']}})['then'](handleEntityNotFound(_0x2575b1,null))[_0x6e9d('0x1e')](saveUpdates(_0x3c7a86[_0x6e9d('0x59')],null))[_0x6e9d('0x1e')](respondWithResult(_0x2575b1,null))[_0x6e9d('0x28')](handleError(_0x2575b1,null));};exports[_0x6e9d('0x72')]=function(_0x587f63,_0x5cd30f,_0x49f9b1){_0x587f63['body'][_0x6e9d('0x73')]=_0x587f63['file'][_0x6e9d('0x6e')];return db[_0x6e9d('0x53')]['find']({'where':{'id':_0x587f63[_0x6e9d('0x60')]['id']}})['then'](handleEntityNotFound(_0x5cd30f,null))[_0x6e9d('0x1e')](saveUpdates(_0x587f63[_0x6e9d('0x59')],null))['then'](respondWithResult(_0x5cd30f,null))[_0x6e9d('0x28')](handleError(_0x5cd30f,null));};exports[_0x6e9d('0x74')]=function(_0x62f8a8,_0x49a592,_0x5021de){_0x62f8a8[_0x6e9d('0x59')][_0x6e9d('0x75')]=_0x62f8a8[_0x6e9d('0x71')]['filename'];return db['ChatWebsite'][_0x6e9d('0x57')]({'where':{'id':_0x62f8a8[_0x6e9d('0x60')]['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x49a592,null))['then'](saveUpdates(_0x62f8a8['body'],null))[_0x6e9d('0x1e')](respondWithResult(_0x49a592,null))[_0x6e9d('0x28')](handleError(_0x49a592,null));};exports['getLogo']=function(_0x4bbcd2,_0x24bb9f,_0x50da9d){var _0x4faed5=path[_0x6e9d('0x76')](config['root'],_0x6e9d('0x77'));var _0x5fed85={'where':{'id':_0x4bbcd2[_0x6e9d('0x60')]['id']},'attributes':['id',_0x6e9d('0x6d')],'raw':!![]};var _0x52e1ad=![];return require(_0x6e9d('0x78'))[_0x6e9d('0x79')]()[_0x6e9d('0x1e')](function(_0x39a195){if(_0x39a195){_0x52e1ad=_0x39a195[_0x6e9d('0x7a')];}})['then'](function(){return db['ChatWebsite'][_0x6e9d('0x57')](_0x5fed85);})[_0x6e9d('0x1e')](handleEntityNotFound(_0x24bb9f,null))[_0x6e9d('0x1e')](function(_0x59009b){if(_0x59009b){if(!_[_0x6e9d('0x7b')](_0x59009b['sitepic'])){if(fs[_0x6e9d('0x7c')](path[_0x6e9d('0x76')](config[_0x6e9d('0x7d')],'server/files/images/logos/',_0x59009b[_0x6e9d('0x6d')]))&&_0x52e1ad){_0x4faed5=path['join'](config[_0x6e9d('0x7d')],_0x6e9d('0x7e'),_0x59009b[_0x6e9d('0x6d')]);}}return _0x24bb9f[_0x6e9d('0x7f')](_0x4faed5);}})[_0x6e9d('0x28')](handleError(_0x24bb9f,null));};exports[_0x6e9d('0x80')]=function(_0x281387,_0x362fb1,_0x3223a6){var _0x48b050=path[_0x6e9d('0x76')](config[_0x6e9d('0x7d')],_0x6e9d('0x81'));var _0x51c844={'where':{'id':_0x281387[_0x6e9d('0x60')]['id']},'attributes':['id',_0x6e9d('0x70')],'raw':!![]};return db[_0x6e9d('0x53')][_0x6e9d('0x57')](_0x51c844)[_0x6e9d('0x1e')](handleEntityNotFound(_0x362fb1,null))[_0x6e9d('0x1e')](function(_0x38287f){if(_0x38287f){if(!_[_0x6e9d('0x7b')](_0x38287f['agentAvatar'])){if(fs[_0x6e9d('0x7c')](path[_0x6e9d('0x76')](config['root'],_0x6e9d('0x82'),_0x38287f[_0x6e9d('0x70')]))){_0x48b050=path[_0x6e9d('0x76')](config[_0x6e9d('0x7d')],_0x6e9d('0x82'),_0x38287f[_0x6e9d('0x70')]);}}return _0x362fb1[_0x6e9d('0x7f')](_0x48b050);}})[_0x6e9d('0x28')](handleError(_0x362fb1,null));};exports[_0x6e9d('0x83')]=function(_0x176350,_0x556af8,_0x27b93f){var _0x4a7d4f=path[_0x6e9d('0x76')](config['root'],_0x6e9d('0x84'));var _0x3614e1={'where':{'id':_0x176350['params']['id']},'attributes':['id','customerAvatar',_0x6e9d('0x85')],'raw':!![]};return db[_0x6e9d('0x53')][_0x6e9d('0x57')](_0x3614e1)[_0x6e9d('0x1e')](handleEntityNotFound(_0x556af8,null))['then'](function(_0x20eb36){if(_0x20eb36){if(!_['isNil'](_0x20eb36[_0x6e9d('0x73')])){if(fs[_0x6e9d('0x7c')](path[_0x6e9d('0x76')](config[_0x6e9d('0x7d')],_0x6e9d('0x82'),_0x20eb36[_0x6e9d('0x73')]))&&_0x20eb36[_0x6e9d('0x85')]){_0x4a7d4f=path['join'](config['root'],'server/files/images/avatars/',_0x20eb36['customerAvatar']);}}return _0x556af8[_0x6e9d('0x7f')](_0x4a7d4f);}})[_0x6e9d('0x28')](handleError(_0x556af8,null));};exports[_0x6e9d('0x86')]=function(_0x450951,_0x36af9b,_0x38c1d5){var _0xf4bdea=path[_0x6e9d('0x76')](config[_0x6e9d('0x7d')],'server/files/images/avatars/system_avatar.png');var _0x5da83d={'where':{'id':_0x450951['params']['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db['ChatWebsite']['find'](_0x5da83d)['then'](handleEntityNotFound(_0x36af9b,null))[_0x6e9d('0x1e')](function(_0x5add06){if(_0x5add06){if(!_[_0x6e9d('0x7b')](_0x5add06[_0x6e9d('0x75')])){if(fs[_0x6e9d('0x7c')](path[_0x6e9d('0x76')](config[_0x6e9d('0x7d')],_0x6e9d('0x82'),_0x5add06['systemAvatar']))){_0xf4bdea=path[_0x6e9d('0x76')](config[_0x6e9d('0x7d')],_0x6e9d('0x82'),_0x5add06['systemAvatar']);}}return _0x36af9b[_0x6e9d('0x7f')](_0xf4bdea);}})[_0x6e9d('0x28')](handleError(_0x36af9b,null));};exports[_0x6e9d('0x87')]=function(_0x3106be,_0x3303f3,_0x3eccd7){var _0x41ef30=require(_0x6e9d('0x88'));var _0x3da9e1=new _0x41ef30();var _0x592f90=_0x3da9e1[_0x6e9d('0x89')](_0x3106be['headers'][_0x6e9d('0x8a')])[_0x6e9d('0x8b')]();var _0x2cad43={'body':_0x3106be[_0x6e9d('0x59')],'channel':'chat'};var _0x1586df=[];var _0x1355e7=[];var _0x2a7782={};var _0x1c0c37=![];return db[_0x6e9d('0x8c')][_0x6e9d('0x61')]()['then'](function(_0x11e917){if(!_0x11e917){throw new db[(_0x6e9d('0x8d'))][(_0x6e9d('0x8e'))](_0x6e9d('0x8f'));}_0x1586df=_['difference'](_[_0x6e9d('0x3c')](_0x11e917),[_0x6e9d('0x90'),_0x6e9d('0x91')]);_0x1355e7=_[_0x6e9d('0x92')](_[_0x6e9d('0x3c')](_0x11e917),[_0x6e9d('0x90'),_0x6e9d('0x91'),'CompanyId',_0x6e9d('0x93')]);if(_0x3106be[_0x6e9d('0x59')]['id']){delete _0x3106be[_0x6e9d('0x59')]['id'];}if(_[_0x6e9d('0x7b')](_0x3106be[_0x6e9d('0x59')][_0x6e9d('0x94')])){throw new db[(_0x6e9d('0x8d'))][(_0x6e9d('0x8e'))](_0x6e9d('0x95'));}if(_[_0x6e9d('0x7b')](_0x3106be[_0x6e9d('0x59')][_0x6e9d('0x59')])||_0x3106be['body']['body']===''){throw new db[(_0x6e9d('0x8d'))]['ValidationError'](_0x6e9d('0x96'));}if(_[_0x6e9d('0x7b')](_0x3106be[_0x6e9d('0x59')][_0x6e9d('0x97')])){throw new db[(_0x6e9d('0x8d'))][(_0x6e9d('0x8e'))](_0x6e9d('0x98')+_0x1355e7);}if(!_['includes'](_0x1355e7,_0x3106be['body'][_0x6e9d('0x97')])){throw new db[(_0x6e9d('0x8d'))][(_0x6e9d('0x8e'))](_0x6e9d('0x99')+_0x1355e7);}_0x2a7782[_0x3106be[_0x6e9d('0x59')]['mapKey']]=_0x3106be[_0x6e9d('0x59')][_0x6e9d('0x94')];})[_0x6e9d('0x1e')](function(){return db['ChatWebsite']['find']({'where':{'id':_0x3106be['params']['id']},'include':[{'model':db[_0x6e9d('0x9a')],'as':_0x6e9d('0x9b'),'include':[{'model':db[_0x6e9d('0x8c')],'as':_0x6e9d('0x9c'),'where':_0x2a7782,'limit':0x1,'order':[[_0x6e9d('0x91'),_0x6e9d('0x9d')]]}]},{'model':db[_0x6e9d('0x9e')],'as':_0x6e9d('0x9f')}]});})[_0x6e9d('0x1e')](handleEntityNotFound(_0x3303f3,null))[_0x6e9d('0x1e')](function(_0x2b8a42){if(_0x2b8a42&&_0x2b8a42[_0x6e9d('0x9b')]){_0x2cad43[_0x6e9d('0xa0')]=_0x2b8a42;_0x2cad43['applications']=_0x2b8a42[_0x6e9d('0x9f')];_0x2cad43[_0x6e9d('0xa1')]=_0x2b8a42[_0x6e9d('0x9b')];_0x2cad43[_0x6e9d('0xa2')]=_[_0x6e9d('0xa3')](_0x2cad43[_0x6e9d('0xa2')],[_0x6e9d('0xa4')],[_0x6e9d('0xa5')]);if(_0x2cad43['account'][_0x6e9d('0x9f')]){delete _0x2cad43[_0x6e9d('0xa0')]['Applications'];}if(_0x2cad43['account'][_0x6e9d('0x9b')]&&_0x2cad43[_0x6e9d('0xa0')][_0x6e9d('0x9b')]['Contacts']['length']){return _0x2cad43[_0x6e9d('0xa0')]['List'][_0x6e9d('0x9c')][0x0];}var _0x2866dc=_[_0x6e9d('0x17')](_0x3106be[_0x6e9d('0x59')],{'firstName':_0x3106be['body'][_0x6e9d('0x94')],'ListId':_0x2b8a42[_0x6e9d('0x93')]});_0x2866dc[_0x3106be[_0x6e9d('0x59')][_0x6e9d('0x97')]]=_0x3106be[_0x6e9d('0x59')][_0x6e9d('0x94')];return db[_0x6e9d('0x8c')]['create'](_0x2866dc,{'fields':_0x1586df,'raw':!![]});}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x3303f3,null))['then'](function(_0x393eb9){_0x2cad43[_0x6e9d('0xa6')]=_0x393eb9;if(_0x393eb9){var _0x579553={'ContactId':_0x393eb9['id'],'ChatWebsiteId':_0x3106be[_0x6e9d('0x60')]['id'],'from':(_0x393eb9[_0x6e9d('0xa7')]||'')+'\x20'+(_0x393eb9[_0x6e9d('0xa8')]||''),'customerIp':_0x3106be['body'][_0x6e9d('0xa9')],'referer':_0x3106be[_0x6e9d('0x59')][_0x6e9d('0xaa')],'browserName':_0x592f90['browser'][_0x6e9d('0x39')]&&_0x592f90[_0x6e9d('0xab')][_0x6e9d('0xac')]?util[_0x6e9d('0xad')](_0x6e9d('0xae'),_0x592f90[_0x6e9d('0xab')]['name'],_0x592f90['browser']['version']):_0x6e9d('0xaf'),'browserVersion':_0x592f90[_0x6e9d('0xab')][_0x6e9d('0xac')]||_0x6e9d('0xaf'),'osName':util[_0x6e9d('0xad')](_0x6e9d('0xae'),_0x592f90['os'][_0x6e9d('0x39')],_0x592f90['os']['version']),'osVersion':_0x592f90['os'][_0x6e9d('0xac')],'deviceModel':_0x592f90['device'][_0x6e9d('0x40')]&&_0x592f90['device'][_0x6e9d('0xb0')]?util[_0x6e9d('0xad')]('%s\x20%s\x20%s',_0x592f90[_0x6e9d('0xb1')][_0x6e9d('0x40')],_0x592f90[_0x6e9d('0xb1')][_0x6e9d('0xb0')],_0x592f90['device'][_0x6e9d('0xb2')]):null,'deviceVendor':_0x592f90[_0x6e9d('0xb1')][_0x6e9d('0xb0')],'deviceType':_0x592f90[_0x6e9d('0xb1')][_0x6e9d('0xb2')],'formData':JSON['stringify'](_0x3106be[_0x6e9d('0x59')])};var _0x5f0e4b={'ChatWebsiteId':_0x3106be[_0x6e9d('0x60')]['id'],'closed':![]};if(_0x3106be[_0x6e9d('0x59')][_0x6e9d('0xb3')]){_0x5f0e4b['threadId']=_0x3106be['body'][_0x6e9d('0xb3')];return db[_0x6e9d('0xb4')][_0x6e9d('0x57')]({'where':_0x5f0e4b})[_0x6e9d('0x1e')](function(_0x8e0dc5){if(_0x8e0dc5){return[_0x8e0dc5,![]];}_0x579553['threadId']=_0x3106be[_0x6e9d('0x59')][_0x6e9d('0xb3')];_0x579553['externalUrl']=_0x3106be[_0x6e9d('0x59')]['externalUrl'];return db[_0x6e9d('0xb4')][_0x6e9d('0x58')](_0x579553)[_0x6e9d('0x1e')](function(_0x55ac90){return[_0x55ac90,!![]];});});}_0x5f0e4b['ContactId']=_0x393eb9['id'];if(_0x3106be[_0x6e9d('0x59')][_0x6e9d('0xb5')]&&_0x3106be[_0x6e9d('0x59')][_0x6e9d('0xb5')]['id']){_0x5f0e4b['id']=_0x3106be[_0x6e9d('0x59')][_0x6e9d('0xb5')]['id'];return db[_0x6e9d('0xb4')]['find']({'where':_0x5f0e4b})['then'](function(_0x1923b3){if(_0x1923b3){return[_0x1923b3,![]];}return db[_0x6e9d('0xb4')][_0x6e9d('0x58')](_0x579553)['then'](function(_0x5396bd){return[_0x5396bd,!![]];});});}return db[_0x6e9d('0xb4')][_0x6e9d('0x58')](_0x579553)[_0x6e9d('0x1e')](function(_0x38931d){return[_0x38931d,!![]];});}})[_0x6e9d('0xb6')](function(_0x43cb8b,_0x28ad25){if(_0x43cb8b){_0x1c0c37=_0x28ad25;if(!_0x28ad25){var _0x222540={'from':(_0x2cad43[_0x6e9d('0xa6')][_0x6e9d('0xa7')]||'')+'\x20'+(_0x2cad43[_0x6e9d('0xa6')][_0x6e9d('0xa8')]||'')};if(_0x3106be['body'][_0x6e9d('0xb3')]&&_0x3106be[_0x6e9d('0x59')][_0x6e9d('0xb7')]&&_0x3106be['body'][_0x6e9d('0xb3')]!=_0x3106be[_0x6e9d('0x59')][_0x6e9d('0xb7')]){_0x222540[_0x6e9d('0xb3')]=_0x3106be[_0x6e9d('0x59')][_0x6e9d('0xb7')];}return _0x43cb8b['update'](_0x222540);}else{return _0x43cb8b;}}})[_0x6e9d('0x1e')](function(_0x2badd8){_0x2cad43[_0x6e9d('0xb5')]=_0x2badd8[_0x6e9d('0x33')]({'plain':!![]});_0x2cad43[_0x6e9d('0xb5')][_0x6e9d('0xb8')]=_0x1c0c37;if(_0x2cad43['interaction'][_0x6e9d('0xb8')]){if(_0x2cad43['account'][_0x6e9d('0xb9')]){_0x2cad43[_0x6e9d('0xa2')][_0x6e9d('0xba')]({'id':0x0,'priority':_0x2cad43[_0x6e9d('0xa2')][_0x6e9d('0x65')]+0x1,'app':'close','appdata':_0x6e9d('0xbb'),'interval':_0x6e9d('0xbc')});}}return db[_0x6e9d('0xbd')][_0x6e9d('0x58')]({'body':_0x3106be['body'][_0x6e9d('0x59')],'ChatWebsiteId':_0x3106be['params']['id'],'ChatInteractionId':_0x2badd8['id'],'direction':'in','ContactId':_0x2cad43[_0x6e9d('0xa6')]['id'],'AttachmentId':_0x3106be[_0x6e9d('0x59')][_0x6e9d('0xbe')]});})[_0x6e9d('0x1e')](function(_0x4d9424){_0x2cad43[_0x6e9d('0x26')]=_0x4d9424;if(_0x2cad43[_0x6e9d('0xb5')][_0x6e9d('0xbf')]){return db[_0x6e9d('0xc0')][_0x6e9d('0x57')]({'attributes':['id',_0x6e9d('0x39')],'where':{'id':_0x2cad43[_0x6e9d('0xb5')][_0x6e9d('0xbf')]}})[_0x6e9d('0x1e')](function(_0x48a86f){if(_0x48a86f){_0x2cad43['applications']['unshift']({'id':0x0,'priority':0x0,'app':_0x6e9d('0xc1'),'appdata':_0x48a86f[_0x6e9d('0x39')]+','+(_0x2cad43[_0x6e9d('0xa0')][_0x6e9d('0xc2')]||0xa),'interval':'*,*,*,*'});_0x2cad43[_0x6e9d('0xc3')]=!![];}return respondWithRpcPromise(_0x6e9d('0xc4'),_0x6e9d('0xc5'),_0x2cad43);});}return respondWithRpcPromise(_0x6e9d('0xc4'),_0x6e9d('0xc5'),_0x2cad43);})[_0x6e9d('0x1e')](function(_0x11e387){respondWithRpcPromise(_0x6e9d('0xc6'),_0x6e9d('0xc6'),{'event':_0x6e9d('0x87'),'message':_0x11e387},client9002);return _0x11e387;})[_0x6e9d('0x1e')](respondWithResult(_0x3303f3,null))[_0x6e9d('0x28')](handleError(_0x3303f3,null));};exports[_0x6e9d('0xc7')]=function(_0x453551,_0x275458,_0x386dbc){var _0x625cef,_0x5a7795,_0x27600c;var _0x12a33d=[];var _0x23c676=[];var _0x2f085a={};return db[_0x6e9d('0x8c')][_0x6e9d('0x61')]()[_0x6e9d('0x1e')](function(_0x3af9f3){if(!_0x3af9f3){throw new db[(_0x6e9d('0x8d'))][(_0x6e9d('0x8e'))](_0x6e9d('0x8f'));}_0x23c676=_[_0x6e9d('0x92')](_[_0x6e9d('0x3c')](_0x3af9f3),[_0x6e9d('0x90'),_0x6e9d('0x91')]);_0x12a33d=_[_0x6e9d('0x92')](_['keys'](_0x3af9f3),['createdAt',_0x6e9d('0x91'),_0x6e9d('0xc8'),_0x6e9d('0x93')]);if(_0x453551[_0x6e9d('0x59')]['id']){delete _0x453551[_0x6e9d('0x59')]['id'];}if(_[_0x6e9d('0x7b')](_0x453551['body'][_0x6e9d('0x94')])){throw _0x275458[_0x6e9d('0x29')](0x1f4)[_0x6e9d('0x3a')](new db['Sequelize'][(_0x6e9d('0x8e'))]('from\x20is\x20mandatory'));}if(_[_0x6e9d('0x7b')](_0x453551[_0x6e9d('0x59')]['body'])||_0x453551[_0x6e9d('0x59')][_0x6e9d('0x59')]===''){throw _0x275458[_0x6e9d('0x29')](0x1f4)['send'](new db[(_0x6e9d('0x8d'))][(_0x6e9d('0x8e'))](_0x6e9d('0x96')));}if(_[_0x6e9d('0x7b')](_0x453551['body'][_0x6e9d('0xc9')])){throw _0x275458['status'](0x1f4)[_0x6e9d('0x3a')](new db[(_0x6e9d('0x8d'))][(_0x6e9d('0x8e'))]('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x12a33d));}if(!_[_0x6e9d('0xca')](_0x12a33d,_0x453551[_0x6e9d('0x59')]['mapKeyOffline'])){throw _0x275458[_0x6e9d('0x29')](0x1f4)[_0x6e9d('0x3a')](new db[(_0x6e9d('0x8d'))][(_0x6e9d('0x8e'))](_0x6e9d('0xcb')+_0x12a33d));}_0x2f085a[_0x453551[_0x6e9d('0x59')][_0x6e9d('0xc9')]]=_0x453551[_0x6e9d('0x59')][_0x6e9d('0x94')];})[_0x6e9d('0x1e')](function(){return db[_0x6e9d('0x53')][_0x6e9d('0x57')]({'where':{'id':_0x453551[_0x6e9d('0x60')]['id']},'include':[{'model':db[_0x6e9d('0x9a')],'as':_0x6e9d('0x9b')}]});})[_0x6e9d('0x1e')](handleEntityNotFound(_0x275458,null))['then'](function(_0x6a3492){if(_0x6a3492&&_0x6a3492['List']){_0x5a7795=_0x6a3492;var _0x143d55=_[_0x6e9d('0x17')](_0x453551[_0x6e9d('0x59')],{'firstName':_0x453551[_0x6e9d('0x59')][_0x6e9d('0x94')],'phone':_0x453551['body'][_0x6e9d('0x94')],'ListId':_0x6a3492[_0x6e9d('0x93')]});_0x143d55[_0x453551['body']['mapKeyOffline']]=_0x453551[_0x6e9d('0x59')][_0x6e9d('0x94')];return db[_0x6e9d('0x8c')][_0x6e9d('0xcc')]({'where':_0x2f085a,'defaults':_0x143d55});}})[_0x6e9d('0xb6')](function(_0x2db530){if(_0x2db530){_0x27600c=_0x2db530;var _0x537dd7=fs[_0x6e9d('0xcd')](path['join'](config['root'],_0x6e9d('0xce')),_0x6e9d('0xcf'));var _0x2657fc=ejs['render'](_0x537dd7,{'body':_[_0x6e9d('0xd0')](_0x453551[_0x6e9d('0x59')][_0x6e9d('0x59')]),'bodyTitle':_0x5a7795['offlineMessageBody']});return db[_0x6e9d('0xd1')]['create']({'body':_0x2657fc,'ContactId':_0x2db530['id'],'ChatWebsiteId':_0x5a7795['id']});}})[_0x6e9d('0x1e')](function(_0x3319b8){if(_0x3319b8){_0x625cef=_0x3319b8;return db[_0x6e9d('0xd2')][_0x6e9d('0x64')]({'where':{'service':!![]},'include':[{'model':db[_0x6e9d('0xd3')],'as':_0x6e9d('0xd4'),'raw':!![]}]});}})[_0x6e9d('0x1e')](function(_0x441273){if(_0x441273&&_0x441273[_0x6e9d('0xd4')]&&_0x5a7795[_0x6e9d('0xd5')]){var _0x54bf24={'tls':{'rejectUnauthorized':![]}};if(_0x441273[_0x6e9d('0xd4')][_0x6e9d('0xd6')]){_0x54bf24['service']=_0x441273['Smtp'][_0x6e9d('0xd6')];}else{_0x54bf24['host']=_0x441273[_0x6e9d('0xd4')][_0x6e9d('0xd7')];_0x54bf24['port']=_0x441273[_0x6e9d('0xd4')]['port'];_0x54bf24[_0x6e9d('0xd8')]=_0x441273[_0x6e9d('0xd4')][_0x6e9d('0xd8')];}if(_0x441273[_0x6e9d('0xd4')][_0x6e9d('0xd9')]){_0x54bf24['auth']={'user':_0x441273[_0x6e9d('0xd4')][_0x6e9d('0x5a')],'pass':_0x441273[_0x6e9d('0xd4')][_0x6e9d('0xda')]};}return respondWithRpcPromise(_0x6e9d('0xdb'),_0x6e9d('0xdc'),{'account':_0x54bf24,'message':{'from':util[_0x6e9d('0xad')](_0x6e9d('0xdd'),_0x441273[_0x6e9d('0x39')],_0x441273[_0x6e9d('0xde')]||_0x441273[_0x6e9d('0xd4')]['user']),'to':_0x5a7795['forwardOfflineAddress'],'subject':_0x5a7795[_0x6e9d('0xdf')],'text':_0x625cef['body']}},client9003)[_0x6e9d('0x1e')](function(){return _0x625cef;})[_0x6e9d('0x28')](function(_0x231dcd){console[_0x6e9d('0x25')](_0x231dcd);});}})['then'](function(){if(_0x625cef){return _0x625cef;}})[_0x6e9d('0x1e')](respondWithResult(_0x275458,null))[_0x6e9d('0x28')](handleError(_0x275458,null));};exports['addInteraction']=function(_0x5a606c,_0x449bed,_0x59021b){return db['ChatInteraction'][_0x6e9d('0x57')]({'where':{'id':_0x5a606c['params']['id']}})['then'](handleEntityNotFound(_0x449bed,null))['then'](function(_0x17d2d1){if(_0x17d2d1){return _0x17d2d1['addInteraction'](_0x5a606c[_0x6e9d('0x59')][_0x6e9d('0x67')],_[_0x6e9d('0xe0')](_0x5a606c[_0x6e9d('0x59')],[_0x6e9d('0x67'),'id'])||{});}})[_0x6e9d('0x1e')](respondWithResult(_0x449bed,null))[_0x6e9d('0x28')](handleError(_0x449bed,null));};exports[_0x6e9d('0xe1')]=function(_0x5b615c,_0xdc36d0,_0x2922f3){var _0x28be58={'raw':![],'where':{}};var _0x57d42e={};var _0x42752b={'count':0x0,'rows':[]};return db[_0x6e9d('0x53')][_0x6e9d('0x64')]({'where':{'id':_0x5b615c[_0x6e9d('0x60')]['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0xdc36d0,null))[_0x6e9d('0x1e')](function(_0x53b17c){if(_0x53b17c){_0x57d42e[_0x6e9d('0x40')]=_[_0x6e9d('0x3c')](db[_0x6e9d('0xb4')][_0x6e9d('0x3b')]);_0x57d42e['query']=_['keys'](_0x5b615c[_0x6e9d('0x3d')]);_0x57d42e[_0x6e9d('0x3f')]=_['intersection'](_0x57d42e[_0x6e9d('0x40')],_0x57d42e[_0x6e9d('0x3d')]);_0x28be58['attributes']=_[_0x6e9d('0x42')](_0x57d42e[_0x6e9d('0x40')],qs[_0x6e9d('0x43')](_0x5b615c[_0x6e9d('0x3d')][_0x6e9d('0x43')]));_0x28be58['attributes']=_0x28be58[_0x6e9d('0x41')][_0x6e9d('0x65')]?_0x28be58['attributes']:_0x57d42e[_0x6e9d('0x40')];if(!_0x5b615c[_0x6e9d('0x3d')][_0x6e9d('0x44')](_0x6e9d('0x45'))){_0x28be58['limit']=qs[_0x6e9d('0x2d')](_0x5b615c[_0x6e9d('0x3d')]['limit']);_0x28be58[_0x6e9d('0x2c')]=qs[_0x6e9d('0x2c')](_0x5b615c['query']['offset']);}_0x28be58['order']=qs[_0x6e9d('0x47')](_0x5b615c['query'][_0x6e9d('0x47')]);_0x28be58['where']=qs[_0x6e9d('0x3f')](_[_0x6e9d('0x48')](_0x5b615c[_0x6e9d('0x3d')],_0x57d42e['filters']));_0x28be58['where']['ChatWebsiteId']=_0x53b17c['id'];if(_0x5b615c['query'][_0x6e9d('0x4f')]){_0x28be58[_0x6e9d('0x4c')]=_[_0x6e9d('0x4d')](_0x28be58[_0x6e9d('0x4c')],{'$or':_[_0x6e9d('0x4e')](_0x28be58[_0x6e9d('0x41')],function(_0x2860e3){var _0x328c64={};_0x328c64[_0x2860e3]={'$like':'%'+_0x5b615c[_0x6e9d('0x3d')][_0x6e9d('0x4f')]+'%'};return _0x328c64;})});}_0x28be58=_[_0x6e9d('0x4d')]({},_0x28be58,_0x5b615c[_0x6e9d('0x50')]);return db['ChatInteraction'][_0x6e9d('0x2b')]({'where':_0x28be58[_0x6e9d('0x4c')]})[_0x6e9d('0x1e')](function(_0x1e6e03){_0x42752b['count']=_0x1e6e03;if(_0x5b615c[_0x6e9d('0x3d')]['includeAll']){_0x28be58['include']=[{'model':db[_0x6e9d('0x8c')],'as':'Contact','required':![]},{'model':db[_0x6e9d('0xc0')],'as':_0x6e9d('0xe2'),'attributes':[_0x6e9d('0x39'),_0x6e9d('0xe3'),_0x6e9d('0xe4')],'required':![]},{'model':db[_0x6e9d('0xe5')],'as':_0x6e9d('0xe6'),'attributes':['id',_0x6e9d('0x39'),_0x6e9d('0xe7')],'where':_0x5b615c[_0x6e9d('0x3d')][_0x6e9d('0xe8')]?{'id':_0x5b615c['query'][_0x6e9d('0xe8')]}:undefined,'required':_0x5b615c[_0x6e9d('0x3d')][_0x6e9d('0xe8')]?!![]:![]}];}return db[_0x6e9d('0xb4')][_0x6e9d('0x54')](_0x28be58);})[_0x6e9d('0x1e')](function(_0x483199){_0x42752b[_0x6e9d('0x55')]=_0x483199;return _0x42752b;});}})['then'](respondWithFilteredResult(_0xdc36d0,_0x28be58))[_0x6e9d('0x28')](handleError(_0xdc36d0,null));};function iftimePromise(_0x4c9cd2,_0xa8e1aa){return respondWithRpcPromise(_0x6e9d('0xe9'),_0x6e9d('0xea'),{'command':_0xa8e1aa[_0x6e9d('0xeb')]?util[_0x6e9d('0xad')](_0x6e9d('0xec'),_0x4c9cd2['interval'],_0xa8e1aa[_0x6e9d('0xeb')]):util[_0x6e9d('0xad')](_0x6e9d('0xed'),_0x4c9cd2[_0x6e9d('0xee')])},client9002)[_0x6e9d('0x1e')](function(_0x1a80ad){var _0x5c904d=_0x1a80ad&&_0x1a80ad[_0x6e9d('0xef')](_0x6e9d('0xf0'))>=0x0?!![]:![];logger[_0x6e9d('0x1f')](_0x6e9d('0xf1'),_0xa8e1aa['id'],_0x4c9cd2['id'],_0x4c9cd2[_0x6e9d('0xee')],_0x5c904d?_0x6e9d('0xf2'):'OFFLINE',_0xa8e1aa[_0x6e9d('0xeb')]?_0xa8e1aa['timezone']:_0x6e9d('0xf3'));return _0x5c904d;})['catch'](function(_0x2fdefc){logger[_0x6e9d('0x25')]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0xa8e1aa['id'],_0x4c9cd2['id'],_0x4c9cd2['interval'],util['inspect'](_0x2fdefc,{'showHidden':![],'depth':null}),_0xa8e1aa[_0x6e9d('0xeb')]?_0xa8e1aa['timezone']:_0x6e9d('0xf3'));return![];});}exports[_0x6e9d('0xea')]=function(_0x4b02ed,_0x29fe9d,_0x3ebf2b){var _0x3002bb=0x0;var _0x639bff=0x0;var _0x3dcfd1=![];var _0x567d3e;var _0x457ce8;return db[_0x6e9d('0x53')]['find']({'where':{'id':_0x4b02ed[_0x6e9d('0x60')]['id']},'include':[{'model':db[_0x6e9d('0xf4')],'as':_0x6e9d('0xf4'),'include':[{'model':db['Interval'],'as':'Intervals','attributes':['id','interval'],'raw':!![]}]}]})['then'](handleEntityNotFound(_0x29fe9d,null))[_0x6e9d('0x1e')](function(_0x1dfb22){if(_0x1dfb22){_0x567d3e=_0x1dfb22;return _0x1dfb22[_0x6e9d('0xf5')]({'raw':!![]});}})[_0x6e9d('0x1e')](function(_0x2e1c94){if(_0x567d3e){if(_0x2e1c94){_0x457ce8=_0x2e1c94;}}return require(_0x6e9d('0x78'))['getLicense']();})[_0x6e9d('0x1e')](function(_0x28a154){if(_0x28a154){_0x639bff=_0x28a154['virtual'];_0x3dcfd1=_0x28a154[_0x6e9d('0x7a')];}})[_0x6e9d('0x1e')](function(){return db['ChatInteraction'][_0x6e9d('0x2b')]({'where':{'closed':![]}});})['then'](function(_0x15e9d9){_0x3002bb=_0x15e9d9;if(_0x639bff&&_0x15e9d9>_0x639bff){return db[_0x6e9d('0xf6')][_0x6e9d('0x64')]({'where':{'id':0x1}})[_0x6e9d('0x1e')](function(_0x533875){if(_0x533875){_0x533875['increment'](_0x6e9d('0xf7'));}});}})['then'](function(){if(_0x567d3e['Interval']&&_0x567d3e['Interval'][_0x6e9d('0xf8')]){var _0x484b3e=[];for(var _0x164266=0x0;_0x164266<_0x567d3e[_0x6e9d('0xf4')][_0x6e9d('0xf8')][_0x6e9d('0x65')];_0x164266++){var _0x4dcf26=_0x567d3e[_0x6e9d('0xf4')]['Intervals'][_0x164266]['get']({'plain':!![]});_0x484b3e['push'](iftimePromise(_0x4dcf26,_0x567d3e));}return BPromise['all'](_0x484b3e)[_0x6e9d('0x1e')](function(_0x383c9e){return _[_0x6e9d('0xf9')](_0x383c9e);});}else{return!![];}})['then'](function(_0xae0552){var _0x30d1b1=fs[_0x6e9d('0xcd')](path[_0x6e9d('0x76')](config[_0x6e9d('0x7d')],_0x6e9d('0xfa')),_0x6e9d('0xcf'));var _0x3c120f={'remote':_0x567d3e['remote'],'query':querystring[_0x6e9d('0x24')](_[_0x6e9d('0x4d')](_0x567d3e['get']({'plain':!![]}),{'customerIp':_0x4b02ed[_0x6e9d('0xfb')][_0x6e9d('0xfc')]||_0x4b02ed[_0x6e9d('0xfb')][_0x6e9d('0xfd')]||_0x4b02ed[_0x6e9d('0xfe')][_0x6e9d('0xff')]||_0x4b02ed['ip'],'referer':_0x4b02ed['headers'][_0x6e9d('0xaa')],'openedInteractions':_0x3002bb,'maxInteractions':_0x639bff,'virtual':_0x3dcfd1[_0x6e9d('0x100')],'online':_0xae0552,'custom':_0x3dcfd1}))[_0x6e9d('0x101')](/'/g,'\x5c\x27')};_0x29fe9d[_0x6e9d('0x3a')](ejs[_0x6e9d('0x102')](Mustache['render'](_0x30d1b1,_0x3c120f),{'proactiveActions':_0x457ce8,'alignment':_0x567d3e[_0x6e9d('0x103')],'verticalAlignment':_0x567d3e[_0x6e9d('0x104')]}));})[_0x6e9d('0x28')](handleError(_0x29fe9d,null));};exports[_0x6e9d('0x105')]=function(_0x2e8685,_0x105579,_0x141cf8){return db[_0x6e9d('0x53')][_0x6e9d('0x64')]({'where':{'id':_0x2e8685['params']['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x105579,null))[_0x6e9d('0x1e')](function(_0x29e6b5){if(_0x29e6b5){return db['sequelize'][_0x6e9d('0x106')](function(_0xd0b616){return db[_0x6e9d('0x9e')][_0x6e9d('0x32')]({'where':{'ChatWebsiteId':_0x2e8685[_0x6e9d('0x60')]['id']},'transaction':_0xd0b616})[_0x6e9d('0x1e')](function(_0x483b48){var _0x245913=_[_0x6e9d('0x4e')](_0x2e8685[_0x6e9d('0x59')],function(_0x4a5596){_0x4a5596[_0x6e9d('0x66')]=_0x2e8685[_0x6e9d('0x60')]['id'];return _0x4a5596;});return db[_0x6e9d('0x9e')]['bulkCreate'](_0x245913,{'transaction':_0xd0b616});});})[_0x6e9d('0x1e')](function(){return db[_0x6e9d('0x9e')][_0x6e9d('0x107')]({'where':{'ChatWebsiteId':_0x2e8685[_0x6e9d('0x60')]['id']},'order':_0x6e9d('0xa4')});});}})[_0x6e9d('0x1e')](respondWithResult(_0x105579,null))[_0x6e9d('0x28')](handleError(_0x105579,null));};exports[_0x6e9d('0x108')]=function(_0x1396b5,_0x593d20,_0x2382ab){var _0x49e579={};var _0x5da06a={};var _0x46bd0f;var _0x117f30;return db[_0x6e9d('0x53')][_0x6e9d('0x64')]({'where':{'id':_0x1396b5[_0x6e9d('0x60')]['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x593d20,null))[_0x6e9d('0x1e')](function(_0x56cd62){if(_0x56cd62){_0x46bd0f=_0x56cd62;_0x5da06a[_0x6e9d('0x40')]=_[_0x6e9d('0x3c')](db['ChatApplication']['rawAttributes']);_0x5da06a[_0x6e9d('0x3d')]=_[_0x6e9d('0x3c')](_0x1396b5[_0x6e9d('0x3d')]);_0x5da06a[_0x6e9d('0x3f')]=_[_0x6e9d('0x42')](_0x5da06a[_0x6e9d('0x40')],_0x5da06a[_0x6e9d('0x3d')]);_0x49e579[_0x6e9d('0x41')]=_[_0x6e9d('0x42')](_0x5da06a['model'],qs[_0x6e9d('0x43')](_0x1396b5[_0x6e9d('0x3d')]['fields']));_0x49e579['attributes']=_0x49e579[_0x6e9d('0x41')]['length']?_0x49e579[_0x6e9d('0x41')]:_0x5da06a[_0x6e9d('0x40')];_0x49e579['order']=qs['sort'](_0x1396b5[_0x6e9d('0x3d')]['sort']);_0x49e579[_0x6e9d('0x4c')]=qs[_0x6e9d('0x3f')](_[_0x6e9d('0x48')](_0x1396b5[_0x6e9d('0x3d')],_0x5da06a[_0x6e9d('0x3f')]));if(_0x1396b5[_0x6e9d('0x3d')]['filter']){_0x49e579['where']=_[_0x6e9d('0x4d')](_0x49e579[_0x6e9d('0x4c')],{'$or':_[_0x6e9d('0x4e')](_0x49e579[_0x6e9d('0x41')],function(_0x5e4c52){var _0x10c27d={};_0x10c27d[_0x5e4c52]={'$like':'%'+_0x1396b5['query'][_0x6e9d('0x4f')]+'%'};return _0x10c27d;})});}_0x49e579=_[_0x6e9d('0x4d')]({},_0x49e579,_0x1396b5['options']);return _0x46bd0f[_0x6e9d('0x108')](_0x49e579);}})['then'](function(_0x31f7e2){if(_0x31f7e2){_0x117f30=_0x31f7e2['length'];if(!_0x1396b5[_0x6e9d('0x3d')]['hasOwnProperty'](_0x6e9d('0x45'))){_0x49e579[_0x6e9d('0x2d')]=qs['limit'](_0x1396b5[_0x6e9d('0x3d')]['limit']);_0x49e579['offset']=qs[_0x6e9d('0x2c')](_0x1396b5[_0x6e9d('0x3d')][_0x6e9d('0x2c')]);}return _0x46bd0f[_0x6e9d('0x108')](_0x49e579);}})[_0x6e9d('0x1e')](function(_0x3b858a){if(_0x3b858a){return _0x3b858a?{'count':_0x117f30,'rows':_0x3b858a}:null;}})['then'](respondWithResult(_0x593d20,null))[_0x6e9d('0x28')](handleError(_0x593d20,null));};exports[_0x6e9d('0x109')]=function(_0x1302be,_0x5c0319,_0x4aa4c9){return db[_0x6e9d('0x10a')]['find']({'where':{'id':_0x1302be[_0x6e9d('0x60')]['id']}})['then'](handleEntityNotFound(_0x5c0319,null))[_0x6e9d('0x1e')](function(_0x5c0138){if(_0x5c0138){return _0x5c0138[_0x6e9d('0x109')](_0x1302be[_0x6e9d('0x59')]['ids'],_[_0x6e9d('0xe0')](_0x1302be[_0x6e9d('0x59')],['ids','id'])||{});}})[_0x6e9d('0x1e')](respondWithResult(_0x5c0319,null))['catch'](handleError(_0x5c0319,null));};exports['getProactiveActions']=function(_0xb2b15,_0x134859,_0x2787a1){var _0x23f7bc={};var _0x5d0835={};var _0x570699;var _0x329933;return db[_0x6e9d('0x53')][_0x6e9d('0x64')]({'where':{'id':_0xb2b15[_0x6e9d('0x60')]['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x134859,null))['then'](function(_0x45d213){if(_0x45d213){_0x570699=_0x45d213;_0x5d0835['model']=_[_0x6e9d('0x3c')](db[_0x6e9d('0x10b')]['rawAttributes']);_0x5d0835['query']=_[_0x6e9d('0x3c')](_0xb2b15[_0x6e9d('0x3d')]);_0x5d0835[_0x6e9d('0x3f')]=_['intersection'](_0x5d0835[_0x6e9d('0x40')],_0x5d0835['query']);_0x23f7bc[_0x6e9d('0x41')]=_[_0x6e9d('0x42')](_0x5d0835[_0x6e9d('0x40')],qs[_0x6e9d('0x43')](_0xb2b15[_0x6e9d('0x3d')][_0x6e9d('0x43')]));_0x23f7bc[_0x6e9d('0x41')]=_0x23f7bc[_0x6e9d('0x41')][_0x6e9d('0x65')]?_0x23f7bc[_0x6e9d('0x41')]:_0x5d0835[_0x6e9d('0x40')];_0x23f7bc[_0x6e9d('0x46')]=qs[_0x6e9d('0x47')](_0xb2b15[_0x6e9d('0x3d')][_0x6e9d('0x47')]);_0x23f7bc['where']=qs[_0x6e9d('0x3f')](_['pick'](_0xb2b15[_0x6e9d('0x3d')],_0x5d0835[_0x6e9d('0x3f')]));if(_0xb2b15[_0x6e9d('0x3d')]['filter']){_0x23f7bc[_0x6e9d('0x4c')]=_[_0x6e9d('0x4d')](_0x23f7bc[_0x6e9d('0x4c')],{'$or':_[_0x6e9d('0x4e')](_0x23f7bc['attributes'],function(_0x53816a){var _0x1a6367={};_0x1a6367[_0x53816a]={'$like':'%'+_0xb2b15['query'][_0x6e9d('0x4f')]+'%'};return _0x1a6367;})});}_0x23f7bc=_['merge']({},_0x23f7bc,_0xb2b15['options']);return _0x570699[_0x6e9d('0xf5')](_0x23f7bc);}})[_0x6e9d('0x1e')](function(_0x1f8c93){if(_0x1f8c93){_0x329933=_0x1f8c93[_0x6e9d('0x65')];if(!_0xb2b15[_0x6e9d('0x3d')][_0x6e9d('0x44')]('nolimit')){_0x23f7bc[_0x6e9d('0x2d')]=qs['limit'](_0xb2b15['query'][_0x6e9d('0x2d')]);_0x23f7bc[_0x6e9d('0x2c')]=qs['offset'](_0xb2b15[_0x6e9d('0x3d')][_0x6e9d('0x2c')]);}return _0x570699[_0x6e9d('0xf5')](_0x23f7bc);}})[_0x6e9d('0x1e')](function(_0x43c353){if(_0x43c353){return _0x43c353?{'count':_0x329933,'rows':_0x43c353}:null;}})[_0x6e9d('0x1e')](respondWithResult(_0x134859,null))[_0x6e9d('0x28')](handleError(_0x134859,null));};exports[_0x6e9d('0x10c')]=function(_0x4b483a,_0x3427b5,_0x44f4ee){var _0x648974=_0x4b483a[_0x6e9d('0x3d')][_0x6e9d('0x10d')]===_0x6e9d('0x10e')?'offlineForm':_0x6e9d('0x10f');return db['ChatWebsite'][_0x6e9d('0x57')]({'attributes':['id',_0x648974],'where':{'id':_0x4b483a[_0x6e9d('0x60')]['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x3427b5,null))['then'](function(_0x2698e6){if(_0x2698e6){var _0x1db444=_0x2698e6[_0x648974];var _0x5da8d9=_0x1db444&&_0x1db444['items']?_0x1db444[_0x6e9d('0x110')]:[];_0x3427b5[_0x6e9d('0x3a')]({'fromKey':_[_0x6e9d('0x7b')](_0x1db444[_0x6e9d('0x111')])?undefined:_0x1db444[_0x6e9d('0x111')],'count':_0x5da8d9[_0x6e9d('0x65')],'rows':_0x5da8d9});}})[_0x6e9d('0x28')](handleError(_0x3427b5,null));};exports['getOfflineMessages']=function(_0x39f387,_0x2aa87b,_0x17994a){var _0x1a7df0={'raw':!![],'where':{}};var _0x544c7d={};var _0x3a15f9={'count':0x0,'rows':[]};return db[_0x6e9d('0x53')][_0x6e9d('0x64')]({'where':{'id':_0x39f387[_0x6e9d('0x60')]['id']}})['then'](handleEntityNotFound(_0x2aa87b,null))['then'](function(_0x5dbf63){if(_0x5dbf63){_0x544c7d[_0x6e9d('0x40')]=_[_0x6e9d('0x3c')](db[_0x6e9d('0xd1')]['rawAttributes']);_0x544c7d[_0x6e9d('0x3d')]=_[_0x6e9d('0x3c')](_0x39f387[_0x6e9d('0x3d')]);_0x544c7d[_0x6e9d('0x3f')]=_[_0x6e9d('0x42')](_0x544c7d[_0x6e9d('0x40')],_0x544c7d['query']);_0x1a7df0[_0x6e9d('0x41')]=_[_0x6e9d('0x42')](_0x544c7d[_0x6e9d('0x40')],qs[_0x6e9d('0x43')](_0x39f387[_0x6e9d('0x3d')][_0x6e9d('0x43')]));_0x1a7df0['attributes']=_0x1a7df0[_0x6e9d('0x41')]['length']?_0x1a7df0[_0x6e9d('0x41')]:_0x544c7d[_0x6e9d('0x40')];if(!_0x39f387[_0x6e9d('0x3d')][_0x6e9d('0x44')]('nolimit')){_0x1a7df0[_0x6e9d('0x2d')]=qs[_0x6e9d('0x2d')](_0x39f387['query'][_0x6e9d('0x2d')]);_0x1a7df0[_0x6e9d('0x2c')]=qs[_0x6e9d('0x2c')](_0x39f387[_0x6e9d('0x3d')]['offset']);}_0x1a7df0[_0x6e9d('0x46')]=qs[_0x6e9d('0x47')](_0x39f387[_0x6e9d('0x3d')][_0x6e9d('0x47')]);_0x1a7df0['where']=qs[_0x6e9d('0x3f')](_['pick'](_0x39f387[_0x6e9d('0x3d')],_0x544c7d[_0x6e9d('0x3f')]));_0x1a7df0[_0x6e9d('0x4c')][_0x6e9d('0x66')]=_0x5dbf63['id'];if(_0x39f387['query'][_0x6e9d('0x4f')]){_0x1a7df0['where']=_[_0x6e9d('0x4d')](_0x1a7df0[_0x6e9d('0x4c')],{'$or':_['map'](_0x1a7df0['attributes'],function(_0x11ea0f){var _0x2e05d8={};_0x2e05d8[_0x11ea0f]={'$like':'%'+_0x39f387[_0x6e9d('0x3d')][_0x6e9d('0x4f')]+'%'};return _0x2e05d8;})});}_0x1a7df0=_[_0x6e9d('0x4d')]({},_0x1a7df0,_0x39f387[_0x6e9d('0x50')]);return db[_0x6e9d('0xd1')][_0x6e9d('0x2b')]({'where':_0x1a7df0[_0x6e9d('0x4c')]})[_0x6e9d('0x1e')](function(_0x3024af){_0x3a15f9[_0x6e9d('0x2b')]=_0x3024af;if(_0x39f387[_0x6e9d('0x3d')][_0x6e9d('0x51')]){_0x1a7df0[_0x6e9d('0x52')]=[{'all':!![]}];}return db[_0x6e9d('0xd1')][_0x6e9d('0x54')](_0x1a7df0);})[_0x6e9d('0x1e')](function(_0x30389c){_0x3a15f9[_0x6e9d('0x55')]=_0x30389c;return _0x3a15f9;});}})['then'](respondWithFilteredResult(_0x2aa87b,_0x1a7df0))[_0x6e9d('0x28')](handleError(_0x2aa87b,null));};exports[_0x6e9d('0x112')]=function(_0x3eefc5,_0x2fbcd7,_0x2e1acb){return db['ChatWebsite'][_0x6e9d('0x57')]({'where':{'id':_0x3eefc5['params']['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x2fbcd7,null))['then'](function(_0x10cb08){if(_0x10cb08){return _0x10cb08[_0x6e9d('0x112')](_0x3eefc5[_0x6e9d('0x59')][_0x6e9d('0x67')],_[_0x6e9d('0xe0')](_0x3eefc5[_0x6e9d('0x59')],['ids','id'])||{})['spread'](function(_0x26a5ac){for(var _0x295d52=0x0;_0x295d52<_0x3eefc5[_0x6e9d('0x59')]['ids'][_0x6e9d('0x65')];_0x295d52+=0x1){socket[_0x6e9d('0x113')]('userChatWebsite:save',{'UserId':_0x3eefc5[_0x6e9d('0x59')]['ids'][_0x295d52],'ChatWebsiteId':_0x3eefc5[_0x6e9d('0x60')]['id']});}return _0x26a5ac;});}})[_0x6e9d('0x1e')](respondWithResult(_0x2fbcd7,null))['catch'](handleError(_0x2fbcd7,null));};exports[_0x6e9d('0x114')]=function(_0x278284,_0x172421,_0x37cffa){var _0x112a15;return db['ChatWebsite'][_0x6e9d('0x57')]({'where':{'id':_0x278284['params']['id']}})[_0x6e9d('0x1e')](handleEntityNotFound(_0x172421,null))[_0x6e9d('0x1e')](function(_0x5045cd){if(_0x5045cd){return _0x5045cd[_0x6e9d('0x114')](_0x278284[_0x6e9d('0x3d')][_0x6e9d('0x67')])['then'](function(_0x49a07b){if(_['isArray'](_0x278284['query'][_0x6e9d('0x67')])){for(var _0x278543=0x0;_0x278543<_0x278284[_0x6e9d('0x3d')][_0x6e9d('0x67')][_0x6e9d('0x65')];_0x278543+=0x1){socket[_0x6e9d('0x113')](_0x6e9d('0x115'),{'UserId':_0x278284[_0x6e9d('0x3d')]['ids'][_0x278543],'ChatWebsiteId':_0x278284[_0x6e9d('0x60')]['id']});}}else{socket[_0x6e9d('0x113')](_0x6e9d('0x115'),{'UserId':_0x278284['query'][_0x6e9d('0x67')],'ChatWebsiteId':_0x278284[_0x6e9d('0x60')]['id']});}});}})['then'](respondWithStatusCode(_0x172421,null))[_0x6e9d('0x28')](handleError(_0x172421,null));};exports['getAgents']=function(_0x46a40a,_0x48033b,_0x306803){var _0x5d22b8={};var _0x24c695={};var _0x10a85d;var _0x34877f;return db['ChatWebsite'][_0x6e9d('0x64')]({'where':{'id':_0x46a40a[_0x6e9d('0x60')]['id']}})['then'](handleEntityNotFound(_0x48033b,null))[_0x6e9d('0x1e')](function(_0x384440){if(_0x384440){_0x10a85d=_0x384440;_0x24c695[_0x6e9d('0x40')]=_[_0x6e9d('0x3c')](db[_0x6e9d('0xc0')][_0x6e9d('0x3b')]);_0x24c695[_0x6e9d('0x3d')]=_[_0x6e9d('0x3c')](_0x46a40a['query']);_0x24c695[_0x6e9d('0x3f')]=_['intersection'](_0x24c695[_0x6e9d('0x40')],_0x24c695[_0x6e9d('0x3d')]);_0x5d22b8[_0x6e9d('0x41')]=_['intersection'](_0x24c695['model'],qs['fields'](_0x46a40a[_0x6e9d('0x3d')][_0x6e9d('0x43')]));_0x5d22b8[_0x6e9d('0x41')]=_0x5d22b8[_0x6e9d('0x41')]['length']?_0x5d22b8[_0x6e9d('0x41')]:_0x24c695[_0x6e9d('0x40')];_0x5d22b8[_0x6e9d('0x46')]=qs['sort'](_0x46a40a[_0x6e9d('0x3d')][_0x6e9d('0x47')]);_0x5d22b8[_0x6e9d('0x4c')]=qs['filters'](_[_0x6e9d('0x48')](_0x46a40a[_0x6e9d('0x3d')],_0x24c695[_0x6e9d('0x3f')]));if(_0x46a40a[_0x6e9d('0x3d')][_0x6e9d('0x4f')]){_0x5d22b8[_0x6e9d('0x4c')]=_[_0x6e9d('0x4d')](_0x5d22b8[_0x6e9d('0x4c')],{'$or':_['map'](_0x5d22b8[_0x6e9d('0x41')],function(_0x59501e){var _0x28d306={};_0x28d306[_0x59501e]={'$like':'%'+_0x46a40a[_0x6e9d('0x3d')][_0x6e9d('0x4f')]+'%'};return _0x28d306;})});}_0x5d22b8=_['merge']({},_0x5d22b8,_0x46a40a[_0x6e9d('0x50')]);return _0x10a85d[_0x6e9d('0x116')](_0x5d22b8);}})['then'](function(_0x1525aa){if(_0x1525aa){_0x34877f=_0x1525aa[_0x6e9d('0x65')];if(!_0x46a40a['query'][_0x6e9d('0x44')]('nolimit')){_0x5d22b8[_0x6e9d('0x2d')]=qs['limit'](_0x46a40a[_0x6e9d('0x3d')][_0x6e9d('0x2d')]);_0x5d22b8[_0x6e9d('0x2c')]=qs[_0x6e9d('0x2c')](_0x46a40a[_0x6e9d('0x3d')]['offset']);}return _0x10a85d[_0x6e9d('0x116')](_0x5d22b8);}})[_0x6e9d('0x1e')](function(_0x55cfa0){if(_0x55cfa0){return _0x55cfa0?{'count':_0x34877f,'rows':_0x55cfa0}:null;}})[_0x6e9d('0x1e')](respondWithResult(_0x48033b,null))[_0x6e9d('0x28')](handleError(_0x48033b,null));};
\ No newline at end of file
+var _0xf523=['removeAnswers','sitepic','file','filename','addAvatar','agentAvatar','addCustomerAvatar','customerAvatar','addSystemAvatar','root','../../config/license/util','getLicense','custom','isNil','join','server/files/images/logos/','getAvatar','server/files/images/avatars/default_avatar.png','server/files/images/avatars/','download','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','existsSync','server/files/images/avatars/system_avatar.png','systemAvatar','setUA','headers','user-agent','chat','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','Contacts','ChatApplication','Applications','account','applications','orderBy','priority','ListId','lastName','customerIp','referer','browser','version','format','%s\x20%s','%s\x20%s\x20%s','device','vendor','stringify','threadId','ChatInteraction','externalUrl','ContactId','interaction','firstName','contact','messageId','autoclose','push','close','unmanaged','*,*,*,*','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','forcedOwnership','Start','startRouting','EventManager','offline','mapKeyOffline','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','findOrCreate','spread','readFileSync','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','MailAccount','MailServerOut','Smtp','forwardOfflineAddress','service','host','port','secure','authentication','auth','pass','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','addInteraction','omit','getInteractions','Contact','Owner','fullname','internal','Tag','color','tag','getSnippet','iftime\x20%s,%s','interval','timezone','iftime\x20%s','indexOf','ONLINE','OFFLINE','No\x20timezone','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','inspect','Interval','Intervals','getProactiveActions','virtual','License','increment','chatLicenseExceeded','all','some','x-forwarded-for','connection','remoteAddress','replace','alignment','addApplications','sequelize','transaction','bulkCreate','findAndCountAll','addProactiveActions','chatProactiveAction','ChatProactiveAction','getFields','online','false','onlineForm','items','fromKey','getOfflineMessages','addAgents','emit','removeAgents','isArray','userChatWebsite:remove','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','ejs','lodash','squel','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','jayson/promise','client','http','request','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','error','code','message','catch','sendStatus','status','count','offset','limit','set','json','apply','reject','save','update','destroy','UserProfileResource','end','stack','name','send','index','rawAttributes','model','query','dateStart','dateEnd','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','day','add','merge','filter','map','type','key','VIRTUAL','options','ChatWebsite','include','findAll','rows','show','params','find','create','body','user','get','role','ChatWebsites','UserProfileSection','autoAssociation','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','findOne','includeAll','removeDispositions','ids','addAnswer','getAnswers','CannedAnswer'];(function(_0x1b0e96,_0x52196d){var _0x4c95a5=function(_0x3668a2){while(--_0x3668a2){_0x1b0e96['push'](_0x1b0e96['shift']());}};_0x4c95a5(++_0x52196d);}(_0xf523,0xa9));var _0x3f52=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xf523[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0x3f52('0x0'));var emlformat=require(_0x3f52('0x1'));var rimraf=require(_0x3f52('0x2'));var zipdir=require(_0x3f52('0x3'));var jsonpatch=require(_0x3f52('0x4'));var rp=require(_0x3f52('0x5'));var moment=require(_0x3f52('0x6'));var BPromise=require(_0x3f52('0x7'));var Mustache=require(_0x3f52('0x8'));var util=require('util');var path=require(_0x3f52('0x9'));var sox=require(_0x3f52('0xa'));var csv=require('to-csv');var ejs=require(_0x3f52('0xb'));var fs=require('fs');var _=require(_0x3f52('0xc'));var squel=require(_0x3f52('0xd'));var crypto=require('crypto');var jsforce=require(_0x3f52('0xe'));var deskjs=require(_0x3f52('0xf'));var toCsv=require(_0x3f52('0x10'));var querystring=require(_0x3f52('0x11'));var Papa=require(_0x3f52('0x12'));var Redis=require(_0x3f52('0x13'));var qs=require(_0x3f52('0x14'));var logger=require('../../config/logger')(_0x3f52('0x15'));var utils=require(_0x3f52('0x16'));var config=require(_0x3f52('0x17'));var db=require(_0x3f52('0x18'))['db'];config[_0x3f52('0x19')]=_[_0x3f52('0x1a')](config[_0x3f52('0x19')],{'host':_0x3f52('0x1b'),'port':0x18eb});var socket=require(_0x3f52('0x1c'))(new Redis(config[_0x3f52('0x19')]));require('./chatWebsite.socket')[_0x3f52('0x1d')](socket);var jayson=require(_0x3f52('0x1e'));var client=jayson[_0x3f52('0x1f')][_0x3f52('0x20')]({'port':0x232c});var client9002=jayson[_0x3f52('0x1f')]['http']({'port':0x232a});var client9003=jayson[_0x3f52('0x1f')][_0x3f52('0x20')]({'port':0x232b});function respondWithRpcPromise(_0x9f3a64,_0x291c31,_0x3efac8,_0x537d30){return new BPromise(function(_0x28181a,_0x349776){var _0x5501ba=_0x537d30||client;return _0x5501ba[_0x3f52('0x21')](_0x9f3a64,_0x3efac8)[_0x3f52('0x22')](function(_0x4c7800){logger[_0x3f52('0x23')](_0x3f52('0x24'),_0x291c31,_0x3f52('0x25'));logger[_0x3f52('0x26')]('ChatWebsite,\x20%s,\x20%s,\x20%s',_0x291c31,_0x3f52('0x25'),JSON['stringify'](_0x4c7800));if(_0x4c7800[_0x3f52('0x27')]){if(_0x4c7800[_0x3f52('0x27')][_0x3f52('0x28')]===0x1f4){logger[_0x3f52('0x27')](_0x3f52('0x24'),_0x291c31,_0x4c7800[_0x3f52('0x27')][_0x3f52('0x29')]);return _0x349776(_0x4c7800[_0x3f52('0x27')]['message']);}logger[_0x3f52('0x27')]('ChatWebsite,\x20%s,\x20%s',_0x291c31,_0x4c7800[_0x3f52('0x27')]['message']);return _0x28181a(_0x4c7800[_0x3f52('0x27')][_0x3f52('0x29')]);}else{logger[_0x3f52('0x23')](_0x3f52('0x24'),_0x291c31,_0x3f52('0x25'));_0x28181a(_0x4c7800['result'][_0x3f52('0x29')]);}})[_0x3f52('0x2a')](function(_0x407fa9){logger['error'](_0x3f52('0x24'),_0x291c31,_0x407fa9);_0x349776(_0x407fa9);});});}function respondWithStatusCode(_0x57a978,_0x57e853){_0x57e853=_0x57e853||0xcc;return function(_0x8bef24){if(_0x8bef24){return _0x57a978[_0x3f52('0x2b')](_0x57e853);}return _0x57a978[_0x3f52('0x2c')](_0x57e853)['end']();};}function respondWithResult(_0x2e8c56,_0x28fb43){_0x28fb43=_0x28fb43||0xc8;return function(_0x122911){if(_0x122911){return _0x2e8c56[_0x3f52('0x2c')](_0x28fb43)['json'](_0x122911);}};}function respondWithFilteredResult(_0xa10ab1,_0x49b866){return function(_0x1f477a){if(_0x1f477a){var _0x18bd86=_0x1f477a[_0x3f52('0x2d')],_0xda4144=_0x49b866[_0x3f52('0x2e')],_0x171c84=_0x49b866[_0x3f52('0x2e')]+_0x49b866[_0x3f52('0x2f')],_0x1eaf79;if(_0x171c84>=_0x18bd86){_0x171c84=_0x18bd86;_0x1eaf79=0xc8;}else{_0x1eaf79=0xce;}_0xa10ab1[_0x3f52('0x2c')](_0x1eaf79);return _0xa10ab1[_0x3f52('0x30')]('Content-Range',_0xda4144+'-'+_0x171c84+'/'+_0x18bd86)[_0x3f52('0x31')](_0x1f477a);}return null;};}function patchUpdates(_0x1eb643){return function(_0x573e65){try{jsonpatch[_0x3f52('0x32')](_0x573e65,_0x1eb643,!![]);}catch(_0x65ccb){return BPromise[_0x3f52('0x33')](_0x65ccb);}return _0x573e65[_0x3f52('0x34')]();};}function saveUpdates(_0x6916c7,_0x489922){return function(_0x5397fe){if(_0x5397fe){return _0x5397fe[_0x3f52('0x35')](_0x6916c7)[_0x3f52('0x22')](function(_0x55eb38){return _0x55eb38;});}return null;};}function removeEntity(_0x121d9f,_0x4c11dc){return function(_0x4a7e46){if(_0x4a7e46){return _0x4a7e46[_0x3f52('0x36')]()[_0x3f52('0x22')](function(){var _0x1b8f67=_0x4a7e46['get']({'plain':!![]});var _0x1b78d8='ChatWebsites';return db[_0x3f52('0x37')][_0x3f52('0x36')]({'where':{'type':_0x1b78d8,'resourceId':_0x1b8f67['id']}})[_0x3f52('0x22')](function(){return _0x4a7e46;});})[_0x3f52('0x22')](function(){_0x121d9f[_0x3f52('0x2c')](0xcc)[_0x3f52('0x38')]();});}};}function handleEntityNotFound(_0x3377b4,_0x464ff0){return function(_0xd664af){if(!_0xd664af){_0x3377b4[_0x3f52('0x2b')](0x194);}return _0xd664af;};}function handleError(_0x19c67a,_0x48b1a0){_0x48b1a0=_0x48b1a0||0x1f4;return function(_0x3c7de7){logger[_0x3f52('0x27')](_0x3c7de7[_0x3f52('0x39')]);if(_0x3c7de7[_0x3f52('0x3a')]){delete _0x3c7de7[_0x3f52('0x3a')];}_0x19c67a[_0x3f52('0x2c')](_0x48b1a0)[_0x3f52('0x3b')](_0x3c7de7);};}exports[_0x3f52('0x3c')]=function(_0x24dd06,_0x10726e){var _0x6251aa={},_0x3dfb81={},_0x3fe78d={'count':0x0,'rows':[]};var _0x50868d=db['ChatWebsite'][_0x3f52('0x3d')];_0x3dfb81[_0x3f52('0x3e')]=_['keys'](_0x50868d);var _0x629faa={'dateStart':_0x24dd06[_0x3f52('0x3f')][_0x3f52('0x40')],'dateEnd':_0x24dd06[_0x3f52('0x3f')][_0x3f52('0x41')]};delete _0x24dd06['query'][_0x3f52('0x40')];delete _0x24dd06[_0x3f52('0x3f')][_0x3f52('0x41')];_0x3dfb81[_0x3f52('0x3f')]=_[_0x3f52('0x42')](_0x24dd06[_0x3f52('0x3f')]);_0x3dfb81['filters']=_[_0x3f52('0x43')](_0x3dfb81[_0x3f52('0x3e')],_0x3dfb81[_0x3f52('0x3f')]);_0x6251aa[_0x3f52('0x44')]=_[_0x3f52('0x43')](_0x3dfb81[_0x3f52('0x3e')],qs[_0x3f52('0x45')](_0x24dd06[_0x3f52('0x3f')][_0x3f52('0x45')]));_0x6251aa[_0x3f52('0x44')]=_0x6251aa['attributes'][_0x3f52('0x46')]?_0x6251aa[_0x3f52('0x44')]:_0x3dfb81[_0x3f52('0x3e')];if(!_0x24dd06['query'][_0x3f52('0x47')](_0x3f52('0x48'))){_0x6251aa[_0x3f52('0x2f')]=qs[_0x3f52('0x2f')](_0x24dd06['query'][_0x3f52('0x2f')]);_0x6251aa['offset']=qs[_0x3f52('0x2e')](_0x24dd06[_0x3f52('0x3f')]['offset']);}_0x6251aa[_0x3f52('0x49')]=qs['sort'](_0x24dd06['query'][_0x3f52('0x4a')]);_0x6251aa[_0x3f52('0x4b')]=qs[_0x3f52('0x4c')](_[_0x3f52('0x4d')](_0x24dd06[_0x3f52('0x3f')],_0x3dfb81[_0x3f52('0x4c')]));if(_0x629faa[_0x3f52('0x40')]){if(_0x629faa[_0x3f52('0x41')]){_0x629faa[_0x3f52('0x41')]=moment(_0x629faa[_0x3f52('0x41')])['add'](0x1,_0x3f52('0x4e'));}else{_0x629faa[_0x3f52('0x41')]=moment(_0x629faa['dateStart'])[_0x3f52('0x4f')](0x1,_0x3f52('0x4e'));}_[_0x3f52('0x50')](_0x6251aa[_0x3f52('0x4b')],{'createdAt':{'$gte':_0x629faa[_0x3f52('0x40')],'$lte':_0x629faa['dateEnd']}});}if(_0x24dd06['query'][_0x3f52('0x51')]){_0x6251aa['where']=_[_0x3f52('0x50')](_0x6251aa[_0x3f52('0x4b')],{'$or':_[_0x3f52('0x52')](_0x50868d,function(_0x1992ca){if(_0x1992ca[_0x3f52('0x53')][_0x3f52('0x54')]!==_0x3f52('0x55')){var _0x5ae273={};_0x5ae273[_0x1992ca['field']]={'$like':'%'+_0x24dd06[_0x3f52('0x3f')]['filter']+'%'};return _0x5ae273;}})});}_0x6251aa=_[_0x3f52('0x50')]({},_0x6251aa,_0x24dd06[_0x3f52('0x56')]);var _0x3115c0={'where':_0x6251aa[_0x3f52('0x4b')]};return db[_0x3f52('0x57')]['count'](_0x3115c0)['then'](function(_0x4357bb){_0x3fe78d['count']=_0x4357bb;if(_0x24dd06[_0x3f52('0x3f')]['includeAll']){_0x6251aa[_0x3f52('0x58')]=[{'all':!![]}];}return db[_0x3f52('0x57')][_0x3f52('0x59')](_0x6251aa);})['then'](function(_0x407aff){_0x3fe78d[_0x3f52('0x5a')]=_0x407aff;return _0x3fe78d;})[_0x3f52('0x22')](respondWithFilteredResult(_0x10726e,_0x6251aa))['catch'](handleError(_0x10726e,null));};exports[_0x3f52('0x5b')]=function(_0x2e1e2f,_0x14ebb5){var _0x2db693={'raw':![],'where':{'id':_0x2e1e2f[_0x3f52('0x5c')]['id']}},_0x37ef50={};_0x37ef50['model']=_['keys'](db['ChatWebsite']['rawAttributes']);_0x37ef50['query']=_[_0x3f52('0x42')](_0x2e1e2f[_0x3f52('0x3f')]);_0x37ef50[_0x3f52('0x4c')]=_[_0x3f52('0x43')](_0x37ef50[_0x3f52('0x3e')],_0x37ef50[_0x3f52('0x3f')]);_0x2db693['attributes']=_[_0x3f52('0x43')](_0x37ef50[_0x3f52('0x3e')],qs[_0x3f52('0x45')](_0x2e1e2f[_0x3f52('0x3f')][_0x3f52('0x45')]));_0x2db693[_0x3f52('0x44')]=_0x2db693['attributes']['length']?_0x2db693[_0x3f52('0x44')]:_0x37ef50['model'];if(_0x2e1e2f[_0x3f52('0x3f')]['includeAll']){_0x2db693[_0x3f52('0x58')]=[{'all':!![]}];}_0x2db693=_[_0x3f52('0x50')]({},_0x2db693,_0x2e1e2f[_0x3f52('0x56')]);return db['ChatWebsite'][_0x3f52('0x5d')](_0x2db693)['then'](handleEntityNotFound(_0x14ebb5,null))[_0x3f52('0x22')](respondWithResult(_0x14ebb5,null))[_0x3f52('0x2a')](handleError(_0x14ebb5,null));};exports['create']=function(_0x3b5e71,_0x282822){return db[_0x3f52('0x57')][_0x3f52('0x5e')](_0x3b5e71[_0x3f52('0x5f')],{})[_0x3f52('0x22')](function(_0x167015){var _0x503451=_0x3b5e71[_0x3f52('0x60')][_0x3f52('0x61')]({'plain':!![]});if(!_0x503451)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x503451[_0x3f52('0x62')]===_0x3f52('0x60')){var _0x2f0387=_0x167015[_0x3f52('0x61')]({'plain':!![]});var _0x204db6=_0x3f52('0x63');return db[_0x3f52('0x64')][_0x3f52('0x5d')]({'where':{'name':_0x204db6,'userProfileId':_0x503451['userProfileId']},'raw':!![]})['then'](function(_0x575dc1){if(_0x575dc1&&_0x575dc1[_0x3f52('0x65')]===0x0){return db[_0x3f52('0x37')]['create']({'name':_0x2f0387[_0x3f52('0x3a')],'resourceId':_0x2f0387['id'],'type':_0x575dc1['name'],'sectionId':_0x575dc1['id']},{})[_0x3f52('0x22')](function(){return _0x167015;});}else{return _0x167015;}})['catch'](function(_0x229ffb){logger[_0x3f52('0x27')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x229ffb);throw _0x229ffb;});}return _0x167015;})[_0x3f52('0x22')](respondWithResult(_0x282822,0xc9))[_0x3f52('0x2a')](handleError(_0x282822,null));};exports[_0x3f52('0x35')]=function(_0x5cacf5,_0xc5ff8){if(_0x5cacf5['body']['id']){delete _0x5cacf5[_0x3f52('0x5f')]['id'];}return db[_0x3f52('0x57')]['find']({'where':{'id':_0x5cacf5[_0x3f52('0x5c')]['id']}})['then'](handleEntityNotFound(_0xc5ff8,null))[_0x3f52('0x22')](saveUpdates(_0x5cacf5[_0x3f52('0x5f')],null))['then'](respondWithResult(_0xc5ff8,null))[_0x3f52('0x2a')](handleError(_0xc5ff8,null));};exports[_0x3f52('0x36')]=function(_0x11169b,_0x5c6448){return db[_0x3f52('0x57')][_0x3f52('0x5d')]({'where':{'id':_0x11169b['params']['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x5c6448,null))[_0x3f52('0x22')](removeEntity(_0x5c6448,null))[_0x3f52('0x2a')](handleError(_0x5c6448,null));};exports[_0x3f52('0x66')]=function(_0x87c2a,_0x3ea3a9){return db[_0x3f52('0x57')][_0x3f52('0x66')]()['then'](respondWithResult(_0x3ea3a9,null))[_0x3f52('0x2a')](handleError(_0x3ea3a9,null));};exports[_0x3f52('0x67')]=function(_0x9a0854,_0x393daf,_0x2b328c){if(_0x9a0854[_0x3f52('0x5f')]['id']){delete _0x9a0854[_0x3f52('0x5f')]['id'];}return db['ChatWebsite'][_0x3f52('0x5d')]({'where':{'id':_0x9a0854['params']['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x393daf,null))[_0x3f52('0x22')](function(_0xd09285){if(_0xd09285){_0x9a0854[_0x3f52('0x5f')][_0x3f52('0x68')]=_0xd09285['id'];return db[_0x3f52('0x69')][_0x3f52('0x5e')](_0x9a0854[_0x3f52('0x5f')]);}})[_0x3f52('0x22')](respondWithResult(_0x393daf,null))[_0x3f52('0x2a')](handleError(_0x393daf,null));};exports[_0x3f52('0x6a')]=function(_0x3995c6,_0x4fc058,_0x3e95a8){var _0x14a25a={'raw':![],'where':{}};var _0x592bcb={};var _0x48aa76={'count':0x0,'rows':[]};return db[_0x3f52('0x57')][_0x3f52('0x6b')]({'where':{'id':_0x3995c6['params']['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x4fc058,null))['then'](function(_0x11e30d){if(_0x11e30d){_0x592bcb[_0x3f52('0x3e')]=_['keys'](db['Disposition'][_0x3f52('0x3d')]);_0x592bcb['query']=_['keys'](_0x3995c6[_0x3f52('0x3f')]);_0x592bcb['filters']=_[_0x3f52('0x43')](_0x592bcb[_0x3f52('0x3e')],_0x592bcb['query']);_0x14a25a['attributes']=_[_0x3f52('0x43')](_0x592bcb['model'],qs['fields'](_0x3995c6['query'][_0x3f52('0x45')]));_0x14a25a['attributes']=_0x14a25a[_0x3f52('0x44')][_0x3f52('0x46')]?_0x14a25a[_0x3f52('0x44')]:_0x592bcb[_0x3f52('0x3e')];if(!_0x3995c6[_0x3f52('0x3f')]['hasOwnProperty'](_0x3f52('0x48'))){_0x14a25a['limit']=qs[_0x3f52('0x2f')](_0x3995c6['query']['limit']);_0x14a25a[_0x3f52('0x2e')]=qs[_0x3f52('0x2e')](_0x3995c6[_0x3f52('0x3f')][_0x3f52('0x2e')]);}_0x14a25a[_0x3f52('0x49')]=qs[_0x3f52('0x4a')](_0x3995c6['query'][_0x3f52('0x4a')]);_0x14a25a['where']=qs[_0x3f52('0x4c')](_['pick'](_0x3995c6[_0x3f52('0x3f')],_0x592bcb[_0x3f52('0x4c')]));_0x14a25a[_0x3f52('0x4b')]['ChatWebsiteId']=_0x11e30d['id'];if(_0x3995c6[_0x3f52('0x3f')][_0x3f52('0x51')]){_0x14a25a[_0x3f52('0x4b')]=_[_0x3f52('0x50')](_0x14a25a[_0x3f52('0x4b')],{'$or':_['map'](_0x14a25a[_0x3f52('0x44')],function(_0x866f55){var _0x45baaa={};_0x45baaa[_0x866f55]={'$like':'%'+_0x3995c6['query']['filter']+'%'};return _0x45baaa;})});}_0x14a25a=_[_0x3f52('0x50')]({},_0x14a25a,_0x3995c6[_0x3f52('0x56')]);return db[_0x3f52('0x69')][_0x3f52('0x2d')]({'where':_0x14a25a[_0x3f52('0x4b')]})[_0x3f52('0x22')](function(_0x5c4114){_0x48aa76[_0x3f52('0x2d')]=_0x5c4114;if(_0x3995c6[_0x3f52('0x3f')][_0x3f52('0x6c')]){_0x14a25a[_0x3f52('0x58')]=[{'all':!![]}];}return db[_0x3f52('0x69')][_0x3f52('0x59')](_0x14a25a);})[_0x3f52('0x22')](function(_0x1d7ef6){_0x48aa76[_0x3f52('0x5a')]=_0x1d7ef6;return _0x48aa76;});}})[_0x3f52('0x22')](respondWithFilteredResult(_0x4fc058,_0x14a25a))['catch'](handleError(_0x4fc058,null));};exports['removeDispositions']=function(_0x33b355,_0x325fd5,_0x3f420e){var _0x2310da;return db['ChatWebsite'][_0x3f52('0x5d')]({'where':{'id':_0x33b355['params']['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x325fd5,null))[_0x3f52('0x22')](function(_0x5a9099){if(_0x5a9099){return _0x5a9099[_0x3f52('0x6d')](_0x33b355[_0x3f52('0x3f')][_0x3f52('0x6e')]);}})[_0x3f52('0x22')](respondWithStatusCode(_0x325fd5,null))['catch'](handleError(_0x325fd5,null));};exports[_0x3f52('0x6f')]=function(_0xfcb449,_0x46b0a2,_0x3bb0b3){if(_0xfcb449['body']['id']){delete _0xfcb449[_0x3f52('0x5f')]['id'];}return db[_0x3f52('0x57')][_0x3f52('0x5d')]({'where':{'id':_0xfcb449[_0x3f52('0x5c')]['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x46b0a2,null))[_0x3f52('0x22')](function(_0x14dd86){if(_0x14dd86){_0xfcb449[_0x3f52('0x5f')]['ChatWebsiteId']=_0x14dd86['id'];return db['CannedAnswer'][_0x3f52('0x5e')](_0xfcb449[_0x3f52('0x5f')]);}})[_0x3f52('0x22')](respondWithResult(_0x46b0a2,null))[_0x3f52('0x2a')](handleError(_0x46b0a2,null));};exports[_0x3f52('0x70')]=function(_0x4ec562,_0x1013d,_0xb44556){var _0x536fb7={'raw':![],'where':{}};var _0x177f2d={};var _0x4ab6d7={'count':0x0,'rows':[]};return db[_0x3f52('0x57')][_0x3f52('0x6b')]({'where':{'id':_0x4ec562['params']['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x1013d,null))['then'](function(_0x41efec){if(_0x41efec){_0x177f2d[_0x3f52('0x3e')]=_[_0x3f52('0x42')](db[_0x3f52('0x71')][_0x3f52('0x3d')]);_0x177f2d[_0x3f52('0x3f')]=_[_0x3f52('0x42')](_0x4ec562[_0x3f52('0x3f')]);_0x177f2d[_0x3f52('0x4c')]=_[_0x3f52('0x43')](_0x177f2d[_0x3f52('0x3e')],_0x177f2d['query']);_0x536fb7[_0x3f52('0x44')]=_[_0x3f52('0x43')](_0x177f2d[_0x3f52('0x3e')],qs[_0x3f52('0x45')](_0x4ec562['query']['fields']));_0x536fb7[_0x3f52('0x44')]=_0x536fb7['attributes']['length']?_0x536fb7[_0x3f52('0x44')]:_0x177f2d[_0x3f52('0x3e')];if(!_0x4ec562['query'][_0x3f52('0x47')]('nolimit')){_0x536fb7[_0x3f52('0x2f')]=qs['limit'](_0x4ec562[_0x3f52('0x3f')][_0x3f52('0x2f')]);_0x536fb7[_0x3f52('0x2e')]=qs['offset'](_0x4ec562[_0x3f52('0x3f')]['offset']);}_0x536fb7[_0x3f52('0x49')]=qs[_0x3f52('0x4a')](_0x4ec562['query'][_0x3f52('0x4a')]);_0x536fb7['where']=qs['filters'](_['pick'](_0x4ec562[_0x3f52('0x3f')],_0x177f2d[_0x3f52('0x4c')]));_0x536fb7[_0x3f52('0x4b')]['ChatWebsiteId']=_0x41efec['id'];if(_0x4ec562[_0x3f52('0x3f')][_0x3f52('0x51')]){_0x536fb7['where']=_[_0x3f52('0x50')](_0x536fb7[_0x3f52('0x4b')],{'$or':_[_0x3f52('0x52')](_0x536fb7[_0x3f52('0x44')],function(_0x55d187){var _0x2b406c={};_0x2b406c[_0x55d187]={'$like':'%'+_0x4ec562[_0x3f52('0x3f')]['filter']+'%'};return _0x2b406c;})});}_0x536fb7=_[_0x3f52('0x50')]({},_0x536fb7,_0x4ec562['options']);return db[_0x3f52('0x71')][_0x3f52('0x2d')]({'where':_0x536fb7[_0x3f52('0x4b')]})['then'](function(_0x46f1b0){_0x4ab6d7[_0x3f52('0x2d')]=_0x46f1b0;if(_0x4ec562[_0x3f52('0x3f')]['includeAll']){_0x536fb7[_0x3f52('0x58')]=[{'all':!![]}];}return db[_0x3f52('0x71')][_0x3f52('0x59')](_0x536fb7);})['then'](function(_0x3e0962){_0x4ab6d7[_0x3f52('0x5a')]=_0x3e0962;return _0x4ab6d7;});}})[_0x3f52('0x22')](respondWithFilteredResult(_0x1013d,_0x536fb7))[_0x3f52('0x2a')](handleError(_0x1013d,null));};exports['removeAnswers']=function(_0x1be10b,_0x41e1ce,_0x124def){var _0xf65814;return db[_0x3f52('0x57')][_0x3f52('0x5d')]({'where':{'id':_0x1be10b['params']['id']}})['then'](handleEntityNotFound(_0x41e1ce,null))[_0x3f52('0x22')](function(_0x5e155a){if(_0x5e155a){return _0x5e155a[_0x3f52('0x72')](_0x1be10b[_0x3f52('0x3f')][_0x3f52('0x6e')]);}})[_0x3f52('0x22')](respondWithStatusCode(_0x41e1ce,null))[_0x3f52('0x2a')](handleError(_0x41e1ce,null));};exports['addLogo']=function(_0x279fb6,_0x46339d,_0x24f88c){_0x279fb6[_0x3f52('0x5f')][_0x3f52('0x73')]=_0x279fb6[_0x3f52('0x74')][_0x3f52('0x75')];return db[_0x3f52('0x57')][_0x3f52('0x5d')]({'where':{'id':_0x279fb6['params']['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x46339d,null))[_0x3f52('0x22')](saveUpdates(_0x279fb6[_0x3f52('0x5f')],null))['then'](respondWithResult(_0x46339d,null))[_0x3f52('0x2a')](handleError(_0x46339d,null));};exports[_0x3f52('0x76')]=function(_0xd31914,_0x55718d,_0x490646){_0xd31914[_0x3f52('0x5f')][_0x3f52('0x77')]=_0xd31914[_0x3f52('0x74')][_0x3f52('0x75')];return db['ChatWebsite'][_0x3f52('0x5d')]({'where':{'id':_0xd31914[_0x3f52('0x5c')]['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x55718d,null))[_0x3f52('0x22')](saveUpdates(_0xd31914[_0x3f52('0x5f')],null))[_0x3f52('0x22')](respondWithResult(_0x55718d,null))[_0x3f52('0x2a')](handleError(_0x55718d,null));};exports[_0x3f52('0x78')]=function(_0x497565,_0x24a441,_0x7c8d49){_0x497565[_0x3f52('0x5f')][_0x3f52('0x79')]=_0x497565[_0x3f52('0x74')][_0x3f52('0x75')];return db[_0x3f52('0x57')][_0x3f52('0x5d')]({'where':{'id':_0x497565['params']['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x24a441,null))['then'](saveUpdates(_0x497565[_0x3f52('0x5f')],null))['then'](respondWithResult(_0x24a441,null))[_0x3f52('0x2a')](handleError(_0x24a441,null));};exports[_0x3f52('0x7a')]=function(_0x59f643,_0x22c2ef,_0x3da651){_0x59f643[_0x3f52('0x5f')]['systemAvatar']=_0x59f643[_0x3f52('0x74')][_0x3f52('0x75')];return db[_0x3f52('0x57')]['find']({'where':{'id':_0x59f643[_0x3f52('0x5c')]['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x22c2ef,null))[_0x3f52('0x22')](saveUpdates(_0x59f643[_0x3f52('0x5f')],null))[_0x3f52('0x22')](respondWithResult(_0x22c2ef,null))[_0x3f52('0x2a')](handleError(_0x22c2ef,null));};exports['getLogo']=function(_0x5a4661,_0x137be1,_0x4ce0ea){var _0x44bfbe=path['join'](config[_0x3f52('0x7b')],'server/files/images/logos/default_logo.png');var _0x7055fa={'where':{'id':_0x5a4661[_0x3f52('0x5c')]['id']},'attributes':['id',_0x3f52('0x73')],'raw':!![]};var _0x24e286=![];return require(_0x3f52('0x7c'))[_0x3f52('0x7d')]()[_0x3f52('0x22')](function(_0x1b2643){if(_0x1b2643){_0x24e286=_0x1b2643[_0x3f52('0x7e')];}})[_0x3f52('0x22')](function(){return db['ChatWebsite'][_0x3f52('0x5d')](_0x7055fa);})[_0x3f52('0x22')](handleEntityNotFound(_0x137be1,null))[_0x3f52('0x22')](function(_0x59cc0c){if(_0x59cc0c){if(!_[_0x3f52('0x7f')](_0x59cc0c[_0x3f52('0x73')])){if(fs['existsSync'](path[_0x3f52('0x80')](config[_0x3f52('0x7b')],_0x3f52('0x81'),_0x59cc0c[_0x3f52('0x73')]))&&_0x24e286){_0x44bfbe=path[_0x3f52('0x80')](config[_0x3f52('0x7b')],'server/files/images/logos/',_0x59cc0c[_0x3f52('0x73')]);}}return _0x137be1['download'](_0x44bfbe);}})[_0x3f52('0x2a')](handleError(_0x137be1,null));};exports[_0x3f52('0x82')]=function(_0x145c2a,_0x1da875,_0x11810a){var _0x45f148=path[_0x3f52('0x80')](config[_0x3f52('0x7b')],_0x3f52('0x83'));var _0x53ab8a={'where':{'id':_0x145c2a[_0x3f52('0x5c')]['id']},'attributes':['id',_0x3f52('0x77')],'raw':!![]};return db[_0x3f52('0x57')]['find'](_0x53ab8a)[_0x3f52('0x22')](handleEntityNotFound(_0x1da875,null))['then'](function(_0x447910){if(_0x447910){if(!_[_0x3f52('0x7f')](_0x447910['agentAvatar'])){if(fs['existsSync'](path[_0x3f52('0x80')](config[_0x3f52('0x7b')],_0x3f52('0x84'),_0x447910[_0x3f52('0x77')]))){_0x45f148=path[_0x3f52('0x80')](config[_0x3f52('0x7b')],_0x3f52('0x84'),_0x447910[_0x3f52('0x77')]);}}return _0x1da875[_0x3f52('0x85')](_0x45f148);}})[_0x3f52('0x2a')](handleError(_0x1da875,null));};exports['getCustomerAvatar']=function(_0x4d095d,_0x5b6d17,_0x477e91){var _0x2eaa20=path['join'](config[_0x3f52('0x7b')],_0x3f52('0x86'));var _0xde7796={'where':{'id':_0x4d095d[_0x3f52('0x5c')]['id']},'attributes':['id',_0x3f52('0x79'),_0x3f52('0x87')],'raw':!![]};return db['ChatWebsite'][_0x3f52('0x5d')](_0xde7796)[_0x3f52('0x22')](handleEntityNotFound(_0x5b6d17,null))['then'](function(_0x1663e0){if(_0x1663e0){if(!_[_0x3f52('0x7f')](_0x1663e0[_0x3f52('0x79')])){if(fs[_0x3f52('0x88')](path['join'](config[_0x3f52('0x7b')],'server/files/images/avatars/',_0x1663e0['customerAvatar']))&&_0x1663e0[_0x3f52('0x87')]){_0x2eaa20=path[_0x3f52('0x80')](config[_0x3f52('0x7b')],_0x3f52('0x84'),_0x1663e0[_0x3f52('0x79')]);}}return _0x5b6d17[_0x3f52('0x85')](_0x2eaa20);}})[_0x3f52('0x2a')](handleError(_0x5b6d17,null));};exports['getSystemAvatar']=function(_0x150eb7,_0xb4bfa2,_0x2ed6a5){var _0x945b6c=path[_0x3f52('0x80')](config[_0x3f52('0x7b')],_0x3f52('0x89'));var _0x442c02={'where':{'id':_0x150eb7[_0x3f52('0x5c')]['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db['ChatWebsite'][_0x3f52('0x5d')](_0x442c02)[_0x3f52('0x22')](handleEntityNotFound(_0xb4bfa2,null))['then'](function(_0x552a9c){if(_0x552a9c){if(!_[_0x3f52('0x7f')](_0x552a9c[_0x3f52('0x8a')])){if(fs[_0x3f52('0x88')](path[_0x3f52('0x80')](config['root'],_0x3f52('0x84'),_0x552a9c[_0x3f52('0x8a')]))){_0x945b6c=path[_0x3f52('0x80')](config[_0x3f52('0x7b')],_0x3f52('0x84'),_0x552a9c[_0x3f52('0x8a')]);}}return _0xb4bfa2[_0x3f52('0x85')](_0x945b6c);}})[_0x3f52('0x2a')](handleError(_0xb4bfa2,null));};exports['notify']=function(_0x4a74b0,_0x1659c9,_0x522dd3){var _0x552d83=require('user-agent-parser');var _0x3a2c2a=new _0x552d83();var _0x4d81e0=_0x3a2c2a[_0x3f52('0x8b')](_0x4a74b0[_0x3f52('0x8c')][_0x3f52('0x8d')])['getResult']();var _0x9c8d5={'body':_0x4a74b0['body'],'channel':_0x3f52('0x8e')};var _0x366e5c=[];var _0x53d3a9=[];var _0x46359b={};var _0xb400fd=![];return db[_0x3f52('0x8f')]['describe']()[_0x3f52('0x22')](function(_0x184b3d){if(!_0x184b3d){throw new db[(_0x3f52('0x90'))][(_0x3f52('0x91'))](_0x3f52('0x92'));}_0x366e5c=_[_0x3f52('0x93')](_[_0x3f52('0x42')](_0x184b3d),[_0x3f52('0x94'),'updatedAt']);_0x53d3a9=_[_0x3f52('0x93')](_[_0x3f52('0x42')](_0x184b3d),[_0x3f52('0x94'),_0x3f52('0x95'),'CompanyId','ListId']);if(_0x4a74b0[_0x3f52('0x5f')]['id']){delete _0x4a74b0[_0x3f52('0x5f')]['id'];}if(_[_0x3f52('0x7f')](_0x4a74b0['body'][_0x3f52('0x96')])){throw new db['Sequelize']['ValidationError'](_0x3f52('0x97'));}if(_[_0x3f52('0x7f')](_0x4a74b0[_0x3f52('0x5f')][_0x3f52('0x5f')])||_0x4a74b0[_0x3f52('0x5f')]['body']===''){throw new db[(_0x3f52('0x90'))]['ValidationError'](_0x3f52('0x98'));}if(_['isNil'](_0x4a74b0[_0x3f52('0x5f')][_0x3f52('0x99')])){throw new db[(_0x3f52('0x90'))]['ValidationError'](_0x3f52('0x9a')+_0x53d3a9);}if(!_[_0x3f52('0x9b')](_0x53d3a9,_0x4a74b0[_0x3f52('0x5f')][_0x3f52('0x99')])){throw new db['Sequelize']['ValidationError'](_0x3f52('0x9c')+_0x53d3a9);}_0x46359b[_0x4a74b0[_0x3f52('0x5f')][_0x3f52('0x99')]]=_0x4a74b0['body'][_0x3f52('0x96')];})[_0x3f52('0x22')](function(){return db[_0x3f52('0x57')]['find']({'where':{'id':_0x4a74b0[_0x3f52('0x5c')]['id']},'include':[{'model':db[_0x3f52('0x9d')],'as':_0x3f52('0x9e'),'include':[{'model':db['CmContact'],'as':_0x3f52('0x9f'),'where':_0x46359b,'limit':0x1,'order':[[_0x3f52('0x95'),'DESC']]}]},{'model':db[_0x3f52('0xa0')],'as':_0x3f52('0xa1')}]});})['then'](handleEntityNotFound(_0x1659c9,null))[_0x3f52('0x22')](function(_0xe1d953){if(_0xe1d953&&_0xe1d953[_0x3f52('0x9e')]){_0x9c8d5[_0x3f52('0xa2')]=_0xe1d953;_0x9c8d5[_0x3f52('0xa3')]=_0xe1d953[_0x3f52('0xa1')];_0x9c8d5['list']=_0xe1d953[_0x3f52('0x9e')];_0x9c8d5[_0x3f52('0xa3')]=_[_0x3f52('0xa4')](_0x9c8d5[_0x3f52('0xa3')],[_0x3f52('0xa5')],['asc']);if(_0x9c8d5[_0x3f52('0xa2')][_0x3f52('0xa1')]){delete _0x9c8d5[_0x3f52('0xa2')][_0x3f52('0xa1')];}if(_0x9c8d5['account']['List']&&_0x9c8d5[_0x3f52('0xa2')][_0x3f52('0x9e')][_0x3f52('0x9f')][_0x3f52('0x46')]){return _0x9c8d5[_0x3f52('0xa2')][_0x3f52('0x9e')][_0x3f52('0x9f')][0x0];}var _0x52feea=_['defaults'](_0x4a74b0[_0x3f52('0x5f')],{'firstName':_0x4a74b0[_0x3f52('0x5f')][_0x3f52('0x96')],'ListId':_0xe1d953[_0x3f52('0xa6')]});_0x52feea[_0x4a74b0[_0x3f52('0x5f')][_0x3f52('0x99')]]=_0x4a74b0[_0x3f52('0x5f')][_0x3f52('0x96')];return db[_0x3f52('0x8f')][_0x3f52('0x5e')](_0x52feea,{'fields':_0x366e5c,'raw':!![]});}})[_0x3f52('0x22')](handleEntityNotFound(_0x1659c9,null))[_0x3f52('0x22')](function(_0xc075c5){_0x9c8d5['contact']=_0xc075c5;if(_0xc075c5){var _0x471787={'ContactId':_0xc075c5['id'],'ChatWebsiteId':_0x4a74b0['params']['id'],'from':(_0xc075c5['firstName']||'')+'\x20'+(_0xc075c5[_0x3f52('0xa7')]||''),'customerIp':_0x4a74b0[_0x3f52('0x5f')][_0x3f52('0xa8')],'referer':_0x4a74b0[_0x3f52('0x5f')][_0x3f52('0xa9')],'browserName':_0x4d81e0['browser'][_0x3f52('0x3a')]&&_0x4d81e0[_0x3f52('0xaa')][_0x3f52('0xab')]?util[_0x3f52('0xac')](_0x3f52('0xad'),_0x4d81e0['browser']['name'],_0x4d81e0[_0x3f52('0xaa')]['version']):'unknown','browserVersion':_0x4d81e0[_0x3f52('0xaa')]['version']||'unknown','osName':util[_0x3f52('0xac')]('%s\x20%s',_0x4d81e0['os'][_0x3f52('0x3a')],_0x4d81e0['os'][_0x3f52('0xab')]),'osVersion':_0x4d81e0['os'][_0x3f52('0xab')],'deviceModel':_0x4d81e0['device'][_0x3f52('0x3e')]&&_0x4d81e0['device']['vendor']?util[_0x3f52('0xac')](_0x3f52('0xae'),_0x4d81e0['device'][_0x3f52('0x3e')],_0x4d81e0[_0x3f52('0xaf')]['vendor'],_0x4d81e0[_0x3f52('0xaf')][_0x3f52('0x53')]):null,'deviceVendor':_0x4d81e0['device'][_0x3f52('0xb0')],'deviceType':_0x4d81e0[_0x3f52('0xaf')]['type'],'formData':JSON[_0x3f52('0xb1')](_0x4a74b0[_0x3f52('0x5f')])};var _0x1f29c3={'ChatWebsiteId':_0x4a74b0[_0x3f52('0x5c')]['id'],'closed':![]};if(_0x4a74b0[_0x3f52('0x5f')]['threadId']){_0x1f29c3['threadId']=_0x4a74b0[_0x3f52('0x5f')][_0x3f52('0xb2')];return db[_0x3f52('0xb3')][_0x3f52('0x5d')]({'where':_0x1f29c3})['then'](function(_0x449b34){if(_0x449b34){return[_0x449b34,![]];}_0x471787[_0x3f52('0xb2')]=_0x4a74b0[_0x3f52('0x5f')][_0x3f52('0xb2')];_0x471787[_0x3f52('0xb4')]=_0x4a74b0[_0x3f52('0x5f')]['externalUrl'];return db[_0x3f52('0xb3')][_0x3f52('0x5e')](_0x471787)[_0x3f52('0x22')](function(_0x18e1b3){return[_0x18e1b3,!![]];});});}_0x1f29c3[_0x3f52('0xb5')]=_0xc075c5['id'];if(_0x4a74b0[_0x3f52('0x5f')][_0x3f52('0xb6')]&&_0x4a74b0[_0x3f52('0x5f')]['interaction']['id']){_0x1f29c3['id']=_0x4a74b0[_0x3f52('0x5f')]['interaction']['id'];return db[_0x3f52('0xb3')][_0x3f52('0x5d')]({'where':_0x1f29c3})[_0x3f52('0x22')](function(_0x283e23){if(_0x283e23){return[_0x283e23,![]];}return db[_0x3f52('0xb3')][_0x3f52('0x5e')](_0x471787)[_0x3f52('0x22')](function(_0xab2988){return[_0xab2988,!![]];});});}return db[_0x3f52('0xb3')][_0x3f52('0x5e')](_0x471787)[_0x3f52('0x22')](function(_0x588a4d){return[_0x588a4d,!![]];});}})['spread'](function(_0x62d147,_0x50dccc){if(_0x62d147){_0xb400fd=_0x50dccc;if(!_0x50dccc){var _0x25cf0b={'from':(_0x9c8d5['contact'][_0x3f52('0xb7')]||'')+'\x20'+(_0x9c8d5[_0x3f52('0xb8')][_0x3f52('0xa7')]||'')};if(_0x4a74b0[_0x3f52('0x5f')]['threadId']&&_0x4a74b0['body'][_0x3f52('0xb9')]&&_0x4a74b0[_0x3f52('0x5f')]['threadId']!=_0x4a74b0[_0x3f52('0x5f')][_0x3f52('0xb9')]){_0x25cf0b[_0x3f52('0xb2')]=_0x4a74b0[_0x3f52('0x5f')]['messageId'];}return _0x62d147[_0x3f52('0x35')](_0x25cf0b);}else{return _0x62d147;}}})[_0x3f52('0x22')](function(_0x2eab7a){_0x9c8d5[_0x3f52('0xb6')]=_0x2eab7a['get']({'plain':!![]});_0x9c8d5[_0x3f52('0xb6')]['created']=_0xb400fd;if(_0x9c8d5[_0x3f52('0xb6')]['created']){if(_0x9c8d5[_0x3f52('0xa2')][_0x3f52('0xba')]){_0x9c8d5[_0x3f52('0xa3')][_0x3f52('0xbb')]({'id':0x0,'priority':_0x9c8d5[_0x3f52('0xa3')][_0x3f52('0x46')]+0x1,'app':_0x3f52('0xbc'),'appdata':_0x3f52('0xbd'),'interval':_0x3f52('0xbe')});}}return db['ChatMessage']['create']({'body':_0x4a74b0['body']['body'],'ChatWebsiteId':_0x4a74b0[_0x3f52('0x5c')]['id'],'ChatInteractionId':_0x2eab7a['id'],'direction':'in','ContactId':_0x9c8d5[_0x3f52('0xb8')]['id'],'AttachmentId':_0x4a74b0[_0x3f52('0x5f')][_0x3f52('0xbf')]});})['then'](function(_0x4c1815){_0x9c8d5[_0x3f52('0x29')]=_0x4c1815;if(_0x9c8d5[_0x3f52('0xb6')][_0x3f52('0xc0')]){return db[_0x3f52('0xc1')][_0x3f52('0x5d')]({'attributes':['id',_0x3f52('0x3a')],'where':{'id':_0x9c8d5[_0x3f52('0xb6')][_0x3f52('0xc0')]}})['then'](function(_0x50640a){if(_0x50640a){_0x9c8d5[_0x3f52('0xa3')][_0x3f52('0xc2')]({'id':0x0,'priority':0x0,'app':_0x3f52('0xc3'),'appdata':_0x50640a[_0x3f52('0x3a')]+','+(_0x9c8d5[_0x3f52('0xa2')][_0x3f52('0xc4')]||0xa),'interval':_0x3f52('0xbe')});_0x9c8d5[_0x3f52('0xc5')]=!![];}return respondWithRpcPromise(_0x3f52('0xc6'),_0x3f52('0xc7'),_0x9c8d5);});}return respondWithRpcPromise(_0x3f52('0xc6'),_0x3f52('0xc7'),_0x9c8d5);})[_0x3f52('0x22')](function(_0x4cda53){respondWithRpcPromise(_0x3f52('0xc8'),_0x3f52('0xc8'),{'event':'notify','message':_0x4cda53},client9002);return _0x4cda53;})['then'](respondWithResult(_0x1659c9,null))[_0x3f52('0x2a')](handleError(_0x1659c9,null));};exports[_0x3f52('0xc9')]=function(_0x5974e6,_0x376365,_0x54b3f7){var _0x45083c,_0x8a4173,_0x27ebba;var _0x2d5c46=[];var _0x2cd2fc=[];var _0x2af1d5={};return db[_0x3f52('0x8f')][_0x3f52('0x66')]()[_0x3f52('0x22')](function(_0x2a57f8){if(!_0x2a57f8){throw new db[(_0x3f52('0x90'))]['ValidationError'](_0x3f52('0x92'));}_0x2cd2fc=_['difference'](_[_0x3f52('0x42')](_0x2a57f8),[_0x3f52('0x94'),_0x3f52('0x95')]);_0x2d5c46=_[_0x3f52('0x93')](_[_0x3f52('0x42')](_0x2a57f8),[_0x3f52('0x94'),'updatedAt','CompanyId',_0x3f52('0xa6')]);if(_0x5974e6[_0x3f52('0x5f')]['id']){delete _0x5974e6[_0x3f52('0x5f')]['id'];}if(_[_0x3f52('0x7f')](_0x5974e6[_0x3f52('0x5f')][_0x3f52('0x96')])){throw _0x376365['status'](0x1f4)['send'](new db[(_0x3f52('0x90'))][(_0x3f52('0x91'))](_0x3f52('0x97')));}if(_[_0x3f52('0x7f')](_0x5974e6['body'][_0x3f52('0x5f')])||_0x5974e6[_0x3f52('0x5f')]['body']===''){throw _0x376365[_0x3f52('0x2c')](0x1f4)['send'](new db[(_0x3f52('0x90'))][(_0x3f52('0x91'))]('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0x3f52('0x7f')](_0x5974e6[_0x3f52('0x5f')][_0x3f52('0xca')])){throw _0x376365[_0x3f52('0x2c')](0x1f4)[_0x3f52('0x3b')](new db['Sequelize'][(_0x3f52('0x91'))]('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x2d5c46));}if(!_[_0x3f52('0x9b')](_0x2d5c46,_0x5974e6[_0x3f52('0x5f')][_0x3f52('0xca')])){throw _0x376365[_0x3f52('0x2c')](0x1f4)[_0x3f52('0x3b')](new db[(_0x3f52('0x90'))][(_0x3f52('0x91'))](_0x3f52('0xcb')+_0x2d5c46));}_0x2af1d5[_0x5974e6[_0x3f52('0x5f')][_0x3f52('0xca')]]=_0x5974e6[_0x3f52('0x5f')]['from'];})[_0x3f52('0x22')](function(){return db[_0x3f52('0x57')][_0x3f52('0x5d')]({'where':{'id':_0x5974e6[_0x3f52('0x5c')]['id']},'include':[{'model':db[_0x3f52('0x9d')],'as':_0x3f52('0x9e')}]});})[_0x3f52('0x22')](handleEntityNotFound(_0x376365,null))[_0x3f52('0x22')](function(_0x1c2297){if(_0x1c2297&&_0x1c2297[_0x3f52('0x9e')]){_0x8a4173=_0x1c2297;var _0x33467c=_['defaults'](_0x5974e6[_0x3f52('0x5f')],{'firstName':_0x5974e6[_0x3f52('0x5f')][_0x3f52('0x96')],'phone':_0x5974e6[_0x3f52('0x5f')][_0x3f52('0x96')],'ListId':_0x1c2297[_0x3f52('0xa6')]});_0x33467c[_0x5974e6[_0x3f52('0x5f')][_0x3f52('0xca')]]=_0x5974e6[_0x3f52('0x5f')][_0x3f52('0x96')];return db[_0x3f52('0x8f')][_0x3f52('0xcc')]({'where':_0x2af1d5,'defaults':_0x33467c});}})[_0x3f52('0xcd')](function(_0x445b95){if(_0x445b95){_0x27ebba=_0x445b95;var _0x3af964=fs[_0x3f52('0xce')](path[_0x3f52('0x80')](config['root'],'server/files/templates/chatOfflineMessage.ejs'),_0x3f52('0xcf'));var _0x5edeb4=ejs[_0x3f52('0xd0')](_0x3af964,{'body':_[_0x3f52('0xd1')](_0x5974e6[_0x3f52('0x5f')][_0x3f52('0x5f')]),'bodyTitle':_0x8a4173[_0x3f52('0xd2')]});return db[_0x3f52('0xd3')]['create']({'body':_0x5edeb4,'ContactId':_0x445b95['id'],'ChatWebsiteId':_0x8a4173['id']});}})[_0x3f52('0x22')](function(_0x2b4830){if(_0x2b4830){_0x45083c=_0x2b4830;return db[_0x3f52('0xd4')]['findOne']({'where':{'service':!![]},'include':[{'model':db[_0x3f52('0xd5')],'as':_0x3f52('0xd6'),'raw':!![]}]});}})[_0x3f52('0x22')](function(_0x3b8ece){if(_0x3b8ece&&_0x3b8ece[_0x3f52('0xd6')]&&_0x8a4173[_0x3f52('0xd7')]){var _0x8c3d6f={'tls':{'rejectUnauthorized':![]}};if(_0x3b8ece['Smtp'][_0x3f52('0xd8')]){_0x8c3d6f['service']=_0x3b8ece[_0x3f52('0xd6')][_0x3f52('0xd8')];}else{_0x8c3d6f['host']=_0x3b8ece[_0x3f52('0xd6')][_0x3f52('0xd9')];_0x8c3d6f[_0x3f52('0xda')]=_0x3b8ece[_0x3f52('0xd6')][_0x3f52('0xda')];_0x8c3d6f[_0x3f52('0xdb')]=_0x3b8ece[_0x3f52('0xd6')]['secure'];}if(_0x3b8ece[_0x3f52('0xd6')][_0x3f52('0xdc')]){_0x8c3d6f[_0x3f52('0xdd')]={'user':_0x3b8ece[_0x3f52('0xd6')]['user'],'pass':_0x3b8ece['Smtp'][_0x3f52('0xde')]};}return respondWithRpcPromise('SendMail',_0x3f52('0xdf'),{'account':_0x8c3d6f,'message':{'from':util['format'](_0x3f52('0xe0'),_0x3b8ece[_0x3f52('0x3a')],_0x3b8ece[_0x3f52('0xe1')]||_0x3b8ece[_0x3f52('0xd6')]['user']),'to':_0x8a4173[_0x3f52('0xd7')],'subject':_0x8a4173[_0x3f52('0xe2')],'text':_0x45083c[_0x3f52('0x5f')]}},client9003)[_0x3f52('0x22')](function(){return _0x45083c;})[_0x3f52('0x2a')](function(_0x1f809a){console['error'](_0x1f809a);});}})['then'](function(){if(_0x45083c){return _0x45083c;}})[_0x3f52('0x22')](respondWithResult(_0x376365,null))['catch'](handleError(_0x376365,null));};exports['addInteraction']=function(_0x167e15,_0x5ad463,_0x545866){return db[_0x3f52('0xb3')][_0x3f52('0x5d')]({'where':{'id':_0x167e15[_0x3f52('0x5c')]['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x5ad463,null))[_0x3f52('0x22')](function(_0xc46c50){if(_0xc46c50){return _0xc46c50[_0x3f52('0xe3')](_0x167e15['body'][_0x3f52('0x6e')],_[_0x3f52('0xe4')](_0x167e15[_0x3f52('0x5f')],[_0x3f52('0x6e'),'id'])||{});}})[_0x3f52('0x22')](respondWithResult(_0x5ad463,null))['catch'](handleError(_0x5ad463,null));};exports[_0x3f52('0xe5')]=function(_0x3bfb88,_0x1ce45f,_0x46abe1){var _0x51c4b9={'raw':![],'where':{}};var _0x492386={};var _0x38559e={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x3f52('0x6b')]({'where':{'id':_0x3bfb88[_0x3f52('0x5c')]['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x1ce45f,null))[_0x3f52('0x22')](function(_0x33fa16){if(_0x33fa16){_0x492386[_0x3f52('0x3e')]=_[_0x3f52('0x42')](db[_0x3f52('0xb3')][_0x3f52('0x3d')]);_0x492386['query']=_[_0x3f52('0x42')](_0x3bfb88[_0x3f52('0x3f')]);_0x492386[_0x3f52('0x4c')]=_[_0x3f52('0x43')](_0x492386[_0x3f52('0x3e')],_0x492386[_0x3f52('0x3f')]);_0x51c4b9['attributes']=_[_0x3f52('0x43')](_0x492386[_0x3f52('0x3e')],qs[_0x3f52('0x45')](_0x3bfb88[_0x3f52('0x3f')][_0x3f52('0x45')]));_0x51c4b9[_0x3f52('0x44')]=_0x51c4b9[_0x3f52('0x44')][_0x3f52('0x46')]?_0x51c4b9[_0x3f52('0x44')]:_0x492386[_0x3f52('0x3e')];if(!_0x3bfb88['query']['hasOwnProperty'](_0x3f52('0x48'))){_0x51c4b9[_0x3f52('0x2f')]=qs[_0x3f52('0x2f')](_0x3bfb88[_0x3f52('0x3f')][_0x3f52('0x2f')]);_0x51c4b9[_0x3f52('0x2e')]=qs[_0x3f52('0x2e')](_0x3bfb88[_0x3f52('0x3f')][_0x3f52('0x2e')]);}_0x51c4b9[_0x3f52('0x49')]=qs[_0x3f52('0x4a')](_0x3bfb88[_0x3f52('0x3f')]['sort']);_0x51c4b9['where']=qs[_0x3f52('0x4c')](_[_0x3f52('0x4d')](_0x3bfb88['query'],_0x492386[_0x3f52('0x4c')]));_0x51c4b9['where'][_0x3f52('0x68')]=_0x33fa16['id'];if(_0x3bfb88[_0x3f52('0x3f')][_0x3f52('0x51')]){_0x51c4b9['where']=_[_0x3f52('0x50')](_0x51c4b9[_0x3f52('0x4b')],{'$or':_['map'](_0x51c4b9[_0x3f52('0x44')],function(_0x2bd3f0){var _0x299f6e={};_0x299f6e[_0x2bd3f0]={'$like':'%'+_0x3bfb88[_0x3f52('0x3f')][_0x3f52('0x51')]+'%'};return _0x299f6e;})});}_0x51c4b9=_[_0x3f52('0x50')]({},_0x51c4b9,_0x3bfb88['options']);return db[_0x3f52('0xb3')]['count']({'where':_0x51c4b9[_0x3f52('0x4b')]})[_0x3f52('0x22')](function(_0x40278e){_0x38559e[_0x3f52('0x2d')]=_0x40278e;if(_0x3bfb88[_0x3f52('0x3f')]['includeAll']){_0x51c4b9[_0x3f52('0x58')]=[{'model':db[_0x3f52('0x8f')],'as':_0x3f52('0xe6'),'required':![]},{'model':db[_0x3f52('0xc1')],'as':_0x3f52('0xe7'),'attributes':[_0x3f52('0x3a'),_0x3f52('0xe8'),_0x3f52('0xe9')],'required':![]},{'model':db[_0x3f52('0xea')],'as':'Tags','attributes':['id',_0x3f52('0x3a'),_0x3f52('0xeb')],'where':_0x3bfb88[_0x3f52('0x3f')][_0x3f52('0xec')]?{'id':_0x3bfb88[_0x3f52('0x3f')][_0x3f52('0xec')]}:undefined,'required':_0x3bfb88[_0x3f52('0x3f')][_0x3f52('0xec')]?!![]:![]}];}return db[_0x3f52('0xb3')][_0x3f52('0x59')](_0x51c4b9);})[_0x3f52('0x22')](function(_0x159b81){_0x38559e['rows']=_0x159b81;return _0x38559e;});}})['then'](respondWithFilteredResult(_0x1ce45f,_0x51c4b9))[_0x3f52('0x2a')](handleError(_0x1ce45f,null));};function iftimePromise(_0x44014e,_0x5e068b){return respondWithRpcPromise('Command',_0x3f52('0xed'),{'command':_0x5e068b['timezone']?util[_0x3f52('0xac')](_0x3f52('0xee'),_0x44014e[_0x3f52('0xef')],_0x5e068b[_0x3f52('0xf0')]):util[_0x3f52('0xac')](_0x3f52('0xf1'),_0x44014e[_0x3f52('0xef')])},client9002)[_0x3f52('0x22')](function(_0x452f13){var _0x401144=_0x452f13&&_0x452f13[_0x3f52('0xf2')]('true')>=0x0?!![]:![];logger[_0x3f52('0x23')]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x5e068b['id'],_0x44014e['id'],_0x44014e[_0x3f52('0xef')],_0x401144?_0x3f52('0xf3'):_0x3f52('0xf4'),_0x5e068b[_0x3f52('0xf0')]?_0x5e068b[_0x3f52('0xf0')]:_0x3f52('0xf5'));return _0x401144;})[_0x3f52('0x2a')](function(_0x1a64d9){logger[_0x3f52('0x27')](_0x3f52('0xf6'),_0x5e068b['id'],_0x44014e['id'],_0x44014e[_0x3f52('0xef')],util[_0x3f52('0xf7')](_0x1a64d9,{'showHidden':![],'depth':null}),_0x5e068b[_0x3f52('0xf0')]?_0x5e068b[_0x3f52('0xf0')]:'No\x20timezone');return![];});}exports[_0x3f52('0xed')]=function(_0x20bfa8,_0x3b6b6f,_0x11e7d7){var _0x17d94f=0x0;var _0x3a15a6=0x0;var _0x15af61=![];var _0xc86c14;var _0x58e14d;return db[_0x3f52('0x57')][_0x3f52('0x5d')]({'where':{'id':_0x20bfa8[_0x3f52('0x5c')]['id']},'include':[{'model':db[_0x3f52('0xf8')],'as':_0x3f52('0xf8'),'include':[{'model':db['Interval'],'as':_0x3f52('0xf9'),'attributes':['id','interval'],'raw':!![]}]}]})['then'](handleEntityNotFound(_0x3b6b6f,null))[_0x3f52('0x22')](function(_0x2ce533){if(_0x2ce533){_0xc86c14=_0x2ce533;return _0x2ce533[_0x3f52('0xfa')]({'raw':!![]});}})[_0x3f52('0x22')](function(_0x33f599){if(_0xc86c14){if(_0x33f599){_0x58e14d=_0x33f599;}}return require(_0x3f52('0x7c'))[_0x3f52('0x7d')]();})[_0x3f52('0x22')](function(_0x21d4ba){if(_0x21d4ba){_0x3a15a6=_0x21d4ba[_0x3f52('0xfb')];_0x15af61=_0x21d4ba[_0x3f52('0x7e')];}})[_0x3f52('0x22')](function(){return db['ChatInteraction'][_0x3f52('0x2d')]({'where':{'closed':![]}});})[_0x3f52('0x22')](function(_0x335ab1){_0x17d94f=_0x335ab1;if(_0x3a15a6&&_0x335ab1>_0x3a15a6){return db[_0x3f52('0xfc')][_0x3f52('0x6b')]({'where':{'id':0x1}})[_0x3f52('0x22')](function(_0x270a01){if(_0x270a01){_0x270a01[_0x3f52('0xfd')](_0x3f52('0xfe'));}});}})['then'](function(){if(_0xc86c14[_0x3f52('0xf8')]&&_0xc86c14['Interval'][_0x3f52('0xf9')]){var _0x44386a=[];for(var _0xf6752c=0x0;_0xf6752c<_0xc86c14[_0x3f52('0xf8')][_0x3f52('0xf9')][_0x3f52('0x46')];_0xf6752c++){var _0x644b3b=_0xc86c14['Interval'][_0x3f52('0xf9')][_0xf6752c][_0x3f52('0x61')]({'plain':!![]});_0x44386a['push'](iftimePromise(_0x644b3b,_0xc86c14));}return BPromise[_0x3f52('0xff')](_0x44386a)[_0x3f52('0x22')](function(_0x57fe1d){return _[_0x3f52('0x100')](_0x57fe1d);});}else{return!![];}})[_0x3f52('0x22')](function(_0x4e56f3){var _0x376bc1=fs[_0x3f52('0xce')](path['join'](config[_0x3f52('0x7b')],'server/files/chat/iframe.js'),_0x3f52('0xcf'));var _0x14149c={'remote':_0xc86c14['remote'],'query':querystring[_0x3f52('0xb1')](_[_0x3f52('0x50')](_0xc86c14[_0x3f52('0x61')]({'plain':!![]}),{'customerIp':_0x20bfa8['headers'][_0x3f52('0x101')]||_0x20bfa8['headers']['x-real-ip']||_0x20bfa8[_0x3f52('0x102')][_0x3f52('0x103')]||_0x20bfa8['ip'],'referer':_0x20bfa8[_0x3f52('0x8c')]['referer'],'openedInteractions':_0x17d94f,'maxInteractions':_0x3a15a6,'virtual':_0x15af61['virtual'],'online':_0x4e56f3,'custom':_0x15af61}))[_0x3f52('0x104')](/'/g,'\x5c\x27')};_0x3b6b6f['send'](ejs[_0x3f52('0xd0')](Mustache[_0x3f52('0xd0')](_0x376bc1,_0x14149c),{'proactiveActions':_0x58e14d,'alignment':_0xc86c14[_0x3f52('0x105')],'verticalAlignment':_0xc86c14['verticalAlignment']}));})['catch'](handleError(_0x3b6b6f,null));};exports[_0x3f52('0x106')]=function(_0x33e310,_0x92343c,_0x190ee3){return db[_0x3f52('0x57')][_0x3f52('0x6b')]({'where':{'id':_0x33e310['params']['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x92343c,null))['then'](function(_0x3f5f22){if(_0x3f5f22){return db[_0x3f52('0x107')][_0x3f52('0x108')](function(_0x580ba6){return db[_0x3f52('0xa0')][_0x3f52('0x36')]({'where':{'ChatWebsiteId':_0x33e310['params']['id']},'transaction':_0x580ba6})[_0x3f52('0x22')](function(_0x81908a){var _0x568d40=_[_0x3f52('0x52')](_0x33e310[_0x3f52('0x5f')],function(_0x497560){_0x497560['ChatWebsiteId']=_0x33e310[_0x3f52('0x5c')]['id'];return _0x497560;});return db[_0x3f52('0xa0')][_0x3f52('0x109')](_0x568d40,{'transaction':_0x580ba6});});})['then'](function(){return db[_0x3f52('0xa0')][_0x3f52('0x10a')]({'where':{'ChatWebsiteId':_0x33e310[_0x3f52('0x5c')]['id']},'order':_0x3f52('0xa5')});});}})[_0x3f52('0x22')](respondWithResult(_0x92343c,null))['catch'](handleError(_0x92343c,null));};exports['getApplications']=function(_0x23fedf,_0x5d81ad,_0x2af003){var _0x1eef77={};var _0x5a3d47={};var _0x573251;var _0x1418bb;return db[_0x3f52('0x57')][_0x3f52('0x6b')]({'where':{'id':_0x23fedf[_0x3f52('0x5c')]['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x5d81ad,null))[_0x3f52('0x22')](function(_0x4c7641){if(_0x4c7641){_0x573251=_0x4c7641;_0x5a3d47[_0x3f52('0x3e')]=_[_0x3f52('0x42')](db[_0x3f52('0xa0')][_0x3f52('0x3d')]);_0x5a3d47[_0x3f52('0x3f')]=_[_0x3f52('0x42')](_0x23fedf[_0x3f52('0x3f')]);_0x5a3d47[_0x3f52('0x4c')]=_[_0x3f52('0x43')](_0x5a3d47[_0x3f52('0x3e')],_0x5a3d47['query']);_0x1eef77['attributes']=_[_0x3f52('0x43')](_0x5a3d47[_0x3f52('0x3e')],qs[_0x3f52('0x45')](_0x23fedf['query'][_0x3f52('0x45')]));_0x1eef77[_0x3f52('0x44')]=_0x1eef77[_0x3f52('0x44')][_0x3f52('0x46')]?_0x1eef77[_0x3f52('0x44')]:_0x5a3d47['model'];_0x1eef77[_0x3f52('0x49')]=qs[_0x3f52('0x4a')](_0x23fedf['query'][_0x3f52('0x4a')]);_0x1eef77['where']=qs['filters'](_[_0x3f52('0x4d')](_0x23fedf[_0x3f52('0x3f')],_0x5a3d47['filters']));if(_0x23fedf['query'][_0x3f52('0x51')]){_0x1eef77[_0x3f52('0x4b')]=_['merge'](_0x1eef77[_0x3f52('0x4b')],{'$or':_[_0x3f52('0x52')](_0x1eef77['attributes'],function(_0x2b885a){var _0x4cd649={};_0x4cd649[_0x2b885a]={'$like':'%'+_0x23fedf[_0x3f52('0x3f')][_0x3f52('0x51')]+'%'};return _0x4cd649;})});}_0x1eef77=_[_0x3f52('0x50')]({},_0x1eef77,_0x23fedf[_0x3f52('0x56')]);return _0x573251['getApplications'](_0x1eef77);}})[_0x3f52('0x22')](function(_0x40beed){if(_0x40beed){_0x1418bb=_0x40beed[_0x3f52('0x46')];if(!_0x23fedf[_0x3f52('0x3f')]['hasOwnProperty'](_0x3f52('0x48'))){_0x1eef77[_0x3f52('0x2f')]=qs[_0x3f52('0x2f')](_0x23fedf['query'][_0x3f52('0x2f')]);_0x1eef77[_0x3f52('0x2e')]=qs[_0x3f52('0x2e')](_0x23fedf[_0x3f52('0x3f')][_0x3f52('0x2e')]);}return _0x573251['getApplications'](_0x1eef77);}})[_0x3f52('0x22')](function(_0x1866da){if(_0x1866da){return _0x1866da?{'count':_0x1418bb,'rows':_0x1866da}:null;}})['then'](respondWithResult(_0x5d81ad,null))['catch'](handleError(_0x5d81ad,null));};exports[_0x3f52('0x10b')]=function(_0x502d51,_0x1bec34,_0x2f2bed){return db[_0x3f52('0x10c')][_0x3f52('0x5d')]({'where':{'id':_0x502d51[_0x3f52('0x5c')]['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x1bec34,null))[_0x3f52('0x22')](function(_0x4a9912){if(_0x4a9912){return _0x4a9912['addProactiveActions'](_0x502d51[_0x3f52('0x5f')]['ids'],_[_0x3f52('0xe4')](_0x502d51[_0x3f52('0x5f')],[_0x3f52('0x6e'),'id'])||{});}})[_0x3f52('0x22')](respondWithResult(_0x1bec34,null))['catch'](handleError(_0x1bec34,null));};exports[_0x3f52('0xfa')]=function(_0x4b4f2f,_0x3a450c,_0x37623e){var _0x13122a={};var _0x28cdc6={};var _0x307994;var _0x3b4d28;return db[_0x3f52('0x57')][_0x3f52('0x6b')]({'where':{'id':_0x4b4f2f[_0x3f52('0x5c')]['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x3a450c,null))['then'](function(_0x18251d){if(_0x18251d){_0x307994=_0x18251d;_0x28cdc6[_0x3f52('0x3e')]=_[_0x3f52('0x42')](db[_0x3f52('0x10d')]['rawAttributes']);_0x28cdc6[_0x3f52('0x3f')]=_[_0x3f52('0x42')](_0x4b4f2f[_0x3f52('0x3f')]);_0x28cdc6['filters']=_['intersection'](_0x28cdc6[_0x3f52('0x3e')],_0x28cdc6[_0x3f52('0x3f')]);_0x13122a[_0x3f52('0x44')]=_[_0x3f52('0x43')](_0x28cdc6['model'],qs[_0x3f52('0x45')](_0x4b4f2f['query'][_0x3f52('0x45')]));_0x13122a[_0x3f52('0x44')]=_0x13122a[_0x3f52('0x44')][_0x3f52('0x46')]?_0x13122a['attributes']:_0x28cdc6[_0x3f52('0x3e')];_0x13122a[_0x3f52('0x49')]=qs[_0x3f52('0x4a')](_0x4b4f2f[_0x3f52('0x3f')]['sort']);_0x13122a[_0x3f52('0x4b')]=qs[_0x3f52('0x4c')](_[_0x3f52('0x4d')](_0x4b4f2f[_0x3f52('0x3f')],_0x28cdc6[_0x3f52('0x4c')]));if(_0x4b4f2f[_0x3f52('0x3f')]['filter']){_0x13122a[_0x3f52('0x4b')]=_[_0x3f52('0x50')](_0x13122a['where'],{'$or':_[_0x3f52('0x52')](_0x13122a[_0x3f52('0x44')],function(_0x1b587a){var _0x1c7ae8={};_0x1c7ae8[_0x1b587a]={'$like':'%'+_0x4b4f2f[_0x3f52('0x3f')]['filter']+'%'};return _0x1c7ae8;})});}_0x13122a=_['merge']({},_0x13122a,_0x4b4f2f[_0x3f52('0x56')]);return _0x307994[_0x3f52('0xfa')](_0x13122a);}})[_0x3f52('0x22')](function(_0x23a14e){if(_0x23a14e){_0x3b4d28=_0x23a14e[_0x3f52('0x46')];if(!_0x4b4f2f[_0x3f52('0x3f')]['hasOwnProperty'](_0x3f52('0x48'))){_0x13122a[_0x3f52('0x2f')]=qs['limit'](_0x4b4f2f[_0x3f52('0x3f')]['limit']);_0x13122a[_0x3f52('0x2e')]=qs[_0x3f52('0x2e')](_0x4b4f2f[_0x3f52('0x3f')][_0x3f52('0x2e')]);}return _0x307994[_0x3f52('0xfa')](_0x13122a);}})['then'](function(_0x402109){if(_0x402109){return _0x402109?{'count':_0x3b4d28,'rows':_0x402109}:null;}})['then'](respondWithResult(_0x3a450c,null))['catch'](handleError(_0x3a450c,null));};exports[_0x3f52('0x10e')]=function(_0x265adb,_0x50a840,_0x3e958b){var _0x218f78=_0x265adb[_0x3f52('0x3f')][_0x3f52('0x10f')]===_0x3f52('0x110')?'offlineForm':_0x3f52('0x111');return db['ChatWebsite'][_0x3f52('0x5d')]({'attributes':['id',_0x218f78],'where':{'id':_0x265adb[_0x3f52('0x5c')]['id']}})['then'](handleEntityNotFound(_0x50a840,null))[_0x3f52('0x22')](function(_0x160995){if(_0x160995){var _0x33b0d0=_0x160995[_0x218f78];var _0x1e4d79=_0x33b0d0&&_0x33b0d0[_0x3f52('0x112')]?_0x33b0d0['items']:[];_0x50a840[_0x3f52('0x3b')]({'fromKey':_['isNil'](_0x33b0d0[_0x3f52('0x113')])?undefined:_0x33b0d0[_0x3f52('0x113')],'count':_0x1e4d79[_0x3f52('0x46')],'rows':_0x1e4d79});}})['catch'](handleError(_0x50a840,null));};exports[_0x3f52('0x114')]=function(_0x2512ab,_0x31a1bf,_0x183be3){var _0x34232f={'raw':!![],'where':{}};var _0x360e4a={};var _0x5951e8={'count':0x0,'rows':[]};return db[_0x3f52('0x57')][_0x3f52('0x6b')]({'where':{'id':_0x2512ab[_0x3f52('0x5c')]['id']}})['then'](handleEntityNotFound(_0x31a1bf,null))[_0x3f52('0x22')](function(_0x5314ec){if(_0x5314ec){_0x360e4a['model']=_[_0x3f52('0x42')](db[_0x3f52('0xd3')][_0x3f52('0x3d')]);_0x360e4a[_0x3f52('0x3f')]=_[_0x3f52('0x42')](_0x2512ab[_0x3f52('0x3f')]);_0x360e4a[_0x3f52('0x4c')]=_['intersection'](_0x360e4a['model'],_0x360e4a[_0x3f52('0x3f')]);_0x34232f[_0x3f52('0x44')]=_['intersection'](_0x360e4a[_0x3f52('0x3e')],qs[_0x3f52('0x45')](_0x2512ab[_0x3f52('0x3f')][_0x3f52('0x45')]));_0x34232f[_0x3f52('0x44')]=_0x34232f[_0x3f52('0x44')][_0x3f52('0x46')]?_0x34232f[_0x3f52('0x44')]:_0x360e4a['model'];if(!_0x2512ab[_0x3f52('0x3f')]['hasOwnProperty'](_0x3f52('0x48'))){_0x34232f[_0x3f52('0x2f')]=qs[_0x3f52('0x2f')](_0x2512ab[_0x3f52('0x3f')][_0x3f52('0x2f')]);_0x34232f[_0x3f52('0x2e')]=qs['offset'](_0x2512ab[_0x3f52('0x3f')][_0x3f52('0x2e')]);}_0x34232f[_0x3f52('0x49')]=qs[_0x3f52('0x4a')](_0x2512ab[_0x3f52('0x3f')][_0x3f52('0x4a')]);_0x34232f[_0x3f52('0x4b')]=qs['filters'](_[_0x3f52('0x4d')](_0x2512ab[_0x3f52('0x3f')],_0x360e4a[_0x3f52('0x4c')]));_0x34232f[_0x3f52('0x4b')][_0x3f52('0x68')]=_0x5314ec['id'];if(_0x2512ab['query'][_0x3f52('0x51')]){_0x34232f[_0x3f52('0x4b')]=_[_0x3f52('0x50')](_0x34232f[_0x3f52('0x4b')],{'$or':_['map'](_0x34232f[_0x3f52('0x44')],function(_0x4baff4){var _0x18fb32={};_0x18fb32[_0x4baff4]={'$like':'%'+_0x2512ab[_0x3f52('0x3f')][_0x3f52('0x51')]+'%'};return _0x18fb32;})});}_0x34232f=_[_0x3f52('0x50')]({},_0x34232f,_0x2512ab[_0x3f52('0x56')]);return db['ChatOfflineMessage'][_0x3f52('0x2d')]({'where':_0x34232f['where']})[_0x3f52('0x22')](function(_0x230779){_0x5951e8[_0x3f52('0x2d')]=_0x230779;if(_0x2512ab['query'][_0x3f52('0x6c')]){_0x34232f['include']=[{'all':!![]}];}return db[_0x3f52('0xd3')][_0x3f52('0x59')](_0x34232f);})['then'](function(_0x3f177f){_0x5951e8['rows']=_0x3f177f;return _0x5951e8;});}})[_0x3f52('0x22')](respondWithFilteredResult(_0x31a1bf,_0x34232f))[_0x3f52('0x2a')](handleError(_0x31a1bf,null));};exports[_0x3f52('0x115')]=function(_0x31c839,_0x144c9b,_0x1e774f){return db[_0x3f52('0x57')]['find']({'where':{'id':_0x31c839[_0x3f52('0x5c')]['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x144c9b,null))[_0x3f52('0x22')](function(_0x45a111){if(_0x45a111){return _0x45a111[_0x3f52('0x115')](_0x31c839[_0x3f52('0x5f')][_0x3f52('0x6e')],_[_0x3f52('0xe4')](_0x31c839[_0x3f52('0x5f')],[_0x3f52('0x6e'),'id'])||{})[_0x3f52('0xcd')](function(_0x248010){for(var _0x20350f=0x0;_0x20350f<_0x31c839[_0x3f52('0x5f')]['ids'][_0x3f52('0x46')];_0x20350f+=0x1){socket[_0x3f52('0x116')]('userChatWebsite:save',{'UserId':_0x31c839[_0x3f52('0x5f')][_0x3f52('0x6e')][_0x20350f],'ChatWebsiteId':_0x31c839['params']['id']});}return _0x248010;});}})[_0x3f52('0x22')](respondWithResult(_0x144c9b,null))[_0x3f52('0x2a')](handleError(_0x144c9b,null));};exports[_0x3f52('0x117')]=function(_0x3f951e,_0x1531b8,_0x12701c){var _0x588189;return db[_0x3f52('0x57')][_0x3f52('0x5d')]({'where':{'id':_0x3f951e[_0x3f52('0x5c')]['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x1531b8,null))[_0x3f52('0x22')](function(_0x3beb45){if(_0x3beb45){return _0x3beb45['removeAgents'](_0x3f951e[_0x3f52('0x3f')][_0x3f52('0x6e')])[_0x3f52('0x22')](function(_0x563a77){if(_[_0x3f52('0x118')](_0x3f951e['query'][_0x3f52('0x6e')])){for(var _0x2cbe81=0x0;_0x2cbe81<_0x3f951e['query'][_0x3f52('0x6e')][_0x3f52('0x46')];_0x2cbe81+=0x1){socket[_0x3f52('0x116')](_0x3f52('0x119'),{'UserId':_0x3f951e['query'][_0x3f52('0x6e')][_0x2cbe81],'ChatWebsiteId':_0x3f951e['params']['id']});}}else{socket['emit'](_0x3f52('0x119'),{'UserId':_0x3f951e[_0x3f52('0x3f')][_0x3f52('0x6e')],'ChatWebsiteId':_0x3f951e[_0x3f52('0x5c')]['id']});}});}})['then'](respondWithStatusCode(_0x1531b8,null))['catch'](handleError(_0x1531b8,null));};exports[_0x3f52('0x11a')]=function(_0x3ff2fc,_0x16840a,_0x56ffe6){var _0x58213b={};var _0xd024f8={};var _0x5039aa;var _0x1f6c00;return db[_0x3f52('0x57')]['findOne']({'where':{'id':_0x3ff2fc['params']['id']}})[_0x3f52('0x22')](handleEntityNotFound(_0x16840a,null))['then'](function(_0x56fb39){if(_0x56fb39){_0x5039aa=_0x56fb39;_0xd024f8['model']=_[_0x3f52('0x42')](db[_0x3f52('0xc1')]['rawAttributes']);_0xd024f8[_0x3f52('0x3f')]=_[_0x3f52('0x42')](_0x3ff2fc['query']);_0xd024f8['filters']=_[_0x3f52('0x43')](_0xd024f8[_0x3f52('0x3e')],_0xd024f8[_0x3f52('0x3f')]);_0x58213b[_0x3f52('0x44')]=_['intersection'](_0xd024f8[_0x3f52('0x3e')],qs[_0x3f52('0x45')](_0x3ff2fc[_0x3f52('0x3f')][_0x3f52('0x45')]));_0x58213b[_0x3f52('0x44')]=_0x58213b[_0x3f52('0x44')]['length']?_0x58213b[_0x3f52('0x44')]:_0xd024f8[_0x3f52('0x3e')];_0x58213b[_0x3f52('0x49')]=qs[_0x3f52('0x4a')](_0x3ff2fc[_0x3f52('0x3f')]['sort']);_0x58213b['where']=qs['filters'](_['pick'](_0x3ff2fc['query'],_0xd024f8['filters']));if(_0x3ff2fc['query']['filter']){_0x58213b[_0x3f52('0x4b')]=_['merge'](_0x58213b[_0x3f52('0x4b')],{'$or':_[_0x3f52('0x52')](_0x58213b[_0x3f52('0x44')],function(_0x474fac){var _0x31c077={};_0x31c077[_0x474fac]={'$like':'%'+_0x3ff2fc['query']['filter']+'%'};return _0x31c077;})});}_0x58213b=_[_0x3f52('0x50')]({},_0x58213b,_0x3ff2fc[_0x3f52('0x56')]);return _0x5039aa[_0x3f52('0x11a')](_0x58213b);}})[_0x3f52('0x22')](function(_0x4da7d8){if(_0x4da7d8){_0x1f6c00=_0x4da7d8[_0x3f52('0x46')];if(!_0x3ff2fc[_0x3f52('0x3f')][_0x3f52('0x47')]('nolimit')){_0x58213b['limit']=qs[_0x3f52('0x2f')](_0x3ff2fc[_0x3f52('0x3f')][_0x3f52('0x2f')]);_0x58213b[_0x3f52('0x2e')]=qs[_0x3f52('0x2e')](_0x3ff2fc['query'][_0x3f52('0x2e')]);}return _0x5039aa[_0x3f52('0x11a')](_0x58213b);}})[_0x3f52('0x22')](function(_0x3bfd55){if(_0x3bfd55){return _0x3bfd55?{'count':_0x1f6c00,'rows':_0x3bfd55}:null;}})[_0x3f52('0x22')](respondWithResult(_0x16840a,null))['catch'](handleError(_0x16840a,null));};
\ No newline at end of file