"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.classifyCalendarDay = classifyCalendarDay;
exports.isOffDayClassification = isOffDayClassification;
const date_fns_tz_1 = require("date-fns-tz");
const helpers_1 = require("./helpers");
function classifyCalendarDay(member, requestDate, timeZone, working_days, holidays) {
    const { startUtc } = (0, helpers_1.getUtcStartEndOfDate)(requestDate, timeZone);
    const isHoliday = holidays.some((holiday) => {
        if (!holiday.departments?.length)
            return true;
        return holiday.departments.some((d) => d.id === member.department_id);
    });
    if (isHoliday) {
        return 'holiday';
    }
    const weekDay = (0, date_fns_tz_1.formatInTimeZone)(startUtc, timeZone, 'EEEE').toLowerCase();
    const isWeekend = !!working_days &&
        Array.isArray(working_days) &&
        working_days.length > 0 &&
        !working_days.includes(weekDay);
    return isWeekend ? 'weekend' : 'working_day';
}
function isOffDayClassification(classification) {
    return classification === 'weekend' || classification === 'holiday';
}
//# sourceMappingURL=day-classification.js.map