"use client"; import { useState } from "react"; interface Snippet { label: string; code: string; } interface HmacRecipeBlockProps { title?: string; /** Single code block (backward compat) */ code?: string; /** Multiple language snippets rendered with tab switcher */ snippets?: Snippet[]; } export function HmacRecipeBlock({ code, title, snippets }: HmacRecipeBlockProps) { const tabs: Snippet[] = snippets ?? (code ? [{ label: "Node.js", code }] : []); const [active, setActive] = useState(0); const [copied, setCopied] = useState(false); const copy = async () => { await navigator.clipboard.writeText(tabs[active]?.code ?? ""); setCopied(true); setTimeout(() => setCopied(false), 2000); }; if (tabs.length === 0) return null; return (
{title && (

{title}

)} {tabs.length > 1 && (
{tabs.map((s, i) => ( ))}
)}
          {tabs[active]?.code}
        
); }