@tdacorp/hyle-sdk 0.21.0 → 0.22.2

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 (58) hide show
  1. package/README.md +110 -18
  2. package/dist/check-routes-bin.js +154 -42
  3. package/dist/{chunk-X2TLYM7Y.js → chunk-7T5EEJHK.js} +1 -1
  4. package/dist/chunk-DUPT6XLB.js +57 -0
  5. package/dist/{chunk-56Y24XBV.js → chunk-IW3TUD4G.js} +4 -3
  6. package/dist/{chunk-75JFLML4.js → chunk-KU7LWK4E.js} +75 -12
  7. package/dist/{chunk-K5VDLROQ.js → chunk-SFFBZFEN.js} +34 -1
  8. package/dist/{chunk-HJX57NLI.js → chunk-ZIW6FDU2.js} +246 -225
  9. package/dist/{client-LwzHwqpM.d.ts → client-BGjmEWhN.d.cts} +7 -1
  10. package/dist/{client-41fU6OY2.d.cts → client-D0LTpr3Y.d.ts} +7 -1
  11. package/dist/code-copy.cjs +4 -2
  12. package/dist/code-copy.d.cts +5 -2
  13. package/dist/code-copy.d.ts +5 -2
  14. package/dist/code-copy.js +5 -3
  15. package/dist/comments.cjs +11 -6
  16. package/dist/comments.js +11 -6
  17. package/dist/docs-enhance.cjs +7 -4
  18. package/dist/docs-enhance.d.cts +5 -3
  19. package/dist/docs-enhance.d.ts +5 -3
  20. package/dist/docs-enhance.js +8 -5
  21. package/dist/{embed-BUFRQboD.d.ts → embed-CbtsbZs3.d.cts} +4 -2
  22. package/dist/{embed-CYt-q13P.d.cts → embed-Cf_2ZR5x.d.ts} +4 -2
  23. package/dist/html.cjs +11 -6
  24. package/dist/html.d.cts +1 -1
  25. package/dist/html.d.ts +1 -1
  26. package/dist/html.js +2 -2
  27. package/dist/index.cjs +65 -12
  28. package/dist/index.d.cts +13 -11
  29. package/dist/index.d.ts +13 -11
  30. package/dist/index.js +2 -2
  31. package/dist/mermaid-diagram.cjs +46 -6
  32. package/dist/mermaid-diagram.js +15 -6
  33. package/dist/mermaid-image.cjs +4 -1
  34. package/dist/mermaid-image.js +1 -1
  35. package/dist/next.cjs +410 -241
  36. package/dist/next.d.cts +39 -17
  37. package/dist/next.d.ts +39 -17
  38. package/dist/next.js +116 -32
  39. package/dist/print-coordinator.js +1 -1
  40. package/dist/react.cjs +230 -197
  41. package/dist/react.d.cts +17 -6
  42. package/dist/react.d.ts +17 -6
  43. package/dist/react.js +5 -3
  44. package/dist/{resolve-eI1muCKL.d.cts → resolve-BnIv7aB7.d.cts} +1 -1
  45. package/dist/{resolve-BjAK0k_Y.d.ts → resolve-BysHtZ_i.d.ts} +1 -1
  46. package/dist/{sanitize-ijiWjEm9.d.cts → sanitize-BpY_AdZh.d.cts} +1 -1
  47. package/dist/{sanitize-ijiWjEm9.d.ts → sanitize-BpY_AdZh.d.ts} +1 -1
  48. package/dist/styles.css +4 -4
  49. package/dist/toc-spy.cjs +2 -1
  50. package/dist/toc-spy.js +2 -1
  51. package/dist/{types-3F0wqD-o.d.cts → types-D09Z072G.d.cts} +32 -1
  52. package/dist/{types-3F0wqD-o.d.ts → types-D09Z072G.d.ts} +32 -1
  53. package/dist/use-cache.cjs +53 -3
  54. package/dist/use-cache.d.cts +3 -3
  55. package/dist/use-cache.d.ts +3 -3
  56. package/dist/use-cache.js +3 -3
  57. package/package.json +3 -3
  58. package/dist/chunk-67IOIAVW.js +0 -35
package/dist/next.cjs CHANGED
@@ -37,6 +37,8 @@ __export(next_exports, {
37
37
  hyleFeedLink: () => hyleFeedLink,
38
38
  hyleMetadata: () => hyleMetadata,
39
39
  hylePage: () => hylePage,
40
+ hylePreviewMetadata: () => hylePreviewMetadata,
41
+ hylePreviewPage: () => hylePreviewPage,
40
42
  hyleRootMetadata: () => hyleRootMetadata,
41
43
  hyleRootPage: () => hyleRootPage,
42
44
  hyleRootSitemap: () => hyleRootSitemap,
@@ -52,12 +54,26 @@ var import_navigation3 = require("next/navigation");
52
54
  // src/asset-path.ts
53
55
  var ASSET_ROUTE_PREFIX = "/api/hyle/assets";
54
56
  var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
55
- var EXTENSIONS = "png|jpg|gif|webp|svg|pdf|mp4|webm|mp3|ogg";
57
+ var EXTENSIONS = "png|jpg|gif|webp|svg|pdf|mp4|webm|mp3|ogg|woff2";
56
58
  var ASSET_FILE = new RegExp(`^${UUID}(?:\\.(?:${EXTENSIONS}))?$`);
57
- var HYLE_ASSET_URL = new RegExp(`^/assets/(${UUID}(?:\\.(?:${EXTENSIONS}))?)$`, "i");
59
+ var THEME_FILE = /^theme-([0-9a-f]{16})-([0-9a-f]{64})\.css$/;
60
+ var THEME_FONT = new RegExp(`^/assets/${UUID}\\.woff2$`);
61
+ function themeStylesheetHref({ scope, hash }) {
62
+ const file = `theme-${scope}-${hash}.css`;
63
+ return THEME_FILE.test(file) ? `${ASSET_ROUTE_PREFIX}/${file}` : void 0;
64
+ }
65
+ function themeFontHrefs(preload) {
66
+ return preload.flatMap((src) => typeof src === "string" && THEME_FONT.test(src) ? [hostAssetSrc(src)] : []);
67
+ }
68
+ var PREVIEW_TOKEN_SOURCE = "hyle_pv_[A-Za-z0-9_-]{43}";
69
+ var PREVIEW_TOKEN = new RegExp(`^${PREVIEW_TOKEN_SOURCE}$`);
70
+ var PREVIEW_HEADER = "cp-preview";
71
+ var PREVIEW_PARAM = "hyle_preview";
72
+ var PREVIEW_QUERY_SOURCE = `\\?${PREVIEW_PARAM}=${PREVIEW_TOKEN_SOURCE}`;
73
+ var HYLE_ASSET_URL = new RegExp(`^/assets/(${UUID}(?:\\.(?:${EXTENSIONS}))?)(${PREVIEW_QUERY_SOURCE})?$`, "i");
58
74
  function hostAssetSrc(src) {
59
- const file = HYLE_ASSET_URL.exec(src)?.[1];
60
- return file ? `${ASSET_ROUTE_PREFIX}/${file.toLowerCase()}` : src;
75
+ const [, file, query = ""] = HYLE_ASSET_URL.exec(src) ?? [];
76
+ return file ? `${ASSET_ROUTE_PREFIX}/${file.toLowerCase()}${query}` : src;
61
77
  }
62
78
  function hostAssetHtml(html) {
63
79
  return html.replace(new RegExp(`(\\ssrc=")(/assets/${UUID}(?:\\.(?:${EXTENSIONS}))?)(")`, "gi"), (_m, open, url, close) => `${open}${hostAssetSrc(url)}${close}`);
@@ -72,7 +88,8 @@ var ASSET_CONTENT_TYPES = /* @__PURE__ */ new Set([
72
88
  "video/mp4",
73
89
  "video/webm",
74
90
  "audio/mpeg",
75
- "audio/ogg"
91
+ "audio/ogg",
92
+ "font/woff2"
76
93
  ]);
77
94
 
78
95
  // src/errors.ts
@@ -91,6 +108,30 @@ var Cp1ClientError = class extends Error {
91
108
  }
92
109
  };
93
110
 
111
+ // src/preview.ts
112
+ var ASSET_PATH = /^\/assets\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?:\.[a-z0-9]+)?(?= |$)/i;
113
+ var ASSET_PROPERTIES = ["src", "dataLight", "dataDark"];
114
+ var MAX_DEPTH = 200;
115
+ function mapNode(node, mark, depth) {
116
+ if (typeof node !== "object" || node === null || depth > MAX_DEPTH) return node;
117
+ const { properties, children } = node;
118
+ const marked = properties && Object.fromEntries(ASSET_PROPERTIES.filter((name) => name in properties).map((name) => [name, mark(properties[name])]));
119
+ return {
120
+ ...node,
121
+ ...properties ? { properties: { ...properties, ...marked } } : {},
122
+ ...Array.isArray(children) ? { children: children.map((child) => mapNode(child, mark, depth + 1)) } : {}
123
+ };
124
+ }
125
+ function withPreviewAssets(article, token) {
126
+ const mark = (value) => typeof value === "string" ? value.replace(ASSET_PATH, (path) => `${path}?${PREVIEW_PARAM}=${token}`) : value;
127
+ const { publication, content } = article;
128
+ return {
129
+ ...article,
130
+ publication: publication.cover ? { ...publication, cover: { path: String(mark(publication.cover.path)) } } : publication,
131
+ content: content.format === "hast" ? { ...content, tree: mapNode(content.tree, mark, 0) } : content
132
+ };
133
+ }
134
+
94
135
  // src/client.ts
95
136
  var RENDERER_VERSION = "4";
96
137
  function applyCredential(headers, credential, method, url) {
@@ -126,6 +167,17 @@ async function readCapped(res, max) {
126
167
  }
127
168
  return Buffer.concat(chunks).toString("utf8");
128
169
  }
170
+ function isNotFoundBody(status, body) {
171
+ if (status !== 404) return false;
172
+ try {
173
+ return JSON.parse(body)?.error?.code === "NOT_FOUND";
174
+ } catch {
175
+ return false;
176
+ }
177
+ }
178
+ async function isNotFoundResponse(res) {
179
+ return isNotFoundBody(res.status, await readCapped(res, 64 * 1024).catch(() => ""));
180
+ }
129
181
  var KINDS = /* @__PURE__ */ new Set(["article", "list", "redirect", "notfound", "disabled"]);
130
182
  var isStrings = (value) => Array.isArray(value) && value.every((v) => typeof v === "string");
131
183
  function isMounts(data) {
@@ -203,8 +255,20 @@ function createHyleClient(options) {
203
255
  if (data?.cp === 1 && data.kind === "push_posts" && Array.isArray(data.posts) && typeof data.complete === "boolean") return data;
204
256
  throw failure(reply2);
205
257
  }
258
+ async function preview(token) {
259
+ if (typeof token !== "string" || !PREVIEW_TOKEN.test(token)) return { kind: "notfound" };
260
+ const reply2 = await get("/cp1/read/_preview", new URLSearchParams(), { headers: { [PREVIEW_HEADER]: token }, cache: "no-store" });
261
+ if (reply2.status === 404 && reply2.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
262
+ const data = reply2.parsed?.data;
263
+ if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
264
+ const article = data?.article;
265
+ if (data?.cp !== 1 || data.kind !== "preview" || typeof data.expires_at !== "string" || article?.kind !== "article" || article.content?.format !== "hast" || !article.publication) throw failure(reply2);
266
+ return { kind: "preview", expires_at: data.expires_at, article: withPreviewAssets(article, token) };
267
+ }
206
268
  async function asset(file, opts = {}) {
207
269
  if (!ASSET_FILE.test(file)) throw new TypeError("asset file must be <uuid>[.<ext>]");
270
+ const { previewToken } = opts;
271
+ if (previewToken !== void 0 && !PREVIEW_TOKEN.test(previewToken)) throw new TypeError("previewToken is not a preview token");
208
272
  const url = `${base}/cp1/read/assets/${file}`;
209
273
  const headers = new Headers();
210
274
  const applied = applyCredential(headers, options, "GET", url);
@@ -213,9 +277,17 @@ function createHyleClient(options) {
213
277
  const value = opts.headers?.[name];
214
278
  if (value) headers.set(name, value);
215
279
  }
280
+ if (previewToken !== void 0) headers.set(PREVIEW_HEADER, previewToken);
281
+ return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS), ...previewToken === void 0 ? {} : { cache: "no-store" } });
282
+ }
283
+ async function theme(opts = {}) {
284
+ const url = `${base}/cp1/read/theme.css`;
285
+ const headers = new Headers();
286
+ const applied = applyCredential(headers, options, "GET", url);
287
+ if (applied) await applied;
216
288
  return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS) });
