@tdacorp/hyle-sdk 0.14.1 → 0.21.0

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 (86) hide show
  1. package/README.md +171 -32
  2. package/dist/check-routes-bin.js +48 -21
  3. package/dist/chunk-56Y24XBV.js +840 -0
  4. package/dist/{chunk-MGSUQBDW.js → chunk-75JFLML4.js} +176 -14
  5. package/dist/chunk-HJX57NLI.js +1105 -0
  6. package/dist/chunk-K5VDLROQ.js +145 -0
  7. package/dist/{chunk-BUJFMR3M.js → chunk-QVYQM5R2.js} +15 -6
  8. package/dist/chunk-U74B7AUG.js +398 -0
  9. package/dist/{chunk-6VOHFFA5.js → chunk-X2TLYM7Y.js} +2 -2
  10. package/dist/client-41fU6OY2.d.cts +201 -0
  11. package/dist/client-LwzHwqpM.d.ts +201 -0
  12. package/dist/code-copy.cjs +72 -0
  13. package/dist/code-copy.d.cts +15 -0
  14. package/dist/code-copy.d.ts +15 -0
  15. package/dist/code-copy.js +48 -0
  16. package/dist/comments.cjs +733 -278
  17. package/dist/comments.d.cts +66 -3
  18. package/dist/comments.d.ts +66 -3
  19. package/dist/comments.js +414 -330
  20. package/dist/{diagram-viewer-DYX6R63Y.js → diagram-viewer-XY3CG75U.js} +107 -46
  21. package/dist/{embed-B76zRRPa.d.cts → embed-BUFRQboD.d.ts} +10 -5
  22. package/dist/{embed-SqOBGI-E.d.ts → embed-CYt-q13P.d.cts} +10 -5
  23. package/dist/fragment-alias.cjs +51 -0
  24. package/dist/fragment-alias.d.cts +7 -0
  25. package/dist/fragment-alias.d.ts +7 -0
  26. package/dist/fragment-alias.js +27 -0
  27. package/dist/html.cjs +881 -0
  28. package/dist/html.d.cts +20 -0
  29. package/dist/html.d.ts +20 -0
  30. package/dist/html.js +45 -0
  31. package/dist/index.cjs +181 -14
  32. package/dist/index.d.cts +14 -62
  33. package/dist/index.d.ts +14 -62
  34. package/dist/index.js +11 -1
  35. package/dist/labels-CrA-iqTN.d.cts +46 -0
  36. package/dist/labels-CrA-iqTN.d.ts +46 -0
  37. package/dist/mermaid-diagram.cjs +453 -148
  38. package/dist/mermaid-diagram.d.cts +25 -42
  39. package/dist/mermaid-diagram.d.ts +25 -42
  40. package/dist/mermaid-diagram.js +205 -50
  41. package/dist/mermaid-image.cjs +1456 -0
  42. package/dist/mermaid-image.d.cts +30 -0
  43. package/dist/mermaid-image.d.ts +30 -0
  44. package/dist/mermaid-image.js +93 -0
  45. package/dist/next.cjs +1709 -1134
  46. package/dist/next.d.cts +67 -14
  47. package/dist/next.d.ts +67 -14
  48. package/dist/next.js +950 -794
  49. package/dist/print-coordinator.cjs +157 -0
  50. package/dist/print-coordinator.d.cts +27 -0
  51. package/dist/print-coordinator.d.ts +27 -0
  52. package/dist/print-coordinator.js +83 -0
  53. package/dist/react.cjs +677 -264
  54. package/dist/react.d.cts +161 -31
  55. package/dist/react.d.ts +161 -31
  56. package/dist/react.js +23 -3
  57. package/dist/reactions.cjs +653 -0
  58. package/dist/reactions.d.cts +27 -0
  59. package/dist/reactions.d.ts +27 -0
  60. package/dist/reactions.js +364 -0
  61. package/dist/{resolve-DC2ccfwA.d.ts → resolve-BjAK0k_Y.d.ts} +2 -2
  62. package/dist/{resolve-DKLVftk_.d.cts → resolve-eI1muCKL.d.cts} +2 -2
  63. package/dist/revalidation-callback-BQl77tQR.d.cts +75 -0
  64. package/dist/revalidation-callback-BQl77tQR.d.ts +75 -0
  65. package/dist/sanitize-ijiWjEm9.d.cts +23 -0
  66. package/dist/sanitize-ijiWjEm9.d.ts +23 -0
  67. package/dist/styles.css +107 -47
  68. package/dist/toc-spy.cjs +59 -0
  69. package/dist/toc-spy.d.cts +15 -0
  70. package/dist/toc-spy.d.ts +15 -0
  71. package/dist/toc-spy.js +35 -0
  72. package/dist/{types-ByodIyEv.d.cts → types-3F0wqD-o.d.cts} +44 -4
  73. package/dist/{types-ByodIyEv.d.ts → types-3F0wqD-o.d.ts} +44 -4
  74. package/dist/use-cache.cjs +37 -11
  75. package/dist/use-cache.d.cts +12 -5
  76. package/dist/use-cache.d.ts +12 -5
  77. package/dist/use-cache.js +7 -7
  78. package/dist/youtube-facade.cjs +50 -0
  79. package/dist/youtube-facade.d.cts +17 -0
  80. package/dist/youtube-facade.d.ts +17 -0
  81. package/dist/youtube-facade.js +26 -0
  82. package/package.json +16 -3
  83. package/dist/chunk-4V4VKB3O.js +0 -1471
  84. package/dist/chunk-R5EMI4HQ.js +0 -61
  85. package/dist/revalidation-callback-D7Ms_Puz.d.cts +0 -42
  86. package/dist/revalidation-callback-D7Ms_Puz.d.ts +0 -42
