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/plus/salesSdk/components/SalesSdkConfirmHolderModal.tsx
var SalesSdkConfirmHolderModal_exports = {};
__export(SalesSdkConfirmHolderModal_exports, {
  SalesSdkConfirmHolderModal: () => SalesSdkConfirmHolderModal
});
module.exports = __toCommonJS(SalesSdkConfirmHolderModal_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_ahooks = require("ahooks");
var import_utils = require("@pisell/utils");
var import_materials = require("@pisell/materials");
var import_compensatedPisellContainer = __toESM(require("../../../pro/compensatedPisellContainer"));
var import_responsive = require("../../../responsive");
var import_confirmHolderModal = require("../../../components/booking/utils/confirmHolderModal.less");
var { LineItem } = import_materials.ProductCard;
var STATUS_OPTIONS = [
  { key: "new", labelKey: "pisell2.sale-detail.status.new", color: "#91caff" },
  {
    key: "confirmed",
    labelKey: "pisell2.sale-detail.status.confirmed",
    color: "#b7eb8f"
  },
  {
    key: "arrived",
    labelKey: "pisell2.sale-detail.status.arrived",
    color: "#d3adf7"
  },
  {
    key: "started",
    labelKey: "pisell2.sale-detail.status.started",
    color: "#fffb8f"
  },
  {
    key: "cancelled",
    labelKey: "pisell2.sale-detail.status.cancelled",
    color: "#bfbfbf",
    danger: true
  },
  {
    key: "no_show",
    labelKey: "pisell2.sale-detail.status.no_show",
    color: "#ffa39e",
    danger: true
  },
  {
    key: "completed",
    labelKey: "pisell2.sale-detail.status.completed",
    color: "#ffd591"
  }
];
function SalesSdkConfirmHolderModalContent({
  open,
  lines,
  liveUnassignedCount,
  bookingConfig,
  onAssign,
  onConfirm,
  onSkip,
  onDismissConfirmed,
  variant
}) {
  var _a, _b;
  const isPhoneVariant = variant === "phone";
  const [modal, contextHolder] = import_antd.Modal.useModal();
  const isSubjectOptional = ((_b = (_a = bookingConfig == null ? void 0 : bookingConfig.config) == null ? void 0 : _a.basic) == null ? void 0 : _b.subject_require) !== "require";
  const statusOptions = (0, import_react.useMemo)(
    () => STATUS_OPTIONS.map((option) => ({
      key: option.key,
      label: import_utils.locales.getText(option.labelKey),
      color: option.color,
      danger: option.danger
    })),
    []
  );
  const handleClose = () => {
    if (!open) return;
    modal.confirm({
      title: import_utils.locales.getText("pisell2.text.deposit-delete-message-title"),
      content: import_utils.locales.getText("pisell2.text.close-confirm-message"),
      okText: import_utils.locales.getText("pisell2.text.confirm"),
      cancelText: import_utils.locales.getText("pisell2.text.cancel"),
      onOk: () => {
        onDismissConfirmed();
      }
    });
  };
  const { run: debouncedHandleClose } = (0, import_ahooks.useDebounceFn)(handleClose, {
    wait: 500,
    leading: true,
    trailing: false
  });
  if (!open) return null;
  const title = import_utils.locales.getText("pisell2.text.holder-unassigned")(liveUnassignedCount);
  const hintText = liveUnassignedCount > 0 ? import_utils.locales.getText("pisell2.text.press-card-assign-holder") : "";
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    import_compensatedPisellContainer.default,
    {
      renderType: isPhoneVariant ? "drawer" : "modal",
      props: isPhoneVariant ? {
        open,
        placement: "bottom",
        width: "100%",
        height: "95vh",
        onClose: debouncedHandleClose,
        title,
        footer: null,
        destroyOnClose: true,
        maskClosable: false,
        closable: true
      } : {
        open,
        onCancel: debouncedHandleClose,
        title,
        footer: null,
        width: 800,
        destroyOnClose: true,
        maskClosable: false,
        closable: true
      }
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "confirm-holder-modal-content" }, hintText ? /* @__PURE__ */ import_react.default.createElement("div", { className: "confirm-holder-modal-hint" }, hintText) : null, /* @__PURE__ */ import_react.default.createElement("div", { className: "confirm-holder-modal-service" }, lines.map((line) => {
      var _a2;
      return /* @__PURE__ */ import_react.default.createElement(
        LineItem,
        {
          key: ((_a2 = line.orderLine.metadata) == null ? void 0 : _a2.unique_identification_number) || line.booking.booking_id || line.cacheItem._id,
          itemType: "booking",
          type: "a9",
          dataSource: line.displayBooking,
          statusOptions,
          scenario: "booking2",
          disabledEdit: true,
          isShowDelete: false,
          isShowAmountFooter: true,
          isShowNote: true,
          isShowImage: true,
          maxSpecsCount: 1,
          onCard: () => {
            void onAssign(line);
          },
          onAction: () => {
          },
          onDelete: () => {
          },
          onNote: () => {
          },
          onPromotion: () => {
          },
          onGift: () => {
          }
        }
      );
    })), /* @__PURE__ */ import_react.default.createElement("div", { className: "confirm-holder-modal-footer" }, isSubjectOptional && onSkip ? /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { onClick: onSkip, className: "skip-button", size: "large" }, import_utils.locales.getText("pisell2.text.skip-for-now")) : null, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { type: "primary", onClick: onConfirm, className: "confirm-button" }, import_utils.locales.getText("pisell2.text.confirm"))))
  ), contextHolder);
}
SalesSdkConfirmHolderModalContent.displayName = "SalesSdkConfirmHolderModal";
var SalesSdkConfirmHolderModal = (0, import_responsive.withResponsive)(
  SalesSdkConfirmHolderModalContent
);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  SalesSdkConfirmHolderModal
});