217
289
  }
218
- return { resolve, mounts, pushPosts, asset };
290
+ return { resolve, mounts, pushPosts, preview, asset, theme };
219
291
  }
220
292
 
221
293
  // src/delivery-dedupe.ts
@@ -553,7 +625,7 @@ var HastLimitError = class extends Error {
553
625
  };
554
626
  var MAX_NODES = 2e4;
555
627
  var MAX_TEXT = 512 * 1024;
556
- var MAX_DEPTH = 128;
628
+ var MAX_DEPTH2 = 128;
557
629
  var MAX_SRCDOC = 1024 * 1024;
558
630
  var DROP = /* @__PURE__ */ new Set(["script", "style", "template", "noscript"]);
559
631
  var VOID = /* @__PURE__ */ new Set(["br", "hr", "img", "input", "path"]);
@@ -619,7 +691,7 @@ var ENTITIES = { "&#x3c;": "<", "&#x26;": "&", "&lt;": "<", "&gt;": ">", "&amp;"
619
691
  function mermaidSource(srcDoc) {
620
692
  return MERMAID_SRCDOC.exec(srcDoc)?.[1]?.replace(/&(?:#x3c|#x26|#x27|lt|gt|amp|quot);/gi, (e) => ENTITIES[e.toLowerCase()]);
621
693
  }
622
- var RENDER_REF = /^(\/assets\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.svg) ([1-9]\d{0,5}) ([1-9]\d{0,5})$/;
694
+ var RENDER_REF = new RegExp(`^(/assets/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\.svg(?:${PREVIEW_QUERY_SOURCE})?) ([1-9]\\d{0,5}) ([1-9]\\d{0,5})$`);
623
695
  var isRenderRef = matches(RENDER_REF);
624
696
  function diagramRender(value) {
625
697
  const m = typeof value === "string" ? RENDER_REF.exec(value) : null;
@@ -671,11 +743,11 @@ var ATTRS = new Map(
671
743
  );
672
744
  var isObject = (v) => typeof v === "object" && v !== null;
673
745
  function textOf(node, depth = 0) {
674
- if (!isObject(node) || depth > MAX_DEPTH) return "";
746
+ if (!isObject(node) || depth > MAX_DEPTH2) return "";
675
747
  if (node.type === "text") return typeof node.value === "string" ? node.value : "";
676
748
  return Array.isArray(node.children) ? node.children.map((c) => textOf(c, depth + 1)).join("") : "";
677
749
  }
678
- var holdsEmbed = (node, depth = 0) => isObject(node) && depth <= MAX_DEPTH && (isObject(node.properties) && "dataEmbed" in node.properties || Array.isArray(node.children) && node.children.some((c) => holdsEmbed(c, depth + 1)));
750
+ var holdsEmbed = (node, depth = 0) => isObject(node) && depth <= MAX_DEPTH2 && (isObject(node.properties) && "dataEmbed" in node.properties || Array.isArray(node.children) && node.children.some((c) => holdsEmbed(c, depth + 1)));
679
751
  var collapse = (text) => text.replace(/\s+/g, " ").trim();
680
752
  var CALLOUT_MARKER = /^\s*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*/i;
681
753
  var CALLOUT_KIND = { note: "note", tip: "tip", important: "important", warning: "warning", caution: "caution" };
@@ -706,7 +778,7 @@ function toFigure(children) {
706
778
  return { type: "element", tagName: "figure", properties: { dataSlotComponent: "Image" }, children: [media, ...caption] };
707
779
  }
708
780
  function clean(node, depth, ctx2, budget) {
709
- if (!isObject(node) || depth > MAX_DEPTH) return [];
781
+ if (!isObject(node) || depth > MAX_DEPTH2) return [];
710
782
  if (++budget.nodes > MAX_NODES) throw new HastLimitError("content has too many nodes");
711
783
  if (node.type === "text") {
712
784
  if (typeof node.value !== "string") return [];
@@ -756,7 +828,7 @@ function sanitizeHast(tree, title, description) {
756
828
  const [first] = elements;
757
829
  const skip = title !== void 0 && isObject(first) && first.tagName === "h1" && collapse(textOf(first)) === collapse(title) ? first : void 0;
758
830
  const lead = elements[skip ? 1 : 0];
759
- const repeat = description && isObject(lead) && lead.tagName === "p" && collapse(textOf(lead)).startsWith(collapse(description)) && !holdsEmbed(lead) ? lead : void 0;
831
+ const repeat = description && isObject(lead) && lead.tagName === "p" && collapse(textOf(lead)) === collapse(description) && !holdsEmbed(lead) ? lead : void 0;
760
832
  const budget = { nodes: 0, text: 0 };
761
833
  return { type: "root", children: raw.filter((n) => n !== skip && n !== repeat).flatMap((n) => clean(n, 0, { katex: false }, budget)) };
762
834
  }
@@ -1688,79 +1760,94 @@ function CommentBody({ tree }) {
1688
1760
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle-cm-body", children: (0, import_hast_util_to_jsx_runtime2.toJsxRuntime)({ type: "root", children }, { Fragment: import_react3.Fragment, jsx: import_jsx_runtime5.jsx, jsxs: import_jsx_runtime5.jsxs, elementAttributeNameCase: "react", stylePropertyNameCase: "dom" }) });
1689
1761
  }
1690
1762
 
1691
- // src/react/embed.tsx
1763
+ // src/react/theme.tsx
1692
1764
  var import_jsx_runtime7 = require("react/jsx-runtime");
1693
- function HyleListView({ items, layout = "list", title, headingLevel = 2, moreHref, olderHref, ...base }) {
1765
+ function HyleTheme({ theme }) {
1766
+ const href = theme ? themeStylesheetHref(theme) : void 0;
1767
+ if (!href) return null;
1768
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1769
+ themeFontHrefs(Array.isArray(theme?.preload) ? theme.preload : []).map((font) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("link", { rel: "preload", as: "font", type: "font/woff2", href: font, crossOrigin: "anonymous" }, font)),
1770
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("link", { rel: "stylesheet", href, precedence: "hyle-theme" })
1771
+ ] });
1772
+ }
1773
+
1774
+ // src/react/embed.tsx
1775
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1776
+ function HyleListView({ items, layout = "list", title, headingLevel = 2, moreHref, olderHref, theme, ...base }) {
1694
1777
  const c = ctx(base, "en");
1695
1778
  const { s, Link } = c;
1696
1779
  const Row = base.slots?.["list.item"];
1697
1780
  const Heading = `h${headingLevel}`;
1698
1781
  const safe = items.filter((item) => item.canonical_path.startsWith("/"));
1699
- if (safe.length === 0) return base.slots?.["list.empty"] ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle hyle-embed", "data-layout": layout, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Slot, { name: "list.empty", slots: base.slots }) }) : null;
1700
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle hyle-embed", "data-layout": layout, lang: c.locale, children: [
1701
- title ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Heading, { className: "hyle-title", children: title }) : null,
1702
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { className: "hyle-items", children: safe.map((item) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("li", { children: Row ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
1703
- item.published_at ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }) : null,
1704
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
1705
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "t", children: item.title }),
1706
- item.description ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: item.description }) : null
1782
+ if (safe.length === 0) return base.slots?.["list.empty"] ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle hyle-embed", "data-layout": layout, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "list.empty", slots: base.slots }) }) : null;
1783
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle hyle-embed", "data-layout": layout, lang: c.locale, children: [
1784
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HyleTheme, { theme }),
1785
+ title ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Heading, { className: "hyle-title", children: title }) : null,
1786
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: "hyle-items", children: safe.map((item) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: Row ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
1787
+ item.published_at ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }) : null,
1788
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
1789
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "t", children: item.title }),
1790
+ item.description ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: item.description }) : null
1707
1791
  ] })
