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/ecocup/components/CupActionList/index.tsx
var CupActionList_exports = {};
__export(CupActionList_exports, {
  default: () => CupActionList_default
});
module.exports = __toCommonJS(CupActionList_exports);
var import_react = __toESM(require("react"));
var import_utils = require("@pisell/utils");
var import_materials = require("@pisell/materials");
var import_types = require("../../types");
var import_hooks = require("../../hooks");
var import_CupActionModal = __toESM(require("../CupActionModal"));
var import_MoreDropdown = __toESM(require("../MoreDropdown"));
var import_index = require("./index.less");
var import_dayjs = __toESM(require("dayjs"));
var CupActionList = (props) => {
  const {
    maxNum,
    currentNum,
    cups,
    customerData,
    onClearAll,
    onRemove,
    onAction
  } = props;
  const cupActionModal = (0, import_hooks.useModal)("ecocup-cup-action-modal");
  const isOverMax = (0, import_react.useMemo)(() => {
    return currentNum > maxNum;
  }, [currentNum, maxNum]);
  const handleAction = (type, cup) => {
    cupActionModal.open({
      data: {
        type,
        cupData: cup,
        customerData
      },
      onOk: () => {
        onAction(type, cup);
      }
    });
  };
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2-ecocup-cup-action-list" }, isOverMax && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2-ecocup-cup-action-list-over-max" }, /* @__PURE__ */ import_react.default.createElement("span", null, import_utils.locales.getText("pisell2.text.ecocup.customer-first-modal.over-max").replace("{{num}}", (currentNum - maxNum).toString())), /* @__PURE__ */ import_react.default.createElement("span", { onClick: onClearAll }, import_utils.locales.getText("pisell2.text.ecocup.button.clear-all"))), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2-ecocup-cup-action-list-cup-list" }, cups.map((cup) => {
    var _a;
    const isInStock = (cup == null ? void 0 : cup.status) === import_types.ECupStatus.IN_STOCK;
    return /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        key: cup.code,
        className: "pisell2-ecocup-cup-action-list-cup",
        style: isInStock ? {
          backgroundColor: "#F6F2FF",
          border: "1px solid #F6F2FF"
        } : {
          border: "1px solid #D0D5DD"
        }
      },
      /* @__PURE__ */ import_react.default.createElement(import_materials.Icon, { type: "RestOutlined", size: 24, color: "#7F56DA" }),
      /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2-ecocup-cup-action-list-cup-info" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2-ecocup-cup-action-list-cup-info-top" }, /* @__PURE__ */ import_react.default.createElement("span", null, import_utils.locales.getText("pisell2.text.ecocup.cup-id")), /* @__PURE__ */ import_react.default.createElement("span", null, (cup == null ? void 0 : cup.eco_cup_code) || (cup == null ? void 0 : cup.code) || "-")), !isInStock && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2-ecocup-cup-action-list-cup-info-bottom" }, /* @__PURE__ */ import_react.default.createElement("span", null, ((_a = cup == null ? void 0 : cup.rent_shop) == null ? void 0 : _a.name) || "-"), /* @__PURE__ */ import_react.default.createElement("span", null, (cup == null ? void 0 : cup.rent_time) ? (0, import_dayjs.default)(cup == null ? void 0 : cup.rent_time).format("DD/MM/YYYY") : "-"))),
      isInStock ? /* @__PURE__ */ import_react.default.createElement(
        import_materials.Button,
        {
          type: "primary",
          icon: /* @__PURE__ */ import_react.default.createElement(import_materials.Icon, { type: "pisell2-trash-01", size: 24, color: "#7F56DA" }),
          onClick: () => onRemove(cup),
          className: "pisell2-ecocup-cup-action-list-cup-info-remove"
        },
        import_utils.locales.getText("pisell2.text.ecocup.button.remove")
      ) : /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2-ecocup-cup-action-list-cup-info-actions" }, /* @__PURE__ */ import_react.default.createElement(
        import_materials.Button,
        {
          type: "primary",
          onClick: () => handleAction(import_types.ECupActionType.RETURN, cup)
        },
        "Return"
      ), /* @__PURE__ */ import_react.default.createElement(
        import_MoreDropdown.default,
        {
          locales: import_utils.locales,
          onClick: (key) => handleAction(key, cup),
          buttonText: import_utils.locales.getText(
            "pisell2.text.ecocup.button.others"
          )
        }
      ))
    );
  })), (cupActionModal == null ? void 0 : cupActionModal.visible) && /* @__PURE__ */ import_react.default.createElement(import_CupActionModal.default, { ...cupActionModal == null ? void 0 : cupActionModal.modalProps }));
};
var CupActionList_default = CupActionList;
