"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.coalesceWeekdayType = exports.SHORT_WEEKDAYS = void 0;
exports.convertWeekdayToNumber = convertWeekdayToNumber;
exports.convertBCWeekdayToNumber = convertBCWeekdayToNumber;
exports.convertNumberToWeekday = convertNumberToWeekday;
const TimerHelper_1 = require("../helpers/TimerHelper");
const IPower_1 = require("./IPower");
exports.SHORT_WEEKDAYS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
function convertWeekdayToNumber(weekday) {
    return IPower_1.WeekdayNumbered[weekday];
}
function convertBCWeekdayToNumber(weekday) {
    const short = (0, exports.coalesceWeekdayType)(weekday);
    return TimerHelper_1.TimerWeekday[short];
}
function convertNumberToWeekday(weekday) {
    return IPower_1.WeekdayNumbered[weekday];
}
const coalesceWeekdayType = (weekday) => {
    if (isShortWeekdayType(weekday)) {
        return weekday;
    }
    if (isWeekdayType(weekday)) {
        return {
            MONDAY: 'mon',
            TUESDAY: 'tue',
            WEDNESDAY: 'wed',
            THURSDAY: 'thu',
            FRIDAY: 'fri',
            SATURDAY: 'sat',
            SUNDAY: 'sun',
        }[weekday];
    }
    if (isWeekdayNumberType(weekday)) {
        return exports.SHORT_WEEKDAYS[weekday];
    }
    throw new Error(`Unknown week day value "${weekday}"`);
};
exports.coalesceWeekdayType = coalesceWeekdayType;
const isShortWeekdayType = (weekday) => exports.SHORT_WEEKDAYS.includes(weekday);
const isWeekdayType = (weekday) => weekday in IPower_1.WeekdayNamed;
const isWeekdayNumberType = (weekday) => typeof weekday === 'number' && weekday >= 0 && weekday <= 6;
//# sourceMappingURL=PowerHelper.js.map