"use client"; import React, { useEffect, useRef, useState } from "react"; import { Check, Copy } from "lucide-react"; import { cn } from "@/lib/utils"; /** Monospace install command with an inline copy affordance. */ export function CopyCommand({ command, className, }: { command: string; className?: string; }) { const [copied, setCopied] = useState(false); const timeout = useRef | null>(null); useEffect(() => { return () => { if (timeout.current) clearTimeout(timeout.current); }; }, []); const copy = async () => { try { await navigator.clipboard.writeText(command); } catch { return; } setCopied(true); if (timeout.current) clearTimeout(timeout.current); timeout.current = setTimeout(() => setCopied(false), 2000); }; return ( ); }