Your Name 1912bcd25b
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
chore: sync all remaining local workspace changes
2026-05-08 11:26:57 +08:00

1344 lines
44 KiB
JavaScript

/*
* Extracted from browser-delivered Turbopack chunk: 5d5b47876e53e564.da1ba52a93.js
* Module id: 68461
* For reading/searching only; this factory depends on the original Turbopack runtime.
*/
const moduleFactory = (e, t, r) => {
"use strict";
let n;
Object.defineProperty(r, "__esModule", { value: !0 });
var o = {
createKey: function () {
return K;
},
default: function () {
return Q;
},
matchesMiddleware: function () {
return H;
},
};
for (var a in o) Object.defineProperty(r, a, { enumerable: !0, get: o[a] });
let i = e.r(481258),
l = e.r(744066),
s = e.r(239314),
c = e.r(656297),
u = e.r(111894),
d = l._(e.r(194334)),
f = e.r(634778),
m = e.r(522741),
p = i._(e.r(924433)),
h = e.r(911861),
g = e.r(683302),
b = e.r(107174),
v = e.r(453636),
_ = e.r(790237),
y = e.r(390063);
e.r(853553);
let x = e.r(969674),
C = e.r(577226),
E = e.r(645181),
S = e.r(381609),
w = e.r(175744),
k = e.r(367803),
j = e.r(608334),
P = e.r(173169),
R = e.r(73465),
N = e.r(424701),
$ = e.r(714783),
O = e.r(401636),
T = e.r(367750),
M = e.r(571864),
I = e.r(479682),
A = e.r(225185),
L = e.r(695283),
B = e.r(523426);
function D() {
return Object.assign(
Object.defineProperty(Error("Route Cancelled"), "__NEXT_ERROR_CODE", {
value: "E315",
enumerable: !1,
configurable: !0,
}),
{ cancelled: !0 },
);
}
async function H(e) {
let t = await Promise.resolve(e.router.pageLoader.getMiddleware());
if (!t) return !1;
let { pathname: r } = (0, x.parsePath)(e.asPath),
n = (0, k.hasBasePath)(r) ? (0, S.removeBasePath)(r) : r,
o = (0, w.addBasePath)((0, C.addLocale)(n, e.locale));
return t.some((e) => new RegExp(e.regexp).test(o));
}
function z(e) {
let t = (0, h.getLocationOrigin)();
return e.startsWith(t) ? e.substring(t.length) : e;
}
function W(e, t, r) {
let [n, o] = (0, j.resolveHref)(e, t, !0),
a = (0, h.getLocationOrigin)(),
i = n.startsWith(a),
l = o && o.startsWith(a);
(n = z(n)), (o = o ? z(o) : o);
let s = i ? n : (0, w.addBasePath)(n),
c = r ? z((0, j.resolveHref)(e, r)) : o || n;
return { url: s, as: l ? c : (0, w.addBasePath)(c) };
}
function F(e, t) {
let r = (0, s.removeTrailingSlash)((0, f.denormalizePagePath)(e));
return "/404" === r || "/_error" === r
? e
: (t.includes(r) ||
t.some((t) => {
if (
(0, g.isDynamicRoute)(t) &&
(0, _.getRouteRegex)(t).re.test(r)
)
return (e = t), !0;
}),
(0, s.removeTrailingSlash)(e));
}
async function U(e) {
if (!(await H(e)) || !e.fetchData) return null;
let t = await e.fetchData(),
r = await (function (e, t, r) {
let o = {
basePath: r.router.basePath,
i18n: { locales: r.router.locales },
trailingSlash: !1,
},
a = t.headers.get("x-nextjs-rewrite"),
i = a || t.headers.get("x-nextjs-matched-path"),
l = t.headers.get(L.MATCHED_PATH_HEADER);
if (
(!l ||
i ||
l.includes("__next_data_catchall") ||
l.includes("/_error") ||
l.includes("/404") ||
(i = l),
i)
) {
if (i.startsWith("/")) {
let t = (0, b.parseRelativeUrl)(i),
l = (0, R.getNextPathnameInfo)(t.pathname, {
nextConfig: o,
parseData: !0,
}),
u = (0, s.removeTrailingSlash)(l.pathname);
return Promise.all([
r.router.pageLoader.getPageList(),
(0, c.getClientBuildManifest)(),
]).then(([o, { __rewrites: i }]) => {
let s = (0, C.addLocale)(l.pathname, l.locale);
if (
(0, g.isDynamicRoute)(s) ||
(!a &&
o.includes(
(0, m.normalizeLocalePath)(
(0, S.removeBasePath)(s),
r.router.locales,
).pathname,
))
) {
let r = (0, R.getNextPathnameInfo)(
(0, b.parseRelativeUrl)(e).pathname,
{ nextConfig: void 0, parseData: !0 },
);
t.pathname = s = (0, w.addBasePath)(r.pathname);
}
{
let e = n(s, o, i, t.query, (e) => F(e, o), r.router.locales);
e.matchedPage &&
((t.pathname = e.parsedAs.pathname),
(s = t.pathname),
Object.assign(t.query, e.parsedAs.query));
}
let c = o.includes(u)
? u
: F(
(0, m.normalizeLocalePath)(
(0, S.removeBasePath)(t.pathname),
r.router.locales,
).pathname,
o,
);
if ((0, g.isDynamicRoute)(c)) {
let e = (0, v.getRouteMatcher)((0, _.getRouteRegex)(c))(s);
Object.assign(t.query, e || {});
}
return { type: "rewrite", parsedAs: t, resolvedHref: c };
});
}
let t = (0, x.parsePath)(e),
l = (0, N.formatNextPathnameInfo)({
...(0, R.getNextPathnameInfo)(t.pathname, {
nextConfig: o,
parseData: !0,
}),
defaultLocale: r.router.defaultLocale,
buildId: "",
});
return Promise.resolve({
type: "redirect-external",
destination: `${l}${t.query}${t.hash}`,
});
}
let u = t.headers.get("x-nextjs-redirect");
if (u) {
if (u.startsWith("/")) {
let e = (0, x.parsePath)(u),
t = (0, N.formatNextPathnameInfo)({
...(0, R.getNextPathnameInfo)(e.pathname, {
nextConfig: o,
parseData: !0,
}),
defaultLocale: r.router.defaultLocale,
buildId: "",
});
return Promise.resolve({
type: "redirect-internal",
newAs: `${t}${e.query}${e.hash}`,
newUrl: `${t}${e.query}${e.hash}`,
});
}
return Promise.resolve({
type: "redirect-external",
destination: u,
});
}
return Promise.resolve({ type: "next" });
})(t.dataHref, t.response, e);
return {
dataHref: t.dataHref,
json: t.json,
response: t.response,
text: t.text,
cacheKey: t.cacheKey,
effect: r,
};
}
n = e.r(280732).default;
let G = Symbol("SSG_DATA_NOT_FOUND");
function q(e) {
try {
return JSON.parse(e);
} catch (e) {
return null;
}
}
function X({
dataHref: e,
inflightCache: t,
isPrefetch: r,
hasMiddleware: n,
isServerRender: o,
parseJSON: a,
persistCache: i,
isBackground: l,
unstable_skipClientCache: s,
}) {
let { href: u } = new URL(e, window.location.href),
d = (0, B.getDeploymentId)(),
f = (l) =>
(function e(t, r, n) {
return fetch(t, {
credentials: "same-origin",
method: n.method || "GET",
headers: Object.assign({}, n.headers, { "x-nextjs-data": "1" }),
}).then((o) =>
!o.ok && r > 1 && o.status >= 500 ? e(t, r - 1, n) : o,
);
})(e, o ? 3 : 1, {
headers: Object.assign(
{},
r ? { purpose: "prefetch" } : {},
r && n ? { "x-middleware-prefetch": "1" } : {},
d ? { "x-deployment-id": d } : {},
),
method: l?.method ?? "GET",
})
.then((t) =>
t.ok && l?.method === "HEAD"
? { dataHref: e, response: t, text: "", json: {}, cacheKey: u }
: t.text().then((r) => {
if (!t.ok) {
if (n && [301, 302, 307, 308].includes(t.status))
return {
dataHref: e,
response: t,
text: r,
json: {},
cacheKey: u,
};
if (404 === t.status && q(r)?.notFound)
return {
dataHref: e,
json: { notFound: G },
response: t,
text: r,
cacheKey: u,
};
let a = Object.defineProperty(
Error("Failed to load static props"),
"__NEXT_ERROR_CODE",
{ value: "E124", enumerable: !1, configurable: !0 },
);
throw (o || (0, c.markAssetError)(a), a);
}
return {
dataHref: e,
json: a ? q(r) : null,
response: t,
text: r,
cacheKey: u,
};
}),
)
.then(
(e) => (
(i &&
"no-cache" !==
e.response.headers.get("x-middleware-cache")) ||
delete t[u],
e
),
)
.catch((e) => {
throw (
(s || delete t[u],
("Failed to fetch" === e.message ||
"NetworkError when attempting to fetch resource." ===
e.message ||
"Load failed" === e.message) &&
(0, c.markAssetError)(e),
e)
);
});
return s && i
? f({}).then(
(e) => (
"no-cache" !== e.response.headers.get("x-middleware-cache") &&
(t[u] = Promise.resolve(e)),
e
),
)
: void 0 !== t[u]
? t[u]
: (t[u] = f(l ? { method: "HEAD" } : {}));
}
function K() {
return Math.random().toString(36).slice(2, 10);
}
function V({ url: e, router: t }) {
if (e === (0, w.addBasePath)((0, C.addLocale)(t.asPath, t.locale)))
throw Object.defineProperty(
Error(
`Invariant: attempted to hard navigate to the same URL ${e} ${location.href}`,
),
"__NEXT_ERROR_CODE",
{ value: "E282", enumerable: !1, configurable: !0 },
);
window.location.href = e;
}
let Y = ({ route: e, router: t }) => {
let r = !1,
n = (t.clc = () => {
r = !0;
});
return () => {
if (r) {
let t = Object.defineProperty(
Error(`Abort fetching component for route: "${e}"`),
"__NEXT_ERROR_CODE",
{ value: "E483", enumerable: !1, configurable: !0 },
);
throw ((t.cancelled = !0), t);
}
n === t.clc && (t.clc = null);
};
};
class Q {
static {
this.events = (0, p.default)();
}
constructor(
e,
t,
r,
{
initialProps: n,
pageLoader: o,
App: a,
wrapApp: i,
Component: l,
err: c,
subscription: u,
isFallback: d,
locale: f,
locales: m,
defaultLocale: p,
domainLocales: v,
isPreview: _,
},
) {
(this.sdc = {}),
(this.sbc = {}),
(this.isFirstPopStateEvent = !0),
(this._key = K()),
(this.onPopState = (e) => {
let t,
{ isFirstPopStateEvent: r } = this;
this.isFirstPopStateEvent = !1;
let n = e.state;
if (!n) {
let { pathname: e, query: t } = this;
this.changeState(
"replaceState",
(0, y.formatWithValidation)({
pathname: (0, w.addBasePath)(e),
query: t,
}),
(0, h.getURL)(),
);
return;
}
if (n.__NA) return void window.location.reload();
if (
!n.__N ||
(r && this.locale === n.options.locale && n.as === this.asPath)
)
return;
let { url: o, as: a, options: i, key: l } = n;
this._key = l;
let { pathname: s } = (0, b.parseRelativeUrl)(o);
(this.isSsr &&
a === (0, w.addBasePath)(this.asPath) &&
s === (0, w.addBasePath)(this.pathname)) ||
((!this._bps || this._bps(n)) &&
this.change(
"replaceState",
o,
a,
Object.assign({}, i, {
shallow: i.shallow && this._shallow,
locale: i.locale || this.defaultLocale,
_h: 0,
}),
t,
));
});
const x = (0, s.removeTrailingSlash)(e);
(this.components = {}),
"/_error" !== e &&
(this.components[x] = {
Component: l,
initial: !0,
props: n,
err: c,
__N_SSG: n && n.__N_SSG,
__N_SSP: n && n.__N_SSP,
}),
(this.components["/_app"] = { Component: a, styleSheets: [] }),
(this.events = Q.events),
(this.pageLoader = o);
const C = (0, g.isDynamicRoute)(e) && self.__NEXT_DATA__.autoExport;
if (
((this.basePath = ""),
(this.sub = u),
(this.clc = null),
(this._wrapApp = i),
(this.isSsr = !0),
(this.isLocaleDomain = !1),
(this.isReady = !!(
self.__NEXT_DATA__.gssp ||
self.__NEXT_DATA__.gip ||
self.__NEXT_DATA__.isExperimentalCompile ||
(self.__NEXT_DATA__.appGip && !self.__NEXT_DATA__.gsp) ||
(!C && !self.location.search && 0)
)),
(this.state = {
route: x,
pathname: e,
query: t,
asPath: C ? e : r,
isPreview: !!_,
locale: void 0,
isFallback: d,
}),
(this._initialMatchesMiddlewarePromise = Promise.resolve(!1)),
"u" > typeof window)
) {
if (!r.startsWith("//")) {
const n = { locale: f },
o = (0, h.getURL)();
this._initialMatchesMiddlewarePromise = H({
router: this,
locale: f,
asPath: o,
}).then(
(a) => (
(n._shouldResolveHref = r !== e),
this.changeState(
"replaceState",
a
? o
: (0, y.formatWithValidation)({
pathname: (0, w.addBasePath)(e),
query: t,
}),
o,
n,
),
a
),
);
}
window.addEventListener("popstate", this.onPopState);
}
}
reload() {
window.location.reload();
}
back() {
window.history.back();
}
forward() {
window.history.forward();
}
push(e, t, r = {}) {
return (
({ url: e, as: t } = W(this, e, t)), this.change("pushState", e, t, r)
);
}
replace(e, t, r = {}) {
return (
({ url: e, as: t } = W(this, e, t)),
this.change("replaceState", e, t, r)
);
}
async _bfl(t, r, n, o) {
{
if (!this._bfl_s && !this._bfl_d) {
let r,
a,
{ BloomFilter: i } = e.r(232077);
try {
({ __routerFilterStatic: r, __routerFilterDynamic: a } = await (0,
c.getClientBuildManifest)());
} catch (e) {
if ((console.error(e), o)) return !0;
return (
V({
url: (0, w.addBasePath)(
(0, C.addLocale)(t, n || this.locale, this.defaultLocale),
),
router: this,
}),
new Promise(() => {})
);
}
let l = {
numItems: 7,
errorRate: 1e-4,
numBits: 135,
numHashes: 14,
bitArray: [
1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0,
0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1,
1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1,
0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1,
0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0,
1, 0, 1, 0, 0, 1, 1, 0, 0,
],
};
!r && l && (r = l || void 0);
let s = {
numItems: 1,
errorRate: 1e-4,
numBits: 20,
numHashes: 14,
bitArray: [
1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0,
],
};
!a && s && (a = s),
r?.numHashes &&
((this._bfl_s = new i(r.numItems, r.errorRate)),
this._bfl_s.import(r)),
a?.numHashes &&
((this._bfl_d = new i(a.numItems, a.errorRate)),
this._bfl_d.import(a));
}
let a = !1,
i = !1;
for (let { as: e, allowMatchCurrent: l } of [{ as: t }, { as: r }])
if (e) {
let r = (0, s.removeTrailingSlash)(
new URL(e, "http://n").pathname,
),
c = (0, w.addBasePath)((0, C.addLocale)(r, n || this.locale));
if (
l ||
r !==
(0, s.removeTrailingSlash)(
new URL(this.asPath, "http://n").pathname,
)
) {
for (let e of ((a =
a ||
!!this._bfl_s?.contains(r) ||
!!this._bfl_s?.contains(c)),
[r, c])) {
let t = e.split("/");
for (let e = 0; !i && e < t.length + 1; e++) {
let r = t.slice(0, e).join("/");
if (r && this._bfl_d?.contains(r)) {
i = !0;
break;
}
}
}
if (a || i) {
if (o) return !0;
return (
V({
url: (0, w.addBasePath)(
(0, C.addLocale)(
t,
n || this.locale,
this.defaultLocale,
),
),
router: this,
}),
new Promise(() => {})
);
}
}
}
}
return !1;
}
async change(e, t, r, o, a) {
let i, l;
if (!(0, O.isLocalURL)(t)) return V({ url: t, router: this }), !1;
let f = 1 === o._h;
f || o.shallow || (await this._bfl(r, void 0, o.locale));
let m =
f ||
o._shouldResolveHref ||
(0, x.parsePath)(t).pathname === (0, x.parsePath)(r).pathname,
p = { ...this.state },
j = !0 !== this.isReady;
this.isReady = !0;
let P = this.isSsr;
if ((f || (this.isSsr = !1), f && this.clc)) return !1;
let R = p.locale;
h.ST && performance.mark("routeChange");
let { shallow: N = !1, scroll: T = !0 } = o,
A = { shallow: N };
this._inFlightRoute &&
this.clc &&
(P || Q.events.emit("routeChangeError", D(), this._inFlightRoute, A),
this.clc(),
(this.clc = null)),
(r = (0, w.addBasePath)(
(0, C.addLocale)(
(0, k.hasBasePath)(r) ? (0, S.removeBasePath)(r) : r,
o.locale,
this.defaultLocale,
),
));
let L = (0, E.removeLocale)(
(0, k.hasBasePath)(r) ? (0, S.removeBasePath)(r) : r,
p.locale,
);
this._inFlightRoute = r;
let B = R !== p.locale;
if (!f && this.onlyAHashChange(L) && !B) {
(p.asPath = L),
Q.events.emit("hashChangeStart", r, A),
this.changeState(e, t, r, { ...o, scroll: !1 }),
T && this.scrollToHash(L);
try {
await this.set(p, this.components[p.route], null);
} catch (e) {
throw (
((0, d.default)(e) &&
e.cancelled &&
Q.events.emit("routeChangeError", e, L, A),
e)
);
}
return Q.events.emit("hashChangeComplete", r, A), !0;
}
let z = (0, b.parseRelativeUrl)(t),
{ pathname: U, query: q } = z;
try {
[i, { __rewrites: l }] = await Promise.all([
this.pageLoader.getPageList(),
(0, c.getClientBuildManifest)(),
this.pageLoader.getMiddleware(),
]);
} catch (e) {
return V({ url: r, router: this }), !1;
}
this.urlIsNew(L) || B || (e = "replaceState");
let X = r;
U = U ? (0, s.removeTrailingSlash)((0, S.removeBasePath)(U)) : U;
let K = (0, s.removeTrailingSlash)(U),
Y = r.startsWith("/") && (0, b.parseRelativeUrl)(r).pathname;
if (this.components[U]?.__appRouter)
return V({ url: r, router: this }), new Promise(() => {});
let Z = !!(
Y &&
K !== Y &&
(!(0, g.isDynamicRoute)(K) ||
!(0, v.getRouteMatcher)((0, _.getRouteRegex)(K))(Y))
),
J =
!o.shallow &&
(await H({ asPath: r, locale: p.locale, router: this }));
if ((f && J && (m = !1), m && "/_error" !== U))
if (((o._shouldResolveHref = !0), r.startsWith("/"))) {
let e = n(
(0, w.addBasePath)((0, C.addLocale)(L, p.locale), !0),
i,
l,
q,
(e) => F(e, i),
this.locales,
);
if (e.externalDest) return V({ url: r, router: this }), !0;
J || (X = e.asPath),
e.matchedPage &&
e.resolvedHref &&
((U = e.resolvedHref),
(z.pathname = (0, w.addBasePath)(U)),
J || (t = (0, y.formatWithValidation)(z)));
} else
(z.pathname = F(U, i)),
z.pathname !== U &&
((U = z.pathname),
(z.pathname = (0, w.addBasePath)(U)),
J || (t = (0, y.formatWithValidation)(z)));
if (!(0, O.isLocalURL)(r)) return V({ url: r, router: this }), !1;
(X = (0, E.removeLocale)((0, S.removeBasePath)(X), p.locale)),
(K = (0, s.removeTrailingSlash)(U));
let ee = !1;
if ((0, g.isDynamicRoute)(K)) {
let e = (0, b.parseRelativeUrl)(X),
n = e.pathname,
o = (0, _.getRouteRegex)(K);
ee = (0, v.getRouteMatcher)(o)(n);
let a = K === n,
i = a ? (0, I.interpolateAs)(K, n, q) : {};
if (ee && (!a || i.result))
a
? (r = (0, y.formatWithValidation)(
Object.assign({}, e, {
pathname: i.result,
query: (0, M.omit)(q, i.params),
}),
))
: Object.assign(q, ee);
else {
let e = Object.keys(o.groups).filter(
(e) => !q[e] && !o.groups[e].optional,
);
if (e.length > 0 && !J)
throw Object.defineProperty(
Error(
(a
? `The provided \`href\` (${t}) value is missing query values (${e.join(", ")}) to be interpolated properly. `
: `The provided \`as\` value (${n}) is incompatible with the \`href\` value (${K}). `) +
`Read more: https://nextjs.org/docs/messages/${a ? "href-interpolation-failed" : "incompatible-href-as"}`,
),
"__NEXT_ERROR_CODE",
{ value: "E344", enumerable: !1, configurable: !0 },
);
}
}
f || Q.events.emit("routeChangeStart", r, A);
let et = "/404" === this.pathname || "/_error" === this.pathname;
try {
let n = await this.getRouteInfo({
route: K,
pathname: U,
query: q,
as: r,
resolvedAs: X,
routeProps: A,
locale: p.locale,
isPreview: p.isPreview,
hasMiddleware: J,
unstable_skipClientCache: o.unstable_skipClientCache,
isQueryUpdating: f && !this.isFallback,
isMiddlewareRewrite: Z,
});
if (
(f ||
o.shallow ||
(await this._bfl(
r,
"resolvedAs" in n ? n.resolvedAs : void 0,
p.locale,
)),
"route" in n && J)
) {
(K = U = n.route || K),
A.shallow || (q = Object.assign({}, n.query || {}, q));
let e = (0, k.hasBasePath)(z.pathname)
? (0, S.removeBasePath)(z.pathname)
: z.pathname;
if (
(ee &&
U !== e &&
Object.keys(ee).forEach((e) => {
ee && q[e] === ee[e] && delete q[e];
}),
(0, g.isDynamicRoute)(U))
) {
let e =
!A.shallow && n.resolvedAs
? n.resolvedAs
: (0, w.addBasePath)(
(0, C.addLocale)(
new URL(r, location.href).pathname,
p.locale,
),
!0,
);
(0, k.hasBasePath)(e) && (e = (0, S.removeBasePath)(e));
let t = (0, _.getRouteRegex)(U),
o = (0, v.getRouteMatcher)(t)(
new URL(e, location.href).pathname,
);
o && Object.assign(q, o);
}
}
if ("type" in n)
if ("redirect-internal" === n.type)
return this.change(e, n.newUrl, n.newAs, o);
else
return (
V({ url: n.destination, router: this }), new Promise(() => {})
);
let l = n.Component;
if (
(l &&
l.unstable_scriptLoader &&
[].concat(l.unstable_scriptLoader()).forEach((e) => {
(0, u.handleClientScriptLoad)(e.props);
}),
(n.__N_SSG || n.__N_SSP) && n.props)
) {
if (n.props.pageProps && n.props.pageProps.__N_REDIRECT) {
o.locale = !1;
let t = n.props.pageProps.__N_REDIRECT;
if (
t.startsWith("/") &&
!1 !== n.props.pageProps.__N_REDIRECT_BASE_PATH
) {
let r = (0, b.parseRelativeUrl)(t);
r.pathname = F(r.pathname, i);
let { url: n, as: a } = W(this, t, t);
return this.change(e, n, a, o);
}
return V({ url: t, router: this }), new Promise(() => {});
}
if (
((p.isPreview = !!n.props.__N_PREVIEW), n.props.notFound === G)
) {
let e;
try {
await this.fetchComponent("/404"), (e = "/404");
} catch (t) {
e = "/_error";
}
if (
((n = await this.getRouteInfo({
route: e,
pathname: e,
query: q,
as: r,
resolvedAs: X,
routeProps: { shallow: !1 },
locale: p.locale,
isPreview: p.isPreview,
isNotFound: !0,
})),
"type" in n)
)
throw Object.defineProperty(
Error("Unexpected middleware effect on /404"),
"__NEXT_ERROR_CODE",
{ value: "E158", enumerable: !1, configurable: !0 },
);
}
}
f &&
"/_error" === this.pathname &&
self.__NEXT_DATA__.props?.pageProps?.statusCode === 500 &&
n.props?.pageProps &&
(n.props.pageProps.statusCode = 500);
let s = o.shallow && p.route === (n.route ?? K),
c = o.scroll ?? (!f && !s),
m = a ?? (c ? { x: 0, y: 0 } : null),
h = {
...p,
route: K,
pathname: U,
query: q,
asPath: L,
isFallback: !1,
};
if (f && et) {
if (
((n = await this.getRouteInfo({
route: this.pathname,
pathname: this.pathname,
query: q,
as: r,
resolvedAs: X,
routeProps: { shallow: !1 },
locale: p.locale,
isPreview: p.isPreview,
isQueryUpdating: f && !this.isFallback,
})),
"type" in n)
)
throw Object.defineProperty(
Error(`Unexpected middleware effect on ${this.pathname}`),
"__NEXT_ERROR_CODE",
{ value: "E225", enumerable: !1, configurable: !0 },
);
"/_error" === this.pathname &&
self.__NEXT_DATA__.props?.pageProps?.statusCode === 500 &&
n.props?.pageProps &&
(n.props.pageProps.statusCode = 500);
try {
await this.set(h, n, m);
} catch (e) {
throw (
((0, d.default)(e) &&
e.cancelled &&
Q.events.emit("routeChangeError", e, L, A),
e)
);
}
return !0;
}
if (
(Q.events.emit("beforeHistoryChange", r, A),
this.changeState(e, t, r, o),
!(f && !m && !j && !B && (0, $.compareRouterStates)(h, this.state)))
) {
try {
await this.set(h, n, m);
} catch (e) {
if (e.cancelled) n.error = n.error || e;
else throw e;
}
if (n.error)
throw (
(f || Q.events.emit("routeChangeError", n.error, L, A), n.error)
);
f || Q.events.emit("routeChangeComplete", r, A),
c && /#.+$/.test(r) && this.scrollToHash(r);
}
return !0;
} catch (e) {
if ((0, d.default)(e) && e.cancelled) return !1;
throw e;
}
}
changeState(e, t, r, n = {}) {
("pushState" !== e || (0, h.getURL)() !== r) &&
((this._shallow = n.shallow),
window.history[e](
{
url: t,
as: r,
options: n,
__N: !0,
key: (this._key = "pushState" !== e ? this._key : K()),
},
"",
r,
));
}
async handleRouteInfoError(e, t, r, n, o, a) {
if (e.cancelled) throw e;
if ((0, c.isAssetError)(e) || a)
throw (
(Q.events.emit("routeChangeError", e, n, o),
V({ url: n, router: this }),
D())
);
console.error(e);
try {
let n,
{ page: o, styleSheets: a } = await this.fetchComponent("/_error"),
i = { props: n, Component: o, styleSheets: a, err: e, error: e };
if (!i.props)
try {
i.props = await this.getInitialProps(o, {
err: e,
pathname: t,
query: r,
});
} catch (e) {
console.error("Error in error page `getInitialProps`: ", e),
(i.props = {});
}
return i;
} catch (e) {
return this.handleRouteInfoError(
(0, d.default)(e)
? e
: Object.defineProperty(Error(e + ""), "__NEXT_ERROR_CODE", {
value: "E394",
enumerable: !1,
configurable: !0,
}),
t,
r,
n,
o,
!0,
);
}
}
async getRouteInfo({
route: e,
pathname: t,
query: r,
as: n,
resolvedAs: o,
routeProps: a,
locale: i,
hasMiddleware: l,
isPreview: c,
unstable_skipClientCache: u,
isQueryUpdating: f,
isMiddlewareRewrite: p,
isNotFound: h,
}) {
let g = e;
try {
let e = this.components[g];
if (a.shallow && e && this.route === g) return e;
let d = Y({ route: g, router: this });
l && (e = void 0);
let b = !e || "initial" in e ? void 0 : e,
v = {
dataHref: this.pageLoader.getDataHref({
href: (0, y.formatWithValidation)({ pathname: t, query: r }),
skipInterpolation: !0,
asPath: h ? "/404" : o,
locale: i,
}),
hasMiddleware: !0,
isServerRender: this.isSsr,
parseJSON: !0,
inflightCache: f ? this.sbc : this.sdc,
persistCache: !c,
isPrefetch: !1,
unstable_skipClientCache: u,
isBackground: f,
},
_ =
f && !p
? null
: await U({
fetchData: () => X(v),
asPath: h ? "/404" : o,
locale: i,
router: this,
}).catch((e) => {
if (f) return null;
throw e;
});
if (
(_ && ("/_error" === t || "/404" === t) && (_.effect = void 0),
f &&
(_
? (_.json = self.__NEXT_DATA__.props)
: (_ = { json: self.__NEXT_DATA__.props })),
d(),
_?.effect?.type === "redirect-internal" ||
_?.effect?.type === "redirect-external")
)
return _.effect;
if (_?.effect?.type === "rewrite") {
let n = (0, s.removeTrailingSlash)(_.effect.resolvedHref),
i = await this.pageLoader.getPageList();
if (
(!f || i.includes(n)) &&
((g = n),
(t = _.effect.resolvedHref),
(r = { ...r, ..._.effect.parsedAs.query }),
(o = (0, S.removeBasePath)(
(0, m.normalizeLocalePath)(
_.effect.parsedAs.pathname,
this.locales,
).pathname,
)),
(e = this.components[g]),
a.shallow && e && this.route === g && !l)
)
return { ...e, route: g };
}
if ((0, P.isAPIRoute)(g))
return V({ url: n, router: this }), new Promise(() => {});
let x =
b ||
(await this.fetchComponent(g).then((e) => ({
Component: e.page,
styleSheets: e.styleSheets,
__N_SSG: e.mod.__N_SSG,
__N_SSP: e.mod.__N_SSP,
}))),
C = _?.response?.headers.get("x-middleware-skip"),
E = x.__N_SSG || x.__N_SSP;
C && _?.dataHref && delete this.sdc[_.dataHref];
let { props: w, cacheKey: k } = await this._getData(async () => {
if (E) {
if (_?.json && !C) return { cacheKey: _.cacheKey, props: _.json };
let e = _?.dataHref
? _.dataHref
: this.pageLoader.getDataHref({
href: (0, y.formatWithValidation)({
pathname: t,
query: r,
}),
asPath: o,
locale: i,
}),
n = await X({
dataHref: e,
isServerRender: this.isSsr,
parseJSON: !0,
inflightCache: C ? {} : this.sdc,
persistCache: !c,
isPrefetch: !1,
unstable_skipClientCache: u,
});
return { cacheKey: n.cacheKey, props: n.json || {} };
}
return {
headers: {},
props: await this.getInitialProps(x.Component, {
pathname: t,
query: r,
asPath: n,
locale: i,
locales: this.locales,
defaultLocale: this.defaultLocale,
}),
};
});
return (
x.__N_SSP && v.dataHref && k && delete this.sdc[k],
this.isPreview ||
!x.__N_SSG ||
f ||
X(
Object.assign({}, v, {
isBackground: !0,
persistCache: !1,
inflightCache: this.sbc,
}),
).catch(() => {}),
(w.pageProps = Object.assign({}, w.pageProps)),
(x.props = w),
(x.route = g),
(x.query = r),
(x.resolvedAs = o),
(this.components[g] = x),
x
);
} catch (e) {
return this.handleRouteInfoError(
(0, d.getProperError)(e),
t,
r,
n,
a,
);
}
}
set(e, t, r) {
return (
(this.state = e), this.sub(t, this.components["/_app"].Component, r)
);
}
beforePopState(e) {
this._bps = e;
}
onlyAHashChange(e) {
if (!this.asPath) return !1;
let [t, r] = this.asPath.split("#", 2),
[n, o] = e.split("#", 2);
return (!!o && t === n && r === o) || (t === n && r !== o);
}
scrollToHash(e) {
let [, t = ""] = e.split("#", 2);
(0, A.disableSmoothScrollDuringRouteTransition)(
() => {
if ("" === t || "top" === t) return void window.scrollTo(0, 0);
let e = decodeURIComponent(t),
r = document.getElementById(e);
if (r) return void r.scrollIntoView();
let n = document.getElementsByName(e)[0];
n && n.scrollIntoView();
},
{ onlyHashChange: this.onlyAHashChange(e) },
);
}
urlIsNew(e) {
return this.asPath !== e;
}
async prefetch(e, t = e, r = {}) {
if ("u" > typeof window && (0, T.isBot)(window.navigator.userAgent))
return;
let o = (0, b.parseRelativeUrl)(e),
a = o.pathname,
{ pathname: i, query: l } = o,
u = await this.pageLoader.getPageList(),
d = t,
f = void 0 !== r.locale ? r.locale || void 0 : this.locale,
m = await H({ asPath: t, locale: f, router: this });
if (t.startsWith("/")) {
let r;
({ __rewrites: r } = await (0, c.getClientBuildManifest)());
let a = n(
(0, w.addBasePath)((0, C.addLocale)(t, this.locale), !0),
u,
r,
o.query,
(e) => F(e, u),
this.locales,
);
if (a.externalDest) return;
m ||
(d = (0, E.removeLocale)(
(0, S.removeBasePath)(a.asPath),
this.locale,
)),
a.matchedPage &&
a.resolvedHref &&
((o.pathname = i = a.resolvedHref),
m || (e = (0, y.formatWithValidation)(o)));
}
(o.pathname = F(o.pathname, u)),
(0, g.isDynamicRoute)(o.pathname) &&
((i = o.pathname),
(o.pathname = i),
Object.assign(
l,
(0, v.getRouteMatcher)((0, _.getRouteRegex)(o.pathname))(
(0, x.parsePath)(t).pathname,
) || {},
),
m || (e = (0, y.formatWithValidation)(o)));
let p = (0, s.removeTrailingSlash)(i);
(await this._bfl(t, d, r.locale, !0)) &&
(this.components[a] = { __appRouter: !0 }),
await Promise.all([
this.pageLoader._isSsg(p).then(
(t) =>
!!t &&
X({
dataHref: this.pageLoader.getDataHref({
href: e,
asPath: d,
locale: f,
}),
isServerRender: !1,
parseJSON: !0,
inflightCache: this.sdc,
persistCache: !this.isPreview,
isPrefetch: !0,
unstable_skipClientCache:
r.unstable_skipClientCache || (r.priority && !0),
})
.then(() => !1)
.catch(() => !1),
),
this.pageLoader[r.priority ? "loadPage" : "prefetch"](p),
]);
}
async fetchComponent(e) {
let t = Y({ route: e, router: this });
try {
let r = await this.pageLoader.loadPage(e);
return t(), r;
} catch (e) {
throw (t(), e);
}
}
_getData(e) {
let t = !1,
r = () => {
t = !0;
};
return (
(this.clc = r),
e().then((e) => {
if ((r === this.clc && (this.clc = null), t)) {
let e = Object.defineProperty(
Error("Loading initial props cancelled"),
"__NEXT_ERROR_CODE",
{ value: "E405", enumerable: !1, configurable: !0 },
);
throw ((e.cancelled = !0), e);
}
return e;
})
);
}
getInitialProps(e, t) {
let { Component: r } = this.components["/_app"],
n = this._wrapApp(r);
return (
(t.AppTree = n),
(0, h.loadGetInitialProps)(r, {
AppTree: n,
Component: e,
router: this,
ctx: t,
})
);
}
get route() {
return this.state.route;
}
get pathname() {
return this.state.pathname;
}
get query() {
return this.state.query;
}
get asPath() {
return this.state.asPath;
}
get locale() {
return this.state.locale;
}
get isFallback() {
return this.state.isFallback;
}
get isPreview() {
return this.state.isPreview;
}
}
};
export default moduleFactory;