const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_usePisellConfig = require("../../../pisell-config-provider/hooks/usePisellConfig.js");
let react = require("react");
react = require_runtime.__toESM(react);
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
require("./ReadPretty.less");
//#region src/components/dataSourceComponents/fields/DatePicker/ReadPretty.tsx
const DEFAULT_FORMAT = "DD/MM/YYYY HH:mm";
const DATE_FORMATS = {
	"zh-CN": {
		withTime: "YYYY-MM-DD HH:mm",
		withoutTime: "YYYY-MM-DD"
	},
	"en-US": {
		withTime: "MM/DD/YYYY HH:mm",
		withoutTime: "MM/DD/YYYY"
	},
	"en-AU": {
		withTime: "DD/MM/YYYY HH:mm",
		withoutTime: "DD/MM/YYYY"
	},
	en: {
		withTime: "DD/MM/YYYY HH:mm",
		withoutTime: "DD/MM/YYYY"
	}
};
const DatePickerReadPretty = ({ value, renderMode, showTime }) => {
	const { locale = "zh-CN" } = require_usePisellConfig.default();
	const dateFormat = (0, react.useMemo)(() => {
		if (locale in DATE_FORMATS) {
			const formats = DATE_FORMATS[locale];
			return showTime ? formats.withTime : formats.withoutTime;
		}
		if (process.env.NODE_ENV !== "production") console.warn(`Unsupported locale: ${locale}, falling back to default format`);
		return DEFAULT_FORMAT;
	}, [locale, showTime]);
	const formattedDate = (0, react.useMemo)(() => {
		if (!value) return "";
		try {
			return (0, dayjs.default)(value).format(dateFormat);
		} catch (error) {
			if (process.env.NODE_ENV !== "production") console.error("Error formatting date:", error);
			return "";
		}
	}, [value, dateFormat]);
	return /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)("pisell-date-picker-read-pretty", { "pisell-date-picker-read-pretty-table-view": renderMode === "tableView" }) }, formattedDate);
};
//#endregion
exports.default = DatePickerReadPretty;
