diff --git a/Build/src/book.js b/Build/src/book.js index 58cc06c..c843e10 100644 --- a/Build/src/book.js +++ b/Build/src/book.js @@ -23,7 +23,15 @@ const tocContainer = document.getElementById('toc-container'); const tocContent = document.getElementById('toc-content'); const viewer = document.getElementById('viewer'); -/***** Book Opening functions *****/ +/** + * Open an EPUB file selected via a file input and load it into the viewer. + * + * Validates the selected file is an EPUB, shows a loading indicator, reads the file + * as an ArrayBuffer, and calls loadBook with the file data. On read/load errors + * it hides the loading indicator and displays an error message. + * + * @param {Event} e - Change event from a file input; the function reads e.target.files[0]. + */ export function openBook(e) { const file = e.target.files[0]; if (!file) return; @@ -50,7 +58,16 @@ export function openBook(e) { } // Immediately close library on click so the user sees the main viewer -// (and the loading spinner) right away +/** + * Open and load an EPUB from a library entry, managing the library UI and loading spinner. + * + * Reads the file from the given library entry (object with an async `getFile()` method), converts it to an ArrayBuffer, + * and delegates to `loadBook` to render the book. Closes the library and shows a loading indicator while loading. + * If an error occurs, the library is reopened and an error message is shown; the function always hides the loading indicator before returning. + * + * @param {Object} entry - Library entry providing an async `getFile()` method that returns a `File`/Blob. + * @return {Promise} Resolves once loading has finished or an error has been handled. + */ export async function openBookFromEntry(entry) { // Close library right away toggleLibrary(false); @@ -68,6 +85,19 @@ export async function openBookFromEntry(entry) { } } +/** + * Load and render an EPUB into the viewer, initialise navigation, and wire up UI and event handlers. + * + * This replaces any currently loaded book, creates a new ePub instance and rendition rendered into the + * viewer element, generates the table of contents and location map, enables navigation controls, + * and registers relocation and keyboard listeners. The relocation handler updates the global + * `currentLocation` and the page input when location data exists. Also attempts to set the visible + * book title from metadata (with fallbacks). + * + * @param {ArrayBuffer|Uint8Array|Blob|string} bookData - EPUB data or URL accepted by epubjs. + * @param {string} [startLocation] - Optional initial location (CFI or href) to display. + * @returns {Promise} A promise that resolves when the rendition's initial display operation completes. + */ async function loadBook(bookData, startLocation) { if (book) { book = null; @@ -109,6 +139,14 @@ async function loadBook(bookData, startLocation) { return displayed; } +/** + * Generate the book's virtual pagination (locations) and update the UI with the total page count. + * + * This async function returns early if no book is loaded. It calls the EPUB book's + * locations.generate(1000) to build location data, stores the resulting locations in the + * module-level `locations` variable, and updates `totalPagesSpan.textContent` with the + * computed number of locations. Errors are caught and logged; the function does not throw. + */ async function generateLocations() { if (!book) return; try { @@ -120,6 +158,18 @@ async function generateLocations() { } } +/** + * Build and render the book's table of contents (TOC) into the UI. + * + * If a book is loaded, asynchronously reads the book's navigation TOC, clears the + * existing TOC container, and creates a clickable entry for each TOC item. + * Clicking an entry displays that location in the rendition and closes the TOC overlay. + * + * Does nothing if no book is loaded. Errors encountered while retrieving or + * rendering the TOC are caught and logged to the console. + * + * @returns {Promise} Resolves when the TOC has been generated and appended to the DOM. + */ async function generateToc() { if (!book) return; try { @@ -140,14 +190,35 @@ async function generateToc() { } } +/** + * Navigate the viewer to the previous page. + * + * If a rendition is active, calls its `prev()` method; otherwise does nothing. + */ export function prevPage() { if (rendition) rendition.prev(); } +/** + * Advance the current rendition to the next page/location. + * + * This is a no-op if no rendition is initialized. + */ export function nextPage() { if (rendition) rendition.next(); } +/** + * Navigate the viewer to the page number entered in the page input field. + * + * Reads a 1-based page number from `currentPageInput.value`, converts it to a + * 0-based location index, validates it against the book's generated locations, + * converts that location index to a CFI using `book.locations.cfiFromLocation`, + * and displays it in the rendition. + * + * No action is taken if there is no loaded book or location data, or if the + * entered page number is out of range or not a valid integer. + */ export function goToPage() { if (!book || !locations) return; const pageNumber = parseInt(currentPageInput.value, 10) - 1; @@ -157,17 +228,31 @@ export function goToPage() { } } +/** + * Handle keyboard navigation: left/right arrow keys move to the previous/next page. + * @param {KeyboardEvent} e - Keyboard event; listens for 'ArrowLeft' to go to the previous page and 'ArrowRight' to go to the next page. + */ function handleKeyEvents(e) { if (!book || !rendition) return; if (e.key === 'ArrowLeft') prevPage(); if (e.key === 'ArrowRight') nextPage(); } +/** + * Toggle the visibility of the table of contents overlay. + * + * Adds or removes the 'open' class on the TOC container and the overlay element to show or hide the table of contents. + */ export function toggleToc() { tocContainer.classList.toggle('open'); overlay.classList.toggle('open'); } +/** + * Close the table of contents overlay. + * + * Removes the 'open' class from the TOC container and the page overlay, hiding the table of contents. + */ export function closeToc() { tocContainer.classList.remove('open'); overlay.classList.remove('open'); diff --git a/Build/src/indexedDB.js b/Build/src/indexedDB.js index 3800d84..7e7f2a4 100644 --- a/Build/src/indexedDB.js +++ b/Build/src/indexedDB.js @@ -1,3 +1,12 @@ +/** + * Open (or create) the IndexedDB database "htmlreader-db" (version 1) and ensure the "handles" object store exists. + * + * Returns a promise that resolves to the opened IDBDatabase instance. During upgrade, an object store named + * "handles" with keyPath "name" is created if missing. The promise rejects with the underlying IndexedDB error + * if opening the database fails. + * + * @return {Promise} Promise resolving to the opened IndexedDB database. + */ function getDB() { return new Promise((resolve, reject) => { const request = indexedDB.open("htmlreader-db", 1); @@ -9,6 +18,12 @@ function getDB() { request.onerror = e => reject(e.target.error); }); } +/** + * Persistently stores the provided library handle in the IndexedDB "handles" object store under the key "library". + * + * @param {*} handle - The library handle to store (e.g., a FileSystem handle or other serializable handle). + * @returns {Promise} Resolves when the handle has been written to the database. Rejects with the underlying error if the database write fails. + */ export async function storeLibraryHandle(handle) { const db = await getDB(); return new Promise((resolve, reject) => { @@ -19,6 +34,15 @@ export async function storeLibraryHandle(handle) { req.onerror = e => reject(e.target.error); }); } +/** + * Retrieve the stored library handle from the "handles" object store. + * + * Returns a Promise that resolves to the stored handle (if present) or null + * when no entry named "library" exists. The Promise rejects with the + * underlying IndexedDB error if the request fails. + * + * @return {Promise} The stored library handle or null. + */ export async function getStoredLibraryHandle() { const db = await getDB(); return new Promise((resolve, reject) => { diff --git a/Build/src/library.js b/Build/src/library.js index 790e7d6..ac4ed97 100644 --- a/Build/src/library.js +++ b/Build/src/library.js @@ -8,6 +8,15 @@ const libraryContainer = document.getElementById('library-container'); const libraryContent = document.getElementById('library-content'); const overlay = document.getElementById('overlay'); +/** + * Open the user's EPUB library: get or prompt for a directory, scan for .epub files, display them, and open the library UI. + * + * Attempts to use a previously stored directory handle; if none is available, prompts the user to pick a directory and stores the handle. + * Scans the directory for files whose names end with ".epub", passes those entries to the library grid renderer, and opens the library overlay. + * On failure, reports a user-facing error via showError; the function catches errors and does not rethrow. + * + * @returns {Promise} Resolves after the library grid is displayed or after an error has been reported. + */ export async function openLibrary() { try { // Try to retrieve stored library directory handle @@ -29,13 +38,26 @@ export async function openLibrary() { showError('Failed to open library: ' + err.message); } } -// Fallback for multiple file selection if directory picker is not available +/** + * Handle a file-input change by displaying selected EPUB files in the library and opening the library UI. + * @param {Event} e - Change event from a file input (``); selected File objects are read and shown in the library grid. + */ export function handleLibraryFiles(e) { const files = Array.from(e.target.files); displayLibraryGrid(files); toggleLibrary(true); } +/** + * Render a grid of EPUB items into the library UI. + * + * Clears the library content area and, for each entry in `fileEntries`, creates + * a library item (cover + title) and appends it to the grid. If `fileEntries` + * is empty, shows a "No EPUB files found." message instead. + * + * @param {Array} fileEntries - Array of file entries to display. Each entry may be a File, FileSystemFileHandle, or similar object accepted by createLibraryItem. + * @return {Promise} + */ async function displayLibraryGrid(fileEntries) { libraryContent.innerHTML = ''; if (fileEntries.length === 0) { @@ -50,6 +72,18 @@ async function displayLibraryGrid(fileEntries) { } } +/** + * Create a DOM element representing an EPUB library item (cover + title) for the given file entry. + * + * The function accepts either a File object or a FileSystemFileHandle (from the File System Access API), + * reads the EPUB to extract a cover image and metadata title when available, and falls back to the + * file name and a generic placeholder cover if not. It attaches a click handler that opens the book + * via openBookFromEntry(fileEntry). Errors while loading cover/metadata are caught and logged; they + * do not prevent the returned element from being used. + * + * @param {File|FileSystemFileHandle} fileEntry - The EPUB file or a handle for the EPUB file. + * @return {HTMLElement} A '.library-item' element containing an image ('.library-cover') and title ('.library-title'). + */ async function createLibraryItem(fileEntry) { const item = document.createElement('div'); item.className = 'library-item'; @@ -93,6 +127,11 @@ async function createLibraryItem(fileEntry) { return item; } +/** + * Open, close, or toggle the library UI. + * + * @param {boolean|undefined} forceOpen - If true, ensures the library is opened; if false, ensures it is closed; if omitted, toggles the current state. + */ export function toggleLibrary(forceOpen) { if (forceOpen === true) { libraryContainer.classList.add('open'); diff --git a/Build/src/main.js b/Build/src/main.js index 81f1126..e6c1640 100644 --- a/Build/src/main.js +++ b/Build/src/main.js @@ -39,17 +39,38 @@ closeErrorButton.addEventListener('click', hideError); // Fallback: multiple file input for library import libraryInput.addEventListener('change', handleLibraryFiles); -/***** Message Functions *****/ +/** + * Show the global loading message/overlay. + * + * Makes the loadingMessage element visible by adding the CSS `show` class. + */ export function showLoading() { loadingMessage.classList.add('show'); } +/** + * Hide the global loading indicator. + * + * Removes the 'show' CSS class from the loading message element to hide the loading UI. + */ export function hideLoading() { loadingMessage.classList.remove('show'); } +/** + * Display an error message in the UI. + * + * Sets the visible error panel's text to `message` and makes the panel visible by adding the `show` class. + * + * @param {string} message - The error text to display to the user. + */ export function showError(message) { errorText.textContent = message; errorMessage.classList.add('show'); } +/** + * Hide the visible error message UI. + * + * Removes the 'show' class from the error message element so the error overlay is hidden. + */ export function hideError() { errorMessage.classList.remove('show'); } diff --git a/workbox-3bd99cbd.js b/workbox-3bd99cbd.js index e5b251d..12e57a7 100644 --- a/workbox-3bd99cbd.js +++ b/workbox-3bd99cbd.js @@ -1,2 +1,70 @@ -define(["exports"],function(t){"use strict";try{self["workbox:core:7.2.0"]&&_()}catch(t){}const e=(t,...e)=>{let s=t;return e.length>0&&(s+=` :: ${JSON.stringify(e)}`),s};class s extends Error{constructor(t,s){super(e(t,s)),this.name=t,this.details=s}}try{self["workbox:routing:7.2.0"]&&_()}catch(t){}const n=t=>t&&"object"==typeof t?t:{handle:t};class r{constructor(t,e,s="GET"){this.handler=n(e),this.match=t,this.method=s}setCatchHandler(t){this.catchHandler=n(t)}}class i extends r{constructor(t,e,s){super(({url:e})=>{const s=t.exec(e.href);if(s&&(e.origin===location.origin||0===s.index))return s.slice(1)},e,s)}}class o{constructor(){this.t=new Map,this.i=new Map}get routes(){return this.t}addFetchListener(){self.addEventListener("fetch",t=>{const{request:e}=t,s=this.handleRequest({request:e,event:t});s&&t.respondWith(s)})}addCacheListener(){self.addEventListener("message",t=>{if(t.data&&"CACHE_URLS"===t.data.type){const{payload:e}=t.data,s=Promise.all(e.urlsToCache.map(e=>{"string"==typeof e&&(e=[e]);const s=new Request(...e);return this.handleRequest({request:s,event:t})}));t.waitUntil(s),t.ports&&t.ports[0]&&s.then(()=>t.ports[0].postMessage(!0))}})}handleRequest({request:t,event:e}){const s=new URL(t.url,location.href);if(!s.protocol.startsWith("http"))return;const n=s.origin===location.origin,{params:r,route:i}=this.findMatchingRoute({event:e,request:t,sameOrigin:n,url:s});let o=i&&i.handler;const a=t.method;if(!o&&this.i.has(a)&&(o=this.i.get(a)),!o)return;let c;try{c=o.handle({url:s,request:t,event:e,params:r})}catch(t){c=Promise.reject(t)}const h=i&&i.catchHandler;return c instanceof Promise&&(this.o||h)&&(c=c.catch(async n=>{if(h)try{return await h.handle({url:s,request:t,event:e,params:r})}catch(t){t instanceof Error&&(n=t)}if(this.o)return this.o.handle({url:s,request:t,event:e});throw n})),c}findMatchingRoute({url:t,sameOrigin:e,request:s,event:n}){const r=this.t.get(s.method)||[];for(const i of r){let r;const o=i.match({url:t,sameOrigin:e,request:s,event:n});if(o)return r=o,(Array.isArray(r)&&0===r.length||o.constructor===Object&&0===Object.keys(o).length||"boolean"==typeof o)&&(r=void 0),{route:i,params:r}}return{}}setDefaultHandler(t,e="GET"){this.i.set(e,n(t))}setCatchHandler(t){this.o=n(t)}registerRoute(t){this.t.has(t.method)||this.t.set(t.method,[]),this.t.get(t.method).push(t)}unregisterRoute(t){if(!this.t.has(t.method))throw new s("unregister-route-but-not-found-with-method",{method:t.method});const e=this.t.get(t.method).indexOf(t);if(!(e>-1))throw new s("unregister-route-route-not-registered");this.t.get(t.method).splice(e,1)}}let a;const c=()=>(a||(a=new o,a.addFetchListener(),a.addCacheListener()),a);function h(t,e,n){let o;if("string"==typeof t){const s=new URL(t,location.href);o=new r(({url:t})=>t.href===s.href,e,n)}else if(t instanceof RegExp)o=new i(t,e,n);else if("function"==typeof t)o=new r(t,e,n);else{if(!(t instanceof r))throw new s("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});o=t}return c().registerRoute(o),o}try{self["workbox:strategies:7.2.0"]&&_()}catch(t){}const u={cacheWillUpdate:async({response:t})=>200===t.status||0===t.status?t:null},l={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!=typeof registration?registration.scope:""},f=t=>[l.prefix,t,l.suffix].filter(t=>t&&t.length>0).join("-"),w=t=>t||f(l.precache),d=t=>t||f(l.runtime);function p(t,e){const s=new URL(t);for(const t of e)s.searchParams.delete(t);return s.href}class y{constructor(){this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}}const g=new Set;function m(t){return"string"==typeof t?new Request(t):t}class R{constructor(t,e){this.h={},Object.assign(this,e),this.event=e.event,this.u=t,this.l=new y,this.p=[],this.m=[...t.plugins],this.R=new Map;for(const t of this.m)this.R.set(t,{});this.event.waitUntil(this.l.promise)}async fetch(t){const{event:e}=this;let n=m(t);if("navigate"===n.mode&&e instanceof FetchEvent&&e.preloadResponse){const t=await e.preloadResponse;if(t)return t}const r=this.hasCallback("fetchDidFail")?n.clone():null;try{for(const t of this.iterateCallbacks("requestWillFetch"))n=await t({request:n.clone(),event:e})}catch(t){if(t instanceof Error)throw new s("plugin-error-request-will-fetch",{thrownErrorMessage:t.message})}const i=n.clone();try{let t;t=await fetch(n,"navigate"===n.mode?void 0:this.u.fetchOptions);for(const s of this.iterateCallbacks("fetchDidSucceed"))t=await s({event:e,request:i,response:t});return t}catch(t){throw r&&await this.runCallbacks("fetchDidFail",{error:t,event:e,originalRequest:r.clone(),request:i.clone()}),t}}async fetchAndCachePut(t){const e=await this.fetch(t),s=e.clone();return this.waitUntil(this.cachePut(t,s)),e}async cacheMatch(t){const e=m(t);let s;const{cacheName:n,matchOptions:r}=this.u,i=await this.getCacheKey(e,"read"),o=Object.assign(Object.assign({},r),{cacheName:n});s=await caches.match(i,o);for(const t of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await t({cacheName:n,matchOptions:r,cachedResponse:s,request:i,event:this.event})||void 0;return s}async cachePut(t,e){const n=m(t);var r;await(r=0,new Promise(t=>setTimeout(t,r)));const i=await this.getCacheKey(n,"write");if(!e)throw new s("cache-put-with-no-response",{url:(o=i.url,new URL(String(o),location.href).href.replace(new RegExp(`^${location.origin}`),""))});var o;const a=await this.v(e);if(!a)return!1;const{cacheName:c,matchOptions:h}=this.u,u=await self.caches.open(c),l=this.hasCallback("cacheDidUpdate"),f=l?await async function(t,e,s,n){const r=p(e.url,s);if(e.url===r)return t.match(e,n);const i=Object.assign(Object.assign({},n),{ignoreSearch:!0}),o=await t.keys(e,i);for(const e of o)if(r===p(e.url,s))return t.match(e,n)}(u,i.clone(),["__WB_REVISION__"],h):null;try{await u.put(i,l?a.clone():a)}catch(t){if(t instanceof Error)throw"QuotaExceededError"===t.name&&await async function(){for(const t of g)await t()}(),t}for(const t of this.iterateCallbacks("cacheDidUpdate"))await t({cacheName:c,oldResponse:f,newResponse:a.clone(),request:i,event:this.event});return!0}async getCacheKey(t,e){const s=`${t.url} | ${e}`;if(!this.h[s]){let n=t;for(const t of this.iterateCallbacks("cacheKeyWillBeUsed"))n=m(await t({mode:e,request:n,event:this.event,params:this.params}));this.h[s]=n}return this.h[s]}hasCallback(t){for(const e of this.u.plugins)if(t in e)return!0;return!1}async runCallbacks(t,e){for(const s of this.iterateCallbacks(t))await s(e)}*iterateCallbacks(t){for(const e of this.u.plugins)if("function"==typeof e[t]){const s=this.R.get(e),n=n=>{const r=Object.assign(Object.assign({},n),{state:s});return e[t](r)};yield n}}waitUntil(t){return this.p.push(t),t}async doneWaiting(){let t;for(;t=this.p.shift();)await t}destroy(){this.l.resolve(null)}async v(t){let e=t,s=!1;for(const t of this.iterateCallbacks("cacheWillUpdate"))if(e=await t({request:this.request,response:e,event:this.event})||void 0,s=!0,!e)break;return s||e&&200!==e.status&&(e=void 0),e}}class v{constructor(t={}){this.cacheName=d(t.cacheName),this.plugins=t.plugins||[],this.fetchOptions=t.fetchOptions,this.matchOptions=t.matchOptions}handle(t){const[e]=this.handleAll(t);return e}handleAll(t){t instanceof FetchEvent&&(t={event:t,request:t.request});const e=t.event,s="string"==typeof t.request?new Request(t.request):t.request,n="params"in t?t.params:void 0,r=new R(this,{event:e,request:s,params:n}),i=this.q(r,s,e);return[i,this.U(i,r,s,e)]}async q(t,e,n){let r;await t.runCallbacks("handlerWillStart",{event:n,request:e});try{if(r=await this.L(e,t),!r||"error"===r.type)throw new s("no-response",{url:e.url})}catch(s){if(s instanceof Error)for(const i of t.iterateCallbacks("handlerDidError"))if(r=await i({error:s,event:n,request:e}),r)break;if(!r)throw s}for(const s of t.iterateCallbacks("handlerWillRespond"))r=await s({event:n,request:e,response:r});return r}async U(t,e,s,n){let r,i;try{r=await t}catch(i){}try{await e.runCallbacks("handlerDidRespond",{event:n,request:s,response:r}),await e.doneWaiting()}catch(t){t instanceof Error&&(i=t)}if(await e.runCallbacks("handlerDidComplete",{event:n,request:s,response:r,error:i}),e.destroy(),i)throw i}}function q(t,e){const s=e();return t.waitUntil(s),s}try{self["workbox:precaching:7.2.0"]&&_()}catch(t){}function U(t){if(!t)throw new s("add-to-cache-list-unexpected-type",{entry:t});if("string"==typeof t){const e=new URL(t,location.href);return{cacheKey:e.href,url:e.href}}const{revision:e,url:n}=t;if(!n)throw new s("add-to-cache-list-unexpected-type",{entry:t});if(!e){const t=new URL(n,location.href);return{cacheKey:t.href,url:t.href}}const r=new URL(n,location.href),i=new URL(n,location.href);return r.searchParams.set("__WB_REVISION__",e),{cacheKey:r.href,url:i.href}}class L{constructor(){this.updatedURLs=[],this.notUpdatedURLs=[],this.handlerWillStart=async({request:t,state:e})=>{e&&(e.originalRequest=t)},this.cachedResponseWillBeUsed=async({event:t,state:e,cachedResponse:s})=>{if("install"===t.type&&e&&e.originalRequest&&e.originalRequest instanceof Request){const t=e.originalRequest.url;s?this.notUpdatedURLs.push(t):this.updatedURLs.push(t)}return s}}}class b{constructor({precacheController:t}){this.cacheKeyWillBeUsed=async({request:t,params:e})=>{const s=(null==e?void 0:e.cacheKey)||this._.getCacheKeyForURL(t.url);return s?new Request(s,{headers:t.headers}):t},this._=t}}let E,x;async function C(t,e){let n=null;if(t.url){n=new URL(t.url).origin}if(n!==self.location.origin)throw new s("cross-origin-copy-response",{origin:n});const r=t.clone(),i={headers:new Headers(r.headers),status:r.status,statusText:r.statusText},o=e?e(i):i,a=function(){if(void 0===E){const t=new Response("");if("body"in t)try{new Response(t.body),E=!0}catch(t){E=!1}E=!1}return E}()?r.body:await r.blob();return new Response(a,o)}class O extends v{constructor(t={}){t.cacheName=w(t.cacheName),super(t),this.C=!1!==t.fallbackToNetwork,this.plugins.push(O.copyRedirectedCacheableResponsesPlugin)}async L(t,e){const s=await e.cacheMatch(t);return s||(e.event&&"install"===e.event.type?await this.O(t,e):await this.N(t,e))}async N(t,e){let n;const r=e.params||{};if(!this.C)throw new s("missing-precache-entry",{cacheName:this.cacheName,url:t.url});{const s=r.integrity,i=t.integrity,o=!i||i===s;n=await e.fetch(new Request(t,{integrity:"no-cors"!==t.mode?i||s:void 0})),s&&o&&"no-cors"!==t.mode&&(this.P(),await e.cachePut(t,n.clone()))}return n}async O(t,e){this.P();const n=await e.fetch(t);if(!await e.cachePut(t,n.clone()))throw new s("bad-precaching-response",{url:t.url,status:n.status});return n}P(){let t=null,e=0;for(const[s,n]of this.plugins.entries())n!==O.copyRedirectedCacheableResponsesPlugin&&(n===O.defaultPrecacheCacheabilityPlugin&&(t=s),n.cacheWillUpdate&&e++);0===e?this.plugins.push(O.defaultPrecacheCacheabilityPlugin):e>1&&null!==t&&this.plugins.splice(t,1)}}O.defaultPrecacheCacheabilityPlugin={cacheWillUpdate:async({response:t})=>!t||t.status>=400?null:t},O.copyRedirectedCacheableResponsesPlugin={cacheWillUpdate:async({response:t})=>t.redirected?await C(t):t};class N{constructor({cacheName:t,plugins:e=[],fallbackToNetwork:s=!0}={}){this.T=new Map,this.W=new Map,this.k=new Map,this.u=new O({cacheName:w(t),plugins:[...e,new b({precacheController:this})],fallbackToNetwork:s}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this.u}precache(t){this.addToCacheList(t),this.K||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this.K=!0)}addToCacheList(t){const e=[];for(const n of t){"string"==typeof n?e.push(n):n&&void 0===n.revision&&e.push(n.url);const{cacheKey:t,url:r}=U(n),i="string"!=typeof n&&n.revision?"reload":"default";if(this.T.has(r)&&this.T.get(r)!==t)throw new s("add-to-cache-list-conflicting-entries",{firstEntry:this.T.get(r),secondEntry:t});if("string"!=typeof n&&n.integrity){if(this.k.has(t)&&this.k.get(t)!==n.integrity)throw new s("add-to-cache-list-conflicting-integrities",{url:r});this.k.set(t,n.integrity)}if(this.T.set(r,t),this.W.set(r,i),e.length>0){const t=`Workbox is precaching URLs without revision info: ${e.join(", ")}\nThis is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(t)}}}install(t){return q(t,async()=>{const e=new L;this.strategy.plugins.push(e);for(const[e,s]of this.T){const n=this.k.get(s),r=this.W.get(e),i=new Request(e,{integrity:n,cache:r,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:s},request:i,event:t}))}const{updatedURLs:s,notUpdatedURLs:n}=e;return{updatedURLs:s,notUpdatedURLs:n}})}activate(t){return q(t,async()=>{const t=await self.caches.open(this.strategy.cacheName),e=await t.keys(),s=new Set(this.T.values()),n=[];for(const r of e)s.has(r.url)||(await t.delete(r),n.push(r.url));return{deletedURLs:n}})}getURLsToCacheKeys(){return this.T}getCachedURLs(){return[...this.T.keys()]}getCacheKeyForURL(t){const e=new URL(t,location.href);return this.T.get(e.href)}getIntegrityForCacheKey(t){return this.k.get(t)}async matchPrecache(t){const e=t instanceof Request?t.url:t,s=this.getCacheKeyForURL(e);if(s){return(await self.caches.open(this.strategy.cacheName)).match(s)}}createHandlerBoundToURL(t){const e=this.getCacheKeyForURL(t);if(!e)throw new s("non-precached-url",{url:t});return s=>(s.request=new Request(t),s.params=Object.assign({cacheKey:e},s.params),this.strategy.handle(s))}}const P=()=>(x||(x=new N),x);class T extends r{constructor(t,e){super(({request:s})=>{const n=t.getURLsToCacheKeys();for(const r of function*(t,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:s="index.html",cleanURLs:n=!0,urlManipulation:r}={}){const i=new URL(t,location.href);i.hash="",yield i.href;const o=function(t,e=[]){for(const s of[...t.searchParams.keys()])e.some(t=>t.test(s))&&t.searchParams.delete(s);return t}(i,e);if(yield o.href,s&&o.pathname.endsWith("/")){const t=new URL(o.href);t.pathname+=s,yield t.href}if(n){const t=new URL(o.href);t.pathname+=".html",yield t.href}if(r){const t=r({url:i});for(const e of t)yield e.href}}(s.url,e)){const e=n.get(r);if(e){return{cacheKey:e,integrity:t.getIntegrityForCacheKey(e)}}}},t.strategy)}}t.CacheFirst=class extends v{async L(t,e){let n,r=await e.cacheMatch(t);if(!r)try{r=await e.fetchAndCachePut(t)}catch(t){t instanceof Error&&(n=t)}if(!r)throw new s("no-response",{url:t.url,error:n});return r}},t.NavigationRoute=class extends r{constructor(t,{allowlist:e=[/./],denylist:s=[]}={}){super(t=>this.j(t),t),this.M=e,this.S=s}j({url:t,request:e}){if(e&&"navigate"!==e.mode)return!1;const s=t.pathname+t.search;for(const t of this.S)if(t.test(s))return!1;return!!this.M.some(t=>t.test(s))}},t.NetworkFirst=class extends v{constructor(t={}){super(t),this.plugins.some(t=>"cacheWillUpdate"in t)||this.plugins.unshift(u),this.D=t.networkTimeoutSeconds||0}async L(t,e){const n=[],r=[];let i;if(this.D){const{id:s,promise:o}=this.I({request:t,logs:n,handler:e});i=s,r.push(o)}const o=this.F({timeoutId:i,request:t,logs:n,handler:e});r.push(o);const a=await e.waitUntil((async()=>await e.waitUntil(Promise.race(r))||await o)());if(!a)throw new s("no-response",{url:t.url});return a}I({request:t,logs:e,handler:s}){let n;return{promise:new Promise(e=>{n=setTimeout(async()=>{e(await s.cacheMatch(t))},1e3*this.D)}),id:n}}async F({timeoutId:t,request:e,logs:s,handler:n}){let r,i;try{i=await n.fetchAndCachePut(e)}catch(t){t instanceof Error&&(r=t)}return t&&clearTimeout(t),!r&&i||(i=await n.cacheMatch(e)),i}},t.cleanupOutdatedCaches=function(){self.addEventListener("activate",t=>{const e=w();t.waitUntil((async(t,e="-precache-")=>{const s=(await self.caches.keys()).filter(s=>s.includes(e)&&s.includes(self.registration.scope)&&s!==t);return await Promise.all(s.map(t=>self.caches.delete(t))),s})(e).then(t=>{}))})},t.clientsClaim=function(){self.addEventListener("activate",()=>self.clients.claim())},t.createHandlerBoundToURL=function(t){return P().createHandlerBoundToURL(t)},t.precacheAndRoute=function(t,e){!function(t){P().precache(t)}(t),function(t){const e=P();h(new T(e,t))}(e)},t.registerRoute=h}); +define(["exports"],function(t){"use strict";try{self["workbox:core:7.2.0"]&&_()}catch(t){}const e=(t,...e)=>{let s=t;return e.length>0&&(s+=` :: ${JSON.stringify(e)}`),s};class s extends Error{constructor(t,s){super(e(t,s)),this.name=t,this.details=s}}try{self["workbox:routing:7.2.0"]&&_()}catch(t){}const n=t=>t&&"object"==typeof t?t:{handle:t};class r{constructor(t,e,s="GET"){this.handler=n(e),this.match=t,this.method=s}setCatchHandler(t){this.catchHandler=n(t)}}class i extends r{constructor(t,e,s){super(({url:e})=>{const s=t.exec(e.href);if(s&&(e.origin===location.origin||0===s.index))return s.slice(1)},e,s)}}class o{constructor(){this.t=new Map,this.i=new Map}get routes(){return this.t}addFetchListener(){self.addEventListener("fetch",t=>{const{request:e}=t,s=this.handleRequest({request:e,event:t});s&&t.respondWith(s)})}addCacheListener(){self.addEventListener("message",t=>{if(t.data&&"CACHE_URLS"===t.data.type){const{payload:e}=t.data,s=Promise.all(e.urlsToCache.map(e=>{"string"==typeof e&&(e=[e]);const s=new Request(...e);return this.handleRequest({request:s,event:t})}));t.waitUntil(s),t.ports&&t.ports[0]&&s.then(()=>t.ports[0].postMessage(!0))}})}handleRequest({request:t,event:e}){const s=new URL(t.url,location.href);if(!s.protocol.startsWith("http"))return;const n=s.origin===location.origin,{params:r,route:i}=this.findMatchingRoute({event:e,request:t,sameOrigin:n,url:s});let o=i&&i.handler;const a=t.method;if(!o&&this.i.has(a)&&(o=this.i.get(a)),!o)return;let c;try{c=o.handle({url:s,request:t,event:e,params:r})}catch(t){c=Promise.reject(t)}const h=i&&i.catchHandler;return c instanceof Promise&&(this.o||h)&&(c=c.catch(async n=>{if(h)try{return await h.handle({url:s,request:t,event:e,params:r})}catch(t){t instanceof Error&&(n=t)}if(this.o)return this.o.handle({url:s,request:t,event:e});throw n})),c}findMatchingRoute({url:t,sameOrigin:e,request:s,event:n}){const r=this.t.get(s.method)||[];for(const i of r){let r;const o=i.match({url:t,sameOrigin:e,request:s,event:n});if(o)return r=o,(Array.isArray(r)&&0===r.length||o.constructor===Object&&0===Object.keys(o).length||"boolean"==typeof o)&&(r=void 0),{route:i,params:r}}return{}}setDefaultHandler(t,e="GET"){this.i.set(e,n(t))}setCatchHandler(t){this.o=n(t)}registerRoute(t){this.t.has(t.method)||this.t.set(t.method,[]),this.t.get(t.method).push(t)}unregisterRoute(t){if(!this.t.has(t.method))throw new s("unregister-route-but-not-found-with-method",{method:t.method});const e=this.t.get(t.method).indexOf(t);if(!(e>-1))throw new s("unregister-route-route-not-registered");this.t.get(t.method).splice(e,1)}}let a;const c=()=>(a||(a=new o,a.addFetchListener(),a.addCacheListener()),a);/** + * Create and register a route from a variety of route descriptors. + * + * Accepts a string URL, RegExp, function, or an existing Route instance: + * - string: creates a Route that matches requests whose URL exactly equals the provided URL. + * - RegExp: creates a RegExp-based Route that matches captured groups. + * - function: uses the function as the Route match callback. + * - Route instance: registers the instance directly. + * + * @param {string|RegExp|function|r} t - Route descriptor: a URL string, RegExp, match function, or Route instance. + * @param {*} e - Handler for the route (a value accepted by the Route constructor / descriptor). + * @param {string} [n] - Optional HTTP method for the route (e.g., "GET"); if omitted the Route's default is used. + * @returns {r} The registered Route instance. + * @throws {s} If `t` is not a supported route type an `unsupported-route-type` Workbox error is thrown. + */ +function h(t,e,n){let o;if("string"==typeof t){const s=new URL(t,location.href);o=new r(({url:t})=>t.href===s.href,e,n)}else if(t instanceof RegExp)o=new i(t,e,n);else if("function"==typeof t)o=new r(t,e,n);else{if(!(t instanceof r))throw new s("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});o=t}return c().registerRoute(o),o}try{self["workbox:strategies:7.2.0"]&&_()}catch(t){}const u={cacheWillUpdate:async({response:t})=>200===t.status||0===t.status?t:null},l={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!=typeof registration?registration.scope:""},f=t=>[l.prefix,t,l.suffix].filter(t=>t&&t.length>0).join("-"),w=t=>t||f(l.precache),d=t=>t||f(l.runtime);/** + * Return the input URL as a string with the given query parameter names removed. + * @param {string|URL} t - The input URL (string or URL). + * @param {Iterable} e - Iterable of query parameter names to delete. + * @return {string} The resulting URL href with the specified query parameters removed. + */ +function p(t,e){const s=new URL(t);for(const t of e)s.searchParams.delete(t);return s.href}class y{constructor(){this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}}const g=new Set;/** + * Normalize an input to a Request object. + * + * If given a URL string, returns a new Request constructed from that URL. + * If given a Request, returns it unchanged. + * + * @param {string|Request} t - A URL string or an existing Request. + * @return {Request} A Request instance. + */ +function m(t){return"string"==typeof t?new Request(t):t}class R{constructor(t,e){this.h={},Object.assign(this,e),this.event=e.event,this.u=t,this.l=new y,this.p=[],this.m=[...t.plugins],this.R=new Map;for(const t of this.m)this.R.set(t,{});this.event.waitUntil(this.l.promise)}async fetch(t){const{event:e}=this;let n=m(t);if("navigate"===n.mode&&e instanceof FetchEvent&&e.preloadResponse){const t=await e.preloadResponse;if(t)return t}const r=this.hasCallback("fetchDidFail")?n.clone():null;try{for(const t of this.iterateCallbacks("requestWillFetch"))n=await t({request:n.clone(),event:e})}catch(t){if(t instanceof Error)throw new s("plugin-error-request-will-fetch",{thrownErrorMessage:t.message})}const i=n.clone();try{let t;t=await fetch(n,"navigate"===n.mode?void 0:this.u.fetchOptions);for(const s of this.iterateCallbacks("fetchDidSucceed"))t=await s({event:e,request:i,response:t});return t}catch(t){throw r&&await this.runCallbacks("fetchDidFail",{error:t,event:e,originalRequest:r.clone(),request:i.clone()}),t}}async fetchAndCachePut(t){const e=await this.fetch(t),s=e.clone();return this.waitUntil(this.cachePut(t,s)),e}async cacheMatch(t){const e=m(t);let s;const{cacheName:n,matchOptions:r}=this.u,i=await this.getCacheKey(e,"read"),o=Object.assign(Object.assign({},r),{cacheName:n});s=await caches.match(i,o);for(const t of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await t({cacheName:n,matchOptions:r,cachedResponse:s,request:i,event:this.event})||void 0;return s}async cachePut(t,e){const n=m(t);var r;await(r=0,new Promise(t=>setTimeout(t,r)));const i=await this.getCacheKey(n,"write");if(!e)throw new s("cache-put-with-no-response",{url:(o=i.url,new URL(String(o),location.href).href.replace(new RegExp(`^${location.origin}`),""))});var o;const a=await this.v(e);if(!a)return!1;const{cacheName:c,matchOptions:h}=this.u,u=await self.caches.open(c),l=this.hasCallback("cacheDidUpdate"),f=l?await async function(t,e,s,n){const r=p(e.url,s);if(e.url===r)return t.match(e,n);const i=Object.assign(Object.assign({},n),{ignoreSearch:!0}),o=await t.keys(e,i);for(const e of o)if(r===p(e.url,s))return t.match(e,n)}(u,i.clone(),["__WB_REVISION__"],h):null;try{await u.put(i,l?a.clone():a)}catch(t){if(t instanceof Error)throw"QuotaExceededError"===t.name&&await async function(){for(const t of g)await t()}(),t}for(const t of this.iterateCallbacks("cacheDidUpdate"))await t({cacheName:c,oldResponse:f,newResponse:a.clone(),request:i,event:this.event});return!0}async getCacheKey(t,e){const s=`${t.url} | ${e}`;if(!this.h[s]){let n=t;for(const t of this.iterateCallbacks("cacheKeyWillBeUsed"))n=m(await t({mode:e,request:n,event:this.event,params:this.params}));this.h[s]=n}return this.h[s]}hasCallback(t){for(const e of this.u.plugins)if(t in e)return!0;return!1}async runCallbacks(t,e){for(const s of this.iterateCallbacks(t))await s(e)}*iterateCallbacks(t){for(const e of this.u.plugins)if("function"==typeof e[t]){const s=this.R.get(e),n=n=>{const r=Object.assign(Object.assign({},n),{state:s});return e[t](r)};yield n}}waitUntil(t){return this.p.push(t),t}async doneWaiting(){let t;for(;t=this.p.shift();)await t}destroy(){this.l.resolve(null)}async v(t){let e=t,s=!1;for(const t of this.iterateCallbacks("cacheWillUpdate"))if(e=await t({request:this.request,response:e,event:this.event})||void 0,s=!0,!e)break;return s||e&&200!==e.status&&(e=void 0),e}}class v{constructor(t={}){this.cacheName=d(t.cacheName),this.plugins=t.plugins||[],this.fetchOptions=t.fetchOptions,this.matchOptions=t.matchOptions}handle(t){const[e]=this.handleAll(t);return e}handleAll(t){t instanceof FetchEvent&&(t={event:t,request:t.request});const e=t.event,s="string"==typeof t.request?new Request(t.request):t.request,n="params"in t?t.params:void 0,r=new R(this,{event:e,request:s,params:n}),i=this.q(r,s,e);return[i,this.U(i,r,s,e)]}async q(t,e,n){let r;await t.runCallbacks("handlerWillStart",{event:n,request:e});try{if(r=await this.L(e,t),!r||"error"===r.type)throw new s("no-response",{url:e.url})}catch(s){if(s instanceof Error)for(const i of t.iterateCallbacks("handlerDidError"))if(r=await i({error:s,event:n,request:e}),r)break;if(!r)throw s}for(const s of t.iterateCallbacks("handlerWillRespond"))r=await s({event:n,request:e,response:r});return r}async U(t,e,s,n){let r,i;try{r=await t}catch(i){}try{await e.runCallbacks("handlerDidRespond",{event:n,request:s,response:r}),await e.doneWaiting()}catch(t){t instanceof Error&&(i=t)}if(await e.runCallbacks("handlerDidComplete",{event:n,request:s,response:r,error:i}),e.destroy(),i)throw i}}/** + * Calls the provided factory to obtain a promise, registers it with the event via waitUntil, and returns it. + * @param {ExtendableEvent} event - Event object with a waitUntil(promise) method. + * @param {function(): Promise} promiseFactory - Function that returns the promise to be awaited. + * @return {Promise} The promise produced by the factory. + */ +function q(t,e){const s=e();return t.waitUntil(s),s}try{self["workbox:precaching:7.2.0"]&&_()}catch(t){}/** + * Normalizes a precache entry into a {cacheKey, url} pair. + * + * Accepts either a URL string or an object with a `url` property and an optional + * `revision` string. If `revision` is provided the `cacheKey` is the URL with + * a `__WB_REVISION__` query parameter set to that revision; otherwise the + * `cacheKey` is the URL itself. The `url` returned is always the resolved + * absolute URL without the injected revision query parameter. + * + * @param {string|Object} entry - A URL string or an entry object {url, revision?}. + * @return {{cacheKey: string, url: string}} Resolved absolute `cacheKey` and `url`. + * @throws {Error} Throws a Workbox error "add-to-cache-list-unexpected-type" when + * `entry` is falsy or an object missing a `url` property. + */ +function U(t){if(!t)throw new s("add-to-cache-list-unexpected-type",{entry:t});if("string"==typeof t){const e=new URL(t,location.href);return{cacheKey:e.href,url:e.href}}const{revision:e,url:n}=t;if(!n)throw new s("add-to-cache-list-unexpected-type",{entry:t});if(!e){const t=new URL(n,location.href);return{cacheKey:t.href,url:t.href}}const r=new URL(n,location.href),i=new URL(n,location.href);return r.searchParams.set("__WB_REVISION__",e),{cacheKey:r.href,url:i.href}}class L{constructor(){this.updatedURLs=[],this.notUpdatedURLs=[],this.handlerWillStart=async({request:t,state:e})=>{e&&(e.originalRequest=t)},this.cachedResponseWillBeUsed=async({event:t,state:e,cachedResponse:s})=>{if("install"===t.type&&e&&e.originalRequest&&e.originalRequest instanceof Request){const t=e.originalRequest.url;s?this.notUpdatedURLs.push(t):this.updatedURLs.push(t)}return s}}}class b{constructor({precacheController:t}){this.cacheKeyWillBeUsed=async({request:t,params:e})=>{const s=(null==e?void 0:e.cacheKey)||this._.getCacheKeyForURL(t.url);return s?new Request(s,{headers:t.headers}):t},this._=t}}let E,x;/** + * Create a same-origin copy of a Response, optionally allowing modification of response init. + * + * If the input Response is from a different origin than the service worker (self.location.origin), + * this function throws a `s` error with name "cross-origin-copy-response". + * + * The function attempts to reuse the original response body stream when the platform supports + * constructing a new Response from an existing Response body; otherwise it falls back to reading + * the body as a Blob. The optional `initTransformer` can adjust headers/status/statusText used + * for the created copy. + * + * @param {Response} t - The response to copy. Must be same-origin (t.url === self.location.origin). + * @param {(init: {headers: Headers, status: number, statusText: string}) => {headers: Headers, status: number, statusText: string}|void} [e] + * Optional transformer called with a mutable-ish init object; return value (if any) is used + * as the response init for the copied Response. + * @returns {Promise} A promise that resolves to the new Response copy. + * @throws {s} If the response's origin differs from self.location.origin (error name "cross-origin-copy-response"). + */ +async function C(t,e){let n=null;if(t.url){n=new URL(t.url).origin}if(n!==self.location.origin)throw new s("cross-origin-copy-response",{origin:n});const r=t.clone(),i={headers:new Headers(r.headers),status:r.status,statusText:r.statusText},o=e?e(i):i,a=function(){if(void 0===E){const t=new Response("");if("body"in t)try{new Response(t.body),E=!0}catch(t){E=!1}E=!1}return E}()?r.body:await r.blob();return new Response(a,o)}class O extends v{constructor(t={}){t.cacheName=w(t.cacheName),super(t),this.C=!1!==t.fallbackToNetwork,this.plugins.push(O.copyRedirectedCacheableResponsesPlugin)}async L(t,e){const s=await e.cacheMatch(t);return s||(e.event&&"install"===e.event.type?await this.O(t,e):await this.N(t,e))}async N(t,e){let n;const r=e.params||{};if(!this.C)throw new s("missing-precache-entry",{cacheName:this.cacheName,url:t.url});{const s=r.integrity,i=t.integrity,o=!i||i===s;n=await e.fetch(new Request(t,{integrity:"no-cors"!==t.mode?i||s:void 0})),s&&o&&"no-cors"!==t.mode&&(this.P(),await e.cachePut(t,n.clone()))}return n}async O(t,e){this.P();const n=await e.fetch(t);if(!await e.cachePut(t,n.clone()))throw new s("bad-precaching-response",{url:t.url,status:n.status});return n}P(){let t=null,e=0;for(const[s,n]of this.plugins.entries())n!==O.copyRedirectedCacheableResponsesPlugin&&(n===O.defaultPrecacheCacheabilityPlugin&&(t=s),n.cacheWillUpdate&&e++);0===e?this.plugins.push(O.defaultPrecacheCacheabilityPlugin):e>1&&null!==t&&this.plugins.splice(t,1)}}O.defaultPrecacheCacheabilityPlugin={cacheWillUpdate:async({response:t})=>!t||t.status>=400?null:t},O.copyRedirectedCacheableResponsesPlugin={cacheWillUpdate:async({response:t})=>t.redirected?await C(t):t};class N{constructor({cacheName:t,plugins:e=[],fallbackToNetwork:s=!0}={}){this.T=new Map,this.W=new Map,this.k=new Map,this.u=new O({cacheName:w(t),plugins:[...e,new b({precacheController:this})],fallbackToNetwork:s}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this.u}precache(t){this.addToCacheList(t),this.K||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this.K=!0)}addToCacheList(t){const e=[];for(const n of t){"string"==typeof n?e.push(n):n&&void 0===n.revision&&e.push(n.url);const{cacheKey:t,url:r}=U(n),i="string"!=typeof n&&n.revision?"reload":"default";if(this.T.has(r)&&this.T.get(r)!==t)throw new s("add-to-cache-list-conflicting-entries",{firstEntry:this.T.get(r),secondEntry:t});if("string"!=typeof n&&n.integrity){if(this.k.has(t)&&this.k.get(t)!==n.integrity)throw new s("add-to-cache-list-conflicting-integrities",{url:r});this.k.set(t,n.integrity)}if(this.T.set(r,t),this.W.set(r,i),e.length>0){const t=`Workbox is precaching URLs without revision info: ${e.join(", ")}\nThis is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(t)}}}install(t){return q(t,async()=>{const e=new L;this.strategy.plugins.push(e);for(const[e,s]of this.T){const n=this.k.get(s),r=this.W.get(e),i=new Request(e,{integrity:n,cache:r,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:s},request:i,event:t}))}const{updatedURLs:s,notUpdatedURLs:n}=e;return{updatedURLs:s,notUpdatedURLs:n}})}activate(t){return q(t,async()=>{const t=await self.caches.open(this.strategy.cacheName),e=await t.keys(),s=new Set(this.T.values()),n=[];for(const r of e)s.has(r.url)||(await t.delete(r),n.push(r.url));return{deletedURLs:n}})}getURLsToCacheKeys(){return this.T}getCachedURLs(){return[...this.T.keys()]}getCacheKeyForURL(t){const e=new URL(t,location.href);return this.T.get(e.href)}getIntegrityForCacheKey(t){return this.k.get(t)}async matchPrecache(t){const e=t instanceof Request?t.url:t,s=this.getCacheKeyForURL(e);if(s){return(await self.caches.open(this.strategy.cacheName)).match(s)}}createHandlerBoundToURL(t){const e=this.getCacheKeyForURL(t);if(!e)throw new s("non-precached-url",{url:t});return s=>(s.request=new Request(t),s.params=Object.assign({cacheKey:e},s.params),this.strategy.handle(s))}}const P=()=>(x||(x=new N),x);class T extends r{constructor(t,e){super(({request:s})=>{const n=t.getURLsToCacheKeys();for(const r of function*(t,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:s="index.html",cleanURLs:n=!0,urlManipulation:r}={}){const i=new URL(t,location.href);i.hash="",yield i.href;const o=function(t,e=[]){for(const s of[...t.searchParams.keys()])e.some(t=>t.test(s))&&t.searchParams.delete(s);return t}(i,e);if(yield o.href,s&&o.pathname.endsWith("/")){const t=new URL(o.href);t.pathname+=s,yield t.href}if(n){const t=new URL(o.href);t.pathname+=".html",yield t.href}if(r){const t=r({url:i});for(const e of t)yield e.href}}(s.url,e)){const e=n.get(r);if(e){return{cacheKey:e,integrity:t.getIntegrityForCacheKey(e)}}}},t.strategy)}}t.CacheFirst=class extends v{async L(t,e){let n,r=await e.cacheMatch(t);if(!r)try{r=await e.fetchAndCachePut(t)}catch(t){t instanceof Error&&(n=t)}if(!r)throw new s("no-response",{url:t.url,error:n});return r}},t.NavigationRoute=class extends r{constructor(t,{allowlist:e=[/./],denylist:s=[]}={}){super(t=>this.j(t),t),this.M=e,this.S=s}j({url:t,request:e}){if(e&&"navigate"!==e.mode)return!1;const s=t.pathname+t.search;for(const t of this.S)if(t.test(s))return!1;return!!this.M.some(t=>t.test(s))}},t.NetworkFirst=class extends v{constructor(t={}){super(t),this.plugins.some(t=>"cacheWillUpdate"in t)||this.plugins.unshift(u),this.D=t.networkTimeoutSeconds||0}async L(t,e){const n=[],r=[];let i;if(this.D){const{id:s,promise:o}=this.I({request:t,logs:n,handler:e});i=s,r.push(o)}const o=this.F({timeoutId:i,request:t,logs:n,handler:e});r.push(o);const a=await e.waitUntil((async()=>await e.waitUntil(Promise.race(r))||await o)());if(!a)throw new s("no-response",{url:t.url});return a}I({request:t,logs:e,handler:s}){let n;return{promise:new Promise(e=>{n=setTimeout(async()=>{e(await s.cacheMatch(t))},1e3*this.D)}),id:n}}async F({timeoutId:t,request:e,logs:s,handler:n}){let r,i;try{i=await n.fetchAndCachePut(e)}catch(t){t instanceof Error&&(r=t)}return t&&clearTimeout(t),!r&&i||(i=await n.cacheMatch(e)),i}},t.cleanupOutdatedCaches=function(){self.addEventListener("activate",t=>{const e=w();t.waitUntil((async(t,e="-precache-")=>{const s=(await self.caches.keys()).filter(s=>s.includes(e)&&s.includes(self.registration.scope)&&s!==t);return await Promise.all(s.map(t=>self.caches.delete(t))),s})(e).then(t=>{}))})},t.clientsClaim=function(){self.addEventListener("activate",()=>self.clients.claim())},t.createHandlerBoundToURL=function(t){return P().createHandlerBoundToURL(t)},t.precacheAndRoute=function(t,e){!function(t){P().precache(t)}(t),function(t){const e=P();h(new T(e,t))}(e)},t.registerRoute=h}); //# sourceMappingURL=workbox-3bd99cbd.js.map