import type { ReactNode } from "react"; import { CodeBlock } from "@/components/mdx/code-block"; import { Say } from "@/components/mdx/say"; import { slugify } from "@/lib/utils"; function textOf(node: ReactNode): string { if (typeof node === "string" || typeof node === "number") return String(node); if (Array.isArray(node)) return node.map(textOf).join(""); if (node && typeof node === "object" && "props" in node) { return textOf((node as { props: { children?: ReactNode } }).props.children); } return ""; } function H2({ children }: { children?: ReactNode }) { return

{children}

; } function H3({ children }: { children?: ReactNode }) { return

{children}

; } const CALLOUT_LABELS = { note: "Note", tip: "Tip", warning: "Heads up", safety: "Safety" }; function Callout({ type = "note", children }: { type?: keyof typeof CALLOUT_LABELS; children: ReactNode }) { const strong = type === "safety" || type === "warning"; return ( ); } // Numbered steps: wrap a run of blocks in function Steps({ children }: { children: ReactNode }) { return
    {children}
; } function Step({ title, children }: { title: string; children: ReactNode }) { return (
  • {title}

    {children}
  • ); } // A simple inline SVG diagram drawn in currentColor (works in light and dark), with an optional caption function Diagram({ caption, title, children }: { caption?: string; title?: string; children: ReactNode }) { return (
    {title &&

    {title}

    } {children} {caption &&
    {caption}
    }
    ); } // Links to official material: wrap a run of blocks in function Resources({ children }: { children: ReactNode }) { return
      {children}
    ; } function Resource({ title, href, source, kind, children }: { title: string; href: string; source: string; kind: string; children: ReactNode }) { return (
  • {title} {" "} ({kind}, {source})
    {children}
  • ); } export const mdxComponents = { h2: H2, h3: H3, pre: CodeBlock, Callout, Steps, Step, Diagram, Say, Resources, Resource, };