workbox-27b29e6f.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. define(['exports'], function (t) {
  2. 'use strict';
  3. try {
  4. self['workbox:core:7.0.0'] && _();
  5. } catch (t) {}
  6. const e = (t, ...e) => {
  7. let s = t;
  8. return e.length > 0 && (s += ` :: ${JSON.stringify(e)}`), s;
  9. };
  10. class s extends Error {
  11. constructor(t, s) {
  12. super(e(t, s)), (this.name = t), (this.details = s);
  13. }
  14. }
  15. try {
  16. self['workbox:routing:7.0.0'] && _();
  17. } catch (t) {}
  18. const n = t => (t && 'object' == typeof t ? t : { handle: t });
  19. class i {
  20. constructor(t, e, s = 'GET') {
  21. (this.handler = n(e)), (this.match = t), (this.method = s);
  22. }
  23. setCatchHandler(t) {
  24. this.catchHandler = n(t);
  25. }
  26. }
  27. class r extends i {
  28. constructor(t, e, s) {
  29. super(
  30. ({ url: e }) => {
  31. const s = t.exec(e.href);
  32. if (s && (e.origin === location.origin || 0 === s.index))
  33. return s.slice(1);
  34. },
  35. e,
  36. s
  37. );
  38. }
  39. }
  40. class o {
  41. constructor() {
  42. (this.t = new Map()), (this.i = new Map());
  43. }
  44. get routes() {
  45. return this.t;
  46. }
  47. addFetchListener() {
  48. self.addEventListener('fetch', t => {
  49. const { request: e } = t,
  50. s = this.handleRequest({ request: e, event: t });
  51. s && t.respondWith(s);
  52. });
  53. }
  54. addCacheListener() {
  55. self.addEventListener('message', t => {
  56. if (t.data && 'CACHE_URLS' === t.data.type) {
  57. const { payload: e } = t.data,
  58. s = Promise.all(
  59. e.urlsToCache.map(e => {
  60. 'string' == typeof e && (e = [e]);
  61. const s = new Request(...e);
  62. return this.handleRequest({ request: s, event: t });
  63. })
  64. );
  65. t.waitUntil(s),
  66. t.ports && t.ports[0] && s.then(() => t.ports[0].postMessage(!0));
  67. }
  68. });
  69. }
  70. handleRequest({ request: t, event: e }) {
  71. const s = new URL(t.url, location.href);
  72. if (!s.protocol.startsWith('http')) return;
  73. const n = s.origin === location.origin,
  74. { params: i, route: r } = this.findMatchingRoute({
  75. event: e,
  76. request: t,
  77. sameOrigin: n,
  78. url: s
  79. });
  80. let o = r && r.handler;
  81. const c = t.method;
  82. if ((!o && this.i.has(c) && (o = this.i.get(c)), !o)) return;
  83. let a;
  84. try {
  85. a = o.handle({ url: s, request: t, event: e, params: i });
  86. } catch (t) {
  87. a = Promise.reject(t);
  88. }
  89. const h = r && r.catchHandler;
  90. return (
  91. a instanceof Promise &&
  92. (this.o || h) &&
  93. (a = a.catch(async n => {
  94. if (h)
  95. try {
  96. return await h.handle({
  97. url: s,
  98. request: t,
  99. event: e,
  100. params: i
  101. });
  102. } catch (t) {
  103. t instanceof Error && (n = t);
  104. }
  105. if (this.o) return this.o.handle({ url: s, request: t, event: e });
  106. throw n;
  107. })),
  108. a
  109. );
  110. }
  111. findMatchingRoute({ url: t, sameOrigin: e, request: s, event: n }) {
  112. const i = this.t.get(s.method) || [];
  113. for (const r of i) {
  114. let i;
  115. const o = r.match({ url: t, sameOrigin: e, request: s, event: n });
  116. if (o)
  117. return (
  118. (i = o),
  119. ((Array.isArray(i) && 0 === i.length) ||
  120. (o.constructor === Object && 0 === Object.keys(o).length) ||
  121. 'boolean' == typeof o) &&
  122. (i = void 0),
  123. { route: r, params: i }
  124. );
  125. }
  126. return {};
  127. }
  128. setDefaultHandler(t, e = 'GET') {
  129. this.i.set(e, n(t));
  130. }
  131. setCatchHandler(t) {
  132. this.o = n(t);
  133. }
  134. registerRoute(t) {
  135. this.t.has(t.method) || this.t.set(t.method, []),
  136. this.t.get(t.method).push(t);
  137. }
  138. unregisterRoute(t) {
  139. if (!this.t.has(t.method))
  140. throw new s('unregister-route-but-not-found-with-method', {
  141. method: t.method
  142. });
  143. const e = this.t.get(t.method).indexOf(t);
  144. if (!(e > -1)) throw new s('unregister-route-route-not-registered');
  145. this.t.get(t.method).splice(e, 1);
  146. }
  147. }
  148. let c;
  149. const a = () => (
  150. c || ((c = new o()), c.addFetchListener(), c.addCacheListener()), c
  151. );
  152. function h(t, e, n) {
  153. let o;
  154. if ('string' == typeof t) {
  155. const s = new URL(t, location.href);
  156. o = new i(({ url: t }) => t.href === s.href, e, n);
  157. } else if (t instanceof RegExp) o = new r(t, e, n);
  158. else if ('function' == typeof t) o = new i(t, e, n);
  159. else {
  160. if (!(t instanceof i))
  161. throw new s('unsupported-route-type', {
  162. moduleName: 'workbox-routing',
  163. funcName: 'registerRoute',
  164. paramName: 'capture'
  165. });
  166. o = t;
  167. }
  168. return a().registerRoute(o), o;
  169. }
  170. const u = {
  171. googleAnalytics: 'googleAnalytics',
  172. precache: 'precache-v2',
  173. prefix: 'workbox',
  174. runtime: 'runtime',
  175. suffix: 'undefined' != typeof registration ? registration.scope : ''
  176. },
  177. l = t => [u.prefix, t, u.suffix].filter(t => t && t.length > 0).join('-'),
  178. f = t => t || l(u.precache),
  179. w = t => t || l(u.runtime);
  180. function d(t, e) {
  181. const s = e();
  182. return t.waitUntil(s), s;
  183. }
  184. try {
  185. self['workbox:precaching:7.0.0'] && _();
  186. } catch (t) {}
  187. function p(t) {
  188. if (!t) throw new s('add-to-cache-list-unexpected-type', { entry: t });
  189. if ('string' == typeof t) {
  190. const e = new URL(t, location.href);
  191. return { cacheKey: e.href, url: e.href };
  192. }
  193. const { revision: e, url: n } = t;
  194. if (!n) throw new s('add-to-cache-list-unexpected-type', { entry: t });
  195. if (!e) {
  196. const t = new URL(n, location.href);
  197. return { cacheKey: t.href, url: t.href };
  198. }
  199. const i = new URL(n, location.href),
  200. r = new URL(n, location.href);
  201. return (
  202. i.searchParams.set('__WB_REVISION__', e),
  203. { cacheKey: i.href, url: r.href }
  204. );
  205. }
  206. class y {
  207. constructor() {
  208. (this.updatedURLs = []),
  209. (this.notUpdatedURLs = []),
  210. (this.handlerWillStart = async ({ request: t, state: e }) => {
  211. e && (e.originalRequest = t);
  212. }),
  213. (this.cachedResponseWillBeUsed = async ({
  214. event: t,
  215. state: e,
  216. cachedResponse: s
  217. }) => {
  218. if (
  219. 'install' === t.type &&
  220. e &&
  221. e.originalRequest &&
  222. e.originalRequest instanceof Request
  223. ) {
  224. const t = e.originalRequest.url;
  225. s ? this.notUpdatedURLs.push(t) : this.updatedURLs.push(t);
  226. }
  227. return s;
  228. });
  229. }
  230. }
  231. class g {
  232. constructor({ precacheController: t }) {
  233. (this.cacheKeyWillBeUsed = async ({ request: t, params: e }) => {
  234. const s =
  235. (null == e ? void 0 : e.cacheKey) || this.h.getCacheKeyForURL(t.url);
  236. return s ? new Request(s, { headers: t.headers }) : t;
  237. }),
  238. (this.h = t);
  239. }
  240. }
  241. let R;
  242. async function m(t, e) {
  243. let n = null;
  244. if (t.url) {
  245. n = new URL(t.url).origin;
  246. }
  247. if (n !== self.location.origin)
  248. throw new s('cross-origin-copy-response', { origin: n });
  249. const i = t.clone(),
  250. r = {
  251. headers: new Headers(i.headers),
  252. status: i.status,
  253. statusText: i.statusText
  254. },
  255. o = e ? e(r) : r,
  256. c = (function () {
  257. if (void 0 === R) {
  258. const t = new Response('');
  259. if ('body' in t)
  260. try {
  261. new Response(t.body), (R = !0);
  262. } catch (t) {
  263. R = !1;
  264. }
  265. R = !1;
  266. }
  267. return R;
  268. })()
  269. ? i.body
  270. : await i.blob();
  271. return new Response(c, o);
  272. }
  273. function v(t, e) {
  274. const s = new URL(t);
  275. for (const t of e) s.searchParams.delete(t);
  276. return s.href;
  277. }
  278. class q {
  279. constructor() {
  280. this.promise = new Promise((t, e) => {
  281. (this.resolve = t), (this.reject = e);
  282. });
  283. }
  284. }
  285. const U = new Set();
  286. try {
  287. self['workbox:strategies:7.0.0'] && _();
  288. } catch (t) {}
  289. function L(t) {
  290. return 'string' == typeof t ? new Request(t) : t;
  291. }
  292. class b {
  293. constructor(t, e) {
  294. (this.u = {}),
  295. Object.assign(this, e),
  296. (this.event = e.event),
  297. (this.l = t),
  298. (this.p = new q()),
  299. (this.g = []),
  300. (this.R = [...t.plugins]),
  301. (this.m = new Map());
  302. for (const t of this.R) this.m.set(t, {});
  303. this.event.waitUntil(this.p.promise);
  304. }
  305. async fetch(t) {
  306. const { event: e } = this;
  307. let n = L(t);
  308. // 检查预加载响应
  309. if ("navigate" === n.mode && e instanceof FetchEvent && e.preloadResponse) {
  310. const t = await e.preloadResponse;
  311. if (t) return t;
  312. }
  313. const i = this.hasCallback("fetchDidFail") ? n.clone() : null;
  314. try {
  315. // 执行 requestWillFetch 回调
  316. for (const t of this.iterateCallbacks("requestWillFetch")) {
  317. n = await t({
  318. request: n.clone(),
  319. event: e
  320. });
  321. }
  322. } catch (t) {
  323. if (t instanceof Error) {
  324. console.error("requestWillFetch error:", t);
  325. throw new s("plugin-error-request-will-fetch", {
  326. thrownErrorMessage: t.message
  327. });
  328. }
  329. }
  330. const r = n.clone();
  331. try {
  332. // 发起 fetch 请求
  333. let t = await fetch(n, "navigate" === n.mode ? void 0 : this.l.fetchOptions);
  334. // 执行 fetchDidSucceed 回调
  335. for (const s of this.iterateCallbacks("fetchDidSucceed")) {
  336. t = await s({
  337. event: e,
  338. request: r,
  339. response: t
  340. });
  341. }
  342. return t;
  343. } catch (t) {
  344. console.error("Fetch failed:", t);
  345. // 执行 fetchDidFail 回调
  346. if (i) {
  347. await this.runCallbacks("fetchDidFail", {
  348. error: t,
  349. event: e,
  350. originalRequest: i.clone(),
  351. request: r.clone()
  352. });
  353. }
  354. throw t;
  355. }
  356. }
  357. async fetchAndCachePut(t) {
  358. const e = await this.fetch(t),
  359. s = e.clone();
  360. return this.waitUntil(this.cachePut(t, s)), e;
  361. }
  362. async cacheMatch(t) {
  363. const e = L(t);
  364. let s;
  365. const { cacheName: n, matchOptions: i } = this.l,
  366. r = await this.getCacheKey(e, 'read'),
  367. o = Object.assign(Object.assign({}, i), { cacheName: n });
  368. s = await caches.match(r, o);
  369. for (const t of this.iterateCallbacks('cachedResponseWillBeUsed'))
  370. s =
  371. (await t({
  372. cacheName: n,
  373. matchOptions: i,
  374. cachedResponse: s,
  375. request: r,
  376. event: this.event
  377. })) || void 0;
  378. return s;
  379. }
  380. async cachePut(t, e) {
  381. const n = L(t);
  382. var i;
  383. await ((i = 0), new Promise(t => setTimeout(t, i)));
  384. const r = await this.getCacheKey(n, 'write');
  385. if (!e)
  386. throw new s('cache-put-with-no-response', {
  387. url:
  388. ((o = r.url),
  389. new URL(String(o), location.href).href.replace(
  390. new RegExp(`^${location.origin}`),
  391. ''
  392. ))
  393. });
  394. var o;
  395. const c = await this.v(e);
  396. if (!c) return !1;
  397. const { cacheName: a, matchOptions: h } = this.l,
  398. u = await self.caches.open(a),
  399. l = this.hasCallback('cacheDidUpdate'),
  400. f = l
  401. ? await (async function (t, e, s, n) {
  402. const i = v(e.url, s);
  403. if (e.url === i) return t.match(e, n);
  404. const r = Object.assign(Object.assign({}, n), {
  405. ignoreSearch: !0
  406. }),
  407. o = await t.keys(e, r);
  408. for (const e of o) if (i === v(e.url, s)) return t.match(e, n);
  409. })(u, r.clone(), ['__WB_REVISION__'], h)
  410. : null;
  411. try {
  412. await u.put(r, l ? c.clone() : c);
  413. } catch (t) {
  414. if (t instanceof Error)
  415. throw (
  416. ('QuotaExceededError' === t.name &&
  417. (await (async function () {
  418. for (const t of U) await t();
  419. })()),
  420. t)
  421. );
  422. }
  423. for (const t of this.iterateCallbacks('cacheDidUpdate'))
  424. await t({
  425. cacheName: a,
  426. oldResponse: f,
  427. newResponse: c.clone(),
  428. request: r,
  429. event: this.event
  430. });
  431. return !0;
  432. }
  433. async getCacheKey(t, e) {
  434. const s = `${t.url} | ${e}`;
  435. if (!this.u[s]) {
  436. let n = t;
  437. for (const t of this.iterateCallbacks('cacheKeyWillBeUsed'))
  438. n = L(
  439. await t({
  440. mode: e,
  441. request: n,
  442. event: this.event,
  443. params: this.params
  444. })
  445. );
  446. this.u[s] = n;
  447. }
  448. return this.u[s];
  449. }
  450. hasCallback(t) {
  451. for (const e of this.l.plugins) if (t in e) return !0;
  452. return !1;
  453. }
  454. async runCallbacks(t, e) {
  455. for (const s of this.iterateCallbacks(t)) await s(e);
  456. }
  457. *iterateCallbacks(t) {
  458. for (const e of this.l.plugins)
  459. if ('function' == typeof e[t]) {
  460. const s = this.m.get(e),
  461. n = n => {
  462. const i = Object.assign(Object.assign({}, n), { state: s });
  463. return e[t](i);
  464. };
  465. yield n;
  466. }
  467. }
  468. waitUntil(t) {
  469. return this.g.push(t), t;
  470. }
  471. async doneWaiting() {
  472. let t;
  473. for (; (t = this.g.shift()); ) await t;
  474. }
  475. destroy() {
  476. this.p.resolve(null);
  477. }
  478. async v(t) {
  479. let e = t,
  480. s = !1;
  481. for (const t of this.iterateCallbacks('cacheWillUpdate'))
  482. if (
  483. ((e =
  484. (await t({
  485. request: this.request,
  486. response: e,
  487. event: this.event
  488. })) || void 0),
  489. (s = !0),
  490. !e)
  491. )
  492. break;
  493. return s || (e && 200 !== e.status && (e = void 0)), e;
  494. }
  495. }
  496. class C {
  497. constructor(t = {}) {
  498. (this.cacheName = w(t.cacheName)),
  499. (this.plugins = t.plugins || []),
  500. (this.fetchOptions = t.fetchOptions),
  501. (this.matchOptions = t.matchOptions);
  502. }
  503. handle(t) {
  504. const [e] = this.handleAll(t);
  505. return e;
  506. }
  507. handleAll(t) {
  508. t instanceof FetchEvent && (t = { event: t, request: t.request });
  509. const e = t.event,
  510. s = 'string' == typeof t.request ? new Request(t.request) : t.request,
  511. n = 'params' in t ? t.params : void 0,
  512. i = new b(this, { event: e, request: s, params: n }),
  513. r = this.q(i, s, e);
  514. return [r, this.U(r, i, s, e)];
  515. }
  516. async q(t, e, n) {
  517. let i;
  518. await t.runCallbacks('handlerWillStart', { event: n, request: e });
  519. try {
  520. if (((i = await this.L(e, t)), !i || 'error' === i.type))
  521. throw new s('no-response', { url: e.url });
  522. } catch (s) {
  523. if (s instanceof Error)
  524. for (const r of t.iterateCallbacks('handlerDidError'))
  525. if (((i = await r({ error: s, event: n, request: e })), i)) break;
  526. if (!i) throw s;
  527. }
  528. for (const s of t.iterateCallbacks('handlerWillRespond'))
  529. i = await s({ event: n, request: e, response: i });
  530. return i;
  531. }
  532. async U(t, e, s, n) {
  533. let i, r;
  534. try {
  535. i = await t;
  536. } catch (r) {}
  537. try {
  538. await e.runCallbacks('handlerDidRespond', {
  539. event: n,
  540. request: s,
  541. response: i
  542. }),
  543. await e.doneWaiting();
  544. } catch (t) {
  545. t instanceof Error && (r = t);
  546. }
  547. if (
  548. (await e.runCallbacks('handlerDidComplete', {
  549. event: n,
  550. request: s,
  551. response: i,
  552. error: r
  553. }),
  554. e.destroy(),
  555. r)
  556. )
  557. throw r;
  558. }
  559. }
  560. class E extends C {
  561. constructor(t = {}) {
  562. (t.cacheName = f(t.cacheName)),
  563. super(t),
  564. (this._ = !1 !== t.fallbackToNetwork),
  565. this.plugins.push(E.copyRedirectedCacheableResponsesPlugin);
  566. }
  567. async L(t, e) {
  568. const s = await e.cacheMatch(t);
  569. return (
  570. s ||
  571. (e.event && 'install' === e.event.type
  572. ? await this.C(t, e)
  573. : await this.O(t, e))
  574. );
  575. }
  576. async O(t, e) {
  577. let n;
  578. const i = e.params || {};
  579. if (!this._)
  580. throw new s('missing-precache-entry', {
  581. cacheName: this.cacheName,
  582. url: t.url
  583. });
  584. {
  585. const s = i.integrity,
  586. r = t.integrity,
  587. o = !r || r === s;
  588. (n = await e.fetch(
  589. new Request(t, { integrity: 'no-cors' !== t.mode ? r || s : void 0 })
  590. )),
  591. s &&
  592. o &&
  593. 'no-cors' !== t.mode &&
  594. (this.N(), await e.cachePut(t, n.clone()));
  595. }
  596. return n;
  597. }
  598. async C(t, e) {
  599. this.N();
  600. const n = await e.fetch(t);
  601. if (!(await e.cachePut(t, n.clone())))
  602. throw new s('bad-precaching-response', {
  603. url: t.url,
  604. status: n.status
  605. });
  606. return n;
  607. }
  608. N() {
  609. let t = null,
  610. e = 0;
  611. for (const [s, n] of this.plugins.entries())
  612. n !== E.copyRedirectedCacheableResponsesPlugin &&
  613. (n === E.defaultPrecacheCacheabilityPlugin && (t = s),
  614. n.cacheWillUpdate && e++);
  615. 0 === e
  616. ? this.plugins.push(E.defaultPrecacheCacheabilityPlugin)
  617. : e > 1 && null !== t && this.plugins.splice(t, 1);
  618. }
  619. }
  620. (E.defaultPrecacheCacheabilityPlugin = {
  621. cacheWillUpdate: async ({ response: t }) =>
  622. !t || t.status >= 400 ? null : t
  623. }),
  624. (E.copyRedirectedCacheableResponsesPlugin = {
  625. cacheWillUpdate: async ({ response: t }) =>
  626. t.redirected ? await m(t) : t
  627. });
  628. class O {
  629. constructor({
  630. cacheName: t,
  631. plugins: e = [],
  632. fallbackToNetwork: s = !0
  633. } = {}) {
  634. (this.k = new Map()),
  635. (this.K = new Map()),
  636. (this.P = new Map()),
  637. (this.l = new E({
  638. cacheName: f(t),
  639. plugins: [...e, new g({ precacheController: this })],
  640. fallbackToNetwork: s
  641. })),
  642. (this.install = this.install.bind(this)),
  643. (this.activate = this.activate.bind(this));
  644. }
  645. get strategy() {
  646. return this.l;
  647. }
  648. precache(t) {
  649. this.addToCacheList(t),
  650. this.T ||
  651. (self.addEventListener('install', this.install),
  652. self.addEventListener('activate', this.activate),
  653. (this.T = !0));
  654. }
  655. addToCacheList(t) {
  656. const e = [];
  657. for (const n of t) {
  658. 'string' == typeof n
  659. ? e.push(n)
  660. : n && void 0 === n.revision && e.push(n.url);
  661. const { cacheKey: t, url: i } = p(n),
  662. r = 'string' != typeof n && n.revision ? 'reload' : 'default';
  663. if (this.k.has(i) && this.k.get(i) !== t)
  664. throw new s('add-to-cache-list-conflicting-entries', {
  665. firstEntry: this.k.get(i),
  666. secondEntry: t
  667. });
  668. if ('string' != typeof n && n.integrity) {
  669. if (this.P.has(t) && this.P.get(t) !== n.integrity)
  670. throw new s('add-to-cache-list-conflicting-integrities', {
  671. url: i
  672. });
  673. this.P.set(t, n.integrity);
  674. }
  675. if ((this.k.set(i, t), this.K.set(i, r), e.length > 0)) {
  676. const t = `Workbox is precaching URLs without revision info: ${e.join(
  677. ', '
  678. )}\nThis is generally NOT safe. Learn more at https://bit.ly/wb-precache`;
  679. console.warn(t);
  680. }
  681. }
  682. }
  683. install(t) {
  684. return d(t, async () => {
  685. const e = new y();
  686. this.strategy.plugins.push(e);
  687. for (const [e, s] of this.k) {
  688. const n = this.P.get(s),
  689. i = this.K.get(e),
  690. r = new Request(e, {
  691. integrity: n,
  692. cache: i,
  693. credentials: 'same-origin'
  694. });
  695. await Promise.all(
  696. this.strategy.handleAll({
  697. params: { cacheKey: s },
  698. request: r,
  699. event: t
  700. })
  701. );
  702. }
  703. const { updatedURLs: s, notUpdatedURLs: n } = e;
  704. return { updatedURLs: s, notUpdatedURLs: n };
  705. });
  706. }
  707. activate(t) {
  708. return d(t, async () => {
  709. const t = await self.caches.open(this.strategy.cacheName),
  710. e = await t.keys(),
  711. s = new Set(this.k.values()),
  712. n = [];
  713. for (const i of e) s.has(i.url) || (await t.delete(i), n.push(i.url));
  714. return { deletedURLs: n };
  715. });
  716. }
  717. getURLsToCacheKeys() {
  718. return this.k;
  719. }
  720. getCachedURLs() {
  721. return [...this.k.keys()];
  722. }
  723. getCacheKeyForURL(t) {
  724. const e = new URL(t, location.href);
  725. return this.k.get(e.href);
  726. }
  727. getIntegrityForCacheKey(t) {
  728. return this.P.get(t);
  729. }
  730. async matchPrecache(t) {
  731. const e = t instanceof Request ? t.url : t,
  732. s = this.getCacheKeyForURL(e);
  733. if (s) {
  734. return (await self.caches.open(this.strategy.cacheName)).match(s);
  735. }
  736. }
  737. createHandlerBoundToURL(t) {
  738. const e = this.getCacheKeyForURL(t);
  739. if (!e) throw new s('non-precached-url', { url: t });
  740. return s => (
  741. (s.request = new Request(t)),
  742. (s.params = Object.assign({ cacheKey: e }, s.params)),
  743. this.strategy.handle(s)
  744. );
  745. }
  746. }
  747. let x;
  748. const N = () => (x || (x = new O()), x);
  749. class k extends i {
  750. constructor(t, e) {
  751. super(({ request: s }) => {
  752. const n = t.getURLsToCacheKeys();
  753. for (const i of (function* (
  754. t,
  755. {
  756. ignoreURLParametersMatching: e = [/^utm_/, /^fbclid$/],
  757. directoryIndex: s = 'index.html',
  758. cleanURLs: n = !0,
  759. urlManipulation: i
  760. } = {}
  761. ) {
  762. const r = new URL(t, location.href);
  763. (r.hash = ''), yield r.href;
  764. const o = (function (t, e = []) {
  765. for (const s of [...t.searchParams.keys()])
  766. e.some(t => t.test(s)) && t.searchParams.delete(s);
  767. return t;
  768. })(r, e);
  769. if ((yield o.href, s && o.pathname.endsWith('/'))) {
  770. const t = new URL(o.href);
  771. (t.pathname += s), yield t.href;
  772. }
  773. if (n) {
  774. const t = new URL(o.href);
  775. (t.pathname += '.html'), yield t.href;
  776. }
  777. if (i) {
  778. const t = i({ url: r });
  779. for (const e of t) yield e.href;
  780. }
  781. })(s.url, e)) {
  782. const e = n.get(i);
  783. if (e) {
  784. return { cacheKey: e, integrity: t.getIntegrityForCacheKey(e) };
  785. }
  786. }
  787. }, t.strategy);
  788. }
  789. }
  790. (t.NavigationRoute = class extends i {
  791. constructor(t, { allowlist: e = [/./], denylist: s = [] } = {}) {
  792. super(t => this.W(t), t), (this.j = e), (this.M = s);
  793. }
  794. W({ url: t, request: e }) {
  795. if (e && 'navigate' !== e.mode) return !1;
  796. const s = t.pathname + t.search;
  797. for (const t of this.M) if (t.test(s)) return !1;
  798. return !!this.j.some(t => t.test(s));
  799. }
  800. }),
  801. (t.cleanupOutdatedCaches = function () {
  802. self.addEventListener('activate', t => {
  803. const e = f();
  804. t.waitUntil(
  805. (async (t, e = '-precache-') => {
  806. const s = (await self.caches.keys()).filter(
  807. s =>
  808. s.includes(e) && s.includes(self.registration.scope) && s !== t
  809. );
  810. return await Promise.all(s.map(t => self.caches.delete(t))), s;
  811. })(e).then(t => {})
  812. );
  813. });
  814. }),
  815. (t.createHandlerBoundToURL = function (t) {
  816. return N().createHandlerBoundToURL(t);
  817. }),
  818. (t.precacheAndRoute = function (t, e) {
  819. !(function (t) {
  820. N().precache(t);
  821. })(t),
  822. (function (t) {
  823. const e = N();
  824. h(new k(e, t));
  825. })(e);
  826. }),
  827. (t.registerRoute = h);
  828. });