"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6842,9689],{29689:function(e,r,n){n.r(r);var t=n(85893),o=n(67294),s=n(68387),a=n(45007);r.default=e=>{let{children:r,onNotificationReceived:n}=e,[i,l]=(0,o.useState)(null),[c,u]=(0,o.useState)(null),[g,f]=(0,o.useState)(!1),[p,d]=(0,o.useState)(""),{fetchToken:v,onMessageListener:h}=(0,s.Z)(),w=(0,a.v9)(e=>{var r;return null===(r=e.WebSetting)||void 0===r?void 0:r.fcmToken}),k=async()=>{await v(f,d)};return(0,o.useEffect)(()=>{k()},[c]),(0,o.useEffect)(()=>{u(w)},[c]),(0,o.useEffect)(()=>{h().then(e=>{e&&e.data&&(l(e.data),n(e.data))}).catch(e=>{console.error("Error handling foreground notification:",e)})},[i,n]),(0,o.useEffect)(()=>{p&&"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)})},[p]),(0,t.jsx)(t.Fragment,{children:r})}},68387:function(e,r,n){var t=n(83977),o=n(20061),s=n(80770),a=n(2370),i=n(30836),l=n(87076);r.Z=()=>{let e={apiKey:"AIzaSyAvaRmrG6-zPdBrFN9G3RNZC7FeT61FL3U",authDomain:"relocate-2c85c.firebaseapp.com",projectId:"relocate-2c85c",storageBucket:"relocate-2c85c.firebasestorage.app",messagingSenderId:"271378157146",appId:"1:271378157146:web:1980efc00967f2951b9263",measurementId:"G-72PHP9RLQD"};s.Z.apps.length||s.Z.initializeApp(e);let r=(0,t.ZF)(e),n=(0,a.v0)(r),c=(0,t.C6)().length?(0,t.Mq)():(0,t.ZF)(e),u=async()=>{if("serviceWorker"in navigator)try{let e=await navigator.serviceWorker.register("/firebase-messaging-sw.js");return console.info("Service Worker registered:",e.scope),e}catch(e){console.error("Service Worker registration failed:",e)}return null},g=async()=>{try{if(await (0,o.Gb)())return(0,o.KL)(c);return console.error("Firebase messaging is not supported in this browser"),(0,l.e8)(),null}catch(e){return console.error("Error checking messaging support:",e),null}};return{firebaseApp:c,authentication:n,fetchToken:async(e,r)=>{try{await u();let n=await g();if(!n){console.error("Messaging not supported in this browser"),null==e||e(!1),null==r||r(null);return}let t=await Notification.requestPermission();if("granted"!==t){console.error("Notification permission denied"),null==e||e(!1),null==r||r(null);return}let s=await (0,o.LP)(n,{vapidKey:"BNK1VjEjJ1x2NGp6UB-oJIscknnWomYwH7NqftWOdzvQRrujscpt3aIAgwhpqR5pwBSYA0fOyofyBXoaLmi_1XY"});s?(null==r||r(s),(0,i.Cw)(s),null==e||e(!0)):(console.error("No token available"),null==e||e(!1),null==r||r(null))}catch(n){console.error("Error fetching token:",n),null==e||e(!1),null==r||r(null)}},onMessageListener:async()=>{let e=await g();return e?new Promise(r=>{(0,o.ps)(e,e=>{r(e)})}):(console.error("Messaging not supported."),null)},signOut:()=>n.signOut()}}}}]);