1708
1792
  ] }) }, item.canonical_path)) }),
1709
- olderHref ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(OlderNav, { href: olderHref, c }) : null,
1710
- moreHref ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("a", { className: "hyle-more", href: moreHref, children: s.viewAll }) : null
1793
+ olderHref ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OlderNav, { href: olderHref, c }) : null,
1794
+ moreHref ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", { className: "hyle-more", href: moreHref, children: s.viewAll }) : null
1711
1795
  ] });
1712
1796
  }
1713
1797
  function HyleArticleView({ article, headingLevel = 2, ...base }) {
1714
1798
  const { publication: pub } = article;
1715
1799
  const c = ctx(base, pub.locale);
1716
1800
  const Heading = `h${headingLevel}`;
1717
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("article", { lang: c.locale, children: [
1718
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("header", { className: "hyle-head", children: [
1719
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Heading, { className: "hyle-title", children: pub.title }),
1720
- pub.description ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
1721
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle-meta", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) }) }) })
1722
- ] }),
1723
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Body, { article, components: base.components, locale: c.locale }),
1724
- pub.canonical_path.startsWith("/") ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("a", { className: "hyle-more", href: c.href(pub.canonical_path, pub.locale), rel: "bookmark", children: [
1725
- c.s.readAtSource,
1726
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "hyle-sr", children: [
1727
- ": ",
1728
- pub.title
1729
- ] })
1730
- ] }) : null
1731
- ] }) });
1801
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle hyle-embed", children: [
1802
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HyleTheme, { theme: article.theme }),
1803
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("article", { lang: c.locale, children: [
1804
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("header", { className: "hyle-head", children: [
1805
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Heading, { className: "hyle-title", children: pub.title }),
1806
+ pub.description ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
1807
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle-meta", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) }) }) })
1808
+ ] }),
1809
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Body, { article, components: base.components, locale: c.locale }),
1810
+ pub.canonical_path.startsWith("/") ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("a", { className: "hyle-more", href: c.href(pub.canonical_path, pub.locale), rel: "bookmark", children: [
1811
+ c.s.readAtSource,
1812
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "hyle-sr", children: [
1813
+ ": ",
1814
+ pub.title
1815
+ ] })
1816
+ ] }) : null
1817
+ ] })
1818
+ ] });
1732
1819
  }
1733
1820
  var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((w) => [...w][0] ?? "").join("").toUpperCase() || "?";
1734
1821
  function StaticThread({ nodes, locale, s, level = 1 }) {
1735
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ol", { className: "hyle-cm-list", role: "list", children: nodes.map((node) => {
1736
- const kids = node.kids.length > 0 && level < 32 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StaticThread, { nodes: node.kids, locale, s, level: level + 1 }) : null;
1822
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ol", { className: "hyle-cm-list", role: "list", children: nodes.map((node) => {
1823
+ const kids = node.kids.length > 0 && level < 32 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StaticThread, { nodes: node.kids, locale, s, level: level + 1 }) : null;
1737
1824
  if (node.status === "removed") {
1738
1825
  const why = node.removedBy === "moderator" ? s.removedByModerator : node.removedBy === "author" ? s.removedByAuthor : s.removed;
1739
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "removed", "data-removed-by": node.removedBy, children: [
1740
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("article", { "aria-label": why, children: [
1741
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "ban" }) }),
1742
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle-cm-main", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle-cm-body", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: why }) }) })
1826
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "removed", "data-removed-by": node.removedBy, children: [
1827
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("article", { "aria-label": why, children: [
1828
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "ban" }) }),
1829
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle-cm-main", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle-cm-body", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: why }) }) })
1743
1830
  ] }),
1744
1831
  kids
1745
1832
  ] }, node.id);
1746
1833
  }
1747
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "visible", children: [
1748
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("article", { children: [
1749
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: initials(node.name ?? "") }),
1750
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-cm-main", children: [
1751
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-cm-by", children: [
1752
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("b", { children: node.name }),
1753
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1754
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("time", { dateTime: node.createdAt, title: node.createdAt, children: formatDate(node.createdAt, locale) }),
1755
- node.editedAt ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1834
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "visible", children: [
1835
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("article", { children: [
1836
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: initials(node.name ?? "") }),
1837
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-cm-main", children: [
1838
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-cm-by", children: [
1839
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("b", { children: node.name }),
1840
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
1841
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: node.createdAt, title: node.createdAt, children: formatDate(node.createdAt, locale) }),
1842
+ node.editedAt ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1756
1843
  " ",
1757
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-hidden": "true", children: "\xB7" }),
1844
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { "aria-hidden": "true", children: "\xB7" }),
1758
1845
  " ",
1759
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: s.edited })
1846
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: s.edited })
1760
1847
  ] }) : null
1761
1848
  ] })
1762
1849
  ] }),
1763
- node.unrenderable ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle-cm-body", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: s.unrenderable }) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CommentBody, { tree: node.tree })
1850
+ node.unrenderable ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle-cm-body", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: s.unrenderable }) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CommentBody, { tree: node.tree })
1764
1851
  ] })
1765
1852
  ] }),
1766
1853
  kids
@@ -1771,26 +1858,26 @@ function HyleCommentsView({ listing, locale }) {
1771
1858
  const thread = buildThread(listing, []);
1772
1859
  if (thread.length === 0) return null;
1773
1860
  const s = stringsFor(locale).comments;
1774
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", lang: locale, children: [
1775
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle-cm-head", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("h2", { children: [
1861
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", lang: locale, children: [
1862
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle-cm-head", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("h2", { children: [
1776
1863
  s.heading,
1777
1864
  " ",
1778
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-cm-count", "aria-label": s.countLabel.replace("{n}", String(listing.comment_count)), children: listing.comment_count })
1865
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-cm-count", "aria-label": s.countLabel.replace("{n}", String(listing.comment_count)), children: listing.comment_count })
1779
1866
  ] }) }),
1780
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StaticThread, { nodes: thread, locale, s }),
1781
- listing.truncated ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "hyle-cm-note", children: s.truncated }) : null
1867
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StaticThread, { nodes: thread, locale, s }),
1868
+ listing.truncated ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "hyle-cm-note", children: s.truncated }) : null
1782
1869
  ] }) });
1783
1870
  }
1784
1871
  function HyleCommentsFallback({ locale }) {
1785
1872
  const s = stringsFor(locale).comments;
1786
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { role: "status", "aria-live": "polite", "aria-busy": "true", children: [
1787
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-sr", children: s.loading }),
1788
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { "aria-hidden": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-cm-sk", children: [
1789
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-sk c" }),
1790
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
1791
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-sk l", style: { width: 120 } }),
1792
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-sk l", style: { width: "100%" } }),
1793
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-sk l", style: { width: "72%" } })
1873
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { role: "status", "aria-live": "polite", "aria-busy": "true", children: [
1874
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-sr", children: s.loading }),
1875
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "aria-hidden": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-cm-sk", children: [
1876
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-sk c" }),
1877
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
1878
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-sk l", style: { width: 120 } }),
1879
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-sk l", style: { width: "100%" } }),
1880
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-sk l", style: { width: "72%" } })
1794
1881
  ] })
1795
1882
  ] }, i)) })
1796
1883
  ] }) }) });
@@ -1921,13 +2008,16 @@ function listJsonLd({ list, origin, href, path, locale, description, jsonLd, cur
1921
2008
 
1922
2009
  // src/react/pages.tsx
1923
2010
  var import_toc_spy = require("./toc-spy.cjs");
1924
- var import_jsx_runtime8 = require("react/jsx-runtime");
2011
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1925
2012
  function Slot({ name, slots, tag: Tag = "div", className }) {
1926
2013
  const fill = slots?.[name];
1927
- return fill ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Tag, { "data-slot": name, className, children: fill }) : null;
2014
+ return fill ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Tag, { "data-slot": name, className, children: fill }) : null;
1928
2015
  }
