// Generated by stillpub-pwa-precache — do not edit.
const CACHE = 'stillpub-8c377e09d1cf';
const PRECACHE = ["/app/","/app/assets/fabricLayout-CLPHLabh.js","/app/assets/index-DtqT604u.js","/app/assets/index-MSkwazQm.css","/app/assets/pub2json-DQ6lLw69.wasm","/app/assets/pub2json-Dh9ChSvv.mjs","/app/assets/worker-Ciqz0UQ4.js","/app/brand/favicon.svg","/app/brand/icon-maskable.svg","/app/brand/mark.svg","/app/brand/palette-options.svg","/app/brand/wordmark-dark.svg","/app/brand/wordmark-mask.svg","/app/brand/wordmark.svg","/app/favicon.svg","/app/fonts/alfa-slab-one/AlfaSlabOne-Regular.ttf","/app/fonts/anton/Anton-Regular.ttf","/app/fonts/caladea/Caladea-Bold.ttf","/app/fonts/caladea/Caladea-BoldItalic.ttf","/app/fonts/caladea/Caladea-Italic.ttf","/app/fonts/caladea/Caladea-Regular.ttf","/app/fonts/carlito/Carlito-Bold.ttf","/app/fonts/carlito/Carlito-BoldItalic.ttf","/app/fonts/carlito/Carlito-Italic.ttf","/app/fonts/carlito/Carlito-Regular.ttf","/app/fonts/crimson-text/CrimsonText-Bold.ttf","/app/fonts/crimson-text/CrimsonText-BoldItalic.ttf","/app/fonts/crimson-text/CrimsonText-Italic.ttf","/app/fonts/crimson-text/CrimsonText-Regular.ttf","/app/fonts/great-vibes/GreatVibes-Regular.ttf","/app/fonts/liberation-mono/LiberationMono-Bold.ttf","/app/fonts/liberation-mono/LiberationMono-BoldItalic.ttf","/app/fonts/liberation-mono/LiberationMono-Italic.ttf","/app/fonts/liberation-mono/LiberationMono-Regular.ttf","/app/fonts/liberation-sans/LiberationSans-Bold.ttf","/app/fonts/liberation-sans/LiberationSans-BoldItalic.ttf","/app/fonts/liberation-sans/LiberationSans-Italic.ttf","/app/fonts/liberation-sans/LiberationSans-Regular.ttf","/app/fonts/liberation-serif/LiberationSerif-Bold.ttf","/app/fonts/liberation-serif/LiberationSerif-BoldItalic.ttf","/app/fonts/liberation-serif/LiberationSerif-Italic.ttf","/app/fonts/liberation-serif/LiberationSerif-Regular.ttf","/app/fonts/lilita-one/LilitaOne-Regular.ttf","/app/fonts/pacifico/Pacifico-Regular.ttf","/app/fonts/quattrocento/Quattrocento-Bold.ttf","/app/fonts/quattrocento/Quattrocento-Regular.ttf","/app/fonts/quattrocento-sans/QuattrocentoSans-Bold.ttf","/app/fonts/quattrocento-sans/QuattrocentoSans-BoldItalic.ttf","/app/fonts/quattrocento-sans/QuattrocentoSans-Italic.ttf","/app/fonts/quattrocento-sans/QuattrocentoSans-Regular.ttf","/app/fonts/titillium-web/TitilliumWeb-Bold.ttf","/app/fonts/titillium-web/TitilliumWeb-BoldItalic.ttf","/app/fonts/titillium-web/TitilliumWeb-Italic.ttf","/app/fonts/titillium-web/TitilliumWeb-Regular.ttf","/app/icon-192.png","/app/icon-512.png","/app/icons.svg","/app/index.html","/app/manifest.webmanifest"];

// Install caches each entry on its own and tolerates stragglers. addAll() is
// all-or-nothing: one flaky response and the whole offline bundle is silently
// absent, with the app looking fine until the user goes offline. Here a
// failure costs exactly that one file (re-fetched from the network on demand)
// and says so in the console.
self.addEventListener('install', (event) => {
  event.waitUntil(
    caches.open(CACHE)
      .then((cache) => Promise.allSettled(PRECACHE.map((url) => cache.add(url))))
      .then((results) => {
        const failed = results.filter((r) => r.status === 'rejected');
        if (failed.length > 0) {
          console.warn(
            '[stillpub] offline copy incomplete: ' + failed.length + ' of ' + PRECACHE.length +
            ' files could not be cached. The app still works online and will retry those on next load.',
            failed.map((r) => r.reason)
          );
        }
      })
      .catch((err) => {
        console.warn('[stillpub] offline copy could not be created; the app still works online.', err);
      })
  );
});

// Deliberately NOT skipWaiting() on install. A worker that takes over
// immediately leaves every open tab running the previous build's JavaScript
// with no signal, so people keep hitting bugs that are already fixed and
// report them. Instead the new worker parks here until the page asks, which
// it does after telling the user an update is ready. See src/pwa.ts.
self.addEventListener('message', (event) => {
  if (event.data && event.data.type === 'SKIP_WAITING') self.skipWaiting();
});

self.addEventListener('activate', (event) => {
  event.waitUntil(
    caches.keys()
      .then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k))))
      .then(() => self.clients.claim())
  );
});

// Cache-first for same-origin GETs; navigations fall back to the cached
// shell when offline. Nothing is ever sent anywhere: this worker only
// reads the local cache and the app's own origin.
self.addEventListener('fetch', (event) => {
  const request = event.request;
  if (request.method !== 'GET') return;
  const url = new URL(request.url);
  if (url.origin !== self.location.origin) return;
  event.respondWith(
    caches.match(request, { ignoreSearch: request.mode === 'navigate' }).then((hit) => {
      if (hit) return hit;
      return fetch(request)
        .then((response) => {
          if (response.ok) {
            const copy = response.clone();
            caches.open(CACHE).then((cache) => cache.put(request, copy));
          }
          return response;
        })
        .catch(() => (request.mode === 'navigate' ? caches.match("/app/") : Promise.reject(new Error('offline'))));
    })
  );
});
