@bison-lab/payload-core 5.12.0 → 5.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +125 -10
  2. package/dist/admin-branding-CEKdfYah.mjs +178 -0
  3. package/dist/admin-branding-CEKdfYah.mjs.map +1 -0
  4. package/dist/admin-head-CcpH7P4C.mjs +187 -0
  5. package/dist/admin-head-CcpH7P4C.mjs.map +1 -0
  6. package/dist/admin-head-QfW81bDy.d.mts +63 -0
  7. package/dist/admin-head-QfW81bDy.d.mts.map +1 -0
  8. package/dist/admin-server.d.mts +52 -0
  9. package/dist/admin-server.d.mts.map +1 -0
  10. package/dist/admin-server.mjs +94 -0
  11. package/dist/admin-server.mjs.map +1 -0
  12. package/dist/admin.d.mts.map +1 -1
  13. package/dist/admin.mjs +12 -4
  14. package/dist/admin.mjs.map +1 -1
  15. package/dist/{alternates-DxBTUXHh.mjs → alternates-Tv5-ccza.mjs} +1 -1
  16. package/dist/{alternates-DxBTUXHh.mjs.map → alternates-Tv5-ccza.mjs.map} +1 -1
  17. package/dist/{alternates-DlRTsaVe.d.mts → alternates-aRncEUBI.d.mts} +1 -1
  18. package/dist/{alternates-DlRTsaVe.d.mts.map → alternates-aRncEUBI.d.mts.map} +1 -1
  19. package/dist/block-library.d.mts +1 -1
  20. package/dist/block-library.mjs +1 -1
  21. package/dist/{block-thumbnails-DC34uFtE.mjs → block-thumbnails-DvILqW_e.mjs} +1 -1
  22. package/dist/{block-thumbnails-DC34uFtE.mjs.map → block-thumbnails-DvILqW_e.mjs.map} +1 -1
  23. package/dist/block-thumbnails-cli.mjs +1 -1
  24. package/dist/block-thumbnails.mjs +1 -1
  25. package/dist/{capability-Kd5LgQpm.mjs → capability-B4FLx4OX.mjs} +4 -159
  26. package/dist/capability-B4FLx4OX.mjs.map +1 -0
  27. package/dist/{capability-NlorUIta.d.mts → capability-DonuHSPG.d.mts} +1 -1
  28. package/dist/{capability-NlorUIta.d.mts.map → capability-DonuHSPG.d.mts.map} +1 -1
  29. package/dist/{catalogue-CJ0RlTg4.d.mts → catalogue-tVovXWp9.d.mts} +1 -1
  30. package/dist/{catalogue-CJ0RlTg4.d.mts.map → catalogue-tVovXWp9.d.mts.map} +1 -1
  31. package/dist/{facet-field-DO3VT_Cz.mjs → facet-field-7p6_MhsT.mjs} +1 -1
  32. package/dist/{facet-field-DO3VT_Cz.mjs.map → facet-field-7p6_MhsT.mjs.map} +1 -1
  33. package/dist/{facet-field-Cd6lffed.d.mts → facet-field-Dbcu1L91.d.mts} +1 -1
  34. package/dist/{facet-field-Cd6lffed.d.mts.map → facet-field-Dbcu1L91.d.mts.map} +1 -1
  35. package/dist/{types-B1MmE-L3.d.mts → identity-B4Lew8Fu.d.mts} +40 -24
  36. package/dist/identity-B4Lew8Fu.d.mts.map +1 -0
  37. package/dist/{identity-CN6EOeDM.mjs → identity-CkUE_uN2.mjs} +11 -3
  38. package/dist/{identity-CN6EOeDM.mjs.map → identity-CkUE_uN2.mjs.map} +1 -1
  39. package/dist/index.d.mts +58 -16
  40. package/dist/index.d.mts.map +1 -1
  41. package/dist/index.mjs +150 -60
  42. package/dist/index.mjs.map +1 -1
  43. package/dist/island-97l5VY8l.mjs.map +1 -1
  44. package/dist/languages-B_iiWwxE.mjs +179 -0
  45. package/dist/languages-B_iiWwxE.mjs.map +1 -0
  46. package/dist/languages-cDe9Lznx.d.mts +86 -0
  47. package/dist/languages-cDe9Lznx.d.mts.map +1 -0
  48. package/dist/{locale-tnKLkutC.d.mts → locale-CTT3nn6T.d.mts} +1 -1
  49. package/dist/locale-CTT3nn6T.d.mts.map +1 -0
  50. package/dist/{locale-B6rUVwpg.mjs → locale-DaEJ1d2O.mjs} +1 -1
  51. package/dist/{locale-B6rUVwpg.mjs.map → locale-DaEJ1d2O.mjs.map} +1 -1
  52. package/dist/locale-routing.d.mts +129 -0
  53. package/dist/locale-routing.d.mts.map +1 -0
  54. package/dist/locale-routing.mjs +256 -0
  55. package/dist/locale-routing.mjs.map +1 -0
  56. package/dist/lookup-DiOCro-_.mjs +165 -0
  57. package/dist/lookup-DiOCro-_.mjs.map +1 -0
  58. package/dist/lookup-uyEKHlLX.d.mts +41 -0
  59. package/dist/lookup-uyEKHlLX.d.mts.map +1 -0
  60. package/dist/{messages-XFoL9RtF.mjs → messages-Bv6JIEiG.mjs} +2 -2
  61. package/dist/{messages-XFoL9RtF.mjs.map → messages-Bv6JIEiG.mjs.map} +1 -1
  62. package/dist/metadata.d.mts +2 -2
  63. package/dist/metadata.mjs +1 -1
  64. package/dist/navigation.d.mts +2 -2
  65. package/dist/navigation.mjs +1 -1
  66. package/dist/og.d.mts +2 -2
  67. package/dist/og.mjs +2 -2
  68. package/dist/{preview-Br1SQCKn.mjs → preview-BE7P1ezl.mjs} +5 -120
  69. package/dist/preview-BE7P1ezl.mjs.map +1 -0
  70. package/dist/{preview-B69Dhi8T.d.mts → preview-DSQN4uYa.d.mts} +2 -2
  71. package/dist/{preview-B69Dhi8T.d.mts.map → preview-DSQN4uYa.d.mts.map} +1 -1
  72. package/dist/{published-Vu_QX2Vv.mjs → published-BF2F3od_.mjs} +2 -2
  73. package/dist/{published-Vu_QX2Vv.mjs.map → published-BF2F3od_.mjs.map} +1 -1
  74. package/dist/{published-hqtvmVUD.mjs → published-BzihgcSf.mjs} +1 -1
  75. package/dist/{published-hqtvmVUD.mjs.map → published-BzihgcSf.mjs.map} +1 -1
  76. package/dist/{published-B80KqlcU.mjs → published-C8bW5jvC.mjs} +3 -3
  77. package/dist/{published-B80KqlcU.mjs.map → published-C8bW5jvC.mjs.map} +1 -1
  78. package/dist/{published-2I-k6zEo.d.mts → published-DYpXTy84.d.mts} +3 -3
  79. package/dist/{published-2I-k6zEo.d.mts.map → published-DYpXTy84.d.mts.map} +1 -1
  80. package/dist/{published-BhYTEAK_.d.mts → published-VTz_aYaQ.d.mts} +2 -2
  81. package/dist/{published-BhYTEAK_.d.mts.map → published-VTz_aYaQ.d.mts.map} +1 -1
  82. package/dist/{root-page-key-kx3C1eyp.mjs → root-page-key-ywNz2k4L.mjs} +1 -1
  83. package/dist/{root-page-key-kx3C1eyp.mjs.map → root-page-key-ywNz2k4L.mjs.map} +1 -1
  84. package/dist/seo.d.mts +1 -1
  85. package/dist/seo.mjs +2 -2
  86. package/dist/{strings-Fd7kUCT7.mjs → strings-_9n8BefX.mjs} +1 -1
  87. package/dist/{strings-Fd7kUCT7.mjs.map → strings-_9n8BefX.mjs.map} +1 -1
  88. package/dist/taxonomy.d.mts +1 -1
  89. package/dist/taxonomy.mjs +1 -1
  90. package/dist/theme.d.mts +6 -5
  91. package/dist/theme.d.mts.map +1 -1
  92. package/dist/theme.mjs +6 -63
  93. package/dist/{title-BVV3o329.d.mts → title-DBSLJfrW.d.mts} +1 -1
  94. package/dist/{title-BVV3o329.d.mts.map → title-DBSLJfrW.d.mts.map} +1 -1
  95. package/dist/translate-messages-cli.mjs +2 -2
  96. package/dist/translate.d.mts +2 -77
  97. package/dist/translate.d.mts.map +1 -1
  98. package/dist/translate.mjs +4 -3
  99. package/dist/translate.mjs.map +1 -1
  100. package/dist/{wireframe-Ba65SOj8.mjs → wireframe-DjPHSACa.mjs} +1 -1
  101. package/dist/{wireframe-Ba65SOj8.mjs.map → wireframe-DjPHSACa.mjs.map} +1 -1
  102. package/dist/wireframe-cli.mjs +1 -1
  103. package/dist/wireframe.mjs +1 -1
  104. package/package.json +11 -3
  105. package/dist/capability-Kd5LgQpm.mjs.map +0 -1
  106. package/dist/locale-tnKLkutC.d.mts.map +0 -1
  107. package/dist/preview-Br1SQCKn.mjs.map +0 -1
  108. package/dist/theme.mjs.map +0 -1
  109. package/dist/types-B1MmE-L3.d.mts.map +0 -1
