import { jsx as _jsx } from "react/jsx-runtime";
import * as React from 'react';
import { BlockIdContext } from "../../../../context/blockIdContext/index.js";
import { InnerContext } from "../../../../context/innerContext/index.js";
import Loadable from "../../../Loadable/Loadable.js";
export const ConstructorLoadable = (props) => {
    const { blocks } = React.useContext(InnerContext);
    const { block, blockKey, config, serviceId, params } = props;
    const { type } = block;
    const { fetch, component: ChildComponent } = config;
    const parentId = React.useContext(BlockIdContext);
    const blockData = blocks.find(({ type: blockType }) => blockType === type);
    if (!blockData) {
        return null;
    }
    const Component = blockData.component;
    return (_jsx(BlockIdContext.Provider, { value: [...parentId, Number(blockKey)], children: _jsx(Loadable, { block: block, blockKey: blockKey, Component: Component, ChildComponent: ChildComponent, fetch: fetch, serviceId: serviceId, params: params }, blockKey) }, blockKey));
};
//# sourceMappingURL=ConstructorLoadable.js.map
