@atom63/mdx 0.4.0-beta.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 (88) hide show
  1. package/API.md +47 -0
  2. package/CONTRIBUTING.md +58 -0
  3. package/LICENSE +21 -0
  4. package/README.md +190 -0
  5. package/dist/article/index.d.ts +32 -0
  6. package/dist/article/index.js +38 -0
  7. package/dist/article/index.js.map +1 -0
  8. package/dist/blocks/credits-block-entry.d.ts +14 -0
  9. package/dist/blocks/credits-block-entry.js +4 -0
  10. package/dist/blocks/credits-block-entry.js.map +1 -0
  11. package/dist/blocks/index.d.ts +175 -0
  12. package/dist/blocks/index.js +9 -0
  13. package/dist/blocks/index.js.map +1 -0
  14. package/dist/blocks/media-caption-entry.d.ts +11 -0
  15. package/dist/blocks/media-caption-entry.js +4 -0
  16. package/dist/blocks/media-caption-entry.js.map +1 -0
  17. package/dist/chunk-2RCEDZBB.js +11 -0
  18. package/dist/chunk-2RCEDZBB.js.map +1 -0
  19. package/dist/chunk-34B2U2Y2.js +59 -0
  20. package/dist/chunk-34B2U2Y2.js.map +1 -0
  21. package/dist/chunk-A3NG5VKX.js +169 -0
  22. package/dist/chunk-A3NG5VKX.js.map +1 -0
  23. package/dist/chunk-CSXZ2XEN.js +479 -0
  24. package/dist/chunk-CSXZ2XEN.js.map +1 -0
  25. package/dist/chunk-DJSENA7Q.js +63 -0
  26. package/dist/chunk-DJSENA7Q.js.map +1 -0
  27. package/dist/chunk-EIY6ZR6T.js +2471 -0
  28. package/dist/chunk-EIY6ZR6T.js.map +1 -0
  29. package/dist/chunk-EPSRYU5X.js +61 -0
  30. package/dist/chunk-EPSRYU5X.js.map +1 -0
  31. package/dist/chunk-FVCE4FER.js +132 -0
  32. package/dist/chunk-FVCE4FER.js.map +1 -0
  33. package/dist/chunk-IART7J2U.js +101 -0
  34. package/dist/chunk-IART7J2U.js.map +1 -0
  35. package/dist/chunk-OUEW54AC.js +144 -0
  36. package/dist/chunk-OUEW54AC.js.map +1 -0
  37. package/dist/chunk-WZ6US342.js +231 -0
  38. package/dist/chunk-WZ6US342.js.map +1 -0
  39. package/dist/constants-CuaBcwMe.d.ts +4 -0
  40. package/dist/editor/index.d.ts +47 -0
  41. package/dist/editor/index.js +118 -0
  42. package/dist/editor/index.js.map +1 -0
  43. package/dist/framed-block-DM5LLxO7.d.ts +87 -0
  44. package/dist/index.d.ts +45 -0
  45. package/dist/index.js +20 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/lightbox/index.d.ts +44 -0
  48. package/dist/lightbox/index.js +5 -0
  49. package/dist/lightbox/index.js.map +1 -0
  50. package/dist/mdx-provider-6gOypsy5.d.ts +185 -0
  51. package/dist/photo-swipe-CwzAHpP-.d.ts +66 -0
  52. package/dist/primitives/index.d.ts +130 -0
  53. package/dist/primitives/index.js +132 -0
  54. package/dist/primitives/index.js.map +1 -0
  55. package/dist/runtime/index.d.ts +39 -0
  56. package/dist/runtime/index.js +4 -0
  57. package/dist/runtime/index.js.map +1 -0
  58. package/dist/slots-BvPdUMdY.d.ts +23 -0
  59. package/dist/video-block-C0a5Yx9x.d.ts +468 -0
  60. package/package.json +139 -0
  61. package/src/blocks/callout/callout.css +37 -0
  62. package/src/blocks/code-block/code-block.css +40 -0
  63. package/src/blocks/color-swatch-item/color-swatch-item.css +36 -0
  64. package/src/blocks/compare/compare.css +14 -0
  65. package/src/blocks/comparison-pair/comparison-pair.css +27 -0
  66. package/src/blocks/credits-block/credits-block.css +16 -0
  67. package/src/blocks/demo-stage/demo-stage.css +50 -0
  68. package/src/blocks/doc-example/doc-example.css +44 -0
  69. package/src/blocks/image-compare/image-compare.css +45 -0
  70. package/src/blocks/layer-stack/layer-stack.css +28 -0
  71. package/src/blocks/media-placeholder/media-placeholder.css +11 -0
  72. package/src/blocks/mermaid-diagram/mermaid-diagram.css +52 -0
  73. package/src/blocks/page-meta/page-meta.css +7 -0
  74. package/src/blocks/page-table-of-contents/page-table-of-contents.css +73 -0
  75. package/src/blocks/resource-list/resource-list.css +138 -0
  76. package/src/blocks/scroll-stage/scroll-stage.css +12 -0
  77. package/src/blocks/stat-card/stat-card.css +18 -0
  78. package/src/blocks/steps/steps.css +20 -0
  79. package/src/blocks/timeline/timeline.css +12 -0
  80. package/src/blocks/video-block/video-block.css +11 -0
  81. package/src/primitives/motion-tokens.css +16 -0
  82. package/src/styles/a63.css +13 -0
  83. package/src/styles/base.css +362 -0
  84. package/src/styles/block-recipes.css +21 -0
  85. package/src/styles/consumer.css +7 -0
  86. package/src/styles/index.css +12 -0
  87. package/src/styles/mdx-blocks.css +9 -0
  88. package/src/styles/shadcn.css +12 -0