1929
- function Shell({ children }) {
1930
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle-page", children }) });
2016
+ function Shell({ children, theme }) {
2017
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2018
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HyleTheme, { theme }),
2019
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "hyle", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "hyle-page", children }) })
2020
+ ] });
1931
2021
  }
1932
2022
  function ctx(p, fallbackLocale) {
1933
2023
  const locale = p.locale ?? fallbackLocale;
@@ -1936,29 +2026,29 @@ function ctx(p, fallbackLocale) {
1936
2026
  function Pager({ prev, next, c }) {
1937
2027
  if (!prev && !next) return null;
1938
2028
  const { Link, s } = c;
1939
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("nav", { className: "hyle-pager", "aria-label": s.pager, children: [
1940
- prev ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Link, { href: c.href(prev.canonical_path), rel: "prev", children: [
1941
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "dir", children: [
1942
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chev-left" }),
2029
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("nav", { className: "hyle-pager", "aria-label": s.pager, children: [
2030
+ prev ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Link, { href: c.href(prev.canonical_path), rel: "prev", children: [
2031
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "dir", children: [
2032
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev-left" }),
1943
2033
  s.prev
1944
2034
  ] }),
1945
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "ttl", children: prev.title })
1946
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "none", "aria-hidden": "true" }),
1947
- next ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Link, { href: c.href(next.canonical_path), rel: "next", className: "next", children: [
1948
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "dir", children: [
2035
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ttl", children: prev.title })
2036
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "none", "aria-hidden": "true" }),
2037
+ next ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Link, { href: c.href(next.canonical_path), rel: "next", className: "next", children: [
2038
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "dir", children: [
1949
2039
  s.next,
1950
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chev" })
2040
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev" })
1951
2041
  ] }),
1952
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "ttl", children: next.title })
2042
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ttl", children: next.title })
1953
2043
  ] }) : null
1954
2044
  ] });
1955
2045
  }
1956
2046
  function OlderNav({ href, c }) {
1957
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("nav", { className: "hyle-pagination", "aria-label": c.s.pager, children: [
1958
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "sp" }),
1959
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(c.Link, { className: "hyle-btn sm", href, rel: "next", children: [
2047
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("nav", { className: "hyle-pagination", "aria-label": c.s.pager, children: [
2048
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "sp" }),
2049
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(c.Link, { className: "hyle-btn sm", href, rel: "next", children: [
1960
2050
  c.s.older,
1961
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chev" })
2051
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev" })
1962
2052
  ] })
1963
2053
  ] });
1964
2054
  }
@@ -1969,9 +2059,9 @@ function TocList({ toc }) {
1969
2059
  if (entry.depth === 3 && last) last.subs.push(entry);
1970
2060
  else groups.push({ entry, subs: [] });
1971
2061
  }
1972
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { children: groups.map(({ entry, subs }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("li", { children: [
1973
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", { href: `#${scopeId(entry.id)}`, children: entry.text }),
1974
- subs.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { children: subs.map((sub) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", { href: `#${scopeId(sub.id)}`, children: sub.text }) }, sub.id)) }) : null
2062
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { children: groups.map(({ entry, subs }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("li", { children: [
2063
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("a", { href: `#${scopeId(entry.id)}`, children: entry.text }),
2064
+ subs.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { children: subs.map((sub) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("a", { href: `#${scopeId(sub.id)}`, children: sub.text }) }, sub.id)) }) : null
1975
2065
  ] }, entry.id)) });
1976
2066
  }
1977
2067
  function Toc({ toc, c, aside, spy, className }) {
@@ -1980,21 +2070,21 @@ function Toc({ toc, c, aside, spy, className }) {
1980
2070
  const { s } = c;
1981
2071
  const classes = (own) => className ? `${className} ${own}` : own;
1982
2072
  return {
1983
- narrow: entries.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("details", { className: classes("hyle-toc-m"), children: [
1984
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("summary", { children: [
1985
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "file" }),
2073
+ narrow: entries.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("details", { className: classes("hyle-toc-m"), children: [
2074
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("summary", { children: [
2075
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "file" }),
1986
2076
  s.toc,
1987
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
2077
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
1988
2078
  ] }),
1989
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("nav", { className: "hyle-toc-list", "aria-label": s.toc, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TocList, { toc: entries }) })
2079
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("nav", { className: "hyle-toc-list", "aria-label": s.toc, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TocList, { toc: entries }) })
1990
2080
  ] }),
1991
- wide: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("aside", { className: classes("hyle-toc-d"), "aria-label": s.toc, children: [
1992
- entries.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1993
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "hyle-toc-title", children: s.toc }),
1994
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("nav", { className: "hyle-toc-list", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TocList, { toc: entries }) })
2081
+ wide: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("aside", { className: classes("hyle-toc-d"), "aria-label": s.toc, children: [
2082
+ entries.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2083
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "hyle-toc-title", children: s.toc }),
2084
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("nav", { className: "hyle-toc-list", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TocList, { toc: entries }) })
1995
2085
  ] }),
1996
2086
  aside,
1997
- spy && entries.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_toc_spy.TocSpy, { ids: entries.map((t) => scopeId(t.id)) }) : null
2087
+ spy && entries.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_toc_spy.TocSpy, { ids: entries.map((t) => scopeId(t.id)) }) : null
1998
2088
  ] })
1999
2089
  };
2000
2090
  }
@@ -2002,27 +2092,27 @@ function Body({ article, components, locale }) {
2002
2092
  const { content, publication } = article;
2003
2093
  const lang = article.fallback ? void 0 : publication.locale;
2004
2094
  if (content.format === "hast") {
2005
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ProseBody, { className: "hyle-body hyle-prose", lang, tree: content.tree, title: publication.title, description: publication.description, components: components ?? {}, locale });
2095
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ProseBody, { className: "hyle-body hyle-prose", lang, tree: content.tree, title: publication.title, description: publication.description, components: components ?? {}, locale });
2006
2096
  }
2007
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle-body hyle-prose", lang, children: content.format === "html" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TrustedServerHtml, { html: content.html }) : null });
2097
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "hyle-body hyle-prose", lang, children: content.format === "html" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TrustedServerHtml, { html: content.html }) : null });
2008
2098
  }
2009
2099
  function Languages({ alternates, current, c }) {
2010
2100
  if (alternates.length < 2) return null;
2011
2101
  const { Link, s } = c;
2012
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("nav", { className: "hyle-langs", "aria-label": s.languages, children: [
2013
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: s.readIn }),
2014
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { children: alternates.map((a) => {
2102
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("nav", { className: "hyle-langs", "aria-label": s.languages, children: [
2103
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: s.readIn }),
2104
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { children: alternates.map((a) => {
2015
2105
  const label = languageName(a.locale, a.locale);
2016
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: a.locale === current ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, "aria-current": "true", children: label }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Link, { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, children: label }) }, a.locale);
2106
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: a.locale === current ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("a", { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, "aria-current": "true", children: label }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Link, { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, children: label }) }, a.locale);
2017
2107
  }) })
2018
2108
  ] });
2019
2109
  }
2020
2110
  function LdScript({ json: json2 }) {
2021
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: json2 } });
2111
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: json2 } });
2022
2112
  }
2023
2113
  function Crumbs({ items, c }) {
2024
2114
  const { Link } = c;
2025
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("nav", { className: "hyle-crumbs", "aria-label": c.s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ol", { children: items.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { "aria-current": i === items.length - 1 ? "page" : void 0, children: i === items.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Link, { href: crumbHref(c.href, b.canonical_path, c.locale), children: b.title }) }, b.canonical_path)) }) });
2115
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("nav", { className: "hyle-crumbs", "aria-label": c.s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ol", { children: items.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { "aria-current": i === items.length - 1 ? "page" : void 0, children: i === items.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Link, { href: crumbHref(c.href, b.canonical_path, c.locale), children: b.title }) }, b.canonical_path)) }) });
2026
2116
  }
2027
2117
  function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, imageWidth, imageHeight, related, ...base }) {
2028
2118
  const { publication: pub } = article;
@@ -2032,66 +2122,66 @@ function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, imageWidth
2032
2122
  const author = articleAuthor(article, jsonLd)?.name;
2033
2123
  const modified = modifiedAt(pub);
2034
2124
  const words = wordCountOf(pub);
2035
- const toc = Toc({ toc: article.toc, c, spy: true, aside: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "article.aside", slots: base.slots, className: "hyle-slot-wrap" }) });
2125
+ const toc = Toc({ toc: article.toc, c, spy: true, aside: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "article.aside", slots: base.slots, className: "hyle-slot-wrap" }) });
2036
2126
  const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
2037
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Shell, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("article", { className: "hyle-article", "data-hyle-page": "article", lang: c.locale, children: [
2038
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("header", { className: "hyle-head", children: [
2039
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "article.before", slots: base.slots, className: "hyle-eyebrow" }),
2040
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Crumbs, { items: breadcrumbItems(article, jsonLd), c }),
2041
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h1", { className: "hyle-title", children: pub.title }),
2042
- pub.description ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
2043
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-meta", children: [
2044
- author ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
2045
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: author.slice(0, 2).toUpperCase() }),
2046
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
2047
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "hyle-sr", children: [
2127
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Shell, { theme: article.theme, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("article", { className: "hyle-article", "data-hyle-page": "article", lang: c.locale, children: [
2128
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("header", { className: "hyle-head", children: [
2129
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "article.before", slots: base.slots, className: "hyle-eyebrow" }),
2130
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Crumbs, { items: breadcrumbItems(article, jsonLd), c }),
2131
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h1", { className: "hyle-title", children: pub.title }),
2132
+ pub.description ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
2133
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-meta", children: [
2134
+ author ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
2135
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: author.slice(0, 2).toUpperCase() }),
2136
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
2137
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "hyle-sr", children: [
2048
2138
  s.by,
2049
2139
  " "
2050
2140
  ] }),
2051
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "by", children: author })
2141
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "by", children: author })
2052
2142
  ] })
