'use strict';

/**
 * Generated by Progressive Web Apps For WordPress:
 * https://codecanyon.net/user/DaftPlug/
 * by DaftPlug
**/
const version = '{{time}}';const pushLatestPush=self.registration.scope+'wp-content/pwa-latest-push.json';self.addEventListener('push',event=>{event.waitUntil(registration.pushManager.getSubscription().then(function(subscription){return fetch(pushLatestPush).then(function(response){return response.json().then(function(data){return self.registration.showNotification(data.title,{body:data.body,badge:data.badge,icon:data.icon,image:data.image})})})}))});self.addEventListener('notificationclick',event=>{const notification=event.notification;const action=event.action;if(action==='close'){notification.close()}else{event.waitUntil(fetch(pushLatestPush).then(function(response){return response.json().then(function(data){if(''!==data.redirect){clients.openWindow(data.redirect)}
notification.close()})}).catch(function(err){notification.close()}))}})