"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withLatex = withLatex;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const react_2 = require("@diplodoc/latex-extension/react");
const useLatexRuntime_1 = require("./useLatexRuntime.js");
function withLatex(opts) {
    return (Component) => (0, react_1.forwardRef)(function WithLatex(props, ref) {
        const { meta, html } = props;
        const renderLatex = (0, react_2.useLatex)();
        (0, useLatexRuntime_1.useLatexRuntime)(meta, opts.runtime);
        (0, react_1.useEffect)(() => {
            renderLatex({ throwOnError: false });
        }, [html, renderLatex]);
        return (0, jsx_runtime_1.jsx)(Component, { ...props, ref: ref });
    });
}
//# sourceMappingURL=index.js.map
