"use strict";(self.webpackChunkbongacams=self.webpackChunkbongacams||[]).push([[392,795],{67374:function(t,e,n){n.d(e,{I_:function(){return l},qu:function(){return s},bk:function(){return c},xc:function(){return o}});var s={maxDelay:6e5,retries:1/0},i=n(15215),r=n(41669),a=[],o=function(t){r.noticeSocket&&t&&a.indexOf(t)>=0&&(a=a.filter(function(e){return e!==t}),r.noticeSocket.send({data:{data:{model:t},type:2},type:"cms"}))},c=function(t){(0,i.fX)([],a,!0).map(function(t){return o(t)}),function(t){r.noticeSocket&&t&&a.indexOf(t)<0&&(a.push(t),r.noticeSocket.send({data:{data:{model:t},type:1},type:"cms"}))}(t)},u=n(99525),h=n(26859),l=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,i.sH)(this,void 0,void 0,function(){var e,n,s,r,a;return(0,i.YH)(this,function(i){switch(i.label){case 0:return t?this.isAvailable()?(e=this.getUnmuteKey(),[4,this.getData(e)]):[2,!0]:[2,!1];case 1:return n=i.sent()||{},s=n[t],(r=!s||Date.now()>=s)?(a=u.A.getState().config,n[t]=Date.now()+(null==a?void 0:a.notificationsMutePeriod),[4,this.setData(e,n)]):[3,3];case 2:i.sent(),i.label=3;case 3:return[2,r]}})})},t.prototype.clearNotificationMuteData=function(){return(0,i.sH)(this,void 0,void 0,function(){var t;return(0,i.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.getNotificationMuteData=function(){},t.prototype.checkIsAuth=function(){return(0,i.sH)(this,void 0,void 0,function(){var t;return(0,i.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 this.getData("token")},t.prototype.saveToken=function(t){return(0,i.sH)(this,void 0,void 0,function(){return(0,i.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,i.sH)(this,void 0,void 0,function(){return(0,i.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,i.sH)(this,void 0,void 0,function(){var t;return(0,i.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,i.sH)(this,void 0,void 0,function(){return(0,i.YH)(this,function(e){switch(e.label){case 0:return[4,this.idb.open()];case 1:return e.sent(),[2,this.idb.getItem(t)]}})})},t.prototype.setData=function(t,e){return(0,i.sH)(this,void 0,void 0,function(){return(0,i.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,i.sH)(this,void 0,void 0,function(){return(0,i.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}()},69760:function(t,e,n){n.r(e),n.d(e,{PushNotification:function(){return c}});var s=n(15215),i=n(44198),r=n(67374),a=n(84435),o=function(t){function e(){var e=t.call(this)||this;return e._innerStatus=1,e.waitMaxFails=20,e.waitFailCounter=0,e.callbacks=[],e.waitLoading=function(){if(!e.checkStatusComplete(2,!0))throw new Error("Firebase not loaded but status do not equal ".concat(2," (initializing): ").concat(e.status));if("firebase"in window&&"messaging"in firebase)try{e.status=3,e.init()}catch(t){e.status=0}else e.waitFailCounter++,e.waitFailCounter>e.waitMaxFails?e.status=0:window.setTimeout(e.waitLoading,1e3)},e.handleMessage=function(t){(0,i._b)("PushAPI Firebase handleMessage").log(t),e.callbacks.map(function(e){e(t)})},"Notification"in window&&"serviceWorker"in navigator&&"https:"===window.location.protocol||(e.status=0),e}return(0,s.C6)(e,t),e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.prototype.subscribe=function(){return(0,s.sH)(this,void 0,void 0,function(){var t,e;return(0,s.YH)(this,function(n){switch(n.label){case 0:return n.trys.push([0,4,,5]),[4,this.ready()];case 1:return n.sent(),[4,(t=firebase.messaging()).requestPermission()];case 2:return n.sent(),[4,t.getToken()];case 3:return[2,n.sent()];case 4:throw e=n.sent(),(0,i._b)("PushAPI Firebase subscribe failed").error(e.message||e),e;case 5:return[2]}})})},e.prototype.unsubscribe=function(t){return(0,s.sH)(this,void 0,void 0,function(){var e;return(0,s.YH)(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,this.ready()];case 1:return n.sent(),[4,firebase.messaging().deleteToken(t)];case 2:return[2,n.sent()];case 3:throw e=n.sent(),(0,i._b)("PushAPI Firebase unsubscribe failed").error(e.message||e),e;case 4:return[2]}})})},e.prototype.onMessage=function(t){this.callbacks.push(t)},e.prototype.isAvailable=function(){return 0!==this.status},e.prototype.setup=function(){if(this.isAvailable()&&!("firebase"in window)&&!this.checkStatusComplete(3)){this.status=2;var t=function(n){if(e.libUris[n]){var s=e.libUris[n];if(!document.querySelector('script[src="'.concat(s,'"]'))){var r=document.createElement("script");r.async=!0,r.src=s,r.onload=function(){(0,i._b)("PushAPI Firebase loadLib success").log(n,s),t(n+1)},document.head.appendChild(r)}}};e.libUris.length&&t(0),this.waitLoading()}},e.prototype.init=function(){this.isAvailable()&&!this.checkStatusComplete(4)&&(this.status=4,firebase.initializeApp(e.config),firebase.messaging().onMessage(this.handleMessage))},e.prototype.ready=function(){return(0,s.sH)(this,void 0,void 0,function(){var t,e=this;return(0,s.YH)(this,function(n){switch(n.label){case 0:return this.checkStatusComplete(4)?[2,!0]:this.checkStatusComplete(2)?(t=this,[4,new Promise(function(n,i){e.readyGenerator=function(){return(0,s.YH)(this,function(e){switch(e.label){case 0:return t.checkStatusComplete(4)?[3,2]:[4];case 1:return e.sent(),t.isAvailable()||i("Network error"),[3,0];case 2:return n(),[2,!0]}})}(),e.readyGenerator.next(null)})]):((0,i._b)("PushAPI Firebase ready").error("You must setup firebase before"),[2,!1]);case 1:return[2,n.sent()]}})})},e.prototype.onChangeStatus=function(t,e){(0,i._b)("PushAPI Firebase onChangeStatus").log(t,"->",e),this.readyGenerator&&this.readyGenerator.next(e)},e.prototype.checkStatusComplete=function(t,e){return void 0===e&&(e=!1),e?this.status===t:this.status>=t},Object.defineProperty(e.prototype,"status",{get:function(){return this._innerStatus},set:function(t){var e=this.status;this._innerStatus=t,this.onChangeStatus(e,t)},enumerable:!1,configurable:!0}),e.libVersion="7.21.0",e.libUris=["https://www.gstatic.com/firebasejs/".concat(e.libVersion,"/firebase-app.js"),"https://www.gstatic.com/firebasejs/".concat(e.libVersion,"/firebase-messaging.js")],e.config={apiKey:"AIzaSyBZPKKo_tInwfJZ0COBg0ZfmYyxacO6lsU",projectId:"bongacams-e8ad2",messagingSenderId:"918428164766",appId:"1:918428164766:web:c8b01dbfcdaf92e0c8918f"},e}(n(1292).T),c=function(){function t(){var e,n=this;if(this.token=null,this.onMessage=function(e){n.isAvailable()&&t.callbacks.push(e)},this.removeMessageListener=function(e){if(n.isAvailable()){var s=[];t.callbacks.map(function(t){t!==e&&s.push(t)}),t.callbacks=s}},"Notification"in window&&!a.BrowserDetect.isSafari()){var s=o.getInstance();s.isAvailable()&&(s.setup(),e=s)}e?(this.service=e,this.service.onMessage(function(e){(0,i._b)("PushAPI PushNotification onMessage").log(e),t.callbacks.map(function(t){t(e)})})):(0,i._b)("PushAPI PushNotification init failed").error("not available")}return t.getInstance=function(){return(0,s.sH)(this,void 0,void 0,function(){return(0,s.YH)(this,function(e){switch(e.label){case 0:return t.instance?[3,2]:(t.instance=new t,[4,t.instance.checkSubscription()]);case 1:e.sent(),e.label=2;case 2:return[2,t.instance]}})})},t.prototype.isAvailable=function(){return Boolean(this.service)},t.prototype.getToken=function(){return this.token},t.prototype.subscribe=function(){return(0,s.sH)(this,void 0,void 0,function(){var t,e;return(0,s.YH)(this,function(n){switch(n.label){case 0:if(!this.isAvailable())return[2,null];n.label=1;case 1:return n.trys.push([1,6,,7]),(0,i._b)("PushAPI PushNotification subscribe try").log(),[4,this.service.subscribe()];case 2:return(t=n.sent())?(this.token=t,[4,r.I_.getInstance().saveToken(this.token)]):[3,5];case 3:return n.sent(),[4,r.I_.getInstance().checkIsAuth()];case 4:n.sent(),(0,i._b)("PushAPI PushNotification subscribe success").log(t),n.label=5;case 5:return[2,t];case 6:switch((e=n.sent()).code){case"messaging/permission-blocked":case"messaging/permission-default":(0,i._b)("PushAPI PushNotification subscribe failed").log("show alert");break;case"messaging/unsupported-browser":(0,i._b)("PushAPI PushNotification subscribe failed").log("unsupported browser");break;default:(0,i._b)("PushAPI PushNotification subscribe failed").log(e)}return[2,null];case 7:return[2]}})})},t.prototype.unsubscribeAll=function(){return(0,s.sH)(this,void 0,void 0,function(){var t,e;return(0,s.YH)(this,function(n){switch(n.label){case 0:if(!this.isAvailable()||!this.isSubscribed())return[2,!1];n.label=1;case 1:return n.trys.push([1,5,,6]),(0,i._b)("PushAPI PushNotification unsubscribeAll try").log(),[4,this.service.unsubscribe(this.token)];case 2:return(t=n.sent())?[4,r.I_.getInstance().removeToken()]:[3,4];case 3:n.sent(),this.token=null,(0,i._b)("PushAPI PushNotification unsubscribeAll success").log(),n.label=4;case 4:return[2,t];case 5:if("messaging/delete-token-not-found"===(e=n.sent()).code);else(0,i._b)("PushAPI PushNotification unsubscribeAll failed").error(e);return[3,6];case 6:return[2]}})})},t.prototype.isSubscribed=function(){return Boolean(this.token)},t.prototype.checkSubscription=function(){return(0,s.sH)(this,void 0,void 0,function(){var t,e;return(0,s.YH)(this,function(n){switch(n.label){case 0:return[4,r.I_.getInstance().checkIsAuth()];case 1:return n.sent(),window.Notification&&"granted"===Notification.permission&&r.I_.getInstance().isAvailable()&&this.isAvailable()?[4,r.I_.getInstance().getToken()]:[2];case 2:return t=n.sent(),(0,i._b)("PushAPI PushNotification checkSubscription savedToken").log(t),t?[4,this.service.subscribe()]:[2];case 3:return e=n.sent(),(0,i._b)("PushAPI PushNotification checkSubscription serviceToken").log(e),e&&t===e?[3,7]:((0,i._b)("PushAPI PushNotification checkSubscription").log("remove all"),[4,r.I_.getInstance().removeToken()]);case 4:return n.sent(),e?[4,this.service.unsubscribe(e)]:[3,6];case 5:n.sent(),n.label=6;case 6:return[2];case 7:return this.token=e,(0,i._b)("PushAPI PushNotification checkSubscription success").log(),[2]}})})},t.callbacks=[],t}()},1292:function(t,e,n){n.d(e,{k:function(){return i.PushNotification},T:function(){return s}});var s=function(){},i=n(69760)}}]);