import CollapsibleList from "../../collapsibleList/index.js";
import { renderBundles } from "../../collapsibleList/utils.js";
import BrowserSelect from "../../browserSelect/index.js";
import React from "react";
import { createArray, formatAmount, image, locales } from "@pisell/utils";
import classNames from "classnames";
import "./index.less";
//#region src/components/booking/components/TabProduct/selectProductItem/index.tsx
const SelectProductItem = ({ item, onClick, onChangeQuantity, amountSymbol, style, className, disabled }) => {
	var _item$_extend, _item$_extend2;
	const list = createArray(100, (d, i) => {
		let item = {
			label: i,
			value: i
		};
		if (i === 0) item.label = locales.getText("pisell2.text.remove");
		return item;
	});
	return /* @__PURE__ */ React.createElement("div", {
		style,
		className: classNames("server-select-product", className),
		onClick: () => {
			onClick === null || onClick === void 0 || onClick(item);
		}
	}, item.cover ? /* @__PURE__ */ React.createElement("img", {
		src: image.ali(item.cover, 100),
		className: "server-select-product-cover"
	}) : /* @__PURE__ */ React.createElement("div", null), /* @__PURE__ */ React.createElement("div", { className: "server-select-product-content" }, /* @__PURE__ */ React.createElement("div", { className: "server-select-product-title" }, item.title), /* @__PURE__ */ React.createElement("div", { className: "server-select-product-subtitle" }, item.subtitle || ""), (((_item$_extend = item._extend) === null || _item$_extend === void 0 || (_item$_extend = _item$_extend.other) === null || _item$_extend === void 0 ? void 0 : _item$_extend.bundle) || []).length ? /* @__PURE__ */ React.createElement(CollapsibleList, {
		style: { width: "100%" },
		list: ((_item$_extend2 = item._extend) === null || _item$_extend2 === void 0 || (_item$_extend2 = _item$_extend2.other) === null || _item$_extend2 === void 0 ? void 0 : _item$_extend2.bundle) || [],
		renderItem: (item) => renderBundles(item, amountSymbol)
	}) : null, /* @__PURE__ */ React.createElement("div", {
		className: "server-select-product-quantity",
		onClick: (e) => {
			e.preventDefault();
			e.stopPropagation();
		}
	}, /* @__PURE__ */ React.createElement(BrowserSelect, {
		options: list,
		value: item._extend.quantity,
		onChange: onChangeQuantity,
		style: { minWidth: 50 },
		disabled
	}), /* @__PURE__ */ React.createElement("div", { className: "server-select-product-total" }, item._extend.origin_total !== item._extend.total && /* @__PURE__ */ React.createElement("span", { className: "server-select-product-origin-total" }, formatAmount(item._extend.origin_total * item._extend.quantity, 2, amountSymbol)), formatAmount(item._extend.total * item._extend.quantity, 2, amountSymbol)))));
};
//#endregion
export { SelectProductItem as default };
