{"version":3,"file":"content-BHhVNZIN.mjs","names":["isInsideRoot","toContentSlug","collectContentAssets","collectAssets"],"sources":["../src/install.ts","../src/npm-badge.ts","../src/npm.ts","../src/markdown/plugins/context.ts","../src/markdown/plugins/rehype-asset-transform.ts","../src/markdown/plugins/rehype-link-transform.ts","../src/content.ts"],"sourcesContent":["import { processMarkdown, type MarkdownConfig } from \"@pagesmith/core/markdown\";\nimport type { DocsInstall } from \"./schemas/docs-content.js\";\n\nconst DEFAULT_INSTALL_LANG = \"bash\";\n\n/** Spec resolved from either the string shorthand or the rich object form. */\ntype ResolvedInstallSpec = {\n  code: string;\n  lang: string;\n  title?: string;\n  frame?: \"code\" | \"terminal\" | \"plain\";\n  showLineNumbers?: boolean;\n};\n\nfunction normalizeInstall(install: DocsInstall): ResolvedInstallSpec | null {\n  if (typeof install === \"string\") {\n    const code = install.replace(/\\r\\n/g, \"\\n\").replace(/\\s+$/, \"\");\n    if (code.length === 0) return null;\n    return { code, lang: DEFAULT_INSTALL_LANG };\n  }\n\n  const code = install.code.replace(/\\r\\n/g, \"\\n\").replace(/\\s+$/, \"\");\n  if (code.length === 0) return null;\n  return {\n    code,\n    lang: install.lang?.trim() || DEFAULT_INSTALL_LANG,\n    title: install.title?.trim() || undefined,\n    frame: install.frame,\n    showLineNumbers: install.showLineNumbers,\n  };\n}\n\nfunction escapeMetaValue(value: string): string {\n  return value.replace(/\"/g, '\\\\\"');\n}\n\nfunction buildFenceMeta(spec: ResolvedInstallSpec): string {\n  const tokens: string[] = [];\n  if (spec.title) tokens.push(`title=\"${escapeMetaValue(spec.title)}\"`);\n  if (spec.frame) tokens.push(`frame=${spec.frame}`);\n  if (spec.showLineNumbers !== undefined) {\n    tokens.push(`showLineNumbers=${spec.showLineNumbers ? \"true\" : \"false\"}`);\n  }\n  return tokens.join(\" \");\n}\n\n/**\n * Pick the longest run of backticks needed to safely fence the install snippet.\n *\n * Install snippets that themselves contain triple-backticks (e.g. a markdown\n * cheat-sheet) would prematurely close a `\\`\\`\\`` fence — count the longest\n * existing backtick run and use one more.\n */\nfunction chooseFence(code: string): string {\n  let longestRun = 0;\n  let currentRun = 0;\n  for (let index = 0; index < code.length; index++) {\n    if (code[index] === \"`\") {\n      currentRun++;\n      if (currentRun > longestRun) longestRun = currentRun;\n    } else {\n      currentRun = 0;\n    }\n  }\n  return \"`\".repeat(Math.max(longestRun + 1, 3));\n}\n\n/**\n * Render the home-page install snippet through the standard Pagesmith\n * markdown code pipeline so it shares Shiki highlighting, frame chrome, line\n * numbers, copy button, and tab-grouping with `\\`\\`\\`` blocks elsewhere.\n *\n * Returns `null` when the spec is empty so callers can skip rendering the\n * surrounding section entirely.\n */\nexport async function renderInstallHtml(\n  install: DocsInstall,\n  markdownConfig: MarkdownConfig,\n): Promise<string | null> {\n  const spec = normalizeInstall(install);\n  if (!spec) return null;\n\n  const fence = chooseFence(spec.code);\n  const meta = buildFenceMeta(spec);\n  const fenceLine = meta.length > 0 ? `${fence}${spec.lang} ${meta}` : `${fence}${spec.lang}`;\n  const synthetic = `${fenceLine}\\n${spec.code}\\n${fence}\\n`;\n\n  const result = await processMarkdown(synthetic, markdownConfig, {\n    content: synthetic,\n    frontmatter: {},\n  });\n  return result.html;\n}\n","/**\n * Inline NPM badge SVG generator.\n *\n * Renders a shields.io-style \"npm | <version>\" badge as a self-contained SVG\n * with explicit `width`/`height` and a `viewBox`, so the home-page packages\n * grid never reflows after the badge paints. This is the no-CLS contract:\n * dimensions are computed at build time, the SVG is inlined into the page\n * (no extra request, no late-loading external resource), and the surrounding\n * card reserves exactly the right space.\n *\n * Width is computed from a conservative monospace-character estimate so the\n * box is always wide enough for the rendered text — there is no JS-side\n * measurement and no font fallback to worry about.\n */\n\nconst BADGE_HEIGHT = 20;\nconst LABEL_TEXT = \"npm\";\n/** Fixed left segment width — fits \"npm\" with comfortable padding in DejaVu/Verdana 11px. */\nconst LABEL_WIDTH = 38;\n/** Per-character width estimate for Verdana/DejaVu Sans 11px. Slightly generous to avoid glyph clipping. */\nconst VERSION_CHAR_WIDTH = 7;\nconst VERSION_HORIZONTAL_PADDING = 12;\n/** Minimum value-segment width so even very short versions stay readable. */\nconst VERSION_MIN_WIDTH = 44;\n\nconst LABEL_BG = \"#555\";\nconst VALUE_BG = \"#4c1\";\n\n/** Escape `\"`, `<`, `>`, `&` for safe inclusion as SVG text content. */\nfunction escapeXml(value: string): string {\n  return value\n    .replace(/&/g, \"&amp;\")\n    .replace(/</g, \"&lt;\")\n    .replace(/>/g, \"&gt;\")\n    .replace(/\"/g, \"&quot;\")\n    .replace(/'/g, \"&apos;\");\n}\n\n/**\n * Build a per-badge ID suffix derived from the package name + version so\n * multiple inlined badges on the same page each get unique `<linearGradient>`\n * and `<clipPath>` IDs (duplicate IDs are invalid HTML and can cause one\n * badge's gradient/clip to bleed into another).\n */\nfunction buildIdSuffix(packageName: string, version: string): string {\n  const raw = `${packageName}-${version}`;\n  // Restrict to a CSS/HTML-id-safe character set; collapse anything else to `-`.\n  return raw\n    .toLowerCase()\n    .replace(/[^a-z0-9_-]+/g, \"-\")\n    .replace(/-+/g, \"-\")\n    .replace(/^-|-$/g, \"\");\n}\n\nexport type NpmBadge = {\n  /** Self-contained `<svg>` markup with explicit width/height. */\n  svg: string;\n  width: number;\n  height: number;\n  /** Convenience link to the package on npmjs.com. */\n  href: string;\n};\n\n/**\n * Build an inline NPM badge SVG for a published package.\n *\n * Both arguments must be non-empty — call sites that have not resolved a\n * version yet should skip rendering instead of passing an empty string.\n */\nexport function renderNpmBadge(packageName: string, version: string): NpmBadge {\n  const safeVersion = version.trim();\n  const versionWidth = Math.max(\n    VERSION_MIN_WIDTH,\n    safeVersion.length * VERSION_CHAR_WIDTH + VERSION_HORIZONTAL_PADDING,\n  );\n  const totalWidth = LABEL_WIDTH + versionWidth;\n  const labelTextX = LABEL_WIDTH / 2;\n  const valueTextX = LABEL_WIDTH + versionWidth / 2;\n  const accessibleLabel = `npm package ${packageName} version ${safeVersion}`;\n  const idSuffix = buildIdSuffix(packageName, safeVersion);\n  const gradientId = `ps-npm-badge-gradient-${idSuffix}`;\n  const clipId = `ps-npm-badge-clip-${idSuffix}`;\n\n  const svg = [\n    `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${totalWidth}\" height=\"${BADGE_HEIGHT}\" viewBox=\"0 0 ${totalWidth} ${BADGE_HEIGHT}\" role=\"img\" aria-label=\"${escapeXml(accessibleLabel)}\" class=\"ps-npm-badge\">`,\n    `<title>${escapeXml(accessibleLabel)}</title>`,\n    `<linearGradient id=\"${gradientId}\" x2=\"0\" y2=\"100%\">`,\n    `<stop offset=\"0\" stop-color=\"#bbb\" stop-opacity=\".1\"/>`,\n    `<stop offset=\"1\" stop-opacity=\".1\"/>`,\n    `</linearGradient>`,\n    `<clipPath id=\"${clipId}\"><rect width=\"${totalWidth}\" height=\"${BADGE_HEIGHT}\" rx=\"3\" fill=\"#fff\"/></clipPath>`,\n    `<g clip-path=\"url(#${clipId})\">`,\n    `<rect width=\"${LABEL_WIDTH}\" height=\"${BADGE_HEIGHT}\" fill=\"${LABEL_BG}\"/>`,\n    `<rect x=\"${LABEL_WIDTH}\" width=\"${versionWidth}\" height=\"${BADGE_HEIGHT}\" fill=\"${VALUE_BG}\"/>`,\n    `<rect width=\"${totalWidth}\" height=\"${BADGE_HEIGHT}\" fill=\"url(#${gradientId})\"/>`,\n    `</g>`,\n    `<g fill=\"#fff\" text-anchor=\"middle\" font-family=\"DejaVu Sans,Verdana,Geneva,sans-serif\" font-size=\"11\">`,\n    `<text x=\"${labelTextX}\" y=\"14\" fill=\"#010101\" fill-opacity=\".3\">${LABEL_TEXT}</text>`,\n    `<text x=\"${labelTextX}\" y=\"13\">${LABEL_TEXT}</text>`,\n    `<text x=\"${valueTextX}\" y=\"14\" fill=\"#010101\" fill-opacity=\".3\">${escapeXml(safeVersion)}</text>`,\n    `<text x=\"${valueTextX}\" y=\"13\">${escapeXml(safeVersion)}</text>`,\n    `</g>`,\n    `</svg>`,\n  ].join(\"\");\n\n  return {\n    svg,\n    width: totalWidth,\n    height: BADGE_HEIGHT,\n    href: `https://www.npmjs.com/package/${packageName}`,\n  };\n}\n","/**\n * Build-time NPM registry helpers.\n *\n * Fetches the latest published version for a package from the public NPM\n * registry and caches the result on disk under\n * `node_modules/.cache/pagesmith-docs-npm/versions.json` so repeated builds\n * (incremental rebuilds, dev server, parallel page renders) hit the registry\n * at most once per package per cache window.\n *\n * Network and registry errors degrade gracefully — callers receive `undefined`\n * and rendering proceeds without the badge / version pill instead of failing\n * the build. This keeps offline builds and CI cold-starts robust.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { join } from \"path\";\n\nconst REGISTRY_BASE = \"https://registry.npmjs.org\";\n/** Cache window for resolved versions (1 hour). Keeps dev/build fast without going stale for long. */\nconst CACHE_TTL_MS = 60 * 60 * 1000;\n/** Per-request hard ceiling so a slow registry can never block a build for long.\n *  Generous enough to absorb a cold DNS+TLS handshake on a fresh CI runner. */\nconst REQUEST_TIMEOUT_MS = 10_000;\n\ntype CacheEntry = {\n  version: string | null;\n  fetchedAt: number;\n};\n\ntype CacheFile = Record<string, CacheEntry>;\n\nlet memoryCache: CacheFile | null = null;\nlet cacheFilePath: string | null = null;\nconst inFlight = new Map<string, Promise<string | undefined>>();\n\nfunction ensureCacheLoaded(rootDir: string): CacheFile {\n  if (memoryCache && cacheFilePath) return memoryCache;\n  const cacheDir = join(rootDir, \"node_modules\", \".cache\", \"pagesmith-docs-npm\");\n  mkdirSync(cacheDir, { recursive: true });\n  cacheFilePath = join(cacheDir, \"versions.json\");\n  if (existsSync(cacheFilePath)) {\n    try {\n      const raw = readFileSync(cacheFilePath, \"utf-8\");\n      const parsed = JSON.parse(raw) as unknown;\n      if (parsed && typeof parsed === \"object\") {\n        memoryCache = parsed as CacheFile;\n        return memoryCache;\n      }\n    } catch {\n      // Fall through to fresh cache — corrupt cache files are silently rebuilt.\n    }\n  }\n  memoryCache = {};\n  return memoryCache;\n}\n\nfunction persistCache(): void {\n  if (!cacheFilePath || !memoryCache) return;\n  try {\n    writeFileSync(cacheFilePath, JSON.stringify(memoryCache, null, 2), \"utf-8\");\n  } catch {\n    // Cache writes are best-effort; a read-only filesystem must not break the build.\n  }\n}\n\nasync function fetchVersionFromRegistry(packageName: string): Promise<string | null> {\n  const url = `${REGISTRY_BASE}/${encodeNpmName(packageName)}/latest`;\n  const controller = new AbortController();\n  const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);\n  try {\n    const response = await fetch(url, {\n      headers: { accept: \"application/json\" },\n      signal: controller.signal,\n    });\n    if (!response.ok) {\n      console.warn(\n        `[pagesmith] npm registry returned ${response.status} for ${packageName}; will fall back to local node_modules if available.`,\n      );\n      return null;\n    }\n    const json = (await response.json()) as { version?: unknown };\n    return typeof json.version === \"string\" ? json.version : null;\n  } catch (error) {\n    const reason = error instanceof Error ? `${error.name}: ${error.message}` : String(error);\n    console.warn(\n      `[pagesmith] npm registry fetch failed for ${packageName} (${reason}); will fall back to local node_modules if available.`,\n    );\n    return null;\n  } finally {\n    clearTimeout(timer);\n  }\n}\n\n/**\n * Read the installed version of a package from `node_modules/<name>/package.json`.\n *\n * Used as a fallback when the registry is unreachable (cold CI runners, offline\n * builds) so the NPM badge still renders with the correct version. Returns\n * `undefined` when the package is not installed locally.\n */\nfunction resolveLocalPackageVersion(packageName: string, rootDir: string): string | undefined {\n  try {\n    const pkgPath = join(rootDir, \"node_modules\", packageName, \"package.json\");\n    if (!existsSync(pkgPath)) return undefined;\n    const raw = readFileSync(pkgPath, \"utf-8\");\n    const parsed = JSON.parse(raw) as { version?: unknown };\n    return typeof parsed.version === \"string\" ? parsed.version : undefined;\n  } catch {\n    return undefined;\n  }\n}\n\n/** Encode a scoped npm package name for the registry URL — `@scope/name` → `@scope%2Fname`. */\nfunction encodeNpmName(name: string): string {\n  if (name.startsWith(\"@\")) {\n    const slash = name.indexOf(\"/\");\n    if (slash > 0) {\n      return `${name.slice(0, slash)}%2F${encodeURIComponent(name.slice(slash + 1))}`;\n    }\n  }\n  return encodeURIComponent(name);\n}\n\n/**\n * Resolve the latest published version for an npm package.\n *\n * Returns `undefined` when the package is unpublished, the registry is\n * unreachable, the request times out, or the response shape is unexpected —\n * callers should treat that as \"no version available\" and skip badge rendering.\n */\nexport async function getLatestNpmVersion(\n  packageName: string,\n  rootDir: string,\n): Promise<string | undefined> {\n  if (!packageName.trim()) return undefined;\n  const cache = ensureCacheLoaded(rootDir);\n  const entry = cache[packageName];\n  const now = Date.now();\n  if (entry && now - entry.fetchedAt < CACHE_TTL_MS) {\n    return entry.version ?? undefined;\n  }\n\n  const existing = inFlight.get(packageName);\n  if (existing) return existing;\n\n  const promise = (async () => {\n    const registryVersion = await fetchVersionFromRegistry(packageName);\n    if (registryVersion) {\n      cache[packageName] = { version: registryVersion, fetchedAt: Date.now() };\n      persistCache();\n      return registryVersion;\n    }\n    // Registry failed or returned nothing — fall back to the locally installed\n    // version. This keeps the badge correct on CI runners where the first\n    // outbound HTTPS call is slow enough to hit the abort, and in fully\n    // offline builds.\n    const localVersion = resolveLocalPackageVersion(packageName, rootDir);\n    if (localVersion) {\n      cache[packageName] = { version: localVersion, fetchedAt: Date.now() };\n      persistCache();\n      return localVersion;\n    }\n    cache[packageName] = { version: null, fetchedAt: Date.now() };\n    persistCache();\n    return undefined;\n  })();\n  inFlight.set(packageName, promise);\n  try {\n    return await promise;\n  } finally {\n    inFlight.delete(packageName);\n  }\n}\n\n/** Reset module-level state. Exposed for test suites; not part of the public surface. */\nexport function __resetNpmVersionCacheForTests(): void {\n  memoryCache = null;\n  cacheFilePath = null;\n  inFlight.clear();\n}\n","import { AsyncLocalStorage } from \"node:async_hooks\";\n\nexport type PagesmithDocsTransformContext = {\n  basePath: string;\n  contentDir: string;\n  filePath: string;\n  trailingSlash: boolean;\n};\n\nconst contextStorage = new AsyncLocalStorage<PagesmithDocsTransformContext>();\n\nexport function runWithDocsTransformContext<T>(\n  context: PagesmithDocsTransformContext,\n  fn: () => Promise<T>,\n): Promise<T> {\n  return contextStorage.run(context, fn);\n}\n\nexport function getDocsTransformContext(): PagesmithDocsTransformContext | undefined {\n  return contextStorage.getStore();\n}\n","import { existsSync, readFileSync } from \"fs\";\nimport type { Element, Root, RootContent } from \"hast\";\nimport { dirname, relative, resolve } from \"path\";\nimport { SKIP, visit } from \"unist-util-visit\";\nimport { getDocsTransformContext } from \"./context\";\n\nconst ASSET_EXTS = /\\.(svg|png|jpg|jpeg|gif|webp|avif|ico)$/i;\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 isInsideRoot(targetPath: string, rootDir: string): boolean {\n  const rel = relative(rootDir, targetPath);\n  return rel === \"\" || !rel.startsWith(\"..\");\n}\n\nfunction resolveLocalAssetPath(currentFilePath: string, ref: string): string | undefined {\n  if (!isRelativeRef(ref)) return undefined;\n  const assetRoot = dirname(currentFilePath);\n  const resolvedPath = resolve(assetRoot, splitRef(ref).pathname);\n  return isInsideRoot(resolvedPath, assetRoot) ? resolvedPath : undefined;\n}\n\nfunction normalizeBasePath(basePath: string): string {\n  const normalized = basePath.replace(/\\/+$/, \"\");\n  return normalized === \"/\" ? \"\" : normalized;\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 toPublishedAssetPath(\n  currentFilePath: string,\n  contentDir: string,\n  ref: string,\n): string | undefined {\n  if (!isRelativeRef(ref)) return undefined;\n  const resolvedPath = resolve(dirname(currentFilePath), splitRef(ref).pathname);\n  if (!isInsideRoot(resolvedPath, contentDir)) return undefined;\n  return relative(contentDir, resolvedPath).replace(/\\\\/g, \"/\");\n}\n\nfunction toPublishedAssetUrl(\n  ref: string,\n  basePath: string,\n  currentFilePath: string,\n  contentDir: string,\n): string | undefined {\n  const { pathname, suffix } = splitRef(ref);\n  const assetPath = toPublishedAssetPath(currentFilePath, contentDir, pathname);\n  if (!assetPath) return undefined;\n  return `${normalizeBasePath(basePath)}/assets/${assetPath}${suffix}`;\n}\n\nfunction rewriteSrcset(\n  srcset: string,\n  basePath: string,\n  currentFilePath: string,\n  contentDir: string,\n): string {\n  return srcset\n    .split(\",\")\n    .map((entry) => {\n      const [rawUrl, ...descriptor] = entry.trim().split(/\\s+/);\n      if (isRelativeRef(rawUrl) && ASSET_EXTS.test(splitRef(rawUrl).pathname)) {\n        const rewrittenUrl = toPublishedAssetUrl(rawUrl, basePath, currentFilePath, contentDir);\n        if (rewrittenUrl) {\n          return [rewrittenUrl, ...descriptor].join(\" \");\n        }\n      }\n      return entry.trim();\n    })\n    .join(\", \");\n}\n\nfunction rewriteRawAssetAttributes(\n  html: string,\n  basePath: string,\n  currentFilePath: string,\n  contentDir: string,\n): string {\n  const rewriteRefAttribute = (value: string): string =>\n    value.replace(\n      /\\b(src|href|data-zoom-src|data-zoom-src-light|data-zoom-src-dark)=(\"|')([^\"']*)\\2/gi,\n      (match, attr: string, quote: string, ref: string) => {\n        if (!(isRelativeRef(ref) && ASSET_EXTS.test(splitRef(ref).pathname))) {\n          return match;\n        }\n\n        const rewrittenUrl = toPublishedAssetUrl(ref, basePath, currentFilePath, contentDir);\n        return rewrittenUrl ? `${attr}=${quote}${rewrittenUrl}${quote}` : match;\n      },\n    );\n\n  return rewriteRefAttribute(html).replace(\n    /\\bsrcset=(\"|')([^\"']*)\\1/gi,\n    (match, quote: string, srcset: string) =>\n      srcset.includes(\"./\") || srcset.includes(\"../\") || ASSET_EXTS.test(srcset)\n        ? `srcset=${quote}${rewriteSrcset(srcset, basePath, currentFilePath, contentDir)}${quote}`\n        : match,\n  );\n}\n\nexport function rehypeAssetTransform() {\n  return (tree: Root) => {\n    const context = getDocsTransformContext();\n    if (!context?.filePath) return;\n\n    visit(tree, \"raw\", (node) => {\n      node.value = rewriteRawAssetAttributes(\n        node.value,\n        context.basePath,\n        context.filePath,\n        context.contentDir,\n      );\n    });\n\n    const rewriteImgZoomDataAttr = (element: Element, name: string): void => {\n      const value = element.properties?.[name];\n      if (typeof value !== \"string\" || !isRelativeRef(value)) return;\n      if (!ASSET_EXTS.test(splitRef(value).pathname)) return;\n      const rewritten = toPublishedAssetUrl(\n        value,\n        context.basePath,\n        context.filePath,\n        context.contentDir,\n      );\n      if (rewritten) {\n        element.properties = element.properties || {};\n        element.properties[name] = rewritten;\n      }\n    };\n\n    visit(tree, \"element\", (element: Element, index, parent) => {\n      // Transform img src\n      if (element.tagName === \"img\") {\n        // Always rewrite zoom data attrs even when src isn't local: themed\n        // <picture> imgs may carry data-zoom-src-light/dark with relative\n        // paths even though their fallback `src` is non-relative.\n        rewriteImgZoomDataAttr(element, \"data-zoom-src\");\n        rewriteImgZoomDataAttr(element, \"data-zoom-src-light\");\n        rewriteImgZoomDataAttr(element, \"data-zoom-src-dark\");\n\n        const src = element.properties?.src;\n        if (\n          typeof src !== \"string\" ||\n          !isRelativeRef(src) ||\n          !ASSET_EXTS.test(splitRef(src).pathname)\n        ) {\n          return;\n        }\n\n        // Inline SVG: embed content directly in HTML\n        if (src.endsWith(\".inline.svg\")) {\n          const filePath = resolveLocalAssetPath(context.filePath, src);\n          if (filePath && existsSync(filePath)) {\n            let svgContent = readFileSync(filePath, \"utf-8\");\n            // Strip XML declaration and DOCTYPE\n            svgContent = svgContent.replace(/<\\?xml[^?]*\\?>\\s*/g, \"\");\n            svgContent = svgContent.replace(/<!DOCTYPE[^>]*>\\s*/g, \"\");\n            // Add accessibility and styling attributes to root <svg>\n            const alt = element.properties?.alt || \"\";\n            const escapedAlt = String(alt)\n              .replace(/&/g, \"&amp;\")\n              .replace(/\"/g, \"&quot;\")\n              .replace(/</g, \"&lt;\")\n              .replace(/>/g, \"&gt;\");\n            svgContent = svgContent.replace(\n              \"<svg\",\n              `<svg role=\"img\" aria-label=\"${escapedAlt}\" class=\"inline-svg\"`,\n            );\n            if (parent && index !== undefined) {\n              (parent.children as RootContent[])[index] = { type: \"raw\", value: svgContent };\n              return SKIP;\n            }\n          }\n        }\n\n        const publishedUrl = toPublishedAssetUrl(\n          src,\n          context.basePath,\n          context.filePath,\n          context.contentDir,\n        );\n        if (!publishedUrl) return;\n\n        element.properties = element.properties || {};\n        element.properties.src = publishedUrl;\n      }\n\n      // Transform source srcset (for <picture> elements)\n      if (element.tagName === \"source\") {\n        const srcset = element.properties?.srcset;\n        if (\n          typeof srcset === \"string\" &&\n          (srcset.includes(\"./\") || srcset.includes(\"../\") || ASSET_EXTS.test(srcset))\n        ) {\n          element.properties = element.properties || {};\n          element.properties.srcset = rewriteSrcset(\n            srcset,\n            context.basePath,\n            context.filePath,\n            context.contentDir,\n          );\n        }\n      }\n\n      // Transform a href pointing to asset files\n      if (element.tagName === \"a\") {\n        const href = element.properties?.href;\n        if (\n          typeof href === \"string\" &&\n          isRelativeRef(href) &&\n          ASSET_EXTS.test(splitRef(href).pathname)\n        ) {\n          const publishedUrl = toPublishedAssetUrl(\n            href,\n            context.basePath,\n            context.filePath,\n            context.contentDir,\n          );\n          if (!publishedUrl) return;\n\n          element.properties = element.properties || {};\n          element.properties.href = publishedUrl;\n        }\n      }\n    });\n  };\n}\n","import type { Element, Root } from \"hast\";\nimport { existsSync } from \"fs\";\nimport { dirname, extname, relative, resolve } from \"path\";\nimport { visit } from \"unist-util-visit\";\nimport { getDocsTransformContext } from \"./context\";\n\nfunction toContentSlug(filePath: string, contentDir: string): string {\n  const ext = extname(filePath);\n  let slug = relative(contentDir, filePath).replace(/\\\\/g, \"/\");\n\n  if (ext) {\n    slug = slug.slice(0, -ext.length);\n  }\n\n  if (slug === \"README\" || slug === \"index\") return \"/\";\n  if (slug.endsWith(\"/README\")) slug = slug.slice(0, -7);\n  if (slug.endsWith(\"/index\")) slug = slug.slice(0, -6);\n\n  return slug;\n}\n\nfunction isInsideRoot(targetPath: string, rootDir: string): boolean {\n  const rel = relative(rootDir, targetPath);\n  return rel === \"\" || !rel.startsWith(\"..\");\n}\n\nfunction splitPathSuffix(href: string): { pathPart: string; suffix: string } {\n  const queryIndex = href.indexOf(\"?\");\n  const hashIndex = href.indexOf(\"#\");\n  const boundaryCandidates = [queryIndex, hashIndex].filter((index) => index >= 0);\n  const boundary = boundaryCandidates.length > 0 ? Math.min(...boundaryCandidates) : -1;\n  return boundary >= 0\n    ? { pathPart: href.slice(0, boundary), suffix: href.slice(boundary) }\n    : { pathPart: href, suffix: \"\" };\n}\n\nfunction isExternalUrl(href: string): boolean {\n  return (\n    href.startsWith(\"http://\") ||\n    href.startsWith(\"https://\") ||\n    href.startsWith(\"mailto:\") ||\n    href.startsWith(\"tel:\") ||\n    href.startsWith(\"//\")\n  );\n}\n\nfunction hasFileExtension(path: string): boolean {\n  return /\\/[^/?#]+\\.[^/?#]+(?:[?#].*)?$/u.test(path);\n}\n\nfunction formatTrailingSlash(path: string, trailingSlash: boolean): string {\n  if (!path || path === \"/\") return \"/\";\n  if (trailingSlash) {\n    return path.endsWith(\"/\") ? path : `${path}/`;\n  }\n  return path.endsWith(\"/\") ? path.slice(0, -1) : path;\n}\n\n/** Resolve a relative href to a content page file path, or undefined if not a content page. */\nfunction resolveContentTarget(\n  href: string,\n  currentFilePath: string,\n  contentDir: string,\n): string | undefined {\n  const targetPath = resolve(dirname(currentFilePath), href);\n  if (!isInsideRoot(targetPath, contentDir)) return undefined;\n\n  // Direct .md file\n  if (existsSync(targetPath) && extname(targetPath) === \".md\") {\n    return targetPath;\n  }\n\n  // Directory with README.md or index.md\n  for (const indexFile of [\"README.md\", \"index.md\"]) {\n    const candidate = resolve(targetPath, indexFile);\n    if (existsSync(candidate)) return candidate;\n  }\n\n  // Bare name — try appending .md\n  const withMd = `${targetPath}.md`;\n  if (existsSync(withMd)) return withMd;\n\n  return undefined;\n}\n\nexport function rehypeLinkTransform() {\n  return (tree: Root) => {\n    const docsData = getDocsTransformContext();\n    const basePath = docsData?.basePath ?? \"\";\n    const contentDir = docsData?.contentDir;\n    const currentFilePath = docsData?.filePath;\n    const trailingSlash = docsData?.trailingSlash ?? false;\n\n    if (!contentDir || !currentFilePath) return;\n\n    visit(tree, \"element\", (node: Element) => {\n      if (node.tagName !== \"a\") return;\n\n      const href = node.properties?.href;\n      if (typeof href !== \"string\") return;\n\n      // Skip external URLs and fragment-only links\n      if (isExternalUrl(href) || href.startsWith(\"#\")) return;\n\n      const { pathPart, suffix } = splitPathSuffix(href);\n      if (!pathPart) return;\n\n      // Relative link — resolve against current file\n      if (!pathPart.startsWith(\"/\")) {\n        const contentTarget = resolveContentTarget(pathPart, currentFilePath, contentDir);\n        if (!contentTarget) return;\n\n        const slug = toContentSlug(contentTarget, contentDir);\n        const routePath = slug === \"/\" ? \"/\" : `/${slug}`;\n        const formatted = formatTrailingSlash(routePath, trailingSlash);\n\n        node.properties = node.properties || {};\n        node.properties.href = `${basePath}${formatted}${suffix}`;\n        return;\n      }\n\n      // Absolute internal link — apply basePath prefix and trailingSlash\n      if (pathPart.startsWith(\"/\") && !hasFileExtension(pathPart)) {\n        // Strip existing basePath if already present to avoid double-prefix\n        const cleanPath =\n          basePath && pathPart.startsWith(`${basePath}/`)\n            ? pathPart.slice(basePath.length)\n            : pathPart === basePath\n              ? \"/\"\n              : pathPart;\n        const formatted = formatTrailingSlash(cleanPath, trailingSlash);\n\n        node.properties = node.properties || {};\n        node.properties.href = `${basePath}${formatted}${suffix}`;\n      }\n    });\n  };\n}\n","import { extractFrontmatter } from \"@pagesmith/core\";\nimport { processMarkdown, type MarkdownConfig } from \"@pagesmith/core/markdown\";\nimport type { Heading } from \"@pagesmith/core/schemas\";\nimport type {\n  SiteNavItem as NavItem,\n  SitePageLink as PrevNextLink,\n  SiteSidebarItem as SidebarItem,\n  SiteSidebarSection as SidebarSection,\n} from \"@pagesmith/site/components\";\nimport { execFileSync } from \"child_process\";\nimport { existsSync, readFileSync, readdirSync } from \"fs\";\nimport { availableParallelism } from \"os\";\nimport { extname, join, relative, resolve } from \"path\";\nimport { collectContentAssets as collectAssets, CONTENT_ASSET_EXTS } from \"@pagesmith/core/assets\";\nimport { readJson5File, toTitleCase, type ResolvedDocsConfig } from \"./config.js\";\nimport { renderInstallHtml } from \"./install.js\";\nimport { renderNpmBadge } from \"./npm-badge.js\";\nimport { getLatestNpmVersion } from \"./npm.js\";\nimport { runWithDocsTransformContext } from \"./markdown/plugins/context.js\";\nimport { rehypeAssetTransform, rehypeLinkTransform } from \"./markdown/plugins/index.js\";\nimport {\n  DocsFrontmatterSchema,\n  type DocsFrontmatter,\n  type DocsRootMeta,\n  type DocsSectionMeta,\n} from \"./schemas/docs-content.js\";\n\nexport { CONTENT_ASSET_EXTS };\nexport { DocsFrontmatterSchema } from \"./schemas/docs-content.js\";\nexport type { DocsFrontmatter, DocsRootMeta, DocsSectionMeta } from \"./schemas/docs-content.js\";\nexport type { NavItem, SidebarItem, SidebarSection, PrevNextLink };\n\nexport type DocsPage = {\n  title: string;\n  routePath: string;\n  contentSlug: string;\n  section?: string;\n  frontmatter: DocsFrontmatter;\n  html: string;\n  headings: Heading[];\n  sourcePath: string;\n  isHome: boolean;\n  layoutName: string;\n  lastUpdated?: string;\n};\n\nexport type SiteModel = {\n  navItems: NavItem[];\n  sidebarBySection: Map<string, SidebarSection[]>;\n  pageByPath: Map<string, DocsPage>;\n  /** Maps folder slugs to resolved URL paths (with basePath). Folders without an index page resolve to their first child page. */\n  folderPaths: Map<string, string>;\n  rootMeta?: DocsRootMeta;\n  sectionMetas: Map<string, DocsSectionMeta>;\n};\n\nfunction shouldIgnoreContentEntry(name: string): boolean {\n  return name.startsWith(\".\") || name.startsWith(\"_\");\n}\n\nexport function toContentSlug(filePath: string, contentDir: string): string {\n  const ext = extname(filePath);\n  let slug = relative(contentDir, filePath).replace(/\\\\/g, \"/\");\n\n  if (ext) {\n    slug = slug.slice(0, -ext.length);\n  }\n\n  if (slug === \"README\" || slug === \"index\") return \"/\";\n  if (slug.endsWith(\"/README\")) slug = slug.slice(0, -7);\n  if (slug.endsWith(\"/index\")) slug = slug.slice(0, -6);\n\n  return slug;\n}\n\nexport function loadRootMeta(contentDir: string): DocsRootMeta | undefined {\n  return readJson5File<DocsRootMeta>(join(contentDir, \"meta.json5\"));\n}\n\nexport function loadSectionMetas(contentDir: string): Map<string, DocsSectionMeta> {\n  const metas = new Map<string, DocsSectionMeta>();\n  if (!existsSync(contentDir)) return metas;\n  for (const entry of readdirSync(contentDir, { withFileTypes: true })) {\n    if (!entry.isDirectory() || shouldIgnoreContentEntry(entry.name)) continue;\n    const meta = readJson5File<DocsSectionMeta>(join(contentDir, entry.name, \"meta.json5\"));\n    if (meta) metas.set(entry.name, meta);\n  }\n  return metas;\n}\n\nfunction collectMarkdownFiles(contentDir: string): string[] {\n  const files: string[] = [];\n\n  function walk(currentDir: string): void {\n    for (const entry of readdirSync(currentDir, { withFileTypes: true })) {\n      if (shouldIgnoreContentEntry(entry.name)) continue;\n      const fullPath = join(currentDir, entry.name);\n\n      if (entry.isDirectory()) {\n        walk(fullPath);\n        continue;\n      }\n\n      if (entry.name.endsWith(\".md\")) {\n        files.push(fullPath);\n      }\n    }\n  }\n\n  if (existsSync(contentDir)) {\n    walk(contentDir);\n  }\n\n  return files.sort();\n}\n\nfunction resolvePageSection(\n  filePath: string,\n  contentDir: string,\n  isHome: boolean,\n): string | undefined {\n  if (isHome) return undefined;\n\n  const relativePath = relative(contentDir, filePath).replace(/\\\\/g, \"/\");\n  const segments = relativePath.split(\"/\");\n\n  // Top-level folders define docs categories. Root-level markdown files are still\n  // valid pages, but they do not become top-level navigation categories.\n  return segments.length > 1 ? segments[0] : undefined;\n}\n\nconst GIT_LOG_MARKER = \"__PAGESMITH_COMMIT__\";\n\nfunction getGitLastUpdatedMap(rootDir: string, contentDir: string): Map<string, string> {\n  const updated = new Map<string, string>();\n\n  try {\n    const target = relative(rootDir, contentDir) || \".\";\n    const output = execFileSync(\n      \"git\",\n      [\"log\", `--format=${GIT_LOG_MARKER}%n%cI`, \"--name-only\", \"--\", target],\n      {\n        cwd: rootDir,\n        encoding: \"utf-8\",\n        stdio: [\"pipe\", \"pipe\", \"pipe\"],\n      },\n    );\n\n    let currentDate: string | undefined;\n    let expectingDate = false;\n\n    for (const rawLine of output.split(/\\r?\\n/)) {\n      const line = rawLine.trim();\n      if (!line) continue;\n\n      if (line === GIT_LOG_MARKER) {\n        expectingDate = true;\n        continue;\n      }\n\n      if (expectingDate) {\n        currentDate = line;\n        expectingDate = false;\n        continue;\n      }\n\n      if (!currentDate) continue;\n      const filePath = resolve(rootDir, rawLine);\n      if (!updated.has(filePath)) {\n        updated.set(filePath, currentDate);\n      }\n    }\n  } catch {\n    // Git is unavailable, the content directory is outside the repo, or the\n    // target path has no tracked history.\n  }\n\n  return updated;\n}\n\nfunction toDisplaySourcePath(filePath: string, rootDir: string): string {\n  const displayPath = relative(rootDir, filePath).replace(/\\\\/g, \"/\");\n  return displayPath || filePath.replace(/\\\\/g, \"/\");\n}\n\nfunction wrapMarkdownFileError(\n  filePath: string,\n  rootDir: string,\n  action: string,\n  error: unknown,\n): Error {\n  const displayPath = toDisplaySourcePath(filePath, rootDir);\n  if (error instanceof Error && error.message.includes(displayPath)) {\n    return error;\n  }\n\n  const message =\n    error instanceof Error\n      ? `${action} in ${displayPath}`\n      : `${action} in ${displayPath}: ${String(error)}`;\n\n  return new Error(message, {\n    cause: error instanceof Error ? error : undefined,\n  });\n}\n\n/**\n * Determine which npm package identifier to use when fetching the latest\n * version and building the NPM badge for a home-page package card.\n *\n * Resolution rules:\n * - If `npmPackage` is `false`, opt out of registry lookup entirely.\n * - If `npmPackage` is a non-empty string, use it verbatim.\n * - Otherwise fall back to `name` only when it looks like an npm package\n *   identifier (`my-pkg` or `@scope/my-pkg`) — this avoids hitting the\n *   registry for human-readable names like `\"My CLI\"`.\n */\nfunction resolveNpmIdentifier(pkg: { name: string; npmPackage?: string | false }): string | null {\n  if (pkg.npmPackage === false) return null;\n  if (typeof pkg.npmPackage === \"string\") {\n    const trimmed = pkg.npmPackage.trim();\n    return trimmed.length > 0 ? trimmed : null;\n  }\n  const name = pkg.name.trim();\n  if (!name) return null;\n  // Conservative npm-name pattern: optional `@scope/`, then lower-case identifier.\n  if (/^(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]*$/i.test(name)) return name;\n  return null;\n}\n\n/**\n * Run async tasks with bounded concurrency.\n * Prevents memory blowup when processing thousands of pages.\n */\nasync function mapWithConcurrency<T, R>(\n  items: T[],\n  concurrency: number,\n  fn: (item: T) => Promise<R>,\n): Promise<R[]> {\n  const results: R[] = Array.from({ length: items.length });\n  let index = 0;\n\n  async function worker(): Promise<void> {\n    while (index < items.length) {\n      const i = index++;\n      results[i] = await fn(items[i]);\n    }\n  }\n\n  const workers = Array.from({ length: Math.min(concurrency, items.length) }, () => worker());\n  await Promise.all(workers);\n  return results;\n}\n\n/**\n * Generate breadcrumbs from a content slug.\n * Returns array of { label, path } from root to current page.\n *\n * When `folderPaths` is provided, ancestor crumb links are resolved through it\n * so that folders without an index page link to their first child page instead\n * of producing a 404.\n */\nexport function buildBreadcrumbs(\n  contentSlug: string,\n  title: string,\n  basePath: string,\n  folderPaths?: Map<string, string>,\n): Array<{ label: string; path: string }> {\n  if (contentSlug === \"/\") return [];\n\n  const segments = contentSlug.split(\"/\");\n  const crumbs: Array<{ label: string; path: string }> = [];\n\n  for (let i = 0; i < segments.length - 1; i++) {\n    const slug = segments.slice(0, i + 1).join(\"/\");\n    crumbs.push({\n      label: toTitleCase(segments[i]),\n      path: folderPaths?.get(slug) ?? `${basePath}/${slug}`,\n    });\n  }\n\n  // Current page (no link)\n  crumbs.push({ label: title, path: \"\" });\n  return crumbs;\n}\n\nexport async function loadDocsPages(\n  config: ResolvedDocsConfig,\n  sectionMetas?: Map<string, DocsSectionMeta>,\n): Promise<DocsPage[]> {\n  const homeConfig = config.homeConfigFile\n    ? readJson5File<Record<string, unknown>>(config.homeConfigFile)\n    : undefined;\n\n  const files = collectMarkdownFiles(config.contentDir);\n  const concurrency = Math.max(1, availableParallelism() * 2);\n  const lastUpdatedByFile = config.lastUpdated\n    ? getGitLastUpdatedMap(config.rootDir, config.contentDir)\n    : undefined;\n\n  // Build a single shared config — same object reference enables the processor\n  // WeakMap cache so the expensive markdown processor and Shiki setup run only once.\n  const sharedMarkdownConfig: MarkdownConfig = {\n    ...(config.markdown ?? {}),\n    shiki: {\n      themes: config.markdown?.shiki?.themes ?? {\n        light: \"github-light\",\n        dark: \"github-dark\",\n      },\n      defaultShowLineNumbers: config.markdown?.shiki?.defaultShowLineNumbers,\n      langAlias: config.markdown?.shiki?.langAlias,\n    },\n    rehypePlugins: [rehypeLinkTransform, rehypeAssetTransform],\n  };\n\n  // Process markdown files with bounded concurrency to manage memory at scale\n  const results = await mapWithConcurrency(files, concurrency, async (filePath) => {\n    let raw: string;\n    try {\n      raw = readFileSync(filePath, \"utf-8\");\n    } catch (error) {\n      throw wrapMarkdownFileError(filePath, config.rootDir, \"Failed to read markdown file\", error);\n    }\n\n    // Extract frontmatter early to skip expensive markdown processing for drafts\n    let extracted: ReturnType<typeof extractFrontmatter>;\n    try {\n      extracted = extractFrontmatter(raw);\n    } catch (error) {\n      throw wrapMarkdownFileError(filePath, config.rootDir, \"Failed to parse frontmatter\", error);\n    }\n\n    let earlyFrontmatter: DocsFrontmatter;\n    try {\n      earlyFrontmatter = DocsFrontmatterSchema.parse(extracted.frontmatter ?? {});\n    } catch (error) {\n      throw wrapMarkdownFileError(filePath, config.rootDir, \"Invalid frontmatter\", error);\n    }\n    const contentSlug = toContentSlug(filePath, config.contentDir);\n    const isHome = contentSlug === \"/\";\n\n    const frontmatter =\n      isHome && homeConfig ? { ...homeConfig, ...earlyFrontmatter } : earlyFrontmatter;\n    if (frontmatter.draft) return null;\n\n    if (isHome && frontmatter.install != null) {\n      try {\n        const installHtml = await renderInstallHtml(frontmatter.install, sharedMarkdownConfig);\n        if (installHtml) {\n          (frontmatter as Record<string, unknown>).installHtml = installHtml;\n        }\n      } catch (error) {\n        throw wrapMarkdownFileError(\n          filePath,\n          config.rootDir,\n          \"Failed to render `install` snippet\",\n          error,\n        );\n      }\n    }\n\n    if (isHome && Array.isArray(frontmatter.packages) && frontmatter.packages.length > 0) {\n      // Resolve npm versions in parallel — registry calls are cached on disk so\n      // repeated builds and the dev server's incremental rebuilds reuse them.\n      // The inline NPM badge SVG is computed at build time with explicit\n      // `width`/`height`, so the rendered card reserves space and avoids any\n      // CLS when the home page paints.\n      const enrichedPackages = await Promise.all(\n        frontmatter.packages.map(async (pkg) => {\n          const npmIdentifier = resolveNpmIdentifier(pkg);\n          if (!npmIdentifier) return pkg;\n          const resolvedVersion =\n            pkg.version ?? (await getLatestNpmVersion(npmIdentifier, config.rootDir));\n          if (!resolvedVersion) return pkg;\n          const badge = renderNpmBadge(npmIdentifier, resolvedVersion);\n          return {\n            ...pkg,\n            version: resolvedVersion,\n            npmHref: badge.href,\n            npmBadgeSvg: badge.svg,\n            npmBadgeWidth: badge.width,\n            npmBadgeHeight: badge.height,\n          };\n        }),\n      );\n      (frontmatter as Record<string, unknown>).packages = enrichedPackages;\n    }\n\n    let result: Awaited<ReturnType<typeof processMarkdown>>;\n    try {\n      result = await runWithDocsTransformContext(\n        {\n          basePath: config.basePath,\n          contentDir: config.contentDir,\n          filePath,\n          trailingSlash: config.trailingSlash,\n        },\n        () =>\n          processMarkdown(raw, sharedMarkdownConfig, {\n            content: extracted.content,\n            frontmatter: extracted.frontmatter,\n            fileData: {\n              pagesmithFilePath: filePath,\n              pagesmithAssetRoot: config.contentDir,\n            },\n          }),\n      );\n    } catch (error) {\n      throw wrapMarkdownFileError(filePath, config.rootDir, \"Failed to render markdown\", error);\n    }\n    const html = result.html;\n\n    const routePath = isHome ? \"/\" : `/${contentSlug}`;\n    const section = resolvePageSection(filePath, config.contentDir, isHome);\n    const title =\n      frontmatter.title ??\n      (isHome ? config.title : toTitleCase(contentSlug.split(\"/\").at(-1) ?? section ?? \"Home\"));\n\n    // Resolve layout name: page frontmatter wins, then section meta defaults.\n    const sectionMeta = section ? sectionMetas?.get(section) : undefined;\n    const isLanding = section != null && contentSlug === section;\n    const fmLayout =\n      typeof frontmatter.layout === \"string\" && frontmatter.layout ? frontmatter.layout : undefined;\n    let layoutName: string;\n    if (isHome) {\n      layoutName = fmLayout ?? \"home\";\n    } else if (fmLayout) {\n      layoutName = fmLayout;\n    } else if (isLanding && sectionMeta?.layout) {\n      layoutName = sectionMeta.layout;\n    } else if (!isLanding && sectionMeta?.itemLayout) {\n      layoutName = sectionMeta.itemLayout;\n    } else {\n      layoutName = \"page\";\n    }\n\n    // Git last-updated timestamp (only when enabled)\n    const lastUpdated = config.lastUpdated ? lastUpdatedByFile?.get(filePath) : undefined;\n\n    return {\n      title,\n      routePath,\n      contentSlug,\n      section,\n      frontmatter,\n      html,\n      headings: result.headings,\n      sourcePath: filePath,\n      isHome,\n      layoutName,\n      lastUpdated,\n    } as DocsPage;\n  });\n\n  const pages: DocsPage[] = [];\n  for (const result of results) {\n    if (result != null) pages.push(result);\n  }\n  return pages.sort((left, right) => left.routePath.localeCompare(right.routePath));\n}\n\nexport function collectContentAssets(contentDir: string) {\n  return collectAssets([contentDir]);\n}\n"],"mappings":";;;;;;;;;;;;AAGA,MAAM,uBAAuB;AAW7B,SAAS,iBAAiB,SAAkD;CAC1E,IAAI,OAAO,YAAY,UAAU;EAC/B,MAAM,OAAO,QAAQ,QAAQ,SAAS,IAAI,EAAE,QAAQ,QAAQ,EAAE;EAC9D,IAAI,KAAK,WAAW,GAAG,OAAO;EAC9B,OAAO;GAAE;GAAM,MAAM;EAAqB;CAC5C;CAEA,MAAM,OAAO,QAAQ,KAAK,QAAQ,SAAS,IAAI,EAAE,QAAQ,QAAQ,EAAE;CACnE,IAAI,KAAK,WAAW,GAAG,OAAO;CAC9B,OAAO;EACL;EACA,MAAM,QAAQ,MAAM,KAAK,KAAK;EAC9B,OAAO,QAAQ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