2053
2143
  ] }) : null,
2054
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
2055
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "calendar" }),
2056
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) })
2144
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
2145
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "calendar" }),
2146
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) })
2057
2147
  ] }),
2058
- modified ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
2059
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "calendar" }),
2148
+ modified ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
2149
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "calendar" }),
2060
2150
  s.updated,
2061
2151
  " ",
2062
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: modified, title: modified, children: formatDate(modified, c.locale) })
2152
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("time", { dateTime: modified, title: modified, children: formatDate(modified, c.locale) })
2063
2153
  ] }) : null,
2064
- words ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
2065
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "clock" }),
2154
+ words ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
2155
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "clock" }),
2066
2156
  s.readingTime.replace("{n}", String(readingMinutes(words)))
2067
2157
  ] }) : null,
2068
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
2069
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "globe" }),
2070
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { lang: pub.locale, children: languageName(pub.locale, c.locale) })
2158
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
2159
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "globe" }),
2160
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { lang: pub.locale, children: languageName(pub.locale, c.locale) })
2071
2161
  ] }),
2072
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "article.meta", slots: base.slots, tag: "span" })
2162
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "article.meta", slots: base.slots, tag: "span" })
2073
2163
  ] }),
2074
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Languages, { alternates: article.alternates, current: pub.locale, c }),
2075
- notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
2076
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "alert" }),
2077
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
2078
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("b", { children: notTranslated }),
2164
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Languages, { alternates: article.alternates, current: pub.locale, c }),
2165
+ notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
2166
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "alert" }),
2167
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2168
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("b", { children: notTranslated }),
2079
2169
  " ",
2080
2170
  s.fallbackBody
2081
2171
  ] })
2082
2172
  ] }) : null
2083
2173
  ] }),
2084
2174
  toc.narrow,
2085
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Body, { article, components: base.components, locale: c.locale }),
2086
- engagement ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_comments.Comments, { path: pub.canonical_path, endpoint: engagement.endpoint ?? "/api/hyle/engage", signInHref: engagement.signInHref, locale: c.locale, labels: s.comments }) : null,
2087
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Pager, { prev: article.prev, next: article.next, c }),
2088
- related ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
2089
- related.items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HyleListView, { items: related.items, title: related.title ?? s.moreInSection, ...base, locale: c.locale }) : null,
2090
- article.children.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HyleListView, { items: article.children.map((child) => ({ ...child, description: null, published_at: "" })), title: s.subPages, ...base, locale: c.locale }) : null
2175
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Body, { article, components: base.components, locale: c.locale }),
2176
+ engagement ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_comments.Comments, { path: pub.canonical_path, endpoint: engagement.endpoint ?? "/api/hyle/engage", signInHref: engagement.signInHref, locale: c.locale, labels: s.comments }) : null,
2177
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Pager, { prev: article.prev, next: article.next, c }),
2178
+ related ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2179
+ related.items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HyleListView, { items: related.items, title: related.title ?? s.moreInSection, ...base, locale: c.locale }) : null,
2180
+ article.children.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HyleListView, { items: article.children.map((child) => ({ ...child, description: null, published_at: "" })), title: s.subPages, ...base, locale: c.locale }) : null
2091
2181
  ] }) : null,
2092
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "article.after", slots: base.slots, className: "hyle-after" }),
2182
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "article.after", slots: base.slots, className: "hyle-after" }),
2093
2183
  toc.wide,
2094
- jsonLdOrigin ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LdScript, { json: articleJsonLd({ article, origin: jsonLdOrigin, href: c.href, jsonLd, imageUrl, imageWidth, imageHeight }) }) : null
2184
+ jsonLdOrigin ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(LdScript, { json: articleJsonLd({ article, origin: jsonLdOrigin, href: c.href, jsonLd, imageUrl, imageWidth, imageHeight }) }) : null
2095
2185
  ] }) });
2096
2186
  }
2097
2187
  function ListPage({ list, olderHref, description, origin, path, jsonLd, cursor, ...base }) {
@@ -2102,37 +2192,37 @@ function ListPage({ list, olderHref, description, origin, path, jsonLd, cursor,
2102
2192
  for (const item of list.items) groups.set(item.published_at.slice(0, 7), [...groups.get(item.published_at.slice(0, 7)) ?? [], item]);
2103
2193
  const notTranslated = list.fallback ? s.fallbackTitle.replace("{language}", languageName(list.fallback.requested_locale, c.locale)) : void 0;
2104
2194
  const jsonLdOrigin = bareOrigin(origin);
2105
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Shell, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-listpage", "data-hyle-page": "list", lang: c.locale, children: [
2106
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("header", { className: "hyle-head", children: [
2107
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h1", { className: "hyle-title", children: list.section.title }),
2108
- description ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "hyle-desc", children: description }) : null,
2109
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "list.header", slots: base.slots, className: "hyle-slot-wrap" }),
2110
- notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
2111
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "alert" }),
2112
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
2113
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("b", { children: notTranslated }),
2195
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Shell, { theme: list.theme, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-listpage", "data-hyle-page": "list", lang: c.locale, children: [
2196
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("header", { className: "hyle-head", children: [
2197
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h1", { className: "hyle-title", children: list.section.title }),
2198
+ description ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "hyle-desc", children: description }) : null,
2199
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "list.header", slots: base.slots, className: "hyle-slot-wrap" }),
2200
+ notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
2201
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "alert" }),
2202
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2203
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("b", { children: notTranslated }),
2114
2204
  " ",
2115
2205
  s.fallbackBody
2116
2206
  ] })
2117
2207
  ] }) : null
2118
2208
  ] }),
2119
- list.items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-empty", "data-slot-state": "empty", children: [
2120
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "file" }),
2121
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h2", { children: s.emptyTitle }),
2122
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: s.emptyBody }),
2123
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "list.empty", slots: base.slots })
2124
- ] }) : [...groups].map(([month, items]) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { "aria-label": formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }), children: [
2125
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h2", { className: "hyle-year", children: formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }) }),
2126
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: "hyle-items", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: Row ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
2127
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }),
2128
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
2129
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "t", children: item.title }),
2130
- item.description ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: item.description }) : null
2209
+ list.items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-empty", "data-slot-state": "empty", children: [
2210
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "file" }),
2211
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { children: s.emptyTitle }),
2212
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: s.emptyBody }),
2213
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "list.empty", slots: base.slots })
2214
+ ] }) : [...groups].map(([month, items]) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { "aria-label": formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }), children: [
2215
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { className: "hyle-year", children: formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }) }),
2216
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { className: "hyle-items", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: Row ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
2217
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }),
2218
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2219
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "t", children: item.title }),
2220
+ item.description ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: item.description }) : null
2131
2221
  ] })
2132
2222
  ] }) }, item.canonical_path)) })
2133
2223
  ] }, month)),
2134
- olderHref ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OlderNav, { href: olderHref, c }) : null,
2135
- jsonLdOrigin && path ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LdScript, { json: listJsonLd({ list, origin: jsonLdOrigin, href: c.href, path, locale: c.locale, description, jsonLd, cursor }) }) : null
2224
+ olderHref ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(OlderNav, { href: olderHref, c }) : null,
2225
+ jsonLdOrigin && path ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(LdScript, { json: listJsonLd({ list, origin: jsonLdOrigin, href: c.href, path, locale: c.locale, description, jsonLd, cursor }) }) : null
2136
2226
  ] }) });
2137
2227
  }
2138
2228
 
@@ -2142,7 +2232,7 @@ var import_reactions = require("./reactions.cjs");
2142
2232
 
2143
2233
  // src/react/docs.tsx
2144
2234
  var import_docs_enhance = require("./docs-enhance.cjs");
2145
- var import_jsx_runtime9 = require("react/jsx-runtime");
2235
+ var import_jsx_runtime10 = require("react/jsx-runtime");
2146
2236
  var ROOT_ID = "hyle-docs";
2147
2237
  var NAV_ID = "hyle-docs-nav";
