// W·Dot CMS — service worker self-unregister stub.
// Returns 200 so browsers that previously cached an SW can deactivate it cleanly,
// then refreshes the open clients so they no longer reference the dead worker.
self.addEventListener('install', () => self.skipWaiting());
self.addEventListener('activate', (event) => {
  event.waitUntil((async () => {
    try {
      await self.registration.unregister();
      const clients = await self.clients.matchAll({ type: 'window' });
      clients.forEach((client) => {
        try { client.navigate(client.url); } catch (_) { /* ignore */ }
      });
    } catch (_) {
      /* swallow: best-effort cleanup */
    }
  })());
});
