sw.js 51.5 KB
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)r.d(n,s,function(t){return e[t]}.bind(null,s));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";r(1);var n=o(r(2)),s=o(r(3));function o(e){return e&&e.__esModule?e:{default:e}}var a=["boys","girls","kids","lifestyle","cate","list","search","product","shop","guang"],i={customCacheUrl:[/^https:\/\/(.*)cdn\.yoho\.cn/i],precachePage:["/offline.html"],precacheStaticFile:["/index.css","/common.css","/libs.js","/font/iconfont.woff","/common.offline.js","/common.offline.css"],precacheCdnStaticFile:["https://cdn.yoho.cn/pwa/404.png"]},c=(0,s.default)(self.location.search.substr(1)),h=new n.default({clientsClaim:!0,skipWaiting:!0}),u=h.strategies.cacheFirst({cacheableResponse:{statuses:[0,200]},cacheExpiration:{maxEntries:1e3,maxAgeSeconds:604800}}),l=[{url:"/sw.js?t="+c.t+"&staticServer="+c.staticServer}].concat(i.precacheStaticFile.map(function(e){return{url:self.location.protocol+c.staticServer+e+"?t="+c.t}})).concat(i.precachePage.map(function(e){return{url:e+"?t="+c.t}})).concat(i.precacheCdnStaticFile.map(function(e){return{url:e}}));h.precache(l),i.customCacheUrl.forEach(function(e){h.router.registerRoute(e,u)}),h.router.registerRoute(function(e){var t=!1,r=new RegExp("^/("+a.join("|")+")");return/^https:\/\/m.yohobuy.com/.test(e.url.href)&&(r.test(e.url.pathname)||"/"===e.url.pathname)&&(t=!0),"XMLHttpRequest"===e.event.request.headers.get("x-requested-with")&&(t=!1),t},function(e){return h.strategies.networkFirst({cacheExpiration:{maxEntries:300,maxAgeSeconds:43200}}).handle(e).then(function(t){return t||"navigate"!==e.event.request.mode?t:caches.match("offline.html?t="+c.t)})}),h.router.registerRoute(function(e){var t=!1;return/image\/webp/i.test(e.event.request.headers.get("Accept"))?(/^https:\/\/(.*)static\.yhbimg\.com(.*)(png|jpg|jpeg)\?(imageView|imageMogr)(.*)/.test(e.url.href)&&/^(?!.*format\/).*/.test(e.url.href)&&(t=!0),t):t},function(e){return e.event=new FetchEvent(e.event.type,{request:new Request(e.event.request.url+"/format/webp"),clientId:e.event.clientId,isReload:e.event.isReload}),h.strategies.networkOnly().handle(e)})},function(e,t){!function(e){"use strict";if(!e.fetch){var t={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(t.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=function(e){return e&&DataView.prototype.isPrototypeOf(e)},s=ArrayBuffer.isView||function(e){return e&&r.indexOf(Object.prototype.toString.call(e))>-1};u.prototype.append=function(e,t){e=i(e),t=c(t);var r=this.map[e];this.map[e]=r?r+","+t:t},u.prototype.delete=function(e){delete this.map[i(e)]},u.prototype.get=function(e){return e=i(e),this.has(e)?this.map[e]:null},u.prototype.has=function(e){return this.map.hasOwnProperty(i(e))},u.prototype.set=function(e,t){this.map[i(e)]=c(t)},u.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},u.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),h(e)},u.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),h(e)},u.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),h(e)},t.iterable&&(u.prototype[Symbol.iterator]=u.prototype.entries);var o=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},g.call(m.prototype),g.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},b.error=function(){var e=new b(null,{status:0,statusText:""});return e.type="error",e};var a=[301,302,303,307,308];b.redirect=function(e,t){if(-1===a.indexOf(t))throw new RangeError("Invalid status code");return new b(null,{status:t,headers:{location:e}})},e.Headers=u,e.Request=m,e.Response=b,e.fetch=function(e,r){return new Promise(function(n,s){var o=new m(e,r),a=new XMLHttpRequest;a.onload=function(){var e={status:a.status,statusText:a.statusText,headers:function(e){var t=new u;return e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var s=r.join(":").trim();t.append(n,s)}}),t}(a.getAllResponseHeaders()||"")};e.url="responseURL"in a?a.responseURL:e.headers.get("X-Request-URL");var t="response"in a?a.response:a.responseText;n(new b(t,e))},a.onerror=function(){s(new TypeError("Network request failed"))},a.ontimeout=function(){s(new TypeError("Network request failed"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&t.blob&&(a.responseType="blob"),o.headers.forEach(function(e,t){a.setRequestHeader(t,e)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})},e.fetch.polyfill=!0}function i(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function c(e){return"string"!=typeof e&&(e=String(e)),e}function h(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t.iterable&&(r[Symbol.iterator]=function(){return r}),r}function u(e){this.map={},e instanceof u?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function l(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function d(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function p(e){var t=new FileReader,r=d(t);return t.readAsArrayBuffer(e),r}function f(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function g(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(t.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(t.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(t.arrayBuffer&&t.blob&&n(e))this._bodyArrayBuffer=f(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!t.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(e)&&!s(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=f(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},t.blob&&(this.blob=function(){var e=l(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?l(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(p)}),this.text=function(){var e=l(this);if(e)return e;if(this._bodyBlob)return function(e){var t=new FileReader,r=d(t);return t.readAsText(e),r}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},t.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}function m(e,t){var r=(t=t||{}).body;if(e instanceof m){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new u(e.headers)),this.method=e.method,this.mode=e.mode,r||null==e._bodyInit||(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"omit",!t.headers&&this.headers||(this.headers=new u(t.headers)),this.method=function(e){var t=e.toUpperCase();return o.indexOf(t)>-1?t:e}(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function y(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),s=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(s))}}),t}function b(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new u(t.headers),this.url=t.url||"",this._initBody(e)}}("undefined"!=typeof self?self:this)},function(e,t,r){"use strict";r.r(t);class n{constructor(e){this._errors=e}createError(e,t){if(!(e in this._errors))throw new Error(`Unable to generate error '${e}'.`);let r=this._errors[e].replace(/\s+/g," "),n=null;t&&(r+=` [${t.message}]`,n=t.stack);const s=new Error;return s.name=e,s.message=r,s.stack=n,s}}var s=new n({"not-in-sw":"workbox-sw must be loaded in your service worker file.","unsupported-route-type":"The first parameter to registerRoute() should be either an Express-style path string, a RegExp, or a function.","empty-express-string":"The Express style route string must have some characters, an empty string is invalid.","bad-revisioned-cache-list":"The 'precache()' method expectsan array of revisioned urls like so: ['/example/hello.1234.txt', {path: 'hello.txt', revision: '1234'}]","navigation-route-url-string":"The registerNavigationRoute() method expects a URL string as its first parameter.","bad-cache-id":"The 'cacheId' parameter must be a string with at least one character","bad-skip-waiting":"The 'skipWaiting' parameter must be a boolean.","bad-clients-claim":"The 'clientsClaim' parameter must be a boolean.","bad-directory-index":"The 'directoryIndex' parameter must be a boolean."});class o{constructor(){this._logs=[],this._childGroups=[],this._isFallbackMode=!1;const e=/Firefox\/(\d*)\.\d*/.exec(navigator.userAgent);if(e)try{55>parseInt(e[1],10)&&(this._isFallbackMode=!0)}catch(e){this._isFallbackMode=!0}/Edge\/\d*\.\d*/.exec(navigator.userAgent)&&(this._isFallbackMode=!0)}addPrimaryLog(e){this._primaryLog=e}addLog(e){this._logs.push(e)}addChildGroup(e){0===e._logs.length||this._childGroups.push(e)}print(){return 0===this._logs.length&&0===this._childGroups.length?void this._printLogDetails(this._primaryLog):(this._primaryLog&&(this._isFallbackMode?this._printLogDetails(this._primaryLog):console.groupCollapsed(...this._getLogContent(this._primaryLog))),this._logs.forEach(e=>{this._printLogDetails(e)}),this._childGroups.forEach(e=>{e.print()}),void(this._primaryLog&&!this._isFallbackMode&&console.groupEnd()))}_printLogDetails(e){(e.logFunc?e.logFunc:console.log)(...this._getLogContent(e))}_getLogContent(e){let t=e.message;this._isFallbackMode&&"string"==typeof t&&(t=t.replace(/%c/g,""));let r=[t];return!this._isFallbackMode&&e.colors&&(r=r.concat(e.colors)),e.args&&(r=r.concat(e.args)),r}}function a(){return"ServiceWorkerGlobalScope"in self&&self instanceof ServiceWorkerGlobalScope}self.workbox=self.workbox||{},self.workbox.LOG_LEVEL=self.workbox.LOG_LEVEL||{none:-1,verbose:0,debug:1,warn:2,error:3};const i="#bdc3c7",c="#7f8c8d",h="#2ecc71",u="#f1c40f",l="#e74c3c",d="#3498db";var p=new class{constructor(){this._defaultLogLevel=self.workbox.LOG_LEVEL.warn}log(e){this._printMessage(self.workbox.LOG_LEVEL.verbose,e)}debug(e){this._printMessage(self.workbox.LOG_LEVEL.debug,e)}warn(e){this._printMessage(self.workbox.LOG_LEVEL.warn,e)}error(e){this._printMessage(self.workbox.LOG_LEVEL.error,e)}_printMessage(e,t){this._shouldLogMessage(e,t)&&this._getAllLogGroups(e,t).print()}_getAllLogGroups(e,t){const r=new o,n=this._getPrimaryMessageDetails(e,t);if(r.addPrimaryLog(n),t.error){const e={message:t.error,logFunc:console.error};r.addLog(e)}const s=new o;if(t.that&&t.that.constructor&&t.that.constructor.name){const e=t.that.constructor.name;s.addLog(this._getKeyValueDetails("class",e))}return t.data&&("object"!=typeof t.data||t.data instanceof Array?s.addLog(this._getKeyValueDetails("additionalData",t.data)):Object.keys(t.data).forEach(e=>{s.addLog(this._getKeyValueDetails(e,t.data[e]))})),r.addChildGroup(s),r}_getKeyValueDetails(e,t){return{message:`%c${e}: `,colors:[`color: ${d}`],args:t}}_getPrimaryMessageDetails(e,t){let r,n;e===self.workbox.LOG_LEVEL.verbose?(r="Info",n=i):e===self.workbox.LOG_LEVEL.debug?(r="Debug",n=h):e===self.workbox.LOG_LEVEL.warn?(r="Warn",n=u):e===self.workbox.LOG_LEVEL.error&&(r="Error",n=l);let s=`%c🔧 %c[${r}]`;const o=[`color: ${i}`,`color: ${n}`];let a;return"string"==typeof t?a=t:t.message&&(a=t.message),a&&(s+=`%c ${a=a.replace(/\s+/g," ")}`,o.push(`color: ${c}; font-weight: normal`)),{message:s,colors:o}}_shouldLogMessage(e,t){if(!t)return!1;let r=this._defaultLogLevel;return self&&self.workbox&&"number"==typeof self.workbox.logLevel&&(r=self.workbox.logLevel),!(r===self.workbox.LOG_LEVEL.none||e<r)}};var f=new n({"express-route-invalid-path":"When using ExpressRoute, you must\n    provide a path that starts with a '/' character (to match same-origin\n    requests) or that starts with 'http' (to match cross-origin requests)"}),g={parse:()=>[]};function m(e){const t=Object.keys(e);t.some(t=>void 0!==e[t])||_("Please set at least one of the following parameters: "+t.map(e=>`'${e}'`).join(", "))}function y(e,t){const r=Object.keys(e).pop();e[r]instanceof t||_(`The '${r}' parameter must be an instance of\n      '${t.name}'`)}function b(e,t){const r=Object.keys(e).pop(),n=typeof e[r];n!==t&&_(`The '${r}' parameter has the wrong type. (Expected:\n      ${t}, actual: ${n})`)}function w(e,t){const r=Object.keys(e).pop(),n=`The '${r}' parameter should be an array containing\n    one or more '${t}' elements.`;Array.isArray(e[r])||_(n);for(let s of e[r])typeof s!==t&&_(n)}function v(e,t){const r=Object.keys(e).pop(),n=`The '${r}' parameter should be an array containing\n    one or more '${t.name}' instances.`;Array.isArray(e[r])||_(n);for(let s of e[r])s instanceof t||_(n)}function _(e){e=e.replace(/\s+/g," ");const t=new Error(e);t.name="assertion-failed";const r=g.parse(t);throw 3<=r.length&&(t.message=`Invalid call to ${r[2].functionName}()  `+e),t}function x(e){return"object"==typeof e?(function(e,t){const r=Object.keys(e).pop();"function"!=typeof e[r][t]&&_(`The '${r}' parameter must be an object that exposes a\n      '${t}' method.`)}({handler:e},"handle"),e):(b({handler:e},"function"),{handle:e})}const E="GET",R=["DELETE","GET","HEAD","POST","PUT"];class C{constructor({match:e,handler:t,method:r}={}){this.handler=x(t),b({match:e},"function"),this.match=e,r?(function(e,t){const r=Object.keys(e).pop();t.includes(e[r])||_(`The '${r}' parameter must be set to one of the\n      following: ${t}`)}({method:r},R),this.method=r):this.method=E}}var q=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)},N=W,L=P,T=function(e,t){return S(P(e,t))},D=S,k=M,U=new RegExp("(\\\\.)|([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))","g");function P(e,t){for(var r,n=[],s=0,o=0,a="",i=t&&t.delimiter||"/";null!=(r=U.exec(e));){var c=r[0],h=r[1],u=r.index;if(a+=e.slice(o,u),o=u+c.length,h)a+=h[1];else{var l=e[o],d=r[2],p=r[3],f=r[4],g=r[5],m=r[6],y=r[7];a&&(n.push(a),a="");var b=r[2]||i,w=f||g;n.push({name:p||s++,prefix:d||"",delimiter:b,optional:"?"===m||"*"===m,repeat:"+"===m||"*"===m,partial:null!=d&&null!=l&&l!==d,asterisk:!!y,pattern:w?j(w):y?".*":"[^"+I(b)+"]+?"})}}return o<e.length&&(a+=e.substr(o)),a&&n.push(a),n}function O(e){return encodeURI(e).replace(/[\/?#]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}function A(e){return encodeURI(e).replace(/[?#]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}function S(e){for(var t=Array(e.length),r=0;r<e.length;r++)"object"==typeof e[r]&&(t[r]=new RegExp("^(?:"+e[r].pattern+")$"));return function(r,n){for(var s,o="",a=r||{},i=(n||{}).pretty?O:encodeURIComponent,c=0;c<e.length;c++)if("string"!=typeof(s=e[c])){var h,u=a[s.name];if(null==u){if(s.optional){s.partial&&(o+=s.prefix);continue}throw new TypeError('Expected "'+s.name+'" to be defined')}if(q(u)){if(!s.repeat)throw new TypeError('Expected "'+s.name+'" to not repeat, but received `'+JSON.stringify(u)+"`");if(0===u.length){if(s.optional)continue;throw new TypeError('Expected "'+s.name+'" to not be empty')}for(var l=0;l<u.length;l++){if(h=i(u[l]),!t[c].test(h))throw new TypeError('Expected all "'+s.name+'" to match "'+s.pattern+'", but received `'+JSON.stringify(h)+"`");o+=(0===l?s.prefix:s.delimiter)+h}}else{if(h=s.asterisk?A(u):i(u),!t[c].test(h))throw new TypeError('Expected "'+s.name+'" to match "'+s.pattern+'", but received "'+h+'"');o+=s.prefix+h}}else o+=s;return o}}function I(e){return e.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function j(e){return e.replace(/([=!:$\/()])/g,"\\$1")}function F(e,t){return e.keys=t,e}function B(e){return e.sensitive?"":"i"}function M(e,t,r){q(t)||(r=t||r,t=[]);for(var n,s=(r=r||{}).strict,o=!1!==r.end,a="",i=0;i<e.length;i++)if("string"==typeof(n=e[i]))a+=I(n);else{var c=I(n.prefix),h="(?:"+n.pattern+")";t.push(n),n.repeat&&(h+="(?:"+c+h+")*"),a+=h=n.optional?n.partial?c+"("+h+")?":"(?:"+c+"("+h+"))?":c+"("+h+")"}var u=I(r.delimiter||"/"),l=a.slice(-u.length)===u;return s||(a=(l?a.slice(0,-u.length):a)+"(?:"+u+"(?=$))?"),a+=o?"$":s&&l?"":"(?="+u+"|$)",F(new RegExp("^"+a,B(r)),t)}function W(e,t,r){return q(t)||(r=t||r,t=[]),r=r||{},e instanceof RegExp?function(e,t){var r=e.source.match(/\((?!\?)/g);if(r)for(var n=0;n<r.length;n++)t.push({name:n,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return F(e,t)}(e,t):q(e)?function(e,t,r){for(var n=[],s=0;s<e.length;s++)n.push(W(e[s],t,r).source);return F(new RegExp("(?:"+n.join("|")+")",B(r)),t)}(e,t,r):function(e,t,r){return M(P(e,r),t,r)}(e,t,r)}N.parse=L,N.compile=T,N.tokensToFunction=D,N.tokensToRegExp=k;class $ extends C{constructor({path:e,handler:t,method:r}){if(!e.startsWith("/")&&!e.startsWith("http"))throw f.createError("express-route-invalid-path");let n=[];const s=N(e,n);super({match:({url:t})=>{if(e.startsWith("/")&&t.origin!==location.origin)return null;const r=(e.startsWith("/")?t.pathname:t.href).match(s);if(!r)return null;const o={};return n.forEach((e,t)=>{o[e.name]=r[t+1]}),o},handler:t,method:r})}}class G extends C{constructor({whitelist:e,blacklist:t,handler:r}={}){v({whitelist:e},RegExp),t?v({blacklist:t},RegExp):t=[],super({match:({event:n,url:s})=>{let o,a=!1;if("navigate"===n.request.mode){const n=s.pathname+s.search;e.some(e=>e.test(n))?t.some(e=>e.test(n))?o="The navigation route is not being used, since the request URL matches both the whitelist and blacklist.":(o="The navigation route is being used.",a=!0):o="The navigation route is not being used, since the URL being navigated to doesn't match the whitelist.",p.debug({that:this,message:o,data:{"request-url":s.href,whitelist:e,blacklist:t,handler:r}})}return a},handler:r,method:"GET"})}}class H extends C{constructor({regExp:e,handler:t,method:r}){y({regExp:e},RegExp),super({match:({url:t})=>{const r=e.exec(t.href);return r?t.origin!==location.origin&&0!==r.index?(p.debug({that:this,message:"Skipping route, because the RegExp match didn't occur at the start of the URL.",data:{url:t.href,regExp:e}}),null):r.slice(1):null},handler:t,method:r})}}class V{constructor(){this._routes=new Map,this._isListenerRegistered=!1}addFetchListener(){return this._isListenerRegistered?(p.warn({that:this,message:"addFetchListener() has already been called for this Router."}),!1):(this._isListenerRegistered=!0,self.addEventListener("fetch",e=>{const t=this.handleRequest({event:e});t&&e.respondWith(t)}),!0)}handleRequest({event:e}){y({event:e},FetchEvent);const t=new URL(e.request.url);if(!t.protocol.startsWith("http"))return void p.log({that:this,message:"The URL does not start with HTTP, so it can't be handled.",data:{request:e.request}});let{handler:r,params:n}=this._findHandlerAndParams({event:e,url:t});if(!r&&this.defaultHandler&&(r=this.defaultHandler),r){let s=r.handle({url:t,event:e,params:n});return this.catchHandler&&(s=s.catch(r=>this.catchHandler.handle({url:t,event:e,error:r}))),s}}_findHandlerAndParams({event:e,url:t}){const r=this._routes.get(e.request.method)||[];for(const n of r){let r=n.match({url:t,event:e});if(r)return p.log({that:this,message:"The router found a matching route.",data:{route:n,request:e.request}}),Array.isArray(r)&&0===r.length?r=void 0:r.constructor===Object&&0===Object.keys(r).length&&(r=void 0),{params:r,handler:n.handler}}return{handler:void 0,params:void 0}}setDefaultHandler({handler:e}={}){this.defaultHandler=x(e)}setCatchHandler({handler:e}={}){this.catchHandler=x(e)}registerRoutes({routes:e}={}){v({routes:e},C);for(let t of e)this._routes.has(t.method)||this._routes.set(t.method,[]),this._routes.get(t.method).unshift(t)}registerRoute({route:e}={}){y({route:e},C),this.registerRoutes({routes:[e]})}unregisterRoutes({routes:e}={}){v({routes:e},C);for(let t of e){this._routes.has(t.method)||p.error({that:this,message:`Can't unregister route; there are no ${t.method}\n            routes registered.`,data:{route:t}});const e=this._routes.get(t.method).indexOf(t);-1<e?this._routes.get(t.method).splice(e,1):p.error({that:this,message:"Can't unregister route; the route wasn't previously\n            registered.",data:{route:t}})}}unregisterRoute({route:e}={}){y({route:e},C),this.unregisterRoutes({routes:[e]})}}class K extends V{constructor(e,t){super({handleFetch:t}),this._revisionedCacheName=e}registerRoute(e,t,r="GET"){let n;if("function"==typeof t&&(t={handle:t}),"string"==typeof e){if(0===e.length)throw s.createError("empty-express-string");const o=(e.startsWith("http")?new URL(e,location).pathname:e).match(/[*:?+]/);o&&p.warn({message:"registerRoute() was called with a string containing an Express-style wildcard character. In the next version of Workbox, Express-style wildcards won't be supported, and strings will be treated a exact matches. Please switch to regular expressions for equivalent behavior.",data:{"Path String":e,"Wildcard Character":o[0],"Learn More":"https://goo.gl/xZMKEV"}}),n=new $({path:e,handler:t,method:r})}else if(e instanceof RegExp)n=new H({regExp:e,handler:t,method:r});else{if("function"!=typeof e)throw s.createError("unsupported-route-type");n=new C({match:e,handler:t,method:r})}return super.registerRoute({route:n}),n}registerNavigationRoute(e,t={}){if("string"!=typeof e)throw s.createError("navigation-route-url-string");const r="cacheName"in t?t.cacheName:this._revisionedCacheName;super.registerRoute({route:new G({handler:()=>caches.match(e,{cacheName:r}),whitelist:t.whitelist||[/./],blacklist:t.blacklist||[]})})}}var J=new n({"multiple-cache-will-update-plugins":"You cannot register more than one plugin that implements cacheWillUpdate.","multiple-cached-response-will-be-used-plugins":"You cannot register more than one plugin that implements cachedResponseWillBeUsed.","invalid-response-for-caching":"The fetched response could not be cached due to an invalid response code.","no-response-received":"No response received; falling back to cache.","bad-cache-id":"The 'cacheId' parameter must be a string with at least one character."});class X{constructor({statuses:e,headers:t}={}){m({statuses:e,headers:t}),void 0!==e&&w({statuses:e},"number"),void 0!==t&&b({headers:t},"object"),this.statuses=e,this.headers=t}isResponseCacheable({request:e,response:t}={}){y({response:t},Response);let r=!0;if(this.statuses&&(r=this.statuses.includes(t.status)),this.headers&&r&&(r=Object.keys(this.headers).some(e=>t.headers.get(e)===this.headers[e])),!r){const r={response:t};this.statuses&&(r["valid-status-codes"]=JSON.stringify(this.statuses)),this.headers&&(r["valid-headers"]=JSON.stringify(this.headers)),e&&(r.request=e),p.debug({message:"The response does not meet the criteria for being added to the\n          cache.",data:r})}return r}}class z extends X{cacheWillUpdate({request:e,response:t}={}){return this.isResponseCacheable({request:e,response:t})}}const Y=({cacheId:e}={})=>{let t="workbox-runtime-caching";return e&&(t=`${e}-${t}`),self&&self.registration&&(t+=`-${self.registration.scope}`),t},Z=["cacheDidUpdate","cachedResponseWillBeUsed","cacheWillUpdate","fetchDidFail","requestWillFetch"];var Q=({response:e})=>{y({response:e},Response);const t=e.clone();return("body"in t?Promise.resolve(t.body):t.blob()).then(e=>new Response(e,{headers:t.headers,status:t.status,statusText:t.statusText}))},ee=function(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,r){return function n(s,o){try{var a=t[s](o),i=a.value}catch(e){return void r(e)}if(!a.done)return Promise.resolve(i).then(function(e){n("next",e)},function(e){n("throw",e)});e(i)}("next")})}};class te{constructor({cacheName:e,cacheId:t,plugins:r,fetchOptions:n,matchOptions:s}={}){if(t&&("string"!=typeof t||0===t.length))throw J.createError("bad-cache-id");e?(b({cacheName:e},"string"),this.cacheName=e,t&&(this.cacheName=`${t}-${this.cacheName}`)):this.cacheName=Y({cacheId:t}),n&&(b({fetchOptions:n},"object"),this.fetchOptions=n),s&&(b({matchOptions:s},"object"),this.matchOptions=s),this.plugins=new Map,r&&(w({plugins:r},"object"),r.forEach(e=>{for(let t of Z)if("function"==typeof e[t]){if(this.plugins.has(t)){if("cacheWillUpdate"===t)throw J.createError("multiple-cache-will-update-plugins");if("cachedResponseWillBeUsed"===t)throw J.createError("multiple-cached-response-will-be-used-plugins")}else this.plugins.set(t,[]);this.plugins.get(t).push(e)}})),this.plugins.has("cacheWillUpdate")&&(this._userSpecifiedCachableResponsePlugin=this.plugins.get("cacheWillUpdate")[0])}getDefaultCacheableResponsePlugin(){return this._defaultCacheableResponsePlugin||(this._defaultCacheableResponsePlugin=new z({statuses:[200]})),this._defaultCacheableResponsePlugin}getCache(){var e=this;return ee(function*(){return e._cache||(e._cache=yield caches.open(e.cacheName)),e._cache})()}match({request:e}){var t=this;return ee(function*(){m({request:e});const r=yield t.getCache();let n=yield r.match(e,t.matchOptions);if(t.plugins.has("cachedResponseWillBeUsed")){n=yield t.plugins.get("cachedResponseWillBeUsed")[0].cachedResponseWillBeUsed({request:e,cache:r,cachedResponse:n,matchOptions:t.matchOptions,cacheName:t.cacheName})}return n})()}fetch({request:e}){var t=this;return ee(function*(){"string"==typeof e?e=new Request(e):y({request:e},Request);const r=t.plugins.has("fetchDidFail")?e.clone():null;if(t.plugins.has("requestWillFetch"))for(let r of t.plugins.get("requestWillFetch")){const t=yield r.requestWillFetch({request:e});y({returnedRequest:t},Request),e=t}try{return yield fetch(e,t.fetchOptions)}catch(e){if(t.plugins.has("fetchDidFail"))for(let e of t.plugins.get("fetchDidFail"))yield e.fetchDidFail({request:r.clone()});throw e}})()}fetchAndCache({request:e,waitOnCache:t,cacheKey:r,cacheResponsePlugin:n,cleanRedirects:s}){var o=this;return ee(function*(){let a;m({request:e});const i=yield o.fetch({request:e}),c=yield(o._userSpecifiedCachableResponsePlugin||n||o.getDefaultCacheableResponsePlugin()).cacheWillUpdate({request:e,response:i});if(c){const t=s&&i.redirected?yield Q({response:i}):i.clone();a=o.getCache().then((()=>{var n=ee(function*(n){let s;const a=r||e;if("opaque"!==i.type&&o.plugins.has("cacheDidUpdate")&&(s=yield o.match({request:a})),yield n.put(a,t),o.plugins.has("cacheDidUpdate"))for(let e of o.plugins.get("cacheDidUpdate"))yield e.cacheDidUpdate({cacheName:o.cacheName,oldResponse:s,newResponse:t,url:"url"in a?a.url:a})});return function(){return n.apply(this,arguments)}})())}else if(!c&&t)throw J.createError("invalid-response-for-caching");return t&&a&&(yield a),i})()}}class re{constructor({requestWrapper:e,waitOnCache:t}={}){this.requestWrapper=e||new te,this.waitOnCache=!!t}handle({event:e,params:t}={}){throw Error("This abstract method must be implemented in a subclass.")}}class ne extends re{handle({event:e}={}){var t=this;return ee(function*(){return y({event:e},FetchEvent),(yield t.requestWrapper.match({request:e.request}))||(yield t.requestWrapper.fetchAndCache({request:e.request,waitOnCache:t.waitOnCache}))})()}}class se extends re{handle({event:e}={}){var t=this;return ee(function*(){return y({event:e},FetchEvent),yield t.requestWrapper.match({request:e.request})})()}}class oe extends re{constructor(e={}){super(e),this._cacheablePlugin=new z({statuses:[0,200]});const{networkTimeoutSeconds:t}=e;t&&(b({networkTimeoutSeconds:t},"number"),this.networkTimeoutSeconds=t)}handle({event:e}={}){var t=this;return ee(function*(){y({event:e},FetchEvent);const r=[];let n;t.networkTimeoutSeconds&&r.push(new Promise(function(r){n=setTimeout(function(){r(t.requestWrapper.match({request:e.request}))},1e3*t.networkTimeoutSeconds)}));const s=t.requestWrapper.fetchAndCache({request:e.request,waitOnCache:t.waitOnCache,cacheResponsePlugin:t._cacheablePlugin}).then(function(e){return n&&clearTimeout(n),e||Promise.reject(J.createError("no-response-received"))}).catch(function(){return t.requestWrapper.match({request:e.request})});return r.push(s),Promise.race(r)})()}}class ae extends re{handle({event:e}={}){var t=this;return ee(function*(){return y({event:e},FetchEvent),yield t.requestWrapper.fetch({request:e.request})})()}}class ie extends re{constructor(e={}){super(e),this._cacheablePlugin=new z({statuses:[0,200]})}handle({event:e}={}){var t=this;return ee(function*(){y({event:e},FetchEvent);const r=t.requestWrapper.fetchAndCache({request:e.request,waitOnCache:t.waitOnCache,cacheResponsePlugin:t._cacheablePlugin}).catch(function(){return Response.error()});return(yield t.requestWrapper.match({request:e.request}))||(yield r)})()}}let ce="workbox-cache-expiration";self&&self.registration&&(ce+=`-${self.registration.scope}`);const he=ce,ue=1,le="url",de="timestamp";var pe=function(e,t){return e(t={exports:{}},t.exports),t.exports}(function(e){!function(){function t(e){return new Promise(function(t,r){e.onsuccess=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function r(e,r,n){var s,o=new Promise(function(o,a){t(s=e[r].apply(e,n)).then(o,a)});return o.request=s,o}function n(e,t,n){var s=r(e,t,n);return s.then(function(e){return e?new h(e,s.request):void 0})}function s(e,t,r){r.forEach(function(r){Object.defineProperty(e.prototype,r,{get:function(){return this[t][r]},set:function(e){this[t][r]=e}})})}function o(e,t,n,s){s.forEach(function(s){s in n.prototype&&(e.prototype[s]=function(){return r(this[t],s,arguments)})})}function a(e,t,r,n){n.forEach(function(n){n in r.prototype&&(e.prototype[n]=function(){return this[t][n].apply(this[t],arguments)})})}function i(e,t,r,s){s.forEach(function(s){s in r.prototype&&(e.prototype[s]=function(){return n(this[t],s,arguments)})})}function c(e){this._index=e}function h(e,t){this._cursor=e,this._request=t}function u(e){this._store=e}function l(e){this._tx=e,this.complete=new Promise(function(t,r){e.oncomplete=function(){t()},e.onerror=function(){r(e.error)},e.onabort=function(){r(e.error)}})}function d(e,t,r){this._db=e,this.oldVersion=t,this.transaction=new l(r)}function p(e){this._db=e}s(c,"_index",["name","keyPath","multiEntry","unique"]),o(c,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),i(c,"_index",IDBIndex,["openCursor","openKeyCursor"]),s(h,"_cursor",["direction","key","primaryKey","value"]),o(h,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach(function(e){e in IDBCursor.prototype&&(h.prototype[e]=function(){var r=this,n=arguments;return Promise.resolve().then(function(){return r._cursor[e].apply(r._cursor,n),t(r._request).then(function(e){return e?new h(e,r._request):void 0})})})}),u.prototype.createIndex=function(){return new c(this._store.createIndex.apply(this._store,arguments))},u.prototype.index=function(){return new c(this._store.index.apply(this._store,arguments))},s(u,"_store",["name","keyPath","indexNames","autoIncrement"]),o(u,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),i(u,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),a(u,"_store",IDBObjectStore,["deleteIndex"]),l.prototype.objectStore=function(){return new u(this._tx.objectStore.apply(this._tx,arguments))},s(l,"_tx",["objectStoreNames","mode"]),a(l,"_tx",IDBTransaction,["abort"]),d.prototype.createObjectStore=function(){return new u(this._db.createObjectStore.apply(this._db,arguments))},s(d,"_db",["name","version","objectStoreNames"]),a(d,"_db",IDBDatabase,["deleteObjectStore","close"]),p.prototype.transaction=function(){return new l(this._db.transaction.apply(this._db,arguments))},s(p,"_db",["name","version","objectStoreNames"]),a(p,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach(function(e){[u,c].forEach(function(t){t.prototype[e.replace("open","iterate")]=function(){var t=function(e){return Array.prototype.slice.call(e)}(arguments),r=t[t.length-1],n=this._store||this._index,s=n[e].apply(n,t.slice(0,-1));s.onsuccess=function(){r(s.result)}}})}),[c,u].forEach(function(e){e.prototype.getAll||(e.prototype.getAll=function(e,t){var r=this,n=[];return new Promise(function(s){r.iterateCursor(e,function(e){return e?(n.push(e.value),void 0!==t&&n.length==t?void s(n):void e.continue()):void s(n)})})})});var f={open:function(e,t,n){var s=r(indexedDB,"open",[e,t]),o=s.request;return o.onupgradeneeded=function(e){n&&n(new d(o.result,e.oldVersion,o.transaction))},s.then(function(e){return new p(e)})},delete:function(e){return r(indexedDB,"deleteDatabase",[e])}};e.exports=f,e.exports.default=e.exports}()});var fe=new n({"max-entries-or-age-required":"Either the maxEntries or maxAgeSeconds\n    parameters (or both) are required when constructing Plugin.","max-entries-must-be-number":"The maxEntries parameter to the Plugin\n    constructor must either be a number or undefined.","max-age-seconds-must-be-number":"The maxAgeSeconds parameter to the Plugin\n    constructor must either be a number or undefined."});class ge{constructor({maxEntries:e,maxAgeSeconds:t}={}){if(!e&&!t)throw fe.createError("max-entries-or-age-required");if(e&&"number"!=typeof e)throw fe.createError("max-entries-must-be-number");if(t&&"number"!=typeof t)throw fe.createError("max-age-seconds-must-be-number");this.maxEntries=e,this.maxAgeSeconds=t,this._dbs=new Map,this._caches=new Map,this._expirationMutex=!1,this._timestampForNextRun=null}getDB({cacheName:e}={}){var t=this;return ee(function*(){b({cacheName:e},"string");const r=`${he}-${e}`;if(!t._dbs.has(r)){const n=yield pe.open(r,ue,function(t){t.createObjectStore(e,{keyPath:le}).createIndex(de,de,{unique:!1})});t._dbs.set(r,n)}return t._dbs.get(r)})()}getCache({cacheName:e}={}){var t=this;return ee(function*(){if(b({cacheName:e},"string"),!t._caches.has(e)){const r=yield caches.open(e);t._caches.set(e,r)}return t._caches.get(e)})()}isResponseFresh({cacheName:e,cachedResponse:t,now:r}={}){if(t&&this.maxAgeSeconds){y({cachedResponse:t},Response);const n=t.headers.get("date");if(n){void 0===r&&(r=Date.now());const e=new Date(n).getTime();return!!isNaN(e)||e+1e3*this.maxAgeSeconds>r}return this.expireEntries({cacheName:e,now:r}),!0}return!0}updateTimestamp({cacheName:e,url:t,now:r}={}){var n=this;return ee(function*(){b({url:t},"string"),b({cacheName:e},"string");const s=new URL(t,location);s.hash="",void 0===r&&(r=Date.now());const o=(yield n.getDB({cacheName:e})).transaction(e,"readwrite");o.objectStore(e).put({[de]:r,[le]:s.href}),yield o.complete})()}expireEntries({cacheName:e,now:t}={}){var r=this;return ee(function*(){if(r._expirationMutex)return void(r._timestampForNextRun=t);r._expirationMutex=!0,b({cacheName:e},"string"),void 0===t&&(t=Date.now());const n=r.maxAgeSeconds?yield r.findOldEntries({cacheName:e,now:t}):[],s=r.maxEntries?yield r.findExtraEntries({cacheName:e}):[],o=[...new Set(n.concat(s))];if(yield r.deleteFromCacheAndIDB({cacheName:e,urls:o}),0<o.length&&p.debug({that:r,message:"Expired entries have been removed from the cache.",data:{cacheName:e,urls:o}}),r._expirationMutex=!1,r._timestampForNextRun){const t=r._timestampForNextRun;return r._timestampForNextRun=null,r.expireEntries({cacheName:e,now:t})}})()}findOldEntries({cacheName:e,now:t}={}){var r=this;return ee(function*(){b({cacheName:e},"string"),b({now:t},"number");const n=t-1e3*r.maxAgeSeconds,s=[],o=(yield r.getDB({cacheName:e})).transaction(e,"readonly");return o.objectStore(e).index(de).iterateCursor(function(e){e&&(e.value[de]<n&&s.push(e.value[le]),e.continue())}),yield o.complete,s})()}findExtraEntries({cacheName:e}={}){var t=this;return ee(function*(){b({cacheName:e},"string");const r=[],n=yield t.getDB({cacheName:e});let s=n.transaction(e,"readonly"),o=s.objectStore(e),a=o.index(de);const i=yield a.count();return i>t.maxEntries&&(a=(o=(s=n.transaction(e,"readonly")).objectStore(e)).index(de)).iterateCursor(function(e){e&&(r.push(e.value[le]),i-r.length>t.maxEntries&&e.continue())}),yield s.complete,r})()}deleteFromCacheAndIDB({cacheName:e,urls:t}={}){var r=this;return ee(function*(){if(b({cacheName:e},"string"),w({urls:t},"string"),0<t.length){const n=yield r.getCache({cacheName:e}),s=yield r.getDB({cacheName:e});for(let r of t){yield n.delete(r);const t=s.transaction(e,"readwrite");t.objectStore(e).delete(r),yield t.complete}}})()}}class me extends ge{cachedResponseWillBeUsed({cacheName:e,cachedResponse:t,now:r}={}){return this.isResponseFresh({cacheName:e,cachedResponse:t,now:r})?t:null}cacheDidUpdate({cacheName:e,newResponse:t,url:r,now:n}={}){var s=this;return ee(function*(){b({cacheName:e},"string"),y({newResponse:t},Response),void 0===n&&(n=Date.now()),yield s.updateTimestamp({cacheName:e,url:r,now:n}),yield s.expireEntries({cacheName:e,now:n})})()}}var ye=new n({"channel-name-required":"The channelName parameter is required when\n    constructing a new BroadcastCacheUpdate instance.","responses-are-same-parameters-required":"The first, second, and\n    headersToCheck parameters must be valid when calling responsesAreSame()"});const be="CACHE_UPDATED",we=["content-length","etag","last-modified"],ve="workbox-broadcast-cache-update";class _e{constructor({channelName:e,headersToCheck:t,source:r}={}){if("string"!=typeof e||0===e.length)throw ye.createError("channel-name-required");this.channelName=e,this.headersToCheck=t||we,this.source=r||ve}get channel(){return this._channel||("BroadcastChannel"in self?this._channel=new BroadcastChannel(this.channelName):this._channel={postMessage:()=>{}}),this._channel}notifyIfUpdated({first:e,second:t,cacheName:r,url:n}){b({cacheName:r},"string"),function({first:e,second:t,headersToCheck:r}={}){if(!(e instanceof Response&&t instanceof Response&&r instanceof Array))throw ye.createError("responses-are-same-parameters-required");return r.some(r=>e.headers.has(r)&&t.headers.has(r))?r.every(r=>e.headers.has(r)===t.headers.has(r)&&e.headers.get(r)===t.headers.get(r)):(p.log({message:"Unable to determine whether the response has been updated\n        because none of the headers that would be checked are present.",data:{"First Response":e,"Second Response":t,"Headers To Check":JSON.stringify(r)}}),!0)}({first:e,second:t,headersToCheck:this.headersToCheck})||function({channel:e,cacheName:t,url:r,source:n}={}){"BroadcastChannel"in self&&(y({channel:e},BroadcastChannel),b({cacheName:t},"string"),b({source:n},"string"),b({url:r},"string"),e.postMessage({type:be,meta:n,payload:{cacheName:t,updatedUrl:r}}))}({cacheName:r,url:n,channel:this.channel,source:this.source})}}class xe extends _e{cacheDidUpdate({cacheName:e,oldResponse:t,newResponse:r,url:n}){b({cacheName:e},"string"),y({newResponse:r},Response),t&&this.notifyIfUpdated({cacheName:e,first:t,second:r,url:n})}}class Ee{constructor({cacheId:e}={}){this._cacheId=e}cacheFirst(e){return this._getCachingMechanism(ne,e)}cacheOnly(e){return this._getCachingMechanism(se,e)}networkFirst(e){return this._getCachingMechanism(oe,e)}networkOnly(e){return this._getCachingMechanism(ae,e)}staleWhileRevalidate(e){return this._getCachingMechanism(ie,e)}_getCachingMechanism(e,t={}){const r={cacheExpiration:me,broadcastCacheUpdate:xe,cacheableResponse:z},n={plugins:[]};return t.excludeCacheId||(n.cacheId=this._cacheId),t.cacheName&&(n.cacheName=t.cacheName),Object.keys(r).forEach(e=>{if(t[e]){const s=r[e],o=t[e];n.plugins.push(new s(o))}}),t.plugins&&t.plugins.forEach(e=>{n.plugins.push(e)}),t.requestWrapper=new te(n),new e(t)}}const Re=(e,t)=>{let r="An error was thrown by workbox with error code: "+`;'${e}'`;return t&&(r+=` with extras: '${JSON.stringify(t)}'`),r};class Ce extends Error{constructor(e,t){super(),this.name=e,this.message=Re(e,t),t&&(this.extras=t)}}class qe{constructor({cacheName:e,cacheId:t,plugins:r}={}){if(t&&("string"!=typeof t||0===t.length))throw new Ce("bad-cache-id",{cacheId:t});this._entriesToCache=new Map,this._requestWrapper=new te({cacheName:e,cacheId:t,plugins:r,fetchOptions:{credentials:"same-origin"}})}_addEntries(e){this._parsedCacheUrls=null,e.forEach(e=>{this._addEntryToInstallList(this._parseEntry(e))})}getCacheName(){return this._requestWrapper.cacheName}getCachedUrls(){return this._parsedCacheUrls||(this._parsedCacheUrls=Array.from(this._entriesToCache.keys()).map(e=>new URL(e,location).href)),this._parsedCacheUrls}_addEntryToInstallList(e){const t=e.entryID,r=this._entriesToCache.get(e.entryID);return r?void this._onDuplicateInstallEntryFound(e,r):void this._entriesToCache.set(t,e)}install(){var e=this;return ee(function*(){if(0===e._entriesToCache.size)return[];const t=[];return e._entriesToCache.forEach(function(r){t.push(e._cacheEntry(r))}),Promise.all(t)})()}_cacheEntry(e){var t=this;return ee(function*(){const r=yield t._isAlreadyCached(e),n={url:e.request.url,revision:e.revision,wasUpdated:!r};if(r)return n;try{return yield t._requestWrapper.fetchAndCache({request:e.getNetworkRequest(),waitOnCache:!0,cacheKey:e.request,cleanRedirects:!0}),yield t._onEntryCached(e),n}catch(t){throw new Ce("request-not-cached",{url:e.request.url,error:t})}})()}cleanup(){var e=this;return ee(function*(){if(!(yield caches.has(e.getCacheName())))return;const t=[];e._entriesToCache.forEach(function(e){t.push(e.request.url)});const r=yield e._getCache(),n=(yield r.keys()).filter(function(e){return!t.includes(e.url)});return Promise.all(n.map((()=>{var t=ee(function*(t){yield r.delete(t),yield e._onEntryDeleted(t.url)});return function(){return t.apply(this,arguments)}})()))})()}_getCache(){var e=this;return ee(function*(){return e._cache||(e._cache=yield caches.open(e.getCacheName())),e._cache})()}_parseEntry(){throw new Ce("requires-overriding")}_onDuplicateEntryFound(){throw new Ce("requires-overriding")}_isAlreadyCached(){throw new Ce("requires-overriding")}_onEntryCached(){throw new Ce("requires-overriding")}_onEntryDeleted(){throw new Ce("requires-overriding")}}class Ne{constructor(e,t,r){if(null==e||null==t||null==r)throw Error("name, version, storeName must be passed to the constructor.");this._name=e,this._version=t,this._storeName=r}_getDb(){return this._dbPromise?this._dbPromise:(this._dbPromise=pe.open(this._name,this._version,e=>{e.createObjectStore(this._storeName)}).then(e=>e),this._dbPromise)}close(){return this._dbPromise?this._dbPromise.then(e=>{e.close(),this._dbPromise=null}):void 0}put(e,t){return this._getDb().then(r=>{const n=r.transaction(this._storeName,"readwrite");return n.objectStore(this._storeName).put(t,e),n.complete})}delete(e){return this._getDb().then(t=>{const r=t.transaction(this._storeName,"readwrite");return r.objectStore(this._storeName).delete(e),r.complete})}get(e){return this._getDb().then(t=>t.transaction(this._storeName).objectStore(this._storeName).get(e))}getAllValues(){return this._getDb().then(e=>e.transaction(this._storeName).objectStore(this._storeName).getAll())}getAllKeys(){return this._getDb().then(e=>e.transaction(this._storeName).objectStore(this._storeName).getAllKeys())}}const Le="_workbox-precaching",Te="workbox-precaching",De="1",ke="asset-revisions";let Ue="workbox-precaching-revisioned-v1";self&&self.registration&&(Ue+=`-${self.registration.scope}`);const Pe=Ue;class Oe{constructor(){this._idbHelper=new Ne(Te,De,ke)}get(e){return this._idbHelper.get(e)}put(e,t){return this._idbHelper.put(e,t)}delete(e){return this._idbHelper.delete(e)}_close(){this._idbHelper.close()}}class Ae{constructor({entryID:e,revision:t,request:r,cacheBust:n}){this.entryID=e,this.revision=t,this.request=r,this.cacheBust=n}getNetworkRequest(){if(!0!==this.cacheBust)return this.request;let e=this.request.url;const t={};if(!0===this.cacheBust)if("cache"in Request.prototype)t.cache="reload";else{const t=new URL(e,location);t.search+=(t.search?"&":"")+encodeURIComponent(Le)+"="+encodeURIComponent(this.revision),e=t.toString()}return new Request(e,t)}}class Se extends Ae{constructor(e){if(b({url:e},"string"),0===e.length)throw new Ce("invalid-string-entry",{url:e});super({entryID:e,revision:e,request:new Request(e),cacheBust:!1})}}class Ie extends Ae{constructor({entryID:e,revision:t,url:r,cacheBust:n}){if(void 0!==t&&(b({revision:t},"string"),0===t.length))throw new Ce("invalid-object-entry",{problemParam:"revision",problemValue:t});if(void 0===n&&(n=!!t),b({cacheBust:n},"boolean"),b({url:r},"string"),0===r.length)throw new Ce("invalid-object-entry",{problemParam:"url",problemValue:r});if(void 0===e)e=new URL(r,location).toString();else if(0===e.length)throw new Ce("invalid-object-entry",{problemParam:"entryID",problemValue:e});super({entryID:e,revision:t||r,request:new Request(r),cacheBust:n})}}class je extends qe{constructor(e={}){e.cacheName=e.cacheName||Pe,super(e),this._revisionDetailsModel=new Oe}addToCacheList({revisionedFiles:e}={}){y({revisionedFiles:e},Array),super._addEntries(e);const t=e.filter(e=>"string"==typeof e||!e.revision);0<t.length&&p.debug({that:this,message:"Some precache entries are URLs without separate revision\n          fields. If the URLs themselves do not contain revisioning info,\n          like a hash or a version number, your users won't receive updates.",data:{"URLs without revision fields":JSON.stringify(t),"Examples of safe, versioned URLs":"'/path/file.abcd1234.css' or '/v1.0.0/file.js'","Examples of dangerous, unversioned URLs":"'index.html' or '/path/file.css' or '/latest/file.js'"}})}_parseEntry(e){if(null===e)throw new Ce("unexpected-precache-entry",{input:e});let t;switch(typeof e){case"string":t=new Se(e);break;case"object":t=new Ie(e);break;default:throw new Ce("unexpected-precache-entry",{input:e})}return t}_onDuplicateInstallEntryFound(e,t){if(t.revision!==e.revision)throw new Ce("duplicate-entry-diff-revisions",{firstEntry:{url:t.request.url,revision:t.revision},secondEntry:{url:e.request.url,revision:e.revision}})}_isAlreadyCached(e){var t=this;return ee(function*(){return(yield t._revisionDetailsModel.get(e.entryID))===e.revision&&!!(yield(yield t._getCache()).match(e.request))})()}_onEntryCached(e){var t=this;return ee(function*(){yield t._revisionDetailsModel.put(e.entryID,e.revision)})()}_onEntryDeleted(e){var t=this;return ee(function*(){yield t._revisionDetailsModel.delete(e)})()}_close(){this._revisionDetailsModel._close()}cleanup(){return super.cleanup().then(()=>this._close())}_createLogFriendlyString(e){let t="\n";return e.forEach(e=>{t+=`    URL: '${e.url}' Revision: `+`'${e.revision}'\n`}),t}install(){return super.install().then(e=>{const t=[],r=[];e.forEach(e=>{e.wasUpdated?t.push({url:e.url,revision:e.revision}):r.push({url:e.url,revision:e.revision})});const n={};return 0<t.length&&(n["New / Updated Precache URL's"]=this._createLogFriendlyString(t)),0<r.length&&(n["Up-to-date Precache URL's"]=this._createLogFriendlyString(r)),p.log({message:`Precache Details: ${t.length} requests `+"were added or updated and "+`${r.length} request are already `+"cached and up-to-date.",data:n}),e})}}if(!a())throw new Ce("not-in-sw");t.default=class{constructor({cacheId:e,skipWaiting:t,clientsClaim:r,handleFetch:n=!0,directoryIndex:o="index.html",precacheChannelName:i="precache-updates",ignoreUrlParametersMatching:c=[/^utm_/]}={}){if(!a())throw s.createError("not-in-sw");if(e&&("string"!=typeof e||0===e.length))throw s.createError("bad-cache-id");if(t&&"boolean"!=typeof t)throw s.createError("bad-skip-waiting");if(r&&"boolean"!=typeof r)throw s.createError("bad-clients-claim");if(void 0!==o)if(!1===o||null===o)o=!1;else if("string"!=typeof o||0===o.length)throw s.createError("bad-directory-index");const h=[];i&&h.push(new xe({channelName:i,source:registration&&registration.scope?registration.scope:location})),this._runtimeCacheName=Y({cacheId:e}),this._revisionedCacheManager=new je({cacheId:e,plugins:h}),this._strategies=new Ee({cacheId:e}),this._precacheRouter=new K(this._revisionedCacheManager.getCacheName()),this._router=new K(this._revisionedCacheManager.getCacheName()),n&&(this._precacheRouter.addFetchListener(),this._router.addFetchListener()),this._registerInstallActivateEvents(t,r),this._registerDefaultRoutes(c,o)}precache(e){if(!Array.isArray(e))throw s.createError("bad-revisioned-cache-list");this._revisionedCacheManager.addToCacheList({revisionedFiles:e})}get router(){return this._router}get strategies(){return this._strategies}get runtimeCacheName(){return this._runtimeCacheName}_registerInstallActivateEvents(e,t){self.addEventListener("install",t=>{const r=this._revisionedCacheManager.getCachedUrls();0<r.length&&p.debug({that:this,message:"The precached URLs will automatically be served using a\n            cache-first strategy.",data:{"Precached URLs":JSON.stringify(r)}}),t.waitUntil(this._revisionedCacheManager.install().then(()=>{if(e)return self.skipWaiting()}))}),self.addEventListener("activate",e=>{e.waitUntil(this._revisionedCacheManager.cleanup().then(()=>{if(t)return self.clients.claim()}))})}_registerDefaultRoutes(e,t){const r=[];(e||t)&&r.push(this._getCacheMatchPlugin(e,t));const n=this.strategies.cacheFirst({cacheName:this._revisionedCacheManager.getCacheName(),plugins:r,excludeCacheId:!0});this._precacheRouter.registerRoute(({url:r})=>{r.hash="";const n=this._revisionedCacheManager.getCachedUrls();if(-1!==n.indexOf(r.href))return!0;let s=this._removeIgnoreUrlParams(r.href,e);return-1!==n.indexOf(s.href)||t&&s.pathname.endsWith("/")&&(s.pathname+=t,-1!==n.indexOf(s.href))},n)}_getCacheMatchPlugin(e,t){var r=this;return{cachedResponseWillBeUsed:(()=>{var n=ee(function*({request:n,cache:s,cachedResponse:o,matchOptions:a}){if(o)return o;let i=r._removeIgnoreUrlParams(n.url,e);return s.match(i.toString(),a).then(function(e){return!e&&i.pathname.endsWith("/")?(i.pathname+=t,s.match(i.toString(),a)):e})});return function(){return n.apply(this,arguments)}})()}}_removeIgnoreUrlParams(e,t){const r=new URL(e),n=r.search.slice(1).split("&").map(e=>e.split("=")).filter(e=>t.every(t=>!t.test(e[0]))).map(e=>e.join("="));return r.search=n.join("&"),r}}},function(e,t){e.exports=function(e){var t,r,n,s={};if(e=e||"")for(t=e.split("&"),n=0;n<t.length;n++)s[(r=t[n].split("="))[0]]=r[1];return s}}]);