Built motion from commit f861bcb808219e66da88ba48b61bddb35224a65e. Version 3.0.0...
[motion-next.git] / server / api / chatWebsite / chatWebsite.controller.js
index 05b1766..b396227 100644 (file)
@@ -1 +1 @@
-'use strict';const a133_0x4282=['firstName','systemAvatar','ChatWebsite','removeAnswers','ListId','pass','rpcEmailIp','end','orderBy','code','name','alignment','Pause','lodash','agentAvatar','describe','removeDispositions','interval','update','bulkCreate','browser','version','CompanyId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','true','threadId','chat','ids','UserProfileResource','getFields','model','iftime\x20%s,%s','no\x20available\x20attributes','send','userChatWebsite:save','attributes','./chatWebsite.socket','addProactiveActions','242tqWaob','ejs','service','query','rpcAmiPort','findAll','error','order','api','remote','get','set','address','file','fromKey','files/images/avatars/system_avatar.png','Smtp','Command','false','2156tHlHub','offlineMessageSubject','omit','554774UzkGWR','unshift','userChatWebsite:remove','path','agent','ChatApplication','filter','updatedAt','result','%s\x20%s','Applications','body','files/images/avatars/default_avatar.png','@utils/filter-attributes','offline','Tags','files/images/logos/','toPairs','files/templates/chatOfflineMessage.ejs','addCustomerAvatar','getDispositions','631478FndjFG','jayson/promise','referer','ChatWebsite,\x20%s,\x20%s,\x20%s','removeAgents','interaction','messageId','http','pick','files/images/avatars/','UserId','chatProactiveAction','utf8','externalUrl','timezone','@mysqldb','addSystemAvatar','isDevelopment','unmanaged','addLogo','*,*,*,*','Start','json','files/images/logos/default_logo.svg','offlineMessageBody','status','tag','143108UUoOaO','getCustomerAvatar','files/chat/iframe.ejs','col','UserProfileSection','secure','onlineForm','from\x20is\x20mandatory','getOfflineMessages','rpcRoutingIp','request\x20sent','fieldName','render','stringify','created','\x22%s\x22\x20<%s>','auth','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','nolimit','AttachmentId','catch','ChatOfflineMessage','@config/config.service','x-forwarded-for','Content-Type','contact','rows','List','filename','mustache','getAgents','textColor','map','where','chatLicenseExceeded','findOne','rpcAmiIp','role','244grzEOi','difference','userProfileId','664854usbJwk','index','virtual','Disposition','getApplications','CmContact','info','priority','split','getAnswers','root','fields','items','type','body\x20is\x20mandatory\x20and\x20not\x20empty','addApplications','Contact','ONLINE','createdAt','sequelize','options','from','length','getSnippet','list','undefined','includeAll','host','destroy','format','getResult','Intervals','color','customerAvatar','indexOf','ChatWebsites','user','filters','x-real-port','addAgents','getLicense','rpcRoutingPort','addAnswer','port','headers','CmList','notify','lastName','params','Owner','offset','push','includes','isNil','device','appdata','client','register','2523VLzDrc','download','addInteraction','sort','@config/environment','Contacts','applications','EventManager','getLogo','iftime\x20%s','ChatProactiveAction','forwardOfflineAddress','emit','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','sendStatus','create','intersection','util','OFFLINE','limit','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','unknown','mapKeyOffline','account','message','replace','waitForTheAssignedAgent','startRouting','ChatWebsiteId','join','asc','1GgVwgY','User','178ojROAl','keys','defaults','rawAttributes','request','mandatoryDispositionPause','ChatWebsite,\x20%s,\x20%s','sendMail','merge','show','mapKey','Interval','count','some','close','CannedAnswer','License','findAndCountAll','Unable\x20to\x20retrieve\x20the\x20current\x20user','sitepic','online','vendor','89vTUnNU','MailServerOut','Tag','ChatInteraction','Content-Range','remoteAddress','getProactiveActions','showCustomerAvatar','No\x20timezone','%s\x20%s\x20%s','inspect','@components/parsers/qs','offlineForm','readFileSync','custom','transaction','user-agent-parser','include','then','getInteractions'];const a133_0x52fb=function(_0x32d2b7,_0x3b4339){_0x32d2b7=_0x32d2b7-0x17d;let _0x4282c1=a133_0x4282[_0x32d2b7];return _0x4282c1;};const a133_0x21f2f4=a133_0x52fb;(function(_0x57c719,_0x53ef72){const _0xaca7aa=a133_0x52fb;while(!![]){try{const _0x316b70=-parseInt(_0xaca7aa(0x1b9))*-parseInt(_0xaca7aa(0x27a))+-parseInt(_0xaca7aa(0x1bb))*-parseInt(_0xaca7aa(0x277))+-parseInt(_0xaca7aa(0x221))+parseInt(_0xaca7aa(0x236))+-parseInt(_0xaca7aa(0x251))+-parseInt(_0xaca7aa(0x1d1))*-parseInt(_0xaca7aa(0x19a))+-parseInt(_0xaca7aa(0x21e))*parseInt(_0xaca7aa(0x20b));if(_0x316b70===_0x53ef72)break;else _0x57c719['push'](_0x57c719['shift']());}catch(_0x32a06c){_0x57c719['push'](_0x57c719['shift']());}}}(a133_0x4282,0x54265));const Mustache=require(a133_0x21f2f4(0x26e)),util=require(a133_0x21f2f4(0x1ab)),path=require(a133_0x21f2f4(0x224)),ejs=require(a133_0x21f2f4(0x20c)),fs=require('fs'),_=require(a133_0x21f2f4(0x1f2)),querystring=require('querystring'),qs=require(a133_0x21f2f4(0x1dc)),logger=require('@config/logger')(a133_0x21f2f4(0x213)),config=require(a133_0x21f2f4(0x19e)),{getConfigService}=require(a133_0x21f2f4(0x267)),{db}=require(a133_0x21f2f4(0x245)),{ValidationError}=require(a133_0x21f2f4(0x28d)),{filterAttributes}=require(a133_0x21f2f4(0x22e)),{getSocket}=require('@rediscache'),socket=getSocket(),UAParser=require(a133_0x21f2f4(0x1e1));require(a133_0x21f2f4(0x209))[a133_0x21f2f4(0x199)](socket);const jayson=require(a133_0x21f2f4(0x237)),{consoleLogger}=require('@utils/console-logger'),cs=getConfigService(),rpcAmiClient=jayson[a133_0x21f2f4(0x198)][a133_0x21f2f4(0x23d)]({'host':cs[a133_0x21f2f4(0x275)],'port':cs[a133_0x21f2f4(0x20f)]}),rpcEmailClient=jayson['client'][a133_0x21f2f4(0x23d)]({'host':cs[a133_0x21f2f4(0x1eb)],'port':cs['rpcEmailPort']}),rpcRoutingClient=jayson['client'][a133_0x21f2f4(0x23d)]({'host':cs[a133_0x21f2f4(0x25a)],'port':cs[a133_0x21f2f4(0x189)]});function respondWithRpcPromise(_0x40baf1,_0xe14021,_0x2e41ff,_0x258ff0){return new Promise(function(_0xd863a1,_0x1ac486){const _0x19a88e=a133_0x52fb,_0x10391c=_0x258ff0||rpcRoutingClient;return _0x10391c[_0x19a88e(0x1bf)](_0x40baf1,_0x2e41ff)[_0x19a88e(0x1e3)](function(_0x508cab){const _0x12acfa=_0x19a88e;logger['info'](_0x12acfa(0x1c1),_0xe14021,_0x12acfa(0x25b)),logger['debug'](_0x12acfa(0x239),_0xe14021,_0x12acfa(0x25b),JSON[_0x12acfa(0x25e)](_0x508cab));if(_0x508cab[_0x12acfa(0x211)]){if(_0x508cab[_0x12acfa(0x211)][_0x12acfa(0x1ee)]===0x1f4)return logger['error'](_0x12acfa(0x1c1),_0xe14021,_0x508cab[_0x12acfa(0x211)][_0x12acfa(0x1b2)]),_0x1ac486(_0x508cab[_0x12acfa(0x211)]['message']);return logger[_0x12acfa(0x211)](_0x12acfa(0x1c1),_0xe14021,_0x508cab[_0x12acfa(0x211)][_0x12acfa(0x1b2)]),_0xd863a1(_0x508cab[_0x12acfa(0x211)][_0x12acfa(0x1b2)]);}else logger[_0x12acfa(0x280)](_0x12acfa(0x1c1),_0xe14021,_0x12acfa(0x25b)),_0xd863a1(_0x508cab[_0x12acfa(0x229)][_0x12acfa(0x1b2)]);})[_0x19a88e(0x265)](function(_0x339dc8){const _0x1a81b6=_0x19a88e;logger['error'](_0x1a81b6(0x1c1),_0xe14021,_0x339dc8),_0x1ac486(_0x339dc8);});});}function respondWithStatusCode(_0x42915e,_0x2345f6){return _0x2345f6=_0x2345f6||0xcc,function(_0x4615c1){const _0x41ac15=a133_0x52fb;if(_0x4615c1)return _0x42915e[_0x41ac15(0x1a8)](_0x2345f6);return _0x42915e['status'](_0x2345f6)[_0x41ac15(0x1ec)]();};}function respondWithResult(_0x2d8456,_0x148e10){return _0x148e10=_0x148e10||0xc8,function(_0x381b3a){const _0x2dcfaa=a133_0x52fb;if(_0x381b3a)return _0x2d8456[_0x2dcfaa(0x24f)](_0x148e10)[_0x2dcfaa(0x24c)](_0x381b3a);};}function respondWithFilteredResult(_0x4257ba,_0x51f2d4){return function(_0x51125f){const _0x383abe=a133_0x52fb;if(_0x51125f){const _0x3cf394=_0x51125f[_0x383abe(0x1c7)],_0x55e2ee=_0x51f2d4[_0x383abe(0x192)];let _0xfebac4=_0x51f2d4['offset']+_0x51f2d4[_0x383abe(0x1ad)],_0x2490b9;return _0xfebac4>=_0x3cf394?(_0xfebac4=_0x3cf394,_0x2490b9=0xc8):_0x2490b9=0xce,_0x4257ba['status'](_0x2490b9),_0x4257ba['set'](_0x383abe(0x1d5),_0x55e2ee+'-'+_0xfebac4+'/'+_0x3cf394)[_0x383abe(0x24c)](_0x51125f);}return null;};}function saveUpdates(_0x44e3af){return function(_0x333405){const _0x528e4b=a133_0x52fb;if(_0x333405)return _0x333405[_0x528e4b(0x1f7)](_0x44e3af)['then'](function(_0xf7ffc2){return _0xf7ffc2;});return null;};}function removeEntity(_0x316bdb){return function(_0x177e81){const _0xde559e=a133_0x52fb;if(_0x177e81)return _0x177e81[_0xde559e(0x296)]()[_0xde559e(0x1e3)](function(){const _0x1570f8=_0xde559e,_0x320cff=_0x177e81[_0x1570f8(0x215)]({'plain':!![]}),_0x5cd233=_0x1570f8(0x183);return db[_0x1570f8(0x201)]['destroy']({'where':{'type':_0x5cd233,'resourceId':_0x320cff['id']}})['then'](function(){return _0x177e81;});})[_0xde559e(0x1e3)](function(){const _0x26cab3=_0xde559e;_0x316bdb[_0x26cab3(0x24f)](0xcc)['end']();});};}function handleEntityNotFound(_0x466971){return function(_0x3a74bf){const _0x5b8a8e=a133_0x52fb;return!_0x3a74bf&&_0x466971[_0x5b8a8e(0x1a8)](0x194),_0x3a74bf;};}function handleError(_0x3c8dd5,_0x3765eb){return _0x3765eb=_0x3765eb||0x1f4,function(_0x410662){const _0x257b2a=a133_0x52fb;logger['error'](_0x410662['stack']),_0x410662[_0x257b2a(0x1ef)]&&delete _0x410662[_0x257b2a(0x1ef)],_0x3c8dd5['status'](_0x3765eb)[_0x257b2a(0x206)](_0x410662);};}exports[a133_0x21f2f4(0x27b)]=function(_0x235fcf,_0x4d1f89){const _0x55940d=a133_0x21f2f4;let _0x50b4ca={'include':[{'model':db[_0x55940d(0x1f1)],'as':_0x55940d(0x1c0)}]};const _0x5d1666={},_0x33aef1={'count':0x0,'rows':[]},_0x54a76d=_[_0x55940d(0x271)](db['ChatWebsite'][_0x55940d(0x1be)],function(_0x2ffd4e){const _0x4cf9c0=_0x55940d;return{'name':_0x2ffd4e[_0x4cf9c0(0x25c)],'type':_0x2ffd4e[_0x4cf9c0(0x287)]['key']};});_0x5d1666[_0x55940d(0x203)]=_[_0x55940d(0x271)](_0x54a76d,_0x55940d(0x1ef)),_0x5d1666['query']=_[_0x55940d(0x1bc)](_0x235fcf[_0x55940d(0x20e)]),_0x5d1666[_0x55940d(0x185)]=_[_0x55940d(0x1aa)](_0x5d1666['model'],_0x5d1666[_0x55940d(0x20e)]),_0x50b4ca[_0x55940d(0x208)]=_[_0x55940d(0x1aa)](_0x5d1666['model'],qs['fields'](_0x235fcf[_0x55940d(0x20e)][_0x55940d(0x285)])),_0x50b4ca['attributes']=_0x50b4ca[_0x55940d(0x208)][_0x55940d(0x290)]?_0x50b4ca[_0x55940d(0x208)]:_0x5d1666[_0x55940d(0x203)];typeof _0x235fcf[_0x55940d(0x20e)][_0x55940d(0x263)]===_0x55940d(0x293)&&(_0x50b4ca[_0x55940d(0x1ad)]=qs['limit'](_0x235fcf[_0x55940d(0x20e)]['limit']),_0x50b4ca[_0x55940d(0x192)]=qs[_0x55940d(0x192)](_0x235fcf['query'][_0x55940d(0x192)]));_0x50b4ca['order']=qs[_0x55940d(0x19d)](_0x235fcf[_0x55940d(0x20e)][_0x55940d(0x19d)]),_0x50b4ca[_0x55940d(0x272)]=qs[_0x55940d(0x185)](_['pick'](_0x235fcf[_0x55940d(0x20e)],_0x5d1666[_0x55940d(0x185)]),_0x54a76d),_0x50b4ca=filterAttributes(_0x50b4ca,_0x235fcf[_0x55940d(0x20e)][_0x55940d(0x227)],_0x54a76d,_0x235fcf[_0x55940d(0x28e)]);const _0x5c4d64={'where':_0x50b4ca[_0x55940d(0x272)]};return db[_0x55940d(0x1e7)][_0x55940d(0x1c7)](_0x5c4d64)[_0x55940d(0x1e3)](function(_0x2a18d6){const _0x5e72c5=_0x55940d;return _0x33aef1['count']=_0x2a18d6,_0x235fcf['query']['includeAll']&&(_0x50b4ca[_0x5e72c5(0x1e2)]=[{'all':!![]}]),db[_0x5e72c5(0x1e7)][_0x5e72c5(0x210)](_0x50b4ca);})['then'](function(_0x187533){const _0x3626f3=_0x55940d;return _0x33aef1[_0x3626f3(0x26b)]=_0x187533,_0x33aef1;})[_0x55940d(0x1e3)](respondWithFilteredResult(_0x4d1f89,_0x50b4ca))[_0x55940d(0x265)](handleError(_0x4d1f89,null));},exports[a133_0x21f2f4(0x1c4)]=function(_0x4fba6f,_0x276397){const _0x1d0db1=a133_0x21f2f4;let _0x175411={'raw':![],'where':{'id':_0x4fba6f[_0x1d0db1(0x190)]['id']},'include':[{'model':db[_0x1d0db1(0x1f1)],'as':_0x1d0db1(0x1c0)}]};const _0xd3dc1e={};return _0xd3dc1e[_0x1d0db1(0x203)]=_[_0x1d0db1(0x1bc)](db[_0x1d0db1(0x1e7)]['rawAttributes']),_0xd3dc1e[_0x1d0db1(0x20e)]=_[_0x1d0db1(0x1bc)](_0x4fba6f['query']),_0xd3dc1e[_0x1d0db1(0x185)]=_['intersection'](_0xd3dc1e[_0x1d0db1(0x203)],_0xd3dc1e[_0x1d0db1(0x20e)]),_0x175411[_0x1d0db1(0x208)]=_[_0x1d0db1(0x1aa)](_0xd3dc1e[_0x1d0db1(0x203)],qs[_0x1d0db1(0x285)](_0x4fba6f['query'][_0x1d0db1(0x285)])),_0x175411[_0x1d0db1(0x208)]=_0x175411[_0x1d0db1(0x208)][_0x1d0db1(0x290)]?_0x175411[_0x1d0db1(0x208)]:_0xd3dc1e['model'],_0x4fba6f['query'][_0x1d0db1(0x294)]&&(_0x175411[_0x1d0db1(0x1e2)]=[{'all':!![]}]),_0x175411=_['merge']({},_0x175411,_0x4fba6f[_0x1d0db1(0x28e)]),db[_0x1d0db1(0x1e7)][_0x1d0db1(0x274)](_0x175411)[_0x1d0db1(0x1e3)](handleEntityNotFound(_0x276397,null))[_0x1d0db1(0x1e3)](respondWithResult(_0x276397,null))[_0x1d0db1(0x265)](handleError(_0x276397,null));},exports['create']=function(_0x4f09db,_0x3e4cbd){const _0x5d0ac7=a133_0x21f2f4;return db[_0x5d0ac7(0x1e7)]['create'](_0x4f09db[_0x5d0ac7(0x22c)],{})['then'](function(_0x2eb177){const _0x5b1482=_0x5d0ac7,_0xf39b14=_0x4f09db[_0x5b1482(0x184)][_0x5b1482(0x215)]({'plain':!![]});if(!_0xf39b14)throw new Error(_0x5b1482(0x1cd));if(_0xf39b14[_0x5b1482(0x276)]===_0x5b1482(0x184)){const _0x46839f=_0x2eb177['get']({'plain':!![]}),_0x305389='ChatWebsites';return db[_0x5b1482(0x255)][_0x5b1482(0x274)]({'where':{'name':_0x305389,'userProfileId':_0xf39b14[_0x5b1482(0x279)]},'raw':!![]})[_0x5b1482(0x1e3)](function(_0x11ec63){const _0x18adb0=_0x5b1482;return _0x11ec63&&_0x11ec63['autoAssociation']===0x0?db[_0x18adb0(0x201)][_0x18adb0(0x1a9)]({'name':_0x46839f[_0x18adb0(0x1ef)],'resourceId':_0x46839f['id'],'type':_0x11ec63['name'],'sectionId':_0x11ec63['id']},{})[_0x18adb0(0x1e3)](function(){return _0x2eb177;}):_0x2eb177;})[_0x5b1482(0x265)](function(_0x186ac1){const _0x14b6a9=_0x5b1482;logger['error'](_0x14b6a9(0x1fc),_0x186ac1);throw _0x186ac1;});}return _0x2eb177;})[_0x5d0ac7(0x1e3)](respondWithResult(_0x3e4cbd,0xc9))['catch'](handleError(_0x3e4cbd,null));},exports['update']=function(_0x1b654b,_0x2d85e0){const _0x16a4a2=a133_0x21f2f4;return _0x1b654b[_0x16a4a2(0x22c)]['id']&&delete _0x1b654b[_0x16a4a2(0x22c)]['id'],db[_0x16a4a2(0x1e7)][_0x16a4a2(0x274)]({'where':{'id':_0x1b654b['params']['id']},'include':[{'model':db[_0x16a4a2(0x1f1)],'as':_0x16a4a2(0x1c0)}]})[_0x16a4a2(0x1e3)](handleEntityNotFound(_0x2d85e0,null))[_0x16a4a2(0x1e3)](saveUpdates(_0x1b654b['body'],null))[_0x16a4a2(0x1e3)](respondWithResult(_0x2d85e0,null))[_0x16a4a2(0x265)](handleError(_0x2d85e0,null));},exports[a133_0x21f2f4(0x296)]=function(_0x25c8cf,_0x4abc7e){const _0x2b5030=a133_0x21f2f4;return db[_0x2b5030(0x1e7)][_0x2b5030(0x274)]({'where':{'id':_0x25c8cf[_0x2b5030(0x190)]['id']}})['then'](handleEntityNotFound(_0x4abc7e,null))[_0x2b5030(0x1e3)](removeEntity(_0x4abc7e,null))[_0x2b5030(0x265)](handleError(_0x4abc7e,null));},exports['describe']=function(_0x200165,_0x39efb2){const _0x19e79b=a133_0x21f2f4;return db[_0x19e79b(0x1e7)][_0x19e79b(0x1f4)]()['then'](respondWithResult(_0x39efb2,null))['catch'](handleError(_0x39efb2,null));},exports['addDisposition']=function(_0x264934,_0x19ff7d){const _0x397f7f=a133_0x21f2f4;return _0x264934['body']['id']&&delete _0x264934[_0x397f7f(0x22c)]['id'],db[_0x397f7f(0x1e7)][_0x397f7f(0x274)]({'where':{'id':_0x264934[_0x397f7f(0x190)]['id']}})[_0x397f7f(0x1e3)](handleEntityNotFound(_0x19ff7d,null))[_0x397f7f(0x1e3)](function(_0x5d445e){const _0x494a88=_0x397f7f;if(_0x5d445e)return _0x264934['body'][_0x494a88(0x1b6)]=_0x5d445e['id'],db[_0x494a88(0x27d)][_0x494a88(0x1a9)](_0x264934[_0x494a88(0x22c)]);})[_0x397f7f(0x1e3)](respondWithResult(_0x19ff7d,null))[_0x397f7f(0x265)](handleError(_0x19ff7d,null));},exports[a133_0x21f2f4(0x235)]=function(_0xa7a09f,_0x4f15a8){const _0x56479f=a133_0x21f2f4;let _0x48eebd={'raw':![],'where':{}};const _0x23567e={},_0x4aaef9={'count':0x0,'rows':[]};return db[_0x56479f(0x1e7)]['findOne']({'where':{'id':_0xa7a09f[_0x56479f(0x190)]['id']}})['then'](handleEntityNotFound(_0x4f15a8,null))[_0x56479f(0x1e3)](function(_0x2c613a){const _0x33e7ba=_0x56479f;if(_0x2c613a)return _0x23567e[_0x33e7ba(0x203)]=_[_0x33e7ba(0x1bc)](db['Disposition'][_0x33e7ba(0x1be)]),_0x23567e[_0x33e7ba(0x20e)]=_[_0x33e7ba(0x1bc)](_0xa7a09f['query']),_0x23567e[_0x33e7ba(0x185)]=_[_0x33e7ba(0x1aa)](_0x23567e['model'],_0x23567e[_0x33e7ba(0x20e)]),_0x48eebd[_0x33e7ba(0x208)]=_[_0x33e7ba(0x1aa)](_0x23567e[_0x33e7ba(0x203)],qs[_0x33e7ba(0x285)](_0xa7a09f['query']['fields'])),_0x48eebd['attributes']=_0x48eebd[_0x33e7ba(0x208)][_0x33e7ba(0x290)]?_0x48eebd[_0x33e7ba(0x208)]:_0x23567e['model'],typeof _0xa7a09f[_0x33e7ba(0x20e)][_0x33e7ba(0x263)]===_0x33e7ba(0x293)&&(_0x48eebd[_0x33e7ba(0x1ad)]=qs[_0x33e7ba(0x1ad)](_0xa7a09f['query'][_0x33e7ba(0x1ad)]),_0x48eebd[_0x33e7ba(0x192)]=qs[_0x33e7ba(0x192)](_0xa7a09f[_0x33e7ba(0x20e)][_0x33e7ba(0x192)])),_0x48eebd['order']=qs[_0x33e7ba(0x19d)](_0xa7a09f[_0x33e7ba(0x20e)]['sort']),_0x48eebd['where']=qs[_0x33e7ba(0x185)](_[_0x33e7ba(0x23e)](_0xa7a09f['query'],_0x23567e[_0x33e7ba(0x185)])),_0x48eebd[_0x33e7ba(0x272)][_0x33e7ba(0x1b6)]=_0x2c613a['id'],_0x48eebd=filterAttributes(_0x48eebd,_0xa7a09f[_0x33e7ba(0x20e)][_0x33e7ba(0x227)],_0x48eebd['attributes'],_0xa7a09f['options'],![]),db[_0x33e7ba(0x27d)][_0x33e7ba(0x1c7)]({'where':_0x48eebd[_0x33e7ba(0x272)]})['then'](function(_0x328f43){const _0x26234a=_0x33e7ba;return _0x4aaef9[_0x26234a(0x1c7)]=_0x328f43,_0xa7a09f[_0x26234a(0x20e)][_0x26234a(0x294)]&&(_0x48eebd[_0x26234a(0x1e2)]=[{'all':!![]}]),db[_0x26234a(0x27d)][_0x26234a(0x210)](_0x48eebd);})[_0x33e7ba(0x1e3)](function(_0xe711fa){const _0x1ae349=_0x33e7ba;return _0x4aaef9[_0x1ae349(0x26b)]=_0xe711fa,_0x4aaef9;});})['then'](respondWithFilteredResult(_0x4f15a8,_0x48eebd))[_0x56479f(0x265)](handleError(_0x4f15a8,null));},exports[a133_0x21f2f4(0x1f5)]=function(_0x4cbe0e,_0x58942e){const _0x659b1a=a133_0x21f2f4;return db[_0x659b1a(0x1e7)][_0x659b1a(0x274)]({'where':{'id':_0x4cbe0e['params']['id']}})[_0x659b1a(0x1e3)](handleEntityNotFound(_0x58942e,null))[_0x659b1a(0x1e3)](function(_0x2d8569){const _0x3514aa=_0x659b1a;if(_0x2d8569)return _0x2d8569['removeDispositions'](_0x4cbe0e['query'][_0x3514aa(0x200)]);})[_0x659b1a(0x1e3)](respondWithStatusCode(_0x58942e,null))[_0x659b1a(0x265)](handleError(_0x58942e,null));},exports[a133_0x21f2f4(0x18a)]=function(_0x5f55d3,_0x1f788b){const _0x4a5bc0=a133_0x21f2f4;return _0x5f55d3[_0x4a5bc0(0x22c)]['id']&&delete _0x5f55d3['body']['id'],db[_0x4a5bc0(0x1e7)]['findOne']({'where':{'id':_0x5f55d3[_0x4a5bc0(0x190)]['id']}})['then'](handleEntityNotFound(_0x1f788b,null))[_0x4a5bc0(0x1e3)](function(_0x535923){const _0x26a40f=_0x4a5bc0;if(_0x535923)return _0x5f55d3[_0x26a40f(0x22c)][_0x26a40f(0x1b6)]=_0x535923['id'],db['CannedAnswer'][_0x26a40f(0x1a9)](_0x5f55d3['body']);})[_0x4a5bc0(0x1e3)](respondWithResult(_0x1f788b,null))[_0x4a5bc0(0x265)](handleError(_0x1f788b,null));},exports[a133_0x21f2f4(0x283)]=function(_0x11cbcb,_0x2d37c8){const _0x3e58eb=a133_0x21f2f4;let _0x5aa808={'raw':![],'where':{}};const _0x5496bc={},_0x39a48f={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x3e58eb(0x274)]({'where':{'id':_0x11cbcb[_0x3e58eb(0x190)]['id']}})['then'](handleEntityNotFound(_0x2d37c8,null))[_0x3e58eb(0x1e3)](function(_0xe24c81){const _0x2d5318=_0x3e58eb;if(_0xe24c81)return _0x5496bc[_0x2d5318(0x203)]=_[_0x2d5318(0x1bc)](db[_0x2d5318(0x1ca)]['rawAttributes']),_0x5496bc[_0x2d5318(0x20e)]=_[_0x2d5318(0x1bc)](_0x11cbcb[_0x2d5318(0x20e)]),_0x5496bc[_0x2d5318(0x185)]=_['intersection'](_0x5496bc[_0x2d5318(0x203)],_0x5496bc['query']),_0x5aa808[_0x2d5318(0x208)]=_[_0x2d5318(0x1aa)](_0x5496bc['model'],qs['fields'](_0x11cbcb[_0x2d5318(0x20e)][_0x2d5318(0x285)])),_0x5aa808[_0x2d5318(0x208)]=_0x5aa808[_0x2d5318(0x208)][_0x2d5318(0x290)]?_0x5aa808[_0x2d5318(0x208)]:_0x5496bc[_0x2d5318(0x203)],typeof _0x11cbcb['query'][_0x2d5318(0x263)]===_0x2d5318(0x293)&&(_0x5aa808[_0x2d5318(0x1ad)]=qs['limit'](_0x11cbcb[_0x2d5318(0x20e)]['limit']),_0x5aa808[_0x2d5318(0x192)]=qs[_0x2d5318(0x192)](_0x11cbcb[_0x2d5318(0x20e)][_0x2d5318(0x192)])),_0x5aa808[_0x2d5318(0x212)]=qs[_0x2d5318(0x19d)](_0x11cbcb[_0x2d5318(0x20e)]['sort']),_0x5aa808[_0x2d5318(0x272)]=qs['filters'](_[_0x2d5318(0x23e)](_0x11cbcb[_0x2d5318(0x20e)],_0x5496bc[_0x2d5318(0x185)])),_0x5aa808[_0x2d5318(0x272)][_0x2d5318(0x1b6)]=_0xe24c81['id'],_0x5aa808=filterAttributes(_0x5aa808,_0x11cbcb[_0x2d5318(0x20e)][_0x2d5318(0x227)],_0x5aa808[_0x2d5318(0x208)],_0x11cbcb[_0x2d5318(0x28e)],![]),db[_0x2d5318(0x1ca)][_0x2d5318(0x1c7)]({'where':_0x5aa808[_0x2d5318(0x272)]})[_0x2d5318(0x1e3)](function(_0x121904){const _0x25e94b=_0x2d5318;return _0x39a48f[_0x25e94b(0x1c7)]=_0x121904,_0x11cbcb[_0x25e94b(0x20e)][_0x25e94b(0x294)]&&(_0x5aa808[_0x25e94b(0x1e2)]=[{'all':!![]}]),db[_0x25e94b(0x1ca)][_0x25e94b(0x210)](_0x5aa808);})[_0x2d5318(0x1e3)](function(_0x277586){const _0x2e5218=_0x2d5318;return _0x39a48f[_0x2e5218(0x26b)]=_0x277586,_0x39a48f;});})[_0x3e58eb(0x1e3)](respondWithFilteredResult(_0x2d37c8,_0x5aa808))[_0x3e58eb(0x265)](handleError(_0x2d37c8,null));},exports[a133_0x21f2f4(0x1e8)]=function(_0x520ecb,_0x383570){const _0x25f3e2=a133_0x21f2f4;return db[_0x25f3e2(0x1e7)][_0x25f3e2(0x274)]({'where':{'id':_0x520ecb[_0x25f3e2(0x190)]['id']}})['then'](handleEntityNotFound(_0x383570,null))[_0x25f3e2(0x1e3)](function(_0x349ab5){if(_0x349ab5)return _0x349ab5['removeAnswers'](_0x520ecb['query']['ids']);})[_0x25f3e2(0x1e3)](respondWithStatusCode(_0x383570,null))['catch'](handleError(_0x383570,null));},exports[a133_0x21f2f4(0x249)]=function(_0x2562a5,_0x261cfb){const _0x3e8d42=a133_0x21f2f4;return _0x2562a5[_0x3e8d42(0x22c)][_0x3e8d42(0x1ce)]=_0x2562a5['file'][_0x3e8d42(0x26d)],db[_0x3e8d42(0x1e7)]['findOne']({'where':{'id':_0x2562a5[_0x3e8d42(0x190)]['id']}})[_0x3e8d42(0x1e3)](handleEntityNotFound(_0x261cfb,null))[_0x3e8d42(0x1e3)](saveUpdates(_0x2562a5[_0x3e8d42(0x22c)],null))[_0x3e8d42(0x1e3)](respondWithResult(_0x261cfb,null))[_0x3e8d42(0x265)](handleError(_0x261cfb,null));},exports['addAvatar']=function(_0x394a9f,_0xd9f4b7){const _0x108cb7=a133_0x21f2f4;return _0x394a9f['body'][_0x108cb7(0x1f3)]=_0x394a9f['file'][_0x108cb7(0x26d)],db[_0x108cb7(0x1e7)][_0x108cb7(0x274)]({'where':{'id':_0x394a9f[_0x108cb7(0x190)]['id']}})[_0x108cb7(0x1e3)](handleEntityNotFound(_0xd9f4b7,null))[_0x108cb7(0x1e3)](saveUpdates(_0x394a9f[_0x108cb7(0x22c)],null))[_0x108cb7(0x1e3)](respondWithResult(_0xd9f4b7,null))[_0x108cb7(0x265)](handleError(_0xd9f4b7,null));},exports[a133_0x21f2f4(0x234)]=function(_0x376cab,_0x1d3961){const _0x35577b=a133_0x21f2f4;return _0x376cab['body'][_0x35577b(0x181)]=_0x376cab['file']['filename'],db[_0x35577b(0x1e7)]['findOne']({'where':{'id':_0x376cab[_0x35577b(0x190)]['id']}})['then'](handleEntityNotFound(_0x1d3961,null))[_0x35577b(0x1e3)](saveUpdates(_0x376cab[_0x35577b(0x22c)],null))[_0x35577b(0x1e3)](respondWithResult(_0x1d3961,null))[_0x35577b(0x265)](handleError(_0x1d3961,null));},exports[a133_0x21f2f4(0x246)]=function(_0x10b1c6,_0x449235){const _0x128133=a133_0x21f2f4;return _0x10b1c6['body'][_0x128133(0x1e6)]=_0x10b1c6[_0x128133(0x218)][_0x128133(0x26d)],db['ChatWebsite'][_0x128133(0x274)]({'where':{'id':_0x10b1c6[_0x128133(0x190)]['id']}})[_0x128133(0x1e3)](handleEntityNotFound(_0x449235,null))['then'](saveUpdates(_0x10b1c6[_0x128133(0x22c)],null))['then'](respondWithResult(_0x449235,null))[_0x128133(0x265)](handleError(_0x449235,null));},exports[a133_0x21f2f4(0x1a2)]=function(_0x88059a,_0x35f016){const _0x4e71b5=a133_0x21f2f4;let _0x8f19fe=path[_0x4e71b5(0x1b7)](config[_0x4e71b5(0x284)],_0x4e71b5(0x24d));const _0x3dff86={'where':{'id':_0x88059a[_0x4e71b5(0x190)]['id']},'attributes':['id',_0x4e71b5(0x1ce)],'raw':!![]};let _0x42a394=![];return require('@config/license/util')['getLicense']()['then'](function(_0x2b3fa0){const _0x1ec87b=_0x4e71b5;_0x2b3fa0&&(_0x42a394=_0x2b3fa0[_0x1ec87b(0x1df)]);})['then'](function(){const _0x5ee261=_0x4e71b5;return db[_0x5ee261(0x1e7)][_0x5ee261(0x274)](_0x3dff86);})[_0x4e71b5(0x1e3)](handleEntityNotFound(_0x35f016,null))[_0x4e71b5(0x1e3)](function(_0x545651){const _0x13876d=_0x4e71b5;if(_0x545651)return!_[_0x13876d(0x195)](_0x545651[_0x13876d(0x1ce)])&&(fs['existsSync'](path[_0x13876d(0x1b7)](config[_0x13876d(0x284)],_0x13876d(0x231),_0x545651[_0x13876d(0x1ce)]))&&_0x42a394&&(_0x8f19fe=path['join'](config['root'],'files/images/logos/',_0x545651[_0x13876d(0x1ce)]))),_0x35f016[_0x13876d(0x19b)](_0x8f19fe);})['catch'](handleError(_0x35f016,null));},exports['getAvatar']=function(_0xfbb728,_0x156ba5){const _0x4512c1=a133_0x21f2f4;let _0x2a3542=path[_0x4512c1(0x1b7)](config[_0x4512c1(0x284)],_0x4512c1(0x22d));const _0x1dfe1f={'where':{'id':_0xfbb728[_0x4512c1(0x190)]['id']},'attributes':['id',_0x4512c1(0x1f3)],'raw':!![]};return db[_0x4512c1(0x1e7)][_0x4512c1(0x274)](_0x1dfe1f)[_0x4512c1(0x1e3)](handleEntityNotFound(_0x156ba5,null))[_0x4512c1(0x1e3)](function(_0x5060e0){const _0x3dfc20=_0x4512c1;if(_0x5060e0)return!_[_0x3dfc20(0x195)](_0x5060e0[_0x3dfc20(0x1f3)])&&(fs['existsSync'](path[_0x3dfc20(0x1b7)](config[_0x3dfc20(0x284)],_0x3dfc20(0x23f),_0x5060e0['agentAvatar']))&&(_0x2a3542=path['join'](config[_0x3dfc20(0x284)],_0x3dfc20(0x23f),_0x5060e0[_0x3dfc20(0x1f3)]))),_0x156ba5[_0x3dfc20(0x19b)](_0x2a3542);})[_0x4512c1(0x265)](handleError(_0x156ba5,null));},exports[a133_0x21f2f4(0x252)]=function(_0x435348,_0x320484){const _0x42e91c=a133_0x21f2f4;let _0x54a999=path[_0x42e91c(0x1b7)](config[_0x42e91c(0x284)],'files/images/avatars/customer_avatar.png');const _0x509485={'where':{'id':_0x435348['params']['id']},'attributes':['id',_0x42e91c(0x181),_0x42e91c(0x1d8)],'raw':!![]};return db[_0x42e91c(0x1e7)]['findOne'](_0x509485)['then'](handleEntityNotFound(_0x320484,null))[_0x42e91c(0x1e3)](function(_0x50f43f){const _0x4c2b09=_0x42e91c;if(_0x50f43f)return!_[_0x4c2b09(0x195)](_0x50f43f[_0x4c2b09(0x181)])&&(fs['existsSync'](path[_0x4c2b09(0x1b7)](config[_0x4c2b09(0x284)],'files/images/avatars/',_0x50f43f['customerAvatar']))&&_0x50f43f[_0x4c2b09(0x1d8)]&&(_0x54a999=path[_0x4c2b09(0x1b7)](config[_0x4c2b09(0x284)],'files/images/avatars/',_0x50f43f[_0x4c2b09(0x181)]))),_0x320484[_0x4c2b09(0x19b)](_0x54a999);})['catch'](handleError(_0x320484,null));},exports['getSystemAvatar']=function(_0x258c94,_0x38b841){const _0x464891=a133_0x21f2f4;let _0x5a65e2=path[_0x464891(0x1b7)](config['root'],_0x464891(0x21a));const _0x2f2948={'where':{'id':_0x258c94['params']['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db[_0x464891(0x1e7)][_0x464891(0x274)](_0x2f2948)['then'](handleEntityNotFound(_0x38b841,null))[_0x464891(0x1e3)](function(_0x43f977){const _0x16081c=_0x464891;if(_0x43f977)return!_[_0x16081c(0x195)](_0x43f977['systemAvatar'])&&(fs['existsSync'](path['join'](config[_0x16081c(0x284)],_0x16081c(0x23f),_0x43f977[_0x16081c(0x1e6)]))&&(_0x5a65e2=path['join'](config[_0x16081c(0x284)],'files/images/avatars/',_0x43f977['systemAvatar']))),_0x38b841['download'](_0x5a65e2);})[_0x464891(0x265)](handleError(_0x38b841,null));},exports['notify']=function(_0x178677,_0xd339e7){const _0x58f9f8=a133_0x21f2f4,_0x19feb2=new UAParser(),_0x2676f1=_0x19feb2['setUA'](_0x178677[_0x58f9f8(0x18c)]['user-agent'])[_0x58f9f8(0x17e)](),_0x2221a6={'body':_0x178677[_0x58f9f8(0x22c)],'channel':_0x58f9f8(0x1ff)};let _0x149d62=[],_0x4afb11=[];const _0x23cccd={};let _0x259afa=![];return db[_0x58f9f8(0x27f)][_0x58f9f8(0x1f4)]()['then'](function(_0x58a617){const _0x8e3456=_0x58f9f8;if(!_0x58a617)throw new ValidationError(_0x8e3456(0x205));_0x149d62=_[_0x8e3456(0x278)](_[_0x8e3456(0x1bc)](_0x58a617),[_0x8e3456(0x28c),_0x8e3456(0x228)]),_0x4afb11=_[_0x8e3456(0x278)](_[_0x8e3456(0x1bc)](_0x58a617),[_0x8e3456(0x28c),_0x8e3456(0x228),'CompanyId',_0x8e3456(0x1e9)]);_0x178677[_0x8e3456(0x22c)]['id']&&delete _0x178677[_0x8e3456(0x22c)]['id'];if(_['isNil'](_0x178677[_0x8e3456(0x22c)][_0x8e3456(0x28f)]))throw new ValidationError(_0x8e3456(0x258));if(_[_0x8e3456(0x195)](_0x178677[_0x8e3456(0x22c)][_0x8e3456(0x22c)])||_0x178677[_0x8e3456(0x22c)][_0x8e3456(0x22c)]==='')throw new ValidationError(_0x8e3456(0x288));if(_[_0x8e3456(0x195)](_0x178677[_0x8e3456(0x22c)][_0x8e3456(0x1c5)]))throw new ValidationError('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4afb11);if(!_[_0x8e3456(0x194)](_0x4afb11,_0x178677['body']['mapKey']))throw new ValidationError(_0x8e3456(0x1ae)+_0x4afb11);_0x23cccd[_0x178677[_0x8e3456(0x22c)][_0x8e3456(0x1c5)]]=_0x178677[_0x8e3456(0x22c)][_0x8e3456(0x28f)];})[_0x58f9f8(0x1e3)](function(){const _0x300f5b=_0x58f9f8;return db[_0x300f5b(0x1e7)][_0x300f5b(0x274)]({'where':{'id':_0x178677['params']['id']},'include':[{'model':db[_0x300f5b(0x18d)],'as':_0x300f5b(0x26c),'include':[{'model':db['CmContact'],'as':_0x300f5b(0x19f),'where':_0x23cccd,'limit':0x1,'order':[[_0x300f5b(0x228),'DESC']]}]},{'model':db[_0x300f5b(0x226)],'as':_0x300f5b(0x22b)}]});})[_0x58f9f8(0x1e3)](handleEntityNotFound(_0xd339e7,null))[_0x58f9f8(0x1e3)](function(_0x3f018c){const _0x1b1056=_0x58f9f8;if(_0x3f018c&&_0x3f018c[_0x1b1056(0x26c)]){_0x2221a6[_0x1b1056(0x1b1)]=_0x3f018c,_0x2221a6[_0x1b1056(0x1a0)]=_0x3f018c['Applications'],_0x2221a6[_0x1b1056(0x292)]=_0x3f018c[_0x1b1056(0x26c)],_0x2221a6[_0x1b1056(0x1a0)]=_[_0x1b1056(0x1ed)](_0x2221a6[_0x1b1056(0x1a0)],[_0x1b1056(0x281)],[_0x1b1056(0x1b8)]);_0x2221a6[_0x1b1056(0x1b1)]['Applications']&&delete _0x2221a6['account'][_0x1b1056(0x22b)];if(_0x2221a6[_0x1b1056(0x1b1)][_0x1b1056(0x26c)]&&_0x2221a6['account']['List'][_0x1b1056(0x19f)][_0x1b1056(0x290)])return _0x2221a6['account'][_0x1b1056(0x26c)][_0x1b1056(0x19f)][0x0];const _0x38e972=_[_0x1b1056(0x1bd)](_0x178677[_0x1b1056(0x22c)],{'firstName':_0x178677[_0x1b1056(0x22c)][_0x1b1056(0x28f)],'ListId':_0x3f018c[_0x1b1056(0x1e9)]});return _0x38e972[_0x178677[_0x1b1056(0x22c)]['mapKey']]=_0x178677[_0x1b1056(0x22c)][_0x1b1056(0x28f)],db[_0x1b1056(0x27f)][_0x1b1056(0x1a9)](_0x38e972,{'fields':_0x149d62,'raw':!![]});}})['then'](handleEntityNotFound(_0xd339e7,null))[_0x58f9f8(0x1e3)](function(_0x10df7c){const _0x398ae9=_0x58f9f8;_0x2221a6[_0x398ae9(0x26a)]=_0x10df7c;let _0x4ff78a=_0x178677['body']['customerIp'];if(_0x178677['headers']['cf-connecting-ip'])_0x4ff78a=_0x178677[_0x398ae9(0x18c)]['cf-connecting-ip'];else _0x178677[_0x398ae9(0x18c)][_0x398ae9(0x268)]&&(_0x4ff78a=_['first'](_0x178677[_0x398ae9(0x18c)]['x-forwarded-for'][_0x398ae9(0x282)](',')));if(_0x10df7c){const _0x6e8052={'ContactId':_0x10df7c['id'],'ChatWebsiteId':_0x178677[_0x398ae9(0x190)]['id'],'from':(_0x10df7c['firstName']||'')+'\x20'+(_0x10df7c[_0x398ae9(0x18f)]||''),'customerIp':_0x4ff78a,'customerPort':_0x178677['headers'][_0x398ae9(0x186)]?_0x178677[_0x398ae9(0x18c)][_0x398ae9(0x186)]:null,'referer':_0x178677[_0x398ae9(0x22c)]['referer'],'browserName':_0x2676f1[_0x398ae9(0x1f9)][_0x398ae9(0x1ef)]&&_0x2676f1['browser']['version']?util['format'](_0x398ae9(0x22a),_0x2676f1[_0x398ae9(0x1f9)]['name'],_0x2676f1['browser'][_0x398ae9(0x1fa)]):_0x398ae9(0x1af),'browserVersion':_0x2676f1['browser']['version']||_0x398ae9(0x1af),'osName':util[_0x398ae9(0x17d)](_0x398ae9(0x22a),_0x2676f1['os'][_0x398ae9(0x1ef)],_0x2676f1['os'][_0x398ae9(0x1fa)]),'osVersion':_0x2676f1['os'][_0x398ae9(0x1fa)],'deviceModel':_0x2676f1[_0x398ae9(0x196)][_0x398ae9(0x203)]&&_0x2676f1[_0x398ae9(0x196)][_0x398ae9(0x1d0)]?util[_0x398ae9(0x17d)](_0x398ae9(0x1da),_0x2676f1[_0x398ae9(0x196)][_0x398ae9(0x203)],_0x2676f1[_0x398ae9(0x196)][_0x398ae9(0x1d0)],_0x2676f1[_0x398ae9(0x196)][_0x398ae9(0x287)]):null,'deviceVendor':_0x2676f1[_0x398ae9(0x196)]['vendor'],'deviceType':_0x2676f1[_0x398ae9(0x196)]['type'],'formData':JSON[_0x398ae9(0x25e)](_0x178677['body'])},_0xb96018={'ChatWebsiteId':_0x178677[_0x398ae9(0x190)]['id'],'closed':![]};if(_0x178677[_0x398ae9(0x22c)]['threadId'])return _0xb96018[_0x398ae9(0x1fe)]=_0x178677['body'][_0x398ae9(0x1fe)],db[_0x398ae9(0x1d4)]['findOne']({'where':_0xb96018})[_0x398ae9(0x1e3)](function(_0x1a5102){const _0x1c5e5a=_0x398ae9;if(_0x1a5102)return[_0x1a5102,![]];return _0x6e8052[_0x1c5e5a(0x1fe)]=_0x178677['body']['threadId'],_0x6e8052[_0x1c5e5a(0x243)]=_0x178677[_0x1c5e5a(0x22c)][_0x1c5e5a(0x243)],db['ChatInteraction'][_0x1c5e5a(0x1a9)](_0x6e8052)[_0x1c5e5a(0x1e3)](function(_0x473c48){return[_0x473c48,!![]];});});_0xb96018['ContactId']=_0x10df7c['id'];if(_0x178677[_0x398ae9(0x22c)][_0x398ae9(0x23b)]&&_0x178677[_0x398ae9(0x22c)][_0x398ae9(0x23b)]['id'])return _0xb96018['id']=_0x178677[_0x398ae9(0x22c)][_0x398ae9(0x23b)]['id'],db['ChatInteraction'][_0x398ae9(0x274)]({'where':_0xb96018})[_0x398ae9(0x1e3)](function(_0x401d5e){const _0x3eafd1=_0x398ae9;if(_0x401d5e)return[_0x401d5e,![]];return db[_0x3eafd1(0x1d4)]['create'](_0x6e8052)[_0x3eafd1(0x1e3)](function(_0x361dc2){return[_0x361dc2,!![]];});});return db['ChatInteraction'][_0x398ae9(0x1a9)](_0x6e8052)[_0x398ae9(0x1e3)](function(_0x32a56e){return[_0x32a56e,!![]];});}})[_0x58f9f8(0x1e3)](function([_0x5f40bd,_0x22aa19]){const _0x2673fb=_0x58f9f8;if(_0x5f40bd){_0x259afa=_0x22aa19;if(!_0x22aa19){const _0x503abc={'from':(_0x2221a6[_0x2673fb(0x26a)][_0x2673fb(0x1e5)]||'')+'\x20'+(_0x2221a6[_0x2673fb(0x26a)][_0x2673fb(0x18f)]||'')};return _0x178677[_0x2673fb(0x22c)][_0x2673fb(0x1fe)]&&_0x178677[_0x2673fb(0x22c)]['messageId']&&_0x178677[_0x2673fb(0x22c)][_0x2673fb(0x1fe)]!=_0x178677['body'][_0x2673fb(0x23c)]&&(_0x503abc[_0x2673fb(0x1fe)]=_0x178677['body'][_0x2673fb(0x23c)]),_0x5f40bd[_0x2673fb(0x1f7)](_0x503abc);}else return _0x5f40bd;}})[_0x58f9f8(0x1e3)](function(_0x1d813a){const _0x278cbb=_0x58f9f8;return _0x2221a6['interaction']=_0x1d813a[_0x278cbb(0x215)]({'plain':!![]}),_0x2221a6[_0x278cbb(0x23b)][_0x278cbb(0x25f)]=_0x259afa,_0x2221a6['interaction']['created']&&(_0x2221a6[_0x278cbb(0x1b1)]['autoclose']&&_0x2221a6['applications'][_0x278cbb(0x193)]({'id':0x0,'priority':_0x2221a6[_0x278cbb(0x1a0)][_0x278cbb(0x290)]+0x1,'app':_0x278cbb(0x1c9),'appdata':_0x278cbb(0x248),'interval':_0x278cbb(0x24a)})),db['ChatMessage'][_0x278cbb(0x1a9)]({'body':_0x178677['body'][_0x278cbb(0x22c)],'ChatWebsiteId':_0x178677[_0x278cbb(0x190)]['id'],'ChatInteractionId':_0x1d813a['id'],'direction':'in','ContactId':_0x2221a6[_0x278cbb(0x26a)]['id'],'AttachmentId':_0x178677[_0x278cbb(0x22c)][_0x278cbb(0x264)]});})[_0x58f9f8(0x1e3)](function(_0x244cf5){const _0x36129b=_0x58f9f8;_0x2221a6[_0x36129b(0x1b2)]=_0x244cf5;if(_0x2221a6['interaction'][_0x36129b(0x240)])return db[_0x36129b(0x1ba)][_0x36129b(0x274)]({'attributes':['id',_0x36129b(0x1ef)],'where':{'id':_0x2221a6[_0x36129b(0x23b)][_0x36129b(0x240)]}})[_0x36129b(0x1e3)](function(_0x587447){const _0x2bb0d8=_0x36129b;return _0x587447&&(_0x2221a6['applications'][_0x2bb0d8(0x222)]({'id':0x0,'priority':0x0,'app':_0x2bb0d8(0x225),'appdata':_0x587447[_0x2bb0d8(0x1ef)]+','+(_0x2221a6[_0x2bb0d8(0x1b1)][_0x2bb0d8(0x1b4)]||0xa),'interval':_0x2bb0d8(0x24a)}),_0x2221a6['forcedOwnership']=!![]),respondWithRpcPromise(_0x2bb0d8(0x24b),_0x2bb0d8(0x1b5),_0x2221a6);});return respondWithRpcPromise('Start','startRouting',_0x2221a6);})[_0x58f9f8(0x1e3)](function(_0x2fc6c3){const _0xb89c5d=_0x58f9f8;return respondWithRpcPromise(_0xb89c5d(0x1a1),_0xb89c5d(0x1a1),{'event':_0xb89c5d(0x18e),'message':_0x2fc6c3},rpcAmiClient),_0x2fc6c3;})[_0x58f9f8(0x1e3)](respondWithResult(_0xd339e7,null))['catch'](handleError(_0xd339e7,null));},exports[a133_0x21f2f4(0x22f)]=function(_0x25bbca,_0x109d02){const _0x33a3a6=a133_0x21f2f4;let _0x5a5464,_0x577269,_0x1112fa=[];const _0x2a9c79={};return db[_0x33a3a6(0x27f)][_0x33a3a6(0x1f4)]()[_0x33a3a6(0x1e3)](function(_0x460411){const _0xc3539c=_0x33a3a6;if(!_0x460411)throw new ValidationError(_0xc3539c(0x205));_0x1112fa=_[_0xc3539c(0x278)](_['keys'](_0x460411),[_0xc3539c(0x28c),'updatedAt',_0xc3539c(0x1fb),_0xc3539c(0x1e9)]);_0x25bbca[_0xc3539c(0x22c)]['id']&&delete _0x25bbca['body']['id'];if(_[_0xc3539c(0x195)](_0x25bbca[_0xc3539c(0x22c)][_0xc3539c(0x28f)]))throw _0x109d02[_0xc3539c(0x24f)](0x1f4)[_0xc3539c(0x206)](new ValidationError('from\x20is\x20mandatory'));if(_[_0xc3539c(0x195)](_0x25bbca[_0xc3539c(0x22c)]['body'])||_0x25bbca[_0xc3539c(0x22c)][_0xc3539c(0x22c)]==='')throw _0x109d02['status'](0x1f4)['send'](new ValidationError(_0xc3539c(0x288)));if(_[_0xc3539c(0x195)](_0x25bbca[_0xc3539c(0x22c)][_0xc3539c(0x1b0)]))throw _0x109d02[_0xc3539c(0x24f)](0x1f4)['send'](new ValidationError('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x1112fa));if(!_[_0xc3539c(0x194)](_0x1112fa,_0x25bbca['body'][_0xc3539c(0x1b0)]))throw _0x109d02[_0xc3539c(0x24f)](0x1f4)[_0xc3539c(0x206)](new ValidationError(_0xc3539c(0x1a7)+_0x1112fa));_0x2a9c79[_0x25bbca['body']['mapKeyOffline']]=_0x25bbca[_0xc3539c(0x22c)][_0xc3539c(0x28f)];})[_0x33a3a6(0x1e3)](function(){const _0x5db1ec=_0x33a3a6;return db['ChatWebsite'][_0x5db1ec(0x274)]({'where':{'id':_0x25bbca[_0x5db1ec(0x190)]['id']},'include':[{'model':db[_0x5db1ec(0x18d)],'as':'List'}]});})['then'](handleEntityNotFound(_0x109d02,null))['then'](function(_0x37d4d1){const _0x138874=_0x33a3a6;if(_0x37d4d1&&_0x37d4d1['List']){_0x577269=_0x37d4d1;const _0x1ccf45=_[_0x138874(0x1bd)](_0x25bbca[_0x138874(0x22c)],{'firstName':_0x25bbca['body'][_0x138874(0x28f)],'phone':_0x25bbca['body'][_0x138874(0x28f)],'ListId':_0x37d4d1['ListId']});return _0x1ccf45[_0x25bbca[_0x138874(0x22c)][_0x138874(0x1b0)]]=_0x25bbca[_0x138874(0x22c)][_0x138874(0x28f)],db['CmContact']['findOrCreate']({'where':_0x2a9c79,'defaults':_0x1ccf45});}})['then'](function([_0x602119]){const _0x38fc2d=_0x33a3a6;if(_0x602119){const _0x39464a=fs['readFileSync'](path[_0x38fc2d(0x1b7)](config[_0x38fc2d(0x284)],_0x38fc2d(0x233)),_0x38fc2d(0x242)),_0x2046bc=ejs[_0x38fc2d(0x25d)](_0x39464a,{'body':_[_0x38fc2d(0x232)](_0x25bbca['body'][_0x38fc2d(0x22c)]),'bodyTitle':_0x577269[_0x38fc2d(0x24e)]});return db[_0x38fc2d(0x266)]['create']({'body':_0x2046bc,'ContactId':_0x602119['id'],'ChatWebsiteId':_0x577269['id']});}})['then'](function(_0x550a16){const _0x43914b=_0x33a3a6;if(_0x550a16)return _0x5a5464=_0x550a16,db['MailAccount'][_0x43914b(0x274)]({'where':{'service':!![]},'include':[{'model':db[_0x43914b(0x1d2)],'as':'Smtp','raw':!![]}]});})[_0x33a3a6(0x1e3)](function(_0x54f462){const _0x15c86d=_0x33a3a6;if(_0x54f462&&_0x54f462['Smtp']&&_0x577269[_0x15c86d(0x1a5)]){const _0x1c375b={'tls':{'rejectUnauthorized':![]}};return _0x54f462[_0x15c86d(0x21b)]['service']?_0x1c375b[_0x15c86d(0x20d)]=_0x54f462[_0x15c86d(0x21b)]['service']:(_0x1c375b[_0x15c86d(0x295)]=_0x54f462['Smtp'][_0x15c86d(0x295)],_0x1c375b[_0x15c86d(0x18b)]=_0x54f462[_0x15c86d(0x21b)]['port'],_0x1c375b[_0x15c86d(0x256)]=_0x54f462['Smtp']['secure']),_0x54f462[_0x15c86d(0x21b)]['authentication']&&(_0x1c375b[_0x15c86d(0x261)]={'user':_0x54f462[_0x15c86d(0x21b)][_0x15c86d(0x184)],'pass':_0x54f462[_0x15c86d(0x21b)][_0x15c86d(0x1ea)]}),respondWithRpcPromise('SendMail',_0x15c86d(0x1c2),{'account':_0x1c375b,'message':{'from':util[_0x15c86d(0x17d)](_0x15c86d(0x260),_0x54f462[_0x15c86d(0x1ef)],_0x54f462['email']||_0x54f462['Smtp'][_0x15c86d(0x184)]),'to':_0x577269['forwardOfflineAddress'],'subject':_0x577269[_0x15c86d(0x21f)],'text':_0x5a5464['body']}},rpcEmailClient)[_0x15c86d(0x1e3)](function(){return _0x5a5464;})[_0x15c86d(0x265)](function(_0x391aba){const _0x3f42c7=_0x15c86d;consoleLogger[_0x3f42c7(0x211)](_0x391aba);});}})[_0x33a3a6(0x1e3)](function(){if(_0x5a5464)return _0x5a5464;})[_0x33a3a6(0x1e3)](respondWithResult(_0x109d02,null))['catch'](handleError(_0x109d02,null));},exports[a133_0x21f2f4(0x19c)]=function(_0x32d331,_0x33ac2c){const _0x526d4a=a133_0x21f2f4;return db['ChatInteraction'][_0x526d4a(0x274)]({'where':{'id':_0x32d331['params']['id']}})['then'](function(_0x4fb40b){const _0x1b5174=_0x526d4a;if(_0x4fb40b)return _0x4fb40b[_0x1b5174(0x19c)](_0x32d331[_0x1b5174(0x22c)][_0x1b5174(0x200)],{'through':_[_0x1b5174(0x220)](_0x32d331[_0x1b5174(0x22c)],[_0x1b5174(0x200),'id'])});})[_0x526d4a(0x1e3)](respondWithResult(_0x33ac2c,null))[_0x526d4a(0x265)](handleError(_0x33ac2c,null));},exports[a133_0x21f2f4(0x1e4)]=function(_0x1b22d2,_0x5964da){const _0x2e70cf=a133_0x21f2f4;let _0x17af92={'raw':![],'where':{}};const _0x1234ae={},_0x4caacd={'count':0x0,'rows':[]};return db[_0x2e70cf(0x1e7)][_0x2e70cf(0x274)]({'where':{'id':_0x1b22d2[_0x2e70cf(0x190)]['id']}})[_0x2e70cf(0x1e3)](handleEntityNotFound(_0x5964da,null))['then'](function(_0x5a364b){const _0x4ceb5d=_0x2e70cf;if(_0x5a364b)return _0x1234ae[_0x4ceb5d(0x203)]=_['keys'](db['ChatInteraction'][_0x4ceb5d(0x1be)]),_0x1234ae[_0x4ceb5d(0x20e)]=_[_0x4ceb5d(0x1bc)](_0x1b22d2[_0x4ceb5d(0x20e)]),_0x1234ae[_0x4ceb5d(0x185)]=_[_0x4ceb5d(0x1aa)](_0x1234ae[_0x4ceb5d(0x203)],_0x1234ae[_0x4ceb5d(0x20e)]),_0x17af92[_0x4ceb5d(0x208)]=_['intersection'](_0x1234ae[_0x4ceb5d(0x203)],qs[_0x4ceb5d(0x285)](_0x1b22d2['query'][_0x4ceb5d(0x285)])),_0x17af92[_0x4ceb5d(0x208)]=_0x17af92[_0x4ceb5d(0x208)][_0x4ceb5d(0x290)]?_0x17af92['attributes']:_0x1234ae[_0x4ceb5d(0x203)],typeof _0x1b22d2[_0x4ceb5d(0x20e)][_0x4ceb5d(0x263)]==='undefined'&&(_0x17af92['limit']=qs[_0x4ceb5d(0x1ad)](_0x1b22d2[_0x4ceb5d(0x20e)][_0x4ceb5d(0x1ad)]),_0x17af92['offset']=qs[_0x4ceb5d(0x192)](_0x1b22d2[_0x4ceb5d(0x20e)][_0x4ceb5d(0x192)])),_0x17af92[_0x4ceb5d(0x212)]=qs[_0x4ceb5d(0x19d)](_0x1b22d2[_0x4ceb5d(0x20e)][_0x4ceb5d(0x19d)]),_0x17af92['where']=qs[_0x4ceb5d(0x185)](_[_0x4ceb5d(0x23e)](_0x1b22d2[_0x4ceb5d(0x20e)],_0x1234ae[_0x4ceb5d(0x185)])),_0x17af92[_0x4ceb5d(0x272)][_0x4ceb5d(0x1b6)]=_0x5a364b['id'],_0x17af92=filterAttributes(_0x17af92,_0x1b22d2[_0x4ceb5d(0x20e)][_0x4ceb5d(0x227)],_0x17af92[_0x4ceb5d(0x208)],_0x1b22d2[_0x4ceb5d(0x28e)],![]),db['ChatInteraction']['count']({'where':_0x17af92[_0x4ceb5d(0x272)]})[_0x4ceb5d(0x1e3)](function(_0x159943){const _0x5b8f3f=_0x4ceb5d;return _0x4caacd[_0x5b8f3f(0x1c7)]=_0x159943,_0x1b22d2[_0x5b8f3f(0x20e)]['includeAll']&&(_0x17af92['include']=[{'model':db[_0x5b8f3f(0x27f)],'as':_0x5b8f3f(0x28a),'required':![]},{'model':db[_0x5b8f3f(0x1ba)],'as':_0x5b8f3f(0x191),'attributes':[_0x5b8f3f(0x1ef),'fullname','internal'],'required':![]},{'model':db[_0x5b8f3f(0x1d3)],'as':_0x5b8f3f(0x230),'attributes':['id',_0x5b8f3f(0x1ef),_0x5b8f3f(0x180)],'where':_0x1b22d2[_0x5b8f3f(0x20e)][_0x5b8f3f(0x250)]?{'id':_0x1b22d2[_0x5b8f3f(0x20e)][_0x5b8f3f(0x250)]}:undefined,'required':_0x1b22d2[_0x5b8f3f(0x20e)]['tag']?!![]:![]}]),db[_0x5b8f3f(0x1d4)]['findAll'](_0x17af92);})[_0x4ceb5d(0x1e3)](function(_0x1a5021){return _0x4caacd['rows']=_0x1a5021,_0x4caacd;});})[_0x2e70cf(0x1e3)](respondWithFilteredResult(_0x5964da,_0x17af92))['catch'](handleError(_0x5964da,null));};function iftimePromise(_0x1d4a95,_0x25b28b){const _0x57ab3e=a133_0x21f2f4;return respondWithRpcPromise(_0x57ab3e(0x21c),_0x57ab3e(0x291),{'command':_0x25b28b[_0x57ab3e(0x244)]?util[_0x57ab3e(0x17d)](_0x57ab3e(0x204),_0x1d4a95['interval'],_0x25b28b[_0x57ab3e(0x244)]):util[_0x57ab3e(0x17d)](_0x57ab3e(0x1a3),_0x1d4a95[_0x57ab3e(0x1f6)])},rpcAmiClient)[_0x57ab3e(0x1e3)](function(_0x18ac7a){const _0x27db58=_0x57ab3e,_0x215ed2=_0x18ac7a&&_0x18ac7a[_0x27db58(0x182)](_0x27db58(0x1fd))>=0x0?!![]:![];return logger[_0x27db58(0x280)]('[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)',_0x25b28b['id'],_0x1d4a95['id'],_0x1d4a95[_0x27db58(0x1f6)],_0x215ed2?_0x27db58(0x28b):_0x27db58(0x1ac),_0x25b28b[_0x27db58(0x244)]?_0x25b28b[_0x27db58(0x244)]:'No\x20timezone'),_0x215ed2;})[_0x57ab3e(0x265)](function(_0x45e804){const _0x17ead1=_0x57ab3e;return logger[_0x17ead1(0x211)](_0x17ead1(0x262),_0x25b28b['id'],_0x1d4a95['id'],_0x1d4a95['interval'],util[_0x17ead1(0x1db)](_0x45e804,{'showHidden':![],'depth':null}),_0x25b28b[_0x17ead1(0x244)]?_0x25b28b[_0x17ead1(0x244)]:_0x17ead1(0x1d9)),![];});}exports[a133_0x21f2f4(0x291)]=function(_0x18c26b,_0xceed34){const _0x52325c=a133_0x21f2f4;let _0x32d12d=0x0,_0x53094c=0x0,_0xe72ce4=![],_0x3aa202,_0x44166c;return db['ChatWebsite'][_0x52325c(0x274)]({'where':{'id':_0x18c26b['params']['id']},'include':[{'model':db[_0x52325c(0x1c6)],'as':_0x52325c(0x1c6),'include':[{'model':db['Interval'],'as':_0x52325c(0x17f),'attributes':['id',_0x52325c(0x1f6)],'raw':!![]}]}]})[_0x52325c(0x1e3)](handleEntityNotFound(_0xceed34,null))[_0x52325c(0x1e3)](function(_0x44f5e9){const _0x1dfc48=_0x52325c;if(_0x44f5e9)return _0x3aa202=_0x44f5e9,_0x44f5e9[_0x1dfc48(0x1d7)]({'raw':!![]});})[_0x52325c(0x1e3)](function(_0xfde365){const _0x267c6b=_0x52325c;return _0x3aa202&&(_0xfde365&&(_0x44166c=_0xfde365)),require('@config/license/util')[_0x267c6b(0x188)]();})[_0x52325c(0x1e3)](function(_0x2c8def){const _0x3375f4=_0x52325c;_0x2c8def&&(_0x53094c=_0x2c8def[_0x3375f4(0x27c)],_0xe72ce4=_0x2c8def[_0x3375f4(0x1df)]);})['then'](function(){const _0x41d2e9=_0x52325c;return db[_0x41d2e9(0x1d4)][_0x41d2e9(0x1c7)]({'where':{'closed':![]}});})[_0x52325c(0x1e3)](function(_0x4fab03){const _0x16b6fd=_0x52325c;_0x32d12d=_0x4fab03;if(_0x53094c&&_0x4fab03>_0x53094c)return db[_0x16b6fd(0x1cb)][_0x16b6fd(0x274)]({'where':{'id':0x1}})[_0x16b6fd(0x1e3)](function(_0x508b23){const _0x5c6063=_0x16b6fd;_0x508b23&&_0x508b23['increment'](_0x5c6063(0x273));});})[_0x52325c(0x1e3)](function(){const _0x13895f=_0x52325c;if(_0x3aa202[_0x13895f(0x1c6)]&&_0x3aa202[_0x13895f(0x1c6)]['Intervals']){const _0xd9bf61=[];for(let _0x3b9dc2=0x0;_0x3b9dc2<_0x3aa202[_0x13895f(0x1c6)][_0x13895f(0x17f)][_0x13895f(0x290)];_0x3b9dc2++){const _0x2f02a4=_0x3aa202[_0x13895f(0x1c6)][_0x13895f(0x17f)][_0x3b9dc2][_0x13895f(0x215)]({'plain':!![]});_0xd9bf61[_0x13895f(0x193)](iftimePromise(_0x2f02a4,_0x3aa202));}return Promise['all'](_0xd9bf61)[_0x13895f(0x1e3)](function(_0x31b796){const _0x225c66=_0x13895f;return _[_0x225c66(0x1c8)](_0x31b796);});}else return!![];})[_0x52325c(0x1e3)](function(_0x1fa397){const _0x45bf99=_0x52325c,_0x15ffc9=_0x18c26b['app']['get']('chatVersion'),_0x5b4e7c=fs[_0x45bf99(0x1de)](path[_0x45bf99(0x1b7)](config['root'],_0x45bf99(0x253)),_0x45bf99(0x242)),_0x552e71={'chatVersion':_0x15ffc9,'remote':_0x3aa202[_0x45bf99(0x214)],'query':querystring[_0x45bf99(0x25e)](_[_0x45bf99(0x1c3)](_0x3aa202[_0x45bf99(0x215)]({'plain':!![]}),{'customerIp':_0x18c26b[_0x45bf99(0x18c)]['x-forwarded-for']||_0x18c26b[_0x45bf99(0x18c)]['x-real-ip']||_0x18c26b['socket'][_0x45bf99(0x1d6)]||_0x18c26b['ip'],'referer':_0x18c26b['headers'][_0x45bf99(0x238)],'openedInteractions':_0x32d12d,'maxInteractions':_0x53094c,'virtual':_0xe72ce4['virtual'],'online':_0x1fa397,'custom':_0xe72ce4}))[_0x45bf99(0x1b3)](/'/g,'\x5c\x27')};_0xceed34['set'](_0x45bf99(0x269),'text/javascript')[_0x45bf99(0x216)]('Access-Control-Allow-Origin',_0x3aa202[_0x45bf99(0x217)])['send'](ejs['render'](Mustache[_0x45bf99(0x25d)](_0x5b4e7c,_0x552e71),{'proactiveActions':_0x44166c,'alignment':_0x3aa202[_0x45bf99(0x1f0)],'verticalAlignment':_0x3aa202['verticalAlignment'],'div_color':_0x3aa202[_0x45bf99(0x180)],'text_color':_0x3aa202[_0x45bf99(0x270)],'isDevelopment':cs[_0x45bf99(0x247)]}));})['catch'](handleError(_0xceed34,null));},exports[a133_0x21f2f4(0x289)]=function(_0x112057,_0x4072c3){const _0xe06dd8=a133_0x21f2f4;return db['ChatWebsite'][_0xe06dd8(0x274)]({'where':{'id':_0x112057[_0xe06dd8(0x190)]['id']}})[_0xe06dd8(0x1e3)](handleEntityNotFound(_0x4072c3,null))[_0xe06dd8(0x1e3)](function(_0x42be98){const _0x57e2a3=_0xe06dd8;if(_0x42be98)return db[_0x57e2a3(0x28d)][_0x57e2a3(0x1e0)](function(_0x36a75c){const _0x28e7ad=_0x57e2a3;return db[_0x28e7ad(0x226)]['destroy']({'where':{'ChatWebsiteId':_0x112057[_0x28e7ad(0x190)]['id']},'transaction':_0x36a75c})['then'](function(){const _0x604e59=_0x28e7ad,_0x873c1d=_[_0x604e59(0x271)](_0x112057[_0x604e59(0x22c)],function(_0x3a44eb){const _0x4914a4=_0x604e59;return _0x3a44eb[_0x4914a4(0x1b6)]=_0x112057[_0x4914a4(0x190)]['id'],_0x3a44eb;}),_0x13988d=_0x873c1d['filter'](_0x1440f2=>_0x1440f2[_0x604e59(0x197)]);return db[_0x604e59(0x226)][_0x604e59(0x1f8)](_0x13988d,{'transaction':_0x36a75c});});})[_0x57e2a3(0x1e3)](function(){const _0x19078a=_0x57e2a3;return db[_0x19078a(0x226)][_0x19078a(0x1cc)]({'where':{'ChatWebsiteId':_0x112057[_0x19078a(0x190)]['id']},'order':db[_0x19078a(0x28d)][_0x19078a(0x254)]('priority')});});})[_0xe06dd8(0x1e3)](respondWithResult(_0x4072c3,null))[_0xe06dd8(0x265)](handleError(_0x4072c3,null));},exports[a133_0x21f2f4(0x27e)]=function(_0x263549,_0x4b9302){const _0x358faf=a133_0x21f2f4;let _0x41554d={};const _0x89d16c={};let _0x1a44b7,_0x5ad2de;return db['ChatWebsite'][_0x358faf(0x274)]({'where':{'id':_0x263549['params']['id']}})['then'](handleEntityNotFound(_0x4b9302,null))[_0x358faf(0x1e3)](function(_0x5022d1){const _0x36158e=_0x358faf;if(_0x5022d1)return _0x1a44b7=_0x5022d1,_0x89d16c[_0x36158e(0x203)]=_[_0x36158e(0x1bc)](db['ChatApplication']['rawAttributes']),_0x89d16c['query']=_['keys'](_0x263549['query']),_0x89d16c[_0x36158e(0x185)]=_[_0x36158e(0x1aa)](_0x89d16c[_0x36158e(0x203)],_0x89d16c[_0x36158e(0x20e)]),_0x41554d[_0x36158e(0x208)]=_[_0x36158e(0x1aa)](_0x89d16c['model'],qs[_0x36158e(0x285)](_0x263549[_0x36158e(0x20e)][_0x36158e(0x285)])),_0x41554d[_0x36158e(0x208)]=_0x41554d[_0x36158e(0x208)][_0x36158e(0x290)]?_0x41554d[_0x36158e(0x208)]:_0x89d16c[_0x36158e(0x203)],_0x41554d[_0x36158e(0x212)]=qs[_0x36158e(0x19d)](_0x263549[_0x36158e(0x20e)]['sort']),_0x41554d[_0x36158e(0x272)]=qs['filters'](_[_0x36158e(0x23e)](_0x263549[_0x36158e(0x20e)],_0x89d16c[_0x36158e(0x185)])),_0x41554d=filterAttributes(_0x41554d,_0x263549[_0x36158e(0x20e)]['filter'],_0x41554d['attributes'],_0x263549['options'],![]),_0x1a44b7['getApplications'](_0x41554d);})[_0x358faf(0x1e3)](function(_0x436145){const _0x8af536=_0x358faf;if(_0x436145)return _0x5ad2de=_0x436145['length'],typeof _0x263549[_0x8af536(0x20e)][_0x8af536(0x263)]==='undefined'&&(_0x41554d[_0x8af536(0x1ad)]=qs['limit'](_0x263549[_0x8af536(0x20e)][_0x8af536(0x1ad)]),_0x41554d[_0x8af536(0x192)]=qs[_0x8af536(0x192)](_0x263549[_0x8af536(0x20e)][_0x8af536(0x192)])),_0x1a44b7[_0x8af536(0x27e)](_0x41554d);})[_0x358faf(0x1e3)](function(_0x4e991a){if(_0x4e991a)return _0x4e991a?{'count':_0x5ad2de,'rows':_0x4e991a}:null;})[_0x358faf(0x1e3)](respondWithResult(_0x4b9302,null))[_0x358faf(0x265)](handleError(_0x4b9302,null));},exports[a133_0x21f2f4(0x20a)]=function(_0x2cd1a4,_0x182c48){const _0x203d5d=a133_0x21f2f4;return db[_0x203d5d(0x241)]['findOne']({'where':{'id':_0x2cd1a4['params']['id']}})[_0x203d5d(0x1e3)](function(_0x2ee003){const _0x3ad5db=_0x203d5d;if(_0x2ee003)return _0x2ee003[_0x3ad5db(0x20a)](_0x2cd1a4[_0x3ad5db(0x22c)][_0x3ad5db(0x200)],{'through':_[_0x3ad5db(0x220)](_0x2cd1a4[_0x3ad5db(0x22c)],['ids','id'])});})[_0x203d5d(0x1e3)](respondWithResult(_0x182c48,null))[_0x203d5d(0x265)](handleError(_0x182c48,null));},exports[a133_0x21f2f4(0x1d7)]=function(_0x48168e,_0x3f9634){const _0x32f9cf=a133_0x21f2f4;let _0x5f26e4={};const _0x27efa2={};let _0x4f9c9d,_0x4524e1;return db[_0x32f9cf(0x1e7)]['findOne']({'where':{'id':_0x48168e[_0x32f9cf(0x190)]['id']}})[_0x32f9cf(0x1e3)](handleEntityNotFound(_0x3f9634,null))['then'](function(_0x58404e){const _0x485a50=_0x32f9cf;if(_0x58404e)return _0x4f9c9d=_0x58404e,_0x27efa2[_0x485a50(0x203)]=_[_0x485a50(0x1bc)](db[_0x485a50(0x1a4)][_0x485a50(0x1be)]),_0x27efa2[_0x485a50(0x20e)]=_[_0x485a50(0x1bc)](_0x48168e['query']),_0x27efa2[_0x485a50(0x185)]=_['intersection'](_0x27efa2[_0x485a50(0x203)],_0x27efa2[_0x485a50(0x20e)]),_0x5f26e4[_0x485a50(0x208)]=_[_0x485a50(0x1aa)](_0x27efa2['model'],qs['fields'](_0x48168e[_0x485a50(0x20e)][_0x485a50(0x285)])),_0x5f26e4['attributes']=_0x5f26e4[_0x485a50(0x208)][_0x485a50(0x290)]?_0x5f26e4[_0x485a50(0x208)]:_0x27efa2['model'],_0x5f26e4[_0x485a50(0x212)]=qs[_0x485a50(0x19d)](_0x48168e[_0x485a50(0x20e)]['sort']),_0x5f26e4['where']=qs[_0x485a50(0x185)](_[_0x485a50(0x23e)](_0x48168e[_0x485a50(0x20e)],_0x27efa2['filters'])),_0x5f26e4=filterAttributes(_0x5f26e4,_0x48168e['query'][_0x485a50(0x227)],_0x5f26e4[_0x485a50(0x208)],_0x48168e[_0x485a50(0x28e)],![]),_0x4f9c9d[_0x485a50(0x1d7)](_0x5f26e4);})['then'](function(_0x420bd7){const _0x2800ff=_0x32f9cf;if(_0x420bd7)return _0x4524e1=_0x420bd7['length'],typeof _0x48168e[_0x2800ff(0x20e)][_0x2800ff(0x263)]===_0x2800ff(0x293)&&(_0x5f26e4['limit']=qs[_0x2800ff(0x1ad)](_0x48168e[_0x2800ff(0x20e)][_0x2800ff(0x1ad)]),_0x5f26e4[_0x2800ff(0x192)]=qs['offset'](_0x48168e['query']['offset'])),_0x4f9c9d[_0x2800ff(0x1d7)](_0x5f26e4);})[_0x32f9cf(0x1e3)](function(_0x2d9787){if(_0x2d9787)return _0x2d9787?{'count':_0x4524e1,'rows':_0x2d9787}:null;})[_0x32f9cf(0x1e3)](respondWithResult(_0x3f9634,null))[_0x32f9cf(0x265)](handleError(_0x3f9634,null));},exports[a133_0x21f2f4(0x202)]=function(_0x22b4e8,_0x2965d5){const _0x3b569e=a133_0x21f2f4,_0xc8984b=_0x22b4e8[_0x3b569e(0x20e)][_0x3b569e(0x1cf)]===_0x3b569e(0x21d)?_0x3b569e(0x1dd):_0x3b569e(0x257);return db[_0x3b569e(0x1e7)][_0x3b569e(0x274)]({'attributes':['id',_0xc8984b],'where':{'id':_0x22b4e8['params']['id']}})[_0x3b569e(0x1e3)](handleEntityNotFound(_0x2965d5,null))[_0x3b569e(0x1e3)](function(_0x1c59a7){const _0x4dae36=_0x3b569e;if(_0x1c59a7){const _0x25bd01=_0x1c59a7[_0xc8984b],_0x30be6b=_0x25bd01&&_0x25bd01[_0x4dae36(0x286)]?_0x25bd01[_0x4dae36(0x286)]:[];_0x2965d5[_0x4dae36(0x206)]({'fromKey':_[_0x4dae36(0x195)](_0x25bd01[_0x4dae36(0x219)])?undefined:_0x25bd01[_0x4dae36(0x219)],'count':_0x30be6b[_0x4dae36(0x290)],'rows':_0x30be6b});}})[_0x3b569e(0x265)](handleError(_0x2965d5,null));},exports[a133_0x21f2f4(0x259)]=function(_0x5d3243,_0x4d9fd1){const _0x11b48e=a133_0x21f2f4;let _0x58db04={'raw':![],'where':{}};const _0x22c723={},_0x4934e4={'count':0x0,'rows':[]};return db[_0x11b48e(0x1e7)][_0x11b48e(0x274)]({'where':{'id':_0x5d3243[_0x11b48e(0x190)]['id']}})[_0x11b48e(0x1e3)](handleEntityNotFound(_0x4d9fd1,null))[_0x11b48e(0x1e3)](function(_0x5ab8a6){const _0xd39563=_0x11b48e;if(_0x5ab8a6)return _0x22c723[_0xd39563(0x203)]=_[_0xd39563(0x1bc)](db[_0xd39563(0x266)][_0xd39563(0x1be)]),_0x22c723[_0xd39563(0x20e)]=_[_0xd39563(0x1bc)](_0x5d3243[_0xd39563(0x20e)]),_0x22c723[_0xd39563(0x185)]=_[_0xd39563(0x1aa)](_0x22c723[_0xd39563(0x203)],_0x22c723['query']),_0x58db04['attributes']=_[_0xd39563(0x1aa)](_0x22c723[_0xd39563(0x203)],qs['fields'](_0x5d3243[_0xd39563(0x20e)][_0xd39563(0x285)])),_0x58db04[_0xd39563(0x208)]=_0x58db04[_0xd39563(0x208)][_0xd39563(0x290)]?_0x58db04[_0xd39563(0x208)]:_0x22c723[_0xd39563(0x203)],typeof _0x5d3243[_0xd39563(0x20e)][_0xd39563(0x263)]===_0xd39563(0x293)&&(_0x58db04[_0xd39563(0x1ad)]=qs[_0xd39563(0x1ad)](_0x5d3243[_0xd39563(0x20e)][_0xd39563(0x1ad)]),_0x58db04[_0xd39563(0x192)]=qs[_0xd39563(0x192)](_0x5d3243[_0xd39563(0x20e)][_0xd39563(0x192)])),_0x58db04[_0xd39563(0x212)]=qs['sort'](_0x5d3243[_0xd39563(0x20e)][_0xd39563(0x19d)]),_0x58db04[_0xd39563(0x272)]=qs[_0xd39563(0x185)](_[_0xd39563(0x23e)](_0x5d3243[_0xd39563(0x20e)],_0x22c723[_0xd39563(0x185)])),_0x58db04[_0xd39563(0x272)][_0xd39563(0x1b6)]=_0x5ab8a6['id'],_0x58db04=filterAttributes(_0x58db04,_0x5d3243['query']['filter'],_0x58db04['attributes'],_0x5d3243[_0xd39563(0x28e)],![]),db[_0xd39563(0x266)][_0xd39563(0x1c7)]({'where':_0x58db04['where']})[_0xd39563(0x1e3)](function(_0x248957){const _0x246a28=_0xd39563;return _0x4934e4[_0x246a28(0x1c7)]=_0x248957,_0x5d3243['query']['includeAll']?_0x58db04['include']=[{'all':!![]}]:_0x58db04[_0x246a28(0x1e2)]=[{'model':db['CmContact'],'as':'Contact','required':![]}],db[_0x246a28(0x266)]['findAll'](_0x58db04);})['then'](function(_0x4e1294){return _0x4934e4['rows']=_0x4e1294,_0x4934e4;});})[_0x11b48e(0x1e3)](respondWithFilteredResult(_0x4d9fd1,_0x58db04))[_0x11b48e(0x265)](handleError(_0x4d9fd1,null));},exports[a133_0x21f2f4(0x187)]=function(_0x15bff2,_0x3e220c){const _0x223358=a133_0x21f2f4;return db[_0x223358(0x1e7)][_0x223358(0x274)]({'where':{'id':_0x15bff2[_0x223358(0x190)]['id']}})[_0x223358(0x1e3)](function(_0x41842e){const _0x404708=_0x223358;if(_0x41842e)return _0x41842e['addAgents'](_0x15bff2['body'][_0x404708(0x200)],{'through':_[_0x404708(0x220)](_0x15bff2[_0x404708(0x22c)],['ids','id'])})[_0x404708(0x1e3)](function(_0x44a76f){const _0x12b2dc=_0x404708;for(let _0x1a59d0=0x0;_0x1a59d0<_0x15bff2['body']['ids'][_0x12b2dc(0x290)];_0x1a59d0+=0x1){socket[_0x12b2dc(0x1a6)](_0x12b2dc(0x207),{'UserId':_0x15bff2[_0x12b2dc(0x22c)][_0x12b2dc(0x200)][_0x1a59d0],'ChatWebsiteId':_0x15bff2[_0x12b2dc(0x190)]['id']});}return _0x44a76f;});})[_0x223358(0x1e3)](respondWithResult(_0x3e220c,null))['catch'](handleError(_0x3e220c,null));},exports[a133_0x21f2f4(0x23a)]=function(_0x3fd191,_0x29a741){const _0x4cbafa=a133_0x21f2f4;return db[_0x4cbafa(0x1e7)][_0x4cbafa(0x274)]({'where':{'id':_0x3fd191['params']['id']}})[_0x4cbafa(0x1e3)](handleEntityNotFound(_0x29a741,null))[_0x4cbafa(0x1e3)](function(_0x15d977){const _0x140557=_0x4cbafa;if(_0x15d977)return _0x15d977[_0x140557(0x23a)](_0x3fd191[_0x140557(0x20e)]['ids'])['then'](function(){const _0x4f5413=_0x140557;if(_['isArray'](_0x3fd191[_0x4f5413(0x20e)][_0x4f5413(0x200)]))for(let _0x33326e=0x0;_0x33326e<_0x3fd191[_0x4f5413(0x20e)]['ids'][_0x4f5413(0x290)];_0x33326e+=0x1){socket['emit']('userChatWebsite:remove',{'UserId':Number(_0x3fd191[_0x4f5413(0x20e)][_0x4f5413(0x200)][_0x33326e]),'ChatWebsiteId':Number(_0x3fd191['params']['id'])});}else socket['emit'](_0x4f5413(0x223),{'UserId':Number(_0x3fd191['query'][_0x4f5413(0x200)]),'ChatWebsiteId':Number(_0x3fd191['params']['id'])});});})[_0x4cbafa(0x1e3)](respondWithStatusCode(_0x29a741,null))[_0x4cbafa(0x265)](handleError(_0x29a741,null));},exports[a133_0x21f2f4(0x26f)]=function(_0xef4a4,_0x1763a7){const _0x1ea145=a133_0x21f2f4;let _0x2e873d={};const _0x4299a9={};let _0x17d9ea,_0x2bde88;return db[_0x1ea145(0x1e7)]['findOne']({'where':{'id':_0xef4a4[_0x1ea145(0x190)]['id']}})[_0x1ea145(0x1e3)](handleEntityNotFound(_0x1763a7,null))[_0x1ea145(0x1e3)](function(_0x313b22){const _0x38c7a1=_0x1ea145;if(_0x313b22)return _0x17d9ea=_0x313b22,_0x4299a9[_0x38c7a1(0x203)]=_['keys'](db[_0x38c7a1(0x1ba)][_0x38c7a1(0x1be)]),_0x4299a9[_0x38c7a1(0x20e)]=_[_0x38c7a1(0x1bc)](_0xef4a4[_0x38c7a1(0x20e)]),_0x4299a9[_0x38c7a1(0x185)]=_['intersection'](_0x4299a9[_0x38c7a1(0x203)],_0x4299a9[_0x38c7a1(0x20e)]),_0x2e873d['attributes']=_[_0x38c7a1(0x1aa)](_0x4299a9[_0x38c7a1(0x203)],qs[_0x38c7a1(0x285)](_0xef4a4['query'][_0x38c7a1(0x285)])),_0x2e873d[_0x38c7a1(0x208)]=_0x2e873d[_0x38c7a1(0x208)][_0x38c7a1(0x290)]?_0x2e873d[_0x38c7a1(0x208)]:_0x4299a9[_0x38c7a1(0x203)],_0x2e873d[_0x38c7a1(0x212)]=qs['sort'](_0xef4a4[_0x38c7a1(0x20e)][_0x38c7a1(0x19d)]),_0x2e873d['where']=qs[_0x38c7a1(0x185)](_[_0x38c7a1(0x23e)](_0xef4a4[_0x38c7a1(0x20e)],_0x4299a9[_0x38c7a1(0x185)])),_0x2e873d=filterAttributes(_0x2e873d,_0xef4a4[_0x38c7a1(0x20e)][_0x38c7a1(0x227)],_0x2e873d[_0x38c7a1(0x208)],_0xef4a4['options'],![]),_0x17d9ea[_0x38c7a1(0x26f)](_0x2e873d);})['then'](function(_0x2f664d){const _0x33fd41=_0x1ea145;if(_0x2f664d)return _0x2bde88=_0x2f664d[_0x33fd41(0x290)],typeof _0xef4a4[_0x33fd41(0x20e)][_0x33fd41(0x263)]==='undefined'&&(_0x2e873d[_0x33fd41(0x1ad)]=qs['limit'](_0xef4a4[_0x33fd41(0x20e)]['limit']),_0x2e873d[_0x33fd41(0x192)]=qs[_0x33fd41(0x192)](_0xef4a4[_0x33fd41(0x20e)]['offset'])),_0x17d9ea[_0x33fd41(0x26f)](_0x2e873d);})[_0x1ea145(0x1e3)](function(_0x29f59f){if(_0x29f59f)return _0x29f59f?{'count':_0x2bde88,'rows':_0x29f59f}:null;})[_0x1ea145(0x1e3)](respondWithResult(_0x1763a7,null))[_0x1ea145(0x265)](handleError(_0x1763a7,null));};
\ No newline at end of file
+'use strict';const a133_0x5073=['ejs','include','getDispositions','download','join','filter','info','sort','defaults','result','Unable\x20to\x20retrieve\x20the\x20current\x20user','agent','ONLINE','Command','catch','order','applications','commit','mapKeyOffline','port','set','@utils/console-logger','app','contact','verticalAlignment','priority','Applications','unknown','918686kbgWfC','getAnswers','stack','limit','Could\x20not\x20remove\x20attachment\x20file','describe','body','index','getFields','getResult','bulkCreate','merge','user-agent-parser','service','lastName','firstName','mandatoryDispositionPause','fields','headers','Content-Range','remoteAddress','CmList','orderBy','getLicense','CannedAnswer','type','code','referer','autoclose','@components/parsers/qs','get','map','ChatWebsite','end','3BtyBUs','offlineMessageSubject','NotifyMailAccount','path','CmContact','mimetype','@utils/filter-attributes','fs-extra','error','transaction','findOne','User','updatedAt','getProactiveActions','1302090tEgHyG','basename','getInteractions','205738qLqadH','fromKey','startRouting','files','count','sendStatus','addLogo','getAgents','ListId','keys','omit','messageId','mustache','readFile','host','length','indexOf','ChatWebsiteId','findAndCountAll','files/images/avatars/','Attachment','Access-Control-Allow-Origin','close','notify','agentAvatar','openNewInteraction','stringify','List','OFFLINE','body\x20is\x20mandatory\x20and\x20not\x20empty','items','Interval','unshift','customerAvatar','ChatApplication','addInteraction','name','[%s][INTERVAL][%s]\x20%s\x20%s\x20(%s)','showCustomerAvatar','userChatWebsite:remove','text/javascript','timezone','file','Contact','request\x20sent','fieldName','addAvatar','options','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','MailAccountId','getLogo','backgroundColor','pick','attributes','getCustomerAvatar','query','appdata','secure','util','emit','undefined','custom','Tags','addDisposition','getOfflineMessages','account','@mysqldb','iftime\x20%s','iftime\x20%s,%s','col','227296vTrxxJ','root','sequelize','inspect','device','UserProfileSection','toPairs','ChatWebsites','@rediscache','browser','Intervals','CompanyId','from','format','getSnippet','findAll','interval','SendMail','show','nolimit','Not\x20Found','addCustomerAvatar','pass','offline-chat','vendor','push','intersection','mapKeyOffline\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','online','x-real-port','update','ChatOfflineMessage','difference','getApplications','x-forwarded-for','ChatWebsite,\x20%s,\x20%s','forwardOffline','isNil','interaction','then','2kibCjm','rpcRoutingPort','Contacts','addAgents','customerIp','Smtp','rows','version','EventManager','params','sitepic','client','rpcEmailIp','No\x20timezone','jayson/promise','register','systemAvatar','email','@config/logger','Pause','offset','no\x20available\x20attributes','UserId','forcedOwnership','key','69038Zlqxgl','userProfileId','includeAll','setUA','findOrCreate','Disposition','chatProactiveAction','created','color','some','address','threadId','role','%s\x20%s','13zLXWZq','ChatMessage','originalname','increment','virtual','from\x20is\x20mandatory','user-agent','autoAssociation','Start','filename','create','@config/get-config','onlineForm','rawAttributes','querystring','@config/license/util','./chatWebsite.socket','filters','rpcRoutingIp','333773YFXreC','render','3hFKoZP','attachments','destroy','removeDispositions','ChatWebsite,\x20%s,\x20%s,\x20%s','waitForTheAssignedAgent','addProactiveActions','chat','http','ids','License','ChatInteraction','isArray','files/images/logos/default_logo.svg','message','AttachmentId','split','cf-connecting-ip','existsSync','MailAccount','replace','authentication','status','json','ContactId','removeAnswers','%s\x20%s\x20%s','files/images/logos/','rpcAmiPort','*,*,*,*','mapKey','addSystemAvatar','model','notifyMail','alignment','where','offline','546022PZxeHa','chatVersion','textColor','removeAgents','includes','user','files/images/avatars/system_avatar.png','getSystemAvatar','getAvatar','Attachments','send','unmanaged','all','Owner','remove'];const a133_0x24b1=function(_0x3be105,_0x16e005){_0x3be105=_0x3be105-0x1e7;let _0x5073c7=a133_0x5073[_0x3be105];return _0x5073c7;};const a133_0x5904da=a133_0x24b1;(function(_0x433d54,_0x5f3939){const _0x16fb6d=a133_0x24b1;while(!![]){try{const _0x34ecaa=parseInt(_0x16fb6d(0x2dd))*-parseInt(_0x16fb6d(0x26f))+parseInt(_0x16fb6d(0x23c))+-parseInt(_0x16fb6d(0x2b5))*parseInt(_0x16fb6d(0x25e))+parseInt(_0x16fb6d(0x304))*-parseInt(_0x16fb6d(0x2f6))+-parseInt(_0x16fb6d(0x211))+parseInt(_0x16fb6d(0x1ea))*parseInt(_0x16fb6d(0x1ec))+parseInt(_0x16fb6d(0x26c));if(_0x34ecaa===_0x5f3939)break;else _0x433d54['push'](_0x433d54['shift']());}catch(_0x6acb00){_0x433d54['push'](_0x433d54['shift']());}}}(a133_0x5073,0xa749f));const Mustache=require(a133_0x5904da(0x27b)),util=require(a133_0x5904da(0x2a9)),path=require(a133_0x5904da(0x261)),ejs=require(a133_0x5904da(0x220)),fs=require(a133_0x5904da(0x265)),_=require('lodash'),querystring=require(a133_0x5904da(0x312)),qs=require(a133_0x5904da(0x259)),logger=require(a133_0x5904da(0x2ef))('api'),{getConfig}=require(a133_0x5904da(0x30f)),{db}=require(a133_0x5904da(0x2b1)),{ValidationError}=require(a133_0x5904da(0x2b7)),{filterAttributes}=require(a133_0x5904da(0x264)),{getSocket}=require(a133_0x5904da(0x2bd)),socket=getSocket(),UAParser=require(a133_0x5904da(0x248));require(a133_0x5904da(0x1e7))[a133_0x5904da(0x2ec)](socket);const jayson=require(a133_0x5904da(0x2eb)),{consoleLogger}=require(a133_0x5904da(0x235)),config=getConfig(),client=jayson[a133_0x5904da(0x2e8)][a133_0x5904da(0x1f4)]({'host':config['rpcIp'],'port':config['rpcPort']}),rpcAmiClient=jayson[a133_0x5904da(0x2e8)][a133_0x5904da(0x1f4)]({'host':config['rpcAmiIp'],'port':config[a133_0x5904da(0x208)]}),rpcEmailClient=jayson[a133_0x5904da(0x2e8)][a133_0x5904da(0x1f4)]({'host':config[a133_0x5904da(0x2e9)],'port':config['rpcEmailPort']}),rpcRoutingClient=jayson[a133_0x5904da(0x2e8)][a133_0x5904da(0x1f4)]({'host':config[a133_0x5904da(0x1e9)],'port':config[a133_0x5904da(0x2de)]});function respondWithRpcPromise(_0x2089fd,_0x138049,_0x157280,_0x303991){return new Promise(function(_0x1680e3,_0x150171){const _0x58ffc9=a133_0x24b1,_0x533390=_0x303991||rpcRoutingClient;return _0x533390['request'](_0x2089fd,_0x157280)['then'](function(_0x5d4f54){const _0x38e958=a133_0x24b1;logger[_0x38e958(0x226)](_0x38e958(0x2d8),_0x138049,'request\x20sent'),logger['debug'](_0x38e958(0x1f0),_0x138049,'request\x20sent',JSON[_0x38e958(0x289)](_0x5d4f54));if(_0x5d4f54[_0x38e958(0x266)]){if(_0x5d4f54[_0x38e958(0x266)][_0x38e958(0x256)]===0x1f4)return logger[_0x38e958(0x266)](_0x38e958(0x2d8),_0x138049,_0x5d4f54[_0x38e958(0x266)][_0x38e958(0x1fa)]),_0x150171(_0x5d4f54[_0x38e958(0x266)][_0x38e958(0x1fa)]);return logger['error'](_0x38e958(0x2d8),_0x138049,_0x5d4f54[_0x38e958(0x266)][_0x38e958(0x1fa)]),_0x1680e3(_0x5d4f54['error'][_0x38e958(0x1fa)]);}else logger['info']('ChatWebsite,\x20%s,\x20%s',_0x138049,_0x38e958(0x29b)),_0x1680e3(_0x5d4f54[_0x38e958(0x229)][_0x38e958(0x1fa)]);})[_0x58ffc9(0x22e)](function(_0x1dec96){const _0x3bc314=_0x58ffc9;logger[_0x3bc314(0x266)](_0x3bc314(0x2d8),_0x138049,_0x1dec96),_0x150171(_0x1dec96);});});}function respondWithStatusCode(_0x311c51,_0x44c820){return _0x44c820=_0x44c820||0xcc,function(_0x2d7866){const _0x3b00aa=a133_0x24b1;if(_0x2d7866)return _0x311c51[_0x3b00aa(0x274)](_0x44c820);return _0x311c51[_0x3b00aa(0x202)](_0x44c820)[_0x3b00aa(0x25d)]();};}function respondWithResult(_0x2c3f38,_0x2eca5c){return _0x2eca5c=_0x2eca5c||0xc8,function(_0x14a617){const _0x2fb674=a133_0x24b1;if(_0x14a617)return _0x2c3f38[_0x2fb674(0x202)](_0x2eca5c)[_0x2fb674(0x203)](_0x14a617);};}function respondWithFilteredResult(_0x21e4d5,_0x515ec4){return function(_0x28bb3f){const _0x4d1f5f=a133_0x24b1;if(_0x28bb3f){const _0x1e282c=_0x28bb3f['count'],_0xf9405a=_0x515ec4[_0x4d1f5f(0x2f1)];let _0x1cfb3f=_0x515ec4['offset']+_0x515ec4[_0x4d1f5f(0x23f)],_0xf48e4;return _0x1cfb3f>=_0x1e282c?(_0x1cfb3f=_0x1e282c,_0xf48e4=0xc8):_0xf48e4=0xce,_0x21e4d5[_0x4d1f5f(0x202)](_0xf48e4),_0x21e4d5['set'](_0x4d1f5f(0x24f),_0xf9405a+'-'+_0x1cfb3f+'/'+_0x1e282c)[_0x4d1f5f(0x203)](_0x28bb3f);}return null;};}function saveUpdates(_0x131bf7){return function(_0x16fc4d){const _0x505618=a133_0x24b1;if(_0x16fc4d)return _0x16fc4d[_0x505618(0x2d3)](_0x131bf7)[_0x505618(0x2dc)](function(_0x15d62d){return _0x15d62d;});return null;};}function removeEntity(_0x58b949){return function(_0x3ba0b8){const _0x110243=a133_0x24b1;if(_0x3ba0b8)return _0x3ba0b8[_0x110243(0x1ee)]()[_0x110243(0x2dc)](function(){const _0x3714a7=_0x110243,_0x1f7d7a=_0x3ba0b8['get']({'plain':!![]}),_0x2666ef=_0x3714a7(0x2bc);return db['UserProfileResource']['destroy']({'where':{'type':_0x2666ef,'resourceId':_0x1f7d7a['id']}})['then'](function(){return _0x3ba0b8;});})[_0x110243(0x2dc)](function(){const _0x5d785b=_0x110243;_0x58b949[_0x5d785b(0x202)](0xcc)[_0x5d785b(0x25d)]();});};}function handleEntityNotFound(_0x18e844){return function(_0x46655e){return!_0x46655e&&_0x18e844['sendStatus'](0x194),_0x46655e;};}function handleError(_0x2a10d6,_0x449225){return _0x449225=_0x449225||0x1f4,function(_0x39d055){const _0xb163e=a133_0x24b1;logger[_0xb163e(0x266)](_0x39d055[_0xb163e(0x23e)]),_0x39d055[_0xb163e(0x293)]&&delete _0x39d055['name'],_0x2a10d6[_0xb163e(0x202)](_0x449225)[_0xb163e(0x21b)](_0x39d055);};}exports[a133_0x5904da(0x243)]=function(_0x4ff6fa,_0x34a972){const _0x27a5ec=a133_0x5904da;let _0x519781={'include':[{'model':db[_0x27a5ec(0x2f0)],'as':_0x27a5ec(0x24c)}]};const _0x4529e7={},_0x7063f0={'count':0x0,'rows':[]},_0x28d755=_[_0x27a5ec(0x25b)](db[_0x27a5ec(0x25c)][_0x27a5ec(0x311)],function(_0x5d9041){const _0x4e1004=_0x27a5ec;return{'name':_0x5d9041[_0x4e1004(0x29c)],'type':_0x5d9041[_0x4e1004(0x255)][_0x4e1004(0x2f5)]};});_0x4529e7[_0x27a5ec(0x20c)]=_[_0x27a5ec(0x25b)](_0x28d755,'name'),_0x4529e7[_0x27a5ec(0x2a6)]=_['keys'](_0x4ff6fa[_0x27a5ec(0x2a6)]),_0x4529e7[_0x27a5ec(0x1e8)]=_[_0x27a5ec(0x2cf)](_0x4529e7[_0x27a5ec(0x20c)],_0x4529e7[_0x27a5ec(0x2a6)]),_0x519781['attributes']=_[_0x27a5ec(0x2cf)](_0x4529e7['model'],qs[_0x27a5ec(0x24d)](_0x4ff6fa[_0x27a5ec(0x2a6)]['fields'])),_0x519781[_0x27a5ec(0x2a4)]=_0x519781[_0x27a5ec(0x2a4)]['length']?_0x519781[_0x27a5ec(0x2a4)]:_0x4529e7[_0x27a5ec(0x20c)];typeof _0x4ff6fa[_0x27a5ec(0x2a6)][_0x27a5ec(0x2c8)]===_0x27a5ec(0x2ab)&&(_0x519781[_0x27a5ec(0x23f)]=qs[_0x27a5ec(0x23f)](_0x4ff6fa[_0x27a5ec(0x2a6)][_0x27a5ec(0x23f)]),_0x519781[_0x27a5ec(0x2f1)]=qs[_0x27a5ec(0x2f1)](_0x4ff6fa[_0x27a5ec(0x2a6)][_0x27a5ec(0x2f1)]));_0x519781['order']=qs[_0x27a5ec(0x227)](_0x4ff6fa[_0x27a5ec(0x2a6)][_0x27a5ec(0x227)]),_0x519781['where']=qs['filters'](_['pick'](_0x4ff6fa['query'],_0x4529e7[_0x27a5ec(0x1e8)]),_0x28d755),_0x519781=filterAttributes(_0x519781,_0x4ff6fa['query'][_0x27a5ec(0x225)],_0x28d755,_0x4ff6fa[_0x27a5ec(0x29e)]);const _0xa6ccef={'where':_0x519781[_0x27a5ec(0x20f)]};return db[_0x27a5ec(0x25c)][_0x27a5ec(0x273)](_0xa6ccef)[_0x27a5ec(0x2dc)](function(_0x595aed){const _0x49ba1=_0x27a5ec;return _0x7063f0[_0x49ba1(0x273)]=_0x595aed,_0x4ff6fa['query'][_0x49ba1(0x2f8)]&&(_0x519781[_0x49ba1(0x221)]=[{'all':!![]}]),db[_0x49ba1(0x25c)][_0x49ba1(0x2c4)](_0x519781);})['then'](function(_0x203ddf){const _0x423fb4=_0x27a5ec;return _0x7063f0[_0x423fb4(0x2e3)]=_0x203ddf,_0x7063f0;})['then'](respondWithFilteredResult(_0x34a972,_0x519781))[_0x27a5ec(0x22e)](handleError(_0x34a972,null));},exports[a133_0x5904da(0x2c7)]=function(_0x268992,_0x42e6a4){const _0x1ada45=a133_0x5904da;let _0x31e9b1={'raw':![],'where':{'id':_0x268992['params']['id']},'include':[{'model':db[_0x1ada45(0x2f0)],'as':_0x1ada45(0x24c)}]};const _0x23a4c6={};return _0x23a4c6[_0x1ada45(0x20c)]=_[_0x1ada45(0x278)](db['ChatWebsite'][_0x1ada45(0x311)]),_0x23a4c6[_0x1ada45(0x2a6)]=_[_0x1ada45(0x278)](_0x268992[_0x1ada45(0x2a6)]),_0x23a4c6[_0x1ada45(0x1e8)]=_[_0x1ada45(0x2cf)](_0x23a4c6[_0x1ada45(0x20c)],_0x23a4c6['query']),_0x31e9b1['attributes']=_[_0x1ada45(0x2cf)](_0x23a4c6[_0x1ada45(0x20c)],qs[_0x1ada45(0x24d)](_0x268992['query'][_0x1ada45(0x24d)])),_0x31e9b1[_0x1ada45(0x2a4)]=_0x31e9b1[_0x1ada45(0x2a4)][_0x1ada45(0x27e)]?_0x31e9b1[_0x1ada45(0x2a4)]:_0x23a4c6[_0x1ada45(0x20c)],_0x268992[_0x1ada45(0x2a6)]['includeAll']&&(_0x31e9b1[_0x1ada45(0x221)]=[{'all':!![]}]),_0x31e9b1=_[_0x1ada45(0x247)]({},_0x31e9b1,_0x268992[_0x1ada45(0x29e)]),db[_0x1ada45(0x25c)][_0x1ada45(0x268)](_0x31e9b1)[_0x1ada45(0x2dc)](handleEntityNotFound(_0x42e6a4,null))[_0x1ada45(0x2dc)](respondWithResult(_0x42e6a4,null))[_0x1ada45(0x22e)](handleError(_0x42e6a4,null));},exports[a133_0x5904da(0x30e)]=function(_0x2cf0b7,_0x42c7b2){const _0x40fb10=a133_0x5904da;return db['ChatWebsite']['create'](_0x2cf0b7[_0x40fb10(0x242)],{})[_0x40fb10(0x2dc)](function(_0x30a4b0){const _0x164efa=_0x40fb10,_0x5a0343=_0x2cf0b7[_0x164efa(0x216)][_0x164efa(0x25a)]({'plain':!![]});if(!_0x5a0343)throw new Error(_0x164efa(0x22a));if(_0x5a0343[_0x164efa(0x302)]===_0x164efa(0x216)){const _0x378680=_0x30a4b0[_0x164efa(0x25a)]({'plain':!![]}),_0x5f2083=_0x164efa(0x2bc);return db[_0x164efa(0x2ba)][_0x164efa(0x268)]({'where':{'name':_0x5f2083,'userProfileId':_0x5a0343[_0x164efa(0x2f7)]},'raw':!![]})[_0x164efa(0x2dc)](function(_0x3251d3){const _0x55a18f=_0x164efa;return _0x3251d3&&_0x3251d3[_0x55a18f(0x30b)]===0x0?db['UserProfileResource']['create']({'name':_0x378680['name'],'resourceId':_0x378680['id'],'type':_0x3251d3[_0x55a18f(0x293)],'sectionId':_0x3251d3['id']},{})[_0x55a18f(0x2dc)](function(){return _0x30a4b0;}):_0x30a4b0;})[_0x164efa(0x22e)](function(_0x16e3c8){const _0x22b698=_0x164efa;logger[_0x22b698(0x266)](_0x22b698(0x29f),_0x16e3c8);throw _0x16e3c8;});}return _0x30a4b0;})[_0x40fb10(0x2dc)](respondWithResult(_0x42c7b2,0xc9))[_0x40fb10(0x22e)](handleError(_0x42c7b2,null));},exports[a133_0x5904da(0x2d3)]=function(_0x37681a,_0x3b9e3c){const _0x14a092=a133_0x5904da;return _0x37681a['body']['id']&&delete _0x37681a[_0x14a092(0x242)]['id'],db[_0x14a092(0x25c)][_0x14a092(0x268)]({'where':{'id':_0x37681a[_0x14a092(0x2e6)]['id']},'include':[{'model':db[_0x14a092(0x2f0)],'as':_0x14a092(0x24c)}]})['then'](handleEntityNotFound(_0x3b9e3c,null))['then'](saveUpdates(_0x37681a[_0x14a092(0x242)],null))[_0x14a092(0x2dc)](respondWithResult(_0x3b9e3c,null))[_0x14a092(0x22e)](handleError(_0x3b9e3c,null));},exports['destroy']=function(_0x30b043,_0x3377b6){const _0x57d3b3=a133_0x5904da;return db[_0x57d3b3(0x25c)][_0x57d3b3(0x268)]({'where':{'id':_0x30b043[_0x57d3b3(0x2e6)]['id']}})[_0x57d3b3(0x2dc)](handleEntityNotFound(_0x3377b6,null))[_0x57d3b3(0x2dc)](removeEntity(_0x3377b6,null))[_0x57d3b3(0x22e)](handleError(_0x3377b6,null));},exports['describe']=function(_0x12b09f,_0x54399c){const _0x3f7bd5=a133_0x5904da;return db[_0x3f7bd5(0x25c)][_0x3f7bd5(0x241)]()[_0x3f7bd5(0x2dc)](respondWithResult(_0x54399c,null))[_0x3f7bd5(0x22e)](handleError(_0x54399c,null));},exports[a133_0x5904da(0x2ae)]=function(_0x145156,_0x4074bb){const _0x1e9f5e=a133_0x5904da;return _0x145156[_0x1e9f5e(0x242)]['id']&&delete _0x145156['body']['id'],db['ChatWebsite'][_0x1e9f5e(0x268)]({'where':{'id':_0x145156['params']['id']}})[_0x1e9f5e(0x2dc)](handleEntityNotFound(_0x4074bb,null))[_0x1e9f5e(0x2dc)](function(_0x3114e1){if(_0x3114e1)return _0x145156['body']['ChatWebsiteId']=_0x3114e1['id'],db['Disposition']['create'](_0x145156['body']);})[_0x1e9f5e(0x2dc)](respondWithResult(_0x4074bb,null))[_0x1e9f5e(0x22e)](handleError(_0x4074bb,null));},exports[a133_0x5904da(0x222)]=function(_0xb53cb3,_0x2903ef){const _0x1768fa=a133_0x5904da;let _0x5c44d3={'raw':![],'where':{}};const _0x299e97={},_0x7267ef={'count':0x0,'rows':[]};return db['ChatWebsite'][_0x1768fa(0x268)]({'where':{'id':_0xb53cb3['params']['id']}})[_0x1768fa(0x2dc)](handleEntityNotFound(_0x2903ef,null))[_0x1768fa(0x2dc)](function(_0x2953e9){const _0x45eee3=_0x1768fa;if(_0x2953e9)return _0x299e97[_0x45eee3(0x20c)]=_[_0x45eee3(0x278)](db[_0x45eee3(0x2fb)][_0x45eee3(0x311)]),_0x299e97[_0x45eee3(0x2a6)]=_[_0x45eee3(0x278)](_0xb53cb3['query']),_0x299e97[_0x45eee3(0x1e8)]=_[_0x45eee3(0x2cf)](_0x299e97[_0x45eee3(0x20c)],_0x299e97[_0x45eee3(0x2a6)]),_0x5c44d3[_0x45eee3(0x2a4)]=_[_0x45eee3(0x2cf)](_0x299e97[_0x45eee3(0x20c)],qs[_0x45eee3(0x24d)](_0xb53cb3[_0x45eee3(0x2a6)][_0x45eee3(0x24d)])),_0x5c44d3['attributes']=_0x5c44d3['attributes'][_0x45eee3(0x27e)]?_0x5c44d3[_0x45eee3(0x2a4)]:_0x299e97[_0x45eee3(0x20c)],typeof _0xb53cb3[_0x45eee3(0x2a6)][_0x45eee3(0x2c8)]===_0x45eee3(0x2ab)&&(_0x5c44d3[_0x45eee3(0x23f)]=qs[_0x45eee3(0x23f)](_0xb53cb3[_0x45eee3(0x2a6)][_0x45eee3(0x23f)]),_0x5c44d3[_0x45eee3(0x2f1)]=qs['offset'](_0xb53cb3['query'][_0x45eee3(0x2f1)])),_0x5c44d3[_0x45eee3(0x22f)]=qs[_0x45eee3(0x227)](_0xb53cb3[_0x45eee3(0x2a6)][_0x45eee3(0x227)]),_0x5c44d3[_0x45eee3(0x20f)]=qs[_0x45eee3(0x1e8)](_[_0x45eee3(0x2a3)](_0xb53cb3['query'],_0x299e97[_0x45eee3(0x1e8)])),_0x5c44d3[_0x45eee3(0x20f)][_0x45eee3(0x280)]=_0x2953e9['id'],_0x5c44d3=filterAttributes(_0x5c44d3,_0xb53cb3[_0x45eee3(0x2a6)][_0x45eee3(0x225)],_0x5c44d3[_0x45eee3(0x2a4)],_0xb53cb3['options'],![]),db[_0x45eee3(0x2fb)][_0x45eee3(0x273)]({'where':_0x5c44d3[_0x45eee3(0x20f)]})[_0x45eee3(0x2dc)](function(_0x4da567){const _0x2613e9=_0x45eee3;return _0x7267ef['count']=_0x4da567,_0xb53cb3[_0x2613e9(0x2a6)]['includeAll']&&(_0x5c44d3[_0x2613e9(0x221)]=[{'all':!![]}]),db['Disposition']['findAll'](_0x5c44d3);})[_0x45eee3(0x2dc)](function(_0x336c11){const _0x4bf910=_0x45eee3;return _0x7267ef[_0x4bf910(0x2e3)]=_0x336c11,_0x7267ef;});})['then'](respondWithFilteredResult(_0x2903ef,_0x5c44d3))[_0x1768fa(0x22e)](handleError(_0x2903ef,null));},exports[a133_0x5904da(0x1ef)]=function(_0x5dda27,_0x1a2d3c){const _0x36e47c=a133_0x5904da;return db[_0x36e47c(0x25c)][_0x36e47c(0x268)]({'where':{'id':_0x5dda27[_0x36e47c(0x2e6)]['id']}})['then'](handleEntityNotFound(_0x1a2d3c,null))[_0x36e47c(0x2dc)](function(_0x10ad9e){const _0x281045=_0x36e47c;if(_0x10ad9e)return _0x10ad9e[_0x281045(0x1ef)](_0x5dda27[_0x281045(0x2a6)][_0x281045(0x1f5)]);})[_0x36e47c(0x2dc)](respondWithStatusCode(_0x1a2d3c,null))[_0x36e47c(0x22e)](handleError(_0x1a2d3c,null));},exports['addAnswer']=function(_0x2b959a,_0x2e1d9b){const _0x4ab15b=a133_0x5904da;return _0x2b959a[_0x4ab15b(0x242)]['id']&&delete _0x2b959a[_0x4ab15b(0x242)]['id'],db[_0x4ab15b(0x25c)][_0x4ab15b(0x268)]({'where':{'id':_0x2b959a[_0x4ab15b(0x2e6)]['id']}})['then'](handleEntityNotFound(_0x2e1d9b,null))['then'](function(_0x5abb87){const _0x51422e=_0x4ab15b;if(_0x5abb87)return _0x2b959a['body'][_0x51422e(0x280)]=_0x5abb87['id'],db[_0x51422e(0x254)][_0x51422e(0x30e)](_0x2b959a[_0x51422e(0x242)]);})[_0x4ab15b(0x2dc)](respondWithResult(_0x2e1d9b,null))['catch'](handleError(_0x2e1d9b,null));},exports[a133_0x5904da(0x23d)]=function(_0x590dd9,_0x21e8f8){const _0x2d2e5c=a133_0x5904da;let _0x20bdb2={'raw':![],'where':{}};const _0xbdeeed={},_0x575a3f={'count':0x0,'rows':[]};return db[_0x2d2e5c(0x25c)][_0x2d2e5c(0x268)]({'where':{'id':_0x590dd9['params']['id']}})[_0x2d2e5c(0x2dc)](handleEntityNotFound(_0x21e8f8,null))[_0x2d2e5c(0x2dc)](function(_0x31e12f){const _0x4e36d6=_0x2d2e5c;if(_0x31e12f)return _0xbdeeed[_0x4e36d6(0x20c)]=_[_0x4e36d6(0x278)](db['CannedAnswer']['rawAttributes']),_0xbdeeed['query']=_['keys'](_0x590dd9[_0x4e36d6(0x2a6)]),_0xbdeeed[_0x4e36d6(0x1e8)]=_[_0x4e36d6(0x2cf)](_0xbdeeed['model'],_0xbdeeed[_0x4e36d6(0x2a6)]),_0x20bdb2[_0x4e36d6(0x2a4)]=_[_0x4e36d6(0x2cf)](_0xbdeeed[_0x4e36d6(0x20c)],qs[_0x4e36d6(0x24d)](_0x590dd9['query'][_0x4e36d6(0x24d)])),_0x20bdb2[_0x4e36d6(0x2a4)]=_0x20bdb2[_0x4e36d6(0x2a4)][_0x4e36d6(0x27e)]?_0x20bdb2[_0x4e36d6(0x2a4)]:_0xbdeeed[_0x4e36d6(0x20c)],typeof _0x590dd9[_0x4e36d6(0x2a6)][_0x4e36d6(0x2c8)]===_0x4e36d6(0x2ab)&&(_0x20bdb2[_0x4e36d6(0x23f)]=qs[_0x4e36d6(0x23f)](_0x590dd9[_0x4e36d6(0x2a6)][_0x4e36d6(0x23f)]),_0x20bdb2[_0x4e36d6(0x2f1)]=qs[_0x4e36d6(0x2f1)](_0x590dd9[_0x4e36d6(0x2a6)][_0x4e36d6(0x2f1)])),_0x20bdb2[_0x4e36d6(0x22f)]=qs['sort'](_0x590dd9['query'][_0x4e36d6(0x227)]),_0x20bdb2[_0x4e36d6(0x20f)]=qs[_0x4e36d6(0x1e8)](_['pick'](_0x590dd9[_0x4e36d6(0x2a6)],_0xbdeeed[_0x4e36d6(0x1e8)])),_0x20bdb2['where'][_0x4e36d6(0x280)]=_0x31e12f['id'],_0x20bdb2=filterAttributes(_0x20bdb2,_0x590dd9[_0x4e36d6(0x2a6)][_0x4e36d6(0x225)],_0x20bdb2['attributes'],_0x590dd9[_0x4e36d6(0x29e)],![]),db[_0x4e36d6(0x254)][_0x4e36d6(0x273)]({'where':_0x20bdb2[_0x4e36d6(0x20f)]})[_0x4e36d6(0x2dc)](function(_0x2c5ef0){const _0x73100e=_0x4e36d6;return _0x575a3f[_0x73100e(0x273)]=_0x2c5ef0,_0x590dd9[_0x73100e(0x2a6)][_0x73100e(0x2f8)]&&(_0x20bdb2['include']=[{'all':!![]}]),db['CannedAnswer'][_0x73100e(0x2c4)](_0x20bdb2);})[_0x4e36d6(0x2dc)](function(_0x2edb9f){const _0x278a21=_0x4e36d6;return _0x575a3f[_0x278a21(0x2e3)]=_0x2edb9f,_0x575a3f;});})[_0x2d2e5c(0x2dc)](respondWithFilteredResult(_0x21e8f8,_0x20bdb2))['catch'](handleError(_0x21e8f8,null));},exports['removeAnswers']=function(_0x1df565,_0x5954e6){const _0x537a8a=a133_0x5904da;return db[_0x537a8a(0x25c)][_0x537a8a(0x268)]({'where':{'id':_0x1df565[_0x537a8a(0x2e6)]['id']}})[_0x537a8a(0x2dc)](handleEntityNotFound(_0x5954e6,null))['then'](function(_0x50c7b7){const _0x29dc30=_0x537a8a;if(_0x50c7b7)return _0x50c7b7[_0x29dc30(0x205)](_0x1df565['query'][_0x29dc30(0x1f5)]);})[_0x537a8a(0x2dc)](respondWithStatusCode(_0x5954e6,null))['catch'](handleError(_0x5954e6,null));},exports[a133_0x5904da(0x275)]=function(_0x39560f,_0xa2aa57){const _0x37d21d=a133_0x5904da;return _0x39560f[_0x37d21d(0x242)]['sitepic']=_0x39560f['file'][_0x37d21d(0x30d)],db['ChatWebsite'][_0x37d21d(0x268)]({'where':{'id':_0x39560f[_0x37d21d(0x2e6)]['id']}})['then'](handleEntityNotFound(_0xa2aa57,null))[_0x37d21d(0x2dc)](saveUpdates(_0x39560f[_0x37d21d(0x242)],null))[_0x37d21d(0x2dc)](respondWithResult(_0xa2aa57,null))[_0x37d21d(0x22e)](handleError(_0xa2aa57,null));},exports[a133_0x5904da(0x29d)]=function(_0x125181,_0x11ae76){const _0x1ef534=a133_0x5904da;return _0x125181[_0x1ef534(0x242)][_0x1ef534(0x287)]=_0x125181[_0x1ef534(0x299)][_0x1ef534(0x30d)],db[_0x1ef534(0x25c)]['findOne']({'where':{'id':_0x125181['params']['id']}})[_0x1ef534(0x2dc)](handleEntityNotFound(_0x11ae76,null))[_0x1ef534(0x2dc)](saveUpdates(_0x125181['body'],null))[_0x1ef534(0x2dc)](respondWithResult(_0x11ae76,null))['catch'](handleError(_0x11ae76,null));},exports[a133_0x5904da(0x2ca)]=function(_0x684f75,_0x4338ff){const _0x34e4fe=a133_0x5904da;return _0x684f75['body'][_0x34e4fe(0x290)]=_0x684f75[_0x34e4fe(0x299)][_0x34e4fe(0x30d)],db[_0x34e4fe(0x25c)][_0x34e4fe(0x268)]({'where':{'id':_0x684f75[_0x34e4fe(0x2e6)]['id']}})[_0x34e4fe(0x2dc)](handleEntityNotFound(_0x4338ff,null))[_0x34e4fe(0x2dc)](saveUpdates(_0x684f75[_0x34e4fe(0x242)],null))[_0x34e4fe(0x2dc)](respondWithResult(_0x4338ff,null))['catch'](handleError(_0x4338ff,null));},exports[a133_0x5904da(0x20b)]=function(_0x10855b,_0x5f37cf){const _0x5ab8ac=a133_0x5904da;return _0x10855b[_0x5ab8ac(0x242)]['systemAvatar']=_0x10855b[_0x5ab8ac(0x299)][_0x5ab8ac(0x30d)],db[_0x5ab8ac(0x25c)][_0x5ab8ac(0x268)]({'where':{'id':_0x10855b[_0x5ab8ac(0x2e6)]['id']}})['then'](handleEntityNotFound(_0x5f37cf,null))[_0x5ab8ac(0x2dc)](saveUpdates(_0x10855b[_0x5ab8ac(0x242)],null))[_0x5ab8ac(0x2dc)](respondWithResult(_0x5f37cf,null))['catch'](handleError(_0x5f37cf,null));},exports[a133_0x5904da(0x2a1)]=function(_0x2fa858,_0x46e5dc){const _0x54bfbb=a133_0x5904da;let _0x33e0fb=path[_0x54bfbb(0x224)](config[_0x54bfbb(0x2b6)],_0x54bfbb(0x1f9));const _0x2d1b87={'where':{'id':_0x2fa858[_0x54bfbb(0x2e6)]['id']},'attributes':['id',_0x54bfbb(0x2e7)],'raw':!![]};let _0x2bc03a=![];return require(_0x54bfbb(0x313))[_0x54bfbb(0x253)]()[_0x54bfbb(0x2dc)](function(_0x3f087d){const _0x327f0b=_0x54bfbb;_0x3f087d&&(_0x2bc03a=_0x3f087d[_0x327f0b(0x2ac)]);})[_0x54bfbb(0x2dc)](function(){const _0x5188c2=_0x54bfbb;return db[_0x5188c2(0x25c)]['findOne'](_0x2d1b87);})[_0x54bfbb(0x2dc)](handleEntityNotFound(_0x46e5dc,null))[_0x54bfbb(0x2dc)](function(_0x107210){const _0x20c6c7=_0x54bfbb;if(_0x107210)return!_[_0x20c6c7(0x2da)](_0x107210['sitepic'])&&(fs[_0x20c6c7(0x1fe)](path[_0x20c6c7(0x224)](config[_0x20c6c7(0x2b6)],_0x20c6c7(0x207),_0x107210[_0x20c6c7(0x2e7)]))&&_0x2bc03a&&(_0x33e0fb=path[_0x20c6c7(0x224)](config[_0x20c6c7(0x2b6)],_0x20c6c7(0x207),_0x107210[_0x20c6c7(0x2e7)]))),_0x46e5dc[_0x20c6c7(0x223)](_0x33e0fb);})['catch'](handleError(_0x46e5dc,null));},exports[a133_0x5904da(0x219)]=function(_0x4af6cb,_0x38ecd7){const _0x462215=a133_0x5904da;let _0x42205f=path[_0x462215(0x224)](config['root'],'files/images/avatars/default_avatar.png');const _0x2c4033={'where':{'id':_0x4af6cb[_0x462215(0x2e6)]['id']},'attributes':['id','agentAvatar'],'raw':!![]};return db[_0x462215(0x25c)][_0x462215(0x268)](_0x2c4033)['then'](handleEntityNotFound(_0x38ecd7,null))['then'](function(_0x575cdf){const _0x191888=_0x462215;if(_0x575cdf)return!_[_0x191888(0x2da)](_0x575cdf['agentAvatar'])&&(fs[_0x191888(0x1fe)](path[_0x191888(0x224)](config[_0x191888(0x2b6)],_0x191888(0x282),_0x575cdf['agentAvatar']))&&(_0x42205f=path[_0x191888(0x224)](config[_0x191888(0x2b6)],'files/images/avatars/',_0x575cdf[_0x191888(0x287)]))),_0x38ecd7[_0x191888(0x223)](_0x42205f);})['catch'](handleError(_0x38ecd7,null));},exports[a133_0x5904da(0x2a5)]=function(_0x389ad6,_0x538462){const _0x84c0e8=a133_0x5904da;let _0x344986=path[_0x84c0e8(0x224)](config[_0x84c0e8(0x2b6)],'files/images/avatars/customer_avatar.png');const _0x20434c={'where':{'id':_0x389ad6[_0x84c0e8(0x2e6)]['id']},'attributes':['id',_0x84c0e8(0x290),_0x84c0e8(0x295)],'raw':!![]};return db[_0x84c0e8(0x25c)][_0x84c0e8(0x268)](_0x20434c)[_0x84c0e8(0x2dc)](handleEntityNotFound(_0x538462,null))['then'](function(_0x53099c){const _0x230eff=_0x84c0e8;if(_0x53099c)return!_[_0x230eff(0x2da)](_0x53099c[_0x230eff(0x290)])&&(fs['existsSync'](path[_0x230eff(0x224)](config[_0x230eff(0x2b6)],_0x230eff(0x282),_0x53099c[_0x230eff(0x290)]))&&_0x53099c[_0x230eff(0x295)]&&(_0x344986=path[_0x230eff(0x224)](config[_0x230eff(0x2b6)],_0x230eff(0x282),_0x53099c[_0x230eff(0x290)]))),_0x538462[_0x230eff(0x223)](_0x344986);})['catch'](handleError(_0x538462,null));},exports[a133_0x5904da(0x218)]=function(_0x2ab23,_0x1fcbc3){const _0x1ce08f=a133_0x5904da;let _0x4aeb0d=path[_0x1ce08f(0x224)](config[_0x1ce08f(0x2b6)],_0x1ce08f(0x217));const _0x314845={'where':{'id':_0x2ab23[_0x1ce08f(0x2e6)]['id']},'attributes':['id','systemAvatar'],'raw':!![]};return db[_0x1ce08f(0x25c)][_0x1ce08f(0x268)](_0x314845)[_0x1ce08f(0x2dc)](handleEntityNotFound(_0x1fcbc3,null))[_0x1ce08f(0x2dc)](function(_0x4304be){const _0x4fce5a=_0x1ce08f;if(_0x4304be)return!_[_0x4fce5a(0x2da)](_0x4304be[_0x4fce5a(0x2ed)])&&(fs['existsSync'](path[_0x4fce5a(0x224)](config[_0x4fce5a(0x2b6)],'files/images/avatars/',_0x4304be['systemAvatar']))&&(_0x4aeb0d=path[_0x4fce5a(0x224)](config[_0x4fce5a(0x2b6)],_0x4fce5a(0x282),_0x4304be[_0x4fce5a(0x2ed)]))),_0x1fcbc3[_0x4fce5a(0x223)](_0x4aeb0d);})[_0x1ce08f(0x22e)](handleError(_0x1fcbc3,null));},exports[a133_0x5904da(0x286)]=function(_0x4903e0,_0x2a932e){const _0x1e3dce=a133_0x5904da,_0x36f8ad=new UAParser(),_0x105f12=_0x36f8ad[_0x1e3dce(0x2f9)](_0x4903e0[_0x1e3dce(0x24e)][_0x1e3dce(0x30a)])[_0x1e3dce(0x245)](),_0x2bde10={'body':_0x4903e0[_0x1e3dce(0x242)],'channel':_0x1e3dce(0x1f3)};let _0x248181=[],_0x4e42e8=[];const _0x173335={};let _0x35ecb1=![];return db[_0x1e3dce(0x262)][_0x1e3dce(0x241)]()['then'](function(_0x134d4e){const _0x33fc1b=_0x1e3dce;if(!_0x134d4e)throw new ValidationError(_0x33fc1b(0x2f2));_0x248181=_[_0x33fc1b(0x2d5)](_[_0x33fc1b(0x278)](_0x134d4e),['createdAt','updatedAt']),_0x4e42e8=_['difference'](_[_0x33fc1b(0x278)](_0x134d4e),['createdAt',_0x33fc1b(0x26a),'CompanyId',_0x33fc1b(0x277)]);_0x4903e0['body']['id']&&delete _0x4903e0['body']['id'];if(_[_0x33fc1b(0x2da)](_0x4903e0[_0x33fc1b(0x242)][_0x33fc1b(0x2c1)]))throw new ValidationError(_0x33fc1b(0x309));if(_['isNil'](_0x4903e0['body'][_0x33fc1b(0x242)])||_0x4903e0['body']['body']==='')throw new ValidationError(_0x33fc1b(0x28c));if(_[_0x33fc1b(0x2da)](_0x4903e0[_0x33fc1b(0x242)]['mapKey']))throw new ValidationError('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4e42e8);if(!_[_0x33fc1b(0x215)](_0x4e42e8,_0x4903e0['body'][_0x33fc1b(0x20a)]))throw new ValidationError('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4e42e8);_0x173335[_0x4903e0[_0x33fc1b(0x242)]['mapKey']]=_0x4903e0['body'][_0x33fc1b(0x2c1)];})[_0x1e3dce(0x2dc)](function(){const _0x8efec0=_0x1e3dce;return db[_0x8efec0(0x25c)][_0x8efec0(0x268)]({'where':{'id':_0x4903e0['params']['id']},'include':[{'model':db[_0x8efec0(0x251)],'as':_0x8efec0(0x28a),'include':[{'model':db[_0x8efec0(0x262)],'as':_0x8efec0(0x2df),'where':_0x173335,'limit':0x1,'order':[[_0x8efec0(0x26a),'DESC']]}]},{'model':db[_0x8efec0(0x291)],'as':'Applications'}]});})['then'](handleEntityNotFound(_0x2a932e,null))[_0x1e3dce(0x2dc)](function(_0x4b4fca){const _0x2a3d0b=_0x1e3dce;if(_0x4b4fca&&_0x4b4fca['List']){_0x2bde10['account']=_0x4b4fca,_0x2bde10['applications']=_0x4b4fca[_0x2a3d0b(0x23a)],_0x2bde10['list']=_0x4b4fca[_0x2a3d0b(0x28a)],_0x2bde10[_0x2a3d0b(0x230)]=_[_0x2a3d0b(0x252)](_0x2bde10[_0x2a3d0b(0x230)],[_0x2a3d0b(0x239)],['asc']);_0x2bde10[_0x2a3d0b(0x2b0)][_0x2a3d0b(0x23a)]&&delete _0x2bde10[_0x2a3d0b(0x2b0)][_0x2a3d0b(0x23a)];if(_0x2bde10['account'][_0x2a3d0b(0x28a)]&&_0x2bde10['account']['List']['Contacts'][_0x2a3d0b(0x27e)])return _0x2bde10[_0x2a3d0b(0x2b0)][_0x2a3d0b(0x28a)][_0x2a3d0b(0x2df)][0x0];const _0x3268dd=_[_0x2a3d0b(0x228)](_0x4903e0['body'],{'firstName':_0x4903e0[_0x2a3d0b(0x242)]['from'],'ListId':_0x4b4fca[_0x2a3d0b(0x277)]});return _0x3268dd[_0x4903e0[_0x2a3d0b(0x242)][_0x2a3d0b(0x20a)]]=_0x4903e0[_0x2a3d0b(0x242)][_0x2a3d0b(0x2c1)],db[_0x2a3d0b(0x262)][_0x2a3d0b(0x30e)](_0x3268dd,{'fields':_0x248181,'raw':!![]});}})['then'](handleEntityNotFound(_0x2a932e,null))['then'](function(_0x2a89a4){const _0x2e3e50=_0x1e3dce;_0x2bde10['contact']=_0x2a89a4;let _0xc9539e=_0x4903e0[_0x2e3e50(0x242)][_0x2e3e50(0x2e1)];if(_0x4903e0[_0x2e3e50(0x24e)][_0x2e3e50(0x1fd)])_0xc9539e=_0x4903e0[_0x2e3e50(0x24e)][_0x2e3e50(0x1fd)];else _0x4903e0[_0x2e3e50(0x24e)][_0x2e3e50(0x2d7)]&&(_0xc9539e=_['first'](_0x4903e0[_0x2e3e50(0x24e)]['x-forwarded-for'][_0x2e3e50(0x1fc)](',')));if(_0x2a89a4){const _0x4eab43={'ContactId':_0x2a89a4['id'],'ChatWebsiteId':_0x4903e0[_0x2e3e50(0x2e6)]['id'],'from':(_0x2a89a4[_0x2e3e50(0x24b)]||'')+'\x20'+(_0x2a89a4[_0x2e3e50(0x24a)]||''),'customerIp':_0xc9539e,'customerPort':_0x4903e0['headers'][_0x2e3e50(0x2d2)]?_0x4903e0[_0x2e3e50(0x24e)]['x-real-port']:null,'referer':_0x4903e0['body'][_0x2e3e50(0x257)],'browserName':_0x105f12['browser'][_0x2e3e50(0x293)]&&_0x105f12[_0x2e3e50(0x2be)][_0x2e3e50(0x2e4)]?util[_0x2e3e50(0x2c2)]('%s\x20%s',_0x105f12[_0x2e3e50(0x2be)][_0x2e3e50(0x293)],_0x105f12[_0x2e3e50(0x2be)]['version']):'unknown','browserVersion':_0x105f12[_0x2e3e50(0x2be)][_0x2e3e50(0x2e4)]||_0x2e3e50(0x23b),'osName':util['format'](_0x2e3e50(0x303),_0x105f12['os'][_0x2e3e50(0x293)],_0x105f12['os'][_0x2e3e50(0x2e4)]),'osVersion':_0x105f12['os'][_0x2e3e50(0x2e4)],'deviceModel':_0x105f12[_0x2e3e50(0x2b9)][_0x2e3e50(0x20c)]&&_0x105f12[_0x2e3e50(0x2b9)][_0x2e3e50(0x2cd)]?util[_0x2e3e50(0x2c2)](_0x2e3e50(0x206),_0x105f12[_0x2e3e50(0x2b9)]['model'],_0x105f12[_0x2e3e50(0x2b9)]['vendor'],_0x105f12['device'][_0x2e3e50(0x255)]):null,'deviceVendor':_0x105f12[_0x2e3e50(0x2b9)]['vendor'],'deviceType':_0x105f12[_0x2e3e50(0x2b9)][_0x2e3e50(0x255)],'formData':JSON[_0x2e3e50(0x289)](_0x4903e0[_0x2e3e50(0x242)])},_0x29d99c={'ChatWebsiteId':_0x4903e0[_0x2e3e50(0x2e6)]['id'],'closed':![]};if(_0x4903e0[_0x2e3e50(0x242)][_0x2e3e50(0x301)])return _0x29d99c[_0x2e3e50(0x301)]=_0x4903e0[_0x2e3e50(0x242)][_0x2e3e50(0x301)],db[_0x2e3e50(0x1f7)]['findOne']({'where':_0x29d99c})[_0x2e3e50(0x2dc)](function(_0x29b080){const _0x48a781=_0x2e3e50;if(_0x29b080)return[_0x29b080,![]];return _0x4eab43[_0x48a781(0x301)]=_0x4903e0[_0x48a781(0x242)][_0x48a781(0x301)],_0x4eab43['externalUrl']=_0x4903e0[_0x48a781(0x242)]['externalUrl'],db[_0x48a781(0x1f7)][_0x48a781(0x30e)](_0x4eab43)[_0x48a781(0x2dc)](function(_0x5a14ea){return[_0x5a14ea,!![]];});});_0x29d99c[_0x2e3e50(0x204)]=_0x2a89a4['id'];if(_0x4903e0['body'][_0x2e3e50(0x2db)]&&_0x4903e0[_0x2e3e50(0x242)][_0x2e3e50(0x2db)]['id'])return _0x29d99c['id']=_0x4903e0['body'][_0x2e3e50(0x2db)]['id'],db['ChatInteraction'][_0x2e3e50(0x268)]({'where':_0x29d99c})['then'](function(_0x383644){const _0x57eb01=_0x2e3e50;if(_0x383644)return[_0x383644,![]];return db[_0x57eb01(0x1f7)]['create'](_0x4eab43)[_0x57eb01(0x2dc)](function(_0x4fc137){return[_0x4fc137,!![]];});});return db['ChatInteraction']['create'](_0x4eab43)[_0x2e3e50(0x2dc)](function(_0x21d199){return[_0x21d199,!![]];});}})[_0x1e3dce(0x2dc)](function([_0x288064,_0x33d218]){const _0x4c4852=_0x1e3dce;if(_0x288064){_0x35ecb1=_0x33d218;if(!_0x33d218){const _0x20a184={'from':(_0x2bde10[_0x4c4852(0x237)][_0x4c4852(0x24b)]||'')+'\x20'+(_0x2bde10[_0x4c4852(0x237)][_0x4c4852(0x24a)]||'')};return _0x4903e0[_0x4c4852(0x242)][_0x4c4852(0x301)]&&_0x4903e0[_0x4c4852(0x242)][_0x4c4852(0x27a)]&&_0x4903e0[_0x4c4852(0x242)][_0x4c4852(0x301)]!==_0x4903e0[_0x4c4852(0x242)][_0x4c4852(0x27a)]&&(_0x20a184[_0x4c4852(0x301)]=_0x4903e0[_0x4c4852(0x242)][_0x4c4852(0x27a)]),_0x288064[_0x4c4852(0x2d3)](_0x20a184);}else return _0x288064;}})[_0x1e3dce(0x2dc)](function(_0x573753){const _0x374ec2=_0x1e3dce;return _0x2bde10[_0x374ec2(0x2db)]=_0x573753[_0x374ec2(0x25a)]({'plain':!![]}),_0x2bde10[_0x374ec2(0x2db)][_0x374ec2(0x2fd)]=_0x35ecb1,_0x2bde10[_0x374ec2(0x2db)][_0x374ec2(0x2fd)]&&(_0x2bde10['account'][_0x374ec2(0x258)]&&_0x2bde10[_0x374ec2(0x230)][_0x374ec2(0x2ce)]({'id':0x0,'priority':_0x2bde10[_0x374ec2(0x230)][_0x374ec2(0x27e)]+0x1,'app':_0x374ec2(0x285),'appdata':_0x374ec2(0x21c),'interval':_0x374ec2(0x209)})),db[_0x374ec2(0x305)][_0x374ec2(0x30e)]({'body':_0x4903e0[_0x374ec2(0x242)][_0x374ec2(0x242)],'ChatWebsiteId':_0x4903e0['params']['id'],'ChatInteractionId':_0x573753['id'],'direction':'in','ContactId':_0x2bde10[_0x374ec2(0x237)]['id'],'AttachmentId':_0x4903e0[_0x374ec2(0x242)][_0x374ec2(0x1fb)]});})[_0x1e3dce(0x2dc)](function(_0x567829){const _0x3a718d=_0x1e3dce;_0x2bde10[_0x3a718d(0x1fa)]=_0x567829;if(_0x2bde10[_0x3a718d(0x2db)][_0x3a718d(0x2f3)])return db[_0x3a718d(0x269)][_0x3a718d(0x268)]({'attributes':['id',_0x3a718d(0x293)],'where':{'id':_0x2bde10['interaction'][_0x3a718d(0x2f3)]}})[_0x3a718d(0x2dc)](function(_0x34c73f){const _0x5ce103=_0x3a718d;return _0x34c73f&&(_0x2bde10[_0x5ce103(0x230)][_0x5ce103(0x28f)]({'id':0x0,'priority':0x0,'app':_0x5ce103(0x22b),'appdata':_0x34c73f[_0x5ce103(0x293)]+','+(_0x2bde10[_0x5ce103(0x2b0)][_0x5ce103(0x1f1)]||0xa),'interval':_0x5ce103(0x209)}),_0x2bde10[_0x5ce103(0x2f4)]=!![]),respondWithRpcPromise('Start',_0x5ce103(0x271),_0x2bde10);});return respondWithRpcPromise(_0x3a718d(0x30c),'startRouting',_0x2bde10);})[_0x1e3dce(0x2dc)](function(_0x3d09d4){const _0x3b3325=_0x1e3dce;return respondWithRpcPromise(_0x3b3325(0x2e5),'EventManager',{'event':_0x3b3325(0x286),'message':_0x3d09d4},rpcAmiClient),_0x3d09d4;})[_0x1e3dce(0x2dc)](respondWithResult(_0x2a932e,null))[_0x1e3dce(0x22e)](handleError(_0x2a932e,null));};async function clearFiles(_0x1f99dc){const _0x4c1911=a133_0x5904da;for(const _0x5f4d53 of _0x1f99dc){const _0x5d1200=path['join'](config['root'],_0x4c1911(0x272),_0x4c1911(0x1ed),_0x4c1911(0x2cc),_0x5f4d53[_0x4c1911(0x30d)]);try{await fs[_0x4c1911(0x21f)](_0x5d1200);}catch(_0x1c6b3e){consoleLogger(_0x4c1911(0x240),_0x5d1200,_0x1c6b3e);}}}async function offline(_0x5b849e,_0x34f880){const _0x20bed7=a133_0x5904da;let _0x25887c=0xc8,_0x552387=undefined,_0x317948=null,_0x5070ec=null,_0x3eae0d=null,_0x3e8bec=null,_0x6929cf=[];const _0x2d130c={},_0x34f340=_0x5b849e[_0x20bed7(0x272)]||[];try{const _0x30941a=await db[_0x20bed7(0x262)][_0x20bed7(0x241)]();if(!_0x30941a)throw new ValidationError(_0x20bed7(0x2f2));_0x6929cf=_[_0x20bed7(0x2d5)](_['keys'](_0x30941a),['createdAt',_0x20bed7(0x26a),_0x20bed7(0x2c0),_0x20bed7(0x277)]);const {id:_0x145f22,..._0x59214a}=_0x5b849e[_0x20bed7(0x242)];if(_[_0x20bed7(0x2da)](_0x59214a['from']))throw new ValidationError(_0x20bed7(0x309));if(_['isNil'](_0x59214a[_0x20bed7(0x242)])||_0x59214a['body']==='')throw new ValidationError(_0x20bed7(0x28c));if(_['isNil'](_0x59214a[_0x20bed7(0x232)]))throw new ValidationError('mapKeyOffline\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x6929cf);if(!_[_0x20bed7(0x215)](_0x6929cf,_0x59214a['mapKeyOffline']))throw new ValidationError(_0x20bed7(0x2d0)+_0x6929cf);_0x2d130c[_0x59214a['mapKeyOffline']]=_0x59214a[_0x20bed7(0x2c1)],_0x5070ec=await db[_0x20bed7(0x25c)][_0x20bed7(0x268)]({'where':{'id':_0x5b849e[_0x20bed7(0x2e6)]['id']},'include':[{'model':db['CmList'],'as':_0x20bed7(0x28a)},{'model':db[_0x20bed7(0x1ff)],'as':_0x20bed7(0x1ff)}]});if(!_0x5070ec)throw new Error(_0x20bed7(0x2c9));let _0x9ff088=[];const _0x56e110=await db[_0x20bed7(0x2b7)][_0x20bed7(0x267)]();if(_0x5070ec&&_0x5070ec[_0x20bed7(0x28a)]){const _0x69af2d=_[_0x20bed7(0x228)](_0x59214a,{'firstName':_0x59214a[_0x20bed7(0x2c1)],'phone':_0x59214a[_0x20bed7(0x2c1)],'ListId':_0x5070ec[_0x20bed7(0x277)]});_0x69af2d[_0x59214a[_0x20bed7(0x232)]]=_0x59214a['from'];const {body:_0x3da3ed,mapKeyOffline:_0x4deed0,from:_0x59baa3,..._0x372b2e}=_0x69af2d,[_0x3ca023]=await db['CmContact'][_0x20bed7(0x2fa)]({'where':_0x2d130c,'defaults':_0x372b2e,'transaction':_0x56e110});_0x3eae0d=_0x3ca023;}if(_0x3eae0d){const _0x1aa5e3=await fs[_0x20bed7(0x27c)](path[_0x20bed7(0x224)](config['root'],'files/templates/chatOfflineMessage.ejs'),'utf8'),_0x19eda3=ejs[_0x20bed7(0x1eb)](_0x1aa5e3,{'body':_[_0x20bed7(0x2bb)](_0x59214a[_0x20bed7(0x242)]),'bodyTitle':_0x5070ec['offlineMessageBody']});_0x317948=await db[_0x20bed7(0x2d4)]['create']({'body':_0x19eda3,'ContactId':_0x3eae0d['id'],'ChatWebsiteId':_0x5070ec['id']},{'transaction':_0x56e110});const _0x69b3ca=_0x34f340[_0x20bed7(0x25b)](_0x69dbed=>({'name':_0x69dbed[_0x20bed7(0x306)],'basename':_0x69dbed[_0x20bed7(0x30d)],'type':_0x69dbed[_0x20bed7(0x263)],'ChatOfflineMessageId':_0x317948['id']}));_0x9ff088=await db[_0x20bed7(0x283)]['bulkCreate'](_0x69b3ca,{'transaction':_0x56e110});}await _0x56e110[_0x20bed7(0x231)]();_0x317948&&(_0x3e8bec=await db[_0x20bed7(0x1ff)][_0x20bed7(0x268)]({'where':{'service':!![]},'include':[{'model':db['MailServerOut'],'as':_0x20bed7(0x2e2),'raw':!![]}]}));if(_0x3e8bec&&_0x3e8bec['Smtp']&&_0x5070ec[_0x20bed7(0x2d9)]&&_0x5070ec['forwardOfflineAddress']){const _0x52ae2b={'tls':{'rejectUnauthorized':![]}};_0x3e8bec[_0x20bed7(0x2e2)][_0x20bed7(0x249)]?_0x52ae2b[_0x20bed7(0x249)]=_0x3e8bec[_0x20bed7(0x2e2)][_0x20bed7(0x249)]:(_0x52ae2b[_0x20bed7(0x27d)]=_0x3e8bec[_0x20bed7(0x2e2)][_0x20bed7(0x27d)],_0x52ae2b[_0x20bed7(0x233)]=_0x3e8bec[_0x20bed7(0x2e2)][_0x20bed7(0x233)],_0x52ae2b[_0x20bed7(0x2a8)]=_0x3e8bec[_0x20bed7(0x2e2)][_0x20bed7(0x2a8)]);_0x3e8bec['Smtp'][_0x20bed7(0x201)]&&(_0x52ae2b['auth']={'user':_0x3e8bec[_0x20bed7(0x2e2)]['user'],'pass':_0x3e8bec[_0x20bed7(0x2e2)][_0x20bed7(0x2cb)]});try{const _0x513c8e=_0x9ff088[_0x20bed7(0x25b)](_0x1d4f4b=>{const _0x4ad39d=_0x20bed7,_0x174c3c={'filename':_0x1d4f4b['name'],'path':path['join'](config[_0x4ad39d(0x2b6)],_0x4ad39d(0x272),_0x4ad39d(0x1ed),_0x4ad39d(0x2cc),_0x1d4f4b[_0x4ad39d(0x26d)])};return _0x174c3c;});await respondWithRpcPromise(_0x20bed7(0x2c6),'sendMail',{'account':_0x52ae2b,'message':{'from':'\x22'+_0x3e8bec[_0x20bed7(0x293)]+'\x22\x20<'+(_0x3e8bec[_0x20bed7(0x2ee)]||_0x3e8bec[_0x20bed7(0x2e2)]['user'])+'>','to':_0x5070ec['forwardOfflineAddress'],'subject':_0x5070ec[_0x20bed7(0x25f)],'text':_0x317948[_0x20bed7(0x242)],'attachments':_0x513c8e}},rpcEmailClient);}catch(_0x560eb4){consoleLogger[_0x20bed7(0x266)](_0x560eb4);}if(_0x5070ec&&_0x5070ec[_0x20bed7(0x288)]&&_0x5070ec['MailAccountId']){const _0x56a9bb={'from':_0x3eae0d[_0x20bed7(0x2ee)],'firstName':_0x3eae0d['firstName'],'lastName':_0x3eae0d['lastName'],'mapKey':'email','message':{'from':_0x3eae0d[_0x20bed7(0x2ee)],'to':_0x5070ec[_0x20bed7(0x1ff)][_0x20bed7(0x2ee)],'cc':'','subject':_0x5070ec['offlineMessageSubject'],'messageId':'','sentAt':new Date(),'attach':![],'attachments':[],'originChannel':'Chat','ChatWebsiteId':_0x5070ec['id'],'ChatOfflineMessageId':_0x317948['id'],'originTo':_0x5070ec[_0x20bed7(0x1ff)]['email']},'body':_0x317948[_0x20bed7(0x242)]},_0xf5645b={'account':{'id':_0x5070ec[_0x20bed7(0x2a0)]},'body':_0x56a9bb,'log':_0x20bed7(0x260)};try{await respondWithRpcPromise(_0x20bed7(0x260),_0x20bed7(0x20d),_0xf5645b,client);}catch(_0x396831){consoleLogger['error'](_0x396831);}}}}catch(_0x5a5e84){await clearFiles(_0x34f340),_0x25887c=0x1f4;if(_0x5a5e84 instanceof ValidationError)_0x25887c=0x190;else _0x5a5e84?.[_0x20bed7(0x1fa)]===_0x20bed7(0x2c9)?_0x25887c=0x194:logger[_0x20bed7(0x266)](_0x5a5e84[_0x20bed7(0x23e)]);const {message:_0x2fefd1,stack:_0x22cf0e,name:_0x1858d8,errors:_0xf35a8e}=_0x5a5e84;_0x552387=_0x25887c===0x190?{'message':_0x2fefd1,'stack':_0x22cf0e,'name':_0x1858d8,'errors':_0xf35a8e}:undefined;}finally{_0x34f880[_0x20bed7(0x202)](_0x25887c)[_0x20bed7(0x21b)](_0x552387);}}exports[a133_0x5904da(0x210)]=offline,exports[a133_0x5904da(0x292)]=function(_0x50c738,_0x170f9b){const _0x35bd20=a133_0x5904da;return db[_0x35bd20(0x1f7)][_0x35bd20(0x268)]({'where':{'id':_0x50c738[_0x35bd20(0x2e6)]['id']}})[_0x35bd20(0x2dc)](function(_0x5bcfcc){const _0x143c2e=_0x35bd20;if(_0x5bcfcc)return _0x5bcfcc[_0x143c2e(0x292)](_0x50c738[_0x143c2e(0x242)]['ids'],{'through':_['omit'](_0x50c738[_0x143c2e(0x242)],['ids','id'])});})[_0x35bd20(0x2dc)](respondWithResult(_0x170f9b,null))['catch'](handleError(_0x170f9b,null));},exports[a133_0x5904da(0x26e)]=function(_0xa873e0,_0x2a0f8f){const _0x23cc20=a133_0x5904da;let _0x3b6b27={'raw':![],'where':{}};const _0x763da1={},_0x450214={'count':0x0,'rows':[]};return db[_0x23cc20(0x25c)][_0x23cc20(0x268)]({'where':{'id':_0xa873e0[_0x23cc20(0x2e6)]['id']}})[_0x23cc20(0x2dc)](handleEntityNotFound(_0x2a0f8f,null))[_0x23cc20(0x2dc)](function(_0x279d26){const _0x457096=_0x23cc20;if(_0x279d26)return _0x763da1[_0x457096(0x20c)]=_['keys'](db[_0x457096(0x1f7)][_0x457096(0x311)]),_0x763da1[_0x457096(0x2a6)]=_[_0x457096(0x278)](_0xa873e0[_0x457096(0x2a6)]),_0x763da1[_0x457096(0x1e8)]=_[_0x457096(0x2cf)](_0x763da1[_0x457096(0x20c)],_0x763da1[_0x457096(0x2a6)]),_0x3b6b27[_0x457096(0x2a4)]=_[_0x457096(0x2cf)](_0x763da1['model'],qs[_0x457096(0x24d)](_0xa873e0[_0x457096(0x2a6)]['fields'])),_0x3b6b27[_0x457096(0x2a4)]=_0x3b6b27[_0x457096(0x2a4)][_0x457096(0x27e)]?_0x3b6b27[_0x457096(0x2a4)]:_0x763da1[_0x457096(0x20c)],typeof _0xa873e0['query'][_0x457096(0x2c8)]===_0x457096(0x2ab)&&(_0x3b6b27[_0x457096(0x23f)]=qs[_0x457096(0x23f)](_0xa873e0[_0x457096(0x2a6)][_0x457096(0x23f)]),_0x3b6b27[_0x457096(0x2f1)]=qs[_0x457096(0x2f1)](_0xa873e0[_0x457096(0x2a6)]['offset'])),_0x3b6b27[_0x457096(0x22f)]=qs[_0x457096(0x227)](_0xa873e0[_0x457096(0x2a6)]['sort']),_0x3b6b27[_0x457096(0x20f)]=qs[_0x457096(0x1e8)](_[_0x457096(0x2a3)](_0xa873e0[_0x457096(0x2a6)],_0x763da1[_0x457096(0x1e8)])),_0x3b6b27[_0x457096(0x20f)]['ChatWebsiteId']=_0x279d26['id'],_0x3b6b27=filterAttributes(_0x3b6b27,_0xa873e0[_0x457096(0x2a6)][_0x457096(0x225)],_0x3b6b27[_0x457096(0x2a4)],_0xa873e0[_0x457096(0x29e)],![]),db[_0x457096(0x1f7)][_0x457096(0x273)]({'where':_0x3b6b27[_0x457096(0x20f)]})[_0x457096(0x2dc)](function(_0x137bab){const _0x16807a=_0x457096;return _0x450214[_0x16807a(0x273)]=_0x137bab,_0xa873e0[_0x16807a(0x2a6)]['includeAll']&&(_0x3b6b27[_0x16807a(0x221)]=[{'model':db['CmContact'],'as':_0x16807a(0x29a),'required':![]},{'model':db[_0x16807a(0x269)],'as':_0x16807a(0x21e),'attributes':[_0x16807a(0x293),'fullname','internal'],'required':![]},{'model':db['Tag'],'as':_0x16807a(0x2ad),'attributes':['id',_0x16807a(0x293),_0x16807a(0x2fe)],'where':_0xa873e0[_0x16807a(0x2a6)]['tag']?{'id':_0xa873e0[_0x16807a(0x2a6)]['tag']}:undefined,'required':_0xa873e0[_0x16807a(0x2a6)]['tag']?!![]:![]}]),db[_0x16807a(0x1f7)]['findAll'](_0x3b6b27);})[_0x457096(0x2dc)](function(_0x3b8d53){return _0x450214['rows']=_0x3b8d53,_0x450214;});})['then'](respondWithFilteredResult(_0x2a0f8f,_0x3b6b27))[_0x23cc20(0x22e)](handleError(_0x2a0f8f,null));};function iftimePromise(_0x379cd6,_0x1bfa3b){const _0x2b176d=a133_0x5904da;return respondWithRpcPromise(_0x2b176d(0x22d),_0x2b176d(0x2c3),{'command':_0x1bfa3b['timezone']?util[_0x2b176d(0x2c2)](_0x2b176d(0x2b3),_0x379cd6['interval'],_0x1bfa3b['timezone']):util['format'](_0x2b176d(0x2b2),_0x379cd6[_0x2b176d(0x2c5)])},rpcAmiClient)[_0x2b176d(0x2dc)](function(_0x46100c){const _0x252561=_0x2b176d,_0xf05eb2=_0x46100c&&_0x46100c[_0x252561(0x27f)]('true')>=0x0?!![]:![];return logger[_0x252561(0x226)](_0x252561(0x294),_0x1bfa3b['id'],_0x379cd6['id'],_0x379cd6[_0x252561(0x2c5)],_0xf05eb2?_0x252561(0x22c):_0x252561(0x28b),_0x1bfa3b[_0x252561(0x298)]?_0x1bfa3b[_0x252561(0x298)]:_0x252561(0x2ea)),_0xf05eb2;})[_0x2b176d(0x22e)](function(_0x134d0){const _0x44e925=_0x2b176d;return logger[_0x44e925(0x266)](_0x44e925(0x294),_0x1bfa3b['id'],_0x379cd6['id'],_0x379cd6[_0x44e925(0x2c5)],util[_0x44e925(0x2b8)](_0x134d0,{'showHidden':![],'depth':null}),_0x1bfa3b[_0x44e925(0x298)]?_0x1bfa3b['timezone']:_0x44e925(0x2ea)),![];});}exports[a133_0x5904da(0x2c3)]=function(_0x375f0c,_0x145d36){const _0x1bacae=a133_0x5904da;let _0x198332=0x0,_0x5f0c13=0x0,_0x6a8a09=![],_0x1d0fa4,_0x4def72;return db['ChatWebsite'][_0x1bacae(0x268)]({'where':{'id':_0x375f0c[_0x1bacae(0x2e6)]['id']},'include':[{'model':db['Interval'],'as':_0x1bacae(0x28e),'include':[{'model':db['Interval'],'as':_0x1bacae(0x2bf),'attributes':['id','interval'],'raw':!![]}]}]})['then'](handleEntityNotFound(_0x145d36,null))[_0x1bacae(0x2dc)](function(_0x216003){const _0x397d4e=_0x1bacae;if(_0x216003)return _0x1d0fa4=_0x216003,_0x216003[_0x397d4e(0x26b)]({'raw':!![]});})[_0x1bacae(0x2dc)](function(_0x39a5ff){const _0x21046e=_0x1bacae;return _0x1d0fa4&&(_0x39a5ff&&(_0x4def72=_0x39a5ff)),require(_0x21046e(0x313))[_0x21046e(0x253)]();})['then'](function(_0x13e5f7){const _0x39dd44=_0x1bacae;_0x13e5f7&&(_0x5f0c13=_0x13e5f7[_0x39dd44(0x308)],_0x6a8a09=_0x13e5f7[_0x39dd44(0x2ac)]);})[_0x1bacae(0x2dc)](function(){const _0x20a7d9=_0x1bacae;return db[_0x20a7d9(0x1f7)]['count']({'where':{'closed':![]}});})['then'](function(_0x4afb2e){const _0x41746a=_0x1bacae;_0x198332=_0x4afb2e;if(_0x5f0c13&&_0x4afb2e>_0x5f0c13)return db[_0x41746a(0x1f6)][_0x41746a(0x268)]({'where':{'id':0x1}})[_0x41746a(0x2dc)](function(_0x57a011){const _0x9fbb89=_0x41746a;_0x57a011&&_0x57a011[_0x9fbb89(0x307)]('chatLicenseExceeded');});})[_0x1bacae(0x2dc)](function(){const _0x14f9f0=_0x1bacae;if(_0x1d0fa4[_0x14f9f0(0x28e)]&&_0x1d0fa4['Interval'][_0x14f9f0(0x2bf)]){const _0xd2eef1=[];for(let _0x30a606=0x0;_0x30a606<_0x1d0fa4[_0x14f9f0(0x28e)][_0x14f9f0(0x2bf)][_0x14f9f0(0x27e)];_0x30a606++){const _0x495050=_0x1d0fa4[_0x14f9f0(0x28e)][_0x14f9f0(0x2bf)][_0x30a606][_0x14f9f0(0x25a)]({'plain':!![]});_0xd2eef1[_0x14f9f0(0x2ce)](iftimePromise(_0x495050,_0x1d0fa4));}return Promise[_0x14f9f0(0x21d)](_0xd2eef1)['then'](function(_0x236d46){const _0x5bd43a=_0x14f9f0;return _[_0x5bd43a(0x2ff)](_0x236d46);});}else return!![];})['then'](function(_0xc80d16){const _0x17b366=_0x1bacae,_0x21f791=_0x375f0c[_0x17b366(0x236)][_0x17b366(0x25a)](_0x17b366(0x212)),_0x283217=fs['readFileSync'](path[_0x17b366(0x224)](config[_0x17b366(0x2b6)],'files/chat/iframe.ejs'),'utf8'),_0xf818a8={'chatVersion':_0x21f791,'remote':_0x1d0fa4['remote'],'query':querystring['stringify'](_[_0x17b366(0x247)](_0x1d0fa4[_0x17b366(0x25a)]({'plain':!![]}),{'customerIp':_0x375f0c['headers'][_0x17b366(0x2d7)]||_0x375f0c['headers']['x-real-ip']||_0x375f0c['socket'][_0x17b366(0x250)]||_0x375f0c['ip'],'referer':_0x375f0c[_0x17b366(0x24e)][_0x17b366(0x257)],'openedInteractions':_0x198332,'maxInteractions':_0x5f0c13,'virtual':_0x6a8a09['virtual'],'online':_0xc80d16,'custom':_0x6a8a09}))[_0x17b366(0x200)](/'/g,'\x5c\x27')};_0x145d36[_0x17b366(0x234)]('Content-Type',_0x17b366(0x297))[_0x17b366(0x234)](_0x17b366(0x284),_0x1d0fa4[_0x17b366(0x300)])[_0x17b366(0x21b)](ejs[_0x17b366(0x1eb)](Mustache[_0x17b366(0x1eb)](_0x283217,_0xf818a8),{'proactiveActions':_0x4def72,'alignment':_0x1d0fa4[_0x17b366(0x20e)],'verticalAlignment':_0x1d0fa4[_0x17b366(0x238)],'div_color':_0x1d0fa4[_0x17b366(0x2fe)],'text_color':_0x1d0fa4[_0x17b366(0x213)],'button_color':_0x1d0fa4['color_button'],'background_color':_0x1d0fa4[_0x17b366(0x2a2)],'isDevelopment':config['isDevelopment']}));})[_0x1bacae(0x22e)](handleError(_0x145d36,null));},exports['addApplications']=function(_0x1eebd9,_0x1d6764){const _0x1f0bad=a133_0x5904da;return db[_0x1f0bad(0x25c)][_0x1f0bad(0x268)]({'where':{'id':_0x1eebd9[_0x1f0bad(0x2e6)]['id']}})[_0x1f0bad(0x2dc)](handleEntityNotFound(_0x1d6764,null))[_0x1f0bad(0x2dc)](function(_0x4cbc3d){const _0xc34355=_0x1f0bad;if(_0x4cbc3d)return db[_0xc34355(0x2b7)]['transaction'](function(_0x1f5092){const _0x54ca97=_0xc34355;return db[_0x54ca97(0x291)][_0x54ca97(0x1ee)]({'where':{'ChatWebsiteId':_0x1eebd9[_0x54ca97(0x2e6)]['id']},'transaction':_0x1f5092})[_0x54ca97(0x2dc)](function(){const _0x56e674=_0x54ca97,_0x223bcb=_[_0x56e674(0x25b)](_0x1eebd9[_0x56e674(0x242)],function(_0x1e52a5){const _0x50053d=_0x56e674;return _0x1e52a5[_0x50053d(0x280)]=_0x1eebd9['params']['id'],_0x1e52a5;}),_0x24cebf=_0x223bcb['filter'](_0x57fb60=>_0x57fb60[_0x56e674(0x2a7)]);return db[_0x56e674(0x291)][_0x56e674(0x246)](_0x24cebf,{'transaction':_0x1f5092});});})['then'](function(){const _0x278a25=_0xc34355;return db[_0x278a25(0x291)][_0x278a25(0x281)]({'where':{'ChatWebsiteId':_0x1eebd9[_0x278a25(0x2e6)]['id']},'order':db['sequelize'][_0x278a25(0x2b4)](_0x278a25(0x239))});});})['then'](respondWithResult(_0x1d6764,null))[_0x1f0bad(0x22e)](handleError(_0x1d6764,null));},exports[a133_0x5904da(0x2d6)]=function(_0x2a12cf,_0x40f2c3){const _0x4c02e0=a133_0x5904da;let _0x6a6c00={};const _0x545851={};let _0x5ad575,_0x32f16f;return db[_0x4c02e0(0x25c)][_0x4c02e0(0x268)]({'where':{'id':_0x2a12cf['params']['id']}})[_0x4c02e0(0x2dc)](handleEntityNotFound(_0x40f2c3,null))['then'](function(_0x18ae70){const _0x55ecbe=_0x4c02e0;if(_0x18ae70)return _0x5ad575=_0x18ae70,_0x545851['model']=_['keys'](db[_0x55ecbe(0x291)][_0x55ecbe(0x311)]),_0x545851['query']=_['keys'](_0x2a12cf[_0x55ecbe(0x2a6)]),_0x545851[_0x55ecbe(0x1e8)]=_['intersection'](_0x545851['model'],_0x545851[_0x55ecbe(0x2a6)]),_0x6a6c00[_0x55ecbe(0x2a4)]=_[_0x55ecbe(0x2cf)](_0x545851['model'],qs['fields'](_0x2a12cf[_0x55ecbe(0x2a6)][_0x55ecbe(0x24d)])),_0x6a6c00['attributes']=_0x6a6c00['attributes'][_0x55ecbe(0x27e)]?_0x6a6c00['attributes']:_0x545851[_0x55ecbe(0x20c)],_0x6a6c00[_0x55ecbe(0x22f)]=qs['sort'](_0x2a12cf[_0x55ecbe(0x2a6)][_0x55ecbe(0x227)]),_0x6a6c00[_0x55ecbe(0x20f)]=qs[_0x55ecbe(0x1e8)](_[_0x55ecbe(0x2a3)](_0x2a12cf[_0x55ecbe(0x2a6)],_0x545851[_0x55ecbe(0x1e8)])),_0x6a6c00=filterAttributes(_0x6a6c00,_0x2a12cf[_0x55ecbe(0x2a6)][_0x55ecbe(0x225)],_0x6a6c00[_0x55ecbe(0x2a4)],_0x2a12cf[_0x55ecbe(0x29e)],![]),_0x5ad575[_0x55ecbe(0x2d6)](_0x6a6c00);})['then'](function(_0x1a4a5f){const _0x231a17=_0x4c02e0;if(_0x1a4a5f)return _0x32f16f=_0x1a4a5f[_0x231a17(0x27e)],typeof _0x2a12cf[_0x231a17(0x2a6)][_0x231a17(0x2c8)]===_0x231a17(0x2ab)&&(_0x6a6c00[_0x231a17(0x23f)]=qs[_0x231a17(0x23f)](_0x2a12cf[_0x231a17(0x2a6)][_0x231a17(0x23f)]),_0x6a6c00[_0x231a17(0x2f1)]=qs[_0x231a17(0x2f1)](_0x2a12cf['query'][_0x231a17(0x2f1)])),_0x5ad575[_0x231a17(0x2d6)](_0x6a6c00);})[_0x4c02e0(0x2dc)](function(_0x338514){if(_0x338514)return _0x338514?{'count':_0x32f16f,'rows':_0x338514}:null;})[_0x4c02e0(0x2dc)](respondWithResult(_0x40f2c3,null))[_0x4c02e0(0x22e)](handleError(_0x40f2c3,null));},exports['addProactiveActions']=function(_0x71cda0,_0x4c68dd){const _0x3f94bc=a133_0x5904da;return db[_0x3f94bc(0x2fc)][_0x3f94bc(0x268)]({'where':{'id':_0x71cda0[_0x3f94bc(0x2e6)]['id']}})[_0x3f94bc(0x2dc)](function(_0x533a64){const _0x1d5fe5=_0x3f94bc;if(_0x533a64)return _0x533a64[_0x1d5fe5(0x1f2)](_0x71cda0[_0x1d5fe5(0x242)][_0x1d5fe5(0x1f5)],{'through':_[_0x1d5fe5(0x279)](_0x71cda0[_0x1d5fe5(0x242)],[_0x1d5fe5(0x1f5),'id'])});})[_0x3f94bc(0x2dc)](respondWithResult(_0x4c68dd,null))[_0x3f94bc(0x22e)](handleError(_0x4c68dd,null));},exports['getProactiveActions']=function(_0x270a89,_0x21cca7){const _0x2d0525=a133_0x5904da;let _0x576d70={};const _0x461ce8={};let _0x108e5e,_0x713bfc;return db[_0x2d0525(0x25c)][_0x2d0525(0x268)]({'where':{'id':_0x270a89[_0x2d0525(0x2e6)]['id']}})[_0x2d0525(0x2dc)](handleEntityNotFound(_0x21cca7,null))[_0x2d0525(0x2dc)](function(_0x523d9c){const _0x3878da=_0x2d0525;if(_0x523d9c)return _0x108e5e=_0x523d9c,_0x461ce8[_0x3878da(0x20c)]=_['keys'](db['ChatProactiveAction']['rawAttributes']),_0x461ce8[_0x3878da(0x2a6)]=_[_0x3878da(0x278)](_0x270a89[_0x3878da(0x2a6)]),_0x461ce8[_0x3878da(0x1e8)]=_[_0x3878da(0x2cf)](_0x461ce8['model'],_0x461ce8['query']),_0x576d70[_0x3878da(0x2a4)]=_[_0x3878da(0x2cf)](_0x461ce8[_0x3878da(0x20c)],qs[_0x3878da(0x24d)](_0x270a89[_0x3878da(0x2a6)]['fields'])),_0x576d70[_0x3878da(0x2a4)]=_0x576d70[_0x3878da(0x2a4)]['length']?_0x576d70[_0x3878da(0x2a4)]:_0x461ce8['model'],_0x576d70['order']=qs[_0x3878da(0x227)](_0x270a89[_0x3878da(0x2a6)][_0x3878da(0x227)]),_0x576d70['where']=qs['filters'](_['pick'](_0x270a89['query'],_0x461ce8['filters'])),_0x576d70=filterAttributes(_0x576d70,_0x270a89[_0x3878da(0x2a6)]['filter'],_0x576d70[_0x3878da(0x2a4)],_0x270a89['options'],![]),_0x108e5e['getProactiveActions'](_0x576d70);})[_0x2d0525(0x2dc)](function(_0x55d5d1){const _0x46ea56=_0x2d0525;if(_0x55d5d1)return _0x713bfc=_0x55d5d1[_0x46ea56(0x27e)],typeof _0x270a89[_0x46ea56(0x2a6)]['nolimit']===_0x46ea56(0x2ab)&&(_0x576d70[_0x46ea56(0x23f)]=qs['limit'](_0x270a89[_0x46ea56(0x2a6)]['limit']),_0x576d70[_0x46ea56(0x2f1)]=qs[_0x46ea56(0x2f1)](_0x270a89[_0x46ea56(0x2a6)][_0x46ea56(0x2f1)])),_0x108e5e['getProactiveActions'](_0x576d70);})[_0x2d0525(0x2dc)](function(_0x5f5528){if(_0x5f5528)return _0x5f5528?{'count':_0x713bfc,'rows':_0x5f5528}:null;})['then'](respondWithResult(_0x21cca7,null))[_0x2d0525(0x22e)](handleError(_0x21cca7,null));},exports[a133_0x5904da(0x244)]=function(_0x2e4c37,_0x851e18){const _0x3886aa=a133_0x5904da,_0x388a62=_0x2e4c37[_0x3886aa(0x2a6)][_0x3886aa(0x2d1)]==='false'?'offlineForm':_0x3886aa(0x310);return db['ChatWebsite']['findOne']({'attributes':['id',_0x388a62],'where':{'id':_0x2e4c37[_0x3886aa(0x2e6)]['id']}})['then'](handleEntityNotFound(_0x851e18,null))[_0x3886aa(0x2dc)](function(_0x1611b6){const _0x39344e=_0x3886aa;if(_0x1611b6){const _0x4891ec=_0x1611b6[_0x388a62],_0x37229c=_0x4891ec&&_0x4891ec[_0x39344e(0x28d)]?_0x4891ec[_0x39344e(0x28d)]:[];_0x851e18[_0x39344e(0x21b)]({'fromKey':_[_0x39344e(0x2da)](_0x4891ec[_0x39344e(0x270)])?undefined:_0x4891ec['fromKey'],'count':_0x37229c[_0x39344e(0x27e)],'rows':_0x37229c});}})[_0x3886aa(0x22e)](handleError(_0x851e18,null));},exports[a133_0x5904da(0x2af)]=function(_0x5b0515,_0x3d0acd){const _0x3a0d41=a133_0x5904da;let _0x50df9b={'raw':![],'where':{}};const _0x3bdab6={},_0x39ecc5={'count':0x0,'rows':[]};return db[_0x3a0d41(0x25c)]['findOne']({'where':{'id':_0x5b0515[_0x3a0d41(0x2e6)]['id']}})[_0x3a0d41(0x2dc)](handleEntityNotFound(_0x3d0acd,null))[_0x3a0d41(0x2dc)](function(_0x128c1f){const _0x3bb397=_0x3a0d41;if(_0x128c1f)return _0x3bdab6[_0x3bb397(0x20c)]=_[_0x3bb397(0x278)](db['ChatOfflineMessage'][_0x3bb397(0x311)]),_0x3bdab6['query']=_[_0x3bb397(0x278)](_0x5b0515[_0x3bb397(0x2a6)]),_0x3bdab6[_0x3bb397(0x1e8)]=_[_0x3bb397(0x2cf)](_0x3bdab6[_0x3bb397(0x20c)],_0x3bdab6[_0x3bb397(0x2a6)]),_0x50df9b[_0x3bb397(0x2a4)]=_['intersection'](_0x3bdab6[_0x3bb397(0x20c)],qs['fields'](_0x5b0515['query'][_0x3bb397(0x24d)])),_0x50df9b[_0x3bb397(0x2a4)]=_0x50df9b[_0x3bb397(0x2a4)][_0x3bb397(0x27e)]?_0x50df9b[_0x3bb397(0x2a4)]:_0x3bdab6[_0x3bb397(0x20c)],typeof _0x5b0515['query'][_0x3bb397(0x2c8)]===_0x3bb397(0x2ab)&&(_0x50df9b['limit']=qs[_0x3bb397(0x23f)](_0x5b0515[_0x3bb397(0x2a6)][_0x3bb397(0x23f)]),_0x50df9b[_0x3bb397(0x2f1)]=qs['offset'](_0x5b0515[_0x3bb397(0x2a6)][_0x3bb397(0x2f1)])),_0x50df9b[_0x3bb397(0x22f)]=qs['sort'](_0x5b0515[_0x3bb397(0x2a6)][_0x3bb397(0x227)]),_0x50df9b[_0x3bb397(0x20f)]=qs[_0x3bb397(0x1e8)](_[_0x3bb397(0x2a3)](_0x5b0515['query'],_0x3bdab6[_0x3bb397(0x1e8)])),_0x50df9b[_0x3bb397(0x20f)][_0x3bb397(0x280)]=_0x128c1f['id'],_0x50df9b=filterAttributes(_0x50df9b,_0x5b0515[_0x3bb397(0x2a6)]['filter'],_0x50df9b[_0x3bb397(0x2a4)],_0x5b0515[_0x3bb397(0x29e)],![]),db[_0x3bb397(0x2d4)][_0x3bb397(0x273)]({'where':_0x50df9b[_0x3bb397(0x20f)]})[_0x3bb397(0x2dc)](function(_0x10dcff){const _0x1c3872=_0x3bb397;return _0x39ecc5[_0x1c3872(0x273)]=_0x10dcff,_0x5b0515[_0x1c3872(0x2a6)][_0x1c3872(0x2f8)]?_0x50df9b[_0x1c3872(0x221)]=[{'all':!![]}]:_0x50df9b[_0x1c3872(0x221)]=[{'model':db[_0x1c3872(0x262)],'as':_0x1c3872(0x29a),'required':![]},{'model':db[_0x1c3872(0x283)],'as':_0x1c3872(0x21a),'required':![]}],db['ChatOfflineMessage'][_0x1c3872(0x2c4)](_0x50df9b);})[_0x3bb397(0x2dc)](function(_0x3f668d){const _0x2b4212=_0x3bb397;return _0x39ecc5[_0x2b4212(0x2e3)]=_0x3f668d,_0x39ecc5;});})[_0x3a0d41(0x2dc)](respondWithFilteredResult(_0x3d0acd,_0x50df9b))[_0x3a0d41(0x22e)](handleError(_0x3d0acd,null));},exports[a133_0x5904da(0x2e0)]=function(_0x29e3d3,_0x542966){const _0x121ebc=a133_0x5904da;return db[_0x121ebc(0x25c)][_0x121ebc(0x268)]({'where':{'id':_0x29e3d3[_0x121ebc(0x2e6)]['id']}})[_0x121ebc(0x2dc)](function(_0x2b2c59){const _0x5afe42=_0x121ebc;if(_0x2b2c59)return _0x2b2c59[_0x5afe42(0x2e0)](_0x29e3d3[_0x5afe42(0x242)]['ids'],{'through':_['omit'](_0x29e3d3['body'],['ids','id'])})['then'](function(_0x9e9fc5){const _0xc78b4d=_0x5afe42;for(let _0x596162=0x0;_0x596162<_0x29e3d3[_0xc78b4d(0x242)][_0xc78b4d(0x1f5)][_0xc78b4d(0x27e)];_0x596162+=0x1){socket['emit']('userChatWebsite:save',{'UserId':_0x29e3d3['body']['ids'][_0x596162],'ChatWebsiteId':_0x29e3d3['params']['id']});}return _0x9e9fc5;});})[_0x121ebc(0x2dc)](respondWithResult(_0x542966,null))[_0x121ebc(0x22e)](handleError(_0x542966,null));},exports[a133_0x5904da(0x214)]=function(_0x37f611,_0x4f6bf9){const _0x26f098=a133_0x5904da;return db[_0x26f098(0x25c)][_0x26f098(0x268)]({'where':{'id':_0x37f611[_0x26f098(0x2e6)]['id']}})[_0x26f098(0x2dc)](handleEntityNotFound(_0x4f6bf9,null))[_0x26f098(0x2dc)](function(_0x2cc52e){const _0x2c1084=_0x26f098;if(_0x2cc52e)return _0x2cc52e[_0x2c1084(0x214)](_0x37f611[_0x2c1084(0x2a6)][_0x2c1084(0x1f5)])[_0x2c1084(0x2dc)](function(){const _0x1c9561=_0x2c1084;if(_[_0x1c9561(0x1f8)](_0x37f611[_0x1c9561(0x2a6)][_0x1c9561(0x1f5)]))for(let _0x1d2326=0x0;_0x1d2326<_0x37f611['query'][_0x1c9561(0x1f5)]['length'];_0x1d2326+=0x1){socket[_0x1c9561(0x2aa)](_0x1c9561(0x296),{'UserId':Number(_0x37f611['query'][_0x1c9561(0x1f5)][_0x1d2326]),'ChatWebsiteId':Number(_0x37f611[_0x1c9561(0x2e6)]['id'])});}else socket['emit'](_0x1c9561(0x296),{'UserId':Number(_0x37f611[_0x1c9561(0x2a6)]['ids']),'ChatWebsiteId':Number(_0x37f611['params']['id'])});});})[_0x26f098(0x2dc)](respondWithStatusCode(_0x4f6bf9,null))[_0x26f098(0x22e)](handleError(_0x4f6bf9,null));},exports['getAgents']=function(_0x24ecda,_0x4edb6c){const _0x1f34f3=a133_0x5904da;let _0x3b9654={};const _0x565fc9={};let _0x27fa61,_0x140a5a;return db[_0x1f34f3(0x25c)][_0x1f34f3(0x268)]({'where':{'id':_0x24ecda[_0x1f34f3(0x2e6)]['id']}})[_0x1f34f3(0x2dc)](handleEntityNotFound(_0x4edb6c,null))['then'](function(_0x3cf5d5){const _0x2a95fe=_0x1f34f3;if(_0x3cf5d5)return _0x27fa61=_0x3cf5d5,_0x565fc9[_0x2a95fe(0x20c)]=_[_0x2a95fe(0x278)](db[_0x2a95fe(0x269)][_0x2a95fe(0x311)]),_0x565fc9[_0x2a95fe(0x2a6)]=_[_0x2a95fe(0x278)](_0x24ecda[_0x2a95fe(0x2a6)]),_0x565fc9['filters']=_[_0x2a95fe(0x2cf)](_0x565fc9['model'],_0x565fc9[_0x2a95fe(0x2a6)]),_0x3b9654[_0x2a95fe(0x2a4)]=_[_0x2a95fe(0x2cf)](_0x565fc9['model'],qs[_0x2a95fe(0x24d)](_0x24ecda[_0x2a95fe(0x2a6)][_0x2a95fe(0x24d)])),_0x3b9654[_0x2a95fe(0x2a4)]=_0x3b9654[_0x2a95fe(0x2a4)][_0x2a95fe(0x27e)]?_0x3b9654['attributes']:_0x565fc9[_0x2a95fe(0x20c)],_0x3b9654['order']=qs[_0x2a95fe(0x227)](_0x24ecda[_0x2a95fe(0x2a6)][_0x2a95fe(0x227)]),_0x3b9654[_0x2a95fe(0x20f)]=qs[_0x2a95fe(0x1e8)](_['pick'](_0x24ecda[_0x2a95fe(0x2a6)],_0x565fc9['filters'])),_0x3b9654=filterAttributes(_0x3b9654,_0x24ecda[_0x2a95fe(0x2a6)][_0x2a95fe(0x225)],_0x3b9654[_0x2a95fe(0x2a4)],_0x24ecda[_0x2a95fe(0x29e)],![]),_0x27fa61[_0x2a95fe(0x276)](_0x3b9654);})[_0x1f34f3(0x2dc)](function(_0x59057c){const _0xd7828b=_0x1f34f3;if(_0x59057c)return _0x140a5a=_0x59057c['length'],typeof _0x24ecda['query'][_0xd7828b(0x2c8)]===_0xd7828b(0x2ab)&&(_0x3b9654['limit']=qs['limit'](_0x24ecda[_0xd7828b(0x2a6)]['limit']),_0x3b9654['offset']=qs[_0xd7828b(0x2f1)](_0x24ecda[_0xd7828b(0x2a6)]['offset'])),_0x27fa61['getAgents'](_0x3b9654);})['then'](function(_0x384ab3){if(_0x384ab3)return _0x384ab3?{'count':_0x140a5a,'rows':_0x384ab3}:null;})['then'](respondWithResult(_0x4edb6c,null))['catch'](handleError(_0x4edb6c,null));};
\ No newline at end of file