Built motion from commit 43538d75.|2.5.35
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index ae13b59..3f37d8c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x6eed=['catch','sendStatus','status','json','undefined','limit','count','offset','set','apply','reject','save','update','destroy','get','ChatWebsites','UserProfileResource','end','stack','name','index','Pause','mandatoryDispositionPause','map','fieldName','key','model','query','attributes','intersection','fields','length','order','sort','filters','pick','filter','where','merge','VIRTUAL','options','ChatWebsite','includeAll','rows','show','params','keys','rawAttributes','include','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','findOne','nolimit','findAll','removeDispositions','ids','CannedAnswer','getAnswers','hasOwnProperty','removeAnswers','sitepic','filename','addAvatar','agentAvatar','addCustomerAvatar','customerAvatar','systemAvatar','join','server/files/images/logos/default_logo.svg','isNil','existsSync','server/files/images/logos/','root','download','getAvatar','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','getSystemAvatar','server/files/images/avatars/system_avatar.png','user-agent-parser','setUA','headers','user-agent','getResult','chat','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','from','CmList','List','CmContact','Contacts','ChatApplication','Applications','account','applications','list','orderBy','priority','contact','cf-connecting-ip','x-forwarded-for','first','x-real-port','referer','browser','version','format','unknown','%s\x20%s','device','vendor','%s\x20%s\x20%s','type','threadId','ChatInteraction','externalUrl','ContactId','interaction','spread','firstName','lastName','messageId','autoclose','close','unmanaged','AttachmentId','User','unshift','agent','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','startRouting','Start','EventManager','notify','files','ListId','send','from\x20is\x20mandatory','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','findOrCreate','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','ChatOfflineMessage','originalname','server','basename','openNewInteraction','sequelize','Attachment','bulkCreate','MailServerOut','Smtp','forwardOffline','forwardOfflineAddress','service','host','port','secure','auth','SendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','MailAccountId','subjectOffline','mapValues','Chat','NotifyMailAccount','notifyMail','attachments','offline-chat','remove','addInteraction','getInteractions','Contact','internal','Tags','color','tag','Command','timezone','iftime\x20%s,%s','iftime\x20%s','interval','indexOf','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','OFFLINE','No\x20timezone','getSnippet','Interval','Intervals','getProactiveActions','getLicense','virtual','License','chatLicenseExceeded','some','server/files/chat/iframe.js','remote','x-real-ip','connection','remoteAddress','verticalAlignment','backgroundColor','addApplications','findAndCountAll','getApplications','addProactiveActions','chatProactiveAction','omit','ChatProactiveAction','getFields','online','offlineForm','items','fromKey','Attachments','addAgents','emit','removeAgents','isArray','userChatWebsite:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','sox','to-csv','ejs','fs-extra','lodash','jsforce','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./chatWebsite.socket','register','jayson/promise','client','http','then','info','ChatWebsite,\x20%s,\x20%s','request\x20sent','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','message'];(function(_0x2a1da9,_0x4ecf18){var _0x9be406=function(_0x57f9be){while(--_0x57f9be){_0x2a1da9['push'](_0x2a1da9['shift']());}};_0x9be406(++_0x4ecf18);}(_0x6eed,0xff));var _0xd6ee=function(_0x5d0db2,_0x29d33f){_0x5d0db2=_0x5d0db2-0x0;var _0x2d6bdf=_0x6eed[_0x5d0db2];return _0x2d6bdf;};'use strict';var emlformat=require(_0xd6ee('0x0'));var rimraf=require(_0xd6ee('0x1'));var zipdir=require(_0xd6ee('0x2'));var jsonpatch=require(_0xd6ee('0x3'));var rp=require(_0xd6ee('0x4'));var moment=require('moment');var BPromise=require(_0xd6ee('0x5'));var Mustache=require(_0xd6ee('0x6'));var util=require('util');var path=require('path');var sox=require(_0xd6ee('0x7'));var csv=require(_0xd6ee('0x8'));var ejs=require(_0xd6ee('0x9'));var fs=require('fs');var fs_extra=require(_0xd6ee('0xa'));var _=require(_0xd6ee('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xd6ee('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xd6ee('0xd'));var Redis=require(_0xd6ee('0xe'));var authService=require('../../components/auth/service');var qs=require(_0xd6ee('0xf'));var as=require(_0xd6ee('0x10'));var hardwareService=require(_0xd6ee('0x11'));var logger=require(_0xd6ee('0x12'))('api');var utils=require(_0xd6ee('0x13'));var config=require(_0xd6ee('0x14'));var licenseUtil=require(_0xd6ee('0x15'));var db=require(_0xd6ee('0x16'))['db'];config[_0xd6ee('0x17')]=_[_0xd6ee('0x18')](config['redis'],{'host':_0xd6ee('0x19'),'port':0x18eb});var socket=require(_0xd6ee('0x1a'))(new Redis(config['redis']));require(_0xd6ee('0x1b'))[_0xd6ee('0x1c')](socket);var jayson=require(_0xd6ee('0x1d'));var client=jayson[_0xd6ee('0x1e')][_0xd6ee('0x1f')]({'port':0x232c});var client9002=jayson[_0xd6ee('0x1e')]['http']({'port':0x232a});var client9003=jayson[_0xd6ee('0x1e')][_0xd6ee('0x1f')]({'port':0x232b});var client9001=jayson[_0xd6ee('0x1e')]['http']({'port':0x2329});function respondWithRpcPromise(_0x3196c0,_0x5ef16b,_0x3a82bf,_0x2b0495){return new BPromise(function(_0x81d533,_0x572d04){var _0x8a2718=_0x2b0495||client;return _0x8a2718['request'](_0x3196c0,_0x3a82bf)[_0xd6ee('0x20')](function(_0x48a921){logger[_0xd6ee('0x21')](_0xd6ee('0x22'),_0x5ef16b,_0xd6ee('0x23'));logger[_0xd6ee('0x24')](_0xd6ee('0x25'),_0x5ef16b,'request\x20sent',JSON[_0xd6ee('0x26')](_0x48a921));if(_0x48a921['error']){if(_0x48a921[_0xd6ee('0x27')][_0xd6ee('0x28')]===0x1f4){logger[_0xd6ee('0x27')](_0xd6ee('0x22'),_0x5ef16b,_0x48a921[_0xd6ee('0x27')]['message']);return _0x572d04(_0x48a921['error'][_0xd6ee('0x29')]);}logger['error'](_0xd6ee('0x22'),_0x5ef16b,_0x48a921['error'][_0xd6ee('0x29')]);return _0x81d533(_0x48a921[_0xd6ee('0x27')][_0xd6ee('0x29')]);}else{logger[_0xd6ee('0x21')](_0xd6ee('0x22'),_0x5ef16b,'request\x20sent');_0x81d533(_0x48a921['result'][_0xd6ee('0x29')]);}})[_0xd6ee('0x2a')](function(_0x4edb7d){logger[_0xd6ee('0x27')](_0xd6ee('0x22'),_0x5ef16b,_0x4edb7d);_0x572d04(_0x4edb7d);});});}function respondWithStatusCode(_0x30a40a,_0x373308){_0x373308=_0x373308||0xcc;return function(_0x3766df){if(_0x3766df){return _0x30a40a[_0xd6ee('0x2b')](_0x373308);}return _0x30a40a[_0xd6ee('0x2c')](_0x373308)['end']();};}function respondWithResult(_0x202e11,_0x124ab7){_0x124ab7=_0x124ab7||0xc8;return function(_0x50b786){if(_0x50b786){return _0x202e11['status'](_0x124ab7)[_0xd6ee('0x2d')](_0x50b786);}};}function respondWithFilteredResult(_0x4580a7,_0xddca){return function(_0x15a6fd){if(_0x15a6fd){var _0x1f9f6d=typeof _0xddca['offset']===_0xd6ee('0x2e')&&typeof _0xddca[_0xd6ee('0x2f')]===_0xd6ee('0x2e');var _0x4a9bdb=_0x15a6fd[_0xd6ee('0x30')];var _0x1becc3=_0x1f9f6d?0x0:_0xddca[_0xd6ee('0x31')];var _0x54d471=_0x1f9f6d?_0x15a6fd[_0xd6ee('0x30')]:_0xddca[_0xd6ee('0x31')]+_0xddca[_0xd6ee('0x2f')];var _0x405044;if(_0x54d471>=_0x4a9bdb){_0x54d471=_0x4a9bdb;_0x405044=0xc8;}else{_0x405044=0xce;}_0x4580a7[_0xd6ee('0x2c')](_0x405044);return _0x4580a7[_0xd6ee('0x32')]('Content-Range',_0x1becc3+'-'+_0x54d471+'/'+_0x4a9bdb)[_0xd6ee('0x2d')](_0x15a6fd);}return null;};}function patchUpdates(_0x3c16eb){return function(_0x3375b2){try{jsonpatch[_0xd6ee('0x33')](_0x3375b2,_0x3c16eb,!![]);}catch(_0x4f4e84){return BPromise[_0xd6ee('0x34')](_0x4f4e84);}return _0x3375b2[_0xd6ee('0x35')]();};}function saveUpdates(_0x2916a3,_0x52b472){return function(_0x483dca){if(_0x483dca){return _0x483dca[_0xd6ee('0x36')](_0x2916a3)[_0xd6ee('0x20')](function(_0x1479a4){return _0x1479a4;});}return null;};}function removeEntity(_0x139a15,_0x430b10){return function(_0x9ba178){if(_0x9ba178){return _0x9ba178[_0xd6ee('0x37')]()[_0xd6ee('0x20')](function(){var _0x2cf544=_0x9ba178[_0xd6ee('0x38')]({'plain':!![]});var _0x114ad4=_0xd6ee('0x39');return db[_0xd6ee('0x3a')][_0xd6ee('0x37')]({'where':{'type':_0x114ad4,'resourceId':_0x2cf544['id']}})[_0xd6ee('0x20')](function(){return _0x9ba178;});})['then'](function(){_0x139a15[_0xd6ee('0x2c')](0xcc)[_0xd6ee('0x3b')]();});}};}function handleEntityNotFound(_0x198185,_0x533273){return function(_0x564adc){if(!_0x564adc){_0x198185['sendStatus'](0x194);}return _0x564adc;};}function handleError(_0x49b9ab,_0x18639d){_0x18639d=_0x18639d||0x1f4;return function(_0x415375){logger[_0xd6ee('0x27')](_0x415375[_0xd6ee('0x3c')]);if(_0x415375[_0xd6ee('0x3d')]){delete _0x415375[_0xd6ee('0x3d')];}_0x49b9ab[_0xd6ee('0x2c')](_0x18639d)['send'](_0x415375);};}exports[_0xd6ee('0x3e')]=function(_0xb5558c,_0x48fb7b){var _0x2dbb34={'include':[{'model':db[_0xd6ee('0x3f')],'as':_0xd6ee('0x40')}]},_0x407748={},_0xe3baf2={'count':0x0,'rows':[]};var _0x13ef37=_[_0xd6ee('0x41')](db['ChatWebsite']['rawAttributes'],function(_0x4bc27e){return{'name':_0x4bc27e[_0xd6ee('0x42')],'type':_0x4bc27e['type'][_0xd6ee('0x43')]};});_0x407748[_0xd6ee('0x44')]=_[_0xd6ee('0x41')](_0x13ef37,_0xd6ee('0x3d'));_0x407748[_0xd6ee('0x45')]=_['keys'](_0xb5558c['query']);_0x407748['filters']=_['intersection'](_0x407748[_0xd6ee('0x44')],_0x407748[_0xd6ee('0x45')]);_0x2dbb34[_0xd6ee('0x46')]=_[_0xd6ee('0x47')](_0x407748[_0xd6ee('0x44')],qs[_0xd6ee('0x48')](_0xb5558c[_0xd6ee('0x45')][_0xd6ee('0x48')]));_0x2dbb34[_0xd6ee('0x46')]=_0x2dbb34['attributes'][_0xd6ee('0x49')]?_0x2dbb34[_0xd6ee('0x46')]:_0x407748['model'];if(!_0xb5558c[_0xd6ee('0x45')]['hasOwnProperty']('nolimit')){_0x2dbb34[_0xd6ee('0x2f')]=qs[_0xd6ee('0x2f')](_0xb5558c[_0xd6ee('0x45')][_0xd6ee('0x2f')]);_0x2dbb34[_0xd6ee('0x31')]=qs[_0xd6ee('0x31')](_0xb5558c['query']['offset']);}_0x2dbb34[_0xd6ee('0x4a')]=qs[_0xd6ee('0x4b')](_0xb5558c['query'][_0xd6ee('0x4b')]);_0x2dbb34['where']=qs[_0xd6ee('0x4c')](_[_0xd6ee('0x4d')](_0xb5558c[_0xd6ee('0x45')],_0x407748[_0xd6ee('0x4c')]),_0x13ef37);if(_0xb5558c[_0xd6ee('0x45')][_0xd6ee('0x4e')]){_0x2dbb34[_0xd6ee('0x4f')]=_[_0xd6ee('0x50')](_0x2dbb34[_0xd6ee('0x4f')],{'$or':_[_0xd6ee('0x41')](_0x13ef37,function(_0x41b826){if(_0x41b826['type']!==_0xd6ee('0x51')){var _0x1646f3={};_0x1646f3[_0x41b826[_0xd6ee('0x3d')]]={'$like':'%'+_0xb5558c[_0xd6ee('0x45')][_0xd6ee('0x4e')]+'%'};return _0x1646f3;}})});}_0x2dbb34=_[_0xd6ee('0x50')]({},_0x2dbb34,_0xb5558c[_0xd6ee('0x52')]);var _0x225679={'where':_0x2dbb34[_0xd6ee('0x4f')]};return db[_0xd6ee('0x53')][_0xd6ee('0x30')](_0x225679)[_0xd6ee('0x20')](function(_0x5130a6){_0xe3baf2[_0xd6ee('0x30')]=_0x5130a6;if(_0xb5558c[_0xd6ee('0x45')][_0xd6ee('0x54')]){_0x2dbb34['include']=[{'all':!![]}];}return db[_0xd6ee('0x53')]['findAll'](_0x2dbb34);})[_0xd6ee('0x20')](function(_0x47882c){_0xe3baf2[_0xd6ee('0x55')]=_0x47882c;return _0xe3baf2;})[_0xd6ee('0x20')](respondWithFilteredResult(_0x48fb7b,_0x2dbb34))['catch'](handleError(_0x48fb7b,null));};exports[_0xd6ee('0x56')]=function(_0x164df4,_0xaef499){var _0x5226be={'raw':![],'where':{'id':_0x164df4[_0xd6ee('0x57')]['id']},'include':[{'model':db['Pause'],'as':_0xd6ee('0x40')}]},_0x212417={};_0x212417['model']=_[_0xd6ee('0x58')](db[_0xd6ee('0x53')][_0xd6ee('0x59')]);_0x212417[_0xd6ee('0x45')]=_['keys'](_0x164df4[_0xd6ee('0x45')]);_0x212417['filters']=_[_0xd6ee('0x47')](_0x212417[_0xd6ee('0x44')],_0x212417['query']);_0x5226be[_0xd6ee('0x46')]=_[_0xd6ee('0x47')](_0x212417[_0xd6ee('0x44')],qs[_0xd6ee('0x48')](_0x164df4[_0xd6ee('0x45')][_0xd6ee('0x48')]));_0x5226be[_0xd6ee('0x46')]=_0x5226be[_0xd6ee('0x46')]['length']?_0x5226be[_0xd6ee('0x46')]:_0x212417['model'];if(_0x164df4[_0xd6ee('0x45')][_0xd6ee('0x54')]){_0x5226be[_0xd6ee('0x5a')]=[{'all':!![]}];}_0x5226be=_[_0xd6ee('0x50')]({},_0x5226be,_0x164df4['options']);return db[_0xd6ee('0x53')]['find'](_0x5226be)[_0xd6ee('0x20')](handleEntityNotFound(_0xaef499,null))['then'](respondWithResult(_0xaef499,null))[_0xd6ee('0x2a')](handleError(_0xaef499,null));};exports['create']=function(_0x27d110,_0x3bb0f9){return db[_0xd6ee('0x53')][_0xd6ee('0x5b')](_0x27d110[_0xd6ee('0x5c')],{})[_0xd6ee('0x20')](function(_0x3c1530){var _0x150f3b=_0x27d110[_0xd6ee('0x5d')]['get']({'plain':!![]});if(!_0x150f3b)throw new Error(_0xd6ee('0x5e'));if(_0x150f3b['role']===_0xd6ee('0x5d')){var _0x3be1be=_0x3c1530['get']({'plain':!![]});var _0x4ebdfd=_0xd6ee('0x39');return db[_0xd6ee('0x5f')][_0xd6ee('0x60')]({'where':{'name':_0x4ebdfd,'userProfileId':_0x150f3b[_0xd6ee('0x61')]},'raw':!![]})[_0xd6ee('0x20')](function(_0x3db2e4){if(_0x3db2e4&&_0x3db2e4[_0xd6ee('0x62')]===0x0){return db[_0xd6ee('0x3a')]['create']({'name':_0x3be1be[_0xd6ee('0x3d')],'resourceId':_0x3be1be['id'],'type':_0x3db2e4[_0xd6ee('0x3d')],'sectionId':_0x3db2e4['id']},{})['then'](function(){return _0x3c1530;});}else{return _0x3c1530;}})[_0xd6ee('0x2a')](function(_0x335b08){logger[_0xd6ee('0x27')](_0xd6ee('0x63'),_0x335b08);throw _0x335b08;});}return _0x3c1530;})[_0xd6ee('0x20')](respondWithResult(_0x3bb0f9,0xc9))[_0xd6ee('0x2a')](handleError(_0x3bb0f9,null));};exports[_0xd6ee('0x36')]=function(_0xd083f0,_0x372231){if(_0xd083f0[_0xd6ee('0x5c')]['id']){delete _0xd083f0[_0xd6ee('0x5c')]['id'];}return db['ChatWebsite'][_0xd6ee('0x60')]({'where':{'id':_0xd083f0[_0xd6ee('0x57')]['id']},'include':[{'model':db['Pause'],'as':_0xd6ee('0x40')}]})[_0xd6ee('0x20')](handleEntityNotFound(_0x372231,null))['then'](saveUpdates(_0xd083f0[_0xd6ee('0x5c')],null))[_0xd6ee('0x20')](respondWithResult(_0x372231,null))['catch'](handleError(_0x372231,null));};exports[_0xd6ee('0x37')]=function(_0x1e20da,_0x4e55ba){return db[_0xd6ee('0x53')][_0xd6ee('0x60')]({'where':{'id':_0x1e20da['params']['id']}})['then'](handleEntityNotFound(_0x4e55ba,null))['then'](removeEntity(_0x4e55ba,null))['catch'](handleError(_0x4e55ba,null));};exports[_0xd6ee('0x64')]=function(_0x10e165,_0x2c81fc){return db[_0xd6ee('0x53')][_0xd6ee('0x64')]()[_0xd6ee('0x20')](respondWithResult(_0x2c81fc,null))[_0xd6ee('0x2a')](handleError(_0x2c81fc,null));};exports[_0xd6ee('0x65')]=function(_0x2e8c1f,_0x33ee97,_0x432286){if(_0x2e8c1f[_0xd6ee('0x5c')]['id']){delete _0x2e8c1f[_0xd6ee('0x5c')]['id'];}return db['ChatWebsite'][_0xd6ee('0x60')]({'where':{'id':_0x2e8c1f[_0xd6ee('0x57')]['id']}})['then'](handleEntityNotFound(_0x33ee97,null))['then'](function(_0x1df2f0){if(_0x1df2f0){_0x2e8c1f['body'][_0xd6ee('0x66')]=_0x1df2f0['id'];return db[_0xd6ee('0x67')][_0xd6ee('0x5b')](_0x2e8c1f['body']);}})['then'](respondWithResult(_0x33ee97,null))[_0xd6ee('0x2a')](handleError(_0x33ee97,null));};exports[_0xd6ee('0x68')]=function(_0x29c448,_0x2c43da,_0x33de89){var _0x2aaf02={'raw':![],'where':{}};var _0x933004={};var _0x2c9b07={'count':0x0,'rows':[]};return db['ChatWebsite'][_0xd6ee('0x69')]({'where':{'id':_0x29c448[_0xd6ee('0x57')]['id']}})['then'](handleEntityNotFound(_0x2c43da,null))[_0xd6ee('0x20')](function(_0x179540){if(_0x179540){_0x933004[_0xd6ee('0x44')]=_[_0xd6ee('0x58')](db[_0xd6ee('0x67')][_0xd6ee('0x59')]);_0x933004[_0xd6ee('0x45')]=_[_0xd6ee('0x58')](_0x29c448['query']);_0x933004[_0xd6ee('0x4c')]=_[_0xd6ee('0x47')](_0x933004[_0xd6ee('0x44')],_0x933004[_0xd6ee('0x45')]);_0x2aaf02['attributes']=_['intersection'](_0x933004[_0xd6ee('0x44')],qs[_0xd6ee('0x48')](_0x29c448[_0xd6ee('0x45')][_0xd6ee('0x48')]));_0x2aaf02['attributes']=_0x2aaf02[_0xd6ee('0x46')][_0xd6ee('0x49')]?_0x2aaf02[_0xd6ee('0x46')]:_0x933004[_0xd6ee('0x44')];if(!_0x29c448[_0xd6ee('0x45')]['hasOwnProperty'](_0xd6ee('0x6a'))){_0x2aaf02[_0xd6ee('0x2f')]=qs[_0xd6ee('0x2f')](_0x29c448[_0xd6ee('0x45')][_0xd6ee('0x2f')]);_0x2aaf02[_0xd6ee('0x31')]=qs[_0xd6ee('0x31')](_0x29c448[_0xd6ee('0x45')][_0xd6ee('0x31')]);}_0x2aaf02[_0xd6ee('0x4a')]=qs[_0xd6ee('0x4b')](_0x29c448[_0xd6ee('0x45')][_0xd6ee('0x4b')]);_0x2aaf02[_0xd6ee('0x4f')]=qs[_0xd6ee('0x4c')](_['pick'](_0x29c448['query'],_0x933004['filters']));_0x2aaf02[_0xd6ee('0x4f')][_0xd6ee('0x66')]=_0x179540['id'];if(_0x29c448[_0xd6ee('0x45')][_0xd6ee('0x4e')]){_0x2aaf02[_0xd6ee('0x4f')]=_[_0xd6ee('0x50')](_0x2aaf02[_0xd6ee('0x4f')],{'$or':_['map'](_0x2aaf02[_0xd6ee('0x46')],function(_0x1285e4){var _0x12910e={};_0x12910e[_0x1285e4]={'$like':'%'+_0x29c448[_0xd6ee('0x45')][_0xd6ee('0x4e')]+'%'};return _0x12910e;})});}_0x2aaf02=_[_0xd6ee('0x50')]({},_0x2aaf02,_0x29c448[_0xd6ee('0x52')]);return db[_0xd6ee('0x67')][_0xd6ee('0x30')]({'where':_0x2aaf02[_0xd6ee('0x4f')]})[_0xd6ee('0x20')](function(_0x1621dd){_0x2c9b07[_0xd6ee('0x30')]=_0x1621dd;if(_0x29c448['query'][_0xd6ee('0x54')]){_0x2aaf02[_0xd6ee('0x5a')]=[{'all':!![]}];}return db['Disposition'][_0xd6ee('0x6b')](_0x2aaf02);})[_0xd6ee('0x20')](function(_0x5aa53a){_0x2c9b07[_0xd6ee('0x55')]=_0x5aa53a;return _0x2c9b07;});}})[_0xd6ee('0x20')](respondWithFilteredResult(_0x2c43da,_0x2aaf02))['catch'](handleError(_0x2c43da,null));};exports[_0xd6ee('0x6c')]=function(_0x3039cf,_0x5006b0,_0x14aaff){return db[_0xd6ee('0x53')]['find']({'where':{'id':_0x3039cf[_0xd6ee('0x57')]['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0x5006b0,null))[_0xd6ee('0x20')](function(_0x47e116){if(_0x47e116){return _0x47e116['removeDispositions'](_0x3039cf['query'][_0xd6ee('0x6d')]);}})[_0xd6ee('0x20')](respondWithStatusCode(_0x5006b0,null))[_0xd6ee('0x2a')](handleError(_0x5006b0,null));};exports['addAnswer']=function(_0x505091,_0x1ae77c,_0x385a61){if(_0x505091[_0xd6ee('0x5c')]['id']){delete _0x505091[_0xd6ee('0x5c')]['id'];}return db['ChatWebsite'][_0xd6ee('0x60')]({'where':{'id':_0x505091[_0xd6ee('0x57')]['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0x1ae77c,null))[_0xd6ee('0x20')](function(_0x39eded){if(_0x39eded){_0x505091[_0xd6ee('0x5c')][_0xd6ee('0x66')]=_0x39eded['id'];return db[_0xd6ee('0x6e')][_0xd6ee('0x5b')](_0x505091[_0xd6ee('0x5c')]);}})['then'](respondWithResult(_0x1ae77c,null))[_0xd6ee('0x2a')](handleError(_0x1ae77c,null));};exports[_0xd6ee('0x6f')]=function(_0x31b1d0,_0x2661af,_0x498124){var _0x3fa872={'raw':![],'where':{}};var _0xadbec2={};var _0x58348f={'count':0x0,'rows':[]};return db[_0xd6ee('0x53')][_0xd6ee('0x69')]({'where':{'id':_0x31b1d0[_0xd6ee('0x57')]['id']}})['then'](handleEntityNotFound(_0x2661af,null))[_0xd6ee('0x20')](function(_0x45f1c2){if(_0x45f1c2){_0xadbec2['model']=_['keys'](db['CannedAnswer']['rawAttributes']);_0xadbec2[_0xd6ee('0x45')]=_[_0xd6ee('0x58')](_0x31b1d0[_0xd6ee('0x45')]);_0xadbec2[_0xd6ee('0x4c')]=_['intersection'](_0xadbec2[_0xd6ee('0x44')],_0xadbec2[_0xd6ee('0x45')]);_0x3fa872['attributes']=_['intersection'](_0xadbec2[_0xd6ee('0x44')],qs[_0xd6ee('0x48')](_0x31b1d0[_0xd6ee('0x45')][_0xd6ee('0x48')]));_0x3fa872['attributes']=_0x3fa872['attributes'][_0xd6ee('0x49')]?_0x3fa872['attributes']:_0xadbec2[_0xd6ee('0x44')];if(!_0x31b1d0[_0xd6ee('0x45')][_0xd6ee('0x70')](_0xd6ee('0x6a'))){_0x3fa872[_0xd6ee('0x2f')]=qs['limit'](_0x31b1d0[_0xd6ee('0x45')][_0xd6ee('0x2f')]);_0x3fa872[_0xd6ee('0x31')]=qs['offset'](_0x31b1d0[_0xd6ee('0x45')]['offset']);}_0x3fa872['order']=qs[_0xd6ee('0x4b')](_0x31b1d0[_0xd6ee('0x45')][_0xd6ee('0x4b')]);_0x3fa872[_0xd6ee('0x4f')]=qs[_0xd6ee('0x4c')](_['pick'](_0x31b1d0[_0xd6ee('0x45')],_0xadbec2[_0xd6ee('0x4c')]));_0x3fa872[_0xd6ee('0x4f')][_0xd6ee('0x66')]=_0x45f1c2['id'];if(_0x31b1d0[_0xd6ee('0x45')]['filter']){_0x3fa872[_0xd6ee('0x4f')]=_['merge'](_0x3fa872[_0xd6ee('0x4f')],{'$or':_['map'](_0x3fa872[_0xd6ee('0x46')],function(_0x57598f){var _0x466e54={};_0x466e54[_0x57598f]={'$like':'%'+_0x31b1d0[_0xd6ee('0x45')]['filter']+'%'};return _0x466e54;})});}_0x3fa872=_['merge']({},_0x3fa872,_0x31b1d0[_0xd6ee('0x52')]);return db['CannedAnswer'][_0xd6ee('0x30')]({'where':_0x3fa872[_0xd6ee('0x4f')]})[_0xd6ee('0x20')](function(_0x4cc0ce){_0x58348f[_0xd6ee('0x30')]=_0x4cc0ce;if(_0x31b1d0[_0xd6ee('0x45')][_0xd6ee('0x54')]){_0x3fa872['include']=[{'all':!![]}];}return db['CannedAnswer'][_0xd6ee('0x6b')](_0x3fa872);})['then'](function(_0x1ca560){_0x58348f[_0xd6ee('0x55')]=_0x1ca560;return _0x58348f;});}})[_0xd6ee('0x20')](respondWithFilteredResult(_0x2661af,_0x3fa872))[_0xd6ee('0x2a')](handleError(_0x2661af,null));};exports[_0xd6ee('0x71')]=function(_0x151418,_0xf7a67f,_0x578cc4){return db[_0xd6ee('0x53')][_0xd6ee('0x60')]({'where':{'id':_0x151418[_0xd6ee('0x57')]['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0xf7a67f,null))[_0xd6ee('0x20')](function(_0x104f76){if(_0x104f76){return _0x104f76[_0xd6ee('0x71')](_0x151418['query'][_0xd6ee('0x6d')]);}})[_0xd6ee('0x20')](respondWithStatusCode(_0xf7a67f,null))[_0xd6ee('0x2a')](handleError(_0xf7a67f,null));};exports['addLogo']=function(_0x477b72,_0x6132a4,_0x51da21){_0x477b72[_0xd6ee('0x5c')][_0xd6ee('0x72')]=_0x477b72['file'][_0xd6ee('0x73')];return db[_0xd6ee('0x53')][_0xd6ee('0x60')]({'where':{'id':_0x477b72['params']['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0x6132a4,null))[_0xd6ee('0x20')](saveUpdates(_0x477b72[_0xd6ee('0x5c')],null))[_0xd6ee('0x20')](respondWithResult(_0x6132a4,null))[_0xd6ee('0x2a')](handleError(_0x6132a4,null));};exports[_0xd6ee('0x74')]=function(_0x33da19,_0x19add4,_0x5c3af5){_0x33da19[_0xd6ee('0x5c')][_0xd6ee('0x75')]=_0x33da19['file']['filename'];return db[_0xd6ee('0x53')]['find']({'where':{'id':_0x33da19[_0xd6ee('0x57')]['id']}})['then'](handleEntityNotFound(_0x19add4,null))['then'](saveUpdates(_0x33da19[_0xd6ee('0x5c')],null))[_0xd6ee('0x20')](respondWithResult(_0x19add4,null))[_0xd6ee('0x2a')](handleError(_0x19add4,null));};exports[_0xd6ee('0x76')]=function(_0x9cdd04,_0x1a745f,_0x1a3608){_0x9cdd04[_0xd6ee('0x5c')][_0xd6ee('0x77')]=_0x9cdd04['file'][_0xd6ee('0x73')];return db['ChatWebsite']['find']({'where':{'id':_0x9cdd04[_0xd6ee('0x57')]['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0x1a745f,null))['then'](saveUpdates(_0x9cdd04[_0xd6ee('0x5c')],null))[_0xd6ee('0x20')](respondWithResult(_0x1a745f,null))[_0xd6ee('0x2a')](handleError(_0x1a745f,null));};exports['addSystemAvatar']=function(_0x3ead7c,_0xbb1f1e,_0x5a4496){_0x3ead7c[_0xd6ee('0x5c')][_0xd6ee('0x78')]=_0x3ead7c['file'][_0xd6ee('0x73')];return db['ChatWebsite'][_0xd6ee('0x60')]({'where':{'id':_0x3ead7c[_0xd6ee('0x57')]['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0xbb1f1e,null))[_0xd6ee('0x20')](saveUpdates(_0x3ead7c[_0xd6ee('0x5c')],null))[_0xd6ee('0x20')](respondWithResult(_0xbb1f1e,null))[_0xd6ee('0x2a')](handleError(_0xbb1f1e,null));};exports['getLogo']=function(_0xd93cfb,_0x25e092,_0x1aa644){var _0x809341=path[_0xd6ee('0x79')](config['root'],_0xd6ee('0x7a'));var _0x31498c={'where':{'id':_0xd93cfb[_0xd6ee('0x57')]['id']},'attributes':['id',_0xd6ee('0x72')],'raw':!![]};var _0x4b1c19=![];return require(_0xd6ee('0x15'))['getLicense']()[_0xd6ee('0x20')](function(_0x515d86){if(_0x515d86){_0x4b1c19=_0x515d86['custom'];}})[_0xd6ee('0x20')](function(){return db[_0xd6ee('0x53')][_0xd6ee('0x60')](_0x31498c);})[_0xd6ee('0x20')](handleEntityNotFound(_0x25e092,null))['then'](function(_0x197869){if(_0x197869){if(!_[_0xd6ee('0x7b')](_0x197869[_0xd6ee('0x72')])){if(fs[_0xd6ee('0x7c')](path[_0xd6ee('0x79')](config['root'],_0xd6ee('0x7d'),_0x197869[_0xd6ee('0x72')]))&&_0x4b1c19){_0x809341=path[_0xd6ee('0x79')](config[_0xd6ee('0x7e')],_0xd6ee('0x7d'),_0x197869[_0xd6ee('0x72')]);}}return _0x25e092[_0xd6ee('0x7f')](_0x809341);}})[_0xd6ee('0x2a')](handleError(_0x25e092,null));};exports[_0xd6ee('0x80')]=function(_0x5c6861,_0x39e2b2,_0x29d6e6){var _0xccb14a=path[_0xd6ee('0x79')](config[_0xd6ee('0x7e')],'server/files/images/avatars/default_avatar.png');var _0x24b1a4={'where':{'id':_0x5c6861['params']['id']},'attributes':['id',_0xd6ee('0x75')],'raw':!![]};return db[_0xd6ee('0x53')][_0xd6ee('0x60')](_0x24b1a4)[_0xd6ee('0x20')](handleEntityNotFound(_0x39e2b2,null))['then'](function(_0x2e9d7b){if(_0x2e9d7b){if(!_[_0xd6ee('0x7b')](_0x2e9d7b[_0xd6ee('0x75')])){if(fs[_0xd6ee('0x7c')](path['join'](config[_0xd6ee('0x7e')],_0xd6ee('0x81'),_0x2e9d7b['agentAvatar']))){_0xccb14a=path[_0xd6ee('0x79')](config[_0xd6ee('0x7e')],_0xd6ee('0x81'),_0x2e9d7b[_0xd6ee('0x75')]);}}return _0x39e2b2[_0xd6ee('0x7f')](_0xccb14a);}})[_0xd6ee('0x2a')](handleError(_0x39e2b2,null));};exports[_0xd6ee('0x82')]=function(_0x581a4e,_0x5d872e,_0x15d32c){var _0x22c50b=path[_0xd6ee('0x79')](config[_0xd6ee('0x7e')],_0xd6ee('0x83'));var _0x3a58c4={'where':{'id':_0x581a4e[_0xd6ee('0x57')]['id']},'attributes':['id',_0xd6ee('0x77'),'showCustomerAvatar'],'raw':!![]};return db[_0xd6ee('0x53')][_0xd6ee('0x60')](_0x3a58c4)['then'](handleEntityNotFound(_0x5d872e,null))['then'](function(_0x44b764){if(_0x44b764){if(!_['isNil'](_0x44b764[_0xd6ee('0x77')])){if(fs['existsSync'](path[_0xd6ee('0x79')](config[_0xd6ee('0x7e')],_0xd6ee('0x81'),_0x44b764[_0xd6ee('0x77')]))&&_0x44b764['showCustomerAvatar']){_0x22c50b=path['join'](config['root'],'server/files/images/avatars/',_0x44b764[_0xd6ee('0x77')]);}}return _0x5d872e[_0xd6ee('0x7f')](_0x22c50b);}})['catch'](handleError(_0x5d872e,null));};exports[_0xd6ee('0x84')]=function(_0x3f43e5,_0x5c38dc,_0x11f0b0){var _0x2ac1f2=path[_0xd6ee('0x79')](config[_0xd6ee('0x7e')],_0xd6ee('0x85'));var _0x1dbb50={'where':{'id':_0x3f43e5[_0xd6ee('0x57')]['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db[_0xd6ee('0x53')]['find'](_0x1dbb50)[_0xd6ee('0x20')](handleEntityNotFound(_0x5c38dc,null))[_0xd6ee('0x20')](function(_0x524943){if(_0x524943){if(!_[_0xd6ee('0x7b')](_0x524943[_0xd6ee('0x78')])){if(fs['existsSync'](path[_0xd6ee('0x79')](config['root'],_0xd6ee('0x81'),_0x524943[_0xd6ee('0x78')]))){_0x2ac1f2=path[_0xd6ee('0x79')](config[_0xd6ee('0x7e')],_0xd6ee('0x81'),_0x524943[_0xd6ee('0x78')]);}}return _0x5c38dc[_0xd6ee('0x7f')](_0x2ac1f2);}})['catch'](handleError(_0x5c38dc,null));};exports['notify']=function(_0x403583,_0x395bf1,_0x12e4dc){var _0x2b0bd3=require(_0xd6ee('0x86'));var _0x3beb7b=new _0x2b0bd3();var _0x1bcd9b=_0x3beb7b[_0xd6ee('0x87')](_0x403583[_0xd6ee('0x88')][_0xd6ee('0x89')])[_0xd6ee('0x8a')]();var _0x481e0b={'body':_0x403583[_0xd6ee('0x5c')],'channel':_0xd6ee('0x8b')};var _0x3899f0=[];var _0x4a355f=[];var _0x1e19ed={};var _0x5948a2=![];return db['CmContact'][_0xd6ee('0x64')]()[_0xd6ee('0x20')](function(_0xafe32c){if(!_0xafe32c){throw new db[(_0xd6ee('0x8c'))][(_0xd6ee('0x8d'))](_0xd6ee('0x8e'));}_0x3899f0=_[_0xd6ee('0x8f')](_[_0xd6ee('0x58')](_0xafe32c),[_0xd6ee('0x90'),'updatedAt']);_0x4a355f=_[_0xd6ee('0x8f')](_[_0xd6ee('0x58')](_0xafe32c),[_0xd6ee('0x90'),_0xd6ee('0x91'),_0xd6ee('0x92'),'ListId']);if(_0x403583['body']['id']){delete _0x403583[_0xd6ee('0x5c')]['id'];}if(_[_0xd6ee('0x7b')](_0x403583[_0xd6ee('0x5c')]['from'])){throw new db[(_0xd6ee('0x8c'))][(_0xd6ee('0x8d'))]('from\x20is\x20mandatory');}if(_[_0xd6ee('0x7b')](_0x403583['body']['body'])||_0x403583['body'][_0xd6ee('0x5c')]===''){throw new db[(_0xd6ee('0x8c'))][(_0xd6ee('0x8d'))](_0xd6ee('0x93'));}if(_[_0xd6ee('0x7b')](_0x403583['body'][_0xd6ee('0x94')])){throw new db[(_0xd6ee('0x8c'))][(_0xd6ee('0x8d'))](_0xd6ee('0x95')+_0x4a355f);}if(!_['includes'](_0x4a355f,_0x403583['body'][_0xd6ee('0x94')])){throw new db[(_0xd6ee('0x8c'))][(_0xd6ee('0x8d'))](_0xd6ee('0x96')+_0x4a355f);}_0x1e19ed[_0x403583[_0xd6ee('0x5c')][_0xd6ee('0x94')]]=_0x403583[_0xd6ee('0x5c')][_0xd6ee('0x97')];})[_0xd6ee('0x20')](function(){return db['ChatWebsite'][_0xd6ee('0x60')]({'where':{'id':_0x403583[_0xd6ee('0x57')]['id']},'include':[{'model':db[_0xd6ee('0x98')],'as':_0xd6ee('0x99'),'include':[{'model':db[_0xd6ee('0x9a')],'as':_0xd6ee('0x9b'),'where':_0x1e19ed,'limit':0x1,'order':[[_0xd6ee('0x91'),'DESC']]}]},{'model':db[_0xd6ee('0x9c')],'as':_0xd6ee('0x9d')}]});})['then'](handleEntityNotFound(_0x395bf1,null))[_0xd6ee('0x20')](function(_0x45d9db){if(_0x45d9db&&_0x45d9db[_0xd6ee('0x99')]){_0x481e0b[_0xd6ee('0x9e')]=_0x45d9db;_0x481e0b[_0xd6ee('0x9f')]=_0x45d9db['Applications'];_0x481e0b[_0xd6ee('0xa0')]=_0x45d9db[_0xd6ee('0x99')];_0x481e0b[_0xd6ee('0x9f')]=_[_0xd6ee('0xa1')](_0x481e0b[_0xd6ee('0x9f')],[_0xd6ee('0xa2')],['asc']);if(_0x481e0b['account'][_0xd6ee('0x9d')]){delete _0x481e0b['account']['Applications'];}if(_0x481e0b['account']['List']&&_0x481e0b[_0xd6ee('0x9e')]['List'][_0xd6ee('0x9b')]['length']){return _0x481e0b[_0xd6ee('0x9e')][_0xd6ee('0x99')][_0xd6ee('0x9b')][0x0];}var _0x453149=_[_0xd6ee('0x18')](_0x403583[_0xd6ee('0x5c')],{'firstName':_0x403583[_0xd6ee('0x5c')][_0xd6ee('0x97')],'ListId':_0x45d9db['ListId']});_0x453149[_0x403583['body'][_0xd6ee('0x94')]]=_0x403583[_0xd6ee('0x5c')]['from'];return db[_0xd6ee('0x9a')][_0xd6ee('0x5b')](_0x453149,{'fields':_0x3899f0,'raw':!![]});}})['then'](handleEntityNotFound(_0x395bf1,null))[_0xd6ee('0x20')](function(_0x49e345){_0x481e0b[_0xd6ee('0xa3')]=_0x49e345;var _0x4821dd=_0x403583[_0xd6ee('0x5c')]['customerIp'];if(_0x403583[_0xd6ee('0x88')]['cf-connecting-ip']){_0x4821dd=_0x403583[_0xd6ee('0x88')][_0xd6ee('0xa4')];}else if(_0x403583['headers'][_0xd6ee('0xa5')]){_0x4821dd=_[_0xd6ee('0xa6')](_0x403583[_0xd6ee('0x88')][_0xd6ee('0xa5')]['split'](','));}if(_0x49e345){var _0x57ce66={'ContactId':_0x49e345['id'],'ChatWebsiteId':_0x403583['params']['id'],'from':(_0x49e345['firstName']||'')+'\x20'+(_0x49e345['lastName']||''),'customerIp':_0x4821dd,'customerPort':_0x403583[_0xd6ee('0x88')][_0xd6ee('0xa7')]?_0x403583['headers'][_0xd6ee('0xa7')]:null,'referer':_0x403583[_0xd6ee('0x5c')][_0xd6ee('0xa8')],'browserName':_0x1bcd9b['browser'][_0xd6ee('0x3d')]&&_0x1bcd9b[_0xd6ee('0xa9')][_0xd6ee('0xaa')]?util[_0xd6ee('0xab')]('%s\x20%s',_0x1bcd9b['browser'][_0xd6ee('0x3d')],_0x1bcd9b['browser'][_0xd6ee('0xaa')]):_0xd6ee('0xac'),'browserVersion':_0x1bcd9b[_0xd6ee('0xa9')][_0xd6ee('0xaa')]||'unknown','osName':util[_0xd6ee('0xab')](_0xd6ee('0xad'),_0x1bcd9b['os']['name'],_0x1bcd9b['os'][_0xd6ee('0xaa')]),'osVersion':_0x1bcd9b['os'][_0xd6ee('0xaa')],'deviceModel':_0x1bcd9b[_0xd6ee('0xae')]['model']&&_0x1bcd9b[_0xd6ee('0xae')][_0xd6ee('0xaf')]?util['format'](_0xd6ee('0xb0'),_0x1bcd9b[_0xd6ee('0xae')][_0xd6ee('0x44')],_0x1bcd9b['device'][_0xd6ee('0xaf')],_0x1bcd9b[_0xd6ee('0xae')]['type']):null,'deviceVendor':_0x1bcd9b['device']['vendor'],'deviceType':_0x1bcd9b[_0xd6ee('0xae')][_0xd6ee('0xb1')],'formData':JSON['stringify'](_0x403583[_0xd6ee('0x5c')])};var _0x23cadc={'ChatWebsiteId':_0x403583[_0xd6ee('0x57')]['id'],'closed':![]};if(_0x403583[_0xd6ee('0x5c')][_0xd6ee('0xb2')]){_0x23cadc[_0xd6ee('0xb2')]=_0x403583['body'][_0xd6ee('0xb2')];return db[_0xd6ee('0xb3')][_0xd6ee('0x60')]({'where':_0x23cadc})[_0xd6ee('0x20')](function(_0x6f24bd){if(_0x6f24bd){return[_0x6f24bd,![]];}_0x57ce66[_0xd6ee('0xb2')]=_0x403583[_0xd6ee('0x5c')][_0xd6ee('0xb2')];_0x57ce66[_0xd6ee('0xb4')]=_0x403583[_0xd6ee('0x5c')][_0xd6ee('0xb4')];return db[_0xd6ee('0xb3')][_0xd6ee('0x5b')](_0x57ce66)[_0xd6ee('0x20')](function(_0x203fe0){return[_0x203fe0,!![]];});});}_0x23cadc[_0xd6ee('0xb5')]=_0x49e345['id'];if(_0x403583[_0xd6ee('0x5c')]['interaction']&&_0x403583['body'][_0xd6ee('0xb6')]['id']){_0x23cadc['id']=_0x403583[_0xd6ee('0x5c')][_0xd6ee('0xb6')]['id'];return db['ChatInteraction'][_0xd6ee('0x60')]({'where':_0x23cadc})[_0xd6ee('0x20')](function(_0x1349bb){if(_0x1349bb){return[_0x1349bb,![]];}return db[_0xd6ee('0xb3')]['create'](_0x57ce66)[_0xd6ee('0x20')](function(_0x2bd3e2){return[_0x2bd3e2,!![]];});});}return db[_0xd6ee('0xb3')]['create'](_0x57ce66)[_0xd6ee('0x20')](function(_0x4d5386){return[_0x4d5386,!![]];});}})[_0xd6ee('0xb7')](function(_0x47c5f0,_0x537650){if(_0x47c5f0){_0x5948a2=_0x537650;if(!_0x537650){var _0x4ecdea={'from':(_0x481e0b[_0xd6ee('0xa3')][_0xd6ee('0xb8')]||'')+'\x20'+(_0x481e0b[_0xd6ee('0xa3')][_0xd6ee('0xb9')]||'')};if(_0x403583[_0xd6ee('0x5c')][_0xd6ee('0xb2')]&&_0x403583[_0xd6ee('0x5c')][_0xd6ee('0xba')]&&_0x403583[_0xd6ee('0x5c')][_0xd6ee('0xb2')]!=_0x403583[_0xd6ee('0x5c')][_0xd6ee('0xba')]){_0x4ecdea[_0xd6ee('0xb2')]=_0x403583[_0xd6ee('0x5c')]['messageId'];}return _0x47c5f0[_0xd6ee('0x36')](_0x4ecdea);}else{return _0x47c5f0;}}})[_0xd6ee('0x20')](function(_0x3627e1){_0x481e0b[_0xd6ee('0xb6')]=_0x3627e1['get']({'plain':!![]});_0x481e0b[_0xd6ee('0xb6')]['created']=_0x5948a2;if(_0x481e0b[_0xd6ee('0xb6')]['created']){if(_0x481e0b[_0xd6ee('0x9e')][_0xd6ee('0xbb')]){_0x481e0b[_0xd6ee('0x9f')]['push']({'id':0x0,'priority':_0x481e0b[_0xd6ee('0x9f')][_0xd6ee('0x49')]+0x1,'app':_0xd6ee('0xbc'),'appdata':_0xd6ee('0xbd'),'interval':'*,*,*,*'});}}return db['ChatMessage']['create']({'body':_0x403583[_0xd6ee('0x5c')][_0xd6ee('0x5c')],'ChatWebsiteId':_0x403583['params']['id'],'ChatInteractionId':_0x3627e1['id'],'direction':'in','ContactId':_0x481e0b[_0xd6ee('0xa3')]['id'],'AttachmentId':_0x403583['body'][_0xd6ee('0xbe')]});})[_0xd6ee('0x20')](function(_0x3a26c7){_0x481e0b[_0xd6ee('0x29')]=_0x3a26c7;if(_0x481e0b[_0xd6ee('0xb6')]['UserId']){return db[_0xd6ee('0xbf')][_0xd6ee('0x60')]({'attributes':['id','name'],'where':{'id':_0x481e0b[_0xd6ee('0xb6')]['UserId']}})[_0xd6ee('0x20')](function(_0x1f6a4){if(_0x1f6a4){_0x481e0b[_0xd6ee('0x9f')][_0xd6ee('0xc0')]({'id':0x0,'priority':0x0,'app':_0xd6ee('0xc1'),'appdata':_0x1f6a4['name']+','+(_0x481e0b['account'][_0xd6ee('0xc2')]||0xa),'interval':_0xd6ee('0xc3')});_0x481e0b[_0xd6ee('0xc4')]=!![];}return respondWithRpcPromise('Start',_0xd6ee('0xc5'),_0x481e0b);});}return respondWithRpcPromise(_0xd6ee('0xc6'),_0xd6ee('0xc5'),_0x481e0b);})[_0xd6ee('0x20')](function(_0x21b9d9){respondWithRpcPromise(_0xd6ee('0xc7'),'EventManager',{'event':_0xd6ee('0xc8'),'message':_0x21b9d9},client9002);return _0x21b9d9;})[_0xd6ee('0x20')](respondWithResult(_0x395bf1,null))[_0xd6ee('0x2a')](handleError(_0x395bf1,null));};exports['offline']=function(_0x8051cc,_0x20f856,_0x877903){var _0x428710,_0x506960,_0x4e3677;var _0x4ec9b1=[];var _0x18cb0d=[];var _0x5c1a96={};var _0x4fbc1e=_0x8051cc[_0xd6ee('0xc9')]||[];var _0x3e2ed6=[];var _0x253baf;return db['CmContact']['describe']()[_0xd6ee('0x20')](function(_0x28333d){if(!_0x28333d){throw new db[(_0xd6ee('0x8c'))][(_0xd6ee('0x8d'))](_0xd6ee('0x8e'));}_0x18cb0d=_[_0xd6ee('0x8f')](_[_0xd6ee('0x58')](_0x28333d),[_0xd6ee('0x90'),_0xd6ee('0x91')]);_0x4ec9b1=_[_0xd6ee('0x8f')](_[_0xd6ee('0x58')](_0x28333d),[_0xd6ee('0x90'),'updatedAt','CompanyId',_0xd6ee('0xca')]);if(_0x8051cc[_0xd6ee('0x5c')]['id']){delete _0x8051cc['body']['id'];}if(_[_0xd6ee('0x7b')](_0x8051cc['body'][_0xd6ee('0x97')])){throw _0x20f856[_0xd6ee('0x2c')](0x1f4)[_0xd6ee('0xcb')](new db['Sequelize'][(_0xd6ee('0x8d'))](_0xd6ee('0xcc')));}if(_[_0xd6ee('0x7b')](_0x8051cc[_0xd6ee('0x5c')][_0xd6ee('0x5c')])||_0x8051cc[_0xd6ee('0x5c')][_0xd6ee('0x5c')]===''){throw _0x20f856['status'](0x1f4)[_0xd6ee('0xcb')](new db[(_0xd6ee('0x8c'))]['ValidationError'](_0xd6ee('0x93')));}if(_[_0xd6ee('0x7b')](_0x8051cc[_0xd6ee('0x5c')][_0xd6ee('0xcd')])){throw _0x20f856[_0xd6ee('0x2c')](0x1f4)['send'](new db[(_0xd6ee('0x8c'))]['ValidationError'](_0xd6ee('0xce')+_0x4ec9b1));}if(!_[_0xd6ee('0xcf')](_0x4ec9b1,_0x8051cc[_0xd6ee('0x5c')][_0xd6ee('0xcd')])){throw _0x20f856[_0xd6ee('0x2c')](0x1f4)[_0xd6ee('0xcb')](new db[(_0xd6ee('0x8c'))]['ValidationError'](_0xd6ee('0xd0')+_0x4ec9b1));}_0x5c1a96[_0x8051cc[_0xd6ee('0x5c')]['mapKeyOffline']]=_0x8051cc[_0xd6ee('0x5c')][_0xd6ee('0x97')];})['then'](function(){return db[_0xd6ee('0x53')][_0xd6ee('0x60')]({'where':{'id':_0x8051cc[_0xd6ee('0x57')]['id']},'include':[{'model':db['CmList'],'as':_0xd6ee('0x99')},{'model':db[_0xd6ee('0xd1')],'as':_0xd6ee('0xd1')}]});})[_0xd6ee('0x20')](handleEntityNotFound(_0x20f856,null))[_0xd6ee('0x20')](function(_0x2f0a4d){if(_0x2f0a4d&&_0x2f0a4d[_0xd6ee('0x99')]){_0x506960=_0x2f0a4d;var _0x5bced5=_[_0xd6ee('0x18')](_0x8051cc['body'],{'firstName':_0x8051cc['body'][_0xd6ee('0x97')],'phone':_0x8051cc[_0xd6ee('0x5c')][_0xd6ee('0x97')],'ListId':_0x2f0a4d[_0xd6ee('0xca')]});_0x5bced5[_0x8051cc[_0xd6ee('0x5c')]['mapKeyOffline']]=_0x8051cc[_0xd6ee('0x5c')][_0xd6ee('0x97')];return db[_0xd6ee('0x9a')][_0xd6ee('0xd2')]({'where':_0x5c1a96,'defaults':_0x5bced5});}})['spread'](function(_0x531f10){if(_0x531f10){_0x4e3677=_0x531f10;var _0xbdf938=fs[_0xd6ee('0xd3')](path[_0xd6ee('0x79')](config[_0xd6ee('0x7e')],_0xd6ee('0xd4')),_0xd6ee('0xd5'));var _0x1c7a78=ejs[_0xd6ee('0xd6')](_0xbdf938,{'body':_['toPairs'](_0x8051cc[_0xd6ee('0x5c')][_0xd6ee('0x5c')]),'bodyTitle':_0x506960['offlineMessageBody']});return db[_0xd6ee('0xd7')][_0xd6ee('0x5b')]({'body':_0x1c7a78,'ContactId':_0x531f10['id'],'ChatWebsiteId':_0x506960['id']});}})[_0xd6ee('0x20')](function(_0x3c734f){_0x253baf=_0x3c734f;if(_0x4fbc1e[_0xd6ee('0x49')]){var _0x57536a=_0x4fbc1e[_0xd6ee('0x41')](function(_0x465caa){return{'name':_0x465caa[_0xd6ee('0xd8')],'basename':_0x465caa['filename'],'type':_0x465caa['mimetype'],'ChatOfflineMessageId':_0x3c734f['id']};});_0x3e2ed6=_0x57536a[_0xd6ee('0x41')](_0x113b76=>{var _0x3821f3={'filename':_0x113b76[_0xd6ee('0x3d')],'path':path['join'](config['root'],_0xd6ee('0xd9'),_0xd6ee('0xc9'),'attachments','offline-chat',_0x113b76[_0xd6ee('0xda')])};return _0x3821f3;});if(!_0x506960[_0xd6ee('0xdb')]){return db[_0xd6ee('0xdc')]['transaction'](function(_0x4459ba){return db[_0xd6ee('0xdd')][_0xd6ee('0xde')](_0x57536a,{'transaction':_0x4459ba});});}}})['then'](function(){if(_0x253baf){_0x428710=_0x253baf;return db[_0xd6ee('0xd1')][_0xd6ee('0x69')]({'where':{'active':!![]},'include':[{'model':db[_0xd6ee('0xdf')],'as':_0xd6ee('0xe0'),'raw':!![]}]});}})[_0xd6ee('0x20')](function(_0x3e4f69){if(_0x3e4f69&&_0x3e4f69[_0xd6ee('0xe0')]&&_0x506960[_0xd6ee('0xe1')]&&_0x506960[_0xd6ee('0xe2')]){var _0x216529={'tls':{'rejectUnauthorized':![]}};if(_0x3e4f69['Smtp'][_0xd6ee('0xe3')]){_0x216529[_0xd6ee('0xe3')]=_0x3e4f69['Smtp'][_0xd6ee('0xe3')];}else{_0x216529[_0xd6ee('0xe4')]=_0x3e4f69[_0xd6ee('0xe0')][_0xd6ee('0xe4')];_0x216529[_0xd6ee('0xe5')]=_0x3e4f69[_0xd6ee('0xe0')][_0xd6ee('0xe5')];_0x216529[_0xd6ee('0xe6')]=_0x3e4f69[_0xd6ee('0xe0')][_0xd6ee('0xe6')];}if(_0x3e4f69['Smtp']['authentication']){_0x216529[_0xd6ee('0xe7')]={'user':_0x3e4f69[_0xd6ee('0xe0')][_0xd6ee('0x5d')],'pass':_0x3e4f69[_0xd6ee('0xe0')]['pass']};}return respondWithRpcPromise(_0xd6ee('0xe8'),'sendMail',{'account':_0x216529,'message':{'from':util['format'](_0xd6ee('0xe9'),_0x3e4f69[_0xd6ee('0x3d')],_0x3e4f69[_0xd6ee('0xea')]||_0x3e4f69['Smtp'][_0xd6ee('0x5d')]),'to':_0x506960[_0xd6ee('0xe2')],'subject':_0x506960[_0xd6ee('0xeb')],'html':_0x428710[_0xd6ee('0x5c')],'attachments':_0x3e2ed6}},client9003)[_0xd6ee('0x20')](function(){return _0x428710;})['catch'](function(_0x1cc2ea){console['error'](_0x1cc2ea);});}})[_0xd6ee('0x20')](function(){if(_0x506960&&_0x506960[_0xd6ee('0xdb')]&&_0x506960[_0xd6ee('0xec')]){var _0x34faf5=[];if(_0x4fbc1e['length']){_0x34faf5=_0x4fbc1e['map'](function(_0x44a312){return{'name':_0x44a312[_0xd6ee('0xd8')],'basename':_0x44a312[_0xd6ee('0x73')],'type':_0x44a312['mimetype'],'ChatOfflineMessageId':_0x253baf['id']};});}var _0x3be736;if(!_[_0xd6ee('0x7b')](_0x506960[_0xd6ee('0xed')])){var _0x1b05a2=_[_0xd6ee('0x41')](_0x8051cc[_0xd6ee('0x5c')],function(_0x1cf694){return _0x1cf694;});var _0x2072d1=_['toPairsIn'](_0x1b05a2)[0x0];var _0x4aed67=_[_0xd6ee('0xee')](_0x2072d1,function(_0x2e5533){return _0x2e5533;});_0x3be736=_0x4aed67[0x1][_0x506960[_0xd6ee('0xed')]];}var _0x42388d={'from':_0x4e3677[_0xd6ee('0xea')],'firstName':_0x4e3677['firstName'],'lastName':_0x4e3677[_0xd6ee('0xb9')],'mapKey':_0xd6ee('0xea'),'message':{'from':_0x4e3677[_0xd6ee('0xea')],'to':_0x506960['MailAccount'][_0xd6ee('0xea')],'cc':'','subject':_['isNil'](_0x3be736)?_0x506960[_0xd6ee('0xeb')]:_0x3be736,'messageId':'','sentAt':new Date(),'attach':_0x34faf5[_0xd6ee('0x49')],'attachments':_0x34faf5,'originChannel':_0xd6ee('0xef'),'ChatWebsiteId':_0x506960['id'],'ChatOfflineMessageId':_0x428710['id'],'originTo':_0x506960[_0xd6ee('0xd1')]['email']},'body':_0x428710[_0xd6ee('0x5c')]};var _0x1a1f3e={'account':{'id':_0x506960[_0xd6ee('0xec')]},'body':_0x42388d,'log':'NotifyMailAccount'};return respondWithRpcPromise(_0xd6ee('0xf0'),_0xd6ee('0xf1'),_0x1a1f3e,client9001)[_0xd6ee('0x20')](function(){return _0x428710;})['catch'](function(_0x4c26c2){console['error'](_0x4c26c2);});}return;})[_0xd6ee('0x20')](function(){if(_0x428710){return _0x428710;}})['then'](respondWithResult(_0x20f856,null))['catch'](function(_0x43c62c){console[_0xd6ee('0x27')]('catch',_0x43c62c);for(var _0x38954e of _0x4fbc1e){var _0x433cc1=path['join'](config[_0xd6ee('0x7e')],_0xd6ee('0xd9'),_0xd6ee('0xc9'),_0xd6ee('0xf2'),_0xd6ee('0xf3'),_0x38954e['filename']);fs_extra[_0xd6ee('0xf4')](_0x433cc1)['catch'](function(_0x40c246){console[_0xd6ee('0x27')]('Could\x20not\x20remove\x20attachment\x20file',_0x433cc1,_0x40c246);});}});};exports[_0xd6ee('0xf5')]=function(_0x751255,_0x40bcd1,_0x5eb664){return db[_0xd6ee('0xb3')]['find']({'where':{'id':_0x751255[_0xd6ee('0x57')]['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0x40bcd1,null))[_0xd6ee('0x20')](function(_0x389e62){if(_0x389e62){return _0x389e62[_0xd6ee('0xf5')](_0x751255['body'][_0xd6ee('0x6d')],_['omit'](_0x751255['body'],[_0xd6ee('0x6d'),'id'])||{});}})[_0xd6ee('0x20')](respondWithResult(_0x40bcd1,null))[_0xd6ee('0x2a')](handleError(_0x40bcd1,null));};exports[_0xd6ee('0xf6')]=function(_0x29c697,_0x4ab57e,_0xb03664){var _0x3b69e4={'raw':![],'where':{}};var _0x27670f={};var _0x229dd6={'count':0x0,'rows':[]};return db[_0xd6ee('0x53')][_0xd6ee('0x69')]({'where':{'id':_0x29c697['params']['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0x4ab57e,null))['then'](function(_0x160240){if(_0x160240){_0x27670f['model']=_[_0xd6ee('0x58')](db['ChatInteraction'][_0xd6ee('0x59')]);_0x27670f[_0xd6ee('0x45')]=_[_0xd6ee('0x58')](_0x29c697['query']);_0x27670f['filters']=_[_0xd6ee('0x47')](_0x27670f['model'],_0x27670f[_0xd6ee('0x45')]);_0x3b69e4[_0xd6ee('0x46')]=_['intersection'](_0x27670f[_0xd6ee('0x44')],qs[_0xd6ee('0x48')](_0x29c697[_0xd6ee('0x45')][_0xd6ee('0x48')]));_0x3b69e4[_0xd6ee('0x46')]=_0x3b69e4['attributes'][_0xd6ee('0x49')]?_0x3b69e4['attributes']:_0x27670f[_0xd6ee('0x44')];if(!_0x29c697['query']['hasOwnProperty'](_0xd6ee('0x6a'))){_0x3b69e4[_0xd6ee('0x2f')]=qs['limit'](_0x29c697[_0xd6ee('0x45')][_0xd6ee('0x2f')]);_0x3b69e4[_0xd6ee('0x31')]=qs[_0xd6ee('0x31')](_0x29c697[_0xd6ee('0x45')][_0xd6ee('0x31')]);}_0x3b69e4[_0xd6ee('0x4a')]=qs[_0xd6ee('0x4b')](_0x29c697[_0xd6ee('0x45')]['sort']);_0x3b69e4['where']=qs[_0xd6ee('0x4c')](_[_0xd6ee('0x4d')](_0x29c697[_0xd6ee('0x45')],_0x27670f['filters']));_0x3b69e4[_0xd6ee('0x4f')][_0xd6ee('0x66')]=_0x160240['id'];if(_0x29c697['query']['filter']){_0x3b69e4['where']=_['merge'](_0x3b69e4[_0xd6ee('0x4f')],{'$or':_[_0xd6ee('0x41')](_0x3b69e4[_0xd6ee('0x46')],function(_0x5abda8){var _0x17fddd={};_0x17fddd[_0x5abda8]={'$like':'%'+_0x29c697[_0xd6ee('0x45')][_0xd6ee('0x4e')]+'%'};return _0x17fddd;})});}_0x3b69e4=_[_0xd6ee('0x50')]({},_0x3b69e4,_0x29c697[_0xd6ee('0x52')]);return db[_0xd6ee('0xb3')][_0xd6ee('0x30')]({'where':_0x3b69e4[_0xd6ee('0x4f')]})['then'](function(_0xa25e3d){_0x229dd6['count']=_0xa25e3d;if(_0x29c697[_0xd6ee('0x45')]['includeAll']){_0x3b69e4[_0xd6ee('0x5a')]=[{'model':db[_0xd6ee('0x9a')],'as':_0xd6ee('0xf7'),'required':![]},{'model':db[_0xd6ee('0xbf')],'as':'Owner','attributes':[_0xd6ee('0x3d'),'fullname',_0xd6ee('0xf8')],'required':![]},{'model':db['Tag'],'as':_0xd6ee('0xf9'),'attributes':['id',_0xd6ee('0x3d'),_0xd6ee('0xfa')],'where':_0x29c697[_0xd6ee('0x45')]['tag']?{'id':_0x29c697[_0xd6ee('0x45')]['tag']}:undefined,'required':_0x29c697[_0xd6ee('0x45')][_0xd6ee('0xfb')]?!![]:![]}];}return db[_0xd6ee('0xb3')]['findAll'](_0x3b69e4);})['then'](function(_0xc130bd){_0x229dd6[_0xd6ee('0x55')]=_0xc130bd;return _0x229dd6;});}})[_0xd6ee('0x20')](respondWithFilteredResult(_0x4ab57e,_0x3b69e4))['catch'](handleError(_0x4ab57e,null));};function iftimePromise(_0x2f34d9,_0x233b7b){return respondWithRpcPromise(_0xd6ee('0xfc'),'getSnippet',{'command':_0x233b7b[_0xd6ee('0xfd')]?util[_0xd6ee('0xab')](_0xd6ee('0xfe'),_0x2f34d9['interval'],_0x233b7b[_0xd6ee('0xfd')]):util[_0xd6ee('0xab')](_0xd6ee('0xff'),_0x2f34d9[_0xd6ee('0x100')])},client9002)[_0xd6ee('0x20')](function(_0x1d878d){var _0x41b85a=_0x1d878d&&_0x1d878d[_0xd6ee('0x101')]('true')>=0x0?!![]:![];logger[_0xd6ee('0x21')](_0xd6ee('0x102'),_0x233b7b['id'],_0x2f34d9['id'],_0x2f34d9[_0xd6ee('0x100')],_0x41b85a?_0xd6ee('0x103'):_0xd6ee('0x104'),_0x233b7b[_0xd6ee('0xfd')]?_0x233b7b[_0xd6ee('0xfd')]:_0xd6ee('0x105'));return _0x41b85a;})['catch'](function(_0x15b882){logger[_0xd6ee('0x27')](_0xd6ee('0x102'),_0x233b7b['id'],_0x2f34d9['id'],_0x2f34d9[_0xd6ee('0x100')],util['inspect'](_0x15b882,{'showHidden':![],'depth':null}),_0x233b7b[_0xd6ee('0xfd')]?_0x233b7b['timezone']:_0xd6ee('0x105'));return![];});}exports[_0xd6ee('0x106')]=function(_0x4148c6,_0x21e0a9,_0xe38fb7){var _0x2164b4=0x0;var _0x3aaaf8=0x0;var _0x23fc8b=![];var _0x32bacd;var _0x4e5686;return db[_0xd6ee('0x53')][_0xd6ee('0x60')]({'where':{'id':_0x4148c6[_0xd6ee('0x57')]['id']},'include':[{'model':db[_0xd6ee('0x107')],'as':_0xd6ee('0x107'),'include':[{'model':db[_0xd6ee('0x107')],'as':_0xd6ee('0x108'),'attributes':['id',_0xd6ee('0x100')],'raw':!![]}]}]})[_0xd6ee('0x20')](handleEntityNotFound(_0x21e0a9,null))[_0xd6ee('0x20')](function(_0x4d5efa){if(_0x4d5efa){_0x32bacd=_0x4d5efa;return _0x4d5efa[_0xd6ee('0x109')]({'raw':!![]});}})[_0xd6ee('0x20')](function(_0x50dac5){if(_0x32bacd){if(_0x50dac5){_0x4e5686=_0x50dac5;}}return require(_0xd6ee('0x15'))[_0xd6ee('0x10a')]();})[_0xd6ee('0x20')](function(_0x3369e6){if(_0x3369e6){_0x3aaaf8=_0x3369e6[_0xd6ee('0x10b')];_0x23fc8b=_0x3369e6['custom'];}})[_0xd6ee('0x20')](function(){return db[_0xd6ee('0xb3')][_0xd6ee('0x30')]({'where':{'closed':![]}});})['then'](function(_0x11662b){_0x2164b4=_0x11662b;if(_0x3aaaf8&&_0x11662b>_0x3aaaf8){return db[_0xd6ee('0x10c')][_0xd6ee('0x69')]({'where':{'id':0x1}})[_0xd6ee('0x20')](function(_0x38ffcd){if(_0x38ffcd){_0x38ffcd['increment'](_0xd6ee('0x10d'));}});}})[_0xd6ee('0x20')](function(){if(_0x32bacd[_0xd6ee('0x107')]&&_0x32bacd['Interval']['Intervals']){var _0x4544c7=[];for(var _0x13d0fe=0x0;_0x13d0fe<_0x32bacd['Interval'][_0xd6ee('0x108')][_0xd6ee('0x49')];_0x13d0fe++){var _0x4c4706=_0x32bacd['Interval'][_0xd6ee('0x108')][_0x13d0fe][_0xd6ee('0x38')]({'plain':!![]});_0x4544c7['push'](iftimePromise(_0x4c4706,_0x32bacd));}return BPromise['all'](_0x4544c7)[_0xd6ee('0x20')](function(_0x5ee9c2){return _[_0xd6ee('0x10e')](_0x5ee9c2);});}else{return!![];}})['then'](function(_0x2d8bb4){var _0x2ac619=fs['readFileSync'](path['join'](config[_0xd6ee('0x7e')],_0xd6ee('0x10f')),'utf8');var _0x2d59f7={'remote':_0x32bacd[_0xd6ee('0x110')],'query':querystring[_0xd6ee('0x26')](_[_0xd6ee('0x50')](_0x32bacd[_0xd6ee('0x38')]({'plain':!![]}),{'customerIp':_0x4148c6[_0xd6ee('0x88')][_0xd6ee('0xa5')]||_0x4148c6[_0xd6ee('0x88')][_0xd6ee('0x111')]||_0x4148c6[_0xd6ee('0x112')][_0xd6ee('0x113')]||_0x4148c6['ip'],'referer':_0x4148c6['headers'][_0xd6ee('0xa8')],'openedInteractions':_0x2164b4,'maxInteractions':_0x3aaaf8,'virtual':_0x23fc8b['virtual'],'online':_0x2d8bb4,'custom':_0x23fc8b}))['replace'](/'/g,'\x5c\x27')};_0x21e0a9['send'](ejs[_0xd6ee('0xd6')](Mustache[_0xd6ee('0xd6')](_0x2ac619,_0x2d59f7),{'proactiveActions':_0x4e5686,'alignment':_0x32bacd['alignment'],'verticalAlignment':_0x32bacd[_0xd6ee('0x114')],'div_color':_0x32bacd['color'],'text_color':_0x32bacd['textColor'],'button_color':_0x32bacd['color_button'],'background_color':_0x32bacd[_0xd6ee('0x115')]}));})[_0xd6ee('0x2a')](handleError(_0x21e0a9,null));};exports[_0xd6ee('0x116')]=function(_0x2ece71,_0x40f379,_0x3ffe19){return db[_0xd6ee('0x53')][_0xd6ee('0x69')]({'where':{'id':_0x2ece71['params']['id']}})['then'](handleEntityNotFound(_0x40f379,null))['then'](function(_0x4de858){if(_0x4de858){return db['sequelize']['transaction'](function(_0x4f6c6b){return db[_0xd6ee('0x9c')][_0xd6ee('0x37')]({'where':{'ChatWebsiteId':_0x2ece71['params']['id']},'transaction':_0x4f6c6b})[_0xd6ee('0x20')](function(_0x2be26a){var _0x1f6529=_['map'](_0x2ece71[_0xd6ee('0x5c')],function(_0x296edb){_0x296edb[_0xd6ee('0x66')]=_0x2ece71[_0xd6ee('0x57')]['id'];return _0x296edb;});return db[_0xd6ee('0x9c')][_0xd6ee('0xde')](_0x1f6529,{'transaction':_0x4f6c6b});});})[_0xd6ee('0x20')](function(){return db[_0xd6ee('0x9c')][_0xd6ee('0x117')]({'where':{'ChatWebsiteId':_0x2ece71[_0xd6ee('0x57')]['id']},'order':_0xd6ee('0xa2')});});}})[_0xd6ee('0x20')](respondWithResult(_0x40f379,null))['catch'](handleError(_0x40f379,null));};exports['getApplications']=function(_0x5d2fd4,_0x1bf78f,_0x1fbe68){var _0x38059b={};var _0x3badd6={};var _0x2fc5da;var _0x59ecae;return db['ChatWebsite'][_0xd6ee('0x69')]({'where':{'id':_0x5d2fd4[_0xd6ee('0x57')]['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0x1bf78f,null))[_0xd6ee('0x20')](function(_0x59e846){if(_0x59e846){_0x2fc5da=_0x59e846;_0x3badd6['model']=_['keys'](db[_0xd6ee('0x9c')][_0xd6ee('0x59')]);_0x3badd6[_0xd6ee('0x45')]=_[_0xd6ee('0x58')](_0x5d2fd4['query']);_0x3badd6[_0xd6ee('0x4c')]=_[_0xd6ee('0x47')](_0x3badd6[_0xd6ee('0x44')],_0x3badd6['query']);_0x38059b[_0xd6ee('0x46')]=_[_0xd6ee('0x47')](_0x3badd6['model'],qs['fields'](_0x5d2fd4[_0xd6ee('0x45')][_0xd6ee('0x48')]));_0x38059b[_0xd6ee('0x46')]=_0x38059b[_0xd6ee('0x46')][_0xd6ee('0x49')]?_0x38059b['attributes']:_0x3badd6[_0xd6ee('0x44')];_0x38059b[_0xd6ee('0x4a')]=qs['sort'](_0x5d2fd4[_0xd6ee('0x45')][_0xd6ee('0x4b')]);_0x38059b['where']=qs[_0xd6ee('0x4c')](_[_0xd6ee('0x4d')](_0x5d2fd4['query'],_0x3badd6['filters']));if(_0x5d2fd4[_0xd6ee('0x45')][_0xd6ee('0x4e')]){_0x38059b[_0xd6ee('0x4f')]=_[_0xd6ee('0x50')](_0x38059b[_0xd6ee('0x4f')],{'$or':_[_0xd6ee('0x41')](_0x38059b[_0xd6ee('0x46')],function(_0x350caa){var _0xb80ac7={};_0xb80ac7[_0x350caa]={'$like':'%'+_0x5d2fd4[_0xd6ee('0x45')][_0xd6ee('0x4e')]+'%'};return _0xb80ac7;})});}_0x38059b=_['merge']({},_0x38059b,_0x5d2fd4[_0xd6ee('0x52')]);return _0x2fc5da[_0xd6ee('0x118')](_0x38059b);}})[_0xd6ee('0x20')](function(_0x311b47){if(_0x311b47){_0x59ecae=_0x311b47[_0xd6ee('0x49')];if(!_0x5d2fd4['query'][_0xd6ee('0x70')](_0xd6ee('0x6a'))){_0x38059b[_0xd6ee('0x2f')]=qs[_0xd6ee('0x2f')](_0x5d2fd4['query']['limit']);_0x38059b[_0xd6ee('0x31')]=qs['offset'](_0x5d2fd4['query'][_0xd6ee('0x31')]);}return _0x2fc5da[_0xd6ee('0x118')](_0x38059b);}})[_0xd6ee('0x20')](function(_0x2ccb45){if(_0x2ccb45){return _0x2ccb45?{'count':_0x59ecae,'rows':_0x2ccb45}:null;}})[_0xd6ee('0x20')](respondWithResult(_0x1bf78f,null))['catch'](handleError(_0x1bf78f,null));};exports[_0xd6ee('0x119')]=function(_0x33360,_0x2fa3b5,_0x20c409){return db[_0xd6ee('0x11a')][_0xd6ee('0x60')]({'where':{'id':_0x33360[_0xd6ee('0x57')]['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0x2fa3b5,null))[_0xd6ee('0x20')](function(_0x3d4973){if(_0x3d4973){return _0x3d4973[_0xd6ee('0x119')](_0x33360['body']['ids'],_[_0xd6ee('0x11b')](_0x33360['body'],[_0xd6ee('0x6d'),'id'])||{});}})[_0xd6ee('0x20')](respondWithResult(_0x2fa3b5,null))[_0xd6ee('0x2a')](handleError(_0x2fa3b5,null));};exports['getProactiveActions']=function(_0x4bd06d,_0x110d25,_0x52b60e){var _0x4ef4e0={};var _0x13ec29={};var _0x187bd3;var _0x279681;return db[_0xd6ee('0x53')][_0xd6ee('0x69')]({'where':{'id':_0x4bd06d[_0xd6ee('0x57')]['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0x110d25,null))[_0xd6ee('0x20')](function(_0x329370){if(_0x329370){_0x187bd3=_0x329370;_0x13ec29['model']=_[_0xd6ee('0x58')](db[_0xd6ee('0x11c')]['rawAttributes']);_0x13ec29['query']=_[_0xd6ee('0x58')](_0x4bd06d[_0xd6ee('0x45')]);_0x13ec29[_0xd6ee('0x4c')]=_[_0xd6ee('0x47')](_0x13ec29[_0xd6ee('0x44')],_0x13ec29[_0xd6ee('0x45')]);_0x4ef4e0[_0xd6ee('0x46')]=_['intersection'](_0x13ec29['model'],qs[_0xd6ee('0x48')](_0x4bd06d[_0xd6ee('0x45')][_0xd6ee('0x48')]));_0x4ef4e0[_0xd6ee('0x46')]=_0x4ef4e0['attributes'][_0xd6ee('0x49')]?_0x4ef4e0[_0xd6ee('0x46')]:_0x13ec29[_0xd6ee('0x44')];_0x4ef4e0[_0xd6ee('0x4a')]=qs[_0xd6ee('0x4b')](_0x4bd06d[_0xd6ee('0x45')][_0xd6ee('0x4b')]);_0x4ef4e0[_0xd6ee('0x4f')]=qs[_0xd6ee('0x4c')](_[_0xd6ee('0x4d')](_0x4bd06d[_0xd6ee('0x45')],_0x13ec29[_0xd6ee('0x4c')]));if(_0x4bd06d[_0xd6ee('0x45')][_0xd6ee('0x4e')]){_0x4ef4e0[_0xd6ee('0x4f')]=_[_0xd6ee('0x50')](_0x4ef4e0[_0xd6ee('0x4f')],{'$or':_[_0xd6ee('0x41')](_0x4ef4e0[_0xd6ee('0x46')],function(_0x384a7b){var _0x2bc8c7={};_0x2bc8c7[_0x384a7b]={'$like':'%'+_0x4bd06d['query'][_0xd6ee('0x4e')]+'%'};return _0x2bc8c7;})});}_0x4ef4e0=_[_0xd6ee('0x50')]({},_0x4ef4e0,_0x4bd06d['options']);return _0x187bd3[_0xd6ee('0x109')](_0x4ef4e0);}})[_0xd6ee('0x20')](function(_0x29cf52){if(_0x29cf52){_0x279681=_0x29cf52[_0xd6ee('0x49')];if(!_0x4bd06d['query']['hasOwnProperty'](_0xd6ee('0x6a'))){_0x4ef4e0['limit']=qs['limit'](_0x4bd06d[_0xd6ee('0x45')]['limit']);_0x4ef4e0[_0xd6ee('0x31')]=qs['offset'](_0x4bd06d[_0xd6ee('0x45')][_0xd6ee('0x31')]);}return _0x187bd3['getProactiveActions'](_0x4ef4e0);}})[_0xd6ee('0x20')](function(_0x294ab3){if(_0x294ab3){return _0x294ab3?{'count':_0x279681,'rows':_0x294ab3}:null;}})[_0xd6ee('0x20')](respondWithResult(_0x110d25,null))[_0xd6ee('0x2a')](handleError(_0x110d25,null));};exports[_0xd6ee('0x11d')]=function(_0x32a518,_0x2b45d0,_0xa4e265){var _0x28cba3=_0x32a518[_0xd6ee('0x45')][_0xd6ee('0x11e')]==='false'?_0xd6ee('0x11f'):'onlineForm';return db[_0xd6ee('0x53')][_0xd6ee('0x60')]({'attributes':['id',_0x28cba3],'where':{'id':_0x32a518[_0xd6ee('0x57')]['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0x2b45d0,null))[_0xd6ee('0x20')](function(_0x7fa5cb){if(_0x7fa5cb){var _0x1738e9=_0x7fa5cb[_0x28cba3];var _0x59b221=_0x1738e9&&_0x1738e9[_0xd6ee('0x120')]?_0x1738e9[_0xd6ee('0x120')]:[];_0x2b45d0[_0xd6ee('0xcb')]({'fromKey':_[_0xd6ee('0x7b')](_0x1738e9[_0xd6ee('0x121')])?undefined:_0x1738e9[_0xd6ee('0x121')],'count':_0x59b221[_0xd6ee('0x49')],'rows':_0x59b221});}})[_0xd6ee('0x2a')](handleError(_0x2b45d0,null));};exports['getOfflineMessages']=function(_0x2a4c85,_0x4f847c,_0x2a0c4e){var _0x23dd9d={'raw':![],'where':{}};var _0x8ac206={};var _0x27b264={'count':0x0,'rows':[]};return db['ChatWebsite'][_0xd6ee('0x69')]({'where':{'id':_0x2a4c85[_0xd6ee('0x57')]['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0x4f847c,null))[_0xd6ee('0x20')](function(_0x1ef8b4){if(_0x1ef8b4){_0x8ac206[_0xd6ee('0x44')]=_['keys'](db['ChatOfflineMessage'][_0xd6ee('0x59')]);_0x8ac206[_0xd6ee('0x45')]=_['keys'](_0x2a4c85[_0xd6ee('0x45')]);_0x8ac206[_0xd6ee('0x4c')]=_[_0xd6ee('0x47')](_0x8ac206[_0xd6ee('0x44')],_0x8ac206[_0xd6ee('0x45')]);_0x23dd9d['attributes']=_[_0xd6ee('0x47')](_0x8ac206[_0xd6ee('0x44')],qs[_0xd6ee('0x48')](_0x2a4c85['query'][_0xd6ee('0x48')]));_0x23dd9d[_0xd6ee('0x46')]=_0x23dd9d[_0xd6ee('0x46')][_0xd6ee('0x49')]?_0x23dd9d[_0xd6ee('0x46')]:_0x8ac206[_0xd6ee('0x44')];if(!_0x2a4c85[_0xd6ee('0x45')]['hasOwnProperty'](_0xd6ee('0x6a'))){_0x23dd9d[_0xd6ee('0x2f')]=qs[_0xd6ee('0x2f')](_0x2a4c85['query'][_0xd6ee('0x2f')]);_0x23dd9d[_0xd6ee('0x31')]=qs[_0xd6ee('0x31')](_0x2a4c85[_0xd6ee('0x45')][_0xd6ee('0x31')]);}_0x23dd9d[_0xd6ee('0x4a')]=qs[_0xd6ee('0x4b')](_0x2a4c85[_0xd6ee('0x45')][_0xd6ee('0x4b')]);_0x23dd9d['where']=qs[_0xd6ee('0x4c')](_[_0xd6ee('0x4d')](_0x2a4c85['query'],_0x8ac206[_0xd6ee('0x4c')]));_0x23dd9d[_0xd6ee('0x4f')][_0xd6ee('0x66')]=_0x1ef8b4['id'];if(_0x2a4c85['query'][_0xd6ee('0x4e')]){_0x23dd9d['where']=_[_0xd6ee('0x50')](_0x23dd9d['where'],{'$or':_[_0xd6ee('0x41')](_0x23dd9d[_0xd6ee('0x46')],function(_0x389761){var _0x2ffd21={};_0x2ffd21[_0x389761]={'$like':'%'+_0x2a4c85[_0xd6ee('0x45')][_0xd6ee('0x4e')]+'%'};return _0x2ffd21;})});}_0x23dd9d=_[_0xd6ee('0x50')]({},_0x23dd9d,_0x2a4c85[_0xd6ee('0x52')]);return db[_0xd6ee('0xd7')][_0xd6ee('0x30')]({'where':_0x23dd9d[_0xd6ee('0x4f')]})[_0xd6ee('0x20')](function(_0x3a9a31){_0x27b264[_0xd6ee('0x30')]=_0x3a9a31;if(_0x2a4c85[_0xd6ee('0x45')]['includeAll']){_0x23dd9d['include']=[{'all':!![]}];}else{_0x23dd9d['include']=[{'model':db[_0xd6ee('0x9a')],'as':_0xd6ee('0xf7'),'required':![]},{'model':db[_0xd6ee('0xdd')],'as':_0xd6ee('0x122'),'required':![]}];}return db[_0xd6ee('0xd7')][_0xd6ee('0x6b')](_0x23dd9d);})[_0xd6ee('0x20')](function(_0xb4535f){_0x27b264['rows']=_0xb4535f;return _0x27b264;});}})[_0xd6ee('0x20')](respondWithFilteredResult(_0x4f847c,_0x23dd9d))[_0xd6ee('0x2a')](handleError(_0x4f847c,null));};exports[_0xd6ee('0x123')]=function(_0x176683,_0x4f64bd,_0x14e536){return db[_0xd6ee('0x53')]['find']({'where':{'id':_0x176683[_0xd6ee('0x57')]['id']}})['then'](handleEntityNotFound(_0x4f64bd,null))[_0xd6ee('0x20')](function(_0x1abaab){if(_0x1abaab){return _0x1abaab[_0xd6ee('0x123')](_0x176683['body'][_0xd6ee('0x6d')],_[_0xd6ee('0x11b')](_0x176683[_0xd6ee('0x5c')],[_0xd6ee('0x6d'),'id'])||{})['spread'](function(_0x4da2cb){for(var _0x397e4d=0x0;_0x397e4d<_0x176683[_0xd6ee('0x5c')][_0xd6ee('0x6d')][_0xd6ee('0x49')];_0x397e4d+=0x1){socket[_0xd6ee('0x124')]('userChatWebsite:save',{'UserId':_0x176683[_0xd6ee('0x5c')][_0xd6ee('0x6d')][_0x397e4d],'ChatWebsiteId':_0x176683[_0xd6ee('0x57')]['id']});}return _0x4da2cb;});}})[_0xd6ee('0x20')](respondWithResult(_0x4f64bd,null))['catch'](handleError(_0x4f64bd,null));};exports[_0xd6ee('0x125')]=function(_0x294b89,_0x5be431,_0x30bff6){return db[_0xd6ee('0x53')][_0xd6ee('0x60')]({'where':{'id':_0x294b89['params']['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0x5be431,null))[_0xd6ee('0x20')](function(_0xa9a195){if(_0xa9a195){return _0xa9a195[_0xd6ee('0x125')](_0x294b89[_0xd6ee('0x45')][_0xd6ee('0x6d')])['then'](function(){if(_[_0xd6ee('0x126')](_0x294b89[_0xd6ee('0x45')][_0xd6ee('0x6d')])){for(var _0x3ad875=0x0;_0x3ad875<_0x294b89['query'][_0xd6ee('0x6d')]['length'];_0x3ad875+=0x1){socket[_0xd6ee('0x124')]('userChatWebsite:remove',{'UserId':Number(_0x294b89[_0xd6ee('0x45')][_0xd6ee('0x6d')][_0x3ad875]),'ChatWebsiteId':Number(_0x294b89[_0xd6ee('0x57')]['id'])});}}else{socket[_0xd6ee('0x124')](_0xd6ee('0x127'),{'UserId':Number(_0x294b89[_0xd6ee('0x45')][_0xd6ee('0x6d')]),'ChatWebsiteId':Number(_0x294b89['params']['id'])});}});}})[_0xd6ee('0x20')](respondWithStatusCode(_0x5be431,null))[_0xd6ee('0x2a')](handleError(_0x5be431,null));};exports[_0xd6ee('0x128')]=function(_0x2808b,_0x5bb0cc,_0x1392e2){var _0x588ad0={};var _0x15e4b8={};var _0x55487f;var _0x5c96d0;return db[_0xd6ee('0x53')][_0xd6ee('0x69')]({'where':{'id':_0x2808b[_0xd6ee('0x57')]['id']}})[_0xd6ee('0x20')](handleEntityNotFound(_0x5bb0cc,null))[_0xd6ee('0x20')](function(_0x203f4b){if(_0x203f4b){_0x55487f=_0x203f4b;_0x15e4b8[_0xd6ee('0x44')]=_[_0xd6ee('0x58')](db[_0xd6ee('0xbf')][_0xd6ee('0x59')]);_0x15e4b8[_0xd6ee('0x45')]=_[_0xd6ee('0x58')](_0x2808b[_0xd6ee('0x45')]);_0x15e4b8[_0xd6ee('0x4c')]=_[_0xd6ee('0x47')](_0x15e4b8[_0xd6ee('0x44')],_0x15e4b8[_0xd6ee('0x45')]);_0x588ad0[_0xd6ee('0x46')]=_[_0xd6ee('0x47')](_0x15e4b8[_0xd6ee('0x44')],qs['fields'](_0x2808b['query'][_0xd6ee('0x48')]));_0x588ad0['attributes']=_0x588ad0[_0xd6ee('0x46')][_0xd6ee('0x49')]?_0x588ad0[_0xd6ee('0x46')]:_0x15e4b8[_0xd6ee('0x44')];_0x588ad0['order']=qs[_0xd6ee('0x4b')](_0x2808b[_0xd6ee('0x45')][_0xd6ee('0x4b')]);_0x588ad0[_0xd6ee('0x4f')]=qs[_0xd6ee('0x4c')](_[_0xd6ee('0x4d')](_0x2808b['query'],_0x15e4b8['filters']));if(_0x2808b[_0xd6ee('0x45')][_0xd6ee('0x4e')]){_0x588ad0['where']=_['merge'](_0x588ad0[_0xd6ee('0x4f')],{'$or':_['map'](_0x588ad0[_0xd6ee('0x46')],function(_0x4b55c0){var _0x217fac={};_0x217fac[_0x4b55c0]={'$like':'%'+_0x2808b[_0xd6ee('0x45')]['filter']+'%'};return _0x217fac;})});}_0x588ad0=_['merge']({},_0x588ad0,_0x2808b[_0xd6ee('0x52')]);return _0x55487f[_0xd6ee('0x128')](_0x588ad0);}})['then'](function(_0x259e79){if(_0x259e79){_0x5c96d0=_0x259e79['length'];if(!_0x2808b['query'][_0xd6ee('0x70')](_0xd6ee('0x6a'))){_0x588ad0[_0xd6ee('0x2f')]=qs[_0xd6ee('0x2f')](_0x2808b[_0xd6ee('0x45')]['limit']);_0x588ad0[_0xd6ee('0x31')]=qs[_0xd6ee('0x31')](_0x2808b[_0xd6ee('0x45')][_0xd6ee('0x31')]);}return _0x55487f['getAgents'](_0x588ad0);}})['then'](function(_0x37be06){if(_0x37be06){return _0x37be06?{'count':_0x5c96d0,'rows':_0x37be06}:null;}})[_0xd6ee('0x20')](respondWithResult(_0x5bb0cc,null))[_0xd6ee('0x2a')](handleError(_0x5bb0cc,null));};
\ No newline at end of file
+var _0x748a=['filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','where','merge','filter','options','includeAll','rows','mandatoryDispositionPause','rawAttributes','include','find','create','body','user','role','get','UserProfileSection','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','addDisposition','Disposition','sort','ChatWebsiteId','findAll','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','findOne','pick','removeAnswers','addLogo','file','filename','agentAvatar','customerAvatar','addSystemAvatar','systemAvatar','getLogo','join','root','sitepic','custom','isNil','existsSync','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','notify','user-agent','getResult','chat','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','from','from\x20is\x20mandatory','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','List','Contacts','ChatApplication','Applications','account','applications','list','orderBy','priority','asc','contact','customerIp','headers','cf-connecting-ip','first','x-forwarded-for','firstName','lastName','x-real-port','browser','version','%s\x20%s','unknown','format','device','vendor','%s\x20%s\x20%s','threadId','ChatInteraction','externalUrl','interaction','spread','messageId','created','autoclose','push','unmanaged','ChatMessage','AttachmentId','UserId','User','unshift','agent','waitForTheAssignedAgent','forcedOwnership','startRouting','offline','files','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','MailAccount','findOrCreate','server/files/templates/chatOfflineMessage.ejs','render','offlineMessageBody','originalname','mimetype','server','attachments','offline-chat','basename','openNewInteraction','sequelize','Attachment','MailServerOut','Smtp','forwardOfflineAddress','service','host','port','secure','authentication','pass','SendMail','sendMail','\x22%s\x22\x20<%s>','email','offlineMessageSubject','MailAccountId','subjectOffline','toPairsIn','mapValues','Chat','NotifyMailAccount','notifyMail','remove','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','getInteractions','Contact','fullname','internal','Tag','Tags','color','tag','Command','iftime\x20%s,%s','interval','timezone','iftime\x20%s','indexOf','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','OFFLINE','inspect','No\x20timezone','Interval','getProactiveActions','virtual','License','increment','chatLicenseExceeded','Intervals','some','readFileSync','server/files/chat/iframe.ejs','utf8','remote','x-real-ip','connection','remoteAddress','referer','replace','alignment','verticalAlignment','textColor','color_button','backgroundColor','addApplications','bulkCreate','findAndCountAll','getApplications','addProactiveActions','chatProactiveAction','online','false','onlineForm','items','fromKey','getOfflineMessages','Attachments','ChatOfflineMessage','addAgents','emit','removeAgents','userChatWebsite:remove','getAgents','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','util','path','sox','to-csv','squel','jsforce','desk.js','querystring','ioredis','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','localhost','socket.io-emitter','redis','./chatWebsite.socket','register','jayson/promise','client','http','request','info','ChatWebsite,\x20%s,\x20%s','debug','ChatWebsite,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','catch','status','json','offset','undefined','count','limit','set','apply','reject','save','update','then','destroy','ChatWebsites','UserProfileResource','end','sendStatus','stack','name','send','Pause','map','ChatWebsite','type','model','query','keys'];(function(_0x113976,_0x2849f2){var _0x5273a3=function(_0x4ef37b){while(--_0x4ef37b){_0x113976['push'](_0x113976['shift']());}};_0x5273a3(++_0x2849f2);}(_0x748a,0xe9));var _0xa748=function(_0xfae23b,_0x2be4ba){_0xfae23b=_0xfae23b-0x0;var _0x200640=_0x748a[_0xfae23b];return _0x200640;};'use strict';var emlformat=require(_0xa748('0x0'));var rimraf=require(_0xa748('0x1'));var zipdir=require(_0xa748('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xa748('0x3'));var moment=require(_0xa748('0x4'));var BPromise=require(_0xa748('0x5'));var Mustache=require('mustache');var util=require(_0xa748('0x6'));var path=require(_0xa748('0x7'));var sox=require(_0xa748('0x8'));var csv=require(_0xa748('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xa748('0xa'));var crypto=require('crypto');var jsforce=require(_0xa748('0xb'));var deskjs=require(_0xa748('0xc'));var toCsv=require(_0xa748('0x9'));var querystring=require(_0xa748('0xd'));var Papa=require('papaparse');var Redis=require(_0xa748('0xe'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xa748('0xf'));var logger=require('../../config/logger')(_0xa748('0x10'));var utils=require(_0xa748('0x11'));var config=require(_0xa748('0x12'));var licenseUtil=require(_0xa748('0x13'));var db=require(_0xa748('0x14'))['db'];config['redis']=_[_0xa748('0x15')](config['redis'],{'host':_0xa748('0x16'),'port':0x18eb});var socket=require(_0xa748('0x17'))(new Redis(config[_0xa748('0x18')]));require(_0xa748('0x19'))[_0xa748('0x1a')](socket);var jayson=require(_0xa748('0x1b'));var client=jayson[_0xa748('0x1c')][_0xa748('0x1d')]({'port':0x232c});var client9002=jayson[_0xa748('0x1c')][_0xa748('0x1d')]({'port':0x232a});var client9003=jayson[_0xa748('0x1c')][_0xa748('0x1d')]({'port':0x232b});var client9001=jayson[_0xa748('0x1c')][_0xa748('0x1d')]({'port':0x2329});function respondWithRpcPromise(_0x2a0e93,_0x3c20cb,_0x574823,_0x46706f){return new BPromise(function(_0x2641a9,_0x2ba713){var _0x583247=_0x46706f||client;return _0x583247[_0xa748('0x1e')](_0x2a0e93,_0x574823)['then'](function(_0x2738e7){logger[_0xa748('0x1f')](_0xa748('0x20'),_0x3c20cb,'request\x20sent');logger[_0xa748('0x21')](_0xa748('0x22'),_0x3c20cb,_0xa748('0x23'),JSON[_0xa748('0x24')](_0x2738e7));if(_0x2738e7[_0xa748('0x25')]){if(_0x2738e7[_0xa748('0x25')][_0xa748('0x26')]===0x1f4){logger['error'](_0xa748('0x20'),_0x3c20cb,_0x2738e7[_0xa748('0x25')][_0xa748('0x27')]);return _0x2ba713(_0x2738e7[_0xa748('0x25')][_0xa748('0x27')]);}logger['error'](_0xa748('0x20'),_0x3c20cb,_0x2738e7[_0xa748('0x25')][_0xa748('0x27')]);return _0x2641a9(_0x2738e7[_0xa748('0x25')][_0xa748('0x27')]);}else{logger[_0xa748('0x1f')](_0xa748('0x20'),_0x3c20cb,_0xa748('0x23'));_0x2641a9(_0x2738e7[_0xa748('0x28')]['message']);}})[_0xa748('0x29')](function(_0x4bcd1d){logger[_0xa748('0x25')](_0xa748('0x20'),_0x3c20cb,_0x4bcd1d);_0x2ba713(_0x4bcd1d);});});}function respondWithStatusCode(_0x358bc4,_0x4e8835){_0x4e8835=_0x4e8835||0xcc;return function(_0x70720b){if(_0x70720b){return _0x358bc4['sendStatus'](_0x4e8835);}return _0x358bc4[_0xa748('0x2a')](_0x4e8835)['end']();};}function respondWithResult(_0x10ae2b,_0x1b9f2f){_0x1b9f2f=_0x1b9f2f||0xc8;return function(_0x3f283e){if(_0x3f283e){return _0x10ae2b[_0xa748('0x2a')](_0x1b9f2f)[_0xa748('0x2b')](_0x3f283e);}};}function respondWithFilteredResult(_0x43ccb1,_0x3483a6){return function(_0x391c8a){if(_0x391c8a){var _0x3a38f4=typeof _0x3483a6[_0xa748('0x2c')]===_0xa748('0x2d')&&typeof _0x3483a6['limit']===_0xa748('0x2d');var _0x432d5b=_0x391c8a[_0xa748('0x2e')];var _0x4e4449=_0x3a38f4?0x0:_0x3483a6[_0xa748('0x2c')];var _0x2c8259=_0x3a38f4?_0x391c8a[_0xa748('0x2e')]:_0x3483a6[_0xa748('0x2c')]+_0x3483a6[_0xa748('0x2f')];var _0x2b2152;if(_0x2c8259>=_0x432d5b){_0x2c8259=_0x432d5b;_0x2b2152=0xc8;}else{_0x2b2152=0xce;}_0x43ccb1[_0xa748('0x2a')](_0x2b2152);return _0x43ccb1[_0xa748('0x30')]('Content-Range',_0x4e4449+'-'+_0x2c8259+'/'+_0x432d5b)[_0xa748('0x2b')](_0x391c8a);}return null;};}function patchUpdates(_0x56f58c){return function(_0x5ba24f){try{jsonpatch[_0xa748('0x31')](_0x5ba24f,_0x56f58c,!![]);}catch(_0x5db37c){return BPromise[_0xa748('0x32')](_0x5db37c);}return _0x5ba24f[_0xa748('0x33')]();};}function saveUpdates(_0x485976,_0x4997a9){return function(_0x4c601f){if(_0x4c601f){return _0x4c601f[_0xa748('0x34')](_0x485976)[_0xa748('0x35')](function(_0x4ddd8f){return _0x4ddd8f;});}return null;};}function removeEntity(_0x3aceca,_0x52834d){return function(_0x398143){if(_0x398143){return _0x398143[_0xa748('0x36')]()[_0xa748('0x35')](function(){var _0x578b51=_0x398143['get']({'plain':!![]});var _0x459226=_0xa748('0x37');return db[_0xa748('0x38')]['destroy']({'where':{'type':_0x459226,'resourceId':_0x578b51['id']}})[_0xa748('0x35')](function(){return _0x398143;});})[_0xa748('0x35')](function(){_0x3aceca['status'](0xcc)[_0xa748('0x39')]();});}};}function handleEntityNotFound(_0x4c8d86,_0x1f04a0){return function(_0x149e72){if(!_0x149e72){_0x4c8d86[_0xa748('0x3a')](0x194);}return _0x149e72;};}function handleError(_0x4d15d1,_0x56624f){_0x56624f=_0x56624f||0x1f4;return function(_0x4c1912){logger[_0xa748('0x25')](_0x4c1912[_0xa748('0x3b')]);if(_0x4c1912[_0xa748('0x3c')]){delete _0x4c1912[_0xa748('0x3c')];}_0x4d15d1['status'](_0x56624f)[_0xa748('0x3d')](_0x4c1912);};}exports['index']=function(_0x147477,_0x29acf0){var _0x1d1661={'include':[{'model':db[_0xa748('0x3e')],'as':'mandatoryDispositionPause'}]},_0x3f5455={},_0x42337e={'count':0x0,'rows':[]};var _0x481a73=_[_0xa748('0x3f')](db[_0xa748('0x40')]['rawAttributes'],function(_0x1ba19d){return{'name':_0x1ba19d['fieldName'],'type':_0x1ba19d[_0xa748('0x41')]['key']};});_0x3f5455[_0xa748('0x42')]=_[_0xa748('0x3f')](_0x481a73,'name');_0x3f5455[_0xa748('0x43')]=_[_0xa748('0x44')](_0x147477[_0xa748('0x43')]);_0x3f5455[_0xa748('0x45')]=_[_0xa748('0x46')](_0x3f5455[_0xa748('0x42')],_0x3f5455[_0xa748('0x43')]);_0x1d1661[_0xa748('0x47')]=_[_0xa748('0x46')](_0x3f5455[_0xa748('0x42')],qs[_0xa748('0x48')](_0x147477[_0xa748('0x43')][_0xa748('0x48')]));_0x1d1661[_0xa748('0x47')]=_0x1d1661[_0xa748('0x47')][_0xa748('0x49')]?_0x1d1661[_0xa748('0x47')]:_0x3f5455[_0xa748('0x42')];if(!_0x147477[_0xa748('0x43')][_0xa748('0x4a')](_0xa748('0x4b'))){_0x1d1661[_0xa748('0x2f')]=qs[_0xa748('0x2f')](_0x147477['query'][_0xa748('0x2f')]);_0x1d1661[_0xa748('0x2c')]=qs[_0xa748('0x2c')](_0x147477[_0xa748('0x43')][_0xa748('0x2c')]);}_0x1d1661[_0xa748('0x4c')]=qs['sort'](_0x147477[_0xa748('0x43')]['sort']);_0x1d1661[_0xa748('0x4d')]=qs[_0xa748('0x45')](_['pick'](_0x147477[_0xa748('0x43')],_0x3f5455['filters']),_0x481a73);if(_0x147477[_0xa748('0x43')]['filter']){_0x1d1661[_0xa748('0x4d')]=_[_0xa748('0x4e')](_0x1d1661[_0xa748('0x4d')],{'$or':_['map'](_0x481a73,function(_0x96c72d){if(_0x96c72d['type']!=='VIRTUAL'){var _0x2296f3={};_0x2296f3[_0x96c72d[_0xa748('0x3c')]]={'$like':'%'+_0x147477['query'][_0xa748('0x4f')]+'%'};return _0x2296f3;}})});}_0x1d1661=_[_0xa748('0x4e')]({},_0x1d1661,_0x147477[_0xa748('0x50')]);var _0x2e573d={'where':_0x1d1661[_0xa748('0x4d')]};return db[_0xa748('0x40')][_0xa748('0x2e')](_0x2e573d)[_0xa748('0x35')](function(_0x35c4bb){_0x42337e[_0xa748('0x2e')]=_0x35c4bb;if(_0x147477[_0xa748('0x43')][_0xa748('0x51')]){_0x1d1661['include']=[{'all':!![]}];}return db[_0xa748('0x40')]['findAll'](_0x1d1661);})['then'](function(_0x3ff86b){_0x42337e[_0xa748('0x52')]=_0x3ff86b;return _0x42337e;})[_0xa748('0x35')](respondWithFilteredResult(_0x29acf0,_0x1d1661))[_0xa748('0x29')](handleError(_0x29acf0,null));};exports['show']=function(_0x2f2c14,_0x366af3){var _0x104377={'raw':![],'where':{'id':_0x2f2c14['params']['id']},'include':[{'model':db['Pause'],'as':_0xa748('0x53')}]},_0x325e13={};_0x325e13['model']=_[_0xa748('0x44')](db[_0xa748('0x40')][_0xa748('0x54')]);_0x325e13[_0xa748('0x43')]=_[_0xa748('0x44')](_0x2f2c14[_0xa748('0x43')]);_0x325e13[_0xa748('0x45')]=_[_0xa748('0x46')](_0x325e13[_0xa748('0x42')],_0x325e13['query']);_0x104377[_0xa748('0x47')]=_[_0xa748('0x46')](_0x325e13[_0xa748('0x42')],qs[_0xa748('0x48')](_0x2f2c14[_0xa748('0x43')]['fields']));_0x104377['attributes']=_0x104377[_0xa748('0x47')]['length']?_0x104377[_0xa748('0x47')]:_0x325e13[_0xa748('0x42')];if(_0x2f2c14[_0xa748('0x43')]['includeAll']){_0x104377[_0xa748('0x55')]=[{'all':!![]}];}_0x104377=_[_0xa748('0x4e')]({},_0x104377,_0x2f2c14[_0xa748('0x50')]);return db[_0xa748('0x40')][_0xa748('0x56')](_0x104377)[_0xa748('0x35')](handleEntityNotFound(_0x366af3,null))[_0xa748('0x35')](respondWithResult(_0x366af3,null))[_0xa748('0x29')](handleError(_0x366af3,null));};exports[_0xa748('0x57')]=function(_0x387b7c,_0xbcaeb7){return db['ChatWebsite']['create'](_0x387b7c[_0xa748('0x58')],{})[_0xa748('0x35')](function(_0x4aa1b7){var _0x1cd825=_0x387b7c[_0xa748('0x59')]['get']({'plain':!![]});if(!_0x1cd825)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x1cd825[_0xa748('0x5a')]==='user'){var _0x187ea8=_0x4aa1b7[_0xa748('0x5b')]({'plain':!![]});var _0xf78624=_0xa748('0x37');return db[_0xa748('0x5c')][_0xa748('0x56')]({'where':{'name':_0xf78624,'userProfileId':_0x1cd825['userProfileId']},'raw':!![]})[_0xa748('0x35')](function(_0xbfe63e){if(_0xbfe63e&&_0xbfe63e['autoAssociation']===0x0){return db[_0xa748('0x38')]['create']({'name':_0x187ea8[_0xa748('0x3c')],'resourceId':_0x187ea8['id'],'type':_0xbfe63e[_0xa748('0x3c')],'sectionId':_0xbfe63e['id']},{})[_0xa748('0x35')](function(){return _0x4aa1b7;});}else{return _0x4aa1b7;}})[_0xa748('0x29')](function(_0x3ffd03){logger['error'](_0xa748('0x5d'),_0x3ffd03);throw _0x3ffd03;});}return _0x4aa1b7;})[_0xa748('0x35')](respondWithResult(_0xbcaeb7,0xc9))[_0xa748('0x29')](handleError(_0xbcaeb7,null));};exports[_0xa748('0x34')]=function(_0x3c62f4,_0x444339){if(_0x3c62f4['body']['id']){delete _0x3c62f4[_0xa748('0x58')]['id'];}return db[_0xa748('0x40')][_0xa748('0x56')]({'where':{'id':_0x3c62f4[_0xa748('0x5e')]['id']},'include':[{'model':db[_0xa748('0x3e')],'as':_0xa748('0x53')}]})[_0xa748('0x35')](handleEntityNotFound(_0x444339,null))['then'](saveUpdates(_0x3c62f4[_0xa748('0x58')],null))['then'](respondWithResult(_0x444339,null))[_0xa748('0x29')](handleError(_0x444339,null));};exports[_0xa748('0x36')]=function(_0xeb2f70,_0x4292c4){return db[_0xa748('0x40')][_0xa748('0x56')]({'where':{'id':_0xeb2f70[_0xa748('0x5e')]['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x4292c4,null))[_0xa748('0x35')](removeEntity(_0x4292c4,null))['catch'](handleError(_0x4292c4,null));};exports[_0xa748('0x5f')]=function(_0x4aad58,_0x10dbd8){return db['ChatWebsite'][_0xa748('0x5f')]()[_0xa748('0x35')](respondWithResult(_0x10dbd8,null))[_0xa748('0x29')](handleError(_0x10dbd8,null));};exports[_0xa748('0x60')]=function(_0x182f74,_0x17a1f5,_0x4c6a74){if(_0x182f74[_0xa748('0x58')]['id']){delete _0x182f74[_0xa748('0x58')]['id'];}return db[_0xa748('0x40')][_0xa748('0x56')]({'where':{'id':_0x182f74['params']['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x17a1f5,null))[_0xa748('0x35')](function(_0x27b47e){if(_0x27b47e){_0x182f74[_0xa748('0x58')]['ChatWebsiteId']=_0x27b47e['id'];return db[_0xa748('0x61')]['create'](_0x182f74[_0xa748('0x58')]);}})['then'](respondWithResult(_0x17a1f5,null))[_0xa748('0x29')](handleError(_0x17a1f5,null));};exports['getDispositions']=function(_0x8ec969,_0x5d1263,_0x47a7fd){var _0x1978cd={'raw':![],'where':{}};var _0x1f2d75={};var _0x3cf70f={'count':0x0,'rows':[]};return db['ChatWebsite']['findOne']({'where':{'id':_0x8ec969[_0xa748('0x5e')]['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x5d1263,null))[_0xa748('0x35')](function(_0x264f85){if(_0x264f85){_0x1f2d75[_0xa748('0x42')]=_[_0xa748('0x44')](db[_0xa748('0x61')][_0xa748('0x54')]);_0x1f2d75['query']=_[_0xa748('0x44')](_0x8ec969[_0xa748('0x43')]);_0x1f2d75['filters']=_[_0xa748('0x46')](_0x1f2d75[_0xa748('0x42')],_0x1f2d75['query']);_0x1978cd[_0xa748('0x47')]=_['intersection'](_0x1f2d75['model'],qs[_0xa748('0x48')](_0x8ec969[_0xa748('0x43')][_0xa748('0x48')]));_0x1978cd[_0xa748('0x47')]=_0x1978cd[_0xa748('0x47')]['length']?_0x1978cd['attributes']:_0x1f2d75[_0xa748('0x42')];if(!_0x8ec969[_0xa748('0x43')][_0xa748('0x4a')](_0xa748('0x4b'))){_0x1978cd[_0xa748('0x2f')]=qs[_0xa748('0x2f')](_0x8ec969[_0xa748('0x43')][_0xa748('0x2f')]);_0x1978cd[_0xa748('0x2c')]=qs[_0xa748('0x2c')](_0x8ec969[_0xa748('0x43')][_0xa748('0x2c')]);}_0x1978cd[_0xa748('0x4c')]=qs[_0xa748('0x62')](_0x8ec969[_0xa748('0x43')]['sort']);_0x1978cd[_0xa748('0x4d')]=qs['filters'](_['pick'](_0x8ec969[_0xa748('0x43')],_0x1f2d75[_0xa748('0x45')]));_0x1978cd[_0xa748('0x4d')][_0xa748('0x63')]=_0x264f85['id'];if(_0x8ec969[_0xa748('0x43')][_0xa748('0x4f')]){_0x1978cd[_0xa748('0x4d')]=_['merge'](_0x1978cd['where'],{'$or':_[_0xa748('0x3f')](_0x1978cd[_0xa748('0x47')],function(_0x13af75){var _0x3c78c5={};_0x3c78c5[_0x13af75]={'$like':'%'+_0x8ec969[_0xa748('0x43')][_0xa748('0x4f')]+'%'};return _0x3c78c5;})});}_0x1978cd=_['merge']({},_0x1978cd,_0x8ec969[_0xa748('0x50')]);return db['Disposition']['count']({'where':_0x1978cd[_0xa748('0x4d')]})[_0xa748('0x35')](function(_0x510ff0){_0x3cf70f[_0xa748('0x2e')]=_0x510ff0;if(_0x8ec969[_0xa748('0x43')][_0xa748('0x51')]){_0x1978cd[_0xa748('0x55')]=[{'all':!![]}];}return db[_0xa748('0x61')][_0xa748('0x64')](_0x1978cd);})[_0xa748('0x35')](function(_0x18bc8b){_0x3cf70f[_0xa748('0x52')]=_0x18bc8b;return _0x3cf70f;});}})[_0xa748('0x35')](respondWithFilteredResult(_0x5d1263,_0x1978cd))[_0xa748('0x29')](handleError(_0x5d1263,null));};exports['removeDispositions']=function(_0x321f1f,_0x566916,_0x33c915){return db[_0xa748('0x40')]['find']({'where':{'id':_0x321f1f[_0xa748('0x5e')]['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x566916,null))[_0xa748('0x35')](function(_0x43421f){if(_0x43421f){return _0x43421f[_0xa748('0x65')](_0x321f1f['query'][_0xa748('0x66')]);}})[_0xa748('0x35')](respondWithStatusCode(_0x566916,null))[_0xa748('0x29')](handleError(_0x566916,null));};exports[_0xa748('0x67')]=function(_0x5bc8fc,_0x17823f,_0x51d393){if(_0x5bc8fc[_0xa748('0x58')]['id']){delete _0x5bc8fc[_0xa748('0x58')]['id'];}return db[_0xa748('0x40')]['find']({'where':{'id':_0x5bc8fc[_0xa748('0x5e')]['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x17823f,null))[_0xa748('0x35')](function(_0x33f915){if(_0x33f915){_0x5bc8fc[_0xa748('0x58')][_0xa748('0x63')]=_0x33f915['id'];return db[_0xa748('0x68')][_0xa748('0x57')](_0x5bc8fc[_0xa748('0x58')]);}})['then'](respondWithResult(_0x17823f,null))['catch'](handleError(_0x17823f,null));};exports[_0xa748('0x69')]=function(_0x2e2ba5,_0x2f3870,_0x5b9d89){var _0xe1bb29={'raw':![],'where':{}};var _0x5af594={};var _0x422cf7={'count':0x0,'rows':[]};return db[_0xa748('0x40')][_0xa748('0x6a')]({'where':{'id':_0x2e2ba5[_0xa748('0x5e')]['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x2f3870,null))[_0xa748('0x35')](function(_0x467fa8){if(_0x467fa8){_0x5af594[_0xa748('0x42')]=_[_0xa748('0x44')](db[_0xa748('0x68')]['rawAttributes']);_0x5af594[_0xa748('0x43')]=_[_0xa748('0x44')](_0x2e2ba5['query']);_0x5af594[_0xa748('0x45')]=_[_0xa748('0x46')](_0x5af594[_0xa748('0x42')],_0x5af594['query']);_0xe1bb29[_0xa748('0x47')]=_[_0xa748('0x46')](_0x5af594[_0xa748('0x42')],qs[_0xa748('0x48')](_0x2e2ba5[_0xa748('0x43')]['fields']));_0xe1bb29[_0xa748('0x47')]=_0xe1bb29['attributes'][_0xa748('0x49')]?_0xe1bb29[_0xa748('0x47')]:_0x5af594['model'];if(!_0x2e2ba5[_0xa748('0x43')][_0xa748('0x4a')](_0xa748('0x4b'))){_0xe1bb29[_0xa748('0x2f')]=qs[_0xa748('0x2f')](_0x2e2ba5[_0xa748('0x43')]['limit']);_0xe1bb29[_0xa748('0x2c')]=qs[_0xa748('0x2c')](_0x2e2ba5[_0xa748('0x43')]['offset']);}_0xe1bb29[_0xa748('0x4c')]=qs[_0xa748('0x62')](_0x2e2ba5['query'][_0xa748('0x62')]);_0xe1bb29[_0xa748('0x4d')]=qs['filters'](_[_0xa748('0x6b')](_0x2e2ba5['query'],_0x5af594['filters']));_0xe1bb29[_0xa748('0x4d')][_0xa748('0x63')]=_0x467fa8['id'];if(_0x2e2ba5[_0xa748('0x43')][_0xa748('0x4f')]){_0xe1bb29[_0xa748('0x4d')]=_[_0xa748('0x4e')](_0xe1bb29[_0xa748('0x4d')],{'$or':_[_0xa748('0x3f')](_0xe1bb29['attributes'],function(_0x4066b7){var _0x3b7c4a={};_0x3b7c4a[_0x4066b7]={'$like':'%'+_0x2e2ba5['query'][_0xa748('0x4f')]+'%'};return _0x3b7c4a;})});}_0xe1bb29=_['merge']({},_0xe1bb29,_0x2e2ba5[_0xa748('0x50')]);return db[_0xa748('0x68')][_0xa748('0x2e')]({'where':_0xe1bb29[_0xa748('0x4d')]})[_0xa748('0x35')](function(_0x17d96f){_0x422cf7[_0xa748('0x2e')]=_0x17d96f;if(_0x2e2ba5[_0xa748('0x43')][_0xa748('0x51')]){_0xe1bb29[_0xa748('0x55')]=[{'all':!![]}];}return db[_0xa748('0x68')][_0xa748('0x64')](_0xe1bb29);})['then'](function(_0x50677c){_0x422cf7[_0xa748('0x52')]=_0x50677c;return _0x422cf7;});}})[_0xa748('0x35')](respondWithFilteredResult(_0x2f3870,_0xe1bb29))['catch'](handleError(_0x2f3870,null));};exports[_0xa748('0x6c')]=function(_0x2ee2d6,_0x5bb741,_0x39e2b1){return db[_0xa748('0x40')][_0xa748('0x56')]({'where':{'id':_0x2ee2d6[_0xa748('0x5e')]['id']}})['then'](handleEntityNotFound(_0x5bb741,null))[_0xa748('0x35')](function(_0x29e3d2){if(_0x29e3d2){return _0x29e3d2['removeAnswers'](_0x2ee2d6[_0xa748('0x43')][_0xa748('0x66')]);}})[_0xa748('0x35')](respondWithStatusCode(_0x5bb741,null))[_0xa748('0x29')](handleError(_0x5bb741,null));};exports[_0xa748('0x6d')]=function(_0x587915,_0xd623,_0x1fcdb5){_0x587915['body']['sitepic']=_0x587915[_0xa748('0x6e')][_0xa748('0x6f')];return db[_0xa748('0x40')][_0xa748('0x56')]({'where':{'id':_0x587915[_0xa748('0x5e')]['id']}})['then'](handleEntityNotFound(_0xd623,null))['then'](saveUpdates(_0x587915['body'],null))['then'](respondWithResult(_0xd623,null))[_0xa748('0x29')](handleError(_0xd623,null));};exports['addAvatar']=function(_0x169b45,_0x34def1,_0x555bdc){_0x169b45['body'][_0xa748('0x70')]=_0x169b45[_0xa748('0x6e')][_0xa748('0x6f')];return db['ChatWebsite'][_0xa748('0x56')]({'where':{'id':_0x169b45[_0xa748('0x5e')]['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x34def1,null))['then'](saveUpdates(_0x169b45[_0xa748('0x58')],null))[_0xa748('0x35')](respondWithResult(_0x34def1,null))[_0xa748('0x29')](handleError(_0x34def1,null));};exports['addCustomerAvatar']=function(_0x2933a9,_0x1fdf5e,_0x16373b){_0x2933a9['body'][_0xa748('0x71')]=_0x2933a9[_0xa748('0x6e')][_0xa748('0x6f')];return db[_0xa748('0x40')][_0xa748('0x56')]({'where':{'id':_0x2933a9['params']['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x1fdf5e,null))[_0xa748('0x35')](saveUpdates(_0x2933a9[_0xa748('0x58')],null))[_0xa748('0x35')](respondWithResult(_0x1fdf5e,null))[_0xa748('0x29')](handleError(_0x1fdf5e,null));};exports[_0xa748('0x72')]=function(_0x3db3f2,_0x38a726,_0x2f0a03){_0x3db3f2[_0xa748('0x58')][_0xa748('0x73')]=_0x3db3f2[_0xa748('0x6e')][_0xa748('0x6f')];return db[_0xa748('0x40')][_0xa748('0x56')]({'where':{'id':_0x3db3f2['params']['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x38a726,null))[_0xa748('0x35')](saveUpdates(_0x3db3f2[_0xa748('0x58')],null))[_0xa748('0x35')](respondWithResult(_0x38a726,null))['catch'](handleError(_0x38a726,null));};exports[_0xa748('0x74')]=function(_0x24be87,_0x302511,_0x4fc6aa){var _0x2bdece=path[_0xa748('0x75')](config[_0xa748('0x76')],'server/files/images/logos/default_logo.svg');var _0x59250c={'where':{'id':_0x24be87[_0xa748('0x5e')]['id']},'attributes':['id',_0xa748('0x77')],'raw':!![]};var _0x1b1b9f=![];return require(_0xa748('0x13'))['getLicense']()['then'](function(_0x26f388){if(_0x26f388){_0x1b1b9f=_0x26f388[_0xa748('0x78')];}})[_0xa748('0x35')](function(){return db[_0xa748('0x40')][_0xa748('0x56')](_0x59250c);})['then'](handleEntityNotFound(_0x302511,null))['then'](function(_0x47df5d){if(_0x47df5d){if(!_[_0xa748('0x79')](_0x47df5d[_0xa748('0x77')])){if(fs[_0xa748('0x7a')](path[_0xa748('0x75')](config[_0xa748('0x76')],_0xa748('0x7b'),_0x47df5d[_0xa748('0x77')]))&&_0x1b1b9f){_0x2bdece=path[_0xa748('0x75')](config[_0xa748('0x76')],_0xa748('0x7b'),_0x47df5d['sitepic']);}}return _0x302511[_0xa748('0x7c')](_0x2bdece);}})[_0xa748('0x29')](handleError(_0x302511,null));};exports[_0xa748('0x7d')]=function(_0x5655cd,_0x28bed0,_0xaff46e){var _0x1021c7=path['join'](config[_0xa748('0x76')],_0xa748('0x7e'));var _0x1ba355={'where':{'id':_0x5655cd['params']['id']},'attributes':['id',_0xa748('0x70')],'raw':!![]};return db['ChatWebsite'][_0xa748('0x56')](_0x1ba355)['then'](handleEntityNotFound(_0x28bed0,null))['then'](function(_0x29bdaa){if(_0x29bdaa){if(!_[_0xa748('0x79')](_0x29bdaa['agentAvatar'])){if(fs['existsSync'](path[_0xa748('0x75')](config['root'],'server/files/images/avatars/',_0x29bdaa['agentAvatar']))){_0x1021c7=path['join'](config[_0xa748('0x76')],_0xa748('0x7f'),_0x29bdaa['agentAvatar']);}}return _0x28bed0[_0xa748('0x7c')](_0x1021c7);}})['catch'](handleError(_0x28bed0,null));};exports[_0xa748('0x80')]=function(_0x24a326,_0x2c4c87,_0x3e416b){var _0x37d468=path[_0xa748('0x75')](config['root'],_0xa748('0x81'));var _0x3e0cb3={'where':{'id':_0x24a326['params']['id']},'attributes':['id',_0xa748('0x71'),_0xa748('0x82')],'raw':!![]};return db[_0xa748('0x40')][_0xa748('0x56')](_0x3e0cb3)[_0xa748('0x35')](handleEntityNotFound(_0x2c4c87,null))[_0xa748('0x35')](function(_0x2cf55b){if(_0x2cf55b){if(!_[_0xa748('0x79')](_0x2cf55b[_0xa748('0x71')])){if(fs[_0xa748('0x7a')](path['join'](config['root'],_0xa748('0x7f'),_0x2cf55b[_0xa748('0x71')]))&&_0x2cf55b[_0xa748('0x82')]){_0x37d468=path[_0xa748('0x75')](config[_0xa748('0x76')],'server/files/images/avatars/',_0x2cf55b[_0xa748('0x71')]);}}return _0x2c4c87[_0xa748('0x7c')](_0x37d468);}})[_0xa748('0x29')](handleError(_0x2c4c87,null));};exports['getSystemAvatar']=function(_0x4849ce,_0x38d464,_0x1ef1dd){var _0x56b3e7=path[_0xa748('0x75')](config['root'],'server/files/images/avatars/system_avatar.png');var _0x205032={'where':{'id':_0x4849ce[_0xa748('0x5e')]['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db['ChatWebsite'][_0xa748('0x56')](_0x205032)[_0xa748('0x35')](handleEntityNotFound(_0x38d464,null))['then'](function(_0x2ded93){if(_0x2ded93){if(!_[_0xa748('0x79')](_0x2ded93['systemAvatar'])){if(fs[_0xa748('0x7a')](path[_0xa748('0x75')](config[_0xa748('0x76')],'server/files/images/avatars/',_0x2ded93[_0xa748('0x73')]))){_0x56b3e7=path[_0xa748('0x75')](config[_0xa748('0x76')],_0xa748('0x7f'),_0x2ded93[_0xa748('0x73')]);}}return _0x38d464['download'](_0x56b3e7);}})[_0xa748('0x29')](handleError(_0x38d464,null));};exports[_0xa748('0x83')]=function(_0x5d2ba9,_0x5f20b0,_0x5600f8){var _0x53c072=require('user-agent-parser');var _0x3e649a=new _0x53c072();var _0x2d6074=_0x3e649a['setUA'](_0x5d2ba9['headers'][_0xa748('0x84')])[_0xa748('0x85')]();var _0x44fa7b={'body':_0x5d2ba9['body'],'channel':_0xa748('0x86')};var _0x5b3f93=[];var _0x15c7c4=[];var _0x2d7ee5={};var _0x10bf57=![];return db[_0xa748('0x87')][_0xa748('0x5f')]()[_0xa748('0x35')](function(_0x599121){if(!_0x599121){throw new db[(_0xa748('0x88'))][(_0xa748('0x89'))](_0xa748('0x8a'));}_0x5b3f93=_[_0xa748('0x8b')](_[_0xa748('0x44')](_0x599121),[_0xa748('0x8c'),'updatedAt']);_0x15c7c4=_[_0xa748('0x8b')](_[_0xa748('0x44')](_0x599121),[_0xa748('0x8c'),_0xa748('0x8d'),_0xa748('0x8e'),_0xa748('0x8f')]);if(_0x5d2ba9[_0xa748('0x58')]['id']){delete _0x5d2ba9[_0xa748('0x58')]['id'];}if(_[_0xa748('0x79')](_0x5d2ba9[_0xa748('0x58')][_0xa748('0x90')])){throw new db[(_0xa748('0x88'))]['ValidationError'](_0xa748('0x91'));}if(_['isNil'](_0x5d2ba9[_0xa748('0x58')]['body'])||_0x5d2ba9[_0xa748('0x58')][_0xa748('0x58')]===''){throw new db[(_0xa748('0x88'))][(_0xa748('0x89'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0xa748('0x79')](_0x5d2ba9[_0xa748('0x58')]['mapKey'])){throw new db['Sequelize'][(_0xa748('0x89'))](_0xa748('0x92')+_0x15c7c4);}if(!_[_0xa748('0x93')](_0x15c7c4,_0x5d2ba9[_0xa748('0x58')][_0xa748('0x94')])){throw new db[(_0xa748('0x88'))][(_0xa748('0x89'))](_0xa748('0x95')+_0x15c7c4);}_0x2d7ee5[_0x5d2ba9[_0xa748('0x58')]['mapKey']]=_0x5d2ba9[_0xa748('0x58')]['from'];})[_0xa748('0x35')](function(){return db[_0xa748('0x40')][_0xa748('0x56')]({'where':{'id':_0x5d2ba9[_0xa748('0x5e')]['id']},'include':[{'model':db['CmList'],'as':_0xa748('0x96'),'include':[{'model':db[_0xa748('0x87')],'as':_0xa748('0x97'),'where':_0x2d7ee5,'limit':0x1,'order':[[_0xa748('0x8d'),'DESC']]}]},{'model':db[_0xa748('0x98')],'as':_0xa748('0x99')}]});})['then'](handleEntityNotFound(_0x5f20b0,null))[_0xa748('0x35')](function(_0x1e40d5){if(_0x1e40d5&&_0x1e40d5[_0xa748('0x96')]){_0x44fa7b[_0xa748('0x9a')]=_0x1e40d5;_0x44fa7b[_0xa748('0x9b')]=_0x1e40d5[_0xa748('0x99')];_0x44fa7b[_0xa748('0x9c')]=_0x1e40d5[_0xa748('0x96')];_0x44fa7b[_0xa748('0x9b')]=_[_0xa748('0x9d')](_0x44fa7b['applications'],[_0xa748('0x9e')],[_0xa748('0x9f')]);if(_0x44fa7b[_0xa748('0x9a')][_0xa748('0x99')]){delete _0x44fa7b[_0xa748('0x9a')]['Applications'];}if(_0x44fa7b[_0xa748('0x9a')][_0xa748('0x96')]&&_0x44fa7b['account'][_0xa748('0x96')][_0xa748('0x97')][_0xa748('0x49')]){return _0x44fa7b[_0xa748('0x9a')][_0xa748('0x96')][_0xa748('0x97')][0x0];}var _0x3a33d0=_[_0xa748('0x15')](_0x5d2ba9['body'],{'firstName':_0x5d2ba9[_0xa748('0x58')][_0xa748('0x90')],'ListId':_0x1e40d5['ListId']});_0x3a33d0[_0x5d2ba9[_0xa748('0x58')][_0xa748('0x94')]]=_0x5d2ba9['body']['from'];return db[_0xa748('0x87')][_0xa748('0x57')](_0x3a33d0,{'fields':_0x5b3f93,'raw':!![]});}})[_0xa748('0x35')](handleEntityNotFound(_0x5f20b0,null))[_0xa748('0x35')](function(_0x2610f0){_0x44fa7b[_0xa748('0xa0')]=_0x2610f0;var _0x1f8fe9=_0x5d2ba9[_0xa748('0x58')][_0xa748('0xa1')];if(_0x5d2ba9[_0xa748('0xa2')][_0xa748('0xa3')]){_0x1f8fe9=_0x5d2ba9[_0xa748('0xa2')][_0xa748('0xa3')];}else if(_0x5d2ba9[_0xa748('0xa2')]['x-forwarded-for']){_0x1f8fe9=_[_0xa748('0xa4')](_0x5d2ba9[_0xa748('0xa2')][_0xa748('0xa5')]['split'](','));}if(_0x2610f0){var _0x403045={'ContactId':_0x2610f0['id'],'ChatWebsiteId':_0x5d2ba9[_0xa748('0x5e')]['id'],'from':(_0x2610f0[_0xa748('0xa6')]||'')+'\x20'+(_0x2610f0[_0xa748('0xa7')]||''),'customerIp':_0x1f8fe9,'customerPort':_0x5d2ba9[_0xa748('0xa2')][_0xa748('0xa8')]?_0x5d2ba9[_0xa748('0xa2')][_0xa748('0xa8')]:null,'referer':_0x5d2ba9['body']['referer'],'browserName':_0x2d6074[_0xa748('0xa9')][_0xa748('0x3c')]&&_0x2d6074[_0xa748('0xa9')][_0xa748('0xaa')]?util['format'](_0xa748('0xab'),_0x2d6074[_0xa748('0xa9')]['name'],_0x2d6074[_0xa748('0xa9')][_0xa748('0xaa')]):_0xa748('0xac'),'browserVersion':_0x2d6074[_0xa748('0xa9')][_0xa748('0xaa')]||_0xa748('0xac'),'osName':util[_0xa748('0xad')]('%s\x20%s',_0x2d6074['os'][_0xa748('0x3c')],_0x2d6074['os'][_0xa748('0xaa')]),'osVersion':_0x2d6074['os'][_0xa748('0xaa')],'deviceModel':_0x2d6074[_0xa748('0xae')]['model']&&_0x2d6074[_0xa748('0xae')][_0xa748('0xaf')]?util['format'](_0xa748('0xb0'),_0x2d6074[_0xa748('0xae')]['model'],_0x2d6074[_0xa748('0xae')][_0xa748('0xaf')],_0x2d6074[_0xa748('0xae')][_0xa748('0x41')]):null,'deviceVendor':_0x2d6074['device']['vendor'],'deviceType':_0x2d6074[_0xa748('0xae')]['type'],'formData':JSON[_0xa748('0x24')](_0x5d2ba9[_0xa748('0x58')])};var _0x3b1dc4={'ChatWebsiteId':_0x5d2ba9[_0xa748('0x5e')]['id'],'closed':![]};if(_0x5d2ba9[_0xa748('0x58')][_0xa748('0xb1')]){_0x3b1dc4[_0xa748('0xb1')]=_0x5d2ba9[_0xa748('0x58')][_0xa748('0xb1')];return db[_0xa748('0xb2')][_0xa748('0x56')]({'where':_0x3b1dc4})[_0xa748('0x35')](function(_0x19c79e){if(_0x19c79e){return[_0x19c79e,![]];}_0x403045['threadId']=_0x5d2ba9[_0xa748('0x58')][_0xa748('0xb1')];_0x403045[_0xa748('0xb3')]=_0x5d2ba9[_0xa748('0x58')][_0xa748('0xb3')];return db[_0xa748('0xb2')][_0xa748('0x57')](_0x403045)[_0xa748('0x35')](function(_0xc40e50){return[_0xc40e50,!![]];});});}_0x3b1dc4['ContactId']=_0x2610f0['id'];if(_0x5d2ba9[_0xa748('0x58')][_0xa748('0xb4')]&&_0x5d2ba9[_0xa748('0x58')][_0xa748('0xb4')]['id']){_0x3b1dc4['id']=_0x5d2ba9[_0xa748('0x58')][_0xa748('0xb4')]['id'];return db['ChatInteraction'][_0xa748('0x56')]({'where':_0x3b1dc4})['then'](function(_0x87aa7d){if(_0x87aa7d){return[_0x87aa7d,![]];}return db['ChatInteraction'][_0xa748('0x57')](_0x403045)['then'](function(_0x342ecc){return[_0x342ecc,!![]];});});}return db[_0xa748('0xb2')][_0xa748('0x57')](_0x403045)[_0xa748('0x35')](function(_0x32f525){return[_0x32f525,!![]];});}})[_0xa748('0xb5')](function(_0x652b4b,_0xf929a1){if(_0x652b4b){_0x10bf57=_0xf929a1;if(!_0xf929a1){var _0x9032b1={'from':(_0x44fa7b[_0xa748('0xa0')]['firstName']||'')+'\x20'+(_0x44fa7b[_0xa748('0xa0')][_0xa748('0xa7')]||'')};if(_0x5d2ba9[_0xa748('0x58')][_0xa748('0xb1')]&&_0x5d2ba9['body'][_0xa748('0xb6')]&&_0x5d2ba9[_0xa748('0x58')][_0xa748('0xb1')]!=_0x5d2ba9[_0xa748('0x58')]['messageId']){_0x9032b1[_0xa748('0xb1')]=_0x5d2ba9[_0xa748('0x58')][_0xa748('0xb6')];}return _0x652b4b[_0xa748('0x34')](_0x9032b1);}else{return _0x652b4b;}}})[_0xa748('0x35')](function(_0x3b8665){_0x44fa7b['interaction']=_0x3b8665[_0xa748('0x5b')]({'plain':!![]});_0x44fa7b['interaction'][_0xa748('0xb7')]=_0x10bf57;if(_0x44fa7b[_0xa748('0xb4')]['created']){if(_0x44fa7b[_0xa748('0x9a')][_0xa748('0xb8')]){_0x44fa7b[_0xa748('0x9b')][_0xa748('0xb9')]({'id':0x0,'priority':_0x44fa7b[_0xa748('0x9b')][_0xa748('0x49')]+0x1,'app':'close','appdata':_0xa748('0xba'),'interval':'*,*,*,*'});}}return db[_0xa748('0xbb')]['create']({'body':_0x5d2ba9[_0xa748('0x58')]['body'],'ChatWebsiteId':_0x5d2ba9[_0xa748('0x5e')]['id'],'ChatInteractionId':_0x3b8665['id'],'direction':'in','ContactId':_0x44fa7b[_0xa748('0xa0')]['id'],'AttachmentId':_0x5d2ba9['body'][_0xa748('0xbc')]});})['then'](function(_0x51f98a){_0x44fa7b[_0xa748('0x27')]=_0x51f98a;if(_0x44fa7b[_0xa748('0xb4')][_0xa748('0xbd')]){return db[_0xa748('0xbe')][_0xa748('0x56')]({'attributes':['id','name'],'where':{'id':_0x44fa7b[_0xa748('0xb4')][_0xa748('0xbd')]}})[_0xa748('0x35')](function(_0x354279){if(_0x354279){_0x44fa7b[_0xa748('0x9b')][_0xa748('0xbf')]({'id':0x0,'priority':0x0,'app':_0xa748('0xc0'),'appdata':_0x354279[_0xa748('0x3c')]+','+(_0x44fa7b[_0xa748('0x9a')][_0xa748('0xc1')]||0xa),'interval':'*,*,*,*'});_0x44fa7b[_0xa748('0xc2')]=!![];}return respondWithRpcPromise('Start','startRouting',_0x44fa7b);});}return respondWithRpcPromise('Start',_0xa748('0xc3'),_0x44fa7b);})[_0xa748('0x35')](function(_0xed5a2c){respondWithRpcPromise('EventManager','EventManager',{'event':'notify','message':_0xed5a2c},client9002);return _0xed5a2c;})[_0xa748('0x35')](respondWithResult(_0x5f20b0,null))[_0xa748('0x29')](handleError(_0x5f20b0,null));};exports[_0xa748('0xc4')]=function(_0x547e63,_0x367de7,_0xc7a9c8){var _0x18c8ce,_0x102f0b,_0x465ad5;var _0x491cc7=[];var _0x57ce82=[];var _0x226a72={};var _0x22474b=_0x547e63[_0xa748('0xc5')]||[];var _0x5c0e39=[];var _0x4f01c3;return db[_0xa748('0x87')][_0xa748('0x5f')]()['then'](function(_0x163c29){if(!_0x163c29){throw new db[(_0xa748('0x88'))][(_0xa748('0x89'))](_0xa748('0x8a'));}_0x57ce82=_['difference'](_[_0xa748('0x44')](_0x163c29),[_0xa748('0x8c'),_0xa748('0x8d')]);_0x491cc7=_['difference'](_[_0xa748('0x44')](_0x163c29),[_0xa748('0x8c'),'updatedAt',_0xa748('0x8e'),'ListId']);if(_0x547e63[_0xa748('0x58')]['id']){delete _0x547e63['body']['id'];}if(_[_0xa748('0x79')](_0x547e63[_0xa748('0x58')][_0xa748('0x90')])){throw _0x367de7['status'](0x1f4)['send'](new db[(_0xa748('0x88'))][(_0xa748('0x89'))](_0xa748('0x91')));}if(_[_0xa748('0x79')](_0x547e63[_0xa748('0x58')][_0xa748('0x58')])||_0x547e63['body']['body']===''){throw _0x367de7['status'](0x1f4)[_0xa748('0x3d')](new db['Sequelize'][(_0xa748('0x89'))](_0xa748('0xc6')));}if(_[_0xa748('0x79')](_0x547e63[_0xa748('0x58')][_0xa748('0xc7')])){throw _0x367de7['status'](0x1f4)[_0xa748('0x3d')](new db['Sequelize'][(_0xa748('0x89'))](_0xa748('0xc8')+_0x491cc7));}if(!_[_0xa748('0x93')](_0x491cc7,_0x547e63[_0xa748('0x58')]['mapKeyOffline'])){throw _0x367de7[_0xa748('0x2a')](0x1f4)[_0xa748('0x3d')](new db[(_0xa748('0x88'))][(_0xa748('0x89'))](_0xa748('0xc9')+_0x491cc7));}_0x226a72[_0x547e63['body'][_0xa748('0xc7')]]=_0x547e63[_0xa748('0x58')][_0xa748('0x90')];})[_0xa748('0x35')](function(){return db[_0xa748('0x40')]['find']({'where':{'id':_0x547e63[_0xa748('0x5e')]['id']},'include':[{'model':db[_0xa748('0xca')],'as':_0xa748('0x96')},{'model':db[_0xa748('0xcb')],'as':_0xa748('0xcb')}]});})[_0xa748('0x35')](handleEntityNotFound(_0x367de7,null))[_0xa748('0x35')](function(_0x370a81){if(_0x370a81&&_0x370a81[_0xa748('0x96')]){_0x102f0b=_0x370a81;var _0x39fee8=_[_0xa748('0x15')](_0x547e63[_0xa748('0x58')],{'firstName':_0x547e63['body'][_0xa748('0x90')],'phone':_0x547e63[_0xa748('0x58')][_0xa748('0x90')],'ListId':_0x370a81['ListId']});_0x39fee8[_0x547e63['body']['mapKeyOffline']]=_0x547e63[_0xa748('0x58')][_0xa748('0x90')];return db[_0xa748('0x87')][_0xa748('0xcc')]({'where':_0x226a72,'defaults':_0x39fee8});}})[_0xa748('0xb5')](function(_0x26babb){if(_0x26babb){_0x465ad5=_0x26babb;var _0xd05d84=fs['readFileSync'](path[_0xa748('0x75')](config[_0xa748('0x76')],_0xa748('0xcd')),'utf8');var _0x12397c=ejs[_0xa748('0xce')](_0xd05d84,{'body':_['toPairs'](_0x547e63[_0xa748('0x58')][_0xa748('0x58')]),'bodyTitle':_0x102f0b[_0xa748('0xcf')]});return db['ChatOfflineMessage']['create']({'body':_0x12397c,'ContactId':_0x26babb['id'],'ChatWebsiteId':_0x102f0b['id']});}})[_0xa748('0x35')](function(_0x2ca9f0){_0x4f01c3=_0x2ca9f0;if(_0x22474b[_0xa748('0x49')]){var _0x42ce21=_0x22474b[_0xa748('0x3f')](function(_0x12c891){return{'name':_0x12c891[_0xa748('0xd0')],'basename':_0x12c891[_0xa748('0x6f')],'type':_0x12c891[_0xa748('0xd1')],'ChatOfflineMessageId':_0x2ca9f0['id']};});_0x5c0e39=_0x42ce21['map'](_0x39dc8b=>{var _0x43d16e={'filename':_0x39dc8b[_0xa748('0x3c')],'path':path[_0xa748('0x75')](config[_0xa748('0x76')],_0xa748('0xd2'),'files',_0xa748('0xd3'),_0xa748('0xd4'),_0x39dc8b[_0xa748('0xd5')])};return _0x43d16e;});if(!_0x102f0b[_0xa748('0xd6')]){return db[_0xa748('0xd7')]['transaction'](function(_0x58798f){return db[_0xa748('0xd8')]['bulkCreate'](_0x42ce21,{'transaction':_0x58798f});});}}})[_0xa748('0x35')](function(){if(_0x4f01c3){_0x18c8ce=_0x4f01c3;return db['MailAccount']['findOne']({'where':{'active':!![]},'include':[{'model':db[_0xa748('0xd9')],'as':'Smtp','raw':!![]}]});}})[_0xa748('0x35')](function(_0x58190c){if(_0x58190c&&_0x58190c[_0xa748('0xda')]&&_0x102f0b['forwardOffline']&&_0x102f0b[_0xa748('0xdb')]){var _0x5d2910={'tls':{'rejectUnauthorized':![]}};if(_0x58190c['Smtp'][_0xa748('0xdc')]){_0x5d2910[_0xa748('0xdc')]=_0x58190c[_0xa748('0xda')][_0xa748('0xdc')];}else{_0x5d2910[_0xa748('0xdd')]=_0x58190c[_0xa748('0xda')][_0xa748('0xdd')];_0x5d2910[_0xa748('0xde')]=_0x58190c[_0xa748('0xda')][_0xa748('0xde')];_0x5d2910[_0xa748('0xdf')]=_0x58190c[_0xa748('0xda')][_0xa748('0xdf')];}if(_0x58190c['Smtp'][_0xa748('0xe0')]){_0x5d2910['auth']={'user':_0x58190c[_0xa748('0xda')]['user'],'pass':_0x58190c[_0xa748('0xda')][_0xa748('0xe1')]};}return respondWithRpcPromise(_0xa748('0xe2'),_0xa748('0xe3'),{'account':_0x5d2910,'message':{'from':util[_0xa748('0xad')](_0xa748('0xe4'),_0x58190c[_0xa748('0x3c')],_0x58190c[_0xa748('0xe5')]||_0x58190c[_0xa748('0xda')][_0xa748('0x59')]),'to':_0x102f0b[_0xa748('0xdb')],'subject':_0x102f0b[_0xa748('0xe6')],'html':_0x18c8ce[_0xa748('0x58')],'attachments':_0x5c0e39}},client9003)['then'](function(){return _0x18c8ce;})[_0xa748('0x29')](function(_0xb7af01){console['error'](_0xb7af01);});}})[_0xa748('0x35')](function(){if(_0x102f0b&&_0x102f0b[_0xa748('0xd6')]&&_0x102f0b[_0xa748('0xe7')]){var _0x234c8=[];if(_0x22474b[_0xa748('0x49')]){_0x234c8=_0x22474b[_0xa748('0x3f')](function(_0x321ce9){return{'name':_0x321ce9[_0xa748('0xd0')],'basename':_0x321ce9['filename'],'type':_0x321ce9[_0xa748('0xd1')],'ChatOfflineMessageId':_0x4f01c3['id']};});}var _0x418478;if(!_[_0xa748('0x79')](_0x102f0b[_0xa748('0xe8')])){var _0x37bf0c=_[_0xa748('0x3f')](_0x547e63['body'],function(_0x574cf6){return _0x574cf6;});var _0x4dac67=_[_0xa748('0xe9')](_0x37bf0c)[0x0];var _0x5bb4d2=_[_0xa748('0xea')](_0x4dac67,function(_0x24447f){return _0x24447f;});_0x418478=_0x5bb4d2[0x1][_0x102f0b['subjectOffline']];}var _0x1acb39={'from':_0x465ad5[_0xa748('0xe5')],'firstName':_0x465ad5['firstName'],'lastName':_0x465ad5[_0xa748('0xa7')],'mapKey':_0xa748('0xe5'),'message':{'from':_0x465ad5['email'],'to':_0x102f0b['MailAccount'][_0xa748('0xe5')],'cc':'','subject':_[_0xa748('0x79')](_0x418478)?_0x102f0b[_0xa748('0xe6')]:_0x418478,'messageId':'','sentAt':new Date(),'attach':_0x234c8[_0xa748('0x49')],'attachments':_0x234c8,'originChannel':_0xa748('0xeb'),'ChatWebsiteId':_0x102f0b['id'],'ChatOfflineMessageId':_0x18c8ce['id'],'originTo':_0x102f0b[_0xa748('0xcb')][_0xa748('0xe5')]},'body':_0x18c8ce[_0xa748('0x58')]};var _0x38d8ad={'account':{'id':_0x102f0b[_0xa748('0xe7')]},'body':_0x1acb39,'log':_0xa748('0xec')};return respondWithRpcPromise(_0xa748('0xec'),_0xa748('0xed'),_0x38d8ad,client9001)[_0xa748('0x35')](function(){return _0x18c8ce;})[_0xa748('0x29')](function(_0x249d68){console[_0xa748('0x25')](_0x249d68);});}return;})['then'](function(){if(_0x18c8ce){return _0x18c8ce;}})['then'](respondWithResult(_0x367de7,null))['catch'](function(_0x58876a){console[_0xa748('0x25')](_0xa748('0x29'),_0x58876a);for(var _0x584569 of _0x22474b){var _0xafa8f8=path[_0xa748('0x75')](config[_0xa748('0x76')],_0xa748('0xd2'),'files',_0xa748('0xd3'),_0xa748('0xd4'),_0x584569[_0xa748('0x6f')]);fs_extra[_0xa748('0xee')](_0xafa8f8)['catch'](function(_0x62e1bd){console[_0xa748('0x25')](_0xa748('0xef'),_0xafa8f8,_0x62e1bd);});}});};exports[_0xa748('0xf0')]=function(_0x3b9bce,_0x5d128b,_0x4bdc35){return db[_0xa748('0xb2')]['find']({'where':{'id':_0x3b9bce[_0xa748('0x5e')]['id']}})['then'](handleEntityNotFound(_0x5d128b,null))[_0xa748('0x35')](function(_0x172a09){if(_0x172a09){return _0x172a09['addInteraction'](_0x3b9bce[_0xa748('0x58')][_0xa748('0x66')],_[_0xa748('0xf1')](_0x3b9bce[_0xa748('0x58')],[_0xa748('0x66'),'id'])||{});}})[_0xa748('0x35')](respondWithResult(_0x5d128b,null))[_0xa748('0x29')](handleError(_0x5d128b,null));};exports[_0xa748('0xf2')]=function(_0x2c1f0d,_0x5c0cc1,_0x426d2d){var _0x577574={'raw':![],'where':{}};var _0x430e5f={};var _0x56344e={'count':0x0,'rows':[]};return db[_0xa748('0x40')]['findOne']({'where':{'id':_0x2c1f0d[_0xa748('0x5e')]['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x5c0cc1,null))[_0xa748('0x35')](function(_0x25b50d){if(_0x25b50d){_0x430e5f[_0xa748('0x42')]=_['keys'](db[_0xa748('0xb2')][_0xa748('0x54')]);_0x430e5f[_0xa748('0x43')]=_[_0xa748('0x44')](_0x2c1f0d['query']);_0x430e5f['filters']=_[_0xa748('0x46')](_0x430e5f['model'],_0x430e5f[_0xa748('0x43')]);_0x577574[_0xa748('0x47')]=_[_0xa748('0x46')](_0x430e5f[_0xa748('0x42')],qs[_0xa748('0x48')](_0x2c1f0d['query'][_0xa748('0x48')]));_0x577574[_0xa748('0x47')]=_0x577574[_0xa748('0x47')]['length']?_0x577574[_0xa748('0x47')]:_0x430e5f['model'];if(!_0x2c1f0d['query'][_0xa748('0x4a')](_0xa748('0x4b'))){_0x577574[_0xa748('0x2f')]=qs['limit'](_0x2c1f0d['query']['limit']);_0x577574[_0xa748('0x2c')]=qs[_0xa748('0x2c')](_0x2c1f0d[_0xa748('0x43')]['offset']);}_0x577574[_0xa748('0x4c')]=qs['sort'](_0x2c1f0d['query']['sort']);_0x577574['where']=qs['filters'](_[_0xa748('0x6b')](_0x2c1f0d[_0xa748('0x43')],_0x430e5f[_0xa748('0x45')]));_0x577574[_0xa748('0x4d')][_0xa748('0x63')]=_0x25b50d['id'];if(_0x2c1f0d['query']['filter']){_0x577574[_0xa748('0x4d')]=_[_0xa748('0x4e')](_0x577574[_0xa748('0x4d')],{'$or':_[_0xa748('0x3f')](_0x577574[_0xa748('0x47')],function(_0x2dbb3f){var _0x554fd8={};_0x554fd8[_0x2dbb3f]={'$like':'%'+_0x2c1f0d[_0xa748('0x43')][_0xa748('0x4f')]+'%'};return _0x554fd8;})});}_0x577574=_[_0xa748('0x4e')]({},_0x577574,_0x2c1f0d[_0xa748('0x50')]);return db[_0xa748('0xb2')][_0xa748('0x2e')]({'where':_0x577574[_0xa748('0x4d')]})[_0xa748('0x35')](function(_0x36bd19){_0x56344e['count']=_0x36bd19;if(_0x2c1f0d['query'][_0xa748('0x51')]){_0x577574[_0xa748('0x55')]=[{'model':db[_0xa748('0x87')],'as':_0xa748('0xf3'),'required':![]},{'model':db['User'],'as':'Owner','attributes':[_0xa748('0x3c'),_0xa748('0xf4'),_0xa748('0xf5')],'required':![]},{'model':db[_0xa748('0xf6')],'as':_0xa748('0xf7'),'attributes':['id','name',_0xa748('0xf8')],'where':_0x2c1f0d[_0xa748('0x43')][_0xa748('0xf9')]?{'id':_0x2c1f0d['query'][_0xa748('0xf9')]}:undefined,'required':_0x2c1f0d[_0xa748('0x43')][_0xa748('0xf9')]?!![]:![]}];}return db[_0xa748('0xb2')][_0xa748('0x64')](_0x577574);})['then'](function(_0x50e9eb){_0x56344e[_0xa748('0x52')]=_0x50e9eb;return _0x56344e;});}})['then'](respondWithFilteredResult(_0x5c0cc1,_0x577574))[_0xa748('0x29')](handleError(_0x5c0cc1,null));};function iftimePromise(_0x4d3819,_0x6aa282){return respondWithRpcPromise(_0xa748('0xfa'),'getSnippet',{'command':_0x6aa282['timezone']?util[_0xa748('0xad')](_0xa748('0xfb'),_0x4d3819[_0xa748('0xfc')],_0x6aa282[_0xa748('0xfd')]):util[_0xa748('0xad')](_0xa748('0xfe'),_0x4d3819['interval'])},client9002)[_0xa748('0x35')](function(_0x1f0d85){var _0x5f447f=_0x1f0d85&&_0x1f0d85[_0xa748('0xff')](_0xa748('0x100'))>=0x0?!![]:![];logger[_0xa748('0x1f')](_0xa748('0x101'),_0x6aa282['id'],_0x4d3819['id'],_0x4d3819[_0xa748('0xfc')],_0x5f447f?'ONLINE':_0xa748('0x102'),_0x6aa282['timezone']?_0x6aa282[_0xa748('0xfd')]:'No\x20timezone');return _0x5f447f;})['catch'](function(_0x3ce877){logger[_0xa748('0x25')](_0xa748('0x101'),_0x6aa282['id'],_0x4d3819['id'],_0x4d3819[_0xa748('0xfc')],util[_0xa748('0x103')](_0x3ce877,{'showHidden':![],'depth':null}),_0x6aa282[_0xa748('0xfd')]?_0x6aa282['timezone']:_0xa748('0x104'));return![];});}exports['getSnippet']=function(_0x2f41ce,_0x469d75,_0x6c83d0){var _0x7bb02=0x0;var _0x582750=0x0;var _0x2381f6=![];var _0x5b4ef9;var _0x45925a;return db[_0xa748('0x40')]['find']({'where':{'id':_0x2f41ce[_0xa748('0x5e')]['id']},'include':[{'model':db['Interval'],'as':_0xa748('0x105'),'include':[{'model':db[_0xa748('0x105')],'as':'Intervals','attributes':['id',_0xa748('0xfc')],'raw':!![]}]}]})[_0xa748('0x35')](handleEntityNotFound(_0x469d75,null))[_0xa748('0x35')](function(_0x55b37a){if(_0x55b37a){_0x5b4ef9=_0x55b37a;return _0x55b37a[_0xa748('0x106')]({'raw':!![]});}})[_0xa748('0x35')](function(_0x3c03dd){if(_0x5b4ef9){if(_0x3c03dd){_0x45925a=_0x3c03dd;}}return require(_0xa748('0x13'))['getLicense']();})[_0xa748('0x35')](function(_0x34f28e){if(_0x34f28e){_0x582750=_0x34f28e[_0xa748('0x107')];_0x2381f6=_0x34f28e[_0xa748('0x78')];}})['then'](function(){return db['ChatInteraction'][_0xa748('0x2e')]({'where':{'closed':![]}});})[_0xa748('0x35')](function(_0x668b84){_0x7bb02=_0x668b84;if(_0x582750&&_0x668b84>_0x582750){return db[_0xa748('0x108')][_0xa748('0x6a')]({'where':{'id':0x1}})[_0xa748('0x35')](function(_0x482ca3){if(_0x482ca3){_0x482ca3[_0xa748('0x109')](_0xa748('0x10a'));}});}})[_0xa748('0x35')](function(){if(_0x5b4ef9[_0xa748('0x105')]&&_0x5b4ef9['Interval'][_0xa748('0x10b')]){var _0x343a96=[];for(var _0x5d499c=0x0;_0x5d499c<_0x5b4ef9[_0xa748('0x105')][_0xa748('0x10b')][_0xa748('0x49')];_0x5d499c++){var _0x75bd28=_0x5b4ef9[_0xa748('0x105')][_0xa748('0x10b')][_0x5d499c][_0xa748('0x5b')]({'plain':!![]});_0x343a96[_0xa748('0xb9')](iftimePromise(_0x75bd28,_0x5b4ef9));}return BPromise['all'](_0x343a96)['then'](function(_0x54881f){return _[_0xa748('0x10c')](_0x54881f);});}else{return!![];}})[_0xa748('0x35')](function(_0x40d95c){var _0x971bc0=fs[_0xa748('0x10d')](path[_0xa748('0x75')](config[_0xa748('0x76')],_0xa748('0x10e')),_0xa748('0x10f'));var _0x3ab8fb={'remote':_0x5b4ef9[_0xa748('0x110')],'query':querystring[_0xa748('0x24')](_['merge'](_0x5b4ef9[_0xa748('0x5b')]({'plain':!![]}),{'customerIp':_0x2f41ce['headers'][_0xa748('0xa5')]||_0x2f41ce['headers'][_0xa748('0x111')]||_0x2f41ce[_0xa748('0x112')][_0xa748('0x113')]||_0x2f41ce['ip'],'referer':_0x2f41ce['headers'][_0xa748('0x114')],'openedInteractions':_0x7bb02,'maxInteractions':_0x582750,'virtual':_0x2381f6[_0xa748('0x107')],'online':_0x40d95c,'custom':_0x2381f6}))[_0xa748('0x115')](/'/g,'\x5c\x27')};_0x469d75[_0xa748('0x3d')](ejs[_0xa748('0xce')](Mustache['render'](_0x971bc0,_0x3ab8fb),{'proactiveActions':_0x45925a,'alignment':_0x5b4ef9[_0xa748('0x116')],'verticalAlignment':_0x5b4ef9[_0xa748('0x117')],'div_color':_0x5b4ef9[_0xa748('0xf8')],'text_color':_0x5b4ef9[_0xa748('0x118')],'button_color':_0x5b4ef9[_0xa748('0x119')],'background_color':_0x5b4ef9[_0xa748('0x11a')]}));})[_0xa748('0x29')](handleError(_0x469d75,null));};exports[_0xa748('0x11b')]=function(_0x2a81b0,_0x58bd5c,_0xff9dc7){return db['ChatWebsite'][_0xa748('0x6a')]({'where':{'id':_0x2a81b0[_0xa748('0x5e')]['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x58bd5c,null))[_0xa748('0x35')](function(_0x5d341e){if(_0x5d341e){return db[_0xa748('0xd7')]['transaction'](function(_0x55ba8b){return db[_0xa748('0x98')][_0xa748('0x36')]({'where':{'ChatWebsiteId':_0x2a81b0[_0xa748('0x5e')]['id']},'transaction':_0x55ba8b})[_0xa748('0x35')](function(_0x5ae0e5){var _0x19c73c=_[_0xa748('0x3f')](_0x2a81b0[_0xa748('0x58')],function(_0x56202e){_0x56202e[_0xa748('0x63')]=_0x2a81b0['params']['id'];return _0x56202e;});return db[_0xa748('0x98')][_0xa748('0x11c')](_0x19c73c,{'transaction':_0x55ba8b});});})[_0xa748('0x35')](function(){return db[_0xa748('0x98')][_0xa748('0x11d')]({'where':{'ChatWebsiteId':_0x2a81b0[_0xa748('0x5e')]['id']},'order':'priority'});});}})[_0xa748('0x35')](respondWithResult(_0x58bd5c,null))['catch'](handleError(_0x58bd5c,null));};exports['getApplications']=function(_0x2c7c25,_0x7773c4,_0x52f6e4){var _0x3b6bf0={};var _0xe69c89={};var _0x279182;var _0x2de2e6;return db['ChatWebsite'][_0xa748('0x6a')]({'where':{'id':_0x2c7c25[_0xa748('0x5e')]['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x7773c4,null))[_0xa748('0x35')](function(_0xa9943e){if(_0xa9943e){_0x279182=_0xa9943e;_0xe69c89[_0xa748('0x42')]=_[_0xa748('0x44')](db['ChatApplication'][_0xa748('0x54')]);_0xe69c89[_0xa748('0x43')]=_[_0xa748('0x44')](_0x2c7c25[_0xa748('0x43')]);_0xe69c89[_0xa748('0x45')]=_[_0xa748('0x46')](_0xe69c89[_0xa748('0x42')],_0xe69c89['query']);_0x3b6bf0['attributes']=_['intersection'](_0xe69c89[_0xa748('0x42')],qs[_0xa748('0x48')](_0x2c7c25[_0xa748('0x43')][_0xa748('0x48')]));_0x3b6bf0[_0xa748('0x47')]=_0x3b6bf0['attributes'][_0xa748('0x49')]?_0x3b6bf0[_0xa748('0x47')]:_0xe69c89[_0xa748('0x42')];_0x3b6bf0[_0xa748('0x4c')]=qs['sort'](_0x2c7c25[_0xa748('0x43')][_0xa748('0x62')]);_0x3b6bf0[_0xa748('0x4d')]=qs[_0xa748('0x45')](_[_0xa748('0x6b')](_0x2c7c25[_0xa748('0x43')],_0xe69c89[_0xa748('0x45')]));if(_0x2c7c25[_0xa748('0x43')][_0xa748('0x4f')]){_0x3b6bf0[_0xa748('0x4d')]=_[_0xa748('0x4e')](_0x3b6bf0[_0xa748('0x4d')],{'$or':_[_0xa748('0x3f')](_0x3b6bf0[_0xa748('0x47')],function(_0xbda5a9){var _0x301e3e={};_0x301e3e[_0xbda5a9]={'$like':'%'+_0x2c7c25[_0xa748('0x43')][_0xa748('0x4f')]+'%'};return _0x301e3e;})});}_0x3b6bf0=_[_0xa748('0x4e')]({},_0x3b6bf0,_0x2c7c25[_0xa748('0x50')]);return _0x279182[_0xa748('0x11e')](_0x3b6bf0);}})['then'](function(_0xae3596){if(_0xae3596){_0x2de2e6=_0xae3596[_0xa748('0x49')];if(!_0x2c7c25[_0xa748('0x43')][_0xa748('0x4a')](_0xa748('0x4b'))){_0x3b6bf0['limit']=qs['limit'](_0x2c7c25[_0xa748('0x43')][_0xa748('0x2f')]);_0x3b6bf0[_0xa748('0x2c')]=qs[_0xa748('0x2c')](_0x2c7c25['query'][_0xa748('0x2c')]);}return _0x279182[_0xa748('0x11e')](_0x3b6bf0);}})[_0xa748('0x35')](function(_0x5ccc97){if(_0x5ccc97){return _0x5ccc97?{'count':_0x2de2e6,'rows':_0x5ccc97}:null;}})['then'](respondWithResult(_0x7773c4,null))[_0xa748('0x29')](handleError(_0x7773c4,null));};exports[_0xa748('0x11f')]=function(_0x34d7c6,_0x737352,_0x521dbd){return db[_0xa748('0x120')][_0xa748('0x56')]({'where':{'id':_0x34d7c6[_0xa748('0x5e')]['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x737352,null))['then'](function(_0x5c3846){if(_0x5c3846){return _0x5c3846[_0xa748('0x11f')](_0x34d7c6[_0xa748('0x58')][_0xa748('0x66')],_[_0xa748('0xf1')](_0x34d7c6[_0xa748('0x58')],[_0xa748('0x66'),'id'])||{});}})['then'](respondWithResult(_0x737352,null))[_0xa748('0x29')](handleError(_0x737352,null));};exports[_0xa748('0x106')]=function(_0x2932a9,_0x21e448,_0x46a495){var _0x39fa09={};var _0x39ee20={};var _0x12c16f;var _0x5d2938;return db['ChatWebsite'][_0xa748('0x6a')]({'where':{'id':_0x2932a9[_0xa748('0x5e')]['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x21e448,null))[_0xa748('0x35')](function(_0x33e23c){if(_0x33e23c){_0x12c16f=_0x33e23c;_0x39ee20['model']=_[_0xa748('0x44')](db['ChatProactiveAction']['rawAttributes']);_0x39ee20[_0xa748('0x43')]=_['keys'](_0x2932a9[_0xa748('0x43')]);_0x39ee20[_0xa748('0x45')]=_[_0xa748('0x46')](_0x39ee20[_0xa748('0x42')],_0x39ee20[_0xa748('0x43')]);_0x39fa09[_0xa748('0x47')]=_[_0xa748('0x46')](_0x39ee20[_0xa748('0x42')],qs['fields'](_0x2932a9['query'][_0xa748('0x48')]));_0x39fa09[_0xa748('0x47')]=_0x39fa09[_0xa748('0x47')]['length']?_0x39fa09['attributes']:_0x39ee20['model'];_0x39fa09[_0xa748('0x4c')]=qs[_0xa748('0x62')](_0x2932a9[_0xa748('0x43')][_0xa748('0x62')]);_0x39fa09[_0xa748('0x4d')]=qs[_0xa748('0x45')](_[_0xa748('0x6b')](_0x2932a9['query'],_0x39ee20[_0xa748('0x45')]));if(_0x2932a9[_0xa748('0x43')][_0xa748('0x4f')]){_0x39fa09['where']=_[_0xa748('0x4e')](_0x39fa09[_0xa748('0x4d')],{'$or':_['map'](_0x39fa09[_0xa748('0x47')],function(_0x5d8904){var _0x414834={};_0x414834[_0x5d8904]={'$like':'%'+_0x2932a9[_0xa748('0x43')][_0xa748('0x4f')]+'%'};return _0x414834;})});}_0x39fa09=_[_0xa748('0x4e')]({},_0x39fa09,_0x2932a9[_0xa748('0x50')]);return _0x12c16f['getProactiveActions'](_0x39fa09);}})['then'](function(_0x272215){if(_0x272215){_0x5d2938=_0x272215[_0xa748('0x49')];if(!_0x2932a9[_0xa748('0x43')][_0xa748('0x4a')](_0xa748('0x4b'))){_0x39fa09[_0xa748('0x2f')]=qs[_0xa748('0x2f')](_0x2932a9[_0xa748('0x43')]['limit']);_0x39fa09[_0xa748('0x2c')]=qs[_0xa748('0x2c')](_0x2932a9[_0xa748('0x43')][_0xa748('0x2c')]);}return _0x12c16f[_0xa748('0x106')](_0x39fa09);}})['then'](function(_0x467a6c){if(_0x467a6c){return _0x467a6c?{'count':_0x5d2938,'rows':_0x467a6c}:null;}})[_0xa748('0x35')](respondWithResult(_0x21e448,null))['catch'](handleError(_0x21e448,null));};exports['getFields']=function(_0x235cf1,_0x46ea5c,_0xe57a14){var _0x2ad131=_0x235cf1[_0xa748('0x43')][_0xa748('0x121')]===_0xa748('0x122')?'offlineForm':_0xa748('0x123');return db[_0xa748('0x40')][_0xa748('0x56')]({'attributes':['id',_0x2ad131],'where':{'id':_0x235cf1[_0xa748('0x5e')]['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x46ea5c,null))['then'](function(_0xe806cf){if(_0xe806cf){var _0x4d0a5e=_0xe806cf[_0x2ad131];var _0x3343cb=_0x4d0a5e&&_0x4d0a5e[_0xa748('0x124')]?_0x4d0a5e[_0xa748('0x124')]:[];_0x46ea5c[_0xa748('0x3d')]({'fromKey':_[_0xa748('0x79')](_0x4d0a5e[_0xa748('0x125')])?undefined:_0x4d0a5e['fromKey'],'count':_0x3343cb['length'],'rows':_0x3343cb});}})[_0xa748('0x29')](handleError(_0x46ea5c,null));};exports[_0xa748('0x126')]=function(_0x5787da,_0x3b29fc,_0xea801f){var _0x3e2ae3={'raw':![],'where':{}};var _0x1d859b={};var _0x327833={'count':0x0,'rows':[]};return db[_0xa748('0x40')][_0xa748('0x6a')]({'where':{'id':_0x5787da[_0xa748('0x5e')]['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x3b29fc,null))['then'](function(_0x4b8237){if(_0x4b8237){_0x1d859b['model']=_[_0xa748('0x44')](db['ChatOfflineMessage'][_0xa748('0x54')]);_0x1d859b[_0xa748('0x43')]=_[_0xa748('0x44')](_0x5787da[_0xa748('0x43')]);_0x1d859b[_0xa748('0x45')]=_[_0xa748('0x46')](_0x1d859b['model'],_0x1d859b[_0xa748('0x43')]);_0x3e2ae3[_0xa748('0x47')]=_[_0xa748('0x46')](_0x1d859b[_0xa748('0x42')],qs[_0xa748('0x48')](_0x5787da['query'][_0xa748('0x48')]));_0x3e2ae3[_0xa748('0x47')]=_0x3e2ae3[_0xa748('0x47')][_0xa748('0x49')]?_0x3e2ae3[_0xa748('0x47')]:_0x1d859b[_0xa748('0x42')];if(!_0x5787da['query'][_0xa748('0x4a')](_0xa748('0x4b'))){_0x3e2ae3['limit']=qs['limit'](_0x5787da[_0xa748('0x43')][_0xa748('0x2f')]);_0x3e2ae3[_0xa748('0x2c')]=qs[_0xa748('0x2c')](_0x5787da[_0xa748('0x43')][_0xa748('0x2c')]);}_0x3e2ae3[_0xa748('0x4c')]=qs[_0xa748('0x62')](_0x5787da['query'][_0xa748('0x62')]);_0x3e2ae3[_0xa748('0x4d')]=qs[_0xa748('0x45')](_['pick'](_0x5787da[_0xa748('0x43')],_0x1d859b[_0xa748('0x45')]));_0x3e2ae3['where'][_0xa748('0x63')]=_0x4b8237['id'];if(_0x5787da[_0xa748('0x43')][_0xa748('0x4f')]){_0x3e2ae3[_0xa748('0x4d')]=_[_0xa748('0x4e')](_0x3e2ae3[_0xa748('0x4d')],{'$or':_['map'](_0x3e2ae3['attributes'],function(_0x26b780){var _0xe56c9f={};_0xe56c9f[_0x26b780]={'$like':'%'+_0x5787da['query'][_0xa748('0x4f')]+'%'};return _0xe56c9f;})});}_0x3e2ae3=_['merge']({},_0x3e2ae3,_0x5787da[_0xa748('0x50')]);return db['ChatOfflineMessage']['count']({'where':_0x3e2ae3['where']})['then'](function(_0x30827d){_0x327833[_0xa748('0x2e')]=_0x30827d;if(_0x5787da[_0xa748('0x43')][_0xa748('0x51')]){_0x3e2ae3[_0xa748('0x55')]=[{'all':!![]}];}else{_0x3e2ae3[_0xa748('0x55')]=[{'model':db[_0xa748('0x87')],'as':'Contact','required':![]},{'model':db['Attachment'],'as':_0xa748('0x127'),'required':![]}];}return db[_0xa748('0x128')][_0xa748('0x64')](_0x3e2ae3);})[_0xa748('0x35')](function(_0x4c06b6){_0x327833[_0xa748('0x52')]=_0x4c06b6;return _0x327833;});}})[_0xa748('0x35')](respondWithFilteredResult(_0x3b29fc,_0x3e2ae3))[_0xa748('0x29')](handleError(_0x3b29fc,null));};exports[_0xa748('0x129')]=function(_0x2b5c31,_0x2cb86e,_0x43f2d9){return db[_0xa748('0x40')]['find']({'where':{'id':_0x2b5c31[_0xa748('0x5e')]['id']}})['then'](handleEntityNotFound(_0x2cb86e,null))[_0xa748('0x35')](function(_0x7ee3a5){if(_0x7ee3a5){return _0x7ee3a5[_0xa748('0x129')](_0x2b5c31[_0xa748('0x58')][_0xa748('0x66')],_[_0xa748('0xf1')](_0x2b5c31[_0xa748('0x58')],['ids','id'])||{})[_0xa748('0xb5')](function(_0x437fb3){for(var _0x4f4c0b=0x0;_0x4f4c0b<_0x2b5c31[_0xa748('0x58')][_0xa748('0x66')][_0xa748('0x49')];_0x4f4c0b+=0x1){socket[_0xa748('0x12a')]('userChatWebsite:save',{'UserId':Number(_0x2b5c31['body']['ids'][_0x4f4c0b]),'ChatWebsiteId':Number(_0x2b5c31[_0xa748('0x5e')]['id'])});}return _0x437fb3;});}})['then'](respondWithResult(_0x2cb86e,null))['catch'](handleError(_0x2cb86e,null));};exports[_0xa748('0x12b')]=function(_0x3bdef2,_0x2fd17b,_0x3fa7fd){return db[_0xa748('0x40')]['find']({'where':{'id':_0x3bdef2[_0xa748('0x5e')]['id']}})[_0xa748('0x35')](handleEntityNotFound(_0x2fd17b,null))[_0xa748('0x35')](function(_0x2e23f6){if(_0x2e23f6){return _0x2e23f6[_0xa748('0x12b')](_0x3bdef2[_0xa748('0x43')]['ids'])[_0xa748('0x35')](function(){if(_['isArray'](_0x3bdef2[_0xa748('0x43')][_0xa748('0x66')])){for(var _0x3b77bc=0x0;_0x3b77bc<_0x3bdef2[_0xa748('0x43')]['ids']['length'];_0x3b77bc+=0x1){socket[_0xa748('0x12a')](_0xa748('0x12c'),{'UserId':Number(_0x3bdef2[_0xa748('0x43')]['ids'][_0x3b77bc]),'ChatWebsiteId':Number(_0x3bdef2[_0xa748('0x5e')]['id'])});}}else{socket[_0xa748('0x12a')](_0xa748('0x12c'),{'UserId':Number(_0x3bdef2['query']['ids']),'ChatWebsiteId':Number(_0x3bdef2['params']['id'])});}});}})['then'](respondWithStatusCode(_0x2fd17b,null))[_0xa748('0x29')](handleError(_0x2fd17b,null));};exports[_0xa748('0x12d')]=function(_0x15a3a5,_0xc95adc,_0x4f45ff){var _0x1ba1b2={};var _0x5e6f77={};var _0xed0c34;var _0x3279b0;return db[_0xa748('0x40')][_0xa748('0x6a')]({'where':{'id':_0x15a3a5[_0xa748('0x5e')]['id']}})['then'](handleEntityNotFound(_0xc95adc,null))[_0xa748('0x35')](function(_0x54fb8e){if(_0x54fb8e){_0xed0c34=_0x54fb8e;_0x5e6f77[_0xa748('0x42')]=_['keys'](db['User'][_0xa748('0x54')]);_0x5e6f77[_0xa748('0x43')]=_[_0xa748('0x44')](_0x15a3a5[_0xa748('0x43')]);_0x5e6f77[_0xa748('0x45')]=_[_0xa748('0x46')](_0x5e6f77[_0xa748('0x42')],_0x5e6f77['query']);_0x1ba1b2[_0xa748('0x47')]=_[_0xa748('0x46')](_0x5e6f77['model'],qs[_0xa748('0x48')](_0x15a3a5['query'][_0xa748('0x48')]));_0x1ba1b2[_0xa748('0x47')]=_0x1ba1b2[_0xa748('0x47')]['length']?_0x1ba1b2[_0xa748('0x47')]:_0x5e6f77[_0xa748('0x42')];_0x1ba1b2[_0xa748('0x4c')]=qs[_0xa748('0x62')](_0x15a3a5['query'][_0xa748('0x62')]);_0x1ba1b2[_0xa748('0x4d')]=qs[_0xa748('0x45')](_[_0xa748('0x6b')](_0x15a3a5[_0xa748('0x43')],_0x5e6f77['filters']));if(_0x15a3a5[_0xa748('0x43')][_0xa748('0x4f')]){_0x1ba1b2['where']=_[_0xa748('0x4e')](_0x1ba1b2[_0xa748('0x4d')],{'$or':_['map'](_0x1ba1b2[_0xa748('0x47')],function(_0x49ffe7){var _0x34b25f={};_0x34b25f[_0x49ffe7]={'$like':'%'+_0x15a3a5[_0xa748('0x43')][_0xa748('0x4f')]+'%'};return _0x34b25f;})});}_0x1ba1b2=_[_0xa748('0x4e')]({},_0x1ba1b2,_0x15a3a5[_0xa748('0x50')]);return _0xed0c34[_0xa748('0x12d')](_0x1ba1b2);}})[_0xa748('0x35')](function(_0x227615){if(_0x227615){_0x3279b0=_0x227615[_0xa748('0x49')];if(!_0x15a3a5[_0xa748('0x43')][_0xa748('0x4a')](_0xa748('0x4b'))){_0x1ba1b2[_0xa748('0x2f')]=qs[_0xa748('0x2f')](_0x15a3a5[_0xa748('0x43')][_0xa748('0x2f')]);_0x1ba1b2['offset']=qs[_0xa748('0x2c')](_0x15a3a5[_0xa748('0x43')]['offset']);}return _0xed0c34[_0xa748('0x12d')](_0x1ba1b2);}})[_0xa748('0x35')](function(_0x1c217f){if(_0x1c217f){return _0x1c217f?{'count':_0x3279b0,'rows':_0x1c217f}:null;}})[_0xa748('0x35')](respondWithResult(_0xc95adc,null))['catch'](handleError(_0xc95adc,null));};
\ No newline at end of file