2148
2238
  function navTreeOf(article) {
@@ -2166,15 +2256,15 @@ function pathTo(nodes, path) {
2166
2256
  }
2167
2257
  function Branch({ nodes, current, onPath, c }) {
2168
2258
  const { Link } = c;
2169
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { children: nodes.map((node) => {
2170
- const link = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Link, { href: c.href(node.canonical_path), ...node.canonical_path === current ? { "aria-current": "page" } : {}, children: node.title });
2171
- if (node.children.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: link }, node.canonical_path);
2172
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("details", { ...onPath.has(node.canonical_path) ? { open: true } : {}, children: [
2173
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("summary", { children: [
2174
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev" }),
2259
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { children: nodes.map((node) => {
2260
+ const link = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Link, { href: c.href(node.canonical_path), ...node.canonical_path === current ? { "aria-current": "page" } : {}, children: node.title });
2261
+ if (node.children.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("li", { children: link }, node.canonical_path);
2262
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("details", { ...onPath.has(node.canonical_path) ? { open: true } : {}, children: [
2263
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("summary", { children: [
2264
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "chev" }),
2175
2265
  link
2176
2266
  ] }),
2177
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Branch, { nodes: node.children, current, onPath, c })
2267
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Branch, { nodes: node.children, current, onPath, c })
2178
2268
  ] }) }, node.canonical_path);
2179
2269
  }) });
2180
2270
  }
@@ -2188,47 +2278,47 @@ function DocsPage({ article, ...base }) {
2188
2278
  const siteName = article.breadcrumbs[0]?.title ?? "";
2189
2279
  const headingIds = article.toc.filter((t) => t.depth === 2 || t.depth === 3).map((t) => scopeId(t.id));
2190
2280
  const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
2191
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Shell, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-docs", id: ROOT_ID, lang: c.locale, children: [
2192
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_docs_enhance.DocsEnhance, { headingIds, rootId: ROOT_ID }),
2193
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("button", { type: "button", className: "hyle-nav-bar", popoverTarget: NAV_ID, children: [
2194
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "file" }),
2281
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Shell, { theme: article.theme, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "hyle-docs", id: ROOT_ID, lang: c.locale, children: [
2282
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_docs_enhance.DocsEnhance, { headingIds, rootId: ROOT_ID }),
2283
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("button", { type: "button", className: "hyle-nav-bar", popoverTarget: NAV_ID, children: [
2284
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "file" }),
2195
2285
  s.menu,
2196
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "cur", children: pub.title }),
2197
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
2286
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "cur", children: pub.title }),
2287
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
2198
2288
  ] }),
2199
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("aside", { className: "hyle-nav-d", id: NAV_ID, popover: "auto", "aria-label": s.docs, children: [
2200
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-side-head", children: [
2201
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("b", { children: siteName }),
2202
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "docs.version", slots: base.slots, tag: "span" }),
2203
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: "hyle-nav-x", popoverTarget: NAV_ID, popoverTargetAction: "hide", "aria-label": s.closeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "x" }) })
2289
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("aside", { className: "hyle-nav-d", id: NAV_ID, popover: "auto", "aria-label": s.docs, children: [
2290
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "hyle-side-head", children: [
2291
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("b", { children: siteName }),
2292
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { name: "docs.version", slots: base.slots, tag: "span" }),
2293
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: "hyle-nav-x", popoverTarget: NAV_ID, popoverTargetAction: "hide", "aria-label": s.closeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "x" }) })
2204
2294
  ] }),
2205
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
2206
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Branch, { nodes: tree, current: pub.canonical_path, onPath, c }) }),
2207
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "docs.sidebar-footer", slots: base.slots, className: "hyle-side-slot" })
2295
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
2296
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Branch, { nodes: tree, current: pub.canonical_path, onPath, c }) }),
2297
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { name: "docs.sidebar-footer", slots: base.slots, className: "hyle-side-slot" })
2208
2298
  ] }),
2209
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
2210
- notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
2211
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "alert" }),
2212
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2213
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("b", { children: notTranslated }),
2299
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
2300
+ notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
2301
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "alert" }),
2302
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
2303
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("b", { children: notTranslated }),
2214
2304
  " ",
2215
2305
  s.fallbackBody
2216
2306
  ] })
2217
2307
  ] }) : null,
2218
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
2219
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h1", { className: "hyle-title", children: pub.title }),
2220
- pub.description ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
2221
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { className: "hyle-updated", children: [
2222
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "calendar" }),
2308
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
2309
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h1", { className: "hyle-title", children: pub.title }),
2310
+ pub.description ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
2311
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "hyle-updated", children: [
2312
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "calendar" }),
2223
2313
  s.updated,
2224
2314
  " ",
2225
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("time", { dateTime: pub.updated_at, title: pub.updated_at, children: formatDate(pub.updated_at, c.locale) })
2315
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("time", { dateTime: pub.updated_at, title: pub.updated_at, children: formatDate(pub.updated_at, c.locale) })
2226
2316
  ] }),
2227
2317
  toc.narrow,
2228
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Body, { article, components: base.components, locale: c.locale }),
2229
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Pager, { prev: article.prev, next: article.next, c }),
2230
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" }),
2231
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "hyle-docs-end", "aria-hidden": "true" })
2318
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Body, { article, components: base.components, locale: c.locale }),
2319
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Pager, { prev: article.prev, next: article.next, c }),
2320
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" }),
2321
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "hyle-docs-end", "aria-hidden": "true" })
2232
2322
  ] }),
2233
2323
  toc.wide
2234
2324
  ] }) });
@@ -2256,7 +2346,7 @@ function sitePathFrom(basePath, segments) {
2256
2346
  return void 0;
2257
2347
  }
2258
2348
  if (segment !== segment.normalize("NFC")) return void 0;
2259
- if (segment === "" || segment === "." || segment === ".." || /[/\\\u0000-\u001f\u007f]/.test(segment)) return void 0;
2349
+ if (segment === "" || segment === "." || segment.includes("..") || /[/\\\u0000-\u001f\u007f]|%[0-9a-f]{2}/i.test(segment)) return void 0;
2260
2350
  decoded.push(segment);
2261
2351
  }
2262
2352
  const path = decoded.length === 0 ? basePath || "/" : `${basePath}/${decoded.join("/")}`;
@@ -2318,9 +2408,10 @@ function routeContext(options, params) {
2318
2408
  const toHref = (sitePath, linkLocale = locale) => (linkLocale ? prefix(linkLocale) : "") + sitePath;
2319
2409
  return { basePath, path, locale, toHref };
2320
2410
  }
2321
- function isRejectedRequest(error) {
2411
+ function isNotFoundError(error, cursor) {
2322
2412
  (0, import_navigation.unstable_rethrow)(error);
2323
- return error instanceof Cp1ClientError && error.status >= 400 && error.status < 500 && ![401, 403, 429].includes(error.status);
2413
+ if (!(error instanceof Cp1ClientError)) return false;
2414
+ return error.status === 404 && error.code === "NOT_FOUND" || cursor !== void 0 && error.status === 400 && error.code === "VALIDATION_ERROR";
2324
2415
  }
2325
2416
 
2326
2417
  // src/next/embed.tsx
@@ -2621,7 +2712,9 @@ function createEngagementRoute(options) {
2621
2712
  redirect: "error",
2622
2713
  signal: AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS2)
2623
2714
  });
2624
- return { status: res.status, ok: res.ok, text: await readCapped(res, MAX_RESPONSE_BYTES), retryAfter: res.headers.get("retry-after"), throttle: res.headers.get("hyle-throttle") };
2715
+ const text = await readCapped(res, MAX_RESPONSE_BYTES);
2716
+ const status = res.status === 404 && !isNotFoundBody(res.status, text) ? 502 : res.status;
2717
+ return { status, ok: res.ok, text, retryAfter: res.headers.get("retry-after"), throttle: res.headers.get("hyle-throttle") };
2625
2718
  };
2626
2719
  try {
2627
2720
  const out = route.action(req.method) === "comments.list" ? await shared(`${viewer?.reader.sub ?? ""}
@@ -2638,12 +2731,12 @@ ${built.query.toString()}`, () => listing(viewer, call)) : await call();
2638
2731
  }
2639
2732
 
2640
2733
  // src/next/embed.tsx
