import { clientsClaim } from "workbox-core" ; import { ExpirationPlugin } from "workbox-expiration" ; import { precacheAndRoute , createHandlerBoundToURL } from "workbox-precaching" ; import { registerRoute } from "workbox-routing" ; import { StaleWhileRevalidate } from "workbox-strategies" ; declare const self ; clientsClaim ( ) ; precacheAndRoute ( self . __WB_MANIFEST ) ; const fileExtensionRegexp = new RegExp ( "/[^/?]+\\.[^/]+$" ) ; registerRoute ( ( { request , url } ) => { if ( request . mode !== "navigate" ) { return false ; } if ( url . pathname . startsWith ( "/_" ) ) { return false ; } if ( url . pathname . match ( fileExtensionRegexp ) ) { return false ; } return true ; } , createHandlerBoundToURL ( process . env . PUBLIC_URL + "/index.html" ) ) ; registerRoute ( ( { url } ) => url . origin === self . location . origin && url . pathname . endsWith ( ".png" ) , new StaleWhileRevalidate ( { cacheName : "images" , plugins : [ new ExpirationPlugin ( { maxEntries : 50 } ) , ] , } ) ) ; self . addEventListener ( "message" , ( event ) => { if ( event . data && event . data . type === "SKIP_WAITING" ) { self . skipWaiting ( ) ; } } ) ; self . addEventListener ( "push" , async function ( event ) { if ( event . data ) { const data = JSON . parse ( event . data . text ( ) ) ; event . waitUntil ( self . registration . showNotification ( "Care - CoronaSafe Network" , { body : data . title , tag : data . external_id , } ) ) ; } } ) ; self . addEventListener ( "notificationclick" , ( e ) => { e . notification . close ( ) ; e . waitUntil ( self . clients . matchAll ( { type : "window" } ) . then ( ( clientsArr ) => { const hadWindowToFocus = clientsArr . some ( ( windowClient ) => windowClient . url === "/notifications/" . concat ( e . notification . tag ) ? ( windowClient . focus ( ) , true ) : false ) ; if ( ! hadWindowToFocus ) self . clients . openWindow ( "/notifications/" . concat ( e . notification . tag ) ) . then ( ( windowClient ) => ( windowClient ? windowClient . focus ( ) : null ) ) ; } ) ) ; } ) ;