@@ -0,0 +1,256 @@
1
+ import { a as redirectDestination, c as withoutLanguagePrefix, l as withoutTrailingSlash, o as rowLanguage, s as withSearch, t as REDIRECTS_SLUG, u as normalizeSlug } from "./lookup-DiOCro-_.mjs";
2
+ import { a as LIBRARY_LOCALE_CODES, c as inactiveLocaleRedirect, d as pathAfterPrefix, l as invalidateActiveLocales, o as activeAlternates, r as LIBRARY_DEFAULT_LOCALE, s as activeLocales, t as ACTIVE_LOCALES_CACHE_MS, u as localePath } from "./languages-B_iiWwxE.mjs";
3
+ import { headers } from "next/headers";
4
+ import { NextResponse } from "next/server";
5
+ //#region src/locale-routing.ts
6
+ /**
7
+ * Language URLs a site switches on from Settings → Translation (#339): the
8
+ * proxy helper (`localeProxy`), the pure decision under it (`routeLocale`,
9
+ * for a site's own lookups beside it), the request-locale reader
10
+ * (`getRequestLocale`) and `localePath` for hreflang, the sitemap and the
11
+ * switcher. `matchRedirect` (#340) is the Redirects lookup in the request's
12
+ * language that runs before `localeProxy`.
13
+ *
14
+ * Server only, and light on purpose: a Next proxy imports it on every
15
+ * request. It loads no Payload at runtime (the site passes the live list,
16
+ * from `activeLocales(payload)` or `GET /api/translation/locales`, and its
17
+ * own Payload to `matchRedirect`), no SEO plugin, no React and no
18
+ * `@payloadcms/ui`. `next` is an optional peer.
19
+ */
20
+ /**
21
+ * The request header `localeProxy` passes the language in. It is set (or
22
+ * removed) on every request the proxy sees, so a value a visitor sends
23
+ * never reaches the page.
24
+ */
25
+ const LOCALE_HEADER = "x-bison-locale";
26
+ const NEVER_ROUTED = new Set([
27
+ "admin",
28
+ "api",
29
+ "_next",
30
+ "_vercel"
31
+ ]);
32
+ /** A file, not a page: the last segment ends in an extension (`.png`, `.xml`), never a version like `v1.2`. */
33
+ const FILE = /\.[a-z][a-z0-9]*$/i;
34
+ /** A first segment that could be a language prefix (`es`, `pt-BR`), so the live list must be read to tell. */
35
+ const CODE_SHAPED = /^[a-z]{2,3}(?:-[a-z0-9]{2,8})*$/i;
36
+ function neverRouted(pathname, options) {
37
+ return NEVER_ROUTED.has(pathname.split("/")[1] ?? "") || (options.skip?.(pathname) ?? false);
38
+ }
39
+ function isFile(pathname) {
40
+ return FILE.test(pathname.split("/").at(-1) ?? "");
41
+ }
42
+ /**
43
+ * The routing decision for a path, from the live list. Pure, so a site can
44
+ * run its own lookup (a Redirects row in the request's language) on the
45
+ * same answer before `localeProxy` builds the response. Every path under a
46
+ * language's prefix is handled, files included; a file anywhere else is
47
+ * skipped.
48
+ */
49
+ function routeLocale(pathname, locales, options = {}) {
50
+ if (neverRouted(pathname, options)) return { action: "skip" };
51
+ const [, first = "", ...rest] = pathname.split("/");
52
+ const lower = first.toLowerCase();
53
+ const match = (codes) => first ? codes.find((code) => code.toLowerCase() === lower) : void 0;
54
+ const inactive = match(locales.inactive);
55
+ const live = match(locales.active);
56
+ if (!inactive && !live) return isFile(pathname) ? { action: "skip" } : {
57
+ action: "serve",
58
+ locale: locales.defaultLocale,
59
+ pathname
60
+ };
61
+ const bare = pathAfterPrefix(rest);
62
+ if (inactive || live === locales.defaultLocale) return {
63
+ action: "redirect",
64
+ pathname: bare
65
+ };
66
+ if (first !== live) return {
67
+ action: "redirect",
68
+ pathname: localePath(bare, live, locales.defaultLocale)
69
+ };
70
+ if (neverRouted(bare, options)) return { action: "skip" };
71
+ return {
72
+ action: "rewrite",
73
+ locale: live,
74
+ pathname: bare
75
+ };
76
+ }
77
+ /**
78
+ * The proxy helper a site calls once, from `proxy.ts` (Next 16) or
79
+ * `middleware.ts`, after any lookup of its own:
80
+ *
81
+ * ```ts
82
+ * return localeProxy(request, async () => activeLocales(await getPayload({ config })));
83
+ * ```
84
+ *
85
+ * The default language stays unprefixed. A live language's prefix is
86
+ * rewritten to the site's existing routes, the language passed in
87
+ * `LOCALE_HEADER` for `getRequestLocale`. An unticked language's prefix
88
+ * 308s to the default language's page, uncached, so ticking it again
89
+ * reaches every visitor. `locales` is the live list or a function that
90
+ * reads it, which is not called for a path the helper skips.
91
+ */
92
+ async function localeProxy(request, locales, options = {}) {
93
+ const forwarded = new Headers(request.headers);
94
+ forwarded.delete(LOCALE_HEADER);
95
+ const { pathname } = request.nextUrl;
96
+ const first = pathname.split("/")[1] ?? "";
97
+ if (neverRouted(pathname, options) || isFile(pathname) && !CODE_SHAPED.test(first)) return NextResponse.next({ request: { headers: forwarded } });
98
+ const route = routeLocale(pathname, typeof locales === "function" ? await locales() : locales, options);
99
+ switch (route.action) {
100
+ case "skip": return NextResponse.next({ request: { headers: forwarded } });
101
+ case "serve":
102
+ forwarded.set(LOCALE_HEADER, route.locale);
103
+ return NextResponse.next({ request: { headers: forwarded } });
104
+ case "rewrite": {
105
+ forwarded.set(LOCALE_HEADER, route.locale);
106
+ const url = request.nextUrl.clone();
107
+ url.pathname = route.pathname;
108
+ return NextResponse.rewrite(url, { request: { headers: forwarded } });
109
+ }
110
+ case "redirect": {
111
+ const url = request.nextUrl.clone();
112
+ url.pathname = route.pathname;
113
+ const response = NextResponse.redirect(url, 308);
114
+ response.headers.set("Cache-Control", "no-store");
115
+ return response;
116
+ }
117
+ }
118
+ }
119
+ /**
120
+ * The request's language from the header `localeProxy` set. The default
121
+ * language when it is missing, or not in `locales.active` (the library's
122
+ * languages when no list is given). Pass the live list on a site with
123
+ * languages of its own.
124
+ */
125
+ function localeFromHeaders(headers, locales) {
126
+ const allowed = locales?.active ?? LIBRARY_LOCALE_CODES;
127
+ const fallback = locales?.defaultLocale ?? "en";
128
+ const value = headers.get(LOCALE_HEADER);
129
+ return value && allowed.includes(value) ? value : fallback;
130
+ }
131
+ /**
132
+ * The request's language, for a Server Component, `generateMetadata` or a
133
+ * route handler. Pass it to the readers (`getNavigation`,
134
+ * `getPublishedIdentity`, a page read) as `locale`. Reading request headers
135
+ * makes the route render per request, which a page served in more than
136
+ * one language at one route needs.
137
+ */
138
+ async function getRequestLocale(locales) {
139
+ return localeFromHeaders(await headers(), locales);
140
+ }
141
+ function both(path) {
142
+ return path === "/" ? [path] : [path, `${path}/`];
143
+ }
144
+ /**
145
+ * The rows that could answer a path, best first:
146
+ * - an unprefixed URL: the rows with no language (the default language's);
147
+ * - a live language's URL (`/es/old`): that language's row, then a row with
148
+ * no language saved with the whole path, then the row with no language
149
+ * for the path after the prefix (`/old`), sent on in that language;
150
+ * - an unticked language's URL: only a row with no language saved with the
151
+ * whole path, so that language's own rows stay inert and `localeProxy`
152
+ * 308s the prefix to the default language as before.
153
+ */
154
+ function redirectCandidates(options) {
155
+ const { pathname, locales } = options;
156
+ const route = routeLocale(pathname, locales, options);
157
+ if (route.action === "skip") return [];
158
+ const codes = [...new Set([
159
+ locales.defaultLocale,
160
+ ...locales.active,
161
+ ...locales.inactive
162
+ ])];
163
+ const path = withoutTrailingSlash(pathname);
164
+ const bare = withoutTrailingSlash(withoutLanguagePrefix(path, codes));
165
+ if (options.isReservedSlug && (options.isReservedSlug(normalizeSlug(path)) || options.isReservedSlug(normalizeSlug(bare)))) return [];
166
+ const { defaultLocale } = locales;
167
+ const plain = (from, language) => both(from).map((entry) => ({
168
+ from: entry,
169
+ language: null,
170
+ in: language,
171
+ inLanguage: false
172
+ }));
173
+ if (route.action !== "rewrite") return plain(path, defaultLocale);
174
+ const live = route.locale;
175
+ return [
176
+ ...both(path).map((from) => ({
177
+ from,
178
+ language: live,
179
+ in: live,
180
+ inLanguage: false
181
+ })),
182
+ ...plain(path, live),
183
+ ...both(bare).map((from) => ({
184
+ from,
185
+ language: null,
186
+ in: live,
187
+ inLanguage: true
188
+ }))
189
+ ];
190
+ }
191
+ /**
192
+ * The Redirects row for a request, in the request's language, as the
193
+ * `Location` of a 308; null when no row answers. Call it in the site's proxy
194
+ * before `localeProxy`, with the same live list:
195
+ *
196
+ * ```ts
197
+ * const locales = await activeLocales(payload);
198
+ * const redirect = await matchRedirect({ payload, pathname, search, locales, isReservedSlug });
199
+ * if (redirect) return NextResponse.redirect(new URL(redirect.location, request.url), 308);
200
+ * return localeProxy(request, locales);
201
+ * ```
202
+ *
203
+ * A page reference resolves to the page's path in the visitor's language. A
204
+ * row in a language that is not ticked never answers. Every destination is a
205
+ * path on this site. A failed read answers null, so a database outage never
206
+ * turns into an error page.
207
+ */
208
+ async function matchRedirect(options) {
209
+ const candidates = redirectCandidates(options);
210
+ if (candidates.length === 0) return null;
211
+ const { locales } = options;
212
+ const codes = [...new Set([
213
+ locales.defaultLocale,
214
+ ...locales.active,
215
+ ...locales.inactive
216
+ ])];
217
+ const froms = [...new Set(candidates.map((candidate) => candidate.from))];
218
+ let rows;
219
+ try {
220
+ rows = (await options.payload.find({
221
+ collection: REDIRECTS_SLUG,
222
+ where: { from: { in: froms } },
223
+ depth: 1,
224
+ populate: { pages: {
225
+ slug: true,
226
+ pageKey: true,
227
+ _status: true
228
+ } },
229
+ limit: froms.length,
230
+ pagination: false,
231
+ overrideAccess: true
232
+ })).docs;
233
+ } catch {
234
+ return null;
235
+ }
236
+ const here = withoutTrailingSlash(options.pathname);
237
+ for (const candidate of candidates) {
238
+ const row = rows.find((entry) => entry.from === candidate.from && rowLanguage(entry, locales.defaultLocale) === candidate.language);
239
+ if (!row) continue;
240
+ const location = redirectDestination(row.to, {
241
+ language: candidate.in,
242
+ defaultLocale: locales.defaultLocale,
243
+ codes,
244
+ inLanguage: candidate.inLanguage,
245
+ pagePath: options.pagePath,
246
+ origin: options.origin
247
+ });
248
+ if (!location || withoutTrailingSlash(location.split(/[?#]/)[0] ?? "") === here) continue;
249
+ return { location: withSearch(location, options.search) };
250
+ }
251
+ return null;
252
+ }
253
+ //#endregion
254
+ export { ACTIVE_LOCALES_CACHE_MS, LIBRARY_DEFAULT_LOCALE, LIBRARY_LOCALE_CODES, LOCALE_HEADER, REDIRECTS_SLUG, activeAlternates, activeLocales, getRequestLocale, inactiveLocaleRedirect, invalidateActiveLocales, localeFromHeaders, localePath, localeProxy, matchRedirect, routeLocale };
255
+
256
+ //# sourceMappingURL=locale-routing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-routing.mjs","names":["requestHeaders"],"sources":["../src/locale-routing.ts"],"sourcesContent":["/**\n * Language URLs a site switches on from Settings → Translation (#339): the\n * proxy helper (`localeProxy`), the pure decision under it (`routeLocale`,\n * for a site's own lookups beside it), the request-locale reader\n * (`getRequestLocale`) and `localePath` for hreflang, the sitemap and the\n * switcher. `matchRedirect` (#340) is the Redirects lookup in the request's\n * language that runs before `localeProxy`.\n *\n * Server only, and light on purpose: a Next proxy imports it on every\n * request. It loads no Payload at runtime (the site passes the live list,\n * from `activeLocales(payload)` or `GET /api/translation/locales`, and its\n * own Payload to `matchRedirect`), no SEO plugin, no React and no\n * `@payloadcms/ui`. `next` is an optional peer.\n */\nimport { headers as requestHeaders } from \"next/headers\";\nimport { NextResponse, type NextRequest } from \"next/server\";\nimport type { Payload } from \"payload\";\n\nimport { normalizeSlug } from \"./fields/slug-normalize\";\nimport {\n redirectDestination,\n REDIRECTS_SLUG,\n rowLanguage,\n withoutLanguagePrefix,\n withoutTrailingSlash,\n withSearch,\n type RedirectRow,\n} from \"./redirects/lookup\";\n\nimport {\n LIBRARY_DEFAULT_LOCALE,\n LIBRARY_LOCALE_CODES,\n localePath,\n pathAfterPrefix,\n type ActiveLocales,\n} from \"./translate/languages\";\n\nexport { REDIRECTS_SLUG } from \"./redirects/lookup\";\nexport {\n ACTIVE_LOCALES_CACHE_MS,\n activeAlternates,\n activeLocales,\n inactiveLocaleRedirect,\n invalidateActiveLocales,\n LIBRARY_DEFAULT_LOCALE,\n LIBRARY_LOCALE_CODES,\n localePath,\n type ActiveLocales,\n} from \"./translate/languages\";\n\n/**\n * The request header `localeProxy` passes the language in. It is set (or\n * removed) on every request the proxy sees, so a value a visitor sends\n * never reaches the page.\n */\nexport const LOCALE_HEADER = \"x-bison-locale\";\n\n/** What a request needs from the live list. */\nexport type LocaleSet = Pick<\n ActiveLocales,\n \"defaultLocale\" | \"active\" | \"inactive\"\n>;\n\nexport interface LocaleRoutingOptions {\n /**\n * Paths the helper leaves alone, on top of its own (`/admin`, `/api`,\n * `/_next`, `/_vercel`, and a file outside a language prefix). Called\n * with the request's path, and with the path after a live language's\n * prefix.\n */\n skip?: (pathname: string) => boolean;\n}\n\n/**\n * What to do with a request:\n * - `skip`: not a page (admin, API, a file); pass it through untouched.\n * - `serve`: an unprefixed URL, in the default language.\n * - `rewrite`: a live language's URL; serve `pathname` (the site's existing\n * route) in `locale`.\n * - `redirect`: 308 to `pathname`: an unticked language's URL to the default\n * language's page, the default language's own prefix to its unprefixed\n * URL, or a prefix in the wrong case to the language's own spelling.\n */\nexport type LocaleRoute =\n | { action: \"skip\" }\n | { action: \"serve\"; locale: string; pathname: string }\n | { action: \"rewrite\"; locale: string; pathname: string }\n | { action: \"redirect\"; pathname: string };\n\nconst NEVER_ROUTED = new Set([\"admin\", \"api\", \"_next\", \"_vercel\"]);\n\n/** A file, not a page: the last segment ends in an extension (`.png`, `.xml`), never a version like `v1.2`. */\nconst FILE = /\\.[a-z][a-z0-9]*$/i;\n\n/** A first segment that could be a language prefix (`es`, `pt-BR`), so the live list must be read to tell. */\nconst CODE_SHAPED = /^[a-z]{2,3}(?:-[a-z0-9]{2,8})*$/i;\n\nfunction neverRouted(pathname: string, options: LocaleRoutingOptions): boolean {\n return (\n NEVER_ROUTED.has(pathname.split(\"/\")[1] ?? \"\") ||\n (options.skip?.(pathname) ?? false)\n );\n}\n\nfunction isFile(pathname: string): boolean {\n return FILE.test(pathname.split(\"/\").at(-1) ?? \"\");\n}\n\n/**\n * The routing decision for a path, from the live list. Pure, so a site can\n * run its own lookup (a Redirects row in the request's language) on the\n * same answer before `localeProxy` builds the response. Every path under a\n * language's prefix is handled, files included; a file anywhere else is\n * skipped.\n */\nexport function routeLocale(\n pathname: string,\n locales: LocaleSet,\n options: LocaleRoutingOptions = {},\n): LocaleRoute {\n if (neverRouted(pathname, options)) return { action: \"skip\" };\n const [, first = \"\", ...rest] = pathname.split(\"/\");\n const lower = first.toLowerCase();\n const match = (codes: readonly string[]) =>\n first ? codes.find((code) => code.toLowerCase() === lower) : undefined;\n const inactive = match(locales.inactive);\n const live = match(locales.active);\n\n if (!inactive && !live) {\n return isFile(pathname)\n ? { action: \"skip\" }\n : { action: \"serve\", locale: locales.defaultLocale, pathname };\n }\n const bare = pathAfterPrefix(rest);\n if (inactive || live === locales.defaultLocale)\n return { action: \"redirect\", pathname: bare };\n if (first !== live)\n return {\n action: \"redirect\",\n pathname: localePath(bare, live!, locales.defaultLocale),\n };\n if (neverRouted(bare, options)) return { action: \"skip\" };\n return { action: \"rewrite\", locale: live!, pathname: bare };\n}\n\n/**\n * The proxy helper a site calls once, from `proxy.ts` (Next 16) or\n * `middleware.ts`, after any lookup of its own:\n *\n * ```ts\n * return localeProxy(request, async () => activeLocales(await getPayload({ config })));\n * ```\n *\n * The default language stays unprefixed. A live language's prefix is\n * rewritten to the site's existing routes, the language passed in\n * `LOCALE_HEADER` for `getRequestLocale`. An unticked language's prefix\n * 308s to the default language's page, uncached, so ticking it again\n * reaches every visitor. `locales` is the live list or a function that\n * reads it, which is not called for a path the helper skips.\n */\nexport async function localeProxy(\n request: NextRequest,\n locales: LocaleSet | (() => LocaleSet | Promise<LocaleSet>),\n options: LocaleRoutingOptions = {},\n): Promise<NextResponse> {\n const forwarded = new Headers(request.headers);\n forwarded.delete(LOCALE_HEADER);\n const { pathname } = request.nextUrl;\n // Skipped before the live list is read, so an asset or the admin never waits on it.\n const first = pathname.split(\"/\")[1] ?? \"\";\n if (\n neverRouted(pathname, options) ||\n (isFile(pathname) && !CODE_SHAPED.test(first))\n ) {\n return NextResponse.next({ request: { headers: forwarded } });\n }\n\n const live = typeof locales === \"function\" ? await locales() : locales;\n const route = routeLocale(pathname, live, options);\n switch (route.action) {\n case \"skip\":\n return NextResponse.next({ request: { headers: forwarded } });\n case \"serve\":\n forwarded.set(LOCALE_HEADER, route.locale);\n return NextResponse.next({ request: { headers: forwarded } });\n case \"rewrite\": {\n forwarded.set(LOCALE_HEADER, route.locale);\n // Set on a copy of the request URL, never parsed from a string, so the\n // rewrite always stays on this host.\n const url = request.nextUrl.clone();\n url.pathname = route.pathname;\n return NextResponse.rewrite(url, { request: { headers: forwarded } });\n }\n case \"redirect\": {\n const url = request.nextUrl.clone();\n url.pathname = route.pathname;\n const response = NextResponse.redirect(url, 308);\n // Browsers keep a 308 for good; no-store lets a language ticked again\n // reach these visitors.\n response.headers.set(\"Cache-Control\", \"no-store\");\n return response;\n }\n }\n}\n\n/**\n * The request's language from the header `localeProxy` set. The default\n * language when it is missing, or not in `locales.active` (the library's\n * languages when no list is given). Pass the live list on a site with\n * languages of its own.\n */\nexport function localeFromHeaders(\n headers: Pick<Headers, \"get\">,\n locales?: Pick<LocaleSet, \"defaultLocale\" | \"active\">,\n): string {\n const allowed = locales?.active ?? LIBRARY_LOCALE_CODES;\n const fallback = locales?.defaultLocale ?? LIBRARY_DEFAULT_LOCALE;\n const value = headers.get(LOCALE_HEADER);\n return value && allowed.includes(value) ? value : fallback;\n}\n\n/**\n * The request's language, for a Server Component, `generateMetadata` or a\n * route handler. Pass it to the readers (`getNavigation`,\n * `getPublishedIdentity`, a page read) as `locale`. Reading request headers\n * makes the route render per request, which a page served in more than\n * one language at one route needs.\n */\nexport async function getRequestLocale(\n locales?: Pick<LocaleSet, \"defaultLocale\" | \"active\">,\n): Promise<string> {\n return localeFromHeaders(await requestHeaders(), locales);\n}\n\n// ---------------------------------------------------------------------------\n// Redirects in each language (#340)\n\nexport interface MatchRedirectOptions extends LocaleRoutingOptions {\n /** The site's Payload, or anything with its `find`. Read only for a path that could match. */\n payload: Pick<Payload, \"find\">;\n /** The request's path (`request.nextUrl.pathname`). */\n pathname: string;\n /** The request's query string (`request.nextUrl.search`), kept on the redirect when the row's destination has none. */\n search?: string;\n /** The live list, the same one `localeProxy` is given. */\n locales: LocaleSet;\n /**\n * The site's reserved-slug predicate, the one `createPages` and\n * `createRedirects` take. A path that is reserved, before or after its\n * language prefix, is never redirected, whatever row exists.\n */\n isReservedSlug?: (slug: string) => boolean;\n /** The site's page path, for a site whose pages are not at `/<slug>`. Answer null for a page a visitor cannot open. */\n pagePath?: (page: unknown) => string | null;\n /** The site's origin, so a row's absolute URL on this site still counts. */\n origin?: string;\n}\n\ninterface Candidate {\n from: string;\n /** The row's language; null for a row with none. */\n language: string | null;\n /** The language the destination is resolved in. */\n in: string;\n inLanguage: boolean;\n}\n\nfunction both(path: string): string[] {\n return path === \"/\" ? [path] : [path, `${path}/`];\n}\n\n/**\n * The rows that could answer a path, best first:\n * - an unprefixed URL: the rows with no language (the default language's);\n * - a live language's URL (`/es/old`): that language's row, then a row with\n * no language saved with the whole path, then the row with no language\n * for the path after the prefix (`/old`), sent on in that language;\n * - an unticked language's URL: only a row with no language saved with the\n * whole path, so that language's own rows stay inert and `localeProxy`\n * 308s the prefix to the default language as before.\n */\nfunction redirectCandidates(options: MatchRedirectOptions): Candidate[] {\n const { pathname, locales } = options;\n const route = routeLocale(pathname, locales, options);\n if (route.action === \"skip\") return [];\n const codes = [...new Set([locales.defaultLocale, ...locales.active, ...locales.inactive])];\n const path = withoutTrailingSlash(pathname);\n const bare = withoutTrailingSlash(withoutLanguagePrefix(path, codes));\n if (\n options.isReservedSlug &&\n (options.isReservedSlug(normalizeSlug(path)) || options.isReservedSlug(normalizeSlug(bare)))\n ) {\n return [];\n }\n const { defaultLocale } = locales;\n const plain = (from: string, language: string): Candidate[] =>\n both(from).map((entry) => ({ from: entry, language: null, in: language, inLanguage: false }));\n if (route.action !== \"rewrite\") return plain(path, defaultLocale);\n const live = route.locale;\n return [\n ...both(path).map((from) => ({ from, language: live, in: live, inLanguage: false })),\n ...plain(path, live),\n ...both(bare).map((from) => ({ from, language: null, in: live, inLanguage: true })),\n ];\n}\n\n/**\n * The Redirects row for a request, in the request's language, as the\n * `Location` of a 308; null when no row answers. Call it in the site's proxy\n * before `localeProxy`, with the same live list:\n *\n * ```ts\n * const locales = await activeLocales(payload);\n * const redirect = await matchRedirect({ payload, pathname, search, locales, isReservedSlug });\n * if (redirect) return NextResponse.redirect(new URL(redirect.location, request.url), 308);\n * return localeProxy(request, locales);\n * ```\n *\n * A page reference resolves to the page's path in the visitor's language. A\n * row in a language that is not ticked never answers. Every destination is a\n * path on this site. A failed read answers null, so a database outage never\n * turns into an error page.\n */\nexport async function matchRedirect(options: MatchRedirectOptions): Promise<{ location: string } | null> {\n const candidates = redirectCandidates(options);\n if (candidates.length === 0) return null;\n const { locales } = options;\n const codes = [...new Set([locales.defaultLocale, ...locales.active, ...locales.inactive])];\n const froms = [...new Set(candidates.map((candidate) => candidate.from))];\n let rows: RedirectRow[];\n try {\n const result = await options.payload.find({\n collection: REDIRECTS_SLUG as never,\n where: { from: { in: froms } },\n depth: 1,\n // Only what the Location needs: a whole page would bring every block\n // table into a query that runs on every request.\n populate: { pages: { slug: true, pageKey: true, _status: true } } as never,\n limit: froms.length,\n pagination: false,\n overrideAccess: true,\n });\n rows = result.docs as RedirectRow[];\n } catch {\n return null;\n }\n const here = withoutTrailingSlash(options.pathname);\n for (const candidate of candidates) {\n const row = rows.find(\n (entry) => entry.from === candidate.from && rowLanguage(entry, locales.defaultLocale) === candidate.language,\n );\n if (!row) continue;\n const location = redirectDestination(row.to, {\n language: candidate.in,\n defaultLocale: locales.defaultLocale,\n codes,\n inLanguage: candidate.inLanguage,\n pagePath: options.pagePath,\n origin: options.origin,\n });\n if (!location || withoutTrailingSlash(location.split(/[?#]/)[0] ?? \"\") === here) continue;\n return { location: withSearch(location, options.search) };\n }\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAa,gBAAgB;AAkC7B,MAAM,eAAe,IAAI,IAAI;CAAC;CAAS;CAAO;CAAS;CAAU,CAAC;;AAGlE,MAAM,OAAO;;AAGb,MAAM,cAAc;AAEpB,SAAS,YAAY,UAAkB,SAAwC;AAC7E,QACE,aAAa,IAAI,SAAS,MAAM,IAAI,CAAC,MAAM,GAAG,KAC7C,QAAQ,OAAO,SAAS,IAAI;;AAIjC,SAAS,OAAO,UAA2B;AACzC,QAAO,KAAK,KAAK,SAAS,MAAM,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG;;;;;;;;;AAUpD,SAAgB,YACd,UACA,SACA,UAAgC,EAAE,EACrB;AACb,KAAI,YAAY,UAAU,QAAQ,CAAE,QAAO,E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R;AACN,SAAO;;CAET,MAAM,OAAO,qBAAqB,QAAQ,SAAS;AACnD,MAAK,MAAM,aAAa,YAAY;EAClC,MAAM,MAAM,KAAK,MACd,UAAU,MAAM,SAAS,UAAU,QAAQ,YAAY,OAAO,QAAQ,cAAc,KAAK,UAAU,SACrG;AACD,MAAI,CAAC,IAAK;EACV,MAAM,WAAW,oBAAoB,IAAI,IAAI;GAC3C,UAAU,UAAU;GACpB,eAAe,QAAQ;GACvB;GACA,YAAY,UAAU;GACtB,UAAU,QAAQ;GAClB,QAAQ,QAAQ;GACjB,CAAC;AACF,MAAI,CAAC,YAAY,qBAAqB,SAAS,MAAM,OAAO,CAAC,MAAM,GAAG,KAAK,KAAM;AACjF,SAAO,EAAE,UAAU,WAAW,UAAU,QAAQ,OAAO,EAAE;;AAE3D,QAAO"}
@@ -0,0 +1,165 @@
1
+ import { l as isRootPageKey } from "./root-page-key-ywNz2k4L.mjs";
2
+ import { u as localePath } from "./languages-B_iiWwxE.mjs";
3
+ //#region src/fields/slug-normalize.ts
4
+ /**
5
+ * The slug text rules, apart from the field so the proxy's Redirects lookup
6
+ * (`./locale-routing`) can use them without loading Payload.
7
+ */
8
+ /** One address segment from typed text: NFKD, lowercase, hyphenated, no slashes. */
9
+ function slugifySegment(segment) {
10
+ return segment.normalize("NFKD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
11
+ }
12
+ /**
13
+ * A stored slug from whatever was typed: NFKD, hyphenated, slash segments
14
+ * kept, so `Café / About Us` becomes `cafe/about-us`.
15
+ */
16
+ function normalizeSlug(value) {
17
+ return value.split("/").map(slugifySegment).filter(Boolean).join("/");
18
+ }
19
+ //#endregion
20
+ //#region src/redirects/lookup.ts
21
+ /**
22
+ * The Redirects rules both sides share (#340): how a row's `from` and
23
+ * `language` are stored (the collection's save hook), and where a matched
24
+ * row sends a visitor (the proxy's `matchRedirect`). No Payload at runtime:
25
+ * `./locale-routing` imports this on every request.
26
+ */
27
+ const REDIRECTS_SLUG = "redirects";
28
+ /** The row's language: empty for the default language's URLs (every row saved before #340). */
29
+ const REDIRECT_LANGUAGE_FIELD = "language";
30
+ /** A path without trailing slashes (`/` stays `/`). */
31
+ function withoutTrailingSlash(path) {
32
+ const trimmed = path.replace(/\/+$/, "");
33
+ return trimmed === "" ? "/" : trimmed;
34
+ }
35
+ /** The carried language whose prefix starts `path` (any case), or undefined. */
36
+ function languagePrefixOf(path, codes) {
37
+ const first = (path.split("/")[1] ?? "").toLowerCase();
38
+ return first ? codes.find((code) => code.toLowerCase() === first) : void 0;
39
+ }
40
+ /** `path` with its carried language prefix taken off, or `path` itself. */
41
+ function withoutLanguagePrefix(path, codes) {
42
+ if (!languagePrefixOf(path, codes)) return path;
43
+ return `/${path.split("/").slice(2).join("/").replace(/^[\\/]+/, "")}`;
44
+ }
45
+ /**
46
+ * A row's `from` and `language` as the collection stores them. `from` gets
47
+ * one leading slash and no trailing one. A row in a language stores the
48
+ * whole path, prefix included, in the language's own spelling: `/old` saved
49
+ * as Spanish becomes `/es/old`, and `/ES/old` saved with no language becomes
50
+ * a Spanish row. The default language is stored as no language, so it
51
+ * matches the rows saved before languages existed. A language the site does
52
+ * not carry is left as given, for the field to refuse, and so is a prefix
53
+ * that names another language, for From's validator to refuse. Nothing else about
54
+ * the path changes: a legacy URL keeps its case and characters.
55
+ */
56
+ function normalizeRedirectFrom(from, language, locales) {
57
+ const targets = locales.codes.filter((code) => code !== locales.defaultLocale);
58
+ const trimmed = from.trim();
59
+ const path = trimmed ? withoutTrailingSlash(`/${trimmed.replace(/^[\\/]+/, "")}`) : trimmed;
60
+ if (language && language !== locales.defaultLocale && !targets.includes(language)) return {
61
+ from: path,
62
+ language
63
+ };
64
+ const chosen = language && targets.includes(language) ? language : null;
65
+ if (!trimmed) return {
66
+ from: trimmed,
67
+ language: chosen
68
+ };
69
+ const prefix = languagePrefixOf(path, targets);
70
+ const rest = withoutLanguagePrefix(path, targets);
71
+ if (chosen) {
72
+ if (prefix && prefix !== chosen) return {
73
+ from: path,
74
+ language: chosen
75
+ };
76
+ return {
77
+ from: localePath(prefix ? rest : path, chosen, locales.defaultLocale),
78
+ language: chosen
79
+ };
80
+ }
81
+ if (prefix) return {
82
+ from: localePath(rest, prefix, locales.defaultLocale),
83
+ language: prefix
84
+ };
85
+ return {
86
+ from: path,
87
+ language: null
88
+ };
89
+ }
90
+ /** The row's language, with the default and an empty value both read as none. */
91
+ function rowLanguage(row, defaultLocale) {
92
+ const value = row.language;
93
+ return typeof value === "string" && value && value !== defaultLocale ? value : null;
94
+ }
95
+ const SITE = "http://bison.invalid";
96
+ /**
97
+ * A destination that stays on this site, as a root-relative path with its
98
+ * query and hash, or null. A protocol-relative or backslashed path, another
99
+ * scheme or another host is refused, and so is any value whose path, once
100
+ * dot segments are resolved (`/.//evil.com`), would start with `//` or `/\`
101
+ * and leave the site when a browser resolves it. An absolute URL counts only
102
+ * when `origin` is given and it matches.
103
+ */
104
+ function sitePath(url, origin) {
105
+ if (typeof url !== "string") return null;
106
+ const value = url.trim();
107
+ if (!value || /[\u0000-\u001f\u007f\\]/.test(value)) return null;
108
+ let resolved;
109
+ try {
110
+ if (value.startsWith("/")) {
111
+ if (value.startsWith("//")) return null;
112
+ resolved = new URL(value, SITE);
113
+ if (resolved.origin !== SITE) return null;
114
+ } else {
115
+ if (!origin) return null;
116
+ resolved = new URL(value);
117
+ if (resolved.origin !== new URL(origin).origin) return null;
118
+ }
119
+ } catch {
120
+ return null;
121
+ }
122
+ if (/^\/[\\/]/.test(resolved.pathname)) return null;
123
+ return `${resolved.pathname}${resolved.search}${resolved.hash}`;
124
+ }
125
+ /**
126
+ * A published page's path, before any language prefix: `/` for the home
127
+ * page, `/<slug>` otherwise. Null when the page is missing, not populated,
128
+ * not published, or has no slug, so the request goes on as if no row matched.
129
+ */
130
+ function defaultPagePath(page) {
131
+ if (!page || typeof page !== "object") return null;
132
+ const { slug, pageKey, _status } = page;
133
+ if (_status != null && _status !== "published") return null;
134
+ if (isRootPageKey(pageKey) || slug === "__root__") return "/";
135
+ if (typeof slug !== "string" || !slug) return null;
136
+ const path = `/${slug.replace(/[\u0000-\u001f\u007f]/g, "").replace(/^[\\/]+/, "").split("/").map(encodeURIComponent).join("/")}`;
137
+ return path === "/" ? null : path;
138
+ }
139
+ /** Where a row sends a visitor, as a path on this site, or null. */
140
+ function redirectDestination(to, options) {
141
+ if (!to) return null;
142
+ if (to.type === "custom") {
143
+ const path = sitePath(to.url, options.origin);
144
+ if (!path) return null;
145
+ if (!options.inLanguage || languagePrefixOf(path, options.codes)) return path;
146
+ return localePath(path, options.language, options.defaultLocale);
147
+ }
148
+ const reference = to.reference;
149
+ const page = reference && typeof reference === "object" && "value" in reference ? reference.value : reference;
150
+ const path = (options.pagePath ?? defaultPagePath)(page);
151
+ if (!path) return null;
152
+ const safe = sitePath(path);
153
+ return safe ? localePath(safe, options.language, options.defaultLocale) : null;
154
+ }
155
+ /** `location` with the request's query string, unless it has its own. */
156
+ function withSearch(location, search) {
157
+ if (!search || search === "?" || location.includes("?")) return location;
158
+ const query = search.startsWith("?") ? search : `?${search}`;
159
+ const hash = location.indexOf("#");
160
+ return hash === -1 ? `${location}${query}` : `${location.slice(0, hash)}${query}${location.slice(hash)}`;
161
+ }
162
+ //#endregion
163
+ export { redirectDestination as a, withoutLanguagePrefix as c, slugifySegment as d, normalizeRedirectFrom as i, withoutTrailingSlash as l, REDIRECT_LANGUAGE_FIELD as n, rowLanguage as o, languagePrefixOf as r, withSearch as s, REDIRECTS_SLUG as t, normalizeSlug as u };
164
+
165
+ //# sourceMappingURL=lookup-DiOCro-_.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup-DiOCro-_.mjs","names":[],"sources":["../src/fields/slug-normalize.ts","../src/redirects/lookup.ts"],"sourcesContent":["/**\n * The slug text rules, apart from the field so the proxy's Redirects lookup\n * (`./locale-routing`) can use them without loading Payload.\n */\n\n/** One address segment from typed text: NFKD, lowercase, hyphenated, no slashes. */\nexport function slugifySegment(segment: string): string {\n return segment\n .normalize(\"NFKD\")\n .replace(/\\p{M}/gu, \"\")\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n\n/**\n * A stored slug from whatever was typed: NFKD, hyphenated, slash segments\n * kept, so `Café / About Us` becomes `cafe/about-us`.\n */\nexport function normalizeSlug(value: string): string {\n return value.split(\"/\").map(slugifySegment).filter(Boolean).join(\"/\");\n}\n","/**\n * The Redirects rules both sides share (#340): how a row's `from` and\n * `language` are stored (the collection's save hook), and where a matched\n * row sends a visitor (the proxy's `matchRedirect`). No Payload at runtime:\n * `./locale-routing` imports this on every request.\n */\nimport { isRootPageKey, ROOT_PAGE_SLUG } from \"../collections/root-page-key\";\nimport { localePath } from \"../translate/languages\";\n\nexport const REDIRECTS_SLUG = \"redirects\";\n\n/** The row's language: empty for the default language's URLs (every row saved before #340). */\nexport const REDIRECT_LANGUAGE_FIELD = \"language\";\n\n/** The languages a site carries, as a row's language is checked against them. */\nexport interface RedirectLocales {\n defaultLocale: string;\n /** Every carried locale code, the default included. */\n codes: readonly string[];\n}\n\n/** A Redirects row as the lookup reads it; a generated `Redirect` is assignable. */\nexport interface RedirectRow {\n from?: string | null;\n language?: string | null;\n to?: {\n type?: \"reference\" | \"custom\" | null;\n url?: string | null;\n reference?: { relationTo?: string; value?: unknown } | null;\n } | null;\n}\n\n/** The page fields a destination needs; `matchRedirect` populates only these. */\nexport interface RedirectPage {\n slug?: string | null;\n pageKey?: string | null;\n _status?: string | null;\n}\n\n/** A path without trailing slashes (`/` stays `/`). */\nexport function withoutTrailingSlash(path: string): string {\n const trimmed = path.replace(/\\/+$/, \"\");\n return trimmed === \"\" ? \"/\" : trimmed;\n}\n\n/** The carried language whose prefix starts `path` (any case), or undefined. */\nexport function languagePrefixOf(\n path: string,\n codes: readonly string[],\n): string | undefined {\n const first = (path.split(\"/\")[1] ?? \"\").toLowerCase();\n return first ? codes.find((code) => code.toLowerCase() === first) : undefined;\n}\n\n/** `path` with its carried language prefix taken off, or `path` itself. */\nexport function withoutLanguagePrefix(\n path: string,\n codes: readonly string[],\n): string {\n const code = languagePrefixOf(path, codes);\n if (!code) return path;\n return `/${path\n .split(\"/\")\n .slice(2)\n .join(\"/\")\n .replace(/^[\\\\/]+/, \"\")}`;\n}\n\n/**\n * A row's `from` and `language` as the collection stores them. `from` gets\n * one leading slash and no trailing one. A row in a language stores the\n * whole path, prefix included, in the language's own spelling: `/old` saved\n * as Spanish becomes `/es/old`, and `/ES/old` saved with no language becomes\n * a Spanish row. The default language is stored as no language, so it\n * matches the rows saved before languages existed. A language the site does\n * not carry is left as given, for the field to refuse, and so is a prefix\n * that names another language, for From's validator to refuse. Nothing else about\n * the path changes: a legacy URL keeps its case and characters.\n */\nexport function normalizeRedirectFrom(\n from: string,\n language: string | null | undefined,\n locales: RedirectLocales,\n): { from: string; language: string | null } {\n const targets = locales.codes.filter(\n (code) => code !== locales.defaultLocale,\n );\n const trimmed = from.trim();\n const path = trimmed\n ? withoutTrailingSlash(`/${trimmed.replace(/^[\\\\/]+/, \"\")}`)\n : trimmed;\n // A language the site does not carry is kept as given, so the select refuses it.\n if (\n language &&\n language !== locales.defaultLocale &&\n !targets.includes(language)\n )\n return { from: path, language };\n const chosen = language && targets.includes(language) ? language : null;\n if (!trimmed) return { from: trimmed, language: chosen };\n const prefix = languagePrefixOf(path, targets);\n const rest = withoutLanguagePrefix(path, targets);\n if (chosen) {\n if (prefix && prefix !== chosen) return { from: path, language: chosen };\n return {\n from: localePath(prefix ? rest : path, chosen, locales.defaultLocale),\n language: chosen,\n };\n }\n if (prefix)\n return {\n from: localePath(rest, prefix, locales.defaultLocale),\n language: prefix,\n };\n return { from: path, language: null };\n}\n\n/** The row's language, with the default and an empty value both read as none. */\nexport function rowLanguage(\n row: RedirectRow,\n defaultLocale: string,\n): string | null {\n const value = row.language;\n return typeof value === \"string\" && value && value !== defaultLocale\n ? value\n : null;\n}\n\nconst SITE = \"http://bison.invalid\";\n\n/**\n * A destination that stays on this site, as a root-relative path with its\n * query and hash, or null. A protocol-relative or backslashed path, another\n * scheme or another host is refused, and so is any value whose path, once\n * dot segments are resolved (`/.//evil.com`), would start with `//` or `/\\`\n * and leave the site when a browser resolves it. An absolute URL counts only\n * when `origin` is given and it matches.\n */\nexport function sitePath(\n url: string | null | undefined,\n origin?: string,\n): string | null {\n if (typeof url !== \"string\") return null;\n const value = url.trim();\n if (!value || /[\\u0000-\\u001f\\u007f\\\\]/.test(value)) return null;\n let resolved: URL;\n try {\n if (value.startsWith(\"/\")) {\n if (value.startsWith(\"//\")) return null;\n resolved = new URL(value, SITE);\n if (resolved.origin !== SITE) return null;\n } else {\n if (!origin) return null;\n resolved = new URL(value);\n if (resolved.origin !== new URL(origin).origin) return null;\n }\n } catch {\n return null;\n }\n if (/^\\/[\\\\/]/.test(resolved.pathname)) return null;\n return `${resolved.pathname}${resolved.search}${resolved.hash}`;\n}\n\n/**\n * A published page's path, before any language prefix: `/` for the home\n * page, `/<slug>` otherwise. Null when the page is missing, not populated,\n * not published, or has no slug, so the request goes on as if no row matched.\n */\nexport function defaultPagePath(page: unknown): string | null {\n if (!page || typeof page !== \"object\") return null;\n const { slug, pageKey, _status } = page as RedirectPage;\n if (_status != null && _status !== \"published\") return null;\n if (isRootPageKey(pageKey) || slug === ROOT_PAGE_SLUG) return \"/\";\n if (typeof slug !== \"string\" || !slug) return null;\n const segments = slug\n .replace(/[\\u0000-\\u001f\\u007f]/g, \"\")\n .replace(/^[\\\\/]+/, \"\")\n .split(\"/\");\n const path = `/${segments.map(encodeURIComponent).join(\"/\")}`;\n return path === \"/\" ? null : path;\n}\n\nexport interface DestinationOptions {\n /** The language the visitor is in; a page reference resolves to its path there. */\n language: string;\n defaultLocale: string;\n codes: readonly string[];\n /**\n * True when an English (no-language) row answers a URL in another\n * language: a typed path is sent to that language too (`/about-us` →\n * `/es/about-us`) unless it already names one.\n */\n inLanguage: boolean;\n /** The site's page path; `defaultPagePath` when omitted. */\n pagePath?: (page: unknown) => string | null;\n origin?: string;\n}\n\n/** Where a row sends a visitor, as a path on this site, or null. */\nexport function redirectDestination(\n to: RedirectRow[\"to\"],\n options: DestinationOptions,\n): string | null {\n if (!to) return null;\n if (to.type === \"custom\") {\n const path = sitePath(to.url, options.origin);\n if (!path) return null;\n if (!options.inLanguage || languagePrefixOf(path, options.codes))\n return path;\n return localePath(path, options.language, options.defaultLocale);\n }\n const reference = to.reference;\n const page =\n reference && typeof reference === \"object\" && \"value\" in reference\n ? reference.value\n : reference;\n const path = (options.pagePath ?? defaultPagePath)(page);\n if (!path) return null;\n const safe = sitePath(path);\n return safe\n ? localePath(safe, options.language, options.defaultLocale)\n : null;\n}\n\n/** `location` with the request's query string, unless it has its own. */\nexport function withSearch(\n location: string,\n search: string | undefined,\n): string {\n if (!search || search === \"?\" || location.includes(\"?\")) return location;\n const query = search.startsWith(\"?\") ? search : `?${search}`;\n const hash = location.indexOf(\"#\");\n return hash === -1\n ? `${location}${query}`\n : `${location.slice(0, hash)}${query}${location.slice(hash)}`;\n}\n"],"mappings":";;;;;;;;AAMA,SAAgB,eAAe,SAAyB;AACtD,QAAO,QACJ,UAAU,OAAO,CACjB,QAAQ,WAAW,GAAG,CACtB,aAAa,CACb,QAAQ,eAAe,IAAI,CAC3B,QAAQ,YAAY,GAAG;;;;;;AAO5B,SAAgB,cAAc,OAAuB;AACnD,QAAO,MAAM,MAAM,IAAI,CAAC,IAAI,eAAe,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI;;;;;;;;;;ACXvE,MAAa,iBAAiB;;AAG9B,MAAa,0BAA0B;;AA4BvC,SAAgB,qBAAqB,MAAsB;CACzD,MAAM,UAAU,KAAK,QAAQ,QAAQ,GAAG;AACxC,QAAO,YAAY,KAAK,MAAM;;;AAIhC,SAAgB,iBACd,MACA,OACoB;CACpB,MAAM,SAAS,KAAK,MAAM,IAAI,CAAC,MAAM,IAAI,aAAa;AACtD,QA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AAM,QAAQ,UAAU,QAAQ,cAAc;;CAElE,MAAM,YAAY,GAAG;CACrB,MAAM,OACJ,aAAa,OAAO,cAAc,YAAY,WAAW,YACrD,UAAU,QACV;CACN,MAAM,QAAQ,QAAQ,YAAY,iBAAiB,KAAK;AACxD,KAAI,CAAC,KAAM,QAAO;CAClB,MAAM,OAAO,SAAS,KAAK;AAC3B,QAAO,OACH,WAAW,MAAM,QAAQ,UAAU,QAAQ,cAAc,GACzD;;;AAIN,SAAgB,WACd,UACA,QACQ;AACR,KAAI,CAAC,UAAU,WAAW,OAAO,SAAS,SAAS,IAAI,CAAE,QAAO;CAChE,MAAM,QAAQ,OAAO,WAAW,IAAI,GAAG,SAAS,IAAI;CACpD,MAAM,OAAO,SAAS,QAAQ,IAAI;AAClC,QAAO,SAAS,KACZ,GAAG,WAAW,UACd,GAAG,SAAS,MAAM,GAAG,KAAK,GAAG,QAAQ,SAAS,MAAM,KAAK"}
@@ -0,0 +1,41 @@
1
+ //#region src/redirects/lookup.d.ts
2
+ declare const REDIRECTS_SLUG = "redirects";
3
+ /** The row's language: empty for the default language's URLs (every row saved before #340). */
4
+ declare const REDIRECT_LANGUAGE_FIELD = "language";
5
+ /** The languages a site carries, as a row's language is checked against them. */
6
+ interface RedirectLocales {
7
+ defaultLocale: string;
8
+ /** Every carried locale code, the default included. */
9
+ codes: readonly string[];
10
+ }
11
+ /** A Redirects row as the lookup reads it; a generated `Redirect` is assignable. */
12
+ interface RedirectRow {
13
+ from?: string | null;
14
+ language?: string | null;
15
+ to?: {
16
+ type?: "reference" | "custom" | null;
17
+ url?: string | null;
18
+ reference?: {
19
+ relationTo?: string;
20
+ value?: unknown;
21
+ } | null;
22
+ } | null;
23
+ }
24
+ /**
25
+ * A row's `from` and `language` as the collection stores them. `from` gets
26
+ * one leading slash and no trailing one. A row in a language stores the
27
+ * whole path, prefix included, in the language's own spelling: `/old` saved
28
+ * as Spanish becomes `/es/old`, and `/ES/old` saved with no language becomes
29
+ * a Spanish row. The default language is stored as no language, so it
30
+ * matches the rows saved before languages existed. A language the site does
31
+ * not carry is left as given, for the field to refuse, and so is a prefix
32
+ * that names another language, for From's validator to refuse. Nothing else about
33
+ * the path changes: a legacy URL keeps its case and characters.
34
+ */
35
+ declare function normalizeRedirectFrom(from: string, language: string | null | undefined, locales: RedirectLocales): {
36
+ from: string;
37
+ language: string | null;
38
+ };
39
+ //#endregion
40
+ export { normalizeRedirectFrom as a, RedirectRow as i, REDIRECT_LANGUAGE_FIELD as n, RedirectLocales as r, REDIRECTS_SLUG as t };
41
+ //# sourceMappingURL=lookup-uyEKHlLX.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup-uyEKHlLX.d.mts","names":[],"sources":["../src/redirects/lookup.ts"],"mappings":";cASa,cAAA;AAAb;AAAA,cAGa,uBAAA;;UAGI,eAAA;EACf,aAAA;EAJW;EAMX,KAAA;AAAA;;UAIe,WAAA;EACf,IAAA;EACA,QAAA;EACA,EAAA;IACE,IAAA;IACA,GAAA;IACA,SAAA;MAAc,UAAA;MAAqB,KAAA;IAAA;EAAA;AAAA;;;;;;;;;;;;iBAmDvB,qBAAA,CACd,IAAA,UACA,QAAA,6BACA,OAAA,EAAS,eAAA;EACN,IAAA;EAAc,QAAA;AAAA"}
@@ -1,4 +1,4 @@
1
- import { n as translateStrings } from "./strings-Fd7kUCT7.mjs";
1
+ import { n as translateStrings } from "./strings-_9n8BefX.mjs";
2
2
  //#region src/translate/messages.ts
3
3
  const BATCH_SIZE = 40;
4
4
  /** Every string leaf as [path, value]; array indexes are path segments. */
@@ -90,4 +90,4 @@ async function fillMessages(options) {
90
90
  //#endregion
91
91
  export { fillMessages as t };
92
92
 
93
- //# sourceMappingURL=messages-XFoL9RtF.mjs.map
93
+ //# sourceMappingURL=messages-Bv6JIEiG.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"messages-XFoL9RtF.mjs","names":[],"sources":["../src/translate/messages.ts"],"sourcesContent":["import { translateStrings } from \"./strings\";\nimport type { TranslateSite, Translator } from \"./types\";\n\n/** A next-intl message file: nested objects and arrays with string leaves. */\nexport type MessagesJson = string | number | boolean | null | MessagesJson[] | { [key: string]: MessagesJson };\n\nconst BATCH_SIZE = 40;\n\n/** Every string leaf as [path, value]; array indexes are path segments. */\nfunction stringLeaves(\n node: MessagesJson,\n path: string[] = [],\n out: Array<[string[], string]> = [],\n): Array<[string[], string]> {\n if (typeof node === \"string\") out.push([path, node]);\n else if (Array.isArray(node)) node.forEach((item, index) => stringLeaves(item, [...path, String(index)], out));\n else if (node && typeof node === \"object\") {\n for (const [key, value] of Object.entries(node)) stringLeaves(value, [...path, key], out);\n }\n return out;\n}\n\nfunction getAtPath(root: MessagesJson, path: string[]): MessagesJson | undefined {\n let current: MessagesJson | undefined = root;\n for (const segment of path) {\n if (current == null || typeof current !== \"object\") return undefined;\n current = Array.isArray(current) ? current[Number(segment)] : current[segment];\n }\n return current;\n}\n\nfunction setAtPath(root: { [key: string]: MessagesJson }, path: string[], value: string): void {\n let current: { [key: string]: MessagesJson } | MessagesJson[] = root;\n for (let i = 0; i < path.length - 1; i++) {\n const segment = path[i]!;\n const wantArray = /^\\d+$/.test(path[i + 1]!);\n const container = current as Record<string, MessagesJson>;\n let child = container[segment];\n // Create the container when missing, and REPAIR it when the existing\n // target node has the opposite shape from the source (the source changed\n // an object into a list) so string keys never land in an array or the\n // reverse.\n if (child == null || typeof child !== \"object\" || Array.isArray(child) !== wantArray) {\n child = wantArray ? [] : {};\n container[segment] = child;\n }\n current = child as { [key: string]: MessagesJson } | MessagesJson[];\n }\n (current as Record<string, MessagesJson>)[path[path.length - 1]!] = value;\n}\n\n/**\n * The `{name}` arguments of a message, sorted. Plural and select messages are\n * skipped (their branch bodies are braced text the model rightly translates),\n * so this only checks plain interpolations.\n */\nfunction placeholderNames(message: string): string | null {\n if (/,\\s*(plural|select|selectordinal)\\s*,/.test(message)) return null;\n const names = [...message.matchAll(/\\{\\s*([A-Za-z_][\\w]*)\\s*\\}/g)].map((match) => match[1]!);\n return names.sort().join(\",\");\n}\n\n/** A translation that dropped or renamed a `{placeholder}` would break at render; keep the source instead. */\nexport function keepsPlaceholders(source: string, translated: string): boolean {\n const before = placeholderNames(source);\n return before === null || before === placeholderNames(translated);\n}\n\nexport interface FillMessagesResult {\n /** The target file to write. */\n messages: MessagesJson;\n /** Keys translated. */\n translated: number;\n /**\n * Keys whose batch failed, or whose translation lost a `{placeholder}`.\n * They hold the source text, so the file stays\n * complete (a hole renders as MISSING_MESSAGE); a plain re-run will not\n * retry them, `--force` (or a hand edit) will.\n */\n fellBack: number;\n}\n\n/**\n * Fills a target next-intl message file from the source file. The source is\n * the truth; only keys that are missing or empty in the target are\n * translated, so reviewed copy is never overwritten, unless `force`\n * re-translates every key. Batches of 40, so one failure costs at most 40\n * keys. `{placeholders}` survive because the translator's prompt keeps them.\n */\nexport async function fillMessages(options: {\n source: MessagesJson;\n target?: MessagesJson;\n translator: Translator;\n from: string;\n to: string;\n force?: boolean;\n context?: string;\n site?: TranslateSite;\n onProgress?: (done: number, total: number) => void;\n}): Promise<FillMessagesResult> {\n const base =\n !options.force && options.target && typeof options.target === \"object\" && !Array.isArray(options.target)\n ? (structuredClone(options.target) as { [key: string]: MessagesJson })\n : {};\n const missing = stringLeaves(options.source).filter(([path]) => {\n const existing = getAtPath(base, path);\n return typeof existing !== \"string\" || existing.trim() === \"\";\n });\n\n let translated = 0;\n let fellBack = 0;\n for (let i = 0; i < missing.length; i += BATCH_SIZE) {\n const batch = missing.slice(i, i + BATCH_SIZE);\n const sources = batch.map(([, value]) => value);\n const result = await translateStrings(sources, {\n translator: options.translator,\n from: options.from,\n to: options.to,\n context: options.context ?? \"Website UI strings\",\n ...(options.site ? { site: options.site } : {}),\n });\n batch.forEach(([path, source], index) => {\n const value = result?.[index];\n if (value !== undefined && keepsPlaceholders(source, value)) {\n translated += 1;\n setAtPath(base, path, value);\n } else {\n fellBack += 1;\n setAtPath(base, path, source);\n }\n });\n options.onProgress?.(Math.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O;;AAEhF,QAAO;EAAE,UAAU;EAAM;EAAY;EAAU"}
1
+ {"version":3,"file":"messages-Bv6JIEiG.mjs","names":[],"sources":["../src/translate/messages.ts"],"sourcesContent":["import { translateStrings } from \"./strings\";\nimport type { TranslateSite, Translator } from \"./types\";\n\n/** A next-intl message file: nested objects and arrays with string leaves. */\nexport type MessagesJson = string | number | boolean | null | MessagesJson[] | { [key: string]: MessagesJson };\n\nconst BATCH_SIZE = 40;\n\n/** Every string leaf as [path, value]; array indexes are path segments. */\nfunction stringLeaves(\n node: MessagesJson,\n path: string[] = [],\n out: Array<[string[], string]> = [],\n): Array<[string[], string]> {\n if (typeof node === \"string\") out.push([path, node]);\n else if (Array.isArray(node)) node.forEach((item, index) => stringLeaves(item, [...path, String(index)], out));\n else if (node && typeof node === \"object\") {\n for (const [key, value] of Object.entries(node)) stringLeaves(value, [...path, key], out);\n }\n return out;\n}\n\nfunction getAtPath(root: MessagesJson, path: string[]): MessagesJson | undefined {\n let current: MessagesJson | undefined = root;\n for (const segment of path) {\n if (current == null || typeof current !== \"object\") return undefined;\n current = Array.isArray(current) ? current[Number(segment)] : current[segment];\n }\n return current;\n}\n\nfunction setAtPath(root: { [key: string]: MessagesJson }, path: string[], value: string): void {\n let current: { [key: string]: MessagesJson } | MessagesJson[] = root;\n for (let i = 0; i < path.length - 1; i++) {\n const segment = path[i]!;\n const wantArray = /^\\d+$/.test(path[i + 1]!);\n const container = current as Record<string, MessagesJson>;\n let child = container[segment];\n // Create the container when missing, and REPAIR it when the existing\n // target node has the opposite shape from the source (the source changed\n // an object into a list) so string keys never land in an array or the\n // reverse.\n if (child == null || typeof child !== \"object\" || Array.isArray(child) !== wantArray) {\n child = wantArray ? [] : {};\n container[segment] = child;\n }\n current = child as { [key: string]: MessagesJson } | MessagesJson[];\n }\n (current as Record<string, MessagesJson>)[path[path.length - 1]!] = value;\n}\n\n/**\n * The `{name}` arguments of a message, sorted. Plural and select messages are\n * skipped (their branch bodies are braced text the model rightly translates),\n * so this only checks plain interpolations.\n */\nfunction placeholderNames(message: string): string | null {\n if (/,\\s*(plural|select|selectordinal)\\s*,/.test(message)) return null;\n const names = [...message.matchAll(/\\{\\s*([A-Za-z_][\\w]*)\\s*\\}/g)].map((match) => match[1]!);\n return names.sort().join(\",\");\n}\n\n/** A translation that dropped or renamed a `{placeholder}` would break at render; keep the source instead. */\nexport function keepsPlaceholders(source: string, translated: string): boolean {\n const before = placeholderNames(source);\n return before === null || before === placeholderNames(translated);\n}\n\nexport interface FillMessagesResult {\n /** The target file to write. */\n messages: MessagesJson;\n /** Keys translated. */\n translated: number;\n /**\n * Keys whose batch failed, or whose translation lost a `{placeholder}`.\n * They hold the source text, so the file stays\n * complete (a hole renders as MISSING_MESSAGE); a plain re-run will not\n * retry them, `--force` (or a hand edit) will.\n */\n fellBack: number;\n}\n\n/**\n * Fills a target next-intl message file from the source file. The source is\n * the truth; only keys that are missing or empty in the target are\n * translated, so reviewed copy is never overwritten, unless `force`\n * re-translates every key. Batches of 40, so one failure costs at most 40\n * keys. `{placeholders}` survive because the translator's prompt keeps them.\n */\nexport async function fillMessages(options: {\n source: MessagesJson;\n target?: MessagesJson;\n translator: Translator;\n from: string;\n to: string;\n force?: boolean;\n context?: string;\n site?: TranslateSite;\n onProgress?: (done: number, total: number) => void;\n}): Promise<FillMessagesResult> {\n const base =\n !options.force && options.target && typeof options.target === \"object\" && !Array.isArray(options.target)\n ? (structuredClone(options.target) as { [key: string]: MessagesJson })\n : {};\n const missing = stringLeaves(options.source).filter(([path]) => {\n const existing = getAtPath(base, path);\n return typeof existing !== \"string\" || existing.trim() === \"\";\n });\n\n let translated = 0;\n let fellBack = 0;\n for (let i = 0; i < missing.length; i += BATCH_SIZE) {\n const batch = missing.slice(i, i + BATCH_SIZE);\n const sources = batch.map(([, value]) => value);\n const result = await translateStrings(sources, {\n translator: options.translator,\n from: options.from,\n to: options.to,\n context: options.context ?? \"Website UI strings\",\n ...(options.site ? { site: options.site } : {}),\n });\n batch.forEach(([path, source], index) => {\n const value = result?.[index];\n if (value !== undefined && keepsPlaceholders(source, value)) {\n translated += 1;\n setAtPath(base, path, value);\n } else {\n fellBack += 1;\n setAtPath(base, path, source);\n }\n });\n options.onProgress?.(Math.min(i + BATCH_SIZE, missing.length), missing.length);\n }\n return { messages: base, translated, fellBack };\n}\n"],"mappings":";;AAMA,MAAM,aAAa;;AAGnB,SAAS,aACP,MACA,OAAiB,EAAE,EACnB,MAAiC,EAAE,EACR;AAC3B,KAAI,OAAO,SAAS,SAAU,KAAI,KAAK,CAAC,MAAM,KAAK,CAAC;UAC3C,MAAM,QAAQ,KAAK,CAAE,MAAK,SAAS,MAAM,UAAU,aAAa,MAAM,CAAC,GAAG,MAAM,OAAO,MAAM,CAAC,EAAE,IAAI,CAAC;UACrG,QAAQ,OAAO,SAAS,SAC/B,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,CAAE,cAAa,OAAO,CAAC,GAAG,MAAM,IAAI,EAAE,IAAI;AAE3F,QAAO;;AAGT,SAAS,UAAU,MAAoB,MAA0C;CAC/E,IAAI,UAAoC;AACxC,MAAK,MAAM,WAAW,MAAM;AAC1B,MAAI,WAAW,QAAQ,OAAO,YAAY,SAAU,QAAO,KAAA;AAC3D,YAAU,MAAM,QAAQ,QAAQ,GAAG,QAAQ,OAAO,QAAQ,IAAI,QAAQ;;AAExE,QAAO;;AAGT,SAAS,UAAU,MAAuC,MAAgB,OAAqB;CAC7F,IAAI,UAA4D;AAChE,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,SAAS,GAAG,KAAK;EACxC,MAAM,UAAU,KAAK;EACrB,MAAM,YAAY,QAAQ,KAAK,KAAK,IAAI,GAAI;EAC5C,MAAM,YAAY;EAClB,IAAI,QAAQ,UAAU;AAKtB,MAAI,SAAS,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,MAAM,KAAK,WAAW;AACpF,WAAQ,YAAY,EAAE,GAAG,EAAE;AAC3B,aAAU,WAAW;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AM,MAAM,MAAM;UACvB;AACL,gBAAY;AACZ,cAAU,MAAM,MAAM,OAAO;;IAE/B;AACF,UAAQ,aAAa,KAAK,IAAI,IAAI,YAAY,QAAQ,OAAO,EAAE,QAAQ,OAAO;;AAEhF,QAAO;EAAE,UAAU;EAAM;EAAY;EAAU"}
@@ -1,5 +1,5 @@
1
- import { a as SeoImageSize, i as SeoImageDoc, n as titleTemplate, o as SeoImageValue, r as MediaId, s as SeoMeta, t as documentTitle } from "./title-BVV3o329.mjs";
2
- import { t as LocaleAlternatesOptions } from "./alternates-DlRTsaVe.mjs";
1
+ import { a as SeoImageSize, i as SeoImageDoc, n as titleTemplate, o as SeoImageValue, r as MediaId, s as SeoMeta, t as documentTitle } from "./title-DBSLJfrW.mjs";
2
+ import { t as LocaleAlternatesOptions } from "./alternates-aRncEUBI.mjs";
3
3
 
4
4
  //#region src/seo/metadata.d.ts
5
5
  /** A page as the reader needs it; a site's generated `Page` is assignable. */
package/dist/metadata.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as titleTemplate, t as documentTitle } from "./title-DJ7C48gq.mjs";
2
2
  import { t as SHARE_IMAGE_SIZE } from "./share-image-C8ZtIcU8.mjs";
3
- import { t as languageAlternates } from "./alternates-DxBTUXHh.mjs";
3
+ import { t as languageAlternates } from "./alternates-Tv5-ccza.mjs";
4
4
  //#region src/seo/metadata.ts
5
5
  /**
6
6
  * The share image as a crawler wants it, or `undefined` when the page has
@@ -1,3 +1,3 @@
1
- import { t as LocaleRead } from "./locale-tnKLkutC.mjs";
2
- import { C as NAVIGATION_FOOTER_SLUG, D as NavigationFooter, E as NavigationDoc, O as NavigationHeader, S as NAVIGATION_FOOTER_DB_NAME, T as NavigationBar, _ as validateExternalHref, a as FOOTER_MAX_LINK_COLUMNS, b as NAVIGATION_DB_NAME, c as FooterColumnWidth, d as normalizeFooterDesktop, g as isValidExternalHref, i as FOOTER_MAX_COLUMNS, l as FooterSocial, m as EXTERNAL_HREF_MESSAGE, o as FOOTER_SOCIALS, p as validateFooterSocialUrl, r as FOOTER_COLUMN_WIDTHS, s as FOOTER_TWELFTHS, t as getNavigation, u as footerDesktopTracks, v as validateHeaderCta, w as NAVIGATION_SLUG } from "./published-BhYTEAK_.mjs";
1
+ import { t as LocaleRead } from "./locale-CTT3nn6T.mjs";
2
+ import { C as NAVIGATION_FOOTER_SLUG, D as NavigationFooter, E as NavigationDoc, O as NavigationHeader, S as NAVIGATION_FOOTER_DB_NAME, T as NavigationBar, _ as validateExternalHref, a as FOOTER_MAX_LINK_COLUMNS, b as NAVIGATION_DB_NAME, c as FooterColumnWidth, d as normalizeFooterDesktop, g as isValidExternalHref, i as FOOTER_MAX_COLUMNS, l as FooterSocial, m as EXTERNAL_HREF_MESSAGE, o as FOOTER_SOCIALS, p as validateFooterSocialUrl, r as FOOTER_COLUMN_WIDTHS, s as FOOTER_TWELFTHS, t as getNavigation, u as footerDesktopTracks, v as validateHeaderCta, w as NAVIGATION_SLUG } from "./published-VTz_aYaQ.mjs";
3
3
  export { EXTERNAL_HREF_MESSAGE, FOOTER_COLUMN_WIDTHS, FOOTER_MAX_COLUMNS, FOOTER_MAX_LINK_COLUMNS, FOOTER_SOCIALS, FOOTER_TWELFTHS, type FooterColumnWidth, type FooterSocial, type LocaleRead, NAVIGATION_DB_NAME, NAVIGATION_FOOTER_DB_NAME, NAVIGATION_FOOTER_SLUG, NAVIGATION_SLUG, type NavigationBar, type NavigationDoc, type NavigationFooter, type NavigationHeader, footerDesktopTracks, getNavigation, isValidExternalHref, normalizeFooterDesktop, validateExternalHref, validateFooterSocialUrl, validateHeaderCta };
@@ -1,2 +1,2 @@
1
- import { C as NAVIGATION_SLUG, S as NAVIGATION_FOOTER_SLUG, _ as validateExternalHref, a as FOOTER_MAX_LINK_COLUMNS, c as footerDesktopTracks, f as validateFooterSocialUrl, h as isValidExternalHref, i as FOOTER_MAX_COLUMNS, o as FOOTER_SOCIALS, p as EXTERNAL_HREF_MESSAGE, r as FOOTER_COLUMN_WIDTHS, s as FOOTER_TWELFTHS, t as getNavigation, u as normalizeFooterDesktop, v as validateHeaderCta, x as NAVIGATION_FOOTER_DB_NAME, y as NAVIGATION_DB_NAME } from "./published-Vu_QX2Vv.mjs";
1
+ import { C as NAVIGATION_SLUG, S as NAVIGATION_FOOTER_SLUG, _ as validateExternalHref, a as FOOTER_MAX_LINK_COLUMNS, c as footerDesktopTracks, f as validateFooterSocialUrl, h as isValidExternalHref, i as FOOTER_MAX_COLUMNS, o as FOOTER_SOCIALS, p as EXTERNAL_HREF_MESSAGE, r as FOOTER_COLUMN_WIDTHS, s as FOOTER_TWELFTHS, t as getNavigation, u as normalizeFooterDesktop, v as validateHeaderCta, x as NAVIGATION_FOOTER_DB_NAME, y as NAVIGATION_DB_NAME } from "./published-BF2F3od_.mjs";
2
2
  export { EXTERNAL_HREF_MESSAGE, FOOTER_COLUMN_WIDTHS, FOOTER_MAX_COLUMNS, FOOTER_MAX_LINK_COLUMNS, FOOTER_SOCIALS, FOOTER_TWELFTHS, NAVIGATION_DB_NAME, NAVIGATION_FOOTER_DB_NAME, NAVIGATION_FOOTER_SLUG, NAVIGATION_SLUG, footerDesktopTracks, getNavigation, isValidExternalHref, normalizeFooterDesktop, validateExternalHref, validateFooterSocialUrl, validateHeaderCta };
package/dist/og.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { _ as ThemeIdentityFallback } from "./types-B1MmE-L3.mjs";
2
- import { t as ThemePayload } from "./published-2I-k6zEo.mjs";
1
+ import { r as ThemeIdentityFallback } from "./identity-B4Lew8Fu.mjs";
2
+ import { t as ThemePayload } from "./published-DYpXTy84.mjs";
3
3
  import { FontId } from "@bison-lab/fonts";
4
4
  import { ThemeConfig } from "@bison-lab/tokens";
5
5
  import { Payload } from "payload";