@tdacorp/hyle-sdk 0.17.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 (92) hide show
  1. package/README.md +261 -42
  2. package/dist/check-routes-bin.js +190 -53
  3. package/dist/{chunk-6VOHFFA5.js → chunk-7T5EEJHK.js} +2 -2
  4. package/dist/chunk-DUPT6XLB.js +57 -0
  5. package/dist/chunk-IW3TUD4G.js +841 -0
  6. package/dist/{chunk-MGSUQBDW.js → chunk-KU7LWK4E.js} +249 -24
  7. package/dist/{chunk-BUJFMR3M.js → chunk-QVYQM5R2.js} +15 -6
  8. package/dist/chunk-SFFBZFEN.js +178 -0
  9. package/dist/chunk-U74B7AUG.js +398 -0
  10. package/dist/chunk-ZIW6FDU2.js +1126 -0
  11. package/dist/client-BGjmEWhN.d.cts +207 -0
  12. package/dist/client-D0LTpr3Y.d.ts +207 -0
  13. package/dist/code-copy.cjs +74 -0
  14. package/dist/code-copy.d.cts +18 -0
  15. package/dist/code-copy.d.ts +18 -0
  16. package/dist/code-copy.js +50 -0
  17. package/dist/comments.cjs +738 -280
  18. package/dist/comments.d.cts +66 -3
  19. package/dist/comments.d.ts +66 -3
  20. package/dist/comments.js +419 -331
  21. package/dist/{diagram-viewer-FJPED4SN.js → diagram-viewer-XY3CG75U.js} +62 -21
  22. package/dist/docs-enhance.cjs +7 -4
  23. package/dist/docs-enhance.d.cts +5 -3
  24. package/dist/docs-enhance.d.ts +5 -3
  25. package/dist/docs-enhance.js +8 -5
  26. package/dist/{embed-DNTZ2UXv.d.ts → embed-CbtsbZs3.d.cts} +5 -3
  27. package/dist/{embed-BmdwA2G9.d.cts → embed-Cf_2ZR5x.d.ts} +5 -3
  28. package/dist/fragment-alias.cjs +51 -0
  29. package/dist/fragment-alias.d.cts +7 -0
  30. package/dist/fragment-alias.d.ts +7 -0
  31. package/dist/fragment-alias.js +27 -0
  32. package/dist/html.cjs +886 -0
  33. package/dist/html.d.cts +20 -0
  34. package/dist/html.d.ts +20 -0
  35. package/dist/html.js +45 -0
  36. package/dist/index.cjs +244 -24
  37. package/dist/index.d.cts +22 -68
  38. package/dist/index.d.ts +22 -68
  39. package/dist/index.js +12 -2
  40. package/dist/{labels-nmukKYgL.d.cts → labels-CrA-iqTN.d.cts} +9 -0
  41. package/dist/{labels-nmukKYgL.d.ts → labels-CrA-iqTN.d.ts} +9 -0
  42. package/dist/mermaid-diagram.cjs +441 -125
  43. package/dist/mermaid-diagram.d.cts +23 -7
  44. package/dist/mermaid-diagram.d.ts +23 -7
  45. package/dist/mermaid-diagram.js +213 -51
  46. package/dist/mermaid-image.cjs +137 -60
  47. package/dist/mermaid-image.d.cts +4 -3
  48. package/dist/mermaid-image.d.ts +4 -3
  49. package/dist/mermaid-image.js +27 -28
  50. package/dist/next.cjs +836 -304
  51. package/dist/next.d.cts +45 -20
  52. package/dist/next.d.ts +45 -20
  53. package/dist/next.js +151 -40
  54. package/dist/print-coordinator.cjs +157 -0
  55. package/dist/print-coordinator.d.cts +27 -0
  56. package/dist/print-coordinator.d.ts +27 -0
  57. package/dist/print-coordinator.js +83 -0
  58. package/dist/react.cjs +603 -240
  59. package/dist/react.d.cts +148 -30
  60. package/dist/react.d.ts +148 -30
  61. package/dist/react.js +26 -4
  62. package/dist/reactions.cjs +653 -0
  63. package/dist/reactions.d.cts +27 -0
  64. package/dist/reactions.d.ts +27 -0
  65. package/dist/reactions.js +364 -0
  66. package/dist/{resolve-euZ4-aC9.d.cts → resolve-BnIv7aB7.d.cts} +2 -2
  67. package/dist/{resolve-Ae7UFjsQ.d.ts → resolve-BysHtZ_i.d.ts} +2 -2
  68. package/dist/revalidation-callback-BQl77tQR.d.cts +75 -0
  69. package/dist/revalidation-callback-BQl77tQR.d.ts +75 -0
  70. package/dist/sanitize-BpY_AdZh.d.cts +23 -0
  71. package/dist/sanitize-BpY_AdZh.d.ts +23 -0
  72. package/dist/styles.css +100 -29
  73. package/dist/toc-spy.cjs +60 -0
  74. package/dist/toc-spy.d.cts +15 -0
  75. package/dist/toc-spy.d.ts +15 -0
  76. package/dist/toc-spy.js +36 -0
  77. package/dist/{types-Czt887Iv.d.cts → types-D09Z072G.d.cts} +57 -2
  78. package/dist/{types-Czt887Iv.d.ts → types-D09Z072G.d.ts} +57 -2
  79. package/dist/use-cache.cjs +89 -13
  80. package/dist/use-cache.d.cts +12 -5
  81. package/dist/use-cache.d.ts +12 -5
  82. package/dist/use-cache.js +8 -8
  83. package/dist/youtube-facade.cjs +50 -0
  84. package/dist/youtube-facade.d.cts +17 -0
  85. package/dist/youtube-facade.d.ts +17 -0
  86. package/dist/youtube-facade.js +26 -0
  87. package/package.json +16 -3
  88. package/dist/chunk-67IOIAVW.js +0 -35
  89. package/dist/chunk-DMK4XQLU.js +0 -1556
  90. package/dist/chunk-PJMJMP66.js +0 -63
  91. package/dist/revalidation-callback-D7Ms_Puz.d.cts +0 -42
  92. package/dist/revalidation-callback-D7Ms_Puz.d.ts +0 -42
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,7 +108,43 @@ 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
136
+ var RENDERER_VERSION = "4";
137
+ function applyCredential(headers, credential, method, url) {
138
+ if (!credential.auth) {
139
+ headers.set("authorization", `Bearer ${credential.token}`);
140
+ return void 0;
141
+ }
142
+ const { workspaceId } = credential;
143
+ return credential.auth({ method, url }).then((extra) => {
144
+ for (const [name, value] of Object.entries(extra)) headers.set(name, value);
145
+ headers.set("cp-workspace", workspaceId);
146
+ });
147
+ }
95
148
  var DEFAULT_TIMEOUT_MS = 1e4;
96
149
  var DEFAULT_MAX_RESPONSE_BYTES = 5 * 1024 * 1024;
97
150
  var LOOPBACK = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
@@ -114,6 +167,17 @@ async function readCapped(res, max) {
114
167
  }
115
168
  return Buffer.concat(chunks).toString("utf8");
116
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
+ }
117
181
  var KINDS = /* @__PURE__ */ new Set(["article", "list", "redirect", "notfound", "disabled"]);
118
182
  var isStrings = (value) => Array.isArray(value) && value.every((v) => typeof v === "string");
119
183
  function isMounts(data) {
@@ -133,14 +197,16 @@ function checkBaseUrl(baseUrl, allowInsecureHttp) {
133
197
  }
134
198
  function createHyleClient(options) {
135
199
  checkBaseUrl(options.baseUrl, options.allowInsecureHttp);
136
- if (!options.token) throw new TypeError("token is required");
200
+ if (!options.auth && !options.token) throw new TypeError("token is required");
137
201
  const base = options.baseUrl.replace(/\/+$/, "");
138
202
  const fetchImpl = options.fetch ?? fetch;
139
203
  async function get(pathname, query, init) {
140
204
  const url = new URL(`${base}${pathname}`);
141
205
  url.search = query.toString();
142
206
  const headers = new Headers(init?.headers);
143
- headers.set("authorization", `Bearer ${options.token}`);
207
+ headers.set("cp-renderer-version", RENDERER_VERSION);
208
+ const applied = applyCredential(headers, options, "GET", url.toString());
209
+ if (applied) await applied;
144
210
  const timeout = AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
145
211
  const signal = init?.signal ? AbortSignal.any([init.signal, timeout]) : timeout;
146
212
  const res = await fetchImpl(url.toString(), { ...init, method: "GET", headers, redirect: "error", signal });
@@ -180,16 +246,48 @@ function createHyleClient(options) {
180
246
  if (data?.cp === 1 && data.kind === "mounts" && isMounts(data)) return data;
181
247
  throw failure(reply2);
182
248
  }
249
+ async function pushPosts(opts) {
250
+ if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(opts.section)) throw new TypeError("section must be a section slug");
251
+ const query = new URLSearchParams();
252
+ if (opts.cursor !== void 0) query.set("cursor", opts.cursor);
253
+ const reply2 = await get(`/cp1/read/sections/${opts.section}/posts`, query, opts.init);
254
+ const data = reply2.parsed?.data;
255
+ if (data?.cp === 1 && data.kind === "push_posts" && Array.isArray(data.posts) && typeof data.complete === "boolean") return data;
256
+ throw failure(reply2);
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
+ }
183
268
  async function asset(file, opts = {}) {
184
269
  if (!ASSET_FILE.test(file)) throw new TypeError("asset file must be <uuid>[.<ext>]");
185
- const headers = new Headers({ authorization: `Bearer ${options.token}` });
270
+ const { previewToken } = opts;
271
+ if (previewToken !== void 0 && !PREVIEW_TOKEN.test(previewToken)) throw new TypeError("previewToken is not a preview token");
272
+ const url = `${base}/cp1/read/assets/${file}`;
273
+ const headers = new Headers();
274
+ const applied = applyCredential(headers, options, "GET", url);
275
+ if (applied) await applied;
186
276
  for (const name of ["range", "if-range", "if-none-match"]) {
187
277
  const value = opts.headers?.[name];
188
278
  if (value) headers.set(name, value);
189
279
  }
190
- return fetchImpl(`${base}/cp1/read/assets/${file}`, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS) });
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" } });
191
282
  }
192
- return { resolve, mounts, asset };
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;
288
+ return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS) });
289
+ }
290
+ return { resolve, mounts, pushPosts, preview, asset, theme };
193
291
  }
194
292
 
195
293
  // src/delivery-dedupe.ts
@@ -266,6 +364,35 @@ function isValidCacheTag(tag2) {
266
364
  // src/revalidation-callback.ts
267
365
  var MAX_BODY_BYTES = 65536;
268
366
  var MAX_TAGS = 1e3;
367
+ var HOOK_WAIT_MS = 3e3;
368
+ var COMMENT_EVENT_TYPES = ["comment.held", "comment.reply", "comment.approved", "comment.hidden"];
369
+ var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
370
+ var isText = (v) => typeof v === "string" && v.length > 0;
371
+ var isTextOrNull = (v) => v === null || isText(v);
372
+ var isEventPath = (v) => typeof v === "string" && v.startsWith("/") && !v.startsWith("//") && v.length <= 2048 && !/[\\\u0000-\u001f\u007f]/.test(v);
373
+ function parseCommentEvent(payload) {
374
+ if (!isRecord(payload) || payload.cp !== 1 || !isRecord(payload.data)) return void 0;
375
+ const type = COMMENT_EVENT_TYPES.find((t) => t === payload.type);
376
+ const { id, created_at, workspace_id, event_id, data } = payload;
377
+ if (!type || !isText(id) || !isText(created_at) || !isText(workspace_id) || !isText(event_id)) return void 0;
378
+ const { comment_id, parent_comment_id, publication_path, reader_sub, parent_reader_sub, status } = data;
379
+ if (!isText(comment_id) || !isTextOrNull(parent_comment_id) || !isEventPath(publication_path) || !isTextOrNull(reader_sub) || !isTextOrNull(parent_reader_sub)) return void 0;
380
+ if (status !== "held" && status !== "visible" && status !== "hidden") return void 0;
381
+ return { cp: 1, id, type, created_at, workspace_id, event_id, data: { comment_id, parent_comment_id, publication_path, reader_sub, parent_reader_sub, status } };
382
+ }
383
+ async function runHook(hook, event) {
384
+ let timer;
385
+ try {
386
+ await Promise.race([
387
+ Promise.resolve().then(() => hook(event)),
388
+ new Promise((_, reject) => timer = setTimeout(() => reject(new Error("timeout")), HOOK_WAIT_MS))
389
+ ]);
390
+ } catch {
391
+ console.error(`hyle: onCommentEvent failed or timed out for ${event.type} ${event.id}`);
392
+ } finally {
393
+ clearTimeout(timer);
394
+ }
395
+ }
269
396
  function createRevalidationCallbackRoute(options) {
270
397
  const dedupe = new DeliveryDedupe(options.dedupeCapacity);
271
398
  return {
@@ -300,7 +427,7 @@ function createRevalidationCallbackRoute(options) {
300
427
  if (body.workspace_id !== options.workspaceId) {
301
428
  return okResponse(0);
302
429
  }
303
- const deliveryId = req.headers.get("hyle-delivery-id");
430
+ const deliveryId = typeof body.id === "string" ? body.id : void 0;
304
431
  if (deliveryId && dedupe.has(deliveryId)) {
305
432
  return okResponse(0);
306
433
  }
@@ -315,6 +442,9 @@ function createRevalidationCallbackRoute(options) {
315
442
  return new Response(null, { status: 500 });
316
443
  }
317
444
  if (deliveryId) dedupe.add(deliveryId);
445
+ const hook = options.onCommentEvent;
446
+ const event = hook && parseCommentEvent(body);
447
+ if (hook && event) await runHook(hook, event);
318
448
  return okResponse(purged);
319
449
  }
320
450
  };
@@ -456,9 +586,16 @@ var SHAPES = {
456
586
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M9 1.8v3h3" })
457
587
  ] }),
