"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const react_core_1 = require("@patternfly/react-core");
const common_1 = require("../../../../common");
const constants_1 = require("../constants");
const formik_1 = require("formik");
const LocationsSelector_1 = tslib_1.__importDefault(require("../LocationsSelector"));
const AgentsSelectionHostCountAlerts_1 = tslib_1.__importDefault(require("../../Agent/AgentsSelectionHostCountAlerts"));
const AgentsSelectionHostCountLabelIcon_1 = tslib_1.__importDefault(require("../../Agent/AgentsSelectionHostCountLabelIcon"));
const AgentsSelectionUtils_1 = require("../../Agent/AgentsSelectionUtils");
const use_translation_wrapper_1 = require("../../../../common/hooks/use-translation-wrapper");
const ClusterDeploymentHostsSelectionBasic = ({ isSNOCluster, availableAgents, }) => {
    const { setFieldValue } = (0, formik_1.useFormikContext)();
    const { matchingAgents, selectedAgents, hostCount } = (0, AgentsSelectionUtils_1.useAgentsAutoSelection)(availableAgents);
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    react_1.default.useEffect(() => {
        setFieldValue('useMastersAsWorkers', hostCount === 3);
    }, [hostCount, setFieldValue]);
    return (react_1.default.createElement(react_1.default.Fragment, null,
        react_1.default.createElement(react_core_1.Grid, { hasGutter: true },
            react_1.default.createElement(react_core_1.GridItem, null,
                react_1.default.createElement(common_1.NumberInputField, { label: t('ai:Number of hosts'), labelIcon: react_1.default.createElement(AgentsSelectionHostCountLabelIcon_1.default, null), idPostfix: "hostcount", name: "hostCount", isRequired: true, minValue: isSNOCluster ? 1 : constants_1.HOSTS_MIN_COUNT, maxValue: isSNOCluster ? 1 : constants_1.HOSTS_MAX_COUNT, isDisabled: isSNOCluster })),
            react_1.default.createElement(react_core_1.GridItem, null,
                react_1.default.createElement(common_1.CheckboxField, { idPostfix: "mastersasworkers", name: "useMastersAsWorkers", label: t('ai:Run workloads on control plane hosts'), isDisabled: hostCount !== 3 })),
            react_1.default.createElement(react_core_1.GridItem, null,
                react_1.default.createElement(LocationsSelector_1.default, { agents: availableAgents }))),
        react_1.default.createElement(AgentsSelectionHostCountAlerts_1.default, { matchingAgentsCount: matchingAgents.length, selectedAgents: selectedAgents, targetHostCount: hostCount })));
};
exports.default = ClusterDeploymentHostsSelectionBasic;
//# sourceMappingURL=ClusterDeploymentHostsSelectionBasic.js.map