"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConstructorLoadable = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const React = tslib_1.__importStar(require("react"));
const blockIdContext_1 = require("../../../../context/blockIdContext/index.js");
const innerContext_1 = require("../../../../context/innerContext/index.js");
const Loadable_1 = tslib_1.__importDefault(require("../../../Loadable/Loadable.js"));
const ConstructorLoadable = (props) => {
    const { blocks } = React.useContext(innerContext_1.InnerContext);
    const { block, blockKey, config, serviceId, params } = props;
    const { type } = block;
    const { fetch, component: ChildComponent } = config;
    const parentId = React.useContext(blockIdContext_1.BlockIdContext);
    const blockData = blocks.find(({ type: blockType }) => blockType === type);
    if (!blockData) {
        return null;
    }
    const Component = blockData.component;
    return ((0, jsx_runtime_1.jsx)(blockIdContext_1.BlockIdContext.Provider, { value: [...parentId, Number(blockKey)], children: (0, jsx_runtime_1.jsx)(Loadable_1.default, { block: block, blockKey: blockKey, Component: Component, ChildComponent: ChildComponent, fetch: fetch, serviceId: serviceId, params: params }, blockKey) }, blockKey));
};
exports.ConstructorLoadable = ConstructorLoadable;
//# sourceMappingURL=ConstructorLoadable.js.map