2641
- var import_jsx_runtime10 = require("react/jsx-runtime");
2642
- async function resolveEmbed(options, run) {
2734
+ var import_jsx_runtime11 = require("react/jsx-runtime");
2735
+ async function resolveEmbed(options, run, cursor) {
2643
2736
  try {
2644
2737
  return { result: await run() };
2645
2738
  } catch (error) {
2646
- if (isRejectedRequest(error)) return {};
2739
+ if (isNotFoundError(error, cursor)) return {};
2647
2740
  console.error(`hyle: ${error instanceof Error ? error.name : "UnknownError"}`);
2648
2741
  return { failure: options.onError ? options.onError(error) : null };
2649
2742
  }
@@ -2653,10 +2746,11 @@ async function HyleList({ options, limit = 5, locale, layout, title, headingLeve
2653
2746
  const route = routeContext(locale ? { ...options, locale } : options, {});
2654
2747
  const path = sitePathFrom(route.basePath, void 0);
2655
2748
  if (path === void 0) return null;
2656
- const { result, failure } = await resolveEmbed(options, () => resolve(path, route.locale, limit, validCursor(cursor)));
2749
+ const after = validCursor(cursor);
2750
+ const { result, failure } = await resolveEmbed(options, () => resolve(path, route.locale, limit, after), after);
2657
2751
  if (failure !== void 0) return failure;
2658
2752
  const next = olderHref && result?.kind === "list" ? validCursor(result.next_cursor) : void 0;
2659
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(HyleListView, { items: result?.kind === "list" ? result.items : [], layout, title, headingLevel, moreHref, olderHref: next ? olderHref?.(next) : void 0, components: options.components, slots: options.slots, locale: route.locale, toHref: route.toHref });
2753
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HyleListView, { items: result?.kind === "list" ? result.items : [], theme: result?.kind === "list" ? result.theme : void 0, layout, title, headingLevel, moreHref, olderHref: next ? olderHref?.(next) : void 0, components: options.components, slots: options.slots, locale: route.locale, toHref: route.toHref });
2660
2754
  }
2661
2755
  async function HyleArticle({ options, path, locale, headingLevel }) {
2662
2756
  if (!isSitePath2(path)) return null;
@@ -2665,7 +2759,7 @@ async function HyleArticle({ options, path, locale, headingLevel }) {
2665
2759
  const { result, failure } = await resolveEmbed(options, () => resolve(path, route.locale));
2666
2760
  if (failure !== void 0) return failure;
2667
2761
  if (result?.kind !== "article") return null;
2668
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(HyleArticleView, { article: result, headingLevel, components: options.components, slots: options.slots, locale: route.locale, toHref: route.toHref });
2762
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HyleArticleView, { article: result, headingLevel, components: options.components, slots: options.slots, locale: route.locale, toHref: route.toHref });
2669
2763
  }
2670
2764
  var MAX_LISTING_BYTES = 4 * 1024 * 1024;
2671
2765
  var COMMENTS_TIMEOUT_MS = 1e4;
@@ -2685,7 +2779,7 @@ async function HyleComments({ options, path, revalidate = 60, interactive }) {
2685
2779
  };
2686
2780
  const res = await fetch(`${options.baseUrl.replace(/\/+$/, "")}/cp1/engage/comments?${new URLSearchParams({ path })}`, init);
2687
2781
  if (!res.ok) {
2688
- if (res.status !== 404) console.error(`hyle: comments answered HTTP ${res.status}`);
2782
+ if (!await isNotFoundResponse(res)) console.error(`hyle: comments answered HTTP ${res.status}`);
2689
2783
  return null;
2690
2784
  }
2691
2785
  listing = parseListing(JSON.parse(await readCapped(res, MAX_LISTING_BYTES)).data);
@@ -2697,13 +2791,13 @@ async function HyleComments({ options, path, revalidate = 60, interactive }) {
2697
2791
  return null;
2698
2792
  }
2699
2793
  if (!listing) return null;
2700
- if (!interactive) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(HyleCommentsView, { listing, locale });
2794
+ if (!interactive) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HyleCommentsView, { listing, locale });
2701
2795
  const config = interactive === true ? {} : interactive;
2702
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_comments2.Comments, { path, endpoint: config.endpoint ?? "/api/hyle/engage", signInHref: config.signInHref, locale, labels: stringsFor(locale).comments, initial: listing, initialAt: fetchedAt }) });
2796
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_comments2.Comments, { path, endpoint: config.endpoint ?? "/api/hyle/engage", signInHref: config.signInHref, locale, labels: stringsFor(locale).comments, initial: listing, initialAt: fetchedAt }) });
2703
2797
  }
2704
2798
 
2705
2799
  // src/next/page.tsx
2706
- var import_jsx_runtime11 = require("react/jsx-runtime");
2800
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2707
2801
  function hylePage(options) {
2708
2802
  const resolve = resolverFor(options);
2709
2803
  async function relatedItems(article) {
@@ -2716,21 +2810,22 @@ function hylePage(options) {
2716
2810
  return async function HylePage({ params, searchParams }) {
2717
2811
  const { path, locale, toHref } = routeContext(options, await params ?? {});
2718
2812
  if (path === void 0) (0, import_navigation3.notFound)();
2813
+ let cursor;
2719
2814
  try {
2720
- const cursor = options.paginate === "searchParams" ? validCursor((await searchParams)?.cursor) : void 0;
2815
+ cursor = options.paginate === "searchParams" ? validCursor((await searchParams)?.cursor) : void 0;
2721
2816
  const result = await resolve(path, locale, options.listLimit, cursor, options.layout === "docs" ? "tree" : void 0);
2722
2817
  switch (result.kind) {
2723
2818
  case "article": {
2724
2819
  const image = articleImage(options, result);
2725
2820
  const related = options.related && options.layout !== "docs" ? await relatedItems(result) : void 0;
2726
2821
  const props = { article: result, components: options.components, slots: options.slots, locale, toHref };
2727
- return options.layout === "docs" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DocsPage, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ArticlePage, { ...props, origin: options.siteOrigin, jsonLd: options.jsonLd, imageUrl: image?.url, imageWidth: image?.width, imageHeight: image?.height, related, ...options.engagement ? { engagement: options.engagement } : {} });
2822
+ return options.layout === "docs" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DocsPage, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ArticlePage, { ...props, origin: options.siteOrigin, jsonLd: options.jsonLd, imageUrl: image?.url, imageWidth: image?.width, imageHeight: image?.height, related, ...options.engagement ? { engagement: options.engagement } : {} });
2728
2823
  }
2729
2824
  case "list": {
2730
2825
  const list = options.list?.title ? { ...result, section: { ...result.section, title: options.list.title } } : result;
2731
2826
  const next = options.paginate === "searchParams" ? validCursor(result.next_cursor) : void 0;
2732
2827
  const olderHref = next ? `${toHref(path)}?cursor=${next}` : void 0;
2733
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ListPage, { list, ...olderHref ? { olderHref } : {}, ...options.list?.description ? { description: options.list.description } : {}, components: options.components, slots: options.slots, locale, toHref, origin: options.siteOrigin, path, jsonLd: options.jsonLd, cursor });
2828
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ListPage, { list, ...olderHref ? { olderHref } : {}, ...options.list?.description ? { description: options.list.description } : {}, components: options.components, slots: options.slots, locale, toHref, origin: options.siteOrigin, path, jsonLd: options.jsonLd, cursor });
2734
2829
  }
2735
2830
  case "redirect": {
2736
2831
  const to = safeRedirectTarget(result.to);
@@ -2745,7 +2840,7 @@ function hylePage(options) {
2745
2840
  (0, import_navigation3.notFound)();
2746
2841
  }
2747
2842
  } catch (error) {
2748
- if (isRejectedRequest(error)) (0, import_navigation3.notFound)();
2843
+ if (isNotFoundError(error, cursor)) (0, import_navigation3.notFound)();
2749
2844
  if (!options.onError) throw error;
2750
2845
  console.error(`hyle: ${error instanceof Error ? error.name : "UnknownError"}`);
2751
2846
  return options.onError(error);
@@ -2846,8 +2941,9 @@ function hyleMetadata(options) {
2846
2941
  };
2847
2942
  return Object.keys(types).length ? { ...alternates, types } : alternates;
2848
2943
  };
2944
+ let cursor;
2849
2945
  try {
2850
- const cursor = options.paginate === "searchParams" ? validCursor((await searchParams)?.cursor) : void 0;
2946
+ cursor = options.paginate === "searchParams" ? validCursor((await searchParams)?.cursor) : void 0;
2851
2947
  const result = await resolve(path, locale, options.listLimit, cursor, options.layout === "docs" ? "tree" : void 0);
2852
2948
  const parentMeta = parent ? await parent : void 0;
2853
2949
  const parentImages = parentMeta?.openGraph?.images;
@@ -2923,7 +3019,7 @@ function hyleMetadata(options) {
2923
3019
  } : {}
2924
3020
  };
2925
3021
  } catch (error) {
2926
- if (isRejectedRequest(error)) return {};
3022
+ if (isNotFoundError(error, cursor)) return {};
2927
3023
  throw error;
2928
3024
  }
2929
3025
  };
