{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "code-block",
  "type": "registry:ui",
  "dependencies": [],
  "files": [
    {
      "path": "components/ui/code-block.tsx",
      "content": "import * as React from \"react\";\nimport { codeToHtml } from \"shiki\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport { CopyButton } from \"./copy-button\";\n\ninterface CodeBlockProps {\n  fileName?: string; // If provided, it reads this file from src/registry/\n  code?: string;     // If provided, it just highlights this string\n  language?: string;\n}\n\nexport async function CodeBlock({ fileName, code, language = \"tsx\" }: CodeBlockProps) {\n  let codeString = code || \"\";\n\n  // Try multiple source folders so migrated docs/components can still show code.\n  if (fileName) {\n    const candidates = [\n      path.join(process.cwd(), \"src\", \"registry\", fileName),\n      path.join(process.cwd(), \"src\", \"components\", \"ui\", fileName),\n      path.join(process.cwd(), \"src\", \"components\", \"docs\", fileName),\n      path.join(process.cwd(), \"src\", \"components\", \"docs\", \"Fliptext-examples\", fileName),\n    ];\n\n    try {\n      const existingFilePath = candidates.find((candidatePath) => fs.existsSync(candidatePath));\n\n      if (!existingFilePath) {\n        throw new Error(\"No matching source file found\");\n      }\n\n      codeString = fs.readFileSync(existingFilePath, \"utf8\");\n    } catch (e) {\n      codeString = `// Error reading file: ${fileName}\\n// Looked in src/registry, src/components/ui, and src/components/docs`;\n    }\n  }\n\n  // Convert the raw React code to styled HTML using Shiki\n  const html = await codeToHtml(codeString, {\n    lang: language,\n    theme: \"github-dark-dimmed\", // Sleek, dark theme perfect for VengeanceUI\n  });\n\n  return (\n    <div className=\"relative rounded-xl bg-[#22272e] border border-white/10 overflow-hidden my-6 shadow-2xl\">\n      {/* Header bar with filename and copy button */}\n      <div className=\"flex items-center justify-between px-4 py-2 bg-[#1c2128] border-b border-white/5\">\n        <span className=\"text-xs font-mono text-zinc-400\">\n          {fileName || \"code\"}\n        </span>\n        <CopyButton code={codeString} />\n      </div>\n      \n      {/* The beautifully highlighted code */}\n      <div \n        className=\"p-4 overflow-x-auto text-sm [&>pre]:!bg-transparent\"\n        dangerouslySetInnerHTML={{ __html: html }}\n      />\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/ui/code-block.tsx"
    }
  ]
}