/// <reference lib="webworker" />

// Fase 6.1: minimal custom SW. Named `sw.ts` (not `service-worker.ts`) because
// SvelteKit intercepts the latter filename and blocks Workbox imports; see
// CLAUDE.md gotcha #10. Strategy: precache the built shell via `__WB_MANIFEST`.
// We deliberately skip runtime caching for Supabase — the $lib/sync pending_ops
// queue already handles offline writes and SyncBanner surfaces offline state.

import { precacheAndRoute } from 'workbox-precaching';

declare const self: ServiceWorkerGlobalScope;

precacheAndRoute(self.__WB_MANIFEST);

self.addEventListener('install', () => {
	void self.skipWaiting();
});

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