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/CupActionModal/index.tsx
var CupActionModal_exports = {};
__export(CupActionModal_exports, {
  default: () => CupActionModal_default
});
module.exports = __toCommonJS(CupActionModal_exports);
var import_react = __toESM(require("react"));
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_CustomerCard = __toESM(require("../CustomerCard"));
var import_CupInfoCard = __toESM(require("../CupInfoCard"));
var import_index = require("./index.less");
var import_types = require("../../types");
var import_hooks = require("./hooks");
var CupActionModal = (props) => {
  var _a;
  const { visible, onCancel, onOk, data } = props;
  const { type, cupData } = data || {};
  const cupAction = (0, import_hooks.useCupAction)();
  const style = (0, import_react.useMemo)(() => {
    if ((data == null ? void 0 : data.type) === import_types.ECupActionType.MISSING || (data == null ? void 0 : data.type) === import_types.ECupActionType.BROKEN) {
      return {
        backgroundColor: "#FEE4E2",
        color: "#F04438"
      };
    }
    return {
      backgroundColor: "#F6F2FF",
      color: "#7F56DA"
    };
  }, [data == null ? void 0 : data.type]);
  const _onCancel = () => {
    if (cupAction == null ? void 0 : cupAction.loading) return;
    onCancel == null ? void 0 : onCancel();
  };
  const _onOk = () => {
    if (cupAction == null ? void 0 : cupAction.loading) return;
    cupAction.run((cupData == null ? void 0 : cupData.eco_cup_id) || (cupData == null ? void 0 : cupData.id), type).then((res) => {
      if (res) {
        (0, import_materials.PisellToast)({
          content: import_utils.locales.getText(
            `pisell2.text.ecocup.toast.success-${type}`
          )
        });
        onOk == null ? void 0 : onOk(cupData);
      }
    });
  };
  return /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellModal,
    {
      open: visible,
      headerDivider: false,
      title: import_utils.locales.getText(
        `pisell2.text.ecocup.cup-action-modal.title-${data == null ? void 0 : data.type}`
      ),
      onCancel: _onCancel,
      onOk: _onOk,
      okText: import_utils.locales.getText(
        `pisell2.text.ecocup.button.mark-as-${data == null ? void 0 : data.type}`
      ),
      cancelText: import_utils.locales.getText("pisell2.text.ecocup.button.cancel"),
      okButtonProps: { loading: cupAction == null ? void 0 : cupAction.loading },
      width: 580,
      destroyOnClose: true,
      wrapClassName: "pisell2-ecocup-cup-action-modal"
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2-ecocup-cup-action-modal-content" }, /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: "pisell2-ecocup-cup-action-modal-content-cup",
        style: { ...style }
      },
      /* @__PURE__ */ import_react.default.createElement(import_materials.Icon, { type: "RestOutlined", size: 24 }),
      /* @__PURE__ */ import_react.default.createElement(
        "span",
        {
          style: {
            color: (data == null ? void 0 : data.type) === import_types.ECupActionType.RETURN ? "#667085" : "#F04438"
          }
        },
        import_utils.locales.getText("pisell2.text.ecocup.cup-action-modal.cup-id")
      ),
      /* @__PURE__ */ import_react.default.createElement("span", null, (cupData == null ? void 0 : cupData.eco_cup_code) || (cupData == null ? void 0 : cupData.code) || "")
    ), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2-ecocup-cup-action-modal-info" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2-ecocup-cup-action-modal-info-left" }, /* @__PURE__ */ import_react.default.createElement(
      import_CupInfoCard.default,
      {
        type: "rentInfo",
        data: {
          shop: (_a = cupData == null ? void 0 : cupData.rent_shop) == null ? void 0 : _a.name,
          time: cupData == null ? void 0 : cupData.rent_time
        }
      }
    )), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell2-ecocup-cup-action-modal-info-right" }, /* @__PURE__ */ import_react.default.createElement(import_CustomerCard.default, { ...data == null ? void 0 : data.customerData }))))
  );
};
var CupActionModal_default = CupActionModal;
