"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9689],{29689:function(e,r,t){t.r(r);var s=t(85893),a=t(67294),n=t(68387),i=t(45007);r.default=e=>{let{children:r,onNotificationReceived:t}=e,[o,c]=(0,a.useState)(null),[u,f]=(0,a.useState)(null),[l,g]=(0,a.useState)(!1),[v,d]=(0,a.useState)(""),{fetchToken:h,onMessageListener:k}=(0,n.Z)(),E=(0,i.v9)(e=>{var r;return null===(r=e.WebSetting)||void 0===r?void 0:r.fcmToken}),S=async()=>{await h(g,d)};return(0,a.useEffect)(()=>{S()},[u]),(0,a.useEffect)(()=>{f(E)},[u]),(0,a.useEffect)(()=>{k().then(e=>{e&&e.data&&(c(e.data),t(e.data))}).catch(e=>{console.error("Error handling foreground notification:",e)})},[o,t]),(0,a.useEffect)(()=>{v&&"serviceWorker"in navigator&&navigator.serviceWorker.register("/firebase-messaging-sw.js").then(e=>{console.info("Service Worker registration successful with scope: ",e.scope)}).catch(e=>{console.error("Service Worker registration failed: ",e)})},[v]),(0,s.jsx)(s.Fragment,{children:r})}}}]);