"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CardTypeSelect = void 0;
const hooks_1 = require("../../../hooks/index.js");
const classnames_1 = __importDefault(require("classnames"));
const react_1 = __importDefault(require("react"));
const Hotel_1 = require("../../../models/Client/Hotel/Hotel");
const PaymentCard_1 = require("../../../models/PaymentCard");
const PaymentCardHelper_1 = require("../../../util/PaymentCardHelper");
const CardTypeSelect_module_scss_1 = __importDefault(require("./CardTypeSelect.module.scss"));
const cardType2HotelCardType = {
    [PaymentCard_1.ECardType.Visa]: Hotel_1.EPaymentCardType.Visa,
    [PaymentCard_1.ECardType.Mastercard]: Hotel_1.EPaymentCardType.Mastercard,
    [PaymentCard_1.ECardType.AmericanExpress]: Hotel_1.EPaymentCardType.AmericanExpress,
    [PaymentCard_1.ECardType.JCB]: Hotel_1.EPaymentCardType.JCB,
};
const CardTypeSelect = ({ value, onChange }) => {
    const { hotel } = (0, hooks_1.useCurrentHotel)();
    return (react_1.default.createElement("div", { className: CardTypeSelect_module_scss_1.default.root, onChange: onChange }, Object.values(PaymentCard_1.ECardType)
        .filter((cardType) => {
        var _a;
        const paymentCardType = cardType2HotelCardType[cardType];
        return paymentCardType && ((_a = hotel === null || hotel === void 0 ? void 0 : hotel.paymentCardTypes) === null || _a === void 0 ? void 0 : _a.includes(paymentCardType));
    })
        .map((cardType) => {
        const iconUrl = (0, PaymentCardHelper_1.mapCardTypeToGraphic)(cardType).cardIconUrl;
        return (react_1.default.createElement("div", { key: cardType, className: (0, classnames_1.default)(CardTypeSelect_module_scss_1.default.icon, {
                [CardTypeSelect_module_scss_1.default.isSelected]: value === cardType,
            }) },
            react_1.default.createElement("img", { src: iconUrl, alt: cardType })));
    })));
};
exports.CardTypeSelect = CardTypeSelect;
//# sourceMappingURL=CardTypeSelect.js.map