"use client"; import type { MouseEvent } from "react"; import { useRef, useState } from "react"; export function HeadingAnchor({ id }: { id?: string }) { const [copied, setCopied] = useState(false); const timer = useRef | null>(null); if (!id) return null; async function handleClick(event: MouseEvent) { event.preventDefault(); const url = `${window.location.origin}${window.location.pathname}#${id}`; try { await navigator.clipboard.writeText(url); setCopied(true); } catch {} if (timer.current) clearTimeout(timer.current); timer.current = setTimeout(() => setCopied(false), 1400); } return ( {copied ? ( ) : ( )} ); }