"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ACMClusterDeploymentDetailsStep = void 0;
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const formik_1 = require("formik");
const react_core_1 = require("@patternfly/react-core");
const noop_js_1 = tslib_1.__importDefault(require("lodash-es/noop.js"));
const common_1 = require("../../../../common");
const ClusterDeploymentDetailsStep_1 = require("./ClusterDeploymentDetailsStep");
const helpers_1 = require("../../helpers");
const ClusterDeploymentDetailsForm_1 = require("./ClusterDeploymentDetailsForm");
const DetailsFormBody = ({ onValuesChanged, clusterImages, extensionAfter, isNutanix, osImages, }) => {
    const { values } = (0, formik_1.useFormikContext)();
    const initRenderRef = react_1.default.useRef(true);
    react_1.default.useEffect(() => onValuesChanged(values, initRenderRef.current), [onValuesChanged, values]);
    react_1.default.useEffect(() => {
        initRenderRef.current = false;
    }, []);
    return (react_1.default.createElement(react_core_1.Stack, { hasGutter: true },
        react_1.default.createElement(ClusterDeploymentDetailsForm_1.ClusterDeploymentDetailsForm, { clusterImages: clusterImages, extensionAfter: extensionAfter, isNutanix: isNutanix, osImages: osImages })));
};
const ACMClusterDeploymentDetailsStep = (_a) => {
    var { clusterImages, formRef, usedClusterNames, osImages, isNutanix } = _a, rest = tslib_1.__rest(_a, ["clusterImages", "formRef", "usedClusterNames", "osImages", "isNutanix"]);
    const ocpVersions = (0, helpers_1.getOCPVersions)(clusterImages, !!isNutanix, osImages);
    const [initialValues, validationSchema] = (0, ClusterDeploymentDetailsStep_1.useDetailsFormik)({
        ocpVersions,
        usedClusterNames,
    });
    return (react_1.default.createElement(formik_1.Formik, { initialValues: initialValues, validate: (0, common_1.getRichTextValidation)(validationSchema), innerRef: formRef, onSubmit: noop_js_1.default },
        react_1.default.createElement(DetailsFormBody, Object.assign({ clusterImages: clusterImages, osImages: osImages, isNutanix: isNutanix }, rest))));
};
exports.ACMClusterDeploymentDetailsStep = ACMClusterDeploymentDetailsStep;
//# sourceMappingURL=ACMClusterDeploymentDetailsStep.js.map