var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/eventBooking/components/eventCard/index.tsx
var eventCard_exports = {};
__export(eventCard_exports, {
  default: () => eventCard_default
});
module.exports = __toCommonJS(eventCard_exports);
var import_react = __toESM(require("react"));
var import_materials = require("@pisell/materials");
var import_materials2 = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_classnames = __toESM(require("classnames"));
var import_mock = require("../../mock");
var import_index = require("./index.less");
var EventCard = ({
  data,
  showTitle = true,
  showSubtitle = true,
  showDescription = true,
  showPrice = true,
  showOriginalPrice = true,
  className,
  style
}) => {
  const [expanded, setExpanded] = (0, import_react.useState)(false);
  const [showToggle, setShowToggle] = (0, import_react.useState)(false);
  const descriptionRef = (0, import_react.useRef)(null);
  const { event_card } = import_mock.mock;
  const { title, subtitle, description, price, origin_price } = data || event_card;
  (0, import_react.useEffect)(() => {
    const element = descriptionRef.current;
    const checkLineCount = () => {
      var _a;
      if (element) {
        const lineHeight = parseInt(
          (_a = window.getComputedStyle(element)) == null ? void 0 : _a.lineHeight
        );
        const height = element == null ? void 0 : element.scrollHeight;
        const lines = Math.floor(height / lineHeight);
        setShowToggle(lines > 2);
      }
    };
    checkLineCount();
    window.addEventListener("resize", checkLineCount);
    return () => window.removeEventListener("resize", checkLineCount);
  }, [description]);
  return /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellCard,
    {
      className: (0, import_classnames.default)("pisell-event-card", className),
      style,
      borderRadius: 10,
      isClickable: false
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-event-card-content" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-event-card-title-wrapper" }, showTitle && /* @__PURE__ */ import_react.default.createElement(import_materials2.PisellText, { className: "pisell-event-card-title" }, title), showSubtitle && /* @__PURE__ */ import_react.default.createElement(import_materials2.PisellText, { className: "pisell-event-card-subtitle" }, subtitle)), showPrice && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-event-card-price-wrapper" }, /* @__PURE__ */ import_react.default.createElement(
      import_materials2.PisellText.Amount,
      {
        className: "pisell-event-card-price",
        value: price,
        precision: 2,
        showCurrencySymbol: true
      }
    ), showOriginalPrice && origin_price && price !== origin_price && /* @__PURE__ */ import_react.default.createElement(
      import_materials2.PisellText.Amount,
      {
        className: "pisell-event-card-original-price",
        value: origin_price,
        precision: 2,
        showCurrencySymbol: true
      }
    )), showDescription && description && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-event-card-line" }), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-event-card-description" }, /* @__PURE__ */ import_react.default.createElement(import_materials2.PisellText, { className: "pisell-event-card-description-title" }, import_utils.locales.getText("pisell2.event.description")), /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        ref: descriptionRef,
        className: (0, import_classnames.default)("pisell-event-card-description-content", {
          "pisell-event-card-description-collapsed": !expanded && showToggle
        })
      },
      /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          dangerouslySetInnerHTML: {
            __html: description
          }
        }
      )
    ), showToggle && /* @__PURE__ */ import_react.default.createElement(
      import_materials2.PisellText,
      {
        className: "pisell-event-card-description-toggle",
        onClick: () => setExpanded(!expanded)
      },
      expanded ? import_utils.locales.getText("pisell2.event.view.less") : import_utils.locales.getText("pisell2.event.view.more")
    ))))
  );
};
var eventCard_default = EventCard;
