const CACHE='ep-mail-v22'; const FILES=['./','./index.html','./styles.css','./branding.css','./renderer-state.js','./mail-content-security.js','./renderer-mail-api.js','./app.js','./platform-bridge-loader.js','./platform-bridge.js','./mail-ui.js','./productivity.js','./snooze-ui.js','./account-ui.js','./dav-ui.js','./shortcuts.js','./attachments.js','./pgp-ui.js','./pgp-mail-ui.js','./manifest.webmanifest','./icon.svg','./logo-ep-daylight.svg','./logo-ep-wasteland.svg']; self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES)).then(()=>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()))); self.addEventListener('fetch', event => { const request = event.request; if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return; event.respondWith((async () => { let response; try { response = await fetch(request, { cache: 'no-cache' }); } catch (error) { const cached = await caches.match(request) || (request.mode === 'navigate' ? await caches.match('./index.html') : null); if (cached) return cached; throw error; } if (response.ok) { try { const cache = await caches.open(CACHE); await cache.put(request, response.clone()); } catch (error) { console.error('Could not update offline app cache:', error); } } return response; })()); });