"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 formik_1 = require("formik");
const ui_1 = require("../ui");
const use_translation_wrapper_1 = require("../../hooks/use-translation-wrapper");
const PullSecret = ({ defaultPullSecret, isOcm = false, isSingleClusterFeatureEnabled = false, }) => {
    const [isExpanded, setExpanded] = react_1.default.useState(!defaultPullSecret);
    const { setFieldValue } = (0, formik_1.useFormikContext)();
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    if (isOcm || isSingleClusterFeatureEnabled) {
        const onCheckboxChange = () => {
            if (isExpanded) {
                // about to collapse, reset to original value
                setFieldValue('pullSecret', defaultPullSecret);
            }
            setExpanded(!isExpanded);
        };
        return (react_1.default.createElement(react_1.default.Fragment, null,
            react_1.default.createElement(react_core_1.Checkbox, { id: "checkbox-pull-secret", className: "pf-v6-u-display-inline-flex", "aria-label": t('ai:edit pull secret'), isChecked: isExpanded, onChange: onCheckboxChange, label: react_1.default.createElement(react_1.default.Fragment, null,
                    t('ai:Edit pull secret'),
                    " ",
                    react_1.default.createElement(ui_1.PullSecretInfo, { isOcm: isOcm })) }),
            isExpanded && react_1.default.createElement(ui_1.PullSecretField, { isOcm: isOcm })));
    }
    return react_1.default.createElement(ui_1.PullSecretField, { isOcm: isOcm });
};
exports.default = PullSecret;
//# sourceMappingURL=PullSecret.js.map