import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE_markdown_it__ from "markdown-it";
const md = new __WEBPACK_EXTERNAL_MODULE_markdown_it__["default"]({
    html: true,
    linkify: true,
    typographer: true,
    breaks: true
});
async function parseMarkdown(text) {
    if (!text) return text;
    return md.render(text);
}
function useParseMarkdown(text) {
    const [html, setHtml] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)('');
    const [loading, setLoading] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
    (0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
        setLoading(true);
        parseMarkdown(text).then((r)=>{
            setHtml(r);
            setLoading(false);
        });
    }, [
        text
    ]);
    return {
        html,
        loading
    };
}
function convertToText(markdownText) {
    const content = markdownText;
    let temp = document.createElement('div');
    temp.innerHTML = content;
    const text = temp.innerText;
    temp = null;
    return (null == text ? void 0 : text.replace(/[\n\r]/g, '')) || '';
}
export { convertToText, parseMarkdown, useParseMarkdown };
