import { jsx as _jsx } from "react/jsx-runtime";
import { forwardRef, useEffect } from 'react';
import { useLatex } from '@diplodoc/latex-extension/react';
import { useLatexRuntime } from "./useLatexRuntime.js";
export function withLatex(opts) {
    return (Component) => forwardRef(function WithLatex(props, ref) {
        const { meta, html } = props;
        const renderLatex = useLatex();
        useLatexRuntime(meta, opts.runtime);
        useEffect(() => {
            renderLatex({ throwOnError: false });
        }, [html, renderLatex]);
        return _jsx(Component, { ...props, ref: ref });
    });
}
//# sourceMappingURL=index.js.map
