"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const contexts_1 = require("../../../contexts/index.js");
const hooks_1 = require("../../../hooks/index.js");
const core_1 = require("@roomstay/core");
const classnames_1 = __importDefault(require("classnames"));
const Check_1 = __importDefault(require("icons/Check"));
const react_1 = __importStar(require("react"));
const react_i18next_1 = require("react-i18next");
const BEButton_1 = __importDefault(require("../../generic/BEButton"));
const Currency_1 = __importDefault(require("../../generic/Currency"));
const Headline_1 = __importDefault(require("../../generic/Headline"));
const HtmlContentViewer_1 = require("../../generic/HtmlContentViewer");
const NumberIncrement_1 = __importDefault(require("../../generic/NumberIncrement"));
const Select_1 = require("../../generic/Select/Select");
const TaxInclusionNotice_1 = require("../../generic/TaxInclusionNotice/TaxInclusionNotice");
const Text_1 = __importStar(require("../../generic/Text"));
const AddAddonToCartEvent_1 = require("../../../events/actions/AddAddonToCartEvent");
const RoomstayEventManager_1 = __importDefault(require("../../../events/RoomstayEventManager"));
const ImageProvider_1 = __importStar(require("../../../providers/ImageProvider"));
const Translation_1 = require("../../../translations/Translation");
const Color_1 = require("../../../util/Color");
const DataLayer_1 = __importDefault(require("../../../util/DataLayer"));
const AddonDiscountCalculator_1 = require("../../../utils/AddonDiscountCalculator");
const AddonCard = ({ addon, className }) => {
    var _a;
    const { t } = (0, react_i18next_1.useTranslation)();
    const { hotel } = (0, hooks_1.useCurrentHotel)();
    const basketContext = react_1.default.useContext(contexts_1.BasketContext);
    const addonBasketRow = basketContext.getRowForAddon(addon);
    const [quantity, setQuantity] = (0, react_1.useState)(1);
    const [adultQuantity, setAdultQuantity] = (0, react_1.useState)(addonBasketRow ? addonBasketRow.getAdultQuantity() : 1);
    const [childQuantity, setChildQuantity] = (0, react_1.useState)(addonBasketRow ? addonBasketRow.getChildQuantity() : 0);
    const [priceInfo, setPriceInfo] = (0, react_1.useState)({ quantity: 1 });
    const [selectedDate, setSelectedDate] = (0, react_1.useState)(addonBasketRow ? addonBasketRow.getSelectedDate() : '');
    const [selectedTime, setSelectedTime] = (0, react_1.useState)(addonBasketRow ? addonBasketRow.getSelectedTime() : '');
    (0, react_1.useEffect)(() => {
        var _a, _b, _c, _d, _e, _f, _g;
        if (addonBasketRow) {
            setPriceInfo((_a = addon.availability[addonBasketRow.getSelectedDate()]) !== null && _a !== void 0 ? _a : addon.availability[addon.firstDate]);
            setSelectedDate((_b = addonBasketRow.getSelectedDate()) !== null && _b !== void 0 ? _b : addon.firstDate);
            setSelectedTime((_c = addonBasketRow.getSelectedTime()) !== null && _c !== void 0 ? _c : '');
            setQuantity(addonBasketRow.getQuantity());
            setAdultQuantity(addonBasketRow.getAdultQuantity());
            setChildQuantity(addonBasketRow.getChildQuantity());
        }
        else {
            setPriceInfo((_d = addon.availability[addon.firstDate]) !== null && _d !== void 0 ? _d : []);
            setSelectedDate(addon.firstDate);
            setSelectedTime(((_g = (_f = (_e = addon.availability[addon.firstDate]) === null || _e === void 0 ? void 0 : _e.selectorTimes) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.value) || '');
        }
    }, []);
    const setDate = (date) => {
        var _a, _b, _c;
        setPriceInfo(addon.availability[date]);
        setSelectedDate(date);
        setSelectedTime(((_c = (_b = (_a = addon.availability[date]) === null || _a === void 0 ? void 0 : _a.selectorTimes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.value) || '');
        if (addon.availability[date].quantity < quantity) {
            setQuantity(addon.availability[date].quantity);
        }
    };
    const onClickAddToCartHandler = () => {
        basketContext.setAddonQuantities(addon, {
            quantity,
            adult: adultQuantity,
            child: childQuantity,
        }, selectedDate, selectedTime);
        const basketAddonRow = basketContext.basketAddonRows.find((row) => {
            return row.getAddon().code === addon.code;
        });
        const selectedBasketRow = basketContext.currentBasketRows[0];
        if (basketAddonRow && selectedBasketRow) {
            DataLayer_1.default.instance.sendRoomAddonAddToCart(basketAddonRow, quantity, selectedBasketRow.getStartDate(), selectedBasketRow.getStartDate());
            RoomstayEventManager_1.default.raise(new AddAddonToCartEvent_1.AddAddonToCartEvent(basketAddonRow));
        }
    };
    const classes = (0, classnames_1.default)({
        '--active': !!basketContext.getRowForAddon(addon),
    });
    const onClickRemove = () => {
        const selectedAddon = basketContext.basketAddonRows.find((row) => {
            return row.getAddon().code === addon.code;
        });
        if (selectedAddon)
            basketContext.removeBasketAddonRow(selectedAddon);
    };
    const setQuantityOnChange = (val) => {
        setQuantity(val);
    };
    const setAdultsQuantityOnChange = (val) => {
        setAdultQuantity(val);
    };
    const setChildQuantityOnChange = (val) => {
        setChildQuantity(val);
    };
    const setDateOnChange = (selected) => {
        setDate(selected);
    };
    const setSelectedTimeOnChange = (selected) => {
        setSelectedTime(selected);
    };
    // Pricing type checks
    const isPerPerson = [core_1.EAddonPricingType.PER_PERSON, core_1.EAddonPricingType.PER_PERSON_PER_NIGHT].includes(addon.pricingType);
    const isPerAllPersons = [core_1.EAddonPricingType.PER_ALL_PERSONS, core_1.EAddonPricingType.PER_ALL_PERSONS_PER_NIGHT].includes(addon.pricingType);
    // Hide quantity if admin enabled and addon is per-person type
    const hidePerPersonQuantity = isPerPerson && addon.hideQuantity;
    // Default quantities when addon is per person
    (0, react_1.useEffect)(() => {
        if (!isPerPerson)
            return;
        const rows = basketContext.currentBasketRows;
        if (!rows || rows.length === 0)
            return;
        // Sum all adults & children from all reservations
        const totalAdults = rows.reduce((sum, r) => sum + r.getAdults(), 0);
        const totalChildren = rows.reduce((sum, r) => sum + r.getChildren(), 0);
        // Set adults qty always
        setAdultQuantity(totalAdults);
        // If child pricing exists → set children qty
        if (priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.childPrice) {
            setChildQuantity(totalChildren);
        }
        else {
            // Otherwise fallback to set quantity qty
            setQuantity(totalAdults);
        }
    }, [addon.code, isPerPerson, priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.childPrice, basketContext.currentBasketRows]);
    // --- Enable/Disable Helpers -------------------------------------------------
    const enableDateInput = () => {
        var _a;
        return ((_a = addonBasketRow === null || addonBasketRow === void 0 ? void 0 : addonBasketRow.getNumberOfAvailableNights) === null || _a === void 0 ? void 0 : _a.call(addonBasketRow)) > 1 && !(addonBasketRow === null || addonBasketRow === void 0 ? void 0 : addonBasketRow.getAddon().hideDatePicker);
    };
    const enableQuantityInput = () => {
        return !!(priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.price) && (priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.quantity) > 1 && !hidePerPersonQuantity;
    };
    const enableAdultInput = () => !isPerAllPersons && !!(priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.adultPrice) && !hidePerPersonQuantity;
    const enableChildInput = () => !isPerAllPersons && !!(priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.childPrice) && !hidePerPersonQuantity;
    // --- Addon Configuration ----------------------------------------------------
    const addonConfigurations = [
        {
            name: 'Date',
            enabled: enableDateInput(),
            element: (react_1.default.createElement(Select_1.Select, { nativeOnMobile: true, options: addon.selectorDates, value: selectedDate, onChange: setDateOnChange, keyName: "value", labelName: "text", className: "u-flex align-items-center" })),
        },
        {
            name: 'Time',
            enabled: ((_a = priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.selectorTimes) === null || _a === void 0 ? void 0 : _a.length) !== 0,
            element: (react_1.default.createElement(Select_1.Select, { nativeOnMobile: true, options: (priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.selectorTimes) || [], value: selectedTime, onChange: setSelectedTimeOnChange, keyName: "value", labelName: "text", className: "u-flex align-items-center" })),
        },
        {
            name: Translation_1.Translation.Step.Addon.Quantity,
            enabled: enableQuantityInput(),
            element: react_1.default.createElement(NumberIncrement_1.default, { number: quantity, min: 1, max: priceInfo.quantity, onChange: setQuantityOnChange }),
        },
        {
            name: Translation_1.Translation.Step.Date.Adult_plural,
            enabled: enableAdultInput(),
            element: react_1.default.createElement(NumberIncrement_1.default, { number: adultQuantity, min: 0, max: priceInfo.quantity - childQuantity, onChange: setAdultsQuantityOnChange }),
        },
        {
            name: Translation_1.Translation.Step.Date.Child_plural,
            enabled: enableChildInput(),
            element: react_1.default.createElement(NumberIncrement_1.default, { number: childQuantity, min: 0, max: priceInfo.quantity - adultQuantity, onChange: setChildQuantityOnChange }),
        },
    ];
    const pricingTypeSuffix = (() => {
        switch (addon.pricingType) {
            case core_1.EAddonPricingType.PER_STAY:
                return t(Translation_1.Translation.Misc.QTY);
            case core_1.EAddonPricingType.PER_PERSON:
                return t(Translation_1.Translation.Misc.Person);
            case core_1.EAddonPricingType.PER_PERSON_OCCUPANCY_PER_NIGHT:
            case core_1.EAddonPricingType.PER_PERSON_PER_NIGHT:
                return t(Translation_1.Translation.Misc.PersonPerNight);
            case core_1.EAddonPricingType.PER_ADULT_OCCUPANCY_PER_NIGHT:
            case core_1.EAddonPricingType.PER_CHILD_OCCUPANCY_PER_NIGHT:
                return t(Translation_1.Translation.Misc.AdultPerNight);
            case core_1.EAddonPricingType.PER_NIGHT:
            case core_1.EAddonPricingType.PER_QUANTITY_NAME_PER_NIGHT:
                return t(Translation_1.Translation.Misc.Night);
            case core_1.EAddonPricingType.PER_ROOM_QUANTITY_PER_NIGHT:
                return t(Translation_1.Translation.Misc.PerRoomDay);
        }
    })();
    const addonCardImageStyle = {};
    if (addon.image) {
        addonCardImageStyle.backgroundImage = `url('${ImageProvider_1.default.resizeImage(addon.image, ImageProvider_1.ImageSize.Original)}')`;
    }
    else {
        addonCardImageStyle.backgroundImage = `url('${(hotel === null || hotel === void 0 ? void 0 : hotel.logo) && ImageProvider_1.default.resizeImage(hotel === null || hotel === void 0 ? void 0 : hotel.logo, ImageProvider_1.ImageSize.Original)}')`;
        addonCardImageStyle.backgroundSize = '50%';
        addonCardImageStyle.backgroundRepeat = 'no-repeat';
    }
    const hasFees = (hotel === null || hotel === void 0 ? void 0 : hotel.fees) && hotel.fees.filter((fee) => fee.appliesToAddons).length > 0;
    // Calculate promo code discount for this addon
    const { discountAmount, discountedUnitPrice, discountedAdultPrice, discountedChildPrice } = (0, react_1.useMemo)(() => {
        var _a, _b, _c, _d;
        // Use TotalCalculator to get base price (without fees or discounts)
        const addonDto = {
            code: addon.code,
            pricingType: addon.pricingType,
            price: (_a = priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.price) !== null && _a !== void 0 ? _a : 0,
            adultPrice: priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.adultPrice,
            childPrice: priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.childPrice,
            quantity,
            adultQuantity,
            childQuantity,
            nights: addon.nights || 1,
        };
        const { addonTotal } = core_1.TotalCalculator.calculateBaseAddonTotal(addonDto, false);
        // For per-unit price preview, calculate what the total would be with at least 1 adult and 1 child.
        // This lets us show "A$0 / Child" when children=0 to indicate adding a child would be free.
        const previewAddonDto = Object.assign(Object.assign({}, addonDto), { adultQuantity: Math.max(1, adultQuantity), childQuantity: Math.max(1, childQuantity) });
        const { addonTotal: previewAddonTotal } = core_1.TotalCalculator.calculateBaseAddonTotal(previewAddonDto, false);
        // When addon is already in basket, exclude it from the calculation to avoid double-counting.
        const otherAddonsInBasket = addonBasketRow ? basketContext.basketAddonRows.filter((row) => row.getID() !== addonBasketRow.getID()) : basketContext.basketAddonRows;
        // Calculate actual discount based on current UI state (for totals and actual discount amount).
        const discount = AddonDiscountCalculator_1.AddonDiscountCalculator.calculatePreviewDiscount(addonTotal, otherAddonsInBasket, basketContext.currentBasketRows, basketContext.promoCodeDetails);
        // Calculate preview discount with at least 1 of each person type (for per-unit price display).
        const previewDiscount = AddonDiscountCalculator_1.AddonDiscountCalculator.calculatePreviewDiscount(previewAddonTotal, otherAddonsInBasket, basketContext.currentBasketRows, basketContext.promoCodeDetails);
        // Helper to calculate discounted unit price
        const calcDiscountedPrice = (unitPrice, totalCost, availableDiscount) => {
            if (!unitPrice || availableDiscount <= 0) {
                return { price: unitPrice !== null && unitPrice !== void 0 ? unitPrice : 0, discountUsed: 0 };
            }
            const promoDetails = basketContext.promoCodeDetails;
            if ((promoDetails === null || promoDetails === void 0 ? void 0 : promoDetails.discountType) === core_1.EPromoCodeDiscountType.FlatPercent) {
                const percentOff = promoDetails.discountAmount / 100;
                return {
                    price: Math.round(unitPrice * (1 - percentOff) * 100) / 100,
                    discountUsed: 0,
                };
            }
            // Fixed discount
            const discountUsed = Math.min(availableDiscount, totalCost);
            const perUnitDiscount = totalCost > 0 ? (discountUsed / totalCost) * unitPrice : 0;
            return {
                price: Math.max(0, unitPrice - perUnitDiscount),
                discountUsed,
            };
        };
        // Calculate discounted per-unit prices
        let discUnitPrice = (_b = priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.price) !== null && _b !== void 0 ? _b : 0;
        let discAdultPrice = (_c = priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.adultPrice) !== null && _c !== void 0 ? _c : 0;
        let discChildPrice = (_d = priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.childPrice) !== null && _d !== void 0 ? _d : 0;
        if (previewDiscount > 0 && previewAddonTotal > 0) {
            const isPerNight = core_1.ADDON_PER_NIGHT_TYPES.includes(addon.pricingType);
            const nightsMultiplier = isPerNight ? addon.nights || 1 : 1;
            // Simple unit price (Per Person, Per Night, etc.)
            if (priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.price) {
                const effectiveQty = Math.max(1, quantity);
                const previewCost = priceInfo.price * effectiveQty * nightsMultiplier;
                const result = calcDiscountedPrice(priceInfo.price, previewCost, previewDiscount);
                discUnitPrice = result.price;
            }
            // Adult/child prices - sequential allocation (adults first, then children)
            const effectiveAdultQty = Math.max(1, adultQuantity);
            const effectiveChildQty = Math.max(1, childQuantity);
            const previewAdultCost = (priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.adultPrice) ? priceInfo.adultPrice * effectiveAdultQty * nightsMultiplier : 0;
            const previewChildCost = (priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.childPrice) ? priceInfo.childPrice * effectiveChildQty * nightsMultiplier : 0;
            // Allocate discount sequentially: adults first, then remaining to children
            const adultDiscountUsed = Math.min(previewDiscount, previewAdultCost);
            const remainingForChild = Math.max(0, previewDiscount - adultDiscountUsed);
            if (priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.adultPrice) {
                const result = calcDiscountedPrice(priceInfo.adultPrice, previewAdultCost, adultDiscountUsed);
                discAdultPrice = result.price;
            }
            if (priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.childPrice) {
                const result = calcDiscountedPrice(priceInfo.childPrice, previewChildCost, remainingForChild);
                discChildPrice = result.price;
            }
        }
        return {
            discountAmount: discount,
            discountedPrice: addonTotal - discount,
            discountedUnitPrice: discUnitPrice,
            discountedAdultPrice: discAdultPrice,
            discountedChildPrice: discChildPrice,
        };
    }, [
        priceInfo,
        quantity,
        adultQuantity,
        childQuantity,
        addon.pricingType,
        addon.code,
        addon.nights,
        basketContext.promoCodeDetails,
        basketContext.currentBasketRows,
        basketContext.basketAddonRows,
        addonBasketRow,
    ]);
    const hasDiscount = discountAmount > 0;
    return (react_1.default.createElement("div", { className: (0, classnames_1.default)('u-flex u-flex-flex-start u-rounded addon-card-wrapper', className, classes), style: { backgroundColor: Color_1.Color.White } },
        react_1.default.createElement("div", { className: "addon-card-image", style: addonCardImageStyle }),
        react_1.default.createElement("div", { className: "u-marg-heavy u-marg@m- u-w-100@xl" },
            react_1.default.createElement("div", { className: "u-flex" },
                react_1.default.createElement(Headline_1.default, { bold: true }, addon.name),
                addonBasketRow ? react_1.default.createElement(Check_1.default, null) : react_1.default.createElement(react_1.default.Fragment, null)),
            react_1.default.createElement(Text_1.default, { color: Color_1.Color.DarkGrey, type: Text_1.TextType.Small, asDiv: true },
                react_1.default.createElement(HtmlContentViewer_1.HtmlContentViewer, { content: addon.description })),
            react_1.default.createElement("div", { className: "addon-card-wrapper--price u-flex u-flex-align-flex-end" },
                react_1.default.createElement("div", { className: "u-w-100" }, addonConfigurations.map((input) => {
                    if (!input.enabled) {
                        return;
                    }
                    return (react_1.default.createElement("div", { key: input.name, className: "u-flex justify-content-start u-marg-bot u-marg-top" },
                        react_1.default.createElement(Text_1.default, { className: "u-mw-100", bold: true }, t(input.name)),
                        input.element));
                })),
                react_1.default.createElement("div", { className: "addon-card-wrapper--price-action" },
                    react_1.default.createElement("div", { className: "u-flex u-flex-direction-column u-flex-align-flex-end", style: { alignSelf: 'flex-end' } },
                        react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small, color: Color_1.Color.Navy, inline: true }, t(Translation_1.Translation.Misc.From)),
                        react_1.default.createElement("div", { className: "room-details--content-price flex-align-items-baseline flex-row" },
                            (priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.price) && (react_1.default.createElement("div", { className: "d-flex align-items-end flex-row" },
                                hasDiscount && (react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small, color: Color_1.Color.DarkGrey, inline: true, style: { textDecoration: 'line-through' }, className: "u-marg-right--light" },
                                    react_1.default.createElement(Currency_1.default, { hideDecimals: true }, priceInfo.price))),
                                react_1.default.createElement(Headline_1.default, { size: "large", bold: true, lineHeight: "1em" },
                                    react_1.default.createElement(Currency_1.default, { hideDecimals: true }, hasDiscount ? discountedUnitPrice : priceInfo.price)),
                                react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small, color: Color_1.Color.DarkGrey, inline: true, className: "u-marg-left--light u-clear-font-weight" },
                                    "/ ",
                                    pricingTypeSuffix))),
                            (!!(priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.adultPrice) || !!(priceInfo === null || priceInfo === void 0 ? void 0 : priceInfo.childPrice)) && (react_1.default.createElement("h2", { className: "u-marg-none d-flex flex-wrap justify-content-end" },
                                !!priceInfo.adultPrice && (react_1.default.createElement("div", { className: "d-flex align-items-end flex-row" },
                                    hasDiscount && discountedAdultPrice < priceInfo.adultPrice && (react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small, color: Color_1.Color.DarkGrey, inline: true, style: { textDecoration: 'line-through' }, className: "u-marg-right--light" },
                                        react_1.default.createElement(Currency_1.default, null, priceInfo.adultPrice))),
                                    react_1.default.createElement(Headline_1.default, { size: "large", bold: true, lineHeight: "1em" },
                                        react_1.default.createElement(Currency_1.default, null, hasDiscount ? discountedAdultPrice : priceInfo.adultPrice)),
                                    react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small, color: Color_1.Color.DarkGrey, inline: true, className: "u-marg-left--light u-clear-font-weight" },
                                        "/",
                                        ' ',
                                        addon.pricingType === core_1.EAddonPricingType.PER_ALL_PERSONS_PER_NIGHT
                                            ? t(Translation_1.Translation.Misc.AdultPerNight)
                                            : t(Translation_1.Translation.Step.Date.Adult)))),
                                !!priceInfo.adultPrice && !!priceInfo.childPrice && react_1.default.createElement("br", null),
                                !!priceInfo.childPrice && (react_1.default.createElement("div", { className: "d-flex align-items-end flex-row" },
                                    hasDiscount && discountedChildPrice < priceInfo.childPrice && (react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small, color: Color_1.Color.DarkGrey, inline: true, style: { textDecoration: 'line-through' }, className: "u-marg-right--light" },
                                        react_1.default.createElement(Currency_1.default, null, priceInfo.childPrice))),
                                    react_1.default.createElement(Headline_1.default, { size: "large", bold: true, lineHeight: "1em" },
                                        react_1.default.createElement(Currency_1.default, null, hasDiscount ? discountedChildPrice : priceInfo.childPrice)),
                                    react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small, color: Color_1.Color.DarkGrey, inline: true, className: "u-marg-left--light u-clear-font-weight" },
                                        "/",
                                        ' ',
                                        addon.pricingType === core_1.EAddonPricingType.PER_ALL_PERSONS_PER_NIGHT
                                            ? t(Translation_1.Translation.Misc.ChildPerNight)
                                            : t(Translation_1.Translation.Step.Date.Child))))))),
                        react_1.default.createElement("div", { className: "u-marg-bottom--light" },
                            react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small, color: Color_1.Color.Grey, inline: true, className: "u-nowrap" },
                                react_1.default.createElement(TaxInclusionNotice_1.TaxInclusionNotice, { hasTax: !((hotel === null || hotel === void 0 ? void 0 : hotel.enableCreditCardSurcharge) || hasFees), isAddon: true })))),
                    react_1.default.createElement("div", { className: "u-marg-top--light u-flex justify-content-end u-w-100@l- flex-column flex-lg-row" },
                        addonBasketRow ? (react_1.default.createElement("div", { className: "u-marg-right--light@l u-marg-bottom--light@l-" },
                            react_1.default.createElement(BEButton_1.default, { onClick: onClickRemove, textColor: Color_1.Color.White, backgroundColor: Color_1.Color.Navy, wide: true }, t(Translation_1.Translation.Step.Addon.Remove)))) : (react_1.default.createElement(react_1.default.Fragment, null)),
                        react_1.default.createElement(BEButton_1.default, { onClick: onClickAddToCartHandler, primary: true, filled: true, wide: true }, addonBasketRow ? t(Translation_1.Translation.Step.Addon.UpdateCart) : t(Translation_1.Translation.Step.Addon.AddToCart))))))));
};
exports.default = AddonCard;
//# sourceMappingURL=AddonCard.js.map