"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const formik_1 = require("formik");
const noop_js_1 = tslib_1.__importDefault(require("lodash-es/noop.js"));
const Yup = tslib_1.__importStar(require("yup"));
const NetworkForm_1 = tslib_1.__importDefault(require("./NetworkForm"));
const common_1 = require("../../../../../common");
const use_translation_wrapper_1 = require("../../../../../common/hooks/use-translation-wrapper");
const getValidationSchema = (t) => Yup.lazy((values) => Yup.object().shape({
    sshPublicKey: (0, common_1.sshPublicKeyValidationSchema)(t).required(t('ai:Required field')),
    clusterNetworkCidr: values.isAdvanced
        ? (0, common_1.ipBlockValidationSchema)(values.serviceNetworkCidr, t)
        : Yup.string(),
    serviceNetworkCidr: values.isAdvanced
        ? (0, common_1.ipBlockValidationSchema)(values.clusterNetworkCidr, t)
        : Yup.string(),
    clusterNetworkHostPrefix: values.isAdvanced
        ? (0, common_1.hostPrefixValidationSchema)(values.clusterNetworkCidr, t)
        : Yup.number(),
    httpProxy: (0, common_1.httpProxyValidationSchema)({ values, pairValueName: 'httpsProxy', t }),
    httpsProxy: (0, common_1.httpProxyValidationSchema)({ values, pairValueName: 'httpProxy', t }), // share the schema, httpS is currently not supported
    noProxy: (0, common_1.noProxyValidationSchema)(t),
    nodePortAddress: values.apiPublishingStrategy === 'NodePort'
        ? (0, common_1.day2ApiVipValidationSchema)(t).required(t('ai:Required field'))
        : Yup.string(),
}));
const NetworkStep = ({ formRef, onValuesChanged, initialValues }) => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    return (React.createElement(formik_1.Formik, { initialValues: initialValues, validationSchema: getValidationSchema(t), innerRef: formRef, onSubmit: noop_js_1.default },
        React.createElement(NetworkForm_1.default, { onValuesChanged: onValuesChanged })));
};
exports.default = NetworkStep;
//# sourceMappingURL=NetworkStep.js.map