"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get convertDateToDay () {
        return convertDateToDay;
    },
    get convertDayToDate () {
        return convertDayToDate;
    },
    get getCurrentMonthDays () {
        return getCurrentMonthDays;
    },
    get getCurrentWeekDays () {
        return getCurrentWeekDays;
    },
    get getPrevMonthDays () {
        return getPrevMonthDays;
    }
});
var _date = require("../../utils/date");
var convertDateToDay = function convertDateToDay(date) {
    return date ? {
        year: date.getFullYear(),
        month: date.getMonth() + 1,
        date: date.getDate()
    } : null;
};
var convertDayToDate = function convertDayToDate(day) {
    return day ? new Date(day.year, day.month - 1, day.date) : null;
};
var getPrevMonthDays = function getPrevMonthDays(year, month, firstDayOfWeek) {
    var prevMonth = month - 1;
    var prevYear = year;
    if (prevMonth <= 0) {
        prevMonth = 12;
        prevYear -= 1;
    }
    var days = _date.Utils.getMonthPreDay(year, month);
    days -= firstDayOfWeek;
    if (days >= 7) {
        days -= 7;
    }
    var preDates = _date.Utils.getMonthDays("".concat(prevYear), "".concat(prevMonth));
    var months = Array.from(Array(preDates), function(_, k) {
        return {
            type: 'prev',
            year: prevYear,
            month: prevMonth,
            date: k + 1
        };
    });
    return months.slice(preDates - days);
};
var getCurrentMonthDays = function getCurrentMonthDays(year, month) {
    var days = _date.Utils.getMonthDays("".concat(year), "".concat(month));
    return Array.from(Array(days), function(_, k) {
        return {
            type: 'current',
            year: year,
            month: month,
            date: k + 1
        };
    });
};
var getCurrentWeekDays = function getCurrentWeekDays(day, firstDayOfWeek) {
    var current = new Date(day.year, day.month - 1, day.date);
    var count = (current.getDay() + 7 - firstDayOfWeek) % 7;
    return [
        convertDateToDay(new Date(current.getTime() - 24 * 60 * 60 * 1000 * count)),
        convertDateToDay(new Date(current.getTime() + 24 * 60 * 60 * 1000 * (6 - count)))
    ];
};
