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