@demiurgejs/core 0.2.0-beta.2 → 0.2.0-beta.3

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 (106) hide show
  1. package/dist/adapter/testing.js.map +1 -1
  2. package/dist/browser/file-router.d.ts.map +1 -1
  3. package/dist/chunks/{document-shell-D1xo6cEA.js → document-shell-WoM8yZlR.js} +2 -2
  4. package/dist/chunks/{document-shell-D1xo6cEA.js.map → document-shell-WoM8yZlR.js.map} +1 -1
  5. package/dist/chunks/{image-codec-BGTx_t5K.js → image-codec-Di53WpcH.js} +2 -2
  6. package/dist/chunks/{image-codec-BGTx_t5K.js.map → image-codec-Di53WpcH.js.map} +1 -1
  7. package/dist/chunks/{images-B9MqcjSA.js → images-Edar3eU1.js} +2 -2
  8. package/dist/chunks/{images-B9MqcjSA.js.map → images-Edar3eU1.js.map} +1 -1
  9. package/dist/chunks/{request-metadata-D5NrT8ks.js → request-metadata-DaIYq4Ea.js} +214 -179
  10. package/dist/chunks/request-metadata-DaIYq4Ea.js.map +1 -0
  11. package/dist/chunks/{streaming-BQ1bykDo.js → streaming-D0fGAuiO.js} +5 -5
  12. package/dist/chunks/streaming-D0fGAuiO.js.map +1 -0
  13. package/dist/chunks/{testing-B_iMFYz_.js → testing-CRflAw4X.js} +1228 -1074
  14. package/dist/chunks/testing-CRflAw4X.js.map +1 -0
  15. package/dist/data/cache.d.ts +8 -0
  16. package/dist/data/cache.d.ts.map +1 -1
  17. package/dist/data/idempotency.d.ts.map +1 -1
  18. package/dist/data/index.d.ts +3 -1
  19. package/dist/data/index.d.ts.map +1 -1
  20. package/dist/data/testing.d.ts.map +1 -1
  21. package/dist/data/testing.js +94 -72
  22. package/dist/data/testing.js.map +1 -1
  23. package/dist/data/tiered.d.ts +7 -0
  24. package/dist/data/tiered.d.ts.map +1 -0
  25. package/dist/document/deferred-scripts.d.ts.map +1 -1
  26. package/dist/document/hydration.d.ts.map +1 -1
  27. package/dist/document/index.d.ts +1 -0
  28. package/dist/document/index.d.ts.map +1 -1
  29. package/dist/document/trusted-types.d.ts +10 -0
  30. package/dist/document/trusted-types.d.ts.map +1 -0
  31. package/dist/edge/index.js +3 -3
  32. package/dist/index.d.ts +6 -6
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +768 -432
  35. package/dist/index.js.map +1 -1
  36. package/dist/internal/testing.js +9 -9
  37. package/dist/kv/index.d.ts +2 -0
  38. package/dist/kv/index.d.ts.map +1 -1
  39. package/dist/kv/index.js +71 -48
  40. package/dist/kv/index.js.map +1 -1
  41. package/dist/kv/rate-limit-store.d.ts +8 -0
  42. package/dist/kv/rate-limit-store.d.ts.map +1 -0
  43. package/dist/kv/store.d.ts.map +1 -1
  44. package/dist/node/http.d.ts.map +1 -1
  45. package/dist/node/image.d.ts.map +1 -1
  46. package/dist/node/index.d.ts.map +1 -1
  47. package/dist/node/index.js +3 -3
  48. package/dist/node/index.js.map +1 -1
  49. package/dist/node/static.d.ts.map +1 -1
  50. package/dist/node/streaming.d.ts.map +1 -1
  51. package/dist/platform/images.d.ts.map +1 -1
  52. package/dist/platform/index.d.ts +5 -1
  53. package/dist/platform/index.d.ts.map +1 -1
  54. package/dist/platform/observability.d.ts +2 -1
  55. package/dist/platform/observability.d.ts.map +1 -1
  56. package/dist/platform/web-vitals-client.d.ts +32 -0
  57. package/dist/platform/web-vitals-client.d.ts.map +1 -0
  58. package/dist/platform/web-vitals.d.ts +78 -0
  59. package/dist/platform/web-vitals.d.ts.map +1 -0
  60. package/dist/redis/index.d.ts +2 -0
  61. package/dist/redis/index.d.ts.map +1 -1
  62. package/dist/redis/index.js +84 -46
  63. package/dist/redis/index.js.map +1 -1
  64. package/dist/redis/rate-limit-store.d.ts +8 -0
  65. package/dist/redis/rate-limit-store.d.ts.map +1 -0
  66. package/dist/redis/store.d.ts.map +1 -1
  67. package/dist/route/action.d.ts.map +1 -1
  68. package/dist/route/middleware.d.ts.map +1 -1
  69. package/dist/route/response.d.ts.map +1 -1
  70. package/dist/router/index.d.ts +1 -1
  71. package/dist/router/index.d.ts.map +1 -1
  72. package/dist/router/manifest.d.ts +1 -0
  73. package/dist/router/manifest.d.ts.map +1 -1
  74. package/dist/security/cookies.d.ts +26 -0
  75. package/dist/security/cookies.d.ts.map +1 -0
  76. package/dist/security/env.d.ts.map +1 -1
  77. package/dist/security/fetch-metadata.d.ts +29 -0
  78. package/dist/security/fetch-metadata.d.ts.map +1 -0
  79. package/dist/security/index.d.ts +5 -1
  80. package/dist/security/index.d.ts.map +1 -1
  81. package/dist/security/policy.d.ts.map +1 -1
  82. package/dist/security/rate-limit.d.ts +6 -3
  83. package/dist/security/rate-limit.d.ts.map +1 -1
  84. package/dist/security/request.d.ts.map +1 -1
  85. package/dist/security/types.d.ts +72 -3
  86. package/dist/security/types.d.ts.map +1 -1
  87. package/dist/server/index.d.ts +1 -1
  88. package/dist/server/index.d.ts.map +1 -1
  89. package/dist/server/request-handler.d.ts +6 -2
  90. package/dist/server/request-handler.d.ts.map +1 -1
  91. package/dist/static/index.d.ts.map +1 -1
  92. package/dist/static/index.js +4 -4
  93. package/dist/static/index.js.map +1 -1
  94. package/dist/vite/index.d.ts +3 -0
  95. package/dist/vite/index.d.ts.map +1 -1
  96. package/dist/vite/index.js +1030 -666
  97. package/dist/vite/index.js.map +1 -1
  98. package/dist/vite/plugin.d.ts +2 -0
  99. package/dist/vite/plugin.d.ts.map +1 -1
  100. package/dist/vite/policy-verification.d.ts.map +1 -1
  101. package/dist/vite/route-audit.d.ts +50 -0
  102. package/dist/vite/route-audit.d.ts.map +1 -0
  103. package/package.json +1 -1
  104. package/dist/chunks/request-metadata-D5NrT8ks.js.map +0 -1
  105. package/dist/chunks/streaming-BQ1bykDo.js.map +0 -1
  106. package/dist/chunks/testing-B_iMFYz_.js.map +0 -1
