"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PullSecretInfo = void 0;
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const external_link_alt_icon_1 = require("@patternfly/react-icons/dist/js/icons/external-link-alt-icon");
const config_1 = require("../../../config");
const PopoverIcon_1 = tslib_1.__importDefault(require("../PopoverIcon"));
const TextAreaField_1 = tslib_1.__importDefault(require("./TextAreaField"));
const use_translation_wrapper_1 = require("../../../hooks/use-translation-wrapper");
const react_i18next_1 = require("react-i18next");
const PullSecretInfo = ({ isOcm }) => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    return (react_1.default.createElement(PopoverIcon_1.default, { noVerticalAlign: true, bodyContent: react_1.default.createElement(react_1.default.Fragment, null,
            react_1.default.createElement(react_i18next_1.Trans, { t: t },
                "ai:Pull secrets are used to download OpenShift Container Platform components and connect clusters to a Red Hat account.",
                ' '),
            isOcm ? (react_1.default.createElement(PullSecretInfoLink, null)) : (react_1.default.createElement(react_1.default.Fragment, null,
                react_1.default.createElement(react_i18next_1.Trans, { t: t }, "ai:Pull secrets can be found in"),
                " ",
                react_1.default.createElement(ClusterManagerSiteLink, null)))) }));
};
exports.PullSecretInfo = PullSecretInfo;
const ClusterManagerSiteLink = () => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    return (react_1.default.createElement("a", { href: config_1.CLUSTER_MANAGER_SITE_LINK, target: "_blank", rel: "noopener noreferrer" },
        t('ai:OpenShift Cluster Manager'),
        " ",
        react_1.default.createElement(external_link_alt_icon_1.ExternalLinkAltIcon, null)));
};
const PullSecretInfoLink = () => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    return (react_1.default.createElement("a", { href: config_1.PULL_SECRET_INFO_LINK, target: "_blank", rel: "noopener noreferrer" },
        t('ai:Learn more about pull secrets and view examples'),
        " ",
        react_1.default.createElement(external_link_alt_icon_1.ExternalLinkAltIcon, null),
        "."));
};
const GetPullSecretHelperText = ({ isOcm }) => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    return isOcm ? (react_1.default.createElement(PullSecretInfoLink, null)) : (react_1.default.createElement(react_1.default.Fragment, null,
        t("ai:A Red Hat account's pull secret can be found in "),
        "\u00A0",
        react_1.default.createElement(ClusterManagerSiteLink, null)));
};
const PullSecretField = ({ isOcm }) => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    return (react_1.default.createElement(TextAreaField_1.default, { name: "pullSecret", label: t('ai:Pull secret'), labelIcon: isOcm ? undefined : react_1.default.createElement(exports.PullSecretInfo, { isOcm: isOcm }), getErrorText: (error) => error, helperText: react_1.default.createElement(GetPullSecretHelperText, { isOcm: isOcm }), rows: 10, isRequired: true }));
};
exports.default = PullSecretField;
//# sourceMappingURL=PullSecretField.js.map