"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DndLayoutManager = exports.floatingRender = void 0;
const react_dom_1 = __importDefault(require("react-dom"));
const react_1 = __importDefault(require("react"));
const use_behaviorsubject_1 = require("@rcp/use.behaviorsubject");
const dnd_1 = require("../mometa/runtime/dnd");
const const_1 = require("./config/const");
const floatingRender = (container) => {
    react_dom_1.default.render(react_1.default.createElement(DndLayoutManager, null), container);
    return () => {
        react_dom_1.default.unmountComponentAtNode(container);
    };
};
exports.floatingRender = floatingRender;
function DndLayoutManager() {
    const [wins] = (0, use_behaviorsubject_1.useBehaviorSubject)(const_1.iframeWindowsSubject);
    const doms = react_1.default.useMemo(() => {
        return wins === null || wins === void 0 ? void 0 : wins.map((w) => w.document.body).filter((x) => x && x.parentNode);
    }, [wins]);
    return (react_1.default.createElement(react_1.default.Fragment, null, doms === null || doms === void 0 ? void 0 : doms.map((dom, i) => (react_1.default.createElement(dnd_1.DndLayout, { dom: dom, key: i })))));
}
exports.DndLayoutManager = DndLayoutManager;
//# sourceMappingURL=render-floating.js.map