Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / chatWebsite / chatWebsite.controller.js
index c7f6a76..3526ac2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9760=['../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./chatWebsite.socket','jayson/promise','http','client','info','ChatWebsite,\x20%s,\x20%s','debug','request\x20sent','error','message','result','status','json','count','offset','limit','set','Content-Range','apply','update','then','destroy','end','name','send','index','Pause','mandatoryDispositionPause','map','ChatWebsite','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','options','includeAll','include','rows','params','rawAttributes','find','catch','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','ChatWebsites','UserProfileSection','autoAssociation','UserProfileResource','describe','addDisposition','ChatWebsiteId','Disposition','getDispositions','findOne','order','findAll','removeDispositions','getAnswers','CannedAnswer','removeAnswers','ids','addLogo','sitepic','filename','agentAvatar','addCustomerAvatar','file','addSystemAvatar','systemAvatar','getLogo','join','server/files/images/logos/default_logo.svg','getLicense','custom','isNil','existsSync','root','download','getAvatar','server/files/images/avatars/default_avatar.png','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','customerAvatar','showCustomerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','notify','user-agent-parser','getResult','chat','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','difference','updatedAt','CompanyId','ListId','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','includes','CmList','Contacts','DESC','ChatApplication','Applications','List','account','applications','list','orderBy','priority','asc','contact','headers','cf-connecting-ip','x-forwarded-for','first','split','firstName','lastName','x-real-port','referer','browser','version','format','unknown','%s\x20%s','device','vendor','%s\x20%s\x20%s','stringify','threadId','externalUrl','ChatInteraction','ContactId','interaction','messageId','created','autoclose','push','unmanaged','*,*,*,*','ChatMessage','AttachmentId','UserId','User','waitForTheAssignedAgent','forcedOwnership','startRouting','EventManager','createdAt','mapKeyOffline','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','findOrCreate','spread','readFileSync','server/files/templates/chatOfflineMessage.ejs','utf8','render','toPairs','offlineMessageBody','ChatOfflineMessage','MailAccount','MailServerOut','service','Smtp','host','port','secure','authentication','pass','sendMail','email','forwardOfflineAddress','offlineMessageSubject','addInteraction','getInteractions','Contact','Owner','fullname','Tag','Tags','tag','Command','timezone','interval','iftime\x20%s','true','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','OFFLINE','Interval','Intervals','getProactiveActions','License','increment','remote','x-real-ip','remoteAddress','virtual','alignment','verticalAlignment','textColor','addApplications','sequelize','transaction','findAndCountAll','getApplications','addProactiveActions','chatProactiveAction','omit','ChatProactiveAction','getFields','online','false','offlineForm','items','fromKey','addAgents','emit','userChatWebsite:save','removeAgents','isArray','userChatWebsite:remove','getAgents','eml-format','rimraf','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service'];(function(_0x4b3a3,_0xaa5739){var _0x364df1=function(_0x317713){while(--_0x317713){_0x4b3a3['push'](_0x4b3a3['shift']());}};_0x364df1(++_0xaa5739);}(_0x9760,0x101));var _0x0976=function(_0x4e32d9,_0x1a7974){_0x4e32d9=_0x4e32d9-0x0;var _0x37840f=_0x9760[_0x4e32d9];return _0x37840f;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x0976('0x0'));var rimraf=require(_0x0976('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x0976('0x2'));var moment=require(_0x0976('0x3'));var BPromise=require(_0x0976('0x4'));var Mustache=require(_0x0976('0x5'));var util=require(_0x0976('0x6'));var path=require(_0x0976('0x7'));var sox=require(_0x0976('0x8'));var csv=require(_0x0976('0x9'));var ejs=require(_0x0976('0xa'));var fs=require('fs');var _=require(_0x0976('0xb'));var squel=require(_0x0976('0xc'));var crypto=require(_0x0976('0xd'));var jsforce=require(_0x0976('0xe'));var deskjs=require(_0x0976('0xf'));var toCsv=require(_0x0976('0x9'));var querystring=require(_0x0976('0x10'));var Papa=require(_0x0976('0x11'));var Redis=require('ioredis');var authService=require(_0x0976('0x12'));var qs=require(_0x0976('0x13'));var as=require(_0x0976('0x14'));var hardwareService=require(_0x0976('0x15'));var logger=require(_0x0976('0x16'))('api');var utils=require('../../config/utils');var config=require(_0x0976('0x17'));var licenseUtil=require(_0x0976('0x18'));var db=require(_0x0976('0x19'))['db'];config[_0x0976('0x1a')]=_[_0x0976('0x1b')](config[_0x0976('0x1a')],{'host':'localhost','port':0x18eb});var socket=require(_0x0976('0x1c'))(new Redis(config[_0x0976('0x1a')]));require(_0x0976('0x1d'))['register'](socket);var jayson=require(_0x0976('0x1e'));var client=jayson['client'][_0x0976('0x1f')]({'port':0x232c});var client9002=jayson[_0x0976('0x20')][_0x0976('0x1f')]({'port':0x232a});var client9003=jayson[_0x0976('0x20')]['http']({'port':0x232b});function respondWithRpcPromise(_0x47dff6,_0xd244e7,_0x1b471c,_0x309cea){return new BPromise(function(_0x1a7a44,_0x50f836){var _0x530ff6=_0x309cea||client;return _0x530ff6['request'](_0x47dff6,_0x1b471c)['then'](function(_0x5ca443){logger[_0x0976('0x21')](_0x0976('0x22'),_0xd244e7,'request\x20sent');logger[_0x0976('0x23')]('ChatWebsite,\x20%s,\x20%s,\x20%s',_0xd244e7,_0x0976('0x24'),JSON['stringify'](_0x5ca443));if(_0x5ca443[_0x0976('0x25')]){if(_0x5ca443[_0x0976('0x25')]['code']===0x1f4){logger[_0x0976('0x25')]('ChatWebsite,\x20%s,\x20%s',_0xd244e7,_0x5ca443[_0x0976('0x25')][_0x0976('0x26')]);return _0x50f836(_0x5ca443[_0x0976('0x25')][_0x0976('0x26')]);}logger[_0x0976('0x25')](_0x0976('0x22'),_0xd244e7,_0x5ca443[_0x0976('0x25')][_0x0976('0x26')]);return _0x1a7a44(_0x5ca443[_0x0976('0x25')][_0x0976('0x26')]);}else{logger[_0x0976('0x21')](_0x0976('0x22'),_0xd244e7,_0x0976('0x24'));_0x1a7a44(_0x5ca443[_0x0976('0x27')][_0x0976('0x26')]);}})['catch'](function(_0x58cfec){logger[_0x0976('0x25')](_0x0976('0x22'),_0xd244e7,_0x58cfec);_0x50f836(_0x58cfec);});});}function respondWithStatusCode(_0xfde6b6,_0x5bd4dd){_0x5bd4dd=_0x5bd4dd||0xcc;return function(_0x11d94e){if(_0x11d94e){return _0xfde6b6['sendStatus'](_0x5bd4dd);}return _0xfde6b6[_0x0976('0x28')](_0x5bd4dd)['end']();};}function respondWithResult(_0xead4a3,_0x5b1492){_0x5b1492=_0x5b1492||0xc8;return function(_0x2cc37b){if(_0x2cc37b){return _0xead4a3[_0x0976('0x28')](_0x5b1492)[_0x0976('0x29')](_0x2cc37b);}};}function respondWithFilteredResult(_0x35799b,_0x2f0a4f){return function(_0x194711){if(_0x194711){var _0x444a77=_0x194711[_0x0976('0x2a')],_0xa39c95=_0x2f0a4f['offset'],_0x58b23c=_0x2f0a4f[_0x0976('0x2b')]+_0x2f0a4f[_0x0976('0x2c')],_0x46c062;if(_0x58b23c>=_0x444a77){_0x58b23c=_0x444a77;_0x46c062=0xc8;}else{_0x46c062=0xce;}_0x35799b[_0x0976('0x28')](_0x46c062);return _0x35799b[_0x0976('0x2d')](_0x0976('0x2e'),_0xa39c95+'-'+_0x58b23c+'/'+_0x444a77)[_0x0976('0x29')](_0x194711);}return null;};}function patchUpdates(_0x11d587){return function(_0x50f767){try{jsonpatch[_0x0976('0x2f')](_0x50f767,_0x11d587,!![]);}catch(_0xbd8089){return BPromise['reject'](_0xbd8089);}return _0x50f767['save']();};}function saveUpdates(_0x19a57c,_0x4f33de){return function(_0x418b88){if(_0x418b88){return _0x418b88[_0x0976('0x30')](_0x19a57c)[_0x0976('0x31')](function(_0x30f6dc){return _0x30f6dc;});}return null;};}function removeEntity(_0x1cebfd,_0x2d4084){return function(_0xe0e32d){if(_0xe0e32d){return _0xe0e32d['destroy']()[_0x0976('0x31')](function(){var _0x48d605=_0xe0e32d['get']({'plain':!![]});var _0x4e40c0='ChatWebsites';return db['UserProfileResource'][_0x0976('0x32')]({'where':{'type':_0x4e40c0,'resourceId':_0x48d605['id']}})[_0x0976('0x31')](function(){return _0xe0e32d;});})[_0x0976('0x31')](function(){_0x1cebfd['status'](0xcc)[_0x0976('0x33')]();});}};}function handleEntityNotFound(_0x5a3c27,_0x1ef73d){return function(_0x1bca79){if(!_0x1bca79){_0x5a3c27['sendStatus'](0x194);}return _0x1bca79;};}function handleError(_0x29875c,_0x2beb22){_0x2beb22=_0x2beb22||0x1f4;return function(_0x2e2464){logger['error'](_0x2e2464['stack']);if(_0x2e2464[_0x0976('0x34')]){delete _0x2e2464[_0x0976('0x34')];}_0x29875c[_0x0976('0x28')](_0x2beb22)[_0x0976('0x35')](_0x2e2464);};}exports[_0x0976('0x36')]=function(_0x4082b8,_0x37afaa){var _0x5aed70={'include':[{'model':db[_0x0976('0x37')],'as':_0x0976('0x38')}]},_0x184949={},_0x3a43a8={'count':0x0,'rows':[]};var _0x24bdb3=_[_0x0976('0x39')](db[_0x0976('0x3a')]['rawAttributes'],function(_0x54f8d2){return{'name':_0x54f8d2[_0x0976('0x3b')],'type':_0x54f8d2[_0x0976('0x3c')][_0x0976('0x3d')]};});_0x184949[_0x0976('0x3e')]=_[_0x0976('0x39')](_0x24bdb3,_0x0976('0x34'));_0x184949[_0x0976('0x3f')]=_[_0x0976('0x40')](_0x4082b8[_0x0976('0x3f')]);_0x184949[_0x0976('0x41')]=_[_0x0976('0x42')](_0x184949[_0x0976('0x3e')],_0x184949[_0x0976('0x3f')]);_0x5aed70['attributes']=_[_0x0976('0x42')](_0x184949[_0x0976('0x3e')],qs['fields'](_0x4082b8['query'][_0x0976('0x43')]));_0x5aed70[_0x0976('0x44')]=_0x5aed70[_0x0976('0x44')][_0x0976('0x45')]?_0x5aed70['attributes']:_0x184949[_0x0976('0x3e')];if(!_0x4082b8[_0x0976('0x3f')][_0x0976('0x46')](_0x0976('0x47'))){_0x5aed70['limit']=qs['limit'](_0x4082b8[_0x0976('0x3f')][_0x0976('0x2c')]);_0x5aed70['offset']=qs['offset'](_0x4082b8['query'][_0x0976('0x2b')]);}_0x5aed70['order']=qs['sort'](_0x4082b8[_0x0976('0x3f')][_0x0976('0x48')]);_0x5aed70[_0x0976('0x49')]=qs[_0x0976('0x41')](_[_0x0976('0x4a')](_0x4082b8[_0x0976('0x3f')],_0x184949['filters']),_0x24bdb3);if(_0x4082b8[_0x0976('0x3f')][_0x0976('0x4b')]){_0x5aed70[_0x0976('0x49')]=_['merge'](_0x5aed70[_0x0976('0x49')],{'$or':_[_0x0976('0x39')](_0x24bdb3,function(_0x26b841){if(_0x26b841['type']!=='VIRTUAL'){var _0x1ec052={};_0x1ec052[_0x26b841[_0x0976('0x34')]]={'$like':'%'+_0x4082b8['query'][_0x0976('0x4b')]+'%'};return _0x1ec052;}})});}_0x5aed70=_[_0x0976('0x4c')]({},_0x5aed70,_0x4082b8[_0x0976('0x4d')]);var _0x46cc25={'where':_0x5aed70[_0x0976('0x49')]};return db[_0x0976('0x3a')][_0x0976('0x2a')](_0x46cc25)[_0x0976('0x31')](function(_0x766baf){_0x3a43a8[_0x0976('0x2a')]=_0x766baf;if(_0x4082b8['query'][_0x0976('0x4e')]){_0x5aed70[_0x0976('0x4f')]=[{'all':!![]}];}return db[_0x0976('0x3a')]['findAll'](_0x5aed70);})[_0x0976('0x31')](function(_0x300a3f){_0x3a43a8[_0x0976('0x50')]=_0x300a3f;return _0x3a43a8;})[_0x0976('0x31')](respondWithFilteredResult(_0x37afaa,_0x5aed70))['catch'](handleError(_0x37afaa,null));};exports['show']=function(_0x4bb971,_0xe0ffa7){var _0x495e24={'raw':![],'where':{'id':_0x4bb971[_0x0976('0x51')]['id']},'include':[{'model':db[_0x0976('0x37')],'as':_0x0976('0x38')}]},_0x4192eb={};_0x4192eb[_0x0976('0x3e')]=_[_0x0976('0x40')](db['ChatWebsite'][_0x0976('0x52')]);_0x4192eb[_0x0976('0x3f')]=_[_0x0976('0x40')](_0x4bb971['query']);_0x4192eb[_0x0976('0x41')]=_['intersection'](_0x4192eb[_0x0976('0x3e')],_0x4192eb[_0x0976('0x3f')]);_0x495e24[_0x0976('0x44')]=_[_0x0976('0x42')](_0x4192eb[_0x0976('0x3e')],qs[_0x0976('0x43')](_0x4bb971['query']['fields']));_0x495e24[_0x0976('0x44')]=_0x495e24[_0x0976('0x44')][_0x0976('0x45')]?_0x495e24[_0x0976('0x44')]:_0x4192eb[_0x0976('0x3e')];if(_0x4bb971[_0x0976('0x3f')]['includeAll']){_0x495e24[_0x0976('0x4f')]=[{'all':!![]}];}_0x495e24=_['merge']({},_0x495e24,_0x4bb971[_0x0976('0x4d')]);return db['ChatWebsite'][_0x0976('0x53')](_0x495e24)[_0x0976('0x31')](handleEntityNotFound(_0xe0ffa7,null))['then'](respondWithResult(_0xe0ffa7,null))[_0x0976('0x54')](handleError(_0xe0ffa7,null));};exports[_0x0976('0x55')]=function(_0x3cc447,_0x500505){return db[_0x0976('0x3a')][_0x0976('0x55')](_0x3cc447[_0x0976('0x56')],{})[_0x0976('0x31')](function(_0x3ba444){var _0x4c72ae=_0x3cc447[_0x0976('0x57')][_0x0976('0x58')]({'plain':!![]});if(!_0x4c72ae)throw new Error(_0x0976('0x59'));if(_0x4c72ae[_0x0976('0x5a')]===_0x0976('0x57')){var _0x51dc25=_0x3ba444[_0x0976('0x58')]({'plain':!![]});var _0x144059=_0x0976('0x5b');return db[_0x0976('0x5c')]['find']({'where':{'name':_0x144059,'userProfileId':_0x4c72ae['userProfileId']},'raw':!![]})[_0x0976('0x31')](function(_0x3e8fc6){if(_0x3e8fc6&&_0x3e8fc6[_0x0976('0x5d')]===0x0){return db[_0x0976('0x5e')][_0x0976('0x55')]({'name':_0x51dc25[_0x0976('0x34')],'resourceId':_0x51dc25['id'],'type':_0x3e8fc6[_0x0976('0x34')],'sectionId':_0x3e8fc6['id']},{})[_0x0976('0x31')](function(){return _0x3ba444;});}else{return _0x3ba444;}})[_0x0976('0x54')](function(_0x34c88a){logger[_0x0976('0x25')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x34c88a);throw _0x34c88a;});}return _0x3ba444;})[_0x0976('0x31')](respondWithResult(_0x500505,0xc9))[_0x0976('0x54')](handleError(_0x500505,null));};exports[_0x0976('0x30')]=function(_0x54d4a8,_0x411cb0){if(_0x54d4a8['body']['id']){delete _0x54d4a8[_0x0976('0x56')]['id'];}return db[_0x0976('0x3a')][_0x0976('0x53')]({'where':{'id':_0x54d4a8['params']['id']},'include':[{'model':db[_0x0976('0x37')],'as':_0x0976('0x38')}]})[_0x0976('0x31')](handleEntityNotFound(_0x411cb0,null))['then'](saveUpdates(_0x54d4a8[_0x0976('0x56')],null))[_0x0976('0x31')](respondWithResult(_0x411cb0,null))[_0x0976('0x54')](handleError(_0x411cb0,null));};exports[_0x0976('0x32')]=function(_0x51a59d,_0x5cc81d){return db[_0x0976('0x3a')]['find']({'where':{'id':_0x51a59d[_0x0976('0x51')]['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x5cc81d,null))['then'](removeEntity(_0x5cc81d,null))[_0x0976('0x54')](handleError(_0x5cc81d,null));};exports[_0x0976('0x5f')]=function(_0x2505ab,_0x5ad0bd){return db[_0x0976('0x3a')][_0x0976('0x5f')]()[_0x0976('0x31')](respondWithResult(_0x5ad0bd,null))[_0x0976('0x54')](handleError(_0x5ad0bd,null));};exports[_0x0976('0x60')]=function(_0x368384,_0x29cc29,_0x2f0d68){if(_0x368384[_0x0976('0x56')]['id']){delete _0x368384[_0x0976('0x56')]['id'];}return db[_0x0976('0x3a')][_0x0976('0x53')]({'where':{'id':_0x368384[_0x0976('0x51')]['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x29cc29,null))['then'](function(_0x450135){if(_0x450135){_0x368384['body'][_0x0976('0x61')]=_0x450135['id'];return db[_0x0976('0x62')][_0x0976('0x55')](_0x368384[_0x0976('0x56')]);}})[_0x0976('0x31')](respondWithResult(_0x29cc29,null))[_0x0976('0x54')](handleError(_0x29cc29,null));};exports[_0x0976('0x63')]=function(_0x5d5546,_0x17d8f4,_0x1111be){var _0x4869c0={'raw':![],'where':{}};var _0x54edd9={};var _0x19f5bf={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x0976('0x64')]({'where':{'id':_0x5d5546['params']['id']}})['then'](handleEntityNotFound(_0x17d8f4,null))[_0x0976('0x31')](function(_0x4e1154){if(_0x4e1154){_0x54edd9[_0x0976('0x3e')]=_[_0x0976('0x40')](db[_0x0976('0x62')][_0x0976('0x52')]);_0x54edd9[_0x0976('0x3f')]=_[_0x0976('0x40')](_0x5d5546['query']);_0x54edd9[_0x0976('0x41')]=_[_0x0976('0x42')](_0x54edd9[_0x0976('0x3e')],_0x54edd9[_0x0976('0x3f')]);_0x4869c0[_0x0976('0x44')]=_[_0x0976('0x42')](_0x54edd9[_0x0976('0x3e')],qs['fields'](_0x5d5546['query'][_0x0976('0x43')]));_0x4869c0[_0x0976('0x44')]=_0x4869c0[_0x0976('0x44')][_0x0976('0x45')]?_0x4869c0[_0x0976('0x44')]:_0x54edd9[_0x0976('0x3e')];if(!_0x5d5546[_0x0976('0x3f')][_0x0976('0x46')](_0x0976('0x47'))){_0x4869c0['limit']=qs[_0x0976('0x2c')](_0x5d5546['query'][_0x0976('0x2c')]);_0x4869c0[_0x0976('0x2b')]=qs['offset'](_0x5d5546['query']['offset']);}_0x4869c0[_0x0976('0x65')]=qs[_0x0976('0x48')](_0x5d5546['query']['sort']);_0x4869c0[_0x0976('0x49')]=qs['filters'](_['pick'](_0x5d5546[_0x0976('0x3f')],_0x54edd9[_0x0976('0x41')]));_0x4869c0[_0x0976('0x49')][_0x0976('0x61')]=_0x4e1154['id'];if(_0x5d5546['query'][_0x0976('0x4b')]){_0x4869c0[_0x0976('0x49')]=_[_0x0976('0x4c')](_0x4869c0[_0x0976('0x49')],{'$or':_[_0x0976('0x39')](_0x4869c0[_0x0976('0x44')],function(_0x245bb6){var _0x588c5b={};_0x588c5b[_0x245bb6]={'$like':'%'+_0x5d5546[_0x0976('0x3f')][_0x0976('0x4b')]+'%'};return _0x588c5b;})});}_0x4869c0=_[_0x0976('0x4c')]({},_0x4869c0,_0x5d5546[_0x0976('0x4d')]);return db[_0x0976('0x62')][_0x0976('0x2a')]({'where':_0x4869c0['where']})['then'](function(_0x144961){_0x19f5bf[_0x0976('0x2a')]=_0x144961;if(_0x5d5546[_0x0976('0x3f')][_0x0976('0x4e')]){_0x4869c0['include']=[{'all':!![]}];}return db[_0x0976('0x62')][_0x0976('0x66')](_0x4869c0);})['then'](function(_0xfbafb2){_0x19f5bf['rows']=_0xfbafb2;return _0x19f5bf;});}})[_0x0976('0x31')](respondWithFilteredResult(_0x17d8f4,_0x4869c0))[_0x0976('0x54')](handleError(_0x17d8f4,null));};exports[_0x0976('0x67')]=function(_0x42271d,_0x2b271c,_0x5f3d5c){return db[_0x0976('0x3a')][_0x0976('0x53')]({'where':{'id':_0x42271d['params']['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x2b271c,null))[_0x0976('0x31')](function(_0x5647f5){if(_0x5647f5){return _0x5647f5[_0x0976('0x67')](_0x42271d[_0x0976('0x3f')]['ids']);}})[_0x0976('0x31')](respondWithStatusCode(_0x2b271c,null))['catch'](handleError(_0x2b271c,null));};exports['addAnswer']=function(_0x29601c,_0x2a26a0,_0x3c117e){if(_0x29601c[_0x0976('0x56')]['id']){delete _0x29601c[_0x0976('0x56')]['id'];}return db['ChatWebsite'][_0x0976('0x53')]({'where':{'id':_0x29601c[_0x0976('0x51')]['id']}})['then'](handleEntityNotFound(_0x2a26a0,null))[_0x0976('0x31')](function(_0x21bb79){if(_0x21bb79){_0x29601c[_0x0976('0x56')][_0x0976('0x61')]=_0x21bb79['id'];return db['CannedAnswer'][_0x0976('0x55')](_0x29601c['body']);}})[_0x0976('0x31')](respondWithResult(_0x2a26a0,null))[_0x0976('0x54')](handleError(_0x2a26a0,null));};exports[_0x0976('0x68')]=function(_0x11c7f3,_0x564def,_0x4bd819){var _0x447868={'raw':![],'where':{}};var _0x3b550a={};var _0x24d728={'count':0x0,'rows':[]};return db[_0x0976('0x3a')][_0x0976('0x64')]({'where':{'id':_0x11c7f3['params']['id']}})['then'](handleEntityNotFound(_0x564def,null))[_0x0976('0x31')](function(_0x2420a9){if(_0x2420a9){_0x3b550a['model']=_[_0x0976('0x40')](db[_0x0976('0x69')]['rawAttributes']);_0x3b550a[_0x0976('0x3f')]=_[_0x0976('0x40')](_0x11c7f3['query']);_0x3b550a[_0x0976('0x41')]=_['intersection'](_0x3b550a['model'],_0x3b550a[_0x0976('0x3f')]);_0x447868['attributes']=_[_0x0976('0x42')](_0x3b550a[_0x0976('0x3e')],qs[_0x0976('0x43')](_0x11c7f3[_0x0976('0x3f')]['fields']));_0x447868[_0x0976('0x44')]=_0x447868[_0x0976('0x44')][_0x0976('0x45')]?_0x447868[_0x0976('0x44')]:_0x3b550a[_0x0976('0x3e')];if(!_0x11c7f3['query'][_0x0976('0x46')](_0x0976('0x47'))){_0x447868[_0x0976('0x2c')]=qs[_0x0976('0x2c')](_0x11c7f3[_0x0976('0x3f')][_0x0976('0x2c')]);_0x447868[_0x0976('0x2b')]=qs[_0x0976('0x2b')](_0x11c7f3[_0x0976('0x3f')][_0x0976('0x2b')]);}_0x447868[_0x0976('0x65')]=qs[_0x0976('0x48')](_0x11c7f3[_0x0976('0x3f')][_0x0976('0x48')]);_0x447868['where']=qs[_0x0976('0x41')](_[_0x0976('0x4a')](_0x11c7f3[_0x0976('0x3f')],_0x3b550a[_0x0976('0x41')]));_0x447868[_0x0976('0x49')][_0x0976('0x61')]=_0x2420a9['id'];if(_0x11c7f3[_0x0976('0x3f')]['filter']){_0x447868[_0x0976('0x49')]=_[_0x0976('0x4c')](_0x447868[_0x0976('0x49')],{'$or':_[_0x0976('0x39')](_0x447868[_0x0976('0x44')],function(_0x379750){var _0x4963a1={};_0x4963a1[_0x379750]={'$like':'%'+_0x11c7f3['query'][_0x0976('0x4b')]+'%'};return _0x4963a1;})});}_0x447868=_['merge']({},_0x447868,_0x11c7f3[_0x0976('0x4d')]);return db[_0x0976('0x69')][_0x0976('0x2a')]({'where':_0x447868[_0x0976('0x49')]})[_0x0976('0x31')](function(_0x136a34){_0x24d728[_0x0976('0x2a')]=_0x136a34;if(_0x11c7f3['query'][_0x0976('0x4e')]){_0x447868[_0x0976('0x4f')]=[{'all':!![]}];}return db[_0x0976('0x69')][_0x0976('0x66')](_0x447868);})[_0x0976('0x31')](function(_0x44f978){_0x24d728['rows']=_0x44f978;return _0x24d728;});}})[_0x0976('0x31')](respondWithFilteredResult(_0x564def,_0x447868))['catch'](handleError(_0x564def,null));};exports[_0x0976('0x6a')]=function(_0x36a009,_0x5d5dba,_0x2d7211){return db[_0x0976('0x3a')][_0x0976('0x53')]({'where':{'id':_0x36a009[_0x0976('0x51')]['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x5d5dba,null))[_0x0976('0x31')](function(_0x1efff3){if(_0x1efff3){return _0x1efff3[_0x0976('0x6a')](_0x36a009[_0x0976('0x3f')][_0x0976('0x6b')]);}})[_0x0976('0x31')](respondWithStatusCode(_0x5d5dba,null))[_0x0976('0x54')](handleError(_0x5d5dba,null));};exports[_0x0976('0x6c')]=function(_0x38ae72,_0x4773a8,_0x58c6ae){_0x38ae72['body'][_0x0976('0x6d')]=_0x38ae72['file'][_0x0976('0x6e')];return db[_0x0976('0x3a')]['find']({'where':{'id':_0x38ae72['params']['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x4773a8,null))[_0x0976('0x31')](saveUpdates(_0x38ae72[_0x0976('0x56')],null))[_0x0976('0x31')](respondWithResult(_0x4773a8,null))[_0x0976('0x54')](handleError(_0x4773a8,null));};exports['addAvatar']=function(_0x5e23c1,_0x1b13fc,_0x23dff6){_0x5e23c1['body'][_0x0976('0x6f')]=_0x5e23c1['file'][_0x0976('0x6e')];return db[_0x0976('0x3a')][_0x0976('0x53')]({'where':{'id':_0x5e23c1[_0x0976('0x51')]['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x1b13fc,null))[_0x0976('0x31')](saveUpdates(_0x5e23c1[_0x0976('0x56')],null))['then'](respondWithResult(_0x1b13fc,null))['catch'](handleError(_0x1b13fc,null));};exports[_0x0976('0x70')]=function(_0xd6830d,_0x80ce9e,_0x582525){_0xd6830d[_0x0976('0x56')]['customerAvatar']=_0xd6830d[_0x0976('0x71')]['filename'];return db['ChatWebsite'][_0x0976('0x53')]({'where':{'id':_0xd6830d[_0x0976('0x51')]['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x80ce9e,null))[_0x0976('0x31')](saveUpdates(_0xd6830d['body'],null))[_0x0976('0x31')](respondWithResult(_0x80ce9e,null))['catch'](handleError(_0x80ce9e,null));};exports[_0x0976('0x72')]=function(_0x4b5a98,_0x44e4c4,_0x2cbb0e){_0x4b5a98['body'][_0x0976('0x73')]=_0x4b5a98[_0x0976('0x71')]['filename'];return db['ChatWebsite']['find']({'where':{'id':_0x4b5a98[_0x0976('0x51')]['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x44e4c4,null))[_0x0976('0x31')](saveUpdates(_0x4b5a98['body'],null))[_0x0976('0x31')](respondWithResult(_0x44e4c4,null))['catch'](handleError(_0x44e4c4,null));};exports[_0x0976('0x74')]=function(_0x1a393f,_0x8cffe8,_0x141e90){var _0x26410b=path[_0x0976('0x75')](config['root'],_0x0976('0x76'));var _0x323d49={'where':{'id':_0x1a393f[_0x0976('0x51')]['id']},'attributes':['id',_0x0976('0x6d')],'raw':!![]};var _0x5d8ed3=![];return require(_0x0976('0x18'))[_0x0976('0x77')]()[_0x0976('0x31')](function(_0xfb8392){if(_0xfb8392){_0x5d8ed3=_0xfb8392[_0x0976('0x78')];}})[_0x0976('0x31')](function(){return db[_0x0976('0x3a')][_0x0976('0x53')](_0x323d49);})[_0x0976('0x31')](handleEntityNotFound(_0x8cffe8,null))['then'](function(_0x317875){if(_0x317875){if(!_[_0x0976('0x79')](_0x317875[_0x0976('0x6d')])){if(fs[_0x0976('0x7a')](path[_0x0976('0x75')](config[_0x0976('0x7b')],'server/files/images/logos/',_0x317875['sitepic']))&&_0x5d8ed3){_0x26410b=path[_0x0976('0x75')](config[_0x0976('0x7b')],'server/files/images/logos/',_0x317875['sitepic']);}}return _0x8cffe8[_0x0976('0x7c')](_0x26410b);}})[_0x0976('0x54')](handleError(_0x8cffe8,null));};exports[_0x0976('0x7d')]=function(_0x8d5e53,_0x3a9e80,_0x37205c){var _0x2ae3d3=path[_0x0976('0x75')](config[_0x0976('0x7b')],_0x0976('0x7e'));var _0x92c749={'where':{'id':_0x8d5e53['params']['id']},'attributes':['id','agentAvatar'],'raw':!![]};return db['ChatWebsite']['find'](_0x92c749)[_0x0976('0x31')](handleEntityNotFound(_0x3a9e80,null))[_0x0976('0x31')](function(_0x21e7b8){if(_0x21e7b8){if(!_[_0x0976('0x79')](_0x21e7b8[_0x0976('0x6f')])){if(fs[_0x0976('0x7a')](path[_0x0976('0x75')](config[_0x0976('0x7b')],_0x0976('0x7f'),_0x21e7b8[_0x0976('0x6f')]))){_0x2ae3d3=path[_0x0976('0x75')](config[_0x0976('0x7b')],_0x0976('0x7f'),_0x21e7b8[_0x0976('0x6f')]);}}return _0x3a9e80[_0x0976('0x7c')](_0x2ae3d3);}})[_0x0976('0x54')](handleError(_0x3a9e80,null));};exports[_0x0976('0x80')]=function(_0x601c59,_0x521b81,_0x42bad6){var _0x5bea97=path['join'](config[_0x0976('0x7b')],_0x0976('0x81'));var _0x28a9e0={'where':{'id':_0x601c59['params']['id']},'attributes':['id',_0x0976('0x82'),_0x0976('0x83')],'raw':!![]};return db[_0x0976('0x3a')][_0x0976('0x53')](_0x28a9e0)[_0x0976('0x31')](handleEntityNotFound(_0x521b81,null))['then'](function(_0x46aaac){if(_0x46aaac){if(!_[_0x0976('0x79')](_0x46aaac['customerAvatar'])){if(fs[_0x0976('0x7a')](path[_0x0976('0x75')](config[_0x0976('0x7b')],_0x0976('0x7f'),_0x46aaac['customerAvatar']))&&_0x46aaac[_0x0976('0x83')]){_0x5bea97=path[_0x0976('0x75')](config[_0x0976('0x7b')],_0x0976('0x7f'),_0x46aaac[_0x0976('0x82')]);}}return _0x521b81['download'](_0x5bea97);}})[_0x0976('0x54')](handleError(_0x521b81,null));};exports[_0x0976('0x84')]=function(_0x5935dd,_0xc59a8b,_0x5a04d0){var _0x55abc3=path[_0x0976('0x75')](config[_0x0976('0x7b')],_0x0976('0x85'));var _0x57b03={'where':{'id':_0x5935dd[_0x0976('0x51')]['id']},'attributes':['id',_0x0976('0x73')],'raw':!![]};return db[_0x0976('0x3a')][_0x0976('0x53')](_0x57b03)[_0x0976('0x31')](handleEntityNotFound(_0xc59a8b,null))[_0x0976('0x31')](function(_0x2e56bd){if(_0x2e56bd){if(!_['isNil'](_0x2e56bd['systemAvatar'])){if(fs['existsSync'](path[_0x0976('0x75')](config[_0x0976('0x7b')],_0x0976('0x7f'),_0x2e56bd[_0x0976('0x73')]))){_0x55abc3=path[_0x0976('0x75')](config[_0x0976('0x7b')],_0x0976('0x7f'),_0x2e56bd[_0x0976('0x73')]);}}return _0xc59a8b['download'](_0x55abc3);}})[_0x0976('0x54')](handleError(_0xc59a8b,null));};exports[_0x0976('0x86')]=function(_0x2034e8,_0x122fa9,_0xd9524d){var _0x3aafed=require(_0x0976('0x87'));var _0xaadeeb=new _0x3aafed();var _0x3fade8=_0xaadeeb['setUA'](_0x2034e8['headers']['user-agent'])[_0x0976('0x88')]();var _0x1847c1={'body':_0x2034e8['body'],'channel':_0x0976('0x89')};var _0x2bbb21=[];var _0x261fc2=[];var _0xa6786d={};var _0x43ddcc=![];return db[_0x0976('0x8a')][_0x0976('0x5f')]()['then'](function(_0x264c75){if(!_0x264c75){throw new db[(_0x0976('0x8b'))][(_0x0976('0x8c'))](_0x0976('0x8d'));}_0x2bbb21=_[_0x0976('0x8e')](_['keys'](_0x264c75),['createdAt',_0x0976('0x8f')]);_0x261fc2=_[_0x0976('0x8e')](_[_0x0976('0x40')](_0x264c75),['createdAt','updatedAt',_0x0976('0x90'),_0x0976('0x91')]);if(_0x2034e8['body']['id']){delete _0x2034e8[_0x0976('0x56')]['id'];}if(_[_0x0976('0x79')](_0x2034e8['body'][_0x0976('0x92')])){throw new db[(_0x0976('0x8b'))]['ValidationError'](_0x0976('0x93'));}if(_[_0x0976('0x79')](_0x2034e8[_0x0976('0x56')]['body'])||_0x2034e8[_0x0976('0x56')][_0x0976('0x56')]===''){throw new db[(_0x0976('0x8b'))][(_0x0976('0x8c'))](_0x0976('0x94'));}if(_[_0x0976('0x79')](_0x2034e8[_0x0976('0x56')][_0x0976('0x95')])){throw new db[(_0x0976('0x8b'))][(_0x0976('0x8c'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x261fc2);}if(!_[_0x0976('0x96')](_0x261fc2,_0x2034e8[_0x0976('0x56')][_0x0976('0x95')])){throw new db[(_0x0976('0x8b'))][(_0x0976('0x8c'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x261fc2);}_0xa6786d[_0x2034e8[_0x0976('0x56')][_0x0976('0x95')]]=_0x2034e8[_0x0976('0x56')][_0x0976('0x92')];})[_0x0976('0x31')](function(){return db[_0x0976('0x3a')][_0x0976('0x53')]({'where':{'id':_0x2034e8[_0x0976('0x51')]['id']},'include':[{'model':db[_0x0976('0x97')],'as':'List','include':[{'model':db[_0x0976('0x8a')],'as':_0x0976('0x98'),'where':_0xa6786d,'limit':0x1,'order':[['updatedAt',_0x0976('0x99')]]}]},{'model':db[_0x0976('0x9a')],'as':_0x0976('0x9b')}]});})[_0x0976('0x31')](handleEntityNotFound(_0x122fa9,null))['then'](function(_0x5c4a70){if(_0x5c4a70&&_0x5c4a70[_0x0976('0x9c')]){_0x1847c1[_0x0976('0x9d')]=_0x5c4a70;_0x1847c1[_0x0976('0x9e')]=_0x5c4a70[_0x0976('0x9b')];_0x1847c1[_0x0976('0x9f')]=_0x5c4a70[_0x0976('0x9c')];_0x1847c1['applications']=_[_0x0976('0xa0')](_0x1847c1[_0x0976('0x9e')],[_0x0976('0xa1')],[_0x0976('0xa2')]);if(_0x1847c1['account']['Applications']){delete _0x1847c1[_0x0976('0x9d')][_0x0976('0x9b')];}if(_0x1847c1[_0x0976('0x9d')][_0x0976('0x9c')]&&_0x1847c1[_0x0976('0x9d')][_0x0976('0x9c')][_0x0976('0x98')]['length']){return _0x1847c1[_0x0976('0x9d')][_0x0976('0x9c')][_0x0976('0x98')][0x0];}var _0x1e1764=_['defaults'](_0x2034e8['body'],{'firstName':_0x2034e8[_0x0976('0x56')]['from'],'ListId':_0x5c4a70[_0x0976('0x91')]});_0x1e1764[_0x2034e8[_0x0976('0x56')][_0x0976('0x95')]]=_0x2034e8[_0x0976('0x56')]['from'];return db[_0x0976('0x8a')][_0x0976('0x55')](_0x1e1764,{'fields':_0x2bbb21,'raw':!![]});}})[_0x0976('0x31')](handleEntityNotFound(_0x122fa9,null))[_0x0976('0x31')](function(_0x8174a4){_0x1847c1[_0x0976('0xa3')]=_0x8174a4;var _0x1554e9=_0x2034e8['body']['customerIp'];if(_0x2034e8[_0x0976('0xa4')][_0x0976('0xa5')]){_0x1554e9=_0x2034e8[_0x0976('0xa4')][_0x0976('0xa5')];}else if(_0x2034e8[_0x0976('0xa4')][_0x0976('0xa6')]){_0x1554e9=_[_0x0976('0xa7')](_0x2034e8[_0x0976('0xa4')][_0x0976('0xa6')][_0x0976('0xa8')](','));}if(_0x8174a4){var _0x8dc43b={'ContactId':_0x8174a4['id'],'ChatWebsiteId':_0x2034e8[_0x0976('0x51')]['id'],'from':(_0x8174a4[_0x0976('0xa9')]||'')+'\x20'+(_0x8174a4[_0x0976('0xaa')]||''),'customerIp':_0x1554e9,'customerPort':_0x2034e8[_0x0976('0xa4')][_0x0976('0xab')]?_0x2034e8[_0x0976('0xa4')][_0x0976('0xab')]:null,'referer':_0x2034e8[_0x0976('0x56')][_0x0976('0xac')],'browserName':_0x3fade8[_0x0976('0xad')][_0x0976('0x34')]&&_0x3fade8[_0x0976('0xad')][_0x0976('0xae')]?util[_0x0976('0xaf')]('%s\x20%s',_0x3fade8[_0x0976('0xad')]['name'],_0x3fade8[_0x0976('0xad')]['version']):_0x0976('0xb0'),'browserVersion':_0x3fade8[_0x0976('0xad')][_0x0976('0xae')]||'unknown','osName':util['format'](_0x0976('0xb1'),_0x3fade8['os'][_0x0976('0x34')],_0x3fade8['os'][_0x0976('0xae')]),'osVersion':_0x3fade8['os']['version'],'deviceModel':_0x3fade8[_0x0976('0xb2')][_0x0976('0x3e')]&&_0x3fade8[_0x0976('0xb2')][_0x0976('0xb3')]?util[_0x0976('0xaf')](_0x0976('0xb4'),_0x3fade8[_0x0976('0xb2')][_0x0976('0x3e')],_0x3fade8['device'][_0x0976('0xb3')],_0x3fade8['device'][_0x0976('0x3c')]):null,'deviceVendor':_0x3fade8[_0x0976('0xb2')][_0x0976('0xb3')],'deviceType':_0x3fade8[_0x0976('0xb2')][_0x0976('0x3c')],'formData':JSON[_0x0976('0xb5')](_0x2034e8[_0x0976('0x56')])};var _0x559637={'ChatWebsiteId':_0x2034e8[_0x0976('0x51')]['id'],'closed':![]};if(_0x2034e8['body'][_0x0976('0xb6')]){_0x559637[_0x0976('0xb6')]=_0x2034e8['body'][_0x0976('0xb6')];return db['ChatInteraction']['find']({'where':_0x559637})[_0x0976('0x31')](function(_0x53970a){if(_0x53970a){return[_0x53970a,![]];}_0x8dc43b[_0x0976('0xb6')]=_0x2034e8[_0x0976('0x56')]['threadId'];_0x8dc43b[_0x0976('0xb7')]=_0x2034e8[_0x0976('0x56')][_0x0976('0xb7')];return db[_0x0976('0xb8')]['create'](_0x8dc43b)[_0x0976('0x31')](function(_0x319bec){return[_0x319bec,!![]];});});}_0x559637[_0x0976('0xb9')]=_0x8174a4['id'];if(_0x2034e8['body'][_0x0976('0xba')]&&_0x2034e8[_0x0976('0x56')][_0x0976('0xba')]['id']){_0x559637['id']=_0x2034e8[_0x0976('0x56')]['interaction']['id'];return db[_0x0976('0xb8')][_0x0976('0x53')]({'where':_0x559637})['then'](function(_0x51f574){if(_0x51f574){return[_0x51f574,![]];}return db[_0x0976('0xb8')][_0x0976('0x55')](_0x8dc43b)['then'](function(_0x2d757e){return[_0x2d757e,!![]];});});}return db[_0x0976('0xb8')][_0x0976('0x55')](_0x8dc43b)['then'](function(_0x72f5fa){return[_0x72f5fa,!![]];});}})['spread'](function(_0xc88a14,_0x23176f){if(_0xc88a14){_0x43ddcc=_0x23176f;if(!_0x23176f){var _0x32552c={'from':(_0x1847c1['contact'][_0x0976('0xa9')]||'')+'\x20'+(_0x1847c1[_0x0976('0xa3')][_0x0976('0xaa')]||'')};if(_0x2034e8[_0x0976('0x56')][_0x0976('0xb6')]&&_0x2034e8[_0x0976('0x56')][_0x0976('0xbb')]&&_0x2034e8[_0x0976('0x56')][_0x0976('0xb6')]!=_0x2034e8[_0x0976('0x56')][_0x0976('0xbb')]){_0x32552c[_0x0976('0xb6')]=_0x2034e8[_0x0976('0x56')]['messageId'];}return _0xc88a14[_0x0976('0x30')](_0x32552c);}else{return _0xc88a14;}}})[_0x0976('0x31')](function(_0x3c522c){_0x1847c1[_0x0976('0xba')]=_0x3c522c[_0x0976('0x58')]({'plain':!![]});_0x1847c1['interaction'][_0x0976('0xbc')]=_0x43ddcc;if(_0x1847c1[_0x0976('0xba')][_0x0976('0xbc')]){if(_0x1847c1[_0x0976('0x9d')][_0x0976('0xbd')]){_0x1847c1[_0x0976('0x9e')][_0x0976('0xbe')]({'id':0x0,'priority':_0x1847c1[_0x0976('0x9e')][_0x0976('0x45')]+0x1,'app':'close','appdata':_0x0976('0xbf'),'interval':_0x0976('0xc0')});}}return db[_0x0976('0xc1')][_0x0976('0x55')]({'body':_0x2034e8[_0x0976('0x56')][_0x0976('0x56')],'ChatWebsiteId':_0x2034e8['params']['id'],'ChatInteractionId':_0x3c522c['id'],'direction':'in','ContactId':_0x1847c1['contact']['id'],'AttachmentId':_0x2034e8[_0x0976('0x56')][_0x0976('0xc2')]});})[_0x0976('0x31')](function(_0x266d54){_0x1847c1[_0x0976('0x26')]=_0x266d54;if(_0x1847c1[_0x0976('0xba')][_0x0976('0xc3')]){return db[_0x0976('0xc4')][_0x0976('0x53')]({'attributes':['id',_0x0976('0x34')],'where':{'id':_0x1847c1[_0x0976('0xba')][_0x0976('0xc3')]}})[_0x0976('0x31')](function(_0x2f8a89){if(_0x2f8a89){_0x1847c1[_0x0976('0x9e')]['unshift']({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x2f8a89[_0x0976('0x34')]+','+(_0x1847c1[_0x0976('0x9d')][_0x0976('0xc5')]||0xa),'interval':_0x0976('0xc0')});_0x1847c1[_0x0976('0xc6')]=!![];}return respondWithRpcPromise('Start',_0x0976('0xc7'),_0x1847c1);});}return respondWithRpcPromise('Start',_0x0976('0xc7'),_0x1847c1);})[_0x0976('0x31')](function(_0x3d0d3f){respondWithRpcPromise(_0x0976('0xc8'),_0x0976('0xc8'),{'event':'notify','message':_0x3d0d3f},client9002);return _0x3d0d3f;})['then'](respondWithResult(_0x122fa9,null))[_0x0976('0x54')](handleError(_0x122fa9,null));};exports['offline']=function(_0x156b46,_0x541ace,_0x24d792){var _0x1dce51,_0x2513a0,_0x4c945b;var _0x7e61a4=[];var _0x47f2db=[];var _0x30ac68={};return db[_0x0976('0x8a')][_0x0976('0x5f')]()['then'](function(_0x49415b){if(!_0x49415b){throw new db['Sequelize']['ValidationError'](_0x0976('0x8d'));}_0x47f2db=_[_0x0976('0x8e')](_[_0x0976('0x40')](_0x49415b),['createdAt',_0x0976('0x8f')]);_0x7e61a4=_[_0x0976('0x8e')](_[_0x0976('0x40')](_0x49415b),[_0x0976('0xc9'),_0x0976('0x8f'),_0x0976('0x90'),'ListId']);if(_0x156b46[_0x0976('0x56')]['id']){delete _0x156b46[_0x0976('0x56')]['id'];}if(_[_0x0976('0x79')](_0x156b46[_0x0976('0x56')][_0x0976('0x92')])){throw _0x541ace[_0x0976('0x28')](0x1f4)[_0x0976('0x35')](new db[(_0x0976('0x8b'))][(_0x0976('0x8c'))](_0x0976('0x93')));}if(_[_0x0976('0x79')](_0x156b46[_0x0976('0x56')]['body'])||_0x156b46[_0x0976('0x56')][_0x0976('0x56')]===''){throw _0x541ace[_0x0976('0x28')](0x1f4)['send'](new db[(_0x0976('0x8b'))][(_0x0976('0x8c'))](_0x0976('0x94')));}if(_[_0x0976('0x79')](_0x156b46[_0x0976('0x56')][_0x0976('0xca')])){throw _0x541ace[_0x0976('0x28')](0x1f4)[_0x0976('0x35')](new db[(_0x0976('0x8b'))]['ValidationError'](_0x0976('0xcb')+_0x7e61a4));}if(!_[_0x0976('0x96')](_0x7e61a4,_0x156b46[_0x0976('0x56')][_0x0976('0xca')])){throw _0x541ace[_0x0976('0x28')](0x1f4)[_0x0976('0x35')](new db['Sequelize'][(_0x0976('0x8c'))](_0x0976('0xcc')+_0x7e61a4));}_0x30ac68[_0x156b46[_0x0976('0x56')][_0x0976('0xca')]]=_0x156b46[_0x0976('0x56')]['from'];})[_0x0976('0x31')](function(){return db[_0x0976('0x3a')][_0x0976('0x53')]({'where':{'id':_0x156b46[_0x0976('0x51')]['id']},'include':[{'model':db[_0x0976('0x97')],'as':_0x0976('0x9c')}]});})[_0x0976('0x31')](handleEntityNotFound(_0x541ace,null))[_0x0976('0x31')](function(_0x522ca5){if(_0x522ca5&&_0x522ca5['List']){_0x2513a0=_0x522ca5;var _0x22800b=_[_0x0976('0x1b')](_0x156b46[_0x0976('0x56')],{'firstName':_0x156b46[_0x0976('0x56')][_0x0976('0x92')],'phone':_0x156b46[_0x0976('0x56')][_0x0976('0x92')],'ListId':_0x522ca5[_0x0976('0x91')]});_0x22800b[_0x156b46[_0x0976('0x56')][_0x0976('0xca')]]=_0x156b46[_0x0976('0x56')][_0x0976('0x92')];return db[_0x0976('0x8a')][_0x0976('0xcd')]({'where':_0x30ac68,'defaults':_0x22800b});}})[_0x0976('0xce')](function(_0x32c532){if(_0x32c532){_0x4c945b=_0x32c532;var _0x45893f=fs[_0x0976('0xcf')](path['join'](config['root'],_0x0976('0xd0')),_0x0976('0xd1'));var _0x26d4f7=ejs[_0x0976('0xd2')](_0x45893f,{'body':_[_0x0976('0xd3')](_0x156b46['body'][_0x0976('0x56')]),'bodyTitle':_0x2513a0[_0x0976('0xd4')]});return db[_0x0976('0xd5')][_0x0976('0x55')]({'body':_0x26d4f7,'ContactId':_0x32c532['id'],'ChatWebsiteId':_0x2513a0['id']});}})[_0x0976('0x31')](function(_0x3f573b){if(_0x3f573b){_0x1dce51=_0x3f573b;return db[_0x0976('0xd6')]['findOne']({'where':{'service':!![]},'include':[{'model':db[_0x0976('0xd7')],'as':'Smtp','raw':!![]}]});}})[_0x0976('0x31')](function(_0x2cfba4){if(_0x2cfba4&&_0x2cfba4['Smtp']&&_0x2513a0['forwardOfflineAddress']){var _0x2775b8={'tls':{'rejectUnauthorized':![]}};if(_0x2cfba4['Smtp'][_0x0976('0xd8')]){_0x2775b8[_0x0976('0xd8')]=_0x2cfba4[_0x0976('0xd9')][_0x0976('0xd8')];}else{_0x2775b8['host']=_0x2cfba4[_0x0976('0xd9')][_0x0976('0xda')];_0x2775b8[_0x0976('0xdb')]=_0x2cfba4['Smtp'][_0x0976('0xdb')];_0x2775b8[_0x0976('0xdc')]=_0x2cfba4[_0x0976('0xd9')][_0x0976('0xdc')];}if(_0x2cfba4[_0x0976('0xd9')][_0x0976('0xdd')]){_0x2775b8['auth']={'user':_0x2cfba4[_0x0976('0xd9')][_0x0976('0x57')],'pass':_0x2cfba4['Smtp'][_0x0976('0xde')]};}return respondWithRpcPromise('SendMail',_0x0976('0xdf'),{'account':_0x2775b8,'message':{'from':util[_0x0976('0xaf')]('\x22%s\x22\x20<%s>',_0x2cfba4[_0x0976('0x34')],_0x2cfba4[_0x0976('0xe0')]||_0x2cfba4[_0x0976('0xd9')][_0x0976('0x57')]),'to':_0x2513a0[_0x0976('0xe1')],'subject':_0x2513a0[_0x0976('0xe2')],'text':_0x1dce51['body']}},client9003)['then'](function(){return _0x1dce51;})[_0x0976('0x54')](function(_0x44bb0a){console[_0x0976('0x25')](_0x44bb0a);});}})[_0x0976('0x31')](function(){if(_0x1dce51){return _0x1dce51;}})[_0x0976('0x31')](respondWithResult(_0x541ace,null))[_0x0976('0x54')](handleError(_0x541ace,null));};exports[_0x0976('0xe3')]=function(_0x2346ca,_0x321b7,_0x10089f){return db['ChatInteraction']['find']({'where':{'id':_0x2346ca[_0x0976('0x51')]['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x321b7,null))['then'](function(_0x171f86){if(_0x171f86){return _0x171f86[_0x0976('0xe3')](_0x2346ca[_0x0976('0x56')][_0x0976('0x6b')],_['omit'](_0x2346ca[_0x0976('0x56')],[_0x0976('0x6b'),'id'])||{});}})[_0x0976('0x31')](respondWithResult(_0x321b7,null))[_0x0976('0x54')](handleError(_0x321b7,null));};exports[_0x0976('0xe4')]=function(_0x1e3a26,_0x32d346,_0x17147c){var _0x43a371={'raw':![],'where':{}};var _0x1037ee={};var _0x13cf73={'count':0x0,'rows':[]};return db[_0x0976('0x3a')]['findOne']({'where':{'id':_0x1e3a26[_0x0976('0x51')]['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x32d346,null))[_0x0976('0x31')](function(_0x4e809c){if(_0x4e809c){_0x1037ee[_0x0976('0x3e')]=_[_0x0976('0x40')](db[_0x0976('0xb8')][_0x0976('0x52')]);_0x1037ee[_0x0976('0x3f')]=_['keys'](_0x1e3a26['query']);_0x1037ee[_0x0976('0x41')]=_[_0x0976('0x42')](_0x1037ee[_0x0976('0x3e')],_0x1037ee[_0x0976('0x3f')]);_0x43a371[_0x0976('0x44')]=_[_0x0976('0x42')](_0x1037ee[_0x0976('0x3e')],qs[_0x0976('0x43')](_0x1e3a26[_0x0976('0x3f')][_0x0976('0x43')]));_0x43a371[_0x0976('0x44')]=_0x43a371[_0x0976('0x44')][_0x0976('0x45')]?_0x43a371[_0x0976('0x44')]:_0x1037ee[_0x0976('0x3e')];if(!_0x1e3a26['query']['hasOwnProperty'](_0x0976('0x47'))){_0x43a371[_0x0976('0x2c')]=qs[_0x0976('0x2c')](_0x1e3a26[_0x0976('0x3f')]['limit']);_0x43a371[_0x0976('0x2b')]=qs[_0x0976('0x2b')](_0x1e3a26[_0x0976('0x3f')][_0x0976('0x2b')]);}_0x43a371[_0x0976('0x65')]=qs[_0x0976('0x48')](_0x1e3a26[_0x0976('0x3f')][_0x0976('0x48')]);_0x43a371[_0x0976('0x49')]=qs[_0x0976('0x41')](_['pick'](_0x1e3a26[_0x0976('0x3f')],_0x1037ee[_0x0976('0x41')]));_0x43a371[_0x0976('0x49')]['ChatWebsiteId']=_0x4e809c['id'];if(_0x1e3a26[_0x0976('0x3f')]['filter']){_0x43a371[_0x0976('0x49')]=_[_0x0976('0x4c')](_0x43a371[_0x0976('0x49')],{'$or':_[_0x0976('0x39')](_0x43a371[_0x0976('0x44')],function(_0x3d60fb){var _0x39800b={};_0x39800b[_0x3d60fb]={'$like':'%'+_0x1e3a26[_0x0976('0x3f')][_0x0976('0x4b')]+'%'};return _0x39800b;})});}_0x43a371=_[_0x0976('0x4c')]({},_0x43a371,_0x1e3a26['options']);return db['ChatInteraction'][_0x0976('0x2a')]({'where':_0x43a371['where']})['then'](function(_0x4f35d2){_0x13cf73[_0x0976('0x2a')]=_0x4f35d2;if(_0x1e3a26[_0x0976('0x3f')][_0x0976('0x4e')]){_0x43a371[_0x0976('0x4f')]=[{'model':db[_0x0976('0x8a')],'as':_0x0976('0xe5'),'required':![]},{'model':db[_0x0976('0xc4')],'as':_0x0976('0xe6'),'attributes':[_0x0976('0x34'),_0x0976('0xe7'),'internal'],'required':![]},{'model':db[_0x0976('0xe8')],'as':_0x0976('0xe9'),'attributes':['id','name','color'],'where':_0x1e3a26[_0x0976('0x3f')][_0x0976('0xea')]?{'id':_0x1e3a26[_0x0976('0x3f')][_0x0976('0xea')]}:undefined,'required':_0x1e3a26['query'][_0x0976('0xea')]?!![]:![]}];}return db[_0x0976('0xb8')][_0x0976('0x66')](_0x43a371);})[_0x0976('0x31')](function(_0x3be106){_0x13cf73[_0x0976('0x50')]=_0x3be106;return _0x13cf73;});}})['then'](respondWithFilteredResult(_0x32d346,_0x43a371))['catch'](handleError(_0x32d346,null));};function iftimePromise(_0x3dde9a,_0x4381f4){return respondWithRpcPromise(_0x0976('0xeb'),'getSnippet',{'command':_0x4381f4[_0x0976('0xec')]?util[_0x0976('0xaf')]('iftime\x20%s,%s',_0x3dde9a[_0x0976('0xed')],_0x4381f4[_0x0976('0xec')]):util[_0x0976('0xaf')](_0x0976('0xee'),_0x3dde9a[_0x0976('0xed')])},client9002)[_0x0976('0x31')](function(_0x4cb2d8){var _0xf5f455=_0x4cb2d8&&_0x4cb2d8['indexOf'](_0x0976('0xef'))>=0x0?!![]:![];logger['info'](_0x0976('0xf0'),_0x4381f4['id'],_0x3dde9a['id'],_0x3dde9a[_0x0976('0xed')],_0xf5f455?'ONLINE':_0x0976('0xf1'),_0x4381f4[_0x0976('0xec')]?_0x4381f4['timezone']:'No\x20timezone');return _0xf5f455;})[_0x0976('0x54')](function(_0xb684ac){logger[_0x0976('0x25')]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x4381f4['id'],_0x3dde9a['id'],_0x3dde9a[_0x0976('0xed')],util['inspect'](_0xb684ac,{'showHidden':![],'depth':null}),_0x4381f4[_0x0976('0xec')]?_0x4381f4[_0x0976('0xec')]:'No\x20timezone');return![];});}exports['getSnippet']=function(_0x3b32ff,_0x576dc0,_0x49116c){var _0x4d754d=0x0;var _0x22842c=0x0;var _0x33edc3=![];var _0x41336f;var _0x557024;return db[_0x0976('0x3a')][_0x0976('0x53')]({'where':{'id':_0x3b32ff['params']['id']},'include':[{'model':db[_0x0976('0xf2')],'as':'Interval','include':[{'model':db[_0x0976('0xf2')],'as':_0x0976('0xf3'),'attributes':['id',_0x0976('0xed')],'raw':!![]}]}]})[_0x0976('0x31')](handleEntityNotFound(_0x576dc0,null))[_0x0976('0x31')](function(_0x452a98){if(_0x452a98){_0x41336f=_0x452a98;return _0x452a98[_0x0976('0xf4')]({'raw':!![]});}})[_0x0976('0x31')](function(_0x1746d8){if(_0x41336f){if(_0x1746d8){_0x557024=_0x1746d8;}}return require(_0x0976('0x18'))[_0x0976('0x77')]();})['then'](function(_0x37b3e4){if(_0x37b3e4){_0x22842c=_0x37b3e4['virtual'];_0x33edc3=_0x37b3e4[_0x0976('0x78')];}})[_0x0976('0x31')](function(){return db[_0x0976('0xb8')]['count']({'where':{'closed':![]}});})[_0x0976('0x31')](function(_0x2f2fb3){_0x4d754d=_0x2f2fb3;if(_0x22842c&&_0x2f2fb3>_0x22842c){return db[_0x0976('0xf5')][_0x0976('0x64')]({'where':{'id':0x1}})[_0x0976('0x31')](function(_0x55cf9f){if(_0x55cf9f){_0x55cf9f[_0x0976('0xf6')]('chatLicenseExceeded');}});}})[_0x0976('0x31')](function(){if(_0x41336f['Interval']&&_0x41336f['Interval']['Intervals']){var _0x40d63a=[];for(var _0x46c130=0x0;_0x46c130<_0x41336f[_0x0976('0xf2')][_0x0976('0xf3')][_0x0976('0x45')];_0x46c130++){var _0x2469cb=_0x41336f['Interval'][_0x0976('0xf3')][_0x46c130]['get']({'plain':!![]});_0x40d63a['push'](iftimePromise(_0x2469cb,_0x41336f));}return BPromise['all'](_0x40d63a)[_0x0976('0x31')](function(_0x4e163b){return _['some'](_0x4e163b);});}else{return!![];}})['then'](function(_0x5b9ca2){var _0x893c27=fs[_0x0976('0xcf')](path[_0x0976('0x75')](config[_0x0976('0x7b')],'server/files/chat/iframe.js'),'utf8');var _0x172638={'remote':_0x41336f[_0x0976('0xf7')],'query':querystring[_0x0976('0xb5')](_[_0x0976('0x4c')](_0x41336f[_0x0976('0x58')]({'plain':!![]}),{'customerIp':_0x3b32ff[_0x0976('0xa4')][_0x0976('0xa6')]||_0x3b32ff[_0x0976('0xa4')][_0x0976('0xf8')]||_0x3b32ff['connection'][_0x0976('0xf9')]||_0x3b32ff['ip'],'referer':_0x3b32ff[_0x0976('0xa4')]['referer'],'openedInteractions':_0x4d754d,'maxInteractions':_0x22842c,'virtual':_0x33edc3[_0x0976('0xfa')],'online':_0x5b9ca2,'custom':_0x33edc3}))['replace'](/'/g,'\x5c\x27')};_0x576dc0[_0x0976('0x35')](ejs['render'](Mustache[_0x0976('0xd2')](_0x893c27,_0x172638),{'proactiveActions':_0x557024,'alignment':_0x41336f[_0x0976('0xfb')],'verticalAlignment':_0x41336f[_0x0976('0xfc')],'div_color':_0x41336f['color'],'text_color':_0x41336f[_0x0976('0xfd')]}));})[_0x0976('0x54')](handleError(_0x576dc0,null));};exports[_0x0976('0xfe')]=function(_0x4d93d8,_0xc6a2a8,_0x327a65){return db[_0x0976('0x3a')]['findOne']({'where':{'id':_0x4d93d8[_0x0976('0x51')]['id']}})[_0x0976('0x31')](handleEntityNotFound(_0xc6a2a8,null))[_0x0976('0x31')](function(_0x14d6f3){if(_0x14d6f3){return db[_0x0976('0xff')][_0x0976('0x100')](function(_0x2218d4){return db[_0x0976('0x9a')][_0x0976('0x32')]({'where':{'ChatWebsiteId':_0x4d93d8[_0x0976('0x51')]['id']},'transaction':_0x2218d4})[_0x0976('0x31')](function(_0x3afcc0){var _0xc86fc7=_['map'](_0x4d93d8[_0x0976('0x56')],function(_0x13618c){_0x13618c[_0x0976('0x61')]=_0x4d93d8[_0x0976('0x51')]['id'];return _0x13618c;});return db['ChatApplication']['bulkCreate'](_0xc86fc7,{'transaction':_0x2218d4});});})[_0x0976('0x31')](function(){return db[_0x0976('0x9a')][_0x0976('0x101')]({'where':{'ChatWebsiteId':_0x4d93d8[_0x0976('0x51')]['id']},'order':_0x0976('0xa1')});});}})['then'](respondWithResult(_0xc6a2a8,null))['catch'](handleError(_0xc6a2a8,null));};exports[_0x0976('0x102')]=function(_0x1cfabd,_0x3d3035,_0x32c5a9){var _0x125216={};var _0x39c995={};var _0x3500e0;var _0x261b21;return db[_0x0976('0x3a')][_0x0976('0x64')]({'where':{'id':_0x1cfabd[_0x0976('0x51')]['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x3d3035,null))['then'](function(_0x20a369){if(_0x20a369){_0x3500e0=_0x20a369;_0x39c995[_0x0976('0x3e')]=_['keys'](db[_0x0976('0x9a')][_0x0976('0x52')]);_0x39c995['query']=_[_0x0976('0x40')](_0x1cfabd['query']);_0x39c995['filters']=_[_0x0976('0x42')](_0x39c995[_0x0976('0x3e')],_0x39c995[_0x0976('0x3f')]);_0x125216[_0x0976('0x44')]=_[_0x0976('0x42')](_0x39c995[_0x0976('0x3e')],qs[_0x0976('0x43')](_0x1cfabd[_0x0976('0x3f')][_0x0976('0x43')]));_0x125216[_0x0976('0x44')]=_0x125216['attributes'][_0x0976('0x45')]?_0x125216[_0x0976('0x44')]:_0x39c995[_0x0976('0x3e')];_0x125216[_0x0976('0x65')]=qs['sort'](_0x1cfabd[_0x0976('0x3f')]['sort']);_0x125216[_0x0976('0x49')]=qs[_0x0976('0x41')](_['pick'](_0x1cfabd[_0x0976('0x3f')],_0x39c995['filters']));if(_0x1cfabd[_0x0976('0x3f')][_0x0976('0x4b')]){_0x125216[_0x0976('0x49')]=_['merge'](_0x125216[_0x0976('0x49')],{'$or':_[_0x0976('0x39')](_0x125216[_0x0976('0x44')],function(_0x35480a){var _0x270f19={};_0x270f19[_0x35480a]={'$like':'%'+_0x1cfabd[_0x0976('0x3f')][_0x0976('0x4b')]+'%'};return _0x270f19;})});}_0x125216=_['merge']({},_0x125216,_0x1cfabd[_0x0976('0x4d')]);return _0x3500e0['getApplications'](_0x125216);}})[_0x0976('0x31')](function(_0x1047fe){if(_0x1047fe){_0x261b21=_0x1047fe[_0x0976('0x45')];if(!_0x1cfabd[_0x0976('0x3f')]['hasOwnProperty'](_0x0976('0x47'))){_0x125216[_0x0976('0x2c')]=qs[_0x0976('0x2c')](_0x1cfabd[_0x0976('0x3f')][_0x0976('0x2c')]);_0x125216[_0x0976('0x2b')]=qs[_0x0976('0x2b')](_0x1cfabd[_0x0976('0x3f')]['offset']);}return _0x3500e0[_0x0976('0x102')](_0x125216);}})[_0x0976('0x31')](function(_0x2f6876){if(_0x2f6876){return _0x2f6876?{'count':_0x261b21,'rows':_0x2f6876}:null;}})['then'](respondWithResult(_0x3d3035,null))[_0x0976('0x54')](handleError(_0x3d3035,null));};exports[_0x0976('0x103')]=function(_0x3ed6ad,_0x48a1a4,_0x510319){return db[_0x0976('0x104')][_0x0976('0x53')]({'where':{'id':_0x3ed6ad[_0x0976('0x51')]['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x48a1a4,null))['then'](function(_0x214aa0){if(_0x214aa0){return _0x214aa0['addProactiveActions'](_0x3ed6ad[_0x0976('0x56')]['ids'],_[_0x0976('0x105')](_0x3ed6ad[_0x0976('0x56')],[_0x0976('0x6b'),'id'])||{});}})[_0x0976('0x31')](respondWithResult(_0x48a1a4,null))[_0x0976('0x54')](handleError(_0x48a1a4,null));};exports[_0x0976('0xf4')]=function(_0x36fc60,_0x512622,_0x952bcf){var _0x1eb0a4={};var _0x3923cb={};var _0x4fabef;var _0x458f82;return db[_0x0976('0x3a')][_0x0976('0x64')]({'where':{'id':_0x36fc60[_0x0976('0x51')]['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x512622,null))['then'](function(_0x2bf876){if(_0x2bf876){_0x4fabef=_0x2bf876;_0x3923cb[_0x0976('0x3e')]=_[_0x0976('0x40')](db[_0x0976('0x106')][_0x0976('0x52')]);_0x3923cb[_0x0976('0x3f')]=_[_0x0976('0x40')](_0x36fc60[_0x0976('0x3f')]);_0x3923cb[_0x0976('0x41')]=_[_0x0976('0x42')](_0x3923cb[_0x0976('0x3e')],_0x3923cb[_0x0976('0x3f')]);_0x1eb0a4[_0x0976('0x44')]=_[_0x0976('0x42')](_0x3923cb[_0x0976('0x3e')],qs['fields'](_0x36fc60['query']['fields']));_0x1eb0a4[_0x0976('0x44')]=_0x1eb0a4[_0x0976('0x44')][_0x0976('0x45')]?_0x1eb0a4[_0x0976('0x44')]:_0x3923cb[_0x0976('0x3e')];_0x1eb0a4['order']=qs['sort'](_0x36fc60[_0x0976('0x3f')][_0x0976('0x48')]);_0x1eb0a4[_0x0976('0x49')]=qs[_0x0976('0x41')](_[_0x0976('0x4a')](_0x36fc60[_0x0976('0x3f')],_0x3923cb[_0x0976('0x41')]));if(_0x36fc60[_0x0976('0x3f')][_0x0976('0x4b')]){_0x1eb0a4[_0x0976('0x49')]=_[_0x0976('0x4c')](_0x1eb0a4[_0x0976('0x49')],{'$or':_[_0x0976('0x39')](_0x1eb0a4[_0x0976('0x44')],function(_0x57f922){var _0x337300={};_0x337300[_0x57f922]={'$like':'%'+_0x36fc60[_0x0976('0x3f')][_0x0976('0x4b')]+'%'};return _0x337300;})});}_0x1eb0a4=_['merge']({},_0x1eb0a4,_0x36fc60[_0x0976('0x4d')]);return _0x4fabef[_0x0976('0xf4')](_0x1eb0a4);}})[_0x0976('0x31')](function(_0x188259){if(_0x188259){_0x458f82=_0x188259['length'];if(!_0x36fc60[_0x0976('0x3f')]['hasOwnProperty'](_0x0976('0x47'))){_0x1eb0a4[_0x0976('0x2c')]=qs[_0x0976('0x2c')](_0x36fc60[_0x0976('0x3f')][_0x0976('0x2c')]);_0x1eb0a4['offset']=qs[_0x0976('0x2b')](_0x36fc60['query'][_0x0976('0x2b')]);}return _0x4fabef[_0x0976('0xf4')](_0x1eb0a4);}})[_0x0976('0x31')](function(_0x46d5a0){if(_0x46d5a0){return _0x46d5a0?{'count':_0x458f82,'rows':_0x46d5a0}:null;}})[_0x0976('0x31')](respondWithResult(_0x512622,null))[_0x0976('0x54')](handleError(_0x512622,null));};exports[_0x0976('0x107')]=function(_0x276f48,_0x5389b0,_0x244648){var _0x2f4d20=_0x276f48['query'][_0x0976('0x108')]===_0x0976('0x109')?_0x0976('0x10a'):'onlineForm';return db['ChatWebsite'][_0x0976('0x53')]({'attributes':['id',_0x2f4d20],'where':{'id':_0x276f48[_0x0976('0x51')]['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x5389b0,null))['then'](function(_0x42ec2d){if(_0x42ec2d){var _0xdc3b7c=_0x42ec2d[_0x2f4d20];var _0x3b1ee6=_0xdc3b7c&&_0xdc3b7c[_0x0976('0x10b')]?_0xdc3b7c[_0x0976('0x10b')]:[];_0x5389b0[_0x0976('0x35')]({'fromKey':_['isNil'](_0xdc3b7c[_0x0976('0x10c')])?undefined:_0xdc3b7c[_0x0976('0x10c')],'count':_0x3b1ee6['length'],'rows':_0x3b1ee6});}})['catch'](handleError(_0x5389b0,null));};exports['getOfflineMessages']=function(_0x36628e,_0x4f94a2,_0x337596){var _0x432aec={'raw':![],'where':{}};var _0x500180={};var _0x5d3c93={'count':0x0,'rows':[]};return db[_0x0976('0x3a')][_0x0976('0x64')]({'where':{'id':_0x36628e[_0x0976('0x51')]['id']}})['then'](handleEntityNotFound(_0x4f94a2,null))[_0x0976('0x31')](function(_0x3d3903){if(_0x3d3903){_0x500180[_0x0976('0x3e')]=_['keys'](db[_0x0976('0xd5')][_0x0976('0x52')]);_0x500180[_0x0976('0x3f')]=_[_0x0976('0x40')](_0x36628e[_0x0976('0x3f')]);_0x500180['filters']=_[_0x0976('0x42')](_0x500180[_0x0976('0x3e')],_0x500180[_0x0976('0x3f')]);_0x432aec[_0x0976('0x44')]=_[_0x0976('0x42')](_0x500180['model'],qs['fields'](_0x36628e[_0x0976('0x3f')][_0x0976('0x43')]));_0x432aec[_0x0976('0x44')]=_0x432aec['attributes'][_0x0976('0x45')]?_0x432aec[_0x0976('0x44')]:_0x500180['model'];if(!_0x36628e[_0x0976('0x3f')][_0x0976('0x46')](_0x0976('0x47'))){_0x432aec[_0x0976('0x2c')]=qs[_0x0976('0x2c')](_0x36628e[_0x0976('0x3f')]['limit']);_0x432aec[_0x0976('0x2b')]=qs[_0x0976('0x2b')](_0x36628e['query'][_0x0976('0x2b')]);}_0x432aec[_0x0976('0x65')]=qs[_0x0976('0x48')](_0x36628e[_0x0976('0x3f')][_0x0976('0x48')]);_0x432aec[_0x0976('0x49')]=qs[_0x0976('0x41')](_['pick'](_0x36628e[_0x0976('0x3f')],_0x500180[_0x0976('0x41')]));_0x432aec[_0x0976('0x49')][_0x0976('0x61')]=_0x3d3903['id'];if(_0x36628e[_0x0976('0x3f')][_0x0976('0x4b')]){_0x432aec[_0x0976('0x49')]=_[_0x0976('0x4c')](_0x432aec['where'],{'$or':_[_0x0976('0x39')](_0x432aec[_0x0976('0x44')],function(_0x168002){var _0x4706c7={};_0x4706c7[_0x168002]={'$like':'%'+_0x36628e[_0x0976('0x3f')][_0x0976('0x4b')]+'%'};return _0x4706c7;})});}_0x432aec=_[_0x0976('0x4c')]({},_0x432aec,_0x36628e[_0x0976('0x4d')]);return db[_0x0976('0xd5')][_0x0976('0x2a')]({'where':_0x432aec[_0x0976('0x49')]})[_0x0976('0x31')](function(_0xd082f9){_0x5d3c93[_0x0976('0x2a')]=_0xd082f9;if(_0x36628e[_0x0976('0x3f')]['includeAll']){_0x432aec['include']=[{'all':!![]}];}else{_0x432aec[_0x0976('0x4f')]=[{'model':db[_0x0976('0x8a')],'as':_0x0976('0xe5'),'required':![]}];}return db[_0x0976('0xd5')][_0x0976('0x66')](_0x432aec);})[_0x0976('0x31')](function(_0x1cafbd){_0x5d3c93[_0x0976('0x50')]=_0x1cafbd;return _0x5d3c93;});}})[_0x0976('0x31')](respondWithFilteredResult(_0x4f94a2,_0x432aec))['catch'](handleError(_0x4f94a2,null));};exports[_0x0976('0x10d')]=function(_0x97bf1c,_0x5e150f,_0x1be8c7){return db[_0x0976('0x3a')][_0x0976('0x53')]({'where':{'id':_0x97bf1c[_0x0976('0x51')]['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x5e150f,null))[_0x0976('0x31')](function(_0x2a534a){if(_0x2a534a){return _0x2a534a[_0x0976('0x10d')](_0x97bf1c[_0x0976('0x56')][_0x0976('0x6b')],_[_0x0976('0x105')](_0x97bf1c[_0x0976('0x56')],[_0x0976('0x6b'),'id'])||{})[_0x0976('0xce')](function(_0x3d941b){for(var _0x2eb19a=0x0;_0x2eb19a<_0x97bf1c[_0x0976('0x56')][_0x0976('0x6b')][_0x0976('0x45')];_0x2eb19a+=0x1){socket[_0x0976('0x10e')](_0x0976('0x10f'),{'UserId':_0x97bf1c[_0x0976('0x56')][_0x0976('0x6b')][_0x2eb19a],'ChatWebsiteId':_0x97bf1c[_0x0976('0x51')]['id']});}return _0x3d941b;});}})[_0x0976('0x31')](respondWithResult(_0x5e150f,null))[_0x0976('0x54')](handleError(_0x5e150f,null));};exports[_0x0976('0x110')]=function(_0xfdd8a9,_0x56c946,_0x342d27){return db[_0x0976('0x3a')][_0x0976('0x53')]({'where':{'id':_0xfdd8a9['params']['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x56c946,null))[_0x0976('0x31')](function(_0x13bbb2){if(_0x13bbb2){return _0x13bbb2[_0x0976('0x110')](_0xfdd8a9[_0x0976('0x3f')][_0x0976('0x6b')])[_0x0976('0x31')](function(){if(_[_0x0976('0x111')](_0xfdd8a9['query'][_0x0976('0x6b')])){for(var _0x58ab14=0x0;_0x58ab14<_0xfdd8a9['query'][_0x0976('0x6b')][_0x0976('0x45')];_0x58ab14+=0x1){socket[_0x0976('0x10e')]('userChatWebsite:remove',{'UserId':Number(_0xfdd8a9[_0x0976('0x3f')][_0x0976('0x6b')][_0x58ab14]),'ChatWebsiteId':Number(_0xfdd8a9[_0x0976('0x51')]['id'])});}}else{socket[_0x0976('0x10e')](_0x0976('0x112'),{'UserId':Number(_0xfdd8a9[_0x0976('0x3f')]['ids']),'ChatWebsiteId':Number(_0xfdd8a9['params']['id'])});}});}})[_0x0976('0x31')](respondWithStatusCode(_0x56c946,null))[_0x0976('0x54')](handleError(_0x56c946,null));};exports[_0x0976('0x113')]=function(_0x5d8cdd,_0x3bca48,_0x389e85){var _0x44be3c={};var _0x9071f1={};var _0x2a5dcc;var _0x46e7f8;return db[_0x0976('0x3a')][_0x0976('0x64')]({'where':{'id':_0x5d8cdd['params']['id']}})[_0x0976('0x31')](handleEntityNotFound(_0x3bca48,null))[_0x0976('0x31')](function(_0x4ad385){if(_0x4ad385){_0x2a5dcc=_0x4ad385;_0x9071f1[_0x0976('0x3e')]=_[_0x0976('0x40')](db[_0x0976('0xc4')][_0x0976('0x52')]);_0x9071f1[_0x0976('0x3f')]=_[_0x0976('0x40')](_0x5d8cdd[_0x0976('0x3f')]);_0x9071f1['filters']=_['intersection'](_0x9071f1[_0x0976('0x3e')],_0x9071f1[_0x0976('0x3f')]);_0x44be3c[_0x0976('0x44')]=_[_0x0976('0x42')](_0x9071f1['model'],qs[_0x0976('0x43')](_0x5d8cdd[_0x0976('0x3f')][_0x0976('0x43')]));_0x44be3c['attributes']=_0x44be3c[_0x0976('0x44')][_0x0976('0x45')]?_0x44be3c[_0x0976('0x44')]:_0x9071f1['model'];_0x44be3c[_0x0976('0x65')]=qs[_0x0976('0x48')](_0x5d8cdd[_0x0976('0x3f')]['sort']);_0x44be3c[_0x0976('0x49')]=qs[_0x0976('0x41')](_[_0x0976('0x4a')](_0x5d8cdd[_0x0976('0x3f')],_0x9071f1['filters']));if(_0x5d8cdd[_0x0976('0x3f')]['filter']){_0x44be3c[_0x0976('0x49')]=_[_0x0976('0x4c')](_0x44be3c[_0x0976('0x49')],{'$or':_[_0x0976('0x39')](_0x44be3c[_0x0976('0x44')],function(_0x43753f){var _0xa1b463={};_0xa1b463[_0x43753f]={'$like':'%'+_0x5d8cdd[_0x0976('0x3f')]['filter']+'%'};return _0xa1b463;})});}_0x44be3c=_[_0x0976('0x4c')]({},_0x44be3c,_0x5d8cdd['options']);return _0x2a5dcc[_0x0976('0x113')](_0x44be3c);}})['then'](function(_0xb84f28){if(_0xb84f28){_0x46e7f8=_0xb84f28[_0x0976('0x45')];if(!_0x5d8cdd[_0x0976('0x3f')][_0x0976('0x46')](_0x0976('0x47'))){_0x44be3c[_0x0976('0x2c')]=qs[_0x0976('0x2c')](_0x5d8cdd[_0x0976('0x3f')]['limit']);_0x44be3c[_0x0976('0x2b')]=qs[_0x0976('0x2b')](_0x5d8cdd[_0x0976('0x3f')][_0x0976('0x2b')]);}return _0x2a5dcc[_0x0976('0x113')](_0x44be3c);}})[_0x0976('0x31')](function(_0x1d7043){if(_0x1d7043){return _0x1d7043?{'count':_0x46e7f8,'rows':_0x1d7043}:null;}})[_0x0976('0x31')](respondWithResult(_0x3bca48,null))[_0x0976('0x54')](handleError(_0x3bca48,null));};
\ No newline at end of file
+var _0x671a=['../../errors/api','APINotFoundError','../../mysqldb','redis','localhost','./chatWebsite.socket','register','http','client','request','then','ChatWebsite,\x20%s,\x20%s','request\x20sent','ChatWebsite,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','result','catch','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','update','destroy','get','ChatWebsites','UserProfileResource','stack','name','Command','getSnippet','timezone','format','interval','indexOf','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','ONLINE','inspect','No\x20timezone','map','all','some','setUA','user-agent','getResult','customerIp','cf-connecting-ip','first','x-forwarded-for','split','firstName','lastName','x-real-port','referer','browser','%s\x20%s','unknown','version','device','vendor','%s\x20%s\x20%s','model','type','index','Pause','mandatoryDispositionPause','ChatWebsite','rawAttributes','fieldName','key','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filters','pick','filter','options','includeAll','findAll','include','find','create','body','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','Disposition','getDispositions','findOne','order','ChatWebsiteId','merge','rows','removeDispositions','ids','CannedAnswer','getAnswers','keys','removeAnswers','addLogo','sitepic','file','filename','addAvatar','agentAvatar','addSystemAvatar','systemAvatar','getLogo','join','root','../../config/license/util','getLicense','custom','isNil','existsSync','server/files/images/logos/','download','server/files/images/avatars/default_avatar.png','server/files/images/avatars/','getCustomerAvatar','server/files/images/avatars/customer_avatar.png','showCustomerAvatar','customerAvatar','getSystemAvatar','server/files/images/avatars/system_avatar.png','notify','chat','CmContact','Sequelize','no\x20available\x20attributes','createdAt','difference','updatedAt','ListId','from','ValidationError','from\x20is\x20mandatory','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','CmList','List','DESC','ChatApplication','Applications','Interval','Intervals','Chat\x20Website\x20with\x20id\x20%s\x20not\x20found','account','list','applications','orderBy','priority','asc','Contacts','defaults','contact','threadId','externalUrl','ChatInteraction','interaction','messageId','created','autoclose','push','close','unmanaged','ChatMessage','AttachmentId','UserId','agent','waitForTheAssignedAgent','*,*,*,*','forcedOwnership','queueId','ChatQueue','unshift','queue','waitForTheAssignedQueue','Start','startRouting','EventManager','offline','files','CompanyId','send','mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKeyOffline','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailAccount','findOrCreate','spread','readFileSync','toPairs','offlineMessageBody','ChatOfflineMessage','fromString','server','attachments','offline-chat','basename','openNewInteraction','transaction','Attachment','Smtp','CloudProvider','forwardOffline','forwardOfflineAddress','getSmtpOptions','SendMail','\x22%s\x22\x20<%s>','email','user','offlineMessageSubject','MailAccountId','originalname','mimetype','subjectOffline','toPairsIn','NotifyMailAccount','notifyMail','Could\x20not\x20remove\x20attachment\x20file','addInteraction','omit','getInteractions','Contact','Owner','fullname','Tag','Tags','color','tag','License','chatLicenseExceeded','server/files/chat/iframe.ejs','utf8','URL','origin','3.5.0','remote','headers','x-real-ip','remoteAddress','virtual','replace','render','alignment','verticalAlignment','labelText','textButtonColor','color_button','backgroundColor','hideWhenOffline','IntervalId','addApplications','sequelize','Transaction','ISOLATION_LEVELS','READ_COMMITTED','findAndCountAll','finally','getApplications','addProactiveActions','getProactiveActions','ChatProactiveAction','getFields','online','offlineForm','items','fromKey','getOfflineMessages','Attachments','addAgents','removeAgents','isArray','emit','userChatWebsite:remove','User','getAgents','mustache','util','ejs','fs-extra','lodash','querystring','html-to-text','ioredis','jayson/promise','../../components/parsers/qs','../../config/logger','api','../../config/environment','APIOutOfIntervalError'];(function(_0x333f19,_0x3f6eed){var _0x453f98=function(_0x1d025c){while(--_0x1d025c){_0x333f19['push'](_0x333f19['shift']());}};_0x453f98(++_0x3f6eed);}(_0x671a,0x12b));var _0xa671=function(_0x598408,_0x5e6f74){_0x598408=_0x598408-0x0;var _0x560720=_0x671a[_0x598408];return _0x560720;};'use strict';var Mustache=require(_0xa671('0x0'));var util=require(_0xa671('0x1'));var path=require('path');var ejs=require(_0xa671('0x2'));var fs=require('fs');var fs_extra=require(_0xa671('0x3'));var _=require(_0xa671('0x4'));var querystring=require(_0xa671('0x5'));var htmlToText=require(_0xa671('0x6'));var Redis=require(_0xa671('0x7'));var jayson=require(_0xa671('0x8'));var url=require('url');var qs=require(_0xa671('0x9'));var logger=require(_0xa671('0xa'))(_0xa671('0xb'));var config=require(_0xa671('0xc'));var APIOutOfIntervalError=require('../../errors/api')[_0xa671('0xd')];var APINotFoundError=require(_0xa671('0xe'))[_0xa671('0xf')];var APIHandleError=require(_0xa671('0xe'))['handleError'];var db=require(_0xa671('0x10'))['db'];config[_0xa671('0x11')]=_['defaults'](config[_0xa671('0x11')],{'host':_0xa671('0x12'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xa671('0x11')]));require(_0xa671('0x13'))[_0xa671('0x14')](socket);var client=jayson['client'][_0xa671('0x15')]({'port':0x232c});var client9002=jayson[_0xa671('0x16')]['http']({'port':0x232a});var client9003=jayson[_0xa671('0x16')]['http']({'port':0x232b});var client9001=jayson[_0xa671('0x16')][_0xa671('0x15')]({'port':0x2329});function respondWithRpcPromise(_0x4b1d0e,_0x2e2c18,_0x459c24,_0x4bc393){return new Promise(function(_0xddcb05,_0x373dd5){var _0x1c8475=_0x4bc393||client;return _0x1c8475[_0xa671('0x17')](_0x4b1d0e,_0x459c24)[_0xa671('0x18')](function(_0x9e6765){logger['info'](_0xa671('0x19'),_0x2e2c18,_0xa671('0x1a'));logger['debug'](_0xa671('0x1b'),_0x2e2c18,'request\x20sent',JSON[_0xa671('0x1c')](_0x9e6765));if(_0x9e6765[_0xa671('0x1d')]){if(_0x9e6765[_0xa671('0x1d')][_0xa671('0x1e')]===0x1f4){logger[_0xa671('0x1d')]('ChatWebsite,\x20%s,\x20%s',_0x2e2c18,_0x9e6765[_0xa671('0x1d')]['message']);return _0x373dd5(_0x9e6765[_0xa671('0x1d')][_0xa671('0x1f')]);}logger[_0xa671('0x1d')]('ChatWebsite,\x20%s,\x20%s',_0x2e2c18,_0x9e6765['error'][_0xa671('0x1f')]);return _0xddcb05(_0x9e6765[_0xa671('0x1d')]['message']);}else{logger[_0xa671('0x20')](_0xa671('0x19'),_0x2e2c18,_0xa671('0x1a'));_0xddcb05(_0x9e6765[_0xa671('0x21')][_0xa671('0x1f')]);}})[_0xa671('0x22')](function(_0x3f5d85){logger[_0xa671('0x1d')]('ChatWebsite,\x20%s,\x20%s',_0x2e2c18,_0x3f5d85);_0x373dd5(_0x3f5d85);});});}function respondWithStatusCode(_0x28d586,_0xf2110f){_0xf2110f=_0xf2110f||0xcc;return function(_0x31ab5a){if(_0x31ab5a){return _0x28d586[_0xa671('0x23')](_0xf2110f);}return _0x28d586[_0xa671('0x24')](_0xf2110f)[_0xa671('0x25')]();};}function respondWithResult(_0x306648,_0x1ff023){_0x1ff023=_0x1ff023||0xc8;return function(_0x2cd231){if(_0x2cd231){return _0x306648[_0xa671('0x24')](_0x1ff023)[_0xa671('0x26')](_0x2cd231);}};}function respondWithFilteredResult(_0x48efd0,_0x461a6d){return function(_0x563ad5){if(_0x563ad5){var _0x3b6702=typeof _0x461a6d[_0xa671('0x27')]==='undefined'&&typeof _0x461a6d['limit']===_0xa671('0x28');var _0x46ddd2=_0x563ad5[_0xa671('0x29')];var _0xc5d732=_0x3b6702?0x0:_0x461a6d[_0xa671('0x27')];var _0x2b3b1c=_0x3b6702?_0x563ad5[_0xa671('0x29')]:_0x461a6d[_0xa671('0x27')]+_0x461a6d[_0xa671('0x2a')];var _0xcfbc74;if(_0x2b3b1c>=_0x46ddd2){_0x2b3b1c=_0x46ddd2;_0xcfbc74=0xc8;}else{_0xcfbc74=0xce;}_0x48efd0[_0xa671('0x24')](_0xcfbc74);return _0x48efd0[_0xa671('0x2b')](_0xa671('0x2c'),_0xc5d732+'-'+_0x2b3b1c+'/'+_0x46ddd2)[_0xa671('0x26')](_0x563ad5);}return null;};}function saveUpdates(_0x2689ed){return function(_0x5be149){if(_0x5be149){return _0x5be149[_0xa671('0x2d')](_0x2689ed)[_0xa671('0x18')](function(_0x2f3697){return _0x2f3697;});}return null;};}function removeEntity(_0x4a5c17){return function(_0x431c9b){if(_0x431c9b){return _0x431c9b[_0xa671('0x2e')]()[_0xa671('0x18')](function(){var _0x12e528=_0x431c9b[_0xa671('0x2f')]({'plain':!![]});var _0x32ff1b=_0xa671('0x30');return db[_0xa671('0x31')][_0xa671('0x2e')]({'where':{'type':_0x32ff1b,'resourceId':_0x12e528['id']}})[_0xa671('0x18')](function(){return _0x431c9b;});})[_0xa671('0x18')](function(){_0x4a5c17[_0xa671('0x24')](0xcc)[_0xa671('0x25')]();});}};}function handleEntityNotFound(_0x4e4713){return function(_0x3aaa82){if(!_0x3aaa82){_0x4e4713[_0xa671('0x23')](0x194);}return _0x3aaa82;};}function handleError(_0x23f20d,_0x1374ff){_0x1374ff=_0x1374ff||0x1f4;return function(_0x263b40){logger[_0xa671('0x1d')](_0x263b40[_0xa671('0x32')]);if(_0x263b40[_0xa671('0x33')]){delete _0x263b40[_0xa671('0x33')];}_0x23f20d[_0xa671('0x24')](_0x1374ff)['send'](_0x263b40);};}function iftimePromise(_0x231cdb,_0x1c0c44){return respondWithRpcPromise(_0xa671('0x34'),_0xa671('0x35'),{'command':_0x1c0c44[_0xa671('0x36')]?util[_0xa671('0x37')]('iftime\x20%s,%s',_0x231cdb[_0xa671('0x38')],_0x1c0c44[_0xa671('0x36')]):util[_0xa671('0x37')]('iftime\x20%s',_0x231cdb[_0xa671('0x38')])},client9002)[_0xa671('0x18')](function(_0x3e8ee0){var _0x4f166d=_0x3e8ee0&&_0x3e8ee0[_0xa671('0x39')]('true')>=0x0?!![]:![];logger['info'](_0xa671('0x3a'),_0x1c0c44['id'],_0x231cdb['id'],_0x231cdb[_0xa671('0x38')],_0x4f166d?_0xa671('0x3b'):'OFFLINE',_0x1c0c44[_0xa671('0x36')]?_0x1c0c44[_0xa671('0x36')]:'No\x20timezone');return _0x4f166d;})[_0xa671('0x22')](function(_0x3b7566){logger[_0xa671('0x1d')](_0xa671('0x3a'),_0x1c0c44['id'],_0x231cdb['id'],_0x231cdb['interval'],util[_0xa671('0x3c')](_0x3b7566,{'showHidden':![],'depth':null}),_0x1c0c44['timezone']?_0x1c0c44[_0xa671('0x36')]:_0xa671('0x3d'));return![];});}function checkWebsiteIntervals(_0x3a7879){var _0xfa06ae=_[_0xa671('0x3e')](_0x3a7879['Interval']['Intervals'],function(_0x49cf9f){var _0x36158c=_0x49cf9f[_0xa671('0x2f')]({'plain':!![]});return iftimePromise(_0x36158c,_0x3a7879);});return Promise[_0xa671('0x3f')](_0xfa06ae)[_0xa671('0x18')](function(_0x23fb31){return _[_0xa671('0x40')](_0x23fb31);});}function createInteractionObject(_0x2ea5da,_0x3c1173,_0x4a6dfb,_0x10b51f){var _0x1bb826=require('user-agent-parser');var _0x455bb4=new _0x1bb826();var _0x5786c5=_0x455bb4[_0xa671('0x41')](_0x4a6dfb[_0xa671('0x42')])[_0xa671('0x43')]();var _0x4aed93=_0x3c1173[_0xa671('0x44')];if(_0x4a6dfb[_0xa671('0x45')]){_0x4aed93=_0x4a6dfb['cf-connecting-ip'];}else if(_0x4a6dfb['x-forwarded-for']){_0x4aed93=_[_0xa671('0x46')](_0x4a6dfb[_0xa671('0x47')][_0xa671('0x48')](','));}return{'ContactId':_0x10b51f['id'],'ChatWebsiteId':_0x2ea5da,'from':(_0x10b51f[_0xa671('0x49')]||'')+'\x20'+(_0x10b51f[_0xa671('0x4a')]||''),'customerIp':_0x4aed93,'customerPort':_0x4a6dfb[_0xa671('0x4b')]?_0x4a6dfb['x-real-port']:null,'referer':_0x3c1173[_0xa671('0x4c')],'browserName':_0x5786c5[_0xa671('0x4d')][_0xa671('0x33')]&&_0x5786c5[_0xa671('0x4d')]['version']?util[_0xa671('0x37')](_0xa671('0x4e'),_0x5786c5['browser'][_0xa671('0x33')],_0x5786c5[_0xa671('0x4d')]['version']):_0xa671('0x4f'),'browserVersion':_0x5786c5[_0xa671('0x4d')][_0xa671('0x50')]||'unknown','osName':util[_0xa671('0x37')](_0xa671('0x4e'),_0x5786c5['os']['name'],_0x5786c5['os'][_0xa671('0x50')]),'osVersion':_0x5786c5['os'][_0xa671('0x50')],'deviceModel':_0x5786c5[_0xa671('0x51')]['model']&&_0x5786c5[_0xa671('0x51')][_0xa671('0x52')]?util['format'](_0xa671('0x53'),_0x5786c5[_0xa671('0x51')][_0xa671('0x54')],_0x5786c5[_0xa671('0x51')][_0xa671('0x52')],_0x5786c5[_0xa671('0x51')][_0xa671('0x55')]):null,'deviceVendor':_0x5786c5['device'][_0xa671('0x52')],'deviceType':_0x5786c5[_0xa671('0x51')]['type'],'formData':JSON[_0xa671('0x1c')](_0x3c1173)};}exports[_0xa671('0x56')]=function(_0x3133d4,_0x1a1200){var _0x29fcd8={'include':[{'model':db[_0xa671('0x57')],'as':_0xa671('0x58')}]},_0x25abdb={},_0x43f71f={'count':0x0,'rows':[]};var _0x163c20=_[_0xa671('0x3e')](db[_0xa671('0x59')][_0xa671('0x5a')],function(_0x2eaa05){return{'name':_0x2eaa05[_0xa671('0x5b')],'type':_0x2eaa05[_0xa671('0x55')][_0xa671('0x5c')]};});_0x25abdb[_0xa671('0x54')]=_[_0xa671('0x3e')](_0x163c20,_0xa671('0x33'));_0x25abdb[_0xa671('0x5d')]=_['keys'](_0x3133d4[_0xa671('0x5d')]);_0x25abdb['filters']=_[_0xa671('0x5e')](_0x25abdb[_0xa671('0x54')],_0x25abdb[_0xa671('0x5d')]);_0x29fcd8[_0xa671('0x5f')]=_[_0xa671('0x5e')](_0x25abdb[_0xa671('0x54')],qs[_0xa671('0x60')](_0x3133d4[_0xa671('0x5d')]['fields']));_0x29fcd8[_0xa671('0x5f')]=_0x29fcd8[_0xa671('0x5f')][_0xa671('0x61')]?_0x29fcd8[_0xa671('0x5f')]:_0x25abdb['model'];if(!_0x3133d4[_0xa671('0x5d')][_0xa671('0x62')](_0xa671('0x63'))){_0x29fcd8[_0xa671('0x2a')]=qs[_0xa671('0x2a')](_0x3133d4['query'][_0xa671('0x2a')]);_0x29fcd8['offset']=qs[_0xa671('0x27')](_0x3133d4[_0xa671('0x5d')][_0xa671('0x27')]);}_0x29fcd8['order']=qs[_0xa671('0x64')](_0x3133d4[_0xa671('0x5d')]['sort']);_0x29fcd8[_0xa671('0x65')]=qs[_0xa671('0x66')](_[_0xa671('0x67')](_0x3133d4['query'],_0x25abdb[_0xa671('0x66')]),_0x163c20);if(_0x3133d4[_0xa671('0x5d')][_0xa671('0x68')]){_0x29fcd8[_0xa671('0x65')]=_['merge'](_0x29fcd8[_0xa671('0x65')],{'$or':_['map'](_0x163c20,function(_0x5cc41b){if(_0x5cc41b[_0xa671('0x55')]!=='VIRTUAL'){var _0x136280={};_0x136280[_0x5cc41b[_0xa671('0x33')]]={'$like':'%'+_0x3133d4[_0xa671('0x5d')]['filter']+'%'};return _0x136280;}})});}_0x29fcd8=_['merge']({},_0x29fcd8,_0x3133d4[_0xa671('0x69')]);var _0x48c0b3={'where':_0x29fcd8[_0xa671('0x65')]};return db[_0xa671('0x59')][_0xa671('0x29')](_0x48c0b3)['then'](function(_0x2b95d1){_0x43f71f[_0xa671('0x29')]=_0x2b95d1;if(_0x3133d4[_0xa671('0x5d')][_0xa671('0x6a')]){_0x29fcd8['include']=[{'all':!![]}];}return db[_0xa671('0x59')][_0xa671('0x6b')](_0x29fcd8);})[_0xa671('0x18')](function(_0x589a2b){_0x43f71f['rows']=_0x589a2b;return _0x43f71f;})[_0xa671('0x18')](respondWithFilteredResult(_0x1a1200,_0x29fcd8))[_0xa671('0x22')](handleError(_0x1a1200,null));};exports['show']=function(_0x4d7930,_0x4596e4){var _0x466f69={'raw':![],'where':{'id':_0x4d7930['params']['id']},'include':[{'model':db['Pause'],'as':_0xa671('0x58')}]},_0x1397ac={};_0x1397ac[_0xa671('0x54')]=_['keys'](db['ChatWebsite'][_0xa671('0x5a')]);_0x1397ac['query']=_['keys'](_0x4d7930[_0xa671('0x5d')]);_0x1397ac[_0xa671('0x66')]=_[_0xa671('0x5e')](_0x1397ac[_0xa671('0x54')],_0x1397ac[_0xa671('0x5d')]);_0x466f69[_0xa671('0x5f')]=_['intersection'](_0x1397ac[_0xa671('0x54')],qs[_0xa671('0x60')](_0x4d7930[_0xa671('0x5d')][_0xa671('0x60')]));_0x466f69['attributes']=_0x466f69['attributes'][_0xa671('0x61')]?_0x466f69[_0xa671('0x5f')]:_0x1397ac['model'];if(_0x4d7930[_0xa671('0x5d')][_0xa671('0x6a')]){_0x466f69[_0xa671('0x6c')]=[{'all':!![]}];}_0x466f69=_['merge']({},_0x466f69,_0x4d7930[_0xa671('0x69')]);return db[_0xa671('0x59')][_0xa671('0x6d')](_0x466f69)['then'](handleEntityNotFound(_0x4596e4,null))['then'](respondWithResult(_0x4596e4,null))[_0xa671('0x22')](handleError(_0x4596e4,null));};exports[_0xa671('0x6e')]=function(_0x44b859,_0x1ff0e0){return db[_0xa671('0x59')][_0xa671('0x6e')](_0x44b859[_0xa671('0x6f')],{})[_0xa671('0x18')](function(_0x83cee0){var _0x18a93a=_0x44b859['user'][_0xa671('0x2f')]({'plain':!![]});if(!_0x18a93a)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x18a93a[_0xa671('0x70')]==='user'){var _0x4e4332=_0x83cee0[_0xa671('0x2f')]({'plain':!![]});var _0x13541f='ChatWebsites';return db[_0xa671('0x71')][_0xa671('0x6d')]({'where':{'name':_0x13541f,'userProfileId':_0x18a93a[_0xa671('0x72')]},'raw':!![]})['then'](function(_0x262a92){if(_0x262a92&&_0x262a92[_0xa671('0x73')]===0x0){return db[_0xa671('0x31')][_0xa671('0x6e')]({'name':_0x4e4332[_0xa671('0x33')],'resourceId':_0x4e4332['id'],'type':_0x262a92[_0xa671('0x33')],'sectionId':_0x262a92['id']},{})[_0xa671('0x18')](function(){return _0x83cee0;});}else{return _0x83cee0;}})[_0xa671('0x22')](function(_0xbfd306){logger[_0xa671('0x1d')](_0xa671('0x74'),_0xbfd306);throw _0xbfd306;});}return _0x83cee0;})[_0xa671('0x18')](respondWithResult(_0x1ff0e0,0xc9))['catch'](handleError(_0x1ff0e0,null));};exports['update']=function(_0x1c3627,_0x1566aa){if(_0x1c3627['body']['id']){delete _0x1c3627[_0xa671('0x6f')]['id'];}return db[_0xa671('0x59')]['find']({'where':{'id':_0x1c3627[_0xa671('0x75')]['id']},'include':[{'model':db[_0xa671('0x57')],'as':_0xa671('0x58')}]})[_0xa671('0x18')](handleEntityNotFound(_0x1566aa,null))[_0xa671('0x18')](saveUpdates(_0x1c3627[_0xa671('0x6f')],null))[_0xa671('0x18')](respondWithResult(_0x1566aa,null))['catch'](handleError(_0x1566aa,null));};exports[_0xa671('0x2e')]=function(_0x492be5,_0x4b0e7a){return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x492be5['params']['id']}})['then'](handleEntityNotFound(_0x4b0e7a,null))[_0xa671('0x18')](removeEntity(_0x4b0e7a,null))[_0xa671('0x22')](handleError(_0x4b0e7a,null));};exports[_0xa671('0x76')]=function(_0x2c3611,_0x3f6f3a){return db[_0xa671('0x59')]['describe']()[_0xa671('0x18')](respondWithResult(_0x3f6f3a,null))[_0xa671('0x22')](handleError(_0x3f6f3a,null));};exports['addDisposition']=function(_0x615d9,_0x42c381){if(_0x615d9[_0xa671('0x6f')]['id']){delete _0x615d9[_0xa671('0x6f')]['id'];}return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x615d9[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x42c381,null))[_0xa671('0x18')](function(_0x210ec7){if(_0x210ec7){_0x615d9[_0xa671('0x6f')]['ChatWebsiteId']=_0x210ec7['id'];return db[_0xa671('0x77')][_0xa671('0x6e')](_0x615d9[_0xa671('0x6f')]);}})['then'](respondWithResult(_0x42c381,null))[_0xa671('0x22')](handleError(_0x42c381,null));};exports[_0xa671('0x78')]=function(_0x5f83e4,_0x113b33){var _0x18b906={'raw':![],'where':{}};var _0x13eef0={};var _0x3ff43f={'count':0x0,'rows':[]};return db[_0xa671('0x59')][_0xa671('0x79')]({'where':{'id':_0x5f83e4[_0xa671('0x75')]['id']}})['then'](handleEntityNotFound(_0x113b33,null))[_0xa671('0x18')](function(_0x3a4bd3){if(_0x3a4bd3){_0x13eef0[_0xa671('0x54')]=_['keys'](db[_0xa671('0x77')][_0xa671('0x5a')]);_0x13eef0[_0xa671('0x5d')]=_['keys'](_0x5f83e4['query']);_0x13eef0[_0xa671('0x66')]=_[_0xa671('0x5e')](_0x13eef0[_0xa671('0x54')],_0x13eef0[_0xa671('0x5d')]);_0x18b906[_0xa671('0x5f')]=_[_0xa671('0x5e')](_0x13eef0[_0xa671('0x54')],qs[_0xa671('0x60')](_0x5f83e4[_0xa671('0x5d')][_0xa671('0x60')]));_0x18b906[_0xa671('0x5f')]=_0x18b906[_0xa671('0x5f')]['length']?_0x18b906[_0xa671('0x5f')]:_0x13eef0['model'];if(!_0x5f83e4['query'][_0xa671('0x62')](_0xa671('0x63'))){_0x18b906[_0xa671('0x2a')]=qs['limit'](_0x5f83e4[_0xa671('0x5d')][_0xa671('0x2a')]);_0x18b906[_0xa671('0x27')]=qs[_0xa671('0x27')](_0x5f83e4[_0xa671('0x5d')]['offset']);}_0x18b906[_0xa671('0x7a')]=qs['sort'](_0x5f83e4['query']['sort']);_0x18b906[_0xa671('0x65')]=qs[_0xa671('0x66')](_[_0xa671('0x67')](_0x5f83e4['query'],_0x13eef0[_0xa671('0x66')]));_0x18b906[_0xa671('0x65')][_0xa671('0x7b')]=_0x3a4bd3['id'];if(_0x5f83e4[_0xa671('0x5d')][_0xa671('0x68')]){_0x18b906[_0xa671('0x65')]=_[_0xa671('0x7c')](_0x18b906[_0xa671('0x65')],{'$or':_[_0xa671('0x3e')](_0x18b906[_0xa671('0x5f')],function(_0x3b3a50){var _0x51f406={};_0x51f406[_0x3b3a50]={'$like':'%'+_0x5f83e4[_0xa671('0x5d')][_0xa671('0x68')]+'%'};return _0x51f406;})});}_0x18b906=_['merge']({},_0x18b906,_0x5f83e4[_0xa671('0x69')]);return db[_0xa671('0x77')][_0xa671('0x29')]({'where':_0x18b906[_0xa671('0x65')]})[_0xa671('0x18')](function(_0x27587a){_0x3ff43f[_0xa671('0x29')]=_0x27587a;if(_0x5f83e4[_0xa671('0x5d')][_0xa671('0x6a')]){_0x18b906['include']=[{'all':!![]}];}return db[_0xa671('0x77')][_0xa671('0x6b')](_0x18b906);})[_0xa671('0x18')](function(_0x3fd62d){_0x3ff43f[_0xa671('0x7d')]=_0x3fd62d;return _0x3ff43f;});}})['then'](respondWithFilteredResult(_0x113b33,_0x18b906))['catch'](handleError(_0x113b33,null));};exports[_0xa671('0x7e')]=function(_0x44a4ad,_0x3aae7e){return db['ChatWebsite'][_0xa671('0x6d')]({'where':{'id':_0x44a4ad[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x3aae7e,null))[_0xa671('0x18')](function(_0x12574e){if(_0x12574e){return _0x12574e[_0xa671('0x7e')](_0x44a4ad[_0xa671('0x5d')][_0xa671('0x7f')]);}})['then'](respondWithStatusCode(_0x3aae7e,null))[_0xa671('0x22')](handleError(_0x3aae7e,null));};exports['addAnswer']=function(_0x5c34a6,_0x124a98){if(_0x5c34a6[_0xa671('0x6f')]['id']){delete _0x5c34a6[_0xa671('0x6f')]['id'];}return db['ChatWebsite'][_0xa671('0x6d')]({'where':{'id':_0x5c34a6[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x124a98,null))[_0xa671('0x18')](function(_0x37a335){if(_0x37a335){_0x5c34a6[_0xa671('0x6f')][_0xa671('0x7b')]=_0x37a335['id'];return db[_0xa671('0x80')][_0xa671('0x6e')](_0x5c34a6[_0xa671('0x6f')]);}})[_0xa671('0x18')](respondWithResult(_0x124a98,null))[_0xa671('0x22')](handleError(_0x124a98,null));};exports[_0xa671('0x81')]=function(_0x30f0f9,_0x3dac8c){var _0x2194d7={'raw':![],'where':{}};var _0x27d61c={};var _0x8492d1={'count':0x0,'rows':[]};return db[_0xa671('0x59')][_0xa671('0x79')]({'where':{'id':_0x30f0f9[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x3dac8c,null))[_0xa671('0x18')](function(_0x18906c){if(_0x18906c){_0x27d61c[_0xa671('0x54')]=_[_0xa671('0x82')](db['CannedAnswer'][_0xa671('0x5a')]);_0x27d61c['query']=_[_0xa671('0x82')](_0x30f0f9['query']);_0x27d61c['filters']=_[_0xa671('0x5e')](_0x27d61c['model'],_0x27d61c[_0xa671('0x5d')]);_0x2194d7['attributes']=_[_0xa671('0x5e')](_0x27d61c[_0xa671('0x54')],qs[_0xa671('0x60')](_0x30f0f9['query']['fields']));_0x2194d7[_0xa671('0x5f')]=_0x2194d7[_0xa671('0x5f')][_0xa671('0x61')]?_0x2194d7[_0xa671('0x5f')]:_0x27d61c['model'];if(!_0x30f0f9['query'][_0xa671('0x62')](_0xa671('0x63'))){_0x2194d7['limit']=qs['limit'](_0x30f0f9['query'][_0xa671('0x2a')]);_0x2194d7[_0xa671('0x27')]=qs[_0xa671('0x27')](_0x30f0f9['query'][_0xa671('0x27')]);}_0x2194d7[_0xa671('0x7a')]=qs[_0xa671('0x64')](_0x30f0f9[_0xa671('0x5d')]['sort']);_0x2194d7[_0xa671('0x65')]=qs['filters'](_['pick'](_0x30f0f9[_0xa671('0x5d')],_0x27d61c['filters']));_0x2194d7['where']['ChatWebsiteId']=_0x18906c['id'];if(_0x30f0f9['query'][_0xa671('0x68')]){_0x2194d7[_0xa671('0x65')]=_[_0xa671('0x7c')](_0x2194d7[_0xa671('0x65')],{'$or':_[_0xa671('0x3e')](_0x2194d7[_0xa671('0x5f')],function(_0x44f87a){var _0x36352c={};_0x36352c[_0x44f87a]={'$like':'%'+_0x30f0f9['query']['filter']+'%'};return _0x36352c;})});}_0x2194d7=_[_0xa671('0x7c')]({},_0x2194d7,_0x30f0f9[_0xa671('0x69')]);return db[_0xa671('0x80')]['count']({'where':_0x2194d7[_0xa671('0x65')]})[_0xa671('0x18')](function(_0x31836b){_0x8492d1[_0xa671('0x29')]=_0x31836b;if(_0x30f0f9['query']['includeAll']){_0x2194d7[_0xa671('0x6c')]=[{'all':!![]}];}return db[_0xa671('0x80')]['findAll'](_0x2194d7);})[_0xa671('0x18')](function(_0xa20825){_0x8492d1[_0xa671('0x7d')]=_0xa20825;return _0x8492d1;});}})['then'](respondWithFilteredResult(_0x3dac8c,_0x2194d7))['catch'](handleError(_0x3dac8c,null));};exports[_0xa671('0x83')]=function(_0x542735,_0x5c0e4a){return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x542735['params']['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x5c0e4a,null))['then'](function(_0x2c7e77){if(_0x2c7e77){return _0x2c7e77[_0xa671('0x83')](_0x542735['query'][_0xa671('0x7f')]);}})[_0xa671('0x18')](respondWithStatusCode(_0x5c0e4a,null))[_0xa671('0x22')](handleError(_0x5c0e4a,null));};exports[_0xa671('0x84')]=function(_0x361e3b,_0x31abe8){_0x361e3b[_0xa671('0x6f')][_0xa671('0x85')]=_0x361e3b[_0xa671('0x86')][_0xa671('0x87')];return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x361e3b[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x31abe8,null))[_0xa671('0x18')](saveUpdates(_0x361e3b['body'],null))[_0xa671('0x18')](respondWithResult(_0x31abe8,null))['catch'](handleError(_0x31abe8,null));};exports[_0xa671('0x88')]=function(_0x439141,_0x195019){_0x439141['body'][_0xa671('0x89')]=_0x439141[_0xa671('0x86')][_0xa671('0x87')];return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x439141[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x195019,null))[_0xa671('0x18')](saveUpdates(_0x439141[_0xa671('0x6f')],null))[_0xa671('0x18')](respondWithResult(_0x195019,null))[_0xa671('0x22')](handleError(_0x195019,null));};exports['addCustomerAvatar']=function(_0x51eed8,_0x8b5a88){_0x51eed8['body']['customerAvatar']=_0x51eed8[_0xa671('0x86')][_0xa671('0x87')];return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x51eed8[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x8b5a88,null))[_0xa671('0x18')](saveUpdates(_0x51eed8[_0xa671('0x6f')],null))[_0xa671('0x18')](respondWithResult(_0x8b5a88,null))[_0xa671('0x22')](handleError(_0x8b5a88,null));};exports[_0xa671('0x8a')]=function(_0x11cf22,_0x3fc688){_0x11cf22[_0xa671('0x6f')][_0xa671('0x8b')]=_0x11cf22[_0xa671('0x86')][_0xa671('0x87')];return db[_0xa671('0x59')]['find']({'where':{'id':_0x11cf22[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x3fc688,null))[_0xa671('0x18')](saveUpdates(_0x11cf22[_0xa671('0x6f')],null))['then'](respondWithResult(_0x3fc688,null))[_0xa671('0x22')](handleError(_0x3fc688,null));};exports[_0xa671('0x8c')]=function(_0x3879da,_0x443f39){var _0x239417=path[_0xa671('0x8d')](config[_0xa671('0x8e')],'server/files/images/logos/default_logo.svg');var _0x3223c6={'where':{'id':_0x3879da[_0xa671('0x75')]['id']},'attributes':['id',_0xa671('0x85')],'raw':!![]};var _0x321345=![];return require(_0xa671('0x8f'))[_0xa671('0x90')]()['then'](function(_0x28e306){if(_0x28e306){_0x321345=_0x28e306[_0xa671('0x91')];}})[_0xa671('0x18')](function(){return db[_0xa671('0x59')][_0xa671('0x6d')](_0x3223c6);})[_0xa671('0x18')](handleEntityNotFound(_0x443f39,null))[_0xa671('0x18')](function(_0x257c65){if(_0x257c65){if(!_[_0xa671('0x92')](_0x257c65[_0xa671('0x85')])){if(fs[_0xa671('0x93')](path[_0xa671('0x8d')](config[_0xa671('0x8e')],_0xa671('0x94'),_0x257c65[_0xa671('0x85')]))&&_0x321345){_0x239417=path[_0xa671('0x8d')](config[_0xa671('0x8e')],_0xa671('0x94'),_0x257c65['sitepic']);}}return _0x443f39[_0xa671('0x95')](_0x239417);}})[_0xa671('0x22')](handleError(_0x443f39,null));};exports['getAvatar']=function(_0x5d3057,_0x2f3514){var _0x4893d3=path['join'](config['root'],_0xa671('0x96'));var _0x276831={'where':{'id':_0x5d3057[_0xa671('0x75')]['id']},'attributes':['id',_0xa671('0x89')],'raw':!![]};return db[_0xa671('0x59')][_0xa671('0x6d')](_0x276831)[_0xa671('0x18')](handleEntityNotFound(_0x2f3514,null))[_0xa671('0x18')](function(_0x8eb126){if(_0x8eb126){if(!_['isNil'](_0x8eb126['agentAvatar'])){if(fs[_0xa671('0x93')](path['join'](config[_0xa671('0x8e')],_0xa671('0x97'),_0x8eb126['agentAvatar']))){_0x4893d3=path[_0xa671('0x8d')](config[_0xa671('0x8e')],'server/files/images/avatars/',_0x8eb126[_0xa671('0x89')]);}}return _0x2f3514[_0xa671('0x95')](_0x4893d3);}})['catch'](handleError(_0x2f3514,null));};exports[_0xa671('0x98')]=function(_0x5a2e12,_0x1a789b){var _0x1d1ff4=path[_0xa671('0x8d')](config[_0xa671('0x8e')],_0xa671('0x99'));var _0x441ecb={'where':{'id':_0x5a2e12['params']['id']},'attributes':['id','customerAvatar',_0xa671('0x9a')],'raw':!![]};return db['ChatWebsite'][_0xa671('0x6d')](_0x441ecb)[_0xa671('0x18')](handleEntityNotFound(_0x1a789b,null))[_0xa671('0x18')](function(_0x3e09d0){if(_0x3e09d0){if(!_[_0xa671('0x92')](_0x3e09d0[_0xa671('0x9b')])){if(fs[_0xa671('0x93')](path[_0xa671('0x8d')](config['root'],_0xa671('0x97'),_0x3e09d0[_0xa671('0x9b')]))&&_0x3e09d0[_0xa671('0x9a')]){_0x1d1ff4=path[_0xa671('0x8d')](config[_0xa671('0x8e')],_0xa671('0x97'),_0x3e09d0[_0xa671('0x9b')]);}}return _0x1a789b['download'](_0x1d1ff4);}})[_0xa671('0x22')](handleError(_0x1a789b,null));};exports[_0xa671('0x9c')]=function(_0x362c31,_0x42098e){var _0x44838a=path[_0xa671('0x8d')](config[_0xa671('0x8e')],_0xa671('0x9d'));var _0x45da4b={'where':{'id':_0x362c31['params']['id']},'attributes':['id',_0xa671('0x8b')],'raw':!![]};return db[_0xa671('0x59')][_0xa671('0x6d')](_0x45da4b)[_0xa671('0x18')](handleEntityNotFound(_0x42098e,null))['then'](function(_0x150978){if(_0x150978){if(!_['isNil'](_0x150978[_0xa671('0x8b')])){if(fs[_0xa671('0x93')](path[_0xa671('0x8d')](config['root'],_0xa671('0x97'),_0x150978[_0xa671('0x8b')]))){_0x44838a=path[_0xa671('0x8d')](config[_0xa671('0x8e')],'server/files/images/avatars/',_0x150978[_0xa671('0x8b')]);}}return _0x42098e[_0xa671('0x95')](_0x44838a);}})[_0xa671('0x22')](handleError(_0x42098e,null));};exports[_0xa671('0x9e')]=function(_0xd3307a,_0x2d126b){var _0x231a8d={'body':_0xd3307a[_0xa671('0x6f')],'channel':_0xa671('0x9f')};var _0x10d739=[];var _0x167912=[];var _0x26a137={};var _0x33786f=![];return db[_0xa671('0xa0')][_0xa671('0x76')]()[_0xa671('0x18')](function(_0x41e31c){if(!_0x41e31c){throw new db[(_0xa671('0xa1'))]['ValidationError'](_0xa671('0xa2'));}_0x10d739=_['difference'](_[_0xa671('0x82')](_0x41e31c),[_0xa671('0xa3'),'updatedAt']);_0x167912=_[_0xa671('0xa4')](_[_0xa671('0x82')](_0x41e31c),['createdAt',_0xa671('0xa5'),'CompanyId',_0xa671('0xa6')]);if(_0xd3307a[_0xa671('0x6f')]['id']){delete _0xd3307a[_0xa671('0x6f')]['id'];}if(_[_0xa671('0x92')](_0xd3307a[_0xa671('0x6f')][_0xa671('0xa7')])){throw new db[(_0xa671('0xa1'))][(_0xa671('0xa8'))](_0xa671('0xa9'));}if(_[_0xa671('0x92')](_0xd3307a[_0xa671('0x6f')]['body'])||_0xd3307a[_0xa671('0x6f')]['body']===''){throw new db[(_0xa671('0xa1'))][(_0xa671('0xa8'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_['isNil'](_0xd3307a[_0xa671('0x6f')][_0xa671('0xaa')])){throw new db[(_0xa671('0xa1'))][(_0xa671('0xa8'))](_0xa671('0xab')+_0x167912);}if(!_[_0xa671('0xac')](_0x167912,_0xd3307a[_0xa671('0x6f')][_0xa671('0xaa')])){throw new db['Sequelize'][(_0xa671('0xa8'))](_0xa671('0xad')+_0x167912);}_0x26a137[_0xd3307a['body'][_0xa671('0xaa')]]=_0xd3307a[_0xa671('0x6f')]['from'];})[_0xa671('0x18')](function(){return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0xd3307a[_0xa671('0x75')]['id']},'include':[{'model':db[_0xa671('0xae')],'as':_0xa671('0xaf'),'include':[{'model':db['CmContact'],'as':'Contacts','where':_0x26a137,'limit':0x1,'order':[[_0xa671('0xa5'),_0xa671('0xb0')]]}]},{'model':db[_0xa671('0xb1')],'as':_0xa671('0xb2')},{'model':db[_0xa671('0xb3')],'as':_0xa671('0xb3'),'include':[{'model':db[_0xa671('0xb3')],'as':_0xa671('0xb4'),'attributes':['id',_0xa671('0x38')],'raw':!![]}]}]});})[_0xa671('0x18')](function(_0x1a5606){if(!_0x1a5606)throw new APINotFoundError(util['format'](_0xa671('0xb5'),_0xd3307a['params']['id']));if(!_0x1a5606[_0xa671('0xb3')]||!_0x1a5606[_0xa671('0xb3')][_0xa671('0xb4')])return[_0x1a5606,!![]];return[_0x1a5606,checkWebsiteIntervals(_0x1a5606)];})['spread'](function(_0x40c7fe,_0x5db064){if(!_0x5db064)throw new APIOutOfIntervalError();if(!_0x40c7fe['List'])return;_0x231a8d[_0xa671('0xb6')]=_0x40c7fe;_0x231a8d[_0xa671('0xb7')]=_0x40c7fe[_0xa671('0xaf')];_0x231a8d[_0xa671('0xb8')]=_[_0xa671('0xb9')](_0x40c7fe[_0xa671('0xb2')],[_0xa671('0xba')],[_0xa671('0xbb')]);if(_0x231a8d[_0xa671('0xb6')][_0xa671('0xb2')]){delete _0x231a8d[_0xa671('0xb6')][_0xa671('0xb2')];}if(_0x231a8d[_0xa671('0xb6')][_0xa671('0xaf')]&&_0x231a8d[_0xa671('0xb6')][_0xa671('0xaf')][_0xa671('0xbc')][_0xa671('0x61')]){return _0x231a8d[_0xa671('0xb6')][_0xa671('0xaf')][_0xa671('0xbc')][0x0];}var _0x268793=_[_0xa671('0xbd')](_0xd3307a[_0xa671('0x6f')],{'firstName':_0xd3307a['body'][_0xa671('0xa7')],'ListId':_0x40c7fe['ListId']});_0x268793[_0xd3307a[_0xa671('0x6f')][_0xa671('0xaa')]]=_0xd3307a[_0xa671('0x6f')][_0xa671('0xa7')];return db[_0xa671('0xa0')]['create'](_0x268793,{'fields':_0x10d739,'raw':!![]});})[_0xa671('0x18')](function(_0x3c1892){_0x231a8d[_0xa671('0xbe')]=_0x3c1892;var _0x454ade=createInteractionObject(_0xd3307a['params']['id'],_0xd3307a['body'],_0xd3307a['headers'],_0x3c1892);var _0xcdd55c={'ChatWebsiteId':_0xd3307a[_0xa671('0x75')]['id'],'closed':![]};if(_0xd3307a['body']['threadId']){_0xcdd55c['threadId']=_0xd3307a[_0xa671('0x6f')]['threadId'];return db['ChatInteraction'][_0xa671('0x6d')]({'where':_0xcdd55c})[_0xa671('0x18')](function(_0x174dd0){if(_0x174dd0){_0x33786f=!![];return _0x174dd0;}_0x454ade[_0xa671('0xbf')]=_0xd3307a['body'][_0xa671('0xbf')];_0x454ade['externalUrl']=_0xd3307a[_0xa671('0x6f')][_0xa671('0xc0')];return db[_0xa671('0xc1')][_0xa671('0x6e')](_0x454ade);});}_0xcdd55c['ContactId']=_0x3c1892['id'];if(_0xd3307a[_0xa671('0x6f')][_0xa671('0xc2')]&&_0xd3307a[_0xa671('0x6f')][_0xa671('0xc2')]['id']){_0xcdd55c['id']=_0xd3307a[_0xa671('0x6f')][_0xa671('0xc2')]['id'];return db[_0xa671('0xc1')][_0xa671('0x6d')]({'where':_0xcdd55c})['then'](function(_0x2c5482){if(_0x2c5482){_0x33786f=!![];return _0x2c5482;}return db[_0xa671('0xc1')][_0xa671('0x6e')](_0x454ade);});}return db[_0xa671('0xc1')]['create'](_0x454ade);})[_0xa671('0x18')](function(_0x48368c){if(!_0x33786f)return _0x48368c;var _0x54a174={'from':(_0x231a8d[_0xa671('0xbe')][_0xa671('0x49')]||'')+'\x20'+(_0x231a8d[_0xa671('0xbe')][_0xa671('0x4a')]||'')};if(_0xd3307a[_0xa671('0x6f')][_0xa671('0xbf')]&&_0xd3307a[_0xa671('0x6f')][_0xa671('0xc3')]&&_0xd3307a['body'][_0xa671('0xbf')]!=_0xd3307a[_0xa671('0x6f')][_0xa671('0xc3')]){_0x54a174['threadId']=_0xd3307a[_0xa671('0x6f')][_0xa671('0xc3')];}return _0x48368c[_0xa671('0x2d')](_0x54a174);})[_0xa671('0x18')](function(_0x50bca0){_0x231a8d[_0xa671('0xc2')]=_0x50bca0['get']({'plain':!![]});_0x231a8d[_0xa671('0xc2')][_0xa671('0xc4')]=!_0x33786f;if(_0x231a8d[_0xa671('0xc2')][_0xa671('0xc4')]){if(_0x231a8d[_0xa671('0xb6')][_0xa671('0xc5')]){_0x231a8d['applications'][_0xa671('0xc6')]({'id':0x0,'priority':_0x231a8d[_0xa671('0xb8')]['length']+0x1,'app':_0xa671('0xc7'),'appdata':_0xa671('0xc8'),'interval':'*,*,*,*'});}}return db[_0xa671('0xc9')][_0xa671('0x6e')]({'body':_0xd3307a['body'][_0xa671('0x6f')],'ChatWebsiteId':_0xd3307a[_0xa671('0x75')]['id'],'ChatInteractionId':_0x50bca0['id'],'direction':'in','ContactId':_0x231a8d[_0xa671('0xbe')]['id'],'AttachmentId':_0xd3307a[_0xa671('0x6f')][_0xa671('0xca')]});})['then'](function(_0x5812b3){_0x231a8d[_0xa671('0x1f')]=_0x5812b3;if(!_0x231a8d[_0xa671('0xc2')][_0xa671('0xcb')]){return;}return db['User']['find']({'attributes':['id',_0xa671('0x33')],'where':{'id':_0x231a8d[_0xa671('0xc2')]['UserId']}});})[_0xa671('0x18')](function(_0x402863){if(_0x402863){_0x231a8d[_0xa671('0xb8')]['unshift']({'id':0x0,'priority':0x0,'app':_0xa671('0xcc'),'appdata':_0x402863[_0xa671('0x33')]+','+(_0x231a8d[_0xa671('0xb6')][_0xa671('0xcd')]||0xa),'interval':_0xa671('0xce')});_0x231a8d[_0xa671('0xcf')]=!![];}if(!_0x231a8d[_0xa671('0xc2')][_0xa671('0xd0')]){return;}return db[_0xa671('0xd1')][_0xa671('0x6d')]({'attributes':['id',_0xa671('0x33')],'where':{'id':_0x231a8d[_0xa671('0xc2')][_0xa671('0xd0')]}});})[_0xa671('0x18')](function(_0x33ad5c){if(_0x33ad5c){_0x231a8d['applications'][_0xa671('0xd2')]({'id':0x0,'priority':0x1,'app':_0xa671('0xd3'),'appdata':_0x33ad5c[_0xa671('0x33')]+','+(_0x231a8d[_0xa671('0xb6')][_0xa671('0xd4')]||0x12c),'interval':_0xa671('0xce')});}return respondWithRpcPromise(_0xa671('0xd5'),_0xa671('0xd6'),_0x231a8d);})[_0xa671('0x18')](function(_0x585c86){respondWithRpcPromise(_0xa671('0xd7'),_0xa671('0xd7'),{'event':_0xa671('0x9e'),'message':_0x585c86},client9002);return _0x585c86;})[_0xa671('0x18')](respondWithResult(_0x2d126b,null))[_0xa671('0x22')](APIHandleError(_0x2d126b));};exports[_0xa671('0xd8')]=function(_0x5a1f38,_0x4dbeb5){var _0x21b488,_0x315f1e,_0x5e28e8;var _0x4c3d6d=[];var _0x9ca8c2={};var _0xb50ab9=_0x5a1f38[_0xa671('0xd9')]||[];var _0x6baa4d=[];var _0x37a5b9;return db[_0xa671('0xa0')][_0xa671('0x76')]()[_0xa671('0x18')](function(_0x32295e){if(!_0x32295e){throw new db['Sequelize'][(_0xa671('0xa8'))](_0xa671('0xa2'));}_0x4c3d6d=_['difference'](_['keys'](_0x32295e),[_0xa671('0xa3'),_0xa671('0xa5'),_0xa671('0xda'),'ListId']);if(_0x5a1f38[_0xa671('0x6f')]['id']){delete _0x5a1f38[_0xa671('0x6f')]['id'];}if(_[_0xa671('0x92')](_0x5a1f38[_0xa671('0x6f')][_0xa671('0xa7')])){throw _0x4dbeb5[_0xa671('0x24')](0x1f4)['send'](new db[(_0xa671('0xa1'))][(_0xa671('0xa8'))](_0xa671('0xa9')));}if(_[_0xa671('0x92')](_0x5a1f38[_0xa671('0x6f')][_0xa671('0x6f')])||_0x5a1f38[_0xa671('0x6f')][_0xa671('0x6f')]===''){throw _0x4dbeb5[_0xa671('0x24')](0x1f4)[_0xa671('0xdb')](new db[(_0xa671('0xa1'))][(_0xa671('0xa8'))]('body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0xa671('0x92')](_0x5a1f38[_0xa671('0x6f')]['mapKeyOffline'])){throw _0x4dbeb5[_0xa671('0x24')](0x1f4)[_0xa671('0xdb')](new db[(_0xa671('0xa1'))][(_0xa671('0xa8'))](_0xa671('0xdc')+_0x4c3d6d));}if(!_[_0xa671('0xac')](_0x4c3d6d,_0x5a1f38[_0xa671('0x6f')][_0xa671('0xdd')])){throw _0x4dbeb5[_0xa671('0x24')](0x1f4)[_0xa671('0xdb')](new db['Sequelize']['ValidationError'](_0xa671('0xde')+_0x4c3d6d));}_0x9ca8c2[_0x5a1f38[_0xa671('0x6f')][_0xa671('0xdd')]]=_0x5a1f38[_0xa671('0x6f')]['from'];})[_0xa671('0x18')](function(){return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x5a1f38[_0xa671('0x75')]['id']},'include':[{'model':db['CmList'],'as':_0xa671('0xaf')},{'model':db[_0xa671('0xdf')],'as':_0xa671('0xdf')}]});})[_0xa671('0x18')](handleEntityNotFound(_0x4dbeb5,null))['then'](function(_0x44688e){if(_0x44688e&&_0x44688e['List']){_0x315f1e=_0x44688e;var _0x3f1ed2=_[_0xa671('0xbd')](_0x5a1f38[_0xa671('0x6f')],{'firstName':_0x5a1f38[_0xa671('0x6f')][_0xa671('0xa7')],'phone':_0x5a1f38['body'][_0xa671('0xa7')],'ListId':_0x44688e[_0xa671('0xa6')]});_0x3f1ed2[_0x5a1f38[_0xa671('0x6f')][_0xa671('0xdd')]]=_0x5a1f38[_0xa671('0x6f')][_0xa671('0xa7')];return db[_0xa671('0xa0')][_0xa671('0xe0')]({'where':_0x9ca8c2,'defaults':_0x3f1ed2});}})[_0xa671('0xe1')](function(_0xa34564){if(_0xa34564){_0x5e28e8=_0xa34564;var _0x2a3d8e=fs[_0xa671('0xe2')](path['join'](config[_0xa671('0x8e')],'server/files/templates/chatOfflineMessage.ejs'),'utf8');var _0x244e61=ejs['render'](_0x2a3d8e,{'body':_[_0xa671('0xe3')](_0x5a1f38['body'][_0xa671('0x6f')]),'bodyTitle':_0x315f1e[_0xa671('0xe4')]});return db[_0xa671('0xe5')]['create']({'body':_0x244e61,'plainBody':htmlToText[_0xa671('0xe6')](_0x244e61),'ContactId':_0xa34564['id'],'ChatWebsiteId':_0x315f1e['id']});}})[_0xa671('0x18')](function(_0x2ef7a6){_0x37a5b9=_0x2ef7a6;if(_0xb50ab9['length']){var _0x220a1b=_0xb50ab9['map'](function(_0x194bf5){return{'name':_0x194bf5['originalname'],'basename':_0x194bf5[_0xa671('0x87')],'type':_0x194bf5['mimetype'],'ChatOfflineMessageId':_0x2ef7a6['id']};});_0x6baa4d=_0x220a1b[_0xa671('0x3e')](_0x5603b5=>{var _0x4ba825={'filename':_0x5603b5[_0xa671('0x33')],'path':path[_0xa671('0x8d')](config[_0xa671('0x8e')],_0xa671('0xe7'),'files',_0xa671('0xe8'),_0xa671('0xe9'),_0x5603b5[_0xa671('0xea')])};return _0x4ba825;});if(!_0x315f1e[_0xa671('0xeb')]){return db['sequelize'][_0xa671('0xec')](function(_0x62f02f){return db[_0xa671('0xed')]['bulkCreate'](_0x220a1b,{'transaction':_0x62f02f});});}}})['then'](function(){if(_0x37a5b9){_0x21b488=_0x37a5b9;return db[_0xa671('0xdf')][_0xa671('0x79')]({'where':{'service':!![]},'include':[{'model':db['MailServerOut'],'as':_0xa671('0xee'),'raw':!![],'include':[{'model':db[_0xa671('0xef')],'as':_0xa671('0xef'),'raw':!![]}]}]});}})['then'](function(_0x24274b){if(_0x24274b&&_0x24274b[_0xa671('0xee')]&&_0x315f1e[_0xa671('0xf0')]&&_0x315f1e[_0xa671('0xf1')]){var _0x58a2bf=_0x24274b[_0xa671('0xf2')]();return respondWithRpcPromise(_0xa671('0xf3'),'sendMail',{'account':_0x58a2bf,'message':{'from':util[_0xa671('0x37')](_0xa671('0xf4'),_0x24274b['name'],_0x24274b[_0xa671('0xf5')]||_0x24274b[_0xa671('0xee')][_0xa671('0xf6')]),'to':_0x315f1e[_0xa671('0xf1')],'subject':_0x315f1e[_0xa671('0xf7')],'html':_0x21b488['body'],'attachments':_0x6baa4d}},client9003)[_0xa671('0x18')](function(){return _0x21b488;})[_0xa671('0x22')](function(_0x2cc72e){logger[_0xa671('0x1d')](_0x2cc72e);});}})['then'](function(){if(_0x315f1e&&_0x315f1e['openNewInteraction']&&_0x315f1e[_0xa671('0xf8')]){var _0xde4625=[];if(_0xb50ab9['length']){_0xde4625=_0xb50ab9['map'](function(_0x1f6e3a){return{'name':_0x1f6e3a[_0xa671('0xf9')],'basename':_0x1f6e3a[_0xa671('0x87')],'type':_0x1f6e3a[_0xa671('0xfa')],'ChatOfflineMessageId':_0x37a5b9['id']};});}var _0x6d444f;if(!_['isNil'](_0x315f1e[_0xa671('0xfb')])){var _0x389ef5=_['map'](_0x5a1f38[_0xa671('0x6f')],function(_0x56a103){return _0x56a103;});var _0x3c52b1=_[_0xa671('0xfc')](_0x389ef5)[0x0];var _0x21b4f1=_['mapValues'](_0x3c52b1,function(_0x3db0c4){return _0x3db0c4;});_0x6d444f=_0x21b4f1[0x1][_0x315f1e[_0xa671('0xfb')]];}var _0x416a0c={'from':_0x5e28e8[_0xa671('0xf5')],'firstName':_0x5e28e8[_0xa671('0x49')],'lastName':_0x5e28e8[_0xa671('0x4a')],'mapKey':_0xa671('0xf5'),'message':{'from':_0x5e28e8[_0xa671('0xf5')],'to':_0x315f1e['MailAccount'][_0xa671('0xf5')],'cc':'','subject':_[_0xa671('0x92')](_0x6d444f)?_0x315f1e[_0xa671('0xf7')]:_0x6d444f,'messageId':'','sentAt':new Date(),'attach':_0xde4625['length'],'attachments':_0xde4625,'originChannel':'Chat','ChatWebsiteId':_0x315f1e['id'],'ChatOfflineMessageId':_0x21b488['id'],'originTo':_0x315f1e['MailAccount'][_0xa671('0xf5')]},'body':_0x21b488[_0xa671('0x6f')]};var _0x180f0d={'account':{'id':_0x315f1e[_0xa671('0xf8')]},'body':_0x416a0c,'log':'NotifyMailAccount'};return respondWithRpcPromise(_0xa671('0xfd'),_0xa671('0xfe'),_0x180f0d,client9001)[_0xa671('0x18')](function(){return _0x21b488;})[_0xa671('0x22')](function(_0x416384){logger[_0xa671('0x1d')](_0x416384);});}return;})['then'](function(){if(_0x21b488){return _0x21b488;}})[_0xa671('0x18')](respondWithResult(_0x4dbeb5,null))[_0xa671('0x22')](function(){for(var _0x50dde1 of _0xb50ab9){var _0x3ef76a=path[_0xa671('0x8d')](config['root'],_0xa671('0xe7'),_0xa671('0xd9'),'attachments',_0xa671('0xe9'),_0x50dde1[_0xa671('0x87')]);fs_extra['remove'](_0x3ef76a)['catch'](function(_0x41e0b3){logger['error'](_0xa671('0xff'),_0x3ef76a,_0x41e0b3);});}});};exports[_0xa671('0x100')]=function(_0x1fa555,_0x59a8bb){return db[_0xa671('0xc1')]['find']({'where':{'id':_0x1fa555[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x59a8bb,null))[_0xa671('0x18')](function(_0x16fdfd){if(_0x16fdfd){return _0x16fdfd[_0xa671('0x100')](_0x1fa555['body'][_0xa671('0x7f')],_[_0xa671('0x101')](_0x1fa555['body'],[_0xa671('0x7f'),'id'])||{});}})['then'](respondWithResult(_0x59a8bb,null))[_0xa671('0x22')](handleError(_0x59a8bb,null));};exports[_0xa671('0x102')]=function(_0x57255b,_0x4fd3cc){var _0x50371f={'raw':![],'where':{}};var _0x36a3b9={};var _0x53d56f={'count':0x0,'rows':[]};return db[_0xa671('0x59')][_0xa671('0x79')]({'where':{'id':_0x57255b[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x4fd3cc,null))[_0xa671('0x18')](function(_0x3b4cd7){if(_0x3b4cd7){_0x36a3b9[_0xa671('0x54')]=_[_0xa671('0x82')](db[_0xa671('0xc1')][_0xa671('0x5a')]);_0x36a3b9[_0xa671('0x5d')]=_[_0xa671('0x82')](_0x57255b[_0xa671('0x5d')]);_0x36a3b9[_0xa671('0x66')]=_[_0xa671('0x5e')](_0x36a3b9['model'],_0x36a3b9['query']);_0x50371f[_0xa671('0x5f')]=_[_0xa671('0x5e')](_0x36a3b9['model'],qs[_0xa671('0x60')](_0x57255b[_0xa671('0x5d')]['fields']));_0x50371f[_0xa671('0x5f')]=_0x50371f[_0xa671('0x5f')][_0xa671('0x61')]?_0x50371f[_0xa671('0x5f')]:_0x36a3b9[_0xa671('0x54')];if(!_0x57255b['query'][_0xa671('0x62')]('nolimit')){_0x50371f['limit']=qs[_0xa671('0x2a')](_0x57255b[_0xa671('0x5d')]['limit']);_0x50371f[_0xa671('0x27')]=qs[_0xa671('0x27')](_0x57255b[_0xa671('0x5d')][_0xa671('0x27')]);}_0x50371f[_0xa671('0x7a')]=qs[_0xa671('0x64')](_0x57255b[_0xa671('0x5d')][_0xa671('0x64')]);_0x50371f['where']=qs['filters'](_[_0xa671('0x67')](_0x57255b['query'],_0x36a3b9[_0xa671('0x66')]));_0x50371f[_0xa671('0x65')][_0xa671('0x7b')]=_0x3b4cd7['id'];if(_0x57255b[_0xa671('0x5d')][_0xa671('0x68')]){_0x50371f[_0xa671('0x65')]=_[_0xa671('0x7c')](_0x50371f['where'],{'$or':_['map'](_0x50371f[_0xa671('0x5f')],function(_0x390352){var _0x479ecd={};_0x479ecd[_0x390352]={'$like':'%'+_0x57255b[_0xa671('0x5d')]['filter']+'%'};return _0x479ecd;})});}_0x50371f=_['merge']({},_0x50371f,_0x57255b[_0xa671('0x69')]);return db[_0xa671('0xc1')]['count']({'where':_0x50371f[_0xa671('0x65')]})[_0xa671('0x18')](function(_0x5a7b1a){_0x53d56f['count']=_0x5a7b1a;if(_0x57255b[_0xa671('0x5d')][_0xa671('0x6a')]){_0x50371f[_0xa671('0x6c')]=[{'model':db[_0xa671('0xa0')],'as':_0xa671('0x103'),'required':![]},{'model':db['User'],'as':_0xa671('0x104'),'attributes':['name',_0xa671('0x105'),'internal'],'required':![]},{'model':db[_0xa671('0x106')],'as':_0xa671('0x107'),'attributes':['id',_0xa671('0x33'),_0xa671('0x108')],'where':_0x57255b[_0xa671('0x5d')]['tag']?{'id':_0x57255b['query'][_0xa671('0x109')]}:undefined,'required':_0x57255b[_0xa671('0x5d')]['tag']?!![]:![]}];}return db[_0xa671('0xc1')]['findAll'](_0x50371f);})[_0xa671('0x18')](function(_0xb90da4){_0x53d56f['rows']=_0xb90da4;return _0x53d56f;});}})[_0xa671('0x18')](respondWithFilteredResult(_0x4fd3cc,_0x50371f))[_0xa671('0x22')](handleError(_0x4fd3cc,null));};exports[_0xa671('0x35')]=function(_0x521972,_0xfc8411){var _0x5c6dbe=0x0;var _0x52fea4=0x0;var _0x5aeae1=![];var _0x9e00af;var _0x2540f7;return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x521972[_0xa671('0x75')]['id']},'include':[{'model':db[_0xa671('0xb3')],'as':_0xa671('0xb3'),'include':[{'model':db[_0xa671('0xb3')],'as':'Intervals','attributes':['id','interval']}]}]})[_0xa671('0x18')](handleEntityNotFound(_0xfc8411,null))[_0xa671('0x18')](function(_0x5b9266){if(_0x5b9266){_0x9e00af=_0x5b9266;return _0x5b9266['getProactiveActions']({'raw':!![]});}})[_0xa671('0x18')](function(_0x1b77ff){if(_0x9e00af){if(_0x1b77ff){_0x2540f7=_0x1b77ff;}}return require('../../config/license/util')[_0xa671('0x90')]();})[_0xa671('0x18')](function(_0x337e9b){if(_0x337e9b){_0x52fea4=_0x337e9b['virtual'];_0x5aeae1=_0x337e9b[_0xa671('0x91')];}})[_0xa671('0x18')](function(){return db['ChatInteraction'][_0xa671('0x29')]({'where':{'closed':![]}});})[_0xa671('0x18')](function(_0x597081){_0x5c6dbe=_0x597081;if(_0x52fea4&&_0x597081>_0x52fea4){return db[_0xa671('0x10a')][_0xa671('0x79')]({'where':{'id':0x1}})[_0xa671('0x18')](function(_0x49deae){if(_0x49deae){_0x49deae['increment'](_0xa671('0x10b'));}});}})[_0xa671('0x18')](function(){if(!_0x9e00af[_0xa671('0xb3')]||!_0x9e00af['Interval'][_0xa671('0xb4')])return!![];return checkWebsiteIntervals(_0x9e00af);})[_0xa671('0x18')](function(_0x1e0044){var _0x397098=fs['readFileSync'](path[_0xa671('0x8d')](config[_0xa671('0x8e')],_0xa671('0x10c')),_0xa671('0x10d'));var _0x3eddb1=new url[(_0xa671('0x10e'))](_0x9e00af['address'])[_0xa671('0x10f')];var _0x2b7a58=_0xa671('0x110');var _0x31f00a=![];var _0x5822cb={'chatVersion':_0x2b7a58,'chatWebsiteAddressOrigin':_0x3eddb1,'remote':_0x9e00af[_0xa671('0x111')],'query':querystring[_0xa671('0x1c')](_['merge'](_0x9e00af[_0xa671('0x2f')]({'plain':!![]}),{'customerIp':_0x521972[_0xa671('0x112')][_0xa671('0x47')]||_0x521972[_0xa671('0x112')][_0xa671('0x113')]||_0x521972['connection'][_0xa671('0x114')]||_0x521972['ip'],'referer':_0x521972[_0xa671('0x112')][_0xa671('0x4c')],'openedInteractions':_0x5c6dbe,'maxInteractions':_0x52fea4,'virtual':_0x5aeae1[_0xa671('0x115')],'online':_0x1e0044,'custom':_0x5aeae1}))[_0xa671('0x116')](/'/g,'\x5c\x27')};_0xfc8411['send'](ejs['render'](Mustache[_0xa671('0x117')](_0x397098,_0x5822cb),{'proactiveActions':_0x2540f7,'alignment':_0x9e00af[_0xa671('0x118')],'verticalAlignment':_0x9e00af[_0xa671('0x119')],'div_color':_0x9e00af['color'],'labelText':_0x9e00af[_0xa671('0x11a')],'text_color':_0x9e00af['textColor'],'text_button_color':_0x9e00af[_0xa671('0x11b')],'button_color':_0x9e00af[_0xa671('0x11c')],'background_color':_0x9e00af[_0xa671('0x11d')],'hideWhenOffline':_0x9e00af[_0xa671('0x11e')],'intervalId':_0x9e00af[_0xa671('0x11f')],'isDevelopment':_0x31f00a,'chatVersion':_0x2b7a58}));})[_0xa671('0x22')](handleError(_0xfc8411,null));};exports[_0xa671('0x120')]=function(_0x120c67,_0x16b53a){var _0x1d8dc2=_0x120c67[_0xa671('0x75')]['id'];var _0x321f05=_0x120c67[_0xa671('0x6f')];var _0x4cbcde=0xc8;var _0xbd77db=null;return db[_0xa671('0x121')][_0xa671('0xec')]({'isolationLevel':db['sequelize'][_0xa671('0x122')][_0xa671('0x123')][_0xa671('0x124')]},function(_0x21930d){return db[_0xa671('0x59')][_0xa671('0x79')]({'where':{'id':_0x1d8dc2},'transaction':_0x21930d})[_0xa671('0x18')](function(_0x5abd3e){if(_0x5abd3e){return db[_0xa671('0xb1')]['destroy']({'where':{'ChatWebsiteId':_0x1d8dc2},'transaction':_0x21930d})[_0xa671('0x18')](function(){var _0x22e985=_[_0xa671('0x3e')](_0x321f05,function(_0x2fc56f){_0x2fc56f[_0xa671('0x7b')]=_0x1d8dc2;return _0x2fc56f;});return db['ChatApplication']['bulkCreate'](_0x22e985,{'transaction':_0x21930d});});}else{_0x4cbcde=0x194;_0xbd77db=[];}});})[_0xa671('0x18')](function(){if(_0x4cbcde!==0x194){return db[_0xa671('0xb1')][_0xa671('0x125')]({'where':{'ChatWebsiteId':_0x1d8dc2},'order':_0xa671('0xba')})['then'](function(_0x31feef){_0xbd77db=_0x31feef;});}})['catch'](function(_0x2987cf){_0x4cbcde=0x1f4;logger['error'](_0x2987cf[_0xa671('0x32')]);if(_0x2987cf[_0xa671('0x33')]){delete _0x2987cf['name'];}_0xbd77db=_0x2987cf;})[_0xa671('0x126')](function(){if(_0xbd77db===null){_0x16b53a['sendStatus'](_0x4cbcde);}else{if(_0x4cbcde===0x1f4){_0x16b53a[_0xa671('0x24')](_0x4cbcde)['send'](_0xbd77db);}else{_0x16b53a[_0xa671('0x24')](_0x4cbcde)[_0xa671('0x26')](_0xbd77db);}}});};exports['getApplications']=function(_0x501737,_0x3d30ff){var _0x2fa4d0={};var _0x1ec719={};var _0x2e289e;var _0x4e24e0;return db[_0xa671('0x59')][_0xa671('0x79')]({'where':{'id':_0x501737[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x3d30ff,null))['then'](function(_0x190d20){if(_0x190d20){_0x2e289e=_0x190d20;_0x1ec719[_0xa671('0x54')]=_[_0xa671('0x82')](db[_0xa671('0xb1')][_0xa671('0x5a')]);_0x1ec719[_0xa671('0x5d')]=_[_0xa671('0x82')](_0x501737[_0xa671('0x5d')]);_0x1ec719['filters']=_['intersection'](_0x1ec719[_0xa671('0x54')],_0x1ec719['query']);_0x2fa4d0[_0xa671('0x5f')]=_[_0xa671('0x5e')](_0x1ec719[_0xa671('0x54')],qs[_0xa671('0x60')](_0x501737[_0xa671('0x5d')][_0xa671('0x60')]));_0x2fa4d0[_0xa671('0x5f')]=_0x2fa4d0[_0xa671('0x5f')][_0xa671('0x61')]?_0x2fa4d0['attributes']:_0x1ec719[_0xa671('0x54')];_0x2fa4d0[_0xa671('0x7a')]=qs['sort'](_0x501737[_0xa671('0x5d')]['sort']);_0x2fa4d0[_0xa671('0x65')]=qs[_0xa671('0x66')](_[_0xa671('0x67')](_0x501737[_0xa671('0x5d')],_0x1ec719[_0xa671('0x66')]));if(_0x501737['query']['filter']){_0x2fa4d0['where']=_['merge'](_0x2fa4d0[_0xa671('0x65')],{'$or':_[_0xa671('0x3e')](_0x2fa4d0[_0xa671('0x5f')],function(_0x5624b6){var _0x4043f6={};_0x4043f6[_0x5624b6]={'$like':'%'+_0x501737[_0xa671('0x5d')]['filter']+'%'};return _0x4043f6;})});}_0x2fa4d0=_[_0xa671('0x7c')]({},_0x2fa4d0,_0x501737[_0xa671('0x69')]);return _0x2e289e[_0xa671('0x127')](_0x2fa4d0);}})['then'](function(_0x498ace){if(_0x498ace){_0x4e24e0=_0x498ace[_0xa671('0x61')];if(!_0x501737[_0xa671('0x5d')][_0xa671('0x62')](_0xa671('0x63'))){_0x2fa4d0['limit']=qs['limit'](_0x501737['query'][_0xa671('0x2a')]);_0x2fa4d0[_0xa671('0x27')]=qs['offset'](_0x501737[_0xa671('0x5d')]['offset']);}return _0x2e289e[_0xa671('0x127')](_0x2fa4d0);}})[_0xa671('0x18')](function(_0x2f2a4e){if(_0x2f2a4e){return _0x2f2a4e?{'count':_0x4e24e0,'rows':_0x2f2a4e}:null;}})['then'](respondWithResult(_0x3d30ff,null))[_0xa671('0x22')](handleError(_0x3d30ff,null));};exports[_0xa671('0x128')]=function(_0x5ed53c,_0x865393){return db['chatProactiveAction'][_0xa671('0x6d')]({'where':{'id':_0x5ed53c[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x865393,null))[_0xa671('0x18')](function(_0x4c46e8){if(_0x4c46e8){return _0x4c46e8[_0xa671('0x128')](_0x5ed53c[_0xa671('0x6f')][_0xa671('0x7f')],_[_0xa671('0x101')](_0x5ed53c[_0xa671('0x6f')],['ids','id'])||{});}})[_0xa671('0x18')](respondWithResult(_0x865393,null))[_0xa671('0x22')](handleError(_0x865393,null));};exports[_0xa671('0x129')]=function(_0x3fa742,_0xbfbc0a){var _0x264652={};var _0x2daf8f={};var _0x9c44ce;var _0x229bbc;return db['ChatWebsite']['findOne']({'where':{'id':_0x3fa742['params']['id']}})[_0xa671('0x18')](handleEntityNotFound(_0xbfbc0a,null))[_0xa671('0x18')](function(_0x151ca9){if(_0x151ca9){_0x9c44ce=_0x151ca9;_0x2daf8f[_0xa671('0x54')]=_['keys'](db[_0xa671('0x12a')][_0xa671('0x5a')]);_0x2daf8f['query']=_['keys'](_0x3fa742[_0xa671('0x5d')]);_0x2daf8f[_0xa671('0x66')]=_['intersection'](_0x2daf8f['model'],_0x2daf8f[_0xa671('0x5d')]);_0x264652[_0xa671('0x5f')]=_[_0xa671('0x5e')](_0x2daf8f[_0xa671('0x54')],qs[_0xa671('0x60')](_0x3fa742['query']['fields']));_0x264652['attributes']=_0x264652[_0xa671('0x5f')][_0xa671('0x61')]?_0x264652['attributes']:_0x2daf8f[_0xa671('0x54')];_0x264652[_0xa671('0x7a')]=qs[_0xa671('0x64')](_0x3fa742[_0xa671('0x5d')][_0xa671('0x64')]);_0x264652[_0xa671('0x65')]=qs['filters'](_[_0xa671('0x67')](_0x3fa742[_0xa671('0x5d')],_0x2daf8f['filters']));if(_0x3fa742[_0xa671('0x5d')][_0xa671('0x68')]){_0x264652[_0xa671('0x65')]=_[_0xa671('0x7c')](_0x264652['where'],{'$or':_[_0xa671('0x3e')](_0x264652[_0xa671('0x5f')],function(_0x535e9b){var _0x54a2e5={};_0x54a2e5[_0x535e9b]={'$like':'%'+_0x3fa742['query'][_0xa671('0x68')]+'%'};return _0x54a2e5;})});}_0x264652=_[_0xa671('0x7c')]({},_0x264652,_0x3fa742[_0xa671('0x69')]);return _0x9c44ce[_0xa671('0x129')](_0x264652);}})[_0xa671('0x18')](function(_0x121d94){if(_0x121d94){_0x229bbc=_0x121d94['length'];if(!_0x3fa742[_0xa671('0x5d')][_0xa671('0x62')](_0xa671('0x63'))){_0x264652['limit']=qs[_0xa671('0x2a')](_0x3fa742[_0xa671('0x5d')]['limit']);_0x264652[_0xa671('0x27')]=qs[_0xa671('0x27')](_0x3fa742['query']['offset']);}return _0x9c44ce['getProactiveActions'](_0x264652);}})[_0xa671('0x18')](function(_0x352a8d){if(_0x352a8d){return _0x352a8d?{'count':_0x229bbc,'rows':_0x352a8d}:null;}})['then'](respondWithResult(_0xbfbc0a,null))[_0xa671('0x22')](handleError(_0xbfbc0a,null));};exports[_0xa671('0x12b')]=function(_0x12e571,_0x122484){var _0x5cd8ec=_0x12e571[_0xa671('0x5d')][_0xa671('0x12c')]==='false'?_0xa671('0x12d'):'onlineForm';return db[_0xa671('0x59')]['find']({'attributes':['id',_0x5cd8ec],'where':{'id':_0x12e571['params']['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x122484,null))[_0xa671('0x18')](function(_0x8c001e){if(_0x8c001e){var _0x57dff4=_0x8c001e[_0x5cd8ec];var _0x234a0e=_0x57dff4&&_0x57dff4['items']?_0x57dff4[_0xa671('0x12e')]:[];_0x122484[_0xa671('0xdb')]({'fromKey':_[_0xa671('0x92')](_0x57dff4[_0xa671('0x12f')])?undefined:_0x57dff4[_0xa671('0x12f')],'count':_0x234a0e[_0xa671('0x61')],'rows':_0x234a0e});}})[_0xa671('0x22')](handleError(_0x122484,null));};exports[_0xa671('0x130')]=function(_0x1bd02e,_0x118962){var _0x19696a={'raw':![],'where':{}};var _0x4a0a08={};var _0x5c40e7={'count':0x0,'rows':[]};return db[_0xa671('0x59')][_0xa671('0x79')]({'where':{'id':_0x1bd02e[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x118962,null))[_0xa671('0x18')](function(_0x13502f){if(_0x13502f){_0x4a0a08['model']=_['keys'](db[_0xa671('0xe5')]['rawAttributes']);_0x4a0a08[_0xa671('0x5d')]=_[_0xa671('0x82')](_0x1bd02e[_0xa671('0x5d')]);_0x4a0a08['filters']=_['intersection'](_0x4a0a08[_0xa671('0x54')],_0x4a0a08[_0xa671('0x5d')]);_0x19696a[_0xa671('0x5f')]=_[_0xa671('0x5e')](_0x4a0a08[_0xa671('0x54')],qs[_0xa671('0x60')](_0x1bd02e[_0xa671('0x5d')][_0xa671('0x60')]));_0x19696a[_0xa671('0x5f')]=_0x19696a[_0xa671('0x5f')][_0xa671('0x61')]?_0x19696a['attributes']:_0x4a0a08[_0xa671('0x54')];if(!_0x1bd02e[_0xa671('0x5d')][_0xa671('0x62')]('nolimit')){_0x19696a[_0xa671('0x2a')]=qs[_0xa671('0x2a')](_0x1bd02e['query'][_0xa671('0x2a')]);_0x19696a[_0xa671('0x27')]=qs[_0xa671('0x27')](_0x1bd02e[_0xa671('0x5d')][_0xa671('0x27')]);}_0x19696a[_0xa671('0x7a')]=qs[_0xa671('0x64')](_0x1bd02e[_0xa671('0x5d')][_0xa671('0x64')]);_0x19696a[_0xa671('0x65')]=qs[_0xa671('0x66')](_[_0xa671('0x67')](_0x1bd02e['query'],_0x4a0a08[_0xa671('0x66')]));_0x19696a[_0xa671('0x65')][_0xa671('0x7b')]=_0x13502f['id'];if(_0x1bd02e[_0xa671('0x5d')][_0xa671('0x68')]){_0x19696a[_0xa671('0x65')]=_[_0xa671('0x7c')](_0x19696a[_0xa671('0x65')],{'$or':_['map'](_0x19696a[_0xa671('0x5f')],function(_0x49c6d8){var _0x1e1a36={};_0x1e1a36[_0x49c6d8]={'$like':'%'+_0x1bd02e[_0xa671('0x5d')][_0xa671('0x68')]+'%'};return _0x1e1a36;})});}_0x19696a=_[_0xa671('0x7c')]({},_0x19696a,_0x1bd02e[_0xa671('0x69')]);return db[_0xa671('0xe5')][_0xa671('0x29')]({'where':_0x19696a[_0xa671('0x65')]})[_0xa671('0x18')](function(_0x73202e){_0x5c40e7['count']=_0x73202e;if(_0x1bd02e[_0xa671('0x5d')][_0xa671('0x6a')]){_0x19696a[_0xa671('0x6c')]=[{'all':!![]}];}else{_0x19696a[_0xa671('0x6c')]=[{'model':db[_0xa671('0xa0')],'as':_0xa671('0x103'),'required':![]},{'model':db[_0xa671('0xed')],'as':_0xa671('0x131'),'required':![]}];}return db['ChatOfflineMessage']['findAll'](_0x19696a);})[_0xa671('0x18')](function(_0x45da8){_0x5c40e7[_0xa671('0x7d')]=_0x45da8;return _0x5c40e7;});}})[_0xa671('0x18')](respondWithFilteredResult(_0x118962,_0x19696a))[_0xa671('0x22')](handleError(_0x118962,null));};exports['addAgents']=function(_0x2dde91,_0x1b31f9){return db[_0xa671('0x59')][_0xa671('0x6d')]({'where':{'id':_0x2dde91['params']['id']}})['then'](handleEntityNotFound(_0x1b31f9,null))[_0xa671('0x18')](function(_0xe280ef){if(_0xe280ef){return _0xe280ef[_0xa671('0x132')](_0x2dde91[_0xa671('0x6f')]['ids'],_[_0xa671('0x101')](_0x2dde91['body'],[_0xa671('0x7f'),'id'])||{})['spread'](function(_0x405da2){for(var _0x37b5e4=0x0;_0x37b5e4<_0x2dde91[_0xa671('0x6f')][_0xa671('0x7f')][_0xa671('0x61')];_0x37b5e4+=0x1){socket['emit']('userChatWebsite:save',{'UserId':Number(_0x2dde91['body'][_0xa671('0x7f')][_0x37b5e4]),'ChatWebsiteId':Number(_0x2dde91[_0xa671('0x75')]['id'])});}return _0x405da2;});}})['then'](respondWithResult(_0x1b31f9,null))['catch'](handleError(_0x1b31f9,null));};exports[_0xa671('0x133')]=function(_0x50a31a,_0x2e0525){return db[_0xa671('0x59')]['find']({'where':{'id':_0x50a31a[_0xa671('0x75')]['id']}})['then'](handleEntityNotFound(_0x2e0525,null))['then'](function(_0x220bc6){if(_0x220bc6){return _0x220bc6[_0xa671('0x133')](_0x50a31a['query'][_0xa671('0x7f')])['then'](function(){if(_[_0xa671('0x134')](_0x50a31a[_0xa671('0x5d')][_0xa671('0x7f')])){for(var _0xcfe4eb=0x0;_0xcfe4eb<_0x50a31a[_0xa671('0x5d')][_0xa671('0x7f')][_0xa671('0x61')];_0xcfe4eb+=0x1){socket[_0xa671('0x135')](_0xa671('0x136'),{'UserId':Number(_0x50a31a[_0xa671('0x5d')]['ids'][_0xcfe4eb]),'ChatWebsiteId':Number(_0x50a31a[_0xa671('0x75')]['id'])});}}else{socket[_0xa671('0x135')](_0xa671('0x136'),{'UserId':Number(_0x50a31a[_0xa671('0x5d')]['ids']),'ChatWebsiteId':Number(_0x50a31a[_0xa671('0x75')]['id'])});}});}})[_0xa671('0x18')](respondWithStatusCode(_0x2e0525,null))[_0xa671('0x22')](handleError(_0x2e0525,null));};exports['getAgents']=function(_0x4c1050,_0x55f1cd){var _0x38c97b={};var _0x3e5133={};var _0x339aa3;var _0x129955;return db[_0xa671('0x59')][_0xa671('0x79')]({'where':{'id':_0x4c1050[_0xa671('0x75')]['id']}})[_0xa671('0x18')](handleEntityNotFound(_0x55f1cd,null))[_0xa671('0x18')](function(_0x1bccab){if(_0x1bccab){_0x339aa3=_0x1bccab;_0x3e5133[_0xa671('0x54')]=_[_0xa671('0x82')](db[_0xa671('0x137')][_0xa671('0x5a')]);_0x3e5133[_0xa671('0x5d')]=_[_0xa671('0x82')](_0x4c1050[_0xa671('0x5d')]);_0x3e5133[_0xa671('0x66')]=_[_0xa671('0x5e')](_0x3e5133[_0xa671('0x54')],_0x3e5133[_0xa671('0x5d')]);_0x38c97b[_0xa671('0x5f')]=_[_0xa671('0x5e')](_0x3e5133['model'],qs[_0xa671('0x60')](_0x4c1050[_0xa671('0x5d')][_0xa671('0x60')]));_0x38c97b[_0xa671('0x5f')]=_0x38c97b['attributes'][_0xa671('0x61')]?_0x38c97b[_0xa671('0x5f')]:_0x3e5133[_0xa671('0x54')];_0x38c97b['order']=qs[_0xa671('0x64')](_0x4c1050[_0xa671('0x5d')][_0xa671('0x64')]);_0x38c97b[_0xa671('0x65')]=qs['filters'](_[_0xa671('0x67')](_0x4c1050[_0xa671('0x5d')],_0x3e5133[_0xa671('0x66')]));if(_0x4c1050[_0xa671('0x5d')][_0xa671('0x68')]){_0x38c97b[_0xa671('0x65')]=_['merge'](_0x38c97b[_0xa671('0x65')],{'$or':_[_0xa671('0x3e')](_0x38c97b[_0xa671('0x5f')],function(_0xcc01fb){var _0x15f8b4={};_0x15f8b4[_0xcc01fb]={'$like':'%'+_0x4c1050['query'][_0xa671('0x68')]+'%'};return _0x15f8b4;})});}_0x38c97b=_[_0xa671('0x7c')]({},_0x38c97b,_0x4c1050['options']);return _0x339aa3[_0xa671('0x138')](_0x38c97b);}})[_0xa671('0x18')](function(_0x387377){if(_0x387377){_0x129955=_0x387377['length'];if(!_0x4c1050['query']['hasOwnProperty']('nolimit')){_0x38c97b[_0xa671('0x2a')]=qs['limit'](_0x4c1050['query']['limit']);_0x38c97b[_0xa671('0x27')]=qs[_0xa671('0x27')](_0x4c1050[_0xa671('0x5d')]['offset']);}return _0x339aa3[_0xa671('0x138')](_0x38c97b);}})[_0xa671('0x18')](function(_0x13779a){if(_0x13779a){return _0x13779a?{'count':_0x129955,'rows':_0x13779a}:null;}})[_0xa671('0x18')](respondWithResult(_0x55f1cd,null))[_0xa671('0x22')](handleError(_0x55f1cd,null));};
\ No newline at end of file