"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 constants_1 = require("./constants");
const Day2WizardContext_1 = require("./Day2WizardContext");
const wizardTransition_1 = require("../../clusterWizard/wizardTransition");
const Day2WizardNav = () => {
    const wizardContext = (0, Day2WizardContext_1.useDay2WizardContext)();
    const isStepIdxAfterCurrent = (idx) => {
        return !wizardContext.wizardStepIds.slice(idx).includes(wizardContext.currentStepId);
    };
    const isStepDisabled = (idx, stepId) => {
        return stepId === 'cluster-details' ? false : isStepIdxAfterCurrent(idx);
    };
    const getNavItem = (idx, stepId) => {
        return (react_1.default.createElement(react_core_1.WizardNavItem, { stepIndex: idx, key: stepId, content: constants_1.day2WizardStepNames[stepId], onClick: () => wizardContext.setCurrentStepId(stepId), isCurrent: wizardContext.currentStepId === stepId, isDisabled: isStepDisabled(idx, stepId), "data-testid": `day2-wizard-nav-item-${stepId}` }));
    };
    const getStaticIpFormViewNavItem = (idx) => {
        return (react_1.default.createElement(react_core_1.WizardNavItem, { stepIndex: idx, isExpandable: true, content: "Static network configurations", key: "static-network-configuration-form-view", isCurrent: (0, wizardTransition_1.isStaticIpStep)(wizardContext.currentStepId), isDisabled: isStepIdxAfterCurrent(idx), "data-testid": `day2-wizard-nav-item-static-network-configuration-form-view` },
            react_1.default.createElement(react_core_1.WizardNav, { isInnerList: true, "data-testid": "day2-wizard-nav-item-static-network-configuration-form-view-inner-list" }, constants_1.staticIpFormViewSubSteps.map((stepId, subIdx) => {
                return getNavItem(idx + subIdx, stepId);
            }))));
    };
    const getWizardNavItems = () => {
        const navItems = [];
        let i = 0;
        while (i < wizardContext.wizardStepIds.length) {
            const stepId = wizardContext.wizardStepIds[i];
            if (stepId === 'static-ip-network-wide-configurations') {
                navItems.push(getStaticIpFormViewNavItem(i));
                //skip iteration on form view sub steps
                i += 2;
            }
            else {
                navItems.push(getNavItem(i, stepId));
                i += 1;
            }
        }
        return navItems;
    };
    return react_1.default.createElement(react_core_1.WizardNav, { "data-testid": "day2-wizard-nav" }, getWizardNavItems());
};
exports.default = Day2WizardNav;
//# sourceMappingURL=Day2WizardNav.js.map