import DOMPurify from "dompurify";

const ALLOWED_TAGS = ["p", "span", "strong", "b", "em", "i", "u", "br"];
const ALLOWED_ATTR = ["style"];

export function safeHtml(input: string | null | undefined): string {
  if (!input) return "";
  return DOMPurify.sanitize(input, {
    ALLOWED_TAGS,
    ALLOWED_ATTR,
    KEEP_CONTENT: true,
  });
}
