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/Provider/Information/index.tsx
var Information_exports = {};
__export(Information_exports, {
  default: () => Information_default
});
module.exports = __toCommonJS(Information_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_Sales = require("../../../../Sales");
var import_SelectHolderModal = __toESM(require("../SelectHolderModal"));
var import_InformationOptionsModal = __toESM(require("../InformationOptionsModal/index"));
var import_RemoveOptionConfirmModal = __toESM(require("../RemoveOptionConfirmModal"));
var import_index = require("./index.less");
var Information = () => {
  const { onHolderOpen, open } = (0, import_Sales.useHolder)();
  const { cartDataHolderList } = (0, import_Sales.useCart)();
  const { selectHolder, deleteHolderById } = (0, import_Sales.useHolder)();
  const { prevStep } = (0, import_Sales.useStep)();
  const [openOption, setOpenOption] = (0, import_react.useState)(false);
  const [holderItem, setHolderItem] = (0, import_react.useState)(null);
  const [removeOpen, setRemoveOpen] = (0, import_react.useState)(false);
  const options = [
    {
      key: "edit",
      label: /* @__PURE__ */ import_react.default.createElement("span", { className: "dropdown-menu-item" }, import_utils.locales.getText("pisell2.event.edit.event"))
    },
    {
      key: "remove",
      label: /* @__PURE__ */ import_react.default.createElement("span", { className: "dropdown-menu-item dropdown-menu-remove-item" }, import_utils.locales.getText("pisell2.event.remove"))
    }
  ];
  const handleClick = ({ key }, item) => {
    if (key === "edit") {
      selectHolder(item || holderItem, "createCartItem");
      prevStep();
      return;
    }
    setRemoveOpen(true);
  };
  const renderOptionButton = (item) => {
    if ((0, import_utils.isMobile)()) {
      return /* @__PURE__ */ import_react.default.createElement(
        import_materials.Button,
        {
          size: "large",
          onClick: () => {
            setHolderItem(item);
            setOpenOption(true);
          }
        },
        import_utils.locales.getText("pisell2.event.option")
      );
    }
    return /* @__PURE__ */ import_react.default.createElement(
      import_antd.Dropdown,
      {
        menu: {
          items: options,
          onClick: (e) => {
            setHolderItem(item);
            handleClick(e, item);
          }
        },
        placement: "bottomRight",
        overlayClassName: "provider-information-custom-dropdown-menu"
      },
      /* @__PURE__ */ import_react.default.createElement(import_materials.Button, null, import_utils.locales.getText("pisell2.event.option"))
    );
  };
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "provider-information-wrap" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "title" }, import_utils.locales.getText("pisell2.event.confirm.information.tip")), cartDataHolderList == null ? void 0 : cartDataHolderList.map((item) => {
    var _a;
    return /* @__PURE__ */ import_react.default.createElement(
      import_materials.PisellCard,
      {
        key: item.id,
        padding: 20,
        className: "information-card",
        isClickable: false
      },
      /* @__PURE__ */ import_react.default.createElement("div", { className: "information-header" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "information-left" }, /* @__PURE__ */ import_react.default.createElement(import_materials.PisellAvatar, { src: item.avatar, size: "md" }), /* @__PURE__ */ import_react.default.createElement("div", { className: "information-title" }, /* @__PURE__ */ import_react.default.createElement("span", null, item.name), /* @__PURE__ */ import_react.default.createElement("span", { className: "subtitle" }, `${import_utils.locales.getText(
        "pisell2.event.title"
      )((_a = item.children) == null ? void 0 : _a.length)}`))), renderOptionButton(item)),
      item.children.map((child) => {
        return /* @__PURE__ */ import_react.default.createElement("div", { className: "child-wrap" }, child.name);
      })
    );
  }), /* @__PURE__ */ import_react.default.createElement("span", { className: "add-tip" }, import_utils.locales.getText("pisell2.event.confirm.information.other")), /* @__PURE__ */ import_react.default.createElement(
    import_materials.Button,
    {
      size: "large",
      style: { width: "max-content" },
      onClick: () => {
        onHolderOpen();
      },
      className: "provider-information-add-button"
    },
    /* @__PURE__ */ import_react.default.createElement(import_materials.Iconfont, { type: "pisell2-plus", style: { fontSize: "20px" } }),
    import_utils.locales.getText("pisell2.event.add.others")
  )), /* @__PURE__ */ import_react.default.createElement(import_SelectHolderModal.default, { open, type: "create" }), /* @__PURE__ */ import_react.default.createElement(
    import_InformationOptionsModal.default,
    {
      options,
      open: openOption,
      holderItem,
      onCancel: () => setOpenOption(false),
      onClick: handleClick
    }
  ), /* @__PURE__ */ import_react.default.createElement(
    import_RemoveOptionConfirmModal.default,
    {
      removeOpen,
      onCancel: () => setRemoveOpen(false),
      onOk: () => {
        deleteHolderById(holderItem.id);
        setRemoveOpen(false);
        setOpenOption(false);
      }
    }
  ));
};
var Information_default = Information;
