@demiurgejs/core 0.2.0-beta.5 → 0.2.0-beta.6

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 (92) hide show
  1. package/README.md +14 -0
  2. package/bin/demiurge.mjs +6 -0
  3. package/dist/chunks/{document-shell-9GPwtcTt.js → document-shell-C0aPrkhd.js} +2 -2
  4. package/dist/chunks/{document-shell-9GPwtcTt.js.map → document-shell-C0aPrkhd.js.map} +1 -1
  5. package/dist/chunks/image-CRerJ5BY.js +145 -0
  6. package/dist/chunks/image-CRerJ5BY.js.map +1 -0
  7. package/dist/chunks/{image-codec-Dh1POFhE.js → image-codec-CQ8Cwxwb.js} +2 -2
  8. package/dist/chunks/{image-codec-Dh1POFhE.js.map → image-codec-CQ8Cwxwb.js.map} +1 -1
  9. package/dist/chunks/{images-CG7ZzayG.js → images-QgdmLyQ3.js} +11 -11
  10. package/dist/chunks/{images-CG7ZzayG.js.map → images-QgdmLyQ3.js.map} +1 -1
  11. package/dist/chunks/{index-0MNiR_wo.js → index-LYve1rQp.js} +286 -351
  12. package/dist/chunks/index-LYve1rQp.js.map +1 -0
  13. package/dist/chunks/links-iU22QkCE.js +68 -0
  14. package/dist/chunks/links-iU22QkCE.js.map +1 -0
  15. package/dist/chunks/{plugin-BZauDxRY.js → plugin-bkP6WwrS.js} +13 -12
  16. package/dist/chunks/{plugin-BZauDxRY.js.map → plugin-bkP6WwrS.js.map} +1 -1
  17. package/dist/chunks/runtime-BH519j2t.js +294 -0
  18. package/dist/chunks/runtime-BH519j2t.js.map +1 -0
  19. package/dist/chunks/streaming-BlKlC3nw.js +427 -0
  20. package/dist/chunks/streaming-BlKlC3nw.js.map +1 -0
  21. package/dist/chunks/{testing-CUwGj2ie.js → testing-BEW1nchS.js} +645 -630
  22. package/dist/chunks/testing-BEW1nchS.js.map +1 -0
  23. package/dist/chunks/{vite-QoqrGl6f.js → vite-BADZA8Fl.js} +73 -70
  24. package/dist/chunks/vite-BADZA8Fl.js.map +1 -0
  25. package/dist/cli.d.ts +8 -2
  26. package/dist/cli.d.ts.map +1 -1
  27. package/dist/cli.js +186 -122
  28. package/dist/cli.js.map +1 -1
  29. package/dist/config/index.js +2 -2
  30. package/dist/config/types.d.ts +3 -1
  31. package/dist/config/types.d.ts.map +1 -1
  32. package/dist/config/validate.d.ts.map +1 -1
  33. package/dist/data/cache.d.ts +5 -0
  34. package/dist/data/cache.d.ts.map +1 -1
  35. package/dist/data/index.d.ts +1 -1
  36. package/dist/data/index.d.ts.map +1 -1
  37. package/dist/data/testing.d.ts.map +1 -1
  38. package/dist/data/testing.js +101 -67
  39. package/dist/data/testing.js.map +1 -1
  40. package/dist/data/tiered.d.ts.map +1 -1
  41. package/dist/edge/index.js +27 -26
  42. package/dist/edge/index.js.map +1 -1
  43. package/dist/edge/stores.d.ts.map +1 -1
  44. package/dist/index.d.ts +1 -1
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +126 -125
  47. package/dist/index.js.map +1 -1
  48. package/dist/internal/testing.js +2 -2
  49. package/dist/kv/index.js +7 -6
  50. package/dist/kv/index.js.map +1 -1
  51. package/dist/kv/store.d.ts.map +1 -1
  52. package/dist/node/http.d.ts +2 -0
  53. package/dist/node/http.d.ts.map +1 -1
  54. package/dist/node/index.d.ts +1 -1
  55. package/dist/node/index.d.ts.map +1 -1
  56. package/dist/node/index.js +12 -11
  57. package/dist/node/index.js.map +1 -1
  58. package/dist/node/serve.d.ts +4 -0
  59. package/dist/node/serve.d.ts.map +1 -1
  60. package/dist/redis/index.js +29 -28
  61. package/dist/redis/index.js.map +1 -1
  62. package/dist/redis/store.d.ts.map +1 -1
  63. package/dist/route/serialization.d.ts +4 -4
  64. package/dist/route/serialization.d.ts.map +1 -1
  65. package/dist/static/index.d.ts.map +1 -1
  66. package/dist/static/index.js +255 -255
  67. package/dist/static/index.js.map +1 -1
  68. package/dist/static/testing.d.ts +26 -0
  69. package/dist/static/testing.d.ts.map +1 -0
  70. package/dist/static/testing.js +76 -0
  71. package/dist/static/testing.js.map +1 -0
  72. package/dist/testing/index.d.ts +47 -0
  73. package/dist/testing/index.d.ts.map +1 -0
  74. package/dist/testing/index.js +99 -0
  75. package/dist/testing/index.js.map +1 -0
  76. package/dist/vercel/build.d.ts +31 -0
  77. package/dist/vercel/build.d.ts.map +1 -0
  78. package/dist/vercel/config.d.ts +15 -0
  79. package/dist/vercel/config.d.ts.map +1 -0
  80. package/dist/vercel/index.d.ts +7 -0
  81. package/dist/vercel/index.d.ts.map +1 -0
  82. package/dist/vercel/index.js +11 -0
  83. package/dist/vercel/index.js.map +1 -0
  84. package/dist/vercel/runtime.d.ts +29 -0
  85. package/dist/vercel/runtime.d.ts.map +1 -0
  86. package/dist/vite/index.js +1 -1
  87. package/package.json +13 -1
  88. package/dist/chunks/index-0MNiR_wo.js.map +0 -1
  89. package/dist/chunks/streaming-GYIsVTQH.js +0 -560
  90. package/dist/chunks/streaming-GYIsVTQH.js.map +0 -1
  91. package/dist/chunks/testing-CUwGj2ie.js.map +0 -1
  92. package/dist/chunks/vite-QoqrGl6f.js.map +0 -1
@@ -1,47 +1,48 @@
1
- import { B as Nr, A as Mr, C as Je, D as Ft, E as Wt, e as Bt, F as jr, G as Ur, I as Ir, q as zr, o as Hr, a as Fr } from "./index-0MNiR_wo.js";
2
- import { createElement as Ie } from "react";
1
+ import { r as Nr } from "./links-iU22QkCE.js";
2
+ import { w as Mr, x as Ke, y as Ft, z as Wt, e as Bt, F as jr, A as Ur, B as Ir, p as zr, o as Hr, a as Fr } from "./index-LYve1rQp.js";
3
+ import { createElement as He } from "react";
3
4
  import { renderToString as Vt } from "react-dom/server";
4
5
  import { jsxs as X, jsx as ee } from "react/jsx-runtime";