@@ -1,196 +1,218 @@
1
- import { w as $t, v as kt, x as _e, y as Ve, e as Je, z as Dt, A as Nt, l as Ot, a as Lt } from "./request-metadata-D5NrT8ks.js";
2
- import { createElement as fe } from "react";
3
- import { renderToString as Ke } from "react-dom/server";
4
- import { jsxs as I, jsx as M } from "react/jsx-runtime";
5
- const Ae = ["build", "private", "public"], It = {
1
+ import { x as It, w as Ut, y as Qe, z as Xe, e as et, F as Ft, A as Ht, B as jt, l as Wt, a as zt } from "./request-metadata-DaIYq4Ea.js";
2
+ import { createElement as de } from "react";
3
+ import { renderToString as tt } from "react-dom/server";
4
+ import { jsxs as H, jsx as j } from "react/jsx-runtime";
5
+ const Ne = ["build", "private", "public"], Bt = {
6
6
  app: "demiurge-memory",
7
7
  environment: "local",
8
8
  schemaVersion: 1
9
- }, Mt = 1e4, Ut = 3e4;
10
- function ni(e) {
9
+ }, qt = 1e4, Gt = 3e4;
10
+ function Eo(e) {
11
11
  return (...t) => ({
12
12
  fn: () => e.fn(...t),
13
13
  key: e.key(...t),
14
+ notFoundTtl: e.notFoundTtl,
14
15
  scope: e.scope,
15
16
  staleWhileRevalidate: e.staleWhileRevalidate,
16
17
  tags: e.tags?.(...t),
17
18
  ttl: e.ttl
18
19
  });
19
20
  }
20
- function si(e) {
21
+ class A extends Error {
22
+ constructor(t) {
23
+ super(t ?? "Not found"), this.name = "CacheNotFoundError";
24
+ }
25
+ }
26
+ function vo(e) {
27
+ throw new A(e);
28
+ }
29
+ function Ro(e) {
30
+ return e instanceof A;
31
+ }
32
+ function bo(e) {
21
33
  return { id: e };
22
34
  }
23
- function ii(e) {
35
+ function To(e) {
24
36
  return e;
25
37
  }
26
- function Ye(e) {
27
- const t = e.now ?? Date.now, r = Wt(e.refreshLeaseTtl), n = Ze(e.namespace), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
38
+ function rt(e) {
39
+ const t = e.now ?? Date.now, r = Kt(e.refreshLeaseTtl), n = nt(e.namespace), s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
28
40
  return {
29
- async get(o) {
30
- const a = o.scope ?? "request";
41
+ async get(i) {
42
+ const a = i.scope ?? "request";
31
43
  if (a === "none")
32
- return await o.fn();
33
- const c = $e(o.key);
44
+ return await i.fn();
45
+ const c = Le(i.key);
34
46
  if (a === "request")
35
- return await Ft(s, c, o, t);
36
- const u = ke(n, a, c), f = (o.tags ?? []).map(
37
- (g) => De(n, a, le(g))
38
- ), l = await e.store.get(u);
39
- if (l && (l.expiresAt === null || l.expiresAt > t()))
40
- return l.value;
41
- if (l && qt(l, t())) {
42
- const g = zt(e.store), A = globalThis.crypto.randomUUID();
43
- if (await g.acquireRefreshLease(
47
+ return await Jt(s, c, i, t);
48
+ const u = Me(n, a, c), l = (i.tags ?? []).map(
49
+ (m) => Ie(n, a, he(m))
50
+ ), f = await e.store.get(u);
51
+ if (f && (f.expiresAt === null || f.expiresAt > t())) {
52
+ if (f.negative)
53
+ throw new A(
54
+ typeof f.value == "string" ? f.value : void 0
55
+ );
56
+ return f.value;
57
+ }
58
+ if (f && Yt(f, t())) {
59
+ const m = Zt(e.store), k = globalThis.crypto.randomUUID();
60
+ if (await m.acquireRefreshLease(
44
61
  u,
45
- A,
62
+ k,
46
63
  t() + r
47
64
  )) {
48
- const te = Bt({
65
+ const N = Qt({
49
66
  key: u,
50
67
  now: t,
51
68
  onBackgroundError: e.onBackgroundError,
52
- refreshStore: g,
53
- request: o,
54
- tags: f,
55
- token: A
69
+ refreshStore: m,
70
+ request: i,
71
+ tags: l,
72
+ token: k
56
73
  });
57
- e.waitUntil?.(te);
74
+ e.waitUntil?.(N);
58
75
  }
59
- return l.value;
76
+ return f.value;
60
77
  }
61
- l && await e.store.delete(u);
62
- const m = i.get(u);
63
- if (m)
64
- return await m.promise;
65
- const d = { invalidated: !1 }, P = Promise.resolve().then(o.fn).then(async (g) => (d.invalidated || await e.store.set(u, {
66
- expiresAt: Qe(t(), o.ttl),
67
- staleUntil: Xe(
68
- t(),
69
- o.ttl,
70
- o.staleWhileRevalidate
71
- ),
72
- tags: f,
73
- value: g
74
- }), g)), $ = {
75
- promise: P,
78
+ f && await e.store.delete(u);
79
+ const h = o.get(u);
80
+ if (h)
81
+ return await h.promise;
82
+ const d = { invalidated: !1 }, D = Promise.resolve().then(i.fn).then(
83
+ async (m) => (d.invalidated || await e.store.set(u, {
84
+ expiresAt: Se(t(), i.ttl),
85
+ staleUntil: Ee(
86
+ t(),
87
+ i.ttl,
88
+ i.staleWhileRevalidate
89
+ ),
90
+ tags: l,
91
+ value: m
92
+ }), m),
93
+ async (m) => {
94
+ throw !d.invalidated && m instanceof A && await e.store.set(u, st(t(), i, l, m)), m;
95
+ }
96
+ ), $ = {
97
+ promise: D,
76
98
  state: d,
77
- tags: f
99
+ tags: l
78
100
  };
79
- i.set(u, $);
101
+ o.set(u, $);
80
102
  try {
81
- return await P;
103
+ return await D;
82
104
  } finally {
83
- i.get(u) === $ && i.delete(u);
105
+ o.get(u) === $ && o.delete(u);
84
106
  }
85
107
  },
86
- async invalidateKey(o) {
87
- const a = $e(o), c = s.delete(a);
108
+ async invalidateKey(i) {
109
+ const a = Le(i), c = s.delete(a);
88
110
  let u = !1;
89
- const f = await Promise.all(
90
- Ae.map((l) => {
91
- const m = ke(n, l, a), d = i.get(m);
92
- return d && (d.state.invalidated = !0, u = !0), e.store.delete(m);
111
+ const l = await Promise.all(
112
+ Ne.map((f) => {
113
+ const h = Me(n, f, a), d = o.get(h);
114
+ return d && (d.state.invalidated = !0, u = !0), e.store.delete(h);
93
115
  })
94
116
  );
95
- return c || u || f.some(Boolean);
117
+ return c || u || l.some(Boolean);
96
118
  },
97
- async invalidateTags(o) {
98
- const a = o.map(le), c = Gt(
119
+ async invalidateTags(i) {
120
+ const a = i.map(he), c = Xt(
99
121
  s,
100
122
  new Set(a)
101
123
  ), u = new Set(
102
- Ae.flatMap(
103
- (m) => a.map((d) => De(n, m, d))
124
+ Ne.flatMap(
125
+ (h) => a.map((d) => Ie(n, h, d))
104
126
  )
105
127
  );
106
- let f = 0;
107
- for (const m of i.values())
108
- !m.state.invalidated && m.tags.some((d) => u.has(d)) && (m.state.invalidated = !0, f += 1);
109
- const l = await e.store.invalidateTags([...u]);
110
- return c + f + l;
128
+ let l = 0;
129
+ for (const h of o.values())
130
+ !h.state.invalidated && h.tags.some((d) => u.has(d)) && (h.state.invalidated = !0, l += 1);
131
+ const f = await e.store.invalidateTags([...u]);
132
+ return c + l + f;
111
133
  }
112
134
  };
113
135
  }
114
- function ge(e = {}) {
136
+ function we(e = {}) {
115
137
  const t = e.now ?? Date.now;
116
- return Ye({
117
- namespace: It,
138
+ return rt({
139
+ namespace: Bt,
118
140
  now: t,
119
141
  onBackgroundError: e.onBackgroundError,
120
142
  refreshLeaseTtl: e.refreshLeaseTtl,
121
- store: Ht({
143
+ store: _t({
122
144
  maximumEntries: e.maximumEntries,
123
145
  now: t
124
146
  }),
125
147
  waitUntil: e.waitUntil
126
148
  });
127
149
  }
128
- function Ht(e = {}) {
129
- const t = e.entries ?? /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), n = e.maximumEntries ?? Mt, s = e.now ?? Date.now;
150
+ function _t(e = {}) {
151
+ const t = e.entries ?? /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), n = e.maximumEntries ?? qt, s = e.now ?? Date.now;
130
152
  if (!Number.isSafeInteger(n) || n <= 0)
131
153
  throw new Error(
132
154
  "Demiurge memory cache maximumEntries must be a positive integer."
133
155
  );
134
- re(t, r, s()), jt(t, n);
135
- let i = ne(t);
156
+ se(t, r, s()), Vt(t, n);
157
+ let o = oe(t);
136
158
  return {
137
- acquireRefreshLease(o, a, c) {
138
- const u = s(), f = r.get(o);
139
- return f && f.expiresAt > u ? !1 : (r.set(o, { expiresAt: c, token: a }), !0);
159
+ acquireRefreshLease(i, a, c) {
160
+ const u = s(), l = r.get(i);
161
+ return l && l.expiresAt > u ? !1 : (r.set(i, { expiresAt: c, token: a }), !0);
140
162
  },
141
- delete(o) {
142
- return r.delete(o), t.delete(o);
163
+ delete(i) {
164
+ return r.delete(i), t.delete(i);
143
165
  },
144
- get(o) {
145
- return s() >= i && (re(t, r, s()), i = ne(t)), t.get(o);
166
+ get(i) {
167
+ return s() >= o && (se(t, r, s()), o = oe(t)), t.get(i);
146
168
  },
147
- invalidateTags(o) {
148
- const a = new Set(o);
169
+ invalidateTags(i) {
170
+ const a = new Set(i);
149
171
  let c = 0;
150
- for (const [u, f] of t)
151
- f.tags.some((l) => a.has(l)) && (t.delete(u), r.delete(u), c += 1);
172
+ for (const [u, l] of t)
173
+ l.tags.some((f) => a.has(f)) && (t.delete(u), r.delete(u), c += 1);
152
174
  return c;
153
175
  },
154
- publishRefresh(o, a, c) {
155
- const u = r.get(o);
156
- return !u || u.token !== a || u.expiresAt <= s() ? !1 : (Ce(
176
+ publishRefresh(i, a, c) {
177
+ const u = r.get(i);
178
+ return !u || u.token !== a || u.expiresAt <= s() ? !1 : (Oe(
157
179
  t,
158
180
  r,
159
181
  n,
160
- o,
182
+ i,
161
183
  c
162
- ), r.delete(o), c.staleUntil !== null && (i = Math.min(i, c.staleUntil)), !0);
184
+ ), r.delete(i), c.staleUntil !== null && (o = Math.min(o, c.staleUntil)), !0);
163
185
  },
164
- releaseRefreshLease(o, a) {
165
- r.get(o)?.token === a && r.delete(o);
186
+ releaseRefreshLease(i, a) {
187
+ r.get(i)?.token === a && r.delete(i);
166
188
  },
167
- set(o, a) {
189
+ set(i, a) {
168
190
  const c = s();
169
- c >= i && (re(t, r, c), i = ne(t)), r.delete(o), Ce(
191
+ c >= o && (se(t, r, c), o = oe(t)), r.delete(i), Oe(
170
192
  t,
171
193
  r,
172
194
  n,
173
- o,
195
+ i,
174
196
  a
175
- ), a.staleUntil !== null && (i = Math.min(i, a.staleUntil));
197
+ ), a.staleUntil !== null && (o = Math.min(o, a.staleUntil));
176
198
  }
177
199
  };
178
200
  }
179
- function re(e, t, r) {
201
+ function se(e, t, r) {
180
202
  for (const [n, s] of e)
181
203
  s.staleUntil !== null && s.staleUntil <= r && (e.delete(n), t.delete(n));
182
204
  }
183
- function Ce(e, t, r, n, s) {
205
+ function Oe(e, t, r, n, s) {
184
206
  if (!e.has(n) && e.size >= r)
185
207
  for (; e.size >= r; ) {
186
- const i = e.keys().next().value;
187
- if (i === void 0)
208
+ const o = e.keys().next().value;
209
+ if (o === void 0)
188
210
  break;
189
- e.delete(i), t.delete(i);
211
+ e.delete(o), t.delete(o);
190
212
  }
191
213
  e.set(n, s);
192
214
  }
193
- function jt(e, t) {
215
+ function Vt(e, t) {
194
216
  for (; e.size > t; ) {
195
217
  const r = e.keys().next().value;
196
218
  if (r === void 0)
@@ -198,14 +220,14 @@ function jt(e, t) {
198
220
  e.delete(r);
199
221
  }
200
222
  }
201
- function ne(e) {
223
+ function oe(e) {
202
224
  let t = Number.POSITIVE_INFINITY;
203
225
  for (const r of e.values())
204
226
  r.staleUntil !== null && (t = Math.min(t, r.staleUntil));
205
227
  return t;
206
228
  }
207
- function Ze(e) {
208
- const t = se("app", e.app), r = se(
229
+ function nt(e) {
230
+ const t = ie("app", e.app), r = ie(
209
231
  "environment",
210
232
  e.environment
211
233
  );
@@ -213,13 +235,13 @@ function Ze(e) {
213
235
  throw new Error(
214
236
  "Demiurge cache namespace schemaVersion must be a non-negative integer or string."
215
237
  );
216
- const n = se(
238
+ const n = ie(
217
239
  "schemaVersion",
218
240
  String(e.schemaVersion)
219
241
  );
220
242
  return `${t}:${r}:${n}`;
221
243
  }
222
- function oi(e) {
244
+ function xo(e) {
223
245
  return {
224
246
  async key(t) {
225
247
  return {
@@ -250,7 +272,7 @@ function oi(e) {
250
272
  }
251
273
  };
252
274
  }
253
- function U(e) {
275
+ function P(e) {
254
276
  if (e === void 0)
255
277
  return Number.POSITIVE_INFINITY;
256
278
  if (typeof e == "number") {
@@ -264,40 +286,52 @@ function U(e) {
264
286
  const r = Number(t[1]), n = t[2];
265
287
  return n === "h" ? r * 36e5 : n === "m" ? r * 6e4 : n === "s" ? r * 1e3 : r;
266
288
  }
267
- function $e(e) {
268
- return de(e, /* @__PURE__ */ new Set());
289
+ function Le(e) {
290
+ return me(e, /* @__PURE__ */ new Set());
269
291
  }
270
- function le(e) {
292
+ function he(e) {
271
293
  return e.id;
272
294
  }
273
- async function Ft(e, t, r, n) {
295
+ async function Jt(e, t, r, n) {
274
296
  const s = e.get(t);
275
297
  if (s && s.expiresAt > n())
276
298
  return await s.value;
277
- const i = Promise.resolve().then(r.fn), o = {
278
- expiresAt: n() + U(r.ttl),
279
- tags: (r.tags ?? []).map(le),
280
- value: i
299
+ const o = Promise.resolve().then(r.fn), i = {
300
+ expiresAt: n() + P(r.ttl),
301
+ tags: (r.tags ?? []).map(he),
302
+ value: o
281
303
  };
282
- e.set(t, o);
304
+ e.set(t, i);
283
305
  try {
284
- return await i;
306
+ return await o;
285
307
  } catch (a) {
286
- throw e.get(t) === o && e.delete(t), a;
308
+ throw e.get(t) === i && (a instanceof A ? i.expiresAt = n() + P(r.notFoundTtl ?? r.ttl) : e.delete(t)), a;
287
309
  }
288
310
  }
289
- function ke(e, t, r) {
311
+ function Me(e, t, r) {
290
312
  return `${e}:${t}:key:${r}`;
291
313
  }
292
- function De(e, t, r) {
314
+ function Ie(e, t, r) {
293
315
  return `${e}:${t}:tag:${r}`;
294
316
  }
295
- function Qe(e, t) {
296
- const r = U(t);
317
+ function Se(e, t) {
318
+ const r = P(t);
297
319
  return Number.isFinite(r) ? e + r : null;
298
320
  }
299
- function Xe(e, t, r) {
300
- const n = U(t);
321
+ function st(e, t, r, n) {
322
+ const s = t.notFoundTtl ?? t.ttl;
323
+ return {
324
+ expiresAt: Se(e, s),
325
+ negative: !0,
326
+ // Negative entries do not participate in stale-while-revalidate: they
327
+ // expire outright and recompute on the next request.
328
+ staleUntil: Ee(e, s, void 0),
329
+ tags: r,
330
+ value: n.message
331
+ };
332
+ }
333
+ function Ee(e, t, r) {
334
+ const n = P(t);
301
335
  if (!Number.isFinite(n)) {
302
336
  if (r !== void 0)
303
337
  throw new Error(
@@ -305,32 +339,32 @@ function Xe(e, t, r) {
305
339
  );
306
340
  return null;
307
341
  }
308
- return e + n + U(r ?? 0);
342
+ return e + n + P(r ?? 0);
309
343
  }
310
- function Wt(e) {
311
- const t = U(e ?? Ut);
344
+ function Kt(e) {
345
+ const t = P(e ?? Gt);
312
346
  if (!Number.isFinite(t) || t <= 0)
313
347
  throw new Error(
314
348
  "Demiurge cache refreshLeaseTtl must be a positive finite duration."
315
349
  );
316
350
  return t;
317
351
  }
318
- function qt(e, t) {
352
+ function Yt(e, t) {
319
353
  return e.expiresAt !== null && e.expiresAt <= t && (e.staleUntil === null || e.staleUntil > t);
320
354
  }
321
- function zt(e) {
355
+ function Zt(e) {
322
356
  if (!e.acquireRefreshLease || !e.publishRefresh || !e.releaseRefreshLease)
323
357
  throw new Error(
324
358
  "Demiurge staleWhileRevalidate requires a cache store with acquireRefreshLease, publishRefresh, and releaseRefreshLease coordination methods."
325
359
  );
326
360
  return e;
327
361
  }
328
- async function Bt(e) {
362
+ async function Qt(e) {
329
363
  try {
330
364
  const t = await e.request.fn(), r = e.now();
331
365
  await e.refreshStore.publishRefresh(e.key, e.token, {
332
- expiresAt: Qe(r, e.request.ttl),
333
- staleUntil: Xe(
366
+ expiresAt: Se(r, e.request.ttl),
367
+ staleUntil: Ee(
334
368
  r,
335
369
  e.request.ttl,
336
370
  e.request.staleWhileRevalidate
@@ -339,12 +373,20 @@ async function Bt(e) {
339
373
  value: t
340
374
  });
341
375
  } catch (t) {
376
+ if (t instanceof A) {
377
+ await e.refreshStore.publishRefresh(
378
+ e.key,
379
+ e.token,
380
+ st(e.now(), e.request, e.tags, t)
381
+ );
382
+ return;
383
+ }
342
384
  e.onBackgroundError ? e.onBackgroundError(t) : console.error("Demiurge stale cache refresh failed.", t);
343
385
  } finally {
344
386
  await e.refreshStore.releaseRefreshLease(e.key, e.token);
345
387
  }
346
388
  }
347
- function se(e, t) {
389
+ function ie(e, t) {
348
390
  const r = [...t].some((n) => {
349
391
  const s = n.charCodeAt(0);
350
392
  return s <= 31 || s === 127;
@@ -355,13 +397,13 @@ function se(e, t) {
355
397
  );
356
398
  return t;
357
399
  }
358
- function Gt(e, t) {
400
+ function Xt(e, t) {
359
401
  let r = 0;
360
402
  for (const [n, s] of e)
361
- s.tags.some((i) => t.has(i)) && (e.delete(n), r += 1);
403
+ s.tags.some((o) => t.has(o)) && (e.delete(n), r += 1);
362
404
  return r;
363
405
  }
364
- function de(e, t) {
406
+ function me(e, t) {
365
407
  if (e === null || typeof e == "boolean" || typeof e == "string")
366
408
  return JSON.stringify(e);
367
409
  if (typeof e == "number") {
@@ -378,18 +420,18 @@ function de(e, t) {
378
420
  if (t.has(e))
379
421
  throw new Error("Demiurge cache keys cannot contain circular references.");
380
422
  if (t.add(e), Array.isArray(e)) {
381
- const o = Reflect.ownKeys(e), a = [
382
- ...Array.from({ length: e.length }, (u, f) => String(f)),
423
+ const i = Reflect.ownKeys(e), a = [
424
+ ...Array.from({ length: e.length }, (u, l) => String(l)),
383
425
  "length"
384
426
  ];
385
- if (o.length !== a.length || o.some((u, f) => u !== a[f]) || a.slice(0, -1).some((u) => {
386
- const f = Object.getOwnPropertyDescriptor(e, u);
387
- return !f?.enumerable || !("value" in f);
427
+ if (i.length !== a.length || i.some((u, l) => u !== a[l]) || a.slice(0, -1).some((u) => {
428
+ const l = Object.getOwnPropertyDescriptor(e, u);
429
+ return !l?.enumerable || !("value" in l);
388
430
  }))
389
431
  throw t.delete(e), new Error(
390
432
  "Demiurge cache key arrays must be dense and cannot contain accessors or custom properties."
391
433
  );
392
- const c = `[${e.map((u) => de(u, t)).join(",")}]`;
434
+ const c = `[${e.map((u) => me(u, t)).join(",")}]`;
393
435
  return t.delete(e), c;
394
436
  }
395
437
  const r = Object.getPrototypeOf(e);
@@ -398,47 +440,47 @@ function de(e, t) {
398
440
  "Demiurge cache keys accept only primitives, arrays, and plain objects."
399
441
  );
400
442
  const n = Reflect.ownKeys(e);
401
- if (n.some((o) => typeof o == "symbol") || n.some((o) => {
402
- const a = Object.getOwnPropertyDescriptor(e, o);
443
+ if (n.some((i) => typeof i == "symbol") || n.some((i) => {
444
+ const a = Object.getOwnPropertyDescriptor(e, i);
403
445
  return !a?.enumerable || !("value" in a);
404
446
  }))
405
447
  throw new Error(
406
448
  "Demiurge cache key objects require enumerable string data properties."
407
449
  );
408
- const s = e, i = `{${Object.keys(s).sort().map(
409
- (o) => `${JSON.stringify(o)}:${de(s[o], t)}`
450
+ const s = e, o = `{${Object.keys(s).sort().map(
451
+ (i) => `${JSON.stringify(i)}:${me(s[i], t)}`
410
452
  ).join(",")}}`;
411
- return t.delete(e), i;
453
+ return t.delete(e), o;
412
454
  }
413
- function ai(e) {
455
+ function Ao(e) {
414
456
  return e;
415
457
  }
416
- function ci(e) {
458
+ function Po(e) {
417
459
  return {
418
460
  ...e,
419
461
  kind: "meta"
420
462
  };
421
463
  }
422
- function ui(e) {
464
+ function Co(e) {
423
465
  return {
424
466
  ...e,
425
467
  kind: "link"
426
468
  };
427
469
  }
428
- function fi(e) {
470
+ function Do(e) {
429
471
  return {
430
472
  kind: "structured-data",
431
473
  value: e
432
474
  };
433
475
  }
434
- function v(...e) {
476
+ function R(...e) {
435
477
  const t = {
436
478
  custom: [],
437
479
  structuredData: []
438
480
  };
439
- for (const i of e)
440
- i && _t(t, i);
441
- const r = Jt(t), n = t.description, s = Kt(t.openGraph, r, n);
481
+ for (const o of e)
482
+ o && er(t, o);
483
+ const r = rr(t), n = t.description, s = nr(t.openGraph, r, n);
442
484
  return {
443
485
  canonical: t.canonical,
444
486
  charset: "utf-8",
@@ -451,8 +493,8 @@ function v(...e) {
451
493
  viewport: "width=device-width, initial-scale=1"
452
494
  };
453
495
  }
454
- function _t(e, t) {
455
- Vt(e, t.title), t.description !== void 0 && (e.description = t.description), t.canonical !== void 0 && (e.canonical = t.canonical), t.robots && (e.robots = {
496
+ function er(e, t) {
497
+ tr(e, t.title), t.description !== void 0 && (e.description = t.description), t.canonical !== void 0 && (e.canonical = t.canonical), t.robots && (e.robots = {
456
498
  ...e.robots ?? {},
457
499
  ...t.robots
458
500
  }), t.openGraph && (e.openGraph = {
@@ -460,7 +502,7 @@ function _t(e, t) {
460
502
  ...t.openGraph
461
503
  }), t.custom && e.custom.push(...t.custom), t.structuredData && e.structuredData.push(...t.structuredData);
462
504
  }
463
- function Vt(e, t) {
505
+ function tr(e, t) {
464
506
  if (t !== void 0) {
465
507
  if (typeof t == "string") {
466
508
  e.title = t;
@@ -469,10 +511,10 @@ function Vt(e, t) {
469
511
  t.default !== void 0 && (e.titleDefault = t.default), t.format && (e.titleFormat = t.format);
470
512
  }
471
513
  }
472
- function Jt(e) {
514
+ function rr(e) {
473
515
  return e.title === void 0 ? e.titleDefault : e.titleFormat ? e.titleFormat(e.title) : e.title;
474
516
  }
475
- function Kt(e, t, r) {
517
+ function nr(e, t, r) {
476
518
  if (!(!e && !t && !r))
477
519
  return {
478
520
  ...t ? { title: t } : {},
@@ -480,7 +522,7 @@ function Kt(e, t, r) {
480
522
  ...e ?? {}
481
523
  };
482
524
  }
483
- function et(e) {
525
+ function ot(e) {
484
526
  const t = {
485
527
  fallbacks: {
486
528
  error: [],
@@ -493,57 +535,57 @@ function et(e) {
493
535
  policies: []
494
536
  };
495
537
  for (const [r, n] of Object.entries(e)) {
496
- const s = r.replace(/^\/src\/routes\//, "").replace(/^\.\/routes\//, "").replace(/\.tsx?$/, "").split("/"), i = s.at(-1);
497
- if (i === "@layout") {
538
+ const s = r.replace(/^\/src\/routes\//, "").replace(/^\.\/routes\//, "").replace(/\.tsx?$/, "").split("/"), o = s.at(-1);
539
+ if (o === "@layout") {
498
540
  t.layouts.push({
499
541
  file: r,
500
542
  fileSegments: s.slice(0, -1),
501
- segments: R(s.slice(0, -1)),
543
+ segments: v(s.slice(0, -1)),
502
544
  load: n
503
545
  });
504
546
  continue;
505
547
  }
506
- if (i === "@policy") {
548
+ if (o === "@policy") {
507
549
  t.policies.push({
508
550
  file: r,
509
551
  fileSegments: s.slice(0, -1),
510
- segments: R(s.slice(0, -1)),
552
+ segments: v(s.slice(0, -1)),
511
553
  load: n
512
554
  });
513
555
  continue;
514
556
  }
515
- if (i === "@middleware") {
557
+ if (o === "@middleware") {
516
558
  t.middlewares.push({
517
559
  file: r,
518
560
  fileSegments: s.slice(0, -1),
519
- segments: R(s.slice(0, -1)),
561
+ segments: v(s.slice(0, -1)),
520
562
  load: n
521
563
  });
522
564
  continue;
523
565
  }
524
- if (i === "@loading") {
566
+ if (o === "@loading") {
525
567
  t.fallbacks.loading.push({
526
568
  file: r,
527
569
  fileSegments: s.slice(0, -1),
528
- segments: R(s.slice(0, -1)),
570
+ segments: v(s.slice(0, -1)),
529
571
  load: n
530
572
  });
531
573
  continue;
532
574
  }
533
- if (i === "@error") {
575
+ if (o === "@error") {
534
576
  t.fallbacks.error.push({
535
577
  file: r,
536
578
  fileSegments: s.slice(0, -1),
537
- segments: R(s.slice(0, -1)),
579
+ segments: v(s.slice(0, -1)),
538
580
  load: n
539
581
  });
540
582
  continue;
541
583
  }
542
- if (i === "@not-found") {
584
+ if (o === "@not-found") {
543
585
  t.fallbacks.notFound.push({
544
586
  file: r,
545
587
  fileSegments: s.slice(0, -1),
546
- segments: R(s.slice(0, -1)),
588
+ segments: v(s.slice(0, -1)),
547
589
  load: n
548
590
  });
549
591
  continue;
@@ -551,12 +593,12 @@ function et(e) {
551
593
  t.routes.push({
552
594
  file: r,
553
595
  fileSegments: s,
554
- segments: R(s),
555
- score: dr(s),
596
+ segments: v(s),
597
+ score: Er(s),
556
598
  load: n
557
599
  });
558
600
  }
559
- return Yt(t.routes), t.routes.sort(Xt), t.layouts.sort(
601
+ return sr(t.routes), t.routes.sort(ar), t.layouts.sort(
560
602
  (r, n) => r.fileSegments.length - n.fileSegments.length || r.file.localeCompare(n.file)
561
603
  ), t.policies.sort(
562
604
  (r, n) => r.fileSegments.length - n.fileSegments.length || r.file.localeCompare(n.file)
@@ -570,48 +612,48 @@ function et(e) {
570
612
  (r, n) => r.fileSegments.length - n.fileSegments.length || r.file.localeCompare(n.file)
571
613
  ), t;
572
614
  }
573
- function Yt(e) {
615
+ function sr(e) {
574
616
  const t = /* @__PURE__ */ new Map();
575
617
  for (const r of e) {
576
618
  const n = r.segments.findIndex(
577
- (o) => o.startsWith("*")
619
+ (i) => i.startsWith("*")
578
620
  );
579
621
  if (n !== -1 && n !== r.segments.length - 1)
580
622
  throw new Error(
581
623
  `Catchall route segment in "${r.file}" must be the final URL segment.`
582
624
  );
583
- const s = r.segments.map(Zt).join("/"), i = t.get(s);
584
- if (i)
625
+ const s = r.segments.map(or).join("/"), o = t.get(s);
626
+ if (o)
585
627
  throw new Error(
586
- `Ambiguous routes "${i.file}" and "${r.file}" have the same runtime shape and both match "${Qt(r.segments)}".`
628
+ `Ambiguous routes "${o.file}" and "${r.file}" have the same runtime shape and both match "${ir(r.segments)}".`
587
629
  );
588
630
  t.set(s, r);
589
631
  }
590
632
  }
591
- function Zt(e) {
633
+ function or(e) {
592
634
  return e.startsWith("*") ? "*" : e.startsWith(":") ? ":" : `=${e}`;
593
635
  }
594
- function Qt(e) {
636
+ function ir(e) {
595
637
  return e.length === 0 ? "/" : `/${e.map((t) => t.startsWith(":") || t.startsWith("*") ? "example" : t).join("/")}`;
596
638
  }
597
- function Xt(e, t) {
639
+ function ar(e, t) {
598
640
  const r = Math.max(e.segments.length, t.segments.length);
599
641
  for (let n = 0; n < r; n += 1) {
600
- const s = Ne(t.segments[n]) - Ne(e.segments[n]);
642
+ const s = Ue(t.segments[n]) - Ue(e.segments[n]);
601
643
  if (s !== 0)
602
644
  return s;
603
645
  }
604
646
  return e.file.localeCompare(t.file);
605
647
  }
606
- function Ne(e) {
648
+ function Ue(e) {
607
649
  return e === void 0 ? 4 : e.startsWith("*") ? 1 : e.startsWith(":") ? 2 : 3;
608
650
  }
609
- async function tt(e, t, r = new Request(`http://demiurge.local${t}`), n, s = ge(), i = {}) {
610
- const o = i.documentContributions ?? !0, a = F(e.routes, t);
651
+ async function it(e, t, r = new Request(`http://demiurge.local${t}`), n, s = we(), o = {}) {
652
+ const i = o.documentContributions ?? !0, a = B(e.routes, t);
611
653
  if (!a)
612
654
  return {
613
- ...await me(e, t, {
614
- documentContributions: o
655
+ ...await pe(e, t, {
656
+ documentContributions: i
615
657
  }),
616
658
  status: "not-found"
617
659
  };
@@ -620,136 +662,136 @@ async function tt(e, t, r = new Request(`http://demiurge.local${t}`), n, s = ge(
620
662
  ), u = await a.route.load();
621
663
  if (!u.GET || u.GET.kind !== "page")
622
664
  return {
623
- ...await me(e, t, {
624
- fallback: ye(
665
+ ...await pe(e, t, {
666
+ fallback: ve(
625
667
  e.fallbacks.notFound,
626
668
  a.route
627
669
  ),
628
- documentContributions: o,
670
+ documentContributions: i,
629
671
  layouts: c
630
672
  }),
631
673
  status: "not-found"
632
674
  };
633
- const f = u.GET.layout === !1 ? [] : await Promise.all(c.map((d) => d.load())), l = new URL(r.url), m = {
675
+ const l = u.GET.layout === !1 ? [] : await Promise.all(c.map((d) => d.load())), f = new URL(r.url), h = {
634
676
  cache: s,
635
- context: i.requestContext ?? {},
677
+ context: o.requestContext ?? {},
636
678
  path: a.path,
637
679
  pathname: t,
638
680
  request: r,
639
- search: l.searchParams,
640
- url: l
681
+ search: f.searchParams,
682
+ url: f
641
683
  };
642
684
  return {
643
685
  status: "ready",
644
686
  match: {
645
- data: u.GET.data && !n?.hasData ? await u.GET.data(m) : n?.data,
646
- error: await rt(e, a.route),
647
- links: o ? await kt(
687
+ data: u.GET.data && !n?.hasData ? await u.GET.data(h) : n?.data,
688
+ error: await at(e, a.route),
689
+ links: i ? await Ut(
648
690
  [
649
- ...f.map((d) => d.links),
691
+ ...l.map((d) => d.links),
650
692
  u.links
651
693
  ],
652
- m
694
+ h
653
695
  ) : [],
654
696
  page: u.GET.view,
655
- layouts: f.map(
697
+ layouts: l.map(
656
698
  (d) => d.default
657
699
  ),
658
- metadata: o ? v(
659
- ...f.map((d) => d.metadata),
700
+ metadata: i ? R(
701
+ ...l.map((d) => d.metadata),
660
702
  u.metadata
661
- ) : v(),
703
+ ) : R(),
662
704
  path: a.path,
663
705
  pathname: t,
664
706
  render: u.GET.render,
665
- scripts: o ? await $t(
707
+ scripts: i ? await It(
666
708
  [
667
- ...f.map((d) => d.scripts),
709
+ ...l.map((d) => d.scripts),
668
710
  u.scripts
669
711
  ],
670
- m
712
+ h
671
713
  ) : []
672
714
  }
673
715
  };
674
716
  }
675
- async function li(e, t = {}) {
676
- const r = ge(), n = [];
717
+ async function $o(e, t = {}) {
718
+ const r = we(), n = [];
677
719
  for (const s of e.routes) {
678
- const i = await s.load();
679
- if (!i.GET || i.GET.kind !== "page" && !t.includeResources)
720
+ const o = await s.load();
721
+ if (!o.GET || o.GET.kind !== "page" && !t.includeResources)
680
722
  continue;
681
- if (i.GET.kind === "page" && i.GET.render.mode !== "static")
723
+ if (o.GET.kind === "page" && o.GET.render.mode !== "static")
682
724
  throw new Error(
683
- `Page route "${s.file}" uses render mode "${i.GET.render.mode}" and cannot be emitted as static output. Set render: { mode: "static" } or deploy a runtime adapter.`
725
+ `Page route "${s.file}" uses render mode "${o.GET.render.mode}" and cannot be emitted as static output. Set render: { mode: "static" } or deploy a runtime adapter.`
684
726
  );
685
- const o = or(s.segments);
686
- if (cr(s.segments).length === 0) {
727
+ const i = mr(s.segments);
728
+ if (gr(s.segments).length === 0) {
687
729
  n.push({
688
730
  file: s.file,
689
731
  path: {},
690
- pattern: o,
691
- pathname: o
732
+ pattern: i,
733
+ pathname: i
692
734
  });
693
735
  continue;
694
736
  }
695
- if (!i.paths)
737
+ if (!o.paths)
696
738
  throw new Error(
697
- `Dynamic static route "${s.file}" must export paths for "${o}".`
739
+ `Dynamic static route "${s.file}" must export paths for "${i}".`
698
740
  );
699
- const c = await i.paths({ cache: r });
741
+ const c = await o.paths({ cache: r });
700
742
  for (const u of c) {
701
- const f = ur(s, o, u);
743
+ const l = yr(s, i, u);
702
744
  n.push({
703
745
  file: s.file,
704
- path: f,
705
- pattern: o,
706
- pathname: lr(s.segments, f)
746
+ path: l,
747
+ pattern: i,
748
+ pathname: Sr(s.segments, l)
707
749
  });
708
750
  }
709
751
  }
710
752
  return n;
711
753
  }
712
- async function di(e, t) {
713
- const r = F(e.routes, t);
754
+ async function ko(e, t) {
755
+ const r = B(e.routes, t);
714
756
  if (r)
715
- return await sr(
716
- ye(e.fallbacks.loading, r.route)
757
+ return await dr(
758
+ ve(e.fallbacks.loading, r.route)
717
759
  );
718
760
  }
719
- async function er(e, t) {
761
+ async function cr(e, t) {
720
762
  let r;
721
763
  try {
722
- r = F(e.routes, t);
764
+ r = B(e.routes, t);
723
765
  } catch (n) {
724
- if (!(n instanceof Ee)) throw n;
725
- return await Se(
766
+ if (!(n instanceof Te)) throw n;
767
+ return await be(
726
768
  e.fallbacks.error.find(
727
769
  (s) => s.fileSegments.length === 0
728
770
  )
729
771
  );
730
772
  }
731
- return r ? await rt(e, r.route) : await tr(e, t);
773
+ return r ? await at(e, r.route) : await ur(e, t);
732
774
  }
733
- async function rt(e, t) {
734
- return await Se(
735
- ye(e.fallbacks.error, t)
775
+ async function at(e, t) {
776
+ return await be(
777
+ ve(e.fallbacks.error, t)
736
778
  );
737
779
  }
738
- async function tr(e, t) {
739
- return await Se(
740
- nt(e.fallbacks.error, t)
780
+ async function ur(e, t) {
781
+ return await be(
782
+ ct(e.fallbacks.error, t)
741
783
  );
742
784
  }
743
- async function me(e, t, r = {}) {
744
- const s = await (r.fallback ?? nt(e.fallbacks.notFound, t))?.load(), i = s?.default, o = r.documentContributions ?? !0;
785
+ async function pe(e, t, r = {}) {
786
+ const s = await (r.fallback ?? ct(e.fallbacks.notFound, t))?.load(), o = s?.default, i = r.documentContributions ?? !0;
745
787
  if (s?.layout === !1)
746
788
  return {
747
789
  layouts: [],
748
- metadata: o ? v(s.metadata) : v(),
749
- notFound: i,
790
+ metadata: i ? R(s.metadata) : R(),
791
+ notFound: o,
750
792
  pathname: t
751
793
  };
752
- const a = r.layouts ?? rr(e, t);
794
+ const a = r.layouts ?? lr(e, t);
753
795
  try {
754
796
  const c = await Promise.all(
755
797
  a.map((u) => u.load())
@@ -758,86 +800,86 @@ async function me(e, t, r = {}) {
758
800
  layouts: c.map(
759
801
  (u) => u.default
760
802
  ),
761
- metadata: o ? v(
803
+ metadata: i ? R(
762
804
  ...c.map((u) => u.metadata),
763
805
  s?.metadata
764
- ) : v(),
765
- notFound: i,
806
+ ) : R(),
807
+ notFound: o,
766
808
  pathname: t
767
809
  };
768
810
  } catch (c) {
769
811
  return r.onLayoutError?.(c), {
770
812
  layouts: [],
771
- metadata: o ? v(s?.metadata) : v(),
772
- notFound: i,
813
+ metadata: i ? R(s?.metadata) : R(),
814
+ notFound: o,
773
815
  pathname: t
774
816
  };
775
817
  }
776
818
  }
777
- function rr(e, t) {
778
- const r = X(t);
819
+ function lr(e, t) {
820
+ const r = re(t);
779
821
  return e.layouts.filter(
780
- (n) => !n.fileSegments.some(Q) && we(n.segments, r)
822
+ (n) => !n.fileSegments.some(te) && Re(n.segments, r)
781
823
  );
782
824
  }
783
- function nr(e, t) {
784
- const r = X(t);
825
+ function fr(e, t) {
826
+ const r = re(t);
785
827
  return e.policies.filter(
786
- (n) => !n.fileSegments.some(Q) && we(n.segments, r)
828
+ (n) => !n.fileSegments.some(te) && Re(n.segments, r)
787
829
  );
788
830
  }
789
- function ye(e, t) {
831
+ function ve(e, t) {
790
832
  for (let r = e.length - 1; r >= 0; r -= 1) {
791
833
  const n = e[r];
792
834
  if (T(n.fileSegments, t.fileSegments))
793
835
  return n;
794
836
  }
795
837
  }
796
- function nt(e, t) {
797
- const r = X(t);
838
+ function ct(e, t) {
839
+ const r = re(t);
798
840
  for (let n = e.length - 1; n >= 0; n -= 1) {
799
841
  const s = e[n];
800
- if (!s.fileSegments.some(Q) && we(s.segments, r))
842
+ if (!s.fileSegments.some(te) && Re(s.segments, r))
801
843
  return s;
802
844
  }
803
845
  }
804
- function we(e, t) {
846
+ function Re(e, t) {
805
847
  return e.every((r, n) => r.startsWith("*") ? t.length > n : r.startsWith(":") ? !!t[n] : t[n] === r);
806
848
  }
807
- async function sr(e) {
849
+ async function dr(e) {
808
850
  return e ? (await e.load()).default : void 0;
809
851
  }
810
- async function Se(e) {
852
+ async function be(e) {
811
853
  return e ? (await e.load()).default : void 0;
812
854
  }
813
- function F(e, t) {
814
- const r = X(t);
855
+ function B(e, t) {
856
+ const r = re(t);
815
857
  for (const n of e) {
816
- const s = ir(n.segments, r);
858
+ const s = hr(n.segments, r);
817
859
  if (s)
818
860
  return { route: n, path: s };
819
861
  }
820
862
  return null;
821
863
  }
822
- const mi = tt, hi = F;
823
- function ir(e, t) {
864
+ const No = it, Oo = B;
865
+ function hr(e, t) {
824
866
  const r = {};
825
867
  for (let n = 0; n < e.length; n += 1) {
826
- const s = e[n], i = t[n];
868
+ const s = e[n], o = t[n];
827
869
  if (s?.startsWith("*"))
828
870
  return r[s.slice(1)] = t.slice(n).join("/"), r;
829
- if (!i)
871
+ if (!o)
830
872
  return null;
831
873
  if (s.startsWith(":")) {
832
- r[s.slice(1)] = i;
874
+ r[s.slice(1)] = o;
833
875
  continue;
834
876
  }
835
- if (s !== i)
877
+ if (s !== o)
836
878
  return null;
837
879
  }
838
880
  return e.length === t.length ? r : null;
839
881
  }
840
- function pi(e, t) {
882
+ function Lo(e, t) {
841
883
  return e.every(
842
884
  (r, n) => t[n] === r
843
885
  );
@@ -847,58 +889,58 @@ function T(e, t) {
847
889
  (r, n) => t[n] === r
848
890
  );
849
891
  }
850
- function R(e) {
851
- return e.flatMap((t) => Q(t) ? [] : t === "index" ? [] : t.startsWith("[...") && t.endsWith("]") ? [`*${t.slice(4, -1)}`] : t.startsWith("[") && t.endsWith("]") ? [`:${t.slice(1, -1)}`] : [t]);
892
+ function v(e) {
893
+ 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]);
852
894
  }
853
- function Q(e) {
895
+ function te(e) {
854
896
  return e.startsWith("(") && e.endsWith(")");
855
897
  }
856
- function or(e) {
857
- return e.length === 0 ? "/" : `/${e.map(ar).join("/")}`;
898
+ function mr(e) {
899
+ return e.length === 0 ? "/" : `/${e.map(pr).join("/")}`;
858
900
  }
859
- function ar(e) {
901
+ function pr(e) {
860
902
  return e.startsWith("*") ? `[...${e.slice(1)}]` : e.startsWith(":") ? `[${e.slice(1)}]` : e;
861
903
  }
862
- function cr(e) {
904
+ function gr(e) {
863
905
  return e.flatMap((t) => t.startsWith(":") || t.startsWith("*") ? [t.slice(1)] : []);
864
906
  }
865
- function ur(e, t, r) {
907
+ function yr(e, t, r) {
866
908
  const n = {};
867
909
  for (const s of e.segments) {
868
910
  if (!s.startsWith(":") && !s.startsWith("*"))
869
911
  continue;
870
- const i = s.slice(1), o = r[i];
871
- if (o === void 0)
912
+ const o = s.slice(1), i = r[o];
913
+ if (i === void 0)
872
914
  throw new Error(
873
- `Static paths for "${e.file}" must include "${i}" for "${t}".`
915
+ `Static paths for "${e.file}" must include "${o}" for "${t}".`
874
916
  );
875
- if (!fr(o))
917
+ if (!wr(i))
876
918
  throw new Error(
877
- `Static path "${i}" for "${e.file}" must be a string, number, or boolean.`
919
+ `Static path "${o}" for "${e.file}" must be a string, number, or boolean.`
878
920
  );
879
- n[i] = String(o);
921
+ n[o] = String(i);
880
922
  }
881
923
  return n;
882
924
  }
883
- function fr(e) {
925
+ function wr(e) {
884
926
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean";
885
927
  }
886
- function lr(e, t) {
928
+ function Sr(e, t) {
887
929
  return `/${e.map((n) => n.startsWith("*") ? t[n.slice(1)].split("/").filter(Boolean).map(encodeURIComponent).join("/") : n.startsWith(":") ? encodeURIComponent(t[n.slice(1)]) : encodeURIComponent(n)).filter(Boolean).join("/")}`;
888
930
  }
889
- function dr(e) {
890
- return R(e).reduce((t, r) => r.startsWith("*") ? t : r.startsWith(":") ? t + 1 : t + 2, 0);
931
+ function Er(e) {
932
+ return v(e).reduce((t, r) => r.startsWith("*") ? t : r.startsWith(":") ? t + 1 : t + 2, 0);
891
933
  }
892
- function X(e) {
934
+ function re(e) {
893
935
  return e.replace(/^\/|\/$/g, "").split("/").filter(Boolean).map((t) => {
894
936
  try {
895
937
  return decodeURIComponent(t);
896
938
  } catch (r) {
897
- throw new Ee(e, { cause: r });
939
+ throw new Te(e, { cause: r });
898
940
  }
899
941
  });
900
942
  }
901
- class Ee extends URIError {
943
+ class Te extends URIError {
902
944
  pathname;
903
945
  constructor(t, r) {
904
946
  super(
@@ -907,35 +949,35 @@ class Ee extends URIError {
907
949
  ), this.name = "MalformedPathnameError", this.pathname = t;
908
950
  }
909
951
  }
910
- const C = "x-demiurge-navigation", mr = "data", hr = "data", ie = "error", Oe = "not-found";
911
- function st(e) {
912
- return e.headers.get(C) === mr;
952
+ const C = "x-demiurge-navigation", vr = "data", Rr = "data", ae = "error", Fe = "not-found";
953
+ function ut(e) {
954
+ return e.headers.get(C) === vr;
913
955
  }
914
- function pr(e) {
956
+ function br(e) {
915
957
  return Response.json(
916
958
  { data: e, hasData: !0 },
917
959
  {
918
960
  headers: {
919
961
  "cache-control": "no-store",
920
- [C]: hr,
962
+ [C]: Rr,
921
963
  vary: C
922
964
  }
923
965
  }
924
966
  );
925
967
  }
926
- function z(e, t) {
968
+ function _(e, t) {
927
969
  return e.headers.set("cache-control", "no-store"), e.headers.set(C, t), e.headers.append("vary", C), e;
928
970
  }
929
- function gr(e) {
971
+ function Tr(e) {
930
972
  if (typeof e == "string")
931
973
  return e;
932
- const t = yr(Er(
974
+ const t = xr(Cr(
933
975
  e.to,
934
976
  "path" in e ? e.path : void 0
935
- )), r = e.search === void 0 ? t.search : wr(e.search), n = e.hash === void 0 ? t.hash : e.hash ? e.hash.startsWith("#") ? e.hash : `#${e.hash}` : "";
977
+ )), r = e.search === void 0 ? t.search : Ar(e.search), n = e.hash === void 0 ? t.hash : e.hash ? e.hash.startsWith("#") ? e.hash : `#${e.hash}` : "";
936
978
  return `${t.pathname}${r}${n}`;
937
979
  }
938
- function yr(e) {
980
+ function xr(e) {
939
981
  const t = e.indexOf("#"), r = t === -1 ? e : e.slice(0, t), n = r.indexOf("?");
940
982
  return {
941
983
  hash: t === -1 ? "" : e.slice(t),
@@ -943,133 +985,133 @@ function yr(e) {
943
985
  search: n === -1 ? "" : r.slice(n)
944
986
  };
945
987
  }
946
- function wr(e) {
988
+ function Ar(e) {
947
989
  if (!e)
948
990
  return "";
949
991
  if (typeof e == "string")
950
992
  return e.startsWith("?") ? e : `?${e}`;
951
- const r = (e instanceof URLSearchParams ? e : Sr(e)).toString();
993
+ const r = (e instanceof URLSearchParams ? e : Pr(e)).toString();
952
994
  return r ? `?${r}` : "";
953
995
  }
954
- function Sr(e) {
996
+ function Pr(e) {
955
997
  const t = new URLSearchParams();
956
998
  for (const [r, n] of Object.entries(e)) {
957
999
  const s = Array.isArray(n) ? n : [n];
958
- for (const i of s)
959
- i != null && t.append(r, String(i));
1000
+ for (const o of s)
1001
+ o != null && t.append(r, String(o));
960
1002
  }
961
1003
  return t;
962
1004
  }
963
- function Er(e, t) {
1005
+ function Cr(e, t) {
964
1006
  return t ? e.replace(
965
1007
  /\[(\.\.\.)?([a-zA-Z_$][a-zA-Z0-9_$]*)\]/g,
966
1008
  (r, n, s) => {
967
- const i = t[s];
968
- if (i === void 0)
1009
+ const o = t[s];
1010
+ if (o === void 0)
969
1011
  throw new Error(`Missing path value for "${s}" in route "${e}".`);
970
- return n ? String(i).split("/").filter(Boolean).map((o) => encodeURIComponent(o)).join("/") : encodeURIComponent(String(i));
1012
+ return n ? String(o).split("/").filter(Boolean).map((i) => encodeURIComponent(i)).join("/") : encodeURIComponent(String(o));
971
1013
  }
972
1014
  ) : e;
973
1015
  }
974
- function gi(e, t) {
1016
+ function Mo(e, t) {
975
1017
  return {
976
1018
  cors: t?.cors,
977
1019
  kind: "json",
978
1020
  security: t?.security,
979
- timing: S(t?.timing),
1021
+ timing: E(t?.timing),
980
1022
  value: e,
981
1023
  init: b(t)
982
1024
  };
983
1025
  }
984
- function yi(e, t) {
1026
+ function Io(e, t) {
985
1027
  return {
986
1028
  cors: t?.cors,
987
1029
  init: b(t),
988
1030
  kind: "jsonl",
989
1031
  lines: e,
990
1032
  security: t?.security,
991
- timing: S(t?.timing)
1033
+ timing: E(t?.timing)
992
1034
  };
993
1035
  }
994
- function wi(e, t) {
1036
+ function Uo(e, t) {
995
1037
  return {
996
1038
  cors: t?.cors,
997
1039
  kind: "text",
998
1040
  security: t?.security,
999
- timing: S(t?.timing),
1041
+ timing: E(t?.timing),
1000
1042
  value: e,
1001
1043
  init: b(t)
1002
1044
  };
1003
1045
  }
1004
- function Si(e, t) {
1046
+ function Fo(e, t) {
1005
1047
  return {
1006
1048
  cors: t?.cors,
1007
1049
  kind: "html",
1008
1050
  security: t?.security,
1009
- timing: S(t?.timing),
1051
+ timing: E(t?.timing),
1010
1052
  value: e,
1011
1053
  init: b(t)
1012
1054
  };
1013
1055
  }
1014
- function Ei(e, t) {
1056
+ function Ho(e, t) {
1015
1057
  const r = typeof t == "number" ? void 0 : t;
1016
1058
  return {
1017
1059
  cors: r?.cors,
1018
1060
  kind: "redirect",
1019
1061
  security: r?.security,
1020
- timing: S(r?.timing),
1021
- to: kr(e) ? gr(e) : e,
1062
+ timing: E(r?.timing),
1063
+ to: Fr(e) ? Tr(e) : e,
1022
1064
  init: typeof t == "number" ? { status: t } : b(t)
1023
1065
  };
1024
1066
  }
1025
- function Ri(e, t) {
1067
+ function jo(e, t) {
1026
1068
  return {
1027
1069
  cors: t?.cors,
1028
1070
  kind: "not-found",
1029
1071
  security: t?.security,
1030
- timing: S(t?.timing),
1072
+ timing: E(t?.timing),
1031
1073
  body: e,
1032
1074
  init: b(t)
1033
1075
  };
1034
1076
  }
1035
- function vi(e, t) {
1077
+ function Wo(e, t) {
1036
1078
  return {
1037
1079
  cors: t?.cors,
1038
1080
  kind: "response",
1039
1081
  response: e,
1040
1082
  security: t?.security,
1041
- timing: S(t?.timing)
1083
+ timing: E(t?.timing)
1042
1084
  };
1043
1085
  }
1044
- function bi(e, t) {
1086
+ function zo(e, t) {
1045
1087
  return {
1046
1088
  body: e,
1047
1089
  cors: t?.cors,
1048
1090
  init: b(t),
1049
1091
  kind: "stream",
1050
1092
  security: t?.security,
1051
- timing: S(t?.timing)
1093
+ timing: E(t?.timing)
1052
1094
  };
1053
1095
  }
1054
- function Ti(e, t) {
1096
+ function Bo(e, t) {
1055
1097
  return {
1056
1098
  cors: t?.cors,
1057
1099
  events: e,
1058
1100
  init: b(t),
1059
1101
  kind: "sse",
1060
1102
  security: t?.security,
1061
- timing: S(t?.timing)
1103
+ timing: E(t?.timing)
1062
1104
  };
1063
1105
  }
1064
- function xi(...e) {
1106
+ function qo(...e) {
1065
1107
  return e;
1066
1108
  }
1067
- async function Rr(e, t) {
1109
+ async function Dr(e, t) {
1068
1110
  switch (e.kind) {
1069
1111
  case "json":
1070
- return new Response(JSON.stringify(await y(e.value, t)), {
1112
+ return new Response(JSON.stringify(await w(e.value, t)), {
1071
1113
  ...e.init,
1072
- headers: oe(
1114
+ headers: ce(
1073
1115
  e.init?.headers,
1074
1116
  "content-type",
1075
1117
  "application/json; charset=utf-8"
@@ -1077,10 +1119,10 @@ async function Rr(e, t) {
1077
1119
  });
1078
1120
  case "jsonl":
1079
1121
  return new Response(
1080
- br(await y(e.lines, t)),
1122
+ kr(await w(e.lines, t)),
1081
1123
  {
1082
1124
  ...e.init,
1083
- headers: G(e.init?.headers, {
1125
+ headers: K(e.init?.headers, {
1084
1126
  "cache-control": "no-cache",
1085
1127
  "content-type": "application/x-ndjson; charset=utf-8",
1086
1128
  "x-accel-buffering": "no"
@@ -1088,18 +1130,18 @@ async function Rr(e, t) {
1088
1130
  }
1089
1131
  );
1090
1132
  case "text":
1091
- return new Response(await y(e.value, t), {
1133
+ return new Response(await w(e.value, t), {
1092
1134
  ...e.init,
1093
- headers: oe(
1135
+ headers: ce(
1094
1136
  e.init?.headers,
1095
1137
  "content-type",
1096
1138
  "text/plain; charset=utf-8"
1097
1139
  )
1098
1140
  });
1099
1141
  case "html":
1100
- return new Response(await y(e.value, t), {
1142
+ return new Response(await w(e.value, t), {
1101
1143
  ...e.init,
1102
- headers: oe(
1144
+ headers: ce(
1103
1145
  e.init?.headers,
1104
1146
  "content-type",
1105
1147
  "text/html; charset=utf-8"
@@ -1107,7 +1149,7 @@ async function Rr(e, t) {
1107
1149
  });
1108
1150
  case "redirect": {
1109
1151
  const r = new Headers(e.init?.headers);
1110
- return r.set("location", String(await y(e.to, t))), new Response(null, {
1152
+ return r.set("location", String(await w(e.to, t))), new Response(null, {
1111
1153
  ...e.init,
1112
1154
  headers: r,
1113
1155
  status: e.init?.status ?? 302
@@ -1115,20 +1157,20 @@ async function Rr(e, t) {
1115
1157
  }
1116
1158
  case "not-found":
1117
1159
  return new Response(
1118
- e.body ? await y(e.body, t) : null,
1160
+ e.body ? await w(e.body, t) : null,
1119
1161
  {
1120
1162
  ...e.init,
1121
1163
  status: e.init?.status ?? 404
1122
1164
  }
1123
1165
  );
1124
1166
  case "response":
1125
- return await y(e.response, t);
1167
+ return await w(e.response, t);
1126
1168
  case "stream":
1127
1169
  return new Response(
1128
- Tr(await y(e.body, t)),
1170
+ Nr(await w(e.body, t)),
1129
1171
  {
1130
1172
  ...e.init,
1131
- headers: G(e.init?.headers, {
1173
+ headers: K(e.init?.headers, {
1132
1174
  "content-type": "application/octet-stream",
1133
1175
  "x-accel-buffering": "no"
1134
1176
  })
@@ -1136,10 +1178,10 @@ async function Rr(e, t) {
1136
1178
  );
1137
1179
  case "sse":
1138
1180
  return new Response(
1139
- vr(await y(e.events, t)),
1181
+ $r(await w(e.events, t)),
1140
1182
  {
1141
1183
  ...e.init,
1142
- headers: G(e.init?.headers, {
1184
+ headers: K(e.init?.headers, {
1143
1185
  "cache-control": "no-cache",
1144
1186
  "content-type": "text/event-stream; charset=utf-8",
1145
1187
  "x-accel-buffering": "no"
@@ -1148,22 +1190,22 @@ async function Rr(e, t) {
1148
1190
  );
1149
1191
  }
1150
1192
  }
1151
- async function y(e, t) {
1193
+ async function w(e, t) {
1152
1194
  return typeof e != "function" ? e : await e(
1153
1195
  t
1154
1196
  );
1155
1197
  }
1156
- function oe(e, t, r) {
1157
- return G(e, { [t]: r });
1198
+ function ce(e, t, r) {
1199
+ return K(e, { [t]: r });
1158
1200
  }
1159
- function G(e, t) {
1201
+ function K(e, t) {
1160
1202
  const r = new Headers(e);
1161
1203
  for (const [n, s] of Object.entries(t))
1162
1204
  r.has(n) || r.set(n, s);
1163
1205
  return r;
1164
1206
  }
1165
- function vr(e) {
1166
- const t = new TextEncoder(), r = Re(e);
1207
+ function $r(e) {
1208
+ const t = new TextEncoder(), r = xe(e);
1167
1209
  return new ReadableStream({
1168
1210
  async pull(n) {
1169
1211
  const s = await r.next();
@@ -1171,15 +1213,15 @@ function vr(e) {
1171
1213
  n.close();
1172
1214
  return;
1173
1215
  }
1174
- n.enqueue(t.encode(Ar(s.value)));
1216
+ n.enqueue(t.encode(Mr(s.value)));
1175
1217
  },
1176
1218
  async cancel() {
1177
1219
  await r.return?.();
1178
1220
  }
1179
1221
  });
1180
1222
  }
1181
- function br(e) {
1182
- const t = new TextEncoder(), r = Re(e);
1223
+ function kr(e) {
1224
+ const t = new TextEncoder(), r = xe(e);
1183
1225
  return new ReadableStream({
1184
1226
  async pull(n) {
1185
1227
  const s = await r.next();
@@ -1195,8 +1237,8 @@ function br(e) {
1195
1237
  }
1196
1238
  });
1197
1239
  }
1198
- function Tr(e) {
1199
- const t = new TextEncoder(), r = Re(e);
1240
+ function Nr(e) {
1241
+ const t = new TextEncoder(), r = xe(e);
1200
1242
  return new ReadableStream({
1201
1243
  async pull(n) {
1202
1244
  const s = await r.next();
@@ -1204,17 +1246,17 @@ function Tr(e) {
1204
1246
  n.close();
1205
1247
  return;
1206
1248
  }
1207
- n.enqueue(xr(s.value, t));
1249
+ n.enqueue(Or(s.value, t));
1208
1250
  },
1209
1251
  async cancel() {
1210
1252
  await r.return?.();
1211
1253
  }
1212
1254
  });
1213
1255
  }
1214
- function xr(e, t) {
1256
+ function Or(e, t) {
1215
1257
  return typeof e == "string" ? t.encode(e) : e;
1216
1258
  }
1217
- function Re(e) {
1259
+ function xe(e) {
1218
1260
  if (e instanceof ReadableStream) {
1219
1261
  const t = e.getReader();
1220
1262
  return {
@@ -1226,9 +1268,9 @@ function Re(e) {
1226
1268
  }
1227
1269
  };
1228
1270
  }
1229
- return Symbol.asyncIterator in e ? e[Symbol.asyncIterator]() : Pr(e[Symbol.iterator]());
1271
+ return Symbol.asyncIterator in e ? e[Symbol.asyncIterator]() : Lr(e[Symbol.iterator]());
1230
1272
  }
1231
- function Pr(e) {
1273
+ function Lr(e) {
1232
1274
  return {
1233
1275
  async next() {
1234
1276
  return e.next();
@@ -1238,35 +1280,35 @@ function Pr(e) {
1238
1280
  }
1239
1281
  };
1240
1282
  }
1241
- function Ar(e) {
1283
+ function Mr(e) {
1242
1284
  if (typeof e == "string")
1243
- return Cr(e);
1285
+ return Ir(e);
1244
1286
  const t = [];
1245
- if (e.comment !== void 0 && t.push(...N("", e.comment)), e.id !== void 0 && t.push(...N("id", e.id)), e.event !== void 0 && t.push(...N("event", e.event)), e.retry !== void 0) {
1287
+ if (e.comment !== void 0 && t.push(...M("", e.comment)), e.id !== void 0 && t.push(...M("id", e.id)), e.event !== void 0 && t.push(...M("event", e.event)), e.retry !== void 0) {
1246
1288
  if (!Number.isInteger(e.retry) || e.retry < 0)
1247
1289
  throw new Error("SSE retry must be a non-negative integer.");
1248
1290
  t.push(`retry: ${e.retry}`);
1249
1291
  }
1250
- return e.data !== void 0 && t.push(...N("data", $r(e.data))), `${t.join(`
1292
+ return e.data !== void 0 && t.push(...M("data", Ur(e.data))), `${t.join(`
1251
1293
  `)}
1252
1294
 
1253
1295
  `;
1254
1296
  }
1255
- function Cr(e) {
1256
- return `${N("data", e).join(`
1297
+ function Ir(e) {
1298
+ return `${M("data", e).join(`
1257
1299
  `)}
1258
1300
 
1259
1301
  `;
1260
1302
  }
1261
- function N(e, t) {
1303
+ function M(e, t) {
1262
1304
  return t.split(/\r\n|\r|\n/).map(
1263
1305
  (r) => e ? `${e}: ${r}` : `: ${r}`
1264
1306
  );
1265
1307
  }
1266
- function $r(e) {
1308
+ function Ur(e) {
1267
1309
  return typeof e == "string" ? e : JSON.stringify(e);
1268
1310
  }
1269
- function kr(e) {
1311
+ function Fr(e) {
1270
1312
  return typeof e == "object" && e !== null && !(e instanceof URL) && "to" in e;
1271
1313
  }
1272
1314
  function b(e) {
@@ -1280,10 +1322,10 @@ function b(e) {
1280
1322
  } = e;
1281
1323
  return s;
1282
1324
  }
1283
- function Dr(e, t) {
1325
+ function Hr(e, t) {
1284
1326
  if (!t?.length)
1285
1327
  return e;
1286
- const r = new Headers(e.headers), n = Nr(t), s = r.get("server-timing");
1328
+ const r = new Headers(e.headers), n = jr(t), s = r.get("server-timing");
1287
1329
  return r.set(
1288
1330
  "server-timing",
1289
1331
  s ? `${s}, ${n}` : n
@@ -1293,15 +1335,15 @@ function Dr(e, t) {
1293
1335
  statusText: e.statusText
1294
1336
  });
1295
1337
  }
1296
- function Nr(e) {
1297
- return e.map(Or).join(", ");
1338
+ function jr(e) {
1339
+ return e.map(Wr).join(", ");
1298
1340
  }
1299
- function S(e) {
1341
+ function E(e) {
1300
1342
  if (e)
1301
1343
  return Array.isArray(e) ? e : [e];
1302
1344
  }
1303
- function Or(e) {
1304
- if (!Lr(e.name))
1345
+ function Wr(e) {
1346
+ if (!zr(e.name))
1305
1347
  throw new Error(
1306
1348
  `Server-Timing metric name "${e.name}" is not a valid token.`
1307
1349
  );
@@ -1309,20 +1351,20 @@ function Or(e) {
1309
1351
  if (e.duration !== void 0) {
1310
1352
  if (!Number.isFinite(e.duration) || e.duration < 0)
1311
1353
  throw new Error("Server-Timing metric duration must be a non-negative finite number.");
1312
- t.push(`dur=${Ir(e.duration)}`);
1354
+ t.push(`dur=${Br(e.duration)}`);
1313
1355
  }
1314
- return e.description !== void 0 && t.push(`desc="${Mr(e.description)}"`), t.join(";");
1356
+ return e.description !== void 0 && t.push(`desc="${qr(e.description)}"`), t.join(";");
1315
1357
  }
1316
- function Lr(e) {
1358
+ function zr(e) {
1317
1359
  return /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/.test(e);
1318
1360
  }
1319
- function Ir(e) {
1361
+ function Br(e) {
1320
1362
  return Number.isInteger(e), String(e);
1321
1363
  }
1322
- function Mr(e) {
1364
+ function qr(e) {
1323
1365
  return e.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
1324
1366
  }
1325
- const Ur = [
1367
+ const Gr = [
1326
1368
  400,
1327
1369
  401,
1328
1370
  402,
@@ -1363,7 +1405,7 @@ const Ur = [
1363
1405
  508,
1364
1406
  510,
1365
1407
  511
1366
- ], Hr = {
1408
+ ], _r = {
1367
1409
  400: "Bad Request",
1368
1410
  401: "Unauthorized",
1369
1411
  402: "Payment Required",
@@ -1404,8 +1446,8 @@ const Ur = [
1404
1446
  508: "Loop Detected",
1405
1447
  510: "Not Extended",
1406
1448
  511: "Network Authentication Required"
1407
- }, jr = new Set(Ur);
1408
- class it extends Error {
1449
+ }, Vr = new Set(Gr);
1450
+ class lt extends Error {
1409
1451
  detail;
1410
1452
  extensions;
1411
1453
  headers;
@@ -1413,59 +1455,59 @@ class it extends Error {
1413
1455
  title;
1414
1456
  type;
1415
1457
  constructor(t, r = {}, n = {}) {
1416
- Fr(t);
1458
+ Jr(t);
1417
1459
  const s = typeof r == "string" ? { detail: r } : r, {
1418
- detail: i,
1419
- title: o = Hr[t],
1460
+ detail: o,
1461
+ title: i = _r[t],
1420
1462
  type: a = "about:blank",
1421
1463
  ...c
1422
1464
  } = s;
1423
- super(i ?? o, { cause: n.cause }), this.name = "HttpError", this.detail = i, this.extensions = Object.freeze({ ...c }), this.headers = new Headers(n.headers), this.status = t, this.title = o, this.type = a;
1465
+ super(o ?? i, { cause: n.cause }), this.name = "HttpError", this.detail = o, this.extensions = Object.freeze({ ...c }), this.headers = new Headers(n.headers), this.status = t, this.title = i, this.type = a;
1424
1466
  }
1425
1467
  }
1426
- function Pi(e, t, r) {
1427
- return new it(e, t, r);
1468
+ function Go(e, t, r) {
1469
+ return new lt(e, t, r);
1428
1470
  }
1429
- function ve(e) {
1430
- return e instanceof it;
1471
+ function Ae(e) {
1472
+ return e instanceof lt;
1431
1473
  }
1432
- function Fr(e) {
1433
- if (!jr.has(e))
1474
+ function Jr(e) {
1475
+ if (!Vr.has(e))
1434
1476
  throw new RangeError(
1435
1477
  `HTTP error status must be a standard 4xx or 5xx status; received ${JSON.stringify(e)}.`
1436
1478
  );
1437
1479
  }
1438
- function Le({ pathname: e }) {
1439
- return /* @__PURE__ */ I("main", { children: [
1440
- /* @__PURE__ */ M("h1", { children: "404" }),
1441
- /* @__PURE__ */ I("p", { children: [
1480
+ function He({ pathname: e }) {
1481
+ return /* @__PURE__ */ H("main", { children: [
1482
+ /* @__PURE__ */ j("h1", { children: "404" }),
1483
+ /* @__PURE__ */ H("p", { children: [
1442
1484
  "No route matched ",
1443
1485
  e,
1444
1486
  "."
1445
1487
  ] })
1446
1488
  ] });
1447
1489
  }
1448
- function Ie({ status: e }) {
1449
- return /* @__PURE__ */ I("main", { children: [
1450
- /* @__PURE__ */ M("h1", { children: e }),
1451
- /* @__PURE__ */ M("p", { children: "Something went wrong." })
1490
+ function je({ status: e }) {
1491
+ return /* @__PURE__ */ H("main", { children: [
1492
+ /* @__PURE__ */ j("h1", { children: e }),
1493
+ /* @__PURE__ */ j("p", { children: "Something went wrong." })
1452
1494
  ] });
1453
1495
  }
1454
- function Wr({ error: e, pathname: t, status: r }) {
1455
- const { message: n, name: s, stack: i } = ot(e);
1456
- return /* @__PURE__ */ I("main", { children: [
1457
- /* @__PURE__ */ I("h1", { children: [
1496
+ function Kr({ error: e, pathname: t, status: r }) {
1497
+ const { message: n, name: s, stack: o } = ft(e);
1498
+ return /* @__PURE__ */ H("main", { children: [
1499
+ /* @__PURE__ */ H("h1", { children: [
1458
1500
  r,
1459
1501
  " ",
1460
1502
  s,
1461
1503
  " at ",
1462
1504
  t
1463
1505
  ] }),
1464
- /* @__PURE__ */ M("p", { children: n }),
1465
- i ? /* @__PURE__ */ M("pre", { children: i }) : null
1506
+ /* @__PURE__ */ j("p", { children: n }),
1507
+ o ? /* @__PURE__ */ j("pre", { children: o }) : null
1466
1508
  ] });
1467
1509
  }
1468
- function ot(e) {
1510
+ function ft(e) {
1469
1511
  return e instanceof Error ? {
1470
1512
  message: e.message,
1471
1513
  name: e.name,
@@ -1476,27 +1518,27 @@ function ot(e) {
1476
1518
  stack: void 0
1477
1519
  };
1478
1520
  }
1479
- const qr = ["text/html", "application/xhtml+xml"];
1480
- function at(e) {
1481
- return zr(e.headers.get("accept"));
1521
+ const Yr = ["text/html", "application/xhtml+xml"];
1522
+ function dt(e) {
1523
+ return Zr(e.headers.get("accept"));
1482
1524
  }
1483
- function zr(e) {
1484
- return e ? Br(e).some(
1485
- (t) => t.quality > 0 && qr.includes(t.type)
1525
+ function Zr(e) {
1526
+ return e ? Qr(e).some(
1527
+ (t) => t.quality > 0 && Yr.includes(t.type)
1486
1528
  ) : !1;
1487
1529
  }
1488
- function Br(e) {
1530
+ function Qr(e) {
1489
1531
  return e.split(",").flatMap((t) => {
1490
1532
  const [r, ...n] = t.split(";"), s = r.trim().toLowerCase();
1491
1533
  return s ? [
1492
1534
  {
1493
- quality: Gr(n),
1535
+ quality: Xr(n),
1494
1536
  type: s
1495
1537
  }
1496
1538
  ] : [];
1497
1539
  });
1498
1540
  }
1499
- function Gr(e) {
1541
+ function Xr(e) {
1500
1542
  for (const t of e) {
1501
1543
  const [r, n] = t.split("=");
1502
1544
  if (r?.trim().toLowerCase() !== "q")
@@ -1506,14 +1548,14 @@ function Gr(e) {
1506
1548
  }
1507
1549
  return 1;
1508
1550
  }
1509
- const _r = "application/problem+json";
1510
- function Vr({
1551
+ const en = "application/problem+json";
1552
+ function tn({
1511
1553
  detail: e,
1512
1554
  instance: t,
1513
1555
  status: r,
1514
1556
  title: n,
1515
1557
  type: s = "about:blank",
1516
- ...i
1558
+ ...o
1517
1559
  }) {
1518
1560
  return {
1519
1561
  type: s,
@@ -1521,29 +1563,29 @@ function Vr({
1521
1563
  status: r,
1522
1564
  ...e === void 0 ? {} : { detail: e },
1523
1565
  ...t === void 0 ? {} : { instance: t },
1524
- ...i
1566
+ ...o
1525
1567
  };
1526
1568
  }
1527
- function J(e, t) {
1569
+ function Z(e, t) {
1528
1570
  const r = new Headers(t?.headers);
1529
- return r.set("content-type", `${_r}; charset=utf-8`), new Response(JSON.stringify(Vr(e)), {
1571
+ return r.set("content-type", `${en}; charset=utf-8`), new Response(JSON.stringify(tn(e)), {
1530
1572
  ...t,
1531
1573
  headers: r,
1532
1574
  status: e.status
1533
1575
  });
1534
1576
  }
1535
- const Jr = "Internal Server Error";
1536
- function ct(e) {
1577
+ const rn = "Internal Server Error";
1578
+ function ht(e) {
1537
1579
  return e === !0 && process.env.NODE_ENV !== "production";
1538
1580
  }
1539
- async function _(e, t, r, n, s = {}) {
1581
+ async function Y(e, t, r, n, s = {}) {
1540
1582
  s.onError?.(r, n);
1541
- const i = new URL(t.url);
1542
- return n === "page" || n === "middleware" && at(t) ? await Yr(e, i, r, s) : Kr(i, r, s);
1583
+ const o = new URL(t.url);
1584
+ return n === "page" || n === "middleware" && dt(t) ? await sn(e, o, r, s) : nn(o, r, s);
1543
1585
  }
1544
- function Kr(e, t, r = {}) {
1545
- if (ve(t))
1546
- return J(
1586
+ function nn(e, t, r = {}) {
1587
+ if (Ae(t))
1588
+ return Z(
1547
1589
  {
1548
1590
  ...t.extensions,
1549
1591
  detail: t.detail,
@@ -1554,72 +1596,72 @@ function Kr(e, t, r = {}) {
1554
1596
  },
1555
1597
  { headers: t.headers }
1556
1598
  );
1557
- const { message: n } = ot(t);
1558
- return J({
1599
+ const { message: n } = ft(t);
1600
+ return Z({
1559
1601
  // `detail` carries the thrown message, so it is dev only for the same
1560
1602
  // reason the stack is.
1561
- ...ct(r.dev) ? { detail: n } : {},
1603
+ ...ht(r.dev) ? { detail: n } : {},
1562
1604
  instance: `${e.pathname}${e.search}`,
1563
1605
  status: 500,
1564
1606
  title: "Internal Server Error"
1565
1607
  });
1566
1608
  }
1567
- async function Yr(e, t, r, n) {
1568
- const s = ut(r);
1609
+ async function sn(e, t, r, n) {
1610
+ const s = mt(r);
1569
1611
  try {
1570
- const i = await Qr(
1612
+ const o = await an(
1571
1613
  e,
1572
1614
  t.pathname,
1573
1615
  r,
1574
1616
  n
1575
- ), o = ve(r) ? new Headers(r.headers) : new Headers();
1576
- return o.set("content-type", "text/html; charset=utf-8"), new Response(await n.transformDocument?.(i) ?? i, {
1577
- headers: o,
1617
+ ), i = Ae(r) ? new Headers(r.headers) : new Headers();
1618
+ return i.set("content-type", "text/html; charset=utf-8"), new Response(await n.transformDocument?.(o) ?? o, {
1619
+ headers: i,
1578
1620
  status: s
1579
1621
  });
1580
- } catch (i) {
1581
- return n.onError?.(i, "page"), Zr();
1622
+ } catch (o) {
1623
+ return n.onError?.(o, "page"), on();
1582
1624
  }
1583
1625
  }
1584
- function Zr() {
1585
- return new Response(Jr, {
1626
+ function on() {
1627
+ return new Response(rn, {
1586
1628
  headers: { "content-type": "text/plain; charset=utf-8" },
1587
1629
  status: 500
1588
1630
  });
1589
1631
  }
1590
- async function Qr(e, t, r, n) {
1591
- const s = await Xr(e, t, n), i = _e({
1632
+ async function an(e, t, r, n) {
1633
+ const s = await cn(e, t, n), o = Qe({
1592
1634
  dev: n.dev,
1593
1635
  nonce: n.nonce
1594
- }), o = Ke(
1595
- Ve(
1596
- i,
1597
- fe(s, { error: r, pathname: t, status: ut(r) })
1636
+ }), i = tt(
1637
+ Xe(
1638
+ o,
1639
+ de(s, { error: r, pathname: t, status: mt(r) })
1598
1640
  )
1599
1641
  );
1600
- return Je({
1601
- body: { data: void 0, html: o, navigation: n.navigation },
1642
+ return et({
1643
+ body: { data: void 0, html: i, navigation: n.navigation },
1602
1644
  entrySrc: n.clientEntry,
1603
1645
  lang: n.lang,
1604
1646
  nonce: n.nonce,
1605
- scripts: i.scripts(),
1647
+ scripts: o.scripts(),
1606
1648
  styles: n.styles,
1607
1649
  title: n.title
1608
1650
  });
1609
1651
  }
1610
- function ut(e) {
1611
- return ve(e) ? e.status : 500;
1652
+ function mt(e) {
1653
+ return Ae(e) ? e.status : 500;
1612
1654
  }
1613
- async function Xr(e, t, r) {
1614
- if (ct(r.dev))
1615
- return Wr;
1655
+ async function cn(e, t, r) {
1656
+ if (ht(r.dev))
1657
+ return Kr;
1616
1658
  try {
1617
- return await er(e, t) ?? Ie;
1659
+ return await cr(e, t) ?? je;
1618
1660
  } catch {
1619
- return Ie;
1661
+ return je;
1620
1662
  }
1621
1663
  }
1622
- const K = "{nonce}", Me = `'nonce-${K}'`, ft = {
1664
+ const Q = "{nonce}", We = `'nonce-${Q}'`, pt = {
1623
1665
  baseUri: ["'self'"],
1624
1666
  connectSrc: ["'self'"],
1625
1667
  defaultSrc: ["'self'"],
@@ -1628,14 +1670,14 @@ const K = "{nonce}", Me = `'nonce-${K}'`, ft = {
1628
1670
  frameAncestors: ["'none'"],
1629
1671
  imgSrc: ["'self'", "data:", "blob:"],
1630
1672
  objectSrc: ["'none'"],
1631
- scriptSrc: [Me, "'strict-dynamic'"],
1632
- styleSrc: ["'self'", Me],
1673
+ scriptSrc: [We, "'strict-dynamic'"],
1674
+ styleSrc: ["'self'", We],
1633
1675
  upgradeInsecureRequests: !0
1634
- }, en = {
1635
- ...ft,
1676
+ }, un = {
1677
+ ...pt,
1636
1678
  scriptSrc: ["'self'"],
1637
1679
  styleSrc: ["'self'"]
1638
- }, Ue = {
1680
+ }, ze = {
1639
1681
  contentTypeOptions: "nosniff",
1640
1682
  crossOriginOpenerPolicy: "same-origin",
1641
1683
  crossOriginResourcePolicy: "same-origin",
@@ -1646,43 +1688,43 @@ const K = "{nonce}", Me = `'nonce-${K}'`, ft = {
1646
1688
  maxAge: 31536e3,
1647
1689
  preload: !1
1648
1690
  }
1649
- }, tn = {
1691
+ }, ln = {
1650
1692
  contentTypeOptions: "nosniff",
1651
1693
  crossOriginResourcePolicy: "same-origin",
1652
1694
  referrerPolicy: "strict-origin-when-cross-origin"
1653
- }, D = {
1695
+ }, L = {
1654
1696
  api(e = {}) {
1655
- return O(
1697
+ return I(
1656
1698
  {
1657
- headers: tn
1699
+ headers: ln
1658
1700
  },
1659
1701
  e
1660
1702
  );
1661
1703
  },
1662
1704
  preset(e, t = {}) {
1663
- return e === "api" ? D.api(t) : e === "cross-origin-isolated" ? D.crossOriginIsolated(t) : e === "static" ? D.static(t) : D.strict(t);
1705
+ return e === "api" ? L.api(t) : e === "cross-origin-isolated" ? L.crossOriginIsolated(t) : e === "static" ? L.static(t) : L.strict(t);
1664
1706
  },
1665
1707
  static(e = {}) {
1666
- return O(
1708
+ return I(
1667
1709
  {
1668
- csp: en,
1669
- headers: Ue
1710
+ csp: un,
1711
+ headers: ze
1670
1712
  },
1671
1713
  e
1672
1714
  );
1673
1715
  },
1674
1716
  strict(e = {}) {
1675
- return O(
1717
+ return I(
1676
1718
  {
1677
- csp: ft,
1678
- headers: Ue
1719
+ csp: pt,
1720
+ headers: ze
1679
1721
  },
1680
1722
  e
1681
1723
  );
1682
1724
  },
1683
1725
  crossOriginIsolated(e = {}) {
1684
- return O(
1685
- D.strict({
1726
+ return I(
1727
+ L.strict({
1686
1728
  headers: {
1687
1729
  crossOriginEmbedderPolicy: "require-corp",
1688
1730
  crossOriginOpenerPolicy: "same-origin"
@@ -1692,41 +1734,42 @@ const K = "{nonce}", Me = `'nonce-${K}'`, ft = {
1692
1734
  );
1693
1735
  }
1694
1736
  };
1695
- function Ai(e) {
1737
+ function _o(e) {
1696
1738
  return e;
1697
1739
  }
1698
- function Ci(e) {
1740
+ function Vo(e) {
1699
1741
  return e;
1700
1742
  }
1701
- function rn(...e) {
1702
- return e.reduce((t, r) => r ? O(t, r) : t, {});
1743
+ function fn(...e) {
1744
+ return e.reduce((t, r) => r ? I(t, r) : t, {});
1703
1745
  }
1704
- function Y(...e) {
1746
+ function X(...e) {
1705
1747
  const t = e.reduce((r, n) => n ? {
1706
- document: rn(r.document, n.document),
1707
- security: nn(r.security, n.security)
1748
+ document: fn(r.document, n.document),
1749
+ security: dn(r.security, n.security)
1708
1750
  } : r, {});
1709
1751
  return {
1710
1752
  ...t,
1711
- document: on(t.document, t.security?.needs)
1753
+ document: mn(t.document, t.security?.needs)
1712
1754
  };
1713
1755
  }
1714
- function nn(...e) {
1756
+ function dn(...e) {
1715
1757
  return e.reduce((t, r) => r ? {
1716
1758
  csrf: r.csrf ?? t.csrf,
1717
- needs: sn(t.needs, r.needs),
1759
+ fetchMetadata: r.fetchMetadata ?? t.fetchMetadata,
1760
+ needs: hn(t.needs, r.needs),
1718
1761
  rateLimit: r.rateLimit ?? t.rateLimit,
1719
- request: mt(t.request, r.request)
1762
+ request: wt(t.request, r.request)
1720
1763
  } : t, {});
1721
1764
  }
1722
- const lt = [
1765
+ const gt = [
1723
1766
  { directive: "connectSrc", need: "connect" },
1724
1767
  { directive: "imgSrc", need: "img" },
1725
1768
  { directive: "scriptSrc", need: "script" }
1726
1769
  ];
1727
- function sn(e, t) {
1770
+ function hn(e, t) {
1728
1771
  const r = {};
1729
- for (const { need: n } of lt) {
1772
+ for (const { need: n } of gt) {
1730
1773
  const s = [.../* @__PURE__ */ new Set([
1731
1774
  ...e?.[n] ?? [],
1732
1775
  ...t?.[n] ?? []
@@ -1735,15 +1778,15 @@ function sn(e, t) {
1735
1778
  }
1736
1779
  return Object.keys(r).length > 0 ? r : void 0;
1737
1780
  }
1738
- function on(e, t) {
1781
+ function mn(e, t) {
1739
1782
  if (!e?.csp || !t)
1740
1783
  return e;
1741
1784
  let r = e.csp;
1742
- for (const { directive: n, need: s } of lt)
1743
- r = an(r, n, s, t[s]);
1785
+ for (const { directive: n, need: s } of gt)
1786
+ r = pn(r, n, s, t[s]);
1744
1787
  return r === e.csp ? e : { ...e, csp: r };
1745
1788
  }
1746
- function an(e, t, r, n) {
1789
+ function pn(e, t, r, n) {
1747
1790
  if (!n || n.length === 0)
1748
1791
  return e;
1749
1792
  if (e[t] === !1)
@@ -1760,89 +1803,89 @@ function an(e, t, r, n) {
1760
1803
  [t]: [.../* @__PURE__ */ new Set([...s, ...n])]
1761
1804
  } : e;
1762
1805
  }
1763
- async function $i(e, t = "sha256") {
1806
+ async function Jo(e, t = "sha256") {
1764
1807
  const r = await globalThis.crypto.subtle.digest(
1765
- Rn(t),
1808
+ $n(t),
1766
1809
  new TextEncoder().encode(e)
1767
1810
  );
1768
- return `'${t}-${vn(new Uint8Array(r))}'`;
1811
+ return `'${t}-${kn(new Uint8Array(r))}'`;
1769
1812
  }
1770
- function W(e, t = {}) {
1771
- e.csp && wn(e.csp), yn(e);
1772
- const r = new Headers(), n = e.csp !== !1 && e.csp ? hn(e.csp, t) : void 0, s = dn(e.trustedTypes), i = e.trustedTypes ? e.trustedTypes.mode === "report-only" : !1;
1773
- return w(
1813
+ function q(e, t = {}) {
1814
+ e.csp && Pn(e.csp), An(e);
1815
+ const r = new Headers(), n = e.csp !== !1 && e.csp ? bn(e.csp, t) : void 0, s = En(e.trustedTypes), o = e.trustedTypes ? e.trustedTypes.mode === "report-only" : !1;
1816
+ return S(
1774
1817
  r,
1775
1818
  "content-security-policy",
1776
- Z(n, i ? void 0 : s)
1777
- ), w(
1819
+ ee(n, o ? void 0 : s)
1820
+ ), S(
1778
1821
  r,
1779
1822
  "content-security-policy-report-only",
1780
- i ? Z(s, pt(e.csp)) : void 0
1781
- ), ln(r, e.headers, t), r;
1823
+ o ? ee(s, Et(e.csp)) : void 0
1824
+ ), Sn(r, e.headers, t), r;
1782
1825
  }
1783
- function ee(e) {
1784
- return !e || !e.csp ? !1 : q(e.csp).some(([, t]) => {
1826
+ function ne(e) {
1827
+ return !e || !e.csp ? !1 : G(e.csp).some(([, t]) => {
1785
1828
  const r = x(t);
1786
- return Array.isArray(r) && r.some((n) => n.includes(K));
1829
+ return Array.isArray(r) && r.some((n) => n.includes(Q));
1787
1830
  });
1788
1831
  }
1789
- function dt() {
1832
+ function yt() {
1790
1833
  const e = new Uint8Array(16);
1791
1834
  return globalThis.crypto.getRandomValues(e), btoa(String.fromCharCode(...e));
1792
1835
  }
1793
- function O(e, t) {
1836
+ function I(e, t) {
1794
1837
  return {
1795
- csp: un(e.csp, t.csp),
1796
- headers: cn(e.headers, t.headers),
1838
+ csp: yn(e.csp, t.csp),
1839
+ headers: gn(e.headers, t.headers),
1797
1840
  trustedTypes: t.trustedTypes ?? e.trustedTypes
1798
1841
  };
1799
1842
  }
1800
- function cn(e, t) {
1801
- const r = mt(e, t);
1843
+ function gn(e, t) {
1844
+ const r = wt(e, t);
1802
1845
  return !r || t?.reportingEndpoints === !1 || e?.reportingEndpoints && t?.reportingEndpoints && (r.reportingEndpoints = {
1803
1846
  ...e.reportingEndpoints,
1804
1847
  ...t.reportingEndpoints
1805
1848
  }), r;
1806
1849
  }
1807
- function mt(e, t) {
1850
+ function wt(e, t) {
1808
1851
  return t ? {
1809
1852
  ...e ?? {},
1810
1853
  ...t
1811
1854
  } : e;
1812
1855
  }
1813
- function un(e, t) {
1856
+ function yn(e, t) {
1814
1857
  if (t === !1)
1815
1858
  return !1;
1816
1859
  if (!t)
1817
1860
  return e;
1818
1861
  if (!e)
1819
- return ae(t);
1820
- const r = ae(e), n = ae(t), s = {
1862
+ return ue(t);
1863
+ const r = ue(e), n = ue(t), s = {
1821
1864
  ...r,
1822
1865
  ...n
1823
1866
  };
1824
- for (const [i, o] of q(t)) {
1867
+ for (const [o, i] of G(t)) {
1825
1868
  const a = x(
1826
- r[i]
1869
+ r[o]
1827
1870
  );
1828
- !be(o) && Array.isArray(a) && Array.isArray(o) && ht(
1871
+ !Pe(i) && Array.isArray(a) && Array.isArray(i) && St(
1829
1872
  s,
1830
- i,
1831
- fn([...a, ...o])
1873
+ o,
1874
+ wn([...a, ...i])
1832
1875
  );
1833
1876
  }
1834
1877
  return s;
1835
1878
  }
1836
- function ae(e) {
1879
+ function ue(e) {
1837
1880
  const t = { ...e };
1838
- for (const [r, n] of q(e))
1839
- be(n) && ht(t, r, n.replace);
1881
+ for (const [r, n] of G(e))
1882
+ Pe(n) && St(t, r, n.replace);
1840
1883
  return t;
1841
1884
  }
1842
- function fn(e) {
1885
+ function wn(e) {
1843
1886
  return [...new Set(e)];
1844
1887
  }
1845
- function ht(e, t, r) {
1888
+ function St(e, t, r) {
1846
1889
  if (!(t === "reportTo" || t === "upgradeInsecureRequests")) {
1847
1890
  if (t === "reportUri") {
1848
1891
  e.reportUri = r;
@@ -1851,87 +1894,96 @@ function ht(e, t, r) {
1851
1894
  e[t] = r;
1852
1895
  }
1853
1896
  }
1854
- function ln(e, t, r) {
1855
- t && (w(e, "referrer-policy", t.referrerPolicy), w(e, "x-content-type-options", t.contentTypeOptions), w(e, "cross-origin-opener-policy", t.crossOriginOpenerPolicy), w(e, "cross-origin-embedder-policy", t.crossOriginEmbedderPolicy), w(e, "cross-origin-resource-policy", t.crossOriginResourcePolicy), w(e, "permissions-policy", t.permissionsPolicy), w(
1897
+ function Sn(e, t, r) {
1898
+ t && (S(e, "referrer-policy", t.referrerPolicy), S(e, "x-content-type-options", t.contentTypeOptions), S(e, "cross-origin-opener-policy", t.crossOriginOpenerPolicy), S(e, "cross-origin-embedder-policy", t.crossOriginEmbedderPolicy), S(e, "cross-origin-resource-policy", t.crossOriginResourcePolicy), S(e, "permissions-policy", t.permissionsPolicy), S(
1856
1899
  e,
1857
1900
  "reporting-endpoints",
1858
- pn(t.reportingEndpoints)
1901
+ Tn(t.reportingEndpoints)
1859
1902
  ), t.strictTransportSecurity && (!r.request || new URL(r.request.url).protocol === "https:") && e.set(
1860
1903
  "strict-transport-security",
1861
- mn(t.strictTransportSecurity)
1904
+ Rn(t.strictTransportSecurity)
1862
1905
  ));
1863
1906
  }
1864
- function dn(e) {
1907
+ function En(e) {
1865
1908
  if (!e)
1866
1909
  return;
1867
1910
  const t = [];
1868
- return e.requireFor?.includes("script") && t.push("require-trusted-types-for 'script'"), e.policies.length > 0 && t.push(`trusted-types ${e.policies.join(" ")}`), Z(...t);
1911
+ return e.requireFor?.includes("script") && t.push("require-trusted-types-for 'script'"), t.push(vn(e)), ee(...t);
1869
1912
  }
1870
- function Z(...e) {
1913
+ function vn(e) {
1914
+ if (e.policies !== void 0 && e.policies.length === 0)
1915
+ return "trusted-types 'none'";
1916
+ const t = [Ft];
1917
+ e.allowDefaultPolicy && t.push("default");
1918
+ for (const r of e.policies ?? [])
1919
+ t.push(r);
1920
+ return `trusted-types ${[...new Set(t)].join(" ")}`;
1921
+ }
1922
+ function ee(...e) {
1871
1923
  const t = e.filter((r) => r);
1872
1924
  return t.length > 0 ? t.join("; ") : void 0;
1873
1925
  }
1874
- function w(e, t, r) {
1926
+ function S(e, t, r) {
1875
1927
  r && e.set(t, r);
1876
1928
  }
1877
- function mn(e) {
1929
+ function Rn(e) {
1878
1930
  const t = [`max-age=${e.maxAge}`];
1879
1931
  return e.includeSubDomains && t.push("includeSubDomains"), e.preload && t.push("preload"), t.join("; ");
1880
1932
  }
1881
- function hn(e, t) {
1933
+ function bn(e, t) {
1882
1934
  const r = [];
1883
- for (const [s, i] of q(e)) {
1935
+ for (const [s, o] of G(e)) {
1884
1936
  if (s === "reportTo" || s === "reportUri")
1885
1937
  continue;
1886
- const o = x(i);
1887
- if (o === !1 || o === void 0)
1938
+ const i = x(o);
1939
+ if (i === !1 || i === void 0)
1888
1940
  continue;
1889
- const a = gt(s);
1890
- if (o === !0) {
1941
+ const a = vt(s);
1942
+ if (i === !0 || s === "sandbox" && Array.isArray(i) && i.length === 0) {
1891
1943
  r.push(a);
1892
1944
  continue;
1893
1945
  }
1894
1946
  r.push(
1895
- `${a} ${En(o, t).join(" ")}`
1947
+ `${a} ${Dn(i, t).join(" ")}`
1896
1948
  );
1897
1949
  }
1898
- const n = pt(e);
1950
+ const n = Et(e);
1899
1951
  return n && r.push(n), r.join("; ");
1900
1952
  }
1901
- function pt(e) {
1953
+ function Et(e) {
1902
1954
  if (!e)
1903
1955
  return;
1904
1956
  const t = [], r = x(e.reportUri);
1905
- return Array.isArray(r) && r.length && t.push(`report-uri ${r.join(" ")}`), e.reportTo && t.push(`report-to ${e.reportTo}`), Z(...t);
1957
+ return Array.isArray(r) && r.length && t.push(`report-uri ${r.join(" ")}`), e.reportTo && t.push(`report-to ${e.reportTo}`), ee(...t);
1906
1958
  }
1907
- function pn(e) {
1959
+ function Tn(e) {
1908
1960
  if (e)
1909
- return Object.entries(e).sort(([t], [r]) => t.localeCompare(r)).map(([t, r]) => `${t}="${gn(r)}"`).join(", ");
1961
+ return Object.entries(e).sort(([t], [r]) => t.localeCompare(r)).map(([t, r]) => `${t}="${xn(r)}"`).join(", ");
1910
1962
  }
1911
- function gn(e) {
1963
+ function xn(e) {
1912
1964
  return e.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
1913
1965
  }
1914
- function yn(e) {
1966
+ function An(e) {
1915
1967
  const t = e.headers?.reportingEndpoints;
1916
1968
  if (t) {
1917
1969
  const s = Object.entries(t);
1918
1970
  if (s.length === 0)
1919
1971
  throw new Error("Demiurge Reporting-Endpoints requires at least one endpoint.");
1920
- for (const [i, o] of s)
1921
- He(i), je(o, `Reporting-Endpoints member ${JSON.stringify(i)}`);
1972
+ for (const [o, i] of s)
1973
+ Be(o), qe(i, `Reporting-Endpoints member ${JSON.stringify(o)}`);
1922
1974
  }
1923
1975
  const r = e.csp || void 0;
1924
- if (r?.reportTo && (He(r.reportTo), !t || !(r.reportTo in t)))
1976
+ if (r?.reportTo && (Be(r.reportTo), !t || !(r.reportTo in t)))
1925
1977
  throw new Error(
1926
1978
  `Demiurge CSP report-to group ${JSON.stringify(r.reportTo)} is not defined in headers.reportingEndpoints.`
1927
1979
  );
1928
1980
  const n = x(r?.reportUri);
1929
1981
  for (const s of Array.isArray(n) ? n : [])
1930
- je(s, "CSP report-uri target");
1982
+ qe(s, "CSP report-uri target");
1931
1983
  }
1932
- function wn(e) {
1933
- for (const [t, r] of q(e)) {
1934
- const n = gt(t);
1984
+ function Pn(e) {
1985
+ for (const [t, r] of G(e)) {
1986
+ const n = vt(t);
1935
1987
  if (r === void 0)
1936
1988
  continue;
1937
1989
  if (t === "reportTo") {
@@ -1948,27 +2000,34 @@ function wn(e) {
1948
2000
  );
1949
2001
  continue;
1950
2002
  }
2003
+ if (t === "sandbox") {
2004
+ if (typeof r != "boolean" && (!Array.isArray(r) || !r.every((o) => typeof o == "string")))
2005
+ throw new Error(
2006
+ `Demiurge CSP directive ${JSON.stringify(n)} must be a boolean or a list of sandbox tokens.`
2007
+ );
2008
+ continue;
2009
+ }
1951
2010
  const s = x(r);
1952
- if (s !== !1 && (!Array.isArray(s) || !s.every((i) => typeof i == "string")))
2011
+ if (s !== !1 && (!Array.isArray(s) || !s.every((o) => typeof o == "string")))
1953
2012
  throw new Error(
1954
2013
  `Demiurge CSP directive ${JSON.stringify(n)} must be a source list, false, or a replacement object with a source list.`
1955
2014
  );
1956
2015
  }
1957
2016
  }
1958
- function be(e) {
2017
+ function Pe(e) {
1959
2018
  return !!(e && typeof e == "object" && !Array.isArray(e) && "replace" in e);
1960
2019
  }
1961
2020
  function x(e) {
1962
- return be(e) ? e.replace : e;
2021
+ return Pe(e) ? e.replace : e;
1963
2022
  }
1964
- function He(e) {
2023
+ function Be(e) {
1965
2024
  if (!/^(?:[a-z]|\*)[a-z0-9_.*-]*$/.test(e))
1966
2025
  throw new Error(
1967
2026
  `Invalid reporting endpoint name ${JSON.stringify(e)}. Use a lowercase Structured Field key.`
1968
2027
  );
1969
2028
  }
1970
- function je(e, t) {
1971
- if (!Sn(e) || /[\s,;"\\]/.test(e) || !e.startsWith("/") && !e.startsWith("https://"))
2029
+ function qe(e, t) {
2030
+ if (!Cn(e) || /[\s,;"\\]/.test(e) || !e.startsWith("/") && !e.startsWith("https://"))
1972
2031
  throw new Error(`${t} must be a same-origin path or an HTTPS URL.`);
1973
2032
  if (e.startsWith("//"))
1974
2033
  throw new Error(`${t} must not be a scheme-relative URL.`);
@@ -1981,81 +2040,81 @@ function je(e, t) {
1981
2040
  if (r.username || r.password || r.hash)
1982
2041
  throw new Error(`${t} must not contain credentials or a fragment.`);
1983
2042
  }
1984
- function Sn(e) {
2043
+ function Cn(e) {
1985
2044
  return /^[\x20-\x7e]+$/.test(e);
1986
2045
  }
1987
- function q(e) {
2046
+ function G(e) {
1988
2047
  return Object.entries(e);
1989
2048
  }
1990
- function En(e, t) {
2049
+ function Dn(e, t) {
1991
2050
  return e.map((r) => {
1992
- if (!r.includes(K))
2051
+ if (!r.includes(Q))
1993
2052
  return r;
1994
2053
  if (!t.nonce)
1995
2054
  throw new Error("Demiurge security policy requires a CSP nonce.");
1996
- return r.replaceAll(K, t.nonce);
2055
+ return r.replaceAll(Q, t.nonce);
1997
2056
  });
1998
2057
  }
1999
- function gt(e) {
2058
+ function vt(e) {
2000
2059
  return e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
2001
2060
  }
2002
- function Rn(e) {
2061
+ function $n(e) {
2003
2062
  return e === "sha384" ? "SHA-384" : e === "sha512" ? "SHA-512" : "SHA-256";
2004
2063
  }
2005
- function vn(e) {
2064
+ function kn(e) {
2006
2065
  let t = "";
2007
2066
  for (const r of e)
2008
2067
  t += String.fromCharCode(r);
2009
2068
  return typeof btoa == "function" ? btoa(t) : Buffer.from(t, "binary").toString("base64");
2010
2069
  }
2011
- function yt(e, t, r = {}) {
2012
- Te(e);
2070
+ function Rt(e, t, r = {}) {
2071
+ Ce(e);
2013
2072
  const n = t.request.headers.get("origin"), s = new Headers();
2014
- if (e.origins !== "*" && wt(s, "Origin"), !n)
2073
+ if (e.origins !== "*" && bt(s, "Origin"), !n)
2015
2074
  return s;
2016
- const i = xn(e, n);
2017
- if (!i)
2075
+ const o = Ln(e, n);
2076
+ if (!o)
2018
2077
  return s;
2019
- if (s.set("access-control-allow-origin", i), e.credentials && s.set("access-control-allow-credentials", "true"), e.exposeHeaders?.length && s.set("access-control-expose-headers", e.exposeHeaders.join(", ")), r.preflight) {
2078
+ if (s.set("access-control-allow-origin", o), e.credentials && s.set("access-control-allow-credentials", "true"), e.exposeHeaders?.length && s.set("access-control-expose-headers", e.exposeHeaders.join(", ")), r.preflight) {
2020
2079
  s.set("access-control-allow-methods", r.methods.join(", "));
2021
- const o = t.request.headers.get(
2080
+ const i = t.request.headers.get(
2022
2081
  "access-control-request-headers"
2023
- ), a = e.headers?.join(", ") ?? o;
2082
+ ), a = e.headers?.join(", ") ?? i;
2024
2083
  a && s.set("access-control-allow-headers", a), e.maxAge !== void 0 && s.set("access-control-max-age", String(e.maxAge));
2025
2084
  }
2026
2085
  return s;
2027
2086
  }
2028
- function V(e, t, r) {
2087
+ function U(e, t, r) {
2029
2088
  if (!t)
2030
2089
  return e;
2031
2090
  const n = new Headers(e.headers);
2032
- return Pn(n, yt(t, { request: r })), new Response(e.body, {
2091
+ return Mn(n, Rt(t, { request: r })), new Response(e.body, {
2033
2092
  headers: n,
2034
2093
  status: e.status,
2035
2094
  statusText: e.statusText
2036
2095
  });
2037
2096
  }
2038
- function bn(e, t) {
2039
- const r = t.headers.get("access-control-request-method"), n = An(r);
2097
+ function Nn(e, t) {
2098
+ const r = t.headers.get("access-control-request-method"), n = In(r);
2040
2099
  if (!n)
2041
2100
  return null;
2042
- const s = St(e, n);
2101
+ const s = Tt(e, n);
2043
2102
  if (!s?.cors)
2044
2103
  return null;
2045
- const i = s.cors.methods ?? Cn(e);
2046
- return i.includes(n) ? new Response(null, {
2047
- headers: yt(
2104
+ const o = s.cors.methods ?? Un(e);
2105
+ return o.includes(n) ? new Response(null, {
2106
+ headers: Rt(
2048
2107
  s.cors,
2049
2108
  { request: t },
2050
2109
  {
2051
- methods: i,
2110
+ methods: o,
2052
2111
  preflight: !0
2053
2112
  }
2054
2113
  ),
2055
2114
  status: 204
2056
2115
  }) : null;
2057
2116
  }
2058
- function Te(e) {
2117
+ function Ce(e) {
2059
2118
  if (e.credentials && e.origins === "*")
2060
2119
  throw new Error(
2061
2120
  "Demiurge CORS policy cannot use wildcard origins with credentials."
@@ -2066,59 +2125,59 @@ function Te(e) {
2066
2125
  );
2067
2126
  if (e.origins !== "*")
2068
2127
  for (const t of e.origins)
2069
- Tn(t);
2128
+ On(t);
2070
2129
  if (e.maxAge !== void 0 && (!Number.isSafeInteger(e.maxAge) || e.maxAge < 0))
2071
2130
  throw new Error(
2072
2131
  "Demiurge CORS maxAge must be a non-negative integer number of seconds."
2073
2132
  );
2074
2133
  }
2075
- function Tn(e) {
2134
+ function On(e) {
2076
2135
  let t;
2077
2136
  try {
2078
2137
  t = new URL(e);
2079
2138
  } catch {
2080
- throw Fe(e);
2139
+ throw Ge(e);
2081
2140
  }
2082
2141
  if (t.protocol !== "http:" && t.protocol !== "https:" || t.origin !== e)
2083
- throw Fe(e);
2142
+ throw Ge(e);
2084
2143
  }
2085
- function Fe(e) {
2144
+ function Ge(e) {
2086
2145
  return new Error(
2087
2146
  `Demiurge CORS origin ${JSON.stringify(e)} must be a canonical HTTP(S) origin without credentials, a path, query, or fragment.`
2088
2147
  );
2089
2148
  }
2090
- function xn(e, t) {
2149
+ function Ln(e, t) {
2091
2150
  return e.origins === "*" ? "*" : e.origins.includes(t) ? t : null;
2092
2151
  }
2093
- function Pn(e, t) {
2152
+ function Mn(e, t) {
2094
2153
  t.forEach((r, n) => {
2095
2154
  if (n === "vary" && e.has("vary")) {
2096
2155
  for (const s of r.split(","))
2097
- wt(e, s.trim());
2156
+ bt(e, s.trim());
2098
2157
  return;
2099
2158
  }
2100
2159
  e.set(n, r);
2101
2160
  });
2102
2161
  }
2103
- function wt(e, t) {
2162
+ function bt(e, t) {
2104
2163
  if (!t)
2105
2164
  return;
2106
2165
  const r = e.get("vary")?.split(",").map((n) => n.trim()).filter(Boolean) ?? [];
2107
2166
  r.some((n) => n.toLowerCase() === t.toLowerCase()) || e.set("vary", [...r, t].join(", "));
2108
2167
  }
2109
- function An(e) {
2168
+ function In(e) {
2110
2169
  if (!e)
2111
2170
  return null;
2112
2171
  const t = e.toUpperCase();
2113
- return $n(t) ? t : null;
2172
+ return Fn(t) ? t : null;
2114
2173
  }
2115
- function St(e, t) {
2116
- return t === "HEAD" ? e.HEAD ?? We(e.GET) : We(e[t]);
2174
+ function Tt(e, t) {
2175
+ return t === "HEAD" ? e.HEAD ?? _e(e.GET) : _e(e[t]);
2117
2176
  }
2118
- function We(e) {
2177
+ function _e(e) {
2119
2178
  return e?.kind === "page" ? void 0 : e;
2120
2179
  }
2121
- function Cn(e) {
2180
+ function Un(e) {
2122
2181
  return [
2123
2182
  "GET",
2124
2183
  "POST",
@@ -2127,25 +2186,25 @@ function Cn(e) {
2127
2186
  "DELETE",
2128
2187
  "OPTIONS",
2129
2188
  "HEAD"
2130
- ].filter((t) => St(e, t));
2189
+ ].filter((t) => Tt(e, t));
2131
2190
  }
2132
- function $n(e) {
2191
+ function Fn(e) {
2133
2192
  return e === "GET" || e === "POST" || e === "PUT" || e === "PATCH" || e === "DELETE" || e === "OPTIONS" || e === "HEAD";
2134
2193
  }
2135
- const kn = /* @__PURE__ */ new Set(["DELETE", "PATCH", "POST", "PUT"]);
2136
- function Dn(e = {}) {
2137
- const t = [], r = e.document, n = r ? Ln(r.policy, r.headers, t) : {};
2138
- r && Nn(r.policy, t);
2139
- const s = e.route ? zn(e.route, t) : void 0;
2140
- return r?.scripts && (In(
2194
+ const Hn = /* @__PURE__ */ new Set(["DELETE", "PATCH", "POST", "PUT"]);
2195
+ function jn(e = {}) {
2196
+ const t = [], r = e.document, n = r ? Bn(r.policy, r.headers, t) : {};
2197
+ r && Wn(r.policy, t);
2198
+ const s = e.route ? Qn(e.route, t) : void 0;
2199
+ return r?.scripts && (qn(
2141
2200
  r.policy.csp,
2142
2201
  r.scripts,
2143
2202
  r.headers,
2144
2203
  t
2145
2204
  ), r.scriptDependencies && t.push(
2146
- ...On(
2205
+ ...zn(
2147
2206
  r.scripts,
2148
- Mn(r.scriptDependencies)
2207
+ Gn(r.scriptDependencies)
2149
2208
  )
2150
2209
  )), {
2151
2210
  findings: t,
@@ -2153,21 +2212,21 @@ function Dn(e = {}) {
2153
2212
  route: s
2154
2213
  };
2155
2214
  }
2156
- function Nn(e, t) {
2215
+ function Wn(e, t) {
2157
2216
  if (!e.trustedTypes || e.trustedTypes.mode !== "report-only")
2158
2217
  return;
2159
- const r = e.csp || void 0, n = !!he(r?.reportUri)?.length, s = e.headers?.reportingEndpoints, i = !!(r?.reportTo && s && s[r.reportTo]);
2160
- !n && !i && t.push({
2218
+ const r = e.csp || void 0, n = !!ge(r?.reportUri)?.length, s = e.headers?.reportingEndpoints, o = !!(r?.reportTo && s && s[r.reportTo]);
2219
+ !n && !o && t.push({
2161
2220
  code: "report-only-target-missing",
2162
2221
  message: "Trusted Types report-only mode has no deliverable target. Configure CSP reportTo with a matching Reporting-Endpoints member, reportUri for compatibility, or both.",
2163
2222
  severity: "warning"
2164
2223
  });
2165
2224
  }
2166
- function On(e, t = {}) {
2225
+ function zn(e, t = {}) {
2167
2226
  const r = t.requirePurpose ?? !0, n = [];
2168
2227
  for (const s of e) {
2169
- const i = _n(s);
2170
- i && (r && !s.purpose && n.push({
2228
+ const o = ts(s);
2229
+ o && (r && !s.purpose && n.push({
2171
2230
  code: "script-purpose-missing",
2172
2231
  message: `Third-party script ${s.src} should declare a purpose for audits and consent flows.`,
2173
2232
  severity: "warning"
@@ -2179,7 +2238,7 @@ function On(e, t = {}) {
2179
2238
  code: "script-third-party-before-interactive",
2180
2239
  message: `Third-party script ${s.src} runs before the app is interactive and should be justified by policy.`,
2181
2240
  severity: "warning"
2182
- }), Vn(i) && n.push({
2241
+ }), rs(o) && n.push({
2183
2242
  code: "script-gtm-wide-trust-boundary",
2184
2243
  message: "Google Tag Manager can load additional scripts at runtime and should be treated as a wide trust boundary.",
2185
2244
  severity: "warning"
@@ -2187,9 +2246,9 @@ function On(e, t = {}) {
2187
2246
  }
2188
2247
  return n;
2189
2248
  }
2190
- function Ln(e, t, r) {
2249
+ function Bn(e, t, r) {
2191
2250
  try {
2192
- return Object.fromEntries(W(e, t));
2251
+ return Object.fromEntries(q(e, t));
2193
2252
  } catch (n) {
2194
2253
  return r.push({
2195
2254
  code: "security-header-render-failed",
@@ -2198,71 +2257,71 @@ function Ln(e, t, r) {
2198
2257
  }), {};
2199
2258
  }
2200
2259
  }
2201
- function In(e, t, r, n) {
2260
+ function qn(e, t, r, n) {
2202
2261
  if (!e)
2203
2262
  return;
2204
- const s = Un(e);
2205
- for (const i of t) {
2206
- if (Hn(s) && !i.nonce) {
2263
+ const s = _n(e);
2264
+ for (const o of t) {
2265
+ if (Vn(s) && !o.nonce) {
2207
2266
  n.push({
2208
2267
  code: "csp-script-missing-nonce",
2209
- message: `Document script ${i.src} needs a nonce for the effective script-src policy.`,
2268
+ message: `Document script ${o.src} needs a nonce for the effective script-src policy.`,
2210
2269
  severity: "error"
2211
2270
  });
2212
2271
  continue;
2213
2272
  }
2214
- i.nonce && r?.nonce && i.nonce === r.nonce || jn(s, i.src) || n.push({
2273
+ o.nonce && r?.nonce && o.nonce === r.nonce || Jn(s, o.src) || n.push({
2215
2274
  code: "csp-script-src-blocked",
2216
- message: `Document script ${i.src} is not allowed by the effective script-src policy.`,
2275
+ message: `Document script ${o.src} is not allowed by the effective script-src policy.`,
2217
2276
  severity: "error"
2218
2277
  });
2219
2278
  }
2220
2279
  }
2221
- function Mn(e) {
2280
+ function Gn(e) {
2222
2281
  return typeof e == "boolean" ? {} : e;
2223
2282
  }
2224
- function Un(e) {
2225
- return he(e.scriptSrc) ?? he(e.defaultSrc) ?? [];
2283
+ function _n(e) {
2284
+ return ge(e.scriptSrc) ?? ge(e.defaultSrc) ?? [];
2226
2285
  }
2227
- function he(e) {
2286
+ function ge(e) {
2228
2287
  if (e)
2229
2288
  return "replace" in e ? e.replace : e;
2230
2289
  }
2231
- function Hn(e) {
2290
+ function Vn(e) {
2232
2291
  return e.some((t) => t.includes("'nonce-{nonce}'"));
2233
2292
  }
2234
- function jn(e, t) {
2235
- return qn(e) ? !1 : e.includes("*") ? !0 : e.includes("'none'") || e.some((r) => r.startsWith("'nonce-")) ? !1 : e.includes("'self'") && Fn(t) || t.startsWith("https:") && e.includes("https:") || t.startsWith("http:") && e.includes("http:") ? !0 : e.some((r) => Wn(r, t));
2293
+ function Jn(e, t) {
2294
+ return Zn(e) ? !1 : e.includes("*") ? !0 : e.includes("'none'") || e.some((r) => r.startsWith("'nonce-")) ? !1 : e.includes("'self'") && Kn(t) || t.startsWith("https:") && e.includes("https:") || t.startsWith("http:") && e.includes("http:") ? !0 : e.some((r) => Yn(r, t));
2236
2295
  }
2237
- function Fn(e) {
2296
+ function Kn(e) {
2238
2297
  return e.startsWith("/") && !e.startsWith("//");
2239
2298
  }
2240
- function Wn(e, t) {
2299
+ function Yn(e, t) {
2241
2300
  if (e.startsWith("'"))
2242
2301
  return !1;
2243
2302
  try {
2244
- const r = new URL(e), n = new URL(t), s = r.hostname.startsWith("*.") ? n.hostname.endsWith(r.hostname.slice(1)) && n.hostname !== r.hostname.slice(2) : n.hostname === r.hostname, i = r.pathname === "/" || r.pathname.endsWith("/") ? n.pathname.startsWith(r.pathname) : n.pathname === r.pathname;
2245
- return n.protocol === r.protocol && s && n.port === r.port && i;
2303
+ const r = new URL(e), n = new URL(t), s = r.hostname.startsWith("*.") ? n.hostname.endsWith(r.hostname.slice(1)) && n.hostname !== r.hostname.slice(2) : n.hostname === r.hostname, o = r.pathname === "/" || r.pathname.endsWith("/") ? n.pathname.startsWith(r.pathname) : n.pathname === r.pathname;
2304
+ return n.protocol === r.protocol && s && n.port === r.port && o;
2246
2305
  } catch {
2247
2306
  return !1;
2248
2307
  }
2249
2308
  }
2250
- function qn(e) {
2309
+ function Zn(e) {
2251
2310
  return e.includes("'strict-dynamic'") && e.some(
2252
2311
  (t) => t.startsWith("'nonce-") || /^'sha(?:256|384|512)-/.test(t)
2253
2312
  );
2254
2313
  }
2255
- function zn(e, t) {
2256
- return Bn(e.cors, t), Gn(e.method, e.security, t), {
2314
+ function Qn(e, t) {
2315
+ return Xn(e.cors, t), es(e.method, e.security, t), {
2257
2316
  cors: e.cors,
2258
2317
  method: e.method,
2259
2318
  security: e.security
2260
2319
  };
2261
2320
  }
2262
- function Bn(e, t) {
2321
+ function Xn(e, t) {
2263
2322
  if (e)
2264
2323
  try {
2265
- Te(e);
2324
+ Ce(e);
2266
2325
  } catch (r) {
2267
2326
  t.push({
2268
2327
  code: "cors-invalid",
@@ -2271,8 +2330,8 @@ function Bn(e, t) {
2271
2330
  });
2272
2331
  }
2273
2332
  }
2274
- function Gn(e, t, r) {
2275
- kn.has(e) && (t?.csrf === !1 && r.push({
2333
+ function es(e, t, r) {
2334
+ Hn.has(e) && (t?.csrf === !1 && r.push({
2276
2335
  code: "csrf-disabled",
2277
2336
  message: "CSRF protection is explicitly disabled for this unsafe route.",
2278
2337
  severity: "info"
@@ -2286,7 +2345,7 @@ function Gn(e, t, r) {
2286
2345
  severity: "warning"
2287
2346
  }));
2288
2347
  }
2289
- function _n(e) {
2348
+ function ts(e) {
2290
2349
  try {
2291
2350
  const t = new URL(e.src);
2292
2351
  if (t.protocol === "http:" || t.protocol === "https:")
@@ -2296,17 +2355,17 @@ function _n(e) {
2296
2355
  }
2297
2356
  return null;
2298
2357
  }
2299
- function Vn(e) {
2358
+ function rs(e) {
2300
2359
  return e.hostname === "www.googletagmanager.com" && (e.pathname === "/gtm.js" || e.pathname === "/ns.html");
2301
2360
  }
2302
- const Jn = /* @__PURE__ */ new Set(["DELETE", "PATCH", "POST", "PUT"]), Kn = /^[!#$%&'*+\-.^_`|~A-Za-z0-9]+$/;
2303
- function Yn() {
2361
+ const ns = /* @__PURE__ */ new Set(["DELETE", "PATCH", "POST", "PUT"]), ss = /^[!#$%&'*+\-.^_`|~A-Za-z0-9]+$/;
2362
+ function os() {
2304
2363
  const e = new Uint8Array(32);
2305
2364
  return globalThis.crypto.getRandomValues(e), btoa(String.fromCharCode(...e)).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
2306
2365
  }
2307
- function Zn(e, t = {}) {
2366
+ function is(e, t = {}) {
2308
2367
  const r = t.cookie ?? "csrf-token";
2309
- if (!Kn.test(r))
2368
+ if (!ss.test(r))
2310
2369
  throw new Error("Demiurge CSRF cookie name is invalid.");
2311
2370
  if (!e)
2312
2371
  throw new Error("Demiurge CSRF token must not be empty.");
@@ -2317,25 +2376,25 @@ function Zn(e, t = {}) {
2317
2376
  ];
2318
2377
  return (t.secure ?? !0) && n.push("Secure"), n.join("; ");
2319
2378
  }
2320
- function ki(e = {}) {
2321
- const t = Yn();
2379
+ function Ko(e = {}) {
2380
+ const t = os();
2322
2381
  return {
2323
- cookie: Zn(t, e),
2382
+ cookie: is(t, e),
2324
2383
  token: t
2325
2384
  };
2326
2385
  }
2327
- function Qn(e, t) {
2328
- if (!Jn.has(t.method.toUpperCase()) || e === !1)
2386
+ function as(e, t) {
2387
+ if (!ns.has(t.method.toUpperCase()) || e === !1)
2329
2388
  return null;
2330
2389
  const r = t.headers.get("cookie");
2331
2390
  if (e === void 0 && !r?.trim())
2332
2391
  return null;
2333
- const n = es(e ?? !0), i = Xn(r).get(n.cookie), o = t.headers.get(n.header);
2334
- return !i || !o || !rs(i, o) ? new Response("Invalid CSRF token.", {
2392
+ const n = us(e ?? !0), o = cs(r).get(n.cookie), i = t.headers.get(n.header);
2393
+ return !o || !i || !fs(o, i) ? new Response("Invalid CSRF token.", {
2335
2394
  status: 403
2336
2395
  }) : null;
2337
2396
  }
2338
- function Xn(e) {
2397
+ function cs(e) {
2339
2398
  const t = /* @__PURE__ */ new Map();
2340
2399
  if (!e)
2341
2400
  return t;
@@ -2343,12 +2402,12 @@ function Xn(e) {
2343
2402
  const n = r.indexOf("=");
2344
2403
  if (n === -1)
2345
2404
  continue;
2346
- const s = r.slice(0, n).trim(), i = r.slice(n + 1).trim();
2347
- s && t.set(s, ts(i));
2405
+ const s = r.slice(0, n).trim(), o = r.slice(n + 1).trim();
2406
+ s && t.set(s, ls(o));
2348
2407
  }
2349
2408
  return t;
2350
2409
  }
2351
- function es(e) {
2410
+ function us(e) {
2352
2411
  return e === !0 ? {
2353
2412
  cookie: "csrf-token",
2354
2413
  header: "x-csrf-token"
@@ -2357,27 +2416,88 @@ function es(e) {
2357
2416
  header: e.header ?? "x-csrf-token"
2358
2417
  };
2359
2418
  }
2360
- function ts(e) {
2419
+ function ls(e) {
2361
2420
  try {
2362
2421
  return decodeURIComponent(e);
2363
2422
  } catch {
2364
2423
  return e;
2365
2424
  }
2366
2425
  }
2367
- function rs(e, t) {
2426
+ function fs(e, t) {
2368
2427
  let r = e.length ^ t.length;
2369
2428
  const n = Math.max(e.length, t.length);
2370
2429
  for (let s = 0; s < n; s += 1)
2371
2430
  r |= e.charCodeAt(s) ^ t.charCodeAt(s);
2372
2431
  return r === 0;
2373
2432
  }
2374
- const ns = {
2433
+ const le = "Sec-Fetch-Dest", ds = "Sec-Fetch-Mode", hs = "Sec-Fetch-Site", ms = /* @__PURE__ */ new Set(["embed", "object"]), ps = /* @__PURE__ */ new Set(["GET", "HEAD"]), Ve = {
2434
+ allowCrossSite: !1,
2435
+ allowNavigation: !0,
2436
+ allowSameSite: !1
2437
+ };
2438
+ function gs(e, t, r = t.method) {
2439
+ const n = e === !0 ? Ve : { ...Ve, ...e }, s = [];
2440
+ if (ws(t, r))
2441
+ return { allowed: !0, reason: "cors-preflight", vary: s };
2442
+ s.push(hs);
2443
+ const o = t.headers.get("sec-fetch-site");
2444
+ if (o === null)
2445
+ return { allowed: !0, reason: "metadata-absent", vary: s };
2446
+ if (o === "same-origin")
2447
+ return { allowed: !0, reason: "same-origin", vary: s };
2448
+ if (o === "none")
2449
+ return { allowed: !0, reason: "user-initiated", vary: s };
2450
+ if (o === "same-site" && n.allowSameSite)
2451
+ return { allowed: !0, reason: "same-site-trusted", vary: s };
2452
+ if (n.allowCrossSite)
2453
+ return { allowed: !0, reason: "cross-site-exempt", vary: s };
2454
+ const i = e === !0 ? void 0 : e.allowedDestinations;
2455
+ if (i?.length && (s.push(le), i.includes(t.headers.get("sec-fetch-dest") ?? "")))
2456
+ return { allowed: !0, reason: "destination-exempt", vary: s };
2457
+ if (n.allowNavigation && ps.has(r.toUpperCase()) && (s.push(ds), t.headers.get("sec-fetch-mode") === "navigate")) {
2458
+ const a = t.headers.get("sec-fetch-dest") ?? "";
2459
+ if (s.includes(le) || s.push(le), !ms.has(a))
2460
+ return { allowed: !0, reason: "top-level-navigation", vary: s };
2461
+ }
2462
+ return {
2463
+ allowed: !1,
2464
+ reason: o === "same-site" ? "same-site-denied" : "cross-site-denied",
2465
+ vary: s
2466
+ };
2467
+ }
2468
+ function ys(e, t, r = t.method) {
2469
+ if (!e)
2470
+ return { response: null, vary: [] };
2471
+ const n = gs(e, t, r);
2472
+ if (n.allowed)
2473
+ return { response: null, vary: n.vary };
2474
+ const s = new Response("Request blocked by the Fetch Metadata policy.", {
2475
+ headers: { "content-type": "text/plain; charset=utf-8" },
2476
+ status: 403
2477
+ });
2478
+ return xt(s, n.vary), { response: s, vary: n.vary };
2479
+ }
2480
+ function xt(e, t) {
2481
+ if (t.length === 0)
2482
+ return e;
2483
+ const r = e.headers.get("vary")?.split(",").map((s) => s.trim()).filter(Boolean) ?? [];
2484
+ if (r.includes("*"))
2485
+ return e;
2486
+ const n = [...r];
2487
+ for (const s of t)
2488
+ n.some((o) => o.toLowerCase() === s.toLowerCase()) || n.push(s);
2489
+ return e.headers.set("vary", n.join(", ")), e;
2490
+ }
2491
+ function ws(e, t) {
2492
+ return t.toUpperCase() === "OPTIONS" && e.headers.has("access-control-request-method");
2493
+ }
2494
+ const Ss = {
2375
2495
  h: 3600 * 1e3,
2376
2496
  m: 60 * 1e3,
2377
2497
  s: 1e3
2378
- }, ss = 1e4;
2379
- function Et(e = {}) {
2380
- const t = e.maximumEntries ?? ss;
2498
+ }, Es = 1e4;
2499
+ function At(e = {}) {
2500
+ const t = e.maximumEntries ?? Es;
2381
2501
  if (!Number.isSafeInteger(t) || t <= 0)
2382
2502
  throw new Error(
2383
2503
  "Demiurge rate limit maximumEntries must be a positive integer."
@@ -2385,50 +2505,50 @@ function Et(e = {}) {
2385
2505
  const r = /* @__PURE__ */ new Map();
2386
2506
  let n = Number.POSITIVE_INFINITY;
2387
2507
  return {
2388
- increment(s, i, o) {
2389
- o >= n && (is(r, o), n = os(r));
2508
+ increment(s, o, i) {
2509
+ i >= n && (vs(r, i), n = Rs(r));
2390
2510
  const a = r.get(s);
2391
- if (!a || a.resetAt <= o) {
2511
+ if (!a || a.resetAt <= i) {
2392
2512
  const c = {
2393
2513
  count: 1,
2394
- resetAt: o + i
2514
+ resetAt: i + o
2395
2515
  };
2396
- return !a && r.size >= t && as(r), r.set(s, c), n = Math.min(n, c.resetAt), c;
2516
+ return !a && r.size >= t && bs(r), r.set(s, c), n = Math.min(n, c.resetAt), { count: c.count, resetAt: c.resetAt };
2397
2517
  }
2398
- return a.count += 1, a;
2518
+ return a.count += 1, { count: a.count, resetAt: a.resetAt };
2399
2519
  }
2400
2520
  };
2401
2521
  }
2402
- function is(e, t) {
2522
+ function vs(e, t) {
2403
2523
  for (const [r, n] of e)
2404
2524
  n.resetAt <= t && e.delete(r);
2405
2525
  }
2406
- function os(e) {
2526
+ function Rs(e) {
2407
2527
  let t = Number.POSITIVE_INFINITY;
2408
2528
  for (const r of e.values())
2409
2529
  t = Math.min(t, r.resetAt);
2410
2530
  return t;
2411
2531
  }
2412
- function as(e) {
2532
+ function bs(e) {
2413
2533
  const t = e.keys().next().value;
2414
2534
  t !== void 0 && e.delete(t);
2415
2535
  }
2416
- function cs(e, t, r, n = Date.now()) {
2536
+ async function Ts(e, t, r, n = Date.now()) {
2417
2537
  if (!e)
2418
2538
  return null;
2419
- xe(e);
2420
- const s = Rt(e.window), i = us(e, t), o = r.increment(i, s, n), a = Math.max(0, e.limit - o.count), c = new Headers({
2421
- "retry-after": String(Math.ceil(Math.max(0, o.resetAt - n) / 1e3)),
2539
+ De(e);
2540
+ const s = Pt(e.window), o = xs(e, t), i = await r.increment(o, s, n), a = Math.max(0, e.limit - i.count), c = new Headers({
2541
+ "retry-after": String(Math.ceil(Math.max(0, i.resetAt - n) / 1e3)),
2422
2542
  "x-ratelimit-limit": String(e.limit),
2423
2543
  "x-ratelimit-remaining": String(a),
2424
- "x-ratelimit-reset": String(Math.ceil(o.resetAt / 1e3))
2544
+ "x-ratelimit-reset": String(Math.ceil(i.resetAt / 1e3))
2425
2545
  });
2426
- return o.count > e.limit ? new Response("Rate limit exceeded.", {
2546
+ return i.count > e.limit ? new Response("Rate limit exceeded.", {
2427
2547
  headers: c,
2428
2548
  status: 429
2429
2549
  }) : null;
2430
2550
  }
2431
- function Rt(e) {
2551
+ function Pt(e) {
2432
2552
  if (typeof e == "number") {
2433
2553
  if (!Number.isSafeInteger(e) || e <= 0)
2434
2554
  throw new Error("Demiurge rate limit window must be a positive integer.");
@@ -2437,36 +2557,36 @@ function Rt(e) {
2437
2557
  const t = /^(\d+)(s|m|h)$/i.exec(e.trim());
2438
2558
  if (!t)
2439
2559
  throw new Error("Demiurge rate limit window must use an s/m/h suffix.");
2440
- const r = Number(t[1]), n = t[2].toLowerCase(), s = r * ns[n];
2560
+ const r = Number(t[1]), n = t[2].toLowerCase(), s = r * Ss[n];
2441
2561
  if (!Number.isSafeInteger(s))
2442
2562
  throw new Error("Demiurge rate limit window is too large.");
2443
2563
  return s;
2444
2564
  }
2445
- function xe(e) {
2565
+ function De(e) {
2446
2566
  if (!Number.isSafeInteger(e.limit) || e.limit <= 0)
2447
2567
  throw new Error("Demiurge rate limit limit must be a positive integer.");
2448
- Rt(e.window);
2568
+ Pt(e.window);
2449
2569
  }
2450
- function us(e, t) {
2451
- return `${fs(e.key)}:${ls(e.key, t)}`;
2570
+ function xs(e, t) {
2571
+ return `${As(e.key)}:${Ps(e.key, t)}`;
2452
2572
  }
2453
- function fs(e) {
2573
+ function As(e) {
2454
2574
  return typeof e == "string" ? e : `header:${e.header.toLowerCase()}`;
2455
2575
  }
2456
- function ls(e, t) {
2457
- return e === "ip" ? ds(t) : t.headers.get(e.header) ?? "missing";
2576
+ function Ps(e, t) {
2577
+ return e === "ip" ? Cs(t) : t.headers.get(e.header) ?? "missing";
2458
2578
  }
2459
- function ds(e) {
2460
- return Dt(e)?.clientIp ?? "unknown";
2579
+ function Cs(e) {
2580
+ return Ht(e)?.clientIp ?? "unknown";
2461
2581
  }
2462
- const ms = {
2582
+ const Ds = {
2463
2583
  b: 1,
2464
2584
  gb: 1024 ** 3,
2465
2585
  kb: 1024,
2466
2586
  mb: 1024 ** 2
2467
2587
  };
2468
- function hs(e, t, r) {
2469
- const n = gs(e, r);
2588
+ function $s(e, t, r) {
2589
+ const n = Ns(e, r);
2470
2590
  if (n)
2471
2591
  return n;
2472
2592
  if (e?.maxBodySize === void 0)
@@ -2474,27 +2594,27 @@ function hs(e, t, r) {
2474
2594
  const s = t.headers.get("content-length");
2475
2595
  if (!s)
2476
2596
  return null;
2477
- const i = ys(s);
2478
- if (i === null)
2597
+ const o = Os(s);
2598
+ if (o === null)
2479
2599
  return new Response("Invalid Content-Length.", {
2480
2600
  status: 400
2481
2601
  });
2482
- const o = vt(e.maxBodySize);
2483
- return i > o ? new Response("Request body too large.", {
2602
+ const i = Ct(e.maxBodySize);
2603
+ return o > i ? new Response("Request body too large.", {
2484
2604
  status: 413
2485
2605
  }) : null;
2486
2606
  }
2487
- class L extends Error {
2607
+ class F extends Error {
2488
2608
  constructor() {
2489
2609
  super("Demiurge request body exceeded maxBodySize while being read."), this.name = "RequestBodyTooLargeError";
2490
2610
  }
2491
2611
  }
2492
- function ps(e, t) {
2612
+ function ks(e, t) {
2493
2613
  if (e?.maxBodySize === void 0 || t.body === null)
2494
2614
  return t;
2495
- const r = vt(e.maxBodySize), n = t.body.getReader();
2615
+ const r = Ct(e.maxBodySize), n = t.body.getReader();
2496
2616
  let s = 0;
2497
- const i = new ReadableStream({
2617
+ const o = new ReadableStream({
2498
2618
  async pull(a) {
2499
2619
  const c = await n.read();
2500
2620
  if (c.done) {
@@ -2502,7 +2622,7 @@ function ps(e, t) {
2502
2622
  return;
2503
2623
  }
2504
2624
  if (s += c.value.byteLength, s > r) {
2505
- const u = new L();
2625
+ const u = new F();
2506
2626
  a.error(u);
2507
2627
  try {
2508
2628
  await n.cancel(u);
@@ -2518,24 +2638,24 @@ function ps(e, t) {
2518
2638
  } catch {
2519
2639
  }
2520
2640
  }
2521
- }), o = new Request(t, {
2522
- body: i,
2641
+ }), i = new Request(t, {
2642
+ body: o,
2523
2643
  duplex: "half"
2524
2644
  });
2525
- return Nt(t, o), o;
2645
+ return jt(t, i), i;
2526
2646
  }
2527
- function B() {
2647
+ function V() {
2528
2648
  return new Response("Request body too large.", { status: 413 });
2529
2649
  }
2530
- function gs(e, t) {
2531
- return !e?.allowedMethods || ws(e.allowedMethods, t) ? null : new Response(null, {
2650
+ function Ns(e, t) {
2651
+ return !e?.allowedMethods || Ls(e.allowedMethods, t) ? null : new Response(null, {
2532
2652
  headers: {
2533
- allow: Ss(e.allowedMethods)
2653
+ allow: Ms(e.allowedMethods)
2534
2654
  },
2535
2655
  status: 405
2536
2656
  });
2537
2657
  }
2538
- function vt(e) {
2658
+ function Ct(e) {
2539
2659
  if (typeof e == "number") {
2540
2660
  if (!Number.isSafeInteger(e) || e < 0)
2541
2661
  throw new Error("Demiurge request maxBodySize must be a non-negative integer.");
@@ -2546,25 +2666,25 @@ function vt(e) {
2546
2666
  throw new Error(
2547
2667
  "Demiurge request maxBodySize must use bytes or a b/kb/mb/gb suffix."
2548
2668
  );
2549
- const r = Number(t[1]), n = t[2].toLowerCase(), s = r * ms[n];
2669
+ const r = Number(t[1]), n = t[2].toLowerCase(), s = r * Ds[n];
2550
2670
  if (!Number.isSafeInteger(s))
2551
2671
  throw new Error("Demiurge request maxBodySize is too large.");
2552
2672
  return s;
2553
2673
  }
2554
- function ys(e) {
2674
+ function Os(e) {
2555
2675
  if (!/^\d+$/.test(e))
2556
2676
  return null;
2557
2677
  const t = Number(e);
2558
2678
  return Number.isSafeInteger(t) ? t : null;
2559
2679
  }
2560
- function ws(e, t) {
2680
+ function Ls(e, t) {
2561
2681
  return e.includes(t) || t === "HEAD" && e.includes("GET");
2562
2682
  }
2563
- function Ss(e) {
2683
+ function Ms(e) {
2564
2684
  const t = [...e];
2565
2685
  return t.includes("GET") && !t.includes("HEAD") && t.push("HEAD"), t.join(", ");
2566
2686
  }
2567
- const Es = [
2687
+ const Is = [
2568
2688
  "GET",
2569
2689
  "POST",
2570
2690
  "PUT",
@@ -2573,15 +2693,15 @@ const Es = [
2573
2693
  "OPTIONS",
2574
2694
  "HEAD"
2575
2695
  ];
2576
- function Rs(e, t = {}) {
2696
+ function Us(e, t = {}) {
2577
2697
  for (const [n, s] of Object.entries(e)) {
2578
- vs(n, s);
2579
- for (const i of Es) {
2580
- const o = s[i];
2581
- !o || o.kind === "page" || bs(n, i, o, s);
2698
+ Fs(n, s);
2699
+ for (const o of Is) {
2700
+ const i = s[o];
2701
+ !i || i.kind === "page" || Hs(n, o, i, s);
2582
2702
  }
2583
2703
  }
2584
- const r = et(
2704
+ const r = ot(
2585
2705
  Object.fromEntries(
2586
2706
  Object.entries(e).map(([n, s]) => [
2587
2707
  n,
@@ -2589,53 +2709,53 @@ function Rs(e, t = {}) {
2589
2709
  ])
2590
2710
  )
2591
2711
  );
2592
- return As(r, e, t.adapter), r;
2712
+ return Bs(r, e, t.adapter), r;
2593
2713
  }
2594
- function vs(e, t) {
2714
+ function Fs(e, t) {
2595
2715
  const r = t.policy?.security?.rateLimit;
2596
- r && j(e, "policy", "rate limit", () => {
2597
- xe(r);
2716
+ r && z(e, "policy", "rate limit", () => {
2717
+ De(r);
2598
2718
  });
2599
2719
  }
2600
- function bs(e, t, r, n) {
2601
- r.cors && j(e, t, "CORS", () => {
2602
- Te(r.cors), Ts(e, t, r.cors.methods, n);
2603
- }), r.security?.rateLimit && j(e, t, "rate limit", () => {
2604
- xe(r.security.rateLimit);
2720
+ function Hs(e, t, r, n) {
2721
+ r.cors && z(e, t, "CORS", () => {
2722
+ Ce(r.cors), js(e, t, r.cors.methods, n);
2723
+ }), r.security?.rateLimit && z(e, t, "rate limit", () => {
2724
+ De(r.security.rateLimit);
2605
2725
  });
2606
2726
  }
2607
- function Ts(e, t, r, n) {
2727
+ function js(e, t, r, n) {
2608
2728
  if (r) {
2609
2729
  for (const s of r)
2610
- if (s !== "OPTIONS" && !xs(n, s))
2730
+ if (s !== "OPTIONS" && !Ws(n, s))
2611
2731
  throw new Error(
2612
2732
  `Route ${JSON.stringify(e)} export ${t} allows CORS method ${s}, but the route does not export that response capability.`
2613
2733
  );
2614
2734
  }
2615
2735
  }
2616
- function xs(e, t) {
2736
+ function Ws(e, t) {
2617
2737
  const r = t === "HEAD" ? e.HEAD ?? e.GET : e[t];
2618
- return Ps(r) ? r : void 0;
2738
+ return zs(r) ? r : void 0;
2619
2739
  }
2620
- function Ps(e) {
2740
+ function zs(e) {
2621
2741
  return !!(e && e.kind !== "page");
2622
2742
  }
2623
- function As(e, t, r) {
2743
+ function Bs(e, t, r) {
2624
2744
  for (const s of e.routes) {
2625
- const i = t[s.file], o = i?.GET;
2626
- if (!o || o.kind !== "page")
2745
+ const o = t[s.file], i = o?.GET;
2746
+ if (!i || i.kind !== "page")
2627
2747
  continue;
2628
- const a = Y(
2748
+ const a = X(
2629
2749
  ...e.policies.filter(
2630
2750
  (c) => T(c.fileSegments, s.fileSegments)
2631
2751
  ).map((c) => t[c.file]?.policy),
2632
- i.policy
2752
+ o.policy
2633
2753
  );
2634
- qe(s.file, "GET", a, r), Os(
2754
+ Je(s.file, "GET", a, r), Ks(
2635
2755
  s.file,
2636
- o.render.mode,
2756
+ i.render.mode,
2637
2757
  a.document
2638
- ), Cs(
2758
+ ), qs(
2639
2759
  s.file,
2640
2760
  "GET",
2641
2761
  a,
@@ -2643,7 +2763,7 @@ function As(e, t, r) {
2643
2763
  ...e.layouts.filter(
2644
2764
  (c) => T(c.fileSegments, s.fileSegments)
2645
2765
  ).map((c) => t[c.file]?.scripts),
2646
- i.scripts
2766
+ o.scripts
2647
2767
  ]
2648
2768
  );
2649
2769
  }
@@ -2653,40 +2773,40 @@ function As(e, t, r) {
2653
2773
  ...e.fallbacks.notFound
2654
2774
  ];
2655
2775
  for (const s of n) {
2656
- const i = Y(
2776
+ const o = X(
2657
2777
  ...e.policies.filter(
2658
- (o) => T(o.fileSegments, s.fileSegments)
2659
- ).map((o) => t[o.file]?.policy),
2778
+ (i) => T(i.fileSegments, s.fileSegments)
2779
+ ).map((i) => t[i.file]?.policy),
2660
2780
  t[s.file]?.policy
2661
2781
  );
2662
- qe(
2782
+ Je(
2663
2783
  s.file,
2664
2784
  "policy",
2665
- i,
2785
+ o,
2666
2786
  r
2667
2787
  );
2668
2788
  }
2669
2789
  }
2670
- function Cs(e, t, r, n) {
2790
+ function qs(e, t, r, n) {
2671
2791
  const s = n.flatMap(
2672
- (l) => Array.isArray(l) ? l : []
2792
+ (f) => Array.isArray(f) ? f : []
2673
2793
  );
2674
2794
  if (s.length === 0 || !r.document)
2675
2795
  return;
2676
- const i = "startup-verification-nonce", a = Dn({
2796
+ const o = "startup-verification-nonce", a = jn({
2677
2797
  document: {
2678
- headers: { nonce: i },
2798
+ headers: { nonce: o },
2679
2799
  policy: r.document,
2680
- scripts: s.map((l) => ({
2681
- ...l,
2682
- nonce: ee(r.document) ? i : l.nonce
2800
+ scripts: s.map((f) => ({
2801
+ ...f,
2802
+ nonce: ne(r.document) ? o : f.nonce
2683
2803
  }))
2684
2804
  }
2685
2805
  }).findings.find(
2686
- (l) => l.code === "csp-script-src-blocked"
2806
+ (f) => f.code === "csp-script-src-blocked"
2687
2807
  );
2688
2808
  if (!a) {
2689
- ks(
2809
+ _s(
2690
2810
  e,
2691
2811
  t,
2692
2812
  r.document.csp,
@@ -2695,39 +2815,39 @@ function Cs(e, t, r, n) {
2695
2815
  return;
2696
2816
  }
2697
2817
  const c = s.find(
2698
- (l) => a.message.includes(l.src)
2699
- ), f = (W(r.document, { nonce: i }).get("content-security-policy") ?? "").split("; ").find(
2700
- (l) => l.startsWith("script-src ")
2818
+ (f) => a.message.includes(f.src)
2819
+ ), l = (q(r.document, { nonce: o }).get("content-security-policy") ?? "").split("; ").find(
2820
+ (f) => f.startsWith("script-src ")
2701
2821
  ) ?? "default-src (script-src fallback)";
2702
2822
  throw new Error(
2703
- `Route ${JSON.stringify(e)} export ${t} declares script ${JSON.stringify(c?.src)} that violates the effective ${f} policy.`
2823
+ `Route ${JSON.stringify(e)} export ${t} declares script ${JSON.stringify(c?.src)} that violates the effective ${l} policy.`
2704
2824
  );
2705
2825
  }
2706
- const $s = [
2826
+ const Gs = [
2707
2827
  { directive: "connectSrc", name: "connect-src", need: "connect" },
2708
2828
  { directive: "imgSrc", name: "img-src", need: "img" }
2709
2829
  ];
2710
- function ks(e, t, r, n) {
2830
+ function _s(e, t, r, n) {
2711
2831
  if (r)
2712
2832
  for (const s of n)
2713
- for (const { directive: i, name: o, need: a } of $s) {
2833
+ for (const { directive: o, name: i, need: a } of Gs) {
2714
2834
  const c = s.needs?.[a] ?? [];
2715
2835
  if (c.length === 0)
2716
2836
  continue;
2717
- const u = H(r[i]) ?? H(r.defaultSrc);
2837
+ const u = W(r[o]) ?? W(r.defaultSrc);
2718
2838
  if (u !== void 0) {
2719
- for (const f of c)
2720
- if (!(Array.isArray(u) && Ds(u, f)))
2839
+ for (const l of c)
2840
+ if (!(Array.isArray(u) && Vs(u, l)))
2721
2841
  throw new Error(
2722
- `Route ${JSON.stringify(e)} export ${t} declares script ${JSON.stringify(s.src)} that needs ${o} ${f}, which the effective policy does not allow. Add ${f} to security.needs.${a} or to csp.${i} for this route.`
2842
+ `Route ${JSON.stringify(e)} export ${t} declares script ${JSON.stringify(s.src)} that needs ${i} ${l}, which the effective policy does not allow. Add ${l} to security.needs.${a} or to csp.${o} for this route.`
2723
2843
  );
2724
2844
  }
2725
2845
  }
2726
2846
  }
2727
- function Ds(e, t) {
2728
- return e.includes("'none'") ? !1 : e.includes("*") || e.includes(t) ? !0 : t.startsWith("'") ? !1 : e.some((r) => Ns(r, t));
2847
+ function Vs(e, t) {
2848
+ return e.includes("'none'") ? !1 : e.includes("*") || e.includes(t) ? !0 : t.startsWith("'") ? !1 : e.some((r) => Js(r, t));
2729
2849
  }
2730
- function Ns(e, t) {
2850
+ function Js(e, t) {
2731
2851
  if (e.startsWith("'"))
2732
2852
  return !1;
2733
2853
  let r;
@@ -2752,18 +2872,18 @@ function Ns(e, t) {
2752
2872
  }
2753
2873
  return n.hostname === r.hostname;
2754
2874
  }
2755
- function qe(e, t, r, n) {
2756
- j(e, t, "effective document", () => {
2757
- W(r.document ?? {}, {
2875
+ function Je(e, t, r, n) {
2876
+ z(e, t, "effective document", () => {
2877
+ q(r.document ?? {}, {
2758
2878
  nonce: "startup-verification-nonce"
2759
2879
  });
2760
- }), !(!n || !ee(r.document)) && j(e, t, "effective CSP", () => {
2761
- Ot(n, ["nonceInjection"]);
2880
+ }), !(!n || !ne(r.document)) && z(e, t, "effective CSP", () => {
2881
+ Wt(n, ["nonceInjection"]);
2762
2882
  });
2763
2883
  }
2764
- function Os(e, t, r) {
2884
+ function Ks(e, t, r) {
2765
2885
  if (t === "static") {
2766
- const s = Ls(r?.csp);
2886
+ const s = Ys(r?.csp);
2767
2887
  if (s)
2768
2888
  throw new Error(
2769
2889
  `Route ${JSON.stringify(e)} uses render mode "static" with an effective ${s} directive that depends on a CSP nonce. Use security.static() for static output or remove the nonce source from the document policy.`
@@ -2772,76 +2892,76 @@ function Os(e, t, r) {
2772
2892
  }
2773
2893
  if (t !== "streaming")
2774
2894
  return;
2775
- const n = Is(r?.csp);
2776
- if (!(!n || Ms(n.sources)))
2895
+ const n = Zs(r?.csp);
2896
+ if (!(!n || Qs(n.sources)))
2777
2897
  throw new Error(
2778
2898
  `Route ${JSON.stringify(e)} uses render mode "streaming" with an effective ${n.name} directive that does not allow React runtime inline payload scripts. Add a nonce placeholder or allow 'unsafe-inline' without nonce or hash sources.`
2779
2899
  );
2780
2900
  }
2781
- function Ls(e) {
2901
+ function Ys(e) {
2782
2902
  if (e)
2783
2903
  for (const [t, r] of Object.entries(e)) {
2784
- const n = H(r);
2785
- if (Array.isArray(n) && n.some((s) => Us(s)))
2786
- return js(t);
2904
+ const n = W(r);
2905
+ if (Array.isArray(n) && n.some((s) => Xs(s)))
2906
+ return to(t);
2787
2907
  }
2788
2908
  }
2789
- function Is(e) {
2909
+ function Zs(e) {
2790
2910
  if (!e)
2791
2911
  return;
2792
- const t = H(e.scriptSrc);
2912
+ const t = W(e.scriptSrc);
2793
2913
  if (Array.isArray(t))
2794
2914
  return { name: "script-src", sources: t };
2795
- const r = H(e.defaultSrc);
2915
+ const r = W(e.defaultSrc);
2796
2916
  if (Array.isArray(r))
2797
2917
  return { name: "default-src", sources: r };
2798
2918
  }
2799
- function Ms(e) {
2800
- return e.some((t) => bt(t)) ? !0 : e.includes("'unsafe-inline'") && !e.some((t) => Hs(t));
2919
+ function Qs(e) {
2920
+ return e.some((t) => Dt(t)) ? !0 : e.includes("'unsafe-inline'") && !e.some((t) => eo(t));
2801
2921
  }
2802
- function Us(e) {
2803
- return bt(e) || /^'nonce-[^']*'$/i.test(e);
2922
+ function Xs(e) {
2923
+ return Dt(e) || /^'nonce-[^']*'$/i.test(e);
2804
2924
  }
2805
- function bt(e) {
2925
+ function Dt(e) {
2806
2926
  return e.includes("{nonce}");
2807
2927
  }
2808
- function Hs(e) {
2928
+ function eo(e) {
2809
2929
  return /^'(?:nonce-|sha256-|sha384-|sha512-)/i.test(e);
2810
2930
  }
2811
- function H(e) {
2931
+ function W(e) {
2812
2932
  return e && typeof e == "object" && !Array.isArray(e) && "replace" in e ? e.replace : e;
2813
2933
  }
2814
- function js(e) {
2934
+ function to(e) {
2815
2935
  return e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
2816
2936
  }
2817
- function j(e, t, r, n) {
2937
+ function z(e, t, r, n) {
2818
2938
  try {
2819
2939
  n();
2820
2940
  } catch (s) {
2821
2941
  if (s instanceof Error && s.message.startsWith(`Route ${JSON.stringify(e)} export `))
2822
2942
  throw s;
2823
- const i = s instanceof Error ? s.message : `${r} validation failed.`;
2943
+ const o = s instanceof Error ? s.message : `${r} validation failed.`;
2824
2944
  throw new Error(
2825
- `Route ${JSON.stringify(e)} export ${t} has an invalid ${r} policy. ${i}`,
2945
+ `Route ${JSON.stringify(e)} export ${t} has an invalid ${r} policy. ${o}`,
2826
2946
  { cause: s }
2827
2947
  );
2828
2948
  }
2829
2949
  }
2830
- function Fs(e) {
2831
- return J({
2950
+ function ro(e) {
2951
+ return Z({
2832
2952
  instance: `${e.pathname}${e.search}`,
2833
2953
  status: 404,
2834
2954
  title: "Not Found"
2835
2955
  });
2836
2956
  }
2837
- async function pe(e, t, r = {}) {
2957
+ async function ye(e, t, r = {}) {
2838
2958
  const n = new URL(t.url);
2839
- if (!at(t))
2840
- return Fs(n);
2841
- const s = await me(e, n.pathname, {
2959
+ if (!dt(t))
2960
+ return ro(n);
2961
+ const s = await pe(e, n.pathname, {
2842
2962
  onLayoutError: (u) => r.onError?.(u, "page")
2843
- }), i = await Ws(e, n.pathname), o = r.nonce ?? (ee(i) ? dt() : void 0), a = qs(s, { ...r, nonce: o }), c = W(i ?? {}, {
2844
- nonce: o,
2963
+ }), o = await no(e, n.pathname), i = r.nonce ?? (ne(o) ? yt() : void 0), a = so(s, { ...r, nonce: i }), c = q(o ?? {}, {
2964
+ nonce: i,
2845
2965
  request: t
2846
2966
  });
2847
2967
  return c.set("content-type", "text/html; charset=utf-8"), new Response(
@@ -2852,55 +2972,55 @@ async function pe(e, t, r = {}) {
2852
2972
  }
2853
2973
  );
2854
2974
  }
2855
- async function Ws(e, t) {
2975
+ async function no(e, t) {
2856
2976
  const r = await Promise.all(
2857
- nr(e, t).map((n) => n.load())
2977
+ fr(e, t).map((n) => n.load())
2858
2978
  );
2859
- return Y(...r.map((n) => n.policy)).document;
2979
+ return X(...r.map((n) => n.policy)).document;
2860
2980
  }
2861
- function qs(e, t = {}) {
2862
- const r = e.notFound ?? Le;
2981
+ function so(e, t = {}) {
2982
+ const r = e.notFound ?? He;
2863
2983
  try {
2864
- return ce(e, r, e.layouts, t);
2984
+ return fe(e, r, e.layouts, t);
2865
2985
  } catch (n) {
2866
2986
  t.onError?.(n, "page");
2867
2987
  }
2868
2988
  try {
2869
- return ce(e, r, [], t);
2989
+ return fe(e, r, [], t);
2870
2990
  } catch (n) {
2871
2991
  t.onError?.(n, "page");
2872
2992
  }
2873
- return ce(e, Le, [], t);
2993
+ return fe(e, He, [], t);
2874
2994
  }
2875
- function ce(e, t, r, n) {
2995
+ function fe(e, t, r, n) {
2876
2996
  const s = r.reduceRight(
2877
- (o, a) => fe(a, {
2878
- children: o,
2997
+ (i, a) => de(a, {
2998
+ children: i,
2879
2999
  path: {},
2880
3000
  pathname: e.pathname
2881
3001
  }),
2882
- fe(t, { pathname: e.pathname })
2883
- ), i = _e({
3002
+ de(t, { pathname: e.pathname })
3003
+ ), o = Qe({
2884
3004
  dev: n.dev,
2885
3005
  nonce: n.nonce
2886
3006
  });
2887
- return Je({
3007
+ return et({
2888
3008
  body: {
2889
3009
  data: void 0,
2890
3010
  fallback: "not-found",
2891
- html: Ke(Ve(i, s)),
3011
+ html: tt(Xe(o, s)),
2892
3012
  navigation: n.navigation
2893
3013
  },
2894
3014
  entrySrc: n.clientEntry,
2895
3015
  lang: n.lang,
2896
3016
  metadata: e.metadata,
2897
3017
  nonce: n.nonce,
2898
- scripts: i.scripts(),
3018
+ scripts: o.scripts(),
2899
3019
  styles: n.styles,
2900
3020
  title: n.title
2901
3021
  });
2902
3022
  }
2903
- const Tt = [
3023
+ const $t = [
2904
3024
  "GET",
2905
3025
  "POST",
2906
3026
  "PUT",
@@ -2908,12 +3028,12 @@ const Tt = [
2908
3028
  "DELETE",
2909
3029
  "OPTIONS",
2910
3030
  "HEAD"
2911
- ], xt = Et();
2912
- function Di(e) {
2913
- e.routeModules && Rs(e.routeModules, { adapter: e.adapter });
2914
- const t = et(e.routes), r = e.rateLimitStore ?? Et();
2915
- return e.cacheStore && Ze(e.cacheStore.namespace), async function(s) {
2916
- return await zs(t, s, {
3031
+ ], kt = At();
3032
+ function Yo(e) {
3033
+ e.routeModules && Us(e.routeModules, { adapter: e.adapter });
3034
+ const t = ot(e.routes), r = e.rateLimitStore ?? At();
3035
+ return e.cacheStore && nt(e.cacheStore.namespace), async function(s) {
3036
+ return await oo(t, s, {
2917
3037
  cacheStore: e.cacheStore,
2918
3038
  onError: e.onError,
2919
3039
  rateLimitStore: r,
@@ -2922,31 +3042,31 @@ function Di(e) {
2922
3042
  });
2923
3043
  };
2924
3044
  }
2925
- async function zs(e, t, r = {
2926
- rateLimitStore: xt
3045
+ async function oo(e, t, r = {
3046
+ rateLimitStore: kt
2927
3047
  }) {
2928
- const n = new URL(t.url), s = _s(n, r), i = st(t);
2929
- let o;
3048
+ const n = new URL(t.url), s = co(n, r), o = ut(t);
3049
+ let i;
2930
3050
  try {
2931
- o = F(e.routes, n.pathname);
3051
+ i = B(e.routes, n.pathname);
2932
3052
  } catch (a) {
2933
- if (!(a instanceof Ee))
3053
+ if (!(a instanceof Te))
2934
3054
  throw a;
2935
- const c = J({
3055
+ const c = Z({
2936
3056
  instance: `${n.pathname}${n.search}`,
2937
3057
  status: 400,
2938
3058
  title: "Bad Request"
2939
3059
  });
2940
- return i ? z(c, ie) : c;
3060
+ return o ? _(c, ae) : c;
2941
3061
  }
2942
- if (!o)
3062
+ if (!i)
2943
3063
  try {
2944
- const a = await pe(
3064
+ const a = await ye(
2945
3065
  e,
2946
3066
  t,
2947
3067
  s
2948
3068
  );
2949
- return i ? z(a, Oe) : a;
3069
+ return o ? _(a, Fe) : a;
2950
3070
  } catch (a) {
2951
3071
  return s.onError(a, "page"), new Response("Not Found", {
2952
3072
  headers: { "content-type": "text/plain; charset=utf-8" },
@@ -2954,194 +3074,217 @@ async function zs(e, t, r = {
2954
3074
  });
2955
3075
  }
2956
3076
  try {
2957
- const a = await Bs(
3077
+ const a = await io(
2958
3078
  e,
2959
3079
  t,
2960
3080
  n,
2961
- o,
3081
+ i,
2962
3082
  r,
2963
3083
  s
2964
3084
  );
2965
- return i && !a.headers.has(C) ? z(
3085
+ return o && !a.headers.has(C) ? _(
2966
3086
  a,
2967
- a.status === 404 ? Oe : ie
3087
+ a.status === 404 ? Fe : ae
2968
3088
  ) : a;
2969
3089
  } catch (a) {
2970
- const c = await _(
3090
+ const c = await Y(
2971
3091
  e,
2972
3092
  t,
2973
3093
  a,
2974
3094
  "middleware",
2975
3095
  s
2976
3096
  );
2977
- return i ? z(c, ie) : c;
3097
+ return o ? _(c, ae) : c;
2978
3098
  }
2979
3099
  }
2980
- async function Bs(e, t, r, n, s, i) {
2981
- const o = await n.route.load();
3100
+ async function io(e, t, r, n, s, o) {
3101
+ const i = await n.route.load();
2982
3102
  if (t.method.toUpperCase() === "OPTIONS") {
2983
- const h = bn(o, t);
2984
- if (h)
2985
- return h;
3103
+ const p = Nn(i, t);
3104
+ if (p)
3105
+ return p;
2986
3106
  }
2987
- const a = Ys(t.method);
3107
+ const a = ho(t.method);
2988
3108
  if (!a)
2989
- return Ge(o);
2990
- const c = Zs(o, a);
3109
+ return Ze(i);
3110
+ const c = mo(i, a);
2991
3111
  if (!c)
2992
- return Ge(o);
2993
- const u = await Js(
3112
+ return Ze(i);
3113
+ const u = await lo(
2994
3114
  e,
2995
3115
  n.route,
2996
- o,
3116
+ i,
2997
3117
  c
2998
- ), f = u.security, l = Qn(f?.csrf, t);
2999
- if (l)
3000
- return V(l, ue(c), t);
3001
- const m = cs(
3002
- f?.rateLimit,
3118
+ ), l = u.security, f = ys(
3119
+ l?.fetchMetadata,
3003
3120
  t,
3004
- s.rateLimitStore ?? xt
3121
+ a
3122
+ ), h = (p) => xt(p, f.vary);
3123
+ if (f.response)
3124
+ return h(
3125
+ U(
3126
+ f.response,
3127
+ J(c),
3128
+ t
3129
+ )
3130
+ );
3131
+ const d = as(l?.csrf, t);
3132
+ if (d)
3133
+ return h(
3134
+ U(d, J(c), t)
3135
+ );
3136
+ const D = await Ts(
3137
+ l?.rateLimit,
3138
+ t,
3139
+ s.rateLimitStore ?? kt
3005
3140
  );
3006
- if (m)
3007
- return V(
3008
- m,
3009
- ue(c),
3010
- t
3141
+ if (D)
3142
+ return h(
3143
+ U(
3144
+ D,
3145
+ J(c),
3146
+ t
3147
+ )
3011
3148
  );
3012
- const d = hs(
3013
- f?.request,
3149
+ const $ = $s(
3150
+ l?.request,
3014
3151
  t,
3015
3152
  a
3016
3153
  );
3017
- if (d)
3018
- return V(
3019
- d,
3020
- ue(c),
3021
- t
3154
+ if ($)
3155
+ return h(
3156
+ U(
3157
+ $,
3158
+ J(c),
3159
+ t
3160
+ )
3022
3161
  );
3023
- t = ps(f?.request, t);
3024
- const P = {};
3162
+ t = ks(l?.request, t);
3163
+ const m = {};
3025
3164
  if (c.kind === "page") {
3026
- const h = {
3165
+ const p = {
3027
3166
  path: n.path,
3028
3167
  pathname: r.pathname,
3029
3168
  request: t,
3030
- context: P,
3169
+ context: m,
3031
3170
  search: r.searchParams,
3032
3171
  url: r
3033
- }, te = await ze(
3172
+ }, Nt = await Ke(
3034
3173
  e,
3035
3174
  n.route
3036
- ), k = ee(u.document) ? dt() : void 0, Pt = Gs(s.cacheStore);
3037
- let E;
3175
+ ), O = ne(u.document) ? yt() : void 0, Ot = ao(s.cacheStore);
3176
+ let y;
3038
3177
  try {
3039
- E = await Be(te, h, async () => {
3178
+ y = await Ye(Nt, p, async () => {
3040
3179
  try {
3041
- const p = await tt(
3180
+ const g = await it(
3042
3181
  e,
3043
3182
  r.pathname,
3044
3183
  t,
3045
3184
  void 0,
3046
- Pt,
3047
- { requestContext: P }
3185
+ Ot,
3186
+ { requestContext: m }
3048
3187
  );
3049
- if (p.status !== "ready")
3050
- return await pe(e, t, {
3051
- ...i,
3052
- nonce: k
3188
+ if (g.status !== "ready")
3189
+ return await ye(e, t, {
3190
+ ...o,
3191
+ nonce: O
3053
3192
  });
3054
- if (st(t))
3055
- return pr(p.match.data);
3056
- if (p.match.render.mode === "streaming" && !s.renderPage)
3193
+ if (ut(t))
3194
+ return br(g.match.data);
3195
+ if (g.match.render.mode === "streaming" && !s.renderPage)
3057
3196
  throw new Error(
3058
3197
  "Streaming page routes require an adapter renderer. Pass renderNodePageResponse from @demiurgejs/core/node as createRequestHandler({ renderPage })."
3059
3198
  );
3060
- return await (s.renderPage ?? Lt)(p.match, {
3199
+ return await (s.renderPage ?? zt)(g.match, {
3061
3200
  ...s.ssr,
3062
3201
  dev: s.dev,
3063
- nonce: k,
3064
- onStreamError: (Ct) => {
3065
- s.onError?.(Ct, {
3202
+ nonce: O,
3203
+ onStreamError: (Mt) => {
3204
+ s.onError?.(Mt, {
3066
3205
  pathname: r.pathname,
3067
3206
  site: "page"
3068
3207
  });
3069
3208
  },
3070
3209
  signal: t.signal
3071
3210
  });
3072
- } catch (p) {
3073
- return p instanceof L ? B() : await _(e, t, p, "page", {
3074
- ...i,
3075
- nonce: k
3211
+ } catch (g) {
3212
+ return g instanceof F ? V() : await Y(e, t, g, "page", {
3213
+ ...o,
3214
+ nonce: O
3076
3215
  });
3077
3216
  }
3078
3217
  });
3079
- } catch (p) {
3080
- if (!(p instanceof L))
3081
- throw p;
3082
- E = B();
3218
+ } catch (g) {
3219
+ if (!(g instanceof F))
3220
+ throw g;
3221
+ y = V();
3083
3222
  }
3084
- const At = W(u.document ?? {}, {
3085
- nonce: k,
3223
+ const Lt = q(u.document ?? {}, {
3224
+ nonce: O,
3086
3225
  request: t
3087
3226
  });
3088
- for (const [p, Pe] of At)
3089
- E.headers.set(p, Pe);
3090
- return k && E.headers.set("cache-control", "private, no-store"), a === "HEAD" ? (await E.body?.cancel(), new Response(null, {
3091
- headers: E.headers,
3092
- status: E.status
3093
- })) : E;
3094
- }
3095
- const $ = {
3227
+ for (const [g, ke] of Lt)
3228
+ y.headers.set(g, ke);
3229
+ return O && y.headers.set("cache-control", "private, no-store"), h(y), a === "HEAD" ? (await y.body?.cancel(), new Response(null, {
3230
+ headers: y.headers,
3231
+ status: y.status
3232
+ })) : y;
3233
+ }
3234
+ const k = {
3096
3235
  path: n.path,
3097
3236
  pathname: r.pathname,
3098
3237
  request: t,
3099
- context: P,
3238
+ context: m,
3100
3239
  search: r.searchParams,
3101
3240
  url: r
3102
- }, g = await ze(
3241
+ }, $e = await Ke(
3103
3242
  e,
3104
3243
  n.route
3105
3244
  );
3106
- let A;
3245
+ let N;
3107
3246
  try {
3108
- A = await Be(g, $, async () => {
3247
+ N = await Ye($e, k, async () => {
3109
3248
  try {
3110
- return c.kind === "not-found" && c.body === void 0 ? Vs(
3111
- await pe(e, t, i),
3249
+ return c.kind === "not-found" && c.body === void 0 ? uo(
3250
+ await ye(e, t, o),
3112
3251
  c.init
3113
- ) : await Rr(c, $);
3114
- } catch (h) {
3115
- return h instanceof L ? B() : await _(
3252
+ ) : await Dr(c, k);
3253
+ } catch (p) {
3254
+ return p instanceof F ? V() : await Y(
3116
3255
  e,
3117
3256
  t,
3118
- h,
3257
+ p,
3119
3258
  "route",
3120
- i
3259
+ o
3121
3260
  );
3122
3261
  }
3123
3262
  });
3124
- } catch (h) {
3125
- if (!(h instanceof L))
3126
- throw h;
3127
- A = B();
3263
+ } catch (p) {
3264
+ if (!(p instanceof F))
3265
+ throw p;
3266
+ N = V();
3128
3267
  }
3129
3268
  try {
3130
- return Ks(A, c, t, a);
3131
- } catch (h) {
3132
- return await _(
3133
- e,
3134
- t,
3135
- h,
3136
- "route",
3137
- i
3269
+ return h(
3270
+ fo(N, c, t, a)
3271
+ );
3272
+ } catch (p) {
3273
+ return h(
3274
+ await Y(
3275
+ e,
3276
+ t,
3277
+ p,
3278
+ "route",
3279
+ o
3280
+ )
3138
3281
  );
3139
3282
  }
3140
3283
  }
3141
- function Gs(e) {
3142
- return e ? Ye(e) : ge();
3284
+ function ao(e) {
3285
+ return e ? rt(e) : we();
3143
3286
  }
3144
- function _s(e, t) {
3287
+ function co(e, t) {
3145
3288
  return {
3146
3289
  ...t.ssr,
3147
3290
  dev: t.dev,
@@ -3151,12 +3294,12 @@ function _s(e, t) {
3151
3294
  transformDocument: t.transformDocument
3152
3295
  };
3153
3296
  }
3154
- function Vs(e, t) {
3297
+ function uo(e, t) {
3155
3298
  if (!t)
3156
3299
  return e;
3157
3300
  const r = new Headers(e.headers), n = new Headers(t.headers);
3158
- for (const [s, i] of n)
3159
- s !== "set-cookie" && r.set(s, i);
3301
+ for (const [s, o] of n)
3302
+ s !== "set-cookie" && r.set(s, o);
3160
3303
  for (const s of n.getSetCookie())
3161
3304
  r.append("set-cookie", s);
3162
3305
  return new Response(e.body, {
@@ -3165,21 +3308,21 @@ function Vs(e, t) {
3165
3308
  statusText: t.statusText ?? e.statusText
3166
3309
  });
3167
3310
  }
3168
- async function Js(e, t, r, n) {
3311
+ async function lo(e, t, r, n) {
3169
3312
  const s = await Promise.all(
3170
3313
  e.policies.filter(
3171
- (i) => T(i.fileSegments, t.fileSegments)
3172
- ).map((i) => i.load())
3314
+ (o) => T(o.fileSegments, t.fileSegments)
3315
+ ).map((o) => o.load())
3173
3316
  );
3174
- return Y(
3175
- ...s.map((i) => i.policy),
3317
+ return X(
3318
+ ...s.map((o) => o.policy),
3176
3319
  r.policy,
3177
3320
  {
3178
- security: n.kind === "page" ? void 0 : n.security
3321
+ security: !n || n.kind === "page" ? void 0 : n.security
3179
3322
  }
3180
3323
  );
3181
3324
  }
3182
- async function ze(e, t) {
3325
+ async function Ke(e, t) {
3183
3326
  return (await Promise.all(
3184
3327
  e.middlewares.filter(
3185
3328
  (n) => T(n.fileSegments, t.fileSegments)
@@ -3188,20 +3331,20 @@ async function ze(e, t) {
3188
3331
  (n) => n.middleware ? [n.middleware] : []
3189
3332
  );
3190
3333
  }
3191
- async function Be(e, t, r) {
3334
+ async function Ye(e, t, r) {
3192
3335
  let n = -1;
3193
- async function s(i) {
3194
- if (i <= n)
3336
+ async function s(o) {
3337
+ if (o <= n)
3195
3338
  throw new Error("Demiurge route middleware next() called multiple times.");
3196
- n = i;
3197
- const o = e[i];
3198
- return o ? await o(t, () => s(i + 1)) : await r();
3339
+ n = o;
3340
+ const i = e[o];
3341
+ return i ? await i(t, () => s(o + 1)) : await r();
3199
3342
  }
3200
3343
  return await s(0);
3201
3344
  }
3202
- function Ks(e, t, r, n) {
3203
- const s = Dr(
3204
- V(e, t.cors, r),
3345
+ function fo(e, t, r, n) {
3346
+ const s = Hr(
3347
+ U(e, t.cors, r),
3205
3348
  t.timing
3206
3349
  );
3207
3350
  return n === "HEAD" ? new Response(null, {
@@ -3210,112 +3353,123 @@ function Ks(e, t, r, n) {
3210
3353
  statusText: s.statusText
3211
3354
  }) : s;
3212
3355
  }
3213
- function ue(e) {
3356
+ function J(e) {
3214
3357
  return e.kind === "page" ? void 0 : e.cors;
3215
3358
  }
3216
- function Ys(e) {
3359
+ function ho(e) {
3217
3360
  const t = e.toUpperCase();
3218
- return Tt.includes(t) ? t : null;
3361
+ return $t.includes(t) ? t : null;
3219
3362
  }
3220
- function Zs(e, t) {
3363
+ function mo(e, t) {
3221
3364
  return t === "HEAD" ? e.HEAD ?? e.GET : e[t];
3222
3365
  }
3223
- function Ge(e) {
3366
+ function Ze(e) {
3224
3367
  return new Response(null, {
3225
3368
  headers: {
3226
- allow: Qs(e).join(", ")
3369
+ allow: po(e).join(", ")
3227
3370
  },
3228
3371
  status: 405
3229
3372
  });
3230
3373
  }
3231
- function Qs(e) {
3232
- const t = Tt.filter((r) => e[r]);
3374
+ function po(e) {
3375
+ const t = $t.filter((r) => e[r]);
3233
3376
  return e.GET && !t.includes("HEAD") && t.push("HEAD"), t;
3234
3377
  }
3235
3378
  export {
3236
- hs as $,
3237
- hr as A,
3238
- Oe as B,
3239
- ie as C,
3240
- Pi as D,
3241
- Le as E,
3242
- ve as F,
3243
- it as G,
3244
- Ur as H,
3245
- On as I,
3246
- Ye as J,
3247
- yt as K,
3248
- Zn as L,
3249
- Yn as M,
3379
+ is as $,
3380
+ Wo as A,
3381
+ Dr as B,
3382
+ cs as C,
3383
+ ks as D,
3384
+ Ct as E,
3385
+ Tr as F,
3386
+ ko as G,
3387
+ cr as H,
3388
+ vr as I,
3389
+ Rr as J,
3390
+ Fe as K,
3391
+ ae as L,
3392
+ Te as M,
3250
3393
  C as N,
3251
- oi as O,
3252
- ge as P,
3253
- Ht as Q,
3254
- L as R,
3255
- Dn as S,
3256
- Me as T,
3257
- ai as U,
3258
- Ci as V,
3259
- Ai as W,
3260
- ii as X,
3394
+ Gr as O,
3395
+ Go as P,
3396
+ He as Q,
3397
+ F as R,
3398
+ Ae as S,
3399
+ A as T,
3400
+ lt as U,
3401
+ xt as V,
3402
+ zn as W,
3403
+ vo as X,
3261
3404
  gs as Y,
3262
- Qn as Z,
3263
- cs as _,
3264
- Rs as a,
3265
- Si as a0,
3266
- ki as a1,
3267
- gi as a2,
3268
- yi as a3,
3269
- ui as a4,
3270
- Y as a5,
3271
- nn as a6,
3272
- ci as a7,
3273
- Ri as a8,
3274
- Xn as a9,
3275
- Rt as aa,
3276
- ni as ab,
3277
- Ei as ac,
3278
- v as ad,
3279
- Ze as ae,
3280
- le as af,
3281
- xi as ag,
3282
- Ti as ah,
3283
- bi as ai,
3284
- fi as aj,
3285
- si as ak,
3286
- wi as al,
3287
- hi as am,
3288
- T as an,
3289
- pi as ao,
3290
- mi as ap,
3291
- ir as aq,
3292
- dr as ar,
3293
- X as as,
3294
- R as at,
3295
- li as b,
3296
- Di as c,
3297
- Et as d,
3298
- $i as e,
3299
- W as f,
3300
- xe as g,
3301
- zs as h,
3302
- dt as i,
3303
- F as j,
3304
- et as k,
3305
- $e as l,
3306
- rn as m,
3307
- vi as n,
3308
- ps as o,
3309
- U as p,
3310
- vt as q,
3311
- pe as r,
3312
- D as s,
3313
- Rr as t,
3314
- gr as u,
3315
- Te as v,
3316
- di as w,
3317
- tt as x,
3318
- er as y,
3319
- mr as z
3405
+ rt as Z,
3406
+ Rt as _,
3407
+ Us as a,
3408
+ os as a0,
3409
+ xo as a1,
3410
+ _t as a2,
3411
+ We as a3,
3412
+ Ao as a4,
3413
+ Vo as a5,
3414
+ _o as a6,
3415
+ To as a7,
3416
+ Ns as a8,
3417
+ as as a9,
3418
+ No as aA,
3419
+ hr as aB,
3420
+ Er as aC,
3421
+ re as aD,
3422
+ v as aE,
3423
+ ys as aa,
3424
+ Ts as ab,
3425
+ $s as ac,
3426
+ Fo as ad,
3427
+ Ro as ae,
3428
+ Ko as af,
3429
+ Mo as ag,
3430
+ Io as ah,
3431
+ Co as ai,
3432
+ X as aj,
3433
+ dn as ak,
3434
+ Po as al,
3435
+ jo as am,
3436
+ Pt as an,
3437
+ Eo as ao,
3438
+ Ho as ap,
3439
+ R as aq,
3440
+ nt as ar,
3441
+ qo as as,
3442
+ Bo as at,
3443
+ zo as au,
3444
+ Do as av,
3445
+ bo as aw,
3446
+ Uo as ax,
3447
+ Oo as ay,
3448
+ Lo as az,
3449
+ $o as b,
3450
+ Yo as c,
3451
+ At as d,
3452
+ Jo as e,
3453
+ q as f,
3454
+ De as g,
3455
+ oo as h,
3456
+ it as i,
3457
+ T as j,
3458
+ te as k,
3459
+ lo as l,
3460
+ fn as m,
3461
+ B as n,
3462
+ ne as o,
3463
+ yt as p,
3464
+ jn as q,
3465
+ ye as r,
3466
+ L as s,
3467
+ mr as t,
3468
+ we as u,
3469
+ Ce as v,
3470
+ he as w,
3471
+ Le as x,
3472
+ ot as y,
3473
+ P as z
3320
3474
  };
3321
- //# sourceMappingURL=testing-B_iMFYz_.js.map
3475
+ //# sourceMappingURL=testing-CRflAw4X.js.map