458
588
  chev: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m6 3.5 4.5 4.5L6 12.5" }),
589
+ "chev-up": /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m3.5 10 4.5-4.5L12.5 10" }),
459
590
  "chev-down": /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m3.5 6 4.5 4.5L12.5 6" }),
460
591
  "chev-left": /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 3.5 5.5 8 10 12.5" }),
461
592
  x: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m4 4 8 8M12 4l-8 8" }),
593
+ important: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 2.5h10a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H8l-3.5 2.8v-2.8H3a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1zM8 5v2.8M8 9.5v.1" }),
594
+ copy: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
595
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "5.5", y: "5.5", width: "8", height: "8", rx: "1.3" }),
596
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10.5 5.5v-2a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2" })
597
+ ] }),
598
+ check: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m3 8.5 3.2 3L13 4.5" }),
462
599
  heart: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 13.5S2.2 10 2.2 6.1A3 3 0 0 1 8 5a3 3 0 0 1 5.8 1.1C13.8 10 8 13.5 8 13.5z" }),
463
600
  reply: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M6.5 3.5 2.5 7.5l4 4M2.5 7.5h6a5 5 0 0 1 5 5" }),
464
601
  clock: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
@@ -488,7 +625,7 @@ var HastLimitError = class extends Error {
488
625
  };
489
626
  var MAX_NODES = 2e4;
490
627
  var MAX_TEXT = 512 * 1024;
491
- var MAX_DEPTH = 128;
628
+ var MAX_DEPTH2 = 128;
492
629
  var MAX_SRCDOC = 1024 * 1024;
493
630
  var DROP = /* @__PURE__ */ new Set(["script", "style", "template", "noscript"]);
494
631
  var VOID = /* @__PURE__ */ new Set(["br", "hr", "img", "input", "path"]);
@@ -497,8 +634,15 @@ var isScalar = (v) => typeof v === "string" || typeof v === "number" || typeof v
497
634
  var matches = (re) => (v) => typeof v === "string" && re.test(v);
498
635
  var ID_PREFIX = "user-content-";
499
636
  var scopeId = (id) => id.startsWith(ID_PREFIX) ? id : ID_PREFIX + id;
500
- var ID_BODY = /^[\p{L}\p{N}_:.-]{1,180}$/u;
501
- var isIdValue = (v) => typeof v === "string" && ID_BODY.test(v.startsWith(ID_PREFIX) ? v.slice(ID_PREFIX.length) : v);
637
+ var ID_BODY = /^[\p{L}\p{M}\p{N}\p{Pc}:.-]{1,180}$/u;
638
+ function isIdValue(v) {
639
+ if (typeof v !== "string") return false;
640
+ try {
641
+ return ID_BODY.test(decodeURIComponent(v.startsWith(ID_PREFIX) ? v.slice(ID_PREFIX.length) : v));
642
+ } catch {
643
+ return false;
644
+ }
645
+ }
502
646
  var CLASS_TOKEN = /^[A-Za-z_][\w:-]*$/;
