"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;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaxInclusionNotice = void 0;
const react_1 = __importStar(require("react"));
const react_i18next_1 = require("react-i18next");
const Translation_1 = require("translations/Translation");
const RoomRate_1 = require("../../../models/Room/RoomRate");
const getPriceInclusionStatus = (rate, room) => {
    var _a, _b, _c, _d;
    return (_d = (_b = (_a = rate === null || rate === void 0 ? void 0 : rate.getPriceType) === null || _a === void 0 ? void 0 : _a.call(rate)) !== null && _b !== void 0 ? _b : (_c = room === null || room === void 0 ? void 0 : room.getLowestPriceType) === null || _c === void 0 ? void 0 : _c.call(room)) !== null && _d !== void 0 ? _d : RoomRate_1.RoomRatePriceInclusion.IncludingFeesAndTaxes;
};
const useTaxMessage = (hasTax, isAddon) => {
    const { t } = (0, react_i18next_1.useTranslation)();
    return (0, react_1.useMemo)(() => {
        if (isAddon) {
            return hasTax ? t(Translation_1.Translation.Step.Addon.IncludingFeesAndTaxes) : t(Translation_1.Translation.Step.Addon.ExcludingFees);
        }
        // default: room rate
        return hasTax ? t(Translation_1.Translation.Step.Room.RoomInfo.IncludesTaxes) : t(Translation_1.Translation.Step.Room.ExcludingTaxes);
    }, [hasTax, isAddon, t]);
};
const TaxInclusionNotice = (props) => {
    const hasTax = 'hasTax' in props ? props.hasTax : getPriceInclusionStatus(props.rate, props.room) === RoomRate_1.RoomRatePriceInclusion.IncludingFeesAndTaxes;
    const isAddon = 'hasTax' in props ? props.isAddon : false;
    const message = useTaxMessage(hasTax, isAddon);
    return react_1.default.createElement("span", { dangerouslySetInnerHTML: { __html: message } });
};
exports.TaxInclusionNotice = TaxInclusionNotice;
//# sourceMappingURL=TaxInclusionNotice.js.map