const require_runtime = require("../../../../../../_virtual/_rolldown/runtime.js");
const require_status = require("../../status.js");
const require_index = require("../Favorite/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
require("./index.less");
//#region src/plus/productSelect/ProductCard/SkuCard/components/Cover/index.tsx
const Cover = ({ props }) => {
	const { dataSource, skuImageConfig } = props;
	const { isCover, width, height, radius, isTextFallback, background } = skuImageConfig || {};
	if (!isCover) return null;
	if (!(dataSource === null || dataSource === void 0 ? void 0 : dataSource.cover) && !isTextFallback) return null;
	const getTextCover = (title) => {
		if (!(dataSource === null || dataSource === void 0 ? void 0 : dataSource.title)) return "";
		const cleanTitle = title.trim();
		if (cleanTitle.length === 0) return "";
		return cleanTitle.substring(0, 2).toUpperCase();
	};
	const finalStyle = (0, react.useMemo)(() => {
		return {
			borderRadius: radius,
			background
		};
	}, [radius, background]);
	return /* @__PURE__ */ react.default.createElement("div", { className: `${require_status.PREFIX}__card-cover` }, /* @__PURE__ */ react.default.createElement("div", {
		className: `${require_status.PREFIX}__card-cover-image`,
		style: {
			width: `${width}` || "auto",
			height: `${height}` || "auto"
		}
	}, (dataSource === null || dataSource === void 0 ? void 0 : dataSource.cover) ? /* @__PURE__ */ react.default.createElement("img", {
		loading: "lazy",
		src: _pisell_utils.image.ali(dataSource === null || dataSource === void 0 ? void 0 : dataSource.cover, 360),
		alt: dataSource === null || dataSource === void 0 ? void 0 : dataSource.title,
		style: finalStyle
	}) : /* @__PURE__ */ react.default.createElement("div", {
		className: `${require_status.PREFIX}__card-cover-text`,
		style: finalStyle
	}, getTextCover((dataSource === null || dataSource === void 0 ? void 0 : dataSource.title) || "")), /* @__PURE__ */ react.default.createElement(require_index.default, { props })));
};
//#endregion
exports.default = Cover;
