import { getDiscountTime } from "../../../utils.js";
import index from "../../../../productSelect/components/pisellPriceText/index.js";
import React, { useMemo } from "react";
import { image, locales } from "@pisell/utils";
import Decimal from "decimal.js";
import classNames from "classnames";
import "./index.less";
//#region src/components/booking/components/TabProduct/productItem/index.tsx
const ProductItem = ({ item, onClick, amountSymbol, style, className }) => {
	const { price, is_bundle, minimum_markup_price } = item;
	let _price = price;
	if (is_bundle) _price = new Decimal(price).plus(new Decimal(minimum_markup_price)).toFixed(2);
	const stockText = useMemo(() => {
		if (item.is_track === 0) return false;
		return `${item.stock_quantity} ${locales.getText("pisell2.text.stock")}`;
	}, [item.stock_quantity, item.is_track]);
	return /* @__PURE__ */ React.createElement("div", {
		style,
		className: classNames("server-product", className),
		onClick: () => {
			onClick(item, "select");
		}
	}, item.cover ? /* @__PURE__ */ React.createElement("img", {
		src: image.ali(item.cover, 100),
		className: "server-product-cover",
		loading: "lazy"
	}) : null, /* @__PURE__ */ React.createElement("div", { className: "server-product-content" }, /* @__PURE__ */ React.createElement("span", { className: "server-product-title" }, item.title), /* @__PURE__ */ React.createElement("div", { className: "server-product-time" }, getDiscountTime(item.service_times)), stockText && /* @__PURE__ */ React.createElement("div", { className: "server-product-time" }, stockText), /* @__PURE__ */ React.createElement("div", { className: "server-product-price" }, /* @__PURE__ */ React.createElement(index, {
		value: _price,
		isMini: is_bundle
	}))));
};
//#endregion
export { ProductItem as default };
