import { _formatAmount } from "../packages/utils.js";
import { PREFIX } from "../../index.js";
import React, { useMemo } from "react";
import { locales } from "@pisell/utils";
import { Divider, Tag, Tooltip } from "antd";
import { QuestionCircleOutlined } from "@ant-design/icons";
import classNames from "classnames";
import "./index.less";
//#region src/components/productCard/cartSkuCard/components/AmountFooter/index.tsx
const Footer = ({ item, hideDivider, type, isOnlyTotal }) => {
	const { total, origin_total, symbol, tip, num, discount_reason } = item;
	/**
	* @title: 折扣
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: WangHan
	* @Date: 2024-11-22 13:50
	*/
	const isDiscount = useMemo(() => {
		if (!origin_total) return false;
		return Number(total) != Number(origin_total);
	}, [total, origin_total]);
	const renderDiscountReason = () => {
		if (isDiscount && discount_reason && type === "total") {
			if (Array.isArray(discount_reason)) return /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}_discount-reason` }, discount_reason.map((reason, index) => {
				return /* @__PURE__ */ React.createElement(Tag, {
					key: index,
					color: "red"
				}, reason);
			}));
			return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Divider, { style: { margin: 0 } }), /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}_discount-reason` }, /* @__PURE__ */ React.createElement("span", null, `${locales.getText("pisell2.product.card.discount.reason")}: ${discount_reason}`)));
		}
		return null;
	};
	return /* @__PURE__ */ React.createElement(React.Fragment, null, !hideDivider ? /* @__PURE__ */ React.createElement(Divider, { style: { margin: 0 } }) : null, /* @__PURE__ */ React.createElement("div", { className: classNames(`${PREFIX}__product-footer`, hideDivider && `pisell-cart-sku-card__hide-divider-footer`, isOnlyTotal && `pisell-cart-sku-card__only-total-footer`) }, /* @__PURE__ */ React.createElement("div", { className: classNames(`${PREFIX}__footer-price-wrap`) }, !isOnlyTotal ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: classNames(`${PREFIX}__footer-price`) }, /* @__PURE__ */ React.createElement("span", null, _formatAmount(total, symbol)), tip ? /* @__PURE__ */ React.createElement(Tooltip, {
		title: locales.getText(tip),
		destroyTooltipOnHide: true
	}, /* @__PURE__ */ React.createElement(QuestionCircleOutlined, { style: {
		fontSize: "16px",
		color: "#1570ef"
	} })) : null), /* @__PURE__ */ React.createElement("span", null, `×${num}`)) : null, /* @__PURE__ */ React.createElement("span", { className: `${PREFIX}__footer-total` }, isDiscount ? /* @__PURE__ */ React.createElement("span", { className: `${PREFIX}__footer-origin-total` }, _formatAmount(origin_total * num, symbol, 2)) : null, /* @__PURE__ */ React.createElement("span", null, _formatAmount(total * num, symbol))))), renderDiscountReason());
};
//#endregion
export { Footer as default };
