import { jsx as _jsx } from "react/jsx-runtime";
import * as React from 'react';
import { YandexForm } from "../index.js";
import { FormsContext, } from "../../gravity-blocks/context/formsContext/FormsContext.js";
import { useTheme } from "../../gravity-blocks/context/theme/index.js";
import { isHubspotDataForm, isYandexDataForm } from "../../models/index.js";
import { HubspotForm } from "../../sub-blocks/index.js";
import { getThemedValue } from "../../utils/index.js";
const InnerForm = (props) => {
    const { formData, onContentLoad, className } = props;
    const formsConfig = React.useContext(FormsContext);
    const theme = useTheme();
    React.useEffect(() => {
        if (isHubspotDataForm(formData)) {
            onContentLoad();
        }
    }, [onContentLoad, formData]);
    if (isYandexDataForm(formData)) {
        const { onLoad, ...rest } = getThemedValue(formData.yandex, theme);
        return (_jsx("div", { className: className, children: _jsx(YandexForm, { ...formsConfig.yandex, ...rest, onLoad: () => {
                    onContentLoad();
                    onLoad?.();
                } }) }));
    }
    if (isHubspotDataForm(formData)) {
        const themedFormData = getThemedValue(formData.hubspot, theme);
        return (_jsx(HubspotForm, { createDOMElement: true, ...formsConfig.hubspot, ...themedFormData }));
    }
    return null;
};
export default InnerForm;
//# sourceMappingURL=InnerForm.js.map
