cloudcommerce 0.2.2 → 0.2.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 (76) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.json +3 -3
  3. package/packages/api/package.json +1 -1
  4. package/packages/apps/correios/package.json +1 -1
  5. package/packages/apps/custom-payment/package.json +1 -1
  6. package/packages/apps/custom-shipping/package.json +1 -1
  7. package/packages/apps/datafrete/package.json +1 -1
  8. package/packages/apps/discounts/package.json +1 -1
  9. package/packages/apps/emails/package.json +1 -1
  10. package/packages/apps/fb-conversions/lib/fb-conversions-events.js +131 -111
  11. package/packages/apps/fb-conversions/lib/fb-conversions-events.js.map +1 -1
  12. package/packages/apps/fb-conversions/lib/functions-lib/create-fb-objects.js +69 -0
  13. package/packages/apps/fb-conversions/lib/functions-lib/create-fb-objects.js.map +1 -0
  14. package/packages/apps/fb-conversions/package.json +1 -1
  15. package/packages/apps/fb-conversions/src/fb-conversions-events.ts +173 -125
  16. package/packages/apps/fb-conversions/src/functions-lib/create-fb-objects.ts +104 -0
  17. package/packages/apps/frenet/package.json +1 -1
  18. package/packages/apps/galaxpay/package.json +1 -1
  19. package/packages/apps/google-analytics/package.json +1 -1
  20. package/packages/apps/infinitepay/package.json +1 -1
  21. package/packages/apps/jadlog/package.json +1 -1
  22. package/packages/apps/loyalty-points/package.json +1 -1
  23. package/packages/apps/mercadopago/package.json +1 -1
  24. package/packages/apps/pagarme/package.json +1 -1
  25. package/packages/apps/paghiper/package.json +1 -1
  26. package/packages/apps/pix/package.json +1 -1
  27. package/packages/apps/tiny-erp/package.json +1 -1
  28. package/packages/cli/package.json +1 -1
  29. package/packages/config/package.json +1 -1
  30. package/packages/emails/package.json +1 -1
  31. package/packages/events/package.json +1 -1
  32. package/packages/firebase/lib/config.js +1 -0
  33. package/packages/firebase/lib/config.js.map +1 -1
  34. package/packages/firebase/package.json +1 -1
  35. package/packages/firebase/src/config.ts +1 -0
  36. package/packages/i18n/package.json +1 -1
  37. package/packages/modules/package.json +1 -1
  38. package/packages/passport/package.json +1 -1
  39. package/packages/ssr/package.json +4 -4
  40. package/packages/storefront/dist/client/_astro/PitchBar.f3579a5b.js +1 -0
  41. package/packages/storefront/dist/client/_astro/Prices.8e5cead5.js +1 -0
  42. package/packages/storefront/dist/client/_astro/Prices.vue_vue_type_script_setup_true_lang.b8cbeb54.js +1 -0
  43. package/packages/storefront/dist/client/_astro/ProductCard.6d8b6d86.js +1 -0
  44. package/packages/storefront/dist/client/_astro/StickyHeader.7b0f3963.js +1 -0
  45. package/packages/storefront/dist/client/{assets/_...slug_.b701cbb1.css → _astro/_...slug_.97285eba.css} +1 -1
  46. package/packages/storefront/dist/client/_astro/client.3e777d4c.js +1 -0
  47. package/packages/storefront/dist/client/_astro/ecom-utils.92f137f6.js +1 -0
  48. package/packages/storefront/dist/client/_astro/hoisted.6edd7364.js +1 -0
  49. package/packages/storefront/dist/client/{assets → _astro}/index.90df622b.css +0 -0
  50. package/packages/storefront/dist/client/_astro/modules-info.dde776b4.js +1 -0
  51. package/packages/storefront/dist/client/_astro/runtime-core.esm-bundler.7cf33881.js +1 -0
  52. package/packages/storefront/dist/client/_astro/runtime-dom.esm-bundler.1a4c7407.js +1 -0
  53. package/packages/storefront/dist/client/{assets → _astro}/server.4d9646d8.css +0 -0
  54. package/packages/storefront/dist/client/{chunks/session-utm.ceebe967.js → _astro/session-utm.72684b84.js} +0 -0
  55. package/packages/storefront/dist/client/{chunks/workbox-window.prod.es5.10f2e5ac.js → _astro/workbox-window.prod.es5.295a6886.js} +0 -0
  56. package/packages/storefront/dist/client/fallback/index.html +73 -0
  57. package/packages/storefront/dist/client/sw.js +1 -1
  58. package/packages/storefront/dist/server/chunks/astro.89bd9221.mjs +3378 -0
  59. package/packages/storefront/dist/server/chunks/pages/all.c27193d6.mjs +2195 -0
  60. package/packages/storefront/dist/server/chunks/prerender.89f63027.mjs +2 -0
  61. package/packages/storefront/dist/server/entry.mjs +517 -6083
  62. package/packages/storefront/package.json +7 -7
  63. package/packages/storefront/src/lib/components/Prices.vue +24 -24
  64. package/packages/storefront/src/lib/components/StickyHeader.vue +17 -4
  65. package/packages/storefront/src/lib/layouts/PagesHeader.astro +1 -1
  66. package/packages/storefront/src/lib/ssr/Picture.astro +7 -2
  67. package/packages/types/package.json +1 -1
  68. package/packages/storefront/dist/client/PitchBar.5ae15bda.js +0 -1
  69. package/packages/storefront/dist/client/Prices.248d1aae.js +0 -1
  70. package/packages/storefront/dist/client/ProductCard.4848304c.js +0 -1
  71. package/packages/storefront/dist/client/chunks/Prices.vue_vue_type_script_setup_true_lang.2d01aaa2.js +0 -1
  72. package/packages/storefront/dist/client/chunks/ecom-utils.cd6787a7.js +0 -1
  73. package/packages/storefront/dist/client/chunks/modules-info.fcab5bba.js +0 -1
  74. package/packages/storefront/dist/client/chunks/runtime-dom.esm-bundler.923790dc.js +0 -1
  75. package/packages/storefront/dist/client/client.2356f675.js +0 -1
  76. package/packages/storefront/dist/client/hoisted.11b849a7.js +0 -1