@@ -3040,10 +3136,7 @@ function mountsLoader(config) {
3040
3136
  lastKnownGood.set(key, { loaded, at: Date.now() });
3041
3137
  return loaded;
3042
3138
  } catch (error) {
3043
- if (isRejectedRequest(error)) {
3044
- lastKnownGood.delete(key);
3045
- return NONE;
3046
- }
3139
+ (0, import_navigation5.unstable_rethrow)(error);
3047
3140
  if (error instanceof Cp1ClientError && (error.status === 401 || error.status === 403)) {
3048
3141
  lastKnownGood.delete(key);
3049
3142
  throw error;
@@ -3175,7 +3268,7 @@ function createMarkdownRoute(options) {
3175
3268
  }
3176
3269
  return reply(null, 404);
3177
3270
  } catch (error) {
3178
- if (isRejectedRequest(error)) return reply(null, 404);
3271
+ if (isNotFoundError(error)) return reply(null, 404);
3179
3272
  console.error(`hyle: ${error instanceof Error ? error.name : "UnknownError"}`);
3180
3273
  return reply(null, 502);
3181
3274
  }
@@ -3226,8 +3319,34 @@ var DEFAULT_TIMEOUT_MS3 = 3e4;
3226
3319
  var CACHE_CONTROL = "public, max-age=3600, s-maxage=86400, stale-while-revalidate=86400";
3227
3320
  var PARTIAL_CACHE_CONTROL = "no-store";
3228
3321
  var SAFE_HEADERS = { "X-Content-Type-Options": "nosniff", "Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox" };
3322
+ var PREVIEW_HEADERS = { "Cache-Control": "no-store", "Referrer-Policy": "no-referrer", "X-Robots-Tag": "noindex, nofollow" };
3229
3323
  var empty = (status, headers = {}) => new Response(null, { status, headers: { "Cache-Control": "no-store", ...headers } });
3230
3324
  var isSwitchedOff3 = (value) => ["0", "false"].includes(value?.trim().toLowerCase() ?? "");
3325
+ var THEME_CACHE_CONTROL = "public, max-age=31536000, immutable";
3326
+ var OUTDATED_THEME_CACHE_CONTROL = "public, max-age=60";
3327
+ var THEME_SCOPE_HEADER = "cp-theme-scope";
3328
+ var MAX_THEME_BYTES = 256 * 1024;
3329
+ var sha256Hex = async (text) => Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text))), (byte) => byte.toString(16).padStart(2, "0")).join("");
3330
+ async function serveTheme(client, scope, hash, timeoutMs, head) {
3331
+ try {
3332
+ const upstream = await client.theme({ timeoutMs });
3333
+ const type = upstream.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
3334
+ if (upstream.status === 404) return empty(await isNotFoundResponse(upstream) ? 404 : 502);
3335
+ if (upstream.status !== 200 || type !== "text/css") {
3336
+ void upstream.body?.cancel().catch(() => {
3337
+ });
3338
+ return empty(502);
3339
+ }
3340
+ const css = await readCapped(upstream, MAX_THEME_BYTES);
3341
+ const current = await sha256Hex(css);
3342
+ if (current !== hash && upstream.headers.get(THEME_SCOPE_HEADER) !== scope) return empty(404);
3343
+ const cache = current === hash ? THEME_CACHE_CONTROL : OUTDATED_THEME_CACHE_CONTROL;
3344
+ const headers = { "Content-Type": "text/css; charset=utf-8", "Cache-Control": cache, ETag: `"${current}"`, ...SAFE_HEADERS };
3345
+ return new Response(head ? null : css, { status: 200, headers });
3346
+ } catch {
3347
+ return empty(502);
3348
+ }
3349
+ }
3231
3350
  function capped(body, max) {
3232
3351
  let seen = 0;
3233
3352
  return body.pipeThrough(
@@ -3244,18 +3363,28 @@ function createAssetRoute(options) {
3244
3363
  let client;
3245
3364
  const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
3246
3365
  async function serve(req, ctx2, head) {
3366
+ const previewToken = new URL(req.url).searchParams.get(PREVIEW_PARAM);
3367
+ const res = await relay(req, ctx2, head, previewToken);
3368
+ if (previewToken !== null) for (const [name, value] of Object.entries(PREVIEW_HEADERS)) res.headers.set(name, value);
3369
+ return res;
3370
+ }
3371
+ async function relay(req, ctx2, head, previewToken) {
3247
3372
  if (isSwitchedOff3((options.env ?? process.env).HYLE_CONTENT_ENABLED)) return empty(404);
3248
3373
  const file = (await ctx2.params).file;
3249
- if (typeof file !== "string" || !ASSET_FILE.test(file)) return empty(404);
3374
+ const [, themeScope, themeHash] = typeof file === "string" ? THEME_FILE.exec(file) ?? [] : [];
3375
+ if (typeof file !== "string" || !themeHash && !ASSET_FILE.test(file)) return empty(404);
3376
+ if (previewToken !== null && !PREVIEW_TOKEN.test(previewToken)) return empty(404);
3250
3377
  try {
3251
3378
  client ??= createHyleClient({ baseUrl: options.baseUrl?.trim() ?? "", token: options.token?.trim() ?? "", ...options.fetch ? { fetch: options.fetch } : {} });
3252
3379
  } catch {
3253
3380
  return empty(404);
3254
3381
  }
3382
+ if (themeScope && themeHash) return serveTheme(client, themeScope, themeHash, options.timeoutMs ?? DEFAULT_TIMEOUT_MS3, head);
3255
3383
  let upstream;
3256
3384
  try {
3257
3385
  upstream = await client.asset(file, {
3258
3386
  timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS3,
3387
+ ...previewToken === null ? {} : { previewToken },
3259
3388
  headers: { range: req.headers.get("range"), "if-range": req.headers.get("if-range"), "if-none-match": req.headers.get("if-none-match") }
3260
3389
  });
3261
3390
  } catch {
@@ -3268,10 +3397,16 @@ function createAssetRoute(options) {
3268
3397
  drop();
3269
3398
  return new Response(null, { status: 304, headers: { "Cache-Control": CACHE_CONTROL, Vary: "Range", ...SAFE_HEADERS, ...etag ? { ETag: etag } : {} } });
3270
3399
  }
3271
- if (upstream.status === 404 || upstream.status === 416) {
3400
+ if (upstream.status === 404) return empty(await isNotFoundResponse(upstream) ? 404 : 502);
3401
+ if (upstream.status === 416) {
3272
3402
  drop();
3273
- const range = upstream.status === 416 ? upstream.headers.get("content-range") : null;
3274
- return empty(upstream.status, range ? { "Content-Range": range } : {});
3403
+ const range = upstream.headers.get("content-range");
3404
+ return empty(416, range ? { "Content-Range": range } : {});
3405
+ }
3406
+ if (upstream.status === 429 && previewToken !== null) {
3407
+ drop();
3408
+ const wait = upstream.headers.get("retry-after");
3409
+ return empty(429, wait ? { "Retry-After": wait } : {});
3275
3410
  }
3276
3411
  const type = upstream.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
3277
3412
  const length = Number(upstream.headers.get("content-length"));
@@ -3295,7 +3430,7 @@ function createAssetRoute(options) {
3295
3430
  }
3296
3431
 
3297
3432
  // src/next/og.tsx
3298
- var import_jsx_runtime12 = require("react/jsx-runtime");
3433
+ var import_jsx_runtime13 = require("react/jsx-runtime");
3299
3434
  var SIZE = { width: 1200, height: 630 };
3300
3435
  var MAX_TITLE = 140;
3301
3436
  function createOgImageRoute(options) {
@@ -3320,14 +3455,14 @@ function createOgImageRoute(options) {
3320
3455
  if (result.kind !== "article") return new Response(null, { status: 404 });
3321
3456
  title = result.publication.title;
3322
3457
  } catch (error) {
3323
- return new Response(null, { status: isRejectedRequest(error) ? 404 : 502 });
3458
+ return new Response(null, { status: isNotFoundError(error) ? 404 : 502 });
3324
3459
  }
3325
3460
  const chars = [...title];
3326
3461
  const shown = chars.length > MAX_TITLE ? `${chars.slice(0, MAX_TITLE - 1).join("")}\u2026` : title;
3327
3462
  return new import_og.ImageResponse(
3328
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { style: { display: "flex", flexDirection: "column", justifyContent: "space-between", width: "100%", height: "100%", padding: 80, background: "#111827", color: "#ffffff" }, children: [
3329
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { fontSize: 64, fontWeight: 700, lineHeight: 1.2 }, children: shown }),
3330
- options.siteName ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { fontSize: 32, color: "#9ca3af" }, children: options.siteName }) : null
3463
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { style: { display: "flex", flexDirection: "column", justifyContent: "space-between", width: "100%", height: "100%", padding: 80, background: "#111827", color: "#ffffff" }, children: [
3464
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { style: { fontSize: 64, fontWeight: 700, lineHeight: 1.2 }, children: shown }),
3465
+ options.siteName ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { style: { fontSize: 32, color: "#9ca3af" }, children: options.siteName }) : null
3331
3466
  ] }),
3332
3467
  // shortcut: @vercel/og fetches Google Fonts / emoji assets at render time for non-Latin titles and emoji (no switch to disable it), upgrade to a satori render with bundled fonts if a host needs zero egress.
3333
3468
  { ...SIZE, headers: { "cache-control": "public, max-age=3600, s-maxage=31536000, immutable" } }
@@ -3335,6 +3470,38 @@ function createOgImageRoute(options) {
3335
3470
  }
3336
3471
  };
3337
3472
  }
3473
+
3474
+ // src/next/preview.tsx
3475
+ var import_navigation7 = require("next/navigation");
3476
+ var import_jsx_runtime14 = require("react/jsx-runtime");
3477
+ var hylePreviewMetadata = { robots: { index: false, follow: false }, referrer: "no-referrer" };
3478
+ var BANNER = {
3479
+ position: "sticky",
3480
+ top: 0,
3481
+ zIndex: 2147483647,
3482
+ padding: "8px 16px",
3483
+ background: "#fde047",
3484
+ color: "#1a1a1a",
3485
+ font: "600 14px/1.4 system-ui, sans-serif",
3486
+ textAlign: "center"
3487
+ };
3488
+ function hylePreviewPage(options) {
3489
+ return async function HylePreviewPage({ searchParams }) {
3490
+ const { token } = await searchParams ?? {};
3491
+ const result = await createHyleClient(options).preview(typeof token === "string" ? token : void 0);
3492
+ if (result.kind !== "preview") (0, import_navigation7.notFound)();
3493
+ const { article } = result;
3494
+ const { locale } = article.publication;
3495
+ const toHref = (sitePath, linkLocale = locale) => (options.localePrefix?.(linkLocale) ?? "") + sitePath;
3496
+ const props = { article, components: options.components, slots: options.slots, locale, toHref };
3497
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
3498
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("meta", { name: "robots", content: "noindex, nofollow" }),
3499
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("meta", { name: "referrer", content: "no-referrer" }),
3500
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { role: "status", style: BANNER, children: "Unpublished draft preview" }),
3501
+ options.layout === "docs" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DocsPage, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ArticlePage, { ...props })
3502
+ ] });
3503
+ };
3504
+ }
3338
3505
  // Annotate the CommonJS export names for ESM import in node:
3339
3506
  0 && (module.exports = {
3340
3507
  ENGAGE_CSRF_HEADER,
@@ -3354,6 +3521,8 @@ function createOgImageRoute(options) {
3354
3521
  hyleFeedLink,
3355
3522
  hyleMetadata,
3356
3523
  hylePage,
3524
+ hylePreviewMetadata,
3525
+ hylePreviewPage,
3357
3526
  hyleRootMetadata,
3358
3527
  hyleRootPage,
3359
3528
  hyleRootSitemap,