503
647
  var classTokens = (v) => {
504
648
  const tokens = Array.isArray(v) ? v : typeof v === "string" ? v.split(/\s+/) : [];
@@ -511,6 +655,7 @@ var isLength = matches(/^[\d.]+(em|px|%)?$/);
511
655
  var STYLE_PROPS = /* @__PURE__ */ new Set(["height", "vertical-align", "margin-left", "margin-right", "margin-top", "margin-bottom", "top", "width", "min-width", "border-bottom-width", "padding-left"]);
512
656
  var STYLE_LENGTH = /^(-?\d+(?:\.\d+)?)(em|px|%)?$/;
513
657
  var MAX_STYLE_MAGNITUDE = 100;
658
+ var MAX_MARGIN_MAGNITUDE = 20;
514
659
  function isKatexStyle(v, ctx2) {
515
660
  if (typeof v !== "string" || !ctx2.katex) return false;
516
661
  return v.split(";").filter((d) => d !== "").every((decl) => {
@@ -518,7 +663,8 @@ function isKatexStyle(v, ctx2) {
518
663
  if (extra.length > 0 || prop === void 0 || value === void 0) return false;
519
664
  if (prop === "position") return value === "relative";
520
665
  const m = STYLE_LENGTH.exec(value);
521
- return STYLE_PROPS.has(prop) && m !== null && Math.abs(Number(m[1])) <= MAX_STYLE_MAGNITUDE;
666
+ const max = prop.startsWith("margin-") ? MAX_MARGIN_MAGNITUDE : MAX_STYLE_MAGNITUDE;
667
+ return STYLE_PROPS.has(prop) && m !== null && Math.abs(Number(m[1])) <= max;
522
668
  });
523
669
  }
524
670
  function isSafeUrl(value, kind) {
@@ -545,12 +691,14 @@ var ENTITIES = { "&#x3c;": "<", "&#x26;": "&", "&lt;": "<", "&gt;": ">", "&amp;"
545
691
  function mermaidSource(srcDoc) {
546
692
  return MERMAID_SRCDOC.exec(srcDoc)?.[1]?.replace(/&(?:#x3c|#x26|#x27|lt|gt|amp|quot);/gi, (e) => ENTITIES[e.toLowerCase()]);
547
693
  }
548
- 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})$`);
549
695
  var isRenderRef = matches(RENDER_REF);
550
696
  function diagramRender(value) {
551
697
  const m = typeof value === "string" ? RENDER_REF.exec(value) : null;
552
698
  return m ? { src: hostAssetSrc(m[1]), width: Number(m[2]), height: Number(m[3]) } : void 0;
553
699
  }
700
+ var YOUTUBE_WATCH = /^https:\/\/www\.youtube\.com\/watch\?v=([A-Za-z0-9_-]{11})$/;
701
+ var youtubeId = (href) => typeof href === "string" ? YOUTUBE_WATCH.exec(href)?.[1] : void 0;
554
702
  var heading = { id: isIdValue, className: isClass };
555
703
  var ATTRS = new Map(
556
704
  Object.entries({
@@ -566,6 +714,7 @@ var ATTRS = new Map(
566
714
  tbody: {},
567
715
  tr: {},
568
716
  ol: {},
717
+ kbd: {},
569
718
  ul: { className: isClass },
570
719
  li: { id: isIdValue, className: isClass },
571
720
  h1: heading,
@@ -574,8 +723,8 @@ var ATTRS = new Map(
574
723
  h4: heading,
575
724
  h5: heading,
576
725
  h6: heading,
577
- a: { href: isHref, id: isIdValue, ariaDescribedBy: isIdValue, ariaLabel: isString, dataFootnoteRef: isScalar, dataFootnoteBackref: isScalar, className: isClass },
578
- img: { src: isSrc, alt: isString, width: isPixels, height: isPixels },
726
+ a: { href: isHref, id: isIdValue, ariaDescribedBy: isIdValue, ariaLabel: isString, dataFootnoteRef: isScalar, dataFootnoteBackref: isScalar, dataEmbed: matches(/^youtube$/), className: isClass },
727
+ img: { src: isSrc, alt: isString, title: isString, width: isPixels, height: isPixels },
579
728
  table: {},
580
729
  th: { scope: matches(/^(row|col|rowgroup|colgroup)$/), align: isAlign },
581
730
  td: { align: isAlign },
@@ -594,12 +743,14 @@ var ATTRS = new Map(
594
743
  );
595
744
  var isObject = (v) => typeof v === "object" && v !== null;
596
745
  function textOf(node, depth = 0) {
597
- if (!isObject(node) || depth > MAX_DEPTH) return "";
746
+ if (!isObject(node) || depth > MAX_DEPTH2) return "";
598
747
  if (node.type === "text") return typeof node.value === "string" ? node.value : "";
599
748
  return Array.isArray(node.children) ? node.children.map((c) => textOf(c, depth + 1)).join("") : "";
600
749
  }
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)));
751
+ var collapse = (text) => text.replace(/\s+/g, " ").trim();
601
752
  var CALLOUT_MARKER = /^\s*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*/i;
602
- var CALLOUT_KIND = { note: "note", tip: "tip", important: "warning", warning: "warning", caution: "caution" };
753
+ var CALLOUT_KIND = { note: "note", tip: "tip", important: "important", warning: "warning", caution: "caution" };
603
754
  function toCallout(children) {
604
755
  const first = children.find((c) => c.type === "element");
605
756
  const lead = first?.tagName === "p" ? first.children[0] : void 0;
@@ -611,8 +762,23 @@ function toCallout(children) {
611
762
  const kind = CALLOUT_KIND[(marker[1] ?? "note").toLowerCase()] ?? "note";
612
763
  return { type: "element", tagName: "callout", properties: { kind }, children: [...body, ...children.slice(children.indexOf(first) + 1)] };
613
764
  }
765
+ var isBlank = (node) => node.type === "text" && node.value.trim() === "";
766
+ function soleElement(children) {
767
+ const [only, ...more] = children.filter((c) => !isBlank(c));
768
+ return more.length === 0 && only?.type === "element" ? only : void 0;
769
+ }
770
+ function toFigure(children) {
771
+ const only = soleElement(children);
772
+ const img = only?.tagName === "a" ? soleElement(only.children) : only;
773
+ if (!only || img?.tagName !== "img" || typeof img.properties.src !== "string") return void 0;
774
+ const { title, ...properties } = img.properties;
775
+ const bare = { ...img, properties };
776
+ const media = only === img ? bare : { ...only, children: [bare] };
777
+ const caption = typeof title === "string" && title.trim() ? [{ type: "element", tagName: "figcaption", properties: {}, children: [{ type: "text", value: title }] }] : [];
778
+ return { type: "element", tagName: "figure", properties: { dataSlotComponent: "Image" }, children: [media, ...caption] };
779
+ }
614
780
  function clean(node, depth, ctx2, budget) {
615
- if (!isObject(node) || depth > MAX_DEPTH) return [];
781
+ if (!isObject(node) || depth > MAX_DEPTH2) return [];
616
782
  if (++budget.nodes > MAX_NODES) throw new HastLimitError("content has too many nodes");
617
783
  if (node.type === "text") {
618
784
  if (typeof node.value !== "string") return [];
@@ -644,6 +810,11 @@ function clean(node, depth, ctx2, budget) {
644
810
  }
645
811
  for (const key of ["id", "ariaDescribedBy"]) if (typeof properties[key] === "string") properties[key] = scopeId(properties[key]);
646
812
  if (tag2 === "a" && typeof properties.href === "string" && properties.href.trim().startsWith("#")) properties.href = `#${scopeId(properties.href.trim().slice(1))}`;
813
+ if (tag2 === "a" && properties.dataEmbed !== void 0 && youtubeId(properties.href) === void 0) delete properties.dataEmbed;
814
+ if (tag2 === "p") {
815
+ const figure = toFigure(children);
816
+ if (figure) return [figure];
817
+ }
647
818
  if (tag2 === "blockquote") {
648
819
  const callout = toCallout(children);
649
820
  if (callout) return [callout];
@@ -655,9 +826,9 @@ function sanitizeHast(tree, title, description) {
655
826
  const raw = isObject(tree) && tree.type === "root" && Array.isArray(tree.children) ? tree.children : [];
656
827
  const elements = raw.filter((n) => isObject(n) && n.type === "element");
657
828
  const [first] = elements;
658
- const skip = title !== void 0 && isObject(first) && first.tagName === "h1" && textOf(first).trim() === title.trim() ? first : void 0;
829
+ const skip = title !== void 0 && isObject(first) && first.tagName === "h1" && collapse(textOf(first)) === collapse(title) ? first : void 0;
659
830
  const lead = elements[skip ? 1 : 0];
660
- const repeat = description && isObject(lead) && lead.tagName === "p" && textOf(lead).trim().startsWith(description.trim()) ? lead : void 0;
831
+ const repeat = description && isObject(lead) && lead.tagName === "p" && collapse(textOf(lead)) === collapse(description) && !holdsEmbed(lead) ? lead : void 0;
661
832
  const budget = { nodes: 0, text: 0 };
662
833
  return { type: "root", children: raw.filter((n) => n !== skip && n !== repeat).flatMap((n) => clean(n, 0, { katex: false }, budget)) };
663
834
  }
@@ -696,6 +867,7 @@ var COMMENT_LABELS_EN = {
696
867
  removed: "This comment was removed.",
697
868
  removedByModerator: "This comment was removed by a moderator.",
698
869
  removedByAuthor: "This comment was deleted by its author.",
870
+ unrenderable: "This comment cannot be displayed.",
699
871
  depthEnd: "Replies end at this depth",
700
872
  held: "Awaiting approval.",
701
873
  heldBanner: "Thanks, your comment is awaiting approval",
@@ -722,8 +894,39 @@ var COMMENT_LABELS_EN = {
722
894
  bannedBody: "Commenting is not available for your account on this site. You can still read every comment. If you think this is a mistake, contact the site team.",
723
895
  expired: "Your session ended. Sign in again to post. Your text is kept.",
724
896
  more: "Load more comments",
725
- truncated: "Showing the first 500 comments.",
726
- justNow: "just now"
897
+ truncated: "Only the first part of this discussion is shown.",
898
+ justNow: "just now",
899
+ react: "React",
900
+ reactions: "Reactions",
901
+ reactionLike: "Like",
902
+ reactionLove: "Love",
903
+ reactionInsightful: "Insightful",
904
+ reactionCelebrate: "Celebrate",
905
+ reactionSignIn: "Sign in to react, ",
906
+ reactionAddedLive: "{kind} reaction added",
907
+ reactionRemovedLive: "{kind} reaction removed",
908
+ reactionsLoading: "Loading reactions",
909
+ reactionsError: "Reactions could not be loaded",
910
+ votesOn: "Votes on the comment by {name}",
911
+ score: "Score {n}",
912
+ upvote: "Upvote",
913
+ downvote: "Downvote",
914
+ upvoteSignIn: "Sign in to upvote",
915
+ downvoteSignIn: "Sign in to downvote",
916
+ upvotedLive: "Upvoted. Score {n}",
917
+ downvotedLive: "Downvoted. Score {n}",
918
+ voteRemovedLive: "Vote removed. Score {n}",
919
+ voteRefused: "That vote was not accepted. You cannot vote on your own comment.",
920
+ slowDown: "Too many actions in a short time. Wait a moment and try again.",
921
+ sort: "Sort comments",
922
+ sortNewest: "Newest",
923
+ sortTop: "Top",
924
+ sortedNewestLive: "Showing newest comments first",
925
+ sortedTopLive: "Showing top comments first",
926
+ sortError: "The comments could not be sorted. Please try again.",
927
+ newerLater: "Newer comments appear after you load more.",
928
+ moreError: "More comments could not be loaded. Please try again.",
929
+ loadedLive: "{n} comments loaded"
727
930
  };
728
931
  var COMMENT_LABELS_FR = {
729
932
  heading: "Commentaires",
@@ -758,6 +961,7 @@ var COMMENT_LABELS_FR = {
758
961
  removed: "Ce commentaire a \xE9t\xE9 retir\xE9.",
759
962
  removedByModerator: "Ce commentaire a \xE9t\xE9 retir\xE9 par un mod\xE9rateur.",
760
963
  removedByAuthor: "Ce commentaire a \xE9t\xE9 supprim\xE9 par son auteur.",
964
+ unrenderable: "Ce commentaire ne peut pas \xEAtre affich\xE9.",
761
965
  depthEnd: "Les r\xE9ponses s'arr\xEAtent \xE0 ce niveau",
762
966
  held: "En attente d'approbation.",
763
967
  heldBanner: "Merci, votre commentaire est en attente d'approbation",
@@ -784,8 +988,39 @@ var COMMENT_LABELS_FR = {
784
988
  bannedBody: "Les commentaires ne sont pas disponibles pour votre compte sur ce site. Vous pouvez toujours tout lire. Si vous pensez \xE0 une erreur, contactez l'\xE9quipe du site.",
785
989
  expired: "Votre session a expir\xE9. Reconnectez-vous pour publier. Votre texte est conserv\xE9.",
786
990
  more: "Charger plus de commentaires",
787
- truncated: "Affichage des 500 premiers commentaires.",
788
- justNow: "\xE0 l'instant"
991
+ truncated: "Seul le d\xE9but de cette discussion est affich\xE9.",
992
+ justNow: "\xE0 l'instant",
993
+ react: "R\xE9agir",
994
+ reactions: "R\xE9actions",
995
+ reactionLike: "J'aime",
996
+ reactionLove: "J'adore",
997
+ reactionInsightful: "Instructif",
998
+ reactionCelebrate: "Bravo",
999
+ reactionSignIn: "Connectez-vous pour r\xE9agir, ",
1000
+ reactionAddedLive: "R\xE9action {kind} ajout\xE9e",
1001
+ reactionRemovedLive: "R\xE9action {kind} retir\xE9e",
1002
+ reactionsLoading: "Chargement des r\xE9actions",
1003
+ reactionsError: "Les r\xE9actions n'ont pas pu \xEAtre charg\xE9es",
1004
+ votesOn: "Votes sur le commentaire de {name}",
1005
+ score: "Score {n}",
1006
+ upvote: "Voter pour",
1007
+ downvote: "Voter contre",
1008
+ upvoteSignIn: "Connectez-vous pour voter pour",
1009
+ downvoteSignIn: "Connectez-vous pour voter contre",
1010
+ upvotedLive: "Vote pour enregistr\xE9. Score {n}",
1011
+ downvotedLive: "Vote contre enregistr\xE9. Score {n}",
1012
+ voteRemovedLive: "Vote retir\xE9. Score {n}",
1013
+ voteRefused: "Ce vote a \xE9t\xE9 refus\xE9. Vous ne pouvez pas voter pour votre propre commentaire.",
1014
+ slowDown: "Trop d'actions en peu de temps. Patientez un instant et r\xE9essayez.",
1015
+ sort: "Trier les commentaires",
1016
+ sortNewest: "R\xE9cents",
1017
+ sortTop: "Meilleurs",
1018
+ sortedNewestLive: "Commentaires les plus r\xE9cents en premier",
1019
+ sortedTopLive: "Meilleurs commentaires en premier",
1020
+ sortError: "Les commentaires n'ont pas pu \xEAtre tri\xE9s. R\xE9essayez.",
1021
+ newerLater: "Les commentaires plus r\xE9cents apparaissent apr\xE8s le chargement de la suite.",
1022
+ moreError: "La suite des commentaires n'a pas pu \xEAtre charg\xE9e. R\xE9essayez.",
1023
+ loadedLive: "{n} commentaires charg\xE9s"
789
1024
  };
790
1025
  var COMMENT_LABELS_ES = {
791
1026
  heading: "Comentarios",
@@ -820,6 +1055,7 @@ var COMMENT_LABELS_ES = {
820
1055
  removed: "Este comentario fue eliminado.",
821
1056
  removedByModerator: "Un moderador elimin\xF3 este comentario.",
822
1057
  removedByAuthor: "Su autor elimin\xF3 este comentario.",
1058
+ unrenderable: "Este comentario no se puede mostrar.",
823
1059
  depthEnd: "Las respuestas terminan en este nivel",
824
1060
  held: "Pendiente de aprobaci\xF3n.",
825
1061
  heldBanner: "Gracias, tu comentario est\xE1 pendiente de aprobaci\xF3n",
@@ -846,8 +1082,39 @@ var COMMENT_LABELS_ES = {
846
1082
  bannedBody: "Los comentarios no est\xE1n disponibles para tu cuenta en este sitio. A\xFAn puedes leerlos todos. Si crees que es un error, contacta con el equipo del sitio.",
847
1083
  expired: "Tu sesi\xF3n termin\xF3. Inicia sesi\xF3n de nuevo para publicar. Tu texto se conserva.",
848
1084
  more: "Cargar m\xE1s comentarios",
849
- truncated: "Se muestran los primeros 500 comentarios.",
850
- justNow: "ahora mismo"
1085
+ truncated: "Solo se muestra la primera parte de esta conversaci\xF3n.",
1086
+ justNow: "ahora mismo",
1087
+ react: "Reaccionar",
1088
+ reactions: "Reacciones",
1089
+ reactionLike: "Me gusta",
1090
+ reactionLove: "Me encanta",
1091
+ reactionInsightful: "Interesante",
1092
+ reactionCelebrate: "Celebrar",
1093
+ reactionSignIn: "Inicia sesi\xF3n para reaccionar, ",
1094
+ reactionAddedLive: "Reacci\xF3n {kind} a\xF1adida",
1095
+ reactionRemovedLive: "Reacci\xF3n {kind} eliminada",
1096
+ reactionsLoading: "Cargando reacciones",
1097
+ reactionsError: "No se pudieron cargar las reacciones",
1098
+ votesOn: "Votos del comentario de {name}",
1099
+ score: "Puntuaci\xF3n {n}",
1100
+ upvote: "Votar a favor",
1101
+ downvote: "Votar en contra",
1102
+ upvoteSignIn: "Inicia sesi\xF3n para votar a favor",
1103
+ downvoteSignIn: "Inicia sesi\xF3n para votar en contra",
1104
+ upvotedLive: "Voto a favor registrado. Puntuaci\xF3n {n}",
1105
+ downvotedLive: "Voto en contra registrado. Puntuaci\xF3n {n}",
1106
+ voteRemovedLive: "Voto retirado. Puntuaci\xF3n {n}",
1107
+ voteRefused: "No se acept\xF3 el voto. No puedes votar tu propio comentario.",
1108
+ slowDown: "Demasiadas acciones en poco tiempo. Espera un momento e int\xE9ntalo de nuevo.",
1109
+ sort: "Ordenar comentarios",
1110
+ sortNewest: "Recientes",
1111
+ sortTop: "Destacados",
1112
+ sortedNewestLive: "Comentarios m\xE1s recientes primero",
1113
+ sortedTopLive: "Comentarios destacados primero",
1114
+ sortError: "No se pudieron ordenar los comentarios. Int\xE9ntalo de nuevo.",
1115
+ newerLater: "Los comentarios m\xE1s recientes aparecen al cargar m\xE1s.",
1116
+ moreError: "No se pudieron cargar m\xE1s comentarios. Int\xE9ntalo de nuevo.",
1117
+ loadedLive: "{n} comentarios cargados"
851
1118
  };
852
1119
 
853
1120
  // src/react/viewer/labels.ts
@@ -859,15 +1126,15 @@ var VIEWER_LABELS_EN = {
859
1126
  zoomIn: "Zoom in",
860
1127
  zoomOut: "Zoom out",
861
1128
  fit: "Fit to window",
862
- actual: "Actual size",
1129
+ actual: "100%: actual size",
863
1130
  search: "Find in diagram",
864
1131
  searchPlaceholder: "Find",
865
1132
  noMatch: "No match",
866
1133
  matchOf: "{n} of {total}",
867
- copySource: "Copy diagram source",
868
- downloadSvg: "Download SVG",
869
- downloadPng: "Download PNG",
870
- copyImage: "Copy as image",
1134
+ copySource: "MMD: copy diagram source",
1135
+ downloadSvg: "SVG: download",
1136
+ downloadPng: "PNG: download",
1137
+ copyImage: "IMG: copy as image",
871
1138
  pngScale: "PNG scale",
872
1139
  fullscreen: "Fullscreen",
873
1140
  exitFullscreen: "Exit fullscreen",
@@ -880,7 +1147,16 @@ var VIEWER_LABELS_EN = {
880
1147
  legendDownstream: "Downstream",
881
1148
  outgoing: "outgoing",
882
1149
  tracing: "{label}: {up} upstream, {down} downstream",
883
- map: "Overview map"
1150
+ map: "Overview map",
1151
+ largeTitle: "Large diagram, not drawn automatically",
1152
+ largeBody: "Drawing a diagram this size can freeze this page for a few seconds, so it waits until you ask. Press Draw diagram: it takes a couple of seconds (a few more on a phone) and the page may pause while it works.",
1153
+ drawLarge: "Draw diagram",
1154
+ drawing: "Drawing\u2026",
1155
+ drawingBody: "Drawing the diagram\u2026 this takes a couple of seconds.",
1156
+ drawAgain: "Draw again",
1157
+ showSource: "Show full source",
1158
+ hideSource: "Show less",
1159
+ printPreparing: "Preparing diagrams for print\u2026 Esc cancels between steps."
884
1160
  };
885
1161
  var VIEWER_LABELS_FR = {
886
1162
  expand: "Agrandir le sch\xE9ma",
@@ -890,15 +1166,15 @@ var VIEWER_LABELS_FR = {
890
1166
  zoomIn: "Zoom avant",
891
1167
  zoomOut: "Zoom arri\xE8re",
892
1168
  fit: "Ajuster \xE0 la fen\xEAtre",
893
- actual: "Taille r\xE9elle",
1169
+ actual: "100% : taille r\xE9elle",
894
1170
  search: "Rechercher dans le sch\xE9ma",
895
1171
  searchPlaceholder: "Rechercher",
896
1172
  noMatch: "Aucun r\xE9sultat",
897
1173
  matchOf: "{n} sur {total}",
898
- copySource: "Copier la source du sch\xE9ma",
899
- downloadSvg: "T\xE9l\xE9charger le SVG",
900
- downloadPng: "T\xE9l\xE9charger le PNG",
901
- copyImage: "Copier comme image",
1174
+ copySource: "MMD : copier la source du sch\xE9ma",
1175
+ downloadSvg: "SVG : t\xE9l\xE9charger",
1176
+ downloadPng: "PNG : t\xE9l\xE9charger",
1177
+ copyImage: "IMG : copier comme image",
902
1178
  pngScale: "\xC9chelle du PNG",
903
1179
  fullscreen: "Plein \xE9cran",
904
1180
  exitFullscreen: "Quitter le plein \xE9cran",
@@ -911,7 +1187,16 @@ var VIEWER_LABELS_FR = {
911
1187
  legendDownstream: "En aval",
912
1188
  outgoing: "sortants",
913
1189
  tracing: "{label} : {up} en amont, {down} en aval",
914
- map: "Carte d'ensemble"
1190
+ map: "Carte d'ensemble",
1191
+ largeTitle: "Grand sch\xE9ma, non dessin\xE9 automatiquement",
1192
+ largeBody: "Dessiner un sch\xE9ma de cette taille peut figer la page quelques secondes, il attend donc votre demande. Appuyez sur Dessiner le sch\xE9ma : cela prend quelques secondes (un peu plus sur un t\xE9l\xE9phone) et la page peut se figer pendant ce temps.",
1193
+ drawLarge: "Dessiner le sch\xE9ma",
1194
+ drawing: "Dessin en cours\u2026",
1195
+ drawingBody: "Dessin du sch\xE9ma\u2026 cela prend quelques secondes.",
1196
+ drawAgain: "Redessiner",
1197
+ showSource: "Afficher toute la source",
1198
+ hideSource: "R\xE9duire",
1199
+ printPreparing: "Pr\xE9paration des sch\xE9mas pour l'impression\u2026 \xC9chap annule entre deux \xE9tapes."
915
1200
  };
916
1201
  var VIEWER_LABELS_ES = {
917
1202
  expand: "Ampliar el diagrama",
@@ -921,15 +1206,15 @@ var VIEWER_LABELS_ES = {
921
1206
  zoomIn: "Acercar",
922
1207
  zoomOut: "Alejar",
923
1208
  fit: "Ajustar a la ventana",
924
- actual: "Tama\xF1o real",
1209
+ actual: "100%: tama\xF1o real",
925
1210
  search: "Buscar en el diagrama",
926
1211
  searchPlaceholder: "Buscar",
927
1212
  noMatch: "Sin resultados",
928
1213
  matchOf: "{n} de {total}",
929
- copySource: "Copiar el c\xF3digo del diagrama",
930
- downloadSvg: "Descargar SVG",
931
- downloadPng: "Descargar PNG",
932
- copyImage: "Copiar como imagen",
1214
+ copySource: "MMD: copiar el c\xF3digo del diagrama",
1215
+ downloadSvg: "SVG: descargar",
1216
+ downloadPng: "PNG: descargar",
1217
+ copyImage: "IMG: copiar como imagen",
933
1218
  pngScale: "Escala del PNG",
934
1219
  fullscreen: "Pantalla completa",
935
1220
  exitFullscreen: "Salir de pantalla completa",
@@ -942,7 +1227,16 @@ var VIEWER_LABELS_ES = {
942
1227
  legendDownstream: "Aguas abajo",
943
1228
  outgoing: "salientes",
944
1229
  tracing: "{label}: {up} aguas arriba, {down} aguas abajo",
945
- map: "Mapa general"
1230
+ map: "Mapa general",
1231
+ largeTitle: "Diagrama grande, no se dibuja autom\xE1ticamente",
1232
+ largeBody: "Dibujar un diagrama de este tama\xF1o puede bloquear la p\xE1gina unos segundos, as\xED que espera a que lo pidas. Pulsa Dibujar el diagrama: tarda un par de segundos (algo m\xE1s en un tel\xE9fono) y la p\xE1gina puede detenerse mientras tanto.",
1233
+ drawLarge: "Dibujar el diagrama",
1234
+ drawing: "Dibujando\u2026",
1235
+ drawingBody: "Dibujando el diagrama\u2026 tarda un par de segundos.",
1236
+ drawAgain: "Dibujar de nuevo",
1237
+ showSource: "Mostrar todo el c\xF3digo",
1238
+ hideSource: "Mostrar menos",
1239
+ printPreparing: "Preparando los diagramas para imprimir\u2026 Esc cancela entre pasos."
946
1240
  };
947
1241
 
948
1242
  // src/react/strings.ts
@@ -961,6 +1255,14 @@ var en = {
961
1255
  warning: "Heads up",
962
1256
  tip: "Tip",
963
1257
  caution: "Caution",
1258
+ important: "Important",
1259
+ copyCode: "Copy code",
1260
+ copied: "Copied",
1261
+ copyBlocked: "Copy blocked",
1262
+ done: "Done",
1263
+ notDone: "Not done",
1264
+ playVideo: "Play video",
1265
+ videoFrame: "YouTube video",
964
1266
  diagram: "Diagram",
965
1267
  diagramError: "This diagram could not be rendered.",
966
1268
  diagramLoading: "Loading the diagram",
@@ -1013,6 +1315,14 @@ var fr = {
1013
1315
  warning: "Attention",
1014
1316
  tip: "Astuce",
1015
1317
  caution: "Danger",
1318
+ important: "Important",
1319
+ copyCode: "Copier le code",
1320
+ copied: "Copi\xE9",
1321
+ copyBlocked: "Copie bloqu\xE9e",
1322
+ done: "Termin\xE9",
1323
+ notDone: "\xC0 faire",
1324
+ playVideo: "Lire la vid\xE9o",
1325
+ videoFrame: "Vid\xE9o YouTube",
1016
1326
  diagram: "Sch\xE9ma",
1017
1327
  diagramError: "Ce sch\xE9ma n'a pas pu \xEAtre affich\xE9.",
1018
1328
  diagramLoading: "Chargement du sch\xE9ma",
@@ -1065,6 +1375,14 @@ var es = {
1065
1375
  warning: "Atenci\xF3n",
1066
1376
  tip: "Consejo",
1067
1377
  caution: "Peligro",
1378
+ important: "Importante",
1379
+ copyCode: "Copiar el c\xF3digo",
1380
+ copied: "Copiado",
1381
+ copyBlocked: "Copia bloqueada",
1382
+ done: "Hecho",
1383
+ notDone: "Pendiente",
1384
+ playVideo: "Reproducir el v\xEDdeo",
1385
+ videoFrame: "V\xEDdeo de YouTube",
1068
1386
  diagram: "Diagrama",
1069
1387
  diagramError: "No se pudo mostrar este diagrama.",
1070
1388
  diagramLoading: "Cargando el diagrama",
@@ -1122,14 +1440,15 @@ function formatDate(iso, locale, options = { dateStyle: "medium" }) {
1122
1440
  }
1123
1441
 
1124
1442
  // src/react/content.tsx
1443
+ var import_youtube_facade = require("./youtube-facade.cjs");
1125
1444
  var import_jsx_runtime3 = require("react/jsx-runtime");
1126
1445
  function plainText(node) {
1127
1446
  if (typeof node === "string" || typeof node === "number") return String(node);
1128
1447
  if (Array.isArray(node)) return node.map(plainText).join("");
1129
1448
  return (0, import_react.isValidElement)(node) ? plainText(node.props.children) : "";
1130
1449
  }
1131
- var CALLOUT_ICON = { note: "info", tip: "check-circle", warning: "alert", caution: "x-circle" };
1132
- function buildComponents(c, s) {
1450
+ var CALLOUT_ICON = { note: "info", tip: "check-circle", important: "important", warning: "alert", caution: "x-circle" };
1451
+ function buildComponents(c, s, { opensWithImage, interactive }) {
1133
1452
  const Link = c.Link ?? "a";
1134
1453
  const Img = c.Image ?? "img";
1135
1454
  const A = ({ href, children, ...rest }) => {
@@ -1140,10 +1459,11 @@ function buildComponents(c, s) {
1140
1459
  }
1141
1460
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { href: url, rel: "noopener noreferrer", ...rest, children });
1142
1461
  };
1143
- let images = 0;
1462
+ let eager = opensWithImage;
1144
1463
  const Image = (props) => {
1145
1464
  if (typeof props.src !== "string") return null;
1146
- const first = images++ === 0;
1465
+ const first = eager;
1466
+ eager = false;
1147
1467
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Img, { loading: first ? "eager" : "lazy", ...first ? { fetchPriority: "high" } : {}, decoding: "async", ...props });
1148
1468
  };
1149
1469
  const Pre = ({ children, ...rest }) => {
@@ -1152,13 +1472,22 @@ function buildComponents(c, s) {
1152
1472
  const pre = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { tabIndex: 0, ...rest, children });
1153
1473
  if (c.CodeBlock) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(c.CodeBlock, { code: plainText(children), language, children: pre });
1154
1474
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("figure", { className: "hyle-codeblock", "data-slot-component": "CodeBlock", children: [
1155
- language ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("header", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "lang", children: language }) }) : null,
1475
+ language || interactive ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("header", { children: [
1476
+ language ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "lang", children: language }) : null,
1477
+ interactive ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1478
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("button", { type: "button", "aria-label": s.copyCode, children: [
1479
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "copy" }),
1480
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "check" })
1481
+ ] }),
1482
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "hyle-sr", role: "status" })
1483
+ ] }) : null
1484
+ ] }) : null,
1156
1485
  pre
1157
1486
  ] });
1158
1487
  };
1159
1488
  const Table = ({ children, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "hyle-table", tabIndex: 0, role: "region", "aria-label": s.table, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("table", { ...rest, children }) });
1160
1489
  const Callout = ({ kind, children }) => {
1161
- const k = ["note", "tip", "warning", "caution"].includes(String(kind)) ? kind : "note";
1490
+ const k = Object.hasOwn(CALLOUT_ICON, String(kind)) ? kind : "note";
1162
1491
  const title = s[k];
1163
1492
  if (c.Callout) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(c.Callout, { kind: k, title, children });
1164
1493
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("aside", { className: "hyle-callout", "data-kind": k, "data-slot-component": "Callout", role: "note", children: [
@@ -1184,17 +1513,27 @@ function buildComponents(c, s) {
1184
1513
  };
1185
1514
  const Heading = (level) => function HyleHeading({ id, children, ...rest }) {
1186
1515
  const Tag = `h${level}`;
1516
+ const anchored = typeof id === "string" && !String(rest.className ?? "").split(" ").includes("sr-only");
1187
1517
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Tag, { id, ...rest, children: [
1188
- typeof id === "string" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { className: "hyle-anchor", href: `#${id}`, "aria-label": s.anchor, children: "#" }) : null,
1518
+ anchored ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { className: "hyle-anchor", href: `#${id}`, "aria-label": s.anchor }) : null,
1189
1519
  children
1190
1520
  ] });
1191
1521
  };
1192
- const defaults = { a: A, img: Image, pre: Pre, table: Table, callout: Callout, iframe: Frame, h2: Heading(2), h3: Heading(3), h4: Heading(4) };
1522
+ const Checkbox = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("input", { ...props, "aria-label": props.checked ? s.done : s.notDone });
1523
+ const Paragraph = ({ children, ...rest }) => {
1524
+ const [only, ...more] = import_react.Children.toArray(children).filter((n) => typeof n !== "string" || n.trim() !== "");
1525
+ if (more.length === 0 && (0, import_react.isValidElement)(only) && only.props["data-embed"] === "youtube") {
1526
+ const id = youtubeId(only.props.href);
1527
+ if (id) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_youtube_facade.YouTubeFacade, { videoId: id, playLabel: s.playVideo, frameTitle: s.videoFrame, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: only }) });
1528
+ }
1529
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { ...rest, children });
1530
+ };
1531
+ const defaults = { a: A, img: Image, pre: Pre, table: Table, input: Checkbox, callout: Callout, iframe: Frame, h2: Heading(2), h3: Heading(3), h4: Heading(4), ...interactive ? { p: Paragraph } : {} };
1193
1532
  const overrides = ["a", "img", "code", "pre", "table", "blockquote", "h1", "h2", "h3", "h4", "h5", "h6"];
1194
1533
  for (const key of overrides) if (c[key]) defaults[key] = c[key];
1195
1534
  return defaults;
1196
1535
  }