@@ -0,0 +1,3378 @@
1
+ import { compile } from 'path-to-regexp';
2
+ import 'fs';
3
+ import { TLSSocket } from 'tls';
4
+ import mime from 'mime';
5
+ import { serialize, parse } from 'cookie';
6
+ import { yellow, dim, bold, cyan, red, reset } from 'kleur/colors';
7
+ import 'string-width';
8
+ import slashify from 'slash';
9
+ import { escape } from 'html-escaper';
10
+
11
+ function getRouteGenerator(segments, addTrailingSlash) {
12
+ const template = segments.map((segment) => {
13
+ return "/" + segment.map((part) => {
14
+ if (part.spread) {
15
+ return `:${part.content.slice(3)}(.*)?`;
16
+ } else if (part.dynamic) {
17
+ return `:${part.content}`;
18
+ } else {
19
+ return part.content.normalize().replace(/\?/g, "%3F").replace(/#/g, "%23").replace(/%5B/g, "[").replace(/%5D/g, "]").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
20
+ }
21
+ }).join("");
22
+ }).join("");
23
+ let trailing = "";
24
+ if (addTrailingSlash === "always" && segments.length) {
25
+ trailing = "/";
26
+ }
27
+ const toPath = compile(template + trailing);
28
+ return toPath;
29
+ }
30
+
31
+ function deserializeRouteData(rawRouteData) {
32
+ return {
33
+ route: rawRouteData.route,
34
+ type: rawRouteData.type,
35
+ pattern: new RegExp(rawRouteData.pattern),
36
+ params: rawRouteData.params,
37
+ component: rawRouteData.component,
38
+ generate: getRouteGenerator(rawRouteData.segments, rawRouteData._meta.trailingSlash),
39
+ pathname: rawRouteData.pathname || void 0,
40
+ segments: rawRouteData.segments
41
+ };
42
+ }
43
+
44
+ function deserializeManifest(serializedManifest) {
45
+ const routes = [];
46
+ for (const serializedRoute of serializedManifest.routes) {
47
+ routes.push({
48
+ ...serializedRoute,
49
+ routeData: deserializeRouteData(serializedRoute.routeData)
50
+ });
51
+ const route = serializedRoute;
52
+ route.routeData = deserializeRouteData(serializedRoute.routeData);
53
+ }
54
+ const assets = new Set(serializedManifest.assets);
55
+ return {
56
+ ...serializedManifest,
57
+ assets,
58
+ routes
59
+ };
60
+ }
61
+
62
+ var __accessCheck$3 = (obj, member, msg) => {
63
+ if (!member.has(obj))
64
+ throw TypeError("Cannot " + msg);
65
+ };
66
+ var __privateGet$3 = (obj, member, getter) => {
67
+ __accessCheck$3(obj, member, "read from private field");
68
+ return getter ? getter.call(obj) : member.get(obj);
69
+ };
70
+ var __privateAdd$3 = (obj, member, value) => {
71
+ if (member.has(obj))
72
+ throw TypeError("Cannot add the same private member more than once");
73
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
74
+ };
75
+ var __privateSet$3 = (obj, member, value, setter) => {
76
+ __accessCheck$3(obj, member, "write to private field");
77
+ setter ? setter.call(obj, value) : member.set(obj, value);
78
+ return value;
79
+ };
80
+ var __privateMethod$1 = (obj, member, method) => {
81
+ __accessCheck$3(obj, member, "access private method");
82
+ return method;
83
+ };
84
+ var _request, _requestValues, _outgoing, _ensureParsed, ensureParsed_fn, _ensureOutgoingMap, ensureOutgoingMap_fn, _parse, parse_fn;
85
+ const DELETED_EXPIRATION = new Date(0);
86
+ const DELETED_VALUE = "deleted";
87
+ class AstroCookie {
88
+ constructor(value) {
89
+ this.value = value;
90
+ }
91
+ json() {
92
+ if (this.value === void 0) {
93
+ throw new Error(`Cannot convert undefined to an object.`);
94
+ }
95
+ return JSON.parse(this.value);
96
+ }
97
+ number() {
98
+ return Number(this.value);
99
+ }
100
+ boolean() {
101
+ if (this.value === "false")
102
+ return false;
103
+ if (this.value === "0")
104
+ return false;
105
+ return Boolean(this.value);
106
+ }
107
+ }
108
+ class AstroCookies {
109
+ constructor(request) {
110
+ __privateAdd$3(this, _ensureParsed);
111
+ __privateAdd$3(this, _ensureOutgoingMap);
112
+ __privateAdd$3(this, _parse);
113
+ __privateAdd$3(this, _request, void 0);
114
+ __privateAdd$3(this, _requestValues, void 0);
115
+ __privateAdd$3(this, _outgoing, void 0);
116
+ __privateSet$3(this, _request, request);
117
+ __privateSet$3(this, _requestValues, null);
118
+ __privateSet$3(this, _outgoing, null);
119
+ }
120
+ delete(key, options) {
121
+ const serializeOptions = {
122
+ expires: DELETED_EXPIRATION
123
+ };
124
+ if (options == null ? void 0 : options.domain) {
125
+ serializeOptions.domain = options.domain;
126
+ }
127
+ if (options == null ? void 0 : options.path) {
128
+ serializeOptions.path = options.path;
129
+ }
130
+ __privateMethod$1(this, _ensureOutgoingMap, ensureOutgoingMap_fn).call(this).set(key, [
131
+ DELETED_VALUE,
132
+ serialize(key, DELETED_VALUE, serializeOptions),
133
+ false
134
+ ]);
135
+ }
136
+ get(key) {
137
+ if (__privateGet$3(this, _outgoing) !== null && __privateGet$3(this, _outgoing).has(key)) {
138
+ let [serializedValue, , isSetValue] = __privateGet$3(this, _outgoing).get(key);
139
+ if (isSetValue) {
140
+ return new AstroCookie(serializedValue);
141
+ } else {
142
+ return new AstroCookie(void 0);
143
+ }
144
+ }
145
+ const values = __privateMethod$1(this, _ensureParsed, ensureParsed_fn).call(this);
146
+ const value = values[key];
147
+ return new AstroCookie(value);
148
+ }
149
+ has(key) {
150
+ if (__privateGet$3(this, _outgoing) !== null && __privateGet$3(this, _outgoing).has(key)) {
151
+ let [, , isSetValue] = __privateGet$3(this, _outgoing).get(key);
152
+ return isSetValue;
153
+ }
154
+ const values = __privateMethod$1(this, _ensureParsed, ensureParsed_fn).call(this);
155
+ return !!values[key];
156
+ }
157
+ set(key, value, options) {
158
+ let serializedValue;
159
+ if (typeof value === "string") {
160
+ serializedValue = value;
161
+ } else {
162
+ let toStringValue = value.toString();
163
+ if (toStringValue === Object.prototype.toString.call(value)) {
164
+ serializedValue = JSON.stringify(value);
165
+ } else {
166
+ serializedValue = toStringValue;
167
+ }
168
+ }
169
+ const serializeOptions = {};
170
+ if (options) {
171
+ Object.assign(serializeOptions, options);
172
+ }
173
+ __privateMethod$1(this, _ensureOutgoingMap, ensureOutgoingMap_fn).call(this).set(key, [
174
+ serializedValue,
175
+ serialize(key, serializedValue, serializeOptions),
176
+ true
177
+ ]);
178
+ }
179
+ *headers() {
180
+ if (__privateGet$3(this, _outgoing) == null)
181
+ return;
182
+ for (const [, value] of __privateGet$3(this, _outgoing)) {
183
+ yield value[1];
184
+ }
185
+ }
186
+ }
187
+ _request = new WeakMap();
188
+ _requestValues = new WeakMap();
189
+ _outgoing = new WeakMap();
190
+ _ensureParsed = new WeakSet();
191
+ ensureParsed_fn = function() {
192
+ if (!__privateGet$3(this, _requestValues)) {
193
+ __privateMethod$1(this, _parse, parse_fn).call(this);
194
+ }
195
+ if (!__privateGet$3(this, _requestValues)) {
196
+ __privateSet$3(this, _requestValues, {});
197
+ }
198
+ return __privateGet$3(this, _requestValues);
199
+ };
200
+ _ensureOutgoingMap = new WeakSet();
201
+ ensureOutgoingMap_fn = function() {
202
+ if (!__privateGet$3(this, _outgoing)) {
203
+ __privateSet$3(this, _outgoing, /* @__PURE__ */ new Map());
204
+ }
205
+ return __privateGet$3(this, _outgoing);
206
+ };
207
+ _parse = new WeakSet();
208
+ parse_fn = function() {
209
+ const raw = __privateGet$3(this, _request).headers.get("cookie");
210
+ if (!raw) {
211
+ return;
212
+ }
213
+ __privateSet$3(this, _requestValues, parse(raw));
214
+ };
215
+
216
+ const astroCookiesSymbol = Symbol.for("astro.cookies");
217
+ function attachToResponse(response, cookies) {
218
+ Reflect.set(response, astroCookiesSymbol, cookies);
219
+ }
220
+ function getFromResponse(response) {
221
+ let cookies = Reflect.get(response, astroCookiesSymbol);
222
+ if (cookies != null) {
223
+ return cookies;
224
+ } else {
225
+ return void 0;
226
+ }
227
+ }
228
+ function* getSetCookiesFromResponse(response) {
229
+ const cookies = getFromResponse(response);
230
+ if (!cookies) {
231
+ return;
232
+ }
233
+ for (const headerValue of cookies.headers()) {
234
+ yield headerValue;
235
+ }
236
+ }
237
+
238
+ function baseCreateComponent(cb, moduleId) {
239
+ cb.isAstroComponentFactory = true;
240
+ cb.moduleId = moduleId;
241
+ return cb;
242
+ }
243
+ function createComponentWithOptions(opts) {
244
+ const cb = baseCreateComponent(opts.factory, opts.moduleId);
245
+ cb.propagation = opts.propagation;
246
+ return cb;
247
+ }
248
+ function createComponent(arg1, moduleId) {
249
+ if (typeof arg1 === "function") {
250
+ return baseCreateComponent(arg1, moduleId);
251
+ } else {
252
+ return createComponentWithOptions(arg1);
253
+ }
254
+ }
255
+
256
+ const ASTRO_VERSION = "2.0.2";
257
+
258
+ function createAstroGlobFn() {
259
+ const globHandler = (importMetaGlobResult, globValue) => {
260
+ let allEntries = [...Object.values(importMetaGlobResult)];
261
+ if (allEntries.length === 0) {
262
+ throw new Error(`Astro.glob(${JSON.stringify(globValue())}) - no matches found.`);
263
+ }
264
+ return Promise.all(allEntries.map((fn) => fn()));
265
+ };
266
+ return globHandler;
267
+ }
268
+ function createAstro(site) {
269
+ return {
270
+ site: site ? new URL(site) : void 0,
271
+ generator: `Astro v${ASTRO_VERSION}`,
272
+ glob: createAstroGlobFn()
273
+ };
274
+ }
275
+
276
+ function getHandlerFromModule(mod, method) {
277
+ if (mod[method]) {
278
+ return mod[method];
279
+ }
280
+ if (method === "delete" && mod["del"]) {
281
+ return mod["del"];
282
+ }
283
+ if (mod["all"]) {
284
+ return mod["all"];
285
+ }
286
+ return void 0;
287
+ }
288
+ async function renderEndpoint(mod, context, ssr) {
289
+ var _a;
290
+ const { request, params } = context;
291
+ const chosenMethod = (_a = request.method) == null ? void 0 : _a.toLowerCase();
292
+ const handler = getHandlerFromModule(mod, chosenMethod);
293
+ if (!ssr && ssr === false && chosenMethod && chosenMethod !== "get") {
294
+ console.warn(`
295
+ ${chosenMethod} requests are not available when building a static site. Update your config to output: 'server' to handle ${chosenMethod} requests.`);
296
+ }
297
+ if (!handler || typeof handler !== "function") {
298
+ let response = new Response(null, {
299
+ status: 404,
300
+ headers: {
301
+ "X-Astro-Response": "Not-Found"
302
+ }
303
+ });
304
+ return response;
305
+ }
306
+ if (handler.length > 1) {
307
+ console.warn(`
308
+ API routes with 2 arguments have been deprecated. Instead they take a single argument in the form of:
309
+
310
+ export function get({ params, request }) {
311
+ //...
312
+ }
313
+
314
+ Update your code to remove this warning.`);
315
+ }
316
+ const proxy = new Proxy(context, {
317
+ get(target, prop) {
318
+ if (prop in target) {
319
+ return Reflect.get(target, prop);
320
+ } else if (prop in params) {
321
+ console.warn(`
322
+ API routes no longer pass params as the first argument. Instead an object containing a params property is provided in the form of:
323
+
324
+ export function get({ params }) {
325
+ // ...
326
+ }
327
+
328
+ Update your code to remove this warning.`);
329
+ return Reflect.get(params, prop);
330
+ } else {
331
+ return void 0;
332
+ }
333
+ }
334
+ });
335
+ return handler.call(mod, proxy, request);
336
+ }
337
+
338
+ function serializeListValue(value) {
339
+ const hash = {};
340
+ push(value);
341
+ return Object.keys(hash).join(" ");
342
+ function push(item) {
343
+ if (item && typeof item.forEach === "function")
344
+ item.forEach(push);
345
+ else if (item === Object(item))
346
+ Object.keys(item).forEach((name) => {
347
+ if (item[name])
348
+ push(name);
349
+ });
350
+ else {
351
+ item = item === false || item == null ? "" : String(item).trim();
352
+ if (item) {
353
+ item.split(/\s+/).forEach((name) => {
354
+ hash[name] = true;
355
+ });
356
+ }
357
+ }
358
+ }
359
+ }
360
+ function isPromise(value) {
361
+ return !!value && typeof value === "object" && typeof value.then === "function";
362
+ }
363
+ async function* streamAsyncIterator(stream) {
364
+ const reader = stream.getReader();
365
+ try {
366
+ while (true) {
367
+ const { done, value } = await reader.read();
368
+ if (done)
369
+ return;
370
+ yield value;
371
+ }
372
+ } finally {
373
+ reader.releaseLock();
374
+ }
375
+ }
376
+
377
+ const escapeHTML = escape;
378
+ class HTMLBytes extends Uint8Array {
379
+ }
380
+ Object.defineProperty(HTMLBytes.prototype, Symbol.toStringTag, {
381
+ get() {
382
+ return "HTMLBytes";
383
+ }
384
+ });
385
+ class HTMLString extends String {
386
+ get [Symbol.toStringTag]() {
387
+ return "HTMLString";
388
+ }
389
+ }
390
+ const markHTMLString = (value) => {
391
+ if (value instanceof HTMLString) {
392
+ return value;
393
+ }
394
+ if (typeof value === "string") {
395
+ return new HTMLString(value);
396
+ }
397
+ return value;
398
+ };
399
+ function isHTMLString(value) {
400
+ return Object.prototype.toString.call(value) === "[object HTMLString]";
401
+ }
402
+ function markHTMLBytes(bytes) {
403
+ return new HTMLBytes(bytes);
404
+ }
405
+ function hasGetReader(obj) {
406
+ return typeof obj.getReader === "function";
407
+ }
408
+ async function* unescapeChunksAsync(iterable) {
409
+ if (hasGetReader(iterable)) {
410
+ for await (const chunk of streamAsyncIterator(iterable)) {
411
+ yield unescapeHTML(chunk);
412
+ }
413
+ } else {
414
+ for await (const chunk of iterable) {
415
+ yield unescapeHTML(chunk);
416
+ }
417
+ }
418
+ }
419
+ function* unescapeChunks(iterable) {
420
+ for (const chunk of iterable) {
421
+ yield unescapeHTML(chunk);
422
+ }
423
+ }
424
+ function unescapeHTML(str) {
425
+ if (!!str && typeof str === "object") {
426
+ if (str instanceof Uint8Array) {
427
+ return markHTMLBytes(str);
428
+ } else if (str instanceof Response && str.body) {
429
+ const body = str.body;
430
+ return unescapeChunksAsync(body);
431
+ } else if (typeof str.then === "function") {
432
+ return Promise.resolve(str).then((value) => {
433
+ return unescapeHTML(value);
434
+ });
435
+ } else if (Symbol.iterator in str) {
436
+ return unescapeChunks(str);
437
+ } else if (Symbol.asyncIterator in str || hasGetReader(str)) {
438
+ return unescapeChunksAsync(str);
439
+ }
440
+ }
441
+ return markHTMLString(str);
442
+ }
443
+
444
+ const AstroJSX = "astro:jsx";
445
+ const Empty = Symbol("empty");
446
+ const toSlotName = (slotAttr) => slotAttr;
447
+ function isVNode(vnode) {
448
+ return vnode && typeof vnode === "object" && vnode[AstroJSX];
449
+ }
450
+ function transformSlots(vnode) {
451
+ if (typeof vnode.type === "string")
452
+ return vnode;
453
+ const slots = {};
454
+ if (isVNode(vnode.props.children)) {
455
+ const child = vnode.props.children;
456
+ if (!isVNode(child))
457
+ return;
458
+ if (!("slot" in child.props))
459
+ return;
460
+ const name = toSlotName(child.props.slot);
461
+ slots[name] = [child];
462
+ slots[name]["$$slot"] = true;
463
+ delete child.props.slot;
464
+ delete vnode.props.children;
465
+ }
466
+ if (Array.isArray(vnode.props.children)) {
467
+ vnode.props.children = vnode.props.children.map((child) => {
468
+ if (!isVNode(child))
469
+ return child;
470
+ if (!("slot" in child.props))
471
+ return child;
472
+ const name = toSlotName(child.props.slot);
473
+ if (Array.isArray(slots[name])) {
474
+ slots[name].push(child);
475
+ } else {
476
+ slots[name] = [child];
477
+ slots[name]["$$slot"] = true;
478
+ }
479
+ delete child.props.slot;
480
+ return Empty;
481
+ }).filter((v) => v !== Empty);
482
+ }
483
+ Object.assign(vnode.props, slots);
484
+ }
485
+ function markRawChildren(child) {
486
+ if (typeof child === "string")
487
+ return markHTMLString(child);
488
+ if (Array.isArray(child))
489
+ return child.map((c) => markRawChildren(c));
490
+ return child;
491
+ }
492
+ function transformSetDirectives(vnode) {
493
+ if (!("set:html" in vnode.props || "set:text" in vnode.props))
494
+ return;
495
+ if ("set:html" in vnode.props) {
496
+ const children = markRawChildren(vnode.props["set:html"]);
497
+ delete vnode.props["set:html"];
498
+ Object.assign(vnode.props, { children });
499
+ return;
500
+ }
501
+ if ("set:text" in vnode.props) {
502
+ const children = vnode.props["set:text"];
503
+ delete vnode.props["set:text"];
504
+ Object.assign(vnode.props, { children });
505
+ return;
506
+ }
507
+ }
508
+ function createVNode(type, props) {
509
+ const vnode = {
510
+ [Renderer]: "astro:jsx",
511
+ [AstroJSX]: true,
512
+ type,
513
+ props: props ?? {}
514
+ };
515
+ transformSetDirectives(vnode);
516
+ transformSlots(vnode);
517
+ return vnode;
518
+ }
519
+
520
+ var idle_prebuilt_default = `(self.Astro=self.Astro||{}).idle=t=>{const e=async()=>{await(await t())()};"requestIdleCallback"in window?window.requestIdleCallback(e):setTimeout(e,200)},window.dispatchEvent(new Event("astro:idle"));`;
521
+
522
+ var load_prebuilt_default = `(self.Astro=self.Astro||{}).load=a=>{(async()=>await(await a())())()},window.dispatchEvent(new Event("astro:load"));`;
523
+
524
+ var media_prebuilt_default = `(self.Astro=self.Astro||{}).media=(s,a)=>{const t=async()=>{await(await s())()};if(a.value){const e=matchMedia(a.value);e.matches?t():e.addEventListener("change",t,{once:!0})}},window.dispatchEvent(new Event("astro:media"));`;
525
+
526
+ var only_prebuilt_default = `(self.Astro=self.Astro||{}).only=t=>{(async()=>await(await t())())()},window.dispatchEvent(new Event("astro:only"));`;
527
+
528
+ var visible_prebuilt_default = `(self.Astro=self.Astro||{}).visible=(s,c,n)=>{const r=async()=>{await(await s())()};let i=new IntersectionObserver(e=>{for(const t of e)if(!!t.isIntersecting){i.disconnect(),r();break}});for(let e=0;e<n.children.length;e++){const t=n.children[e];i.observe(t)}},window.dispatchEvent(new Event("astro:visible"));`;
529
+
530
+ var astro_island_prebuilt_default = `var l;{const c={0:t=>t,1:t=>JSON.parse(t,o),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(JSON.parse(t,o)),5:t=>new Set(JSON.parse(t,o)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(JSON.parse(t)),9:t=>new Uint16Array(JSON.parse(t)),10:t=>new Uint32Array(JSON.parse(t))},o=(t,s)=>{if(t===""||!Array.isArray(s))return s;const[e,n]=s;return e in c?c[e](n):void 0};customElements.get("astro-island")||customElements.define("astro-island",(l=class extends HTMLElement{constructor(){super(...arguments);this.hydrate=()=>{if(!this.hydrator||this.parentElement&&this.parentElement.closest("astro-island[ssr]"))return;const s=this.querySelectorAll("astro-slot"),e={},n=this.querySelectorAll("template[data-astro-template]");for(const r of n){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(const r of s){const i=r.closest(this.tagName);!i||!i.isSameNode(this)||(e[r.getAttribute("name")||"default"]=r.innerHTML)}const a=this.hasAttribute("props")?JSON.parse(this.getAttribute("props"),o):{};this.hydrator(this)(this.Component,a,e,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),window.removeEventListener("astro:hydrate",this.hydrate),window.dispatchEvent(new CustomEvent("astro:hydrate"))}}connectedCallback(){!this.hasAttribute("await-children")||this.firstChild?this.childrenConnectedCallback():new MutationObserver((s,e)=>{e.disconnect(),this.childrenConnectedCallback()}).observe(this,{childList:!0})}async childrenConnectedCallback(){window.addEventListener("astro:hydrate",this.hydrate);let s=this.getAttribute("before-hydration-url");s&&await import(s),this.start()}start(){const s=JSON.parse(this.getAttribute("opts")),e=this.getAttribute("client");if(Astro[e]===void 0){window.addEventListener(\`astro:\${e}\`,()=>this.start(),{once:!0});return}Astro[e](async()=>{const n=this.getAttribute("renderer-url"),[a,{default:r}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),i=this.getAttribute("component-export")||"default";if(!i.includes("."))this.Component=a[i];else{this.Component=a;for(const d of i.split("."))this.Component=this.Component[d]}return this.hydrator=r,this.hydrate},s,this)}attributeChangedCallback(){this.hydrator&&this.hydrate()}},l.observedAttributes=["props"],l))}`;
531
+
532
+ function determineIfNeedsHydrationScript(result) {
533
+ if (result._metadata.hasHydrationScript) {
534
+ return false;
535
+ }
536
+ return result._metadata.hasHydrationScript = true;
537
+ }
538
+ const hydrationScripts = {
539
+ idle: idle_prebuilt_default,
540
+ load: load_prebuilt_default,
541
+ only: only_prebuilt_default,
542
+ media: media_prebuilt_default,
543
+ visible: visible_prebuilt_default
544
+ };
545
+ function determinesIfNeedsDirectiveScript(result, directive) {
546
+ if (result._metadata.hasDirectives.has(directive)) {
547
+ return false;
548
+ }
549
+ result._metadata.hasDirectives.add(directive);
550
+ return true;
551
+ }
552
+ function getDirectiveScriptText(directive) {
553
+ if (!(directive in hydrationScripts)) {
554
+ throw new Error(`Unknown directive: ${directive}`);
555
+ }
556
+ const directiveScriptText = hydrationScripts[directive];
557
+ return directiveScriptText;
558
+ }
559
+ function getPrescripts(type, directive) {
560
+ switch (type) {
561
+ case "both":
562
+ return `<style>astro-island,astro-slot{display:contents}</style><script>${getDirectiveScriptText(directive) + astro_island_prebuilt_default}<\/script>`;
563
+ case "directive":
564
+ return `<script>${getDirectiveScriptText(directive)}<\/script>`;
565
+ }
566
+ return "";
567
+ }
568
+
569
+ const headAndContentSym = Symbol.for("astro.headAndContent");
570
+ function isHeadAndContent(obj) {
571
+ return typeof obj === "object" && !!obj[headAndContentSym];
572
+ }
573
+
574
+ var _a$1;
575
+ const renderTemplateResultSym = Symbol.for("astro.renderTemplateResult");
576
+ class RenderTemplateResult {
577
+ constructor(htmlParts, expressions) {
578
+ this[_a$1] = true;
579
+ this.htmlParts = htmlParts;
580
+ this.error = void 0;
581
+ this.expressions = expressions.map((expression) => {
582
+ if (isPromise(expression)) {
583
+ return Promise.resolve(expression).catch((err) => {
584
+ if (!this.error) {
585
+ this.error = err;
586
+ throw err;
587
+ }
588
+ });
589
+ }
590
+ return expression;
591
+ });
592
+ }
593
+ async *[(_a$1 = renderTemplateResultSym, Symbol.asyncIterator)]() {
594
+ const { htmlParts, expressions } = this;
595
+ for (let i = 0; i < htmlParts.length; i++) {
596
+ const html = htmlParts[i];
597
+ const expression = expressions[i];
598
+ yield markHTMLString(html);
599
+ yield* renderChild(expression);
600
+ }
601
+ }
602
+ }
603
+ function isRenderTemplateResult(obj) {
604
+ return typeof obj === "object" && !!obj[renderTemplateResultSym];
605
+ }
606
+ async function* renderAstroTemplateResult(component) {
607
+ for await (const value of component) {
608
+ if (value || value === 0) {
609
+ for await (const chunk of renderChild(value)) {
610
+ switch (chunk.type) {
611
+ case "directive": {
612
+ yield chunk;
613
+ break;
614
+ }
615
+ default: {
616
+ yield markHTMLString(chunk);
617
+ break;
618
+ }
619
+ }
620
+ }
621
+ }
622
+ }
623
+ }
624
+ function renderTemplate(htmlParts, ...expressions) {
625
+ return new RenderTemplateResult(htmlParts, expressions);
626
+ }
627
+
628
+ function isAstroComponentFactory(obj) {
629
+ return obj == null ? false : obj.isAstroComponentFactory === true;
630
+ }
631
+ async function renderToString(result, componentFactory, props, children) {
632
+ const factoryResult = await componentFactory(result, props, children);
633
+ if (factoryResult instanceof Response) {
634
+ const response = factoryResult;
635
+ throw response;
636
+ }
637
+ let parts = new HTMLParts();
638
+ const templateResult = isHeadAndContent(factoryResult) ? factoryResult.content : factoryResult;
639
+ for await (const chunk of renderAstroTemplateResult(templateResult)) {
640
+ parts.append(chunk, result);
641
+ }
642
+ return parts.toString();
643
+ }
644
+ function isAPropagatingComponent(result, factory) {
645
+ let hint = factory.propagation || "none";
646
+ if (factory.moduleId && result.propagation.has(factory.moduleId) && hint === "none") {
647
+ hint = result.propagation.get(factory.moduleId);
648
+ }
649
+ return hint === "in-tree" || hint === "self";
650
+ }
651
+
652
+ const defineErrors = (errs) => errs;
653
+ const AstroErrorData = defineErrors({
654
+ UnknownCompilerError: {
655
+ title: "Unknown compiler error.",
656
+ code: 1e3,
657
+ hint: "This is almost always a problem with the Astro compiler, not your code. Please open an issue at https://astro.build/issues/compiler."
658
+ },
659
+ StaticRedirectNotAvailable: {
660
+ title: "`Astro.redirect` is not available in static mode.",
661
+ code: 3001,
662
+ message: "Redirects are only available when using `output: 'server'`. Update your Astro config if you need SSR features.",
663
+ hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
664
+ },
665
+ ClientAddressNotAvailable: {
666
+ title: "`Astro.clientAddress` is not available in current adapter.",
667
+ code: 3002,
668
+ message: (adapterName) => `\`Astro.clientAddress\` is not available in the \`${adapterName}\` adapter. File an issue with the adapter to add support.`
669
+ },
670
+ StaticClientAddressNotAvailable: {
671
+ title: "`Astro.clientAddress` is not available in static mode.",
672
+ code: 3003,
673
+ message: "`Astro.clientAddress` is only available when using `output: 'server'`. Update your Astro config if you need SSR features.",
674
+ hint: "See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."
675
+ },
676
+ NoMatchingStaticPathFound: {
677
+ title: "No static path found for requested path.",
678
+ code: 3004,
679
+ message: (pathName) => `A \`getStaticPaths()\` route pattern was matched, but no matching static path was found for requested path \`${pathName}\`.`,
680
+ hint: (possibleRoutes) => `Possible dynamic routes being matched: ${possibleRoutes.join(", ")}.`
681
+ },
682
+ OnlyResponseCanBeReturned: {
683
+ title: "Invalid type returned by Astro page.",
684
+ code: 3005,
685
+ message: (route, returnedValue) => `Route \`${route ? route : ""}\` returned a \`${returnedValue}\`. Only a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned from Astro files.`,
686
+ hint: "See https://docs.astro.build/en/guides/server-side-rendering/#response for more information."
687
+ },
688
+ MissingMediaQueryDirective: {
689
+ title: "Missing value for `client:media` directive.",
690
+ code: 3006,
691
+ message: 'Media query not provided for `client:media` directive. A media query similar to `client:media="(max-width: 600px)"` must be provided'
692
+ },
693
+ NoMatchingRenderer: {
694
+ title: "No matching renderer found.",
695
+ code: 3007,
696
+ message: (componentName, componentExtension, plural, validRenderersCount) => `Unable to render \`${componentName}\`.
697
+
698
+ ${validRenderersCount > 0 ? `There ${plural ? "are." : "is."} ${validRenderersCount} renderer${plural ? "s." : ""} configured in your \`astro.config.mjs\` file,
699
+ but ${plural ? "none were." : "it was not."} able to server-side render \`${componentName}\`.` : `No valid renderer was found ${componentExtension ? `for the \`.${componentExtension}\` file extension.` : `for this file extension.`}`}`,
700
+ hint: (probableRenderers) => `Did you mean to enable the ${probableRenderers} integration?
701
+
702
+ See https://docs.astro.build/en/core-concepts/framework-components/ for more information on how to install and configure integrations.`
703
+ },
704
+ NoClientEntrypoint: {
705
+ title: "No client entrypoint specified in renderer.",
706
+ code: 3008,
707
+ message: (componentName, clientDirective, rendererName) => `\`${componentName}\` component has a \`client:${clientDirective}\` directive, but no client entrypoint was provided by \`${rendererName}\`.`,
708
+ hint: "See https://docs.astro.build/en/reference/integrations-reference/#addrenderer-option for more information on how to configure your renderer."
709
+ },
710
+ NoClientOnlyHint: {
711
+ title: "Missing hint on client:only directive.",
712
+ code: 3009,
713
+ message: (componentName) => `Unable to render \`${componentName}\`. When using the \`client:only\` hydration strategy, Astro needs a hint to use the correct renderer.`,
714
+ hint: (probableRenderers) => `Did you mean to pass \`client:only="${probableRenderers}"\`? See https://docs.astro.build/en/reference/directives-reference/#clientonly for more information on client:only`
715
+ },
716
+ InvalidGetStaticPathParam: {
717
+ title: "Invalid value returned by a `getStaticPaths` path.",
718
+ code: 3010,
719
+ message: (paramType) => `Invalid params given to \`getStaticPaths\` path. Expected an \`object\`, got \`${paramType}\``,
720
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
721
+ },
722
+ InvalidGetStaticPathsReturn: {
723
+ title: "Invalid value returned by getStaticPaths.",
724
+ code: 3011,
725
+ message: (returnType) => `Invalid type returned by \`getStaticPaths\`. Expected an \`array\`, got \`${returnType}\``,
726
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
727
+ },
728
+ GetStaticPathsRemovedRSSHelper: {
729
+ title: "getStaticPaths RSS helper is not available anymore.",
730
+ code: 3012,
731
+ message: "The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead.",
732
+ hint: "See https://docs.astro.build/en/guides/rss/ for more information."
733
+ },
734
+ GetStaticPathsExpectedParams: {
735
+ title: "Missing params property on `getStaticPaths` route.",
736
+ code: 3013,
737
+ message: "Missing or empty required `params` property on `getStaticPaths` route.",
738
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
739
+ },
740
+ GetStaticPathsInvalidRouteParam: {
741
+ title: "Invalid value for `getStaticPaths` route parameter.",
742
+ code: 3014,
743
+ message: (key, value, valueType) => `Invalid getStaticPaths route parameter for \`${key}\`. Expected undefined, a string or a number, received \`${valueType}\` (\`${value}\`)`,
744
+ hint: "See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."
745
+ },
746
+ GetStaticPathsRequired: {
747
+ title: "`getStaticPaths()` function required for dynamic routes.",
748
+ code: 3015,
749
+ message: "`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.",
750
+ hint: `See https://docs.astro.build/en/core-concepts/routing/#dynamic-routes for more information on dynamic routes.
751
+
752
+ Alternatively, set \`output: "server"\` in your Astro config file to switch to a non-static server build. This error can also occur if using \`export const prerender = true;\`.
753
+ See https://docs.astro.build/en/guides/server-side-rendering/ for more information on non-static rendering.`
754
+ },
755
+ ReservedSlotName: {
756
+ title: "Invalid slot name.",
757
+ code: 3016,
758
+ message: (slotName) => `Unable to create a slot named \`${slotName}\`. \`${slotName}\` is a reserved slot name. Please update the name of this slot.`
759
+ },
760
+ NoAdapterInstalled: {
761
+ title: "Cannot use Server-side Rendering without an adapter.",
762
+ code: 3017,
763
+ message: `Cannot use \`output: 'server'\` without an adapter. Please install and configure the appropriate server adapter for your final deployment.`,
764
+ hint: "See https://docs.astro.build/en/guides/server-side-rendering/ for more information."
765
+ },
766
+ NoMatchingImport: {
767
+ title: "No import found for component.",
768
+ code: 3018,
769
+ message: (componentName) => `Could not render \`${componentName}\`. No matching import has been found for \`${componentName}\`.`,
770
+ hint: "Please make sure the component is properly imported."
771
+ },
772
+ InvalidPrerenderExport: {
773
+ title: "Invalid prerender export.",
774
+ code: 3019,
775
+ message: (prefix, suffix) => {
776
+ let msg = `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`;
777
+ if (prefix !== "const")
778
+ msg += `
779
+ Expected \`const\` declaration but got \`${prefix}\`.`;
780
+ if (suffix !== "true")
781
+ msg += `
782
+ Expected \`true\` value but got \`${suffix}\`.`;
783
+ return msg;
784
+ },
785
+ hint: "Mutable values declared at runtime are not supported. Please make sure to use exactly `export const prerender = true`."
786
+ },
787
+ UnknownViteError: {
788
+ title: "Unknown Vite Error.",
789
+ code: 4e3
790
+ },
791
+ FailedToLoadModuleSSR: {
792
+ title: "Could not import file.",
793
+ code: 4001,
794
+ message: (importName) => `Could not import \`${importName}\`.`,
795
+ hint: "This is often caused by a typo in the import path. Please make sure the file exists."
796
+ },
797
+ InvalidGlob: {
798
+ title: "Invalid glob pattern.",
799
+ code: 4002,
800
+ message: (globPattern) => `Invalid glob pattern: \`${globPattern}\`. Glob patterns must start with './', '../' or '/'.`,
801
+ hint: "See https://docs.astro.build/en/guides/imports/#glob-patterns for more information on supported glob patterns."
802
+ },
803
+ UnknownCSSError: {
804
+ title: "Unknown CSS Error.",
805
+ code: 5e3
806
+ },
807
+ CSSSyntaxError: {
808
+ title: "CSS Syntax Error.",
809
+ code: 5001
810
+ },
811
+ UnknownMarkdownError: {
812
+ title: "Unknown Markdown Error.",
813
+ code: 6e3
814
+ },
815
+ MarkdownFrontmatterParseError: {
816
+ title: "Failed to parse Markdown frontmatter.",
817
+ code: 6001
818
+ },
819
+ InvalidFrontmatterInjectionError: {
820
+ title: "Invalid frontmatter injection.",
821
+ code: 6003,
822
+ message: 'A remark or rehype plugin attempted to inject invalid frontmatter. Ensure "astro.frontmatter" is set to a valid JSON object that is not `null` or `undefined`.',
823
+ hint: "See the frontmatter injection docs https://docs.astro.build/en/guides/markdown-content/#modifying-frontmatter-programmatically for more information."
824
+ },
825
+ MdxIntegrationMissingError: {
826
+ title: "MDX integration missing.",
827
+ code: 6004,
828
+ message: (file) => `Unable to render ${file}. Ensure that the \`@astrojs/mdx\` integration is installed.`,
829
+ hint: "See the MDX integration docs for installation and usage instructions: https://docs.astro.build/en/guides/integrations-guide/mdx/"
830
+ },
831
+ UnknownConfigError: {
832
+ title: "Unknown configuration error.",
833
+ code: 7e3
834
+ },
835
+ ConfigNotFound: {
836
+ title: "Specified configuration file not found.",
837
+ code: 7001,
838
+ message: (configFile) => `Unable to resolve \`--config "${configFile}"\`. Does the file exist?`
839
+ },
840
+ ConfigLegacyKey: {
841
+ title: "Legacy configuration detected.",
842
+ code: 7002,
843
+ message: (legacyConfigKey) => `Legacy configuration detected: \`${legacyConfigKey}\`.`,
844
+ hint: "Please update your configuration to the new format.\nSee https://astro.build/config for more information."
845
+ },
846
+ UnknownCLIError: {
847
+ title: "Unknown CLI Error.",
848
+ code: 8e3
849
+ },
850
+ GenerateContentTypesError: {
851
+ title: "Failed to generate content types.",
852
+ code: 8001,
853
+ message: "`astro sync` command failed to generate content collection types.",
854
+ hint: "Check your `src/content/config.*` file for typos."
855
+ },
856
+ UnknownContentCollectionError: {
857
+ title: "Unknown Content Collection Error.",
858
+ code: 9e3
859
+ },
860
+ InvalidContentEntryFrontmatterError: {
861
+ title: "Content entry frontmatter does not match schema.",
862
+ code: 9001,
863
+ message: (collection, entryId, error) => {
864
+ return [
865
+ `${String(collection)} \u2192 ${String(entryId)} frontmatter does not match collection schema.`,
866
+ ...error.errors.map((zodError) => zodError.message)
867
+ ].join("\n");
868
+ },
869
+ hint: "See https://docs.astro.build/en/guides/content-collections/ for more information on content schemas."
870
+ },
871
+ InvalidContentEntrySlugError: {
872
+ title: "Invalid content entry slug.",
873
+ code: 9002,
874
+ message: (collection, entryId) => {
875
+ return `${String(collection)} \u2192 ${String(
876
+ entryId
877
+ )} has an invalid slug. \`slug\` must be a string.`;
878
+ },
879
+ hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."
880
+ },
881
+ ContentSchemaContainsSlugError: {
882
+ title: "Content Schema should not contain `slug`.",
883
+ code: 9003,
884
+ message: (collection) => {
885
+ return `A content collection schema should not contain \`slug\` since it is reserved for slug generation. Remove this from your ${collection} collection schema.`;
886
+ },
887
+ hint: "See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."
888
+ },
889
+ UnknownError: {
890
+ title: "Unknown Error.",
891
+ code: 99999
892
+ }
893
+ });
894
+
895
+ function normalizeLF(code) {
896
+ return code.replace(/\r\n|\r(?!\n)|\n/g, "\n");
897
+ }
898
+ function getErrorDataByCode(code) {
899
+ const entry = Object.entries(AstroErrorData).find((data) => data[1].code === code);
900
+ if (entry) {
901
+ return {
902
+ name: entry[0],
903
+ data: entry[1]
904
+ };
905
+ }
906
+ }
907
+
908
+ function codeFrame(src, loc) {
909
+ if (!loc || loc.line === void 0 || loc.column === void 0) {
910
+ return "";
911
+ }
912
+ const lines = normalizeLF(src).split("\n").map((ln) => ln.replace(/\t/g, " "));
913
+ const visibleLines = [];
914
+ for (let n = -2; n <= 2; n++) {
915
+ if (lines[loc.line + n])
916
+ visibleLines.push(loc.line + n);
917
+ }
918
+ let gutterWidth = 0;
919
+ for (const lineNo of visibleLines) {
920
+ let w = `> ${lineNo}`;
921
+ if (w.length > gutterWidth)
922
+ gutterWidth = w.length;
923
+ }
924
+ let output = "";
925
+ for (const lineNo of visibleLines) {
926
+ const isFocusedLine = lineNo === loc.line - 1;
927
+ output += isFocusedLine ? "> " : " ";
928
+ output += `${lineNo + 1} | ${lines[lineNo]}
929
+ `;
930
+ if (isFocusedLine)
931
+ output += `${Array.from({ length: gutterWidth }).join(" ")} | ${Array.from({
932
+ length: loc.column
933
+ }).join(" ")}^
934
+ `;
935
+ }
936
+ return output;
937
+ }
938
+
939
+ class AstroError extends Error {
940
+ constructor(props, ...params) {
941
+ var _a;
942
+ super(...params);
943
+ this.type = "AstroError";
944
+ const { code, name, title, message, stack, location, hint, frame } = props;
945
+ this.errorCode = code;
946
+ if (name && name !== "Error") {
947
+ this.name = name;
948
+ } else {
949
+ this.name = ((_a = getErrorDataByCode(this.errorCode)) == null ? void 0 : _a.name) ?? "UnknownError";
950
+ }
951
+ this.title = title;
952
+ if (message)
953
+ this.message = message;
954
+ this.stack = stack ? stack : this.stack;
955
+ this.loc = location;
956
+ this.hint = hint;
957
+ this.frame = frame;
958
+ }
959
+ setErrorCode(errorCode) {
960
+ this.errorCode = errorCode;
961
+ }
962
+ setLocation(location) {
963
+ this.loc = location;
964
+ }
965
+ setName(name) {
966
+ this.name = name;
967
+ }
968
+ setMessage(message) {
969
+ this.message = message;
970
+ }
971
+ setHint(hint) {
972
+ this.hint = hint;
973
+ }
974
+ setFrame(source, location) {
975
+ this.frame = codeFrame(source, location);
976
+ }
977
+ static is(err) {
978
+ return err.type === "AstroError";
979
+ }
980
+ }
981
+
982
+ const PROP_TYPE = {
983
+ Value: 0,
984
+ JSON: 1,
985
+ RegExp: 2,
986
+ Date: 3,
987
+ Map: 4,
988
+ Set: 5,
989
+ BigInt: 6,
990
+ URL: 7,
991
+ Uint8Array: 8,
992
+ Uint16Array: 9,
993
+ Uint32Array: 10
994
+ };
995
+ function serializeArray(value, metadata = {}, parents = /* @__PURE__ */ new WeakSet()) {
996
+ if (parents.has(value)) {
997
+ throw new Error(`Cyclic reference detected while serializing props for <${metadata.displayName} client:${metadata.hydrate}>!
998
+
999
+ Cyclic references cannot be safely serialized for client-side usage. Please remove the cyclic reference.`);
1000
+ }
1001
+ parents.add(value);
1002
+ const serialized = value.map((v) => {
1003
+ return convertToSerializedForm(v, metadata, parents);
1004
+ });
1005
+ parents.delete(value);
1006
+ return serialized;
1007
+ }
1008
+ function serializeObject(value, metadata = {}, parents = /* @__PURE__ */ new WeakSet()) {
1009
+ if (parents.has(value)) {
1010
+ throw new Error(`Cyclic reference detected while serializing props for <${metadata.displayName} client:${metadata.hydrate}>!
1011
+
1012
+ Cyclic references cannot be safely serialized for client-side usage. Please remove the cyclic reference.`);
1013
+ }
1014
+ parents.add(value);
1015
+ const serialized = Object.fromEntries(
1016
+ Object.entries(value).map(([k, v]) => {
1017
+ return [k, convertToSerializedForm(v, metadata, parents)];
1018
+ })
1019
+ );
1020
+ parents.delete(value);
1021
+ return serialized;
1022
+ }
1023
+ function convertToSerializedForm(value, metadata = {}, parents = /* @__PURE__ */ new WeakSet()) {
1024
+ const tag = Object.prototype.toString.call(value);
1025
+ switch (tag) {
1026
+ case "[object Date]": {
1027
+ return [PROP_TYPE.Date, value.toISOString()];
1028
+ }
1029
+ case "[object RegExp]": {
1030
+ return [PROP_TYPE.RegExp, value.source];
1031
+ }
1032
+ case "[object Map]": {
1033
+ return [
1034
+ PROP_TYPE.Map,
1035
+ JSON.stringify(serializeArray(Array.from(value), metadata, parents))
1036
+ ];
1037
+ }
1038
+ case "[object Set]": {
1039
+ return [
1040
+ PROP_TYPE.Set,
1041
+ JSON.stringify(serializeArray(Array.from(value), metadata, parents))
1042
+ ];
1043
+ }
1044
+ case "[object BigInt]": {
1045
+ return [PROP_TYPE.BigInt, value.toString()];
1046
+ }
1047
+ case "[object URL]": {
1048
+ return [PROP_TYPE.URL, value.toString()];
1049
+ }
1050
+ case "[object Array]": {
1051
+ return [PROP_TYPE.JSON, JSON.stringify(serializeArray(value, metadata, parents))];
1052
+ }
1053
+ case "[object Uint8Array]": {
1054
+ return [PROP_TYPE.Uint8Array, JSON.stringify(Array.from(value))];
1055
+ }
1056
+ case "[object Uint16Array]": {
1057
+ return [PROP_TYPE.Uint16Array, JSON.stringify(Array.from(value))];
1058
+ }
1059
+ case "[object Uint32Array]": {
1060
+ return [PROP_TYPE.Uint32Array, JSON.stringify(Array.from(value))];
1061
+ }
1062
+ default: {
1063
+ if (value !== null && typeof value === "object") {
1064
+ return [PROP_TYPE.Value, serializeObject(value, metadata, parents)];
1065
+ } else {
1066
+ return [PROP_TYPE.Value, value];
1067
+ }
1068
+ }
1069
+ }
1070
+ }
1071
+ function serializeProps(props, metadata) {
1072
+ const serialized = JSON.stringify(serializeObject(props, metadata));
1073
+ return serialized;
1074
+ }
1075
+
1076
+ const HydrationDirectivesRaw = ["load", "idle", "media", "visible", "only"];
1077
+ const HydrationDirectives = new Set(HydrationDirectivesRaw);
1078
+ const HydrationDirectiveProps = new Set(HydrationDirectivesRaw.map((n) => `client:${n}`));
1079
+ function extractDirectives(displayName, inputProps) {
1080
+ let extracted = {
1081
+ isPage: false,
1082
+ hydration: null,
1083
+ props: {}
1084
+ };
1085
+ for (const [key, value] of Object.entries(inputProps)) {
1086
+ if (key.startsWith("server:")) {
1087
+ if (key === "server:root") {
1088
+ extracted.isPage = true;
1089
+ }
1090
+ }
1091
+ if (key.startsWith("client:")) {
1092
+ if (!extracted.hydration) {
1093
+ extracted.hydration = {
1094
+ directive: "",
1095
+ value: "",
1096
+ componentUrl: "",
1097
+ componentExport: { value: "" }
1098
+ };
1099
+ }
1100
+ switch (key) {
1101
+ case "client:component-path": {
1102
+ extracted.hydration.componentUrl = value;
1103
+ break;
1104
+ }
1105
+ case "client:component-export": {
1106
+ extracted.hydration.componentExport.value = value;
1107
+ break;
1108
+ }
1109
+ case "client:component-hydration": {
1110
+ break;
1111
+ }
1112
+ case "client:display-name": {
1113
+ break;
1114
+ }
1115
+ default: {
1116
+ extracted.hydration.directive = key.split(":")[1];
1117
+ extracted.hydration.value = value;
1118
+ if (!HydrationDirectives.has(extracted.hydration.directive)) {
1119
+ throw new Error(
1120
+ `Error: invalid hydration directive "${key}". Supported hydration methods: ${Array.from(
1121
+ HydrationDirectiveProps
1122
+ ).join(", ")}`
1123
+ );
1124
+ }
1125
+ if (extracted.hydration.directive === "media" && typeof extracted.hydration.value !== "string") {
1126
+ throw new AstroError(AstroErrorData.MissingMediaQueryDirective);
1127
+ }
1128
+ break;
1129
+ }
1130
+ }
1131
+ } else if (key === "class:list") {
1132
+ if (value) {
1133
+ extracted.props[key.slice(0, -5)] = serializeListValue(value);
1134
+ }
1135
+ } else {
1136
+ extracted.props[key] = value;
1137
+ }
1138
+ }
1139
+ for (const sym of Object.getOwnPropertySymbols(inputProps)) {
1140
+ extracted.props[sym] = inputProps[sym];
1141
+ }
1142
+ return extracted;
1143
+ }
1144
+ async function generateHydrateScript(scriptOptions, metadata) {
1145
+ const { renderer, result, astroId, props, attrs } = scriptOptions;
1146
+ const { hydrate, componentUrl, componentExport } = metadata;
1147
+ if (!componentExport.value) {
1148
+ throw new Error(
1149
+ `Unable to resolve a valid export for "${metadata.displayName}"! Please open an issue at https://astro.build/issues!`
1150
+ );
1151
+ }
1152
+ const island = {
1153
+ children: "",
1154
+ props: {
1155
+ uid: astroId
1156
+ }
1157
+ };
1158
+ if (attrs) {
1159
+ for (const [key, value] of Object.entries(attrs)) {
1160
+ island.props[key] = escapeHTML(value);
1161
+ }
1162
+ }
1163
+ island.props["component-url"] = await result.resolve(decodeURI(componentUrl));
1164
+ if (renderer.clientEntrypoint) {
1165
+ island.props["component-export"] = componentExport.value;
1166
+ island.props["renderer-url"] = await result.resolve(decodeURI(renderer.clientEntrypoint));
1167
+ island.props["props"] = escapeHTML(serializeProps(props, metadata));
1168
+ }
1169
+ island.props["ssr"] = "";
1170
+ island.props["client"] = hydrate;
1171
+ let beforeHydrationUrl = await result.resolve("astro:scripts/before-hydration.js");
1172
+ if (beforeHydrationUrl.length) {
1173
+ island.props["before-hydration-url"] = beforeHydrationUrl;
1174
+ }
1175
+ island.props["opts"] = escapeHTML(
1176
+ JSON.stringify({
1177
+ name: metadata.displayName,
1178
+ value: metadata.hydrateArgs || ""
1179
+ })
1180
+ );
1181
+ return island;
1182
+ }
1183
+
1184
+ var _a;
1185
+ const astroComponentInstanceSym = Symbol.for("astro.componentInstance");
1186
+ class AstroComponentInstance {
1187
+ constructor(result, props, slots, factory) {
1188
+ this[_a] = true;
1189
+ this.result = result;
1190
+ this.props = props;
1191
+ this.factory = factory;
1192
+ this.slotValues = {};
1193
+ for (const name in slots) {
1194
+ this.slotValues[name] = slots[name]();
1195
+ }
1196
+ }
1197
+ async init() {
1198
+ this.returnValue = this.factory(this.result, this.props, this.slotValues);
1199
+ return this.returnValue;
1200
+ }
1201
+ async *render() {
1202
+ if (this.returnValue === void 0) {
1203
+ await this.init();
1204
+ }
1205
+ let value = this.returnValue;
1206
+ if (isPromise(value)) {
1207
+ value = await value;
1208
+ }
1209
+ if (isHeadAndContent(value)) {
1210
+ yield* value.content;
1211
+ } else {
1212
+ yield* renderChild(value);
1213
+ }
1214
+ }
1215
+ }
1216
+ _a = astroComponentInstanceSym;
1217
+ function validateComponentProps(props, displayName) {
1218
+ if (props != null) {
1219
+ for (const prop of Object.keys(props)) {
1220
+ if (HydrationDirectiveProps.has(prop)) {
1221
+ console.warn(
1222
+ `You are attempting to render <${displayName} ${prop} />, but ${displayName} is an Astro component. Astro components do not render in the client and should not have a hydration directive. Please use a framework component for client rendering.`
1223
+ );
1224
+ }
1225
+ }
1226
+ }
1227
+ }
1228
+ function createAstroComponentInstance(result, displayName, factory, props, slots = {}) {
1229
+ validateComponentProps(props, displayName);
1230
+ const instance = new AstroComponentInstance(result, props, slots, factory);
1231
+ if (isAPropagatingComponent(result, factory) && !result.propagators.has(factory)) {
1232
+ result.propagators.set(factory, instance);
1233
+ }
1234
+ return instance;
1235
+ }
1236
+ function isAstroComponentInstance(obj) {
1237
+ return typeof obj === "object" && !!obj[astroComponentInstanceSym];
1238
+ }
1239
+
1240
+ async function* renderChild(child) {
1241
+ child = await child;
1242
+ if (child instanceof SlotString) {
1243
+ if (child.instructions) {
1244
+ yield* child.instructions;
1245
+ }
1246
+ yield child;
1247
+ } else if (isHTMLString(child)) {
1248
+ yield child;
1249
+ } else if (Array.isArray(child)) {
1250
+ for (const value of child) {
1251
+ yield markHTMLString(await renderChild(value));
1252
+ }
1253
+ } else if (typeof child === "function") {
1254
+ yield* renderChild(child());
1255
+ } else if (typeof child === "string") {
1256
+ yield markHTMLString(escapeHTML(child));
1257
+ } else if (!child && child !== 0) ; else if (isRenderTemplateResult(child)) {
1258
+ yield* renderAstroTemplateResult(child);
1259
+ } else if (isAstroComponentInstance(child)) {
1260
+ yield* child.render();
1261
+ } else if (ArrayBuffer.isView(child)) {
1262
+ yield child;
1263
+ } else if (typeof child === "object" && (Symbol.asyncIterator in child || Symbol.iterator in child)) {
1264
+ yield* child;
1265
+ } else {
1266
+ yield child;
1267
+ }
1268
+ }
1269
+
1270
+ const slotString = Symbol.for("astro:slot-string");
1271
+ class SlotString extends HTMLString {
1272
+ constructor(content, instructions) {
1273
+ super(content);
1274
+ this.instructions = instructions;
1275
+ this[slotString] = true;
1276
+ }
1277
+ }
1278
+ function isSlotString(str) {
1279
+ return !!str[slotString];
1280
+ }
1281
+ async function renderSlot(_result, slotted, fallback) {
1282
+ if (slotted) {
1283
+ let iterator = renderChild(slotted);
1284
+ let content = "";
1285
+ let instructions = null;
1286
+ for await (const chunk of iterator) {
1287
+ if (chunk.type === "directive") {
1288
+ if (instructions === null) {
1289
+ instructions = [];
1290
+ }
1291
+ instructions.push(chunk);
1292
+ } else {
1293
+ content += chunk;
1294
+ }
1295
+ }
1296
+ return markHTMLString(new SlotString(content, instructions));
1297
+ }
1298
+ return fallback;
1299
+ }
1300
+ async function renderSlots(result, slots = {}) {
1301
+ let slotInstructions = null;
1302
+ let children = {};
1303
+ if (slots) {
1304
+ await Promise.all(
1305
+ Object.entries(slots).map(
1306
+ ([key, value]) => renderSlot(result, value).then((output) => {
1307
+ if (output.instructions) {
1308
+ if (slotInstructions === null) {
1309
+ slotInstructions = [];
1310
+ }
1311
+ slotInstructions.push(...output.instructions);
1312
+ }
1313
+ children[key] = output;
1314
+ })
1315
+ )
1316
+ );
1317
+ }
1318
+ return { slotInstructions, children };
1319
+ }
1320
+
1321
+ const Fragment = Symbol.for("astro:fragment");
1322
+ const Renderer = Symbol.for("astro:renderer");
1323
+ const encoder = new TextEncoder();
1324
+ const decoder = new TextDecoder();
1325
+ function stringifyChunk(result, chunk) {
1326
+ switch (chunk.type) {
1327
+ case "directive": {
1328
+ const { hydration } = chunk;
1329
+ let needsHydrationScript = hydration && determineIfNeedsHydrationScript(result);
1330
+ let needsDirectiveScript = hydration && determinesIfNeedsDirectiveScript(result, hydration.directive);
1331
+ let prescriptType = needsHydrationScript ? "both" : needsDirectiveScript ? "directive" : null;
1332
+ if (prescriptType) {
1333
+ let prescripts = getPrescripts(prescriptType, hydration.directive);
1334
+ return markHTMLString(prescripts);
1335
+ } else {
1336
+ return "";
1337
+ }
1338
+ }
1339
+ default: {
1340
+ if (isSlotString(chunk)) {
1341
+ let out = "";
1342
+ const c = chunk;
1343
+ if (c.instructions) {
1344
+ for (const instr of c.instructions) {
1345
+ out += stringifyChunk(result, instr);
1346
+ }
1347
+ }
1348
+ out += chunk.toString();
1349
+ return out;
1350
+ }
1351
+ return chunk.toString();
1352
+ }
1353
+ }
1354
+ }
1355
+ class HTMLParts {
1356
+ constructor() {
1357
+ this.parts = "";
1358
+ }
1359
+ append(part, result) {
1360
+ if (ArrayBuffer.isView(part)) {
1361
+ this.parts += decoder.decode(part);
1362
+ } else {
1363
+ this.parts += stringifyChunk(result, part);
1364
+ }
1365
+ }
1366
+ toString() {
1367
+ return this.parts;
1368
+ }
1369
+ toArrayBuffer() {
1370
+ return encoder.encode(this.parts);
1371
+ }
1372
+ }
1373
+ function chunkToByteArray(result, chunk) {
1374
+ if (chunk instanceof Uint8Array) {
1375
+ return chunk;
1376
+ }
1377
+ return encoder.encode(stringifyChunk(result, chunk));
1378
+ }
1379
+
1380
+ const ClientOnlyPlaceholder = "astro-client-only";
1381
+ class Skip {
1382
+ constructor(vnode) {
1383
+ this.vnode = vnode;
1384
+ this.count = 0;
1385
+ }
1386
+ increment() {
1387
+ this.count++;
1388
+ }
1389
+ haveNoTried() {
1390
+ return this.count === 0;
1391
+ }
1392
+ isCompleted() {
1393
+ return this.count > 2;
1394
+ }
1395
+ }
1396
+ Skip.symbol = Symbol("astro:jsx:skip");
1397
+ let originalConsoleError;
1398
+ let consoleFilterRefs = 0;
1399
+ async function renderJSX(result, vnode) {
1400
+ switch (true) {
1401
+ case vnode instanceof HTMLString:
1402
+ if (vnode.toString().trim() === "") {
1403
+ return "";
1404
+ }
1405
+ return vnode;
1406
+ case typeof vnode === "string":
1407
+ return markHTMLString(escapeHTML(vnode));
1408
+ case typeof vnode === "function":
1409
+ return vnode;
1410
+ case (!vnode && vnode !== 0):
1411
+ return "";
1412
+ case Array.isArray(vnode):
1413
+ return markHTMLString(
1414
+ (await Promise.all(vnode.map((v) => renderJSX(result, v)))).join("")
1415
+ );
1416
+ }
1417
+ let skip;
1418
+ if (vnode.props) {
1419
+ if (vnode.props[Skip.symbol]) {
1420
+ skip = vnode.props[Skip.symbol];
1421
+ } else {
1422
+ skip = new Skip(vnode);
1423
+ }
1424
+ } else {
1425
+ skip = new Skip(vnode);
1426
+ }
1427
+ return renderJSXVNode(result, vnode, skip);
1428
+ }
1429
+ async function renderJSXVNode(result, vnode, skip) {
1430
+ if (isVNode(vnode)) {
1431
+ switch (true) {
1432
+ case !vnode.type: {
1433
+ throw new Error(`Unable to render ${result._metadata.pathname} because it contains an undefined Component!
1434
+ Did you forget to import the component or is it possible there is a typo?`);
1435
+ }
1436
+ case vnode.type === Symbol.for("astro:fragment"):
1437
+ return renderJSX(result, vnode.props.children);
1438
+ case vnode.type.isAstroComponentFactory: {
1439
+ let props = {};
1440
+ let slots = {};
1441
+ for (const [key, value] of Object.entries(vnode.props ?? {})) {
1442
+ if (key === "children" || value && typeof value === "object" && value["$$slot"]) {
1443
+ slots[key === "children" ? "default" : key] = () => renderJSX(result, value);
1444
+ } else {
1445
+ props[key] = value;
1446
+ }
1447
+ }
1448
+ return markHTMLString(await renderToString(result, vnode.type, props, slots));
1449
+ }
1450
+ case (!vnode.type && vnode.type !== 0):
1451
+ return "";
1452
+ case (typeof vnode.type === "string" && vnode.type !== ClientOnlyPlaceholder):
1453
+ return markHTMLString(await renderElement$1(result, vnode.type, vnode.props ?? {}));
1454
+ }
1455
+ if (vnode.type) {
1456
+ let extractSlots2 = function(child) {
1457
+ if (Array.isArray(child)) {
1458
+ return child.map((c) => extractSlots2(c));
1459
+ }
1460
+ if (!isVNode(child)) {
1461
+ _slots.default.push(child);
1462
+ return;
1463
+ }
1464
+ if ("slot" in child.props) {
1465
+ _slots[child.props.slot] = [..._slots[child.props.slot] ?? [], child];
1466
+ delete child.props.slot;
1467
+ return;
1468
+ }
1469
+ _slots.default.push(child);
1470
+ };
1471
+ if (typeof vnode.type === "function" && vnode.type["astro:renderer"]) {
1472
+ skip.increment();
1473
+ }
1474
+ if (typeof vnode.type === "function" && vnode.props["server:root"]) {
1475
+ const output2 = await vnode.type(vnode.props ?? {});
1476
+ return await renderJSX(result, output2);
1477
+ }
1478
+ if (typeof vnode.type === "function") {
1479
+ if (skip.haveNoTried() || skip.isCompleted()) {
1480
+ useConsoleFilter();
1481
+ try {
1482
+ const output2 = await vnode.type(vnode.props ?? {});
1483
+ let renderResult;
1484
+ if (output2 && output2[AstroJSX]) {
1485
+ renderResult = await renderJSXVNode(result, output2, skip);
1486
+ return renderResult;
1487
+ } else if (!output2) {
1488
+ renderResult = await renderJSXVNode(result, output2, skip);
1489
+ return renderResult;
1490
+ }
1491
+ } catch (e) {
1492
+ if (skip.isCompleted()) {
1493
+ throw e;
1494
+ }
1495
+ skip.increment();
1496
+ } finally {
1497
+ finishUsingConsoleFilter();
1498
+ }
1499
+ } else {
1500
+ skip.increment();
1501
+ }
1502
+ }
1503
+ const { children = null, ...props } = vnode.props ?? {};
1504
+ const _slots = {
1505
+ default: []
1506
+ };
1507
+ extractSlots2(children);
1508
+ for (const [key, value] of Object.entries(props)) {
1509
+ if (value["$$slot"]) {
1510
+ _slots[key] = value;
1511
+ delete props[key];
1512
+ }
1513
+ }
1514
+ const slotPromises = [];
1515
+ const slots = {};
1516
+ for (const [key, value] of Object.entries(_slots)) {
1517
+ slotPromises.push(
1518
+ renderJSX(result, value).then((output2) => {
1519
+ if (output2.toString().trim().length === 0)
1520
+ return;
1521
+ slots[key] = () => output2;
1522
+ })
1523
+ );
1524
+ }
1525
+ await Promise.all(slotPromises);
1526
+ props[Skip.symbol] = skip;
1527
+ let output;
1528
+ if (vnode.type === ClientOnlyPlaceholder && vnode.props["client:only"]) {
1529
+ output = await renderComponentToIterable(
1530
+ result,
1531
+ vnode.props["client:display-name"] ?? "",
1532
+ null,
1533
+ props,
1534
+ slots
1535
+ );
1536
+ } else {
1537
+ output = await renderComponentToIterable(
1538
+ result,
1539
+ typeof vnode.type === "function" ? vnode.type.name : vnode.type,
1540
+ vnode.type,
1541
+ props,
1542
+ slots
1543
+ );
1544
+ }
1545
+ if (typeof output !== "string" && Symbol.asyncIterator in output) {
1546
+ let parts = new HTMLParts();
1547
+ for await (const chunk of output) {
1548
+ parts.append(chunk, result);
1549
+ }
1550
+ return markHTMLString(parts.toString());
1551
+ } else {
1552
+ return markHTMLString(output);
1553
+ }
1554
+ }
1555
+ }
1556
+ return markHTMLString(`${vnode}`);
1557
+ }
1558
+ async function renderElement$1(result, tag, { children, ...props }) {
1559
+ return markHTMLString(
1560
+ `<${tag}${spreadAttributes(props)}${markHTMLString(
1561
+ (children == null || children == "") && voidElementNames.test(tag) ? `/>` : `>${children == null ? "" : await renderJSX(result, children)}</${tag}>`
1562
+ )}`
1563
+ );
1564
+ }
1565
+ function useConsoleFilter() {
1566
+ consoleFilterRefs++;
1567
+ if (!originalConsoleError) {
1568
+ originalConsoleError = console.error;
1569
+ try {
1570
+ console.error = filteredConsoleError;
1571
+ } catch (error) {
1572
+ }
1573
+ }
1574
+ }
1575
+ function finishUsingConsoleFilter() {
1576
+ consoleFilterRefs--;
1577
+ }
1578
+ function filteredConsoleError(msg, ...rest) {
1579
+ if (consoleFilterRefs > 0 && typeof msg === "string") {
1580
+ const isKnownReactHookError = msg.includes("Warning: Invalid hook call.") && msg.includes("https://reactjs.org/link/invalid-hook-call");
1581
+ if (isKnownReactHookError)
1582
+ return;
1583
+ }
1584
+ originalConsoleError(msg, ...rest);
1585
+ }
1586
+
1587
+ /**
1588
+ * shortdash - https://github.com/bibig/node-shorthash
1589
+ *
1590
+ * @license
1591
+ *
1592
+ * (The MIT License)
1593
+ *
1594
+ * Copyright (c) 2013 Bibig <bibig@me.com>
1595
+ *
1596
+ * Permission is hereby granted, free of charge, to any person
1597
+ * obtaining a copy of this software and associated documentation
1598
+ * files (the "Software"), to deal in the Software without
1599
+ * restriction, including without limitation the rights to use,
1600
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
1601
+ * copies of the Software, and to permit persons to whom the
1602
+ * Software is furnished to do so, subject to the following
1603
+ * conditions:
1604
+ *
1605
+ * The above copyright notice and this permission notice shall be
1606
+ * included in all copies or substantial portions of the Software.
1607
+ *
1608
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1609
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
1610
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1611
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
1612
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
1613
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1614
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1615
+ * OTHER DEALINGS IN THE SOFTWARE.
1616
+ */
1617
+ const dictionary = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY";
1618
+ const binary = dictionary.length;
1619
+ function bitwise(str) {
1620
+ let hash = 0;
1621
+ if (str.length === 0)
1622
+ return hash;
1623
+ for (let i = 0; i < str.length; i++) {
1624
+ const ch = str.charCodeAt(i);
1625
+ hash = (hash << 5) - hash + ch;
1626
+ hash = hash & hash;
1627
+ }
1628
+ return hash;
1629
+ }
1630
+ function shorthash(text) {
1631
+ let num;
1632
+ let result = "";
1633
+ let integer = bitwise(text);
1634
+ const sign = integer < 0 ? "Z" : "";
1635
+ integer = Math.abs(integer);
1636
+ while (integer >= binary) {
1637
+ num = integer % binary;
1638
+ integer = Math.floor(integer / binary);
1639
+ result = dictionary[num] + result;
1640
+ }
1641
+ if (integer > 0) {
1642
+ result = dictionary[integer] + result;
1643
+ }
1644
+ return sign + result;
1645
+ }
1646
+
1647
+ const voidElementNames = /^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
1648
+ const htmlBooleanAttributes = /^(allowfullscreen|async|autofocus|autoplay|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|hidden|loop|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|itemscope)$/i;
1649
+ const htmlEnumAttributes = /^(contenteditable|draggable|spellcheck|value)$/i;
1650
+ const svgEnumAttributes = /^(autoReverse|externalResourcesRequired|focusable|preserveAlpha)$/i;
1651
+ const STATIC_DIRECTIVES = /* @__PURE__ */ new Set(["set:html", "set:text"]);
1652
+ const toIdent = (k) => k.trim().replace(/(?:(?!^)\b\w|\s+|[^\w]+)/g, (match, index) => {
1653
+ if (/[^\w]|\s/.test(match))
1654
+ return "";
1655
+ return index === 0 ? match : match.toUpperCase();
1656
+ });
1657
+ const toAttributeString = (value, shouldEscape = true) => shouldEscape ? String(value).replace(/&/g, "&#38;").replace(/"/g, "&#34;") : value;
1658
+ const kebab = (k) => k.toLowerCase() === k ? k : k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
1659
+ const toStyleString = (obj) => Object.entries(obj).map(([k, v]) => `${kebab(k)}:${v}`).join(";");
1660
+ function defineScriptVars(vars) {
1661
+ let output = "";
1662
+ for (const [key, value] of Object.entries(vars)) {
1663
+ output += `const ${toIdent(key)} = ${JSON.stringify(value)};
1664
+ `;
1665
+ }
1666
+ return markHTMLString(output);
1667
+ }
1668
+ function formatList(values) {
1669
+ if (values.length === 1) {
1670
+ return values[0];
1671
+ }
1672
+ return `${values.slice(0, -1).join(", ")} or ${values[values.length - 1]}`;
1673
+ }
1674
+ function addAttribute(value, key, shouldEscape = true) {
1675
+ if (value == null) {
1676
+ return "";
1677
+ }
1678
+ if (value === false) {
1679
+ if (htmlEnumAttributes.test(key) || svgEnumAttributes.test(key)) {
1680
+ return markHTMLString(` ${key}="false"`);
1681
+ }
1682
+ return "";
1683
+ }
1684
+ if (STATIC_DIRECTIVES.has(key)) {
1685
+ console.warn(`[astro] The "${key}" directive cannot be applied dynamically at runtime. It will not be rendered as an attribute.
1686
+
1687
+ Make sure to use the static attribute syntax (\`${key}={value}\`) instead of the dynamic spread syntax (\`{...{ "${key}": value }}\`).`);
1688
+ return "";
1689
+ }
1690
+ if (key === "class:list") {
1691
+ const listValue = toAttributeString(serializeListValue(value), shouldEscape);
1692
+ if (listValue === "") {
1693
+ return "";
1694
+ }
1695
+ return markHTMLString(` ${key.slice(0, -5)}="${listValue}"`);
1696
+ }
1697
+ if (key === "style" && !(value instanceof HTMLString) && typeof value === "object") {
1698
+ return markHTMLString(` ${key}="${toAttributeString(toStyleString(value), shouldEscape)}"`);
1699
+ }
1700
+ if (key === "className") {
1701
+ return markHTMLString(` class="${toAttributeString(value, shouldEscape)}"`);
1702
+ }
1703
+ if (value === true && (key.startsWith("data-") || htmlBooleanAttributes.test(key))) {
1704
+ return markHTMLString(` ${key}`);
1705
+ } else {
1706
+ return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
1707
+ }
1708
+ }
1709
+ function internalSpreadAttributes(values, shouldEscape = true) {
1710
+ let output = "";
1711
+ for (const [key, value] of Object.entries(values)) {
1712
+ output += addAttribute(value, key, shouldEscape);
1713
+ }
1714
+ return markHTMLString(output);
1715
+ }
1716
+ function renderElement(name, { props: _props, children = "" }, shouldEscape = true) {
1717
+ const { lang: _, "data-astro-id": astroId, "define:vars": defineVars, ...props } = _props;
1718
+ if (defineVars) {
1719
+ if (name === "style") {
1720
+ delete props["is:global"];
1721
+ delete props["is:scoped"];
1722
+ }
1723
+ if (name === "script") {
1724
+ delete props.hoist;
1725
+ children = defineScriptVars(defineVars) + "\n" + children;
1726
+ }
1727
+ }
1728
+ if ((children == null || children == "") && voidElementNames.test(name)) {
1729
+ return `<${name}${internalSpreadAttributes(props, shouldEscape)} />`;
1730
+ }
1731
+ return `<${name}${internalSpreadAttributes(props, shouldEscape)}>${children}</${name}>`;
1732
+ }
1733
+
1734
+ function componentIsHTMLElement(Component) {
1735
+ return typeof HTMLElement !== "undefined" && HTMLElement.isPrototypeOf(Component);
1736
+ }
1737
+ async function renderHTMLElement(result, constructor, props, slots) {
1738
+ const name = getHTMLElementName(constructor);
1739
+ let attrHTML = "";
1740
+ for (const attr in props) {
1741
+ attrHTML += ` ${attr}="${toAttributeString(await props[attr])}"`;
1742
+ }
1743
+ return markHTMLString(
1744
+ `<${name}${attrHTML}>${await renderSlot(result, slots == null ? void 0 : slots.default)}</${name}>`
1745
+ );
1746
+ }
1747
+ function getHTMLElementName(constructor) {
1748
+ const definedName = customElements.getName(constructor);
1749
+ if (definedName)
1750
+ return definedName;
1751
+ const assignedName = constructor.name.replace(/^HTML|Element$/g, "").replace(/[A-Z]/g, "-$&").toLowerCase().replace(/^-/, "html-");
1752
+ return assignedName;
1753
+ }
1754
+
1755
+ const rendererAliases = /* @__PURE__ */ new Map([["solid", "solid-js"]]);
1756
+ function guessRenderers(componentUrl) {
1757
+ const extname = componentUrl == null ? void 0 : componentUrl.split(".").pop();
1758
+ switch (extname) {
1759
+ case "svelte":
1760
+ return ["@astrojs/svelte"];
1761
+ case "vue":
1762
+ return ["@astrojs/vue"];
1763
+ case "jsx":
1764
+ case "tsx":
1765
+ return ["@astrojs/react", "@astrojs/preact", "@astrojs/solid-js", "@astrojs/vue (jsx)"];
1766
+ default:
1767
+ return [
1768
+ "@astrojs/react",
1769
+ "@astrojs/preact",
1770
+ "@astrojs/solid-js",
1771
+ "@astrojs/vue",
1772
+ "@astrojs/svelte"
1773
+ ];
1774
+ }
1775
+ }
1776
+ function isFragmentComponent(Component) {
1777
+ return Component === Fragment;
1778
+ }
1779
+ function isHTMLComponent(Component) {
1780
+ return Component && typeof Component === "object" && Component["astro:html"];
1781
+ }
1782
+ async function renderFrameworkComponent(result, displayName, Component, _props, slots = {}) {
1783
+ var _a, _b;
1784
+ if (!Component && !_props["client:only"]) {
1785
+ throw new Error(
1786
+ `Unable to render ${displayName} because it is ${Component}!
1787
+ Did you forget to import the component or is it possible there is a typo?`
1788
+ );
1789
+ }
1790
+ const { renderers } = result._metadata;
1791
+ const metadata = { displayName };
1792
+ const { hydration, isPage, props } = extractDirectives(displayName, _props);
1793
+ let html = "";
1794
+ let attrs = void 0;
1795
+ if (hydration) {
1796
+ metadata.hydrate = hydration.directive;
1797
+ metadata.hydrateArgs = hydration.value;
1798
+ metadata.componentExport = hydration.componentExport;
1799
+ metadata.componentUrl = hydration.componentUrl;
1800
+ }
1801
+ const probableRendererNames = guessRenderers(metadata.componentUrl);
1802
+ const validRenderers = renderers.filter((r) => r.name !== "astro:jsx");
1803
+ const { children, slotInstructions } = await renderSlots(result, slots);
1804
+ let renderer;
1805
+ if (metadata.hydrate !== "only") {
1806
+ let isTagged = false;
1807
+ try {
1808
+ isTagged = Component && Component[Renderer];
1809
+ } catch {
1810
+ }
1811
+ if (isTagged) {
1812
+ const rendererName = Component[Renderer];
1813
+ renderer = renderers.find(({ name }) => name === rendererName);
1814
+ }
1815
+ if (!renderer) {
1816
+ let error;
1817
+ for (const r of renderers) {
1818
+ try {
1819
+ if (await r.ssr.check.call({ result }, Component, props, children)) {
1820
+ renderer = r;
1821
+ break;
1822
+ }
1823
+ } catch (e) {
1824
+ error ?? (error = e);
1825
+ }
1826
+ }
1827
+ if (!renderer && error) {
1828
+ throw error;
1829
+ }
1830
+ }
1831
+ if (!renderer && typeof HTMLElement === "function" && componentIsHTMLElement(Component)) {
1832
+ const output = renderHTMLElement(result, Component, _props, slots);
1833
+ return output;
1834
+ }
1835
+ } else {
1836
+ if (metadata.hydrateArgs) {
1837
+ const passedName = metadata.hydrateArgs;
1838
+ const rendererName = rendererAliases.has(passedName) ? rendererAliases.get(passedName) : passedName;
1839
+ renderer = renderers.find(
1840
+ ({ name }) => name === `@astrojs/${rendererName}` || name === rendererName
1841
+ );
1842
+ }
1843
+ if (!renderer && validRenderers.length === 1) {
1844
+ renderer = validRenderers[0];
1845
+ }
1846
+ if (!renderer) {
1847
+ const extname = (_a = metadata.componentUrl) == null ? void 0 : _a.split(".").pop();
1848
+ renderer = renderers.filter(
1849
+ ({ name }) => name === `@astrojs/${extname}` || name === extname
1850
+ )[0];
1851
+ }
1852
+ }
1853
+ if (!renderer) {
1854
+ if (metadata.hydrate === "only") {
1855
+ throw new AstroError({
1856
+ ...AstroErrorData.NoClientOnlyHint,
1857
+ message: AstroErrorData.NoClientOnlyHint.message(metadata.displayName),
1858
+ hint: AstroErrorData.NoClientOnlyHint.hint(
1859
+ probableRendererNames.map((r) => r.replace("@astrojs/", "")).join("|")
1860
+ )
1861
+ });
1862
+ } else if (typeof Component !== "string") {
1863
+ const matchingRenderers = validRenderers.filter(
1864
+ (r) => probableRendererNames.includes(r.name)
1865
+ );
1866
+ const plural = validRenderers.length > 1;
1867
+ if (matchingRenderers.length === 0) {
1868
+ throw new AstroError({
1869
+ ...AstroErrorData.NoMatchingRenderer,
1870
+ message: AstroErrorData.NoMatchingRenderer.message(
1871
+ metadata.displayName,
1872
+ (_b = metadata == null ? void 0 : metadata.componentUrl) == null ? void 0 : _b.split(".").pop(),
1873
+ plural,
1874
+ validRenderers.length
1875
+ ),
1876
+ hint: AstroErrorData.NoMatchingRenderer.hint(
1877
+ formatList(probableRendererNames.map((r) => "`" + r + "`"))
1878
+ )
1879
+ });
1880
+ } else if (matchingRenderers.length === 1) {
1881
+ renderer = matchingRenderers[0];
1882
+ ({ html, attrs } = await renderer.ssr.renderToStaticMarkup.call(
1883
+ { result },
1884
+ Component,
1885
+ props,
1886
+ children,
1887
+ metadata
1888
+ ));
1889
+ } else {
1890
+ throw new Error(`Unable to render ${metadata.displayName}!
1891
+
1892
+ This component likely uses ${formatList(probableRendererNames)},
1893
+ but Astro encountered an error during server-side rendering.
1894
+
1895
+ Please ensure that ${metadata.displayName}:
1896
+ 1. Does not unconditionally access browser-specific globals like \`window\` or \`document\`.
1897
+ If this is unavoidable, use the \`client:only\` hydration directive.
1898
+ 2. Does not conditionally return \`null\` or \`undefined\` when rendered on the server.
1899
+
1900
+ If you're still stuck, please open an issue on GitHub or join us at https://astro.build/chat.`);
1901
+ }
1902
+ }
1903
+ } else {
1904
+ if (metadata.hydrate === "only") {
1905
+ html = await renderSlot(result, slots == null ? void 0 : slots.fallback);
1906
+ } else {
1907
+ ({ html, attrs } = await renderer.ssr.renderToStaticMarkup.call(
1908
+ { result },
1909
+ Component,
1910
+ props,
1911
+ children,
1912
+ metadata
1913
+ ));
1914
+ }
1915
+ }
1916
+ if (renderer && !renderer.clientEntrypoint && renderer.name !== "@astrojs/lit" && metadata.hydrate) {
1917
+ throw new AstroError({
1918
+ ...AstroErrorData.NoClientEntrypoint,
1919
+ message: AstroErrorData.NoClientEntrypoint.message(
1920
+ displayName,
1921
+ metadata.hydrate,
1922
+ renderer.name
1923
+ )
1924
+ });
1925
+ }
1926
+ if (!html && typeof Component === "string") {
1927
+ const Tag = sanitizeElementName(Component);
1928
+ const childSlots = Object.values(children).join("");
1929
+ const iterable = renderAstroTemplateResult(
1930
+ await renderTemplate`<${Tag}${internalSpreadAttributes(props)}${markHTMLString(
1931
+ childSlots === "" && voidElementNames.test(Tag) ? `/>` : `>${childSlots}</${Tag}>`
1932
+ )}`
1933
+ );
1934
+ html = "";
1935
+ for await (const chunk of iterable) {
1936
+ html += chunk;
1937
+ }
1938
+ }
1939
+ if (!hydration) {
1940
+ return async function* () {
1941
+ if (slotInstructions) {
1942
+ yield* slotInstructions;
1943
+ }
1944
+ if (isPage || (renderer == null ? void 0 : renderer.name) === "astro:jsx") {
1945
+ yield html;
1946
+ } else {
1947
+ yield markHTMLString(html.replace(/\<\/?astro-slot\>/g, ""));
1948
+ }
1949
+ }();
1950
+ }
1951
+ const astroId = shorthash(
1952
+ `<!--${metadata.componentExport.value}:${metadata.componentUrl}-->
1953
+ ${html}
1954
+ ${serializeProps(
1955
+ props,
1956
+ metadata
1957
+ )}`
1958
+ );
1959
+ const island = await generateHydrateScript(
1960
+ { renderer, result, astroId, props, attrs },
1961
+ metadata
1962
+ );
1963
+ let unrenderedSlots = [];
1964
+ if (html) {
1965
+ if (Object.keys(children).length > 0) {
1966
+ for (const key of Object.keys(children)) {
1967
+ if (!html.includes(key === "default" ? `<astro-slot>` : `<astro-slot name="${key}">`)) {
1968
+ unrenderedSlots.push(key);
1969
+ }
1970
+ }
1971
+ }
1972
+ } else {
1973
+ unrenderedSlots = Object.keys(children);
1974
+ }
1975
+ const template = unrenderedSlots.length > 0 ? unrenderedSlots.map(
1976
+ (key) => `<template data-astro-template${key !== "default" ? `="${key}"` : ""}>${children[key]}</template>`
1977
+ ).join("") : "";
1978
+ island.children = `${html ?? ""}${template}`;
1979
+ if (island.children) {
1980
+ island.props["await-children"] = "";
1981
+ }
1982
+ async function* renderAll() {
1983
+ if (slotInstructions) {
1984
+ yield* slotInstructions;
1985
+ }
1986
+ yield { type: "directive", hydration, result };
1987
+ yield markHTMLString(renderElement("astro-island", island, false));
1988
+ }
1989
+ return renderAll();
1990
+ }
1991
+ function sanitizeElementName(tag) {
1992
+ const unsafe = /[&<>'"\s]+/g;
1993
+ if (!unsafe.test(tag))
1994
+ return tag;
1995
+ return tag.trim().split(unsafe)[0].trim();
1996
+ }
1997
+ async function renderFragmentComponent(result, slots = {}) {
1998
+ const children = await renderSlot(result, slots == null ? void 0 : slots.default);
1999
+ if (children == null) {
2000
+ return children;
2001
+ }
2002
+ return markHTMLString(children);
2003
+ }
2004
+ async function renderHTMLComponent(result, Component, _props, slots = {}) {
2005
+ const { slotInstructions, children } = await renderSlots(result, slots);
2006
+ const html = Component.render({ slots: children });
2007
+ const hydrationHtml = slotInstructions ? slotInstructions.map((instr) => stringifyChunk(result, instr)).join("") : "";
2008
+ return markHTMLString(hydrationHtml + html);
2009
+ }
2010
+ function renderComponent(result, displayName, Component, props, slots = {}) {
2011
+ if (isPromise(Component)) {
2012
+ return Promise.resolve(Component).then((Unwrapped) => {
2013
+ return renderComponent(result, displayName, Unwrapped, props, slots);
2014
+ });
2015
+ }
2016
+ if (isFragmentComponent(Component)) {
2017
+ return renderFragmentComponent(result, slots);
2018
+ }
2019
+ if (isHTMLComponent(Component)) {
2020
+ return renderHTMLComponent(result, Component, props, slots);
2021
+ }
2022
+ if (isAstroComponentFactory(Component)) {
2023
+ return createAstroComponentInstance(result, displayName, Component, props, slots);
2024
+ }
2025
+ return renderFrameworkComponent(result, displayName, Component, props, slots);
2026
+ }
2027
+ function renderComponentToIterable(result, displayName, Component, props, slots = {}) {
2028
+ const renderResult = renderComponent(result, displayName, Component, props, slots);
2029
+ if (isAstroComponentInstance(renderResult)) {
2030
+ return renderResult.render();
2031
+ }
2032
+ return renderResult;
2033
+ }
2034
+
2035
+ const uniqueElements = (item, index, all) => {
2036
+ const props = JSON.stringify(item.props);
2037
+ const children = item.children;
2038
+ return index === all.findIndex((i) => JSON.stringify(i.props) === props && i.children == children);
2039
+ };
2040
+ async function* renderExtraHead(result, base) {
2041
+ yield base;
2042
+ for (const part of result.extraHead) {
2043
+ yield* renderChild(part);
2044
+ }
2045
+ }
2046
+ function renderAllHeadContent(result) {
2047
+ const styles = Array.from(result.styles).filter(uniqueElements).map((style) => renderElement("style", style));
2048
+ result.styles.clear();
2049
+ const scripts = Array.from(result.scripts).filter(uniqueElements).map((script, i) => {
2050
+ return renderElement("script", script, false);
2051
+ });
2052
+ const links = Array.from(result.links).filter(uniqueElements).map((link) => renderElement("link", link, false));
2053
+ const baseHeadContent = markHTMLString(links.join("\n") + styles.join("\n") + scripts.join("\n"));
2054
+ if (result.extraHead.length > 0) {
2055
+ return renderExtraHead(result, baseHeadContent);
2056
+ } else {
2057
+ return baseHeadContent;
2058
+ }
2059
+ }
2060
+ function createRenderHead(result) {
2061
+ result._metadata.hasRenderedHead = true;
2062
+ return renderAllHeadContent.bind(null, result);
2063
+ }
2064
+ const renderHead = createRenderHead;
2065
+ async function* maybeRenderHead(result) {
2066
+ if (result._metadata.hasRenderedHead) {
2067
+ return;
2068
+ }
2069
+ yield createRenderHead(result)();
2070
+ }
2071
+
2072
+ var __accessCheck$2 = (obj, member, msg) => {
2073
+ if (!member.has(obj))
2074
+ throw TypeError("Cannot " + msg);
2075
+ };
2076
+ var __privateGet$2 = (obj, member, getter) => {
2077
+ __accessCheck$2(obj, member, "read from private field");
2078
+ return getter ? getter.call(obj) : member.get(obj);
2079
+ };
2080
+ var __privateAdd$2 = (obj, member, value) => {
2081
+ if (member.has(obj))
2082
+ throw TypeError("Cannot add the same private member more than once");
2083
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2084
+ };
2085
+ var __privateSet$2 = (obj, member, value, setter) => {
2086
+ __accessCheck$2(obj, member, "write to private field");
2087
+ setter ? setter.call(obj, value) : member.set(obj, value);
2088
+ return value;
2089
+ };
2090
+ const isNodeJS = typeof process === "object" && Object.prototype.toString.call(process) === "[object process]";
2091
+ let StreamingCompatibleResponse;
2092
+ function createResponseClass() {
2093
+ var _isStream, _body, _a;
2094
+ StreamingCompatibleResponse = (_a = class extends Response {
2095
+ constructor(body, init) {
2096
+ let isStream = body instanceof ReadableStream;
2097
+ super(isStream ? null : body, init);
2098
+ __privateAdd$2(this, _isStream, void 0);
2099
+ __privateAdd$2(this, _body, void 0);
2100
+ __privateSet$2(this, _isStream, isStream);
2101
+ __privateSet$2(this, _body, body);
2102
+ }
2103
+ get body() {
2104
+ return __privateGet$2(this, _body);
2105
+ }
2106
+ async text() {
2107
+ if (__privateGet$2(this, _isStream) && isNodeJS) {
2108
+ let decoder = new TextDecoder();
2109
+ let body = __privateGet$2(this, _body);
2110
+ let out = "";
2111
+ for await (let chunk of streamAsyncIterator(body)) {
2112
+ out += decoder.decode(chunk);
2113
+ }
2114
+ return out;
2115
+ }
2116
+ return super.text();
2117
+ }
2118
+ async arrayBuffer() {
2119
+ if (__privateGet$2(this, _isStream) && isNodeJS) {
2120
+ let body = __privateGet$2(this, _body);
2121
+ let chunks = [];
2122
+ let len = 0;
2123
+ for await (let chunk of streamAsyncIterator(body)) {
2124
+ chunks.push(chunk);
2125
+ len += chunk.length;
2126
+ }
2127
+ let ab = new Uint8Array(len);
2128
+ let offset = 0;
2129
+ for (const chunk of chunks) {
2130
+ ab.set(chunk, offset);
2131
+ offset += chunk.length;
2132
+ }
2133
+ return ab;
2134
+ }
2135
+ return super.arrayBuffer();
2136
+ }
2137
+ }, _isStream = new WeakMap(), _body = new WeakMap(), _a);
2138
+ return StreamingCompatibleResponse;
2139
+ }
2140
+ const createResponse = isNodeJS ? (body, init) => {
2141
+ if (typeof body === "string" || ArrayBuffer.isView(body)) {
2142
+ return new Response(body, init);
2143
+ }
2144
+ if (typeof StreamingCompatibleResponse === "undefined") {
2145
+ return new (createResponseClass())(body, init);
2146
+ }
2147
+ return new StreamingCompatibleResponse(body, init);
2148
+ } : (body, init) => new Response(body, init);
2149
+
2150
+ const needsHeadRenderingSymbol = Symbol.for("astro.needsHeadRendering");
2151
+ function nonAstroPageNeedsHeadInjection(pageComponent) {
2152
+ return needsHeadRenderingSymbol in pageComponent && !!pageComponent[needsHeadRenderingSymbol];
2153
+ }
2154
+ async function iterableToHTMLBytes(result, iterable, onDocTypeInjection) {
2155
+ const parts = new HTMLParts();
2156
+ let i = 0;
2157
+ for await (const chunk of iterable) {
2158
+ if (isHTMLString(chunk)) {
2159
+ if (i === 0) {
2160
+ i++;
2161
+ if (!/<!doctype html/i.test(String(chunk))) {
2162
+ parts.append("<!DOCTYPE html>\n", result);
2163
+ if (onDocTypeInjection) {
2164
+ await onDocTypeInjection(parts);
2165
+ }
2166
+ }
2167
+ }
2168
+ }
2169
+ parts.append(chunk, result);
2170
+ }
2171
+ return parts.toArrayBuffer();
2172
+ }
2173
+ async function bufferHeadContent(result) {
2174
+ const iterator = result.propagators.values();
2175
+ while (true) {
2176
+ const { value, done } = iterator.next();
2177
+ if (done) {
2178
+ break;
2179
+ }
2180
+ const returnValue = await value.init();
2181
+ if (isHeadAndContent(returnValue)) {
2182
+ result.extraHead.push(returnValue.head);
2183
+ }
2184
+ }
2185
+ }
2186
+ async function renderPage$1(result, componentFactory, props, children, streaming, route) {
2187
+ if (!isAstroComponentFactory(componentFactory)) {
2188
+ const pageProps = { ...props ?? {}, "server:root": true };
2189
+ let output;
2190
+ try {
2191
+ const renderResult = await renderComponent(
2192
+ result,
2193
+ componentFactory.name,
2194
+ componentFactory,
2195
+ pageProps,
2196
+ null
2197
+ );
2198
+ if (isAstroComponentInstance(renderResult)) {
2199
+ output = renderResult.render();
2200
+ } else {
2201
+ output = renderResult;
2202
+ }
2203
+ } catch (e) {
2204
+ if (AstroError.is(e) && !e.loc) {
2205
+ e.setLocation({
2206
+ file: route == null ? void 0 : route.component
2207
+ });
2208
+ }
2209
+ throw e;
2210
+ }
2211
+ const bytes = await iterableToHTMLBytes(result, output, async (parts) => {
2212
+ if (nonAstroPageNeedsHeadInjection(componentFactory)) {
2213
+ for await (let chunk of maybeRenderHead(result)) {
2214
+ parts.append(chunk, result);
2215
+ }
2216
+ }
2217
+ });
2218
+ return new Response(bytes, {
2219
+ headers: new Headers([
2220
+ ["Content-Type", "text/html; charset=utf-8"],
2221
+ ["Content-Length", bytes.byteLength.toString()]
2222
+ ])
2223
+ });
2224
+ }
2225
+ const factoryReturnValue = await componentFactory(result, props, children);
2226
+ const factoryIsHeadAndContent = isHeadAndContent(factoryReturnValue);
2227
+ if (isRenderTemplateResult(factoryReturnValue) || factoryIsHeadAndContent) {
2228
+ await bufferHeadContent(result);
2229
+ const templateResult = factoryIsHeadAndContent ? factoryReturnValue.content : factoryReturnValue;
2230
+ let iterable = renderAstroTemplateResult(templateResult);
2231
+ let init = result.response;
2232
+ let headers = new Headers(init.headers);
2233
+ let body;
2234
+ if (streaming) {
2235
+ body = new ReadableStream({
2236
+ start(controller) {
2237
+ async function read() {
2238
+ let i = 0;
2239
+ try {
2240
+ for await (const chunk of iterable) {
2241
+ if (isHTMLString(chunk)) {
2242
+ if (i === 0) {
2243
+ if (!/<!doctype html/i.test(String(chunk))) {
2244
+ controller.enqueue(encoder.encode("<!DOCTYPE html>\n"));
2245
+ }
2246
+ }
2247
+ }
2248
+ const bytes = chunkToByteArray(result, chunk);
2249
+ controller.enqueue(bytes);
2250
+ i++;
2251
+ }
2252
+ controller.close();
2253
+ } catch (e) {
2254
+ if (AstroError.is(e) && !e.loc) {
2255
+ e.setLocation({
2256
+ file: route == null ? void 0 : route.component
2257
+ });
2258
+ }
2259
+ controller.error(e);
2260
+ }
2261
+ }
2262
+ read();
2263
+ }
2264
+ });
2265
+ } else {
2266
+ body = await iterableToHTMLBytes(result, iterable);
2267
+ headers.set("Content-Length", body.byteLength.toString());
2268
+ }
2269
+ let response = createResponse(body, { ...init, headers });
2270
+ return response;
2271
+ }
2272
+ if (!(factoryReturnValue instanceof Response)) {
2273
+ throw new AstroError({
2274
+ ...AstroErrorData.OnlyResponseCanBeReturned,
2275
+ message: AstroErrorData.OnlyResponseCanBeReturned.message(
2276
+ route == null ? void 0 : route.route,
2277
+ typeof factoryReturnValue
2278
+ ),
2279
+ location: {
2280
+ file: route == null ? void 0 : route.component
2281
+ }
2282
+ });
2283
+ }
2284
+ return factoryReturnValue;
2285
+ }
2286
+
2287
+ function spreadAttributes(values, _name, { class: scopedClassName } = {}) {
2288
+ let output = "";
2289
+ if (scopedClassName) {
2290
+ if (typeof values.class !== "undefined") {
2291
+ values.class += ` ${scopedClassName}`;
2292
+ } else if (typeof values["class:list"] !== "undefined") {
2293
+ values["class:list"] = [values["class:list"], scopedClassName];
2294
+ } else {
2295
+ values.class = scopedClassName;
2296
+ }
2297
+ }
2298
+ for (const [key, value] of Object.entries(values)) {
2299
+ output += addAttribute(value, key, true);
2300
+ }
2301
+ return markHTMLString(output);
2302
+ }
2303
+
2304
+ const dateTimeFormat = new Intl.DateTimeFormat([], {
2305
+ hour: "2-digit",
2306
+ minute: "2-digit",
2307
+ second: "2-digit"
2308
+ });
2309
+ const levels = {
2310
+ debug: 20,
2311
+ info: 30,
2312
+ warn: 40,
2313
+ error: 50,
2314
+ silent: 90
2315
+ };
2316
+ function log(opts, level, type, message) {
2317
+ const logLevel = opts.level;
2318
+ const dest = opts.dest;
2319
+ const event = {
2320
+ type,
2321
+ level,
2322
+ message
2323
+ };
2324
+ if (levels[logLevel] > levels[level]) {
2325
+ return;
2326
+ }
2327
+ dest.write(event);
2328
+ }
2329
+ function warn(opts, type, message) {
2330
+ return log(opts, "warn", type, message);
2331
+ }
2332
+ function error(opts, type, message) {
2333
+ return log(opts, "error", type, message);
2334
+ }
2335
+ function debug(...args) {
2336
+ if ("_astroGlobalDebug" in globalThis) {
2337
+ globalThis._astroGlobalDebug(...args);
2338
+ }
2339
+ }
2340
+ if (typeof process !== "undefined") {
2341
+ let proc = process;
2342
+ if ("argv" in proc && Array.isArray(proc.argv)) {
2343
+ if (proc.argv.includes("--verbose")) ; else if (proc.argv.includes("--silent")) ; else ;
2344
+ }
2345
+ }
2346
+
2347
+ const VALID_PARAM_TYPES = ["string", "number", "undefined"];
2348
+ function validateGetStaticPathsParameter([key, value], route) {
2349
+ if (!VALID_PARAM_TYPES.includes(typeof value)) {
2350
+ throw new AstroError({
2351
+ ...AstroErrorData.GetStaticPathsInvalidRouteParam,
2352
+ message: AstroErrorData.GetStaticPathsInvalidRouteParam.message(key, value, typeof value),
2353
+ location: {
2354
+ file: route
2355
+ }
2356
+ });
2357
+ }
2358
+ }
2359
+ function validateDynamicRouteModule(mod, {
2360
+ ssr,
2361
+ logging,
2362
+ route
2363
+ }) {
2364
+ if (ssr && mod.getStaticPaths && !mod.prerender) {
2365
+ warn(logging, "getStaticPaths", 'getStaticPaths() is ignored when "output: server" is set.');
2366
+ }
2367
+ if ((!ssr || mod.prerender) && !mod.getStaticPaths) {
2368
+ throw new AstroError({
2369
+ ...AstroErrorData.GetStaticPathsRequired,
2370
+ location: { file: route.component }
2371
+ });
2372
+ }
2373
+ }
2374
+ function validateGetStaticPathsResult(result, logging, route) {
2375
+ if (!Array.isArray(result)) {
2376
+ throw new AstroError({
2377
+ ...AstroErrorData.InvalidGetStaticPathsReturn,
2378
+ message: AstroErrorData.InvalidGetStaticPathsReturn.message(typeof result),
2379
+ location: {
2380
+ file: route.component
2381
+ }
2382
+ });
2383
+ }
2384
+ result.forEach((pathObject) => {
2385
+ if (pathObject.params === void 0 || pathObject.params === null || pathObject.params && Object.keys(pathObject.params).length === 0) {
2386
+ throw new AstroError({
2387
+ ...AstroErrorData.GetStaticPathsExpectedParams,
2388
+ location: {
2389
+ file: route.component
2390
+ }
2391
+ });
2392
+ }
2393
+ if (typeof pathObject.params !== "object") {
2394
+ throw new AstroError({
2395
+ ...AstroErrorData.InvalidGetStaticPathParam,
2396
+ message: AstroErrorData.InvalidGetStaticPathParam.message(typeof pathObject.params),
2397
+ location: {
2398
+ file: route.component
2399
+ }
2400
+ });
2401
+ }
2402
+ for (const [key, val] of Object.entries(pathObject.params)) {
2403
+ if (!(typeof val === "undefined" || typeof val === "string" || typeof val === "number")) {
2404
+ warn(
2405
+ logging,
2406
+ "getStaticPaths",
2407
+ `invalid path param: ${key}. A string, number or undefined value was expected, but got \`${JSON.stringify(
2408
+ val
2409
+ )}\`.`
2410
+ );
2411
+ }
2412
+ if (typeof val === "string" && val === "") {
2413
+ warn(
2414
+ logging,
2415
+ "getStaticPaths",
2416
+ `invalid path param: ${key}. \`undefined\` expected for an optional param, but got empty string.`
2417
+ );
2418
+ }
2419
+ }
2420
+ });
2421
+ }
2422
+
2423
+ function getParams(array) {
2424
+ const fn = (match) => {
2425
+ const params = {};
2426
+ array.forEach((key, i) => {
2427
+ if (key.startsWith("...")) {
2428
+ params[key.slice(3)] = match[i + 1] ? decodeURIComponent(match[i + 1]) : void 0;
2429
+ } else {
2430
+ params[key] = decodeURIComponent(match[i + 1]);
2431
+ }
2432
+ });
2433
+ return params;
2434
+ };
2435
+ return fn;
2436
+ }
2437
+ function stringifyParams(params, routeComponent) {
2438
+ const validatedParams = Object.entries(params).reduce((acc, next) => {
2439
+ validateGetStaticPathsParameter(next, routeComponent);
2440
+ const [key, value] = next;
2441
+ acc[key] = value == null ? void 0 : value.toString();
2442
+ return acc;
2443
+ }, {});
2444
+ return JSON.stringify(validatedParams, Object.keys(params).sort());
2445
+ }
2446
+
2447
+ var __accessCheck$1 = (obj, member, msg) => {
2448
+ if (!member.has(obj))
2449
+ throw TypeError("Cannot " + msg);
2450
+ };
2451
+ var __privateGet$1 = (obj, member, getter) => {
2452
+ __accessCheck$1(obj, member, "read from private field");
2453
+ return getter ? getter.call(obj) : member.get(obj);
2454
+ };
2455
+ var __privateAdd$1 = (obj, member, value) => {
2456
+ if (member.has(obj))
2457
+ throw TypeError("Cannot add the same private member more than once");
2458
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2459
+ };
2460
+ var __privateSet$1 = (obj, member, value, setter) => {
2461
+ __accessCheck$1(obj, member, "write to private field");
2462
+ setter ? setter.call(obj, value) : member.set(obj, value);
2463
+ return value;
2464
+ };
2465
+ var _result, _slots, _loggingOpts;
2466
+ const clientAddressSymbol$2 = Symbol.for("astro.clientAddress");
2467
+ function onlyAvailableInSSR(name) {
2468
+ return function _onlyAvailableInSSR() {
2469
+ switch (name) {
2470
+ case "Astro.redirect":
2471
+ throw new AstroError(AstroErrorData.StaticRedirectNotAvailable);
2472
+ }
2473
+ };
2474
+ }
2475
+ function getFunctionExpression(slot) {
2476
+ var _a;
2477
+ if (!slot)
2478
+ return;
2479
+ if (((_a = slot.expressions) == null ? void 0 : _a.length) !== 1)
2480
+ return;
2481
+ return slot.expressions[0];
2482
+ }
2483
+ class Slots {
2484
+ constructor(result, slots, logging) {
2485
+ __privateAdd$1(this, _result, void 0);
2486
+ __privateAdd$1(this, _slots, void 0);
2487
+ __privateAdd$1(this, _loggingOpts, void 0);
2488
+ __privateSet$1(this, _result, result);
2489
+ __privateSet$1(this, _slots, slots);
2490
+ __privateSet$1(this, _loggingOpts, logging);
2491
+ if (slots) {
2492
+ for (const key of Object.keys(slots)) {
2493
+ if (this[key] !== void 0) {
2494
+ throw new AstroError({
2495
+ ...AstroErrorData.ReservedSlotName,
2496
+ message: AstroErrorData.ReservedSlotName.message(key)
2497
+ });
2498
+ }
2499
+ Object.defineProperty(this, key, {
2500
+ get() {
2501
+ return true;
2502
+ },
2503
+ enumerable: true
2504
+ });
2505
+ }
2506
+ }
2507
+ }
2508
+ has(name) {
2509
+ if (!__privateGet$1(this, _slots))
2510
+ return false;
2511
+ return Boolean(__privateGet$1(this, _slots)[name]);
2512
+ }
2513
+ async render(name, args = []) {
2514
+ if (!__privateGet$1(this, _slots) || !this.has(name))
2515
+ return;
2516
+ if (!Array.isArray(args)) {
2517
+ warn(
2518
+ __privateGet$1(this, _loggingOpts),
2519
+ "Astro.slots.render",
2520
+ `Expected second parameter to be an array, received a ${typeof args}. If you're trying to pass an array as a single argument and getting unexpected results, make sure you're passing your array as a item of an array. Ex: Astro.slots.render('default', [["Hello", "World"]])`
2521
+ );
2522
+ } else if (args.length > 0) {
2523
+ const slotValue = __privateGet$1(this, _slots)[name];
2524
+ const component = typeof slotValue === "function" ? await slotValue() : await slotValue;
2525
+ const expression = getFunctionExpression(component);
2526
+ if (expression) {
2527
+ const slot = expression(...args);
2528
+ return await renderSlot(__privateGet$1(this, _result), slot).then(
2529
+ (res) => res != null ? String(res) : res
2530
+ );
2531
+ }
2532
+ if (typeof component === "function") {
2533
+ return await renderJSX(__privateGet$1(this, _result), component(...args)).then(
2534
+ (res) => res != null ? String(res) : res
2535
+ );
2536
+ }
2537
+ }
2538
+ const content = await renderSlot(__privateGet$1(this, _result), __privateGet$1(this, _slots)[name]);
2539
+ const outHTML = stringifyChunk(__privateGet$1(this, _result), content);
2540
+ return outHTML;
2541
+ }
2542
+ }
2543
+ _result = new WeakMap();
2544
+ _slots = new WeakMap();
2545
+ _loggingOpts = new WeakMap();
2546
+ let renderMarkdown = null;
2547
+ function createResult(args) {
2548
+ const { markdown, params, pathname, renderers, request, resolve } = args;
2549
+ const url = new URL(request.url);
2550
+ const headers = new Headers();
2551
+ headers.set("Content-Type", "text/html");
2552
+ const response = {
2553
+ status: args.status,
2554
+ statusText: "OK",
2555
+ headers
2556
+ };
2557
+ Object.defineProperty(response, "headers", {
2558
+ value: response.headers,
2559
+ enumerable: true,
2560
+ writable: false
2561
+ });
2562
+ let cookies = void 0;
2563
+ const result = {
2564
+ styles: args.styles ?? /* @__PURE__ */ new Set(),
2565
+ scripts: args.scripts ?? /* @__PURE__ */ new Set(),
2566
+ links: args.links ?? /* @__PURE__ */ new Set(),
2567
+ propagation: args.propagation ?? /* @__PURE__ */ new Map(),
2568
+ propagators: /* @__PURE__ */ new Map(),
2569
+ extraHead: [],
2570
+ cookies,
2571
+ createAstro(astroGlobal, props, slots) {
2572
+ const astroSlots = new Slots(result, slots, args.logging);
2573
+ const Astro = {
2574
+ __proto__: astroGlobal,
2575
+ get clientAddress() {
2576
+ if (!(clientAddressSymbol$2 in request)) {
2577
+ if (args.adapterName) {
2578
+ throw new AstroError({
2579
+ ...AstroErrorData.ClientAddressNotAvailable,
2580
+ message: AstroErrorData.ClientAddressNotAvailable.message(args.adapterName)
2581
+ });
2582
+ } else {
2583
+ throw new AstroError(AstroErrorData.StaticClientAddressNotAvailable);
2584
+ }
2585
+ }
2586
+ return Reflect.get(request, clientAddressSymbol$2);
2587
+ },
2588
+ get cookies() {
2589
+ if (cookies) {
2590
+ return cookies;
2591
+ }
2592
+ cookies = new AstroCookies(request);
2593
+ result.cookies = cookies;
2594
+ return cookies;
2595
+ },
2596
+ params,
2597
+ props,
2598
+ request,
2599
+ url,
2600
+ redirect: args.ssr ? (path, status) => {
2601
+ return new Response(null, {
2602
+ status: status || 302,
2603
+ headers: {
2604
+ Location: path
2605
+ }
2606
+ });
2607
+ } : onlyAvailableInSSR("Astro.redirect"),
2608
+ response,
2609
+ slots: astroSlots
2610
+ };
2611
+ Object.defineProperty(Astro, "__renderMarkdown", {
2612
+ enumerable: false,
2613
+ writable: false,
2614
+ value: async function(content, opts) {
2615
+ if (typeof Deno !== "undefined") {
2616
+ throw new Error("Markdown is not supported in Deno SSR");
2617
+ }
2618
+ if (!renderMarkdown) {
2619
+ let astroRemark = "@astrojs/";
2620
+ astroRemark += "markdown-remark";
2621
+ renderMarkdown = (await import(astroRemark)).renderMarkdown;
2622
+ }
2623
+ const { code } = await renderMarkdown(content, { ...markdown, ...opts ?? {} });
2624
+ return code;
2625
+ }
2626
+ });
2627
+ return Astro;
2628
+ },
2629
+ resolve,
2630
+ _metadata: {
2631
+ renderers,
2632
+ pathname,
2633
+ hasHydrationScript: false,
2634
+ hasRenderedHead: false,
2635
+ hasDirectives: /* @__PURE__ */ new Set()
2636
+ },
2637
+ response
2638
+ };
2639
+ return result;
2640
+ }
2641
+
2642
+ function generatePaginateFunction(routeMatch) {
2643
+ return function paginateUtility(data, args = {}) {
2644
+ let { pageSize: _pageSize, params: _params, props: _props } = args;
2645
+ const pageSize = _pageSize || 10;
2646
+ const paramName = "page";
2647
+ const additionalParams = _params || {};
2648
+ const additionalProps = _props || {};
2649
+ let includesFirstPageNumber;
2650
+ if (routeMatch.params.includes(`...${paramName}`)) {
2651
+ includesFirstPageNumber = false;
2652
+ } else if (routeMatch.params.includes(`${paramName}`)) {
2653
+ includesFirstPageNumber = true;
2654
+ } else {
2655
+ throw new Error(
2656
+ `[paginate()] page number param \`${paramName}\` not found in your filepath.
2657
+ Rename your file to \`[...page].astro\` or customize the param name via the \`paginate([], {param: '...'}\` option.`
2658
+ );
2659
+ }
2660
+ const lastPage = Math.max(1, Math.ceil(data.length / pageSize));
2661
+ const result = [...Array(lastPage).keys()].map((num) => {
2662
+ const pageNum = num + 1;
2663
+ const start = pageSize === Infinity ? 0 : (pageNum - 1) * pageSize;
2664
+ const end = Math.min(start + pageSize, data.length);
2665
+ const params = {
2666
+ ...additionalParams,
2667
+ [paramName]: includesFirstPageNumber || pageNum > 1 ? String(pageNum) : void 0
2668
+ };
2669
+ return {
2670
+ params,
2671
+ props: {
2672
+ ...additionalProps,
2673
+ page: {
2674
+ data: data.slice(start, end),
2675
+ start,
2676
+ end: end - 1,
2677
+ size: pageSize,
2678
+ total: data.length,
2679
+ currentPage: pageNum,
2680
+ lastPage,
2681
+ url: {
2682
+ current: routeMatch.generate({ ...params }),
2683
+ next: pageNum === lastPage ? void 0 : routeMatch.generate({ ...params, page: String(pageNum + 1) }),
2684
+ prev: pageNum === 1 ? void 0 : routeMatch.generate({
2685
+ ...params,
2686
+ page: !includesFirstPageNumber && pageNum - 1 === 1 ? void 0 : String(pageNum - 1)
2687
+ })
2688
+ }
2689
+ }
2690
+ }
2691
+ };
2692
+ });
2693
+ return result;
2694
+ };
2695
+ }
2696
+
2697
+ async function callGetStaticPaths({
2698
+ isValidate,
2699
+ logging,
2700
+ mod,
2701
+ route,
2702
+ ssr
2703
+ }) {
2704
+ validateDynamicRouteModule(mod, { ssr, logging, route });
2705
+ if (ssr && !mod.prerender) {
2706
+ return { staticPaths: Object.assign([], { keyed: /* @__PURE__ */ new Map() }) };
2707
+ }
2708
+ if (!mod.getStaticPaths) {
2709
+ throw new Error("Unexpected Error.");
2710
+ }
2711
+ let staticPaths = [];
2712
+ staticPaths = await mod.getStaticPaths({
2713
+ paginate: generatePaginateFunction(route),
2714
+ rss() {
2715
+ throw new AstroError(AstroErrorData.GetStaticPathsRemovedRSSHelper);
2716
+ }
2717
+ });
2718
+ if (Array.isArray(staticPaths)) {
2719
+ staticPaths = staticPaths.flat();
2720
+ }
2721
+ if (isValidate) {
2722
+ validateGetStaticPathsResult(staticPaths, logging, route);
2723
+ }
2724
+ const keyedStaticPaths = staticPaths;
2725
+ keyedStaticPaths.keyed = /* @__PURE__ */ new Map();
2726
+ for (const sp of keyedStaticPaths) {
2727
+ const paramsKey = stringifyParams(sp.params, route.component);
2728
+ keyedStaticPaths.keyed.set(paramsKey, sp);
2729
+ }
2730
+ return {
2731
+ staticPaths: keyedStaticPaths
2732
+ };
2733
+ }
2734
+ class RouteCache {
2735
+ constructor(logging, mode = "production") {
2736
+ this.cache = {};
2737
+ this.logging = logging;
2738
+ this.mode = mode;
2739
+ }
2740
+ clearAll() {
2741
+ this.cache = {};
2742
+ }
2743
+ set(route, entry) {
2744
+ if (this.mode === "production" && this.cache[route.component]) {
2745
+ warn(
2746
+ this.logging,
2747
+ "routeCache",
2748
+ `Internal Warning: route cache overwritten. (${route.component})`
2749
+ );
2750
+ }
2751
+ this.cache[route.component] = entry;
2752
+ }
2753
+ get(route) {
2754
+ return this.cache[route.component];
2755
+ }
2756
+ }
2757
+ function findPathItemByKey(staticPaths, params, route) {
2758
+ const paramsKey = stringifyParams(params, route.component);
2759
+ const matchedStaticPath = staticPaths.keyed.get(paramsKey);
2760
+ if (matchedStaticPath) {
2761
+ return matchedStaticPath;
2762
+ }
2763
+ debug("findPathItemByKey", `Unexpected cache miss looking for ${paramsKey}`);
2764
+ }
2765
+
2766
+ var GetParamsAndPropsError = /* @__PURE__ */ ((GetParamsAndPropsError2) => {
2767
+ GetParamsAndPropsError2[GetParamsAndPropsError2["NoMatchingStaticPath"] = 0] = "NoMatchingStaticPath";
2768
+ return GetParamsAndPropsError2;
2769
+ })(GetParamsAndPropsError || {});
2770
+ async function getParamsAndProps(opts) {
2771
+ const { logging, mod, route, routeCache, pathname, ssr } = opts;
2772
+ let params = {};
2773
+ let pageProps;
2774
+ if (route && !route.pathname) {
2775
+ if (route.params.length) {
2776
+ const paramsMatch = route.pattern.exec(pathname);
2777
+ if (paramsMatch) {
2778
+ params = getParams(route.params)(paramsMatch);
2779
+ }
2780
+ }
2781
+ let routeCacheEntry = routeCache.get(route);
2782
+ if (!routeCacheEntry) {
2783
+ routeCacheEntry = await callGetStaticPaths({ mod, route, isValidate: true, logging, ssr });
2784
+ routeCache.set(route, routeCacheEntry);
2785
+ }
2786
+ const matchedStaticPath = findPathItemByKey(routeCacheEntry.staticPaths, params, route);
2787
+ if (!matchedStaticPath && (ssr ? mod.prerender : true)) {
2788
+ return 0 /* NoMatchingStaticPath */;
2789
+ }
2790
+ pageProps = (matchedStaticPath == null ? void 0 : matchedStaticPath.props) ? { ...matchedStaticPath.props } : {};
2791
+ } else {
2792
+ pageProps = {};
2793
+ }
2794
+ return [params, pageProps];
2795
+ }
2796
+ async function renderPage(mod, ctx, env) {
2797
+ var _a, _b;
2798
+ const paramsAndPropsRes = await getParamsAndProps({
2799
+ logging: env.logging,
2800
+ mod,
2801
+ route: ctx.route,
2802
+ routeCache: env.routeCache,
2803
+ pathname: ctx.pathname,
2804
+ ssr: env.ssr
2805
+ });
2806
+ if (paramsAndPropsRes === 0 /* NoMatchingStaticPath */) {
2807
+ throw new AstroError({
2808
+ ...AstroErrorData.NoMatchingStaticPathFound,
2809
+ message: AstroErrorData.NoMatchingStaticPathFound.message(ctx.pathname),
2810
+ hint: ((_a = ctx.route) == null ? void 0 : _a.component) ? AstroErrorData.NoMatchingStaticPathFound.hint([(_b = ctx.route) == null ? void 0 : _b.component]) : ""
2811
+ });
2812
+ }
2813
+ const [params, pageProps] = paramsAndPropsRes;
2814
+ const Component = mod.default;
2815
+ if (!Component)
2816
+ throw new Error(`Expected an exported Astro component but received typeof ${typeof Component}`);
2817
+ const result = createResult({
2818
+ adapterName: env.adapterName,
2819
+ links: ctx.links,
2820
+ styles: ctx.styles,
2821
+ logging: env.logging,
2822
+ markdown: env.markdown,
2823
+ mode: env.mode,
2824
+ origin: ctx.origin,
2825
+ params,
2826
+ props: pageProps,
2827
+ pathname: ctx.pathname,
2828
+ propagation: ctx.propagation,
2829
+ resolve: env.resolve,
2830
+ renderers: env.renderers,
2831
+ request: ctx.request,
2832
+ site: env.site,
2833
+ scripts: ctx.scripts,
2834
+ ssr: env.ssr,
2835
+ status: ctx.status ?? 200
2836
+ });
2837
+ if (typeof mod.components === "object") {
2838
+ Object.assign(pageProps, { components: mod.components });
2839
+ }
2840
+ const response = await renderPage$1(
2841
+ result,
2842
+ Component,
2843
+ pageProps,
2844
+ null,
2845
+ env.streaming,
2846
+ ctx.route
2847
+ );
2848
+ if (result.cookies) {
2849
+ attachToResponse(response, result.cookies);
2850
+ }
2851
+ return response;
2852
+ }
2853
+
2854
+ const clientAddressSymbol$1 = Symbol.for("astro.clientAddress");
2855
+ function createAPIContext({
2856
+ request,
2857
+ params,
2858
+ site,
2859
+ props,
2860
+ adapterName
2861
+ }) {
2862
+ return {
2863
+ cookies: new AstroCookies(request),
2864
+ request,
2865
+ params,
2866
+ site: site ? new URL(site) : void 0,
2867
+ generator: `Astro v${ASTRO_VERSION}`,
2868
+ props,
2869
+ redirect(path, status) {
2870
+ return new Response(null, {
2871
+ status: status || 302,
2872
+ headers: {
2873
+ Location: path
2874
+ }
2875
+ });
2876
+ },
2877
+ url: new URL(request.url),
2878
+ get clientAddress() {
2879
+ if (!(clientAddressSymbol$1 in request)) {
2880
+ if (adapterName) {
2881
+ throw new AstroError({
2882
+ ...AstroErrorData.ClientAddressNotAvailable,
2883
+ message: AstroErrorData.ClientAddressNotAvailable.message(adapterName)
2884
+ });
2885
+ } else {
2886
+ throw new AstroError(AstroErrorData.StaticClientAddressNotAvailable);
2887
+ }
2888
+ }
2889
+ return Reflect.get(request, clientAddressSymbol$1);
2890
+ }
2891
+ };
2892
+ }
2893
+ async function call(mod, env, ctx) {
2894
+ var _a, _b;
2895
+ const paramsAndPropsResp = await getParamsAndProps({
2896
+ mod,
2897
+ route: ctx.route,
2898
+ routeCache: env.routeCache,
2899
+ pathname: ctx.pathname,
2900
+ logging: env.logging,
2901
+ ssr: env.ssr
2902
+ });
2903
+ if (paramsAndPropsResp === GetParamsAndPropsError.NoMatchingStaticPath) {
2904
+ throw new AstroError({
2905
+ ...AstroErrorData.NoMatchingStaticPathFound,
2906
+ message: AstroErrorData.NoMatchingStaticPathFound.message(ctx.pathname),
2907
+ hint: ((_a = ctx.route) == null ? void 0 : _a.component) ? AstroErrorData.NoMatchingStaticPathFound.hint([(_b = ctx.route) == null ? void 0 : _b.component]) : ""
2908
+ });
2909
+ }
2910
+ const [params, props] = paramsAndPropsResp;
2911
+ const context = createAPIContext({
2912
+ request: ctx.request,
2913
+ params,
2914
+ props,
2915
+ site: env.site,
2916
+ adapterName: env.adapterName
2917
+ });
2918
+ const response = await renderEndpoint(mod, context, env.ssr);
2919
+ if (response instanceof Response) {
2920
+ attachToResponse(response, context.cookies);
2921
+ return {
2922
+ type: "response",
2923
+ response
2924
+ };
2925
+ }
2926
+ return {
2927
+ type: "simple",
2928
+ body: response.body,
2929
+ encoding: response.encoding,
2930
+ cookies: context.cookies
2931
+ };
2932
+ }
2933
+
2934
+ let lastMessage;
2935
+ let lastMessageCount = 1;
2936
+ const consoleLogDestination = {
2937
+ write(event) {
2938
+ let dest = console.error;
2939
+ if (levels[event.level] < levels["error"]) {
2940
+ dest = console.log;
2941
+ }
2942
+ function getPrefix() {
2943
+ let prefix = "";
2944
+ let type = event.type;
2945
+ if (type) {
2946
+ prefix += dim(dateTimeFormat.format(new Date()) + " ");
2947
+ if (event.level === "info") {
2948
+ type = bold(cyan(`[${type}]`));
2949
+ } else if (event.level === "warn") {
2950
+ type = bold(yellow(`[${type}]`));
2951
+ } else if (event.level === "error") {
2952
+ type = bold(red(`[${type}]`));
2953
+ }
2954
+ prefix += `${type} `;
2955
+ }
2956
+ return reset(prefix);
2957
+ }
2958
+ let message = event.message;
2959
+ if (message === lastMessage) {
2960
+ lastMessageCount++;
2961
+ message = `${message} ${yellow(`(x${lastMessageCount})`)}`;
2962
+ } else {
2963
+ lastMessage = message;
2964
+ lastMessageCount = 1;
2965
+ }
2966
+ const outMessage = getPrefix() + message;
2967
+ dest(outMessage);
2968
+ return true;
2969
+ }
2970
+ };
2971
+
2972
+ function appendForwardSlash(path) {
2973
+ return path.endsWith("/") ? path : path + "/";
2974
+ }
2975
+ function prependForwardSlash(path) {
2976
+ return path[0] === "/" ? path : "/" + path;
2977
+ }
2978
+ function removeTrailingForwardSlash(path) {
2979
+ return path.endsWith("/") ? path.slice(0, path.length - 1) : path;
2980
+ }
2981
+ function removeLeadingForwardSlash(path) {
2982
+ return path.startsWith("/") ? path.substring(1) : path;
2983
+ }
2984
+ function trimSlashes(path) {
2985
+ return path.replace(/^\/|\/$/g, "");
2986
+ }
2987
+ function isString(path) {
2988
+ return typeof path === "string" || path instanceof String;
2989
+ }
2990
+ function joinPaths(...paths) {
2991
+ return paths.filter(isString).map(trimSlashes).join("/");
2992
+ }
2993
+
2994
+ function createRenderContext(options) {
2995
+ const request = options.request;
2996
+ const url = new URL(request.url);
2997
+ const origin = options.origin ?? url.origin;
2998
+ const pathname = options.pathname ?? url.pathname;
2999
+ return {
3000
+ ...options,
3001
+ origin,
3002
+ pathname,
3003
+ url
3004
+ };
3005
+ }
3006
+
3007
+ function createEnvironment(options) {
3008
+ return options;
3009
+ }
3010
+
3011
+ function getRootPath(base) {
3012
+ return appendForwardSlash(new URL(base || "/", "http://localhost/").pathname);
3013
+ }
3014
+ function joinToRoot(href, base) {
3015
+ const rootPath = getRootPath(base);
3016
+ const normalizedHref = slashify(href);
3017
+ return appendForwardSlash(rootPath) + removeLeadingForwardSlash(normalizedHref);
3018
+ }
3019
+ function createLinkStylesheetElement(href, base) {
3020
+ return {
3021
+ props: {
3022
+ rel: "stylesheet",
3023
+ href: joinToRoot(href, base)
3024
+ },
3025
+ children: ""
3026
+ };
3027
+ }
3028
+ function createLinkStylesheetElementSet(hrefs, base) {
3029
+ return new Set(hrefs.map((href) => createLinkStylesheetElement(href, base)));
3030
+ }
3031
+ function createModuleScriptElement(script, base) {
3032
+ if (script.type === "external") {
3033
+ return createModuleScriptElementWithSrc(script.value, base);
3034
+ } else {
3035
+ return {
3036
+ props: {
3037
+ type: "module"
3038
+ },
3039
+ children: script.value
3040
+ };
3041
+ }
3042
+ }
3043
+ function createModuleScriptElementWithSrc(src, site) {
3044
+ return {
3045
+ props: {
3046
+ type: "module",
3047
+ src: joinToRoot(src, site)
3048
+ },
3049
+ children: ""
3050
+ };
3051
+ }
3052
+
3053
+ function matchRoute(pathname, manifest) {
3054
+ return manifest.routes.find((route) => route.pattern.test(decodeURI(pathname)));
3055
+ }
3056
+ function matchAssets(route, assets) {
3057
+ for (const asset of assets) {
3058
+ if (!asset.endsWith(".html"))
3059
+ continue;
3060
+ if (route.pattern.test(asset)) {
3061
+ return asset;
3062
+ }
3063
+ if (route.pattern.test(asset.replace(/index\.html$/, ""))) {
3064
+ return asset;
3065
+ }
3066
+ }
3067
+ }
3068
+
3069
+ var __accessCheck = (obj, member, msg) => {
3070
+ if (!member.has(obj))
3071
+ throw TypeError("Cannot " + msg);
3072
+ };
3073
+ var __privateGet = (obj, member, getter) => {
3074
+ __accessCheck(obj, member, "read from private field");
3075
+ return getter ? getter.call(obj) : member.get(obj);
3076
+ };
3077
+ var __privateAdd = (obj, member, value) => {
3078
+ if (member.has(obj))
3079
+ throw TypeError("Cannot add the same private member more than once");
3080
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
3081
+ };
3082
+ var __privateSet = (obj, member, value, setter) => {
3083
+ __accessCheck(obj, member, "write to private field");
3084
+ setter ? setter.call(obj, value) : member.set(obj, value);
3085
+ return value;
3086
+ };
3087
+ var __privateMethod = (obj, member, method) => {
3088
+ __accessCheck(obj, member, "access private method");
3089
+ return method;
3090
+ };
3091
+ var _env, _manifest, _manifestData, _routeDataToRouteInfo, _encoder, _logging, _base, _baseWithoutTrailingSlash, _renderPage, renderPage_fn, _callEndpoint, callEndpoint_fn;
3092
+ class App {
3093
+ constructor(manifest, streaming = true) {
3094
+ __privateAdd(this, _renderPage);
3095
+ __privateAdd(this, _callEndpoint);
3096
+ __privateAdd(this, _env, void 0);
3097
+ __privateAdd(this, _manifest, void 0);
3098
+ __privateAdd(this, _manifestData, void 0);
3099
+ __privateAdd(this, _routeDataToRouteInfo, void 0);
3100
+ __privateAdd(this, _encoder, new TextEncoder());
3101
+ __privateAdd(this, _logging, {
3102
+ dest: consoleLogDestination,
3103
+ level: "info"
3104
+ });
3105
+ __privateAdd(this, _base, void 0);
3106
+ __privateAdd(this, _baseWithoutTrailingSlash, void 0);
3107
+ __privateSet(this, _manifest, manifest);
3108
+ __privateSet(this, _manifestData, {
3109
+ routes: manifest.routes.map((route) => route.routeData)
3110
+ });
3111
+ __privateSet(this, _routeDataToRouteInfo, new Map(manifest.routes.map((route) => [route.routeData, route])));
3112
+ __privateSet(this, _env, createEnvironment({
3113
+ adapterName: manifest.adapterName,
3114
+ logging: __privateGet(this, _logging),
3115
+ markdown: manifest.markdown,
3116
+ mode: "production",
3117
+ renderers: manifest.renderers,
3118
+ async resolve(specifier) {
3119
+ if (!(specifier in manifest.entryModules)) {
3120
+ throw new Error(`Unable to resolve [${specifier}]`);
3121
+ }
3122
+ const bundlePath = manifest.entryModules[specifier];
3123
+ switch (true) {
3124
+ case bundlePath.startsWith("data:"):
3125
+ case bundlePath.length === 0: {
3126
+ return bundlePath;
3127
+ }
3128
+ default: {
3129
+ return prependForwardSlash(joinPaths(manifest.base, bundlePath));
3130
+ }
3131
+ }
3132
+ },
3133
+ routeCache: new RouteCache(__privateGet(this, _logging)),
3134
+ site: __privateGet(this, _manifest).site,
3135
+ ssr: true,
3136
+ streaming
3137
+ }));
3138
+ __privateSet(this, _base, __privateGet(this, _manifest).base || "/");
3139
+ __privateSet(this, _baseWithoutTrailingSlash, removeTrailingForwardSlash(__privateGet(this, _base)));
3140
+ }
3141
+ removeBase(pathname) {
3142
+ if (pathname.startsWith(__privateGet(this, _base))) {
3143
+ return pathname.slice(__privateGet(this, _baseWithoutTrailingSlash).length + 1);
3144
+ }
3145
+ return pathname;
3146
+ }
3147
+ match(request, { matchNotFound = false } = {}) {
3148
+ const url = new URL(request.url);
3149
+ if (__privateGet(this, _manifest).assets.has(url.pathname)) {
3150
+ return void 0;
3151
+ }
3152
+ let pathname = "/" + this.removeBase(url.pathname);
3153
+ let routeData = matchRoute(pathname, __privateGet(this, _manifestData));
3154
+ if (routeData) {
3155
+ const asset = matchAssets(routeData, __privateGet(this, _manifest).assets);
3156
+ if (asset)
3157
+ return void 0;
3158
+ return routeData;
3159
+ } else if (matchNotFound) {
3160
+ return matchRoute("/404", __privateGet(this, _manifestData));
3161
+ } else {
3162
+ return void 0;
3163
+ }
3164
+ }
3165
+ async render(request, routeData) {
3166
+ let defaultStatus = 200;
3167
+ if (!routeData) {
3168
+ routeData = this.match(request);
3169
+ if (!routeData) {
3170
+ defaultStatus = 404;
3171
+ routeData = this.match(request, { matchNotFound: true });
3172
+ }
3173
+ if (!routeData) {
3174
+ return new Response(null, {
3175
+ status: 404,
3176
+ statusText: "Not found"
3177
+ });
3178
+ }
3179
+ }
3180
+ if (routeData.route === "/404") {
3181
+ defaultStatus = 404;
3182
+ }
3183
+ let mod = __privateGet(this, _manifest).pageMap.get(routeData.component);
3184
+ if (routeData.type === "page") {
3185
+ let response = await __privateMethod(this, _renderPage, renderPage_fn).call(this, request, routeData, mod, defaultStatus);
3186
+ if (response.status === 500) {
3187
+ const fiveHundredRouteData = matchRoute("/500", __privateGet(this, _manifestData));
3188
+ if (fiveHundredRouteData) {
3189
+ mod = __privateGet(this, _manifest).pageMap.get(fiveHundredRouteData.component);
3190
+ try {
3191
+ let fiveHundredResponse = await __privateMethod(this, _renderPage, renderPage_fn).call(this, request, fiveHundredRouteData, mod, 500);
3192
+ return fiveHundredResponse;
3193
+ } catch {
3194
+ }
3195
+ }
3196
+ }
3197
+ return response;
3198
+ } else if (routeData.type === "endpoint") {
3199
+ return __privateMethod(this, _callEndpoint, callEndpoint_fn).call(this, request, routeData, mod, defaultStatus);
3200
+ } else {
3201
+ throw new Error(`Unsupported route type [${routeData.type}].`);
3202
+ }
3203
+ }
3204
+ setCookieHeaders(response) {
3205
+ return getSetCookiesFromResponse(response);
3206
+ }
3207
+ }
3208
+ _env = new WeakMap();
3209
+ _manifest = new WeakMap();
3210
+ _manifestData = new WeakMap();
3211
+ _routeDataToRouteInfo = new WeakMap();
3212
+ _encoder = new WeakMap();
3213
+ _logging = new WeakMap();
3214
+ _base = new WeakMap();
3215
+ _baseWithoutTrailingSlash = new WeakMap();
3216
+ _renderPage = new WeakSet();
3217
+ renderPage_fn = async function(request, routeData, mod, status = 200) {
3218
+ const url = new URL(request.url);
3219
+ const pathname = "/" + this.removeBase(url.pathname);
3220
+ const info = __privateGet(this, _routeDataToRouteInfo).get(routeData);
3221
+ const links = createLinkStylesheetElementSet(info.links);
3222
+ let scripts = /* @__PURE__ */ new Set();
3223
+ for (const script of info.scripts) {
3224
+ if ("stage" in script) {
3225
+ if (script.stage === "head-inline") {
3226
+ scripts.add({
3227
+ props: {},
3228
+ children: script.children
3229
+ });
3230
+ }
3231
+ } else {
3232
+ scripts.add(createModuleScriptElement(script));
3233
+ }
3234
+ }
3235
+ try {
3236
+ const ctx = createRenderContext({
3237
+ request,
3238
+ origin: url.origin,
3239
+ pathname,
3240
+ scripts,
3241
+ links,
3242
+ route: routeData,
3243
+ status
3244
+ });
3245
+ const response = await renderPage(mod, ctx, __privateGet(this, _env));
3246
+ return response;
3247
+ } catch (err) {
3248
+ error(__privateGet(this, _logging), "ssr", err.stack || err.message || String(err));
3249
+ return new Response(null, {
3250
+ status: 500,
3251
+ statusText: "Internal server error"
3252
+ });
3253
+ }
3254
+ };
3255
+ _callEndpoint = new WeakSet();
3256
+ callEndpoint_fn = async function(request, routeData, mod, status = 200) {
3257
+ const url = new URL(request.url);
3258
+ const pathname = "/" + this.removeBase(url.pathname);
3259
+ const handler = mod;
3260
+ const ctx = createRenderContext({
3261
+ request,
3262
+ origin: url.origin,
3263
+ pathname,
3264
+ route: routeData,
3265
+ status
3266
+ });
3267
+ const result = await call(handler, __privateGet(this, _env), ctx);
3268
+ if (result.type === "response") {
3269
+ if (result.response.headers.get("X-Astro-Response") === "Not-Found") {
3270
+ const fourOhFourRequest = new Request(new URL("/404", request.url));
3271
+ const fourOhFourRouteData = this.match(fourOhFourRequest);
3272
+ if (fourOhFourRouteData) {
3273
+ return this.render(fourOhFourRequest, fourOhFourRouteData);
3274
+ }
3275
+ }
3276
+ return result.response;
3277
+ } else {
3278
+ const body = result.body;
3279
+ const headers = new Headers();
3280
+ const mimeType = mime.getType(url.pathname);
3281
+ if (mimeType) {
3282
+ headers.set("Content-Type", `${mimeType};charset=utf-8`);
3283
+ } else {
3284
+ headers.set("Content-Type", "text/plain;charset=utf-8");
3285
+ }
3286
+ const bytes = __privateGet(this, _encoder).encode(body);
3287
+ headers.set("Content-Length", bytes.byteLength.toString());
3288
+ const response = new Response(bytes, {
3289
+ status: 200,
3290
+ headers
3291
+ });
3292
+ attachToResponse(response, result.cookies);
3293
+ return response;
3294
+ }
3295
+ };
3296
+
3297
+ const clientAddressSymbol = Symbol.for("astro.clientAddress");
3298
+ function createRequestFromNodeRequest(req, body) {
3299
+ var _a;
3300
+ const protocol = req.socket instanceof TLSSocket || req.headers["x-forwarded-proto"] === "https" ? "https" : "http";
3301
+ let url = `${protocol}://${req.headers.host}${req.url}`;
3302
+ let rawHeaders = req.headers;
3303
+ const entries = Object.entries(rawHeaders);
3304
+ const method = req.method || "GET";
3305
+ let request = new Request(url, {
3306
+ method,
3307
+ headers: new Headers(entries),
3308
+ body: ["HEAD", "GET"].includes(method) ? null : body
3309
+ });
3310
+ if ((_a = req.socket) == null ? void 0 : _a.remoteAddress) {
3311
+ Reflect.set(request, clientAddressSymbol, req.socket.remoteAddress);
3312
+ }
3313
+ return request;
3314
+ }
3315
+ class NodeApp extends App {
3316
+ match(req, opts = {}) {
3317
+ return super.match(req instanceof Request ? req : createRequestFromNodeRequest(req), opts);
3318
+ }
3319
+ render(req, routeData) {
3320
+ if ("on" in req) {
3321
+ let body = Buffer.from([]);
3322
+ let reqBodyComplete = new Promise((resolve, reject) => {
3323
+ req.on("data", (d) => {
3324
+ body = Buffer.concat([body, d]);
3325
+ });
3326
+ req.on("end", () => {
3327
+ resolve(body);
3328
+ });
3329
+ req.on("error", (err) => {
3330
+ reject(err);
3331
+ });
3332
+ });
3333
+ return reqBodyComplete.then(() => {
3334
+ return super.render(
3335
+ req instanceof Request ? req : createRequestFromNodeRequest(req, body),
3336
+ routeData
3337
+ );
3338
+ });
3339
+ }
3340
+ return super.render(
3341
+ req instanceof Request ? req : createRequestFromNodeRequest(req),
3342
+ routeData
3343
+ );
3344
+ }
3345
+ }
3346
+
3347
+ const slotName = (str) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
3348
+ async function check(Component, props, { default: children = null, ...slotted } = {}) {
3349
+ if (typeof Component !== "function")
3350
+ return false;
3351
+ const slots = {};
3352
+ for (const [key, value] of Object.entries(slotted)) {
3353
+ const name = slotName(key);
3354
+ slots[name] = value;
3355
+ }
3356
+ try {
3357
+ const result = await Component({ ...props, ...slots, children });
3358
+ return result[AstroJSX];
3359
+ } catch (e) {
3360
+ }
3361
+ return false;
3362
+ }
3363
+ async function renderToStaticMarkup(Component, props = {}, { default: children = null, ...slotted } = {}) {
3364
+ const slots = {};
3365
+ for (const [key, value] of Object.entries(slotted)) {
3366
+ const name = slotName(key);
3367
+ slots[name] = value;
3368
+ }
3369
+ const { result } = this;
3370
+ const html = await renderJSX(result, createVNode(Component, { ...props, ...slots, children }));
3371
+ return { html };
3372
+ }
3373
+ var server_default = {
3374
+ check,
3375
+ renderToStaticMarkup
3376
+ };
3377
+
3378
+ export { Fragment as F, NodeApp as N, createComponent as a, addAttribute as b, createAstro as c, renderComponent as d, renderSlot as e, renderHead as f, server_default as g, deserializeManifest as h, maybeRenderHead as m, renderTemplate as r, spreadAttributes as s, unescapeHTML as u };