diff --git a/api/index.ts b/api/index.ts index 2849a9b..8e2cda1 100644 --- a/api/index.ts +++ b/api/index.ts @@ -5,11 +5,8 @@ import { cookies } from 'next/headers'; import { createUniqueRandomGenerator } from '@/lib/utils'; import mapMoviesSeriesResponseToShows, { mapMovieSeriesToShow } from './dto/Show'; -import pirateBay from './parsers/pirate-bay'; import toloka from './parsers/toloka'; -import yts from './parsers/yts'; import http from './Http'; -import { Sort } from './parsers'; const session = () => cookies().get('session')?.value; @@ -238,54 +235,4 @@ export const credits = async ({ }); }; -export const trailers = async ({ - showId, - showType -}: { - showId: Show['id']; - showType?: Show['type']; -}): Promise => { - return http - .get<{ id: number; results: Trailer[] }>(`/${showType}/${showId}/videos`, { - params: { - language: 'en-US' - } - }) - .then((data) => data.results); -}; - -export const YTSTorrents = async ({ query, sort, imdbID }: { imdbID: string; query: string; sort: Sort }) => { - try { - return yts.search({ - imdbID, - query, - sort - }); - } catch (error) { - return []; - } -}; - -export const TPBTorrents = async ({ query, sort }: { imdbID: string; query: string; sort: Sort }) => { - try { - return pirateBay.search({ - query, - sort - }); - } catch (error) { - return []; - } -}; - -export const TLKTorrents = async ({ query, sort }: { imdbID: string; query: string; sort: Sort }) => { - try { - return toloka.search({ - query, - sort - }); - } catch (error) { - return []; - } -}; - -export const fetchTLKMagnet = async (url: string) => toloka.magnet(url); \ No newline at end of file +export const fetchTLKMagnet = async (url: string) => toloka.magnet(url); diff --git a/api/parsers/toloka.ts b/api/parsers/toloka.ts index 21737dd..decb2de 100644 --- a/api/parsers/toloka.ts +++ b/api/parsers/toloka.ts @@ -18,7 +18,7 @@ export class Toloka { this.host = host; this.client = axios.create({ baseURL: this.host, - headers: { Cookie: 'toloka_sid=0504c23f6b4fc00d39530cfa78f8d767; toloka_ssl=1' } + headers: { Cookie: 'toloka_sid=e9693224d00c5b60af50c2596d1b880d; toloka_ssl=1' } }); } diff --git a/app/api/torrents/route.ts b/app/api/torrents/route.ts new file mode 100644 index 0000000..ff5ef8d --- /dev/null +++ b/app/api/torrents/route.ts @@ -0,0 +1,21 @@ +import { NextRequest } from 'next/server'; + +import { Sort } from '@/api/parsers'; +import pirateBay from '@/api/parsers/pirate-bay'; +import toloka from '@/api/parsers/toloka'; +import yts from '@/api/parsers/yts'; + +export async function GET({ nextUrl: { searchParams } }: NextRequest) { + const key = searchParams.get('key') as keyof typeof providers; + const imdbID = searchParams.get('imdbID') as string; + const query = searchParams.get('query') as string; + const sort = searchParams.get('sort') as Sort; + + const providers = { yts: yts, tpb: pirateBay, tlk: toloka }; + + try { + return Response.json(await providers[key].search({ imdbID, query, sort })); + } catch (_) { + return Response.json([]); + } +} diff --git a/components/Preview/components/Torrents/constants.ts b/components/Preview/components/Torrents/constants.ts index 5c37099..84cd182 100644 --- a/components/Preview/components/Torrents/constants.ts +++ b/components/Preview/components/Torrents/constants.ts @@ -1,7 +1,27 @@ -import { TLKTorrents, TPBTorrents, YTSTorrents } from '@/api'; +import { Sort } from '@/api/parsers'; + +type Options = { query: string; sort: Sort; imdbID: string }; + +const queryFn = ({ query, sort, imdbID, key }: Options & { key: keyof typeof providers }) => + fetch(`/api/torrents?key=${key}&query=${query}&sort=${sort}&imdbID=${imdbID}`).then((response) => response.json()); export const providers = { - yts: { label: 'YTS', key: 'yts', queryFn: YTSTorrents, sortable: false }, - tpb: { label: 'The Pirate Bay', key: 'tpb', queryFn: TPBTorrents, sortable: true }, - tlk: { label: 'Toloka', key: 'tlk', queryFn: TLKTorrents, sortable: true } + yts: { + label: 'YTS', + key: 'yts', + queryFn: (options: Options) => queryFn({ ...options, key: 'yts' }), + sortable: false + }, + tpb: { + label: 'The Pirate Bay', + key: 'tpb', + queryFn: (options: Options) => queryFn({ ...options, key: 'tpb' }), + sortable: true + }, + tlk: { + label: 'Toloka', + key: 'tlk', + queryFn: (options: Options) => queryFn({ ...options, key: 'tlk' }), + sortable: true + } }; diff --git a/public/sw.js b/public/sw.js index 248524d..3613b12 100644 --- a/public/sw.js +++ b/public/sw.js @@ -1 +1 @@ -if(!self.define){let e,s={};const a=(a,n)=>(a=new URL(a+".js",n).href,s[a]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=a,e.onload=s,document.head.appendChild(e)}else e=a,importScripts(a),s()})).then((()=>{let e=s[a];if(!e)throw new Error(`Module ${a} didn’t register its module`);return e})));self.define=(n,c)=>{const i=e||("document"in self?document.currentScript.src:"")||location.href;if(s[i])return;let t={};const r=e=>a(e,i),u={module:{uri:i},exports:t,require:r};s[i]=Promise.all(n.map((e=>u[e]||r(e)))).then((e=>(c(...e),t)))}}define(["./workbox-4754cb34"],(function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"2f5a1d17c836a7f987c5aad8087f7f69"},{url:"/_next/static/chunks/152.e619d8b05424829e.js",revision:"e619d8b05424829e"},{url:"/_next/static/chunks/23-e95fe3862375276d.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/26.286553a5ff2812fc.js",revision:"286553a5ff2812fc"},{url:"/_next/static/chunks/276.c3c1130f2adade69.js",revision:"c3c1130f2adade69"},{url:"/_next/static/chunks/311-cfac2c6c6bc4f409.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/344.05938a041227e582.js",revision:"05938a041227e582"},{url:"/_next/static/chunks/37-f6e2aef0dac1a9f4.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/383.78d47f7582340f53.js",revision:"78d47f7582340f53"},{url:"/_next/static/chunks/460.ac20021c7496f1d6.js",revision:"ac20021c7496f1d6"},{url:"/_next/static/chunks/497.a16beaad36f500fe.js",revision:"a16beaad36f500fe"},{url:"/_next/static/chunks/61.e269d4a699fba0b6.js",revision:"e269d4a699fba0b6"},{url:"/_next/static/chunks/621-fa4d2ff1cf645813.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/673.362c29137dd3e968.js",revision:"362c29137dd3e968"},{url:"/_next/static/chunks/693-2767062d917b3456.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/695.156d21364de6e419.js",revision:"156d21364de6e419"},{url:"/_next/static/chunks/755.5cd959eac5682527.js",revision:"5cd959eac5682527"},{url:"/_next/static/chunks/792.b51012549074b93f.js",revision:"b51012549074b93f"},{url:"/_next/static/chunks/810.6105e84414768b0d.js",revision:"6105e84414768b0d"},{url:"/_next/static/chunks/922.9ce4bf0553cfb724.js",revision:"9ce4bf0553cfb724"},{url:"/_next/static/chunks/957-9f7dee59febd35c3.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/app/(site)/favorites/page-597921ef02c719df.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/app/(site)/loading-96645736797edde7.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/app/(site)/page-50279285390a6523.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/app/(site)/popular/page-b24c2917fc8bafde.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/app/(site)/similar/page-76c09599bd10ea14.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/app/(site)/starring/page-cddd4e2d83614eda.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/app/(site)/top/page-489f98dd6cd2a463.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/app/(site)/watch-list/page-e3f529e210a2a8e9.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/app/_not-found/page-aa0c8e90320336c2.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/app/layout-e78d8a67bc5fd6ae.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/c8bcbd21.63daf74955ffea8b.js",revision:"63daf74955ffea8b"},{url:"/_next/static/chunks/fd9d1056-bdf7d185613ab264.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/framework-f66176bb897dc684.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/main-af50ab4bffe3e017.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/main-app-51cdaff1a81e6b49.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/pages/_app-6a626577ffa902a4.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/pages/_error-1be831200e60c5c0.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-d4343f8c473d689d.js",revision:"mc2DxrE-1g9uq61LbuNSz"},{url:"/_next/static/css/0d5f6452b2682b9b.css",revision:"0d5f6452b2682b9b"},{url:"/_next/static/css/af880b2e4df9cb52.css",revision:"af880b2e4df9cb52"},{url:"/_next/static/mc2DxrE-1g9uq61LbuNSz/_buildManifest.js",revision:"2ec694eb52ae4f523f265a46bae4d768"},{url:"/_next/static/mc2DxrE-1g9uq61LbuNSz/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/media/46c21389e888bf13-s.woff2",revision:"272930c09ba14c81bb294be1fe18b049"},{url:"/_next/static/media/8888a3826f4a3af4-s.p.woff2",revision:"792477d09826b11d1e5a611162c9797a"},{url:"/_next/static/media/eafabf029ad39a43-s.p.woff2",revision:"43751174b6b810eb169101a20d8c26f8"},{url:"/_next/static/media/f5767adec246cdc1-s.woff2",revision:"7a1c6501aa2b3327c1cf556362a851cb"},{url:"/apple-touch-icon.png",revision:"6ed7ad78b222698b2872b5a7f104fe08"},{url:"/favicon-48x48.png",revision:"d2db6eb5ce8ce1da63114250c9652da7"},{url:"/favicon.ico",revision:"d7c46eb2b2574863f72315ed861b1c99"},{url:"/favicon.svg",revision:"15b76ab693bd3a8320d8f8778332d396"},{url:"/manifest.json",revision:"5707bda32aaccb2ce142908f0baf8a1b"},{url:"/web-app-manifest-192x192.png",revision:"5d8538e4362b4ddbd7ff195fb24c25dc"},{url:"/web-app-manifest-512x512.png",revision:"e0a092cab607727cbe6f61adb0b1e6cf"}],{ignoreURLParametersMatching:[]}),e.cleanupOutdatedCaches(),e.registerRoute("/",new e.NetworkFirst({cacheName:"start-url",plugins:[{cacheWillUpdate:async({request:e,response:s,event:a,state:n})=>s&&"opaqueredirect"===s.type?new Response(s.body,{status:200,statusText:"OK",headers:s.headers}):s}]}),"GET"),e.registerRoute(/^https:\/\/fonts\.(?:gstatic)\.com\/.*/i,new e.CacheFirst({cacheName:"google-fonts-webfonts",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:31536e3})]}),"GET"),e.registerRoute(/^https:\/\/fonts\.(?:googleapis)\.com\/.*/i,new e.StaleWhileRevalidate({cacheName:"google-fonts-stylesheets",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:604800})]}),"GET"),e.registerRoute(/\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,new e.StaleWhileRevalidate({cacheName:"static-font-assets",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:604800})]}),"GET"),e.registerRoute(/\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,new e.StaleWhileRevalidate({cacheName:"static-image-assets",plugins:[new e.ExpirationPlugin({maxEntries:64,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\/_next\/image\?url=.+$/i,new e.StaleWhileRevalidate({cacheName:"next-image",plugins:[new e.ExpirationPlugin({maxEntries:64,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:mp3|wav|ogg)$/i,new e.CacheFirst({cacheName:"static-audio-assets",plugins:[new e.RangeRequestsPlugin,new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:mp4)$/i,new e.CacheFirst({cacheName:"static-video-assets",plugins:[new e.RangeRequestsPlugin,new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:js)$/i,new e.StaleWhileRevalidate({cacheName:"static-js-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:css|less)$/i,new e.StaleWhileRevalidate({cacheName:"static-style-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\/_next\/data\/.+\/.+\.json$/i,new e.StaleWhileRevalidate({cacheName:"next-data",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:json|xml|csv)$/i,new e.NetworkFirst({cacheName:"static-data-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute((({url:e})=>{if(!(self.origin===e.origin))return!1;const s=e.pathname;return!s.startsWith("/api/auth/")&&!!s.startsWith("/api/")}),new e.NetworkFirst({cacheName:"apis",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:16,maxAgeSeconds:86400})]}),"GET"),e.registerRoute((({url:e})=>{if(!(self.origin===e.origin))return!1;return!e.pathname.startsWith("/api/")}),new e.NetworkFirst({cacheName:"others",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute((({url:e})=>!(self.origin===e.origin)),new e.NetworkFirst({cacheName:"cross-origin",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:3600})]}),"GET")})); +if(!self.define){let e,s={};const a=(a,n)=>(a=new URL(a+".js",n).href,s[a]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=a,e.onload=s,document.head.appendChild(e)}else e=a,importScripts(a),s()})).then((()=>{let e=s[a];if(!e)throw new Error(`Module ${a} didn’t register its module`);return e})));self.define=(n,i)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let c={};const r=e=>a(e,t),o={module:{uri:t},exports:c,require:r};s[t]=Promise.all(n.map((e=>o[e]||r(e)))).then((e=>(i(...e),c)))}}define(["./workbox-4754cb34"],(function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"1df7667facd62f5f4fa582d1ba88c5cb"},{url:"/_next/static/EWvUMAZar8b7EDkgXgAVh/_buildManifest.js",revision:"2ec694eb52ae4f523f265a46bae4d768"},{url:"/_next/static/EWvUMAZar8b7EDkgXgAVh/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/152.e619d8b05424829e.js",revision:"e619d8b05424829e"},{url:"/_next/static/chunks/23-e95fe3862375276d.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/26.286553a5ff2812fc.js",revision:"286553a5ff2812fc"},{url:"/_next/static/chunks/276.c3c1130f2adade69.js",revision:"c3c1130f2adade69"},{url:"/_next/static/chunks/311-217b9962adac0d58.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/344.05938a041227e582.js",revision:"05938a041227e582"},{url:"/_next/static/chunks/37-f6e2aef0dac1a9f4.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/383.78d47f7582340f53.js",revision:"78d47f7582340f53"},{url:"/_next/static/chunks/460.ac20021c7496f1d6.js",revision:"ac20021c7496f1d6"},{url:"/_next/static/chunks/497.a16beaad36f500fe.js",revision:"a16beaad36f500fe"},{url:"/_next/static/chunks/61.e269d4a699fba0b6.js",revision:"e269d4a699fba0b6"},{url:"/_next/static/chunks/621-fa4d2ff1cf645813.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/673.362c29137dd3e968.js",revision:"362c29137dd3e968"},{url:"/_next/static/chunks/693-2767062d917b3456.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/695.156d21364de6e419.js",revision:"156d21364de6e419"},{url:"/_next/static/chunks/755.5cd959eac5682527.js",revision:"5cd959eac5682527"},{url:"/_next/static/chunks/792.b51012549074b93f.js",revision:"b51012549074b93f"},{url:"/_next/static/chunks/810.6105e84414768b0d.js",revision:"6105e84414768b0d"},{url:"/_next/static/chunks/922.9ce4bf0553cfb724.js",revision:"9ce4bf0553cfb724"},{url:"/_next/static/chunks/957-9f7dee59febd35c3.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/favorites/page-597921ef02c719df.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/loading-96645736797edde7.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/page-50279285390a6523.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/popular/page-b24c2917fc8bafde.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/similar/page-76c09599bd10ea14.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/starring/page-cddd4e2d83614eda.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/top/page-489f98dd6cd2a463.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/watch-list/page-e3f529e210a2a8e9.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/_not-found/page-aa0c8e90320336c2.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/layout-e78d8a67bc5fd6ae.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/c8bcbd21.63daf74955ffea8b.js",revision:"63daf74955ffea8b"},{url:"/_next/static/chunks/fd9d1056-bdf7d185613ab264.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/framework-f66176bb897dc684.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/main-af50ab4bffe3e017.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/main-app-51cdaff1a81e6b49.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/pages/_app-6a626577ffa902a4.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/pages/_error-1be831200e60c5c0.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-d4343f8c473d689d.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/css/0d5f6452b2682b9b.css",revision:"0d5f6452b2682b9b"},{url:"/_next/static/css/af880b2e4df9cb52.css",revision:"af880b2e4df9cb52"},{url:"/_next/static/media/46c21389e888bf13-s.woff2",revision:"272930c09ba14c81bb294be1fe18b049"},{url:"/_next/static/media/8888a3826f4a3af4-s.p.woff2",revision:"792477d09826b11d1e5a611162c9797a"},{url:"/_next/static/media/eafabf029ad39a43-s.p.woff2",revision:"43751174b6b810eb169101a20d8c26f8"},{url:"/_next/static/media/f5767adec246cdc1-s.woff2",revision:"7a1c6501aa2b3327c1cf556362a851cb"},{url:"/apple-touch-icon.png",revision:"6ed7ad78b222698b2872b5a7f104fe08"},{url:"/favicon-48x48.png",revision:"d2db6eb5ce8ce1da63114250c9652da7"},{url:"/favicon.ico",revision:"d7c46eb2b2574863f72315ed861b1c99"},{url:"/favicon.svg",revision:"15b76ab693bd3a8320d8f8778332d396"},{url:"/manifest.json",revision:"5707bda32aaccb2ce142908f0baf8a1b"},{url:"/web-app-manifest-192x192.png",revision:"5d8538e4362b4ddbd7ff195fb24c25dc"},{url:"/web-app-manifest-512x512.png",revision:"e0a092cab607727cbe6f61adb0b1e6cf"}],{ignoreURLParametersMatching:[]}),e.cleanupOutdatedCaches(),e.registerRoute("/",new e.NetworkFirst({cacheName:"start-url",plugins:[{cacheWillUpdate:async({request:e,response:s,event:a,state:n})=>s&&"opaqueredirect"===s.type?new Response(s.body,{status:200,statusText:"OK",headers:s.headers}):s}]}),"GET"),e.registerRoute(/^https:\/\/fonts\.(?:gstatic)\.com\/.*/i,new e.CacheFirst({cacheName:"google-fonts-webfonts",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:31536e3})]}),"GET"),e.registerRoute(/^https:\/\/fonts\.(?:googleapis)\.com\/.*/i,new e.StaleWhileRevalidate({cacheName:"google-fonts-stylesheets",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:604800})]}),"GET"),e.registerRoute(/\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,new e.StaleWhileRevalidate({cacheName:"static-font-assets",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:604800})]}),"GET"),e.registerRoute(/\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,new e.StaleWhileRevalidate({cacheName:"static-image-assets",plugins:[new e.ExpirationPlugin({maxEntries:64,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\/_next\/image\?url=.+$/i,new e.StaleWhileRevalidate({cacheName:"next-image",plugins:[new e.ExpirationPlugin({maxEntries:64,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:mp3|wav|ogg)$/i,new e.CacheFirst({cacheName:"static-audio-assets",plugins:[new e.RangeRequestsPlugin,new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:mp4)$/i,new e.CacheFirst({cacheName:"static-video-assets",plugins:[new e.RangeRequestsPlugin,new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:js)$/i,new e.StaleWhileRevalidate({cacheName:"static-js-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:css|less)$/i,new e.StaleWhileRevalidate({cacheName:"static-style-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\/_next\/data\/.+\/.+\.json$/i,new e.StaleWhileRevalidate({cacheName:"next-data",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:json|xml|csv)$/i,new e.NetworkFirst({cacheName:"static-data-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute((({url:e})=>{if(!(self.origin===e.origin))return!1;const s=e.pathname;return!s.startsWith("/api/auth/")&&!!s.startsWith("/api/")}),new e.NetworkFirst({cacheName:"apis",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:16,maxAgeSeconds:86400})]}),"GET"),e.registerRoute((({url:e})=>{if(!(self.origin===e.origin))return!1;return!e.pathname.startsWith("/api/")}),new e.NetworkFirst({cacheName:"others",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute((({url:e})=>!(self.origin===e.origin)),new e.NetworkFirst({cacheName:"cross-origin",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:3600})]}),"GET")}));