const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_mock = require("../../mock.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/components/eventBooking/components/eventCard/index.tsx
const EventCard = ({ data, showTitle = true, showSubtitle = true, showDescription = true, showPrice = true, showOriginalPrice = true, className, style }) => {
	const [expanded, setExpanded] = (0, react.useState)(false);
	const [showToggle, setShowToggle] = (0, react.useState)(false);
	const descriptionRef = (0, react.useRef)(null);
	const { event_card } = require_mock.mock;
	const { title, subtitle, description, price, origin_price } = data || event_card;
	/**
	* @title: 检查文本是否超过两行
	* @description:
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-01-09 16:43
	*/
	(0, react.useEffect)(() => {
		const element = descriptionRef.current;
		const checkLineCount = () => {
			if (element) {
				var _window$getComputedSt;
				const lineHeight = parseInt((_window$getComputedSt = window.getComputedStyle(element)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.lineHeight);
				const height = element === null || element === void 0 ? void 0 : element.scrollHeight;
				setShowToggle(Math.floor(height / lineHeight) > 2);
			}
		};
		checkLineCount();
		window.addEventListener("resize", checkLineCount);
		return () => window.removeEventListener("resize", checkLineCount);
	}, [description]);
	return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellCard, {
		className: (0, classnames.default)("pisell-event-card", className),
		style,
		borderRadius: 10,
		isClickable: false
	}, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-event-card-content" }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-event-card-title-wrapper" }, showTitle && /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellText, { className: "pisell-event-card-title" }, title), showSubtitle && /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellText, { className: "pisell-event-card-subtitle" }, subtitle)), showPrice && /* @__PURE__ */ react.default.createElement("div", { className: "pisell-event-card-price-wrapper" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellText.Amount, {
		className: "pisell-event-card-price",
		value: price,
		precision: 2,
		showCurrencySymbol: true
	}), showOriginalPrice && origin_price && price !== origin_price && /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellText.Amount, {
		className: "pisell-event-card-original-price",
		value: origin_price,
		precision: 2,
		showCurrencySymbol: true
	})), showDescription && description && /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-event-card-line" }), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-event-card-description" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellText, { className: "pisell-event-card-description-title" }, _pisell_utils.locales.getText("pisell2.event.description")), /* @__PURE__ */ react.default.createElement("div", {
		ref: descriptionRef,
		className: (0, classnames.default)("pisell-event-card-description-content", { "pisell-event-card-description-collapsed": !expanded && showToggle })
	}, /* @__PURE__ */ react.default.createElement("div", { dangerouslySetInnerHTML: { __html: description } })), showToggle && /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellText, {
		className: "pisell-event-card-description-toggle",
		onClick: () => setExpanded(!expanded)
	}, expanded ? _pisell_utils.locales.getText("pisell2.event.view.less") : _pisell_utils.locales.getText("pisell2.event.view.more"))))));
};
//#endregion
exports.default = EventCard;
