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/productCard/index.tsx
var productCard_exports = {};
__export(productCard_exports, {
  default: () => productCard_default
});
module.exports = __toCommonJS(productCard_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_utils = require("@pisell/utils");
var import_cardPro = __toESM(require("../cardPro"));
var import_Header = __toESM(require("./components/Header"));
var import_DeleteButton = __toESM(require("./components/Header/DeleteButton"));
var import_Time = __toESM(require("./components/Time"));
var import_Packages = __toESM(require("./components/Packages"));
var import_Sales = __toESM(require("./components/Sales"));
var import_AmountFooter = __toESM(require("./components/AmountFooter"));
var import_MultiDay = __toESM(require("./components/MultiDay"));
var import_Note = __toESM(require("./components/Note"));
var import_Action = __toESM(require("./components/Action"));
var import_useOpenNote = __toESM(require("./hooks/useOpenNote"));
var import_locales = __toESM(require("./locales"));
var import_status = require("./status");
var import_useEngineContext = __toESM(require("../../hooks/useEngineContext"));
var import_Warning = __toESM(require("./components/Warning"));
var import_index = require("./index.less");
var import_cartSkuCard = __toESM(require("./cartSkuCard"));
var ProductCard = (props) => {
  var _a, _b;
  const context = (0, import_useEngineContext.default)();
  const utils = context.appHelper.utils || {};
  const {
    dataSource = import_status.defaultValue.dataSource,
    isShowImage = import_status.defaultValue.isShowImage,
    isShowHolder = import_status.defaultValue.isShowHolder,
    isShowNote = import_status.defaultValue.isShowNote,
    isShowDelete = import_status.defaultValue.isShowDelete,
    isShowPackageNote = import_status.defaultValue.isShowPackageNote,
    isShowEditProduct = import_status.defaultValue.isShowEditProduct,
    scenario,
    onEditProduct,
    onAction,
    onDelete,
    onNote,
    onLike,
    onCard,
    onChangeResource,
    onChangeHolder,
    ...other
  } = props;
  const useOpenNoteRef = (0, import_react.useRef)();
  const locale = ((_a = utils == null ? void 0 : utils.storage) == null ? void 0 : _a.get("umi_locale")) || localStorage.getItem("umi_locale");
  import_utils.locales.init(import_locales.default, locale || "en");
  const {
    image,
    bundle,
    relation_products,
    _id,
    isShowAction,
    actionText,
    errorMessage,
    isNormalProduct,
    osWarnTips = []
  } = dataSource;
  const showImage = (0, import_react.useMemo)(() => {
    return isShowImage && image;
  }, [isShowImage, image]);
  const hideDivider = (0, import_react.useMemo)(() => {
    return (bundle == null ? void 0 : bundle.length) || (relation_products == null ? void 0 : relation_products.length);
  }, [bundle, relation_products]);
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)("pisell-lowcode-product-card-wrap", {
        ["pisell-lowcode-product-card-disabled"]: dataSource == null ? void 0 : dataSource.disabled
      }),
      id: dataSource == null ? void 0 : dataSource.rowKey
    },
    (dataSource == null ? void 0 : dataSource.disabled) && /* @__PURE__ */ import_react.default.createElement("div", { className: "delete-btn-wrapper" }, /* @__PURE__ */ import_react.default.createElement(import_DeleteButton.default, { onDelete: () => onDelete == null ? void 0 : onDelete(dataSource) })),
    /* @__PURE__ */ import_react.default.createElement(
      import_cardPro.default,
      {
        className: (0, import_classnames.default)("pisell-lowcode-product-card", {
          ["pisell-lowcode-product-card-image"]: !showImage && scenario !== "booking2",
          ["pisell-lowcode-normal-product-card"]: !showImage && isNormalProduct && scenario !== "booking2",
          ["pisell-lowcode-product-card-image-booking2"]: scenario === "booking2"
        }),
        key: _id
      },
      /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          onClick: (e) => {
            e.preventDefault();
            e.stopPropagation();
            onCard == null ? void 0 : onCard(dataSource);
          }
        },
        /* @__PURE__ */ import_react.default.createElement(
          import_Header.default,
          {
            ...other,
            item: dataSource,
            isShowImage,
            isShowDelete,
            isShowEditProduct,
            showImage,
            onEditProduct: () => onEditProduct == null ? void 0 : onEditProduct(dataSource),
            onDelete: () => {
              onDelete == null ? void 0 : onDelete(dataSource);
            }
          }
        ),
        /* @__PURE__ */ import_react.default.createElement(
          import_Time.default,
          {
            item: dataSource,
            isShowHolder,
            isShowChangeResource: other == null ? void 0 : other.isShowChangeResource,
            isShowChangeHolder: other == null ? void 0 : other.isShowChangeHolder,
            holderMode: other == null ? void 0 : other.holderMode,
            onLike: (item) => onLike == null ? void 0 : onLike(item),
            changeResource: onChangeResource,
            changeHolder: onChangeHolder,
            onAddHolder: other == null ? void 0 : other.onAddHolder,
            isShowAddHolderButton: other == null ? void 0 : other.isShowAddHolderButton,
            onClearResource: other == null ? void 0 : other.onClearResource,
            onClearHolder: other == null ? void 0 : other.onClearHolder
          }
        ),
        /* @__PURE__ */ import_react.default.createElement(import_Packages.default, { item: dataSource, isShowPackageNote }),
        /* @__PURE__ */ import_react.default.createElement(import_Sales.default, { item: dataSource, isShowNote }),
        ((_b = dataSource.items) == null ? void 0 : _b.length) ? /* @__PURE__ */ import_react.default.createElement(import_MultiDay.default, { dataSource, hideDivider }) : /* @__PURE__ */ import_react.default.createElement(
          import_AmountFooter.default,
          {
            item: dataSource,
            hideDivider,
            type: "total"
          }
        ),
        isShowNote ? /* @__PURE__ */ import_react.default.createElement(
          import_Note.default,
          {
            ...other,
            item: dataSource,
            openNote: () => {
              useOpenNoteRef.current.open({
                item: dataSource
              });
            }
          }
        ) : null,
        isShowAction && actionText ? /* @__PURE__ */ import_react.default.createElement(
          import_Action.default,
          {
            item: dataSource,
            onAction: () => onAction == null ? void 0 : onAction(dataSource)
          }
        ) : null,
        /* @__PURE__ */ import_react.default.createElement(import_Warning.default, { errorMessage, osWarnTips })
      ), /* @__PURE__ */ import_react.default.createElement(
        import_useOpenNote.default,
        {
          ref: useOpenNoteRef,
          onNoteChange: (e) => {
            onNote == null ? void 0 : onNote({
              ...dataSource,
              note: e || ""
            });
          }
        }
      ))
    )
  );
};
ProductCard.V2 = import_cartSkuCard.default;
var productCard_default = ProductCard;