1197
- function HastContent({ tree, title, description, components = {}, locale }) {
1536
+ function renderHast({ tree, title, description, components = {}, locale }, interactive) {
1198
1537
  let root;
1199
1538
  try {
1200
1539
  root = sanitizeHast(tree, title, description);
@@ -1206,11 +1545,13 @@ function HastContent({ tree, title, description, components = {}, locale }) {
1206
1545
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: s.contentError })
1207
1546
  ] });
1208
1547
  }
1548
+ const lead = root.children.find((n) => n.type !== "text" || n.value.trim() !== "");
1549
+ const opensWithImage = lead?.type === "element" && lead.tagName === "figure";
1209
1550
  return (0, import_hast_util_to_jsx_runtime.toJsxRuntime)(root, {
1210
1551
  Fragment: import_react.Fragment,
1211
1552
  jsx: import_jsx_runtime2.jsx,
1212
1553
  jsxs: import_jsx_runtime2.jsxs,
1213
- components: buildComponents(components, stringsFor(locale)),
1554
+ components: buildComponents(components, stringsFor(locale), { opensWithImage, interactive }),
1214
1555
  elementAttributeNameCase: "react",
1215
1556
  stylePropertyNameCase: "dom"
1216
1557
  });
@@ -1219,15 +1560,41 @@ function TrustedServerHtml({ html }) {
1219
1560
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { dangerouslySetInnerHTML: { __html: hostAssetHtml(html) } });
1220
1561
  }
1221
1562
 
1563
+ // src/react/body.tsx
1564
+ var import_react2 = require("react");
1565
+ var import_code_copy = require("./code-copy.cjs");
1566
+ var import_fragment_alias = require("./fragment-alias.cjs");
1567
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1568
+ function ProseBody({ id, className, lang, ...content }) {
1569
+ const generated = (0, import_react2.useId)();
1570
+ const rootId = id ?? `hyle-body${generated}`;
1571
+ const s = stringsFor(content.locale);
1572
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1573
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { id: rootId, className, lang, children: renderHast(content, true) }),
1574
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_code_copy.CodeCopy, { rootId, copyLabel: s.copyCode, copiedLabel: s.copied, blockedLabel: s.copyBlocked }),
1575
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_fragment_alias.FragmentAlias, {})
1576
+ ] });
1577
+ }
1578
+
1222
1579
  // src/react/index.ts
1223
1580
  var import_mermaid_diagram2 = require("./mermaid-diagram.cjs");
1581
+ var import_print_coordinator = require("./print-coordinator.cjs");
1224
1582
 
1225
1583
  // src/react/pages.tsx
1226
1584
  var import_comments = require("./comments.cjs");
1227
1585
 
1228
1586
  // src/react/comments-api.ts
1587
+ var REACTION_KINDS = ["like", "love", "insightful", "celebrate"];
1588
+ var isCursor = (v) => typeof v === "string" && /^[A-Za-z0-9_-]{1,200}$/.test(v);
1229
1589
  var isObject2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
