"use strict";(self.webpackChunkbongacams=self.webpackChunkbongacams||[]).push([[549,547],{96575:function(t,e,n){n.d(e,{R:function(){return o}});var i=n(18697);function o(t,e){(0,i._b)("BCC bcAppDispatch").warn(t,{payload:e}),"function"==typeof window.bcAppDispatch&&window.bcAppDispatch(t,e)}Object.prototype.hasOwnProperty.call(window,"legacyAppDispatch")||(window.legacyAppDispatch=function(t,e){(0,i._b)("BCC legacyAppDispatch").warn(t,{payload:e}),document.dispatchEvent(new CustomEvent(t,{detail:e}))})},79797:function(t,e,n){n.r(e),n.d(e,{init:function(){return b}});var i=n(15215),o=n(19826),r=n(80554),s=n(81714),c=function(t){if("function"==typeof Event)return new Event(t);var e=document.createEvent("Event");return e.initEvent(t,!0,!0),e},a=n(67374),u=n(13907),h=n(96575),d=n(88035),f=n(31313),l=n(41669),p=function(){return Promise.all([n.e(11),n.e(10),n.e(44),n.e(37),n.e(16),n.e(12),n.e(110),n.e(102),n.e(61),n.e(48),n.e(97),n.e(54),n.e(157),n.e(267),n.e(68),n.e(88),n.e(106),n.e(560),n.e(389),n.e(283)]).then(n.bind(n,6883))},v=function(){return n.e(358).then(n.bind(n,44327))};function b(){var t=o.A.getState(),e=t.noticeData,n=t.user,b=t.isAuthenticated,m=t.isMobile,g=t.isModerator,y=n.role===s.A.ROLE_MODEL;if(null==e?void 0:e.token){var w=new f.xd((0,u.ip)("@ws_notification"),(0,i.Cl)({plugins:[(0,f.IW)({data:m?(0,i.Cl)((0,i.Cl)({},e),{is_mobile:1}):e,type:"identify"},(function(t){return"open"===t.type})),f.vJ],reconnect:!0},y?a.qu:{}));w.on(f.oR.ON_OPEN,(function(){l(document).trigger("onNoticeSocketOpen")})),w.on(f.oR.ON_MESSAGE,(function(t){(0,d.w)(r.R.SOCKET_NOTIFICATION_MESSAGE,t),l(document).trigger("onNoticeSocketMessage",[t]),b&&(p().then((function(e){e.handleSocketCommon(t)})),g&&v().then((function(e){e.handleSocketAdmin(t)}))),"user"===t.type&&(0,h.R)("@@SocketUserEvent",t.data)})),l.noticeSocket=w,document.dispatchEvent(c("onNoticeSocketReady"))}}},67374:function(t,e,n){n.d(e,{I_:function(){return d},qu:function(){return i},bk:function(){return a},xc:function(){return c}});var i={maxDelay:6e5,retries:1/0},o=n(15215),r=n(41669),s=[],c=function(t){r.noticeSocket&&t&&s.indexOf(t)>=0&&(s=s.filter((function(e){return e!==t})),r.noticeSocket.send({data:{data:{model:t},type:2},type:"cms"}))},a=function(t){(0,o.fX)([],s,!0).map((function(t){return c(t)})),function(t){r.noticeSocket&&t&&s.indexOf(t)<0&&(s.push(t),r.noticeSocket.send({data:{data:{model:t},type:1},type:"cms"}))}(t)},u=n(19826),h=n(91414),d=function(){function t(){var e=u.A.getState().isAuthenticated;this.isAuthenticated=e,this.idb=new h.bp(t.dbName)}return t.getInstance=function(){return t.instance||(t.instance=new this),t.instance},t.prototype.isAvailable=function(){return this.idb.isAvailable()},t.prototype.checkAndSaveAllowing=function(t){return(0,o.sH)(this,void 0,void 0,(function(){var e,n,i,r,s;return(0,o.YH)(this,(function(o){switch(o.label){case 0:return this.isAvailable()?(e=this.getUnmuteKey(),[4,this.getData(e)]):[2,!0];case 1:return n=o.sent()||{},i=n[t],(r=!i||Date.now()>=i)?(s=u.A.getState().config,n[t]=Date.now()+(null==s?void 0:s.notificationsMutePeriod),[4,this.setData(e,n)]):[3,3];case 2:o.sent(),o.label=3;case 3:return[2,r]}}))}))},t.prototype.clearNotificationMuteData=function(){return(0,o.sH)(this,void 0,void 0,(function(){var t;return(0,o.YH)(this,(function(e){switch(e.label){case 0:return this.isAvailable()?(t=this.getUnmuteKey(),[4,this.removeData(t)]):[2];case 1:return e.sent(),[2]}}))}))},t.prototype.checkIsAuth=function(){return(0,o.sH)(this,void 0,void 0,(function(){var t;return(0,o.YH)(this,(function(e){switch(e.label){case 0:return[4,this.getData("isAuth")];case 1:return t=e.sent(),!this.isAuthenticated||t?[3,3]:[4,this.setData("isAuth",!0)];case 2:return e.sent(),[3,5];case 3:return this.isAuthenticated||!t?[3,5]:[4,this.removeData("isAuth")];case 4:e.sent(),e.label=5;case 5:return[2]}}))}))},t.prototype.getToken=function(){return(0,o.sH)(this,void 0,void 0,(function(){return(0,o.YH)(this,(function(t){switch(t.label){case 0:return[4,this.getData("token")];case 1:return[2,t.sent()]}}))}))},t.prototype.saveToken=function(t){return(0,o.sH)(this,void 0,void 0,(function(){return(0,o.YH)(this,(function(e){switch(e.label){case 0:return[4,this.setData("token",t)];case 1:return e.sent(),[2]}}))}))},t.prototype.removeToken=function(){return(0,o.sH)(this,void 0,void 0,(function(){return(0,o.YH)(this,(function(t){switch(t.label){case 0:return[4,this.removeData("token")];case 1:return t.sent(),[2]}}))}))},t.prototype.updateConfig=function(){return(0,o.sH)(this,void 0,void 0,(function(){var t;return(0,o.YH)(this,(function(e){switch(e.label){case 0:return this.isAvailable()?(t=u.A.getState().config,[4,this.setData("mutePeriod",null==t?void 0:t.notificationsMutePeriod)]):[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},t.prototype.getData=function(t){return(0,o.sH)(this,void 0,void 0,(function(){return(0,o.YH)(this,(function(e){switch(e.label){case 0:return[4,this.idb.open()];case 1:return e.sent(),[4,this.idb.getItem(t)];case 2:return[2,e.sent()]}}))}))},t.prototype.setData=function(t,e){return(0,o.sH)(this,void 0,void 0,(function(){return(0,o.YH)(this,(function(n){switch(n.label){case 0:return[4,this.idb.open()];case 1:return n.sent(),[4,this.idb.setItem(t,e)];case 2:return n.sent(),[2]}}))}))},t.prototype.removeData=function(t){return(0,o.sH)(this,void 0,void 0,(function(){return(0,o.YH)(this,(function(e){switch(e.label){case 0:return[4,this.idb.open()];case 1:return e.sent(),[4,this.idb.removeItem(t)];case 2:return e.sent(),[2]}}))}))},t.prototype.getUnmuteKey=function(){var e=u.A.getState().user;return"".concat("um_").concat((null==e?void 0:e.username)||t.guestName)},t.dbName="notificationSettings",t.guestName="guest",t}()}}]);