import index from "../../../../productSelect/components/pisellPriceText/index.js";
import { useEventDetail } from "../../../../Sales/Event/Detail.js";
import OpenCard_default from "../../OpenCard/index.js";
import React from "react";
import { locales } from "@pisell/utils";
import Decimal from "decimal.js";
import { PisellCheckboxGroup, PisellText } from "@pisell/materials";
//#region src/components/eventBooking/components/bookingDetailModal/components/BookingOptions.tsx
const BookingOptions = (props) => {
	var _detail$bookingOption, _detail$bookingOption2;
	const { detail, currentBookingOption, selectEventDetailBookingOptions } = useEventDetail();
	const onChange = (value, item) => {
		var _props$onChangeBookin;
		selectEventDetailBookingOptions(value);
		props === null || props === void 0 || (_props$onChangeBookin = props.onChangeBookingOption) === null || _props$onChangeBookin === void 0 || _props$onChangeBookin.call(props, item);
	};
	return /* @__PURE__ */ React.createElement(OpenCard_default, {
		title: locales.getText("pisell2.event.booking.options"),
		showBorder: true,
		showArrow: false,
		isClick: false,
		className: "detail-option-wrap"
	}, /* @__PURE__ */ React.createElement(PisellCheckboxGroup, {
		mode: "single",
		iconPosition: (detail === null || detail === void 0 || (_detail$bookingOption = detail.bookingOptions) === null || _detail$bookingOption === void 0 ? void 0 : _detail$bookingOption.length) > 1 ? "right" : "hide",
		options: (detail === null || detail === void 0 ? void 0 : detail.bookingOptions) || [],
		optionClassName: `option-item ${(detail === null || detail === void 0 || (_detail$bookingOption2 = detail.bookingOptions) === null || _detail$bookingOption2 === void 0 ? void 0 : _detail$bookingOption2.length) > 1 ? "option-item-pointer" : ""}`,
		value: currentBookingOption,
		renderOption: (option) => {
			const { price, is_bundle, minimum_markup_price } = option._originData || {};
			if (!option._originData || !is_bundle) return /* @__PURE__ */ React.createElement("div", { className: "item" }, /* @__PURE__ */ React.createElement("span", null, option.label), /* @__PURE__ */ React.createElement(PisellText.Amount, {
				value: option.price,
				showCurrencySymbol: true,
				className: "price"
			}));
			let _price = price;
			if (is_bundle) _price = new Decimal(price).plus(new Decimal(minimum_markup_price)).toFixed(2);
			return /* @__PURE__ */ React.createElement("div", { className: "item" }, /* @__PURE__ */ React.createElement("span", null, option.label), /* @__PURE__ */ React.createElement(index, {
				className: "price",
				value: _price,
				isMini: true
			}));
		},
		onChange
	}));
};
//#endregion
export { BookingOptions as default };