1230
1590
  var count = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? Math.trunc(v) : 0;
1591
+ function parseCounts(v) {
1592
+ if (!isObject2(v)) return void 0;
1593
+ return Object.fromEntries(REACTION_KINDS.map((kind) => [kind, count(v[kind])]).filter(([, n]) => n > 0));
1594
+ }
1595
+ var toVote = (v) => v === 1 || v === -1 ? v : null;
1596
+ var toUnrenderable = (v) => v === true ? { unrenderable: true } : {};
1597
+ var toMine = (v) => Array.isArray(v) ? { my_reactions: REACTION_KINDS.filter((kind) => v.includes(kind)) } : {};
1231
1598
  function toComment(raw) {
1232
1599
  if (!isObject2(raw) || typeof raw.id !== "string" || typeof raw.created_at !== "string") return void 0;
1233
1600
  const depth = typeof raw.depth === "number" ? Math.min(4, Math.max(1, Math.trunc(raw.depth))) : 1;
@@ -1235,6 +1602,7 @@ function toComment(raw) {
1235
1602
  const name = typeof raw.author_name === "string" ? raw.author_name : author;
1236
1603
  const body = isObject2(raw.body) && raw.body.format === "hast" ? { format: "hast", tree: raw.body.tree } : null;
1237
1604
  const removed = raw.removed === true || body === null;
1605
+ const reactions = parseCounts(raw.reaction_counts);
1238
1606
  return {
1239
1607
  id: raw.id,
1240
1608
  parent_id: typeof raw.parent_id === "string" ? raw.parent_id : null,
@@ -1243,11 +1611,14 @@ function toComment(raw) {
1243
1611
  created_at: raw.created_at,
1244
1612
  edited_at: typeof raw.edited_at === "string" ? raw.edited_at : null,
1245
1613
  like_count: count(raw.like_count),
1614
+ ...Number.isSafeInteger(raw.score) ? { score: raw.score } : {},
1615
+ ...reactions ? { reaction_counts: reactions } : {},
1246
1616
  removed,
1247
1617
  ...removed && (raw.removed_by === "moderator" || raw.removed_by === "author") ? { removed_by: raw.removed_by } : {},
1618
+ ...removed ? {} : toUnrenderable(raw.unrenderable),
1248
1619
  body,
1249
1620
  // Viewer members exist only on a live comment of a viewer-aware listing; a tombstone never carries them.
1250
- ...!removed && typeof raw.mine === "boolean" ? { mine: raw.mine, liked_by_me: raw.liked_by_me === true, can_edit_until: typeof raw.can_edit_until === "string" ? raw.can_edit_until : null } : {}
1621
+ ...!removed && typeof raw.mine === "boolean" ? { mine: raw.mine, liked_by_me: raw.liked_by_me === true, can_edit_until: typeof raw.can_edit_until === "string" ? raw.can_edit_until : null, ..."my_vote" in raw ? { my_vote: toVote(raw.my_vote) } : {}, ...toMine(raw.my_reactions) } : {}
1251
1622
  };
1252
1623
  }
1253
1624
  function toHeld(raw) {
@@ -1261,20 +1632,22 @@ function toHeld(raw) {
1261
1632
  created_at: raw.created_at,
1262
1633
  edited_at: typeof raw.edited_at === "string" ? raw.edited_at : null,
1263
1634
  can_edit_until: typeof raw.can_edit_until === "string" ? raw.can_edit_until : null,
1635
+ ...toUnrenderable(raw.unrenderable),
1264
1636
  body: { format: "hast", tree: raw.body.tree }
1265
1637
  };
1266
1638
  }
1267
1639
  function parseListing(data) {
1268
1640
  if (!isObject2(data) || data.kind !== "comments" || !Array.isArray(data.comments)) return void 0;
1269
1641
  const comments = data.comments.map(toComment).filter((c) => c !== void 0);
1270
- const viewer = Array.isArray(data.mine_held) ? { liked_by_me: data.liked_by_me === true, mine_held: data.mine_held.slice(0, 5).map(toHeld).filter((h) => h !== void 0) } : {};
1271
- return { cp: 1, kind: "comments", publication_id: String(data.publication_id ?? ""), comment_count: count(data.comment_count), like_count: count(data.like_count), truncated: data.truncated === true, comments, ...viewer };
1642
+ const viewer = Array.isArray(data.mine_held) ? { liked_by_me: data.liked_by_me === true, ...toMine(data.my_reactions), mine_held: data.mine_held.slice(0, 5).map(toHeld).filter((h) => h !== void 0) } : {};
1643
+ const reactions = parseCounts(data.reaction_counts);
1644
+ return { cp: 1, kind: "comments", publication_id: String(data.publication_id ?? ""), comment_count: count(data.comment_count), like_count: count(data.like_count), ...reactions ? { reaction_counts: reactions } : {}, truncated: data.truncated === true, next_cursor: isCursor(data.next_cursor) ? data.next_cursor : null, comments, ...viewer };
1272
1645
  }
1273
1646
  var untilMs = (iso) => {
1274
1647
  const t = iso ? Date.parse(iso) : NaN;
1275
1648
  return Number.isFinite(t) ? t : void 0;
1276
1649
  };
1277
- function buildThread(listing, localHeld) {
1650
+ function buildThread(listing, localHeld, unseen = [], newestOnTop = false) {
1278
1651
  const byId = /* @__PURE__ */ new Map();
1279
1652
  const roots = [];
1280
1653
  const place = (node, parentId) => {
@@ -1292,11 +1665,16 @@ function buildThread(listing, localHeld) {
1292
1665
  mine: !removed && c.mine === true,
1293
1666
  canEditUntil: untilMs(c.can_edit_until),
1294
1667
  likedByMe: !removed && c.liked_by_me === true,
1668
+ myReactions: removed ? void 0 : c.my_reactions,
1295
1669
  name: removed ? null : c.author_name ?? null,
1296
1670
  createdAt: c.created_at,
1297
1671
  editedAt: c.edited_at,
1298
1672
  likes: c.like_count,
1673
+ score: c.score,
1674
+ myVote: c.my_vote,
1675
+ reactions: c.reaction_counts,
1299
1676
  tree: c.body?.tree,
1677
+ unrenderable: c.unrenderable,
1300
1678
  text: void 0,
1301
1679
  kids: []
1302
1680
  };
@@ -1314,23 +1692,49 @@ function buildThread(listing, localHeld) {
1314
1692
  for (const h of listing.mine_held ?? []) {
1315
1693
  heldIds.add(h.id);
1316
1694
  const parent = h.parent_id ? byId.get(h.parent_id) : void 0;
1317
- addHeld({ id: h.id, depth: Math.min(4, (parent?.depth ?? h.depth - 1) + 1), status: "held", removedBy: void 0, mine: true, canEditUntil: untilMs(h.can_edit_until), likedByMe: false, name: h.author_name, createdAt: h.created_at, editedAt: h.edited_at, likes: 0, tree: h.body?.tree, text: void 0, kids: [] }, h.parent_id, true);
1695
+ addHeld({ id: h.id, depth: Math.min(4, (parent?.depth ?? h.depth - 1) + 1), status: "held", removedBy: void 0, mine: true, canEditUntil: untilMs(h.can_edit_until), likedByMe: false, name: h.author_name, createdAt: h.created_at, editedAt: h.edited_at, likes: 0, tree: h.body?.tree, unrenderable: h.unrenderable, text: void 0, kids: [] }, h.parent_id, true);
1318
1696
  }
1319
1697
  if (listing.mine_held === void 0) {
1320
1698
  for (const h of localHeld) {
1321
1699
  if (byId.has(h.id) || heldIds.has(h.id)) continue;
1322
1700
  const parent = h.parentId ? byId.get(h.parentId) : void 0;
1323
- addHeld({ id: h.id, depth: Math.min(4, (parent?.depth ?? 0) + 1), status: "held", removedBy: void 0, mine: true, canEditUntil: void 0, likedByMe: false, name: h.name, createdAt: h.createdAt, editedAt: null, likes: 0, tree: void 0, text: h.text, kids: [] }, h.parentId, false);
1701
+ addHeld(localNode(h, "held", parent), h.parentId, false);
1324
1702
  }
1325
1703
  }
1704
+ for (const u of [...unseen].reverse()) {
1705
+ if (byId.has(u.id) || heldIds.has(u.id) || u.status === "held" && listing.mine_held === void 0) continue;
1706
+ const parent = u.parentId ? byId.get(u.parentId) : void 0;
1707
+ const node = localNode(u, u.status, parent);
1708
+ if (u.status === "held") addHeld(node, u.parentId, true);
1709
+ else if (parent) parent.kids.push(node);
1710
+ else if (newestOnTop) roots.unshift(node);
1711
+ else roots.push(node);
1712
+ byId.set(u.id, node);
1713
+ }
1326
1714
  return [...mine, ...roots];
1327
1715
  }
1716
+ var localNode = (c, status, parent) => ({
1717
+ id: c.id,
1718
+ depth: Math.min(4, (parent?.depth ?? 0) + 1),
1719
+ status,
1720
+ removedBy: void 0,
1721
+ mine: true,
1722
+ canEditUntil: void 0,
1723
+ likedByMe: false,
1724
+ name: c.name,
1725
+ createdAt: c.createdAt,
1726
+ editedAt: null,
1727
+ likes: 0,
1728
+ tree: void 0,
1729
+ text: c.text,
1730
+ kids: []
1731
+ });
1328
1732
 
1329
1733
  // src/react/comments-body.tsx
1330
1734
  var import_hast_util_to_jsx_runtime2 = require("hast-util-to-jsx-runtime");
1331
- var import_react2 = require("react");
1332
- var import_jsx_runtime4 = require("react/jsx-runtime");
1735
+ var import_react3 = require("react");
1333
1736
  var import_jsx_runtime5 = require("react/jsx-runtime");
1737
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1334
1738
  var ALLOWED = /* @__PURE__ */ new Set(["p", "a", "em", "strong", "del", "code", "pre", "blockquote", "ul", "ol", "li", "br"]);
1335
1739
  var LINK_REL = "nofollow ugc noopener noreferrer";
1336
1740
  function narrow(node) {
@@ -1353,82 +1757,97 @@ function CommentBody({ tree }) {
1353
1757
  if (error instanceof HastLimitError) return null;
1354
1758
  throw error;
1355
1759
  }
1356
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "hyle-cm-body", children: (0, import_hast_util_to_jsx_runtime2.toJsxRuntime)({ type: "root", children }, { Fragment: import_react2.Fragment, jsx: import_jsx_runtime4.jsx, jsxs: import_jsx_runtime4.jsxs, elementAttributeNameCase: "react", stylePropertyNameCase: "dom" }) });
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" }) });
1761
+ }
1762
+
1763
+ // src/react/theme.tsx
1764
+ var import_jsx_runtime7 = require("react/jsx-runtime");
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
+ ] });
1357
1772
  }
1358
1773
 
1359
1774
  // src/react/embed.tsx
1360
- var import_jsx_runtime6 = require("react/jsx-runtime");
1361
- function HyleListView({ items, layout = "list", title, headingLevel = 2, moreHref, olderHref, ...base }) {
1775
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1776
+ function HyleListView({ items, layout = "list", title, headingLevel = 2, moreHref, olderHref, theme, ...base }) {
1362
1777
  const c = ctx(base, "en");
1363
1778
  const { s, Link } = c;
1364
1779
  const Row = base.slots?.["list.item"];
1365
1780
  const Heading = `h${headingLevel}`;
1366
1781
  const safe = items.filter((item) => item.canonical_path.startsWith("/"));
1367
- if (safe.length === 0) return base.slots?.["list.empty"] ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle hyle-embed", "data-layout": layout, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Slot, { name: "list.empty", slots: base.slots }) }) : null;
1368
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "hyle hyle-embed", "data-layout": layout, lang: c.locale, children: [
1369
- title ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Heading, { className: "hyle-title", children: title }) : null,
1370
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: "hyle-items", children: safe.map((item) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("li", { children: Row ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
1371
- item.published_at ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }) : null,
1372
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
1373
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "t", children: item.title }),
1374
- item.description ? /* @__PURE__ */ (0, import_jsx_runtime6.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
1375
1791
  ] })
1376
1792
  ] }) }, item.canonical_path)) }),
1377
- olderHref ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(OlderNav, { href: olderHref, c }) : null,
1378
- moreHref ? /* @__PURE__ */ (0, import_jsx_runtime6.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
1379
1795
  ] });
1380
1796
  }
1381
1797
  function HyleArticleView({ article, headingLevel = 2, ...base }) {
1382
1798
  const { publication: pub } = article;
1383
1799
  const c = ctx(base, pub.locale);
1384
1800
  const Heading = `h${headingLevel}`;
1385
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("article", { lang: c.locale, children: [
1386
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("header", { className: "hyle-head", children: [
1387
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Heading, { className: "hyle-title", children: pub.title }),
1388
- pub.description ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
1389
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle-meta", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) }) }) })
1390
- ] }),
1391
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Body, { article, components: base.components, locale: c.locale }),
1392
- pub.canonical_path.startsWith("/") ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("a", { className: "hyle-more", href: c.href(pub.canonical_path, pub.locale), rel: "bookmark", children: [
1393
- c.s.readAtSource,
1394
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "hyle-sr", children: [
1395
- ": ",
1396
- pub.title
1397
- ] })
1398
- ] }) : null
1399
- ] }) });
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
+ ] });
1400
1819
  }
1401
1820
  var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((w) => [...w][0] ?? "").join("").toUpperCase() || "?";