@@ -0,0 +1,1105 @@
1
+ import {
2
+ HastLimitError,
3
+ diagramRender,
4
+ formatDate,
5
+ isSafeUrl,
6
+ languageName,
7
+ mermaidSource,
8
+ sanitizeHast,
9
+ scopeId,
10
+ stringsFor,
11
+ youtubeId
12
+ } from "./chunk-56Y24XBV.js";
13
+ import {
14
+ hostAssetHtml
15
+ } from "./chunk-67IOIAVW.js";
16
+
17
+ // src/react/content.tsx
18
+ import { toJsxRuntime } from "hast-util-to-jsx-runtime";
19
+ import { Children, Fragment as Fragment2, isValidElement } from "react";
20
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
21
+
22
+ // src/react/icons.tsx
23
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
24
+ var SHAPES = {
25
+ info: /* @__PURE__ */ jsxs(Fragment, { children: [
26
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6" }),
27
+ /* @__PURE__ */ jsx("path", { d: "M8 7.3V11M8 5v.1" })
28
+ ] }),
29
+ "check-circle": /* @__PURE__ */ jsxs(Fragment, { children: [
30
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6" }),
31
+ /* @__PURE__ */ jsx("path", { d: "m5.3 8.3 1.9 1.9 3.5-3.9" })
32
+ ] }),
33
+ alert: /* @__PURE__ */ jsx("path", { d: "M8 2 1.8 13h12.4zM8 6.5v3M8 11.3v.1" }),
34
+ "x-circle": /* @__PURE__ */ jsxs(Fragment, { children: [
35
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6" }),
36
+ /* @__PURE__ */ jsx("path", { d: "m5.8 5.8 4.4 4.4M10.2 5.8l-4.4 4.4" })
37
+ ] }),
38
+ calendar: /* @__PURE__ */ jsxs(Fragment, { children: [
39
+ /* @__PURE__ */ jsx("rect", { x: "2", y: "3", width: "12", height: "11", rx: "1.3" }),
40
+ /* @__PURE__ */ jsx("path", { d: "M2 6.5h12M5.5 1.7v2.6M10.5 1.7v2.6" })
41
+ ] }),
42
+ globe: /* @__PURE__ */ jsxs(Fragment, { children: [
43
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6" }),
44
+ /* @__PURE__ */ jsx("path", { d: "M2 8h12M8 2c2 1.7 2.8 3.7 2.8 6S10 12.3 8 14M8 2C6 3.7 5.2 5.7 5.2 8S6 12.3 8 14" })
45
+ ] }),
46
+ file: /* @__PURE__ */ jsxs(Fragment, { children: [
47
+ /* @__PURE__ */ jsx("path", { d: "M4 1.8h5l3 3v8.4a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V2.8a1 1 0 0 1 1-1z" }),
48
+ /* @__PURE__ */ jsx("path", { d: "M9 1.8v3h3" })
49
+ ] }),
50
+ chev: /* @__PURE__ */ jsx("path", { d: "m6 3.5 4.5 4.5L6 12.5" }),
51
+ "chev-up": /* @__PURE__ */ jsx("path", { d: "m3.5 10 4.5-4.5L12.5 10" }),
52
+ "chev-down": /* @__PURE__ */ jsx("path", { d: "m3.5 6 4.5 4.5L12.5 6" }),
53
+ "chev-left": /* @__PURE__ */ jsx("path", { d: "M10 3.5 5.5 8 10 12.5" }),
54
+ x: /* @__PURE__ */ jsx("path", { d: "m4 4 8 8M12 4l-8 8" }),
55
+ important: /* @__PURE__ */ 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" }),
56
+ copy: /* @__PURE__ */ jsxs(Fragment, { children: [
57
+ /* @__PURE__ */ jsx("rect", { x: "5.5", y: "5.5", width: "8", height: "8", rx: "1.3" }),
58
+ /* @__PURE__ */ 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" })
59
+ ] }),
60
+ check: /* @__PURE__ */ jsx("path", { d: "m3 8.5 3.2 3L13 4.5" }),
61
+ heart: /* @__PURE__ */ 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" }),
62
+ reply: /* @__PURE__ */ jsx("path", { d: "M6.5 3.5 2.5 7.5l4 4M2.5 7.5h6a5 5 0 0 1 5 5" }),
63
+ clock: /* @__PURE__ */ jsxs(Fragment, { children: [
64
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6" }),
65
+ /* @__PURE__ */ jsx("path", { d: "M8 4.5V8l2.3 1.5" })
66
+ ] }),
67
+ ban: /* @__PURE__ */ jsxs(Fragment, { children: [
68
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6" }),
69
+ /* @__PURE__ */ jsx("path", { d: "m3.8 12.2 8.4-8.4" })
70
+ ] }),
71
+ refresh: /* @__PURE__ */ jsx("path", { d: "M13 8a5 5 0 1 1-1.6-3.7M13 2.5v2.8h-2.8" })
72
+ };
73
+ function Icon({ name, className }) {
74
+ return /* @__PURE__ */ jsx("svg", { className: className ? `hyle-ic ${className}` : "hyle-ic", viewBox: "0 0 16 16", "aria-hidden": "true", children: SHAPES[name] });
75
+ }
76
+
77
+ // src/react/content.tsx
78
+ import { MermaidDiagram } from "./mermaid-diagram.js";
79
+ import { MermaidImage } from "./mermaid-image.js";
80
+ import { YouTubeFacade } from "./youtube-facade.js";
81
+ import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
82
+ function plainText(node) {
83
+ if (typeof node === "string" || typeof node === "number") return String(node);
84
+ if (Array.isArray(node)) return node.map(plainText).join("");
85
+ return isValidElement(node) ? plainText(node.props.children) : "";
86
+ }
87
+ var CALLOUT_ICON = { note: "info", tip: "check-circle", important: "important", warning: "alert", caution: "x-circle" };
88
+ function buildComponents(c, s, { opensWithImage, interactive }) {
89
+ const Link = c.Link ?? "a";
90
+ const Img = c.Image ?? "img";
91
+ const A = ({ href, children, ...rest }) => {
92
+ if (typeof href !== "string") return /* @__PURE__ */ jsx3(Fragment3, { children });
93
+ const url = href;
94
+ if (url.startsWith("/") || url.startsWith("#")) {
95
+ return url.startsWith("#") ? /* @__PURE__ */ jsx3("a", { href: url, ...rest, children }) : /* @__PURE__ */ jsx3(Link, { href: url, ...rest, children });
96
+ }
97
+ return /* @__PURE__ */ jsx3("a", { href: url, rel: "noopener noreferrer", ...rest, children });
98
+ };
99
+ let eager = opensWithImage;
100
+ const Image = (props) => {
101
+ if (typeof props.src !== "string") return null;
102
+ const first = eager;
103
+ eager = false;
104
+ return /* @__PURE__ */ jsx3(Img, { loading: first ? "eager" : "lazy", ...first ? { fetchPriority: "high" } : {}, decoding: "async", ...props });
105
+ };
106
+ const Pre = ({ children, ...rest }) => {
107
+ const code = Children.toArray(children).find(isValidElement);
108
+ const language = /(?:^|\s)language-([\w-]+)/.exec(code?.props.className ?? "")?.[1];
109
+ const pre = /* @__PURE__ */ jsx3("pre", { tabIndex: 0, ...rest, children });
110
+ if (c.CodeBlock) return /* @__PURE__ */ jsx3(c.CodeBlock, { code: plainText(children), language, children: pre });
111
+ return /* @__PURE__ */ jsxs3("figure", { className: "hyle-codeblock", "data-slot-component": "CodeBlock", children: [
112
+ language || interactive ? /* @__PURE__ */ jsxs3("header", { children: [
113
+ language ? /* @__PURE__ */ jsx3("span", { className: "lang", children: language }) : null,
114
+ interactive ? /* @__PURE__ */ jsxs3(Fragment3, { children: [
115
+ /* @__PURE__ */ jsxs3("button", { type: "button", "aria-label": s.copyCode, children: [
116
+ /* @__PURE__ */ jsx3(Icon, { name: "copy" }),
117
+ /* @__PURE__ */ jsx3(Icon, { name: "check" })
118
+ ] }),
119
+ /* @__PURE__ */ jsx3("span", { className: "hyle-sr", role: "status" })
120
+ ] }) : null
121
+ ] }) : null,
122
+ pre
123
+ ] });
124
+ };
125
+ const Table = ({ children, ...rest }) => /* @__PURE__ */ jsx3("div", { className: "hyle-table", tabIndex: 0, role: "region", "aria-label": s.table, children: /* @__PURE__ */ jsx3("table", { ...rest, children }) });
126
+ const Callout = ({ kind, children }) => {
127
+ const k = Object.hasOwn(CALLOUT_ICON, String(kind)) ? kind : "note";
128
+ const title = s[k];
129
+ if (c.Callout) return /* @__PURE__ */ jsx3(c.Callout, { kind: k, title, children });
130
+ return /* @__PURE__ */ jsxs3("aside", { className: "hyle-callout", "data-kind": k, "data-slot-component": "Callout", role: "note", children: [
131
+ /* @__PURE__ */ jsx3(Icon, { name: CALLOUT_ICON[k] }),
132
+ /* @__PURE__ */ jsxs3("div", { children: [
133
+ /* @__PURE__ */ jsx3("p", { className: "ttl", children: title }),
134
+ /* @__PURE__ */ jsx3("div", { className: "bd", children })
135
+ ] })
136
+ ] });
137
+ };
138
+ const Frame = (props) => {
139
+ const { srcDoc } = props;
140
+ if (typeof srcDoc !== "string") return null;
141
+ const source = mermaidSource(srcDoc);
142
+ if (c.Mermaid) return /* @__PURE__ */ jsx3(c.Mermaid, { srcDoc, source, title: s.diagram });
143
+ if (source === void 0) return null;
144
+ const light = diagramRender(props["data-light"]);
145
+ const dark = diagramRender(props["data-dark"]);
146
+ if (light && dark) {
147
+ return /* @__PURE__ */ jsx3(MermaidImage, { source, title: s.diagram, errorText: s.diagramError, loadingText: s.diagramLoading, sourceLabel: s.diagramSource, light, dark, labels: s.viewer });
148
+ }
149
+ return /* @__PURE__ */ jsx3(MermaidDiagram, { source, title: s.diagram, errorText: s.diagramError, loadingText: s.diagramLoading, labels: s.viewer });
150
+ };
151
+ const Heading = (level) => function HyleHeading({ id, children, ...rest }) {
152
+ const Tag = `h${level}`;
153
+ const anchored = typeof id === "string" && !String(rest.className ?? "").split(" ").includes("sr-only");
154
+ return /* @__PURE__ */ jsxs3(Tag, { id, ...rest, children: [
155
+ anchored ? /* @__PURE__ */ jsx3("a", { className: "hyle-anchor", href: `#${id}`, "aria-label": s.anchor }) : null,
156
+ children
157
+ ] });
158
+ };
159
+ const Checkbox = (props) => /* @__PURE__ */ jsx3("input", { ...props, "aria-label": props.checked ? s.done : s.notDone });
160
+ const Paragraph = ({ children, ...rest }) => {
161
+ const [only, ...more] = Children.toArray(children).filter((n) => typeof n !== "string" || n.trim() !== "");
162
+ if (more.length === 0 && isValidElement(only) && only.props["data-embed"] === "youtube") {
163
+ const id = youtubeId(only.props.href);
164
+ if (id) return /* @__PURE__ */ jsx3(YouTubeFacade, { videoId: id, playLabel: s.playVideo, frameTitle: s.videoFrame, children: /* @__PURE__ */ jsx3("p", { children: only }) });
165
+ }
166
+ return /* @__PURE__ */ jsx3("p", { ...rest, children });
167
+ };
168
+ 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 } : {} };
169
+ const overrides = ["a", "img", "code", "pre", "table", "blockquote", "h1", "h2", "h3", "h4", "h5", "h6"];
170
+ for (const key of overrides) if (c[key]) defaults[key] = c[key];
171
+ return defaults;
172
+ }
173
+ function HastContent(props) {
174
+ return renderHast(props, false);
175
+ }
176
+ function renderHast({ tree, title, description, components = {}, locale }, interactive) {
177
+ let root;
178
+ try {
179
+ root = sanitizeHast(tree, title, description);
180
+ } catch (error) {
181
+ if (!(error instanceof HastLimitError)) throw error;
182
+ const s = stringsFor(locale);
183
+ return /* @__PURE__ */ jsxs3("div", { className: "hyle-banner", "data-kind": "warn", role: "alert", children: [
184
+ /* @__PURE__ */ jsx3(Icon, { name: "alert" }),
185
+ /* @__PURE__ */ jsx3("div", { children: s.contentError })
186
+ ] });
187
+ }
188
+ const lead = root.children.find((n) => n.type !== "text" || n.value.trim() !== "");
189
+ const opensWithImage = lead?.type === "element" && lead.tagName === "figure";
190
+ return toJsxRuntime(root, {
191
+ Fragment: Fragment2,
192
+ jsx: jsx2,
193
+ jsxs: jsxs2,
194
+ components: buildComponents(components, stringsFor(locale), { opensWithImage, interactive }),
195
+ elementAttributeNameCase: "react",
196
+ stylePropertyNameCase: "dom"
197
+ });
198
+ }
199
+ function TrustedServerHtml({ html }) {
200
+ return /* @__PURE__ */ jsx3("div", { dangerouslySetInnerHTML: { __html: hostAssetHtml(html) } });
201
+ }
202
+
203
+ // src/react/body.tsx
204
+ import { useId } from "react";
205
+ import { CodeCopy } from "./code-copy.js";
206
+ import { FragmentAlias } from "./fragment-alias.js";
207
+ import { Fragment as Fragment4, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
208
+ function ProseBody({ id, className, lang, ...content }) {
209
+ const generated = useId();
210
+ const rootId = id ?? `hyle-body${generated}`;
211
+ const s = stringsFor(content.locale);
212
+ return /* @__PURE__ */ jsxs4(Fragment4, { children: [
213
+ /* @__PURE__ */ jsx4("div", { id: rootId, className, lang, children: renderHast(content, true) }),
214
+ /* @__PURE__ */ jsx4(CodeCopy, { rootId, copyLabel: s.copyCode, copiedLabel: s.copied, blockedLabel: s.copyBlocked }),
215
+ /* @__PURE__ */ jsx4(FragmentAlias, {})
216
+ ] });
217
+ }
218
+ function HyleBody(props) {
219
+ return /* @__PURE__ */ jsx4(ProseBody, { ...props, className: "hyle hyle-body hyle-prose" });
220
+ }
221
+
222
+ // src/react/index.ts
223
+ import { MermaidDiagram as MermaidDiagram2 } from "./mermaid-diagram.js";
224
+
225
+ // src/react/mermaid-config.ts
226
+ var MAX_MERMAID_SOURCE = 1024 * 1024;
227
+ var AUTO_RENDER_EDGES = 100;
228
+ var AUTO_RENDER_CHARS = 6e3;
229
+ var AUTO_RENDER_STATEMENTS = 250;
230
+ var AUTO_RENDER_WORDS = 800;
231
+ var AUTO_RENDER_GROUPS = 25;
232
+ var CLAMP_LINES = 12;
233
+ var isClampedSource = (source) => source.trimEnd().split("\n").length > CLAMP_LINES;
234
+ var FRONTMATTER = /\s*-{3}[^\S\n]*\n[\s\S]*?\n[^\S\n]*-{3}[^\S\n]*(?:\n|$)/y;
235
+ var DIRECTIVE = /%%\{(?:(?!\}%%)[\s\S])*(?:\}%%)?/g;
236
+ var MAX_STRIP_ROUNDS = 16;
237
+ function dropFrontmatter(text) {
238
+ let end = 0;
239
+ for (; ; ) {
240
+ FRONTMATTER.lastIndex = end;
241
+ const block = FRONTMATTER.exec(text);
242
+ if (!block) return text.slice(end);
243
+ end += block[0].length;
244
+ }
245
+ }
246
+ function stripMermaidConfig(source) {
247
+ let text = source.replace(/\r\n?/g, "\n");
248
+ for (let round = 0; round < MAX_STRIP_ROUNDS; round++) {
249
+ const next = dropFrontmatter(text).replace(DIRECTIVE, "");
250
+ if (next === text) return text;
251
+ text = next;
252
+ }
253
+ return "";
254
+ }
255
+ var EDGE_TOKEN = /-{2,}|={2,}|~{3}|\.{2,}|\.-|-[>x)]/;
256
+ var ER_TOKEN = /-{2,}|={2,}|~{3}|\.{2,}|\.-|-[>x)]|-\.|to\b/i;
257
+ var AMPERSAND = /\s&(?=\s)/g;
258
+ var GROUP_OPENER = /^(?:subgraph\b|state\b.*\{)/;
259
+ var BLOCK_OPENER = /\bblock\b(?!-)/g;
260
+ var DEFAULT_LIMITS = { statements: AUTO_RENDER_STATEMENTS, words: AUTO_RENDER_WORDS, groups: AUTO_RENDER_GROUPS, edges: AUTO_RENDER_EDGES, blocks: Infinity, token: EDGE_TOKEN };
261
+ var TYPE_LIMITS = {
262
+ mindmap: { statements: 40 },
263
+ kanban: { statements: 100 },
264
+ block: { words: 100, blocks: 8 },
265
+ erDiagram: { statements: 120, edges: 50, token: ER_TOKEN },
266
+ "venn-beta": { statements: 180 },
267
+ classDiagram: { statements: 70, edges: 30 },
268
+ stateDiagram: { statements: 80 }
269
+ };
270
+ var COMMENT_LINE = /^[^\S\n\u2028\u2029]*%%[^\n]+\n?/gm;
271
+ var statementsOf = (code) => code.split(/[\n;]/).map((s) => s.trim()).filter((s) => s && s !== "end");
272
+ var edgeBound = (code, token) => {
273
+ const amps = code.match(AMPERSAND)?.length ?? 0;
274
+ return code.split(token).length - 1 + 2 * amps + Math.floor(amps ** 2 / 4);
275
+ };
276
+ function isLargeDiagram(source) {
277
+ if (source.length > AUTO_RENDER_CHARS) return true;
278
+ const code = stripMermaidConfig(source).replace(COMMENT_LINE, "");
279
+ const statements = statementsOf(code);
280
+ const first = statements.find((line) => !line.startsWith("%%")) ?? "";
281
+ const type = Object.keys(TYPE_LIMITS).find((keyword) => first.startsWith(keyword));
282
+ const limit = { ...DEFAULT_LIMITS, ...type ? TYPE_LIMITS[type] : void 0 };
283
+ const words = statements.reduce((n, line) => n + line.split(/\s+/).length, 0);
284
+ const groups = statements.filter((line) => GROUP_OPENER.test(line)).length;
285
+ const blocks = code.match(BLOCK_OPENER)?.length ?? 0;
286
+ return statements.length > limit.statements || words > limit.words || groups > limit.groups || blocks > limit.blocks || edgeBound(code, limit.token) > limit.edges;
287
+ }
288
+
289
+ // src/react/index.ts
290
+ import { holdPrintUntil, installPrintShortcut } from "./print-coordinator.js";
291
+
292
+ // src/react/pages.tsx
293
+ import { Comments } from "./comments.js";
294
+
295
+ // src/react/comments-api.ts
296
+ var REACTION_KINDS = ["like", "love", "insightful", "celebrate"];
297
+ var isCursor = (v) => typeof v === "string" && /^[A-Za-z0-9_-]{1,200}$/.test(v);
298
+ var isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
299
+ var count = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? Math.trunc(v) : 0;
300
+ function parseCounts(v) {
301
+ if (!isObject(v)) return void 0;
302
+ return Object.fromEntries(REACTION_KINDS.map((kind) => [kind, count(v[kind])]).filter(([, n]) => n > 0));
303
+ }
304
+ var toVote = (v) => v === 1 || v === -1 ? v : null;
305
+ var toUnrenderable = (v) => v === true ? { unrenderable: true } : {};
306
+ var toMine = (v) => Array.isArray(v) ? { my_reactions: REACTION_KINDS.filter((kind) => v.includes(kind)) } : {};
307
+ function toComment(raw) {
308
+ if (!isObject(raw) || typeof raw.id !== "string" || typeof raw.created_at !== "string") return void 0;
309
+ const depth = typeof raw.depth === "number" ? Math.min(4, Math.max(1, Math.trunc(raw.depth))) : 1;
310
+ const author = isObject(raw.author) && typeof raw.author.name === "string" ? raw.author.name : void 0;
311
+ const name = typeof raw.author_name === "string" ? raw.author_name : author;
312
+ const body = isObject(raw.body) && raw.body.format === "hast" ? { format: "hast", tree: raw.body.tree } : null;
313
+ const removed = raw.removed === true || body === null;
314
+ const reactions = parseCounts(raw.reaction_counts);
315
+ return {
316
+ id: raw.id,
317
+ parent_id: typeof raw.parent_id === "string" ? raw.parent_id : null,
318
+ depth,
319
+ author_name: name ?? null,
320
+ created_at: raw.created_at,
321
+ edited_at: typeof raw.edited_at === "string" ? raw.edited_at : null,
322
+ like_count: count(raw.like_count),
323
+ ...Number.isSafeInteger(raw.score) ? { score: raw.score } : {},
324
+ ...reactions ? { reaction_counts: reactions } : {},
325
+ removed,
326
+ ...removed && (raw.removed_by === "moderator" || raw.removed_by === "author") ? { removed_by: raw.removed_by } : {},
327
+ ...removed ? {} : toUnrenderable(raw.unrenderable),
328
+ body,
329
+ // Viewer members exist only on a live comment of a viewer-aware listing; a tombstone never carries them.
330
+ ...!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) } : {}
331
+ };
332
+ }
333
+ function toHeld(raw) {
334
+ if (!isObject(raw) || typeof raw.id !== "string" || typeof raw.created_at !== "string" || !isObject(raw.body) || raw.body.format !== "hast") return void 0;
335
+ const author = isObject(raw.author) && typeof raw.author.name === "string" ? raw.author.name : null;
336
+ return {
337
+ id: raw.id,
338
+ parent_id: typeof raw.parent_id === "string" ? raw.parent_id : null,
339
+ depth: typeof raw.depth === "number" ? Math.min(4, Math.max(1, Math.trunc(raw.depth))) : 1,
340
+ author_name: author,
341
+ created_at: raw.created_at,
342
+ edited_at: typeof raw.edited_at === "string" ? raw.edited_at : null,
343
+ can_edit_until: typeof raw.can_edit_until === "string" ? raw.can_edit_until : null,
344
+ ...toUnrenderable(raw.unrenderable),
345
+ body: { format: "hast", tree: raw.body.tree }
346
+ };
347
+ }
348
+ function parseListing(data) {
349
+ if (!isObject(data) || data.kind !== "comments" || !Array.isArray(data.comments)) return void 0;
350
+ const comments = data.comments.map(toComment).filter((c) => c !== void 0);
351
+ 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) } : {};
352
+ const reactions = parseCounts(data.reaction_counts);
353
+ 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 };
354
+ }
355
+ var untilMs = (iso) => {
356
+ const t = iso ? Date.parse(iso) : NaN;
357
+ return Number.isFinite(t) ? t : void 0;
358
+ };
359
+ function buildThread(listing, localHeld, unseen = [], newestOnTop = false) {
360
+ const byId = /* @__PURE__ */ new Map();
361
+ const roots = [];
362
+ const place = (node, parentId) => {
363
+ const parent = parentId ? byId.get(parentId) : void 0;
364
+ (parent ? parent.kids : roots).push(node);
365
+ };
366
+ for (const c of listing.comments) {
367
+ if (byId.has(c.id)) continue;
368
+ const removed = c.removed;
369
+ const node = {
370
+ id: c.id,
371
+ depth: c.depth,
372
+ status: removed ? "removed" : "visible",
373
+ removedBy: removed ? c.removed_by : void 0,
374
+ mine: !removed && c.mine === true,
375
+ canEditUntil: untilMs(c.can_edit_until),
376
+ likedByMe: !removed && c.liked_by_me === true,
377
+ myReactions: removed ? void 0 : c.my_reactions,
378
+ name: removed ? null : c.author_name ?? null,
379
+ createdAt: c.created_at,
380
+ editedAt: c.edited_at,
381
+ likes: c.like_count,
382
+ score: c.score,
383
+ myVote: c.my_vote,
384
+ reactions: c.reaction_counts,
385
+ tree: c.body?.tree,
386
+ unrenderable: c.unrenderable,
387
+ text: void 0,
388
+ kids: []
389
+ };
390
+ place(node, c.parent_id === c.id ? null : c.parent_id);
391
+ byId.set(c.id, node);
392
+ }
393
+ const mine = [];
394
+ const addHeld = (node, parentId, oldestFirst) => {
395
+ const parent = parentId ? byId.get(parentId) : void 0;
396
+ if (parent) parent.kids.push(node);
397
+ else if (oldestFirst) mine.unshift(node);
398
+ else mine.push(node);
399
+ };
400
+ const heldIds = /* @__PURE__ */ new Set();
401
+ for (const h of listing.mine_held ?? []) {
402
+ heldIds.add(h.id);
403
+ const parent = h.parent_id ? byId.get(h.parent_id) : void 0;
404
+ 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);
405
+ }
406
+ if (listing.mine_held === void 0) {
407
+ for (const h of localHeld) {
408
+ if (byId.has(h.id) || heldIds.has(h.id)) continue;
409
+ const parent = h.parentId ? byId.get(h.parentId) : void 0;
410
+ addHeld(localNode(h, "held", parent), h.parentId, false);
411
+ }
412
+ }
413
+ for (const u of [...unseen].reverse()) {
414
+ if (byId.has(u.id) || heldIds.has(u.id) || u.status === "held" && listing.mine_held === void 0) continue;
415
+ const parent = u.parentId ? byId.get(u.parentId) : void 0;
416
+ const node = localNode(u, u.status, parent);
417
+ if (u.status === "held") addHeld(node, u.parentId, true);
418
+ else if (parent) parent.kids.push(node);
419
+ else if (newestOnTop) roots.unshift(node);
420
+ else roots.push(node);
421
+ byId.set(u.id, node);
422
+ }
423
+ return [...mine, ...roots];
424
+ }
425
+ var localNode = (c, status, parent) => ({
426
+ id: c.id,
427
+ depth: Math.min(4, (parent?.depth ?? 0) + 1),
428
+ status,
429
+ removedBy: void 0,
430
+ mine: true,
431
+ canEditUntil: void 0,
432
+ likedByMe: false,
433
+ name: c.name,
434
+ createdAt: c.createdAt,
435
+ editedAt: null,
436
+ likes: 0,
437
+ tree: void 0,
438
+ text: c.text,
439
+ kids: []
440
+ });
441
+
442
+ // src/react/comments-body.tsx
443
+ import { toJsxRuntime as toJsxRuntime2 } from "hast-util-to-jsx-runtime";
444
+ import { Fragment as Fragment5 } from "react";
445
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
446
+ import { jsx as jsx6 } from "react/jsx-runtime";
447
+ var ALLOWED = /* @__PURE__ */ new Set(["p", "a", "em", "strong", "del", "code", "pre", "blockquote", "ul", "ol", "li", "br"]);
448
+ var LINK_REL = "nofollow ugc noopener noreferrer";
449
+ function narrow(node) {
450
+ if (node.type === "text") return [node];
451
+ if (node.type !== "element") return [];
452
+ const children = node.children.flatMap(narrow);
453
+ if (!ALLOWED.has(node.tagName)) return children;
454
+ if (node.tagName === "a") {
455
+ const href = node.properties.href;
456
+ if (!isSafeUrl(href, "href")) return children;
457
+ return [{ type: "element", tagName: "a", properties: { href: String(href), rel: LINK_REL.split(" ") }, children }];
458
+ }
459
+ return [{ type: "element", tagName: node.tagName, properties: {}, children: node.tagName === "br" ? [] : children }];
460
+ }
461
+ function CommentBody({ tree }) {
462
+ let children;
463
+ try {
464
+ children = sanitizeHast(tree).children.flatMap((n) => narrow(n));
465
+ } catch (error) {
466
+ if (error instanceof HastLimitError) return null;
467
+ throw error;
468
+ }
469
+ return /* @__PURE__ */ jsx6("div", { className: "hyle-cm-body", children: toJsxRuntime2({ type: "root", children }, { Fragment: Fragment5, jsx: jsx5, jsxs: jsxs5, elementAttributeNameCase: "react", stylePropertyNameCase: "dom" }) });
470
+ }
471
+
472
+ // src/react/embed.tsx
473
+ import { Fragment as Fragment6, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
474
+ function HyleListView({ items, layout = "list", title, headingLevel = 2, moreHref, olderHref, ...base }) {
475
+ const c = ctx(base, "en");
476
+ const { s, Link } = c;
477
+ const Row = base.slots?.["list.item"];
478
+ const Heading = `h${headingLevel}`;
479
+ const safe = items.filter((item) => item.canonical_path.startsWith("/"));
480
+ if (safe.length === 0) return base.slots?.["list.empty"] ? /* @__PURE__ */ jsx7("div", { className: "hyle hyle-embed", "data-layout": layout, children: /* @__PURE__ */ jsx7(Slot, { name: "list.empty", slots: base.slots }) }) : null;
481
+ return /* @__PURE__ */ jsxs6("div", { className: "hyle hyle-embed", "data-layout": layout, lang: c.locale, children: [
482
+ title ? /* @__PURE__ */ jsx7(Heading, { className: "hyle-title", children: title }) : null,
483
+ /* @__PURE__ */ jsx7("ul", { className: "hyle-items", children: safe.map((item) => /* @__PURE__ */ jsx7("li", { children: Row ? /* @__PURE__ */ jsx7(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ jsxs6(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
484
+ item.published_at ? /* @__PURE__ */ jsx7("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }) : null,
485
+ /* @__PURE__ */ jsxs6("div", { children: [
486
+ /* @__PURE__ */ jsx7("span", { className: "t", children: item.title }),
487
+ item.description ? /* @__PURE__ */ jsx7("p", { children: item.description }) : null
488
+ ] })
489
+ ] }) }, item.canonical_path)) }),
490
+ olderHref ? /* @__PURE__ */ jsx7(OlderNav, { href: olderHref, c }) : null,
491
+ moreHref ? /* @__PURE__ */ jsx7("a", { className: "hyle-more", href: moreHref, children: s.viewAll }) : null
492
+ ] });
493
+ }
494
+ function HyleArticleView({ article, headingLevel = 2, ...base }) {
495
+ const { publication: pub } = article;
496
+ const c = ctx(base, pub.locale);
497
+ const Heading = `h${headingLevel}`;
498
+ return /* @__PURE__ */ jsx7("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ jsxs6("article", { lang: c.locale, children: [
499
+ /* @__PURE__ */ jsxs6("header", { className: "hyle-head", children: [
500
+ /* @__PURE__ */ jsx7(Heading, { className: "hyle-title", children: pub.title }),
501
+ pub.description ? /* @__PURE__ */ jsx7("p", { className: "hyle-desc", children: pub.description }) : null,
502
+ /* @__PURE__ */ jsx7("div", { className: "hyle-meta", children: /* @__PURE__ */ jsx7("span", { children: /* @__PURE__ */ jsx7("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) }) }) })
503
+ ] }),
504
+ /* @__PURE__ */ jsx7(Body, { article, components: base.components, locale: c.locale }),
505
+ pub.canonical_path.startsWith("/") ? /* @__PURE__ */ jsxs6("a", { className: "hyle-more", href: c.href(pub.canonical_path, pub.locale), rel: "bookmark", children: [
506
+ c.s.readAtSource,
507
+ /* @__PURE__ */ jsxs6("span", { className: "hyle-sr", children: [
508
+ ": ",
509
+ pub.title
510
+ ] })
511
+ ] }) : null
512
+ ] }) });
513
+ }
514
+ var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((w) => [...w][0] ?? "").join("").toUpperCase() || "?";
515
+ function StaticThread({ nodes, locale, s, level = 1 }) {
516
+ return /* @__PURE__ */ jsx7("ol", { className: "hyle-cm-list", role: "list", children: nodes.map((node) => {
517
+ const kids = node.kids.length > 0 && level < 32 ? /* @__PURE__ */ jsx7(StaticThread, { nodes: node.kids, locale, s, level: level + 1 }) : null;
518
+ if (node.status === "removed") {
519
+ const why = node.removedBy === "moderator" ? s.removedByModerator : node.removedBy === "author" ? s.removedByAuthor : s.removed;
520
+ return /* @__PURE__ */ jsxs6("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "removed", "data-removed-by": node.removedBy, children: [
521
+ /* @__PURE__ */ jsxs6("article", { "aria-label": why, children: [
522
+ /* @__PURE__ */ jsx7("span", { className: "hyle-avatar", "aria-hidden": "true", children: /* @__PURE__ */ jsx7(Icon, { name: "ban" }) }),
523
+ /* @__PURE__ */ jsx7("div", { className: "hyle-cm-main", children: /* @__PURE__ */ jsx7("div", { className: "hyle-cm-body", children: /* @__PURE__ */ jsx7("p", { children: why }) }) })
524
+ ] }),
525
+ kids
526
+ ] }, node.id);
527
+ }
528
+ return /* @__PURE__ */ jsxs6("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "visible", children: [
529
+ /* @__PURE__ */ jsxs6("article", { children: [
530
+ /* @__PURE__ */ jsx7("span", { className: "hyle-avatar", "aria-hidden": "true", children: initials(node.name ?? "") }),
531
+ /* @__PURE__ */ jsxs6("div", { className: "hyle-cm-main", children: [
532
+ /* @__PURE__ */ jsxs6("div", { className: "hyle-cm-by", children: [
533
+ /* @__PURE__ */ jsx7("b", { children: node.name }),
534
+ /* @__PURE__ */ jsxs6("span", { children: [
535
+ /* @__PURE__ */ jsx7("time", { dateTime: node.createdAt, title: node.createdAt, children: formatDate(node.createdAt, locale) }),
536
+ node.editedAt ? /* @__PURE__ */ jsxs6(Fragment6, { children: [
537
+ " ",
538
+ /* @__PURE__ */ jsx7("span", { "aria-hidden": "true", children: "\xB7" }),
539
+ " ",
540
+ /* @__PURE__ */ jsx7("span", { children: s.edited })
541
+ ] }) : null
542
+ ] })
543
+ ] }),
544
+ node.unrenderable ? /* @__PURE__ */ jsx7("div", { className: "hyle-cm-body", children: /* @__PURE__ */ jsx7("p", { children: s.unrenderable }) }) : /* @__PURE__ */ jsx7(CommentBody, { tree: node.tree })
545
+ ] })
546
+ ] }),
547
+ kids
548
+ ] }, node.id);
549
+ }) });
550
+ }
551
+ function HyleCommentsView({ listing, locale }) {
552
+ const thread = buildThread(listing, []);
553
+ if (thread.length === 0) return null;
554
+ const s = stringsFor(locale).comments;
555
+ return /* @__PURE__ */ jsx7("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ jsxs6("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", lang: locale, children: [
556
+ /* @__PURE__ */ jsx7("div", { className: "hyle-cm-head", children: /* @__PURE__ */ jsxs6("h2", { children: [
557
+ s.heading,
558
+ " ",
559
+ /* @__PURE__ */ jsx7("span", { className: "hyle-cm-count", "aria-label": s.countLabel.replace("{n}", String(listing.comment_count)), children: listing.comment_count })
560
+ ] }) }),
561
+ /* @__PURE__ */ jsx7(StaticThread, { nodes: thread, locale, s }),
562
+ listing.truncated ? /* @__PURE__ */ jsx7("p", { className: "hyle-cm-note", children: s.truncated }) : null
563
+ ] }) });
564
+ }
565
+ function HyleCommentsFallback({ locale }) {
566
+ const s = stringsFor(locale).comments;
567
+ return /* @__PURE__ */ jsx7("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ jsx7("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", children: /* @__PURE__ */ jsxs6("div", { role: "status", "aria-live": "polite", "aria-busy": "true", children: [
568
+ /* @__PURE__ */ jsx7("span", { className: "hyle-sr", children: s.loading }),
569
+ /* @__PURE__ */ jsx7("div", { "aria-hidden": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ jsxs6("div", { className: "hyle-cm-sk", children: [
570
+ /* @__PURE__ */ jsx7("span", { className: "hyle-sk c" }),
571
+ /* @__PURE__ */ jsxs6("div", { children: [
572
+ /* @__PURE__ */ jsx7("span", { className: "hyle-sk l", style: { width: 120 } }),
573
+ /* @__PURE__ */ jsx7("span", { className: "hyle-sk l", style: { width: "100%" } }),
574
+ /* @__PURE__ */ jsx7("span", { className: "hyle-sk l", style: { width: "72%" } })
575
+ ] })
576
+ ] }, i)) })
577
+ ] }) }) });
578
+ }
579
+
580
+ // src/react/seo.ts
581
+ var BARE_HTTPS_ORIGIN = /^https:\/\/[^/]+$/;
582
+ var bareOrigin = (origin) => origin && BARE_HTTPS_ORIGIN.test(origin) ? origin : void 0;
583
+ var absoluteUrl = (origin, href) => origin + encodeURI(href);
584
+ var modifiedAt = (pub) => pub.updated_at && Date.parse(pub.updated_at) > Date.parse(pub.published_at) ? pub.updated_at : void 0;
585
+ var wordCountOf = (pub) => Number.isInteger(pub.word_count) && pub.word_count > 0 ? pub.word_count : void 0;
586
+ var WORDS_PER_MINUTE = 275;
587
+ var readingMinutes = (wordCount) => Math.max(1, Math.ceil(wordCount / WORDS_PER_MINUTE));
588
+ var breadcrumbItems = (article, jsonLd) => [
589
+ ...jsonLd?.breadcrumbRoot ? [{ title: jsonLd.breadcrumbRoot.name, canonical_path: "/" }] : [],
590
+ ...article.breadcrumbs
591
+ ];
592
+ var crumbHref = (href, path, locale) => path === "/" ? href("/", locale).replace(/(.)\/$/, "$1") : href(path, locale);
593
+ function articleAuthor(article, jsonLd) {
594
+ const authored = article.publication.author;
595
+ if (authored?.name) return { name: authored.name, ...authored.url ? { url: authored.url } : {} };
596
+ const given = jsonLd?.author?.(article);
597
+ if (given && typeof given.name === "string" && given.name) return given;
598
+ const fromFrontmatter = article.frontmatter.author;
599
+ return typeof fromFrontmatter === "string" && fromFrontmatter ? { name: fromFrontmatter } : void 0;
600
+ }
601
+ var UNSAFE_URL = /[\u0000- \u007f\\]/;
602
+ var positive = (n) => typeof n === "number" && Number.isInteger(n) && n > 0 ? n : void 0;
603
+ function validOgImage(image, origin) {
604
+ if (!image || typeof image.url !== "string" || UNSAFE_URL.test(image.url)) return void 0;
605
+ const relative = image.url.startsWith("/") && !image.url.startsWith("//");
606
+ const url = relative ? origin ? origin + image.url : void 0 : image.url;
607
+ if (!url) return void 0;
608
+ try {
609
+ const parsed = new URL(url);
610
+ if (parsed.protocol !== "https:" || relative && parsed.origin !== origin) return void 0;
611
+ } catch {
612
+ return void 0;
613
+ }
614
+ const width = positive(image.width);
615
+ const height = positive(image.height);
616
+ const type = typeof image.type === "string" && image.type ? image.type : "image/png";
617
+ return { url, type, ...width ? { width } : {}, ...height ? { height } : {}, ...typeof image.alt === "string" && image.alt ? { alt: image.alt } : {} };
618
+ }
619
+ function hreflangLanguages(members, defaultLocale, selfUrl, url) {
620
+ const defaultMember = members.find((m) => m.locale === defaultLocale);
621
+ return { ...Object.fromEntries(members.map((m) => [m.locale, url(m)])), "x-default": defaultMember ? url(defaultMember) : selfUrl };
622
+ }
623
+
624
+ // src/react/jsonld.ts
625
+ var script = (value) => JSON.stringify(value).replace(/</g, "\\u003c");
626
+ var organization = (publisher) => ({ "@type": "Organization", "@id": publisher.id, name: publisher.name, ...publisher.logo ? { logo: publisher.logo } : {} });
627
+ var webSite = (website) => ({ "@type": "WebSite", "@id": website.id, name: website.name });
628
+ function articleJsonLd({ article, origin, href, jsonLd, imageUrl, imageWidth, imageHeight }) {
629
+ const { publication: pub } = article;
630
+ const url = (path) => absoluteUrl(origin, href(path, pub.locale));
631
+ const canonical = url(pub.canonical_path);
632
+ const id = (fragment) => ({ "@id": `${canonical}#${fragment}` });
633
+ const full = jsonLd !== void 0;
634
+ const author = articleAuthor(article, jsonLd);
635
+ const publisher = jsonLd?.publisher;
636
+ const website = jsonLd?.website?.(pub.locale);
637
+ const modified = modifiedAt(pub);
638
+ const words = wordCountOf(pub);
639
+ const publisherNode = publisher ? organization(publisher) : void 0;
640
+ const section = article.breadcrumbs[0]?.title;
641
+ const graph = [
642
+ ...full ? [{
643
+ "@type": "WebPage",
644
+ ...id("webpage"),
645
+ url: canonical,
646
+ name: pub.title,
647
+ ...pub.description ? { description: pub.description } : {},
648
+ inLanguage: pub.locale,
649
+ ...website ? { isPartOf: webSite(website) } : {},
650
+ ...publisherNode ? { publisher: publisherNode } : {},
651
+ breadcrumb: id("breadcrumb"),
652
+ mainEntity: id("article")
653
+ }] : [],
654
+ {
655
+ "@type": "BlogPosting",
656
+ ...id("article"),
657
+ headline: pub.title,
658
+ ...pub.description ? { description: pub.description } : {},
659
+ datePublished: pub.published_at,
660
+ ...section ? { articleSection: section } : {},
661
+ ...modified ? { dateModified: modified } : {},
662
+ ...words ? { wordCount: words } : {},
663
+ url: canonical,
664
+ mainEntityOfPage: full ? id("webpage") : canonical,
665
+ ...author ? { author: { "@type": "Person", ...author.id ? { "@id": author.id } : {}, name: author.name, ...author.url ? { url: author.url } : {} } } : {},
666
+ ...publisherNode ? { publisher: publisherNode } : {},
667
+ inLanguage: pub.locale,
668
+ ...imageUrl ? { image: imageWidth && imageHeight ? { "@type": "ImageObject", url: imageUrl, width: imageWidth, height: imageHeight } : [imageUrl] } : {}
669
+ },
670
+ {
671
+ "@type": "BreadcrumbList",
672
+ ...id("breadcrumb"),
673
+ itemListElement: breadcrumbItems(article, jsonLd).map((b, i) => ({
674
+ "@type": "ListItem",
675
+ position: i + 1,
676
+ name: b.title,
677
+ item: absoluteUrl(origin, crumbHref(href, b.canonical_path, pub.locale).replace(/^\/$/, ""))
678
+ }))
679
+ }
680
+ ];
681
+ return script({ "@context": "https://schema.org", "@graph": graph });
682
+ }
683
+ function listJsonLd({ list, origin, href, path, locale, description, jsonLd, cursor }) {
684
+ const url = absoluteUrl(origin, href(path)) + (cursor ? `?cursor=${cursor}` : "");
685
+ const website = jsonLd?.website?.(locale);
686
+ return script({
687
+ "@context": "https://schema.org",
688
+ "@type": "CollectionPage",
689
+ ...jsonLd ? { "@id": `${url}#webpage` } : {},
690
+ url,
691
+ ...website ? { isPartOf: webSite(website) } : {},
692
+ ...jsonLd?.publisher ? { publisher: organization(jsonLd.publisher) } : {},
693
+ name: list.section.title,
694
+ ...description ? { description } : {},
695
+ inLanguage: locale,
696
+ mainEntity: {
697
+ "@type": "ItemList",
698
+ itemListElement: list.items.map((item, i) => ({ "@type": "ListItem", position: i + 1, url: absoluteUrl(origin, href(item.canonical_path)), name: item.title }))
699
+ }
700
+ });
701
+ }
702
+
703
+ // src/react/pages.tsx
704
+ import { TocSpy } from "./toc-spy.js";
705
+ import { Fragment as Fragment7, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
706
+ function Slot({ name, slots, tag: Tag = "div", className }) {
707
+ const fill = slots?.[name];
708
+ return fill ? /* @__PURE__ */ jsx8(Tag, { "data-slot": name, className, children: fill }) : null;
709
+ }
710
+ function Shell({ children }) {
711
+ return /* @__PURE__ */ jsx8("div", { className: "hyle", children: /* @__PURE__ */ jsx8("div", { className: "hyle-page", children }) });
712
+ }
713
+ function ctx(p, fallbackLocale) {
714
+ const locale = p.locale ?? fallbackLocale;
715
+ return { s: stringsFor(locale), locale, href: (path, linkLocale) => p.toHref ? p.toHref(path, linkLocale ?? locale) : path, Link: p.components?.Link ?? "a" };
716
+ }
717
+ function Pager({ prev, next, c }) {
718
+ if (!prev && !next) return null;
719
+ const { Link, s } = c;
720
+ return /* @__PURE__ */ jsxs7("nav", { className: "hyle-pager", "aria-label": s.pager, children: [
721
+ prev ? /* @__PURE__ */ jsxs7(Link, { href: c.href(prev.canonical_path), rel: "prev", children: [
722
+ /* @__PURE__ */ jsxs7("span", { className: "dir", children: [
723
+ /* @__PURE__ */ jsx8(Icon, { name: "chev-left" }),
724
+ s.prev
725
+ ] }),
726
+ /* @__PURE__ */ jsx8("span", { className: "ttl", children: prev.title })
727
+ ] }) : /* @__PURE__ */ jsx8("span", { className: "none", "aria-hidden": "true" }),
728
+ next ? /* @__PURE__ */ jsxs7(Link, { href: c.href(next.canonical_path), rel: "next", className: "next", children: [
729
+ /* @__PURE__ */ jsxs7("span", { className: "dir", children: [
730
+ s.next,
731
+ /* @__PURE__ */ jsx8(Icon, { name: "chev" })
732
+ ] }),
733
+ /* @__PURE__ */ jsx8("span", { className: "ttl", children: next.title })
734
+ ] }) : null
735
+ ] });
736
+ }
737
+ function OlderNav({ href, c }) {
738
+ return /* @__PURE__ */ jsxs7("nav", { className: "hyle-pagination", "aria-label": c.s.pager, children: [
739
+ /* @__PURE__ */ jsx8("span", { className: "sp" }),
740
+ /* @__PURE__ */ jsxs7(c.Link, { className: "hyle-btn sm", href, rel: "next", children: [
741
+ c.s.older,
742
+ /* @__PURE__ */ jsx8(Icon, { name: "chev" })
743
+ ] })
744
+ ] });
745
+ }
746
+ function TocList({ toc }) {
747
+ const groups = [];
748
+ for (const entry of toc) {
749
+ const last = groups.at(-1);
750
+ if (entry.depth === 3 && last) last.subs.push(entry);
751
+ else groups.push({ entry, subs: [] });
752
+ }
753
+ return /* @__PURE__ */ jsx8("ul", { children: groups.map(({ entry, subs }) => /* @__PURE__ */ jsxs7("li", { children: [
754
+ /* @__PURE__ */ jsx8("a", { href: `#${scopeId(entry.id)}`, children: entry.text }),
755
+ subs.length > 0 ? /* @__PURE__ */ jsx8("ul", { children: subs.map((sub) => /* @__PURE__ */ jsx8("li", { children: /* @__PURE__ */ jsx8("a", { href: `#${scopeId(sub.id)}`, children: sub.text }) }, sub.id)) }) : null
756
+ ] }, entry.id)) });
757
+ }
758
+ function Toc({ toc, c, aside, spy, className }) {
759
+ const entries = toc.filter((t) => t.depth === 2 || t.depth === 3);
760
+ if (entries.length === 0 && !aside) return { narrow: null, wide: null };
761
+ const { s } = c;
762
+ const classes = (own) => className ? `${className} ${own}` : own;
763
+ return {
764
+ narrow: entries.length === 0 ? null : /* @__PURE__ */ jsxs7("details", { className: classes("hyle-toc-m"), children: [
765
+ /* @__PURE__ */ jsxs7("summary", { children: [
766
+ /* @__PURE__ */ jsx8(Icon, { name: "file" }),
767
+ s.toc,
768
+ /* @__PURE__ */ jsx8(Icon, { name: "chev-down", className: "hyle-chev" })
769
+ ] }),
770
+ /* @__PURE__ */ jsx8("nav", { className: "hyle-toc-list", "aria-label": s.toc, children: /* @__PURE__ */ jsx8(TocList, { toc: entries }) })
771
+ ] }),
772
+ wide: /* @__PURE__ */ jsxs7("aside", { className: classes("hyle-toc-d"), "aria-label": s.toc, children: [
773
+ entries.length === 0 ? null : /* @__PURE__ */ jsxs7(Fragment7, { children: [
774
+ /* @__PURE__ */ jsx8("p", { className: "hyle-toc-title", children: s.toc }),
775
+ /* @__PURE__ */ jsx8("nav", { className: "hyle-toc-list", children: /* @__PURE__ */ jsx8(TocList, { toc: entries }) })
776
+ ] }),
777
+ aside,
778
+ spy && entries.length > 0 ? /* @__PURE__ */ jsx8(TocSpy, { ids: entries.map((t) => scopeId(t.id)) }) : null
779
+ ] })
780
+ };
781
+ }
782
+ function HyleToc({ toc, variant, aside, locale }) {
783
+ const both = Toc({ toc, c: { s: stringsFor(locale) }, aside, spy: true, className: "hyle hyle-toc-solo" });
784
+ return variant === "rail" ? both.wide : both.narrow;
785
+ }
786
+ function Body({ article, components, locale }) {
787
+ const { content, publication } = article;
788
+ const lang = article.fallback ? void 0 : publication.locale;
789
+ if (content.format === "hast") {
790
+ return /* @__PURE__ */ jsx8(ProseBody, { className: "hyle-body hyle-prose", lang, tree: content.tree, title: publication.title, description: publication.description, components: components ?? {}, locale });
791
+ }
792
+ return /* @__PURE__ */ jsx8("div", { className: "hyle-body hyle-prose", lang, children: content.format === "html" ? /* @__PURE__ */ jsx8(TrustedServerHtml, { html: content.html }) : null });
793
+ }
794
+ function Languages({ alternates, current, c }) {
795
+ if (alternates.length < 2) return null;
796
+ const { Link, s } = c;
797
+ return /* @__PURE__ */ jsxs7("nav", { className: "hyle-langs", "aria-label": s.languages, children: [
798
+ /* @__PURE__ */ jsx8("span", { children: s.readIn }),
799
+ /* @__PURE__ */ jsx8("ul", { children: alternates.map((a) => {
800
+ const label = languageName(a.locale, a.locale);
801
+ return /* @__PURE__ */ jsx8("li", { children: a.locale === current ? /* @__PURE__ */ jsx8("a", { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, "aria-current": "true", children: label }) : /* @__PURE__ */ jsx8(Link, { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, children: label }) }, a.locale);
802
+ }) })
803
+ ] });
804
+ }
805
+ function LdScript({ json }) {
806
+ return /* @__PURE__ */ jsx8("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: json } });
807
+ }
808
+ function Crumbs({ items, c }) {
809
+ const { Link } = c;
810
+ return /* @__PURE__ */ jsx8("nav", { className: "hyle-crumbs", "aria-label": c.s.crumbs, children: /* @__PURE__ */ jsx8("ol", { children: items.map((b, i) => /* @__PURE__ */ jsx8("li", { "aria-current": i === items.length - 1 ? "page" : void 0, children: i === items.length - 1 ? b.title : /* @__PURE__ */ jsx8(Link, { href: crumbHref(c.href, b.canonical_path, c.locale), children: b.title }) }, b.canonical_path)) }) });
811
+ }
812
+ function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, imageWidth, imageHeight, related, ...base }) {
813
+ const { publication: pub } = article;
814
+ const c = ctx(base, pub.locale);
815
+ const { s } = c;
816
+ const jsonLdOrigin = bareOrigin(origin);
817
+ const author = articleAuthor(article, jsonLd)?.name;
818
+ const modified = modifiedAt(pub);
819
+ const words = wordCountOf(pub);
820
+ const toc = Toc({ toc: article.toc, c, spy: true, aside: /* @__PURE__ */ jsx8(Slot, { name: "article.aside", slots: base.slots, className: "hyle-slot-wrap" }) });
821
+ const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
822
+ return /* @__PURE__ */ jsx8(Shell, { children: /* @__PURE__ */ jsxs7("article", { className: "hyle-article", "data-hyle-page": "article", lang: c.locale, children: [
823
+ /* @__PURE__ */ jsxs7("header", { className: "hyle-head", children: [
824
+ /* @__PURE__ */ jsx8(Slot, { name: "article.before", slots: base.slots, className: "hyle-eyebrow" }),
825
+ /* @__PURE__ */ jsx8(Crumbs, { items: breadcrumbItems(article, jsonLd), c }),
826
+ /* @__PURE__ */ jsx8("h1", { className: "hyle-title", children: pub.title }),
827
+ pub.description ? /* @__PURE__ */ jsx8("p", { className: "hyle-desc", children: pub.description }) : null,
828
+ /* @__PURE__ */ jsxs7("div", { className: "hyle-meta", children: [
829
+ author ? /* @__PURE__ */ jsxs7("span", { children: [
830
+ /* @__PURE__ */ jsx8("span", { className: "hyle-avatar", "aria-hidden": "true", children: author.slice(0, 2).toUpperCase() }),
831
+ /* @__PURE__ */ jsxs7("span", { children: [
832
+ /* @__PURE__ */ jsxs7("span", { className: "hyle-sr", children: [
833
+ s.by,
834
+ " "
835
+ ] }),
836
+ /* @__PURE__ */ jsx8("span", { className: "by", children: author })
837
+ ] })
838
+ ] }) : null,
839
+ /* @__PURE__ */ jsxs7("span", { children: [
840
+ /* @__PURE__ */ jsx8(Icon, { name: "calendar" }),
841
+ /* @__PURE__ */ jsx8("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) })
842
+ ] }),
843
+ modified ? /* @__PURE__ */ jsxs7("span", { children: [
844
+ /* @__PURE__ */ jsx8(Icon, { name: "calendar" }),
845
+ s.updated,
846
+ " ",
847
+ /* @__PURE__ */ jsx8("time", { dateTime: modified, title: modified, children: formatDate(modified, c.locale) })
848
+ ] }) : null,
849
+ words ? /* @__PURE__ */ jsxs7("span", { children: [
850
+ /* @__PURE__ */ jsx8(Icon, { name: "clock" }),
851
+ s.readingTime.replace("{n}", String(readingMinutes(words)))
852
+ ] }) : null,
853
+ /* @__PURE__ */ jsxs7("span", { children: [
854
+ /* @__PURE__ */ jsx8(Icon, { name: "globe" }),
855
+ /* @__PURE__ */ jsx8("span", { lang: pub.locale, children: languageName(pub.locale, c.locale) })
856
+ ] }),
857
+ /* @__PURE__ */ jsx8(Slot, { name: "article.meta", slots: base.slots, tag: "span" })
858
+ ] }),
859
+ /* @__PURE__ */ jsx8(Languages, { alternates: article.alternates, current: pub.locale, c }),
860
+ notTranslated ? /* @__PURE__ */ jsxs7("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
861
+ /* @__PURE__ */ jsx8(Icon, { name: "alert" }),
862
+ /* @__PURE__ */ jsxs7("div", { children: [
863
+ /* @__PURE__ */ jsx8("b", { children: notTranslated }),
864
+ " ",
865
+ s.fallbackBody
866
+ ] })
867
+ ] }) : null
868
+ ] }),
869
+ toc.narrow,
870
+ /* @__PURE__ */ jsx8(Body, { article, components: base.components, locale: c.locale }),
871
+ engagement ? /* @__PURE__ */ jsx8(Comments, { path: pub.canonical_path, endpoint: engagement.endpoint ?? "/api/hyle/engage", signInHref: engagement.signInHref, locale: c.locale, labels: s.comments }) : null,
872
+ /* @__PURE__ */ jsx8(Pager, { prev: article.prev, next: article.next, c }),
873
+ related ? /* @__PURE__ */ jsxs7(Fragment7, { children: [
874
+ related.items.length > 0 ? /* @__PURE__ */ jsx8(HyleListView, { items: related.items, title: related.title ?? s.moreInSection, ...base, locale: c.locale }) : null,
875
+ article.children.length > 0 ? /* @__PURE__ */ jsx8(HyleListView, { items: article.children.map((child) => ({ ...child, description: null, published_at: "" })), title: s.subPages, ...base, locale: c.locale }) : null
876
+ ] }) : null,
877
+ /* @__PURE__ */ jsx8(Slot, { name: "article.after", slots: base.slots, className: "hyle-after" }),
878
+ toc.wide,
879
+ jsonLdOrigin ? /* @__PURE__ */ jsx8(LdScript, { json: articleJsonLd({ article, origin: jsonLdOrigin, href: c.href, jsonLd, imageUrl, imageWidth, imageHeight }) }) : null
880
+ ] }) });
881
+ }
882
+ function ListPage({ list, olderHref, description, origin, path, jsonLd, cursor, ...base }) {
883
+ const c = ctx(base, "en");
884
+ const { s, Link } = c;
885
+ const Row = base.slots?.["list.item"];
886
+ const groups = /* @__PURE__ */ new Map();
887
+ for (const item of list.items) groups.set(item.published_at.slice(0, 7), [...groups.get(item.published_at.slice(0, 7)) ?? [], item]);
888
+ const notTranslated = list.fallback ? s.fallbackTitle.replace("{language}", languageName(list.fallback.requested_locale, c.locale)) : void 0;
889
+ const jsonLdOrigin = bareOrigin(origin);
890
+ return /* @__PURE__ */ jsx8(Shell, { children: /* @__PURE__ */ jsxs7("div", { className: "hyle-listpage", "data-hyle-page": "list", lang: c.locale, children: [
891
+ /* @__PURE__ */ jsxs7("header", { className: "hyle-head", children: [
892
+ /* @__PURE__ */ jsx8("h1", { className: "hyle-title", children: list.section.title }),
893
+ description ? /* @__PURE__ */ jsx8("p", { className: "hyle-desc", children: description }) : null,
894
+ /* @__PURE__ */ jsx8(Slot, { name: "list.header", slots: base.slots, className: "hyle-slot-wrap" }),
895
+ notTranslated ? /* @__PURE__ */ jsxs7("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
896
+ /* @__PURE__ */ jsx8(Icon, { name: "alert" }),
897
+ /* @__PURE__ */ jsxs7("div", { children: [
898
+ /* @__PURE__ */ jsx8("b", { children: notTranslated }),
899
+ " ",
900
+ s.fallbackBody
901
+ ] })
902
+ ] }) : null
903
+ ] }),
904
+ list.items.length === 0 ? /* @__PURE__ */ jsxs7("div", { className: "hyle-empty", "data-slot-state": "empty", children: [
905
+ /* @__PURE__ */ jsx8(Icon, { name: "file" }),
906
+ /* @__PURE__ */ jsx8("h2", { children: s.emptyTitle }),
907
+ /* @__PURE__ */ jsx8("p", { children: s.emptyBody }),
908
+ /* @__PURE__ */ jsx8(Slot, { name: "list.empty", slots: base.slots })
909
+ ] }) : [...groups].map(([month, items]) => /* @__PURE__ */ jsxs7("section", { "aria-label": formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }), children: [
910
+ /* @__PURE__ */ jsx8("h2", { className: "hyle-year", children: formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }) }),
911
+ /* @__PURE__ */ jsx8("ul", { className: "hyle-items", children: items.map((item) => /* @__PURE__ */ jsx8("li", { children: Row ? /* @__PURE__ */ jsx8(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ jsxs7(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
912
+ /* @__PURE__ */ jsx8("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }),
913
+ /* @__PURE__ */ jsxs7("div", { children: [
914
+ /* @__PURE__ */ jsx8("span", { className: "t", children: item.title }),
915
+ item.description ? /* @__PURE__ */ jsx8("p", { children: item.description }) : null
916
+ ] })
917
+ ] }) }, item.canonical_path)) })
918
+ ] }, month)),
919
+ olderHref ? /* @__PURE__ */ jsx8(OlderNav, { href: olderHref, c }) : null,
920
+ jsonLdOrigin && path ? /* @__PURE__ */ jsx8(LdScript, { json: listJsonLd({ list, origin: jsonLdOrigin, href: c.href, path, locale: c.locale, description, jsonLd, cursor }) }) : null
921
+ ] }) });
922
+ }
923
+ function NotFound({ path, homeHref = "/", ...base }) {
924
+ const c = ctx(base, "en");
925
+ const { Link, s } = c;
926
+ const body = base.slots?.["notfound.body"];
927
+ return /* @__PURE__ */ jsx8(Shell, { children: /* @__PURE__ */ jsxs7("section", { className: "hyle-state", "data-hyle-page": "not-found", lang: c.locale, children: [
928
+ /* @__PURE__ */ jsx8("span", { className: "kind", children: s.nfKind }),
929
+ /* @__PURE__ */ jsx8("h1", { children: s.nfTitle }),
930
+ body ? /* @__PURE__ */ jsx8("div", { "data-slot": "notfound.body", children: body }) : /* @__PURE__ */ jsx8("p", { children: s.nfBody }),
931
+ path ? /* @__PURE__ */ jsx8("dl", { className: "hyle-addr", children: /* @__PURE__ */ jsxs7("div", { children: [
932
+ /* @__PURE__ */ jsx8("dt", { children: s.path }),
933
+ /* @__PURE__ */ jsx8("dd", { children: path })
934
+ ] }) }) : null,
935
+ /* @__PURE__ */ jsxs7("div", { className: "hyle-actions", children: [
936
+ /* @__PURE__ */ jsx8(Link, { className: "hyle-btn primary", href: crumbHref(c.href, homeHref, c.locale), children: s.home }),
937
+ /* @__PURE__ */ jsx8(Slot, { name: "notfound.actions", slots: base.slots, tag: "span" })
938
+ ] })
939
+ ] }) });
940
+ }
941
+ function Unavailable(base) {
942
+ const c = ctx(base, "en");
943
+ return /* @__PURE__ */ jsx8(Shell, { children: /* @__PURE__ */ jsxs7("section", { className: "hyle-state", "data-hyle-page": "unavailable", lang: c.locale, role: "status", children: [
944
+ /* @__PURE__ */ jsx8("span", { className: "kind", children: c.s.unKind }),
945
+ /* @__PURE__ */ jsx8("h1", { children: c.s.unTitle }),
946
+ /* @__PURE__ */ jsx8("p", { children: c.s.unBody })
947
+ ] }) });
948
+ }
949
+ function Redirecting({ from, to, ...base }) {
950
+ const c = ctx(base, "en");
951
+ const { Link, s } = c;
952
+ const extra = base.slots?.["redirecting.body"];
953
+ return /* @__PURE__ */ jsx8(Shell, { children: /* @__PURE__ */ jsxs7("section", { className: "hyle-state", "data-hyle-page": "redirecting", role: "status", lang: c.locale, children: [
954
+ /* @__PURE__ */ jsx8("span", { className: "kind", children: s.rdKind }),
955
+ /* @__PURE__ */ jsx8("h1", { children: s.rdTitle }),
956
+ /* @__PURE__ */ jsx8("p", { children: s.rdBody }),
957
+ /* @__PURE__ */ jsxs7("dl", { className: "hyle-addr", children: [
958
+ from ? /* @__PURE__ */ jsxs7("div", { children: [
959
+ /* @__PURE__ */ jsx8("dt", { children: s.from }),
960
+ /* @__PURE__ */ jsx8("dd", { children: from })
961
+ ] }) : null,
962
+ /* @__PURE__ */ jsxs7("div", { children: [
963
+ /* @__PURE__ */ jsx8("dt", { children: s.to }),
964
+ /* @__PURE__ */ jsx8("dd", { children: to })
965
+ ] })
966
+ ] }),
967
+ /* @__PURE__ */ jsx8("p", { className: "fine", children: /* @__PURE__ */ jsx8(Link, { href: c.href(to), children: s.rdFallback }) }),
968
+ extra ? /* @__PURE__ */ jsx8("p", { "data-slot": "redirecting.body", className: "fine", children: extra }) : null
969
+ ] }) });
970
+ }
971
+
972
+ // src/react/index.ts
973
+ import { Comments as Comments2 } from "./comments.js";
974
+ import { HyleReactions } from "./reactions.js";
975
+
976
+ // src/react/docs.tsx
977
+ import { DocsEnhance } from "./docs-enhance.js";
978
+ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
979
+ var ROOT_ID = "hyle-docs";
980
+ var NAV_ID = "hyle-docs-nav";
981
+ function navTreeOf(article) {
982
+ if (article.nav && !article.nav.truncated && article.nav.items.length > 0) return article.nav.items;
983
+ const { publication: pub } = article;
984
+ const here = {
985
+ slug: pub.slug,
986
+ title: pub.title,
987
+ canonical_path: pub.canonical_path,
988
+ children: article.children.map((child) => ({ ...child, children: [] }))
989
+ };
990
+ return [article.ancestors.reduceRight((inner, a) => ({ ...a, children: [inner] }), here)];
991
+ }
992
+ function pathTo(nodes, path) {
993
+ for (const node of nodes) {
994
+ if (node.canonical_path === path) return [node.canonical_path];
995
+ const below = pathTo(node.children, path);
996
+ if (below.length > 0) return [node.canonical_path, ...below];
997
+ }
998
+ return [];
999
+ }
1000
+ function Branch({ nodes, current, onPath, c }) {
1001
+ const { Link } = c;
1002
+ return /* @__PURE__ */ jsx9("ul", { children: nodes.map((node) => {
1003
+ const link = /* @__PURE__ */ jsx9(Link, { href: c.href(node.canonical_path), ...node.canonical_path === current ? { "aria-current": "page" } : {}, children: node.title });
1004
+ if (node.children.length === 0) return /* @__PURE__ */ jsx9("li", { children: link }, node.canonical_path);
1005
+ return /* @__PURE__ */ jsx9("li", { children: /* @__PURE__ */ jsxs8("details", { ...onPath.has(node.canonical_path) ? { open: true } : {}, children: [
1006
+ /* @__PURE__ */ jsxs8("summary", { children: [
1007
+ /* @__PURE__ */ jsx9(Icon, { name: "chev" }),
1008
+ link
1009
+ ] }),
1010
+ /* @__PURE__ */ jsx9(Branch, { nodes: node.children, current, onPath, c })
1011
+ ] }) }, node.canonical_path);
1012
+ }) });
1013
+ }
1014
+ function DocsPage({ article, ...base }) {
1015
+ const { publication: pub } = article;
1016
+ const c = ctx(base, pub.locale);
1017
+ const { Link, s } = c;
1018
+ const toc = Toc({ toc: article.toc, c });
1019
+ const tree = navTreeOf(article);
1020
+ const onPath = new Set(pathTo(tree, pub.canonical_path));
1021
+ const siteName = article.breadcrumbs[0]?.title ?? "";
1022
+ const headingIds = article.toc.filter((t) => t.depth === 2 || t.depth === 3).map((t) => scopeId(t.id));
1023
+ const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
1024
+ return /* @__PURE__ */ jsx9(Shell, { children: /* @__PURE__ */ jsxs8("div", { className: "hyle-docs", id: ROOT_ID, lang: c.locale, children: [
1025
+ /* @__PURE__ */ jsx9(DocsEnhance, { headingIds, rootId: ROOT_ID }),
1026
+ /* @__PURE__ */ jsxs8("button", { type: "button", className: "hyle-nav-bar", popoverTarget: NAV_ID, children: [
1027
+ /* @__PURE__ */ jsx9(Icon, { name: "file" }),
1028
+ s.menu,
1029
+ /* @__PURE__ */ jsx9("span", { className: "cur", children: pub.title }),
1030
+ /* @__PURE__ */ jsx9(Icon, { name: "chev-down", className: "hyle-chev" })
1031
+ ] }),
1032
+ /* @__PURE__ */ jsxs8("aside", { className: "hyle-nav-d", id: NAV_ID, popover: "auto", "aria-label": s.docs, children: [
1033
+ /* @__PURE__ */ jsxs8("div", { className: "hyle-side-head", children: [
1034
+ /* @__PURE__ */ jsx9("b", { children: siteName }),
1035
+ /* @__PURE__ */ jsx9(Slot, { name: "docs.version", slots: base.slots, tag: "span" }),
1036
+ /* @__PURE__ */ jsx9("button", { type: "button", className: "hyle-nav-x", popoverTarget: NAV_ID, popoverTargetAction: "hide", "aria-label": s.closeMenu, children: /* @__PURE__ */ jsx9(Icon, { name: "x" }) })
1037
+ ] }),
1038
+ /* @__PURE__ */ jsx9(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
1039
+ /* @__PURE__ */ jsx9("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ jsx9(Branch, { nodes: tree, current: pub.canonical_path, onPath, c }) }),
1040
+ /* @__PURE__ */ jsx9(Slot, { name: "docs.sidebar-footer", slots: base.slots, className: "hyle-side-slot" })
1041
+ ] }),
1042
+ /* @__PURE__ */ jsxs8("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
1043
+ notTranslated ? /* @__PURE__ */ jsxs8("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
1044
+ /* @__PURE__ */ jsx9(Icon, { name: "alert" }),
1045
+ /* @__PURE__ */ jsxs8("div", { children: [
1046
+ /* @__PURE__ */ jsx9("b", { children: notTranslated }),
1047
+ " ",
1048
+ s.fallbackBody
1049
+ ] })
1050
+ ] }) : null,
1051
+ /* @__PURE__ */ jsx9("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ jsx9("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ jsx9("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ jsx9(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
1052
+ /* @__PURE__ */ jsx9("h1", { className: "hyle-title", children: pub.title }),
1053
+ pub.description ? /* @__PURE__ */ jsx9("p", { className: "hyle-desc", children: pub.description }) : null,
1054
+ /* @__PURE__ */ jsxs8("p", { className: "hyle-updated", children: [
1055
+ /* @__PURE__ */ jsx9(Icon, { name: "calendar" }),
1056
+ s.updated,
1057
+ " ",
1058
+ /* @__PURE__ */ jsx9("time", { dateTime: pub.updated_at, title: pub.updated_at, children: formatDate(pub.updated_at, c.locale) })
1059
+ ] }),
1060
+ toc.narrow,
1061
+ /* @__PURE__ */ jsx9(Body, { article, components: base.components, locale: c.locale }),
1062
+ /* @__PURE__ */ jsx9(Pager, { prev: article.prev, next: article.next, c }),
1063
+ /* @__PURE__ */ jsx9(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" }),
1064
+ /* @__PURE__ */ jsx9("span", { className: "hyle-docs-end", "aria-hidden": "true" })
1065
+ ] }),
1066
+ toc.wide
1067
+ ] }) });
1068
+ }
1069
+
1070
+ export {
1071
+ HastContent,
1072
+ TrustedServerHtml,
1073
+ HyleBody,
1074
+ isClampedSource,
1075
+ stripMermaidConfig,
1076
+ isLargeDiagram,
1077
+ REACTION_KINDS,
1078
+ isCursor,
1079
+ parseListing,
1080
+ HyleListView,
1081
+ HyleArticleView,
1082
+ HyleCommentsView,
1083
+ HyleCommentsFallback,
1084
+ BARE_HTTPS_ORIGIN,
1085
+ bareOrigin,
1086
+ absoluteUrl,
1087
+ modifiedAt,
1088
+ wordCountOf,
1089
+ readingMinutes,
1090
+ articleAuthor,
1091
+ validOgImage,
1092
+ hreflangLanguages,
1093
+ HyleToc,
1094
+ ArticlePage,
1095
+ ListPage,
1096
+ NotFound,
1097
+ Unavailable,
1098
+ Redirecting,
1099
+ DocsPage,
1100
+ MermaidDiagram2 as MermaidDiagram,
1101
+ holdPrintUntil,
1102
+ installPrintShortcut,
1103
+ Comments2 as Comments,
1104
+ HyleReactions
1105
+ };