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/booking/deposit/DepositItem/index.tsx
var DepositItem_exports = {};
__export(DepositItem_exports, {
  default: () => DepositItem_default
});
module.exports = __toCommonJS(DepositItem_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_icons = require("@ant-design/icons");
var import_utils = require("@pisell/utils");
var import_ClientItem = __toESM(require("../ClientItem"));
var import_Edit05 = __toESM(require("@pisell/icon/src/Edit05"));
var import_index = require("./index.less");
var statusTagColor = {
  unpaid: "#B2DDFF",
  paid: "#ABEFC6"
};
var statusBgColor = {
  unpaid: "#EFF8FF",
  paid: "#ECFDF3"
};
var DepositItem = (props) => {
  const {
    status,
    customer,
    totalAmountStr,
    onEdit,
    orderId,
    orderNumber,
    handleGoOrderDetail,
    generatePaymentLink,
    depositAmount,
    amountSymbol,
    createdTime,
    isPaid,
    isBookingCancelled,
    sendEmail,
    hideOrderDetail,
    depositPaidAmount,
    depositUnPaidAmount,
    depositOriginPaidAmount
  } = props;
  const rowStatus = props.status === "paid" ? "paid" : "unpaid";
  const statusText = {
    unpaid: import_utils.locales.getText("pisell2.text.deposit-item-status-unpaid"),
    paid: import_utils.locales.getText("pisell2.text.deposit-item-status-paid")
  };
  (0, import_react.useEffect)(() => {
    document.body.id = "body";
  }, []);
  const items = [
    {
      key: "send",
      disabled: isPaid || isBookingCancelled,
      label: /* @__PURE__ */ import_react.default.createElement("div", null, import_utils.locales.getText("pisell2.text.send-mail"))
    },
    {
      key: "1",
      disabled: isPaid || isBookingCancelled,
      label: /* @__PURE__ */ import_react.default.createElement("div", null, import_utils.locales.getText("pisell2.text.copy-to-clipboard"))
    }
  ];
  const onClick = ({ key }) => {
    if (key === "1") {
      generatePaymentLink == null ? void 0 : generatePaymentLink(orderId);
    } else if (key === "send") {
      sendEmail == null ? void 0 : sendEmail(orderId);
    }
  };
  const handlingFee = (Number(depositPaidAmount) || 0) - (Number(depositOriginPaidAmount) || 0);
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__deposit-item" }, /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: "pisell-lowcode__deposit-item-header",
      style: { backgroundColor: statusBgColor[rowStatus] }
    },
    /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: "pisell-lowcode__deposit-status",
        style: { backgroundColor: statusTagColor[rowStatus] }
      },
      statusText[rowStatus]
    ),
    /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__deposit-item-header-right" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode__deposit-item-header-right-amount" }, (0, import_utils.formatAmount)(depositAmount, 2, amountSymbol)), !(isPaid || isBookingCancelled) && /* @__PURE__ */ import_react.default.createElement(
      import_Edit05.default,
      {
        className: "pisell-lowcode__deposit-item-header-right-edit",
        onClick: onEdit
      }
    ))
  ), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__deposit-item-content" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__deposit-item-content-line1" }, import_utils.locales.getText("pisell2.text.deposit-order-no"), " ", orderNumber), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__deposit-item-content-line2" }, createdTime), /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(import_ClientItem.default, { data: customer, coverSize: 40, walkInName: "Walk-In" }))), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__deposit-item-footer" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__deposit-item-footer-total" }, /* @__PURE__ */ import_react.default.createElement("div", null, import_utils.locales.getText("pisell2.text.deposit-order-total")), /* @__PURE__ */ import_react.default.createElement("div", null, totalAmountStr)), rowStatus === "unpaid" && depositPaidAmount > 0 && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__deposit-item-footer-total-deposit" }, /* @__PURE__ */ import_react.default.createElement("div", null, import_utils.locales.getText("pisell2.text.deposit-deposit-paid"), " ", handlingFee > 0 && /* @__PURE__ */ import_react.default.createElement("span", null, "(", import_utils.locales.getText(
    "pisell2.text.deposit-deposit-paid-including-surcharge"
  ), " ", (0, import_utils.formatAmount)(handlingFee, 2, amountSymbol), ")")), /* @__PURE__ */ import_react.default.createElement("div", null, (0, import_utils.formatAmount)(depositPaidAmount, 2, amountSymbol))), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__deposit-item-footer-total-deposit" }, /* @__PURE__ */ import_react.default.createElement("div", null, import_utils.locales.getText("pisell2.text.deposit-deposit-paid-due"), " "), /* @__PURE__ */ import_react.default.createElement("div", null, (0, import_utils.formatAmount)(depositUnPaidAmount, 2, amountSymbol)))), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__deposit-item-footer-action" }, !hideOrderDetail && /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { block: true, size: "large", onClick: handleGoOrderDetail }, import_utils.locales.getText("pisell2.text.deposit-order-detail")), /* @__PURE__ */ import_react.default.createElement(import_antd.Dropdown, { menu: { items, onClick }, placement: "bottom" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { block: true, type: "primary", size: "large" }, import_utils.locales.getText("pisell2.text.deposit-collect-deposit"), " ", /* @__PURE__ */ import_react.default.createElement(import_icons.DownOutlined, null))))));
};
var DepositItem_default = DepositItem;