1402
1821
  function StaticThread({ nodes, locale, s, level = 1 }) {
1403
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ol", { className: "hyle-cm-list", role: "list", children: nodes.map((node) => {
1404
- const kids = node.kids.length > 0 && level < 32 ? /* @__PURE__ */ (0, import_jsx_runtime6.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;
1405
1824
  if (node.status === "removed") {
1406
1825
  const why = node.removedBy === "moderator" ? s.removedByModerator : node.removedBy === "author" ? s.removedByAuthor : s.removed;
1407
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "removed", "data-removed-by": node.removedBy, children: [
1408
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("article", { "aria-label": why, children: [
1409
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "ban" }) }),
1410
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle-cm-main", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle-cm-body", children: /* @__PURE__ */ (0, import_jsx_runtime6.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 }) }) })
1411
1830
  ] }),
1412
1831
  kids
1413
1832
  ] }, node.id);
1414
1833
  }
1415
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "visible", children: [
1416
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("article", { children: [
1417
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: initials(node.name ?? "") }),
1418
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "hyle-cm-main", children: [
1419
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "hyle-cm-by", children: [
1420
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("b", { children: node.name }),
1421
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
1422
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("time", { dateTime: node.createdAt, title: node.createdAt, children: formatDate(node.createdAt, locale) }),
1423
- node.editedAt ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.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: [
1424
1843
  " ",
1425
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "aria-hidden": "true", children: "\xB7" }),
1844
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { "aria-hidden": "true", children: "\xB7" }),
1426
1845
  " ",
1427
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: s.edited })
1846
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: s.edited })
1428
1847
  ] }) : null
1429
1848
  ] })
1430
1849
  ] }),
1431
- /* @__PURE__ */ (0, import_jsx_runtime6.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 })
1432
1851
  ] })
1433
1852
  ] }),
1434
1853
  kids
@@ -1439,26 +1858,26 @@ function HyleCommentsView({ listing, locale }) {
1439
1858
  const thread = buildThread(listing, []);
1440
1859
  if (thread.length === 0) return null;
1441
1860
  const s = stringsFor(locale).comments;
1442
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", lang: locale, children: [
1443
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle-cm-head", children: /* @__PURE__ */ (0, import_jsx_runtime6.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: [
1444
1863
  s.heading,
1445
1864
  " ",
1446
- /* @__PURE__ */ (0, import_jsx_runtime6.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 })
1447
1866
  ] }) }),
1448
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StaticThread, { nodes: thread, locale, s }),
1449
- listing.truncated ? /* @__PURE__ */ (0, import_jsx_runtime6.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
1450
1869
  ] }) });
1451
1870
  }
1452
1871
  function HyleCommentsFallback({ locale }) {
1453
1872
  const s = stringsFor(locale).comments;
1454
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { role: "status", "aria-live": "polite", "aria-busy": "true", children: [
1455
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hyle-sr", children: s.loading }),
1456
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { "aria-hidden": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "hyle-cm-sk", children: [
1457
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hyle-sk c" }),
1458
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
1459
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hyle-sk l", style: { width: 120 } }),
1460
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hyle-sk l", style: { width: "100%" } }),
1461
- /* @__PURE__ */ (0, import_jsx_runtime6.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%" } })
1462
1881
  ] })
1463
1882
  ] }, i)) })
1464
1883
  ] }) }) });
@@ -1588,13 +2007,17 @@ function listJsonLd({ list, origin, href, path, locale, description, jsonLd, cur
1588
2007
  }
1589
2008
 
1590
2009
  // src/react/pages.tsx
1591
- var import_jsx_runtime7 = require("react/jsx-runtime");
2010
+ var import_toc_spy = require("./toc-spy.cjs");
2011
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1592
2012
  function Slot({ name, slots, tag: Tag = "div", className }) {
1593
2013
  const fill = slots?.[name];
1594
- return fill ? /* @__PURE__ */ (0, import_jsx_runtime7.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;
1595
2015
  }
1596
- function Shell({ children }) {
1597
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle", children: /* @__PURE__ */ (0, import_jsx_runtime7.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
+ ] });
1598
2021
  }
1599
2022
  function ctx(p, fallbackLocale) {
1600
2023
  const locale = p.locale ?? fallbackLocale;
@@ -1603,29 +2026,29 @@ function ctx(p, fallbackLocale) {
1603
2026
  function Pager({ prev, next, c }) {
1604
2027
  if (!prev && !next) return null;
1605
2028
  const { Link, s } = c;
1606
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("nav", { className: "hyle-pager", "aria-label": s.pager, children: [
1607
- prev ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Link, { href: c.href(prev.canonical_path), rel: "prev", children: [
1608
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "dir", children: [
1609
- /* @__PURE__ */ (0, import_jsx_runtime7.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" }),
1610
2033
  s.prev
1611
2034
  ] }),
1612
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ttl", children: prev.title })
1613
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "none", "aria-hidden": "true" }),
1614
- next ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Link, { href: c.href(next.canonical_path), rel: "next", className: "next", children: [
1615
- /* @__PURE__ */ (0, import_jsx_runtime7.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: [
1616
2039
  s.next,
1617
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "chev" })
2040
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev" })
1618
2041
  ] }),
1619
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ttl", children: next.title })
2042
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ttl", children: next.title })
1620
2043
  ] }) : null
1621
2044
  ] });
1622
2045
  }
1623
2046
  function OlderNav({ href, c }) {
1624
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("nav", { className: "hyle-pagination", "aria-label": c.s.pager, children: [
1625
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "sp" }),
1626
- /* @__PURE__ */ (0, import_jsx_runtime7.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: [
1627
2050
  c.s.older,
1628
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "chev" })
2051
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev" })
1629
2052
  ] })
1630
2053
  ] });
1631
2054
  }
@@ -1636,54 +2059,60 @@ function TocList({ toc }) {
1636
2059
  if (entry.depth === 3 && last) last.subs.push(entry);
1637
2060
  else groups.push({ entry, subs: [] });
1638
2061
  }
1639
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { children: groups.map(({ entry, subs }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("li", { children: [
1640
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("a", { href: `#${scopeId(entry.id)}`, children: entry.text }),
1641
- subs.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { children: subs.map((sub) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime7.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
1642
2065
  ] }, entry.id)) });
1643
2066
  }
1644
- function Toc({ toc, c, aside }) {
2067
+ function Toc({ toc, c, aside, spy, className }) {
1645
2068
  const entries = toc.filter((t) => t.depth === 2 || t.depth === 3);
1646
2069
  if (entries.length === 0 && !aside) return { narrow: null, wide: null };
1647
2070
  const { s } = c;
2071
+ const classes = (own) => className ? `${className} ${own}` : own;
1648
2072
  return {
1649
- narrow: entries.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("details", { className: "hyle-toc-m", children: [
1650
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("summary", { children: [
1651
- /* @__PURE__ */ (0, import_jsx_runtime7.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" }),
1652
2076
  s.toc,
1653
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
2077
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
1654
2078
  ] }),
1655
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("nav", { className: "hyle-toc-list", "aria-label": s.toc, children: /* @__PURE__ */ (0, import_jsx_runtime7.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 }) })
1656
2080
  ] }),
1657
- wide: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("aside", { className: "hyle-toc-d", "aria-label": s.toc, children: [
1658
- entries.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1659
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "hyle-toc-title", children: s.toc }),
1660
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("nav", { className: "hyle-toc-list", children: /* @__PURE__ */ (0, import_jsx_runtime7.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 }) })
1661
2085
  ] }),
1662
- aside
2086
+ aside,
2087
+ spy && entries.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_toc_spy.TocSpy, { ids: entries.map((t) => scopeId(t.id)) }) : null
1663
2088
  ] })
1664
2089
  };
1665
2090
  }
1666
2091
  function Body({ article, components, locale }) {
1667
2092
  const { content, publication } = article;
1668
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle-body hyle-prose", lang: article.fallback ? void 0 : publication.locale, children: content.format === "hast" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HastContent, { tree: content.tree, title: publication.title, description: publication.description, components: components ?? {}, locale }) : content.format === "html" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TrustedServerHtml, { html: content.html }) : null });
2093
+ const lang = article.fallback ? void 0 : publication.locale;
2094
+ if (content.format === "hast") {
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 });
2096
+ }
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 });
1669
2098
  }
1670
2099
  function Languages({ alternates, current, c }) {
1671
2100
  if (alternates.length < 2) return null;
1672
2101
  const { Link, s } = c;
1673
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("nav", { className: "hyle-langs", "aria-label": s.languages, children: [
1674
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: s.readIn }),
1675
- /* @__PURE__ */ (0, import_jsx_runtime7.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) => {
1676
2105
  const label = languageName(a.locale, a.locale);
1677
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("li", { children: a.locale === current ? /* @__PURE__ */ (0, import_jsx_runtime7.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_runtime7.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);
1678
2107
  }) })
1679
2108
  ] });
1680
2109
  }
1681
2110
  function LdScript({ json: json2 }) {
1682
- return /* @__PURE__ */ (0, import_jsx_runtime7.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 } });
1683
2112
  }
1684
2113
  function Crumbs({ items, c }) {
1685
2114
  const { Link } = c;
1686
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("nav", { className: "hyle-crumbs", "aria-label": c.s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ol", { children: items.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("li", { "aria-current": i === items.length - 1 ? "page" : void 0, children: i === items.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime7.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)) }) });
1687
2116
  }
1688
2117
  function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, imageWidth, imageHeight, related, ...base }) {
1689
2118
  const { publication: pub } = article;
@@ -1693,66 +2122,66 @@ function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, imageWidth
1693
2122
  const author = articleAuthor(article, jsonLd)?.name;
1694
2123
  const modified = modifiedAt(pub);
1695
2124
  const words = wordCountOf(pub);
1696
- const toc = Toc({ toc: article.toc, c, aside: /* @__PURE__ */ (0, import_jsx_runtime7.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" }) });
1697
2126
  const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
1698
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Shell, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("article", { className: "hyle-article", "data-hyle-page": "article", lang: c.locale, children: [
1699
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("header", { className: "hyle-head", children: [
1700
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Slot, { name: "article.before", slots: base.slots, className: "hyle-eyebrow" }),
1701
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Crumbs, { items: breadcrumbItems(article, jsonLd), c }),
1702
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h1", { className: "hyle-title", children: pub.title }),
1703
- pub.description ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
1704
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-meta", children: [
1705
- author ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1706
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: author.slice(0, 2).toUpperCase() }),
1707
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1708
- /* @__PURE__ */ (0, import_jsx_runtime7.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: [
1709
2138
  s.by,
1710
2139
  " "
1711
2140
  ] }),
1712
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "by", children: author })
2141
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "by", children: author })
1713
2142
  ] })
1714
2143
  ] }) : null,
1715
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1716
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "calendar" }),
1717
- /* @__PURE__ */ (0, import_jsx_runtime7.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) })
1718
2147
  ] }),
1719
- modified ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1720
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "calendar" }),
2148
+ modified ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
2149
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "calendar" }),
1721
2150
  s.updated,
1722
2151
  " ",
1723
- /* @__PURE__ */ (0, import_jsx_runtime7.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) })
1724
2153
  ] }) : null,
1725
- words ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1726
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "clock" }),
2154
+ words ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
2155
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "clock" }),
1727
2156
  s.readingTime.replace("{n}", String(readingMinutes(words)))
1728
2157
  ] }) : null,
1729
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1730
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "globe" }),
1731
- /* @__PURE__ */ (0, import_jsx_runtime7.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) })
1732
2161
  ] }),
1733
- /* @__PURE__ */ (0, import_jsx_runtime7.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" })
1734
2163
  ] }),
1735
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Languages, { alternates: article.alternates, current: pub.locale, c }),
1736
- notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
1737
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "alert" }),
1738
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
1739
- /* @__PURE__ */ (0, import_jsx_runtime7.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 }),
1740
2169
  " ",
1741
2170
  s.fallbackBody
1742
2171
  ] })
1743
2172
  ] }) : null
1744
2173
  ] }),
1745
2174
  toc.narrow,
1746
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Body, { article, components: base.components, locale: c.locale }),
1747
- engagement ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_comments.Comments, { path: pub.canonical_path, endpoint: engagement.endpoint ?? "/api/hyle/engage", signInHref: engagement.signInHref, locale: c.locale, labels: s.comments }) : null,
1748
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Pager, { prev: article.prev, next: article.next, c }),
1749
- related ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1750
- related.items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HyleListView, { items: related.items, title: related.title ?? s.moreInSection, ...base, locale: c.locale }) : null,
1751
- article.children.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.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
1752
2181
  ] }) : null,
1753
- /* @__PURE__ */ (0, import_jsx_runtime7.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" }),
1754
2183
  toc.wide,
1755
- jsonLdOrigin ? /* @__PURE__ */ (0, import_jsx_runtime7.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
1756
2185
  ] }) });
1757
2186
  }
1758
2187
  function ListPage({ list, olderHref, description, origin, path, jsonLd, cursor, ...base }) {
@@ -1763,46 +2192,47 @@ function ListPage({ list, olderHref, description, origin, path, jsonLd, cursor,
1763
2192
  for (const item of list.items) groups.set(item.published_at.slice(0, 7), [...groups.get(item.published_at.slice(0, 7)) ?? [], item]);
1764
2193
  const notTranslated = list.fallback ? s.fallbackTitle.replace("{language}", languageName(list.fallback.requested_locale, c.locale)) : void 0;
1765
2194
  const jsonLdOrigin = bareOrigin(origin);
1766
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Shell, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-listpage", "data-hyle-page": "list", lang: c.locale, children: [
1767
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("header", { className: "hyle-head", children: [
1768
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h1", { className: "hyle-title", children: list.section.title }),
1769
- description ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "hyle-desc", children: description }) : null,
1770
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Slot, { name: "list.header", slots: base.slots, className: "hyle-slot-wrap" }),
1771
- notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
1772
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "alert" }),
1773
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
1774
- /* @__PURE__ */ (0, import_jsx_runtime7.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 }),
1775
2204
  " ",