@@ -0,0 +1,2471 @@
1
+ import { createSlot, MdxFrame, MdxFrameHeader, MdxFramePanel, MdxFrameChrome, FramedBlockHeader, MdxFrameFooter, pickSlot, pickRest, hasSlot, FramedBlock, TechnicalFrame, MdxFrameSurface, useMdxReducedMotion, MdxFrameDescription, MdxFrameTitle, MdxFrameItemPanel, motionEasings, motionDurations } from './chunk-WZ6US342.js';
2
+ import { MediaCaption } from './chunk-2RCEDZBB.js';
3
+ import { mdxStyles } from './chunk-FVCE4FER.js';
4
+ import { getImageDimensions, FigureLightboxTrigger, MDX_FIGURE_LIGHTBOX_GALLERY_ID, getRealImageDimensions } from './chunk-IART7J2U.js';
5
+ import { normalizeCodeLanguage, useShikiHighlightResult } from './chunk-A3NG5VKX.js';
6
+ import { Accordion as Accordion$1, AccordionItem, AccordionTrigger, AccordionContent, Separator, Toggle, ScrollArea, Sheet, SheetContent, SheetHeader, SheetTitle, SheetPanel, CopyButton, Skeleton, DropdownMenu, DropdownMenuTrigger, Button, DropdownMenuContent, DropdownMenuItem, ConnectedPanel, ConnectedPanelTrigger, ConnectedPanelContent, ConnectedPanelBody, Card, CardContent, Tabs as Tabs$1, TabsList, TabsTab, TabsPanel, Label, Switch, Tooltip, TooltipTrigger, TooltipContent } from '@atom63/ui-react';
7
+ import { clsx } from 'clsx';
8
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
9
+ import React, { createContext, forwardRef, lazy, useState, useRef, useEffect, Suspense, useContext, useMemo, useLayoutEffect, useId, useCallback, Children, isValidElement, cloneElement } from 'react';
10
+ import { MoveVertical, MoveHorizontal, SlidersHorizontal, LayoutTemplate, Film, ImageIcon, ZoomOut, RotateCcw, ZoomIn, ListTree, ArrowUpRight } from 'lucide-react';
11
+ import { useReducedMotion, motion, AnimatePresence } from 'motion/react';
12
+ import { createPortal } from 'react-dom';
13
+
14
+ function Accordion({ className, ...props }) {
15
+ return /* @__PURE__ */ jsx(
16
+ Accordion$1,
17
+ {
18
+ className: clsx("not-mdx mdx-block", mdxStyles.spacing.block, className),
19
+ ...props
20
+ }
21
+ );
22
+ }
23
+ Accordion.Item = AccordionItem;
24
+ Accordion.Trigger = AccordionTrigger;
25
+ Accordion.Content = AccordionContent;
26
+ function NoticeBlock(props) {
27
+ if (props.mode === "insight") {
28
+ const { body: body2, className: className2, label = "Key idea", title: title2 } = props;
29
+ return /* @__PURE__ */ jsxs(MdxFrame, { as: "aside", className: className2, frameClassName: "mdx-insight-frame", children: [
30
+ /* @__PURE__ */ jsxs(MdxFrameHeader, { children: [
31
+ /* @__PURE__ */ jsx(MdxFrameDescription, { className: "mdx-insight-eyebrow font-mono text-xs tracking-wider uppercase", children: label }),
32
+ title2 ? /* @__PURE__ */ jsx(MdxFrameTitle, { className: "mdx-insight-title mt-2 text-xl leading-tight tracking-tight text-wrap", children: title2 }) : null
33
+ ] }),
34
+ /* @__PURE__ */ jsx(MdxFramePanel, { className: "mdx-insight-panel", children: /* @__PURE__ */ jsx("div", { className: "mdx-insight-body max-w-prose text-base leading-relaxed text-pretty [&_p]:mt-3 [&_strong]:font-semibold [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", children: body2 }) })
35
+ ] });
36
+ }
37
+ const { actions, body, children, className, icon, title, tone = "info" } = props;
38
+ const hasStructure = icon !== void 0 || title !== void 0 || body !== void 0 || actions !== void 0;
39
+ return /* @__PURE__ */ jsx(
40
+ "div",
41
+ {
42
+ className: clsx("callout not-mdx", mdxStyles.layout.callout.base, className),
43
+ "data-tone": tone,
44
+ children: hasStructure ? /* @__PURE__ */ jsxs("div", { className: "flex gap-2.5", children: [
45
+ icon !== void 0 ? /* @__PURE__ */ jsx("div", { className: "shrink-0 pt-0.5", "data-slot": "icon", children: icon }) : null,
46
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
47
+ title !== void 0 ? /* @__PURE__ */ jsx(
48
+ "div",
49
+ {
50
+ className: "mdx-callout-title text-base leading-6 font-semibold",
51
+ "data-slot": "title",
52
+ children: title
53
+ }
54
+ ) : null,
55
+ body !== void 0 ? /* @__PURE__ */ jsx("div", { className: title !== void 0 ? "mt-1" : void 0, "data-slot": "body", children: body }) : null,
56
+ actions !== void 0 ? /* @__PURE__ */ jsx("div", { className: "mt-3 flex gap-2", "data-slot": "actions", children: actions }) : null
57
+ ] })
58
+ ] }) : children
59
+ }
60
+ );
61
+ }
62
+ var CalloutIcon = createSlot("callout-icon");
63
+ var CalloutTitle = createSlot("callout-title");
64
+ var CalloutBody = createSlot("callout-body");
65
+ var CalloutActions = createSlot("callout-actions");
66
+ var SLOTS = [CalloutIcon, CalloutTitle, CalloutBody, CalloutActions];
67
+ function Callout({ children, type = "info", className }) {
68
+ const icon = pickSlot(children, CalloutIcon);
69
+ const title = pickSlot(children, CalloutTitle);
70
+ const body = pickSlot(children, CalloutBody);
71
+ const actions = pickSlot(children, CalloutActions);
72
+ const rest = pickRest(children, SLOTS);
73
+ const usesSlots = SLOTS.some((slot) => hasSlot(children, slot));
74
+ return usesSlots ? /* @__PURE__ */ jsx(
75
+ NoticeBlock,
76
+ {
77
+ actions: actions ?? void 0,
78
+ body: body !== null || rest.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
79
+ body,
80
+ rest.length > 0 ? rest : null
81
+ ] }) : void 0,
82
+ className,
83
+ icon: icon ?? void 0,
84
+ mode: "callout",
85
+ title: title ?? void 0,
86
+ tone: type
87
+ }
88
+ ) : /* @__PURE__ */ jsx(NoticeBlock, { className, mode: "callout", tone: type, children });
89
+ }
90
+ Callout.Icon = CalloutIcon;
91
+ Callout.Title = CalloutTitle;
92
+ Callout.Body = CalloutBody;
93
+ Callout.Actions = CalloutActions;
94
+ var CodeBlockVariantContext = createContext(void 0);
95
+ function CodeBlockVariantProvider({ children, variant }) {
96
+ return /* @__PURE__ */ jsx(CodeBlockVariantContext.Provider, { value: variant, children });
97
+ }
98
+ var LINE_NUMBER_THRESHOLD = 6;
99
+ function CodeFallback({ code, lang }) {
100
+ return /* @__PURE__ */ jsx("pre", { className: "code-block-pre m-0 overflow-visible border-0 bg-transparent p-0 font-mono text-sm leading-relaxed", children: /* @__PURE__ */ jsx("code", { className: clsx("border-0 bg-transparent p-0 shadow-none", lang && `language-${lang}`), children: code.trim() }) });
101
+ }
102
+ function CodeBlockSurface({
103
+ children,
104
+ className,
105
+ code,
106
+ copyLabel = "Copy code",
107
+ fallbackLangLabel = "code",
108
+ lang,
109
+ maxHeight = "max-h-[min(32rem,70vh)]",
110
+ showLineNumbers = false,
111
+ showCopyButton = true,
112
+ spacing,
113
+ variant = "article"
114
+ }) {
115
+ const displayLanguage = lang?.replace(/^language-/, "").trim();
116
+ const resolvedSpacing = spacing ?? (variant === "embedded" ? "none" : "component");
117
+ if (variant === "embedded") {
118
+ return /* @__PURE__ */ jsxs(
119
+ "div",
120
+ {
121
+ className: clsx(
122
+ "code-block code-block-embedded not-mdx mdx-block group/code relative min-w-0",
123
+ resolvedSpacing === "component" && mdxStyles.spacing.component,
124
+ className
125
+ ),
126
+ "data-numbered": showLineNumbers || void 0,
127
+ children: [
128
+ /* @__PURE__ */ jsx(
129
+ ScrollArea,
130
+ {
131
+ className: "code-block-body h-auto min-w-0",
132
+ showScrollbarOnHover: true,
133
+ viewportClassName: clsx(
134
+ "code-block-viewport",
135
+ maxHeight,
136
+ "[&_pre]:m-0 [&_pre]:overflow-visible [&_pre]:border-0 [&_pre]:bg-transparent [&_pre]:p-0",
137
+ "[&_pre]:font-mono [&_pre]:text-xs [&_pre]:leading-relaxed",
138
+ "[&_code]:border-0 [&_code]:bg-transparent [&_code]:p-0 [&_code]:shadow-none",
139
+ "[&_.line]:min-h-[1.45em]",
140
+ "[&_.shiki]:bg-transparent [&_.shiki]:text-[var(--shiki-light)] [&_.shiki_span]:text-[var(--shiki-light)]",
141
+ "dark:[&_.shiki]:text-[var(--shiki-dark)] dark:[&_.shiki_span]:text-[var(--shiki-dark)]"
142
+ ),
143
+ children
144
+ }
145
+ ),
146
+ showCopyButton ? /* @__PURE__ */ jsx(
147
+ CopyButton,
148
+ {
149
+ className: "code-block-copy absolute top-0 right-0 size-11 shrink-0 opacity-0 transition-opacity group-hover/code:opacity-100 focus-visible:opacity-100 md:size-7",
150
+ label: copyLabel,
151
+ size: "icon-sm",
152
+ value: code.trim(),
153
+ variant: "ghost"
154
+ }
155
+ ) : null
156
+ ]
157
+ }
158
+ );
159
+ }
160
+ return /* @__PURE__ */ jsx(
161
+ TechnicalFrame,
162
+ {
163
+ className: clsx(
164
+ "code-block mdx-code-block not-mdx mdx-block group/code min-w-0",
165
+ resolvedSpacing === "component" && mdxStyles.spacing.component,
166
+ className
167
+ ),
168
+ dataNumbered: showLineNumbers,
169
+ headerEnd: showCopyButton ? /* @__PURE__ */ jsx(
170
+ CopyButton,
171
+ {
172
+ className: "size-11 shrink-0 md:size-7",
173
+ label: copyLabel,
174
+ size: "icon-sm",
175
+ value: code.trim(),
176
+ variant: "ghost"
177
+ }
178
+ ) : null,
179
+ headerStart: /* @__PURE__ */ jsx("span", { className: "mdx-code-block-lang truncate font-mono text-xs", children: displayLanguage || fallbackLangLabel }),
180
+ panelClassName: "mdx-code-block-panel code-block-body min-w-0 overflow-hidden p-0",
181
+ width: "wide",
182
+ children: /* @__PURE__ */ jsx(ScrollArea, { className: maxHeight, showScrollbarOnHover: true, children: /* @__PURE__ */ jsx(
183
+ "div",
184
+ {
185
+ className: clsx(
186
+ "px-4 py-3.5",
187
+ "[&_pre]:m-0 [&_pre]:overflow-visible [&_pre]:border-0 [&_pre]:bg-transparent [&_pre]:p-0",
188
+ "[&_pre]:font-mono [&_pre]:text-sm [&_pre]:leading-relaxed",
189
+ "[&_code]:border-0 [&_code]:bg-transparent [&_code]:p-0 [&_code]:shadow-none",
190
+ "[&_.line]:min-h-[1.5em]",
191
+ "[&_.shiki]:bg-transparent [&_.shiki]:text-[var(--shiki-light)] [&_.shiki_span]:text-[var(--shiki-light)]",
192
+ "dark:[&_.shiki]:text-[var(--shiki-dark)] dark:[&_.shiki_span]:text-[var(--shiki-dark)]"
193
+ ),
194
+ children
195
+ }
196
+ ) })
197
+ }
198
+ );
199
+ }
200
+ function CodeBlock({
201
+ children,
202
+ code,
203
+ lang = "tsx",
204
+ loadingLabel = "Highlighting code",
205
+ showLineNumbers,
206
+ variant,
207
+ ...props
208
+ }) {
209
+ const contextualVariant = useContext(CodeBlockVariantContext);
210
+ const resolvedVariant = variant ?? contextualVariant ?? "article";
211
+ const normalizedLanguage = normalizeCodeLanguage(lang);
212
+ const { html, isLoading } = useShikiHighlightResult(code, lang);
213
+ const resolvedLineNumbers = showLineNumbers ?? (resolvedVariant === "article" && code.trim().split("\n").length > LINE_NUMBER_THRESHOLD);
214
+ if (children) {
215
+ return /* @__PURE__ */ jsx(
216
+ CodeBlockSurface,
217
+ {
218
+ code,
219
+ lang: normalizedLanguage ?? lang,
220
+ showLineNumbers: resolvedLineNumbers,
221
+ variant: resolvedVariant,
222
+ ...props,
223
+ children
224
+ }
225
+ );
226
+ }
227
+ return /* @__PURE__ */ jsxs(
228
+ CodeBlockSurface,
229
+ {
230
+ code,
231
+ lang: normalizedLanguage ?? lang,
232
+ showLineNumbers: resolvedLineNumbers,
233
+ variant: resolvedVariant,
234
+ ...props,
235
+ children: [
236
+ html ? /* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: html } }) : /* @__PURE__ */ jsx(CodeFallback, { code, lang: normalizedLanguage }),
237
+ isLoading ? /* @__PURE__ */ jsx("span", { className: "sr-only", children: loadingLabel }) : null
238
+ ]
239
+ }
240
+ );
241
+ }
242
+ function ColorSwatchItem({ name, variable }) {
243
+ return /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-80 items-center gap-2", children: [
244
+ /* @__PURE__ */ jsx("div", { className: "mdx-color-swatch-frame checker-bg size-16 shrink-0 overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "size-full", style: { backgroundColor: `var(${variable})` } }) }),
245
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [
246
+ /* @__PURE__ */ jsx("div", { className: "mdx-color-swatch-name text-sm font-semibold", children: name }),
247
+ /* @__PURE__ */ jsx("div", { className: "mdx-color-swatch-var text-sm", children: variable })
248
+ ] })
249
+ ] });
250
+ }
251
+ var CompareTitleSlot = createSlot("compare-title");
252
+ var CompareDescriptionSlot = createSlot("compare-description");
253
+ var HEADER_SLOTS = [CompareTitleSlot, CompareDescriptionSlot];
254
+ function CompareItem({ children, className, eyebrow, title, tone = "neutral" }) {
255
+ return /* @__PURE__ */ jsx(
256
+ MdxFrameItemPanel,
257
+ {
258
+ bodyClassName: "mdx-compare-item-body",
259
+ className: clsx("mdx-compare-item", className),
260
+ eyebrow,
261
+ title,
262
+ tone,
263
+ children: /* @__PURE__ */ jsx(CodeBlockVariantProvider, { variant: "embedded", children })
264
+ }
265
+ );
266
+ }
267
+ function Compare({ children, className, description, title }) {
268
+ const slotTitle = pickSlot(children, CompareTitleSlot);
269
+ const slotDescription = pickSlot(children, CompareDescriptionSlot);
270
+ const items = pickRest(children, HEADER_SLOTS);
271
+ const resolvedTitle = slotTitle ?? title;
272
+ const resolvedDescription = slotDescription ?? description;
273
+ return /* @__PURE__ */ jsxs(FramedBlock, { className, frameClassName: "mdx-compare-frame", children: [
274
+ /* @__PURE__ */ jsx(
275
+ FramedBlockHeader,
276
+ {
277
+ className: "mdx-compare-header",
278
+ description: resolvedDescription,
279
+ descriptionClassName: "mdx-compare-description max-w-prose leading-relaxed text-pretty",
280
+ title: resolvedTitle,
281
+ titleClassName: "mdx-compare-title text-base leading-tight text-wrap"
282
+ }
283
+ ),
284
+ /* @__PURE__ */ jsx("div", { className: "grid min-w-0 gap-2 md:grid-cols-2", children: items })
285
+ ] });
286
+ }
287
+ Compare.Item = CompareItem;
288
+ Compare.Title = CompareTitleSlot;
289
+ Compare.Description = CompareDescriptionSlot;
290
+ var ComparisonContext = createContext({ durationScale: 1 });
291
+ function ComparisonProvider({
292
+ children,
293
+ durationScale
294
+ }) {
295
+ return /* @__PURE__ */ jsx(ComparisonContext.Provider, { value: { durationScale }, children });
296
+ }
297
+ function useComparisonContext() {
298
+ return useContext(ComparisonContext);
299
+ }
300
+ var BADGE_STYLES = {
301
+ before: "mdx-comparison-badge",
302
+ after: "mdx-comparison-badge"
303
+ };
304
+ function ComparisonSlot({
305
+ children,
306
+ className,
307
+ label,
308
+ side
309
+ }) {
310
+ return /* @__PURE__ */ jsxs(
311
+ "section",
312
+ {
313
+ "aria-label": label ? `${label} \u2014 ${side}` : side,
314
+ className: clsx("relative flex min-w-0 flex-1 flex-col", className),
315
+ children: [
316
+ label ? /* @__PURE__ */ jsxs(
317
+ "div",
318
+ {
319
+ className: clsx(
320
+ "flex items-center gap-1.5 px-4 pt-3",
321
+ side === "after" && "md:justify-end"
322
+ ),
323
+ "data-side": side,
324
+ children: [
325
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "mdx-comparison-dot size-1.5 rounded-full" }),
326
+ /* @__PURE__ */ jsx("span", { className: clsx("text-xs font-medium", BADGE_STYLES[side]), children: label })
327
+ ]
328
+ }
329
+ ) : null,
330
+ /* @__PURE__ */ jsx("div", { className: "flex aspect-square flex-1 items-center justify-center px-6 py-8 md:aspect-auto", children })
331
+ ]
332
+ }
333
+ );
334
+ }
335
+ function Before({ children, className, label }) {
336
+ return /* @__PURE__ */ jsx(ComparisonSlot, { className, label, side: "before", children });
337
+ }
338
+ function After({ children, className, label }) {
339
+ return /* @__PURE__ */ jsx(ComparisonSlot, { className, label, side: "after", children });
340
+ }
341
+ function SlowMotionSwitch({
342
+ slow,
343
+ onToggle,
344
+ label = "Slow motion"
345
+ }) {
346
+ return /* @__PURE__ */ jsxs(
347
+ Label,
348
+ {
349
+ className: "mdx-comparison-switch-label flex items-center gap-2 text-xs",
350
+ "data-slot": "label",
351
+ children: [
352
+ /* @__PURE__ */ jsx(Switch, { checked: slow, onCheckedChange: onToggle }),
353
+ label
354
+ ]
355
+ }
356
+ );
357
+ }
358
+ function ComparisonPair({
359
+ children,
360
+ className,
361
+ label,
362
+ slowMotionLabel = "Slow motion",
363
+ speedControl = false
364
+ }) {
365
+ const ariaLabel = label;
366
+ const [slow, setSlow] = useState(false);
367
+ const speed = slow ? 0.25 : 1;
368
+ const durationScale = useMemo(() => 1 / speed, [speed]);
369
+ return /* @__PURE__ */ jsx(ComparisonProvider, { durationScale, children: /* @__PURE__ */ jsxs(
370
+ MdxFrame,
371
+ {
372
+ "aria-label": ariaLabel,
373
+ className: clsx("comparison-pair mdx-comparison-pair not-prose", className),
374
+ frameClassName: "mdx-comparison-frame",
375
+ spacing: "media",
376
+ children: [
377
+ /* @__PURE__ */ jsx(MdxFramePanel, { className: "mdx-comparison-panel overflow-hidden p-0", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col md:aspect-video md:flex-row", children: React.Children.toArray(children).flatMap(
378
+ (child, i, arr) => i < arr.length - 1 ? [
379
+ child,
380
+ /* @__PURE__ */ jsxs(React.Fragment, { children: [
381
+ /* @__PURE__ */ jsx(
382
+ Separator,
383
+ {
384
+ className: "md:hidden",
385
+ orientation: "horizontal",
386
+ variant: "gradient"
387
+ }
388
+ ),
389
+ /* @__PURE__ */ jsx(
390
+ Separator,
391
+ {
392
+ className: "hidden md:block",
393
+ orientation: "vertical",
394
+ variant: "gradient"
395
+ }
396
+ )
397
+ ] }, `sep-${String(i)}`)
398
+ ] : [child]
399
+ ) }) }),
400
+ speedControl ? /* @__PURE__ */ jsx(MdxFrameFooter, { className: "flex items-center px-3 py-1.5", children: /* @__PURE__ */ jsx(SlowMotionSwitch, { label: slowMotionLabel, onToggle: setSlow, slow }) }) : null
401
+ ]
402
+ }
403
+ ) });
404
+ }
405
+ ComparisonPair.Before = Before;
406
+ ComparisonPair.After = After;
407
+ var DEFAULT_MOBILE_QUERY = "(max-width: 767px)";
408
+ var DEFAULT_PANEL_INSET = 16;
409
+ var DEFAULT_PANEL_WIDTH = 320;
410
+ function useControllableOpen({
411
+ defaultOpen = false,
412
+ onOpenChange,
413
+ open
414
+ }) {
415
+ const [internalOpen, setInternalOpen] = useState(defaultOpen);
416
+ const isControlled = open !== void 0;
417
+ const value = isControlled ? open : internalOpen;
418
+ const setValue = useCallback(
419
+ (nextOpen) => {
420
+ if (!isControlled) {
421
+ setInternalOpen(nextOpen);
422
+ }
423
+ onOpenChange?.(nextOpen);
424
+ },
425
+ [isControlled, onOpenChange]
426
+ );
427
+ return [value, setValue];
428
+ }
429
+ function useMediaQuery(query) {
430
+ const [matches, setMatches] = useState(false);
431
+ useEffect(() => {
432
+ const media = window.matchMedia(query);
433
+ const updateMatches = () => setMatches(media.matches);
434
+ updateMatches();
435
+ media.addEventListener("change", updateMatches);
436
+ return () => media.removeEventListener("change", updateMatches);
437
+ }, [query]);
438
+ return matches;
439
+ }
440
+ function DemoConfigPanel({
441
+ children,
442
+ defaultOpen,
443
+ label = "Tune",
444
+ mobileQuery = DEFAULT_MOBILE_QUERY,
445
+ onOpenChange,
446
+ open,
447
+ panelClassName,
448
+ panelInset = DEFAULT_PANEL_INSET,
449
+ panelWidth = DEFAULT_PANEL_WIDTH,
450
+ sheetClassName,
451
+ sheetPanelClassName,
452
+ stageRef,
453
+ title = "Demo controls"
454
+ }) {
455
+ const triggerRef = useRef(null);
456
+ const [panelStyle, setPanelStyle] = useState();
457
+ const [isOpen, setIsOpen] = useControllableOpen({ defaultOpen, onOpenChange, open });
458
+ const isMobile = useMediaQuery(mobileQuery);
459
+ useLayoutEffect(() => {
460
+ if (!isOpen || isMobile) {
461
+ setPanelStyle(void 0);
462
+ return;
463
+ }
464
+ const updatePanelSize = () => {
465
+ const stage = stageRef.current;
466
+ const trigger = triggerRef.current;
467
+ if (!stage || !trigger) {
468
+ return;
469
+ }
470
+ const stageRect = stage.getBoundingClientRect();
471
+ const triggerRect = trigger.getBoundingClientRect();
472
+ const height = Math.max(1, Math.floor(stageRect.bottom - triggerRect.bottom - panelInset * 2));
473
+ const width = Math.max(1, Math.min(panelWidth, Math.floor(stageRect.width - panelInset * 2)));
474
+ setPanelStyle({
475
+ height,
476
+ position: "absolute",
477
+ right: 0,
478
+ top: `calc(100% + ${panelInset}px)`,
479
+ width
480
+ });
481
+ };
482
+ updatePanelSize();
483
+ const frame = window.requestAnimationFrame(updatePanelSize);
484
+ const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(updatePanelSize);
485
+ if (observer) {
486
+ if (stageRef.current) {
487
+ observer.observe(stageRef.current);
488
+ }
489
+ if (triggerRef.current) {
490
+ observer.observe(triggerRef.current);
491
+ }
492
+ }
493
+ window.addEventListener("resize", updatePanelSize);
494
+ return () => {
495
+ window.cancelAnimationFrame(frame);
496
+ observer?.disconnect();
497
+ window.removeEventListener("resize", updatePanelSize);
498
+ };
499
+ }, [isMobile, isOpen, panelInset, panelWidth, stageRef]);
500
+ return /* @__PURE__ */ jsxs("div", { className: "relative", ref: triggerRef, children: [
501
+ /* @__PURE__ */ jsxs(
502
+ Toggle,
503
+ {
504
+ "aria-expanded": isOpen,
505
+ "aria-label": typeof label === "string" ? `Toggle ${label.toLowerCase()} controls` : title,
506
+ "aria-haspopup": "dialog",
507
+ onPressedChange: setIsOpen,
508
+ pressed: isOpen,
509
+ size: "sm",
510
+ children: [
511
+ /* @__PURE__ */ jsx(SlidersHorizontal, { "aria-hidden": "true", className: "size-3.5" }),
512
+ label
513
+ ]
514
+ }
515
+ ),
516
+ isOpen && !isMobile ? /* @__PURE__ */ jsx(
517
+ "div",
518
+ {
519
+ "aria-label": title,
520
+ className: clsx(
521
+ "mdx-demo-config-panel mdx-demo-config-panel--desktop overflow-hidden",
522
+ panelClassName
523
+ ),
524
+ role: "dialog",
525
+ style: panelStyle,
526
+ children: /* @__PURE__ */ jsx(
527
+ ScrollArea,
528
+ {
529
+ className: "mdx-demo-config-panel__scroll",
530
+ showScrollbarOnHover: true,
531
+ viewportClassName: "mdx-demo-config-panel__viewport overscroll-contain",
532
+ children
533
+ }
534
+ )
535
+ }
536
+ ) : null,
537
+ /* @__PURE__ */ jsx(Sheet, { onOpenChange: setIsOpen, open: isOpen && isMobile, children: /* @__PURE__ */ jsxs(
538
+ SheetContent,
539
+ {
540
+ className: clsx(
541
+ "mdx-demo-config-panel mdx-demo-config-panel--sheet overflow-hidden",
542
+ sheetClassName
543
+ ),
544
+ showCloseButton: false,
545
+ side: "bottom",
546
+ style: {
547
+ backgroundColor: "var(--a63-surface-overlay)",
548
+ backgroundImage: "none",
549
+ boxShadow: "none"
550
+ },
551
+ variant: "default",
552
+ children: [
553
+ /* @__PURE__ */ jsx(SheetHeader, { className: "sr-only", children: /* @__PURE__ */ jsx(SheetTitle, { children: title }) }),
554
+ /* @__PURE__ */ jsx(
555
+ SheetPanel,
556
+ {
557
+ className: clsx("mdx-demo-config-panel__sheet-panel", sheetPanelClassName),
558
+ scrollFade: false,
559
+ children
560
+ }
561
+ )
562
+ ]
563
+ }
564
+ ) })
565
+ ] });
566
+ }
567
+ var DemoStage = forwardRef(function DemoStage2({ children, className, headerEnd, headerStart, panelClassName }, ref) {
568
+ const hasHeader = Boolean(headerStart || headerEnd);
569
+ return /* @__PURE__ */ jsxs(
570
+ MdxFrame,
571
+ {
572
+ className: clsx("demo-stage", className),
573
+ frameClassName: "mdx-demo-stage-frame",
574
+ ref,
575
+ spacing: "media",
576
+ width: "wide",
577
+ children: [
578
+ hasHeader ? /* @__PURE__ */ jsxs(MdxFrameHeader, { className: "mdx-demo-stage-header flex-row items-center justify-between gap-3 px-3 py-2", children: [
579
+ /* @__PURE__ */ jsx("div", { className: "min-w-0", children: headerStart }),
580
+ headerEnd ? /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center gap-1.5", children: headerEnd }) : null
581
+ ] }) : null,
582
+ /* @__PURE__ */ jsx(
583
+ MdxFramePanel,
584
+ {
585
+ className: clsx(
586
+ "mdx-demo-stage not-prose flex aspect-[4/3] items-center justify-center overflow-hidden px-4 md:aspect-video md:px-10",
587
+ panelClassName
588
+ ),
589
+ children
590
+ }
591
+ )
592
+ ]
593
+ }
594
+ );
595
+ });
596
+ var ExampleContext = createContext(false);
597
+ var useIsInsideExample = () => useContext(ExampleContext);
598
+ function ExampleFrame({
599
+ align = "center",
600
+ children,
601
+ className,
602
+ embedded = false
603
+ }) {
604
+ return /* @__PURE__ */ jsx(
605
+ "div",
606
+ {
607
+ className: clsx(
608
+ "relative overflow-hidden bg-[var(--a63-surface-page)]",
609
+ embedded ? "flex min-h-[6.5rem] items-center px-5 py-6 sm:px-8 sm:py-7" : "rounded-xl border border-[var(--a63-border-subtle)] p-6 sm:p-7",
610
+ "[background-size:20px_20px]",
611
+ embedded ? "[background-image:radial-gradient(color-mix(in_oklab,var(--a63-border-subtle)_40%,transparent)_1px,transparent_1px)]" : "[background-image:radial-gradient(var(--a63-border-subtle)_1px,transparent_1px)]",
612
+ className
613
+ ),
614
+ children: /* @__PURE__ */ jsx(ExampleContext.Provider, { value: true, children: /* @__PURE__ */ jsx(
615
+ "div",
616
+ {
617
+ className: clsx(
618
+ "not-mdx relative z-10 flex w-full flex-wrap",
619
+ embedded ? "gap-3" : "gap-4",
620
+ align === "center" && "items-center justify-center [&>*]:mx-auto",
621
+ align === "left" && "items-start justify-start"
622
+ ),
623
+ children
624
+ }
625
+ ) })
626
+ }
627
+ );
628
+ }
629
+ function ExampleContainer({
630
+ children,
631
+ align = "center",
632
+ description,
633
+ spec,
634
+ title,
635
+ className,
636
+ embedded = false,
637
+ wide = false
638
+ }) {
639
+ const Wrapper = wide ? "figure" : "div";
640
+ return /* @__PURE__ */ jsxs(
641
+ Wrapper,
642
+ {
643
+ className: clsx(
644
+ "example-container not-mdx not-prose @container",
645
+ embedded ? "my-0" : mdxStyles.spacing.component
646
+ ),
647
+ "data-mdx-width": wide ? "wide" : "column",
648
+ children: [
649
+ (title || description) && /* @__PURE__ */ jsxs("header", { className: clsx("mb-3 flex flex-col gap-1", align === "center" && "text-center"), children: [
650
+ title ? /* @__PURE__ */ jsx("p", { className: "text-foreground text-sm font-semibold tracking-tight", children: title }) : null,
651
+ description ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm leading-relaxed", children: description }) : null
652
+ ] }),
653
+ /* @__PURE__ */ jsx(ExampleFrame, { align, className, embedded, children }),
654
+ spec ? /* @__PURE__ */ jsx("div", { className: "w-full overflow-hidden", children: spec }) : null
655
+ ]
656
+ }
657
+ );
658
+ }
659
+ function DocExampleCode({ code, lang = "tsx" }) {
660
+ return /* @__PURE__ */ jsx(
661
+ CodeBlock,
662
+ {
663
+ className: "doc-example-code-panel my-0 rounded-none border-0",
664
+ code,
665
+ lang,
666
+ maxHeight: "max-h-[min(24rem,60vh)]",
667
+ showCopyButton: false,
668
+ spacing: "none",
669
+ variant: "embedded"
670
+ }
671
+ );
672
+ }
673
+ var DocExampleTitleSlot = createSlot("doc-example-title");
674
+ var DocExamplePreviewSlot = createSlot("doc-example-preview");
675
+ var DocExampleCodeSlot = createSlot("doc-example-code");
676
+ var DOC_EXAMPLE_SLOTS = [DocExampleTitleSlot, DocExamplePreviewSlot, DocExampleCodeSlot];
677
+ function slugifyTitle(title) {
678
+ return title.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-");
679
+ }
680
+ var tabButtonClass = "mdx-doc-example-tab h-11 px-3 font-medium text-xs transition-colors motion-reduce:transition-none md:h-7";
681
+ function DocExample({
682
+ title,
683
+ code,
684
+ codeLabel = "Code",
685
+ copyCodeLabel = "Copy example code",
686
+ copiedLabel = "Copied to clipboard",
687
+ copiedAnnouncement = "Example code copied",
688
+ lang,
689
+ previewLabel = "Preview",
690
+ children,
691
+ className,
692
+ align = "center",
693
+ wide = false
694
+ }) {
695
+ const baseId = useId();
696
+ const previewId = `${baseId}-preview`;
697
+ const codeId = `${baseId}-code`;
698
+ const [tab, setTab] = useState("preview");
699
+ const slotTitle = pickSlot(children, DocExampleTitleSlot);
700
+ const slotPreview = pickSlot(children, DocExamplePreviewSlot);
701
+ const slotCode = pickSlot(children, DocExampleCodeSlot);
702
+ const restChildren = pickRest(children, DOC_EXAMPLE_SLOTS);
703
+ const resolvedTitle = slotTitle ?? title;
704
+ const titleString = typeof resolvedTitle === "string" ? resolvedTitle : void 0;
705
+ const previewContent = slotPreview ?? restChildren;
706
+ const codeContent = slotCode ?? /* @__PURE__ */ jsx(DocExampleCode, { code, lang });
707
+ const headingId = titleString ? slugifyTitle(titleString) : void 0;
708
+ const previewTabRef = useRef(null);
709
+ const codeTabRef = useRef(null);
710
+ const handleTabKeyDown = (event) => {
711
+ const nextTab = (() => {
712
+ if (event.key === "Home") {
713
+ return "preview";
714
+ }
715
+ if (event.key === "End") {
716
+ return "code";
717
+ }
718
+ if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
719
+ return tab === "preview" ? "code" : "preview";
720
+ }
721
+ return null;
722
+ })();
723
+ if (!nextTab) {
724
+ return;
725
+ }
726
+ event.preventDefault();
727
+ setTab(nextTab);
728
+ window.requestAnimationFrame(() => {
729
+ const nextRef = nextTab === "preview" ? previewTabRef : codeTabRef;
730
+ nextRef.current?.focus();
731
+ });
732
+ };
733
+ return /* @__PURE__ */ jsxs(
734
+ "figure",
735
+ {
736
+ className: clsx(
737
+ "doc-example not-prose",
738
+ resolvedTitle ? "scroll-mt-24" : null,
739
+ resolvedTitle ? mdxStyles.spacing.media : mdxStyles.spacing.block,
740
+ className
741
+ ),
742
+ "data-mdx-width": "wide",
743
+ id: headingId,
744
+ children: [
745
+ resolvedTitle ? /* @__PURE__ */ jsx(
746
+ "figcaption",
747
+ {
748
+ className: "mdx-doc-example-title mb-2.5 text-sm font-medium tracking-tight",
749
+ "data-slot": "title",
750
+ children: resolvedTitle
751
+ }
752
+ ) : null,
753
+ /* @__PURE__ */ jsx(
754
+ TechnicalFrame,
755
+ {
756
+ className: "doc-example-shell",
757
+ headerClassName: "gap-4 px-4 py-0.5 md:py-1.5",
758
+ headerEnd: /* @__PURE__ */ jsx(
759
+ "div",
760
+ {
761
+ className: clsx(
762
+ "flex shrink-0 items-center justify-center",
763
+ tab !== "code" && "pointer-events-none opacity-0"
764
+ ),
765
+ children: /* @__PURE__ */ jsx(
766
+ CopyButton,
767
+ {
768
+ "aria-hidden": tab !== "code",
769
+ className: "size-11 md:size-7",
770
+ copiedLabel,
771
+ label: copyCodeLabel,
772
+ size: "icon-sm",
773
+ successMessage: copiedAnnouncement,
774
+ tabIndex: tab === "code" ? 0 : -1,
775
+ value: code.trim(),
776
+ variant: "ghost"
777
+ }
778
+ )
779
+ }
780
+ ),
781
+ headerStart: /* @__PURE__ */ jsxs(
782
+ "div",
783
+ {
784
+ "aria-label": titleString ? `${titleString} example view` : "Component example view",
785
+ className: "mdx-doc-example-tablist inline-flex h-12 items-center p-0.5 md:h-8",
786
+ onKeyDown: handleTabKeyDown,
787
+ role: "tablist",
788
+ tabIndex: -1,
789
+ children: [
790
+ /* @__PURE__ */ jsx(
791
+ "button",
792
+ {
793
+ "aria-controls": previewId,
794
+ "aria-selected": tab === "preview",
795
+ className: tabButtonClass,
796
+ "data-active": tab === "preview",
797
+ id: `${baseId}-tab-preview`,
798
+ ref: previewTabRef,
799
+ role: "tab",
800
+ tabIndex: tab === "preview" ? 0 : -1,
801
+ type: "button",
802
+ onClick: () => {
803
+ setTab("preview");
804
+ },
805
+ children: previewLabel
806
+ }
807
+ ),
808
+ /* @__PURE__ */ jsx(
809
+ "button",
810
+ {
811
+ "aria-controls": codeId,
812
+ "aria-selected": tab === "code",
813
+ className: tabButtonClass,
814
+ "data-active": tab === "code",
815
+ id: `${baseId}-tab-code`,
816
+ ref: codeTabRef,
817
+ role: "tab",
818
+ tabIndex: tab === "code" ? 0 : -1,
819
+ type: "button",
820
+ onClick: () => {
821
+ setTab("code");
822
+ },
823
+ children: codeLabel
824
+ }
825
+ )
826
+ ]
827
+ }
828
+ ),
829
+ panelClassName: "overflow-hidden p-0",
830
+ children: tab === "preview" ? /* @__PURE__ */ jsx(
831
+ "div",
832
+ {
833
+ "aria-labelledby": `${baseId}-tab-preview`,
834
+ className: "doc-example-preview mdx-doc-example-preview",
835
+ id: previewId,
836
+ role: "tabpanel",
837
+ children: /* @__PURE__ */ jsx(ExampleContainer, { align, embedded: true, wide, children: previewContent })
838
+ }
839
+ ) : /* @__PURE__ */ jsx(
840
+ "div",
841
+ {
842
+ "aria-labelledby": `${baseId}-tab-code`,
843
+ className: "doc-example-code",
844
+ id: codeId,
845
+ role: "tabpanel",
846
+ children: codeContent
847
+ }
848
+ )
849
+ }
850
+ )
851
+ ]
852
+ }
853
+ );
854
+ }
855
+ DocExample.Title = DocExampleTitleSlot;
856
+ DocExample.Preview = DocExamplePreviewSlot;
857
+ DocExample.Code = DocExampleCodeSlot;
858
+ var mediaSpacingClasses = {
859
+ none: "",
860
+ sm: mdxStyles.spacing.mediaSm,
861
+ default: mdxStyles.spacing.media,
862
+ lg: mdxStyles.spacing.mediaLg
863
+ };
864
+ function MediaFrame({ bordered = true, children, className }) {
865
+ return /* @__PURE__ */ jsx("div", { className: clsx("overflow-hidden rounded-xl", bordered && "mdx-media-framed", className), children });
866
+ }
867
+ function MediaFigure({
868
+ aside,
869
+ caption,
870
+ children,
871
+ className,
872
+ spacing = "default"
873
+ }) {
874
+ return /* @__PURE__ */ jsxs(
875
+ "figure",
876
+ {
877
+ className: clsx("not-mdx", mediaSpacingClasses[spacing], className),
878
+ "data-mdx-width": "wide",
879
+ "data-media": "",
880
+ children: [
881
+ children,
882
+ caption ? /* @__PURE__ */ jsx(MediaCaption, { children: caption }) : null,
883
+ aside ? /* @__PURE__ */ jsx(
884
+ "aside",
885
+ {
886
+ className: "mdx-text-secondary mt-2 text-center text-xs leading-relaxed",
887
+ "data-slot": "aside",
888
+ children: aside
889
+ }
890
+ ) : null
891
+ ]
892
+ }
893
+ );
894
+ }
895
+ var aspectRatioClasses = {
896
+ "1/1": "aspect-square object-cover",
897
+ "4/3": "aspect-[4/3] object-cover",
898
+ "3/4": "aspect-[3/4] object-cover",
899
+ "16/9": "aspect-video object-cover",
900
+ "9/16": "aspect-[9/16] object-cover"
901
+ };
902
+ var FigureCaptionSlot = createSlot("figure-caption");
903
+ var FigureAsideSlot = createSlot("figure-aside");
904
+ function FigureBlock({
905
+ src,
906
+ alt,
907
+ caption,
908
+ aspectRatio,
909
+ bordered = true,
910
+ spacing = "default",
911
+ loading = "lazy",
912
+ enableLightbox = true,
913
+ lightboxGalleryId = MDX_FIGURE_LIGHTBOX_GALLERY_ID,
914
+ className,
915
+ children
916
+ }) {
917
+ const [dimensions, setDimensions] = useState(() => getImageDimensions(aspectRatio));
918
+ useEffect(() => {
919
+ if (!enableLightbox) {
920
+ return;
921
+ }
922
+ let cancelled = false;
923
+ const loadDimensions = async () => {
924
+ const next = await getRealImageDimensions(src, aspectRatio);
925
+ if (!cancelled && next.width > 0 && next.height > 0) {
926
+ setDimensions(next);
927
+ }
928
+ };
929
+ void loadDimensions();
930
+ return () => {
931
+ cancelled = true;
932
+ };
933
+ }, [enableLightbox, src, aspectRatio]);
934
+ const slotCaption = pickSlot(children, FigureCaptionSlot);
935
+ const slotAside = pickSlot(children, FigureAsideSlot);
936
+ const image = /* @__PURE__ */ jsx(
937
+ "img",
938
+ {
939
+ alt,
940
+ className: clsx("mt-0 w-full rounded-xl", aspectRatio && aspectRatioClasses[aspectRatio]),
941
+ decoding: "async",
942
+ loading,
943
+ src
944
+ }
945
+ );
946
+ const media = enableLightbox ? /* @__PURE__ */ jsx(MediaFrame, { bordered, children: /* @__PURE__ */ jsx(
947
+ FigureLightboxTrigger,
948
+ {
949
+ alt,
950
+ caption,
951
+ className: "overflow-hidden rounded-xl",
952
+ galleryId: lightboxGalleryId,
953
+ height: dimensions.height,
954
+ src,
955
+ width: dimensions.width,
956
+ children: image
957
+ }
958
+ ) }) : /* @__PURE__ */ jsx(MediaFrame, { bordered, children: image });
959
+ return /* @__PURE__ */ jsx(
960
+ MediaFigure,
961
+ {
962
+ aside: slotAside,
963
+ caption: slotCaption ?? caption,
964
+ className,
965
+ spacing,
966
+ children: media
967
+ }
968
+ );
969
+ }
970
+ FigureBlock.Caption = FigureCaptionSlot;
971
+ FigureBlock.Aside = FigureAsideSlot;
972
+ var CENTER = 50;
973
+ var CompareSlider = lazy(async () => {
974
+ const { ReactCompareSlider, ReactCompareSliderImage } = await import('react-compare-slider');
975
+ function CompareSliderImpl({
976
+ after,
977
+ before,
978
+ changePositionOnHover,
979
+ handle,
980
+ objectFit,
981
+ onPositionChange,
982
+ position,
983
+ transition,
984
+ vertical
985
+ }) {
986
+ const imageStyle = { objectFit };
987
+ return /* @__PURE__ */ jsx(
988
+ ReactCompareSlider,
989
+ {
990
+ changePositionOnHover,
991
+ defaultPosition: position,
992
+ handle,
993
+ itemOne: /* @__PURE__ */ jsx(ReactCompareSliderImage, { alt: before.alt, src: before.src, style: imageStyle }),
994
+ itemTwo: /* @__PURE__ */ jsx(ReactCompareSliderImage, { alt: after.alt, src: after.src, style: imageStyle }),
995
+ onPositionChange,
996
+ onlyHandleDraggable: false,
997
+ portrait: vertical,
998
+ style: { height: "100%", width: "100%" },
999
+ transition
1000
+ }
1001
+ );
1002
+ }
1003
+ return { default: CompareSliderImpl };
1004
+ });
1005
+ function ImageCompareHandle({ vertical = false }) {
1006
+ const Icon = vertical ? MoveVertical : MoveHorizontal;
1007
+ return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full items-center justify-center", children: [
1008
+ /* @__PURE__ */ jsx(
1009
+ "div",
1010
+ {
1011
+ "aria-hidden": true,
1012
+ className: clsx(
1013
+ "mdx-image-compare-handle-bar absolute",
1014
+ vertical ? "h-0.5 w-full" : "h-full w-0.5"
1015
+ )
1016
+ }
1017
+ ),
1018
+ /* @__PURE__ */ jsx(
1019
+ "div",
1020
+ {
1021
+ className: clsx(
1022
+ "mdx-image-compare-handle-knob relative z-30 flex size-9 cursor-grab items-center justify-center rounded-full",
1023
+ "backdrop-blur-sm",
1024
+ "transition-colors duration-200 active:cursor-grabbing"
1025
+ ),
1026
+ children: /* @__PURE__ */ jsx(Icon, { "aria-hidden": true, className: "size-4" })
1027
+ }
1028
+ )
1029
+ ] });
1030
+ }
1031
+ var ImageCompare = forwardRef(
1032
+ ({
1033
+ after,
1034
+ aspectRatio = "16/9",
1035
+ before,
1036
+ bordered = true,
1037
+ caption,
1038
+ changePositionOnHover = false,
1039
+ className,
1040
+ description,
1041
+ handle,
1042
+ idleResetMs = 2500,
1043
+ objectFit = "cover",
1044
+ onPositionChange,
1045
+ position: initialPosition = CENTER,
1046
+ resetAfterIdle = false,
1047
+ resetDelay = 500,
1048
+ resetOnLeave = false,
1049
+ title,
1050
+ transition = "0.25s cubic-bezier(.17,.67,.83,.67)",
1051
+ vertical = false,
1052
+ ...props
1053
+ }, ref) => {
1054
+ const [defaultPosition, setDefaultPosition] = useState(initialPosition);
1055
+ const [sliderKey, setSliderKey] = useState(0);
1056
+ const leaveTimerRef = useRef(null);
1057
+ const idleTimerRef = useRef(null);
1058
+ const isPointerDownRef = useRef(false);
1059
+ const currentPositionRef = useRef(initialPosition);
1060
+ const beforeLabel = before.label ?? "Before";
1061
+ const afterLabel = after.label ?? "After";
1062
+ const framed = Boolean(title || description || caption);
1063
+ const clearLeaveTimer = () => {
1064
+ if (leaveTimerRef.current !== null) {
1065
+ window.clearTimeout(leaveTimerRef.current);
1066
+ leaveTimerRef.current = null;
1067
+ }
1068
+ };
1069
+ const clearIdleTimer = () => {
1070
+ if (idleTimerRef.current !== null) {
1071
+ window.clearTimeout(idleTimerRef.current);
1072
+ idleTimerRef.current = null;
1073
+ }
1074
+ };
1075
+ useEffect(() => {
1076
+ return () => {
1077
+ clearLeaveTimer();
1078
+ clearIdleTimer();
1079
+ };
1080
+ }, []);
1081
+ const resetToCenter = () => {
1082
+ if (Math.abs(currentPositionRef.current - CENTER) < 0.5) return;
1083
+ currentPositionRef.current = CENTER;
1084
+ setDefaultPosition(CENTER);
1085
+ setSliderKey((key) => key + 1);
1086
+ onPositionChange?.(CENTER);
1087
+ };
1088
+ const scheduleIdleReset = () => {
1089
+ if (!resetAfterIdle) return;
1090
+ clearIdleTimer();
1091
+ idleTimerRef.current = window.setTimeout(() => {
1092
+ idleTimerRef.current = null;
1093
+ if (isPointerDownRef.current) return;
1094
+ resetToCenter();
1095
+ }, idleResetMs);
1096
+ };
1097
+ const handlePositionChange = (nextPosition) => {
1098
+ currentPositionRef.current = nextPosition;
1099
+ onPositionChange?.(nextPosition);
1100
+ if (!isPointerDownRef.current) {
1101
+ scheduleIdleReset();
1102
+ }
1103
+ };
1104
+ const handlePointerEnter = () => {
1105
+ clearLeaveTimer();
1106
+ };
1107
+ const handlePointerDown = () => {
1108
+ isPointerDownRef.current = true;
1109
+ clearLeaveTimer();
1110
+ clearIdleTimer();
1111
+ };
1112
+ const handlePointerUp = () => {
1113
+ isPointerDownRef.current = false;
1114
+ scheduleIdleReset();
1115
+ };
1116
+ const handlePointerLeave = () => {
1117
+ isPointerDownRef.current = false;
1118
+ scheduleIdleReset();
1119
+ if (!resetOnLeave) {
1120
+ return;
1121
+ }
1122
+ clearLeaveTimer();
1123
+ leaveTimerRef.current = window.setTimeout(() => {
1124
+ leaveTimerRef.current = null;
1125
+ if (isPointerDownRef.current) return;
1126
+ resetToCenter();
1127
+ }, resetDelay);
1128
+ };
1129
+ const stage = /* @__PURE__ */ jsxs(
1130
+ "div",
1131
+ {
1132
+ className: "mdx-image-compare-stage relative w-full overflow-hidden",
1133
+ onPointerDown: handlePointerDown,
1134
+ onPointerEnter: handlePointerEnter,
1135
+ onPointerLeave: handlePointerLeave,
1136
+ onPointerUp: handlePointerUp,
1137
+ ref,
1138
+ style: { aspectRatio },
1139
+ ...props,
1140
+ children: [
1141
+ /* @__PURE__ */ jsx(
1142
+ Suspense,
1143
+ {
1144
+ fallback: /* @__PURE__ */ jsx(
1145
+ "div",
1146
+ {
1147
+ "aria-hidden": true,
1148
+ className: "mdx-image-compare-skeleton h-full w-full animate-pulse",
1149
+ "data-testid": "image-compare-fallback"
1150
+ }
1151
+ ),
1152
+ children: /* @__PURE__ */ jsx(
1153
+ CompareSlider,
1154
+ {
1155
+ after,
1156
+ before,
1157
+ changePositionOnHover,
1158
+ handle: handle ?? /* @__PURE__ */ jsx(ImageCompareHandle, { vertical }),
1159
+ objectFit,
1160
+ onPositionChange: handlePositionChange,
1161
+ position: defaultPosition,
1162
+ transition,
1163
+ vertical
1164
+ },
1165
+ sliderKey
1166
+ )
1167
+ }
1168
+ ),
1169
+ /* @__PURE__ */ jsxs("div", { className: "pointer-events-none absolute inset-x-3 top-3 z-40 flex items-start justify-between gap-3", children: [
1170
+ /* @__PURE__ */ jsx("span", { className: "mdx-image-compare-label max-w-[45%] min-w-0 truncate px-2 py-1 text-xs font-medium backdrop-blur-sm", children: beforeLabel }),
1171
+ /* @__PURE__ */ jsx("span", { className: "mdx-image-compare-label max-w-[45%] min-w-0 truncate px-2 py-1 text-xs font-medium backdrop-blur-sm", children: afterLabel })
1172
+ ] })
1173
+ ]
1174
+ }
1175
+ );
1176
+ if (!framed) {
1177
+ return /* @__PURE__ */ jsx(
1178
+ "figure",
1179
+ {
1180
+ className: clsx(
1181
+ "mdx-image-compare not-mdx mdx-block",
1182
+ mdxStyles.spacing.media,
1183
+ className
1184
+ ),
1185
+ children: stage
1186
+ }
1187
+ );
1188
+ }
1189
+ return /* @__PURE__ */ jsxs(
1190
+ MdxFrameChrome,
1191
+ {
1192
+ className: clsx("mdx-image-compare not-mdx mdx-block", mdxStyles.spacing.media, className),
1193
+ "data-framed": "",
1194
+ children: [
1195
+ /* @__PURE__ */ jsx(FramedBlockHeader, { description, title }),
1196
+ /* @__PURE__ */ jsx(MdxFramePanel, { className: "overflow-hidden p-0", border: bordered ? void 0 : "off", children: stage }),
1197
+ caption ? /* @__PURE__ */ jsx(MdxFrameFooter, { children: caption }) : null
1198
+ ]
1199
+ }
1200
+ );
1201
+ }
1202
+ );
1203
+ ImageCompare.displayName = "ImageCompare";
1204
+ function KeyIdea({ children, className, label = "Key idea", title }) {
1205
+ return /* @__PURE__ */ jsx(NoticeBlock, { body: children, className, label, mode: "insight", title });
1206
+ }
1207
+ var defaultLayerStackLabels = {
1208
+ metaphor: "Metaphor",
1209
+ description: "System role",
1210
+ constraint: "AI constraint"
1211
+ };
1212
+ function LayerStack({ className, description, labels, layers, title }) {
1213
+ const resolvedLabels = { ...defaultLayerStackLabels, ...labels };
1214
+ return /* @__PURE__ */ jsxs(FramedBlock, { className, children: [
1215
+ /* @__PURE__ */ jsx(
1216
+ FramedBlockHeader,
1217
+ {
1218
+ description,
1219
+ descriptionClassName: "mt-2 max-w-prose leading-relaxed text-pretty",
1220
+ title,
1221
+ titleClassName: "mdx-layer-title text-lg leading-tight text-wrap"
1222
+ }
1223
+ ),
1224
+ layers.map((layer, index) => /* @__PURE__ */ jsxs(
1225
+ MdxFramePanel,
1226
+ {
1227
+ className: "mdx-layer-row grid min-w-0 gap-4 px-4 py-4 transition-colors sm:px-5 md:grid-cols-[10rem_1fr] md:gap-5",
1228
+ children: [
1229
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-start gap-3", children: [
1230
+ /* @__PURE__ */ jsx("span", { className: "mdx-layer-badge flex size-8 shrink-0 items-center justify-center rounded-md font-mono text-xs tabular-nums", children: index + 1 }),
1231
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
1232
+ /* @__PURE__ */ jsx("p", { className: "mdx-layer-label font-mono text-xs tracking-wider uppercase", children: layer.label }),
1233
+ /* @__PURE__ */ jsx("h3", { className: "mdx-layer-title mt-1 text-sm leading-snug font-semibold text-wrap", children: layer.title })
1234
+ ] })
1235
+ ] }),
1236
+ /* @__PURE__ */ jsxs("div", { className: "grid min-w-0 gap-4 text-sm leading-relaxed sm:grid-cols-3", children: [
1237
+ layer.metaphor ? /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
1238
+ /* @__PURE__ */ jsx("p", { className: "mdx-layer-term text-xs font-medium", children: resolvedLabels.metaphor }),
1239
+ /* @__PURE__ */ jsx("div", { className: "mdx-layer-def mt-1.5 text-pretty", children: layer.metaphor })
1240
+ ] }) : null,
1241
+ layer.description ? /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
1242
+ /* @__PURE__ */ jsx("p", { className: "mdx-layer-term text-xs font-medium", children: resolvedLabels.description }),
1243
+ /* @__PURE__ */ jsx("div", { className: "mdx-layer-def mt-1.5 text-pretty", children: layer.description })
1244
+ ] }) : null,
1245
+ layer.constraint ? /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
1246
+ /* @__PURE__ */ jsx("p", { className: "mdx-layer-term text-xs font-medium", children: resolvedLabels.constraint }),
1247
+ /* @__PURE__ */ jsx("div", { className: "mdx-layer-def mt-1.5 text-pretty", children: layer.constraint })
1248
+ ] }) : null
1249
+ ] })
1250
+ ]
1251
+ },
1252
+ index
1253
+ ))
1254
+ ] });
1255
+ }
1256
+ var paragraphRows = [
1257
+ { key: "paragraph-1", width: "w-full" },
1258
+ { key: "paragraph-2", width: "w-11/12" },
1259
+ { key: "paragraph-3", width: "w-4/5" }
1260
+ ];
1261
+ var railRows = [
1262
+ { key: "rail-1", width: "w-8/12" },
1263
+ { key: "rail-2", width: "w-11/12" },
1264
+ { key: "rail-3", width: "w-7/12" }
1265
+ ];
1266
+ function SkeletonRows({ rows }) {
1267
+ return /* @__PURE__ */ jsx("div", { className: "space-y-2.5", children: rows.map((row) => /* @__PURE__ */ jsx(Skeleton, { className: `h-4 rounded-sm ${row.width}` }, row.key)) });
1268
+ }
1269
+ function MdxPageSkeleton({
1270
+ className,
1271
+ showInlineToc = true,
1272
+ showRail = true,
1273
+ variant = "docs"
1274
+ }) {
1275
+ const isLesson = variant === "lesson";
1276
+ return /* @__PURE__ */ jsx(
1277
+ "output",
1278
+ {
1279
+ "aria-label": "Loading page content",
1280
+ "aria-live": "polite",
1281
+ className: className ? `block ${className}` : "block",
1282
+ "data-slot": "mdx-page-skeleton",
1283
+ children: /* @__PURE__ */ jsxs(
1284
+ "div",
1285
+ {
1286
+ className: clsx(
1287
+ "grid w-full min-w-0 grid-cols-1",
1288
+ showRail && "2xl:grid-cols-[minmax(0,1fr)_12rem] 2xl:gap-8"
1289
+ ),
1290
+ children: [
1291
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
1292
+ /* @__PURE__ */ jsxs("header", { className: "space-y-4 pb-8", children: [
1293
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-40 rounded-sm" }),
1294
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-11/12 max-w-xl rounded-sm md:h-12" }),
1295
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-10/12 max-w-2xl rounded-sm" }),
1296
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1297
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-24 rounded-sm" }),
1298
+ isLesson ? /* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-16 rounded-sm" }) : null
1299
+ ] })
1300
+ ] }),
1301
+ showInlineToc ? /* @__PURE__ */ jsxs("div", { className: "mb-8 space-y-2", children: [
1302
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-32 rounded-sm" }),
1303
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-44 rounded-sm" })
1304
+ ] }) : null,
1305
+ /* @__PURE__ */ jsxs("div", { className: "space-y-8", children: [
1306
+ /* @__PURE__ */ jsxs("section", { className: "space-y-5", children: [
1307
+ /* @__PURE__ */ jsx(SkeletonRows, { rows: paragraphRows }),
1308
+ /* @__PURE__ */ jsx(Skeleton, { className: "aspect-[16/9] w-full rounded-lg" })
1309
+ ] }),
1310
+ /* @__PURE__ */ jsxs("section", { className: "space-y-4", children: [
1311
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-56 rounded-sm" }),
1312
+ /* @__PURE__ */ jsx(SkeletonRows, { rows: paragraphRows })
1313
+ ] })
1314
+ ] })
1315
+ ] }),
1316
+ showRail ? /* @__PURE__ */ jsx("aside", { "aria-hidden": true, className: "hidden pt-2 2xl:block", children: /* @__PURE__ */ jsxs("div", { className: "sticky top-6 space-y-3", children: [
1317
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-20 rounded-sm" }),
1318
+ /* @__PURE__ */ jsx(SkeletonRows, { rows: railRows })
1319
+ ] }) }) : null
1320
+ ]
1321
+ }
1322
+ )
1323
+ }
1324
+ );
1325
+ }
1326
+ var KIND_ICON = {
1327
+ image: ImageIcon,
1328
+ video: Film,
1329
+ diagram: LayoutTemplate
1330
+ };
1331
+ function MediaPlaceholder({
1332
+ label,
1333
+ kind = "image",
1334
+ aspectRatio = "16 / 9",
1335
+ className
1336
+ }) {
1337
+ const Icon = KIND_ICON[kind];
1338
+ return /* @__PURE__ */ jsxs(
1339
+ MdxFrameSurface,
1340
+ {
1341
+ className: clsx(
1342
+ "media-placeholder mdx-media-placeholder mx-auto flex w-full max-w-xl flex-col items-center justify-center gap-2.5 border-dashed p-6 text-center",
1343
+ className
1344
+ ),
1345
+ spacing: "media",
1346
+ style: { aspectRatio },
1347
+ children: [
1348
+ /* @__PURE__ */ jsx(Icon, { "aria-hidden": true, className: "mdx-media-placeholder-icon size-6" }),
1349
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-1", children: [
1350
+ /* @__PURE__ */ jsxs("span", { className: "mdx-media-placeholder-icon text-[0.6875rem] font-medium tracking-wide uppercase", children: [
1351
+ kind,
1352
+ " placeholder"
1353
+ ] }),
1354
+ label ? /* @__PURE__ */ jsx("span", { className: "mdx-text-secondary max-w-[85%] text-sm leading-relaxed", children: label }) : null
1355
+ ] })
1356
+ ]
1357
+ }
1358
+ );
1359
+ }
1360
+ var defaultMermaidDiagramLabels = {
1361
+ diagram: "Mermaid diagram",
1362
+ zoomOut: "Zoom diagram out",
1363
+ zoomOutTitle: "Zoom out",
1364
+ resetZoom: "Reset diagram zoom",
1365
+ resetZoomTitle: "Reset zoom",
1366
+ zoomIn: "Zoom diagram in",
1367
+ zoomInTitle: "Zoom in",
1368
+ rendering: "Rendering diagram...",
1369
+ errorMessage: "Unable to render diagram."
1370
+ };
1371
+ function drawInPaths(svg) {
1372
+ const durationMs = motionDurations.slow * 1e3;
1373
+ for (const path of svg.querySelectorAll("path")) {
1374
+ const total = path.getTotalLength?.();
1375
+ if (!total || Number.isNaN(total)) {
1376
+ continue;
1377
+ }
1378
+ path.style.transition = "none";
1379
+ path.style.strokeDasharray = String(total);
1380
+ path.style.strokeDashoffset = String(total);
1381
+ void path.getBoundingClientRect();
1382
+ path.style.transition = `stroke-dashoffset ${durationMs}ms var(--mdx-ease-standard, ease-out)`;
1383
+ path.style.strokeDashoffset = "0";
1384
+ }
1385
+ }
1386
+ var DEFAULT_ZOOM = 1;
1387
+ var MIN_ZOOM = 0.75;
1388
+ var MAX_ZOOM = 2;
1389
+ var ZOOM_STEP = 0.25;
1390
+ var INITIAL_RENDER_RESULT = {
1391
+ error: null,
1392
+ svg: null
1393
+ };
1394
+ function MermaidControlButton({
1395
+ children,
1396
+ disabled,
1397
+ label,
1398
+ onClick,
1399
+ tooltip
1400
+ }) {
1401
+ return /* @__PURE__ */ jsxs(Tooltip, { children: [
1402
+ /* @__PURE__ */ jsx(
1403
+ TooltipTrigger,
1404
+ {
1405
+ render: /* @__PURE__ */ jsx(
1406
+ Button,
1407
+ {
1408
+ "aria-label": label,
1409
+ disabled,
1410
+ onClick,
1411
+ size: "icon-xs",
1412
+ type: "button",
1413
+ variant: "ghost",
1414
+ children
1415
+ }
1416
+ )
1417
+ }
1418
+ ),
1419
+ /* @__PURE__ */ jsx(TooltipContent, { children: tooltip })
1420
+ ] });
1421
+ }
1422
+ function renderDiagram(chart, renderMermaidSVG) {
1423
+ try {
1424
+ return {
1425
+ error: null,
1426
+ svg: renderMermaidSVG(chart, {
1427
+ accent: "color-mix(in oklch, var(--a63-action-primary) 34%, var(--a63-text-primary) 66%)",
1428
+ bg: "var(--a63-surface-page)",
1429
+ border: "color-mix(in oklch, var(--a63-border-subtle) 78%, var(--a63-text-primary) 22%)",
1430
+ fg: "var(--a63-text-primary)",
1431
+ font: "var(--font-mono, ui-monospace, monospace)",
1432
+ componentSpacing: 32,
1433
+ layerSpacing: 44,
1434
+ line: "color-mix(in oklch, var(--a63-text-secondary) 74%, var(--a63-text-primary) 26%)",
1435
+ muted: "color-mix(in oklch, var(--a63-text-secondary) 82%, var(--a63-text-primary) 18%)",
1436
+ nodeSpacing: 32,
1437
+ padding: 16,
1438
+ surface: "color-mix(in oklch, var(--a63-surface-panel) 88%, var(--a63-text-primary) 12%)",
1439
+ transparent: true
1440
+ })
1441
+ };
1442
+ } catch (error) {
1443
+ return {
1444
+ error: error instanceof Error ? error : new Error("Unable to render Mermaid diagram."),
1445
+ svg: null
1446
+ };
1447
+ }
1448
+ }
1449
+ function MermaidDiagram({ animated = false, chart, labels, title }) {
1450
+ const resolvedLabels = { ...defaultMermaidDiagramLabels, ...labels };
1451
+ const reducedMotion = useMdxReducedMotion();
1452
+ const containerRef = useRef(null);
1453
+ const hasAnimatedRef = useRef(false);
1454
+ const dragStateRef = useRef(null);
1455
+ const [isDragging, setIsDragging] = useState(false);
1456
+ const [pan, setPan] = useState({ x: 0, y: 0 });
1457
+ const [renderResult, setRenderResult] = useState(INITIAL_RENDER_RESULT);
1458
+ const [zoom, setZoom] = useState(DEFAULT_ZOOM);
1459
+ const zoomPercent = Math.round(zoom * 100);
1460
+ const canZoomOut = zoom > MIN_ZOOM;
1461
+ const canZoomIn = zoom < MAX_ZOOM;
1462
+ const isRendered = Boolean(renderResult.svg);
1463
+ const canPan = zoom > DEFAULT_ZOOM && isRendered;
1464
+ const updateZoom = useCallback((direction) => {
1465
+ setZoom((currentZoom) => {
1466
+ const nextZoom = Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, currentZoom + direction * ZOOM_STEP));
1467
+ if (nextZoom <= DEFAULT_ZOOM) {
1468
+ setPan({ x: 0, y: 0 });
1469
+ }
1470
+ return nextZoom;
1471
+ });
1472
+ }, []);
1473
+ const resetZoom = useCallback(() => {
1474
+ setZoom(DEFAULT_ZOOM);
1475
+ setPan({ x: 0, y: 0 });
1476
+ }, []);
1477
+ const handlePointerDown = useCallback(
1478
+ (event) => {
1479
+ if (!canPan) {
1480
+ return;
1481
+ }
1482
+ event.currentTarget.setPointerCapture(event.pointerId);
1483
+ dragStateRef.current = {
1484
+ pointerId: event.pointerId,
1485
+ startPan: pan,
1486
+ startX: event.clientX,
1487
+ startY: event.clientY
1488
+ };
1489
+ setIsDragging(true);
1490
+ },
1491
+ [canPan, pan]
1492
+ );
1493
+ const handlePointerMove = useCallback((event) => {
1494
+ const dragState = dragStateRef.current;
1495
+ if (!dragState || dragState.pointerId !== event.pointerId) {
1496
+ return;
1497
+ }
1498
+ setPan({
1499
+ x: dragState.startPan.x + event.clientX - dragState.startX,
1500
+ y: dragState.startPan.y + event.clientY - dragState.startY
1501
+ });
1502
+ }, []);
1503
+ const stopDragging = useCallback((event) => {
1504
+ const dragState = dragStateRef.current;
1505
+ if (!dragState || dragState.pointerId !== event.pointerId) {
1506
+ return;
1507
+ }
1508
+ event.currentTarget.releasePointerCapture(event.pointerId);
1509
+ dragStateRef.current = null;
1510
+ setIsDragging(false);
1511
+ }, []);
1512
+ useEffect(() => {
1513
+ let cancelled = false;
1514
+ setRenderResult(INITIAL_RENDER_RESULT);
1515
+ const render = async () => {
1516
+ try {
1517
+ const { renderMermaidSVG } = await import('beautiful-mermaid');
1518
+ if (!cancelled) {
1519
+ setRenderResult(renderDiagram(chart, renderMermaidSVG));
1520
+ }
1521
+ } catch (error) {
1522
+ if (!cancelled) {
1523
+ setRenderResult({
1524
+ error: error instanceof Error ? error : new Error("Unable to load Mermaid renderer."),
1525
+ svg: null
1526
+ });
1527
+ }
1528
+ }
1529
+ };
1530
+ void render();
1531
+ return () => {
1532
+ cancelled = true;
1533
+ };
1534
+ }, [chart]);
1535
+ useLayoutEffect(() => {
1536
+ if (!containerRef.current) {
1537
+ return;
1538
+ }
1539
+ if (!renderResult.svg) {
1540
+ containerRef.current.innerHTML = "";
1541
+ return;
1542
+ }
1543
+ containerRef.current.innerHTML = renderResult.svg;
1544
+ const svgElement = containerRef.current.querySelector("svg");
1545
+ svgElement?.setAttribute("aria-label", title ?? resolvedLabels.diagram);
1546
+ svgElement?.setAttribute("role", "img");
1547
+ svgElement?.style.setProperty("height", "auto");
1548
+ svgElement?.style.setProperty("max-width", "none");
1549
+ svgElement?.style.setProperty("width", "100%");
1550
+ hasAnimatedRef.current = false;
1551
+ }, [renderResult.svg, title, resolvedLabels.diagram]);
1552
+ useEffect(() => {
1553
+ if (!animated || reducedMotion || !renderResult.svg) {
1554
+ return;
1555
+ }
1556
+ const container = containerRef.current;
1557
+ const svgElement = container?.querySelector("svg");
1558
+ if (!container || !svgElement) {
1559
+ return;
1560
+ }
1561
+ const run = () => {
1562
+ if (hasAnimatedRef.current) {
1563
+ return;
1564
+ }
1565
+ hasAnimatedRef.current = true;
1566
+ drawInPaths(svgElement);
1567
+ };
1568
+ if (typeof IntersectionObserver === "undefined") {
1569
+ run();
1570
+ return;
1571
+ }
1572
+ const observer = new IntersectionObserver(
1573
+ (entries) => {
1574
+ for (const entry of entries) {
1575
+ if (entry.isIntersecting) {
1576
+ run();
1577
+ observer.disconnect();
1578
+ break;
1579
+ }
1580
+ }
1581
+ },
1582
+ { threshold: 0.2 }
1583
+ );
1584
+ observer.observe(container);
1585
+ return () => {
1586
+ observer.disconnect();
1587
+ };
1588
+ }, [animated, reducedMotion, renderResult.svg]);
1589
+ return /* @__PURE__ */ jsxs(
1590
+ MdxFrameChrome,
1591
+ {
1592
+ className: clsx("mermaid-diagram not-mdx mdx-block min-w-0", mdxStyles.spacing.block),
1593
+ children: [
1594
+ /* @__PURE__ */ jsxs(MdxFrameHeader, { className: "flex-row items-center justify-between gap-3 px-3 py-2", children: [
1595
+ /* @__PURE__ */ jsx("div", { className: "min-w-0", children: title ? /* @__PURE__ */ jsx("p", { className: "mdx-mermaid-title truncate text-sm font-medium", children: title }) : /* @__PURE__ */ jsx("p", { className: "mdx-mermaid-diagram-label text-sm font-medium", children: resolvedLabels.diagram }) }),
1596
+ /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [
1597
+ /* @__PURE__ */ jsxs("span", { className: "mdx-mermaid-zoom w-11 text-center font-mono text-xs tabular-nums", children: [
1598
+ zoomPercent,
1599
+ "%"
1600
+ ] }),
1601
+ /* @__PURE__ */ jsx(
1602
+ MermaidControlButton,
1603
+ {
1604
+ disabled: !canZoomOut || !isRendered,
1605
+ label: resolvedLabels.zoomOut,
1606
+ onClick: () => updateZoom(-1),
1607
+ tooltip: resolvedLabels.zoomOutTitle,
1608
+ children: /* @__PURE__ */ jsx(ZoomOut, { "aria-hidden": true })
1609
+ }
1610
+ ),
1611
+ /* @__PURE__ */ jsx(
1612
+ MermaidControlButton,
1613
+ {
1614
+ disabled: zoom === DEFAULT_ZOOM || !isRendered,
1615
+ label: resolvedLabels.resetZoom,
1616
+ onClick: resetZoom,
1617
+ tooltip: resolvedLabels.resetZoomTitle,
1618
+ children: /* @__PURE__ */ jsx(RotateCcw, { "aria-hidden": true })
1619
+ }
1620
+ ),
1621
+ /* @__PURE__ */ jsx(
1622
+ MermaidControlButton,
1623
+ {
1624
+ disabled: !canZoomIn || !isRendered,
1625
+ label: resolvedLabels.zoomIn,
1626
+ onClick: () => updateZoom(1),
1627
+ tooltip: resolvedLabels.zoomInTitle,
1628
+ children: /* @__PURE__ */ jsx(ZoomIn, { "aria-hidden": true })
1629
+ }
1630
+ )
1631
+ ] })
1632
+ ] }),
1633
+ /* @__PURE__ */ jsx(MdxFramePanel, { className: "mdx-mermaid-panel overflow-hidden p-0", children: /* @__PURE__ */ jsxs("div", { className: "mdx-mermaid-scroll scrollbar-reveal overflow-x-auto", children: [
1634
+ /* @__PURE__ */ jsx(
1635
+ "div",
1636
+ {
1637
+ className: `mdx-mermaid-stage relative min-h-80 overflow-hidden outline-none select-none ${canPan ? isDragging ? "cursor-grabbing" : "cursor-grab" : ""}`,
1638
+ onPointerCancel: stopDragging,
1639
+ onPointerDown: handlePointerDown,
1640
+ onPointerMove: handlePointerMove,
1641
+ onPointerUp: stopDragging,
1642
+ children: /* @__PURE__ */ jsx(
1643
+ "div",
1644
+ {
1645
+ className: "mdx-mermaid-canvas flex min-h-80 items-center justify-center transition-transform duration-150 ease-out motion-reduce:transition-none [&_svg]:h-auto [&_svg]:max-w-none [&_svg_*]:select-none",
1646
+ style: {
1647
+ transform: `translate3d(${pan.x}px, ${pan.y}px, 0) scale(${zoom})`,
1648
+ transformOrigin: "center center"
1649
+ },
1650
+ children: /* @__PURE__ */ jsx("div", { className: "w-full max-w-[44rem]", ref: containerRef })
1651
+ }
1652
+ )
1653
+ }
1654
+ ),
1655
+ renderResult.error ? /* @__PURE__ */ jsxs("div", { className: "mdx-mermaid-error space-y-3 p-4", children: [
1656
+ /* @__PURE__ */ jsx("p", { className: "mdx-mermaid-error-text text-sm", children: resolvedLabels.errorMessage }),
1657
+ /* @__PURE__ */ jsx("pre", { className: "mdx-mermaid-error-pre overflow-x-auto p-4 text-sm", children: /* @__PURE__ */ jsx("code", { children: chart }) })
1658
+ ] }) : null,
1659
+ renderResult.svg || renderResult.error ? null : /* @__PURE__ */ jsx("output", { className: "mdx-mermaid-rendering block p-4 text-sm", children: resolvedLabels.rendering })
1660
+ ] }) })
1661
+ ]
1662
+ }
1663
+ );
1664
+ }
1665
+ function PageMeta({
1666
+ title,
1667
+ description,
1668
+ eyebrow,
1669
+ meta,
1670
+ children,
1671
+ className
1672
+ }) {
1673
+ const hasMetaRow = eyebrow || meta;
1674
+ return /* @__PURE__ */ jsxs(
1675
+ "header",
1676
+ {
1677
+ className: clsx(
1678
+ "not-mdx mdx-page-meta mx-auto mb-8 flex w-full max-w-xl flex-col items-start gap-4 text-start first:mt-0",
1679
+ className
1680
+ ),
1681
+ children: [
1682
+ hasMetaRow ? /* @__PURE__ */ jsxs("div", { className: "mdx-page-meta-eyebrow flex flex-wrap items-center justify-start gap-x-2 gap-y-1 font-mono text-xs tracking-wider", children: [
1683
+ eyebrow ? /* @__PURE__ */ jsx("span", { className: "uppercase", children: eyebrow }) : null,
1684
+ eyebrow && meta ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\xB7" }) : null,
1685
+ meta ? /* @__PURE__ */ jsx("span", { children: meta }) : null
1686
+ ] }) : null,
1687
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-start gap-3", children: [
1688
+ /* @__PURE__ */ jsx("h1", { className: "text-4xl font-bold tracking-tight md:text-5xl", children: title }),
1689
+ description ? /* @__PURE__ */ jsx("p", { className: "mdx-text-secondary text-lg leading-relaxed", children: description }) : null
1690
+ ] }),
1691
+ children
1692
+ ]
1693
+ }
1694
+ );
1695
+ }
1696
+ var SLUG_CLEANUP_PATTERN = /[^a-z0-9]+/g;
1697
+ var EDGE_DASH_PATTERN = /(^-|-$)/g;
1698
+ var DEFAULT_ACTIVE_OFFSET = 120;
1699
+ var DEFAULT_CONTAINER_SELECTOR = "[data-mdx-scroll-root], #learn-main, main";
1700
+ var DEFAULT_HEADING_SELECTOR = "[data-mdx-content] h2, [data-mdx-content] h3, article h2, article h3";
1701
+ var DEFAULT_INLINE_POSITION_CLASS_NAME = "fixed top-[calc(--spacing(14)+--spacing(3))] right-4 z-30 xl:hidden";
1702
+ var DEFAULT_SCROLL_OFFSET = 96;
1703
+ var DEFAULT_SMOOTH_SCROLL_DURATION = 420;
1704
+ var activeScrollAnimations = /* @__PURE__ */ new WeakMap();
1705
+ function slugify(value) {
1706
+ return value.toLowerCase().trim().replace(SLUG_CLEANUP_PATTERN, "-").replace(EDGE_DASH_PATTERN, "") || "section";
1707
+ }
1708
+ function createUniqueId(baseId, usedIds) {
1709
+ let nextId = baseId;
1710
+ let suffix = 2;
1711
+ while (usedIds.has(nextId)) {
1712
+ nextId = `${baseId}-${suffix}`;
1713
+ suffix += 1;
1714
+ }
1715
+ usedIds.add(nextId);
1716
+ return nextId;
1717
+ }
1718
+ function buildTocItems(headings) {
1719
+ const usedIds = /* @__PURE__ */ new Set();
1720
+ const nextItems = [];
1721
+ for (const heading of headings) {
1722
+ const title = heading.textContent?.trim();
1723
+ if (!title) {
1724
+ continue;
1725
+ }
1726
+ const baseId = heading.id || slugify(title);
1727
+ const id = createUniqueId(baseId, usedIds);
1728
+ heading.id = id;
1729
+ nextItems.push({
1730
+ depth: heading.tagName === "H3" ? 3 : 2,
1731
+ id,
1732
+ title
1733
+ });
1734
+ }
1735
+ return nextItems;
1736
+ }
1737
+ function getLinkClass(item, variant) {
1738
+ const compactList = variant === "embedded" || variant === "inline";
1739
+ return clsx(
1740
+ "mdx-toc-link relative outline-none transition-colors duration-150",
1741
+ compactList && "mdx-toc-link-inline flex min-h-8 items-center px-2 py-1.5 text-sm",
1742
+ variant === "rail" && "mdx-toc-link-rail block py-px pe-2 text-[0.8125rem] leading-[1.0625rem]",
1743
+ compactList && item.depth === 3 && "ps-5",
1744
+ variant === "rail" && item.depth === 3 && "ps-3 text-xs leading-4"
1745
+ );
1746
+ }
1747
+ function getContentHeadings(contentRoot, headingSelector) {
1748
+ return Array.from(contentRoot.querySelectorAll(headingSelector)).filter(
1749
+ (heading) => !heading.closest("[data-page-nav], [data-toc-exclude]")
1750
+ );
1751
+ }
1752
+ function areTocItemsEqual(currentItems, nextItems) {
1753
+ if (currentItems.length !== nextItems.length) {
1754
+ return false;
1755
+ }
1756
+ return currentItems.every((item, index) => {
1757
+ const nextItem = nextItems.at(index);
1758
+ return item.depth === nextItem?.depth && item.id === nextItem.id && item.title === nextItem.title;
1759
+ });
1760
+ }
1761
+ function getPreferredElement(selector) {
1762
+ const selectors = selector.split(",").map((part) => part.trim()).filter(Boolean);
1763
+ for (const selectorPart of selectors) {
1764
+ const element = document.querySelector(selectorPart);
1765
+ if (element) {
1766
+ return element;
1767
+ }
1768
+ }
1769
+ return null;
1770
+ }
1771
+ function easeOutCubic(progress) {
1772
+ return 1 - (1 - progress) ** 3;
1773
+ }
1774
+ function setElementScrollTop(element, top) {
1775
+ element.scrollTop = top;
1776
+ }
1777
+ function scrollElementTo(element, top, smooth, duration) {
1778
+ const targetTop = Math.max(0, Math.min(top, element.scrollHeight - element.clientHeight));
1779
+ const activeAnimation = activeScrollAnimations.get(element);
1780
+ if (activeAnimation) {
1781
+ window.cancelAnimationFrame(activeAnimation);
1782
+ activeScrollAnimations.delete(element);
1783
+ }
1784
+ if (!smooth) {
1785
+ setElementScrollTop(element, targetTop);
1786
+ return;
1787
+ }
1788
+ const startTop = element.scrollTop;
1789
+ const distance = targetTop - startTop;
1790
+ if (Math.abs(distance) < 1) {
1791
+ return;
1792
+ }
1793
+ const startTime = performance.now();
1794
+ const step = (time) => {
1795
+ const elapsed = time - startTime;
1796
+ const progress = Math.min(elapsed / duration, 1);
1797
+ const eased = easeOutCubic(progress);
1798
+ setElementScrollTop(element, startTop + distance * eased);
1799
+ if (progress < 1) {
1800
+ activeScrollAnimations.set(element, window.requestAnimationFrame(step));
1801
+ } else {
1802
+ activeScrollAnimations.delete(element);
1803
+ }
1804
+ };
1805
+ activeScrollAnimations.set(element, window.requestAnimationFrame(step));
1806
+ }
1807
+ function PageTableOfContents({
1808
+ activeOffset = DEFAULT_ACTIVE_OFFSET,
1809
+ className,
1810
+ containerSelector = DEFAULT_CONTAINER_SELECTOR,
1811
+ headingSelector = DEFAULT_HEADING_SELECTOR,
1812
+ inlinePositionClassName = DEFAULT_INLINE_POSITION_CLASS_NAME,
1813
+ label = "On this page",
1814
+ onActiveLabelChange,
1815
+ onNavigate,
1816
+ scrollOffset = DEFAULT_SCROLL_OFFSET,
1817
+ showProgress = true,
1818
+ smoothScrollDuration = DEFAULT_SMOOTH_SCROLL_DURATION,
1819
+ variant = "rail"
1820
+ }) {
1821
+ const [items, setItems] = useState([]);
1822
+ const [activeId, setActiveId] = useState(null);
1823
+ const [menuOpen, setMenuOpen] = useState(false);
1824
+ const [portalRoot, setPortalRoot] = useState(null);
1825
+ const [scrollProgress, setScrollProgress] = useState(0);
1826
+ const activeIdRef = useRef(null);
1827
+ const menuRef = useRef(null);
1828
+ const activeItem = items.find((item) => item.id === activeId);
1829
+ const activeLabel = activeItem?.title ?? label;
1830
+ const reducedMotion = useReducedMotion();
1831
+ const itemsRef = useRef([]);
1832
+ const scrollProgressRef = useRef(0);
1833
+ useEffect(() => {
1834
+ onActiveLabelChange?.(activeLabel);
1835
+ }, [activeLabel, onActiveLabelChange]);
1836
+ const handleItemClick = (event, item) => {
1837
+ const target = document.getElementById(item.id);
1838
+ if (!target) {
1839
+ return;
1840
+ }
1841
+ event.preventDefault();
1842
+ activeIdRef.current = item.id;
1843
+ setActiveId(item.id);
1844
+ setMenuOpen(false);
1845
+ onNavigate?.();
1846
+ const contentRoot = getPreferredElement(containerSelector);
1847
+ if (!(contentRoot instanceof HTMLElement)) {
1848
+ target.scrollIntoView({
1849
+ behavior: reducedMotion ? "auto" : "smooth",
1850
+ block: "start"
1851
+ });
1852
+ return;
1853
+ }
1854
+ const targetTop = target.getBoundingClientRect().top;
1855
+ const containerTop = contentRoot.getBoundingClientRect().top;
1856
+ const scrollTop = targetTop - containerTop + contentRoot.scrollTop - scrollOffset;
1857
+ scrollElementTo(contentRoot, scrollTop, !reducedMotion, smoothScrollDuration);
1858
+ };
1859
+ useEffect(() => {
1860
+ setPortalRoot(document.body);
1861
+ }, []);
1862
+ useEffect(() => {
1863
+ const contentRoot = getPreferredElement(containerSelector);
1864
+ if (!contentRoot) {
1865
+ return;
1866
+ }
1867
+ let headings = [];
1868
+ let nextItems = [];
1869
+ let updateFrame = 0;
1870
+ const updateScrollState = () => {
1871
+ const totalScroll = contentRoot.scrollHeight - contentRoot.clientHeight;
1872
+ const progress = totalScroll <= 0 ? 0 : Math.min(contentRoot.scrollTop / totalScroll * 100, 100);
1873
+ if (Math.abs(scrollProgressRef.current - progress) > 0.1) {
1874
+ scrollProgressRef.current = progress;
1875
+ setScrollProgress(progress);
1876
+ }
1877
+ if (nextItems.length === 0) {
1878
+ if (activeIdRef.current !== null) {
1879
+ activeIdRef.current = null;
1880
+ setActiveId(null);
1881
+ }
1882
+ return;
1883
+ }
1884
+ const activeLine = contentRoot.getBoundingClientRect().top + activeOffset;
1885
+ let nextActiveId = nextItems.at(0)?.id ?? null;
1886
+ for (const heading of headings) {
1887
+ if (heading.getBoundingClientRect().top > activeLine) {
1888
+ break;
1889
+ }
1890
+ nextActiveId = heading.id;
1891
+ }
1892
+ if (activeIdRef.current !== nextActiveId) {
1893
+ activeIdRef.current = nextActiveId;
1894
+ setActiveId(nextActiveId);
1895
+ }
1896
+ };
1897
+ const scheduleScrollStateUpdate = () => {
1898
+ if (updateFrame) {
1899
+ return;
1900
+ }
1901
+ updateFrame = window.requestAnimationFrame(() => {
1902
+ updateFrame = 0;
1903
+ updateScrollState();
1904
+ });
1905
+ };
1906
+ const refreshItems = () => {
1907
+ headings = getContentHeadings(contentRoot, headingSelector);
1908
+ nextItems = buildTocItems(headings);
1909
+ if (!areTocItemsEqual(itemsRef.current, nextItems)) {
1910
+ itemsRef.current = nextItems;
1911
+ setItems(nextItems);
1912
+ }
1913
+ scheduleScrollStateUpdate();
1914
+ };
1915
+ const observer = new MutationObserver(refreshItems);
1916
+ refreshItems();
1917
+ observer.observe(contentRoot, { childList: true, subtree: true });
1918
+ contentRoot.addEventListener("scroll", scheduleScrollStateUpdate, { passive: true });
1919
+ window.addEventListener("resize", scheduleScrollStateUpdate);
1920
+ window.addEventListener("hashchange", scheduleScrollStateUpdate);
1921
+ return () => {
1922
+ if (updateFrame) {
1923
+ window.cancelAnimationFrame(updateFrame);
1924
+ }
1925
+ observer.disconnect();
1926
+ contentRoot.removeEventListener("scroll", scheduleScrollStateUpdate);
1927
+ window.removeEventListener("resize", scheduleScrollStateUpdate);
1928
+ window.removeEventListener("hashchange", scheduleScrollStateUpdate);
1929
+ };
1930
+ }, [activeOffset, containerSelector, headingSelector]);
1931
+ useEffect(() => {
1932
+ if (!menuOpen || variant !== "inline") {
1933
+ return;
1934
+ }
1935
+ const handlePointerDown = (event) => {
1936
+ if (menuRef.current?.contains(event.target)) {
1937
+ return;
1938
+ }
1939
+ setMenuOpen(false);
1940
+ };
1941
+ const handleKeyDown = (event) => {
1942
+ if (event.key === "Escape") {
1943
+ setMenuOpen(false);
1944
+ }
1945
+ };
1946
+ document.addEventListener("pointerdown", handlePointerDown);
1947
+ document.addEventListener("keydown", handleKeyDown);
1948
+ return () => {
1949
+ document.removeEventListener("pointerdown", handlePointerDown);
1950
+ document.removeEventListener("keydown", handleKeyDown);
1951
+ };
1952
+ }, [menuOpen, variant]);
1953
+ if (items.length === 0) {
1954
+ return null;
1955
+ }
1956
+ if (variant === "embedded") {
1957
+ return /* @__PURE__ */ jsx("nav", { "aria-label": label, className: clsx("flex flex-col gap-1", className), children: items.map((item) => /* @__PURE__ */ jsx(
1958
+ "a",
1959
+ {
1960
+ "aria-current": item.id === activeId ? "location" : void 0,
1961
+ className: getLinkClass(item, variant),
1962
+ "data-active": item.id === activeId,
1963
+ "data-depth": item.depth,
1964
+ href: `#${item.id}`,
1965
+ onClick: (event) => handleItemClick(event, item),
1966
+ children: item.title
1967
+ },
1968
+ item.id
1969
+ )) });
1970
+ }
1971
+ if (variant === "menu") {
1972
+ return /* @__PURE__ */ jsxs(DropdownMenu, { onOpenChange: setMenuOpen, open: menuOpen, children: [
1973
+ /* @__PURE__ */ jsxs(
1974
+ DropdownMenuTrigger,
1975
+ {
1976
+ render: /* @__PURE__ */ jsx(
1977
+ Button,
1978
+ {
1979
+ "aria-label": `Open ${label.toLowerCase()}`,
1980
+ className,
1981
+ size: "sm",
1982
+ type: "button",
1983
+ variant: "outline"
1984
+ }
1985
+ ),
1986
+ children: [
1987
+ /* @__PURE__ */ jsx(ListTree, { "aria-hidden": true, className: "size-4" }),
1988
+ label
1989
+ ]
1990
+ }
1991
+ ),
1992
+ /* @__PURE__ */ jsx(DropdownMenuContent, { align: "end", className: "max-h-72 min-w-56 overflow-y-auto", children: items.map((item) => /* @__PURE__ */ jsx(
1993
+ DropdownMenuItem,
1994
+ {
1995
+ render: /* @__PURE__ */ jsx(
1996
+ "a",
1997
+ {
1998
+ "aria-current": item.id === activeId ? "location" : void 0,
1999
+ "data-depth": item.depth,
2000
+ href: `#${item.id}`,
2001
+ onClick: (event) => handleItemClick(event, item),
2002
+ children: /* @__PURE__ */ jsx("span", { className: clsx(item.depth === 3 && "ps-3"), children: item.title })
2003
+ }
2004
+ )
2005
+ },
2006
+ item.id
2007
+ )) })
2008
+ ] });
2009
+ }
2010
+ if (variant === "inline") {
2011
+ if (!portalRoot) {
2012
+ return null;
2013
+ }
2014
+ return createPortal(
2015
+ /* @__PURE__ */ jsx(
2016
+ "div",
2017
+ {
2018
+ className: clsx("pointer-events-none", inlinePositionClassName, className),
2019
+ "data-page-nav": "",
2020
+ ref: menuRef,
2021
+ children: /* @__PURE__ */ jsxs(
2022
+ ConnectedPanel,
2023
+ {
2024
+ className: "pointer-events-auto",
2025
+ collapsedWidth: 192,
2026
+ expandedWidth: 256,
2027
+ onOpenChange: setMenuOpen,
2028
+ open: menuOpen,
2029
+ children: [
2030
+ /* @__PURE__ */ jsx(
2031
+ ConnectedPanelTrigger,
2032
+ {
2033
+ "aria-label": "Open page navigation",
2034
+ className: "h-11 md:h-7",
2035
+ icon: /* @__PURE__ */ jsx(ListTree, { "aria-hidden": true, className: "mdx-toc-icon size-4 shrink-0" }),
2036
+ summary: activeLabel
2037
+ }
2038
+ ),
2039
+ showProgress ? /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute right-0 bottom-0 left-0 h-px bg-transparent", children: /* @__PURE__ */ jsx(
2040
+ motion.span,
2041
+ {
2042
+ animate: { scaleX: scrollProgress / 100 },
2043
+ className: "mdx-toc-progress block h-full origin-left",
2044
+ initial: false,
2045
+ transition: reducedMotion ? { duration: 0 } : { duration: 0.18 }
2046
+ }
2047
+ ) }) : null,
2048
+ /* @__PURE__ */ jsx(ConnectedPanelContent, { children: /* @__PURE__ */ jsx(ConnectedPanelBody, { className: "p-2", children: /* @__PURE__ */ jsx("nav", { "aria-label": label, className: "flex flex-col gap-1", children: /* @__PURE__ */ jsx("div", { className: "scrollbar-reveal max-h-64 overflow-y-auto overscroll-contain", children: items.map((item) => /* @__PURE__ */ jsx(
2049
+ "a",
2050
+ {
2051
+ "aria-current": item.id === activeId ? "location" : void 0,
2052
+ className: getLinkClass(item, variant),
2053
+ "data-active": item.id === activeId,
2054
+ "data-depth": item.depth,
2055
+ href: `#${item.id}`,
2056
+ onClick: (event) => handleItemClick(event, item),
2057
+ children: item.title
2058
+ },
2059
+ item.id
2060
+ )) }) }) }) })
2061
+ ]
2062
+ }
2063
+ )
2064
+ }
2065
+ ),
2066
+ portalRoot
2067
+ );
2068
+ }
2069
+ return /* @__PURE__ */ jsx(
2070
+ "aside",
2071
+ {
2072
+ className: clsx(
2073
+ "not-mdx mdx-page-nav sticky top-8 hidden max-h-[calc(100dvh-4rem)] overflow-y-auto xl:block",
2074
+ className
2075
+ ),
2076
+ children: /* @__PURE__ */ jsxs("nav", { "aria-label": label, className: "flex flex-col gap-2", "data-page-nav": "", children: [
2077
+ /* @__PURE__ */ jsxs("p", { className: "mdx-toc-title flex items-center gap-1.5 text-[0.8125rem] leading-[1.0625rem] font-medium", children: [
2078
+ /* @__PURE__ */ jsx(ListTree, { "aria-hidden": true, className: "mdx-toc-icon size-3" }),
2079
+ label
2080
+ ] }),
2081
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: items.map((item) => /* @__PURE__ */ jsx(
2082
+ "a",
2083
+ {
2084
+ "aria-current": item.id === activeId ? "location" : void 0,
2085
+ className: getLinkClass(item, variant),
2086
+ "data-active": item.id === activeId,
2087
+ "data-depth": item.depth,
2088
+ href: `#${item.id}`,
2089
+ onClick: (event) => handleItemClick(event, item),
2090
+ children: item.title
2091
+ },
2092
+ item.id
2093
+ )) })
2094
+ ] })
2095
+ }
2096
+ );
2097
+ }
2098
+ function getHostname(url) {
2099
+ try {
2100
+ return new URL(url).hostname.replace(/^www\./, "");
2101
+ } catch {
2102
+ return url;
2103
+ }
2104
+ }
2105
+ function getFaviconUrl(url) {
2106
+ try {
2107
+ const { hostname } = new URL(url);
2108
+ return `https://www.google.com/s2/favicons?domain=${hostname}&sz=64`;
2109
+ } catch {
2110
+ return null;
2111
+ }
2112
+ }
2113
+ function ResourceRow({ item }) {
2114
+ const favicon = useMemo(() => getFaviconUrl(item.url), [item.url]);
2115
+ const hostname = useMemo(() => getHostname(item.url), [item.url]);
2116
+ const faviconRef = useRef(null);
2117
+ useEffect(() => {
2118
+ const img = faviconRef.current;
2119
+ if (!img) return;
2120
+ const hide = () => {
2121
+ img.style.display = "none";
2122
+ };
2123
+ img.addEventListener("error", hide);
2124
+ return () => img.removeEventListener("error", hide);
2125
+ }, []);
2126
+ return /* @__PURE__ */ jsx("li", { className: "mdx-resource-item min-w-0", children: /* @__PURE__ */ jsxs(
2127
+ "a",
2128
+ {
2129
+ className: "group/resource mdx-resource-row grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-3 no-underline transition-[background-color,color,box-shadow]",
2130
+ href: item.url,
2131
+ rel: "noopener noreferrer",
2132
+ target: "_blank",
2133
+ children: [
2134
+ favicon ? /* @__PURE__ */ jsx(
2135
+ "img",
2136
+ {
2137
+ alt: "",
2138
+ className: "mdx-resource-favicon shrink-0",
2139
+ height: 20,
2140
+ loading: "lazy",
2141
+ ref: faviconRef,
2142
+ src: favicon,
2143
+ width: 20
2144
+ }
2145
+ ) : /* @__PURE__ */ jsx("span", { className: "mdx-resource-favicon-fallback shrink-0" }),
2146
+ /* @__PURE__ */ jsxs("span", { className: "min-w-0", children: [
2147
+ /* @__PURE__ */ jsxs("span", { className: "mdx-resource-title-line flex min-w-0 items-center gap-1.5", children: [
2148
+ /* @__PURE__ */ jsx("span", { className: "mdx-resource-name truncate text-sm leading-snug font-medium", children: item.name }),
2149
+ /* @__PURE__ */ jsx(ArrowUpRight, { className: "mdx-resource-arrow size-3.5 shrink-0" })
2150
+ ] }),
2151
+ /* @__PURE__ */ jsx("span", { className: "mdx-resource-note truncate text-xs", children: item.note ? `${item.note} \xB7 ${hostname}` : hostname })
2152
+ ] })
2153
+ ]
2154
+ }
2155
+ ) });
2156
+ }
2157
+ function ResourceList({ items, className }) {
2158
+ if (!items || items.length === 0) {
2159
+ return null;
2160
+ }
2161
+ return /* @__PURE__ */ jsx(
2162
+ MdxFrame,
2163
+ {
2164
+ "aria-label": "External resources",
2165
+ as: "aside",
2166
+ className: clsx("resource-list", className),
2167
+ frameClassName: "mdx-resource-list-frame",
2168
+ spacing: "block",
2169
+ width: "wide",
2170
+ children: /* @__PURE__ */ jsx(MdxFramePanel, { className: "mdx-resource-list-panel overflow-hidden p-0", children: /* @__PURE__ */ jsx("ul", { className: "mdx-resource-list-grid", children: items.map((item) => /* @__PURE__ */ jsx(ResourceRow, { item }, item.url)) }) })
2171
+ }
2172
+ );
2173
+ }
2174
+ function resolveActiveStepIndex(entries) {
2175
+ let best = 0;
2176
+ let bestRatio = -1;
2177
+ for (const entry of entries) {
2178
+ if (entry.ratio > bestRatio || entry.ratio === bestRatio && entry.index < best) {
2179
+ best = entry.index;
2180
+ bestRatio = entry.ratio;
2181
+ }
2182
+ }
2183
+ return best;
2184
+ }
2185
+ function ScrollStageStep(_props) {
2186
+ return null;
2187
+ }
2188
+ function resolveSteps(children) {
2189
+ const steps = [];
2190
+ Children.forEach(children, (child, i) => {
2191
+ if (!isValidElement(child) || child.type !== ScrollStageStep) return;
2192
+ const {
2193
+ media,
2194
+ children: prose,
2195
+ className
2196
+ } = child.props;
2197
+ steps.push({ media, children: prose, className, key: String(child.key ?? i) });
2198
+ });
2199
+ return steps;
2200
+ }
2201
+ var proseClassName = "mdx-scroll-stage-prose text-pretty leading-relaxed [&>*:first-child]:mt-0 [&>*:last-child]:mb-0";
2202
+ var mediaWrapperClassName = "mdx-scroll-stage-media overflow-hidden p-0";
2203
+ function StackedStage({ steps, className }) {
2204
+ return /* @__PURE__ */ jsx("div", { className: clsx("not-mdx mdx-block", mdxStyles.spacing.block, className), children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-10", children: steps.map((step) => /* @__PURE__ */ jsxs("div", { className: step.className, children: [
2205
+ /* @__PURE__ */ jsx(MdxFramePanel, { className: mediaWrapperClassName, children: step.media }),
2206
+ /* @__PURE__ */ jsx("div", { className: clsx("mt-4", proseClassName), children: step.children })
2207
+ ] }, step.key)) }) });
2208
+ }
2209
+ function PinnedStage({ steps, className }) {
2210
+ const [activeIndex, setActiveIndex] = useState(0);
2211
+ const stepRefs = useRef([]);
2212
+ useEffect(() => {
2213
+ const nodes = stepRefs.current.filter((node) => node !== null);
2214
+ if (nodes.length === 0) return;
2215
+ const ratios = /* @__PURE__ */ new Map();
2216
+ const observer = new IntersectionObserver(
2217
+ (observed) => {
2218
+ for (const entry of observed) {
2219
+ const index = Number(entry.target.getAttribute("data-step-index"));
2220
+ ratios.set(index, entry.intersectionRatio);
2221
+ }
2222
+ const entries = Array.from(ratios, ([index, ratio]) => ({ index, ratio }));
2223
+ setActiveIndex(resolveActiveStepIndex(entries));
2224
+ },
2225
+ { rootMargin: "-45% 0px -45% 0px", threshold: [0, 0.25, 0.5, 0.75, 1] }
2226
+ );
2227
+ for (const node of nodes) observer.observe(node);
2228
+ return () => observer.disconnect();
2229
+ }, []);
2230
+ const activeStep = steps[activeIndex] ?? steps[0];
2231
+ return /* @__PURE__ */ jsxs("div", { className: clsx("not-mdx mdx-block", mdxStyles.spacing.block, className), children: [
2232
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-10 lg:hidden", children: steps.map((step) => /* @__PURE__ */ jsxs("div", { className: step.className, children: [
2233
+ /* @__PURE__ */ jsx(MdxFramePanel, { className: mediaWrapperClassName, children: step.media }),
2234
+ /* @__PURE__ */ jsx("div", { className: clsx("mt-4", proseClassName), children: step.children })
2235
+ ] }, step.key)) }),
2236
+ /* @__PURE__ */ jsxs("div", { className: "hidden gap-10 lg:grid lg:grid-cols-2", children: [
2237
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: steps.map((step, index) => /* @__PURE__ */ jsx(
2238
+ "div",
2239
+ {
2240
+ className: clsx("flex min-h-[70vh] flex-col justify-center", step.className),
2241
+ "data-step-index": index,
2242
+ ref: (node) => {
2243
+ stepRefs.current[index] = node;
2244
+ },
2245
+ children: /* @__PURE__ */ jsx("div", { className: proseClassName, children: step.children })
2246
+ },
2247
+ step.key
2248
+ )) }),
2249
+ /* @__PURE__ */ jsx("div", { className: "hidden lg:block", children: /* @__PURE__ */ jsx("div", { className: "sticky top-24 flex h-[70vh] items-center", children: /* @__PURE__ */ jsx(MdxFramePanel, { className: clsx("relative w-full", mediaWrapperClassName), children: /* @__PURE__ */ jsx(AnimatePresence, { initial: false, mode: "sync", children: /* @__PURE__ */ jsx(
2250
+ motion.div,
2251
+ {
2252
+ animate: { opacity: 1 },
2253
+ className: "w-full",
2254
+ exit: { opacity: 0 },
2255
+ initial: { opacity: 0 },
2256
+ transition: {
2257
+ duration: motionDurations.base,
2258
+ ease: motionEasings.standard
2259
+ },
2260
+ children: activeStep?.media
2261
+ },
2262
+ activeStep?.key
2263
+ ) }) }) }) })
2264
+ ] })
2265
+ ] });
2266
+ }
2267
+ function ScrollStage({ children, className }) {
2268
+ const reduced = useMdxReducedMotion();
2269
+ const steps = resolveSteps(children);
2270
+ if (reduced) {
2271
+ return /* @__PURE__ */ jsx(StackedStage, { className, steps });
2272
+ }
2273
+ return /* @__PURE__ */ jsx(PinnedStage, { className, steps });
2274
+ }
2275
+ ScrollStage.Step = ScrollStageStep;
2276
+ var trendClassName = {
2277
+ up: "mdx-stat-card-change-up",
2278
+ down: "mdx-stat-card-change-down",
2279
+ neutral: "mdx-stat-card-change-neutral"
2280
+ };
2281
+ function StatCard({ label, value, change, trend = "neutral", className }) {
2282
+ return /* @__PURE__ */ jsx(Card, { className: clsx("mdx-stat-card not-mdx", className), children: /* @__PURE__ */ jsxs(CardContent, { className: "flex flex-col gap-1", children: [
2283
+ /* @__PURE__ */ jsx("p", { className: "mdx-stat-card-label text-sm font-medium", children: label }),
2284
+ /* @__PURE__ */ jsx("p", { className: "mdx-stat-card-value text-2xl leading-tight font-semibold tabular-nums", children: value }),
2285
+ change != null ? /* @__PURE__ */ jsx(
2286
+ "p",
2287
+ {
2288
+ className: clsx("mdx-stat-card-change text-sm font-medium", trendClassName[trend]),
2289
+ "data-testid": "stat-card-change",
2290
+ children: change
2291
+ }
2292
+ ) : null
2293
+ ] }) });
2294
+ }
2295
+ function StatGrid({ children, className }) {
2296
+ return /* @__PURE__ */ jsx(
2297
+ "div",
2298
+ {
2299
+ className: clsx(
2300
+ "not-mdx mdx-block grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3",
2301
+ mdxStyles.spacing.block,
2302
+ className
2303
+ ),
2304
+ "data-mdx-width": "wide",
2305
+ children
2306
+ }
2307
+ );
2308
+ }
2309
+ function SequenceBlock({ children, className }) {
2310
+ return /* @__PURE__ */ jsx(MdxFrame, { className, children: /* @__PURE__ */ jsx(MdxFramePanel, { children: /* @__PURE__ */ jsx("ol", { className: "grid gap-0", children }) }) });
2311
+ }
2312
+ function SequenceBody({ children, className, title }) {
2313
+ return /* @__PURE__ */ jsxs("div", { className: clsx("min-w-0 pb-6 group-last:pb-0", className), children: [
2314
+ /* @__PURE__ */ jsx("h3", { className: "mdx-steps-title text-base leading-snug font-semibold text-wrap", children: title }),
2315
+ /* @__PURE__ */ jsx("div", { className: "mdx-steps-body mt-1.5 text-sm leading-relaxed text-pretty [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", children })
2316
+ ] });
2317
+ }
2318
+ function SequenceSpine() {
2319
+ return /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "mdx-steps-spine mt-1 w-px flex-1 group-last:hidden" });
2320
+ }
2321
+ function StepsStep({ title, children, className, index = 1 }) {
2322
+ return /* @__PURE__ */ jsxs("li", { className: clsx("group relative grid grid-cols-[2.25rem_1fr] gap-4", className), children: [
2323
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
2324
+ /* @__PURE__ */ jsx(
2325
+ "span",
2326
+ {
2327
+ className: "mdx-steps-number z-10 flex size-8 shrink-0 items-center justify-center rounded-full font-mono text-sm tabular-nums",
2328
+ "data-testid": "steps-step-number",
2329
+ children: index
2330
+ }
2331
+ ),
2332
+ /* @__PURE__ */ jsx(SequenceSpine, {})
2333
+ ] }),
2334
+ /* @__PURE__ */ jsx(SequenceBody, { title, children })
2335
+ ] });
2336
+ }
2337
+ function Steps({ children, className }) {
2338
+ const { nodes: numbered } = Children.toArray(children).reduce(
2339
+ (acc, child) => {
2340
+ if (!isValidElement(child) || child.type !== StepsStep) {
2341
+ return { nodes: [...acc.nodes, child], step: acc.step };
2342
+ }
2343
+ const nextStep = acc.step + 1;
2344
+ return {
2345
+ nodes: [
2346
+ ...acc.nodes,
2347
+ cloneElement(child, { index: nextStep })
2348
+ ],
2349
+ step: nextStep
2350
+ };
2351
+ },
2352
+ { nodes: [], step: 0 }
2353
+ );
2354
+ return /* @__PURE__ */ jsx(SequenceBlock, { className, children: numbered });
2355
+ }
2356
+ Steps.Step = StepsStep;
2357
+ function Tabs({ className, ...props }) {
2358
+ return /* @__PURE__ */ jsx(Tabs$1, { className: clsx("not-mdx mdx-block", mdxStyles.spacing.block, className), ...props });
2359
+ }
2360
+ Tabs.List = TabsList;
2361
+ Tabs.Tab = TabsTab;
2362
+ Tabs.Panel = TabsPanel;
2363
+ function TimelineItem({ date, title, children, className }) {
2364
+ return /* @__PURE__ */ jsxs(
2365
+ "li",
2366
+ {
2367
+ className: clsx(
2368
+ "group relative grid grid-cols-[auto_1.25rem_1fr] gap-x-3 sm:grid-cols-[6rem_1.25rem_1fr] sm:gap-x-4",
2369
+ className
2370
+ ),
2371
+ children: [
2372
+ /* @__PURE__ */ jsx("div", { className: "mdx-timeline-date pt-0.5 font-mono text-xs tracking-wider uppercase tabular-nums sm:text-sm", children: date }),
2373
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
2374
+ /* @__PURE__ */ jsx(
2375
+ "span",
2376
+ {
2377
+ className: "mdx-timeline-dot z-10 mt-1 size-3 shrink-0 rounded-full border-2",
2378
+ "data-testid": "timeline-item-dot"
2379
+ }
2380
+ ),
2381
+ /* @__PURE__ */ jsx(SequenceSpine, {})
2382
+ ] }),
2383
+ /* @__PURE__ */ jsx(SequenceBody, { title, children })
2384
+ ]
2385
+ }
2386
+ );
2387
+ }
2388
+ function Timeline({ children, className }) {
2389
+ return /* @__PURE__ */ jsx(SequenceBlock, { className, children });
2390
+ }
2391
+ Timeline.Item = TimelineItem;
2392
+ var fitClasses = {
2393
+ contain: "object-contain",
2394
+ cover: "object-cover"
2395
+ };
2396
+ function VideoBlock({
2397
+ title,
2398
+ autoPlay = false,
2399
+ caption,
2400
+ className,
2401
+ controls = true,
2402
+ fit = "contain",
2403
+ loop = false,
2404
+ muted = false,
2405
+ showCaption = false,
2406
+ spacing = "default",
2407
+ src,
2408
+ trackSrc
2409
+ }) {
2410
+ const shouldMute = muted || autoPlay;
2411
+ return /* @__PURE__ */ jsx(
2412
+ MediaFigure,
2413
+ {
2414
+ caption: showCaption ? caption : void 0,
2415
+ className,
2416
+ spacing,
2417
+ children: /* @__PURE__ */ jsx(MediaFrame, { className: "mdx-video-block", children: /* @__PURE__ */ jsx("div", { className: "mdx-video-stage relative aspect-video overflow-hidden", children: /* @__PURE__ */ jsxs(
2418
+ "video",
2419
+ {
2420
+ "aria-label": title,
2421
+ autoPlay,
2422
+ className: clsx("h-full w-full", fitClasses[fit]),
2423
+ controls,
2424
+ loop,
2425
+ muted: shouldMute,
2426
+ playsInline: true,
2427
+ preload: "metadata",
2428
+ children: [
2429
+ /* @__PURE__ */ jsx("source", { src, type: "video/mp4" }),
2430
+ trackSrc ? /* @__PURE__ */ jsx("track", { default: true, kind: "captions", label: "English captions", src: trackSrc, srcLang: "en" }) : null
2431
+ ]
2432
+ }
2433
+ ) }) })
2434
+ }
2435
+ );
2436
+ }
2437
+
2438
+ // src/blocks/index.ts
2439
+ var portableBlockNames = [
2440
+ "Accordion",
2441
+ "Callout",
2442
+ "CodeBlock",
2443
+ "ColorSwatchItem",
2444
+ "Compare",
2445
+ "ComparisonPair",
2446
+ "CreditsBlock",
2447
+ "DemoStage",
2448
+ "ExampleContainer",
2449
+ "FigureBlock",
2450
+ "ImageCompare",
2451
+ "KeyIdea",
2452
+ "LayerStack",
2453
+ "MediaCaption",
2454
+ "MediaPlaceholder",
2455
+ "MdxPageSkeleton",
2456
+ "MermaidDiagram",
2457
+ "PageMeta",
2458
+ "PageTableOfContents",
2459
+ "ResourceList",
2460
+ "ScrollStage",
2461
+ "StatCard",
2462
+ "StatGrid",
2463
+ "Steps",
2464
+ "Tabs",
2465
+ "Timeline",
2466
+ "VideoBlock"
2467
+ ];
2468
+
2469
+ export { Accordion, Callout, CodeBlock, ColorSwatchItem, Compare, ComparisonPair, ComparisonProvider, DemoConfigPanel, DemoStage, DocExample, DocExampleCode, ExampleContainer, ExampleContext, FigureBlock, ImageCompare, KeyIdea, LayerStack, MdxPageSkeleton, MediaPlaceholder, MermaidDiagram, PageMeta, PageTableOfContents, ResourceList, ScrollStage, StatCard, StatGrid, Steps, Tabs, Timeline, VideoBlock, defaultMermaidDiagramLabels, portableBlockNames, useComparisonContext, useIsInsideExample };
2470
+ //# sourceMappingURL=chunk-EIY6ZR6T.js.map
2471
+ //# sourceMappingURL=chunk-EIY6ZR6T.js.map