import createDOMPurify from "dompurify";
let purifier;
const escapeHtml = (html)=>html.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
const getPurifier = ()=>{
    if (typeof window === 'undefined') {
        return undefined;
    }
    if (!purifier) {
        purifier = createDOMPurify(window);
    }
    return purifier;
};
export const sanitizeHtml = (html)=>{
    const domPurify = getPurifier();
    if (!domPurify) {
        return escapeHtml(html);
    }
    return domPurify.sanitize(html);
};