5
6
  function Wr(e, t) {
6
- const r = Ae(t.canonical);
7
- if (e.canonical && Ae(e.canonical, r) !== r)
7
+ const r = ke(t.canonical);
8
+ if (e.canonical && ke(e.canonical, r) !== r)
8
9
  throw new Error(
9
10
  `Localized metadata canonical URL ${JSON.stringify(e.canonical)} conflicts with ${JSON.stringify(t.canonical)}.`
10
11
  );
11
12
  const n = e.custom.filter(
12
- (i) => i.kind === "link" && i.rel.toLowerCase() === "alternate" && !!i.hrefLang
13
+ (a) => a.kind === "link" && a.rel.toLowerCase() === "alternate" && !!a.hrefLang
13
14
  ), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
14
- for (const i of [...t.alternates, ...n]) {
15
- const c = i.hrefLang.toLowerCase(), u = Ae(i.href, r), l = o.get(c), d = s.get(u);
15
+ for (const a of [...t.alternates, ...n]) {
16
+ const c = a.hrefLang.toLowerCase(), u = ke(a.href, r), l = o.get(c), d = s.get(u);
16
17
  if (l && l !== u)
17
- throw new Error(`Localized metadata language ${JSON.stringify(i.hrefLang)} has conflicting URLs.`);
18
+ throw new Error(`Localized metadata language ${JSON.stringify(a.hrefLang)} has conflicting URLs.`);
18
19
  if (d && d !== c && d !== "x-default" && c !== "x-default")
19
- throw new Error(`Localized metadata URL ${JSON.stringify(i.href)} has conflicting languages.`);
20
+ throw new Error(`Localized metadata URL ${JSON.stringify(a.href)} has conflicting languages.`);
20
21
  o.set(c, u), s.set(u, c);
21
22
  }
22
- const a = e.custom.filter(
23
- (i) => !(i.kind === "link" && i.rel.toLowerCase() === "alternate" && i.hrefLang)
23
+ const i = e.custom.filter(
24
+ (a) => !(a.kind === "link" && a.rel.toLowerCase() === "alternate" && a.hrefLang)
24
25
  );
25
26
  return {
26
27
  ...e,
27
28
  canonical: r,
28
29
  custom: [
29
- ...a,
30
- ...[...o].map(([i, c]) => Br({ href: c, hrefLang: i, rel: "alternate" }))
30
+ ...i,
31
+ ...[...o].map(([a, c]) => Br({ href: c, hrefLang: a, rel: "alternate" }))
31
32
  ]
32
33
  };
33
34
  }
34
- function Ae(e, t) {
35
+ function ke(e, t) {
35
36
  try {
36
37
  return new URL(e, t).href;
37
38
  } catch {
38
39
  throw new Error(`Localized metadata URL must be an absolute or root-relative URL: ${JSON.stringify(e)}.`);
39
40
  }
40
41
  }
41
- function mi(e) {
42
+ function pi(e) {
42
43
  return e;
43
44
  }
44
- function pi(e) {
45
+ function gi(e) {
45
46
  return {
46
47
  ...e,
47
48
  kind: "meta"
@@ -53,7 +54,7 @@ function Br(e) {
53
54
  kind: "link"
54
55
  };
55
56
  }
56
- function gi(e) {
57
+ function wi(e) {
57
58
  return {
58
59
  kind: "structured-data",
59
60
  value: e
@@ -108,12 +109,12 @@ function Gr(e, t, r) {
108
109
  ...e ?? {}
109
110
  };
110
111
  }
111
- const mt = ["build", "private", "public"], Jr = {
112
+ const pt = ["build", "private", "public"], Jr = {
112
113
  app: "demiurge-memory",
113
114
  environment: "local",
114
115
  schemaVersion: 1
115
116
  }, Kr = 1e4, Yr = 3e4;
116
- function wi(e) {
117
+ function yi(e) {
117
118
  return (...t) => ({
118
119
  fn: () => e.fn(...t),
119
120
  key: e.key(...t),
@@ -130,30 +131,30 @@ class I extends Error {
130
131
  super(t ?? "Not found"), this.name = "CacheNotFoundError";
131
132
  }
132
133
  }
133
- function yi(e) {
134
+ function vi(e) {
134
135
  throw new I(e);
135
136
  }
136
- function vi(e) {
137
+ function Si(e) {
137
138
  return e instanceof I;
138
139
  }
139
- function Si(e) {
140
+ function bi(e) {
140
141
  return { id: e };
141
142
  }
142
- function bi(e) {
143
+ function Ei(e) {
143
144
  return e;
144
145
  }
145
146
  function qt(e) {
146
147
  const t = e.now ?? Date.now, r = en(e.refreshLeaseTtl), n = _t(e.namespace), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
147
148
  return {
148
- async get(a) {
149
- const i = a.scope ?? "request";
150
- if (i === "none")
151
- return await a.fn();
152
- const c = gt(a.key);
153
- if (i === "request")
154
- return await Xr(o, c, a, t);
155
- const u = wt(n, i, c), l = (a.tags ?? []).map(
156
- (g) => yt(n, i, ze(g))
149
+ async get(i) {
150
+ const a = i.scope ?? "request";
151
+ if (a === "none")
152
+ return await i.fn();
153
+ const c = wt(i.key);
154
+ if (a === "request")
155
+ return await Xr(o, c, i, t);
156
+ const u = yt(n, a, c), l = (i.tags ?? []).map(
157
+ (g) => vt(n, a, Fe(g))
157
158
  ), d = await e.store.get(u);
158
159
  if (d && (d.expiresAt === null || d.expiresAt > t())) {
159
160
  if (d.negative)
@@ -174,7 +175,7 @@ function qt(e) {
174
175
  now: t,
175
176
  onBackgroundError: e.onBackgroundError,
176
177
  refreshStore: g,
177
- request: a,
178
+ request: i,
178
179
  tags: l,
179
180
  token: O
180
181
  });
@@ -186,19 +187,19 @@ function qt(e) {
186
187
  const h = s.get(u);
187
188
  if (h)
188
189
  return await h.promise;
189
- const f = { invalidated: !1 }, m = Promise.resolve().then(a.fn).then(
190
+ const f = { invalidated: !1 }, m = Promise.resolve().then(i.fn).then(
190
191
  async (g) => (f.invalidated || await e.store.set(u, {
191
- expiresAt: Ye(t(), a.ttl),
192
- staleUntil: Ze(
192
+ expiresAt: Ze(t(), i.ttl),
193
+ staleUntil: Qe(
193
194
  t(),
194
- a.ttl,
195
- a.staleWhileRevalidate
195
+ i.ttl,
196
+ i.staleWhileRevalidate
196
197
  ),
197
198
  tags: l,
198
199
  value: g
199
200
  }), g),
200
201
  async (g) => {
201
- throw !f.invalidated && g instanceof I && await e.store.set(u, Gt(t(), a, l, g)), g;
202
+ throw !f.invalidated && g instanceof I && await e.store.set(u, Gt(t(), i, l, g)), g;
202
203
  }
203
204
  ), w = {
204
205
  promise: m,
@@ -212,24 +213,24 @@ function qt(e) {
212
213
  s.get(u) === w && s.delete(u);
213
214
  }
214
215
  },
215
- async invalidateKey(a) {
216
- const i = gt(a), c = o.delete(i);
216
+ async invalidateKey(i) {
217
+ const a = wt(i), c = o.delete(a);
217
218
  let u = !1;
218
219
  const l = await Promise.all(
219
- mt.map((d) => {
220
- const h = wt(n, d, i), f = s.get(h);
220
+ pt.map((d) => {
221
+ const h = yt(n, d, a), f = s.get(h);
221
222
  return f && (f.state.invalidated = !0, u = !0), e.store.delete(h);
222
223
  })
223
224
  );
224
225
  return c || u || l.some(Boolean);
225
226
  },
226
- async invalidateTags(a) {
227
- const i = a.map(ze), c = on(
227
+ async invalidateTags(i) {
228
+ const a = i.map(Fe), c = on(
228
229
  o,
229
- new Set(i)
230
+ new Set(a)
230
231
  ), u = new Set(
231
- mt.flatMap(
232
- (h) => i.map((f) => yt(n, h, f))
232
+ pt.flatMap(
233
+ (h) => a.map((f) => vt(n, h, f))
233
234
  )
234
235
  );
235
236
  let l = 0;
@@ -240,7 +241,7 @@ function qt(e) {
240
241
  }
241
242
  };
242
243
  }
243
- function Ke(e = {}) {
244
+ function Ye(e = {}) {
244
245
  const t = e.now ?? Date.now;
245
246
  return qt({
246
247
  namespace: Jr,
@@ -260,56 +261,57 @@ function Zr(e = {}) {
260
261
  throw new Error(
261
262
  "Demiurge memory cache maximumEntries must be a positive integer."
262
263
  );
263
- ke(t, r, o()), Qr(t, n);
264
- let s = Le(t);
264
+ Le(t, r, o()), Qr(t, n);
265
+ let s = Ce(t);
265
266
  return {
266
- acquireRefreshLease(a, i, c) {
267
- const u = o(), l = r.get(a);
268
- return l && l.expiresAt > u ? !1 : (r.set(a, { expiresAt: c, token: i }), !0);
267
+ capabilities: { atomicity: "strong" },
268
+ acquireRefreshLease(i, a, c) {
269
+ const u = o(), l = r.get(i);
270
+ return l && l.expiresAt > u ? !1 : (r.set(i, { expiresAt: c, token: a }), !0);
269
271
  },
270
- delete(a) {
271
- return r.delete(a), t.delete(a);
272
+ delete(i) {
273
+ return r.delete(i), t.delete(i);
272
274
  },
273
- get(a) {
274
- return o() >= s && (ke(t, r, o()), s = Le(t)), t.get(a);
275
+ get(i) {
276
+ return o() >= s && (Le(t, r, o()), s = Ce(t)), t.get(i);
275
277
  },
276
- invalidateTags(a) {
277
- const i = new Set(a);
278
+ invalidateTags(i) {
279
+ const a = new Set(i);
278
280
  let c = 0;
279
281
  for (const [u, l] of t)
280
- l.tags.some((d) => i.has(d)) && (t.delete(u), r.delete(u), c += 1);
282
+ l.tags.some((d) => a.has(d)) && (t.delete(u), r.delete(u), c += 1);
281
283
  return c;
282
284
  },
283
- publishRefresh(a, i, c) {
284
- const u = r.get(a);
285
- return !u || u.token !== i || u.expiresAt <= o() ? !1 : (pt(
285
+ publishRefresh(i, a, c) {
286
+ const u = r.get(i);
287
+ return !u || u.token !== a || u.expiresAt <= o() ? !1 : (gt(
286
288
  t,
287
289
  r,
288
290
  n,
289
- a,
291
+ i,
290
292
  c
291
- ), r.delete(a), c.staleUntil !== null && (s = Math.min(s, c.staleUntil)), !0);
293
+ ), r.delete(i), c.staleUntil !== null && (s = Math.min(s, c.staleUntil)), !0);
292
294
  },
293
- releaseRefreshLease(a, i) {
294
- r.get(a)?.token === i && r.delete(a);
295
+ releaseRefreshLease(i, a) {
296
+ r.get(i)?.token === a && r.delete(i);
295
297
  },
296
- set(a, i) {
298
+ set(i, a) {
297
299
  const c = o();
298
- c >= s && (ke(t, r, c), s = Le(t)), r.delete(a), pt(
300
+ c >= s && (Le(t, r, c), s = Ce(t)), r.delete(i), gt(
299
301
  t,
300
302
  r,
301
303
  n,
302
- a,
303
- i
304
- ), i.staleUntil !== null && (s = Math.min(s, i.staleUntil));
304
+ i,
305
+ a
306
+ ), a.staleUntil !== null && (s = Math.min(s, a.staleUntil));
305
307
  }
306
308
  };
307
309
  }
308
- function ke(e, t, r) {
310
+ function Le(e, t, r) {
309
311
  for (const [n, o] of e)
310
312
  o.staleUntil !== null && o.staleUntil <= r && (e.delete(n), t.delete(n));
311
313
  }
312
- function pt(e, t, r, n, o) {
314
+ function gt(e, t, r, n, o) {
313
315
  if (!e.has(n) && e.size >= r)
314
316
  for (; e.size >= r; ) {
315
317
  const s = e.keys().next().value;
@@ -327,14 +329,14 @@ function Qr(e, t) {
327
329
  e.delete(r);
328
330
  }
329
331
  }
330
- function Le(e) {
332
+ function Ce(e) {
331
333
  let t = Number.POSITIVE_INFINITY;
332
334
  for (const r of e.values())
333
335
  r.staleUntil !== null && (t = Math.min(t, r.staleUntil));
334
336
  return t;
335
337
  }
336
338
  function _t(e) {
337
- const t = Ce("app", e.app), r = Ce(
339
+ const t = Pe("app", e.app), r = Pe(
338
340
  "environment",
339
341
  e.environment
340
342
  );
@@ -342,13 +344,13 @@ function _t(e) {
342
344
  throw new Error(
343
345
  "Demiurge cache namespace schemaVersion must be a non-negative integer or string."
344
346
  );
345
- const n = Ce(
347
+ const n = Pe(
346
348
  "schemaVersion",
347
349
  String(e.schemaVersion)
348
350
  );
349
351
  return `${t}:${r}:${n}`;
350
352
  }
351
- function Ei(e) {
353
+ function Ri(e) {
352
354
  return {
353
355
  async key(t) {
354
356
  return {
@@ -393,51 +395,51 @@ function z(e) {
393
395
  const r = Number(t[1]), n = t[2];
394
396
  return n === "h" ? r * 36e5 : n === "m" ? r * 6e4 : n === "s" ? r * 1e3 : r;
395
397
  }
396
- function gt(e) {
397
- return He(e, /* @__PURE__ */ new Set());
398
+ function wt(e) {
399
+ return We(e, /* @__PURE__ */ new Set());
398
400
  }
399
- function ze(e) {
401
+ function Fe(e) {
400
402
  return e.id;
401
403
  }
402
404
  async function Xr(e, t, r, n) {
403
405
  const o = e.get(t);
404
406
  if (o && o.expiresAt > n())
405
407
  return await o.value;
406
- const s = Promise.resolve().then(r.fn), a = {
408
+ const s = Promise.resolve().then(r.fn), i = {
407
409
  expiresAt: n() + z(r.ttl),
408
- tags: (r.tags ?? []).map(ze),
410
+ tags: (r.tags ?? []).map(Fe),
409
411
  value: s
410
412
  };
411
- e.set(t, a);
413
+ e.set(t, i);
412
414
  try {
413
415
  return await s;
414
- } catch (i) {
415
- throw e.get(t) === a && (i instanceof I ? a.expiresAt = n() + z(r.notFoundTtl ?? r.ttl) : e.delete(t)), i;
416
+ } catch (a) {
417
+ throw e.get(t) === i && (a instanceof I ? i.expiresAt = n() + z(r.notFoundTtl ?? r.ttl) : e.delete(t)), a;
416
418
  }
417
419
  }
418
- function wt(e, t, r) {
420
+ function yt(e, t, r) {
419
421
  return `${e}:${t}:key:${r}`;
420
422
  }
421
- function yt(e, t, r) {
423
+ function vt(e, t, r) {
422
424
  return `${e}:${t}:tag:${r}`;
423
425
  }
424
- function Ye(e, t) {
426
+ function Ze(e, t) {
425
427
  const r = z(t);
426
428
  return Number.isFinite(r) ? e + r : null;
427
429
  }
428
430
  function Gt(e, t, r, n) {
429
431
  const o = t.notFoundTtl ?? t.ttl;
430
432
  return {
431
- expiresAt: Ye(e, o),
433
+ expiresAt: Ze(e, o),
432
434
  negative: !0,
433
435
  // Negative entries do not participate in stale-while-revalidate: they
434
436
  // expire outright and recompute on the next request.
435
- staleUntil: Ze(e, o, void 0),
437
+ staleUntil: Qe(e, o, void 0),
436
438
  tags: r,
437
439
  value: n.message
438
440
  };
439
441
  }
440
- function Ze(e, t, r) {
442
+ function Qe(e, t, r) {
441
443
  const n = z(t);
442
444
  if (!Number.isFinite(n)) {
443
445
  if (r !== void 0)
@@ -470,8 +472,8 @@ async function nn(e) {
470
472
  try {
471
473
  const t = await e.request.fn(), r = e.now();
472
474
  await e.refreshStore.publishRefresh(e.key, e.token, {
473
- expiresAt: Ye(r, e.request.ttl),
474
- staleUntil: Ze(
475
+ expiresAt: Ze(r, e.request.ttl),
476
+ staleUntil: Qe(
475
477
  r,
476
478
  e.request.ttl,
477
479
  e.request.staleWhileRevalidate
@@ -493,7 +495,7 @@ async function nn(e) {
493
495
  await e.refreshStore.releaseRefreshLease(e.key, e.token);
494
496
  }
495
497
  }
496
- function Ce(e, t) {
498
+ function Pe(e, t) {
497
499
  const r = [...t].some((n) => {
498
500
  const o = n.charCodeAt(0);
499
501
  return o <= 31 || o === 127;
@@ -510,7 +512,7 @@ function on(e, t) {
510
512
  o.tags.some((s) => t.has(s)) && (e.delete(n), r += 1);
511
513
  return r;
512
514
  }
513
- function He(e, t) {
515
+ function We(e, t) {
514
516
  if (e === null || typeof e == "boolean" || typeof e == "string")
515
517
  return JSON.stringify(e);
516
518
  if (typeof e == "number") {
@@ -527,18 +529,18 @@ function He(e, t) {
527
529
  if (t.has(e))
528
530
  throw new Error("Demiurge cache keys cannot contain circular references.");
529
531
  if (t.add(e), Array.isArray(e)) {
530
- const a = Reflect.ownKeys(e), i = [
532
+ const i = Reflect.ownKeys(e), a = [
531
533
  ...Array.from({ length: e.length }, (u, l) => String(l)),
532
534
  "length"
533
535
  ];
534
- if (a.length !== i.length || a.some((u, l) => u !== i[l]) || i.slice(0, -1).some((u) => {
536
+ if (i.length !== a.length || i.some((u, l) => u !== a[l]) || a.slice(0, -1).some((u) => {
535
537
  const l = Object.getOwnPropertyDescriptor(e, u);
536
538
  return !l?.enumerable || !("value" in l);
537
539
  }))
538
540
  throw t.delete(e), new Error(
539
541
  "Demiurge cache key arrays must be dense and cannot contain accessors or custom properties."
540
542
  );
541
- const c = `[${e.map((u) => He(u, t)).join(",")}]`;
543
+ const c = `[${e.map((u) => We(u, t)).join(",")}]`;
542
544
  return t.delete(e), c;
543
545
  }
544
546
  const r = Object.getPrototypeOf(e);
@@ -547,15 +549,15 @@ function He(e, t) {
547
549
  "Demiurge cache keys accept only primitives, arrays, and plain objects."
548
550
  );
549
551
  const n = Reflect.ownKeys(e);
550
- if (n.some((a) => typeof a == "symbol") || n.some((a) => {
551
- const i = Object.getOwnPropertyDescriptor(e, a);
552
- return !i?.enumerable || !("value" in i);
552
+ if (n.some((i) => typeof i == "symbol") || n.some((i) => {
553
+ const a = Object.getOwnPropertyDescriptor(e, i);
554
+ return !a?.enumerable || !("value" in a);
553
555
  }))
554
556
  throw new Error(
555
557
  "Demiurge cache key objects require enumerable string data properties."
556
558
  );
557
559
  const o = e, s = `{${Object.keys(o).sort().map(
558
- (a) => `${JSON.stringify(a)}:${He(o[a], t)}`
560
+ (i) => `${JSON.stringify(i)}:${We(o[i], t)}`
559
561
  ).join(",")}}`;
560
562
  return t.delete(e), s;
561
563
  }
@@ -566,36 +568,49 @@ class Jt extends Error {
566
568
  super(t), this.name = "RouteSerializationError", this.route = r, this.field = n;
567
569
  }
568
570
  }
569
- function Fe(e, t, r = [], n = /* @__PURE__ */ new Set()) {
571
+ function fe(e, t, r = [], n = /* @__PURE__ */ new Set(), o = !0) {
570
572
  if (e === null) return;
571
- const o = typeof e;
572
- if (o === "bigint")
573
- throw vt(t, r, "a bigint value");
574
- if (o !== "object") return;
575
- const s = e;
576
- if (n.has(s))
577
- throw vt(t, r, "a circular reference");
578
- if (n.add(s), Array.isArray(s)) {
579
- for (let a = 0; a < s.length; a += 1)
580
- Fe(
581
- s[a],
573
+ const s = typeof e;
574
+ if (s === "bigint")
575
+ throw De(t, r, "a bigint value");
576
+ if (s !== "object") return;
577
+ const i = e;
578
+ if (o) {
579
+ let a = i;
580
+ try {
581
+ const c = i.toJSON;
582
+ typeof c == "function" && (a = c.call(i, r.at(-1) ?? ""));
583
+ } catch {
584
+ throw De(t, r, "a failing toJSON result");
585
+ }
586
+ if (a !== i) {
587
+ fe(a, t, r, n, !1);
588
+ return;
589
+ }
590
+ }
591
+ if (n.has(i))
592
+ throw De(t, r, "a circular reference");
593
+ if (n.add(i), Array.isArray(i)) {
594
+ for (let a = 0; a < i.length; a += 1)
595
+ fe(
596
+ i[a],
582
597
  t,
583
598
  [...r, String(a)],
584
599
  n
585
600
  );
586
- n.delete(s);
601
+ n.delete(i);
587
602
  return;
588
603
  }
589
- for (const a of Object.keys(s))
590
- Fe(
591
- s[a],
604
+ for (const a of Object.keys(i))
605
+ fe(
606
+ i[a],
592
607
  t,
593
608
  [...r, a],
594
609
  n
595
610
  );
596
- n.delete(s);
611
+ n.delete(i);
597
612
  }
598
- function vt(e, t, r) {
613
+ function De(e, t, r) {
599
614
  const n = t.length === 0 ? "<root>" : t.join(".");
600
615
  return new Jt(
601
616
  `Route ${e} could not serialize the field ${n} for the browser. The value contains ${r}.`,
@@ -697,7 +712,7 @@ function sn(e) {
697
712
  const t = /* @__PURE__ */ new Map();
698
713
  for (const r of e) {
699
714
  const n = r.segments.findIndex(
700
- (a) => a.startsWith("*")
715
+ (i) => i.startsWith("*")
701
716
  );
702
717
  if (n !== -1 && n !== r.segments.length - 1)
703
718
  throw new Error(
@@ -729,27 +744,27 @@ function un(e, t) {
729
744
  function St(e) {
730
745
  return e === void 0 ? 4 : e.startsWith("*") ? 1 : e.startsWith(":") ? 2 : 3;
731
746
  }
732
- async function Yt(e, t, r = new Request(`http://demiurge.local${t}`), n, o = Ke(), s = {}) {
733
- const a = s.documentContributions ?? !0, i = V(e.routes, t);
734
- if (!i)
747
+ async function Yt(e, t, r = new Request(`http://demiurge.local${t}`), n, o = Ye(), s = {}) {
748
+ const i = s.documentContributions ?? !0, a = V(e.routes, t);
749
+ if (!a)
735
750
  return {
736
- ...await We(e, t, {
737
- documentContributions: a,
751
+ ...await Be(e, t, {
752
+ documentContributions: i,
738
753
  locale: s.locale
739
754
  }),
740
755
  status: "not-found"
741
756
  };
742
757
  const c = e.layouts.filter(
743
- (m) => C(m.fileSegments, i.route.fileSegments)
744
- ), u = await i.route.load();
758
+ (m) => C(m.fileSegments, a.route.fileSegments)
759
+ ), u = await a.route.load();
745
760
  if (!u.GET || u.GET.kind !== "page")
746
761
  return {
747
- ...await We(e, t, {
748
- fallback: Qe(
762
+ ...await Be(e, t, {
763
+ fallback: Xe(
749
764
  e.fallbacks.notFound,
750
- i.route
765
+ a.route
751
766
  ),
752
- documentContributions: a,
767
+ documentContributions: i,
753
768
  layouts: c,
754
769
  locale: s.locale
755
770
  }),
@@ -759,19 +774,19 @@ async function Yt(e, t, r = new Request(`http://demiurge.local${t}`), n, o = Ke(
759
774
  cache: o,
760
775
  context: s.requestContext ?? {},
761
776
  locale: s.locale,
762
- path: i.path,
777
+ path: a.path,
763
778
  pathname: t,
764
779
  request: r,
765
780
  search: d.searchParams,
766
781
  url: d
767
782
  };
768
783
  let f;
769
- return u.GET.data && !n?.hasData ? (f = await u.GET.data(h), Fe(f, Xt(i.route.segments))) : f = n?.data, {
784
+ return u.GET.data && !n?.hasData ? (f = await u.GET.data(h), fe(f, Xt(a.route.segments))) : f = n?.data, {
770
785
  status: "ready",
771
786
  match: {
772
787
  data: f,
773
- error: await Zt(e, i.route),
774
- links: a ? await Mr(
788
+ error: await Zt(e, a.route),
789
+ links: i ? await Nr(
775
790
  [
776
791
  ...l.map((m) => m.links),
777
792
  u.links
@@ -783,14 +798,14 @@ async function Yt(e, t, r = new Request(`http://demiurge.local${t}`), n, o = Ke(
783
798
  (m) => m.default
784
799
  ),
785
800
  locale: s.locale,
786
- metadata: a ? T(...await Promise.all([
801
+ metadata: i ? T(...await Promise.all([
787
802
  ...l.map((m) => M(m, h)),
788
803
  M(u, h)
789
804
  ])) : T(),
790
- path: i.path,
805
+ path: a.path,
791
806
  pathname: t,
792
807
  render: u.GET.render,
793
- scripts: a ? await Nr(
808
+ scripts: i ? await Mr(
794
809
  [
795
810
  ...l.map((m) => m.scripts),
796
811
  u.scripts
@@ -800,8 +815,8 @@ async function Yt(e, t, r = new Request(`http://demiurge.local${t}`), n, o = Ke(
800
815
  }
801
816
  };
802
817
  }
803
- async function Ri(e, t = {}) {
804
- const r = Ke(), n = [];
818
+ async function Ti(e, t = {}) {
819
+ const r = Ye(), n = [];
805
820
  for (const o of e.routes) {
806
821
  const s = await o.load();
807
822
  if (!s.GET || s.GET.kind !== "page" && !t.includeResources || s.GET.kind === "page" && t.includePages === !1)
@@ -810,41 +825,41 @@ async function Ri(e, t = {}) {
810
825
  throw new Error(
811
826
  `Page route "${o.file}" uses render mode "${s.GET.render.mode}" and cannot be emitted as static output. Set render: { mode: "static" } or deploy a runtime adapter.`
812
827
  );
813
- const a = Xt(o.segments);
828
+ const i = Xt(o.segments);
814
829
  if (wn(o.segments).length === 0) {
815
830
  n.push({
816
831
  file: o.file,
817
832
  path: {},
818
- pattern: a,
819
- pathname: a
833
+ pattern: i,
834
+ pathname: i
820
835
  });
821
836
  continue;
822
837
  }
823
838
  if (!s.paths)
824
839
  throw new Error(
825
- `Dynamic static route "${o.file}" must export paths for "${a}".`
840
+ `Dynamic static route "${o.file}" must export paths for "${i}".`
826
841
  );
827
842
  const c = await s.paths({
828
843
  cache: r,
829
844
  locale: t.locale
830
845
  });
831
846
  for (const u of c) {
832
- const l = yn(o, a, u);
847
+ const l = yn(o, i, u);
833
848
  n.push({
834
849
  file: o.file,
835
850
  path: l,
836
- pattern: a,
851
+ pattern: i,
837
852
  pathname: Sn(o.segments, l)
838
853
  });
839
854
  }
840
855
  }
841
856
  return n;
842
857
  }
843
- async function Ti(e, t) {
858
+ async function $i(e, t) {
844
859
  const r = V(e.routes, t);
845
860
  if (r)
846
861
  return await mn(
847
- Qe(e.fallbacks.loading, r.route)
862
+ Xe(e.fallbacks.loading, r.route)
848
863
  );
849
864
  }
850
865
  async function ln(e, t) {
@@ -852,8 +867,8 @@ async function ln(e, t) {
852
867
  try {
853
868
  r = V(e.routes, t);
854
869
  } catch (n) {
855
- if (!(n instanceof tt)) throw n;
856
- return await et(
870
+ if (!(n instanceof rt)) throw n;
871
+ return await tt(
857
872
  e.fallbacks.error.find(
858
873
  (o) => o.fileSegments.length === 0
859
874
  )
@@ -862,22 +877,22 @@ async function ln(e, t) {
862
877
  return r ? await Zt(e, r.route) : await dn(e, t);
863
878
  }
864
879
  async function Zt(e, t) {
865
- return await et(
866
- Qe(e.fallbacks.error, t)
880
+ return await tt(
881
+ Xe(e.fallbacks.error, t)
867
882
  );
868
883
  }
869
884
  async function dn(e, t) {
870
- return await et(
885
+ return await tt(
871
886
  Qt(e.fallbacks.error, t)
872
887
  );
873
888
  }
874
- async function We(e, t, r = {}) {
875
- const o = await (r.fallback ?? Qt(e.fallbacks.notFound, t))?.load(), s = o?.default, a = r.documentContributions ?? !0, i = { locale: r.locale, path: {}, pathname: t };
889
+ async function Be(e, t, r = {}) {
890
+ const o = await (r.fallback ?? Qt(e.fallbacks.notFound, t))?.load(), s = o?.default, i = r.documentContributions ?? !0, a = { locale: r.locale, path: {}, pathname: t };
876
891
  if (o?.layout === !1)
877
892
  return {
878
893
  layouts: [],
879
894
  locale: r.locale,
880
- metadata: a ? T(await M(o, i)) : T(),
895
+ metadata: i ? T(await M(o, a)) : T(),
881
896
  notFound: s,
882
897
  pathname: t
883
898
  };
@@ -891,9 +906,9 @@ async function We(e, t, r = {}) {
891
906
  (l) => l.default
892
907
  ),
893
908
  locale: r.locale,
894
- metadata: a ? T(...await Promise.all([
895
- ...u.map((l) => M(l, i)),
896
- M(o, i)
909
+ metadata: i ? T(...await Promise.all([
910
+ ...u.map((l) => M(l, a)),
911
+ M(o, a)
897
912
  ])) : T(),
898
913
  notFound: s,
899
914
  pathname: t
@@ -902,7 +917,7 @@ async function We(e, t, r = {}) {
902
917
  return r.onLayoutError?.(u), {
903
918
  layouts: [],
904
919
  locale: r.locale,
905
- metadata: a ? T(await M(o, i)) : T(),
920
+ metadata: i ? T(await M(o, a)) : T(),
906
921
  notFound: s,
907
922
  pathname: t
908
923
  };
@@ -912,18 +927,18 @@ async function M(e, t) {
912
927
  return typeof e?.metadata == "function" ? await e.metadata(t) : e?.metadata;
913
928
  }
914
929
  function fn(e, t) {
915
- const r = Te(t);
930
+ const r = $e(t);
916
931
  return e.layouts.filter(
917
- (n) => !n.fileSegments.some(Re) && Xe(n.segments, r)
932
+ (n) => !n.fileSegments.some(Te) && et(n.segments, r)
918
933
  );
919
934
  }
920
935
  function hn(e, t) {
921
- const r = Te(t);
936
+ const r = $e(t);
922
937
  return e.policies.filter(
923
- (n) => !n.fileSegments.some(Re) && Xe(n.segments, r)
938
+ (n) => !n.fileSegments.some(Te) && et(n.segments, r)
924
939
  );
925
940
  }
926
- function Qe(e, t) {
941
+ function Xe(e, t) {
927
942
  for (let r = e.length - 1; r >= 0; r -= 1) {
928
943
  const n = e[r];
929
944
  if (C(n.fileSegments, t.fileSegments))
@@ -931,24 +946,24 @@ function Qe(e, t) {
931
946
  }
932
947
  }
933
948
  function Qt(e, t) {
934
- const r = Te(t);
949
+ const r = $e(t);
935
950
  for (let n = e.length - 1; n >= 0; n -= 1) {
936
951
  const o = e[n];
937
- if (!o.fileSegments.some(Re) && Xe(o.segments, r))
952
+ if (!o.fileSegments.some(Te) && et(o.segments, r))
938
953
  return o;
939
954
  }
940
955
  }
941
- function Xe(e, t) {
956
+ function et(e, t) {
942
957
  return e.every((r, n) => r.startsWith("*") ? t.length > n : r.startsWith(":") ? !!t[n] : t[n] === r);
943
958
  }
944
959
  async function mn(e) {
945
960
  return e ? (await e.load()).default : void 0;
946
961
  }
947
- async function et(e) {
962
+ async function tt(e) {
948
963
  return e ? (await e.load()).default : void 0;
949
964
  }
950
965
  function V(e, t) {
951
- const r = Te(t);
966
+ const r = $e(t);
952
967
  for (const n of e) {
953
968
  const o = pn(n.segments, r);
954
969
  if (o)
@@ -956,7 +971,7 @@ function V(e, t) {
956
971
  }
957
972
  return null;
958
973
  }
959
- const $i = Yt, xi = V;
974
+ const xi = Yt, Ai = V;
960
975
  function pn(e, t) {
961
976
  const r = {};
962
977
  for (let n = 0; n < e.length; n += 1) {
@@ -974,7 +989,7 @@ function pn(e, t) {
974
989
  }
975
990
  return e.length === t.length ? r : null;
976
991
  }
977
- function Ai(e, t) {
992
+ function ki(e, t) {
978
993
  return e.every(
979
994
  (r, n) => t[n] === r
980
995
  );
@@ -985,9 +1000,9 @@ function C(e, t) {
985
1000
  );
986
1001
  }
987
1002
  function x(e) {
988
- return e.flatMap((t) => Re(t) ? [] : t === "index" ? [] : t.startsWith("[...") && t.endsWith("]") ? [`*${t.slice(4, -1)}`] : t.startsWith("[") && t.endsWith("]") ? [`:${t.slice(1, -1)}`] : [t]);
1003
+ return e.flatMap((t) => Te(t) ? [] : t === "index" ? [] : t.startsWith("[...") && t.endsWith("]") ? [`*${t.slice(4, -1)}`] : t.startsWith("[") && t.endsWith("]") ? [`:${t.slice(1, -1)}`] : [t]);
989
1004
  }
990
- function Re(e) {
1005
+ function Te(e) {
991
1006
  return e.startsWith("(") && e.endsWith(")");
992
1007
  }
993
1008
  function Xt(e) {
@@ -1004,16 +1019,16 @@ function yn(e, t, r) {
1004
1019
  for (const o of e.segments) {
1005
1020
  if (!o.startsWith(":") && !o.startsWith("*"))
1006
1021
  continue;
1007
- const s = o.slice(1), a = r[s];
1008
- if (a === void 0)
1022
+ const s = o.slice(1), i = r[s];
1023
+ if (i === void 0)
1009
1024
  throw new Error(
1010
1025
  `Static paths for "${e.file}" must include "${s}" for "${t}".`
1011
1026
  );
1012
- if (!vn(a))
1027
+ if (!vn(i))
1013
1028
  throw new Error(
1014
1029
  `Static path "${s}" for "${e.file}" must be a string, number, or boolean.`
1015
1030
  );
1016
- n[s] = String(a);
1031
+ n[s] = String(i);
1017
1032
  }
1018
1033
  return n;
1019
1034
  }
@@ -1026,16 +1041,16 @@ function Sn(e, t) {
1026
1041
  function bn(e) {
1027
1042
  return x(e).reduce((t, r) => r.startsWith("*") ? t : r.startsWith(":") ? t + 1 : t + 2, 0);
1028
1043
  }
1029
- function Te(e) {
1044
+ function $e(e) {
1030
1045
  return e.replace(/^\/|\/$/g, "").split("/").filter(Boolean).map((t) => {
1031
1046
  try {
1032
1047
  return decodeURIComponent(t);
1033
1048
  } catch (r) {
1034
- throw new tt(e, { cause: r });
1049
+ throw new rt(e, { cause: r });
1035
1050
  }
1036
1051
  });
1037
1052
  }
1038
- class tt extends URIError {
1053
+ class rt extends URIError {
1039
1054
  pathname;
1040
1055
  constructor(t, r) {
1041
1056
  super(
@@ -1044,11 +1059,11 @@ class tt extends URIError {
1044
1059
  ), this.name = "MalformedPathnameError", this.pathname = t;
1045
1060
  }
1046
1061
  }
1047
- const H = "x-demiurge-navigation", En = "data", Rn = "data", fe = "error", Be = "not-found";
1062
+ const H = "x-demiurge-navigation", En = "data", Rn = "data", he = "error", Ve = "not-found";
1048
1063
  function F(e) {
1049
1064
  return e.headers.get(H) === En;
1050
1065
  }
1051
- function rt(e, t = {}) {
1066
+ function nt(e, t = {}) {
1052
1067
  const r = new Headers(t.headers);
1053
1068
  return r.set("cache-control", "no-store"), r.set(
1054
1069
  H,
@@ -1073,7 +1088,7 @@ function ce(e, t) {
1073
1088
  function oe(e) {
1074
1089
  return typeof e == "object" && e !== null && !Array.isArray(e);
1075
1090
  }
1076
- function ki(e) {
1091
+ function Li(e) {
1077
1092
  return typeof e == "object" && e !== null;
1078
1093
  }
1079
1094
  function Tn(e) {
@@ -1117,53 +1132,53 @@ function kn(e, t) {
1117
1132
  const s = t[o];
1118
1133
  if (s === void 0)
1119
1134
  throw new Error(`Missing path value for "${o}" in route "${e}".`);
1120
- return n ? String(s).split("/").filter(Boolean).map((a) => encodeURIComponent(a)).join("/") : encodeURIComponent(String(s));
1135
+ return n ? String(s).split("/").filter(Boolean).map((i) => encodeURIComponent(i)).join("/") : encodeURIComponent(String(s));
1121
1136
  }
1122
1137
  ) : e;
1123
1138
  }
1124
1139
  function Ln(e) {
1125
1140
  rr(e);
1126
1141
  const t = new Map(
1127
- e.supportedLocales.map((i) => [i, A(i)])
1128
- ), r = (i) => {
1129
- const c = e.supportedLocales.find((u) => u === i);
1130
- if (!c) throw new Error(`The locale target "${i}" must be supported.`);
1142
+ e.supportedLocales.map((a) => [a, A(a)])
1143
+ ), r = (a) => {
1144
+ const c = e.supportedLocales.find((u) => u === a);
1145
+ if (!c) throw new Error(`The locale target "${a}" must be supported.`);
1131
1146
  return t.get(c) ?? c;
1132
1147
  }, o = e.path && Object.fromEntries(
1133
- e.supportedLocales.map((i) => [
1134
- A(i),
1135
- e.path?.labels[i].toLowerCase()
1148
+ e.supportedLocales.map((a) => [
1149
+ A(a),
1150
+ e.path?.labels[a].toLowerCase()
1136
1151
  ])
1137
- ), a = e.domains && Object.fromEntries(
1138
- e.supportedLocales.flatMap((i) => {
1139
- const c = e.domains?.[i];
1140
- return c ? [[A(i), nr(c)]] : [];
1152
+ ), i = e.domains && Object.fromEntries(
1153
+ e.supportedLocales.flatMap((a) => {
1154
+ const c = e.domains?.[a];
1155
+ return c ? [[A(a), nr(c)]] : [];
1141
1156
  })
1142
1157
  );
1143
1158
  return {
1144
1159
  ...e,
1145
1160
  aliases: e.aliases && Object.fromEntries(
1146
- Object.entries(e.aliases).map(([i, c]) => [i.toLowerCase(), r(String(c))])
1161
+ Object.entries(e.aliases).map(([a, c]) => [a.toLowerCase(), r(String(c))])
1147
1162
  ),
1148
1163
  defaultLocale: r(e.defaultLocale),
1149
1164
  // TYPE-EVIDENCE: validation restricts each direction key to a supported TLocale value.
1150
1165
  directions: e.directions && Object.fromEntries(
1151
- Object.entries(e.directions).map(([i, c]) => [
1152
- A(i),
1166
+ Object.entries(e.directions).map(([a, c]) => [
1167
+ A(a),
1153
1168
  c
1154
1169
  ])
1155
1170
  ),
1156
- domains: a,
1171
+ domains: i,
1157
1172
  path: e.path && {
1158
1173
  ...e.path,
1159
1174
  labels: o,
1160
- reserved: e.path.reserved?.map((i) => i.toLowerCase())
1175
+ reserved: e.path.reserved?.map((a) => a.toLowerCase())
1161
1176
  },
1162
1177
  supportedLocales: e.supportedLocales.map(A),
1163
1178
  xDefault: e.xDefault && r(e.xDefault)
1164
1179
  };
1165
1180
  }
1166
- function Pe(e, t) {
1181
+ function Oe(e, t) {
1167
1182
  const r = t?.directions?.[e];
1168
1183
  if (r) return r;
1169
1184
  const n = new Intl.Locale(e), o = n.textInfo?.direction;
@@ -1171,14 +1186,14 @@ function Pe(e, t) {
1171
1186
  }
1172
1187
  function Cn(e, t) {
1173
1188
  rr(t);
1174
- const r = new URL(e.url), [n = "", ...o] = r.pathname.slice(1).split("/"), s = nt(n, t), a = t.path?.reserved?.some(
1189
+ const r = new URL(e.url), [n = "", ...o] = r.pathname.slice(1).split("/"), s = ot(n, t), i = t.path?.reserved?.some(
1175
1190
  (g) => g.toLowerCase() === n.toLowerCase()
1176
- ) ?? !1, i = Pn(r.hostname, t), c = Dn(e, t), u = On(e.headers.get("accept-language"), t), l = s ?? i ?? c ?? u ?? t.defaultLocale, d = s ? "path" : i ? "domain" : c ? "cookie" : u ? "accept-language" : "default", h = s || a ? `/${o.join("/")}`.replace(/\/$/, "") || "/" : r.pathname, f = tr(r, h, l, t), m = {
1191
+ ) ?? !1, a = Pn(r.hostname, t), c = Dn(e, t), u = On(e.headers.get("accept-language"), t), l = s ?? a ?? c ?? u ?? t.defaultLocale, d = s ? "path" : a ? "domain" : c ? "cookie" : u ? "accept-language" : "default", h = s || i ? `/${o.join("/")}`.replace(/\/$/, "") || "/" : r.pathname, f = tr(r, h, l, t), m = {
1177
1192
  locale: l,
1178
1193
  pathname: h,
1179
- redirect: !a && f.href !== r.href ? f : void 0,
1194
+ redirect: !i && f.href !== r.href ? f : void 0,
1180
1195
  source: d,
1181
- unsupported: a
1196
+ unsupported: i
1182
1197
  }, w = t.resolver?.({
1183
1198
  configuration: t,
1184
1199
  defaultResolution: m,
@@ -1193,21 +1208,21 @@ function Cn(e, t) {
1193
1208
  return w;
1194
1209
  }
1195
1210
  function er(e, t, r, n = "http://demiurge.local") {
1196
- const o = new URL(e, n), a = nt(o.pathname.slice(1).split("/")[0] ?? "", r) ? `/${o.pathname.slice(1).split("/").slice(1).join("/")}`.replace(/\/$/, "") || "/" : o.pathname, i = tr(o, a, t, r), c = new URL(n);
1197
- return i.origin === c.origin ? `${i.pathname}${i.search}${i.hash}` : i.href;
1211
+ const o = new URL(e, n), i = ot(o.pathname.slice(1).split("/")[0] ?? "", r) ? `/${o.pathname.slice(1).split("/").slice(1).join("/")}`.replace(/\/$/, "") || "/" : o.pathname, a = tr(o, i, t, r), c = new URL(n);
1212
+ return a.origin === c.origin ? `${a.pathname}${a.search}${a.hash}` : a.href;
1198
1213
  }
1199
- function Li(e, t) {
1214
+ function Ci(e, t) {
1200
1215
  if (!t) return e;
1201
1216
  const r = e.slice(1).split("/");
1202
- return nt(r[0] ?? "", t) ? `/${r.slice(1).join("/")}`.replace(/\/$/, "") || "/" : e;
1217
+ return ot(r[0] ?? "", t) ? `/${r.slice(1).join("/")}`.replace(/\/$/, "") || "/" : e;
1203
1218
  }
1204
1219
  function tr(e, t, r, n) {
1205
- const o = new URL(e), s = n.path?.labels[r], a = s && (r !== n.defaultLocale || n.path?.prefixDefault);
1206
- o.pathname = a ? `/${s}${t === "/" ? "" : t}` : t;
1207
- const i = n.domains?.[r];
1208
- return i && (o.hostname = i), o;
1220
+ const o = new URL(e), s = n.path?.labels[r], i = s && (r !== n.defaultLocale || n.path?.prefixDefault);
1221
+ o.pathname = i ? `/${s}${t === "/" ? "" : t}` : t;
1222
+ const a = n.domains?.[r];
1223
+ return a && (o.hostname = a), o;
1209
1224
  }
1210
- function nt(e, t) {
1225
+ function ot(e, t) {
1211
1226
  const r = Object.entries(t.path?.labels ?? {}).find(([, n]) => String(n).toLowerCase() === e.toLowerCase());
1212
1227
  return r ? r[0] : Object.entries(t.aliases ?? {}).find(([n]) => n.toLowerCase() === e.toLowerCase())?.[1];
1213
1228
  }
@@ -1223,18 +1238,18 @@ function Dn(e, t) {
1223
1238
  function On(e, t) {
1224
1239
  if (!e) return;
1225
1240
  const r = e.split(",").map((n, o) => {
1226
- const [s = "", ...a] = n.trim().split(";"), i = a.find((u) => u.trim().toLowerCase().startsWith("q=")), c = i ? Number(i.trim().slice(2)) : 1;
1241
+ const [s = "", ...i] = n.trim().split(";"), a = i.find((u) => u.trim().toLowerCase().startsWith("q=")), c = a ? Number(a.trim().slice(2)) : 1;
1227
1242
  return { order: o, q: c, tag: s.trim() };
1228
1243
  }).filter(({ q: n, tag: o }) => o !== "" && Number.isFinite(n) && n > 0 && n <= 1).sort((n, o) => o.q - n.q || n.order - o.order);
1229
1244
  for (const n of r) {
1230
1245
  if (n.tag === "*") return t.defaultLocale;
1231
1246
  let o = n.tag.toLowerCase();
1232
1247
  for (; o; ) {
1233
- const s = t.supportedLocales.find((i) => i.toLowerCase() === o) ?? t.supportedLocales.find((i) => i.toLowerCase().startsWith(`${o}-`));
1248
+ const s = t.supportedLocales.find((a) => a.toLowerCase() === o) ?? t.supportedLocales.find((a) => a.toLowerCase().startsWith(`${o}-`));
1234
1249
  if (s) return s;
1235
- const a = o.lastIndexOf("-");
1236
- if (a < 0) break;
1237
- o = o.slice(0, a);
1250
+ const i = o.lastIndexOf("-");
1251
+ if (i < 0) break;
1252
+ o = o.slice(0, i);
1238
1253
  }
1239
1254
  }
1240
1255
  }
@@ -1244,32 +1259,32 @@ function rr(e) {
1244
1259
  if (new Set(t).size !== t.length) throw new Error("Locale configuration contains duplicate canonical locales.");
1245
1260
  if (!t.includes(A(e.defaultLocale))) throw new Error("The default locale must be supported.");
1246
1261
  if (e.supportedLocales.length > 1 && !e.path && !e.domains) throw new Error("Multiple locales require a path or domain binding.");
1247
- const r = new Set(t), n = (i, c) => {
1248
- if (!r.has(A(i))) throw new Error(`The ${c} target "${i}" must be supported.`);
1249
- }, o = /* @__PURE__ */ new Map(), s = (i, c) => {
1250
- const u = i.toLowerCase(), l = o.get(u);
1251
- if (l) throw new Error(`Locale ${c} "${i}" conflicts with ${l}.`);
1252
- o.set(u, `${c} "${i}"`);
1262
+ const r = new Set(t), n = (a, c) => {
1263
+ if (!r.has(A(a))) throw new Error(`The ${c} target "${a}" must be supported.`);
1264
+ }, o = /* @__PURE__ */ new Map(), s = (a, c) => {
1265
+ const u = a.toLowerCase(), l = o.get(u);
1266
+ if (l) throw new Error(`Locale ${c} "${a}" conflicts with ${l}.`);
1267
+ o.set(u, `${c} "${a}"`);
1253
1268
  };
1254
- for (const [i, c] of Object.entries(e.path?.labels ?? {})) {
1255
- if (n(i, "path label"), !/^[a-z0-9][a-z0-9-]*$/i.test(String(c))) throw new Error(`Locale path label "${c}" is invalid.`);
1269
+ for (const [a, c] of Object.entries(e.path?.labels ?? {})) {
1270
+ if (n(a, "path label"), !/^[a-z0-9][a-z0-9-]*$/i.test(String(c))) throw new Error(`Locale path label "${c}" is invalid.`);
1256
1271
  s(String(c), "path label");
1257
1272
  }
1258
- for (const [i, c] of Object.entries(e.aliases ?? {})) {
1259
- if (n(String(c), "alias"), !/^[a-z0-9][a-z0-9-]*$/i.test(i)) throw new Error(`Locale alias "${i}" is invalid.`);
1260
- s(i, "alias");
1273
+ for (const [a, c] of Object.entries(e.aliases ?? {})) {
1274
+ if (n(String(c), "alias"), !/^[a-z0-9][a-z0-9-]*$/i.test(a)) throw new Error(`Locale alias "${a}" is invalid.`);
1275
+ s(a, "alias");
1261
1276
  }
1262
- for (const i of e.path?.reserved ?? []) s(i, "reserved label");
1263
- const a = /* @__PURE__ */ new Set();
1264
- for (const [i, c] of Object.entries(e.domains ?? {})) {
1265
- n(i, "domain");
1277
+ for (const a of e.path?.reserved ?? []) s(a, "reserved label");
1278
+ const i = /* @__PURE__ */ new Set();
1279
+ for (const [a, c] of Object.entries(e.domains ?? {})) {
1280
+ n(a, "domain");
1266
1281
  const u = nr(String(c));
1267
- if (a.has(u)) throw new Error(`Locale domain "${c}" is duplicated.`);
1268
- a.add(u);
1282
+ if (i.has(u)) throw new Error(`Locale domain "${c}" is duplicated.`);
1283
+ i.add(u);
1269
1284
  }
1270
- for (const [i, c] of Object.entries(e.directions ?? {}))
1271
- if (n(i, "direction"), c !== "ltr" && c !== "rtl")
1272
- throw new Error(`Locale direction for "${i}" must be "ltr" or "rtl".`);
1285
+ for (const [a, c] of Object.entries(e.directions ?? {}))
1286
+ if (n(a, "direction"), c !== "ltr" && c !== "rtl")
1287
+ throw new Error(`Locale direction for "${a}" must be "ltr" or "rtl".`);
1273
1288
  if (e.cookie && !/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(e.cookie.name))
1274
1289
  throw new Error("The locale cookie name is invalid.");
1275
1290
  e.xDefault && n(e.xDefault, "x-default");
@@ -1325,7 +1340,7 @@ function nr(e) {
1325
1340
  if (!t || t !== e.toLowerCase()) throw new Error(`Locale domain "${e}" must be a hostname.`);
1326
1341
  return t;
1327
1342
  }
1328
- function Ci(e, t) {
1343
+ function Pi(e, t) {
1329
1344
  return {
1330
1345
  cors: t?.cors,
1331
1346
  kind: "json",
@@ -1335,7 +1350,7 @@ function Ci(e, t) {
1335
1350
  init: k(t)
1336
1351
  };
1337
1352
  }
1338
- function Pi(e, t) {
1353
+ function Di(e, t) {
1339
1354
  return {
1340
1355
  cors: t?.cors,
1341
1356
  init: k(t),
@@ -1345,7 +1360,7 @@ function Pi(e, t) {
1345
1360
  timing: $(t?.timing)
1346
1361
  };
1347
1362
  }
1348
- function Di(e, t) {
1363
+ function Oi(e, t) {
1349
1364
  return {
1350
1365
  cors: t?.cors,
1351
1366
  kind: "text",
@@ -1355,7 +1370,7 @@ function Di(e, t) {
1355
1370
  init: k(t)
1356
1371
  };
1357
1372
  }
1358
- function Oi(e, t) {
1373
+ function Ni(e, t) {
1359
1374
  return {
1360
1375
  cors: t?.cors,
1361
1376
  kind: "html",
@@ -1365,7 +1380,7 @@ function Oi(e, t) {
1365
1380
  init: k(t)
1366
1381
  };
1367
1382
  }
1368
- function Ni(e, t) {
1383
+ function Mi(e, t) {
1369
1384
  const r = typeof t == "number" ? void 0 : t;
1370
1385
  return {
1371
1386
  cors: r?.cors,
@@ -1376,7 +1391,7 @@ function Ni(e, t) {
1376
1391
  init: typeof t == "number" ? { status: t } : k(t)
1377
1392
  };
1378
1393
  }
1379
- function Mi(e, t) {
1394
+ function ji(e, t) {
1380
1395
  return {
1381
1396
  cors: t?.cors,
1382
1397
  kind: "not-found",
@@ -1395,7 +1410,7 @@ function Mn(e, t) {
1395
1410
  timing: $(t?.timing)
1396
1411
  };
1397
1412
  }
1398
- function ji(e, t) {
1413
+ function Ui(e, t) {
1399
1414
  return {
1400
1415
  body: e,
1401
1416
  cors: t?.cors,
@@ -1405,7 +1420,7 @@ function ji(e, t) {
1405
1420
  timing: $(t?.timing)
1406
1421
  };
1407
1422
  }
1408
- function Ui(e, t) {
1423
+ function Ii(e, t) {
1409
1424
  return {
1410
1425
  cors: t?.cors,
1411
1426
  events: e,
@@ -1415,7 +1430,7 @@ function Ui(e, t) {
1415
1430
  timing: $(t?.timing)
1416
1431
  };
1417
1432
  }
1418
- function Ii(...e) {
1433
+ function zi(...e) {
1419
1434
  return e;
1420
1435
  }
1421
1436
  async function or(e, t) {
@@ -1423,7 +1438,7 @@ async function or(e, t) {
1423
1438
  case "json":
1424
1439
  return new Response(JSON.stringify(await E(e.value, t)), {
1425
1440
  ...e.init,
1426
- headers: De(
1441
+ headers: Ne(
1427
1442
  e.init?.headers,
1428
1443
  "content-type",
1429
1444
  "application/json; charset=utf-8"
@@ -1434,7 +1449,7 @@ async function or(e, t) {
1434
1449
  Un(await E(e.lines, t)),
1435
1450
  {
1436
1451
  ...e.init,
1437
- headers: he(e.init?.headers, {
1452
+ headers: me(e.init?.headers, {
1438
1453
  "cache-control": "no-cache",
1439
1454
  "content-type": "application/x-ndjson; charset=utf-8",
1440
1455
  "x-accel-buffering": "no"
@@ -1444,7 +1459,7 @@ async function or(e, t) {
1444
1459
  case "text":
1445
1460
  return new Response(await E(e.value, t), {
1446
1461
  ...e.init,
1447
- headers: De(
1462
+ headers: Ne(
1448
1463
  e.init?.headers,
1449
1464
  "content-type",
1450
1465
  "text/plain; charset=utf-8"
@@ -1453,7 +1468,7 @@ async function or(e, t) {
1453
1468
  case "html":
1454
1469
  return new Response(await E(e.value, t), {
1455
1470
  ...e.init,
1456
- headers: De(
1471
+ headers: Ne(
1457
1472
  e.init?.headers,
1458
1473
  "content-type",
1459
1474
  "text/html; charset=utf-8"
@@ -1482,7 +1497,7 @@ async function or(e, t) {
1482
1497
  In(await E(e.body, t)),
1483
1498
  {
1484
1499
  ...e.init,
1485
- headers: he(e.init?.headers, {
1500
+ headers: me(e.init?.headers, {
1486
1501
  "content-type": "application/octet-stream",
1487
1502
  "x-accel-buffering": "no"
1488
1503
  })
@@ -1493,7 +1508,7 @@ async function or(e, t) {
1493
1508
  jn(await E(e.events, t)),
1494
1509
  {
1495
1510
  ...e.init,
1496
- headers: he(e.init?.headers, {
1511
+ headers: me(e.init?.headers, {
1497
1512
  "cache-control": "no-cache",
1498
1513
  "content-type": "text/event-stream; charset=utf-8",
1499
1514
  "x-accel-buffering": "no"
@@ -1507,17 +1522,17 @@ async function E(e, t) {
1507
1522
  t
1508
1523
  );
1509
1524
  }
1510
- function De(e, t, r) {
1511
- return he(e, { [t]: r });
1525
+ function Ne(e, t, r) {
1526
+ return me(e, { [t]: r });
1512
1527
  }
1513
- function he(e, t) {
1528
+ function me(e, t) {
1514
1529
  const r = new Headers(e);
1515
1530
  for (const [n, o] of Object.entries(t))
1516
1531
  r.has(n) || r.set(n, o);
1517
1532
  return r;
1518
1533
  }
1519
1534
  function jn(e) {
1520
- const t = new TextEncoder(), r = ot(e);
1535
+ const t = new TextEncoder(), r = st(e);
1521
1536
  return new ReadableStream({
1522
1537
  async pull(n) {
1523
1538
  const o = await r.next();
@@ -1533,7 +1548,7 @@ function jn(e) {
1533
1548
  });
1534
1549
  }
1535
1550
  function Un(e) {
1536
- const t = new TextEncoder(), r = ot(e);
1551
+ const t = new TextEncoder(), r = st(e);
1537
1552
  return new ReadableStream({
1538
1553
  async pull(n) {
1539
1554
  const o = await r.next();
@@ -1550,7 +1565,7 @@ function Un(e) {
1550
1565
  });
1551
1566
  }
1552
1567
  function In(e) {
1553
- const t = new TextEncoder(), r = ot(e);
1568
+ const t = new TextEncoder(), r = st(e);
1554
1569
  return new ReadableStream({
1555
1570
  async pull(n) {
1556
1571
  const o = await r.next();
@@ -1568,7 +1583,7 @@ function In(e) {
1568
1583
  function zn(e, t) {
1569
1584
  return typeof e == "string" ? t.encode(e) : e;
1570
1585
  }
1571
- function ot(e) {
1586
+ function st(e) {
1572
1587
  if (e instanceof ReadableStream) {
1573
1588
  const t = e.getReader();
1574
1589
  return {
@@ -1676,7 +1691,7 @@ function Kn(e) {
1676
1691
  function Yn(e) {
1677
1692
  return e.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
1678
1693
  }
1679
- const Zn = "x-demiurge-mutation", Qn = "data;v=1", Ve = "application/vnd.demiurge.mutation+json;v=1";
1694
+ const Zn = "x-demiurge-mutation", Qn = "data;v=1", qe = "application/vnd.demiurge.mutation+json;v=1";
1680
1695
  class sr extends Error {
1681
1696
  validation;
1682
1697
  constructor(t) {
@@ -1689,7 +1704,7 @@ class sr extends Error {
1689
1704
  }
1690
1705
  }
1691
1706
  const W = "x-demiurge-revalidate-tags";
1692
- function zi(e) {
1707
+ function Hi(e) {
1693
1708
  return {
1694
1709
  ...Mn(
1695
1710
  async (r) => {
@@ -1712,7 +1727,7 @@ function zi(e) {
1712
1727
  await to(u, r),
1713
1728
  r
1714
1729
  );
1715
- return l || !qe(r.request) ? d : await eo(
1730
+ return l || !_e(r.request) ? d : await eo(
1716
1731
  d,
1717
1732
  e.revalidateRoute === !0,
1718
1733
  r.pathname
@@ -1731,19 +1746,19 @@ function zi(e) {
1731
1746
  r.pathname
1732
1747
  );
1733
1748
  }
1734
- const a = typeof e.idempotency.key == "function" ? e.idempotency.key(o) : e.idempotency.key, i = await e.idempotency.store.run({
1749
+ const i = typeof e.idempotency.key == "function" ? e.idempotency.key(o) : e.idempotency.key, a = await e.idempotency.store.run({
1735
1750
  fn: s,
1736
- key: a,
1751
+ key: i,
1737
1752
  ttl: e.idempotency.ttl
1738
1753
  });
1739
- if (i.replayed) return ro(i.value);
1740
- if (!bt(i.value)) return i.value;
1754
+ if (a.replayed) return ro(a.value);
1755
+ if (!bt(a.value)) return a.value;
1741
1756
  const c = await Et(
1742
1757
  e.revalidate,
1743
1758
  o
1744
1759
  );
1745
1760
  return await Rt(
1746
- i.value,
1761
+ a.value,
1747
1762
  c,
1748
1763
  r.pathname
1749
1764
  );
@@ -1757,13 +1772,13 @@ function zi(e) {
1757
1772
  mutation: !0
1758
1773
  };
1759
1774
  }
1760
- function qe(e) {
1775
+ function _e(e) {
1761
1776
  return e.headers.get(Zn) === Qn;
1762
1777
  }
1763
1778
  function Xn(e, t, r) {
1764
- const n = qe(e) ? { version: 1, status: "invalid", validation: t } : { type: "validation-error", validation: t }, o = pe(n, r);
1765
- return qe(e) ? new Response(o, {
1766
- headers: { "content-type": Ve },
1779
+ const n = _e(e) ? { version: 1, status: "invalid", validation: t } : { type: "validation-error", validation: t }, o = ge(n, r);
1780
+ return _e(e) ? new Response(o, {
1781
+ headers: { "content-type": qe },
1767
1782
  status: 400
1768
1783
  }) : new Response(o, {
1769
1784
  headers: { "content-type": "application/json; charset=utf-8" },
@@ -1773,37 +1788,37 @@ function Xn(e, t, r) {
1773
1788
  async function eo(e, t, r) {
1774
1789
  if (e.status >= 300 && e.status < 400) {
1775
1790
  const o = e.headers.get("location");
1776
- return o ? new Response(pe({
1791
+ return o ? new Response(ge({
1777
1792
  version: 1,
1778
1793
  status: "redirect",
1779
1794
  location: o,
1780
1795
  history: e.status === 301 || e.status === 308 ? "replace" : "push"
1781
1796
  }, r), {
1782
- headers: { "content-type": Ve },
1797
+ headers: { "content-type": qe },
1783
1798
  status: 200
1784
1799
  }) : e;
1785
1800
  }
1786
1801
  const n = e.headers.get("content-type")?.includes("json") ? await e.clone().json().catch(() => {
1787
1802
  }) : void 0;
1788
- return new Response(pe({
1803
+ return new Response(ge({
1789
1804
  version: 1,
1790
1805
  status: e.ok ? "success" : "failed",
1791
1806
  ...t && e.ok ? { revalidate: !0 } : {},
1792
1807
  ...e.ok && n !== void 0 ? { data: n } : {}
1793
1808
  }, r), {
1794
- headers: { "content-type": Ve },
1809
+ headers: { "content-type": qe },
1795
1810
  status: e.status
1796
1811
  });
1797
1812
  }
1798
1813
  async function to(e, t) {
1799
1814
  if (e instanceof Response || e.kind !== "json") return e;
1800
1815
  const r = typeof e.value == "function" ? await e.value(t) : e.value;
1801
- return ge(r, t.pathname), { ...e, value: r };
1816
+ return we(r, t.pathname), { ...e, value: r };
1802
1817
  }
1803
- function pe(e, t) {
1804
- return ge(e, t), JSON.stringify(e);
1818
+ function ge(e, t) {
1819
+ return we(e, t), JSON.stringify(e);
1805
1820
  }
1806
- function ge(e, t, r = [], n = /* @__PURE__ */ new Set()) {
1821
+ function we(e, t, r = [], n = /* @__PURE__ */ new Set()) {
1807
1822
  if (!(e === null || typeof e == "string" || typeof e == "boolean")) {
1808
1823
  if (typeof e == "number") {
1809
1824
  if (Number.isFinite(e)) return;
@@ -1817,7 +1832,7 @@ function ge(e, t, r = [], n = /* @__PURE__ */ new Set()) {
1817
1832
  for (let o = 0; o < e.length; o += 1) {
1818
1833
  if (!(o in e))
1819
1834
  throw L(t, [...r, String(o)]);
1820
- ge(e[o], t, [...r, String(o)], n);
1835
+ we(e[o], t, [...r, String(o)], n);
1821
1836
  }
1822
1837
  } else {
1823
1838
  const o = Object.getPrototypeOf(e);
@@ -1826,7 +1841,7 @@ function ge(e, t, r = [], n = /* @__PURE__ */ new Set()) {
1826
1841
  for (const s of Reflect.ownKeys(e)) {
1827
1842
  if (typeof s != "string")
1828
1843
  throw L(t, [...r, "<symbol>"]);
1829
- ge(
1844
+ we(
1830
1845
  Object.getOwnPropertyDescriptor(e, s)?.value,
1831
1846
  t,
1832
1847
  [...r, s],
@@ -1857,9 +1872,9 @@ async function Rt(e, t, r) {
1857
1872
  const o = t.keys ?? [], s = t.tags ?? [];
1858
1873
  return (o.length > 0 || s.length > 0) && n.set(
1859
1874
  W,
1860
- encodeURIComponent(pe({
1875
+ encodeURIComponent(ge({
1861
1876
  keys: o,
1862
- tags: s.map((a) => a.id),
1877
+ tags: s.map((i) => i.id),
1863
1878
  version: 1
1864
1879
  }, r))
1865
1880
  ), new Response(e.body, {
@@ -1877,22 +1892,22 @@ function ro(e) {
1877
1892
  statusText: e.statusText
1878
1893
  });
1879
1894
  }
1880
- const Hi = {
1895
+ const Fi = {
1881
1896
  custom(e) {
1882
1897
  return e;
1883
1898
  },
1884
1899
  form(e, t) {
1885
1900
  return async (n) => {
1886
- const o = await n.request.formData(), s = await t(o, n), a = await e["~standard"].validate(s);
1887
- if (a.issues)
1901
+ const o = await n.request.formData(), s = await t(o, n), i = await e["~standard"].validate(s);
1902
+ if (i.issues)
1888
1903
  throw new sr({
1889
- issues: a.issues.map((i) => ({
1904
+ issues: i.issues.map((a) => ({
1890
1905
  code: "invalid",
1891
- message: i.message,
1892
- path: no(i.path)
1906
+ message: a.message,
1907
+ path: no(a.path)
1893
1908
  }))
1894
1909
  });
1895
- return a.value;
1910
+ return i.value;
1896
1911
  };
1897
1912
  },
1898
1913
  async formData({ request: e }) {
@@ -2011,14 +2026,14 @@ class ar extends Error {
2011
2026
  co(t);
2012
2027
  const o = typeof r == "string" ? { detail: r } : r, {
2013
2028
  detail: s,
2014
- title: a = ao[t],
2015
- type: i = "about:blank",
2029
+ title: i = ao[t],
2030
+ type: a = "about:blank",
2016
2031
  ...c
2017
2032
  } = o;
2018
- super(s ?? a, { cause: n.cause }), this.name = "HttpError", this.detail = s, this.extensions = Object.freeze({ ...c }), this.headers = new Headers(n.headers), this.status = t, this.title = a, this.type = i;
2033
+ super(s ?? i, { cause: n.cause }), this.name = "HttpError", this.detail = s, this.extensions = Object.freeze({ ...c }), this.headers = new Headers(n.headers), this.status = t, this.title = i, this.type = a;
2019
2034
  }
2020
2035
  }
2021
- function Fi(e, t, r) {
2036
+ function Wi(e, t, r) {
2022
2037
  return new ar(e, t, r);
2023
2038
  }
2024
2039
  function j(e) {
@@ -2047,7 +2062,7 @@ function $t({ status: e }) {
2047
2062
  ] });
2048
2063
  }
2049
2064
  function uo({ error: e, pathname: t, status: r }) {
2050
- const { message: n, name: o, stack: s } = st(e);
2065
+ const { message: n, name: o, stack: s } = at(e);
2051
2066
  return /* @__PURE__ */ X("main", { children: [
2052
2067
  /* @__PURE__ */ X("h1", { children: [
2053
2068
  r,
@@ -2060,7 +2075,7 @@ function uo({ error: e, pathname: t, status: r }) {
2060
2075
  s ? /* @__PURE__ */ ee("pre", { children: s }) : null
2061
2076
  ] });
2062
2077
  }
2063
- function st(e) {
2078
+ function at(e) {
2064
2079
  return e instanceof Error ? {
2065
2080
  message: e.message,
2066
2081
  name: e.name,
@@ -2128,18 +2143,18 @@ function te(e, t) {
2128
2143
  });
2129
2144
  }
2130
2145
  const wo = "Internal Server Error";
2131
- function at(e) {
2146
+ function it(e) {
2132
2147
  return e === !0 && process.env.NODE_ENV !== "production";
2133
2148
  }
2134
- async function me(e, t, r, n, o = {}) {
2149
+ async function pe(e, t, r, n, o = {}) {
2135
2150
  o.onError?.(r, n);
2136
2151
  const s = new URL(t.url);
2137
2152
  if (!(F(t) || n === "page" || n === "middleware" && ir(t)))
2138
2153
  return yo(s, r, o);
2139
2154
  if (F(t)) {
2140
- const i = st(r), c = j(r) ? new Headers(r.headers) : new Headers();
2141
- return rt(void 0, {
2142
- document: Je({
2155
+ const a = at(r), c = j(r) ? new Headers(r.headers) : new Headers();
2156
+ return nt(void 0, {
2157
+ document: Ke({
2143
2158
  dir: o.dir,
2144
2159
  lang: o.lang,
2145
2160
  metadata: T(),
@@ -2147,12 +2162,12 @@ async function me(e, t, r, n, o = {}) {
2147
2162
  }),
2148
2163
  locale: o.locale,
2149
2164
  error: {
2150
- detail: j(r) ? r.detail : at(o.dev) ? i.message : void 0,
2165
+ detail: j(r) ? r.detail : it(o.dev) ? a.message : void 0,
2151
2166
  title: j(r) ? r.title : "Internal Server Error"
2152
2167
  },
2153
2168
  headers: c,
2154
- kind: fe,
2155
- status: it(r)
2169
+ kind: he,
2170
+ status: ct(r)
2156
2171
  });
2157
2172
  }
2158
2173
  return await vo(e, s, r, o);
@@ -2170,27 +2185,27 @@ function yo(e, t, r = {}) {
2170
2185
  },
2171
2186
  { headers: t.headers }
2172
2187
  );
2173
- const { message: n } = st(t);
2188
+ const { message: n } = at(t);
2174
2189
  return te({
2175
2190
  // `detail` carries the thrown message, so it is dev only for the same
2176
2191
  // reason the stack is.
2177
- ...at(r.dev) ? { detail: n } : {},
2192
+ ...it(r.dev) ? { detail: n } : {},
2178
2193
  instance: `${e.pathname}${e.search}`,
2179
2194
  status: 500,
2180
2195
  title: "Internal Server Error"
2181
2196
  });
2182
2197
  }
2183
2198
  async function vo(e, t, r, n) {
2184
- const o = it(r);
2199
+ const o = ct(r);
2185
2200
  try {
2186
2201
  const s = await bo(
2187
2202
  e,
2188
2203
  n.pathname ?? t.pathname,
2189
2204
  r,
2190
2205
  n
2191
- ), a = j(r) ? new Headers(r.headers) : new Headers();
2192
- return a.set("content-type", "text/html; charset=utf-8"), new Response(await n.transformDocument?.(s) ?? s, {
2193
- headers: a,
2206
+ ), i = j(r) ? new Headers(r.headers) : new Headers();
2207
+ return i.set("content-type", "text/html; charset=utf-8"), new Response(await n.transformDocument?.(s) ?? s, {
2208
+ headers: i,
2194
2209
  status: o
2195
2210
  });
2196
2211
  } catch (s) {
@@ -2207,14 +2222,14 @@ async function bo(e, t, r, n) {
2207
2222
  const o = await Eo(e, t, n), s = Ft({
2208
2223
  dev: n.dev,
2209
2224
  nonce: n.nonce
2210
- }), a = Vt(
2225
+ }), i = Vt(
2211
2226
  Wt(
2212
2227
  s,
2213
- Ie(o, { error: r, locale: n.locale, pathname: t, status: it(r) })
2228
+ He(o, { error: r, locale: n.locale, pathname: t, status: ct(r) })
2214
2229
  )
2215
2230
  );
2216
2231
  return Bt({
2217
- body: { data: void 0, html: a, locale: n.locale, navigation: n.navigation },
2232
+ body: { data: void 0, html: i, locale: n.locale, navigation: n.navigation },
2218
2233
  entrySrc: n.clientEntry,
2219
2234
  lang: n.lang,
2220
2235
  nonce: n.nonce,
@@ -2223,11 +2238,11 @@ async function bo(e, t, r, n) {
2223
2238
  title: n.title
2224
2239
  });
2225
2240
  }
2226
- function it(e) {
2241
+ function ct(e) {
2227
2242
  return j(e) ? e.status : 500;
2228
2243
  }
2229
2244
  async function Eo(e, t, r) {
2230
- if (at(r.dev))
2245
+ if (it(r.dev))
2231
2246
  return uo;
2232
2247
  try {
2233
2248
  return await ln(e, t) ?? $t;
@@ -2236,17 +2251,17 @@ async function Eo(e, t, r) {
2236
2251
  }
2237
2252
  }
2238
2253
  const Ro = 403;
2239
- function Wi(e) {
2254
+ function Bi(e) {
2240
2255
  return e;
2241
2256
  }
2242
2257
  function cr(e) {
2243
2258
  const t = [], r = [];
2244
2259
  let n = !1, o = Ro;
2245
- for (const { policy: s, source: a } of e)
2260
+ for (const { policy: s, source: i } of e)
2246
2261
  s && (s.replaces && (n = !0, t.length = 0, r.push({
2247
2262
  ...s.replaces,
2248
- source: s.replaces.source ?? a
2249
- })), s.public && (n = !0), s.denyStatus && (o = s.denyStatus), s.authorize && (n = !0, t.push({ authorize: s.authorize, source: a })));
2263
+ source: s.replaces.source ?? i
2264
+ })), s.public && (n = !0), s.denyStatus && (o = s.denyStatus), s.authorize && (n = !0, t.push({ authorize: s.authorize, source: i })));
2250
2265
  return {
2251
2266
  chain: t,
2252
2267
  declared: n,
@@ -2260,7 +2275,7 @@ function To(e) {
2260
2275
  }
2261
2276
  async function xt(e, t) {
2262
2277
  if (!e.declared)
2263
- return Oe(
2278
+ return Me(
2264
2279
  e.denyStatus,
2265
2280
  "Forbidden. This route inherits no access declaration."
2266
2281
  );
@@ -2269,10 +2284,10 @@ async function xt(e, t) {
2269
2284
  try {
2270
2285
  n = await r.authorize(t);
2271
2286
  } catch {
2272
- return Oe(e.denyStatus);
2287
+ return Me(e.denyStatus);
2273
2288
  }
2274
2289
  if (!$o(n))
2275
- return Oe(xo(n, e.denyStatus));
2290
+ return Me(xo(n, e.denyStatus));
2276
2291
  }
2277
2292
  return null;
2278
2293
  }
@@ -2285,7 +2300,7 @@ function xo(e, t) {
2285
2300
  function Ao(e) {
2286
2301
  return e === 401 || e === 403 || e === 404;
2287
2302
  }
2288
- function Oe(e, t = ko(e)) {
2303
+ function Me(e, t = ko(e)) {
2289
2304
  return new Response(t, {
2290
2305
  headers: {
2291
2306
  "cache-control": "private, no-store",
@@ -2312,7 +2327,7 @@ function Lo(e) {
2312
2327
  function lr(e) {
2313
2328
  return P(e) ? e : void 0;
2314
2329
  }
2315
- function ct(e) {
2330
+ function ut(e) {
2316
2331
  return P(e) ? e.value : e;
2317
2332
  }
2318
2333
  function dr(e) {
@@ -2338,7 +2353,7 @@ function Do(e, t) {
2338
2353
  request: n && !n.source ? { ...e.request, maxBodySize: { ...n, source: t } } : e.request
2339
2354
  };
2340
2355
  }
2341
- const we = "{nonce}", At = `'nonce-${we}'`, fr = {
2356
+ const ye = "{nonce}", At = `'nonce-${ye}'`, fr = {
2342
2357
  baseUri: ["'self'"],
2343
2358
  connectSrc: ["'self'"],
2344
2359
  defaultSrc: ["'self'"],
@@ -2411,16 +2426,16 @@ const we = "{nonce}", At = `'nonce-${we}'`, fr = {
2411
2426
  );
2412
2427
  }
2413
2428
  };
2414
- function Bi(e) {
2429
+ function Vi(e) {
2415
2430
  return e;
2416
2431
  }
2417
- function Vi(e) {
2432
+ function qi(e) {
2418
2433
  return e;
2419
2434
  }
2420
2435
  function Mo(...e) {
2421
2436
  return e.reduce((t, r) => r ? Y(t, r) : t, {});
2422
2437
  }
2423
- function ye(...e) {
2438
+ function ve(...e) {
2424
2439
  const t = e.reduce((r, n) => n ? {
2425
2440
  document: Mo(r.document, n.document),
2426
2441
  security: jo(r.security, n.security)
@@ -2484,7 +2499,7 @@ function zo(e, t, r, n) {
2484
2499
  [t]: [.../* @__PURE__ */ new Set([...o, ...n])]
2485
2500
  } : e;
2486
2501
  }
2487
- async function qi(e, t = "sha256") {
2502
+ async function _i(e, t = "sha256") {
2488
2503
  const r = await globalThis.crypto.subtle.digest(
2489
2504
  es(t),
2490
2505
  new TextEncoder().encode(e)
@@ -2494,22 +2509,22 @@ async function qi(e, t = "sha256") {
2494
2509
  function se(e, t = {}) {
2495
2510
  const r = S(e.csp);
2496
2511
  r && Zo(r), Yo(e);
2497
- const n = new Headers(), o = r ? Go(r, t) : void 0, s = Vo(e.trustedTypes), a = e.trustedTypes ? e.trustedTypes.mode === "report-only" : !1;
2512
+ const n = new Headers(), o = r ? Go(r, t) : void 0, s = Vo(e.trustedTypes), i = e.trustedTypes ? e.trustedTypes.mode === "report-only" : !1;
2498
2513
  return R(
2499
2514
  n,
2500
2515
  "content-security-policy",
2501
- ve(o, a ? void 0 : s)
2516
+ Se(o, i ? void 0 : s)
2502
2517
  ), R(
2503
2518
  n,
2504
2519
  "content-security-policy-report-only",
2505
- a ? ve(s, wr(r)) : void 0
2520
+ i ? Se(s, wr(r)) : void 0
2506
2521
  ), Bo(n, e.headers, t), n;
2507
2522
  }
2508
- function $e(e) {
2523
+ function xe(e) {
2509
2524
  const t = e ? S(e.csp) : void 0;
2510
2525
  return t ? ae(t).some(([, r]) => {
2511
2526
  const n = D(r);
2512
- return Array.isArray(n) && n.some((o) => o.includes(we));
2527
+ return Array.isArray(n) && n.some((o) => o.includes(ye));
2513
2528
  }) : !1;
2514
2529
  }
2515
2530
  function mr() {
@@ -2543,27 +2558,27 @@ function Fo(e, t) {
2543
2558
  return e;
2544
2559
  const r = S(e);
2545
2560
  if (!r)
2546
- return Ne(t);
2547
- const n = Ne(r), o = Ne(t), s = {
2561
+ return je(t);
2562
+ const n = je(r), o = je(t), s = {
2548
2563
  ...n,
2549
2564
  ...o
2550
2565
  };
2551
- for (const [a, i] of ae(t)) {
2566
+ for (const [i, a] of ae(t)) {
2552
2567
  const c = D(
2553
- n[a]
2568
+ n[i]
2554
2569
  );
2555
- !ut(i) && Array.isArray(c) && Array.isArray(i) && gr(
2570
+ !lt(a) && Array.isArray(c) && Array.isArray(a) && gr(
2556
2571
  s,
2557
- a,
2558
- Wo([...c, ...i])
2572
+ i,
2573
+ Wo([...c, ...a])
2559
2574
  );
2560
2575
  }
2561
2576
  return s;
2562
2577
  }
2563
- function Ne(e) {
2578
+ function je(e) {
2564
2579
  const t = { ...e };
2565
2580
  for (const [r, n] of ae(e))
2566
- ut(n) && gr(t, r, n.replace);
2581
+ lt(n) && gr(t, r, n.replace);
2567
2582
  return t;
2568
2583
  }
2569
2584
  function Wo(e) {
@@ -2592,7 +2607,7 @@ function Vo(e) {
2592
2607
  if (!e)
2593
2608
  return;
2594
2609
  const t = [];
2595
- return e.requireFor?.includes("script") && t.push("require-trusted-types-for 'script'"), t.push(qo(e)), ve(...t);
2610
+ return e.requireFor?.includes("script") && t.push("require-trusted-types-for 'script'"), t.push(qo(e)), Se(...t);
2596
2611
  }
2597
2612
  function qo(e) {
2598
2613
  if (e.policies !== void 0 && e.policies.length === 0)
@@ -2603,7 +2618,7 @@ function qo(e) {
2603
2618
  t.push(r);
2604
2619
  return `trusted-types ${[...new Set(t)].join(" ")}`;
2605
2620
  }
2606
- function ve(...e) {
2621
+ function Se(...e) {
2607
2622
  const t = e.filter((r) => r);
2608
2623
  return t.length > 0 ? t.join("; ") : void 0;
2609
2624
  }
@@ -2619,16 +2634,16 @@ function Go(e, t) {
2619
2634
  for (const [o, s] of ae(e)) {
2620
2635
  if (o === "reportTo" || o === "reportUri")
2621
2636
  continue;
2622
- const a = D(s);
2623
- if (a === !1 || a === void 0)
2637
+ const i = D(s);
2638
+ if (i === !1 || i === void 0)
2624
2639
  continue;
2625
- const i = yr(o);
2626
- if (a === !0 || o === "sandbox" && Array.isArray(a) && a.length === 0) {
2627
- r.push(i);
2640
+ const a = yr(o);
2641
+ if (i === !0 || o === "sandbox" && Array.isArray(i) && i.length === 0) {
2642
+ r.push(a);
2628
2643
  continue;
2629
2644
  }
2630
2645
  r.push(
2631
- `${i} ${Xo(a, t).join(" ")}`
2646
+ `${a} ${Xo(i, t).join(" ")}`
2632
2647
  );
2633
2648
  }
2634
2649
  const n = wr(e);
@@ -2638,7 +2653,7 @@ function wr(e) {
2638
2653
  if (!e)
2639
2654
  return;
2640
2655
  const t = [], r = D(e.reportUri);
2641
- return Array.isArray(r) && r.length && t.push(`report-uri ${r.join(" ")}`), e.reportTo && t.push(`report-to ${e.reportTo}`), ve(...t);
2656
+ return Array.isArray(r) && r.length && t.push(`report-uri ${r.join(" ")}`), e.reportTo && t.push(`report-to ${e.reportTo}`), Se(...t);
2642
2657
  }
2643
2658
  function Jo(e) {
2644
2659
  if (e)
@@ -2653,8 +2668,8 @@ function Yo(e) {
2653
2668
  const o = Object.entries(t);
2654
2669
  if (o.length === 0)
2655
2670
  throw new Error("Demiurge Reporting-Endpoints requires at least one endpoint.");
2656
- for (const [s, a] of o)
2657
- Lt(s), Ct(a, `Reporting-Endpoints member ${JSON.stringify(s)}`);
2671
+ for (const [s, i] of o)
2672
+ Lt(s), Ct(i, `Reporting-Endpoints member ${JSON.stringify(s)}`);
2658
2673
  }
2659
2674
  const r = S(e.csp) || void 0;
2660
2675
  if (r?.reportTo && (Lt(r.reportTo), !t || !(r.reportTo in t)))
@@ -2698,11 +2713,11 @@ function Zo(e) {
2698
2713
  );
2699
2714
  }
2700
2715
  }
2701
- function ut(e) {
2716
+ function lt(e) {
2702
2717
  return !!(e && typeof e == "object" && !Array.isArray(e) && "replace" in e);
2703
2718
  }
2704
2719
  function D(e) {
2705
- return ut(e) ? e.replace : e;
2720
+ return lt(e) ? e.replace : e;
2706
2721
  }
2707
2722
  function Lt(e) {
2708
2723
  if (!/^(?:[a-z]|\*)[a-z0-9_.*-]*$/.test(e))
@@ -2732,11 +2747,11 @@ function ae(e) {
2732
2747
  }
2733
2748
  function Xo(e, t) {
2734
2749
  return e.map((r) => {
2735
- if (!r.includes(we))
2750
+ if (!r.includes(ye))
2736
2751
  return r;
2737
2752
  if (!t.nonce)
2738
2753
  throw new Error("Demiurge security policy requires a CSP nonce.");
2739
- return r.replaceAll(we, t.nonce);
2754
+ return r.replaceAll(ye, t.nonce);
2740
2755
  });
2741
2756
  }
2742
2757
  function yr(e) {
@@ -2752,7 +2767,7 @@ function ts(e) {
2752
2767
  return typeof btoa == "function" ? btoa(t) : Buffer.from(t, "binary").toString("base64");
2753
2768
  }
2754
2769
  function vr(e, t, r = {}) {
2755
- lt(e);
2770
+ dt(e);
2756
2771
  const n = t.request.headers.get("origin"), o = new Headers();
2757
2772
  if (e.origins !== "*" && Sr(o, "Origin"), !n)
2758
2773
  return o;
@@ -2761,10 +2776,10 @@ function vr(e, t, r = {}) {
2761
2776
  return o;
2762
2777
  if (o.set("access-control-allow-origin", s), e.credentials && o.set("access-control-allow-credentials", "true"), e.exposeHeaders?.length && o.set("access-control-expose-headers", e.exposeHeaders.join(", ")), r.preflight) {
2763
2778
  o.set("access-control-allow-methods", r.methods.join(", "));
2764
- const a = t.request.headers.get(
2779
+ const i = t.request.headers.get(
2765
2780
  "access-control-request-headers"
2766
- ), i = e.headers?.join(", ") ?? a;
2767
- i && o.set("access-control-allow-headers", i), e.maxAge !== void 0 && o.set("access-control-max-age", String(e.maxAge));
2781
+ ), a = e.headers?.join(", ") ?? i;
2782
+ a && o.set("access-control-allow-headers", a), e.maxAge !== void 0 && o.set("access-control-max-age", String(e.maxAge));
2768
2783
  }
2769
2784
  return o;
2770
2785
  }
@@ -2798,7 +2813,7 @@ function rs(e, t) {
2798
2813
  status: 204
2799
2814
  }) : null;
2800
2815
  }
2801
- function lt(e) {
2816
+ function dt(e) {
2802
2817
  if (e.credentials && e.origins === "*")
2803
2818
  throw new Error(
2804
2819
  "Demiurge CORS policy cannot use wildcard origins with credentials."
@@ -2880,7 +2895,7 @@ const us = {
2880
2895
  gb: 1024 ** 3,
2881
2896
  kb: 1024,
2882
2897
  mb: 1024 ** 2
2883
- }, dt = "1mb";
2898
+ }, ft = "1mb";
2884
2899
  function ls(e, t, r) {
2885
2900
  const n = fs(e, r);
2886
2901
  if (n)
@@ -2893,8 +2908,8 @@ function ls(e, t, r) {
2893
2908
  return new Response("Invalid Content-Length.", {
2894
2909
  status: 400
2895
2910
  });
2896
- const a = Se(ct(e?.maxBodySize) ?? dt);
2897
- return s > a ? new Response("Request body too large.", {
2911
+ const i = be(ut(e?.maxBodySize) ?? ft);
2912
+ return s > i ? new Response("Request body too large.", {
2898
2913
  status: 413
2899
2914
  }) : null;
2900
2915
  }
@@ -2906,37 +2921,37 @@ class Q extends Error {
2906
2921
  function ds(e, t) {
2907
2922
  if (t.body === null)
2908
2923
  return t;
2909
- const r = Se(ct(e?.maxBodySize) ?? dt), n = t.body.getReader();
2924
+ const r = be(ut(e?.maxBodySize) ?? ft), n = t.body.getReader();
2910
2925
  let o = 0;
2911
2926
  const s = new ReadableStream({
2912
- async pull(i) {
2927
+ async pull(a) {
2913
2928
  const c = await n.read();
2914
2929
  if (c.done) {
2915
- i.close();
2930
+ a.close();
2916
2931
  return;
2917
2932
  }
2918
2933
  if (o += c.value.byteLength, o > r) {
2919
2934
  const u = new Q();
2920
- i.error(u);
2935
+ a.error(u);
2921
2936
  try {
2922
2937
  await n.cancel(u);
2923
2938
  } catch {
2924
2939
  }
2925
2940
  return;
2926
2941
  }
2927
- i.enqueue(c.value);
2942
+ a.enqueue(c.value);
2928
2943
  },
2929
- async cancel(i) {
2944
+ async cancel(a) {
2930
2945
  try {
2931
- await n.cancel(i);
2946
+ await n.cancel(a);
2932
2947
  } catch {
2933
2948
  }
2934
2949
  }
2935
- }), a = new Request(t, {
2950
+ }), i = new Request(t, {
2936
2951
  body: s,
2937
2952
  duplex: "half"
2938
2953
  });
2939
- return Ur(t, a), a;
2954
+ return Ur(t, i), i;
2940
2955
  }
2941
2956
  function ue() {
2942
2957
  return new Response("Request body too large.", { status: 413 });
@@ -2949,7 +2964,7 @@ function fs(e, t) {
2949
2964
  status: 405
2950
2965
  });
2951
2966
  }
2952
- function Se(e) {
2967
+ function be(e) {
2953
2968
  if (typeof e == "number") {
2954
2969
  if (!Number.isSafeInteger(e) || e < 0)
2955
2970
  throw new Error("Demiurge request maxBodySize must be a non-negative integer.");
@@ -3004,7 +3019,7 @@ function ys(e, t) {
3004
3019
  if (r) {
3005
3020
  t.push({
3006
3021
  code: "csp-disabled",
3007
- message: `This document accepts no Content-Security-Policy. ${ft(r)} Reason: ${r.reason}`,
3022
+ message: `This document accepts no Content-Security-Policy. ${ht(r)} Reason: ${r.reason}`,
3008
3023
  origin: r.origin ?? "application",
3009
3024
  severity: "info",
3010
3025
  source: r.source
@@ -3017,14 +3032,14 @@ function ys(e, t) {
3017
3032
  severity: "error"
3018
3033
  });
3019
3034
  }
3020
- function ft(e) {
3035
+ function ht(e) {
3021
3036
  const r = (e.origin ?? "application") === "framework" ? "A framework helper declared this exception" : "The application declared this exception";
3022
3037
  return e.source ? `${r} in ${e.source}.` : `${r}.`;
3023
3038
  }
3024
3039
  function vs(e, t) {
3025
3040
  if (!e.trustedTypes || e.trustedTypes.mode !== "report-only")
3026
3041
  return;
3027
- const r = S(e.csp) || void 0, n = !!_e(r?.reportUri)?.length, o = e.headers?.reportingEndpoints, s = !!(r?.reportTo && o && o[r.reportTo]);
3042
+ const r = S(e.csp) || void 0, n = !!Ge(r?.reportUri)?.length, o = e.headers?.reportingEndpoints, s = !!(r?.reportTo && o && o[r.reportTo]);
3028
3043
  !n && !s && t.push({
3029
3044
  code: "report-only-target-missing",
3030
3045
  message: "Trusted Types report-only mode has no deliverable target. Configure CSP reportTo with a matching Reporting-Endpoints member, reportUri for compatibility, or both.",
@@ -3090,9 +3105,9 @@ function Rs(e) {
3090
3105
  return typeof e == "boolean" ? {} : e;
3091
3106
  }
3092
3107
  function Ts(e) {
3093
- return _e(e.scriptSrc) ?? _e(e.defaultSrc) ?? [];
3108
+ return Ge(e.scriptSrc) ?? Ge(e.defaultSrc) ?? [];
3094
3109
  }
3095
- function _e(e) {
3110
+ function Ge(e) {
3096
3111
  if (e)
3097
3112
  return "replace" in e ? e.replace : e;
3098
3113
  }
@@ -3158,7 +3173,7 @@ function Ds(e) {
3158
3173
  function Os(e, t) {
3159
3174
  if (e)
3160
3175
  try {
3161
- lt(e);
3176
+ dt(e);
3162
3177
  } catch (r) {
3163
3178
  t.push({
3164
3179
  code: "cors-invalid",
@@ -3173,7 +3188,7 @@ function Ns(e, t, r) {
3173
3188
  const n = lr(t?.csrf);
3174
3189
  n && r.push({
3175
3190
  code: "csrf-disabled",
3176
- message: `This unsafe route runs no CSRF check. ${ft(n)} Reason: ${n.reason}`,
3191
+ message: `This unsafe route runs no CSRF check. ${ht(n)} Reason: ${n.reason}`,
3177
3192
  origin: n.origin ?? "application",
3178
3193
  severity: "info",
3179
3194
  source: n.source
@@ -3184,12 +3199,12 @@ function Ns(e, t, r) {
3184
3199
  });
3185
3200
  }
3186
3201
  function Ms(e, t) {
3187
- const r = dr(e?.request?.maxBodySize), n = ct(e?.request?.maxBodySize);
3202
+ const r = dr(e?.request?.maxBodySize), n = ut(e?.request?.maxBodySize);
3188
3203
  if (n === void 0)
3189
3204
  return;
3190
3205
  let o, s;
3191
3206
  try {
3192
- o = Se(n), s = Se(dt);
3207
+ o = be(n), s = be(ft);
3193
3208
  } catch {
3194
3209
  return;
3195
3210
  }
@@ -3204,7 +3219,7 @@ function Ms(e, t) {
3204
3219
  }
3205
3220
  t.push({
3206
3221
  code: "request-body-limit-raised",
3207
- message: `This route raises the inherited request body limit to ${n}. ${ft(r)} Reason: ${r.reason}`,
3222
+ message: `This route raises the inherited request body limit to ${n}. ${ht(r)} Reason: ${r.reason}`,
3208
3223
  origin: r.origin ?? "application",
3209
3224
  severity: "info",
3210
3225
  source: r.source
@@ -3242,7 +3257,7 @@ function Fs(e, t = {}) {
3242
3257
  ];
3243
3258
  return (t.secure ?? !0) && n.push("Secure"), n.join("; ");
3244
3259
  }
3245
- function _i(e = {}) {
3260
+ function Gi(e = {}) {
3246
3261
  const t = Hs();
3247
3262
  return {
3248
3263
  cookie: Fs(t, e),
@@ -3256,11 +3271,11 @@ async function Ws(e, t) {
3256
3271
  const n = t.headers.get("cookie");
3257
3272
  if (r === void 0 && !n?.trim())
3258
3273
  return null;
3259
- const o = Vs(r ?? !0), a = Bs(n).get(o.cookie), i = t.headers.get(o.header);
3260
- if (!!(a && i && Ot(a, i)))
3274
+ const o = Vs(r ?? !0), i = Bs(n).get(o.cookie), a = t.headers.get(o.header);
3275
+ if (!!(i && a && Ot(i, a)))
3261
3276
  return null;
3262
3277
  const u = o.field ? await qs(t.clone(), o.field) : null;
3263
- return !(a && u && Ot(a, u)) ? new Response("Invalid CSRF token.", {
3278
+ return !(i && u && Ot(i, u)) ? new Response("Invalid CSRF token.", {
3264
3279
  status: 403
3265
3280
  }) : null;
3266
3281
  }
@@ -3312,7 +3327,7 @@ function Ot(e, t) {
3312
3327
  r |= e.charCodeAt(o) ^ t.charCodeAt(o);
3313
3328
  return r === 0;
3314
3329
  }
3315
- const Me = "Sec-Fetch-Dest", Gs = "Sec-Fetch-Mode", Js = "Sec-Fetch-Site", Ks = /* @__PURE__ */ new Set(["embed", "object"]), Ys = /* @__PURE__ */ new Set(["GET", "HEAD"]), Nt = {
3330
+ const Ue = "Sec-Fetch-Dest", Gs = "Sec-Fetch-Mode", Js = "Sec-Fetch-Site", Ks = /* @__PURE__ */ new Set(["embed", "object"]), Ys = /* @__PURE__ */ new Set(["GET", "HEAD"]), Nt = {
3316
3331
  allowCrossSite: !1,
3317
3332
  allowNavigation: !0,
3318
3333
  allowSameSite: !1
@@ -3333,12 +3348,12 @@ function Zs(e, t, r = t.method) {
3333
3348
  return { allowed: !0, reason: "same-site-trusted", vary: o };
3334
3349
  if (n.allowCrossSite)
3335
3350
  return { allowed: !0, reason: "cross-site-exempt", vary: o };
3336
- const a = e === !0 ? void 0 : e.allowedDestinations;
3337
- if (a?.length && (o.push(Me), a.includes(t.headers.get("sec-fetch-dest") ?? "")))
3351
+ const i = e === !0 ? void 0 : e.allowedDestinations;
3352
+ if (i?.length && (o.push(Ue), i.includes(t.headers.get("sec-fetch-dest") ?? "")))
3338
3353
  return { allowed: !0, reason: "destination-exempt", vary: o };
3339
3354
  if (n.allowNavigation && Ys.has(r.toUpperCase()) && (o.push(Gs), t.headers.get("sec-fetch-mode") === "navigate")) {
3340
- const i = t.headers.get("sec-fetch-dest") ?? "";
3341
- if (o.includes(Me) || o.push(Me), !Ks.has(i))
3355
+ const a = t.headers.get("sec-fetch-dest") ?? "";
3356
+ if (o.includes(Ue) || o.push(Ue), !Ks.has(a))
3342
3357
  return { allowed: !0, reason: "top-level-navigation", vary: o };
3343
3358
  }
3344
3359
  return {
@@ -3379,14 +3394,14 @@ class Rr extends Error {
3379
3394
  super(aa(t)), this.name = "EnvValidationError", this.issues = t;
3380
3395
  }
3381
3396
  }
3382
- function Gi(e) {
3397
+ function Ji(e) {
3383
3398
  return e;
3384
3399
  }
3385
- function Ji(e, t) {
3400
+ function Ki(e, t) {
3386
3401
  const r = [], n = {};
3387
3402
  for (const o of Object.keys(e)) {
3388
- const s = e[o], a = t[String(o)];
3389
- if (a === void 0 || a === "") {
3403
+ const s = e[o], i = t[String(o)];
3404
+ if (i === void 0 || i === "") {
3390
3405
  if (s.optional) {
3391
3406
  n[o] = void 0;
3392
3407
  continue;
@@ -3399,12 +3414,12 @@ function Ji(e, t) {
3399
3414
  continue;
3400
3415
  }
3401
3416
  try {
3402
- n[o] = s.parse(String(o), a);
3403
- } catch (i) {
3417
+ n[o] = s.parse(String(o), i);
3418
+ } catch (a) {
3404
3419
  r.push({
3405
3420
  code: "invalid",
3406
3421
  key: String(o),
3407
- message: i instanceof Error ? i.message : `Environment variable ${String(o)} is invalid.`
3422
+ message: a instanceof Error ? a.message : `Environment variable ${String(o)} is invalid.`
3408
3423
  });
3409
3424
  }
3410
3425
  }
@@ -3488,22 +3503,22 @@ const N = {
3488
3503
  url: sa
3489
3504
  };
3490
3505
  function q(e, t, r, n = "string", o = {}) {
3491
- const s = { ...e, ...o }, { client: a = !1, deferred: i = !1, optional: c = !1, ...u } = s;
3492
- if (a && t)
3506
+ const s = { ...e, ...o }, { client: i = !1, deferred: a = !1, optional: c = !1, ...u } = s;
3507
+ if (i && t)
3493
3508
  throw new Error(
3494
3509
  "A secret environment variable cannot reach client code. Declare a separate variable for the browser."
3495
3510
  );
3496
- if (c && i)
3511
+ if (c && a)
3497
3512
  throw new Error(
3498
3513
  "An environment variable cannot combine optional with deferred. Declare one of the two options."
3499
3514
  );
3500
- if (a && i)
3515
+ if (i && a)
3501
3516
  throw new Error(
3502
3517
  "A client environment variable cannot be deferred. The build validates the value of a client variable."
3503
3518
  );
3504
3519
  return {
3505
- client: a,
3506
- deferred: i,
3520
+ client: i,
3521
+ deferred: a,
3507
3522
  kind: n,
3508
3523
  optional: c,
3509
3524
  options: u,
@@ -3521,20 +3536,20 @@ function Tr(e, t, r) {
3521
3536
  function aa(e) {
3522
3537
  return e.length === 1 ? e[0].message : `Environment validation failed with ${e.length} issues.`;
3523
3538
  }
3524
- const Mt = Symbol.for("demiurge.environmentState"), jt = Symbol.for("demiurge.deferredEnvironmentState"), be = globalThis, B = ia(), U = ca();
3539
+ const Mt = Symbol.for("demiurge.environmentState"), jt = Symbol.for("demiurge.deferredEnvironmentState"), Ee = globalThis, B = ia(), U = ca();
3525
3540
  function ia() {
3526
- const e = be[Mt];
3541
+ const e = Ee[Mt];
3527
3542
  if (e instanceof Map) return e;
3528
3543
  const t = /* @__PURE__ */ new Map();
3529
- return be[Mt] = t, t;
3544
+ return Ee[Mt] = t, t;
3530
3545
  }
3531
3546
  function ca() {
3532
- const e = be[jt];
3547
+ const e = Ee[jt];
3533
3548
  if (e instanceof Map) return e;
3534
3549
  const t = /* @__PURE__ */ new Map();
3535
- return be[jt] = t, t;
3550
+ return Ee[jt] = t, t;
3536
3551
  }
3537
- function Ki(e) {
3552
+ function Yi(e) {
3538
3553
  return Object.fromEntries(
3539
3554
  Object.entries(e).map(([t, r]) => [t, {
3540
3555
  client: r.client,
@@ -3554,38 +3569,38 @@ function ua(e) {
3554
3569
  ])
3555
3570
  );
3556
3571
  }
3557
- function Yi(e, t = {}) {
3572
+ function Zi(e, t = {}) {
3558
3573
  const r = fa(e) ? e : ua(e), n = t.source ?? ha(), o = [], s = {};
3559
- for (const [a, i] of Object.entries(r)) {
3560
- const c = n[a];
3561
- if (i.deferred) {
3562
- U.set(a, { rawValue: c, variable: i });
3574
+ for (const [i, a] of Object.entries(r)) {
3575
+ const c = n[i];
3576
+ if (a.deferred) {
3577
+ U.set(i, { rawValue: c, variable: a });
3563
3578
  continue;
3564
3579
  }
3565
3580
  if (c === void 0 || c === "") {
3566
- if (s[a] = void 0, i.optional) continue;
3581
+ if (s[i] = void 0, a.optional) continue;
3567
3582
  o.push({
3568
3583
  code: "missing",
3569
- key: a,
3570
- message: `Environment variable ${a} is required.`
3584
+ key: i,
3585
+ message: `Environment variable ${i} is required.`
3571
3586
  });
3572
3587
  continue;
3573
3588
  }
3574
3589
  try {
3575
- s[a] = i.parse(a, c);
3590
+ s[i] = a.parse(i, c);
3576
3591
  } catch (u) {
3577
- s[a] = void 0, o.push({
3592
+ s[i] = void 0, o.push({
3578
3593
  code: "invalid",
3579
- key: a,
3580
- message: u instanceof Error ? u.message : `Environment variable ${a} is invalid.`
3594
+ key: i,
3595
+ message: u instanceof Error ? u.message : `Environment variable ${i} is invalid.`
3581
3596
  });
3582
3597
  }
3583
3598
  }
3584
3599
  if (o.length) throw new Rr(o);
3585
- for (const [a, i] of Object.entries(s)) B.set(a, i);
3600
+ for (const [i, a] of Object.entries(s)) B.set(i, a);
3586
3601
  return { values: s };
3587
3602
  }
3588
- function Zi(e) {
3603
+ function Qi(e) {
3589
3604
  const t = {};
3590
3605
  for (const r of Object.keys(e)) {
3591
3606
  if (U.has(r)) {
@@ -3600,7 +3615,7 @@ function Zi(e) {
3600
3615
  }
3601
3616
  return t;
3602
3617
  }
3603
- function Qi() {
3618
+ function Xi() {
3604
3619
  B.clear(), U.clear();
3605
3620
  }
3606
3621
  function la(e) {
@@ -3668,17 +3683,17 @@ function $r(e = {}) {
3668
3683
  const r = /* @__PURE__ */ new Map();
3669
3684
  let n = Number.POSITIVE_INFINITY;
3670
3685
  return {
3671
- increment(o, s, a) {
3672
- a >= n && (ga(r, a), n = wa(r));
3673
- const i = r.get(o);
3674
- if (!i || i.resetAt <= a) {
3686
+ increment(o, s, i) {
3687
+ i >= n && (ga(r, i), n = wa(r));
3688
+ const a = r.get(o);
3689
+ if (!a || a.resetAt <= i) {
3675
3690
  const c = {
3676
3691
  count: 1,
3677
- resetAt: a + s
3692
+ resetAt: i + s
3678
3693
  };
3679
- return !i && r.size >= t && ya(r), r.set(o, c), n = Math.min(n, c.resetAt), { count: c.count, resetAt: c.resetAt };
3694
+ return !a && r.size >= t && ya(r), r.set(o, c), n = Math.min(n, c.resetAt), { count: c.count, resetAt: c.resetAt };
3680
3695
  }
3681
- return i.count += 1, { count: i.count, resetAt: i.resetAt };
3696
+ return a.count += 1, { count: a.count, resetAt: a.resetAt };
3682
3697
  }
3683
3698
  };
3684
3699
  }
@@ -3699,14 +3714,14 @@ function ya(e) {
3699
3714
  async function va(e, t, r, n = Date.now()) {
3700
3715
  if (!e)
3701
3716
  return null;
3702
- ht(e);
3703
- const o = xr(e.window), s = Sa(e, t), a = await r.increment(s, o, n), i = Math.max(0, e.limit - a.count), c = new Headers({
3704
- "retry-after": String(Math.ceil(Math.max(0, a.resetAt - n) / 1e3)),
3717
+ mt(e);
3718
+ const o = xr(e.window), s = Sa(e, t), i = await r.increment(s, o, n), a = Math.max(0, e.limit - i.count), c = new Headers({
3719
+ "retry-after": String(Math.ceil(Math.max(0, i.resetAt - n) / 1e3)),
3705
3720
  "x-ratelimit-limit": String(e.limit),
3706
- "x-ratelimit-remaining": String(i),
3707
- "x-ratelimit-reset": String(Math.ceil(a.resetAt / 1e3))
3721
+ "x-ratelimit-remaining": String(a),
3722
+ "x-ratelimit-reset": String(Math.ceil(i.resetAt / 1e3))
3708
3723
  });
3709
- return a.count > e.limit ? new Response("Rate limit exceeded.", {
3724
+ return i.count > e.limit ? new Response("Rate limit exceeded.", {
3710
3725
  headers: c,
3711
3726
  status: 429
3712
3727
  }) : null;
@@ -3725,7 +3740,7 @@ function xr(e) {
3725
3740
  throw new Error("Demiurge rate limit window is too large.");
3726
3741
  return o;
3727
3742
  }
3728
- function ht(e) {
3743
+ function mt(e) {
3729
3744
  if (!Number.isSafeInteger(e.limit) || e.limit <= 0)
3730
3745
  throw new Error("Demiurge rate limit limit must be a positive integer.");
3731
3746
  xr(e.window);
@@ -3756,8 +3771,8 @@ function $a(e, t = {}) {
3756
3771
  for (const [n, o] of Object.entries(e)) {
3757
3772
  Aa(n, o);
3758
3773
  for (const s of Ta) {
3759
- const a = o[s];
3760
- !a || a.kind === "page" || ka(n, s, a, o);
3774
+ const i = o[s];
3775
+ !i || i.kind === "page" || ka(n, s, i, o);
3761
3776
  }
3762
3777
  }
3763
3778
  const r = Kt(
@@ -3778,14 +3793,14 @@ function xa(e) {
3778
3793
  function Aa(e, t) {
3779
3794
  const r = t.policy?.security?.rateLimit;
3780
3795
  r && ne(e, "policy", "rate limit", () => {
3781
- ht(r);
3796
+ mt(r);
3782
3797
  });
3783
3798
  }
3784
3799
  function ka(e, t, r, n) {
3785
3800
  r.cors && ne(e, t, "CORS", () => {
3786
- lt(r.cors), La(e, t, r.cors.methods, n);
3801
+ dt(r.cors), La(e, t, r.cors.methods, n);
3787
3802
  }), r.security?.rateLimit && ne(e, t, "rate limit", () => {
3788
- ht(r.security.rateLimit);
3803
+ mt(r.security.rateLimit);
3789
3804
  });
3790
3805
  }
3791
3806
  function La(e, t, r, n) {
@@ -3806,23 +3821,23 @@ function Pa(e) {
3806
3821
  }
3807
3822
  function Da(e, t, r) {
3808
3823
  for (const o of e.routes) {
3809
- const s = t[o.file], a = s?.GET;
3810
- if (!a || a.kind !== "page")
3824
+ const s = t[o.file], i = s?.GET;
3825
+ if (!i || i.kind !== "page")
3811
3826
  continue;
3812
- const i = ye(
3827
+ const a = ve(
3813
3828
  ...e.policies.filter(
3814
3829
  (c) => C(c.fileSegments, o.fileSegments)
3815
3830
  ).map((c) => t[c.file]?.policy),
3816
3831
  s.policy
3817
3832
  );
3818
- Ut(o.file, "GET", i, r), Ia(
3833
+ Ut(o.file, "GET", a, r), Ia(
3819
3834
  o.file,
3820
- a.render.mode,
3821
- i.document
3835
+ i.render.mode,
3836
+ a.document
3822
3837
  ), Oa(
3823
3838
  o.file,
3824
3839
  "GET",
3825
- i,
3840
+ a,
3826
3841
  [
3827
3842
  ...e.layouts.filter(
3828
3843
  (c) => C(c.fileSegments, o.fileSegments)
@@ -3837,10 +3852,10 @@ function Da(e, t, r) {
3837
3852
  ...e.fallbacks.notFound
3838
3853
  ];
3839
3854
  for (const o of n) {
3840
- const s = ye(
3855
+ const s = ve(
3841
3856
  ...e.policies.filter(
3842
- (a) => C(a.fileSegments, o.fileSegments)
3843
- ).map((a) => t[a.file]?.policy),
3857
+ (i) => C(i.fileSegments, o.fileSegments)
3858
+ ).map((i) => t[i.file]?.policy),
3844
3859
  t[o.file]?.policy
3845
3860
  );
3846
3861
  Ut(
@@ -3857,19 +3872,19 @@ function Oa(e, t, r, n) {
3857
3872
  );
3858
3873
  if (o.length === 0 || !r.document)
3859
3874
  return;
3860
- const s = "startup-verification-nonce", i = ws({
3875
+ const s = "startup-verification-nonce", a = ws({
3861
3876
  document: {
3862
3877
  headers: { nonce: s },
3863
3878
  policy: r.document,
3864
3879
  scripts: o.map((d) => ({
3865
3880
  ...d,
3866
- nonce: $e(r.document) ? s : d.nonce
3881
+ nonce: xe(r.document) ? s : d.nonce
3867
3882
  }))
3868
3883
  }
3869
3884
  }).findings.find(
3870
3885
  (d) => d.code === "csp-script-src-blocked"
3871
3886
  );
3872
- if (!i) {
3887
+ if (!a) {
3873
3888
  Ma(
3874
3889
  e,
3875
3890
  t,
@@ -3879,7 +3894,7 @@ function Oa(e, t, r, n) {
3879
3894
  return;
3880
3895
  }
3881
3896
  const c = o.find(
3882
- (d) => i.message.includes(d.src)
3897
+ (d) => a.message.includes(d.src)
3883
3898
  ), l = (se(r.document, { nonce: s }).get("content-security-policy") ?? "").split("; ").find(
3884
3899
  (d) => d.startsWith("script-src ")
3885
3900
  ) ?? "default-src (script-src fallback)";
@@ -3894,8 +3909,8 @@ const Na = [
3894
3909
  function Ma(e, t, r, n) {
3895
3910
  if (r)
3896
3911
  for (const o of n)
3897
- for (const { directive: s, name: a, need: i } of Na) {
3898
- const c = o.needs?.[i] ?? [];
3912
+ for (const { directive: s, name: i, need: a } of Na) {
3913
+ const c = o.needs?.[a] ?? [];
3899
3914
  if (c.length === 0)
3900
3915
  continue;
3901
3916
  const u = re(r[s]) ?? re(r.defaultSrc);
@@ -3903,7 +3918,7 @@ function Ma(e, t, r, n) {
3903
3918
  for (const l of c)
3904
3919
  if (!(Array.isArray(u) && ja(u, l)))
3905
3920
  throw new Error(
3906
- `Route ${JSON.stringify(e)} export ${t} declares script ${JSON.stringify(o.src)} that needs ${a} ${l}, which the effective policy does not allow. Add ${l} to security.needs.${i} or to csp.${s} for this route.`
3921
+ `Route ${JSON.stringify(e)} export ${t} declares script ${JSON.stringify(o.src)} that needs ${i} ${l}, which the effective policy does not allow. Add ${l} to security.needs.${a} or to csp.${s} for this route.`
3907
3922
  );
3908
3923
  }
3909
3924
  }
@@ -3941,7 +3956,7 @@ function Ut(e, t, r, n) {
3941
3956
  se(r.document ?? {}, {
3942
3957
  nonce: "startup-verification-nonce"
3943
3958
  });
3944
- }), !(!n || !$e(r.document)) && ne(e, t, "effective CSP", () => {
3959
+ }), !(!n || !xe(r.document)) && ne(e, t, "effective CSP", () => {
3945
3960
  Hr(n, ["nonceInjection"]);
3946
3961
  });
3947
3962
  }
@@ -4018,20 +4033,20 @@ function qa(e) {
4018
4033
  title: "Not Found"
4019
4034
  });
4020
4035
  }
4021
- async function Ee(e, t, r = {}) {
4036
+ async function Re(e, t, r = {}) {
4022
4037
  const n = new URL(t.url), o = r.pathname ?? n.pathname;
4023
4038
  if (!F(t) && !ir(t))
4024
4039
  return qa(n);
4025
- const s = await We(e, o, {
4040
+ const s = await Be(e, o, {
4026
4041
  locale: r.locale,
4027
4042
  onLayoutError: (l) => r.onError?.(l, "page")
4028
- }), a = await _a(e, o), i = r.nonce ?? ($e(a) ? mr() : void 0), c = se(a ?? {}, {
4029
- nonce: i,
4043
+ }), i = await _a(e, o), a = r.nonce ?? (xe(i) ? mr() : void 0), c = se(i ?? {}, {
4044
+ nonce: a,
4030
4045
  request: t
4031
4046
  });
4032
4047
  if (F(t))
4033
- return rt(void 0, {
4034
- document: Je({
4048
+ return nt(void 0, {
4049
+ document: Ke({
4035
4050
  dir: r.dir,
4036
4051
  lang: r.lang,
4037
4052
  metadata: s.metadata,
@@ -4039,10 +4054,10 @@ async function Ee(e, t, r = {}) {
4039
4054
  }),
4040
4055
  locale: r.locale,
4041
4056
  headers: c,
4042
- kind: Be,
4057
+ kind: Ve,
4043
4058
  status: 404
4044
4059
  });
4045
- const u = Ga(s, { ...r, nonce: i });
4060
+ const u = Ga(s, { ...r, nonce: a });
4046
4061
  return c.set("content-type", "text/html; charset=utf-8"), new Response(
4047
4062
  await r.transformDocument?.(u) ?? u,
4048
4063
  {
@@ -4055,31 +4070,31 @@ async function _a(e, t) {
4055
4070
  const r = await Promise.all(
4056
4071
  hn(e, t).map((n) => n.load())
4057
4072
  );
4058
- return ye(...r.map((n) => n.policy)).document;
4073
+ return ve(...r.map((n) => n.policy)).document;
4059
4074
  }
4060
4075
  function Ga(e, t = {}) {
4061
4076
  const r = e.notFound ?? Tt;
4062
4077
  try {
4063
- return je(e, r, e.layouts, t);
4078
+ return Ie(e, r, e.layouts, t);
4064
4079
  } catch (n) {
4065
4080
  t.onError?.(n, "page");
4066
4081
  }
4067
4082
  try {
4068
- return je(e, r, [], t);
4083
+ return Ie(e, r, [], t);
4069
4084
  } catch (n) {
4070
4085
  t.onError?.(n, "page");
4071
4086
  }
4072
- return je(e, Tt, [], t);
4087
+ return Ie(e, Tt, [], t);
4073
4088
  }
4074
- function je(e, t, r, n) {
4089
+ function Ie(e, t, r, n) {
4075
4090
  const o = r.reduceRight(
4076
- (a, i) => Ie(i, {
4077
- children: a,
4091
+ (i, a) => He(a, {
4092
+ children: i,
4078
4093
  locale: e.locale,
4079
4094
  path: {},
4080
4095
  pathname: e.pathname
4081
4096
  }),
4082
- Ie(t, { locale: e.locale, pathname: e.pathname })
4097
+ He(t, { locale: e.locale, pathname: e.pathname })
4083
4098
  ), s = Ft({
4084
4099
  dev: n.dev,
4085
4100
  nonce: n.nonce
@@ -4110,65 +4125,65 @@ const kr = [
4110
4125
  "OPTIONS",
4111
4126
  "HEAD"
4112
4127
  ], Lr = $r();
4113
- function Xi(e) {
4128
+ function ec(e) {
4114
4129
  e.routeModules && $a(e.routeModules, { adapter: e.adapter });
4115
4130
  const t = Kt(e.routes), r = e.locales ? Ln(e.locales) : void 0, n = e.rateLimitStore ?? $r();
4116
4131
  return e.cacheStore && _t(e.cacheStore.namespace), async function(s) {
4117
- let a = e.ssr;
4132
+ let i = e.ssr;
4118
4133
  if (r) {
4119
- const i = Cn(s, r);
4120
- if (i.unsupported)
4121
- return await Ee(t, s, {
4134
+ const a = Cn(s, r);
4135
+ if (a.unsupported)
4136
+ return await Re(t, s, {
4122
4137
  ...e.ssr,
4123
- dir: Pe(i.locale, r),
4124
- lang: i.locale,
4125
- locale: i.locale,
4126
- pathname: i.pathname
4138
+ dir: Oe(a.locale, r),
4139
+ lang: a.locale,
4140
+ locale: a.locale,
4141
+ pathname: a.pathname
4127
4142
  });
4128
- if (i.redirect) {
4143
+ if (a.redirect) {
4129
4144
  if (s.method !== "GET" && s.method !== "HEAD")
4130
4145
  return te({ status: 400, title: "The locale URL is not canonical." });
4131
- const u = i.source === "cookie" || i.source === "accept-language";
4132
- if (u && !await Ja(t, i.pathname))
4133
- return await Ue(t, s, {
4146
+ const u = a.source === "cookie" || a.source === "accept-language";
4147
+ if (u && !await Ja(t, a.pathname))
4148
+ return await ze(t, s, {
4134
4149
  cacheStore: e.cacheStore,
4135
4150
  onError: e.onError,
4136
4151
  rateLimitStore: n,
4137
4152
  renderPage: e.renderPage,
4138
- routePathname: i.pathname,
4153
+ routePathname: a.pathname,
4139
4154
  ssr: {
4140
4155
  ...e.ssr,
4141
- dir: Pe(r.defaultLocale, r),
4156
+ dir: Oe(r.defaultLocale, r),
4142
4157
  lang: r.defaultLocale,
4143
4158
  locale: r.defaultLocale
4144
4159
  }
4145
4160
  });
4146
- const l = new Headers({ location: i.redirect.href });
4161
+ const l = new Headers({ location: a.redirect.href });
4147
4162
  return u && (l.set("cache-control", "private, no-store"), l.set("vary", [r.cookie ? "Cookie" : void 0, "Accept-Language"].filter(Boolean).join(", "))), new Response(null, { headers: l, status: u ? 307 : 308 });
4148
4163
  }
4149
- a = {
4164
+ i = {
4150
4165
  ...e.ssr,
4151
- dir: Pe(i.locale, r),
4152
- lang: i.locale,
4153
- locale: i.locale
4166
+ dir: Oe(a.locale, r),
4167
+ lang: a.locale,
4168
+ locale: a.locale
4154
4169
  };
4155
- const c = await Ue(t, s, {
4170
+ const c = await ze(t, s, {
4156
4171
  cacheStore: e.cacheStore,
4157
4172
  locales: r,
4158
4173
  onError: e.onError,
4159
4174
  rateLimitStore: n,
4160
4175
  renderPage: e.renderPage,
4161
- routePathname: i.pathname,
4162
- ssr: a
4176
+ routePathname: a.pathname,
4177
+ ssr: i
4163
4178
  });
4164
- return Ka(c, s, i.locale, r), c;
4179
+ return Ka(c, s, a.locale, r), c;
4165
4180
  }
4166
- return await Ue(t, s, {
4181
+ return await ze(t, s, {
4167
4182
  cacheStore: e.cacheStore,
4168
4183
  onError: e.onError,
4169
4184
  rateLimitStore: n,
4170
4185
  renderPage: e.renderPage,
4171
- ssr: a
4186
+ ssr: i
4172
4187
  });
4173
4188
  };
4174
4189
  }
@@ -4185,31 +4200,31 @@ function Ka(e, t, r, n) {
4185
4200
  er(o, r, n, s.href)
4186
4201
  );
4187
4202
  }
4188
- async function Ue(e, t, r = {
4203
+ async function ze(e, t, r = {
4189
4204
  rateLimitStore: Lr
4190
4205
  }) {
4191
- const n = new URL(t.url), o = r.routePathname ?? n.pathname, s = ri(n, r), a = F(t);
4192
- let i;
4206
+ const n = new URL(t.url), o = r.routePathname ?? n.pathname, s = ri(n, r), i = F(t);
4207
+ let a;
4193
4208
  try {
4194
- i = V(e.routes, o);
4209
+ a = V(e.routes, o);
4195
4210
  } catch (c) {
4196
- if (!(c instanceof tt))
4211
+ if (!(c instanceof rt))
4197
4212
  throw c;
4198
4213
  const u = te({
4199
4214
  instance: `${n.pathname}${n.search}`,
4200
4215
  status: 400,
4201
4216
  title: "Bad Request"
4202
4217
  });
4203
- return a ? ce(u, fe) : u;
4218
+ return i ? ce(u, he) : u;
4204
4219
  }
4205
- if (!i)
4220
+ if (!a)
4206
4221
  try {
4207
- const c = await Ee(
4222
+ const c = await Re(
4208
4223
  e,
4209
4224
  t,
4210
4225
  s
4211
4226
  );
4212
- return a ? ce(c, Be) : c;
4227
+ return i ? ce(c, Ve) : c;
4213
4228
  } catch (c) {
4214
4229
  return s.onError(c, "page"), new Response("Not Found", {
4215
4230
  headers: { "content-type": "text/plain; charset=utf-8" },
@@ -4221,43 +4236,43 @@ async function Ue(e, t, r = {
4221
4236
  e,
4222
4237
  t,
4223
4238
  n,
4224
- i,
4239
+ a,
4225
4240
  o,
4226
4241
  r,
4227
4242
  s
4228
4243
  );
4229
- return a && !c.headers.has(H) ? ce(
4244
+ return i && !c.headers.has(H) ? ce(
4230
4245
  c,
4231
- c.status === 404 ? Be : fe
4246
+ c.status === 404 ? Ve : he
4232
4247
  ) : c;
4233
4248
  } catch (c) {
4234
- const u = await me(
4249
+ const u = await pe(
4235
4250
  e,
4236
4251
  t,
4237
4252
  c,
4238
4253
  "middleware",
4239
4254
  s
4240
4255
  );
4241
- return a ? ce(u, fe) : u;
4256
+ return i ? ce(u, he) : u;
4242
4257
  }
4243
4258
  }
4244
- async function Ya(e, t, r, n, o, s, a) {
4245
- const i = await n.route.load();
4259
+ async function Ya(e, t, r, n, o, s, i) {
4260
+ const a = await n.route.load();
4246
4261
  if (t.method.toUpperCase() === "OPTIONS") {
4247
- const p = rs(i, t);
4262
+ const p = rs(a, t);
4248
4263
  if (p)
4249
4264
  return p;
4250
4265
  }
4251
4266
  const c = ai(t.method);
4252
4267
  if (!c)
4253
- return Ht(i);
4254
- const u = ii(i, c);
4268
+ return Ht(a);
4269
+ const u = ii(a, c);
4255
4270
  if (!u)
4256
- return Ht(i);
4271
+ return Ht(a);
4257
4272
  const l = await oi(
4258
4273
  e,
4259
4274
  n.route,
4260
- i,
4275
+ a,
4261
4276
  u
4262
4277
  ), d = l.security, h = Qs(
4263
4278
  d?.fetchMetadata,
@@ -4304,7 +4319,7 @@ async function Ya(e, t, r, n, o, s, a) {
4304
4319
  )
4305
4320
  );
4306
4321
  t = ds(d?.request, t);
4307
- const O = {}, xe = ti(s.cacheStore, s.ssr?.locale);
4322
+ const O = {}, Ae = ti(s.cacheStore, s.ssr?.locale);
4308
4323
  if (u.kind === "page") {
4309
4324
  const p = {
4310
4325
  locale: s.ssr?.locale,
@@ -4317,7 +4332,7 @@ async function Ya(e, t, r, n, o, s, a) {
4317
4332
  }, Pr = await It(
4318
4333
  e,
4319
4334
  n.route
4320
- ), G = $e(l.document) ? mr() : void 0;
4335
+ ), G = xe(l.document) ? mr() : void 0;
4321
4336
  let b;
4322
4337
  try {
4323
4338
  b = await zt(Pr, p, async () => {
@@ -4330,12 +4345,12 @@ async function Ya(e, t, r, n, o, s, a) {
4330
4345
  o,
4331
4346
  t,
4332
4347
  void 0,
4333
- xe,
4348
+ Ae,
4334
4349
  { locale: s.ssr?.locale, requestContext: O }
4335
4350
  );
4336
4351
  if (y.status !== "ready")
4337
- return await Ee(e, t, {
4338
- ...a,
4352
+ return await Re(e, t, {
4353
+ ...i,
4339
4354
  nonce: G
4340
4355
  });
4341
4356
  if (s.locales && s.ssr?.locale && (y.match.metadata = Za(
@@ -4345,8 +4360,8 @@ async function Ya(e, t, r, n, o, s, a) {
4345
4360
  s.ssr.locale,
4346
4361
  s.locales
4347
4362
  )), F(t))
4348
- return rt(y.match.data, {
4349
- document: Je({
4363
+ return nt(y.match.data, {
4364
+ document: Ke({
4350
4365
  dir: s.ssr?.dir,
4351
4366
  lang: s.ssr?.lang,
4352
4367
  links: y.match.links,
@@ -4373,8 +4388,8 @@ async function Ya(e, t, r, n, o, s, a) {
4373
4388
  signal: t.signal
4374
4389
  });
4375
4390
  } catch (v) {
4376
- return v instanceof Q ? ue() : await me(e, t, v, "page", {
4377
- ...a,
4391
+ return v instanceof Q ? ue() : await pe(e, t, v, "page", {
4392
+ ...i,
4378
4393
  nonce: G
4379
4394
  });
4380
4395
  }
@@ -4413,16 +4428,16 @@ async function Ya(e, t, r, n, o, s, a) {
4413
4428
  try {
4414
4429
  const p = await xt(l.access, _);
4415
4430
  return p || (u.kind === "not-found" && u.body === void 0 ? ni(
4416
- await Ee(e, t, a),
4431
+ await Re(e, t, i),
4417
4432
  u.init
4418
4433
  ) : await or(u, _));
4419
4434
  } catch (p) {
4420
- return p instanceof Q ? ue() : await me(
4435
+ return p instanceof Q ? ue() : await pe(
4421
4436
  e,
4422
4437
  t,
4423
4438
  p,
4424
4439
  "route",
4425
- a
4440
+ i
4426
4441
  );
4427
4442
  }
4428
4443
  });
@@ -4432,32 +4447,32 @@ async function Ya(e, t, r, n, o, s, a) {
4432
4447
  ie = ue();
4433
4448
  }
4434
4449
  try {
4435
- return await Qa(ie, xe, "mutation" in u && u.mutation === !0), f(
4450
+ return await Qa(ie, Ae, "mutation" in u && u.mutation === !0), f(
4436
4451
  si(ie, u, t, c)
4437
4452
  );
4438
4453
  } catch (p) {
4439
4454
  return f(
4440
- await me(
4455
+ await pe(
4441
4456
  e,
4442
4457
  t,
4443
4458
  p,
4444
4459
  "route",
4445
- a
4460
+ i
4446
4461
  )
4447
4462
  );
4448
4463
  }
4449
4464
  }
4450
4465
  function Za(e, t, r, n, o) {
4451
- const s = t.url, a = (c) => new URL(er(r, c, o, s), s).href, i = o.supportedLocales.map((c) => ({
4452
- href: a(c),
4466
+ const s = t.url, i = (c) => new URL(er(r, c, o, s), s).href, a = o.supportedLocales.map((c) => ({
4467
+ href: i(c),
4453
4468
  hrefLang: c
4454
4469
  }));
4455
- return o.xDefault && i.push({
4456
- href: a(o.xDefault),
4470
+ return o.xDefault && a.push({
4471
+ href: i(o.xDefault),
4457
4472
  hrefLang: "x-default"
4458
4473
  }), Wr(e, {
4459
- alternates: i,
4460
- canonical: a(n)
4474
+ alternates: a,
4475
+ canonical: i(n)
4461
4476
  });
4462
4477
  }
4463
4478
  async function Qa(e, t, r) {
@@ -4481,16 +4496,16 @@ function Xa(e) {
4481
4496
  return { keys: t.keys, tags: t.tags };
4482
4497
  }
4483
4498
  function ei(e) {
4484
- return Array.isArray(e) && e.every(Ge);
4499
+ return Array.isArray(e) && e.every(Je);
4485
4500
  }
4486
- function Ge(e) {
4487
- return e === null || typeof e == "string" || typeof e == "boolean" ? !0 : typeof e == "number" ? Number.isFinite(e) : Array.isArray(e) ? e.every(Ge) : oe(e) && Object.values(e).every(Ge);
4501
+ function Je(e) {
4502
+ return e === null || typeof e == "string" || typeof e == "boolean" ? !0 : typeof e == "number" ? Number.isFinite(e) : Array.isArray(e) ? e.every(Je) : oe(e) && Object.values(e).every(Je);
4488
4503
  }
4489
4504
  function le() {
4490
4505
  return new Error("Demiurge received invalid internal mutation invalidation metadata.");
4491
4506
  }
4492
4507
  function ti(e, t) {
4493
- const r = e ? qt(e) : Ke();
4508
+ const r = e ? qt(e) : Ye();
4494
4509
  if (!t) return r;
4495
4510
  const n = (s) => ({ id: `demiurge:locale:${t}:${s}` }), o = (s) => [
4496
4511
  { "demiurge:locale": t },
@@ -4501,12 +4516,12 @@ function ti(e, t) {
4501
4516
  s.locale === "neutral" ? s : {
4502
4517
  ...s,
4503
4518
  key: o(s.key),
4504
- tags: s.tags?.map((a) => n(a.id))
4519
+ tags: s.tags?.map((i) => n(i.id))
4505
4520
  }
4506
4521
  ),
4507
4522
  invalidateKey: (s) => r.invalidateKey(o(s)),
4508
4523
  invalidateTags: (s) => r.invalidateTags(
4509
- s.map((a) => n(a.id))
4524
+ s.map((i) => n(i.id))
4510
4525
  )
4511
4526
  };
4512
4527
  }
@@ -4537,14 +4552,14 @@ function ni(e, t) {
4537
4552
  }
4538
4553
  async function oi(e, t, r, n) {
4539
4554
  const o = e.policies.filter(
4540
- (i) => C(i.fileSegments, t.fileSegments)
4555
+ (a) => C(a.fileSegments, t.fileSegments)
4541
4556
  ), s = await Promise.all(
4542
- o.map((i) => i.load())
4557
+ o.map((a) => a.load())
4543
4558
  );
4544
4559
  return {
4545
- ...ye(
4560
+ ...ve(
4546
4561
  ...s.map(
4547
- (i, c) => Co(i.policy, o[c]?.file)
4562
+ (a, c) => Co(a.policy, o[c]?.file)
4548
4563
  ),
4549
4564
  r.policy,
4550
4565
  {
@@ -4552,8 +4567,8 @@ async function oi(e, t, r, n) {
4552
4567
  }
4553
4568
  ),
4554
4569
  access: cr([
4555
- ...s.map((i, c) => ({
4556
- policy: i.policy?.access,
4570
+ ...s.map((a, c) => ({
4571
+ policy: a.policy?.access,
4557
4572
  source: o[c]?.file
4558
4573
  })),
4559
4574
  { policy: r.policy?.access }
@@ -4575,8 +4590,8 @@ async function zt(e, t, r) {
4575
4590
  if (s <= n)
4576
4591
  throw new Error("Demiurge route middleware next() called multiple times.");
4577
4592
  n = s;
4578
- const a = e[s];
4579
- return a ? await a(t, () => o(s + 1)) : await r();
4593
+ const i = e[s];
4594
+ return i ? await i(t, () => o(s + 1)) : await r();
4580
4595
  }
4581
4596
  return await o(0);
4582
4597
  }
@@ -4616,39 +4631,39 @@ function ci(e) {
4616
4631
  export {
4617
4632
  En as $,
4618
4633
  C as A,
4619
- Re as B,
4634
+ Te as B,
4620
4635
  V as C,
4621
- dt as D,
4622
- $e as E,
4636
+ ft as D,
4637
+ xe as E,
4623
4638
  mr as F,
4624
4639
  ws as G,
4625
- Ke as H,
4626
- ze as I,
4627
- gt as J,
4628
- Ki as K,
4640
+ Ye as H,
4641
+ Fe as I,
4642
+ wt as J,
4643
+ Yi as K,
4629
4644
  Kt as L,
4630
- tt as M,
4631
- Yi as N,
4645
+ rt as M,
4646
+ Zi as N,
4632
4647
  z as O,
4633
4648
  Bs as P,
4634
4649
  ds as Q,
4635
4650
  Q as R,
4636
- ki as S,
4651
+ Li as S,
4637
4652
  Tn as T,
4638
4653
  Qn as U,
4639
- Ve as V,
4654
+ qe as V,
4640
4655
  Zn as W,
4641
- Li as X,
4642
- Ti as Y,
4656
+ Ci as X,
4657
+ $i as Y,
4643
4658
  ln as Z,
4644
4659
  H as _,
4645
4660
  x as a,
4646
4661
  _t as a$,
4647
4662
  Rn as a0,
4648
- Be as a1,
4649
- fe as a2,
4663
+ Ve as a1,
4664
+ he as a2,
4650
4665
  so as a3,
4651
- Fi as a4,
4666
+ Wi as a4,
4652
4667
  Tt as a5,
4653
4668
  j as a6,
4654
4669
  I as a7,
@@ -4659,24 +4674,24 @@ export {
4659
4674
  N as aC,
4660
4675
  ur as aD,
4661
4676
  lr as aE,
4662
- Oi as aF,
4663
- vi as aG,
4664
- _i as aH,
4665
- Ci as aI,
4666
- Pi as aJ,
4677
+ Ni as aF,
4678
+ Si as aG,
4679
+ Gi as aH,
4680
+ Pi as aI,
4681
+ Di as aJ,
4667
4682
  Br as aK,
4668
4683
  To as aL,
4669
- ye as aM,
4684
+ ve as aM,
4670
4685
  jo as aN,
4671
- pi as aO,
4672
- zi as aP,
4673
- Hi as aQ,
4674
- Mi as aR,
4686
+ gi as aO,
4687
+ Hi as aP,
4688
+ Fi as aQ,
4689
+ ji as aR,
4675
4690
  xr as aS,
4676
4691
  $o as aT,
4677
- wi as aU,
4678
- Zi as aV,
4679
- Ni as aW,
4692
+ yi as aU,
4693
+ Qi as aV,
4694
+ Mi as aW,
4680
4695
  Lo as aX,
4681
4696
  T as aY,
4682
4697
  cr as aZ,
@@ -4688,64 +4703,64 @@ export {
4688
4703
  Co as ae,
4689
4704
  Ss as af,
4690
4705
  xt as ag,
4691
- yi as ah,
4706
+ vi as ah,
4692
4707
  Zs as ai,
4693
4708
  qt as aj,
4694
4709
  vr as ak,
4695
4710
  Fs as al,
4696
4711
  Hs as am,
4697
- Ei as an,
4712
+ Ri as an,
4698
4713
  Zr as ao,
4699
4714
  At as ap,
4700
- Wi as aq,
4701
- Gi as ar,
4702
- mi as as,
4703
- Vi as at,
4704
- Bi as au,
4705
- bi as av,
4715
+ Bi as aq,
4716
+ Ji as ar,
4717
+ pi as as,
4718
+ qi as at,
4719
+ Vi as au,
4720
+ Ei as av,
4706
4721
  ua as aw,
4707
4722
  fs as ax,
4708
4723
  Ws as ay,
4709
4724
  Qs as az,
4710
4725
  $a as b,
4711
- Ii as b0,
4712
- Ui as b1,
4713
- ji as b2,
4714
- gi as b3,
4715
- Si as b4,
4716
- Di as b5,
4726
+ zi as b0,
4727
+ Ii as b1,
4728
+ Ui as b2,
4729
+ wi as b3,
4730
+ bi as b4,
4731
+ Oi as b5,
4717
4732
  or as b6,
4718
- Qi as b7,
4719
- Ji as b8,
4720
- xi as b9,
4721
- Ai as ba,
4722
- $i as bb,
4733
+ Xi as b7,
4734
+ Ki as b8,
4735
+ Ai as b9,
4736
+ ki as ba,
4737
+ xi as bb,
4723
4738
  pn as bc,
4724
4739
  bn as bd,
4725
- Te as be,
4726
- Xi as c,
4727
- Ri as d,
4740
+ $e as be,
4741
+ ec as c,
4742
+ Ti as d,
4728
4743
  $r as e,
4729
4744
  Ln as f,
4730
- Ee as g,
4731
- Ue as h,
4745
+ Re as g,
4746
+ ze as h,
4732
4747
  oe as i,
4733
- Pe as j,
4734
- qi as k,
4748
+ Oe as j,
4749
+ _i as k,
4735
4750
  er as l,
4736
4751
  Mo as m,
4737
4752
  se as n,
4738
- ht as o,
4753
+ mt as o,
4739
4754
  S as p,
4740
4755
  dr as q,
4741
4756
  Cn as r,
4742
- Se as s,
4757
+ be as s,
4743
4758
  Xt as t,
4744
- ct as u,
4745
- lt as v,
4759
+ ut as u,
4760
+ dt as v,
4746
4761
  J as w,
4747
4762
  P as x,
4748
4763
  oi as y,
4749
4764
  Yt as z
4750
4765
  };
4751
- //# sourceMappingURL=testing-CUwGj2ie.js.map
4766
+ //# sourceMappingURL=testing-BEW1nchS.js.map