import { getCallToBookStatus, getStatus } from "./components/CalendarDate/state.js";
import dayjs from "dayjs";
//#region src/components/eventBooking/components/bookingAvailabilityCalendar/utils.ts
/**
* @title: 格式化日期
* @description: 
* @param {string} date
* @param {string} format
* @return {*}
* @Author: WangHan
* @Date: 2025-01-14 15:19
*/
const formatDate = (date, format) => {
	return dayjs(date).format(format || "YYYY-MM-DD");
};
/**
* @title: 获取列表中包含了几个月
* @description: 
* @param {Dayjs} date
* @return {*}
* @Author: WangHan
* @Date: 2025-01-14 15:25
*/
const getMonthIndex = (lists) => {
	if (!lists.length) return [];
	const arr = [0];
	const firstMonth = formatDate(lists[0], "YYYY-MM");
	const index = lists.findIndex((item) => formatDate(item, "YYYY-MM") !== firstMonth);
	if (index !== -1) arr.push(index);
	return arr;
};
/**
* @title: 获取当前状态
* @description: 
* @param {any} dateLimitData
* @param {any} item
* @param {any} cutTime
* @return {*}
* @Author: WangHan
* @Date: 2025-01-14 15:33
*/
const getCurrentStatus = (dateLimitData, item, cutTime) => {
	const { status, disabled } = getStatus(dateLimitData, item, cutTime);
	return {
		currentStatus: getCallToBookStatus(item, dateLimitData, cutTime) && ["lots_of_space", "filling_up_fast"].includes(status) ? "call_to_book" : status,
		disabled
	};
};
//#endregion
export { formatDate, getCurrentStatus, getMonthIndex };
