"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 react_1 = __importStar(require("react"));
const react_i18next_1 = require("react-i18next");
const react_router_dom_1 = require("react-router-dom");
const Translation_1 = require("translations/Translation");
const BEButton_1 = __importDefault(require("../../generic/BEButton"));
const Currency_1 = __importDefault(require("../../generic/Currency"));
const Headline_1 = __importDefault(require("../../generic/Headline"));
const Icon_1 = require("../../generic/Icon/Icon");
const LineBreak_1 = __importDefault(require("../../generic/LineBreak"));
const SimpleModal_1 = __importStar(require("../../generic/modal/SimpleModal"));
const TaxInclusionNotice_1 = require("../../generic/TaxInclusionNotice/TaxInclusionNotice");
const Text_1 = __importStar(require("../../generic/Text"));
const ImageGallerySlider_1 = __importDefault(require("../room/ImageGallerySlider"));
const TransportDistanceFromHotelBlock_1 = __importDefault(require("../../summary/TransportDistanceFromHotelBlock"));
const StepHotel_1 = __importDefault(require("../../../pages/steps/StepHotel/StepHotel"));
const Color_1 = require("../../../util/Color");
const HotelPerkHelper_1 = require("../../../util/HotelPerkHelper");
const StepManager_1 = __importDefault(require("../../../util/StepManager"));
const HotelCardModal = (props) => {
    var _a, _b, _c, _d, _e;
    const hotel = props.hotel;
    const [images, setImages] = (0, react_1.useState)([props.hotel.heroImage]);
    const ccx = (0, react_1.useContext)(contexts_1.CompanyContext);
    const navigate = (0, react_router_dom_1.useNavigate)();
    const { t } = (0, react_i18next_1.useTranslation)();
    const currentPrice = (_a = hotel.lowestPrice) === null || _a === void 0 ? void 0 : _a.value;
    (0, react_1.useEffect)(() => {
        var _a;
        const newImages = [hotel.heroImage];
        if (hotel.rooms) {
            for (const room of Object.values(hotel.rooms)) {
                (_a = room.images) === null || _a === void 0 ? void 0 : _a.forEach((image) => {
                    newImages.push(image);
                });
            }
        }
        setImages(newImages);
    }, [hotel.rooms]);
    const perksFree = hotel.perks;
    const onClickViewRooms = () => {
        ccx.changeHotel(hotel);
        navigate(StepManager_1.default.getNextStepUrl(StepHotel_1.default));
    };
    return (react_1.default.createElement(SimpleModal_1.default, { style: { overflow: 'scroll' }, size: SimpleModal_1.SimpleModalSize.Small, open: props.open, onClose: props.onClose, title: hotel.name, modalTarget: props.container },
        react_1.default.createElement("div", { style: { backgroundColor: Color_1.Color.White }, id: `hotel-card-modal-${hotel.hotelID}` },
            react_1.default.createElement("div", { style: { height: '350px' } },
                react_1.default.createElement(ImageGallerySlider_1.default, { images: images })),
            react_1.default.createElement("div", { className: "container u-pad--heavy" },
                react_1.default.createElement("div", { className: "u-marg-bottom--heavy" },
                    react_1.default.createElement("div", { className: "u-marg-bottom--light" },
                        react_1.default.createElement(Headline_1.default, { size: "large", bold: true }, hotel.name)),
                    react_1.default.createElement(Text_1.default, { bold: true, color: Color_1.Color.DarkGrey }, (_b = hotel.address) === null || _b === void 0 ? void 0 : _b.city)),
                react_1.default.createElement("div", { className: "u-marg-top-bottom--heavy row u-w-100" },
                    react_1.default.createElement(TransportDistanceFromHotelBlock_1.default, { tightMargins: true, hotel: hotel })),
                react_1.default.createElement("div", { className: "u-marg-bottom--heavy" },
                    react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small, color: Color_1.Color.DarkGrey }, (_c = hotel.address) === null || _c === void 0 ? void 0 :
                        _c.line1,
                        ", ", (_d = hotel.address) === null || _d === void 0 ? void 0 :
                        _d.line2)),
                !!((_e = hotel.perks) === null || _e === void 0 ? void 0 : _e.length) && (react_1.default.createElement("div", null,
                    react_1.default.createElement(Text_1.default, { className: "u-marg-bottom", bold: true, color: Color_1.Color.Accent }, "And these come free..."),
                    react_1.default.createElement("div", { className: "u-flex row u-marg-bottom--massive" }, perksFree === null || perksFree === void 0 ? void 0 : perksFree.map((perk) => {
                        const perkIconElement = (0, HotelPerkHelper_1.getPerkIconElement)(perk);
                        return (react_1.default.createElement("div", { className: "u-flex u-flex-align-center u-flex-flex-start col-sm-4 col-6 u-marg-bottom--light", key: perk.name },
                            react_1.default.createElement("div", { style: { backgroundColor: Color_1.Color.Snow }, className: "u-rounded u-pad--light u-marg-right--light" },
                                react_1.default.createElement("div", { className: "u-mw-16 d-flex justify-content-center" }, perkIconElement)),
                            react_1.default.createElement("div", { className: "u-marg-right u-block@m-" },
                                react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small }, perk.name))));
                    })))),
                react_1.default.createElement("div", null,
                    react_1.default.createElement(Text_1.default, { type: Text_1.TextType.Small },
                        react_1.default.createElement("span", { dangerouslySetInnerHTML: { __html: hotel.description || '' } }))),
                react_1.default.createElement(LineBreak_1.default, null),
                react_1.default.createElement("div", { className: "u-flex" },
                    react_1.default.createElement("div", { style: { paddingLeft: '0' }, className: "col-md-6 u-flex justify-content-start flex-column align-items-start" },
                        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-row" },
                            react_1.default.createElement(Headline_1.default, { bold: true },
                                react_1.default.createElement(Currency_1.default, { hideDecimals: true, fromCurrencyCode: hotel.defaultCurrency }, currentPrice)),
                            react_1.default.createElement(Text_1.default, { color: Color_1.Color.DarkGrey, inline: true },
                                "/",
                                t(Translation_1.Translation.Misc.Night))),
                        react_1.default.createElement("div", { className: "u-marg-bottom" },
                            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: false })))),
                    react_1.default.createElement("div", null,
                        react_1.default.createElement(BEButton_1.default, { primary: true, filled: true, icon: Icon_1.IconType.ArrowRight, iconPosition: "right", onClick: onClickViewRooms }, t(Translation_1.Translation.Step.Hotel.ViewRooms))))))));
};
exports.default = HotelCardModal;
//# sourceMappingURL=HotelCardModal.js.map