'use strict';

// Gets the days in a given month
const getMonthDays = (date) => {
    const month = date.getMonth();
    const year = date.getFullYear();
    const daysInMonth = new Date(year, month + 1, 0).getDate();
    return Array.from({ length: daysInMonth }, (_, i) => new Date(year, month, i + 1));
};
// Gets the remaining days from the previous month to display on the calendar
const getDaysFromPreviousMonth = (date) => {
    const firstDayOfMonth = new Date(date.getFullYear(), date.getMonth(), 1).getDay();
    const prevMonth = new Date(date.getFullYear(), date.getMonth(), 0); // Last day of previous month
    const dates = [];
    for (let i = 0; i < firstDayOfMonth; i++) {
        dates.unshift(new Date(prevMonth.getFullYear(), prevMonth.getMonth(), prevMonth.getDate() - i));
    }
    return dates;
};
// Gets the initial days from the next month to display on the calendar
const getDaysFromNextMonth = (date) => {
    const lastDayOfMonth = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDay();
    const nextMonth = new Date(date.getFullYear(), date.getMonth() + 1, 1); // First day of next month
    const dates = [];
    for (let i = 0; i < (6 - lastDayOfMonth); i++) {
        dates.push(new Date(nextMonth.getFullYear(), nextMonth.getMonth(), nextMonth.getDate() + i));
    }
    return dates;
};
// const defineds = {
//   startOfWeek: startOfWeek(new Date()),
//   endOfWeek: endOfWeek(new Date()),
//   startOfLastWeek: startOfWeek(addDays(new Date(), -7)),
//   endOfLastWeek: endOfWeek(addDays(new Date(), -7)),
//   startOfToday: startOfDay(new Date()),
//   endOfToday: endOfDay(new Date()),
//   startOfYesterday: startOfDay(addDays(new Date(), -1)),
//   endOfYesterday: endOfDay(addDays(new Date(), -1)),
//   startOfMonth: startOfMonth(new Date()),
//   endOfMonth: endOfMonth(new Date()),
//   startOfLastMonth: startOfMonth(addMonths(new Date(), -1)),
//   endOfLastMonth: endOfMonth(addMonths(new Date(), -1)),
// };
// const staticRangeHandler = {
//   range: {},
//   isSelected(range) {
//     const definedRange = this.range();
//     return (
//       isSameDay(range.startDate, definedRange.startDate) &&
//       isSameDay(range.endDate, definedRange.endDate)
//     );
//   },
// };
const isValidDate = (dateString) => {
    // Match D/M/Y or DD/MM/YYYY format
    const regex = /^(0?[1-9]|[12][0-9]|3[01])\/(0?[1-9]|1[0-2])\/\d{4}$/;
    if (!regex.test(dateString))
        return false;
    // Parse and check validity
    const [day, month, year] = dateString.split('/').map(Number);
    const parsedDate = new Date(year, month - 1, day);
    return (parsedDate.getDate() === day &&
        parsedDate.getMonth() === month - 1 &&
        parsedDate.getFullYear() === year);
};
const formatDate = (date) => {
    const day = date.getDate();
    const month = date.getMonth() + 1; // Months are 0-indexed
    const year = date.getFullYear();
    return `${day}/${month}/${year}`;
};
// export function createStaticRanges(ranges) {
//   return ranges.map(range => ({ ...staticRangeHandler, ...range }));
// }
// export const defaultStaticRanges = createStaticRanges([
//   {
//     label: 'Today',
//     range: () => ({
//       startDate: defineds.startOfToday,
//       endDate: defineds.endOfToday,
//     }),
//   },
//   {
//     label: 'Yesterday',
//     range: () => ({
//       startDate: defineds.startOfYesterday,
//       endDate: defineds.endOfYesterday,
//     }),
//   },
//   {
//     label: 'This Week',
//     range: () => ({
//       startDate: defineds.startOfWeek,
//       endDate: defineds.endOfWeek,
//     }),
//   },
//   {
//     label: 'Last Week',
//     range: () => ({
//       startDate: defineds.startOfLastWeek,
//       endDate: defineds.endOfLastWeek,
//     }),
//   },
//   {
//     label: 'This Month',
//     range: () => ({
//       startDate: defineds.startOfMonth,
//       endDate: defineds.endOfMonth,
//     }),
//   },
//   {
//     label: 'Last Month',
//     range: () => ({
//       startDate: defineds.startOfLastMonth,
//       endDate: defineds.endOfLastMonth,
//     }),
//   },
// {
//   label: 'Last 3 Month',
//   range: () => ({
//     startDate: defineds.startOfLastMonth,
//     endDate: defineds.endOfLastMonth,
//   }),
// },
// {
//   label: 'Last 7 Days',
//   range: () => ({
//     startDate: defineds.startOfLastMonth,
//     endDate: defineds.endOfLastMonth,
//   }),
// },
// {
//   label: 'Last 30 Days',
//   range: () => ({
//     startDate: defineds.startOfLastMonth,
//     endDate: defineds.endOfLastMonth,
//   }),
// },
// {
//   label: 'Last 90 Days',
//   range: () => ({
//     startDate: defineds.startOfLastMonth,
//     endDate: defineds.endOfLastMonth,
//   }),
// },
// ]);
const today = new Date();
const yesterday = new Date(today);
yesterday.setDate(yesterday.getDate() - 1);
const startOfToday = new Date(today);
startOfToday.setHours(0, 0, 0, 0);
const endOfToday = new Date(today);
endOfToday.setHours(23, 59, 59, 999);
const startOfYesterday = new Date(yesterday);
startOfYesterday.setHours(0, 0, 0, 0);
const endOfYesterday = new Date(yesterday);
endOfYesterday.setHours(23, 59, 59, 999);
const startOfWeek = new Date(today);
startOfWeek.setDate(today.getDate() - today.getDay());
const endOfWeek = new Date(today);
endOfWeek.setDate(today.getDate() + (6 - today.getDay()));
const startOfLastWeek = new Date(startOfWeek);
startOfLastWeek.setDate(startOfWeek.getDate() - 7);
const endOfLastWeek = new Date(endOfWeek);
endOfLastWeek.setDate(endOfWeek.getDate() - 7);
const startOfMonth = new Date(today);
startOfMonth.setDate(1);
const endOfMonth = new Date(today);
endOfMonth.setMonth(endOfMonth.getMonth() + 1, 0);
const startOfLastMonth = new Date(startOfMonth);
startOfLastMonth.setMonth(startOfLastMonth.getMonth() - 1, 1);
const endOfLastMonth = new Date(startOfMonth);
endOfLastMonth.setDate(endOfLastMonth.getDate() - 1);
const startOfLast3Months = new Date(startOfMonth);
startOfLast3Months.setMonth(startOfLast3Months.getMonth() - 3, 1);
const endOfLast3Months = new Date(startOfMonth);
endOfLast3Months.setDate(endOfLast3Months.getDate() - 1);
const startOfLast7Days = new Date(today);
startOfLast7Days.setDate(startOfLast7Days.getDate() - 6);
const startOfLast30Days = new Date(today);
startOfLast30Days.setDate(startOfLast30Days.getDate() - 29);
const startOfLast90Days = new Date(today);
startOfLast90Days.setDate(startOfLast90Days.getDate() - 89);
const defaultStaticRanges = [
    {
        label: 'Today',
        range: () => ({
            startDate: startOfToday,
            endDate: endOfToday,
        }),
    },
    {
        label: 'Yesterday',
        range: () => ({
            startDate: startOfYesterday,
            endDate: endOfYesterday,
        }),
    },
    {
        label: 'This Week',
        range: () => ({
            startDate: startOfWeek,
            endDate: endOfWeek,
        }),
    },
    {
        label: 'Last Week',
        range: () => ({
            startDate: startOfLastWeek,
            endDate: endOfLastWeek,
        }),
    },
    {
        label: 'This Month',
        range: () => ({
            startDate: startOfMonth,
            endDate: endOfMonth,
        }),
    },
    {
        label: 'Last Month',
        range: () => ({
            startDate: startOfLastMonth,
            endDate: endOfLastMonth,
        }),
    },
    {
        label: 'Last 3 Months',
        range: () => ({
            startDate: startOfLast3Months,
            endDate: endOfLast3Months,
        }),
    },
    {
        label: 'Last 7 Days',
        range: () => ({
            startDate: startOfLast7Days,
            endDate: endOfToday,
        }),
    },
    {
        label: 'Last 30 Days',
        range: () => ({
            startDate: startOfLast30Days,
            endDate: endOfToday,
        }),
    },
    {
        label: 'Last 90 Days',
        range: () => ({
            startDate: startOfLast90Days,
            endDate: endOfToday,
        }),
    },
];
function compareDatesWithoutTime(date1, date2) {
    return (date1.getFullYear() === date2.getFullYear() &&
        date1.getMonth() === date2.getMonth() &&
        date1.getDate() === date2.getDate());
}
const validateInputDate = (date) => {
    // Regular expression to match the date format "Month Day, Year"
    const dateFormat = /^(?:January|February|March|April|May|June|July|August|September|October|November|December) (?:0?[1-9]|[12][0-9]|3[01]), (?:19|20)\d{2}$/;
    if (dateFormat.test(date)) {
        // Date format is valid
        console.log("date is valid");
        return true;
    }
    else {
        // Date format is invalid
        console.log("date is not valid");
        return false;
    }
};

exports.compareDatesWithoutTime = compareDatesWithoutTime;
exports.defaultStaticRanges = defaultStaticRanges;
exports.formatDate = formatDate;
exports.getDaysFromNextMonth = getDaysFromNextMonth;
exports.getDaysFromPreviousMonth = getDaysFromPreviousMonth;
exports.getMonthDays = getMonthDays;
exports.isValidDate = isValidDate;
exports.validateInputDate = validateInputDate;

//# sourceMappingURL=dateUtils-382ae775.js.map