import { PREFIX } from "../../index.js";
import React, { useMemo } from "react";
import { locales } from "@pisell/utils";
import { Divider, Tag } from "antd";
//#region src/components/productCard/cartSkuCard/components/discountReason/index.tsx
const DiscountReason = (props) => {
	const { dataSource = {}, hideDivider } = props;
	const { total, origin_total, symbol, tip, num, discount_reason } = dataSource;
	const isDiscount = useMemo(() => {
		if (!origin_total) return false;
		return Number(total) != Number(origin_total);
	}, [total, origin_total]);
	const renderDivider = () => {
		return isDiscount && discount_reason && !hideDivider ? /* @__PURE__ */ React.createElement(Divider, { style: { margin: 0 } }) : null;
	};
	const renderDiscountReason = () => {
		if (isDiscount && discount_reason) {
			if (Array.isArray(discount_reason)) return /* @__PURE__ */ React.createElement("div", {
				className: `${PREFIX}_discount-reason`,
				style: {
					display: "flex",
					flexWrap: "wrap",
					gap: "4px"
				}
			}, discount_reason.map((reason, index) => {
				return /* @__PURE__ */ React.createElement(Tag, {
					key: index,
					color: "red"
				}, reason);
			}));
			return /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}_discount-reason` }, /* @__PURE__ */ React.createElement("span", null, `${locales.getText("pisell2.product.card.discount.reason")}: ${discount_reason}`));
		}
	};
	return /* @__PURE__ */ React.createElement(React.Fragment, null, renderDivider(), renderDiscountReason());
};
//#endregion
export { DiscountReason as default };
