"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useSearchScopeHook = void 0;
const CurrentHotelHook_1 = require("./CurrentHotelHook");
const useSearchScopeHook = () => {
    var _a;
    const { hotel } = (0, CurrentHotelHook_1.useCurrentHotel)();
    const getMaxSelectableAdults = ({ adults, children = 0 }) => {
        var _a, _b;
        const maxOccupancy = Math.min((_a = hotel === null || hotel === void 0 ? void 0 : hotel.maxAdults) !== null && _a !== void 0 ? _a : +Number.MAX_VALUE, (_b = hotel === null || hotel === void 0 ? void 0 : hotel.maxOccupancy) !== null && _b !== void 0 ? _b : 0);
        const selectedValue = adults !== null && adults !== void 0 ? adults : 1;
        let maxAdults = Math.max(maxOccupancy - children, selectedValue);
        if (maxAdults < 1 || isNaN(maxAdults)) {
            maxAdults = 1;
        }
        return maxAdults;
    };
    const getMaxSelectableChildren = ({ adults }) => {
        var _a, _b;
        return Math.max(Math.min((_a = hotel === null || hotel === void 0 ? void 0 : hotel.maxChildren) !== null && _a !== void 0 ? _a : +Number.MAX_VALUE, (_b = hotel === null || hotel === void 0 ? void 0 : hotel.maxOccupancy) !== null && _b !== void 0 ? _b : 0) - adults, 0);
    };
    const getMaxSelectableInfants = () => {
        var _a;
        return (_a = hotel === null || hotel === void 0 ? void 0 : hotel.maxInfants) !== null && _a !== void 0 ? _a : 10;
    };
    const showChildren = ((_a = hotel === null || hotel === void 0 ? void 0 : hotel.childConfiguration) === null || _a === void 0 ? void 0 : _a.supportChildren) !== false;
    return {
        getMaxSelectableAdults,
        getMaxSelectableChildren,
        getMaxSelectableInfants,
        showChildren,
    };
};
exports.useSearchScopeHook = useSearchScopeHook;
//# sourceMappingURL=useSearchScopeHook.js.map