import IconFont from "../../../../iconfont/index.js";
import { getServiceTime } from "../../../utils.js";
import { PREFIX } from "../../index.js";
import React, { useEffect, useMemo } from "react";
import { Divider } from "antd";
import dayjs from "dayjs";
import "dayjs/locale/zh-cn";
import "dayjs/locale/ja";
import "dayjs/locale/pt";
import "dayjs/locale/en";
import "dayjs/locale/zh-tw";
import "./index.less";
//#region src/components/productCard/cartSkuCard/components/timeRange/index.tsx
const localeTypes = {
	"en-US": "en",
	"zh-CN": "zh-cn",
	"zh-HK": "zh-tw",
	"ja": "ja",
	"pt": "pt"
};
const TimeRange = (props) => {
	const { dataSource = {} } = props;
	const { start_date, end_date, locale = "en-US" } = dataSource;
	if (!dayjs(start_date).isValid() || !dayjs(end_date).isValid()) return null;
	useEffect(() => {
		dayjs.locale(localeTypes[locale]);
	}, [locale]);
	const isEn = useMemo(() => {
		return locale === "en-US" || locale === "en";
	}, [locale]);
	useMemo(() => {
		return isEn ? "HH:mm DD/MM/YYYY" : "YYYY-MM-DD HH:mm";
	}, [isEn]);
	return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Divider, { style: { margin: "0" } }), /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__time-range` }, /* @__PURE__ */ React.createElement(IconFont, {
		className: "time-icon",
		type: "pisell2-clock"
	}), getServiceTime(dataSource, start_date)));
};
//#endregion
export { TimeRange as default };