1776
2205
  s.fallbackBody
1777
2206
  ] })
1778
2207
  ] }) : null
1779
2208
  ] }),
1780
- list.items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-empty", "data-slot-state": "empty", children: [
1781
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "file" }),
1782
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h2", { children: s.emptyTitle }),
1783
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: s.emptyBody }),
1784
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Slot, { name: "list.empty", slots: base.slots })
1785
- ] }) : [...groups].map(([month, items]) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { "aria-label": formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }), children: [
1786
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h2", { className: "hyle-year", children: formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }) }),
1787
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { className: "hyle-items", children: items.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: [
1788
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }),
1789
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
1790
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "t", children: item.title }),
1791
- item.description ? /* @__PURE__ */ (0, import_jsx_runtime7.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
1792
2221
  ] })
1793
2222
  ] }) }, item.canonical_path)) })
1794
2223
  ] }, month)),
1795
- olderHref ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(OlderNav, { href: olderHref, c }) : null,
1796
- jsonLdOrigin && path ? /* @__PURE__ */ (0, import_jsx_runtime7.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
1797
2226
  ] }) });
1798
2227
  }
1799
2228
 
1800
2229
  // src/react/index.ts
1801
2230
  var import_comments2 = require("./comments.cjs");
2231
+ var import_reactions = require("./reactions.cjs");
1802
2232
 
1803
2233
  // src/react/docs.tsx
1804
2234
  var import_docs_enhance = require("./docs-enhance.cjs");
1805
- var import_jsx_runtime8 = require("react/jsx-runtime");
2235
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1806
2236
  var ROOT_ID = "hyle-docs";
1807
2237
  var NAV_ID = "hyle-docs-nav";
1808
2238
  function navTreeOf(article) {
@@ -1826,15 +2256,15 @@ function pathTo(nodes, path) {
1826
2256
  }
1827
2257
  function Branch({ nodes, current, onPath, c }) {
1828
2258
  const { Link } = c;
1829
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { children: nodes.map((node) => {
1830
- const link = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Link, { href: c.href(node.canonical_path), ...node.canonical_path === current ? { "aria-current": "page" } : {}, children: node.title });
1831
- if (node.children.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: link }, node.canonical_path);
1832
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("details", { ...onPath.has(node.canonical_path) ? { open: true } : {}, children: [
1833
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("summary", { children: [
1834
- /* @__PURE__ */ (0, import_jsx_runtime8.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" }),
1835
2265
  link
1836
2266
  ] }),
1837
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Branch, { nodes: node.children, current, onPath, c })
2267
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Branch, { nodes: node.children, current, onPath, c })
1838
2268
  ] }) }, node.canonical_path);
1839
2269
  }) });
1840
2270
  }
@@ -1848,47 +2278,47 @@ function DocsPage({ article, ...base }) {
1848
2278
  const siteName = article.breadcrumbs[0]?.title ?? "";
1849
2279
  const headingIds = article.toc.filter((t) => t.depth === 2 || t.depth === 3).map((t) => scopeId(t.id));
1850
2280
  const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
1851
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Shell, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-docs", id: ROOT_ID, lang: c.locale, children: [
1852
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_docs_enhance.DocsEnhance, { headingIds, rootId: ROOT_ID }),
1853
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", className: "hyle-nav-bar", popoverTarget: NAV_ID, children: [
1854
- /* @__PURE__ */ (0, import_jsx_runtime8.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" }),
1855
2285
  s.menu,
1856
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "cur", children: pub.title }),
1857
- /* @__PURE__ */ (0, import_jsx_runtime8.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" })
1858
2288
  ] }),
1859
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("aside", { className: "hyle-nav-d", id: NAV_ID, popover: "auto", "aria-label": s.docs, children: [
1860
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-side-head", children: [
1861
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("b", { children: siteName }),
1862
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "docs.version", slots: base.slots, tag: "span" }),
1863
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "hyle-nav-x", popoverTarget: NAV_ID, popoverTargetAction: "hide", "aria-label": s.closeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime8.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" }) })
1864
2294
  ] }),
1865
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
1866
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Branch, { nodes: tree, current: pub.canonical_path, onPath, c }) }),
1867
- /* @__PURE__ */ (0, import_jsx_runtime8.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" })
1868
2298
  ] }),
1869
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
1870
- notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
1871
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "alert" }),
1872
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
1873
- /* @__PURE__ */ (0, import_jsx_runtime8.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 }),
1874
2304
  " ",
1875
2305
  s.fallbackBody
1876
2306
  ] })
1877
2307
  ] }) : null,
1878
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
1879
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h1", { className: "hyle-title", children: pub.title }),
1880
- pub.description ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
1881
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("p", { className: "hyle-updated", children: [
1882
- /* @__PURE__ */ (0, import_jsx_runtime8.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" }),
1883
2313
  s.updated,
1884
2314
  " ",
1885
- /* @__PURE__ */ (0, import_jsx_runtime8.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) })
1886
2316
  ] }),
1887
2317
  toc.narrow,
1888
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Body, { article, components: base.components, locale: c.locale }),
1889
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Pager, { prev: article.prev, next: article.next, c }),
1890
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" }),
1891
- /* @__PURE__ */ (0, import_jsx_runtime8.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" })
1892
2322
  ] }),
1893
2323
  toc.wide
1894
2324
  ] }) });
@@ -1916,7 +2346,7 @@ function sitePathFrom(basePath, segments) {
1916
2346
  return void 0;
1917
2347
  }
1918
2348
  if (segment !== segment.normalize("NFC")) return void 0;
1919
- 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;
1920
2350
  decoded.push(segment);
1921
2351
  }
1922
2352
  const path = decoded.length === 0 ? basePath || "/" : `${basePath}/${decoded.join("/")}`;
@@ -1928,7 +2358,7 @@ function safeRedirectTarget(to) {
1928
2358
  }
1929
2359
 
1930
2360
  // src/next/resolve.ts
1931
- var DEFAULT_REVALIDATE = 300;
2361
+ var DEFAULT_REVALIDATE = 86400;
1932
2362
  var MAX_TAGS2 = 64;
