{"version":3,"file":"markdown-DxLtwnaY.mjs","names":["isElement","getClassNames","hasClass","h","text","formatStyle","getTextContent","h","createCopyButton","h","parseYaml"],"sources":["../src/markdown/code/contract.ts","../src/markdown/code/language-badges.ts","../src/markdown/code/meta.ts","../src/markdown/code/renderer.ts","../../../node_modules/unist-util-is/lib/index.js","../../../node_modules/unist-util-visit-parents/lib/color.node.js","../../../node_modules/unist-util-visit-parents/lib/index.js","../../../node_modules/unist-util-visit/lib/index.js","../src/markdown/plugins/rehype-a11y.ts","../src/markdown/plugins/rehype-code-tabs.ts","../src/markdown/plugins/rehype-local-images.ts","../src/markdown/plugins/rehype-scrollable-tables.ts","../src/markdown/pipeline.ts"],"sourcesContent":["/**\n * Pagesmith-owned code block DOM contract.\n *\n * Built-in renderers decorate their root HAST nodes with the class and\n * data attributes defined here before downstream plugins run. This gives\n * code tabs, runtime behavior, and CSS a stable contract that does not\n * depend on a specific renderer's DOM structure.\n */\n\nexport type HastNode = {\n  type: string;\n  tagName?: string;\n  properties?: Record<string, unknown>;\n  data?: Record<string, unknown>;\n  children?: HastNode[];\n  value?: string;\n};\n\nexport type PagesmithCodeFrame = \"code\" | \"terminal\" | \"plain\";\n\nexport type PagesmithCodeBlockMetadata = {\n  renderer: string;\n  title?: string;\n  frame?: PagesmithCodeFrame;\n};\n\nexport const PAGESMITH_CODE_BLOCK_CLASS = \"ps-code-block\";\nexport const PAGESMITH_CODE_RENDERER_ATTR = \"data-ps-code-renderer\";\nexport const PAGESMITH_CODE_TITLE_ATTR = \"data-ps-code-title\";\nexport const PAGESMITH_CODE_FRAME_ATTR = \"data-ps-code-frame\";\nexport const PAGESMITH_CODE_LANG_ATTR = \"data-ps-code-lang\";\n\nfunction isElement(node: HastNode): boolean {\n  return node.type === \"element\";\n}\n\nfunction getClassNames(node: HastNode): string[] {\n  const className = node.properties?.className;\n  if (Array.isArray(className))\n    return className.filter((value): value is string => typeof value === \"string\");\n  if (typeof className === \"string\") return className.split(/\\s+/).filter(Boolean);\n  return [];\n}\n\nfunction setDataAttr(node: HastNode, key: string, value: string | undefined): void {\n  node.properties ||= {};\n  if (value === undefined) {\n    delete node.properties[key];\n    return;\n  }\n  node.properties[key] = value;\n}\n\nexport function addClass(node: HastNode, className: string): void {\n  if (!isElement(node)) return;\n  const classNames = new Set(getClassNames(node));\n  classNames.add(className);\n  node.properties ||= {};\n  node.properties.className = Array.from(classNames);\n}\n\nexport function hasClass(node: HastNode, className: string): boolean {\n  return getClassNames(node).includes(className);\n}\n\nexport function isPagesmithCodeBlock(node: HastNode): boolean {\n  return isElement(node) && hasClass(node, PAGESMITH_CODE_BLOCK_CLASS);\n}\n\nexport function setPagesmithCodeBlockMetadata(\n  node: HastNode,\n  metadata: PagesmithCodeBlockMetadata,\n): void {\n  if (!isElement(node)) return;\n  addClass(node, PAGESMITH_CODE_BLOCK_CLASS);\n  setDataAttr(node, PAGESMITH_CODE_RENDERER_ATTR, metadata.renderer);\n  setDataAttr(node, PAGESMITH_CODE_TITLE_ATTR, metadata.title);\n  setDataAttr(node, PAGESMITH_CODE_FRAME_ATTR, metadata.frame);\n}\n\nexport function getPagesmithCodeBlockTitle(node: HastNode): string | null {\n  const value = node.properties?.[PAGESMITH_CODE_TITLE_ATTR];\n  return typeof value === \"string\" && value.length > 0 ? value : null;\n}\n\nexport function getPagesmithCodeBlockRenderer(node: HastNode): string | null {\n  const value = node.properties?.[PAGESMITH_CODE_RENDERER_ATTR];\n  return typeof value === \"string\" && value.length > 0 ? value : null;\n}\n\nexport function getPagesmithCodeBlockLanguage(node: HastNode): string | null {\n  const value = node.properties?.[PAGESMITH_CODE_LANG_ATTR];\n  return typeof value === \"string\" && value.length > 0 ? value : null;\n}\n","import type { HastNode } from \"./contract\";\n\ntype BadgeIconKind = \"monogram\" | \"terminal\" | \"markup\" | \"data\" | \"document\";\n\ntype BadgePreset = {\n  shortLabel: string;\n  background: string;\n  foreground: string;\n  icon: BadgeIconKind;\n};\n\nconst LANGUAGE_ALIASES: Record<string, string> = {\n  csharp: \"csharp\",\n  \"c#\": \"csharp\",\n  cs: \"csharp\",\n  cpp: \"cpp\",\n  \"c++\": \"cpp\",\n  golang: \"go\",\n  htm: \"html\",\n  javascript: \"js\",\n  json5: \"json\",\n  jsonc: \"json\",\n  jsx: \"jsx\",\n  markdown: \"md\",\n  mdown: \"md\",\n  mdx: \"mdx\",\n  py: \"python\",\n  rs: \"rust\",\n  sass: \"css\",\n  scss: \"css\",\n  shell: \"bash\",\n  shellscript: \"bash\",\n  sh: \"bash\",\n  tsx: \"tsx\",\n  typescript: \"ts\",\n  vuehtml: \"vue\",\n  yml: \"yaml\",\n  zsh: \"bash\",\n};\n\nconst LANGUAGE_PRESETS: Record<string, BadgePreset> = {\n  bash: { shortLabel: \">_\", background: \"#111827\", foreground: \"#86efac\", icon: \"terminal\" },\n  c: { shortLabel: \"C\", background: \"#64748b\", foreground: \"#ffffff\", icon: \"monogram\" },\n  cpp: { shortLabel: \"C++\", background: \"#2563eb\", foreground: \"#ffffff\", icon: \"monogram\" },\n  csharp: { shortLabel: \"C#\", background: \"#68217a\", foreground: \"#ffffff\", icon: \"monogram\" },\n  css: { shortLabel: \"CSS\", background: \"#1572b6\", foreground: \"#ffffff\", icon: \"markup\" },\n  go: { shortLabel: \"GO\", background: \"#00add8\", foreground: \"#0f172a\", icon: \"monogram\" },\n  html: { shortLabel: \"HTML\", background: \"#e34f26\", foreground: \"#ffffff\", icon: \"markup\" },\n  java: { shortLabel: \"JV\", background: \"#f89820\", foreground: \"#111827\", icon: \"monogram\" },\n  js: { shortLabel: \"JS\", background: \"#f7df1e\", foreground: \"#111827\", icon: \"monogram\" },\n  json: { shortLabel: \"{}\", background: \"#f59e0b\", foreground: \"#111827\", icon: \"data\" },\n  jsx: { shortLabel: \"JSX\", background: \"#61dafb\", foreground: \"#0f172a\", icon: \"markup\" },\n  md: { shortLabel: \"MD\", background: \"#0f172a\", foreground: \"#ffffff\", icon: \"document\" },\n  mdx: { shortLabel: \"MDX\", background: \"#6366f1\", foreground: \"#ffffff\", icon: \"document\" },\n  php: { shortLabel: \"PHP\", background: \"#777bb4\", foreground: \"#ffffff\", icon: \"monogram\" },\n  python: { shortLabel: \"PY\", background: \"#3776ab\", foreground: \"#ffffff\", icon: \"monogram\" },\n  ruby: { shortLabel: \"RB\", background: \"#cc342d\", foreground: \"#ffffff\", icon: \"monogram\" },\n  rust: { shortLabel: \"RS\", background: \"#dea584\", foreground: \"#111827\", icon: \"monogram\" },\n  solid: { shortLabel: \"SO\", background: \"#2c4f7c\", foreground: \"#ffffff\", icon: \"monogram\" },\n  sql: { shortLabel: \"SQL\", background: \"#336791\", foreground: \"#ffffff\", icon: \"data\" },\n  svelte: { shortLabel: \"SV\", background: \"#ff3e00\", foreground: \"#ffffff\", icon: \"monogram\" },\n  ts: { shortLabel: \"TS\", background: \"#3178c6\", foreground: \"#ffffff\", icon: \"monogram\" },\n  tsx: { shortLabel: \"TSX\", background: \"#3178c6\", foreground: \"#ffffff\", icon: \"markup\" },\n  vue: { shortLabel: \"VUE\", background: \"#42b883\", foreground: \"#0f172a\", icon: \"monogram\" },\n  yaml: { shortLabel: \"YML\", background: \"#dc2626\", foreground: \"#ffffff\", icon: \"data\" },\n};\n\nfunction h(\n  tagName: string,\n  properties: Record<string, unknown> = {},\n  children: HastNode[] = [],\n): HastNode {\n  return {\n    type: \"element\",\n    tagName,\n    properties,\n    children,\n  };\n}\n\nfunction text(value: string): HastNode {\n  return { type: \"text\", value };\n}\n\nfunction formatStyle(properties: Record<string, string | undefined>): string | undefined {\n  const declarations = Object.entries(properties)\n    .filter(([, value]) => typeof value === \"string\" && value.length > 0)\n    .map(([key, value]) => `${key}:${value}`);\n  return declarations.length > 0 ? declarations.join(\";\") : undefined;\n}\n\nfunction normalizeLanguageKey(lang: string | undefined): string {\n  if (!lang) return \"text\";\n  const cleaned = lang\n    .trim()\n    .toLowerCase()\n    .replace(/^language-/, \"\");\n  if (!cleaned) return \"text\";\n  return LANGUAGE_ALIASES[cleaned] ?? cleaned;\n}\n\nfunction getFallbackColors(key: string): { background: string; foreground: string } {\n  let hash = 0;\n  for (const char of key) {\n    hash = (hash * 31 + char.charCodeAt(0)) >>> 0;\n  }\n  const hue = hash % 360;\n  // Lightness 30% keeps the badge readable across all hues — even the\n  // brightest yellow/green hues clear WCAG 2.2 AA 4.5:1 against the white\n  // foreground. The previous 42% lightness landed around ~3.2:1 for\n  // hues in the 40–80 range (e.g. json5 → hsl(45 62% 42%)).\n  return {\n    background: `hsl(${hue} 62% 30%)`,\n    foreground: \"#ffffff\",\n  };\n}\n\nfunction getFallbackLabel(key: string): string {\n  if (key === \"text\") return \"TXT\";\n  const cleaned = key.replace(/[^a-z0-9]+/gi, \" \").trim();\n  if (!cleaned) return \"TXT\";\n  const parts = cleaned.split(/\\s+/);\n  if (parts.length > 1) {\n    return parts\n      .map((part) => part.charAt(0))\n      .join(\"\")\n      .slice(0, 4)\n      .toUpperCase();\n  }\n  return cleaned.slice(0, 4).toUpperCase();\n}\n\nfunction createMonogramIcon(shortLabel: string): HastNode {\n  const iconLabel = shortLabel.length > 3 ? shortLabel.slice(0, 3) : shortLabel;\n  return h(\n    \"svg\",\n    {\n      className: [\"ps-code-language-icon\", \"ps-code-language-icon--monogram\"],\n      viewBox: \"0 0 20 20\",\n      \"aria-hidden\": \"true\",\n    },\n    [\n      h(\n        \"text\",\n        {\n          x: \"10\",\n          y: \"12.5\",\n          \"text-anchor\": \"middle\",\n          \"font-size\": shortLabel.length > 2 ? \"6\" : \"7\",\n          \"font-weight\": \"700\",\n          fill: \"currentColor\",\n        },\n        [text(iconLabel)],\n      ),\n    ],\n  );\n}\n\nfunction createTerminalIcon(): HastNode {\n  return h(\n    \"svg\",\n    {\n      className: [\"ps-code-language-icon\", \"ps-code-language-icon--terminal\"],\n      viewBox: \"0 0 20 20\",\n      fill: \"none\",\n      stroke: \"currentColor\",\n      \"stroke-width\": \"1.5\",\n      \"stroke-linecap\": \"round\",\n      \"stroke-linejoin\": \"round\",\n      \"aria-hidden\": \"true\",\n    },\n    [\n      h(\"rect\", { x: \"3\", y: \"4\", width: \"14\", height: \"12\", rx: \"2\" }),\n      h(\"path\", { d: \"M6.5 8.5 8.75 10.5 6.5 12.5\" }),\n      h(\"path\", { d: \"M10.5 12.5h3\" }),\n    ],\n  );\n}\n\nfunction createMarkupIcon(): HastNode {\n  return h(\n    \"svg\",\n    {\n      className: [\"ps-code-language-icon\", \"ps-code-language-icon--markup\"],\n      viewBox: \"0 0 20 20\",\n      fill: \"none\",\n      stroke: \"currentColor\",\n      \"stroke-width\": \"1.6\",\n      \"stroke-linecap\": \"round\",\n      \"stroke-linejoin\": \"round\",\n      \"aria-hidden\": \"true\",\n    },\n    [\n      h(\"path\", { d: \"M8 6.5 4.75 10 8 13.5\" }),\n      h(\"path\", { d: \"M12 6.5 15.25 10 12 13.5\" }),\n      h(\"path\", { d: \"M10.75 5.5 9.25 14.5\" }),\n    ],\n  );\n}\n\nfunction createDataIcon(): HastNode {\n  return h(\n    \"svg\",\n    {\n      className: [\"ps-code-language-icon\", \"ps-code-language-icon--data\"],\n      viewBox: \"0 0 20 20\",\n      fill: \"none\",\n      stroke: \"currentColor\",\n      \"stroke-width\": \"1.5\",\n      \"stroke-linecap\": \"round\",\n      \"stroke-linejoin\": \"round\",\n      \"aria-hidden\": \"true\",\n    },\n    [\n      h(\"path\", {\n        d: \"M7.25 5.5c-1 0-1.5.75-1.5 1.75v1.25c0 .8-.45 1.5-1.25 1.5.8 0 1.25.7 1.25 1.5v1.25c0 1 .5 1.75 1.5 1.75\",\n      }),\n      h(\"path\", {\n        d: \"M12.75 5.5c1 0 1.5.75 1.5 1.75v1.25c0 .8.45 1.5 1.25 1.5-.8 0-1.25.7-1.25 1.5v1.25c0 1-.5 1.75-1.5 1.75\",\n      }),\n      h(\"path\", { d: \"M8.5 8h3\" }),\n      h(\"path\", { d: \"M8.5 10h3\" }),\n      h(\"path\", { d: \"M8.5 12h3\" }),\n    ],\n  );\n}\n\nfunction createDocumentIcon(): HastNode {\n  return h(\n    \"svg\",\n    {\n      className: [\"ps-code-language-icon\", \"ps-code-language-icon--document\"],\n      viewBox: \"0 0 20 20\",\n      fill: \"none\",\n      stroke: \"currentColor\",\n      \"stroke-width\": \"1.5\",\n      \"stroke-linecap\": \"round\",\n      \"stroke-linejoin\": \"round\",\n      \"aria-hidden\": \"true\",\n    },\n    [\n      h(\"path\", {\n        d: \"M7 3.75h4.75L15 7v9.25H7A1.25 1.25 0 0 1 5.75 15V5A1.25 1.25 0 0 1 7 3.75Z\",\n      }),\n      h(\"path\", { d: \"M11.75 3.75V7H15\" }),\n      h(\"path\", { d: \"M8 10h4.5\" }),\n      h(\"path\", { d: \"M8 12.5h4.5\" }),\n    ],\n  );\n}\n\nfunction createKnownIcon(kind: BadgeIconKind, shortLabel: string): HastNode {\n  switch (kind) {\n    case \"terminal\":\n      return createTerminalIcon();\n    case \"markup\":\n      return createMarkupIcon();\n    case \"data\":\n      return createDataIcon();\n    case \"document\":\n      return createDocumentIcon();\n    case \"monogram\":\n    default:\n      return createMonogramIcon(shortLabel);\n  }\n}\n\nexport function createLanguageBadge(lang: string | undefined, title?: string): HastNode {\n  const key = normalizeLanguageKey(lang);\n  const preset = LANGUAGE_PRESETS[key];\n\n  if (!preset) {\n    const fallbackColors = getFallbackColors(key);\n    return h(\n      \"span\",\n      {\n        className: [\"ps-code-language-badge\", \"ps-code-language-badge--text\"],\n        \"data-ps-code-language\": key,\n        style: formatStyle({\n          \"--ps-code-language-badge-bg\": fallbackColors.background,\n          \"--ps-code-language-badge-fg\": fallbackColors.foreground,\n        }),\n        \"aria-hidden\": \"true\",\n        ...(title ? { title } : {}),\n      },\n      [text(getFallbackLabel(key))],\n    );\n  }\n\n  return h(\n    \"span\",\n    {\n      className: [\"ps-code-language-badge\", \"ps-code-language-badge--icon\"],\n      \"data-ps-code-language\": key,\n      style: formatStyle({\n        \"--ps-code-language-badge-bg\": preset.background,\n        \"--ps-code-language-badge-fg\": preset.foreground,\n      }),\n      \"aria-hidden\": \"true\",\n      ...(title ? { title } : {}),\n    },\n    [createKnownIcon(preset.icon, preset.shortLabel)],\n  );\n}\n","import type { PagesmithCodeFrame } from \"./contract\";\n\nexport type LineRange = {\n  start: number;\n  end: number;\n};\n\nexport type ParsedCodeFenceMeta = {\n  title?: string;\n  showLineNumbers: boolean;\n  startLineNumber: number;\n  wrap: boolean;\n  frame: PagesmithCodeFrame;\n  mark: LineRange[];\n  ins: LineRange[];\n  del: LineRange[];\n  collapse: LineRange[];\n};\n\ntype RawMetaValue = true | string;\n\nconst TERMINAL_LANGUAGES = new Set([\n  \"bash\",\n  \"console\",\n  \"fish\",\n  \"powershell\",\n  \"ps\",\n  \"ps1\",\n  \"pwsh\",\n  \"shell\",\n  \"sh\",\n  \"zsh\",\n]);\n\nexport function isTerminalLanguage(lang: string | undefined): boolean {\n  return typeof lang === \"string\" && TERMINAL_LANGUAGES.has(lang.toLowerCase());\n}\n\nexport function parseCodeFenceMeta(\n  metaString: string | undefined,\n  options: { defaultShowLineNumbers?: boolean; lang?: string } = {},\n): ParsedCodeFenceMeta {\n  const rawMeta = parseRawMeta(metaString);\n  const defaultShowLineNumbers = options.defaultShowLineNumbers ?? true;\n\n  return {\n    title: normalizeTitle(rawMeta.title),\n    showLineNumbers: parseBoolean(rawMeta.showLineNumbers, defaultShowLineNumbers),\n    startLineNumber: parsePositiveInteger(rawMeta.startLineNumber, 1),\n    wrap: parseBoolean(rawMeta.wrap, false),\n    frame: resolveCodeFrame(rawMeta.frame, options.lang),\n    mark: parseLineRanges(rawMeta.mark),\n    ins: parseLineRanges(rawMeta.ins),\n    del: parseLineRanges(rawMeta.del),\n    collapse: parseLineRanges(rawMeta.collapse),\n  };\n}\n\nexport function lineInRanges(lineNumber: number, ranges: LineRange[]): boolean {\n  return ranges.some((range) => lineNumber >= range.start && lineNumber <= range.end);\n}\n\nfunction parseRawMeta(metaString: string | undefined): Record<string, RawMetaValue> {\n  const meta: Record<string, RawMetaValue> = {};\n  if (!metaString) return meta;\n\n  const tokenRegex = /(\\w+)(?:=(\\{[^}]*\\}|\"[^\"]*\"|'[^']*'|\\S+))?/g;\n  let match: RegExpExecArray | null;\n\n  while ((match = tokenRegex.exec(metaString)) !== null) {\n    const key = match[1];\n    const rawValue = match[2];\n    meta[key] = rawValue === undefined ? true : stripMetaWrapper(rawValue);\n  }\n\n  return meta;\n}\n\nfunction stripMetaWrapper(value: string): string {\n  if (\n    (value.startsWith('\"') && value.endsWith('\"')) ||\n    (value.startsWith(\"'\") && value.endsWith(\"'\")) ||\n    (value.startsWith(\"{\") && value.endsWith(\"}\"))\n  ) {\n    return value.slice(1, -1);\n  }\n  return value;\n}\n\nfunction normalizeTitle(value: RawMetaValue | undefined): string | undefined {\n  if (typeof value !== \"string\") return undefined;\n  const title = value.trim();\n  return title.length > 0 ? title : undefined;\n}\n\nfunction parseBoolean(value: RawMetaValue | undefined, fallback: boolean): boolean {\n  if (value === true) return true;\n  if (typeof value !== \"string\") return fallback;\n\n  const normalized = value.trim().toLowerCase();\n  if (normalized === \"true\" || normalized === \"1\" || normalized === \"yes\" || normalized === \"on\") {\n    return true;\n  }\n  if (normalized === \"false\" || normalized === \"0\" || normalized === \"no\" || normalized === \"off\") {\n    return false;\n  }\n  return fallback;\n}\n\nfunction parsePositiveInteger(value: RawMetaValue | undefined, fallback: number): number {\n  if (typeof value !== \"string\") return fallback;\n  const parsed = Number.parseInt(value, 10);\n  return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;\n}\n\nfunction resolveCodeFrame(\n  value: RawMetaValue | undefined,\n  lang: string | undefined,\n): PagesmithCodeFrame {\n  if (typeof value === \"string\") {\n    const frame = value.trim().toLowerCase();\n    if (frame === \"terminal\") return \"terminal\";\n    if (frame === \"code\") return \"code\";\n    if (frame === \"plain\" || frame === \"none\") return \"plain\";\n  }\n\n  return isTerminalLanguage(lang) ? \"terminal\" : \"code\";\n}\n\nfunction parseLineRanges(value: RawMetaValue | undefined): LineRange[] {\n  if (typeof value !== \"string\") return [];\n  const ranges: LineRange[] = [];\n\n  for (const part of value.split(\",\")) {\n    const token = part.trim();\n    if (!token) continue;\n\n    const singleLineMatch = /^(\\d+)$/.exec(token);\n    if (singleLineMatch) {\n      const singleLine = Number.parseInt(singleLineMatch[1], 10);\n      ranges.push({ start: singleLine, end: singleLine });\n      continue;\n    }\n\n    const rangeMatch = /^(\\d+)\\s*-\\s*(\\d+)$/.exec(token);\n    if (!rangeMatch) continue;\n\n    const start = Number.parseInt(rangeMatch[1], 10);\n    const end = Number.parseInt(rangeMatch[2], 10);\n    if (!Number.isFinite(start) || !Number.isFinite(end)) continue;\n\n    ranges.push(start <= end ? { start, end } : { start: end, end: start });\n  }\n\n  return mergeRanges(ranges);\n}\n\nfunction mergeRanges(ranges: LineRange[]): LineRange[] {\n  if (ranges.length === 0) return [];\n\n  const sorted = [...ranges].sort(\n    (left, right) => left.start - right.start || left.end - right.end,\n  );\n  const merged: LineRange[] = [sorted[0]!];\n\n  for (let index = 1; index < sorted.length; index++) {\n    const current = sorted[index]!;\n    const last = merged[merged.length - 1]!;\n\n    if (current.start <= last.end + 1) {\n      last.end = Math.max(last.end, current.end);\n      continue;\n    }\n\n    merged.push({ ...current });\n  }\n\n  return merged;\n}\n","import {\n  createHighlighter,\n  getSingletonHighlighter,\n  type BundledLanguage,\n  type BundledTheme,\n  type LanguageInput,\n  type SpecialLanguage,\n} from \"shiki\";\nimport type { MarkdownConfig } from \"../../schemas/markdown-config\";\nimport { type HastNode, PAGESMITH_CODE_LANG_ATTR, setPagesmithCodeBlockMetadata } from \"./contract\";\nimport { createLanguageBadge } from \"./language-badges\";\nimport { type LineRange, lineInRanges, parseCodeFenceMeta } from \"./meta\";\n\nconst DEFAULT_LIGHT_THEME = \"github-light\";\nconst DEFAULT_DARK_THEME = \"github-dark\";\nconst PAGESMITH_RENDERER = \"pagesmith\";\ntype RenderableLanguage = BundledLanguage | SpecialLanguage;\n\nconst COMMON_LANGUAGE_LABELS: Record<string, string> = {\n  bash: \"Shell\",\n  c: \"C\",\n  cpp: \"C++\",\n  csharp: \"C#\",\n  css: \"CSS\",\n  go: \"Go\",\n  html: \"HTML\",\n  java: \"Java\",\n  js: \"JavaScript\",\n  json: \"JSON\",\n  jsx: \"JSX\",\n  md: \"Markdown\",\n  mdx: \"MDX\",\n  php: \"PHP\",\n  python: \"Python\",\n  ruby: \"Ruby\",\n  rust: \"Rust\",\n  solid: \"Solid\",\n  sql: \"SQL\",\n  svelte: \"Svelte\",\n  ts: \"TypeScript\",\n  tsx: \"TSX\",\n  vue: \"Vue\",\n  yaml: \"YAML\",\n};\n\n/**\n * Pagesmith ships its own Shiki-backed code renderer implementation,\n * but downstream features only target the Pagesmith code block contract.\n *\n * Keep this renderer inside `@pagesmith/core` until all of the following are true:\n * 1. The Pagesmith code block DOM and metadata contract are stable.\n * 2. Tabs, runtime behavior, and CSS no longer depend on core-internal helpers.\n * 3. There is clear reuse demand outside Pagesmith.\n * 4. Independent release cadence outweighs monorepo dogfooding benefits.\n */\nexport function applyPagesmithCodeRenderer(\n  processor: { use: (...args: any[]) => unknown },\n  config: MarkdownConfig,\n): void {\n  processor.use(rehypePagesmithCodeRenderer, config);\n}\n\nfunction rehypePagesmithCodeRenderer(config: MarkdownConfig) {\n  const lightTheme = config.shiki?.themes?.light || DEFAULT_LIGHT_THEME;\n  const darkTheme = config.shiki?.themes?.dark || DEFAULT_DARK_THEME;\n  const defaultShowLineNumbers = config.shiki?.defaultShowLineNumbers ?? true;\n  // Use Shiki's singleton highlighter so repeated processor builds (one per\n  // markdown pipeline instance, every test render, every dev-server rebuild)\n  // share a single grammar/theme registry. `createHighlighter` instead spins\n  // up a fresh instance each call and Shiki itself warns once 10+ live\n  // instances accumulate.\n  const highlighterPromise = getSingletonHighlighter({\n    themes: [lightTheme, darkTheme],\n    langs: [],\n  });\n\n  return async (tree: HastNode) => {\n    const highlighter = await highlighterPromise;\n    const themeColors = getThemeColors(highlighter, lightTheme, darkTheme);\n\n    await visit(tree);\n\n    async function visit(node: HastNode): Promise<void> {\n      if (!Array.isArray(node.children)) return;\n\n      for (let index = 0; index < node.children.length; index++) {\n        const child = node.children[index];\n        if (isFencePreNode(child)) {\n          node.children[index] = await renderCodeBlock(child, {\n            highlighter,\n            lightTheme,\n            darkTheme,\n            themeColors,\n            defaultShowLineNumbers,\n          });\n          continue;\n        }\n\n        await visit(child);\n      }\n    }\n  };\n}\n\nfunction getTextContent(node: HastNode): string {\n  if (node.type === \"text\") return node.value || \"\";\n  if (node.children) return node.children.map(getTextContent).join(\"\");\n  return \"\";\n}\n\nfunction h(\n  tagName: string,\n  properties: Record<string, unknown> = {},\n  children: HastNode[] = [],\n): HastNode {\n  return {\n    type: \"element\",\n    tagName,\n    properties,\n    children,\n  };\n}\n\nfunction text(value: string): HastNode {\n  return { type: \"text\", value };\n}\n\nfunction isFencePreNode(node: HastNode): boolean {\n  if (node.type !== \"element\" || node.tagName !== \"pre\" || !Array.isArray(node.children))\n    return false;\n  if (node.children.length !== 1) return false;\n  const [codeNode] = node.children;\n  return codeNode?.type === \"element\" && codeNode.tagName === \"code\";\n}\n\nfunction getCodeElement(preNode: HastNode): HastNode {\n  return preNode.children?.[0] as HastNode;\n}\n\nfunction getClassNames(node: HastNode): string[] {\n  const className = node.properties?.className ?? node.properties?.class;\n  if (Array.isArray(className))\n    return className.filter((value): value is string => typeof value === \"string\");\n  if (typeof className === \"string\") return className.split(/\\s+/).filter(Boolean);\n  return [];\n}\n\nfunction getFenceLanguage(codeNode: HastNode): string | undefined {\n  for (const className of getClassNames(codeNode)) {\n    if (className.startsWith(\"language-\")) {\n      const lang = className.slice(\"language-\".length).trim();\n      if (lang) return lang;\n    }\n  }\n  return undefined;\n}\n\nfunction getFenceMeta(codeNode: HastNode): string | undefined {\n  const data = (codeNode as HastNode & { data?: Record<string, unknown> }).data;\n  const meta = data?.meta;\n  return typeof meta === \"string\" && meta.trim().length > 0 ? meta : undefined;\n}\n\nfunction formatStyle(properties: Record<string, string | undefined>): string | undefined {\n  const declarations = Object.entries(properties)\n    .filter(([, value]) => typeof value === \"string\" && value.length > 0)\n    .map(([key, value]) => `${key}:${value}`);\n  return declarations.length > 0 ? declarations.join(\";\") : undefined;\n}\n\nasync function ensureRenderableLanguage(\n  highlighter: Awaited<ReturnType<typeof createHighlighter>>,\n  lang: string | undefined,\n): Promise<RenderableLanguage> {\n  if (!lang || lang === \"text\") return \"text\";\n\n  if (!highlighter.getLoadedLanguages().includes(lang)) {\n    try {\n      await highlighter.loadLanguage(lang as unknown as LanguageInput);\n    } catch {\n      return \"text\";\n    }\n  }\n  return lang as RenderableLanguage;\n}\n\nfunction getThemeColors(\n  highlighter: Awaited<ReturnType<typeof createHighlighter>>,\n  lightTheme: string,\n  darkTheme: string,\n): { lightBg: string; darkBg: string; lightFg: string; darkFg: string } {\n  const light = highlighter.getTheme(lightTheme);\n  const dark = highlighter.getTheme(darkTheme);\n  return {\n    lightBg: light.bg || \"#ffffff\",\n    darkBg: dark.bg || \"#111827\",\n    lightFg: light.fg || \"#111827\",\n    darkFg: dark.fg || \"#f9fafb\",\n  };\n}\n\nfunction getLanguageLabel(\n  highlighter: Awaited<ReturnType<typeof createHighlighter>>,\n  requestedLang: string | undefined,\n  renderedLang: string,\n): string {\n  const lang = requestedLang || renderedLang;\n  if (lang === \"text\") return \"Text\";\n\n  const commonLabel = COMMON_LANGUAGE_LABELS[lang.toLowerCase()];\n  if (commonLabel) return commonLabel;\n\n  let languageInfo:\n    | {\n        displayName?: string;\n      }\n    | undefined;\n  try {\n    languageInfo = highlighter.getLanguage(renderedLang) as { displayName?: string } | undefined;\n  } catch {\n    languageInfo = undefined;\n  }\n  const displayName =\n    languageInfo &&\n    typeof languageInfo.displayName === \"string\" &&\n    languageInfo.displayName.trim().length > 0\n      ? languageInfo.displayName\n      : undefined;\n\n  if (displayName) return displayName;\n  return lang\n    .split(/[-_]/g)\n    .filter(Boolean)\n    .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n    .join(\" \");\n}\n\nfunction createToolbarChip(\n  label: string,\n  lang: string | undefined,\n  languageLabel: string,\n): HastNode {\n  return h(\"span\", { className: [\"ps-code-toolbar-chip\"] }, [\n    createLanguageBadge(lang, languageLabel),\n    h(\"span\", { className: [\"ps-code-toolbar-label\"] }, [text(label)]),\n  ]);\n}\n\nfunction createToolbarMain(\n  label: string,\n  lang: string | undefined,\n  frame: \"code\" | \"terminal\" | \"plain\",\n  languageLabel: string,\n): HastNode | null {\n  if (frame === \"plain\") return null;\n\n  if (frame === \"terminal\") {\n    return h(\"div\", { className: [\"ps-code-toolbar-main\", \"ps-code-toolbar-main--terminal\"] }, [\n      h(\"span\", { className: [\"ps-code-traffic-lights\"], \"aria-hidden\": \"true\" }, [\n        h(\"span\", { className: [\"ps-code-traffic-light\"] }),\n        h(\"span\", { className: [\"ps-code-traffic-light\"] }),\n        h(\"span\", { className: [\"ps-code-traffic-light\"] }),\n      ]),\n      createToolbarChip(label, lang, languageLabel),\n    ]);\n  }\n\n  return h(\"div\", { className: [\"ps-code-toolbar-main\", \"ps-code-toolbar-main--code\"] }, [\n    createToolbarChip(label, lang, languageLabel),\n  ]);\n}\n\nfunction createCopyIcon(): HastNode {\n  return h(\n    \"svg\",\n    {\n      className: [\"ps-code-copy-icon\"],\n      viewBox: \"0 0 16 16\",\n      fill: \"none\",\n      stroke: \"currentColor\",\n      \"stroke-width\": \"1.5\",\n      \"stroke-linecap\": \"round\",\n      \"stroke-linejoin\": \"round\",\n      \"aria-hidden\": \"true\",\n    },\n    [\n      h(\"rect\", { x: \"5.5\", y: \"5.5\", width: \"8\", height: \"8\", rx: \"1.5\" }),\n      h(\"path\", {\n        d: \"M10.5 5.5V4a1.5 1.5 0 0 0-1.5-1.5H4A1.5 1.5 0 0 0 2.5 4v5A1.5 1.5 0 0 0 4 10.5h1.5\",\n      }),\n    ],\n  );\n}\n\nfunction createCopiedIcon(): HastNode {\n  return h(\n    \"svg\",\n    {\n      className: [\"ps-code-copy-icon\", \"ps-code-copy-icon--copied\"],\n      viewBox: \"0 0 16 16\",\n      fill: \"none\",\n      stroke: \"currentColor\",\n      \"stroke-width\": \"1.5\",\n      \"stroke-linecap\": \"round\",\n      \"stroke-linejoin\": \"round\",\n      \"aria-hidden\": \"true\",\n    },\n    [h(\"path\", { d: \"M3.5 9 6.5 12 12.5 4.5\" })],\n  );\n}\n\nfunction createCopyButton(): HastNode {\n  return h(\n    \"button\",\n    {\n      className: [\"ps-code-copy\"],\n      type: \"button\",\n      \"data-ps-code-copy\": \"true\",\n      \"data-copy-label\": \"Copy\",\n      \"data-copied-label\": \"Copied\",\n      \"data-error-label\": \"Retry\",\n      \"aria-label\": \"Copy code block\",\n      title: \"Copy\",\n    },\n    [createCopyIcon(), createCopiedIcon()],\n  );\n}\n\nfunction trimTrailingEmptyTokenLine<T>(lines: T[], code: string): T[] {\n  if (!code.endsWith(\"\\n\")) return lines;\n  return lines.length > 1 ? lines.slice(0, -1) : lines;\n}\n\nfunction getTokenStyle(\n  lightVariant: { color?: string; fontStyle?: number } | undefined,\n  darkVariant: { color?: string; fontStyle?: number } | undefined,\n): string | undefined {\n  const fontStyle = lightVariant?.fontStyle ?? darkVariant?.fontStyle ?? 0;\n  const decorations: string[] = [];\n  if (fontStyle & 4) decorations.push(\"underline\");\n  if (fontStyle & 8) decorations.push(\"line-through\");\n\n  return formatStyle({\n    color: lightVariant?.color,\n    \"--shiki-dark\": darkVariant?.color,\n    \"font-style\": fontStyle & 1 ? \"italic\" : undefined,\n    \"font-weight\": fontStyle & 2 ? \"700\" : undefined,\n    \"text-decoration\": decorations.length > 0 ? decorations.join(\" \") : undefined,\n  });\n}\n\nfunction createLineNode(\n  physicalLineNumber: number,\n  displayLineNumber: number,\n  lineTokens: Array<{\n    content: string;\n    variants: {\n      light: { color?: string; fontStyle?: number };\n      dark: { color?: string; fontStyle?: number };\n    };\n  }>,\n  meta: ReturnType<typeof parseCodeFenceMeta>,\n): HastNode {\n  const className = [\"ps-code-line\"];\n  if (lineInRanges(physicalLineNumber, meta.mark)) className.push(\"ps-code-line--mark\");\n  if (lineInRanges(physicalLineNumber, meta.ins)) className.push(\"ps-code-line--ins\");\n  if (lineInRanges(physicalLineNumber, meta.del)) className.push(\"ps-code-line--del\");\n\n  const children: HastNode[] = [];\n\n  if (meta.showLineNumbers) {\n    children.push(\n      h(\"span\", { className: [\"ps-code-line-number\"], \"aria-hidden\": \"true\" }, [\n        text(String(displayLineNumber)),\n      ]),\n    );\n  }\n\n  const tokenNodes =\n    lineTokens.length > 0\n      ? lineTokens.map((token) =>\n          h(\n            \"span\",\n            {\n              style: getTokenStyle(token.variants.light, token.variants.dark),\n            },\n            [text(token.content)],\n          ),\n        )\n      : [];\n\n  children.push(\n    h(\n      \"span\",\n      {\n        className: [\"ps-code-line-content\"],\n      },\n      tokenNodes,\n    ),\n  );\n\n  return h(\n    \"span\",\n    {\n      className,\n      \"data-ps-code-line\": String(physicalLineNumber),\n    },\n    children,\n  );\n}\n\nfunction createCollapsedGroup(lines: HastNode[], range: LineRange): HastNode {\n  const lineCount = range.end - range.start + 1;\n  const expandLabel = `Show ${lineCount} hidden ${lineCount === 1 ? \"line\" : \"lines\"}`;\n  const collapseLabel = `Hide ${lineCount} hidden ${lineCount === 1 ? \"line\" : \"lines\"}`;\n\n  return h(\"span\", { className: [\"ps-code-collapse\"], \"data-ps-code-collapse\": \"true\" }, [\n    h(\n      \"button\",\n      {\n        className: [\"ps-code-collapse-toggle\"],\n        type: \"button\",\n        \"data-ps-code-collapse-toggle\": \"true\",\n        \"data-expand-label\": expandLabel,\n        \"data-collapse-label\": collapseLabel,\n        \"aria-expanded\": \"false\",\n      },\n      [text(expandLabel)],\n    ),\n    h(\n      \"span\",\n      {\n        className: [\"ps-code-collapse-lines\"],\n        \"data-ps-code-collapse-lines\": \"true\",\n        hidden: true,\n      },\n      lines,\n    ),\n  ]);\n}\n\nfunction applyCollapsedLineRanges(lines: HastNode[], collapseRanges: LineRange[]): HastNode[] {\n  if (collapseRanges.length === 0) return lines;\n\n  const result: HastNode[] = [];\n  let lineIndex = 1;\n\n  for (const range of collapseRanges) {\n    while (lineIndex < range.start && lineIndex <= lines.length) {\n      result.push(lines[lineIndex - 1]!);\n      lineIndex++;\n    }\n\n    if (range.start > lines.length) break;\n\n    const start = Math.max(range.start, 1);\n    const end = Math.min(range.end, lines.length);\n    result.push(createCollapsedGroup(lines.slice(start - 1, end), { start, end }));\n    lineIndex = end + 1;\n  }\n\n  while (lineIndex <= lines.length) {\n    result.push(lines[lineIndex - 1]!);\n    lineIndex++;\n  }\n\n  return result;\n}\n\nasync function renderCodeBlock(\n  preNode: HastNode,\n  options: {\n    highlighter: Awaited<ReturnType<typeof createHighlighter>>;\n    lightTheme: string;\n    darkTheme: string;\n    themeColors: { lightBg: string; darkBg: string; lightFg: string; darkFg: string };\n    defaultShowLineNumbers: boolean;\n  },\n): Promise<HastNode> {\n  const codeNode = getCodeElement(preNode);\n  const requestedLang = getFenceLanguage(codeNode);\n  const rawCode = getTextContent(codeNode).replace(/\\r\\n/g, \"\\n\");\n  const meta = parseCodeFenceMeta(getFenceMeta(codeNode), {\n    defaultShowLineNumbers: options.defaultShowLineNumbers,\n    lang: requestedLang,\n  });\n  const renderedLang = await ensureRenderableLanguage(options.highlighter, requestedLang);\n  const languageLabel = getLanguageLabel(options.highlighter, requestedLang, renderedLang);\n\n  const tokenLines = trimTrailingEmptyTokenLine(\n    options.highlighter.codeToTokensWithThemes(rawCode, {\n      lang: renderedLang,\n      themes: {\n        light: options.lightTheme as BundledTheme,\n        dark: options.darkTheme as BundledTheme,\n      },\n    }),\n    rawCode,\n  );\n\n  const renderedLines = tokenLines.map((lineTokens, index) =>\n    createLineNode(index + 1, meta.startLineNumber + index, lineTokens as any, meta),\n  );\n  const codeChildren = applyCollapsedLineRanges(renderedLines, meta.collapse);\n\n  const toolbarChildren: HastNode[] = [];\n  const toolbarMain = createToolbarMain(\n    meta.title || languageLabel,\n    requestedLang || renderedLang,\n    meta.frame,\n    languageLabel,\n  );\n  if (toolbarMain) toolbarChildren.push(toolbarMain);\n  toolbarChildren.push(createCopyButton());\n\n  const root = h(\n    \"figure\",\n    {\n      className: [\"ps-code-block\"],\n      style: formatStyle({\n        \"--ps-code-light-bg\": options.themeColors.lightBg,\n        \"--ps-code-dark-bg\": options.themeColors.darkBg,\n        \"--ps-code-light-fg\": options.themeColors.lightFg,\n        \"--ps-code-dark-fg\": options.themeColors.darkFg,\n      }),\n      [PAGESMITH_CODE_LANG_ATTR]: requestedLang || renderedLang,\n      \"data-ps-code-wrap\": meta.wrap ? \"true\" : \"false\",\n      \"data-ps-code-line-numbers\": meta.showLineNumbers ? \"true\" : \"false\",\n    },\n    [\n      h(\n        \"div\",\n        {\n          className: [\n            \"ps-code-toolbar\",\n            meta.frame === \"plain\" ? \"ps-code-toolbar--plain\" : `ps-code-toolbar--${meta.frame}`,\n          ],\n        },\n        toolbarChildren,\n      ),\n      h(\"div\", { className: [\"ps-code-body\"] }, [\n        h(\n          \"pre\",\n          {\n            className: [\"ps-code-pre\", \"shiki\", \"shiki-themes\"],\n            tabindex: \"0\",\n            style: formatStyle({\n              \"background-color\": options.themeColors.lightBg,\n              \"--shiki-dark-bg\": options.themeColors.darkBg,\n              color: options.themeColors.lightFg,\n              \"--shiki-dark\": options.themeColors.darkFg,\n            }),\n          },\n          [\n            h(\n              \"code\",\n              {\n                className: [\"ps-code-code\", `language-${requestedLang || renderedLang}`],\n              },\n              codeChildren,\n            ),\n          ],\n        ),\n      ]),\n    ],\n  );\n\n  setPagesmithCodeBlockMetadata(root, {\n    renderer: PAGESMITH_RENDERER,\n    title: meta.title,\n    frame: meta.frame,\n  });\n\n  return root;\n}\n","/**\n * @import {Node, Parent} from 'unist'\n */\n\n/**\n * @template Fn\n * @template Fallback\n * @typedef {Fn extends (value: any) => value is infer Thing ? Thing : Fallback} Predicate\n */\n\n/**\n * @callback Check\n *   Check that an arbitrary value is a node.\n * @param {unknown} this\n *   The given context.\n * @param {unknown} [node]\n *   Anything (typically a node).\n * @param {number | null | undefined} [index]\n *   The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n *   The node’s parent.\n * @returns {boolean}\n *   Whether this is a node and passes a test.\n *\n * @typedef {Record<string, unknown> | Node} Props\n *   Object to check for equivalence.\n *\n *   Note: `Node` is included as it is common but is not indexable.\n *\n * @typedef {Array<Props | TestFunction | string> | ReadonlyArray<Props | TestFunction | string> | Props | TestFunction | string | null | undefined} Test\n *   Check for an arbitrary node.\n *\n * @callback TestFunction\n *   Check if a node passes a test.\n * @param {unknown} this\n *   The given context.\n * @param {Node} node\n *   A node.\n * @param {number | undefined} [index]\n *   The node’s position in its parent.\n * @param {Parent | undefined} [parent]\n *   The node’s parent.\n * @returns {boolean | undefined | void}\n *   Whether this node passes the test.\n *\n *   Note: `void` is included until TS sees no return as `undefined`.\n */\n\n/**\n * Check if `node` is a `Node` and whether it passes the given test.\n *\n * @param {unknown} node\n *   Thing to check, typically `Node`.\n * @param {Test} test\n *   A check for a specific node.\n * @param {number | null | undefined} index\n *   The node’s position in its parent.\n * @param {Parent | null | undefined} parent\n *   The node’s parent.\n * @param {unknown} context\n *   Context object (`this`) to pass to `test` functions.\n * @returns {boolean}\n *   Whether `node` is a node and passes a test.\n */\nexport const is =\n  // Note: overloads in JSDoc can’t yet use different `@template`s.\n  /**\n   * @type {(\n   *   (<Condition extends ReadonlyArray<string>>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition[number]}) &\n   *   (<Condition extends Array<string>>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition[number]}) &\n   *   (<Condition extends string>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &\n   *   (<Condition extends Props>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &\n   *   (<Condition extends TestFunction>(node: unknown, test: Condition, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &\n   *   ((node?: null | undefined) => false) &\n   *   ((node: unknown, test?: null | undefined, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &\n   *   ((node: unknown, test?: Test, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => boolean)\n   * )}\n   */\n  (\n    /**\n     * @param {unknown} [node]\n     * @param {Test} [test]\n     * @param {number | null | undefined} [index]\n     * @param {Parent | null | undefined} [parent]\n     * @param {unknown} [context]\n     * @returns {boolean}\n     */\n    // eslint-disable-next-line max-params\n    function (node, test, index, parent, context) {\n      const check = convert(test)\n\n      if (\n        index !== undefined &&\n        index !== null &&\n        (typeof index !== 'number' ||\n          index < 0 ||\n          index === Number.POSITIVE_INFINITY)\n      ) {\n        throw new Error('Expected positive finite index')\n      }\n\n      if (\n        parent !== undefined &&\n        parent !== null &&\n        (!is(parent) || !parent.children)\n      ) {\n        throw new Error('Expected parent node')\n      }\n\n      if (\n        (parent === undefined || parent === null) !==\n        (index === undefined || index === null)\n      ) {\n        throw new Error('Expected both parent and index')\n      }\n\n      return looksLikeANode(node)\n        ? check.call(context, node, index, parent)\n        : false\n    }\n  )\n\n/**\n * Generate an assertion from a test.\n *\n * Useful if you’re going to test many nodes, for example when creating a\n * utility where something else passes a compatible test.\n *\n * The created function is a bit faster because it expects valid input only:\n * a `node`, `index`, and `parent`.\n *\n * @param {Test} test\n *   *   when nullish, checks if `node` is a `Node`.\n *   *   when `string`, works like passing `(node) => node.type === test`.\n *   *   when `function` checks if function passed the node is true.\n *   *   when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.\n *   *   when `array`, checks if any one of the subtests pass.\n * @returns {Check}\n *   An assertion.\n */\nexport const convert =\n  // Note: overloads in JSDoc can’t yet use different `@template`s.\n  /**\n   * @type {(\n   *   (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &\n   *   (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &\n   *   (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &\n   *   ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &\n   *   ((test?: Test) => Check)\n   * )}\n   */\n  (\n    /**\n     * @param {Test} [test]\n     * @returns {Check}\n     */\n    function (test) {\n      if (test === null || test === undefined) {\n        return ok\n      }\n\n      if (typeof test === 'function') {\n        return castFactory(test)\n      }\n\n      if (typeof test === 'object') {\n        return Array.isArray(test)\n          ? anyFactory(test)\n          : // Cast because `ReadonlyArray` goes into the above but `isArray`\n            // narrows to `Array`.\n            propertiesFactory(/** @type {Props} */ (test))\n      }\n\n      if (typeof test === 'string') {\n        return typeFactory(test)\n      }\n\n      throw new Error('Expected function, string, or object as test')\n    }\n  )\n\n/**\n * @param {Array<Props | TestFunction | string>} tests\n * @returns {Check}\n */\nfunction anyFactory(tests) {\n  /** @type {Array<Check>} */\n  const checks = []\n  let index = -1\n\n  while (++index < tests.length) {\n    checks[index] = convert(tests[index])\n  }\n\n  return castFactory(any)\n\n  /**\n   * @this {unknown}\n   * @type {TestFunction}\n   */\n  function any(...parameters) {\n    let index = -1\n\n    while (++index < checks.length) {\n      if (checks[index].apply(this, parameters)) return true\n    }\n\n    return false\n  }\n}\n\n/**\n * Turn an object into a test for a node with a certain fields.\n *\n * @param {Props} check\n * @returns {Check}\n */\nfunction propertiesFactory(check) {\n  const checkAsRecord = /** @type {Record<string, unknown>} */ (check)\n\n  return castFactory(all)\n\n  /**\n   * @param {Node} node\n   * @returns {boolean}\n   */\n  function all(node) {\n    const nodeAsRecord = /** @type {Record<string, unknown>} */ (\n      /** @type {unknown} */ (node)\n    )\n\n    /** @type {string} */\n    let key\n\n    for (key in check) {\n      if (nodeAsRecord[key] !== checkAsRecord[key]) return false\n    }\n\n    return true\n  }\n}\n\n/**\n * Turn a string into a test for a node with a certain type.\n *\n * @param {string} check\n * @returns {Check}\n */\nfunction typeFactory(check) {\n  return castFactory(type)\n\n  /**\n   * @param {Node} node\n   */\n  function type(node) {\n    return node && node.type === check\n  }\n}\n\n/**\n * Turn a custom test into a test for a node that passes that test.\n *\n * @param {TestFunction} testFunction\n * @returns {Check}\n */\nfunction castFactory(testFunction) {\n  return check\n\n  /**\n   * @this {unknown}\n   * @type {Check}\n   */\n  function check(value, index, parent) {\n    return Boolean(\n      looksLikeANode(value) &&\n        testFunction.call(\n          this,\n          value,\n          typeof index === 'number' ? index : undefined,\n          parent || undefined\n        )\n    )\n  }\n}\n\nfunction ok() {\n  return true\n}\n\n/**\n * @param {unknown} value\n * @returns {value is Node}\n */\nfunction looksLikeANode(value) {\n  return value !== null && typeof value === 'object' && 'type' in value\n}\n","/**\n * @param {string} d\n * @returns {string}\n */\nexport function color(d) {\n  return '\\u001B[33m' + d + '\\u001B[39m'\n}\n","/**\n * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n *   Test from `unist-util-is`.\n *\n *   Note: we have remove and add `undefined`, because otherwise when generating\n *   automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n *   which doesn’t work when publishing on npm.\n */\n\n/**\n * @typedef {(\n *   Fn extends (value: any) => value is infer Thing\n *   ? Thing\n *   : Fallback\n * )} Predicate\n *   Get the value of a type guard `Fn`.\n * @template Fn\n *   Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n *   Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n *   Check extends null | undefined // No test.\n *   ? Value\n *   : Value extends {type: Check} // String (type) test.\n *   ? Value\n *   : Value extends Check // Partial test.\n *   ? Value\n *   : Check extends Function // Function test.\n *   ? Predicate<Check, Value> extends Value\n *     ? Predicate<Check, Value>\n *     : never\n *   : never // Some other test?\n * )} MatchesOne\n *   Check whether a node matches a primitive check in the type system.\n * @template Value\n *   Value; typically unist `Node`.\n * @template Check\n *   Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n *   Check extends ReadonlyArray<infer T>\n *   ? MatchesOne<Value, T>\n *   : Check extends Array<infer T>\n *   ? MatchesOne<Value, T>\n *   : MatchesOne<Value, Check>\n * )} Matches\n *   Check whether a node matches a check in the type system.\n * @template Value\n *   Value; typically unist `Node`.\n * @template Check\n *   Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n *   Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n *   Increment a number in the type system.\n * @template {Uint} [I=0]\n *   Index.\n */\n\n/**\n * @typedef {(\n *   Node extends UnistParent\n *   ? Node extends {children: Array<infer Children>}\n *     ? Child extends Children ? Node : never\n *     : never\n *   : never\n * )} InternalParent\n *   Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n *   All node types in a tree.\n * @template {UnistNode} Child\n *   Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n *   Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n *   All node types in a tree.\n * @template {UnistNode} Child\n *   Node to search for.\n */\n\n/**\n * @typedef {(\n *   Depth extends Max\n *   ? never\n *   :\n *     | InternalParent<Node, Child>\n *     | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>\n * )} InternalAncestor\n *   Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n *   All node types in a tree.\n * @template {UnistNode} Child\n *   Node to search for.\n * @template {Uint} [Max=10]\n *   Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n *   Current depth.\n */\n\n/**\n * @typedef {InternalAncestor<InclusiveDescendant<Tree>, Child>} Ancestor\n *   Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Tree\n *   All node types in a tree.\n * @template {UnistNode} Child\n *   Node to search for.\n */\n\n/**\n * @typedef {(\n *   Tree extends UnistParent\n *     ? Depth extends Max\n *       ? Tree\n *       : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>\n *     : Tree\n * )} InclusiveDescendant\n *   Collect all (inclusive) descendants of `Tree`.\n *\n *   > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n *   > recurse without actually running into an infinite loop, which the\n *   > previous version did.\n *   >\n *   > Practically, a max of `2` is typically enough assuming a `Root` is\n *   > passed, but it doesn’t improve performance.\n *   > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n *   > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n *   Tree type.\n * @template {Uint} [Max=10]\n *   Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n *   Current depth.\n */\n\n/**\n * @typedef {'skip' | boolean} Action\n *   Union of the action types.\n *\n * @typedef {number} Index\n *   Move to the sibling at `index` next (after node itself is completely\n *   traversed).\n *\n *   Useful if mutating the tree, such as removing the node the visitor is\n *   currently on, or any of its previous siblings.\n *   Results less than 0 or greater than or equal to `children.length` stop\n *   traversing the parent.\n *\n * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple\n *   List with one or two values, the first an action, the second an index.\n *\n * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult\n *   Any value that can be returned from a visitor.\n */\n\n/**\n * @callback Visitor\n *   Handle a node (matching `test`, if given).\n *\n *   Visitors are free to transform `node`.\n *   They can also transform the parent of node (the last of `ancestors`).\n *\n *   Replacing `node` itself, if `SKIP` is not returned, still causes its\n *   descendants to be walked (which is a bug).\n *\n *   When adding or removing previous siblings of `node` (or next siblings, in\n *   case of reverse), the `Visitor` should return a new `Index` to specify the\n *   sibling to traverse after `node` is traversed.\n *   Adding or removing next siblings of `node` (or previous siblings, in case\n *   of reverse) is handled as expected without needing to return a new `Index`.\n *\n *   Removing the children property of an ancestor still results in them being\n *   traversed.\n * @param {Visited} node\n *   Found node.\n * @param {Array<VisitedParents>} ancestors\n *   Ancestors of `node`.\n * @returns {VisitorResult}\n *   What to do next.\n *\n *   An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n *   An `Action` is treated as a tuple of `[Action]`.\n *\n *   Passing a tuple back only makes sense if the `Action` is `SKIP`.\n *   When the `Action` is `EXIT`, that action can be returned.\n *   When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n *   Visited node type.\n * @template {UnistParent} [VisitedParents=UnistParent]\n *   Ancestor type.\n */\n\n/**\n * @typedef {Visitor<Matches<InclusiveDescendant<Tree>, Check>, Ancestor<Tree, Matches<InclusiveDescendant<Tree>, Check>>>} BuildVisitor\n *   Build a typed `Visitor` function from a tree and a test.\n *\n *   It will infer which values are passed as `node` and which as `parents`.\n * @template {UnistNode} [Tree=UnistNode]\n *   Tree type.\n * @template {Test} [Check=Test]\n *   Test type.\n */\n\nimport {convert} from 'unist-util-is'\nimport {color} from 'unist-util-visit-parents/do-not-use-color'\n\n/** @type {Readonly<ActionTuple>} */\nconst empty = []\n\n/**\n * Continue traversing as normal.\n */\nexport const CONTINUE = true\n\n/**\n * Stop traversing immediately.\n */\nexport const EXIT = false\n\n/**\n * Do not traverse this node’s children.\n */\nexport const SKIP = 'skip'\n\n/**\n * Visit nodes, with ancestral information.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor<Tree, Check>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor<Tree>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n *   Tree to traverse.\n * @param {Visitor | Test} test\n *   `unist-util-is`-compatible test\n * @param {Visitor | boolean | null | undefined} [visitor]\n *   Handle each node.\n * @param {boolean | null | undefined} [reverse]\n *   Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n *   Nothing.\n *\n * @template {UnistNode} Tree\n *   Node type.\n * @template {Test} Check\n *   `unist-util-is`-compatible test.\n */\nexport function visitParents(tree, test, visitor, reverse) {\n  /** @type {Test} */\n  let check\n\n  if (typeof test === 'function' && typeof visitor !== 'function') {\n    reverse = visitor\n    // @ts-expect-error no visitor given, so `visitor` is test.\n    visitor = test\n  } else {\n    // @ts-expect-error visitor given, so `test` isn’t a visitor.\n    check = test\n  }\n\n  const is = convert(check)\n  const step = reverse ? -1 : 1\n\n  factory(tree, undefined, [])()\n\n  /**\n   * @param {UnistNode} node\n   * @param {number | undefined} index\n   * @param {Array<UnistParent>} parents\n   */\n  function factory(node, index, parents) {\n    const value = /** @type {Record<string, unknown>} */ (\n      node && typeof node === 'object' ? node : {}\n    )\n\n    if (typeof value.type === 'string') {\n      const name =\n        // `hast`\n        typeof value.tagName === 'string'\n          ? value.tagName\n          : // `xast`\n            typeof value.name === 'string'\n            ? value.name\n            : undefined\n\n      Object.defineProperty(visit, 'name', {\n        value:\n          'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'\n      })\n    }\n\n    return visit\n\n    function visit() {\n      /** @type {Readonly<ActionTuple>} */\n      let result = empty\n      /** @type {Readonly<ActionTuple>} */\n      let subresult\n      /** @type {number} */\n      let offset\n      /** @type {Array<UnistParent>} */\n      let grandparents\n\n      if (!test || is(node, index, parents[parents.length - 1] || undefined)) {\n        // @ts-expect-error: `visitor` is now a visitor.\n        result = toResult(visitor(node, parents))\n\n        if (result[0] === EXIT) {\n          return result\n        }\n      }\n\n      if ('children' in node && node.children) {\n        const nodeAsParent = /** @type {UnistParent} */ (node)\n\n        if (nodeAsParent.children && result[0] !== SKIP) {\n          offset = (reverse ? nodeAsParent.children.length : -1) + step\n          grandparents = parents.concat(nodeAsParent)\n\n          while (offset > -1 && offset < nodeAsParent.children.length) {\n            const child = nodeAsParent.children[offset]\n\n            subresult = factory(child, offset, grandparents)()\n\n            if (subresult[0] === EXIT) {\n              return subresult\n            }\n\n            offset =\n              typeof subresult[1] === 'number' ? subresult[1] : offset + step\n          }\n        }\n      }\n\n      return result\n    }\n  }\n}\n\n/**\n * Turn a return value into a clean result.\n *\n * @param {VisitorResult} value\n *   Valid return values from visitors.\n * @returns {Readonly<ActionTuple>}\n *   Clean result.\n */\nfunction toResult(value) {\n  if (Array.isArray(value)) {\n    return value\n  }\n\n  if (typeof value === 'number') {\n    return [CONTINUE, value]\n  }\n\n  return value === null || value === undefined ? empty : [value]\n}\n","/**\n * @import {Node as UnistNode, Parent as UnistParent} from 'unist'\n * @import {VisitorResult} from 'unist-util-visit-parents'\n */\n\n/**\n * @typedef {Exclude<import('unist-util-is').Test, undefined> | undefined} Test\n *   Test from `unist-util-is`.\n *\n *   Note: we have remove and add `undefined`, because otherwise when generating\n *   automatic `.d.ts` files, TS tries to flatten paths from a local perspective,\n *   which doesn’t work when publishing on npm.\n */\n\n// To do: use types from `unist-util-visit-parents` when it’s released.\n\n/**\n * @typedef {(\n *   Fn extends (value: any) => value is infer Thing\n *   ? Thing\n *   : Fallback\n * )} Predicate\n *   Get the value of a type guard `Fn`.\n * @template Fn\n *   Value; typically function that is a type guard (such as `(x): x is Y`).\n * @template Fallback\n *   Value to yield if `Fn` is not a type guard.\n */\n\n/**\n * @typedef {(\n *   Check extends null | undefined // No test.\n *   ? Value\n *   : Value extends {type: Check} // String (type) test.\n *   ? Value\n *   : Value extends Check // Partial test.\n *   ? Value\n *   : Check extends Function // Function test.\n *   ? Predicate<Check, Value> extends Value\n *     ? Predicate<Check, Value>\n *     : never\n *   : never // Some other test?\n * )} MatchesOne\n *   Check whether a node matches a primitive check in the type system.\n * @template Value\n *   Value; typically unist `Node`.\n * @template Check\n *   Value; typically `unist-util-is`-compatible test, but not arrays.\n */\n\n/**\n * @typedef {(\n *   Check extends ReadonlyArray<any>\n *   ? MatchesOne<Value, Check[number]>\n *   : MatchesOne<Value, Check>\n * )} Matches\n *   Check whether a node matches a check in the type system.\n * @template Value\n *   Value; typically unist `Node`.\n * @template Check\n *   Value; typically `unist-util-is`-compatible test.\n */\n\n/**\n * @typedef {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10} Uint\n *   Number; capped reasonably.\n */\n\n/**\n * @typedef {I extends 0 ? 1 : I extends 1 ? 2 : I extends 2 ? 3 : I extends 3 ? 4 : I extends 4 ? 5 : I extends 5 ? 6 : I extends 6 ? 7 : I extends 7 ? 8 : I extends 8 ? 9 : 10} Increment\n *   Increment a number in the type system.\n * @template {Uint} [I=0]\n *   Index.\n */\n\n/**\n * @typedef {(\n *   Node extends UnistParent\n *   ? Node extends {children: Array<infer Children>}\n *     ? Child extends Children ? Node : never\n *     : never\n *   : never\n * )} InternalParent\n *   Collect nodes that can be parents of `Child`.\n * @template {UnistNode} Node\n *   All node types in a tree.\n * @template {UnistNode} Child\n *   Node to search for.\n */\n\n/**\n * @typedef {InternalParent<InclusiveDescendant<Tree>, Child>} Parent\n *   Collect nodes in `Tree` that can be parents of `Child`.\n * @template {UnistNode} Tree\n *   All node types in a tree.\n * @template {UnistNode} Child\n *   Node to search for.\n */\n\n/**\n * @typedef {(\n *   Depth extends Max\n *   ? never\n *   :\n *     | InternalParent<Node, Child>\n *     | InternalAncestor<Node, InternalParent<Node, Child>, Max, Increment<Depth>>\n * )} InternalAncestor\n *   Collect nodes in `Tree` that can be ancestors of `Child`.\n * @template {UnistNode} Node\n *   All node types in a tree.\n * @template {UnistNode} Child\n *   Node to search for.\n * @template {Uint} [Max=10]\n *   Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n *   Current depth.\n */\n\n/**\n * @typedef {(\n *   Tree extends UnistParent\n *     ? Depth extends Max\n *       ? Tree\n *       : Tree | InclusiveDescendant<Tree['children'][number], Max, Increment<Depth>>\n *     : Tree\n * )} InclusiveDescendant\n *   Collect all (inclusive) descendants of `Tree`.\n *\n *   > 👉 **Note**: for performance reasons, this seems to be the fastest way to\n *   > recurse without actually running into an infinite loop, which the\n *   > previous version did.\n *   >\n *   > Practically, a max of `2` is typically enough assuming a `Root` is\n *   > passed, but it doesn’t improve performance.\n *   > It gets higher with `List > ListItem > Table > TableRow > TableCell`.\n *   > Using up to `10` doesn’t hurt or help either.\n * @template {UnistNode} Tree\n *   Tree type.\n * @template {Uint} [Max=10]\n *   Max; searches up to this depth.\n * @template {Uint} [Depth=0]\n *   Current depth.\n */\n\n/**\n * @callback Visitor\n *   Handle a node (matching `test`, if given).\n *\n *   Visitors are free to transform `node`.\n *   They can also transform `parent`.\n *\n *   Replacing `node` itself, if `SKIP` is not returned, still causes its\n *   descendants to be walked (which is a bug).\n *\n *   When adding or removing previous siblings of `node` (or next siblings, in\n *   case of reverse), the `Visitor` should return a new `Index` to specify the\n *   sibling to traverse after `node` is traversed.\n *   Adding or removing next siblings of `node` (or previous siblings, in case\n *   of reverse) is handled as expected without needing to return a new `Index`.\n *\n *   Removing the children property of `parent` still results in them being\n *   traversed.\n * @param {Visited} node\n *   Found node.\n * @param {Visited extends UnistNode ? number | undefined : never} index\n *   Index of `node` in `parent`.\n * @param {Ancestor extends UnistParent ? Ancestor | undefined : never} parent\n *   Parent of `node`.\n * @returns {VisitorResult}\n *   What to do next.\n *\n *   An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n *   An `Action` is treated as a tuple of `[Action]`.\n *\n *   Passing a tuple back only makes sense if the `Action` is `SKIP`.\n *   When the `Action` is `EXIT`, that action can be returned.\n *   When the `Action` is `CONTINUE`, `Index` can be returned.\n * @template {UnistNode} [Visited=UnistNode]\n *   Visited node type.\n * @template {UnistParent} [Ancestor=UnistParent]\n *   Ancestor type.\n */\n\n/**\n * @typedef {Visitor<Visited, Parent<Ancestor, Visited>>} BuildVisitorFromMatch\n *   Build a typed `Visitor` function from a node and all possible parents.\n *\n *   It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Visited\n *   Node type.\n * @template {UnistParent} Ancestor\n *   Parent type.\n */\n\n/**\n * @typedef {(\n *   BuildVisitorFromMatch<\n *     Matches<Descendant, Check>,\n *     Extract<Descendant, UnistParent>\n *   >\n * )} BuildVisitorFromDescendants\n *   Build a typed `Visitor` function from a list of descendants and a test.\n *\n *   It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} Descendant\n *   Node type.\n * @template {Test} Check\n *   Test type.\n */\n\n/**\n * @typedef {(\n *   BuildVisitorFromDescendants<\n *     InclusiveDescendant<Tree>,\n *     Check\n *   >\n * )} BuildVisitor\n *   Build a typed `Visitor` function from a tree and a test.\n *\n *   It will infer which values are passed as `node` and which as `parent`.\n * @template {UnistNode} [Tree=UnistNode]\n *   Node type.\n * @template {Test} [Check=Test]\n *   Test type.\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n\n/**\n * Visit nodes.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @overload\n * @param {Tree} tree\n * @param {Check} check\n * @param {BuildVisitor<Tree, Check>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @overload\n * @param {Tree} tree\n * @param {BuildVisitor<Tree>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {undefined}\n *\n * @param {UnistNode} tree\n *   Tree to traverse.\n * @param {Visitor | Test} testOrVisitor\n *   `unist-util-is`-compatible test (optional, omit to pass a visitor).\n * @param {Visitor | boolean | null | undefined} [visitorOrReverse]\n *   Handle each node (when test is omitted, pass `reverse`).\n * @param {boolean | null | undefined} [maybeReverse=false]\n *   Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns {undefined}\n *   Nothing.\n *\n * @template {UnistNode} Tree\n *   Node type.\n * @template {Test} Check\n *   `unist-util-is`-compatible test.\n */\nexport function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {\n  /** @type {boolean | null | undefined} */\n  let reverse\n  /** @type {Test} */\n  let test\n  /** @type {Visitor} */\n  let visitor\n\n  if (\n    typeof testOrVisitor === 'function' &&\n    typeof visitorOrReverse !== 'function'\n  ) {\n    test = undefined\n    visitor = testOrVisitor\n    reverse = visitorOrReverse\n  } else {\n    // @ts-expect-error: assume the overload with test was given.\n    test = testOrVisitor\n    // @ts-expect-error: assume the overload with test was given.\n    visitor = visitorOrReverse\n    reverse = maybeReverse\n  }\n\n  visitParents(tree, test, overload, reverse)\n\n  /**\n   * @param {UnistNode} node\n   * @param {Array<UnistParent>} parents\n   */\n  function overload(node, parents) {\n    const parent = parents[parents.length - 1]\n    const index = parent ? parent.children.indexOf(node) : undefined\n    return visitor(node, index, parent)\n  }\n}\n","/**\n * `rehype-a11y` — fix common WCAG 2.2 AA gaps that the upstream remark/rehype\n * pipeline leaves in place after rendering Markdown into HTML.\n *\n * Today it patches two specific shapes:\n *\n *   1. **GFM task-list checkboxes** (`- [ ] text`)\n *      `remark-gfm` emits `<input type=\"checkbox\" disabled>` with no label.\n *      Screen readers announce them as nameless form controls. We add\n *      `aria-label` derived from the sibling text so the control is\n *      announced as e.g. \"checkbox, unchecked, configure CI\".\n *\n *   2. **MathJax SVG output** (`rehype-mathjax/svg`)\n *      MathJax emits `<svg role=\"img\">` elements with no `<title>` or\n *      `aria-label`. Browsers and screen readers therefore have no\n *      accessible name for the equation. We attach `aria-label` derived\n *      from the math source preserved in `data-original` / `aria-hidden`\n *      siblings, falling back to `\"Math equation\"` so the control still\n *      has a name.\n *\n * Both patches are idempotent and safe to apply more than once.\n */\n\nimport { visit } from \"unist-util-visit\";\nimport type { Element, Root } from \"hast\";\nimport type { Plugin } from \"unified\";\n\nfunction getText(node: any): string {\n  if (!node) return \"\";\n  if (node.type === \"text\") return String(node.value ?? \"\");\n  if (Array.isArray(node.children)) return node.children.map(getText).join(\"\");\n  return \"\";\n}\n\nfunction findCheckboxLabel(parent: Element | undefined, checkboxIndex: number): string {\n  if (!parent || !Array.isArray(parent.children)) return \"\";\n  // Look at every sibling AFTER the checkbox; that is where remark-gfm\n  // puts the actual task text.\n  const tail = parent.children.slice(checkboxIndex + 1);\n  return tail.map(getText).join(\"\").trim();\n}\n\nconst rehypeA11y: Plugin<[], Root> = () => {\n  return (tree) => {\n    visit(tree, \"element\", (node, index, parent) => {\n      // ── 1. Task-list checkboxes ─────────────────────────────────────\n      if (\n        node.tagName === \"input\" &&\n        (node.properties?.type === \"checkbox\" || node.properties?.type === \"CHECKBOX\")\n      ) {\n        const props = node.properties ?? {};\n        if (!props[\"ariaLabel\"] && !props[\"aria-label\"]) {\n          const labelText =\n            findCheckboxLabel(parent as Element | undefined, index ?? -1) || \"Task item\";\n          const checked = Boolean(props[\"checked\"]);\n          const label = checked ? `Completed: ${labelText}` : `Pending: ${labelText}`;\n          node.properties = { ...props, ariaLabel: label };\n        }\n      }\n\n      // ── 2. MathJax-style SVGs without an accessible name ────────────\n      if (\n        node.tagName === \"svg\" &&\n        node.properties &&\n        (node.properties[\"role\"] === \"img\" || node.properties[\"role\"] === \"IMG\")\n      ) {\n        const props = node.properties;\n        const hasName =\n          Boolean(props[\"ariaLabel\"]) ||\n          Boolean(props[\"aria-label\"]) ||\n          Boolean(props[\"ariaLabelledby\"]) ||\n          Boolean(props[\"aria-labelledby\"]) ||\n          (Array.isArray(node.children) &&\n            node.children.some(\n              (c) => (c as Element).type === \"element\" && (c as Element).tagName === \"title\",\n            ));\n        if (!hasName) {\n          // Try to read the original LaTeX source MathJax preserves on\n          // `data-original` (when configured); fall back to a stable label\n          // so the SVG always has a name.\n          const original =\n            (props[\"dataOriginal\"] as string | undefined) ||\n            (props[\"data-original\"] as string | undefined) ||\n            \"\";\n          const label = original.trim() || \"Math equation\";\n          node.properties = { ...props, ariaLabel: label };\n        }\n      }\n    });\n  };\n};\n\nexport default rehypeA11y;\n","/**\n * Rehype plugin that groups consecutive titled Pagesmith code blocks\n * into a tabbed interface.\n *\n * Runs after the built-in code renderer in the pipeline. Walks the HAST\n * tree, finds runs of 2+ adjacent Pagesmith-owned code block wrappers\n * where every block has a title, and replaces them with an accessible\n * tab container. The runtime JS in `runtime/code-tabs.ts` handles\n * switching, keyboard navigation, and keeping the active tab scrolled\n * into view.\n */\n\nimport {\n  type HastNode,\n  getPagesmithCodeBlockLanguage,\n  getPagesmithCodeBlockTitle,\n  isPagesmithCodeBlock,\n} from \"../code/contract\";\nimport { createLanguageBadge } from \"../code/language-badges\";\n\nfunction isWhitespace(node: HastNode): boolean {\n  return node.type === \"text\" && /^\\s*$/.test(node.value || \"\");\n}\n\nfunction h(tag: string, props: Record<string, unknown>, children: HastNode[] = []): HastNode {\n  return { type: \"element\", tagName: tag, properties: props, children };\n}\n\nfunction createTabLabel(title: string, lang: string | null): HastNode {\n  return h(\"span\", { className: [\"ps-code-tab-inner\"] }, [\n    createLanguageBadge(lang ?? undefined),\n    h(\"span\", { className: [\"ps-code-tab-label\"] }, [{ type: \"text\", value: title }]),\n  ]);\n}\n\nfunction createCopyButton(): HastNode {\n  return h(\n    \"button\",\n    {\n      className: [\"ps-code-copy\"],\n      type: \"button\",\n      \"data-ps-code-copy\": \"true\",\n      \"data-copy-label\": \"Copy\",\n      \"data-copied-label\": \"Copied\",\n      \"data-error-label\": \"Retry\",\n      \"aria-label\": \"Copy active code tab\",\n    },\n    [h(\"span\", { \"data-ps-code-copy-label\": \"true\" }, [{ type: \"text\", value: \"Copy\" }])],\n  );\n}\n\n/**\n * Identify runs of consecutive Pagesmith code blocks that all have titles.\n * Whitespace-only text nodes between blocks are treated as separators\n * (they don't break a run). Returns start index and count for each run.\n */\nfunction findRuns(children: HastNode[]): { start: number; count: number }[] {\n  const runs: { start: number; count: number }[] = [];\n  let i = 0;\n  while (i < children.length) {\n    if (isPagesmithCodeBlock(children[i]) && getPagesmithCodeBlockTitle(children[i]) !== null) {\n      const runStart = i;\n      let codeBlockCount = 1;\n      let j = i + 1;\n      while (j < children.length) {\n        if (isWhitespace(children[j])) {\n          j++;\n          continue;\n        }\n        if (isPagesmithCodeBlock(children[j]) && getPagesmithCodeBlockTitle(children[j]) !== null) {\n          codeBlockCount++;\n          j++;\n          continue;\n        }\n        break;\n      }\n      if (codeBlockCount >= 2) {\n        runs.push({ start: runStart, count: j - runStart });\n      }\n      i = j;\n    } else {\n      i++;\n    }\n  }\n  return runs;\n}\n\nfunction buildTabGroup(codeBlocks: HastNode[], groupId: number): HastNode {\n  const titles = codeBlocks.map((block) => getPagesmithCodeBlockTitle(block)!);\n  const languages = codeBlocks.map((block) => getPagesmithCodeBlockLanguage(block));\n  const inheritedStyle =\n    typeof codeBlocks[0]?.properties?.style === \"string\" &&\n    codeBlocks[0].properties.style.length > 0\n      ? codeBlocks[0].properties.style\n      : undefined;\n  const tabButtons: HastNode[] = titles.map((title, i) =>\n    h(\n      \"button\",\n      {\n        className: [\"ps-code-tab\"],\n        role: \"tab\",\n        \"aria-selected\": i === 0 ? \"true\" : \"false\",\n        \"aria-controls\": `ct-${groupId}-p${i}`,\n        id: `ct-${groupId}-t${i}`,\n        tabindex: i === 0 ? 0 : -1,\n        type: \"button\",\n      },\n      [createTabLabel(title, languages[i])],\n    ),\n  );\n\n  const panels: HastNode[] = codeBlocks.map((block, i) =>\n    h(\n      \"div\",\n      {\n        className: [\"ps-code-tab-panel\"],\n        role: \"tabpanel\",\n        id: `ct-${groupId}-p${i}`,\n        \"aria-labelledby\": `ct-${groupId}-t${i}`,\n      },\n      [block],\n    ),\n  );\n\n  return h(\n    \"div\",\n    {\n      className: [\"ps-code-tabs\"],\n      style: inheritedStyle,\n    },\n    [\n      h(\"div\", { className: [\"ps-code-tabs-header\"] }, [\n        h(\"div\", { className: [\"ps-code-tabs-nav\"], role: \"tablist\" }, tabButtons),\n        h(\"div\", { className: [\"ps-code-tabs-actions\"] }, [createCopyButton()]),\n      ]),\n      h(\"div\", { className: [\"ps-code-tabs-panels\"] }, panels),\n    ],\n  );\n}\n\nexport default function rehypeCodeTabs() {\n  let groupCounter = 0;\n\n  return (tree: HastNode) => {\n    groupCounter = 0;\n    visit(tree);\n  };\n\n  function visit(node: HastNode): void {\n    if (!node.children) return;\n\n    const runs = findRuns(node.children);\n    if (runs.length > 0) {\n      // Process runs in reverse so indices stay valid\n      for (let r = runs.length - 1; r >= 0; r--) {\n        const { start, count } = runs[r];\n        const span = node.children.slice(start, start + count);\n        const codeBlocks = span.filter(isPagesmithCodeBlock);\n        const tabGroup = buildTabGroup(codeBlocks, groupCounter++);\n        node.children.splice(start, count, tabGroup);\n      }\n    }\n\n    for (const child of node.children) {\n      visit(child);\n    }\n  }\n}\n","import type { Element, ElementContent, Root, RootContent } from \"hast\";\nimport { dirname, extname, isAbsolute, relative, resolve } from \"path\";\nimport {\n  getGeneratedImageVariantPath,\n  getLocalImageDimensions,\n  getZoomImageVariantPath,\n  isConvertibleImagePath,\n} from \"../../assets/images\";\n\nconst LOCAL_IMAGE_EXT_PATTERN = /\\.(svg|png|jpe?g|gif|webp|avif|ico)$/i;\nconst IMG_TAG_PATTERN = /<img\\b[^>]*>/gi;\nconst HTML_ATTR_PATTERN = /([^\\s\"'=<>`/]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s\"'=<>`]+)))?/g;\nconst SIMPLE_NUMBER_PATTERN = /^\\s*(\\d+)(?:\\.\\d+)?\\s*$/u;\nconst PICTURE_TAG_PATTERN = /<\\/?picture\\b/gi;\nconst LIGHT_DARK_STEM_PATTERN = /^(.+)-(?:light|dark)$/i;\nconst INVERT_FILENAME_PATTERN = /\\.invert\\./i;\nconst SVG_EXT = \".svg\";\n\ntype HtmlAttribute = {\n  name: string;\n  value?: string;\n  quote?: '\"' | \"'\";\n};\n\n// ── Shared helpers ──\n\nfunction isRelativeRef(ref: string): boolean {\n  const { pathname } = splitRef(ref);\n  if (!pathname) return false;\n  if (pathname.startsWith(\"/\") || pathname.startsWith(\"//\")) return false;\n  return !/^[a-zA-Z][a-zA-Z\\d+.-]*:/.test(pathname);\n}\n\nfunction splitRef(ref: string): { pathname: string; suffix: string } {\n  const pathname = ref.split(/[?#]/u, 1)[0] ?? ref;\n  return { pathname, suffix: ref.slice(pathname.length) };\n}\n\nfunction isLocalImageRef(ref: string): boolean {\n  if (!isRelativeRef(ref)) return false;\n  return LOCAL_IMAGE_EXT_PATTERN.test(splitRef(ref).pathname);\n}\n\nfunction isPathInsideRoot(rootPath: string, candidatePath: string): boolean {\n  const rel = relative(resolve(rootPath), resolve(candidatePath));\n  return rel === \"\" || (!rel.startsWith(\"..\") && !isAbsolute(rel));\n}\n\nfunction resolveLocalImagePath(\n  currentFilePath: string,\n  ref: string,\n  assetRoot: string,\n): string | undefined {\n  if (!isLocalImageRef(ref)) return undefined;\n  const { pathname } = splitRef(ref);\n  const resolvedPath = resolve(dirname(currentFilePath), pathname);\n  return isPathInsideRoot(assetRoot, resolvedPath) ? resolvedPath : undefined;\n}\n\nfunction buildVariantRef(ref: string, format: \"avif\" | \"webp\"): string {\n  const { pathname, suffix } = splitRef(ref);\n  return `${getGeneratedImageVariantPath(pathname, format)}${suffix}`;\n}\n\n/**\n * Path to the high-resolution zoom variant for a raster source. SVG and other\n * non-convertible refs return `undefined` — the zoom modal can use the\n * displayed `<img>` `src` / `currentSrc` directly because those formats are\n * already full quality.\n */\nfunction buildZoomRef(ref: string): string | undefined {\n  if (isSvgRef(ref)) return undefined;\n  if (!isConvertibleImagePath(splitRef(ref).pathname)) return undefined;\n  const { pathname, suffix } = splitRef(ref);\n  return `${getZoomImageVariantPath(pathname)}${suffix}`;\n}\n\nfunction isSvgRef(ref: string): boolean {\n  return extname(splitRef(ref).pathname).toLowerCase() === SVG_EXT;\n}\n\nfunction isRasterRef(ref: string): boolean {\n  return isConvertibleImagePath(splitRef(ref).pathname);\n}\n\nfunction isInvertRef(ref: string): boolean {\n  const { pathname } = splitRef(ref);\n  const lastSlash = pathname.lastIndexOf(\"/\");\n  const fileName = lastSlash >= 0 ? pathname.slice(lastSlash + 1) : pathname;\n  return INVERT_FILENAME_PATTERN.test(fileName);\n}\n\nfunction appendClassName(properties: Element[\"properties\"], className: string): void {\n  const existing = properties.className;\n  if (Array.isArray(existing)) {\n    if (!existing.includes(className)) properties.className = [...existing, className];\n    return;\n  }\n  if (typeof existing === \"string\") {\n    const values = existing.split(/\\s+/).filter(Boolean);\n    if (!values.includes(className)) properties.className = [...values, className];\n    return;\n  }\n  properties.className = [className];\n}\n\n/**\n * Parse a filename into { stem, variant, ext } where variant is 'light' | 'dark' | undefined.\n * E.g. \"chart-light.png\" → { stem: \"chart\", variant: \"light\", ext: \".png\" }\n */\nfunction parseLightDarkFilename(\n  ref: string,\n): { stem: string; variant: \"light\" | \"dark\"; ext: string } | undefined {\n  const { pathname } = splitRef(ref);\n  const ext = extname(pathname);\n  const base = pathname.slice(0, -ext.length);\n  // Get just the filename portion (after the last /)\n  const lastSlash = base.lastIndexOf(\"/\");\n  const dirPart = lastSlash >= 0 ? base.slice(0, lastSlash + 1) : \"\";\n  const namePart = lastSlash >= 0 ? base.slice(lastSlash + 1) : base;\n  const match = namePart.match(LIGHT_DARK_STEM_PATTERN);\n  if (!match) return undefined;\n  const variant = namePart.toLowerCase().endsWith(\"-light\") ? \"light\" : \"dark\";\n  return { stem: `${dirPart}${match[1]}`, variant, ext };\n}\n\n// ── Dimension helpers ──\n\nfunction getNumericProperty(\n  properties: Element[\"properties\"] | undefined,\n  name: \"width\" | \"height\",\n): number | undefined {\n  const value = properties?.[name];\n  if (typeof value === \"number\" && value > 0) return value;\n  if (typeof value === \"string\" && SIMPLE_NUMBER_PATTERN.test(value)) {\n    return Math.max(1, Math.round(Number(value)));\n  }\n  return undefined;\n}\n\nfunction applyMaxWidthStyle(properties: Element[\"properties\"], widthPx: number): void {\n  const maxWidthRule = `max-width:min(${widthPx}px,100%)`;\n  const existing = typeof properties.style === \"string\" ? properties.style : \"\";\n  properties.style = existing ? `${existing.replace(/;\\s*$/, \"\")};${maxWidthRule}` : maxWidthRule;\n}\n\nfunction applyIntrinsicDimensions(\n  properties: Element[\"properties\"],\n  intrinsic: { width: number; height: number },\n): void {\n  const width = getNumericProperty(properties, \"width\");\n  const height = getNumericProperty(properties, \"height\");\n\n  if (width == null && height == null) {\n    properties.width = intrinsic.width;\n    properties.height = intrinsic.height;\n    applyMaxWidthStyle(properties, intrinsic.width);\n    return;\n  }\n\n  if (width != null && height == null) {\n    properties.height = Math.max(1, Math.round((width * intrinsic.height) / intrinsic.width));\n    applyMaxWidthStyle(properties, width);\n    return;\n  }\n\n  if (height != null && width == null) {\n    const computedWidth = Math.max(1, Math.round((height * intrinsic.width) / intrinsic.height));\n    properties.width = computedWidth;\n    applyMaxWidthStyle(properties, computedWidth);\n  }\n}\n\n// ── HAST element builders ──\n\nfunction shouldWrapInPicture(\n  src: string,\n  properties: Element[\"properties\"] | undefined,\n  insidePicture = false,\n): boolean {\n  if (isSvgRef(src)) return false;\n  // Only wrap convertible images — .avif source files don't need picture wrapping\n  if (!isConvertibleImagePath(splitRef(src).pathname)) return false;\n  if (insidePicture) return false;\n  if (typeof properties?.srcset === \"string\") return false;\n  if (typeof properties?.sizes === \"string\") return false;\n  return true;\n}\n\nfunction createPictureElement(img: Element, src: string): Element {\n  return {\n    type: \"element\",\n    tagName: \"picture\",\n    properties: {},\n    children: [\n      {\n        type: \"element\",\n        tagName: \"source\",\n        properties: {\n          srcset: buildVariantRef(src, \"avif\"),\n          type: \"image/avif\",\n        },\n        children: [],\n      },\n      {\n        type: \"element\",\n        tagName: \"source\",\n        properties: {\n          srcset: buildVariantRef(src, \"webp\"),\n          type: \"image/webp\",\n        },\n        children: [],\n      },\n      {\n        type: \"element\",\n        tagName: \"img\",\n        properties: {\n          ...(img.properties ?? {}),\n          // Use webp as the fallback src for broadest modern browser support\n          src: buildVariantRef(src, \"webp\"),\n        },\n        children: [],\n      },\n    ],\n  };\n}\n\nfunction createSourceElement(\n  srcset: string,\n  type: string,\n  options?: { media?: string; scheme?: \"light\" | \"dark\" },\n): Element {\n  const properties: Record<string, string> = { srcset, type };\n  if (options?.media) properties.media = options.media;\n  if (options?.scheme) properties[\"data-scheme\"] = options.scheme;\n  return { type: \"element\", tagName: \"source\", properties, children: [] };\n}\n\nfunction createThemedPictureElement(img: Element, lightSrc: string, darkSrc: string): Element {\n  const lightIsSvg = isSvgRef(lightSrc);\n  const darkIsSvg = isSvgRef(darkSrc);\n\n  const sources: Element[] = [];\n  const darkMedia = {\n    media: \"(prefers-color-scheme: dark)\",\n    scheme: \"dark\" as const,\n  };\n\n  if (darkIsSvg) {\n    sources.push(createSourceElement(darkSrc, \"image/svg+xml\", darkMedia));\n  } else {\n    sources.push(\n      createSourceElement(buildVariantRef(darkSrc, \"avif\"), \"image/avif\", darkMedia),\n      createSourceElement(buildVariantRef(darkSrc, \"webp\"), \"image/webp\", darkMedia),\n    );\n  }\n\n  if (lightIsSvg) {\n    sources.push(createSourceElement(lightSrc, \"image/svg+xml\", { scheme: \"light\" }));\n  } else {\n    sources.push(\n      createSourceElement(buildVariantRef(lightSrc, \"avif\"), \"image/avif\", {\n        scheme: \"light\",\n      }),\n      createSourceElement(buildVariantRef(lightSrc, \"webp\"), \"image/webp\", {\n        scheme: \"light\",\n      }),\n    );\n  }\n\n  // Fallback img: original source for the light variant (SVG as-is, raster original format)\n  const fallbackSrc = lightSrc;\n\n  return {\n    type: \"element\",\n    tagName: \"picture\",\n    properties: {},\n    children: [\n      ...sources,\n      {\n        type: \"element\",\n        tagName: \"img\",\n        properties: { ...(img.properties ?? {}), src: fallbackSrc },\n        children: [],\n      },\n    ],\n  };\n}\n\nfunction createZoomButtonElement(): Element {\n  return {\n    type: \"element\",\n    tagName: \"button\",\n    properties: {\n      type: \"button\",\n      className: [\"ps-img-zoom-btn\"],\n      hidden: true,\n      \"aria-label\": \"Zoom image\",\n      \"data-ps-img-zoom-btn\": \"\",\n    },\n    children: [\n      {\n        type: \"element\",\n        tagName: \"svg\",\n        properties: {\n          className: [\"ps-img-zoom-icon\"],\n          viewBox: \"0 0 24 24\",\n          width: \"16\",\n          height: \"16\",\n          fill: \"none\",\n          stroke: \"currentColor\",\n          \"stroke-width\": \"2\",\n          \"stroke-linecap\": \"round\",\n          \"stroke-linejoin\": \"round\",\n          \"aria-hidden\": \"true\",\n        },\n        children: [\n          {\n            type: \"element\",\n            tagName: \"path\",\n            properties: { d: \"M3 9V3h6 M21 9V3h-6 M3 15v6h6 M21 15v6h-6\" },\n            children: [],\n          },\n        ],\n      },\n    ],\n  };\n}\n\nfunction createFigureElement(\n  content: Element,\n  title: string | undefined,\n  classNames: string[],\n  zoomButton?: Element,\n): Element {\n  const children: ElementContent[] = [content];\n  if (title) {\n    children.push({\n      type: \"element\",\n      tagName: \"figcaption\",\n      properties: {},\n      children: [{ type: \"text\", value: title }],\n    });\n  }\n  if (zoomButton) children.push(zoomButton);\n  return {\n    type: \"element\",\n    tagName: \"figure\",\n    properties: { className: classNames },\n    children,\n  };\n}\n\n// ── Light/dark pair detection for HAST nodes ──\n\ntype ImageCandidate = {\n  index: number;\n  src: string;\n  parsed: { stem: string; variant: \"light\" | \"dark\"; ext: string };\n  node: Element;\n};\n\nfunction isWhitespaceTextNode(node: RootContent): boolean {\n  return node.type === \"text\" && /^\\s*$/u.test((node as { value: string }).value);\n}\n\nfunction getImageSrc(node: RootContent): string | undefined {\n  if (node.type !== \"element\") return undefined;\n  if (node.tagName === \"img\")\n    return typeof node.properties?.src === \"string\" ? node.properties.src : undefined;\n  // Also check if it's a p wrapping a single img (markdown wraps images in <p>)\n  if (node.tagName === \"p\" && node.children?.length === 1) {\n    const child = node.children[0] as Element;\n    if (child?.type === \"element\" && child.tagName === \"img\") {\n      return typeof child.properties?.src === \"string\" ? child.properties.src : undefined;\n    }\n  }\n  return undefined;\n}\n\nfunction getImageElement(node: RootContent): Element | undefined {\n  if (node.type !== \"element\") return undefined;\n  if (node.tagName === \"img\") return node;\n  if (node.tagName === \"p\" && node.children?.length === 1) {\n    const child = node.children[0] as Element;\n    if (child?.type === \"element\" && child.tagName === \"img\") return child;\n  }\n  return undefined;\n}\n\n/**\n * Collect all light/dark-suffixed images in a parent and validate they have pairs.\n * Warns for any -light or -dark image missing its counterpart but continues processing.\n */\nfunction validateLightDarkPairs(parent: Root | Element, currentFilePath: string): void {\n  const children = parent.children as RootContent[];\n  const candidates: ImageCandidate[] = [];\n\n  for (let i = 0; i < children.length; i++) {\n    const src = getImageSrc(children[i]);\n    if (!src || !isLocalImageRef(src)) continue;\n    const parsed = parseLightDarkFilename(src);\n    if (!parsed) continue;\n    const node = getImageElement(children[i]);\n    if (node) candidates.push({ index: i, src, parsed, node });\n  }\n\n  // Group by stem and check each stem has both variants\n  const byStem = new Map<string, ImageCandidate[]>();\n  for (const c of candidates) {\n    const group = byStem.get(c.parsed.stem) ?? [];\n    group.push(c);\n    byStem.set(c.parsed.stem, group);\n  }\n\n  for (const [, group] of byStem) {\n    const variants = new Set(group.map((c) => c.parsed.variant));\n    if (variants.size === 1) {\n      const missing = variants.has(\"light\") ? \"dark\" : \"light\";\n      const present = group[0].src;\n      console.warn(\n        `[pagesmith] Image \"${present}\" in ${currentFilePath} has a -${group[0].parsed.variant} suffix but no matching -${missing} counterpart. ` +\n          `When using -light/-dark suffixes, both variants must be present as consecutive images.`,\n      );\n    }\n  }\n}\n\n/**\n * Scan parent children for consecutive light/dark image pairs and merge them.\n * Returns indices that were consumed by pairs (to skip during normal processing).\n */\nasync function detectAndMergePairs(\n  parent: Root | Element,\n  currentFilePath: string,\n  assetRoot: string,\n): Promise<Set<number>> {\n  const consumed = new Set<number>();\n  const children = parent.children as RootContent[];\n  if (children.length < 2) return consumed;\n\n  // Validate all light/dark images have counterparts before merging\n  validateLightDarkPairs(parent, currentFilePath);\n\n  let i = 0;\n  while (i < children.length - 1) {\n    const srcA = getImageSrc(children[i]);\n    if (!srcA || !isLocalImageRef(srcA)) {\n      i++;\n      continue;\n    }\n\n    const parsedA = parseLightDarkFilename(srcA);\n    if (!parsedA) {\n      i++;\n      continue;\n    }\n\n    // Look ahead for the matching pair (skip whitespace)\n    let j = i + 1;\n    while (j < children.length && isWhitespaceTextNode(children[j])) j++;\n    if (j >= children.length) {\n      i++;\n      continue;\n    }\n\n    const srcB = getImageSrc(children[j]);\n    if (!srcB || !isLocalImageRef(srcB)) {\n      i++;\n      continue;\n    }\n\n    const parsedB = parseLightDarkFilename(srcB);\n    if (!parsedB) {\n      i++;\n      continue;\n    }\n\n    // Check they form a valid light/dark pair\n    if (parsedA.stem !== parsedB.stem || parsedA.variant === parsedB.variant) {\n      i++;\n      continue;\n    }\n\n    const lightSrc = parsedA.variant === \"light\" ? srcA : srcB;\n    const darkSrc = parsedA.variant === \"dark\" ? srcA : srcB;\n    const lightImg =\n      parsedA.variant === \"light\" ? getImageElement(children[i])! : getImageElement(children[j])!;\n\n    // Apply intrinsic dimensions from the light image\n    const lightPath = resolveLocalImagePath(currentFilePath, lightSrc, assetRoot);\n    if (lightPath) {\n      const intrinsic = await getLocalImageDimensions(lightPath);\n      if (intrinsic) {\n        lightImg.properties = lightImg.properties || {};\n        applyIntrinsicDimensions(lightImg.properties, intrinsic);\n      }\n    }\n\n    // Use light image's properties (alt, title, dimensions)\n    const title =\n      typeof lightImg.properties?.title === \"string\" ? lightImg.properties.title : undefined;\n    // Remove title from img properties (it goes to figcaption)\n    const imgProps = { ...(lightImg.properties ?? {}) };\n    delete imgProps.title;\n\n    // Themed raster pairs need the high-res zoom variant per scheme; themed SVG\n    // pairs use the displayed <picture> source directly, so we skip the attrs\n    // entirely when both variants are SVG (the runtime falls back to currentSrc).\n    const lightZoom = buildZoomRef(lightSrc);\n    const darkZoom = buildZoomRef(darkSrc);\n    if (lightZoom && darkZoom) {\n      imgProps[\"data-zoom-src-light\"] = lightZoom;\n      imgProps[\"data-zoom-src-dark\"] = darkZoom;\n      imgProps[\"data-zoom-type-light\"] = \"image/webp\";\n      imgProps[\"data-zoom-type-dark\"] = \"image/webp\";\n    }\n\n    const themedPicture = createThemedPictureElement(\n      { ...lightImg, properties: imgProps } as Element,\n      lightSrc,\n      darkSrc,\n    );\n    const figure = createFigureElement(\n      themedPicture,\n      title,\n      [\"ps-figure\", \"ps-figure-themed\", \"ps-figure-zoomable\"],\n      createZoomButtonElement(),\n    );\n\n    // Replace the first image with the merged figure, mark everything between for removal\n    children[i] = figure as unknown as RootContent;\n    consumed.add(i); // Mark as already processed\n    for (let k = i + 1; k <= j; k++) consumed.add(k);\n\n    // Remove consumed nodes (j down to i+1)\n    children.splice(i + 1, j - i);\n\n    i++; // Move past the merged figure\n  }\n\n  return consumed;\n}\n\n// ── Raw HTML helpers ──\n\nfunction parseHtmlAttributes(imgTag: string): {\n  attrs: HtmlAttribute[];\n  selfClosing: boolean;\n} {\n  const selfClosing = /\\/>\\s*$/u.test(imgTag);\n  const body = imgTag.replace(/^<img\\b/i, \"\").replace(/\\s*\\/?>\\s*$/u, \"\");\n  const attrs: HtmlAttribute[] = [];\n\n  for (const match of body.matchAll(HTML_ATTR_PATTERN)) {\n    const name = match[1];\n    const rawValue = match[2] ?? match[3] ?? match[4];\n    const quote = match[2] !== undefined ? '\"' : match[3] !== undefined ? \"'\" : undefined;\n    attrs.push({ name, value: rawValue, quote });\n  }\n\n  return { attrs, selfClosing };\n}\n\nfunction renderHtmlAttributes(attrs: HtmlAttribute[]): string {\n  return attrs\n    .map((attr) => {\n      if (attr.value == null) return ` ${attr.name}`;\n      const quote = attr.quote ?? '\"';\n      const escaped = attr.value\n        .replace(/&/g, \"&amp;\")\n        .replace(/\"/g, \"&quot;\")\n        .replace(/'/g, \"&#39;\")\n        .replace(/</g, \"&lt;\");\n      return ` ${attr.name}=${quote}${escaped}${quote}`;\n    })\n    .join(\"\");\n}\n\nfunction getHtmlAttribute(attrs: HtmlAttribute[], name: string): HtmlAttribute | undefined {\n  return attrs.find((attr) => attr.name.toLowerCase() === name.toLowerCase());\n}\n\nfunction getNumericHtmlAttribute(attrs: HtmlAttribute[], name: string): number | undefined {\n  const attr = getHtmlAttribute(attrs, name);\n  if (!attr?.value || !SIMPLE_NUMBER_PATTERN.test(attr.value)) return undefined;\n  return Math.max(1, Math.round(Number(attr.value)));\n}\n\nfunction setHtmlAttribute(attrs: HtmlAttribute[], name: string, value: string): void {\n  const existing = getHtmlAttribute(attrs, name);\n  if (existing) {\n    existing.value = value;\n    if (!existing.quote) existing.quote = '\"';\n    return;\n  }\n  attrs.push({ name, value, quote: '\"' });\n}\n\nfunction removeHtmlAttribute(attrs: HtmlAttribute[], name: string): void {\n  const idx = attrs.findIndex((attr) => attr.name.toLowerCase() === name.toLowerCase());\n  if (idx >= 0) attrs.splice(idx, 1);\n}\n\nfunction applyMaxWidthHtmlStyle(attrs: HtmlAttribute[], widthPx: number): void {\n  const maxWidthRule = `max-width:min(${widthPx}px,100%)`;\n  const existing = getHtmlAttribute(attrs, \"style\")?.value ?? \"\";\n  const value = existing ? `${existing.replace(/;\\s*$/, \"\")};${maxWidthRule}` : maxWidthRule;\n  setHtmlAttribute(attrs, \"style\", value);\n}\n\nfunction applyIntrinsicHtmlDimensions(\n  attrs: HtmlAttribute[],\n  intrinsic: { width: number; height: number },\n): void {\n  const width = getNumericHtmlAttribute(attrs, \"width\");\n  const height = getNumericHtmlAttribute(attrs, \"height\");\n\n  if (width == null && height == null) {\n    setHtmlAttribute(attrs, \"width\", String(intrinsic.width));\n    setHtmlAttribute(attrs, \"height\", String(intrinsic.height));\n    applyMaxWidthHtmlStyle(attrs, intrinsic.width);\n    return;\n  }\n\n  if (width != null && height == null) {\n    setHtmlAttribute(\n      attrs,\n      \"height\",\n      String(Math.max(1, Math.round((width * intrinsic.height) / intrinsic.width))),\n    );\n    applyMaxWidthHtmlStyle(attrs, width);\n    return;\n  }\n\n  if (height != null && width == null) {\n    const computedWidth = Math.max(1, Math.round((height * intrinsic.width) / intrinsic.height));\n    setHtmlAttribute(attrs, \"width\", String(computedWidth));\n    applyMaxWidthHtmlStyle(attrs, computedWidth);\n  }\n}\n\nfunction renderHtmlImgTag(attrs: HtmlAttribute[]): string {\n  return `<img${renderHtmlAttributes(attrs)}>`;\n}\n\nfunction escapeHtml(value: string): string {\n  return value\n    .replace(/&/g, \"&amp;\")\n    .replace(/</g, \"&lt;\")\n    .replace(/>/g, \"&gt;\")\n    .replace(/\"/g, \"&quot;\");\n}\n\nfunction getPictureTagDelta(html: string): number {\n  let delta = 0;\n  for (const match of html.matchAll(PICTURE_TAG_PATTERN)) {\n    delta += match[0].startsWith(\"</\") ? -1 : 1;\n  }\n  return delta;\n}\n\nfunction shouldWrapHtmlTagInPicture(\n  attrs: HtmlAttribute[],\n  src: string,\n  allowPictureConversion: boolean,\n): boolean {\n  if (!allowPictureConversion) return false;\n  if (isSvgRef(src)) return false;\n  if (!isConvertibleImagePath(splitRef(src).pathname)) return false;\n  if (getHtmlAttribute(attrs, \"srcset\")?.value) return false;\n  if (getHtmlAttribute(attrs, \"sizes\")?.value) return false;\n  return true;\n}\n\nconst ZOOM_BUTTON_HTML =\n  '<button type=\"button\" class=\"ps-img-zoom-btn\" hidden aria-label=\"Zoom image\" data-ps-img-zoom-btn>' +\n  '<svg class=\"ps-img-zoom-icon\" viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">' +\n  '<path d=\"M3 9V3h6 M21 9V3h-6 M3 15v6h6 M21 15v6h-6\"/>' +\n  \"</svg>\" +\n  \"</button>\";\n\nfunction buildHtmlPictureWithFigure(attrs: HtmlAttribute[], src: string): string {\n  const title = getHtmlAttribute(attrs, \"title\")?.value;\n  removeHtmlAttribute(attrs, \"title\");\n  const zoomRef = buildZoomRef(src);\n  if (zoomRef) {\n    setHtmlAttribute(attrs, \"data-zoom-src\", zoomRef);\n    setHtmlAttribute(attrs, \"data-zoom-type\", \"image/webp\");\n  }\n  // Change img src to webp fallback\n  setHtmlAttribute(attrs, \"src\", buildVariantRef(src, \"webp\"));\n  const img = renderHtmlImgTag(attrs);\n  const avifSrcset = escapeHtml(buildVariantRef(src, \"avif\"));\n  const webpSrcset = escapeHtml(buildVariantRef(src, \"webp\"));\n  const figcaption = title ? `<figcaption>${escapeHtml(title)}</figcaption>` : \"\";\n  return [\n    '<figure class=\"ps-figure ps-figure-zoomable\">',\n    \"<picture>\",\n    `<source srcset=\"${avifSrcset}\" type=\"image/avif\">`,\n    `<source srcset=\"${webpSrcset}\" type=\"image/webp\">`,\n    img,\n    \"</picture>\",\n    figcaption,\n    ZOOM_BUTTON_HTML,\n    \"</figure>\",\n  ]\n    .filter(Boolean)\n    .join(\"\");\n}\n\nfunction buildHtmlSvgFigure(attrs: HtmlAttribute[]): string {\n  const title = getHtmlAttribute(attrs, \"title\")?.value;\n  removeHtmlAttribute(attrs, \"title\");\n  // SVG zoom uses the displayed src directly — no data-zoom-src needed.\n  const img = renderHtmlImgTag(attrs);\n  const figcaption = title ? `<figcaption>${escapeHtml(title)}</figcaption>` : \"\";\n  return [\n    '<figure class=\"ps-figure ps-figure-zoomable\">',\n    img,\n    figcaption,\n    ZOOM_BUTTON_HTML,\n    \"</figure>\",\n  ]\n    .filter(Boolean)\n    .join(\"\");\n}\n\n/**\n * Apply intrinsic dimensions + invert-on-dark class to a raw `<img>` tag\n * without changing its wrapping. Used when the img already lives inside a\n * `<figure>` or `<picture>` the author wrote directly, so we must not add a\n * new figure/picture around it.\n */\nasync function enrichRawImageTag(\n  imgTag: string,\n  currentFilePath: string,\n  assetRoot: string,\n): Promise<string> {\n  const { attrs } = parseHtmlAttributes(imgTag);\n  const src = getHtmlAttribute(attrs, \"src\")?.value;\n  if (typeof src !== \"string\" || !isLocalImageRef(src)) return imgTag;\n\n  const sourcePath = resolveLocalImagePath(currentFilePath, src, assetRoot);\n  if (sourcePath) {\n    const intrinsic = await getLocalImageDimensions(sourcePath);\n    if (intrinsic) applyIntrinsicHtmlDimensions(attrs, intrinsic);\n  }\n\n  if (isInvertRef(src)) {\n    const existing = getHtmlAttribute(attrs, \"class\")?.value ?? \"\";\n    const classes = existing.split(/\\s+/).filter(Boolean);\n    if (!classes.includes(\"invert-on-dark\")) {\n      classes.push(\"invert-on-dark\");\n      setHtmlAttribute(attrs, \"class\", classes.join(\" \"));\n    }\n  }\n\n  // Stamp zoom data so the runtime can pick it up even when the author wrote\n  // the surrounding <picture>/<figure> by hand. Skip for SVG (the displayed src\n  // is already full quality).\n  if (!getHtmlAttribute(attrs, \"data-zoom-src\")?.value) {\n    const zoomRef = buildZoomRef(src);\n    if (zoomRef) {\n      setHtmlAttribute(attrs, \"data-zoom-src\", zoomRef);\n      setHtmlAttribute(attrs, \"data-zoom-type\", \"image/webp\");\n    }\n  }\n\n  return renderHtmlImgTag(attrs);\n}\n\nasync function transformRawImageTag(\n  imgTag: string,\n  currentFilePath: string,\n  assetRoot: string,\n  allowPictureConversion: boolean,\n): Promise<string> {\n  const { attrs } = parseHtmlAttributes(imgTag);\n  const src = getHtmlAttribute(attrs, \"src\")?.value;\n  if (typeof src !== \"string\" || !isLocalImageRef(src)) return imgTag;\n\n  const sourcePath = resolveLocalImagePath(currentFilePath, src, assetRoot);\n  if (!sourcePath) return imgTag;\n\n  const intrinsic = await getLocalImageDimensions(sourcePath);\n  if (!intrinsic) return imgTag;\n\n  applyIntrinsicHtmlDimensions(attrs, intrinsic);\n\n  // Apply invert-on-dark class for .invert. filenames\n  if (isInvertRef(src)) {\n    const existing = getHtmlAttribute(attrs, \"class\")?.value ?? \"\";\n    const classes = existing.split(/\\s+/).filter(Boolean);\n    if (!classes.includes(\"invert-on-dark\")) {\n      classes.push(\"invert-on-dark\");\n      setHtmlAttribute(attrs, \"class\", classes.join(\" \"));\n    }\n  }\n\n  if (isSvgRef(src)) {\n    return buildHtmlSvgFigure(attrs);\n  }\n\n  if (shouldWrapHtmlTagInPicture(attrs, src, allowPictureConversion)) {\n    return buildHtmlPictureWithFigure(attrs, src);\n  }\n\n  // Non-convertible raster or already inside picture — just figure wrap\n  const title = getHtmlAttribute(attrs, \"title\")?.value;\n  removeHtmlAttribute(attrs, \"title\");\n  const zoomRef = buildZoomRef(src);\n  if (zoomRef) {\n    setHtmlAttribute(attrs, \"data-zoom-src\", zoomRef);\n    setHtmlAttribute(attrs, \"data-zoom-type\", \"image/webp\");\n  }\n  const img = renderHtmlImgTag(attrs);\n  const figcaption = title ? `<figcaption>${escapeHtml(title)}</figcaption>` : \"\";\n  return `<figure class=\"ps-figure ps-figure-zoomable\">${img}${figcaption}${ZOOM_BUTTON_HTML}</figure>`;\n}\n\nasync function transformRawHtmlImages(\n  html: string,\n  currentFilePath: string,\n  assetRoot: string,\n  parentInsidePicture = false,\n): Promise<string> {\n  let output = \"\";\n  let lastIndex = 0;\n\n  for (const match of html.matchAll(IMG_TAG_PATTERN)) {\n    const index = match.index ?? 0;\n    const imgTag = match[0];\n    const before = html.slice(0, index).toLowerCase();\n    const insidePicture =\n      parentInsidePicture || before.lastIndexOf(\"<picture\") > before.lastIndexOf(\"</picture>\");\n    const insideFigure = before.lastIndexOf(\"<figure\") > before.lastIndexOf(\"</figure>\");\n    output += html.slice(lastIndex, index);\n\n    // If the img is already inside a <figure> or <picture>, we must NOT wrap\n    // it in a new <figure>. `<figure>` nested inside `<picture>` is invalid\n    // HTML and collapses the theme-source fallback. Instead, just enrich the\n    // existing img tag with intrinsic dimensions and the invert class.\n    if (insideFigure || insidePicture) {\n      output += await enrichRawImageTag(imgTag, currentFilePath, assetRoot);\n    } else {\n      output += await transformRawImageTag(imgTag, currentFilePath, assetRoot, true);\n    }\n    lastIndex = index + imgTag.length;\n  }\n\n  output += html.slice(lastIndex);\n  return output;\n}\n\n// ── HAST tree walker ──\n\nasync function processImageNode(\n  node: Element,\n  currentFilePath: string,\n  assetRoot: string,\n  insidePicture: boolean,\n  insideLink: boolean,\n  parent?: Root | Element,\n  index?: number,\n): Promise<void> {\n  const src = node.properties?.src;\n  if (typeof src !== \"string\" || !isLocalImageRef(src)) return;\n\n  const sourcePath = resolveLocalImagePath(currentFilePath, src, assetRoot);\n  if (!sourcePath) return;\n\n  const intrinsic = await getLocalImageDimensions(sourcePath);\n  if (!intrinsic) return;\n\n  node.properties = node.properties || {};\n  applyIntrinsicDimensions(node.properties, intrinsic);\n\n  // Apply invert-on-dark class for .invert. filenames\n  if (isInvertRef(src)) {\n    appendClassName(node.properties, \"invert-on-dark\");\n  }\n\n  // Don't figure-wrap images inside links — it would break the link structure.\n  // Don't figure-wrap images already inside a <picture> — a figure nested inside\n  // a picture is invalid HTML (figure must wrap picture, not the other way\n  // around). Leave those imgs alone; the surrounding author-written picture is\n  // preserved as-is and the caller is responsible for wrapping it in a figure.\n  if (insideLink || insidePicture || !parent || index === undefined) return;\n\n  const title = typeof node.properties.title === \"string\" ? node.properties.title : undefined;\n  // Remove title from img (it will go to figcaption)\n  delete node.properties.title;\n\n  // For raster sources, stamp the dedicated zoom variant on the underlying\n  // <img>; SVG and other non-convertible formats use the displayed src directly\n  // and need no extra attribute.\n  const zoomRef = buildZoomRef(src);\n  if (zoomRef) {\n    node.properties[\"data-zoom-src\"] = zoomRef;\n    node.properties[\"data-zoom-type\"] = \"image/webp\";\n  }\n\n  let innerContent: Element;\n\n  if (shouldWrapInPicture(src, node.properties, insidePicture)) {\n    innerContent = createPictureElement(node, src);\n  } else {\n    innerContent = node;\n  }\n\n  const figure = createFigureElement(\n    innerContent,\n    title,\n    [\"ps-figure\", \"ps-figure-zoomable\"],\n    createZoomButtonElement(),\n  );\n  parent.children[index] = figure as unknown as RootContent;\n}\n\nasync function walk(\n  node: RootContent | Root,\n  currentFilePath: string,\n  assetRoot: string,\n  insidePicture = false,\n  insideFigure = false,\n  insideLink = false,\n  parent?: Root | Element,\n  index?: number,\n): Promise<void> {\n  if (node.type === \"raw\") {\n    node.value = await transformRawHtmlImages(\n      node.value,\n      currentFilePath,\n      assetRoot,\n      insidePicture,\n    );\n    return;\n  }\n\n  if (node.type === \"element\" && node.tagName === \"img\" && !insideFigure) {\n    await processImageNode(\n      node,\n      currentFilePath,\n      assetRoot,\n      insidePicture,\n      insideLink,\n      parent,\n      index,\n    );\n    return;\n  }\n\n  if (\"children\" in node && Array.isArray(node.children)) {\n    const parentElement = node as Root | Element;\n\n    // First pass: detect and merge light/dark pairs (only at block-level parents)\n    if (!insideFigure && !insidePicture && !insideLink) {\n      await detectAndMergePairs(parentElement, currentFilePath, assetRoot);\n    }\n\n    // Second pass: walk remaining children\n    let siblingInsidePicture = insidePicture;\n    const parentIsPicture = node.type === \"element\" && node.tagName === \"picture\";\n    const parentIsFigure = node.type === \"element\" && node.tagName === \"figure\";\n    const parentIsLink = node.type === \"element\" && node.tagName === \"a\";\n    for (let childIndex = 0; childIndex < node.children.length; childIndex++) {\n      const child = node.children[childIndex];\n      const childInsidePicture = parentIsPicture || siblingInsidePicture;\n      const childInsideFigure = parentIsFigure || insideFigure;\n      const childInsideLink = parentIsLink || insideLink;\n\n      // Skip already-processed figures from pair detection\n      if (\n        child.type === \"element\" &&\n        child.tagName === \"figure\" &&\n        Array.isArray(child.properties?.className) &&\n        (child.properties.className as string[]).includes(\"ps-figure\")\n      ) {\n        continue;\n      }\n\n      await walk(\n        child as RootContent,\n        currentFilePath,\n        assetRoot,\n        childInsidePicture,\n        childInsideFigure,\n        childInsideLink,\n        parentElement,\n        childIndex,\n      );\n      if (child.type === \"raw\") {\n        const delta = getPictureTagDelta(child.value);\n        if (delta > 0) siblingInsidePicture = true;\n        else if (delta < 0) siblingInsidePicture = false;\n      }\n    }\n  }\n}\n\n// ── Loading-hint stamping ──\n\n/**\n * Running document-order state for the loading-hint pass. `assigned` counts how\n * many content images have been seen so far; the first `eagerCount` are eager.\n */\ntype LoadingHintState = { assigned: number; eagerCount: number };\n\nconst IMG_HINT_ATTR_PATTERN = /\\b(?:loading|fetchpriority)\\s*=/i;\nconst IMG_DECODING_ATTR_PATTERN = /\\bdecoding\\s*=/i;\nconst CLASS_ATTR_PATTERN = /\\bclass\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)')/i;\n\n/**\n * Classes marking the *dark* half of a CSS-toggled light/dark image pair\n * (`<img class=\"only-light\">` + `<img class=\"only-dark\">`, the docs diagram\n * embed convention). Both images live in the DOM but only one is ever visible,\n * so the pair is a single logical image and must consume a single slot in the\n * eager/lazy budget.\n */\nconst DARK_TOGGLE_CLASSES = new Set([\"only-dark\", \"show-on-dark\"]);\n\nfunction classListHasDarkToggle(classValue: unknown): boolean {\n  const classes = Array.isArray(classValue)\n    ? classValue.map((c) => String(c))\n    : typeof classValue === \"string\"\n      ? classValue.split(/\\s+/)\n      : [];\n  return classes.some((c) => DARK_TOGGLE_CLASSES.has(c));\n}\n\nfunction rawImgHasDarkToggle(imgTag: string): boolean {\n  const match = CLASS_ATTR_PATTERN.exec(imgTag);\n  return classListHasDarkToggle(match ? (match[1] ?? match[2] ?? \"\") : \"\");\n}\n\n/**\n * Advance the counter and report whether this image should load eagerly.\n *\n * `pairedSecondary` marks the dark half of a themed toggle pair: it mirrors the\n * eager/lazy decision of the immediately-preceding primary (light) image and\n * does **not** advance the counter, so a light/dark pair counts as one logical\n * image. A leading dark-toggle with no preceding image falls back to normal\n * counting.\n */\nfunction takeIsEager(state: LoadingHintState, pairedSecondary = false): boolean {\n  if (pairedSecondary && state.assigned > 0) {\n    return state.assigned - 1 < state.eagerCount;\n  }\n  const eager = state.assigned < state.eagerCount;\n  state.assigned += 1;\n  return eager;\n}\n\n/** Stamp loading hints onto a HAST `<img>` element (skips if author set hints). */\nfunction stampHastImageHints(node: Element, state: LoadingHintState): void {\n  const properties = (node.properties = node.properties ?? {});\n  const eager = takeIsEager(state, classListHasDarkToggle(properties.className));\n  // Respect any author-provided loading strategy.\n  if (properties.loading != null || properties.fetchpriority != null) return;\n  if (eager) {\n    properties.fetchpriority = \"high\";\n  } else {\n    properties.loading = \"lazy\";\n    if (properties.decoding == null) properties.decoding = \"async\";\n  }\n}\n\n/** Inject loading-hint attributes just before the closing bracket of an `<img>` tag. */\nfunction stampRawImageTag(imgTag: string, state: LoadingHintState): string {\n  const eager = takeIsEager(state, rawImgHasDarkToggle(imgTag));\n  // Respect any author-provided loading strategy.\n  if (IMG_HINT_ATTR_PATTERN.test(imgTag)) return imgTag;\n\n  const parts: string[] = [];\n  if (eager) {\n    parts.push('fetchpriority=\"high\"');\n  } else {\n    parts.push('loading=\"lazy\"');\n    if (!IMG_DECODING_ATTR_PATTERN.test(imgTag)) parts.push('decoding=\"async\"');\n  }\n  const injection = parts.join(\" \");\n\n  if (/\\/>\\s*$/u.test(imgTag)) {\n    return imgTag.replace(/\\s*\\/>\\s*$/u, ` ${injection} />`);\n  }\n  return imgTag.replace(/\\s*>\\s*$/u, ` ${injection}>`);\n}\n\n/** Stamp loading hints onto every `<img>` inside a raw HTML string, in order. */\nfunction stampRawImageHints(html: string, state: LoadingHintState): string {\n  let output = \"\";\n  let lastIndex = 0;\n  for (const match of html.matchAll(IMG_TAG_PATTERN)) {\n    const index = match.index ?? 0;\n    output += html.slice(lastIndex, index);\n    output += stampRawImageTag(match[0], state);\n    lastIndex = index + match[0].length;\n  }\n  output += html.slice(lastIndex);\n  return output;\n}\n\n/**\n * Walk the fully-transformed tree in document order and stamp loading hints on\n * every content `<img>` — both HAST elements (including the `<img>` inside a\n * generated `<picture>`) and images embedded in raw HTML nodes. Runs after all\n * structural transforms so the counter reflects final document order.\n */\nfunction stampLoadingHints(node: Root | RootContent, state: LoadingHintState): void {\n  if (node.type === \"raw\") {\n    node.value = stampRawImageHints(node.value, state);\n    return;\n  }\n  if (node.type === \"element\" && node.tagName === \"img\") {\n    stampHastImageHints(node, state);\n    return;\n  }\n  if (\"children\" in node && Array.isArray(node.children)) {\n    for (const child of node.children) {\n      stampLoadingHints(child as RootContent, state);\n    }\n  }\n}\n\nexport type LocalImagesOptions = {\n  /**\n   * Emit browser loading hints on content images. When `true` (default), all\n   * but the first `eagerCount` images get `loading=\"lazy\" decoding=\"async\"` and\n   * the leading images get `fetchpriority=\"high\"`. Set `false` to opt out.\n   */\n  lazyLoading?: boolean;\n  /**\n   * Number of leading images (document order) marked eager with\n   * `fetchpriority=\"high\"` instead of lazy. Defaults to `1`.\n   */\n  eagerCount?: number;\n};\n\nexport function rehypeLocalImages(options: LocalImagesOptions = {}) {\n  const lazyLoading = options.lazyLoading ?? true;\n  const eagerCount = Math.max(0, Math.trunc(options.eagerCount ?? 1));\n\n  return async (tree: Root, file: { data?: Record<string, unknown> }) => {\n    const currentFilePath =\n      typeof file.data?.pagesmithFilePath === \"string\" ? file.data.pagesmithFilePath : undefined;\n    const assetRoot =\n      typeof file.data?.pagesmithAssetRoot === \"string\"\n        ? file.data.pagesmithAssetRoot\n        : currentFilePath\n          ? dirname(currentFilePath)\n          : undefined;\n\n    // Local-image enhancement (dimensions, picture wrapping, themed pairs) needs\n    // the source path; skip it when unavailable but still apply loading hints,\n    // which are independent of filesystem resolution.\n    if (currentFilePath && assetRoot) {\n      await walk(tree, currentFilePath, assetRoot);\n    }\n\n    if (lazyLoading) {\n      stampLoadingHints(tree, { assigned: 0, eagerCount });\n    }\n  };\n}\n","type HastNode = {\n  type: string;\n  tagName?: string;\n  properties?: Record<string, unknown>;\n  children?: HastNode[];\n};\n\nfunction isElement(node: HastNode): boolean {\n  return node.type === \"element\";\n}\n\nfunction hasClass(node: HastNode, cls: string): boolean {\n  const className = node.properties?.className;\n  if (Array.isArray(className)) return className.includes(cls);\n  if (typeof className === \"string\") return className.split(/\\s+/).includes(cls);\n  return false;\n}\n\nfunction h(tag: string, props: Record<string, unknown>, children: HastNode[] = []): HastNode {\n  return { type: \"element\", tagName: tag, properties: props, children };\n}\n\nexport default function rehypeScrollableTables() {\n  return (tree: HastNode) => {\n    visit(tree);\n  };\n\n  function visit(node: HastNode): void {\n    if (!node.children || hasClass(node, \"ps-table-scroll\")) return;\n\n    for (let index = 0; index < node.children.length; index++) {\n      const child = node.children[index];\n\n      if (isElement(child) && child.tagName === \"table\") {\n        // WCAG 2.2 AA — `scrollable-region-focusable`: any horizontally\n        // scrollable container must be reachable by keyboard. The wrapper\n        // becomes a tab stop with an accessible region role + label so\n        // keyboard users can scroll wide tables without a pointer.\n        node.children[index] = h(\n          \"div\",\n          {\n            className: [\"ps-table-scroll\"],\n            tabIndex: 0,\n            role: \"region\",\n            \"aria-label\": \"Scrollable table\",\n          },\n          [child],\n        );\n        continue;\n      }\n\n      visit(child);\n    }\n  }\n}\n","import matter from \"gray-matter\";\nimport { parse as parseYaml } from \"yaml\";\nimport { rehypeAccessibleEmojis } from \"rehype-accessible-emojis\";\nimport rehypeAutolinkHeadings from \"rehype-autolink-headings\";\nimport rehypeExternalLinks from \"rehype-external-links\";\nimport rehypeMathjax from \"rehype-mathjax/svg\";\nimport rehypeSlug from \"rehype-slug\";\nimport rehypeStringify from \"rehype-stringify\";\nimport remarkFrontmatter from \"remark-frontmatter\";\nimport remarkGfm from \"remark-gfm\";\nimport remarkGithubAlerts from \"remark-github-alerts\";\nimport remarkMath from \"remark-math\";\nimport remarkParse from \"remark-parse\";\nimport remarkRehype from \"remark-rehype\";\nimport remarkSmartypants from \"remark-smartypants\";\nimport { unified } from \"unified\";\nimport type { Heading } from \"../schemas/heading\";\nimport type { MarkdownConfig } from \"../schemas/markdown-config\";\nimport { applyPagesmithCodeRenderer } from \"./code/renderer\";\nimport rehypeA11y from \"./plugins/rehype-a11y\";\nimport rehypeCodeTabs from \"./plugins/rehype-code-tabs\";\nimport { rehypeLocalImages } from \"./plugins/rehype-local-images\";\nimport rehypeScrollableTables from \"./plugins/rehype-scrollable-tables\";\n\nexport type MarkdownResult = {\n  html: string;\n  headings: Heading[];\n  frontmatter: Record<string, unknown>;\n};\n\ntype PreExtractedMarkdown = {\n  content: string;\n  frontmatter: Record<string, unknown>;\n  fileData?: Record<string, unknown>;\n};\n\nexport type { MarkdownConfig };\n\nconst DEFAULT_MARKDOWN_CONFIG: MarkdownConfig = {};\n\n/** Default language aliases for fenced code blocks that Shiki doesn't recognize natively. */\nconst DEFAULT_LANG_ALIASES: Record<string, string> = {\n  dot: \"text\",\n  mermaid: \"text\",\n  plantuml: \"text\",\n  excalidraw: \"json\",\n  drawio: \"xml\",\n  proto: \"protobuf\",\n  ejs: \"html\",\n  hbs: \"handlebars\",\n};\n\nfunction getTextContent(node: any): string {\n  if (node.type === \"text\") return node.value || \"\";\n  if (node.children) return node.children.map(getTextContent).join(\"\");\n  return \"\";\n}\n\nfunction extractHeadings(tree: any, headings: Heading[]): void {\n  if (tree.type === \"element\" && /^h[1-6]$/.test(tree.tagName)) {\n    headings.push({\n      depth: parseInt(tree.tagName[1]),\n      text: getTextContent(tree),\n      slug: tree.properties?.id || \"\",\n    });\n  }\n  if (tree.children) {\n    for (const child of tree.children) {\n      extractHeadings(child, headings);\n    }\n  }\n}\n\nfunction contentMayContainMath(content: string): boolean {\n  return (\n    content.includes(\"$$\") ||\n    content.includes(\"\\\\(\") ||\n    content.includes(\"\\\\[\") ||\n    /(^|[^\\\\])\\$(?![\\s$])/.test(content)\n  );\n}\n\nfunction shouldEnableMath(content: string, config: MarkdownConfig): boolean {\n  const mathMode = config.math ?? \"auto\";\n  return mathMode === true || (mathMode === \"auto\" && contentMayContainMath(content));\n}\n\nfunction createProcessor(config: MarkdownConfig, options: { enableMath: boolean }) {\n  const allowDangerousHtml = config.allowDangerousHtml ?? true;\n  const processor = unified()\n    .use(remarkParse)\n    .use(remarkGfm)\n    .use(remarkFrontmatter, [\"yaml\"])\n    // GitHub-flavored alerts: > [!NOTE], > [!TIP], > [!IMPORTANT], > [!WARNING], > [!CAUTION]\n    .use(remarkGithubAlerts)\n    // Smart typography: \"smart quotes\", em—dashes, el…lipses\n    .use(remarkSmartypants);\n\n  if (options.enableMath) {\n    processor.use(remarkMath);\n  }\n\n  if (config.remarkPlugins) {\n    for (const plugin of config.remarkPlugins) {\n      if (Array.isArray(plugin)) processor.use(plugin[0], plugin[1]);\n      else processor.use(plugin);\n    }\n  }\n\n  // Apply language aliases to fenced code blocks before the built-in code renderer processes them.\n  // Merge defaults with user-provided aliases (user overrides take precedence).\n  const langAlias = { ...DEFAULT_LANG_ALIASES, ...config.shiki?.langAlias };\n  processor.use(() => (tree: any) => {\n    const visit = (node: any): void => {\n      if (node?.type === \"code\" && typeof node.lang === \"string\" && langAlias[node.lang]) {\n        node.lang = langAlias[node.lang];\n      }\n      if (Array.isArray(node?.children)) {\n        for (const child of node.children) visit(child);\n      }\n    };\n    visit(tree);\n  });\n\n  processor.use(remarkRehype, { allowDangerousHtml });\n\n  // MathJax must run before the built-in code renderer so math is rendered to SVG\n  // before code highlighting touches the HAST tree.\n  if (options.enableMath) {\n    processor.use(rehypeMathjax);\n  }\n\n  // Built-in code renderer stage. Downstream plugins target the\n  // Pagesmith-owned code block contract instead of renderer internals.\n  applyPagesmithCodeRenderer(processor, config);\n\n  // Group consecutive titled code blocks into a tabbed interface.\n  // Must run after the built-in code renderer so it can inspect the Pagesmith contract.\n  processor.use(rehypeCodeTabs);\n  processor.use(rehypeScrollableTables);\n\n  processor\n    .use(rehypeSlug)\n    .use(rehypeAutolinkHeadings, { behavior: \"wrap\" })\n    // External links: add target=\"_blank\" rel=\"noopener noreferrer\" to absolute URLs\n    .use(rehypeExternalLinks, {\n      target: \"_blank\",\n      rel: [\"noopener\", \"noreferrer\"],\n    })\n    // Accessible emojis: wrap emoji characters in <span role=\"img\" aria-label=\"...\">\n    .use(rehypeAccessibleEmojis)\n    // Patch WCAG 2.2 AA gaps left by upstream plugins:\n    //   - GFM task-list checkboxes are nameless without this.\n    //   - MathJax SVGs (`role=\"img\"`) need an accessible name.\n    .use(rehypeA11y)\n    // Fill intrinsic image dimensions from the local filesystem and wrap JPEGs\n    // in <picture> so browsers can prefer AVIF/WebP while keeping JPEG fallback.\n    // Also stamps loading hints (lazy/eager + fetchpriority) on content images.\n    .use(rehypeLocalImages, {\n      lazyLoading: config.images?.lazyLoading ?? true,\n      eagerCount: config.images?.eagerCount ?? 1,\n    });\n\n  processor.use(() => (tree: any, file: any) => {\n    const headings: Heading[] = [];\n    extractHeadings(tree, headings);\n    file.data.headings = headings;\n  });\n\n  if (config.rehypePlugins) {\n    for (const plugin of config.rehypePlugins) {\n      if (Array.isArray(plugin)) processor.use(plugin[0], plugin[1]);\n      else processor.use(plugin);\n    }\n  }\n\n  processor.use(rehypeStringify, { allowDangerousHtml });\n  return processor;\n}\n\n/**\n * Processor cache keyed by MarkdownConfig object reference.\n *\n * **Why a WeakMap keyed by object reference?**\n * Building a unified processor chain is expensive — it loads Shiki grammars,\n * theme JSON, and instantiates every remark/rehype plugin. Caching the\n * processor by config reference lets callers that reuse the same config object\n * (the common case) skip all of that setup on subsequent calls. The WeakMap\n * also ensures that if a config object is garbage-collected, its processor is\n * too, so long-running processes don't leak memory.\n *\n * Pagesmith keeps separate processor instances per config reference for the\n * math-enabled and math-disabled variants because the auto math mode can\n * choose a cheaper pipeline for content that does not contain math markers.\n *\n * **Why is the config frozen?**\n * The cache assumes the config does not change after the processor is built.\n * If a caller mutated a config object after the processor was created, later\n * calls would still receive the stale processor (keyed by the same reference),\n * producing silently wrong output. Freezing the config at first use turns that\n * silent bug into a loud TypeError on any attempted mutation.\n *\n * **What if a consumer needs different settings?**\n * Pass a new config object — a fresh reference gets its own cache entry.\n * For example: `processMarkdown(md, { ...existingConfig, remarkPlugins: [...] })`.\n */\nfunction deepFreeze<T extends object>(obj: T): T {\n  Object.freeze(obj);\n  for (const value of Object.values(obj)) {\n    if (value && typeof value === \"object\" && !Object.isFrozen(value)) {\n      deepFreeze(value);\n    }\n  }\n  return obj;\n}\n\ntype CachedProcessors = {\n  withMath?: ReturnType<typeof createProcessor>;\n  withoutMath?: ReturnType<typeof createProcessor>;\n};\n\nconst processorCache = new WeakMap<MarkdownConfig, CachedProcessors>();\n\nexport async function processMarkdown(\n  raw: string,\n  config?: MarkdownConfig,\n  preExtracted?: PreExtractedMarkdown,\n): Promise<MarkdownResult> {\n  let frontmatter: Record<string, unknown>;\n  let content: string;\n  const fileData = preExtracted?.fileData ?? {};\n  if (preExtracted) {\n    frontmatter = preExtracted.frontmatter;\n    content = preExtracted.content;\n  } else {\n    const parsed = matter(raw, { engines: { yaml: parseYaml } });\n    frontmatter = parsed.data;\n    content = parsed.content;\n  }\n  const resolvedConfig =\n    config && Object.keys(config).length > 0 ? config : DEFAULT_MARKDOWN_CONFIG;\n  // Freeze to prevent mutation after caching — see processorCache JSDoc above.\n  if (Object.isFrozen(resolvedConfig) === false) deepFreeze(resolvedConfig);\n  const enableMath = shouldEnableMath(content, resolvedConfig);\n  let cachedProcessors = processorCache.get(resolvedConfig);\n  if (!cachedProcessors) {\n    cachedProcessors = {};\n    processorCache.set(resolvedConfig, cachedProcessors);\n  }\n  let processor = enableMath ? cachedProcessors.withMath : cachedProcessors.withoutMath;\n  if (!processor) {\n    processor = createProcessor(resolvedConfig, { enableMath });\n    if (enableMath) cachedProcessors.withMath = processor;\n    else cachedProcessors.withoutMath = processor;\n  }\n  try {\n    const result = await processor.process({\n      value: content,\n      data: fileData,\n    });\n    const headings = Array.isArray(result.data.headings) ? (result.data.headings as Heading[]) : [];\n    return { html: String(result), headings, frontmatter };\n  } catch (err) {\n    throw new Error(\n      `Markdown processing failed: ${err instanceof Error ? err.message : String(err)}`,\n      { cause: err },\n    );\n  }\n}\n"],"x_google_ignoreList":[4,5,6,7],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,6BAA6B;AAC1C,MAAa,+BAA+B;AAC5C,MAAa,4BAA4B;AACzC,MAAa,4BAA4B;AACzC,MAAa,2BAA2B;AAExC,SAASA,YAAU,MAAyB;CAC1C,OAAO,KAAK,SAAS;AACvB;AAEA,SAASC,gBAAc,MAA0B;CAC/C,MAAM,YAAY,KAAK,YAAY;CACnC,IAAI,MAAM,QAAQ,SAAS,GACzB,OAAO,UAAU,QAAQ,UAA2B,OAAO,UAAU,QAAQ;CAC/E,IAAI,OAAO,cAAc,UAAU,OAAO,UAAU,MAAM,KAAK,EAAE,OAAO,OAAO;CAC/E,OAAO,CAAC;AACV;AAEA,SAAS,YAAY,MAAgB,KAAa,OAAiC;CACjF,KAAK,eAAe,CAAC;CACrB,IAAI,UAAU,KAAA,GAAW;EACvB,OAAO,KAAK,WAAW;EACvB;CACF;CACA,KAAK,WAAW,OAAO;AACzB;AAEA,SAAgB,SAAS,MAAgB,WAAyB;CAChE,IAAI,CAACD,YAAU,IAAI,GAAG;CACtB,MAAM,aAAa,IAAI,IAAIC,gBAAc,IAAI,CAAC;CAC9C,WAAW,IAAI,SAAS;CACxB,KAAK,eAAe,CAAC;CACrB,KAAK,WAAW,YAAY,MAAM,KAAK,UAAU;AACnD;AAEA,SAAgBC,WAAS,MAAgB,WAA4B;CACnE,OAAOD,gBAAc,IAAI,EAAE,SAAS,SAAS;AAC/C;AAEA,SAAgB,qBAAqB,MAAyB;CAC5D,OAAOD,YAAU,IAAI,KAAKE,WAAS,MAAA,eAAgC;AACrE;AAEA,SAAgB,8BACd,MACA,UACM;CACN,IAAI,CAACF,YAAU,IAAI,GAAG;CACtB,SAAS,MAAM,0BAA0B;CACzC,YAAY,MAAM,8BAA8B,SAAS,QAAQ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