interface Props {
  html: string;
  className?: string;
}

export function TiptapRenderer({ html, className }: Props) {
  if (!html) return null;
  return (
    <div
      className={`prose-custom max-w-none ${className ?? ""}`}
      dangerouslySetInnerHTML={{ __html: html }}
    />
  );
}

export function estimateReadTimeFromHtml(html: string): number {
  if (!html) return 1;
  const text = html.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
  const words = text.split(" ").filter(Boolean).length;
  return Math.max(1, Math.ceil(words / 200));
}
