/* Minimal service worker.
 *
 * Its main job is to make the app installable (Android Chrome requires a SW
 * with a fetch handler to offer "Add to Home Screen" / launch standalone).
 * We use a network-first passthrough — no aggressive caching, so the viewer
 * always shows the latest chat data. */
self.addEventListener('install', () => self.skipWaiting());

self.addEventListener('activate', (event) => {
  event.waitUntil(self.clients.claim());
});

self.addEventListener('fetch', (event) => {
  // Network-first; fall back to cache only if the network is unavailable.
  event.respondWith(
    fetch(event.request).catch(() => caches.match(event.request))
  );
});