1933
2363
  function workspaceTags(workspaceId, sections = []) {
1934
2364
  const workspaceTag = `hyle:1:ws:${workspaceId}`;
@@ -1978,15 +2408,17 @@ function routeContext(options, params) {
1978
2408
  const toHref = (sitePath, linkLocale = locale) => (linkLocale ? prefix(linkLocale) : "") + sitePath;
1979
2409
  return { basePath, path, locale, toHref };
1980
2410
  }
1981
- function isRejectedRequest(error) {
2411
+ function isNotFoundError(error, cursor) {
1982
2412
  (0, import_navigation.unstable_rethrow)(error);
1983
- 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";
1984
2415
  }
1985
2416
 
1986
2417
  // src/next/embed.tsx
1987
2418
  var import_navigation2 = require("next/navigation");
1988
2419
 
1989
2420
  // src/next/engage.ts
2421
+ var import_node_crypto3 = require("crypto");
1990
2422
  var ENGAGE_CSRF_HEADER = "x-hyle-engage";
1991
2423
  var DEFAULT_TIMEOUT_MS2 = 1e4;
1992
2424
  var DEFAULT_SHARE_MS = 3e3;
@@ -2020,9 +2452,8 @@ function match(segments) {
2020
2452
  methods: ["GET", "POST"],
2021
2453
  rebuild: (method, body, url) => {
2022
2454
  if (method === "GET") {
2023
- const keys = [...url.searchParams.keys()];
2024
- const path = url.searchParams.get("path");
2025
- return keys.length === 1 && isSitePath2(path) ? { upstream: "/comments", query: new URLSearchParams({ path }) } : void 0;
2455
+ const query = listingQuery(url.searchParams);
2456
+ return query && { upstream: "/comments", query };
2026
2457
  }
2027
2458
  const clean2 = pick(body, ["path", "body", "parent_id"], ["path", "body"]);
2028
2459
  if (!clean2 || !isSitePath2(clean2.path) || !isCommentText(clean2.body)) return void 0;
@@ -2049,15 +2480,38 @@ function match(segments) {
2049
2480
  methods: ["PUT", "DELETE"],
2050
2481
  rebuild: (_method, body) => {
2051
2482
  const type = body?.subject_type;
2052
- const clean2 = type === "article" ? pick(body, ["subject_type", "path"], ["subject_type", "path"]) : type === "comment" ? pick(body, ["subject_type", "comment_id"], ["subject_type", "comment_id"]) : void 0;
2053
- if (!clean2) return void 0;
2483
+ const subject = type === "article" ? "path" : type === "comment" ? "comment_id" : void 0;
2484
+ const clean2 = subject && pick(body, ["subject_type", subject, "kind"], ["subject_type", subject]);
2485
+ if (!clean2 || clean2.kind !== void 0 && !REACTION_KINDS.includes(clean2.kind)) return void 0;
2054
2486
  const valid = type === "article" ? isSitePath2(clean2.path) : typeof clean2.comment_id === "string" && UUID2.test(clean2.comment_id);
2055
2487
  return valid ? { upstream: "/reactions", body: clean2 } : void 0;
2056
2488
  }
2057
2489
  };
2058
2490
  }
2491
+ if (a === "votes" && b === void 0) {
2492
+ return {
2493
+ action: (m) => m === "PUT" ? "votes.set" : "votes.remove",
2494
+ methods: ["PUT", "DELETE"],
2495
+ rebuild: (method, body) => {
2496
+ const keys = method === "PUT" ? ["comment_id", "value"] : ["comment_id"];
2497
+ const clean2 = pick(body, keys, keys);
2498
+ if (!clean2 || typeof clean2.comment_id !== "string" || !UUID2.test(clean2.comment_id)) return void 0;
2499
+ if (method === "PUT" && clean2.value !== 1 && clean2.value !== -1) return void 0;
2500
+ return { upstream: "/votes", body: clean2 };
2501
+ }
2502
+ };
2503
+ }
2059
2504
  return void 0;
2060
2505
  }
2506
+ function listingQuery(params) {
2507
+ const keys = [...params.keys()];
2508
+ if (new Set(keys).size !== keys.length || keys.some((k) => k !== "path" && k !== "cursor" && k !== "sort")) return void 0;
2509
+ const path = params.get("path");
2510
+ const cursor = params.get("cursor");
2511
+ const sort = params.get("sort");
2512
+ if (!isSitePath2(path) || cursor !== null && !isCursor(cursor) || sort !== null && sort !== "new" && sort !== "top") return void 0;
2513
+ return new URLSearchParams({ path, ...cursor === null ? {} : { cursor }, ...sort === null ? {} : { sort } });
2514
+ }
2061
2515
  function pick(body, allowed, required) {
2062
2516
  if (!body || Object.keys(body).some((k) => !allowed.includes(k)) || !required.every((k) => k in body)) return void 0;
2063
2517
  return Object.fromEntries(allowed.filter((k) => k in body).map((k) => [k, body[k]]));
@@ -2166,7 +2620,7 @@ function createEngagementRoute(options) {
2166
2620
  entry.result.then(
2167
2621
  (o) => {
2168
2622
  if (cache.get(key) !== entry) return;
2169
- if (o.status !== 200 && o.status !== 404 || o.noShare || o.text.length > MAX_SHARED_ENTRY_BYTES) return forget(key, entry);
2623
+ if (![200, 400, 404].includes(o.status) || o.noShare || o.text.length > MAX_SHARED_ENTRY_BYTES) return forget(key, entry);
2170
2624
  entry.bytes = o.text.length;
2171
2625
  cacheBytes += entry.bytes;
2172
2626
  while ((cacheBytes > MAX_SHARED_BYTES || cache.size > MAX_SHARED) && cache.size > 0) {
@@ -2229,7 +2683,7 @@ function createEngagementRoute(options) {
2229
2683
  }
2230
2684
  if (route.local === "session") {
2231
2685
  const who = await reader(req, config);
2232
- return json(200, { data: { reader: who ? { name: who.reader.name } : null } });
2686
+ return json(200, { data: { reader: who ? { id: (0, import_node_crypto3.createHash)("sha256").update(who.reader.sub).digest("base64url"), name: who.reader.name } : null } });
2233
2687
  }
2234
2688
  let assertion;
2235
2689
  let viewer = null;
@@ -2258,7 +2712,9 @@ function createEngagementRoute(options) {
2258
2712
  redirect: "error",
2259
2713
  signal: AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS2)
2260
2714
  });
2261
- 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") };
2262
2718
  };
2263
2719
  try {
2264
2720
  const out = route.action(req.method) === "comments.list" ? await shared(`${viewer?.reader.sub ?? ""}
@@ -2275,12 +2731,12 @@ ${built.query.toString()}`, () => listing(viewer, call)) : await call();
2275
2731
  }
2276
2732
 
2277
2733
  // src/next/embed.tsx
2278
- var import_jsx_runtime9 = require("react/jsx-runtime");
2279
- async function resolveEmbed(options, run) {
2734
+ var import_jsx_runtime11 = require("react/jsx-runtime");
2735
+ async function resolveEmbed(options, run, cursor) {
2280
2736
  try {
2281
2737
  return { result: await run() };
2282
2738
  } catch (error) {
2283
- if (isRejectedRequest(error)) return {};
2739
+ if (isNotFoundError(error, cursor)) return {};
2284
2740
  console.error(`hyle: ${error instanceof Error ? error.name : "UnknownError"}`);
2285
2741
  return { failure: options.onError ? options.onError(error) : null };
2286
2742
  }
@@ -2290,10 +2746,11 @@ async function HyleList({ options, limit = 5, locale, layout, title, headingLeve
2290
2746
  const route = routeContext(locale ? { ...options, locale } : options, {});
2291
2747
  const path = sitePathFrom(route.basePath, void 0);
2292
2748
  if (path === void 0) return null;
2293
- 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);
2294
2751
  if (failure !== void 0) return failure;
2295
2752
  const next = olderHref && result?.kind === "list" ? validCursor(result.next_cursor) : void 0;
2296
- return /* @__PURE__ */ (0, import_jsx_runtime9.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 });
2297
2754
  }
2298
2755
  async function HyleArticle({ options, path, locale, headingLevel }) {
2299
2756
  if (!isSitePath2(path)) return null;
@@ -2302,7 +2759,7 @@ async function HyleArticle({ options, path, locale, headingLevel }) {
2302
2759
  const { result, failure } = await resolveEmbed(options, () => resolve(path, route.locale));
2303
2760
  if (failure !== void 0) return failure;
2304
2761
  if (result?.kind !== "article") return null;
2305
- return /* @__PURE__ */ (0, import_jsx_runtime9.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 });
2306
2763
  }
2307
2764
  var MAX_LISTING_BYTES = 4 * 1024 * 1024;
2308
2765
  var COMMENTS_TIMEOUT_MS = 1e4;
@@ -2322,7 +2779,7 @@ async function HyleComments({ options, path, revalidate = 60, interactive }) {
2322
2779
  };
2323
2780
  const res = await fetch(`${options.baseUrl.replace(/\/+$/, "")}/cp1/engage/comments?${new URLSearchParams({ path })}`, init);
2324
2781
  if (!res.ok) {
2325
- 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}`);
2326
2783
  return null;
2327
2784
  }
2328
2785
  listing = parseListing(JSON.parse(await readCapped(res, MAX_LISTING_BYTES)).data);
@@ -2334,13 +2791,13 @@ async function HyleComments({ options, path, revalidate = 60, interactive }) {
2334
2791
  return null;
2335
2792
  }
2336
2793
  if (!listing) return null;
2337
- if (!interactive) return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HyleCommentsView, { listing, locale });
2794
+ if (!interactive) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HyleCommentsView, { listing, locale });
2338
2795
  const config = interactive === true ? {} : interactive;
2339
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime9.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 }) });
2340
2797
  }
2341
2798
 
2342
2799
  // src/next/page.tsx
2343
- var import_jsx_runtime10 = require("react/jsx-runtime");
2800
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2344
2801
  function hylePage(options) {
2345
2802
  const resolve = resolverFor(options);
2346
2803
  async function relatedItems(article) {
@@ -2353,21 +2810,22 @@ function hylePage(options) {
2353
2810
  return async function HylePage({ params, searchParams }) {
2354
2811
  const { path, locale, toHref } = routeContext(options, await params ?? {});
2355
2812
  if (path === void 0) (0, import_navigation3.notFound)();
2813
+ let cursor;
2356
2814
  try {
2357
- const cursor = options.paginate === "searchParams" ? validCursor((await searchParams)?.cursor) : void 0;
2815
+ cursor = options.paginate === "searchParams" ? validCursor((await searchParams)?.cursor) : void 0;
2358
2816
  const result = await resolve(path, locale, options.listLimit, cursor, options.layout === "docs" ? "tree" : void 0);
2359
2817
  switch (result.kind) {
2360
2818
  case "article": {
2361
2819
  const image = articleImage(options, result);
2362
2820
  const related = options.related && options.layout !== "docs" ? await relatedItems(result) : void 0;
2363
2821
  const props = { article: result, components: options.components, slots: options.slots, locale, toHref };
2364
- return options.layout === "docs" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DocsPage, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime10.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 } : {} });
2365
2823
  }
2366
2824
  case "list": {
2367
2825
  const list = options.list?.title ? { ...result, section: { ...result.section, title: options.list.title } } : result;
2368
2826
  const next = options.paginate === "searchParams" ? validCursor(result.next_cursor) : void 0;
2369
2827
  const olderHref = next ? `${toHref(path)}?cursor=${next}` : void 0;
2370
- return /* @__PURE__ */ (0, import_jsx_runtime10.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 });
2371
2829
  }
2372
2830
  case "redirect": {
2373
2831
  const to = safeRedirectTarget(result.to);
@@ -2382,7 +2840,7 @@ function hylePage(options) {
2382
2840
  (0, import_navigation3.notFound)();
2383
2841
  }
2384
2842
  } catch (error) {
2385
- if (isRejectedRequest(error)) (0, import_navigation3.notFound)();
2843
+ if (isNotFoundError(error, cursor)) (0, import_navigation3.notFound)();
2386
2844
  if (!options.onError) throw error;
2387
2845
  console.error(`hyle: ${error instanceof Error ? error.name : "UnknownError"}`);
2388
2846
  return options.onError(error);
@@ -2483,8 +2941,9 @@ function hyleMetadata(options) {
2483
2941
  };
2484
2942
  return Object.keys(types).length ? { ...alternates, types } : alternates;
2485
2943
  };
2944
+ let cursor;
2486
2945
  try {
2487
- const cursor = options.paginate === "searchParams" ? validCursor((await searchParams)?.cursor) : void 0;
2946
+ cursor = options.paginate === "searchParams" ? validCursor((await searchParams)?.cursor) : void 0;
2488
2947
  const result = await resolve(path, locale, options.listLimit, cursor, options.layout === "docs" ? "tree" : void 0);
2489
2948
  const parentMeta = parent ? await parent : void 0;
2490
2949
  const parentImages = parentMeta?.openGraph?.images;
@@ -2560,7 +3019,7 @@ function hyleMetadata(options) {
2560
3019
  } : {}
2561
3020
  };
2562
3021
  } catch (error) {
2563
- if (isRejectedRequest(error)) return {};
3022
+ if (isNotFoundError(error, cursor)) return {};
2564
3023
  throw error;
2565
3024
  }
2566
3025
  };
@@ -2622,7 +3081,7 @@ function createRevalidateRoute(options) {
2622
3081
  if (!workspaceId || secrets.length === 0) return new Response(null, { status: 503 });
2623
3082
  const key = `${workspaceId}\0${secrets.join("\0")}`;
2624
3083
  if (cached?.key !== key) {
2625
- cached = { key, route: createRevalidationCallbackRoute({ workspaceId, secrets, revalidateTag: (tag2) => (0, import_cache.revalidateTag)(tag2, { expire: 0 }) }) };
3084
+ cached = { key, route: createRevalidationCallbackRoute({ workspaceId, secrets, revalidateTag: (tag2) => (0, import_cache.revalidateTag)(tag2, { expire: 0 }), onCommentEvent: options.onCommentEvent }) };
2626
3085
  }
2627
3086
  return cached.route.POST(req);
2628
3087
  }
@@ -2677,10 +3136,7 @@ function mountsLoader(config) {
2677
3136
  lastKnownGood.set(key, { loaded, at: Date.now() });
2678
3137
  return loaded;
2679
3138
  } catch (error) {
2680
- if (isRejectedRequest(error)) {
2681
- lastKnownGood.delete(key);
2682
- return NONE;
2683
- }
3139
+ (0, import_navigation5.unstable_rethrow)(error);
2684
3140
  if (error instanceof Cp1ClientError && (error.status === 401 || error.status === 403)) {
2685
3141
  lastKnownGood.delete(key);
2686
3142
  throw error;
@@ -2812,7 +3268,7 @@ function createMarkdownRoute(options) {
2812
3268
  }
2813
3269
  return reply(null, 404);
2814
3270
  } catch (error) {
2815
- if (isRejectedRequest(error)) return reply(null, 404);
3271
+ if (isNotFoundError(error)) return reply(null, 404);
2816
3272
  console.error(`hyle: ${error instanceof Error ? error.name : "UnknownError"}`);
2817
3273
  return reply(null, 502);
2818
3274
  }
@@ -2863,8 +3319,34 @@ var DEFAULT_TIMEOUT_MS3 = 3e4;
2863
3319
  var CACHE_CONTROL = "public, max-age=3600, s-maxage=86400, stale-while-revalidate=86400";
2864
3320
  var PARTIAL_CACHE_CONTROL = "no-store";
2865
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" };
2866
3323
  var empty = (status, headers = {}) => new Response(null, { status, headers: { "Cache-Control": "no-store", ...headers } });
2867
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
+ }
2868
3350
  function capped(body, max) {
2869
3351
  let seen = 0;
2870
3352
  return body.pipeThrough(
@@ -2881,18 +3363,28 @@ function createAssetRoute(options) {
2881
3363
  let client;
2882
3364
  const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
2883
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) {
2884
3372
  if (isSwitchedOff3((options.env ?? process.env).HYLE_CONTENT_ENABLED)) return empty(404);
2885
3373
  const file = (await ctx2.params).file;
2886
- 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);
2887
3377
  try {
2888
3378
  client ??= createHyleClient({ baseUrl: options.baseUrl?.trim() ?? "", token: options.token?.trim() ?? "", ...options.fetch ? { fetch: options.fetch } : {} });
2889
3379
  } catch {
2890
3380
  return empty(404);
2891
3381
  }
3382
+ if (themeScope && themeHash) return serveTheme(client, themeScope, themeHash, options.timeoutMs ?? DEFAULT_TIMEOUT_MS3, head);
2892
3383
  let upstream;
2893
3384
  try {
2894
3385
  upstream = await client.asset(file, {
2895
3386
  timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS3,
3387
+ ...previewToken === null ? {} : { previewToken },
2896
3388
  headers: { range: req.headers.get("range"), "if-range": req.headers.get("if-range"), "if-none-match": req.headers.get("if-none-match") }
2897
3389
  });
2898
3390
  } catch {
@@ -2905,10 +3397,16 @@ function createAssetRoute(options) {
2905
3397
  drop();
2906
3398
  return new Response(null, { status: 304, headers: { "Cache-Control": CACHE_CONTROL, Vary: "Range", ...SAFE_HEADERS, ...etag ? { ETag: etag } : {} } });
2907
3399
  }
2908
- if (upstream.status === 404 || upstream.status === 416) {
3400
+ if (upstream.status === 404) return empty(await isNotFoundResponse(upstream) ? 404 : 502);
3401
+ if (upstream.status === 416) {
3402
+ drop();
3403
+ const range = upstream.headers.get("content-range");
3404
+ return empty(416, range ? { "Content-Range": range } : {});
3405
+ }
3406
+ if (upstream.status === 429 && previewToken !== null) {
2909
3407
  drop();
2910
- const range = upstream.status === 416 ? upstream.headers.get("content-range") : null;
2911
- return empty(upstream.status, range ? { "Content-Range": range } : {});
3408
+ const wait = upstream.headers.get("retry-after");
3409
+ return empty(429, wait ? { "Retry-After": wait } : {});
2912
3410
  }
2913
3411
  const type = upstream.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
2914
3412
  const length = Number(upstream.headers.get("content-length"));
@@ -2932,7 +3430,7 @@ function createAssetRoute(options) {
2932
3430
  }
2933
3431
 
2934
3432
  // src/next/og.tsx
2935
- var import_jsx_runtime11 = require("react/jsx-runtime");
3433
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2936
3434
  var SIZE = { width: 1200, height: 630 };
2937
3435
  var MAX_TITLE = 140;
2938
3436
  function createOgImageRoute(options) {
@@ -2957,14 +3455,14 @@ function createOgImageRoute(options) {
2957
3455
  if (result.kind !== "article") return new Response(null, { status: 404 });
2958
3456
  title = result.publication.title;
2959
3457
  } catch (error) {
2960
- return new Response(null, { status: isRejectedRequest(error) ? 404 : 502 });
3458
+ return new Response(null, { status: isNotFoundError(error) ? 404 : 502 });
2961
3459
  }
2962
3460
  const chars = [...title];
2963
3461
  const shown = chars.length > MAX_TITLE ? `${chars.slice(0, MAX_TITLE - 1).join("")}\u2026` : title;
2964
3462
  return new import_og.ImageResponse(
2965
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: { display: "flex", flexDirection: "column", justifyContent: "space-between", width: "100%", height: "100%", padding: 80, background: "#111827", color: "#ffffff" }, children: [
2966
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { fontSize: 64, fontWeight: 700, lineHeight: 1.2 }, children: shown }),
2967
- options.siteName ? /* @__PURE__ */ (0, import_jsx_runtime11.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
2968
3466
  ] }),
2969
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.
2970
3468
  { ...SIZE, headers: { "cache-control": "public, max-age=3600, s-maxage=31536000, immutable" } }
@@ -2972,6 +3470,38 @@ function createOgImageRoute(options) {
2972
3470
  }
2973
3471
  };
2974
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
+ }
2975
3505
  // Annotate the CommonJS export names for ESM import in node:
2976
3506
  0 && (module.exports = {
2977
3507
  ENGAGE_CSRF_HEADER,
@@ -2991,6 +3521,8 @@ function createOgImageRoute(options) {
2991
3521
  hyleFeedLink,
2992
3522
  hyleMetadata,
2993
3523
  hylePage,
3524
+ hylePreviewMetadata,
3525
+ hylePreviewPage,
2994
3526
  hyleRootMetadata,
2995
3527
  hyleRootPage,
2996
3528
  hyleRootSitemap,