{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "code",
  "title": "Code",
  "description": "Syntax-highlighted code with a copy button, a filename bar, and a package-manager tab strip.",
  "dependencies": [
    "prism-react-renderer",
    "prismjs"
  ],
  "registryDependencies": [
    "https://www.deltacomponents.dev/r/utils.json",
    "https://www.deltacomponents.dev/r/button.json",
    "https://www.deltacomponents.dev/r/tokens.json",
    "https://www.deltacomponents.dev/r/clipboard.json",
    "https://www.deltacomponents.dev/r/icon-context.json"
  ],
  "files": [
    {
      "path": "registry/ui/code.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { useEffect, useState } from \"react\"\nimport { Highlight } from \"prism-react-renderer\"\nimport type { PrismTheme } from \"prism-react-renderer\"\n\n// Side-effect import: registers extra Prism grammars (bash, docker,\n// java, ruby, php, …) on the shared instance. Must come before any\n// ``<Highlight>`` usage in this module.\nimport \"@/lib/prism-languages\"\n\nimport { cn } from \"@/lib/utils\"\nimport { copyToClipboard } from \"@/lib/clipboard\"\nimport { useIcon } from \"@/lib/icon-context\"\nimport { getIconForFile } from \"@/components/ui/code-icons\"\nimport { Button } from \"@/components/ui/button\"\n\ntype PackageManager = \"npm\" | \"yarn\" | \"pnpm\" | \"bun\"\n\n/** Every group the two built-in Prism palettes used to carry as hardcoded hex,\n *  now a named slot in the CSS palette (`--code-token-<key>`, declared in\n *  globals.css §8). One list drives two things: the built-in theme below\n *  (each group's color is just `var(--code-token-<key>)`, resolved by the\n *  `.dark` class with no JS), and `resolveGroupColor` — which walks a\n *  consumer-supplied `adaptiveTheme` palette to find the color it assigns\n *  each group, so that palette can be resolved the same CSS-only way. */\nconst tokenGroups: { key: string; types: string[]; fontStyle?: \"italic\" }[] = [\n  { key: \"comment\", types: [\"comment\"], fontStyle: \"italic\" },\n  { key: \"keyword\", types: [\"keyword\"] },\n  { key: \"property\", types: [\"property\", \"property-access\", \"attr-name\"] },\n  { key: \"tag\", types: [\"tag\"] },\n  { key: \"punctuation\", types: [\"punctuation\", \"symbol\", \"dom\", \"operator\"] },\n  { key: \"definition\", types: [\"definition\"] },\n  { key: \"function\", types: [\"function\"] },\n  { key: \"string\", types: [\"string\", \"char\", \"attr-value\"] },\n  { key: \"static\", types: [\"static\", \"number\"] },\n  { key: \"variable\", types: [\"variable\", \"parameter\"] },\n  { key: \"builtin\", types: [\"builtin\", \"function-definition\"] },\n  { key: \"class-name\", types: [\"class-name\"] },\n]\n\n/** The built-in syntax palette. Every color is a CSS variable reference —\n *  light values on `:root`, dark overrides on `.dark` (globals.css §8) — so\n *  the right palette is already in effect before this ever renders. Merging\n *  the old separate dark/light `PrismTheme`s into one is what makes that\n *  possible: previously the choice of *which* theme object to use lived in\n *  React state, guaranteeing a light-palette frame on every mount. */\nconst builtinTheme: PrismTheme = {\n  plain: { color: \"var(--code-fg)\", backgroundColor: \"var(--code-bg)\" },\n  styles: tokenGroups.map(({ key, types, fontStyle }) => ({\n    types,\n    style: {\n      color: `var(--code-token-${key})`,\n      ...(fontStyle ? { fontStyle } : {}),\n    },\n  })),\n}\n\n/** The color a `PrismTheme` assigns a token group, mirroring how\n *  prism-react-renderer resolves overlapping style entries: the last one\n *  naming the type wins. Falls back to the theme's own plain color for a\n *  group it doesn't style at all — used to project a consumer's\n *  `adaptiveTheme` onto the same `--code-token-*` slots the built-in palette\n *  uses. */\nfunction resolveGroupColor(theme: PrismTheme, types: string[]): string {\n  for (let i = theme.styles.length - 1; i >= 0; i--) {\n    const entry = theme.styles[i]\n    if (types.some((t) => entry.types.includes(t)))\n      return entry.style.color ?? theme.plain?.color ?? \"\"\n  }\n  return theme.plain?.color ?? \"\"\n}\n\ninterface CodeProps extends Omit<React.ComponentProps<\"div\">, \"children\"> {\n  npm?: string\n  yarn?: string\n  pnpm?: string\n  bun?: string\n  defaultPackageManager?: PackageManager\n  code?: string\n  css?: string\n  language?: string\n  defaultLanguage?: string\n  filename?: string\n  showLineNumbers?: boolean\n  theme?: PrismTheme\n  adaptiveTheme?: {\n    light: PrismTheme\n    dark: PrismTheme\n  }\n  /** Paint the header and code surface from the Prism theme's own background\n   *  instead of the page's card token. Defaults to true whenever `theme` or\n   *  `adaptiveTheme` is supplied — a palette brought from elsewhere carries its\n   *  own ground, and pairing its colours with the page's card is what makes a\n   *  dark theme read washed out on a light page. */\n  useThemeBackground?: boolean\n  scrollbar?: boolean\n  expandable?: boolean\n  defaultExpanded?: boolean\n  collapsedHeight?: string\n  /** Label on the affordance that opens a collapsed block. Docs previews say\n   *  \"View code\"; a bare code block says \"Expand\". Expanding is one-way —\n   *  there is no collapse control, so a reader never has to re-open what they\n   *  just opened. A page load starts collapsed again. */\n  expandLabel?: string\n}\n\n/** The code's own type size, set on the block's ROOT rather than on the\n *  `<pre>`, so every part of the block inherits it — the highlighted source,\n *  the line-number gutter, the filename bar and the package-manager tabs. That\n *  is what makes a single `text-sm` in `className` resize the whole block:\n *  tailwind-merge drops this default in favour of the caller's utility, where\n *  a size declared further down would have won on specificity and left the\n *  parts at different sizes. */\nconst CODE_TEXT_SIZE = \"text-[14px]\"\n\nconst monoFontFamily =\n  'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace'\n\nfunction parseMarkdownCodeBlock(input: string): {\n  code: string\n  language: string | null\n} {\n  const markdownRegex = /^```(\\w+)?\\n?([\\s\\S]*?)```$/\n  const match = input.trim().match(markdownRegex)\n\n  if (match) {\n    return {\n      language: match[1] || null,\n      code: match[2]?.trim() || \"\",\n    }\n  }\n\n  return { code: input, language: null }\n}\n\nconst languageAliases: Record<string, string> = {\n  py: \"python\",\n  js: \"javascript\",\n  ts: \"typescript\",\n  tsx: \"tsx\",\n  jsx: \"jsx\",\n  rb: \"ruby\",\n  rs: \"rust\",\n  sh: \"bash\",\n  shell: \"bash\",\n  zsh: \"bash\",\n  console: \"bash\",\n  yml: \"yaml\",\n  md: \"markdown\",\n  dockerfile: \"docker\",\n  Dockerfile: \"docker\",\n  ps1: \"powershell\",\n  ps: \"powershell\",\n}\n\nconst packageManagerCommands: Record<string, PackageManager> = {\n  npx: \"npm\",\n  npm: \"npm\",\n  yarn: \"yarn\",\n  pnpm: \"pnpm\",\n  bunx: \"bun\",\n  bun: \"bun\",\n}\n\nfunction resolveLanguage(lang: string): string {\n  return languageAliases[lang.toLowerCase()] || lang.toLowerCase()\n}\n\nfunction detectPackageManagerFromMarkdown(input: string): {\n  isPackageManager: boolean\n  command: string\n  manager: PackageManager\n} | null {\n  const parsed = parseMarkdownCodeBlock(input)\n  if (!parsed.language) return null\n\n  const lang = parsed.language.toLowerCase()\n  const manager = packageManagerCommands[lang]\n\n  if (manager) {\n    return {\n      isPackageManager: true,\n      command: parsed.code,\n      manager,\n    }\n  }\n\n  return null\n}\n\nfunction convertNpxToPackageManagers(npxCommand: string): {\n  npm: string\n  yarn: string\n  pnpm: string\n  bun: string\n} {\n  // Handle patterns like \"npx shadcn@latest add button\" or just \"shadcn@latest add button\"\n  let command = npxCommand.trim()\n\n  // Remove leading \"npx \" if present\n  if (command.startsWith(\"npx \")) {\n    command = command.slice(4)\n  }\n\n  return {\n    npm: `npx ${command}`,\n    yarn: `yarn dlx ${command}`,\n    pnpm: `pnpm dlx ${command}`,\n    bun: `bunx ${command}`,\n  }\n}\n\n\n/* ------------------------------------------------------------------\n * Icons\n * ------------------------------------------------------------------\n * The copy button's glyphs come from the icon context, like Button's and\n * MP3Player's, so a consumer's chosen icon set carries through to it. The\n * terminal glyph has no name there, so it stays inlined: lucide's own path\n * (ISC), drawn at its 24px grid so it sits correctly beside the rest.\n */\n\ninterface IconProps {\n  className?: string\n  style?: React.CSSProperties\n}\n\nfunction iconProps({ className, style }: IconProps) {\n  return {\n    className,\n    style,\n    viewBox: \"0 0 24 24\",\n    fill: \"none\",\n    stroke: \"currentColor\",\n    strokeWidth: 2,\n    strokeLinecap: \"round\" as const,\n    strokeLinejoin: \"round\" as const,\n    \"aria-hidden\": true,\n  }\n}\n\nfunction TerminalIcon(props: IconProps) {\n  return (\n    <svg {...iconProps(props)}>\n      <polyline points=\"4 17 10 11 4 5\" />\n      <line x1=\"12\" x2=\"20\" y1=\"19\" y2=\"19\" />\n    </svg>\n  )\n}\n\n/** The tone every piece of chrome sitting ON the code surface shares — the\n *  copy glyph, the filename and its file badge, the package-manager tabs — so\n *  they read as one set rather than several separately-tuned greys.\n *\n *  Opacity on the INHERITED colour, never a colour of its own. 60% of a\n *  surface's own foreground IS the muted token: measured against both\n *  palettes it lands within 1/255 of `--muted-foreground` over `--card`, in\n *  light and in dark alike. This used to be two branches saying the same\n *  thing twice — the app's muted token when the block sat on the page's card,\n *  an opacity when it painted from its own palette — and only the opacity\n *  form follows the surface underneath it. Riding the inherited colour means\n *  a palette brought from elsewhere, AND a consumer recolouring the header\n *  with a className, both carry the chrome with them rather than stranding it\n *  on the page's grey.\n *\n *  Hover is the only thing that brightens it — deliberately not touch. A phone\n *  never hovers, so pinning it to full strength there (which is what this used\n *  to do) left the copy glyph permanently darker than the filename it shares a\n *  row with.\n *\n *  Both are complete literal class strings. Tailwind generates utilities by\n *  scanning source text, so a class assembled as `${modifier}:opacity-100`\n *  never reaches the stylesheet — a hover written that way here once did\n *  nothing at all. Keep them literal. */\nconst CHROME_REST = \"opacity-60\"\nconst CHROME_HOVER = \"group-hover:opacity-100\"\n\n/** Copy ⇄ check swap: both glyphs stay mounted, stacked, and cross-morph —\n *  the leaver shrinks to a blurred point while the arriver grows out of one\n *  (same choreography as MP3Player's play/pause). The leaver takes the exit\n *  tier so the arriver is what the eye lands on. Spans, not the svgs, carry\n *  the transition: Button already owns `[&_svg]:transition` for its press dip. */\nconst ICON_SWAP =\n  \"absolute inset-0 flex items-center justify-center opacity-0 scale-25 blur-[4px] transition-[opacity,scale,filter] duration-(--motion-moderate-exit) ease-spring data-[shown=true]:opacity-100 data-[shown=true]:scale-100 data-[shown=true]:blur-none data-[shown=true]:duration-(--motion-moderate)\"\n\n/** Copy-to-clipboard control for a code surface.\n *\n *  Transparent at rest so it doesn't sit on the code as a visible chip; the\n *  ground arrives on hover, mixed against the block's own `--code-fg`/\n *  `--code-bg` (globals.css §8) rather than an app token, because a block\n *  carries its own light/dark palette independent of the page. Both vars are\n *  set once on the block's outer wrapper and inherited here, so this needs no\n *  colour prop of its own.\n *\n *  A floating button (no filename bar to sit in) also gets that ground at\n *  rest on a touch device — there's no hover to reveal it otherwise, so\n *  without a resting ground the glyph lands on top of whatever the first\n *  line happens to be. The two in-header buttons already sit on a bar and\n *  stay transparent until touched or hovered. */\nfunction CopyButton({\n  value,\n  className,\n  floating = false,\n}: {\n  value: string\n  className?: string\n  /** Floats over the code with no header/figcaption underneath it. */\n  floating?: boolean\n}) {\n  const [hasCopied, setHasCopied] = useState(false)\n  const CopyIcon = useIcon(\"copy\")\n  const CheckIcon = useIcon(\"check\")\n\n  useEffect(() => {\n    if (!hasCopied) return\n    const timer = setTimeout(() => setHasCopied(false), 2000)\n    return () => clearTimeout(timer)\n  }, [hasCopied])\n\n  return (\n    <Button\n      data-slot=\"copy-button\"\n      type=\"button\"\n      variant=\"ghost\"\n      size=\"icon-compact\"\n      aria-label={hasCopied ? \"Copied\" : \"Copy code\"}\n      className={cn(\n        \"group size-7 border-none shadow-none transition-colors\",\n        \"bg-transparent hover:bg-[var(--copy-button-hover-bg)] active:bg-[var(--copy-button-hover-bg)]\",\n        // Opt out of the ghost variant's own muted/foreground pair. The glyph\n        // takes its colour from the bar it sits in, so recolouring the header\n        // carries it too — tailwind-merge drops the variant's classes for\n        // these, and the hover half has to be named or it snaps back on hover.\n        \"text-inherit hover:text-inherit\",\n        // No hover on a phone, so only the floating button — the one with no\n        // ground under it already — gets a resting chip there.\n        floating && \"[@media(hover:none)]:bg-[var(--copy-button-rest-bg)]\",\n        className\n      )}\n      style={\n        // Only the floating button, which has no header to take a colour\n        // from. In a header bar it inherits — which is what lets a caller\n        // recolour the bar and carry this glyph along with it.\n        floating ? ({ color: \"var(--code-fg)\" } as React.CSSProperties) : undefined\n      }\n      onClick={async () => {\n        // Only claim success when the copy actually landed.\n        if (await copyToClipboard(value)) setHasCopied(true)\n      }}\n    >\n      <span\n        className={cn(\n          \"relative block size-3.5 transition-opacity\",\n          CHROME_REST,\n          CHROME_HOVER,\n          hasCopied && \"opacity-100\"\n        )}\n      >\n        <span data-shown={!hasCopied} className={ICON_SWAP}>\n          <CopyIcon className=\"size-3.5\" />\n        </span>\n        <span data-shown={hasCopied} className={ICON_SWAP}>\n          <CheckIcon className=\"size-3.5\" />\n        </span>\n      </span>\n    </Button>\n  )\n}\n\n/** The highlighted source itself, with optional gutter line numbers. Shared by\n *  the expandable and plain wrappers so the two can't drift. */\nfunction HighlightedCode({\n  code,\n  language,\n  theme,\n  showLineNumbers,\n}: {\n  code: string\n  language: string\n  theme: PrismTheme\n  showLineNumbers: boolean\n}) {\n  const lineNumberColor = theme.plain?.color\n    ? `color-mix(in srgb, ${theme.plain.color} 35%, transparent)`\n    : \"rgba(128, 128, 128, 0.35)\"\n\n  return (\n    <Highlight theme={theme} code={code.trim()} language={language}>\n      {({ className, style, tokens, getLineProps, getTokenProps }) => (\n        <pre\n          data-slot=\"code-pre\"\n          className={cn(\n            className,\n            // w-max so the block grows to the longest line, min-w-full so it\n            // still fills the scroller when every line is short. Together they\n            // give the rows below a width to stretch to.\n            \"relative w-max min-w-full py-3.5 outline-none\",\n            // Unitless leading rather than `leading-6`: it lands on the same\n            // 24px at the default 14px, but a `text-*` override on the root\n            // now scales the rows with the type instead of leaving them\n            // pinned to a height the larger text overflows.\n            \"leading-[1.7143] font-normal\"\n          )}\n          style={\n            {\n              ...style,\n              fontFamily: monoFontFamily,\n              backgroundColor: \"transparent\",\n              MozOsxFontSmoothing: \"grayscale\",\n              \"--line-number-color\": lineNumberColor,\n            } as React.CSSProperties\n          }\n        >\n          {tokens.map((line, i) => (\n            <div\n              key={i}\n              {...getLineProps({ line })}\n              // A sticky child can only stay put inside its own containing\n              // block. Left to size on its content, a short line's row ended\n              // before the scroll did and its number slid away with it; at the\n              // full block width every gutter survives the whole scroll.\n              className=\"relative flex min-h-[1.7143em] w-max min-w-full\"\n            >\n              {showLineNumbers && (\n                // Sticky so the gutter survives a horizontal scroll; it paints\n                // the block background so code scrolls *under* it, not through.\n                <span\n                  data-slot=\"code-gutter\"\n                  className=\"sticky left-0 z-10 w-16 flex-shrink-0 pr-6 pl-6 text-right font-medium tabular-nums select-none\"\n                  style={{\n                    fontFamily: monoFontFamily,\n                    color: lineNumberColor,\n                    backgroundColor: \"var(--code-bg)\",\n                  }}\n                >\n                  {i + 1}\n                </span>\n              )}\n              <span\n                className={cn(\n                  \"flex-1 pr-6 whitespace-pre\",\n                  !showLineNumbers && \"pl-6\"\n                )}\n              >\n                {line.map((token, key) => (\n                  <span key={key} {...getTokenProps({ token })} />\n                ))}\n              </span>\n            </div>\n          ))}\n        </pre>\n      )}\n    </Highlight>\n  )\n}\n\nconst COLLAPSED_ROW_CAP = 40\n\nexport function Code({\n  npm,\n  yarn,\n  pnpm,\n  bun,\n  defaultPackageManager = \"npm\",\n  code,\n  css,\n  language = \"typescript\",\n  defaultLanguage,\n  filename,\n  showLineNumbers = true,\n  theme,\n  adaptiveTheme,\n  useThemeBackground,\n  className,\n  scrollbar = true,\n  expandable = false,\n  defaultExpanded = false,\n  collapsedHeight = \"12rem\",\n  expandLabel = \"Expand\",\n  style,\n  ...props\n}: CodeProps) {\n  const [packageManager, setPackageManager] = React.useState<PackageManager>(\n    defaultPackageManager\n  )\n  const [isExpanded, setIsExpanded] = useState(defaultExpanded)\n\n  // A caller-supplied palette brings its own background; the built-in pair is\n  // designed to sit flush with --card, so only that one defaults to the token.\n  const paintFromTheme = useThemeBackground ?? Boolean(theme || adaptiveTheme)\n\n  const pageSurfaceVars = { color: \"var(--foreground)\", backgroundColor: \"var(--card)\" }\n\n  // `adaptiveTheme` is the one case that still varies by resolved theme, but\n  // the choice is made by the `.dark` class (see `wrapperVars` below), not by\n  // reading which theme is on screen — so `selectedTheme` itself never\n  // branches on light vs. dark.\n  //\n  // Without the theme's ground, its plain colour can't be trusted against the\n  // page surface either — a dark palette's near-white body text would land on\n  // a light card. Tokens keep their colours; unstyled text falls back.\n  const selectedTheme =\n    theme && !paintFromTheme\n      ? { ...theme, plain: { ...theme.plain, ...pageSurfaceVars } }\n      : theme || builtinTheme\n\n  // The palette's foreground/background, set once on the outer wrapper so the\n  // copy button's resting/hover ground (globals.css §8) can mix against a\n  // block's real surface instead of `transparent`. `adaptiveTheme` sets both\n  // halves of every pair here too, and `.code-adaptive-theme` (also in §8)\n  // is what lets `.dark` pick between them without JS.\n  const wrapperVars: Record<string, string> = adaptiveTheme\n    ? {\n        \"--code-fg-l\": adaptiveTheme.light.plain?.color ?? \"\",\n        \"--code-fg-d\": adaptiveTheme.dark.plain?.color ?? \"\",\n        \"--code-bg-l\": adaptiveTheme.light.plain?.backgroundColor ?? \"\",\n        \"--code-bg-d\": adaptiveTheme.dark.plain?.backgroundColor ?? \"\",\n        ...Object.fromEntries(\n          tokenGroups.flatMap(({ key, types }) => [\n            [`--code-token-${key}-l`, resolveGroupColor(adaptiveTheme.light, types)],\n            [`--code-token-${key}-d`, resolveGroupColor(adaptiveTheme.dark, types)],\n          ])\n        ),\n      }\n    : {\n        \"--code-fg\": theme?.plain?.color ?? \"var(--foreground)\",\n        \"--code-bg\": theme?.plain?.backgroundColor ?? \"var(--card)\",\n      }\n\n  // The code surface paints straight from `--code-bg`, so turning the theme\n  // ground off has to move the variable itself — the header alone would leave\n  // the two halves of the block on different surfaces. Inline vars outrank the\n  // `.code-adaptive-theme` class rules, so this covers the adaptive pair too.\n  if (!paintFromTheme) {\n    wrapperVars[\"--code-fg\"] = pageSurfaceVars.color\n    wrapperVars[\"--code-bg\"] = pageSurfaceVars.backgroundColor\n  }\n\n  const packageManagerFromMarkdown = code\n    ? detectPackageManagerFromMarkdown(code)\n    : null\n\n  const parsedMarkdown = code ? parseMarkdownCodeBlock(code) : null\n  const actualCode = css || (parsedMarkdown?.code ?? code)\n  const actualLanguage = css\n    ? \"css\"\n    : parsedMarkdown?.language\n      ? resolveLanguage(parsedMarkdown.language)\n      : defaultLanguage || language\n\n  // Two ways to get a package-manager block: an explicit npm/yarn/pnpm/bun\n  // prop set, or a ```npx fenced command we expand into all four. They render\n  // the same tab strip, so they resolve to one shape here rather than forking\n  // the JSX.\n  const explicit: Partial<Record<PackageManager, string>> = {\n    npm,\n    yarn,\n    pnpm,\n    bun,\n  }\n  const hasExplicit = Object.values(explicit).some(Boolean)\n  const pmCommands = packageManagerFromMarkdown\n    ? convertNpxToPackageManagers(packageManagerFromMarkdown.command)\n    : hasExplicit\n      ? explicit\n      : null\n\n  if (pmCommands) {\n    const keys = ([\"npm\", \"yarn\", \"pnpm\", \"bun\"] as PackageManager[]).filter(\n      (key) => pmCommands[key]\n    )\n    const active = pmCommands[packageManager] ? packageManager : keys[0]\n    const surfaceStyle = paintFromTheme\n      ? {\n          backgroundColor: selectedTheme.plain?.backgroundColor,\n          color: selectedTheme.plain?.color,\n        }\n      : undefined\n\n    return (\n      <div\n        data-slot=\"code\"\n        className={cn(\n          \"bg-card text-card-foreground border-border/60 overflow-hidden rounded-[var(--radius-bg,var(--radius,0.5rem))] border [background-clip:padding-box]\",\n          CODE_TEXT_SIZE,\n          adaptiveTheme && \"code-adaptive-theme\",\n          className\n        )}\n        style={{ ...(wrapperVars as React.CSSProperties), ...style }}\n        {...props}\n      >\n        <div\n          data-slot=\"code-header\"\n          className={cn(\n            \"border-border/60 flex items-center justify-between border-b px-3 py-2\",\n            !paintFromTheme && \"bg-background\"\n          )}\n          style={surfaceStyle}\n        >\n          <div className=\"flex items-center gap-2.5\">\n            <TerminalIcon className={cn(\"size-4\", CHROME_REST)} />\n            <div\n              role=\"tablist\"\n              aria-label=\"Package manager\"\n              data-slot=\"code-tablist\"\n              className=\"flex items-center\"\n            >\n              {keys.map((key) => (\n                <button\n                  key={key}\n                  type=\"button\"\n                  role=\"tab\"\n                  aria-selected={active === key}\n                  data-state={active === key ? \"active\" : \"inactive\"}\n                  data-slot=\"code-tab\"\n                  onClick={() => setPackageManager(key)}\n                  className={cn(\n                    \"h-7 rounded-[var(--radius-item,var(--radius,0.5rem))] px-2.5 font-medium transition-opacity\",\n                    CHROME_REST,\n                    \"data-[state=active]:opacity-100\",\n                    \"outline-none focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)]\"\n                  )}\n                  style={{ fontFamily: monoFontFamily }}\n                >\n                  {key}\n                </button>\n              ))}\n            </div>\n          </div>\n          <CopyButton value={pmCommands[active] || \"\"} className=\"size-7\" />\n        </div>\n        <div\n          data-slot=\"code-body\"\n          className={cn(\"overflow-x-auto\", !scrollbar && \"scrollbar-hide\")}\n        >\n          <div\n            className={cn(\"relative w-max min-w-full\", !paintFromTheme && \"bg-card\")}\n            style={\n              paintFromTheme\n                ? { backgroundColor: selectedTheme.plain?.backgroundColor }\n                : undefined\n            }\n          >\n            <Highlight\n              theme={selectedTheme}\n              code={pmCommands[active] || \"\"}\n              language=\"bash\"\n            >\n              {({\n                className: highlightClassName,\n                style,\n                tokens,\n                getLineProps,\n                getTokenProps,\n              }) => (\n                <pre\n                  data-slot=\"code-pre\"\n                  className={cn(\n                    highlightClassName,\n                    \"w-max min-w-full px-4 py-4 leading-relaxed font-normal\"\n                  )}\n                  style={{\n                    ...style,\n                    fontFamily: monoFontFamily,\n                    backgroundColor: paintFromTheme\n                      ? selectedTheme.plain?.backgroundColor\n                      : \"transparent\",\n                    WebkitFontSmoothing: \"antialiased\",\n                    MozOsxFontSmoothing: \"grayscale\",\n                  }}\n                >\n                  {tokens.map((line, i) => (\n                    <div key={i} {...getLineProps({ line })}>\n                      {line.map((token, key) => (\n                        <span key={key} {...getTokenProps({ token })} />\n                      ))}\n                    </div>\n                  ))}\n                </pre>\n              )}\n            </Highlight>\n          </div>\n        </div>\n      </div>\n    )\n  }\n\n  if (!actualCode) return null\n\n  // A collapsed block shows a handful of rows under `collapsedHeight`, and\n  // tokenising and mounting the other hundreds — several hundred milliseconds\n  // for a long source file — is what froze a tab switch that revealed one.\n  // Until it is expanded only the rows that can be seen are rendered; the\n  // copy button still carries the whole thing.\n  // ponytail: 40 rows covers a collapsedHeight of ~4× the default; derive\n  // the count from the height if a caller ever collapses taller than that.\n  const collapsed = expandable && !isExpanded\n  const visibleCode = collapsed\n    ? actualCode.split(\"\\n\").slice(0, COLLAPSED_ROW_CAP).join(\"\\n\")\n    : actualCode\n\n  const highlighted = (\n    <HighlightedCode\n      code={visibleCode}\n      language={actualLanguage}\n      theme={selectedTheme}\n      showLineNumbers={showLineNumbers}\n    />\n  )\n\n  return (\n    <div\n      data-slot=\"code\"\n      className={cn(\n        \"pointer-events-auto w-full max-w-full overflow-hidden\",\n        \"border-border/60 border [background-clip:padding-box]\",\n        \"rounded-[var(--radius-bg,var(--radius,0.5rem))]\",\n        CODE_TEXT_SIZE,\n        adaptiveTheme && \"code-adaptive-theme\",\n        className\n      )}\n      style={{ ...(wrapperVars as React.CSSProperties), ...style }}\n      {...props}\n    >\n      {filename && (\n        <figcaption\n          data-slot=\"code-header\"\n          className={cn(\n            \"border-border/60 flex items-center justify-between border-b px-4 py-2.5\",\n            !paintFromTheme && \"bg-background\"\n          )}\n          style={{\n            fontFamily: monoFontFamily,\n            ...(paintFromTheme\n              ? {\n                  backgroundColor: selectedTheme.plain?.backgroundColor,\n                  color: selectedTheme.plain?.color,\n                }\n              : {}),\n          }}\n        >\n          <div\n            data-slot=\"code-filename\"\n            className={cn(\"flex items-center gap-2\", CHROME_REST)}\n          >\n            {/* The file badge is a solid shape where the name beside it is\n                13px text, so at one shared colour it out-weighs the name it\n                belongs to and pulls the eye off both the label and the copy\n                button. The token stays the same; a notch of transparency is\n                what evens the three optically. */}\n            <span className=\"flex items-center opacity-70 [&_svg]:size-3.5\">\n              {getIconForFile(filename)}\n            </span>\n            <span className=\"font-medium tracking-tight\">{filename}</span>\n          </div>\n          <div className=\"flex items-center gap-2\">\n            <CopyButton value={actualCode} />\n          </div>\n        </figcaption>\n      )}\n\n      <div className=\"relative\">\n        {/* With no filename bar to live in, the controls float over the code.\n            The row is pointer-transparent so it doesn't eat text selection;\n            only the controls themselves take pointer events back. */}\n        {!filename && (\n          <div className=\"pointer-events-none absolute inset-x-0 top-0 z-10 flex justify-end\">\n            <div className=\"pointer-events-auto flex items-center gap-2 p-3\">\n              <CopyButton value={actualCode} floating />\n            </div>\n          </div>\n        )}\n\n        {expandable ? (\n          <div\n            data-slot=\"code-body\"\n            className={cn(\n              \"relative w-full transition-all\",\n              isExpanded ? \"overflow-auto\" : \"overflow-hidden\",\n              !scrollbar && \"scrollbar-hide\"\n            )}\n            style={{\n              backgroundColor: \"var(--code-bg)\",\n              maxHeight: isExpanded ? \"none\" : collapsedHeight,\n            }}\n          >\n            {highlighted}\n          </div>\n        ) : (\n          <div\n            data-slot=\"code-body\"\n            className={cn(\n              \"relative max-h-[450px] w-full overflow-auto\",\n              !scrollbar && \"scrollbar-hide\"\n            )}\n            style={{ backgroundColor: \"var(--code-bg)\" }}\n          >\n            {highlighted}\n          </div>\n        )}\n\n        {expandable && !isExpanded && (\n          <div\n            data-slot=\"code-expand-overlay\"\n            className=\"absolute inset-x-0 bottom-0 z-20 flex h-24 items-end justify-center rounded-b-[var(--radius-bg,var(--radius,0.5rem))] pb-4\"\n            style={{\n              background: `linear-gradient(to top, ${\n                paintFromTheme && selectedTheme.plain?.backgroundColor\n                  ? selectedTheme.plain.backgroundColor\n                  : \"var(--card)\"\n              } 40%, color-mix(in oklab, ${\n                paintFromTheme && selectedTheme.plain?.backgroundColor\n                  ? selectedTheme.plain.backgroundColor\n                  : \"var(--card)\"\n              } 60%, transparent) 75%, transparent 100%)`,\n            }}\n          >\n            <Button\n              type=\"button\"\n              data-slot=\"code-expand\"\n              variant=\"tertiary\"\n              size=\"compact\"\n              onClick={() => setIsExpanded(true)}\n              className=\"relative z-10 shadow-none\"\n            >\n              {expandLabel}\n            </Button>\n          </div>\n        )}\n      </div>\n    </div>\n  )\n}\n",
      "type": "registry:ui",
      "target": "components/ui/code.tsx"
    },
    {
      "path": "registry/ui/code-icons.tsx",
      "content": "import type React from \"react\"\n\ntype IconProps = React.HTMLAttributes<SVGElement>\n\nexport const Icons = {\n  ts: (props: IconProps) => (\n    <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" {...props}>\n      <path\n        fill=\"currentColor\"\n        d=\"M1.125 0C.502 0 0 .502 0 1.125v21.75C0 23.498.502 24 1.125 24h21.75c.623 0 1.125-.502 1.125-1.125V1.125C24 .502 23.498 0 22.875 0zm17.363 9.75c.612 0 1.154.037 1.627.111a6.38 6.38 0 0 1 1.306.34v2.458a3.95 3.95 0 0 0-.643-.361 5.093 5.093 0 0 0-.717-.26 5.453 5.453 0 0 0-1.426-.2c-.3 0-.573.028-.819.086a2.1 2.1 0 0 0-.623.242c-.17.104-.3.229-.393.374a.888.888 0 0 0-.14.49c0 .196.053.373.156.529.104.156.252.304.443.444s.423.276.696.41c.273.135.582.274.926.416.47.197.892.407 1.266.628.374.222.695.473.963.753.268.279.472.598.614.957.142.359.214.776.214 1.253 0 .657-.125 1.21-.373 1.656a3.033 3.033 0 0 1-1.012 1.085 4.38 4.38 0 0 1-1.487.596c-.566.12-1.163.18-1.79.18a9.916 9.916 0 0 1-1.84-.164 5.544 5.544 0 0 1-1.512-.493v-2.63a5.033 5.033 0 0 0 3.237 1.2c.333 0 .624-.03.872-.09.249-.06.456-.144.623-.25.166-.108.29-.234.373-.38a1.023 1.023 0 0 0-.074-1.089 2.12 2.12 0 0 0-.537-.5 5.597 5.597 0 0 0-.807-.444 27.72 27.72 0 0 0-1.007-.436c-.918-.383-1.602-.852-2.053-1.405-.45-.553-.676-1.222-.676-2.005 0-.614.123-1.141.369-1.582.246-.441.58-.804 1.004-1.089a4.494 4.494 0 0 1 1.47-.629 7.536 7.536 0 0 1 1.77-.201zm-15.113.188h9.563v2.166H9.506v9.646H6.789v-9.646H3.375z\"\n      />\n    </svg>\n  ),\n  css: (props: IconProps) => (\n    <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" {...props}>\n      <path\n        fill=\"currentColor\"\n        d=\"M1.5 0h21l-1.91 21.563L11.977 24l-8.565-2.438L1.5 0zm17.09 4.413L5.41 4.41l.213 2.622 10.125.002-.255 2.716h-6.64l.24 2.573h6.182l-.366 3.523-2.91.804-2.956-.81-.188-2.11h-2.61l.29 3.855L12 19.288l5.373-1.53L18.59 4.414z\"\n      />\n    </svg>\n  ),\n  json: (props: IconProps) => (\n    <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" {...props}>\n      <path\n        fill=\"currentColor\"\n        d=\"M5.759 3.975h1.783V5.76H5.759v4.458A1.783 1.783 0 0 1 3.975 12a1.783 1.783 0 0 1 1.784 1.783v4.459h1.783v1.783H5.759c-.954-.24-1.784-.803-1.784-1.783v-3.567a1.783 1.783 0 0 0-1.783-1.783H.975v-1.783h1.217a1.783 1.783 0 0 0 1.783-1.784V5.76c0-.98.83-1.543 1.784-1.784m12.482 0c.954.24 1.784.803 1.784 1.783v3.567a1.783 1.783 0 0 0 1.783 1.783h1.217v1.784h-1.217a1.783 1.783 0 0 0-1.783 1.783v3.567c0 .98-.83 1.543-1.784 1.783h-1.783v-1.783h1.783v-4.459A1.783 1.783 0 0 1 20.025 12a1.783 1.783 0 0 1-1.784-1.783V5.759h-1.783V3.975z\"\n      />\n    </svg>\n  ),\n  python: (props: IconProps) => (\n    <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" {...props}>\n      <path\n        fill=\"currentColor\"\n        d=\"M11.914 0C5.82 0 6.2 2.656 6.2 2.656l.007 2.752h5.814v.826H3.9S0 5.789 0 11.969c0 6.18 3.403 5.96 3.403 5.96h2.03v-2.867s-.109-3.42 3.35-3.42h5.766s3.24.052 3.24-3.148V3.202S18.28 0 11.914 0M8.708 1.85c.578 0 1.046.47 1.046 1.052 0 .581-.468 1.051-1.046 1.051-.579 0-1.046-.47-1.046-1.051 0-.582.467-1.052 1.046-1.052\"\n      />\n      <path\n        fill=\"currentColor\"\n        d=\"M12.086 24c6.094 0 5.714-2.656 5.714-2.656l-.007-2.752h-5.814v-.826h8.121s3.9.445 3.9-5.735c0-6.18-3.403-5.96-3.403-5.96h-2.03v2.867s.109 3.42-3.35 3.42H9.451s-3.24-.052-3.24 3.148v5.292S5.72 24 12.086 24m3.206-1.85c-.578 0-1.046-.47-1.046-1.052 0-.581.468-1.051 1.046-1.051.579 0 1.046.47 1.046 1.051 0 .582-.467 1.052-1.046 1.052\"\n      />\n    </svg>\n  ),\n  rust: (props: IconProps) => (\n    <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"22 22 100 100\" {...props}>\n      <path\n        fill=\"currentColor\"\n        d=\"m71.05 23.68c-26.06 0-47.27 21.22-47.27 47.27s21.22 47.27 47.27 47.27 47.27-21.22 47.27-47.27-21.22-47.27-47.27-47.27zm-.07 4.2a3.1 3.11 0 0 1 3.02 3.11 3.11 3.11 0 0 1 -6.22 0 3.11 3.11 0 0 1 3.2-3.11zm7.12 5.12a38.27 38.27 0 0 1 26.2 18.66l-3.67 8.28c-.63 1.43.02 3.11 1.44 3.75l7.06 3.13a38.27 38.27 0 0 1 .08 6.64h-3.93c-.39 0-.55.26-.55.64v1.8c0 4.24-2.39 5.17-4.49 5.4-2 .23-4.21-.84-4.49-2.06-1.18-6.63-3.14-8.04-6.24-10.49 3.85-2.44 7.85-6.05 7.85-10.87 0-5.21-3.57-8.49-6-10.1-3.42-2.25-7.2-2.7-8.22-2.7h-40.6a38.27 38.27 0 0 1 21.41-12.08l4.79 5.02c1.08 1.13 2.87 1.18 4 .09zm-44.2 23.02a3.11 3.11 0 0 1 3.02 3.11 3.11 3.11 0 0 1 -6.22 0 3.11 3.11 0 0 1 3.2-3.11zm74.15.14a3.11 3.11 0 0 1 3.02 3.11 3.11 3.11 0 0 1 -6.22 0 3.11 3.11 0 0 1 3.2-3.11zm-68.29.5h5.42v24.44h-10.94a38.27 38.27 0 0 1 -1.24-14.61l6.7-2.98c1.43-.64 2.08-2.31 1.44-3.74zm22.62.26h12.91c.67 0 4.71.77 4.71 3.8 0 2.51-3.1 3.41-5.65 3.41h-11.98zm0 17.56h9.89c.9 0 4.83.26 6.08 5.28.39 1.54 1.26 6.56 1.85 8.17.59 1.8 2.98 5.4 5.53 5.4h16.14a38.27 38.27 0 0 1 -3.54 4.1l-6.57-1.41c-1.53-.33-3.04.65-3.37 2.18l-1.56 7.28a38.27 38.27 0 0 1 -31.91-.15l-1.56-7.28c-.33-1.53-1.83-2.51-3.36-2.18l-6.43 1.38a38.27 38.27 0 0 1 -3.32-3.92h31.27c.35 0 .59-.06.59-.39v-11.06c0-.32-.24-.39-.59-.39h-9.15zm-14.43 25.33a3.11 3.11 0 0 1 3.02 3.11 3.11 3.11 0 0 1 -6.22 0 3.11 3.11 0 0 1 3.2-3.11zm46.05.14a3.11 3.11 0 0 1 3.02 3.11 3.11 3.11 0 0 1 -6.22 0 3.11 3.11 0 0 1 3.2-3.11z\"\n      />\n      <path\n        fill=\"currentColor\"\n        fillRule=\"evenodd\"\n        stroke=\"currentColor\"\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n        strokeWidth=\"3\"\n        d=\"m115.68 70.95a44.63 44.63 0 0 1 -44.63 44.63 44.63 44.63 0 0 1 -44.63-44.63 44.63 44.63 0 0 1 44.63-44.63 44.63 44.63 0 0 1 44.63 44.63zm-.84-4.31 6.96 4.31-6.96 4.31 5.98 5.59-7.66 2.87 4.78 6.65-8.09 1.32 3.4 7.46-8.19-.29 1.88 7.98-7.98-1.88.29 8.19-7.46-3.4-1.32 8.09-6.65-4.78-2.87 7.66-5.59-5.98-4.31 6.96-4.31-6.96-5.59 5.98-2.87-7.66-6.65 4.78-1.32-8.09-7.46 3.4.29-8.19-7.98 1.88 1.88-7.98-8.19.29 3.4-7.46-8.09-1.32 4.78-6.65-7.66-2.87 5.98-5.59-6.96-4.31 6.96-4.31-5.98-5.59 7.66-2.87-4.78-6.65 8.09-1.32-3.4-7.46 8.19.29-1.88-7.98 7.98 1.88-.29-8.19 7.46 3.4 1.32-8.09 6.65 4.78 2.87-7.66 5.59 5.98 4.31-6.96 4.31 6.96 5.59-5.98 2.87 7.66 6.65-4.78 1.32 8.09 7.46-3.4-.29 8.19 7.98-1.88-1.88 7.98 8.19-.29-3.4 7.46 8.09 1.32-4.78 6.65 7.66 2.87z\"\n      />\n    </svg>\n  ),\n  bash: (props: IconProps) => (\n    <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" {...props}>\n      <path\n        fill=\"currentColor\"\n        d=\"M21.038 4.9 13.461.402a2.86 2.86 0 0 0-2.923.001L2.961 4.9A3.023 3.023 0 0 0 1.5 7.503v8.995c0 1.073.557 2.066 1.462 2.603l7.577 4.497a2.86 2.86 0 0 0 2.922 0l7.577-4.497a3.023 3.023 0 0 0 1.462-2.603V7.503A3.021 3.021 0 0 0 21.038 4.9z\"\n      />\n    </svg>\n  ),\n  html: (props: IconProps) => (\n    <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" {...props}>\n      <path\n        fill=\"currentColor\"\n        d=\"M1.5 0h21l-1.91 21.563L11.977 24l-8.564-2.438L1.5 0Zm7.031 9.75-.232-2.718 10.059.003.23-2.622L5.412 4.41l.698 8.01h9.126l-.326 3.426-2.91.804-2.955-.81-.188-2.11H6.248l.33 4.171L12 19.351l5.379-1.443.744-8.157H8.531Z\"\n      />\n    </svg>\n  ),\n  react: (props: IconProps) => (\n    <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" {...props}>\n      <path\n        fill=\"currentColor\"\n        d=\"M14.23 12.004a2.236 2.236 0 0 1-2.235 2.236 2.236 2.236 0 0 1-2.236-2.236 2.236 2.236 0 0 1 2.235-2.236 2.236 2.236 0 0 1 2.236 2.236zm2.648-10.69c-1.346 0-3.107.96-4.888 2.622-1.78-1.653-3.542-2.602-4.887-2.602-.41 0-.783.093-1.106.278-1.375.793-1.683 3.264-.973 6.365C1.98 8.917 0 10.42 0 12.004c0 1.59 1.99 3.097 5.043 4.03-.704 3.113-.39 5.588.988 6.38.32.187.69.275 1.102.275 1.345 0 3.107-.96 4.888-2.624 1.78 1.654 3.542 2.603 4.887 2.603.41 0 .783-.09 1.106-.275 1.374-.792 1.683-3.263.973-6.365C22.02 15.096 24 13.59 24 12.004c0-1.59-1.99-3.097-5.043-4.032.704-3.11.39-5.587-.988-6.38a2.167 2.167 0 0 0-1.092-.278z\"\n      />\n    </svg>\n  ),\n  go: (props: IconProps) => (\n    <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" {...props}>\n      <path\n        fill=\"currentColor\"\n        d=\"M1.811 10.715c-.047 0-.058-.024-.035-.059l.246-.316c.024-.035.078-.059.129-.059h4.17c.047 0 .058.035.035.07l-.199.305c-.02.035-.082.07-.117.07zm-1.35 1.073c-.047 0-.058-.023-.035-.058l.246-.316c.023-.035.082-.059.129-.059h5.328c.047 0 .07.035.059.07l-.094.28c-.012.046-.059.07-.106.07zm2.156 1.074c-.047 0-.058-.035-.035-.07l.164-.293c.023-.035.07-.07.117-.07h2.337c.047 0 .07.035.07.082l-.023.281c0 .047-.047.082-.082.082zM15.004 10.505c-.735.188-1.239.328-1.963.516-.176.047-.188.059-.34-.117-.176-.199-.305-.328-.551-.445-.738-.363-1.452-.258-2.115.176-.797.516-1.207 1.276-1.195 2.22.012.938.657 1.708 1.582 1.836.797.106 1.464-.164 1.992-.773.106-.129.2-.27.317-.434h-2.258c-.246 0-.305-.152-.223-.352.152-.363.434-.973.598-1.276.047-.082.14-.188.293-.188h4.253c-.024.317-.024.633-.07.95-.118.809-.4 1.558-.856 2.226-.703 1.027-1.64 1.734-2.844 2.033-1.002.246-1.968.176-2.868-.293-.856-.446-1.441-1.123-1.758-2.015-.363-1.027-.317-2.033.129-3.001.504-1.095 1.301-1.898 2.396-2.391 1.002-.445 2.045-.527 3.118-.258.797.199 1.476.61 2.01 1.229.164.199.305.41.48.656h.012zM18.989 16.847c-.925-.012-1.78-.27-2.52-.833-.633-.48-1.038-1.1-1.16-1.874-.176-1.12.152-2.092.867-2.938.668-.797 1.523-1.289 2.555-1.464 1.003-.164 1.945-.023 2.808.539.75.492 1.254 1.158 1.43 2.057.222 1.27-.118 2.32-.949 3.236-.609.68-1.37 1.135-2.25 1.265-.422.07-.845.07-1.278.082z\"\n      />\n    </svg>\n  ),\n  markdown: (props: IconProps) => (\n    <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\" {...props}>\n      <path\n        fill=\"currentColor\"\n        d=\"M102 366C88 366 76 354 76 340V170c0-14 12-26 26-26h307c14 0 26 12 26 26v170c0 14-11 26-25 26zM102 162c-4 0-9 4-9 9v170c0 5 4 9 9 9h307c5 0 9-4 9-9V170c0-5-4-9-9-9H102zm26 153V196h34l34 43 34-43h35v119h-34v-68l-34 43-34-43v68zm216 0-52-57h34v-61h34v60h34z\"\n      />\n    </svg>\n  ),\n  file: (props: IconProps) => (\n    <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" {...props}>\n      <path\n        fill=\"none\"\n        stroke=\"currentColor\"\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n        strokeWidth=\"2\"\n        d=\"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z\"\n      />\n      <polyline\n        fill=\"none\"\n        stroke=\"currentColor\"\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n        strokeWidth=\"2\"\n        points=\"14 2 14 8 20 8\"\n      />\n    </svg>\n  ),\n}\n\nexport function getIconForFile(filename: string) {\n  const extension = filename.split(\".\").pop()?.toLowerCase()\n\n  switch (extension) {\n    case \"json\":\n      return <Icons.json className=\"size-4 fill-current\" />\n    case \"css\":\n      return <Icons.css className=\"size-4 fill-current\" />\n    case \"ts\":\n    case \"tsx\":\n    case \"typescript\":\n      return <Icons.ts className=\"size-4 fill-current\" />\n    case \"js\":\n    case \"jsx\":\n      return <Icons.react className=\"size-4 fill-current\" />\n    case \"py\":\n    case \"python\":\n      return <Icons.python className=\"size-4 fill-current\" />\n    case \"rs\":\n    case \"rust\":\n      return <Icons.rust className=\"size-4 fill-current\" />\n    case \"sh\":\n    case \"bash\":\n    case \"zsh\":\n      return <Icons.bash className=\"size-4 fill-current\" />\n    case \"html\":\n    case \"htm\":\n      return <Icons.html className=\"size-4 fill-current\" />\n    case \"go\":\n      return <Icons.go className=\"size-4 fill-current\" />\n    case \"md\":\n    case \"mdx\":\n      return <Icons.markdown className=\"size-4 fill-current\" />\n    default:\n      return <Icons.file className=\"size-4\" />\n  }\n}\n",
      "type": "registry:ui",
      "target": "components/ui/code-icons.tsx"
    },
    {
      "path": "registry/lib/prism-languages.ts",
      "content": "/**\n * Register additional Prism grammars on the shared instance used by\n * ``prism-react-renderer``.\n *\n * ``prism-react-renderer`` ships with a small built-in set (JS/TS,\n * Python, Go, Rust, JSON, YAML, CSS/HTML, SQL, Swift, Kotlin, etc.)\n * and silently falls back to a plain-text render for anything not on\n * that list. Each language-component file from ``prismjs/components``\n * self-registers on ``globalThis.Prism`` as a side effect of being\n * imported — so we expose the renderer's Prism instance there once,\n * then ``require`` each grammar we want to support.\n *\n * Importing this module anywhere in the app is enough; the\n * registrations are global and idempotent. Keep this file\n * side-effect-only: no exports, no React, no SSR-unsafe globals.\n */\n\nimport { Prism } from \"prism-react-renderer\";\n\n// ``prismjs`` grammars read from ``global.Prism`` (Node) or\n// ``window.Prism`` (browser). ``globalThis`` resolves to whichever is\n// available, so this works on both the server and the client.\n(globalThis as typeof globalThis & { Prism?: typeof Prism }).Prism = Prism;\n\n// Each ``require`` mutates ``globalThis.Prism.languages`` and returns\n// nothing useful — the side effect is the point. Using ``require``\n// rather than ``import`` because the grammar files are CommonJS and\n// expect a synchronous registration order.\n/* eslint-disable @typescript-eslint/no-require-imports */\n// ``prism-markup-templating`` defines ``Prism.languages.markup-templating``\n// and helpers (``tokenizePlaceholders``) that PHP / Smarty / Twig /\n// EJS / ERB grammars look up at registration time. It must load\n// **before** any of those.\nrequire(\"prismjs/components/prism-markup-templating\");\nrequire(\"prismjs/components/prism-bash\");\nrequire(\"prismjs/components/prism-diff\");\nrequire(\"prismjs/components/prism-docker\");\nrequire(\"prismjs/components/prism-ini\");\nrequire(\"prismjs/components/prism-java\");\nrequire(\"prismjs/components/prism-nginx\");\nrequire(\"prismjs/components/prism-php\");\nrequire(\"prismjs/components/prism-powershell\");\nrequire(\"prismjs/components/prism-ruby\");\nrequire(\"prismjs/components/prism-toml\");\n/* eslint-enable @typescript-eslint/no-require-imports */\n",
      "type": "registry:lib",
      "target": "lib/prism-languages.ts"
    }
  ],
  "cssVars": {
    "light": {
      "code-token-comment": "#8b949e",
      "code-token-keyword": "#d73a49",
      "code-token-property": "#005cc5",
      "code-token-tag": "#22863a",
      "code-token-punctuation": "#24292e",
      "code-token-definition": "#24292e",
      "code-token-function": "#6f42c1",
      "code-token-string": "#032f62",
      "code-token-static": "#005cc5",
      "code-token-variable": "#e36209",
      "code-token-builtin": "#d73a49",
      "code-token-class-name": "#6f42c1",
      "copy-button-hover-bg": "color-mix(in oklab, var(--code-fg) 7%, var(--code-bg))",
      "copy-button-rest-bg": "color-mix(in oklab, var(--code-fg) 10%, var(--code-bg))"
    },
    "dark": {
      "code-token-comment": "#757575",
      "code-token-keyword": "#77b7d7",
      "code-token-property": "#77b7d7",
      "code-token-tag": "#dfab5c",
      "code-token-punctuation": "#ffffff",
      "code-token-definition": "#86d9ca",
      "code-token-function": "#86d9ca",
      "code-token-string": "#977cdc",
      "code-token-static": "#ff6658",
      "code-token-variable": "#ffffff",
      "code-token-builtin": "#ffffff",
      "code-token-class-name": "#ffffff"
    }
  },
  "css": {
    ".code-adaptive-theme": {
      "--code-fg": "var(--code-fg-l)",
      "--code-bg": "var(--code-bg-l)",
      "--code-token-comment": "var(--code-token-comment-l)",
      "--code-token-keyword": "var(--code-token-keyword-l)",
      "--code-token-property": "var(--code-token-property-l)",
      "--code-token-tag": "var(--code-token-tag-l)",
      "--code-token-punctuation": "var(--code-token-punctuation-l)",
      "--code-token-definition": "var(--code-token-definition-l)",
      "--code-token-function": "var(--code-token-function-l)",
      "--code-token-string": "var(--code-token-string-l)",
      "--code-token-static": "var(--code-token-static-l)",
      "--code-token-variable": "var(--code-token-variable-l)",
      "--code-token-builtin": "var(--code-token-builtin-l)",
      "--code-token-class-name": "var(--code-token-class-name-l)"
    },
    ".dark .code-adaptive-theme": {
      "--code-fg": "var(--code-fg-d)",
      "--code-bg": "var(--code-bg-d)",
      "--code-token-comment": "var(--code-token-comment-d)",
      "--code-token-keyword": "var(--code-token-keyword-d)",
      "--code-token-property": "var(--code-token-property-d)",
      "--code-token-tag": "var(--code-token-tag-d)",
      "--code-token-punctuation": "var(--code-token-punctuation-d)",
      "--code-token-definition": "var(--code-token-definition-d)",
      "--code-token-function": "var(--code-token-function-d)",
      "--code-token-string": "var(--code-token-string-d)",
      "--code-token-static": "var(--code-token-static-d)",
      "--code-token-variable": "var(--code-token-variable-d)",
      "--code-token-builtin": "var(--code-token-builtin-d)",
      "--code-token-class-name": "var(--code-token-class-name-d)"
    }
  },
  "docs": "Docs & live playground: https://www.deltacomponents.dev/docs/code.",
  "categories": [
    "components"
  ],
  "type": "registry:ui"
}
