import { jsx as _jsx } from "react/jsx-runtime";
import { forwardRef, useEffect } from 'react';
import { useMermaid } from '@diplodoc/mermaid-extension/react';
import { useMermaidRuntime } from "./useMermaidRuntime.js";
export function withMermaid(opts) {
    return (Component) => forwardRef(function WithLatex(props, ref) {
        const { meta, html, mermaidConfig } = props;
        const renderMermaid = useMermaid();
        useMermaidRuntime(meta, opts.runtime);
        useEffect(() => {
            renderMermaid(mermaidConfig);
        }, [html, mermaidConfig, renderMermaid]);
        return _jsx(Component, { ...props, ref: ref });
    });
}
//# sourceMappingURL=index.js.map
