"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withYfmHtmlBlock = withYfmHtmlBlock;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const react_2 = require("@diplodoc/html-extension/react");
const useYfmHtmlBlockRuntime_1 = require("./useYfmHtmlBlockRuntime.js");
function withYfmHtmlBlock(opts) {
    return (Component) => (0, react_1.forwardRef)(function WithYfmHtml(props, ref) {
        const { meta, html, yfmHtmlBlockConfig } = props;
        (0, useYfmHtmlBlockRuntime_1.useYfmHtmlBlockRuntime)(meta, opts.runtime);
        const yfmHtmlBlock = (0, react_2.useDiplodocEmbeddedContentController)();
        (0, react_1.useEffect)(() => {
            if (yfmHtmlBlock) {
                if (yfmHtmlBlockConfig) {
                    yfmHtmlBlock.setConfig(yfmHtmlBlockConfig);
                }
                yfmHtmlBlock.initialize();
            }
        }, [yfmHtmlBlock, html, yfmHtmlBlockConfig]);
        return (0, jsx_runtime_1.jsx)(Component, { ...props, ref: ref });
    });
}
//# sourceMappingURL=index.js.map
