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/checkout/components/AmountSummary/index.tsx
var AmountSummary_exports = {};
__export(AmountSummary_exports, {
  default: () => AmountSummary_default
});
module.exports = __toCommonJS(AmountSummary_exports);
var import_react = require("react");
var import_ahooks = require("ahooks");
var import_antd = require("antd");
var import_icons = require("@ant-design/icons");
var import_icon = require("@pisell/icon");
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_decimal = __toESM(require("decimal.js"));
var import_locales = __toESM(require("../../locales"));
var import_PaymentDetailModal = __toESM(require("../PaymentDetailModal"));
var import_pisellSimplePriceKeyboardPopover = __toESM(require("../../../../pro/pisellSimplePriceKeyboardPopover"));
var import_index = require("./index.less");
var import_classnames = __toESM(require("classnames"));
var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
var import_materials2 = require("@pisell/materials");
var import_useToast = __toESM(require("../../../../hooks/useToast"));
var import_react2 = __toESM(require("react"));
var ChevronSelectorVertical = ({
  style
}) => /* @__PURE__ */ import_react2.default.createElement(
  "svg",
  {
    width: "36",
    height: "36",
    viewBox: "0 0 36 36",
    fill: "none",
    xmlns: "http://www.w3.org/2000/svg",
    style
  },
  /* @__PURE__ */ import_react2.default.createElement(
    "path",
    {
      d: "M21 15L18 12L15 15M15 21L18 24L21 21",
      stroke: "currentColor",
      strokeWidth: "2",
      strokeLinecap: "round",
      strokeLinejoin: "round"
    }
  )
);
function AmountSummary({
  amountSymbol = "$",
  orderInfo,
  open_deposit = false,
  customAmount,
  balanceDueAmount,
  clientInfo,
  onAmountChange,
  onDepositStatusChange,
  onBalanceDueAmountClick,
  onConfirm,
  paymentItems,
  cartData,
  walletPassData,
  totalAmount = 0,
  baseSales
}) {
  var _a;
  const context = (0, import_useEngineContext.default)();
  const { action, token, store, getApp } = (_a = context.appHelper) == null ? void 0 : _a.utils;
  const Toast = (0, import_useToast.default)();
  const getText = (key, fallback) => {
    var _a2, _b, _c, _d, _e, _f, _g, _h;
    const currentLang = ((_e = (_d = (_c = (_b = (_a2 = context.appHelper.utils) == null ? void 0 : _a2.getApp) == null ? void 0 : _b.call(_a2)) == null ? void 0 : _c.locales) == null ? void 0 : _d.getLocale) == null ? void 0 : _e.call(_d)) || ((_g = (_f = context.appHelper.utils) == null ? void 0 : _f.storage) == null ? void 0 : _g.get("umi_locale")) || "en";
    const checkoutText = (_h = import_locales.default[currentLang]) == null ? void 0 : _h[key];
    if (checkoutText) {
      return checkoutText;
    }
    return import_utils.locales.getText(key) || fallback;
  };
  const [paymentType, setPaymentType] = (0, import_react.useState)("regular");
  const [isPaymentDetailOpen, setIsPaymentDetailOpen] = (0, import_react.useState)(false);
  const [summaryData, setSummaryData] = (0, import_react.useState)([]);
  const [partialPaidAmount, setPartialPaidAmount] = (0, import_react.useState)("0");
  const [isKeyboardVisible, setIsKeyboardVisible] = (0, import_react.useState)(false);
  const labelMaps = {
    deposit: getText("pisell2.subtotal.deposit") || "Deposit",
    total: getText("pisell2.subtotal.total") || "Total",
    sub_total: getText("pisell2.subtotal.subtotal") || "Subtotal",
    tax: getText("pisell2.subtotal.tax") || "Tax",
    delivery_fee: getText("pisell2.subtotal.delivery-fee") || "Delivery Fee",
    discount: getText("pisell2.subtotal.discount") || "Discount",
    point_deduction: getText("pisell2.subtotal.point-deduction") || "Point Deduction",
    member_deduction: getText("pisell2.subtotal.member-deduction") || "Member Deduction",
    expect_amount: getText("pisell2.subtotal.expect-amount") || "Expected Amount"
  };
  const getBalanceDueAmount = () => {
    if (paymentType === "deposit") {
      return (orderInfo == null ? void 0 : orderInfo.depositAmount) || "0";
    }
    return (orderInfo == null ? void 0 : orderInfo.remainingAmount) || (orderInfo == null ? void 0 : orderInfo.totalAmount) || "0";
  };
  const parseFormattedAmount = (formattedAmount) => {
    if (typeof formattedAmount === "number") {
      return formattedAmount;
    }
    if (typeof formattedAmount === "string") {
      const numericString = formattedAmount.replace(/[^-0-9.]/g, "");
      try {
        const parsed = new import_decimal.default(numericString || "0");
        return parsed.toNumber();
      } catch {
        return 0;
      }
    }
    return 0;
  };
  const [currentAmount, setCurrentAmount] = (0, import_react.useState)(
    customAmount && customAmount !== "" ? customAmount : parseFormattedAmount(getBalanceDueAmount())
  );
  (0, import_react.useEffect)(() => {
    if (customAmount && customAmount !== "") {
      setCurrentAmount(customAmount);
    }
  }, [customAmount]);
  (0, import_react.useEffect)(() => {
    var _a2, _b, _c;
    if (baseSales && orderInfo) {
      try {
        const summaryInfo = ((_b = (_a2 = baseSales.getOrderAmountSnapshot) == null ? void 0 : _a2.call(baseSales)) == null ? void 0 : _b.summary) || {};
        const translationOriginal = (_c = context.appHelper.utils) == null ? void 0 : _c.translationOriginal;
        const surchargeList = Array.isArray(summaryInfo == null ? void 0 : summaryInfo.surcharges) ? summaryInfo.surcharges.filter((surcharge) => surcharge == null ? void 0 : surcharge.name).map((surcharge, index) => ({
          key: `custom_surcharge_${surcharge.surcharge_id ?? index}`,
          value: surcharge.amount || 0,
          label: (translationOriginal == null ? void 0 : translationOriginal(surcharge.name)) || (typeof surcharge.name === "string" ? surcharge.name : getText("service.charge", "Service Charge"))
        })) : [];
        const summary = [
          { key: "sub_total", value: summaryInfo.product_amount || summaryInfo.product_expect_amount || 0 },
          ...surchargeList,
          { key: "tax", value: summaryInfo.tax_fee || 0 },
          { key: "discount", value: summaryInfo.discount_amount || 0 },
          { key: "expect_amount", value: summaryInfo.expect_amount || summaryInfo.total_amount || 0 }
        ];
        if (Array.isArray(summary)) {
          setSummaryData(summary);
        }
        setPaymentType(orderInfo.isDeposit ? "deposit" : "regular");
      } catch (error) {
        console.warn("Failed to get cart summary:", error);
      }
    }
  }, [baseSales, orderInfo]);
  (0, import_react.useEffect)(() => {
    if (summaryData.length > 0 && (!customAmount || customAmount === "")) {
      setCurrentAmount(parseFormattedAmount(getBalanceDueAmount()));
    }
  }, [summaryData, customAmount]);
  (0, import_react.useEffect)(() => {
    var _a2;
    const nonWalletPassAmount = ((_a2 = paymentItems == null ? void 0 : paymentItems.reduce((acc, item) => {
      if (!item.voucher_id || item.voucher_id && item.isSynced) {
        let itemAmount = new import_decimal.default(item.amount || "0");
        if (item.rounding_amount) {
          const roundingAmount = new import_decimal.default(item.rounding_amount);
          if (roundingAmount.isNegative()) {
            itemAmount = itemAmount.plus(roundingAmount.abs());
            console.log(
              "添加抹零金额到已付:",
              roundingAmount.abs().toNumber(),
              "项目:",
              item
            );
          }
        }
        return acc.plus(itemAmount);
      }
      return acc;
    }, new import_decimal.default(0))) == null ? void 0 : _a2.toNumber()) || 0;
    setPartialPaidAmount(nonWalletPassAmount);
  }, [paymentItems]);
  const paymentOptions = [
    {
      key: "regular",
      label: /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("amount-summary-dropdown-option") }, /* @__PURE__ */ import_react2.default.createElement(import_icons.CheckCircleOutlined, { className: (0, import_classnames.default)("dropdown-icon") }), getText("regular.payment") || "普通支付")
    },
    {
      key: "deposit",
      label: /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("amount-summary-dropdown-option") }, /* @__PURE__ */ import_react2.default.createElement(import_icons.PieChartOutlined, { className: (0, import_classnames.default)("dropdown-icon") }), getText("deposit.payment") || "定金支付")
    }
    // Bond Collection选项暂时隐藏
  ];
  const handlePaymentTypeChange = (key) => {
    const newPaymentType = key;
    setPaymentType(newPaymentType);
    if (onDepositStatusChange) {
      onDepositStatusChange(newPaymentType === "deposit");
    }
  };
  const resolveDropdownContainer = (0, import_react.useCallback)((triggerNode) => {
    return (triggerNode == null ? void 0 : triggerNode.parentElement) || document.body;
  }, []);
  const getWalletTotalAmount = () => {
    if (!(walletPassData == null ? void 0 : walletPassData.selectedWallet) || !Array.isArray(walletPassData.selectedWallet)) {
      return 0;
    }
    const totalDecimal = walletPassData.selectedWallet.reduce(
      (totalDecimal2, wallet) => {
        try {
          const redeemDecimal = new import_decimal.default(wallet.redeem || "0");
          return totalDecimal2.plus(redeemDecimal);
        } catch {
          return totalDecimal2;
        }
      },
      new import_decimal.default(0)
    );
    return totalDecimal.toNumber();
  };
  const getKeyboardLimits = () => {
    const orderDueDecimal = new import_decimal.default(Number(balanceDueAmount || 0));
    const minDecimal = new import_decimal.default(0.01);
    return {
      min: minDecimal.toNumber(),
      max: orderDueDecimal.toNumber()
    };
  };
  const _formatInputAmount = (value) => {
    try {
      const num = new import_decimal.default(value || "0");
      return num.toFixed(2);
    } catch {
      return value;
    }
  };
  const handleKeyboardConfirm = (value) => {
    const inputStr = String(value).trim();
    let numericValue;
    try {
      numericValue = new import_decimal.default(inputStr || "0").toNumber();
    } catch {
      numericValue = 0;
    }
    const limits = getKeyboardLimits();
    if (numericValue === 0) {
      Toast.fail(
        getText(
          "pisell2.amount-summary.amount-cannot-be-zero",
          "The amount cannot be 0"
        )
      );
      return;
    }
    const minDecimal = new import_decimal.default(limits.min);
    const maxDecimal = new import_decimal.default(limits.max);
    const valueDecimal = new import_decimal.default(numericValue);
    const clampedValue = import_decimal.default.min(
      import_decimal.default.max(valueDecimal, minDecimal),
      maxDecimal
    ).toNumber();
    const formattedValue = _formatInputAmount(String(clampedValue));
    setCurrentAmount(parseFormattedAmount(`$${formattedValue}`));
    if (onAmountChange) {
      onAmountChange(formattedValue);
    }
  };
  const handleMoreClick = async () => {
    setIsPaymentDetailOpen(true);
  };
  const handlePaymentDetailClose = () => {
    setIsPaymentDetailOpen(false);
  };
  const getPaymentButtonClassName = () => {
    const baseClass = open_deposit ? "payment-button-with-dropdown" : "payment-button-without-dropdown";
    const typeClass = paymentType === "deposit" ? "payment-button-deposit" : "payment-button-regular";
    return (0, import_classnames.default)(baseClass, typeClass);
  };
  const shouldShowPartialPaidCard = () => {
    var _a2;
    const partialPaidAmountDecimal = new import_decimal.default(partialPaidAmount || "0");
    const voucherPaymentAmount = ((_a2 = paymentItems == null ? void 0 : paymentItems.reduce((acc, item) => {
      if (item.voucher_id && !item.isSynced) {
        try {
          const amount = new import_decimal.default(item.amount || "0");
          const roundingAmount = new import_decimal.default(item.rounding_amount || "0");
          return acc.plus(amount).plus(roundingAmount);
        } catch {
          return acc;
        }
      }
      return acc;
    }, new import_decimal.default(0))) == null ? void 0 : _a2.toNumber()) || 0;
    const totalPaidAmount = partialPaidAmountDecimal.plus(voucherPaymentAmount).toNumber();
    const syncedPaymentItems = (paymentItems == null ? void 0 : paymentItems.filter((item) => item.isSynced && !item.voucher_id)) || [];
    if ((syncedPaymentItems == null ? void 0 : syncedPaymentItems.length) > 0 && totalPaidAmount < totalAmount) {
      return true;
    }
    if (totalPaidAmount >= totalAmount) {
      return false;
    }
    return partialPaidAmountDecimal.toNumber() > 0;
  };
  const renderSummaryItems = () => {
    if (!summaryData || summaryData.length === 0) {
      return null;
    }
    const maxVisibleItems = shouldShowPartialPaidCard() ? 2 : 3;
    const hasMoreItems2 = summaryData.length > maxVisibleItems;
    const visibleItems = hasMoreItems2 ? summaryData.slice(0, maxVisibleItems) : summaryData;
    return visibleItems.map((item) => {
      const displayLabel = item.label || labelMaps[item.key] || item.key;
      return /* @__PURE__ */ import_react2.default.createElement("div", { key: item.key, className: (0, import_classnames.default)("payment-detail-row") }, /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("payment-detail-label") }, displayLabel), /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("payment-detail-amount") }, (0, import_utils.formatAmountWithOptions)(item.value, amountSymbol, {
        precision: 2,
        hideDecimalForWholeNumbers: false,
        useThousandsSeparator: true,
        showCurrencySymbol: true
      })));
    });
  };
  const hasMoreItems = () => {
    if (!summaryData) return false;
    const maxVisibleItems = shouldShowPartialPaidCard() ? 2 : 3;
    return summaryData.length > maxVisibleItems;
  };
  const shouldShowConfirmMode = () => {
    var _a2;
    if (!customAmount) return false;
    let amount;
    try {
      amount = new import_decimal.default(customAmount).toNumber();
    } catch {
      return false;
    }
    if (amount <= 0) {
      const unSyncedPaymentItems = paymentItems == null ? void 0 : paymentItems.filter(
        (item) => !item.isSynced && item.status !== "paid"
      );
      const allItemsHaveVoucherId = unSyncedPaymentItems == null ? void 0 : unSyncedPaymentItems.every(
        (item) => item.voucher_id
      );
      const shouldShow = allItemsHaveVoucherId || (((_a2 = walletPassData == null ? void 0 : walletPassData.selectedDiscountList) == null ? void 0 : _a2.length) ?? 0) > 0;
      return shouldShow;
    }
    return false;
  };
  const { run: runConfirmDebounced } = (0, import_ahooks.useDebounceFn)(
    () => {
      if (onConfirm) onConfirm();
    },
    {
      wait: 500,
      leading: true,
      trailing: true
    }
  );
  const handleConfirmClick = () => {
    runConfirmDebounced();
  };
  const handleVoidPayment = async (paymentItem) => {
    var _a2, _b;
    console.log("Void payment:", paymentItem);
    await ((_b = baseSales == null ? void 0 : baseSales.deleteOrderPayment) == null ? void 0 : _b.call(
      baseSales,
      ((_a2 = paymentItem == null ? void 0 : paymentItem.metadata) == null ? void 0 : _a2.unique_payment_number) || paymentItem.uuid
    ));
    console.log("支付项已删除");
  };
  const renderConfirmMode = () => {
    let balanceDecimal = new import_decimal.default(0);
    const currentVoucherAmount = paymentItems == null ? void 0 : paymentItems.reduce((acc, item) => {
      if (item.voucher_id && !item.isSynced) {
        return acc.plus(item.amount);
      }
      return acc;
    }, new import_decimal.default(0)).toNumber();
    balanceDecimal = new import_decimal.default(Math.abs(balanceDecimal.plus(new import_decimal.default(0)).plus(currentVoucherAmount).toNumber()));
    const finalBalanceAmount = (0, import_utils.formatAmountWithOptions)(
      balanceDecimal.toNumber(),
      amountSymbol,
      {
        precision: 2,
        hideDecimalForWholeNumbers: false,
        useThousandsSeparator: true,
        showCurrencySymbol: true
      }
    );
    return /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("confirm-payment-container") }, /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("confirm-payment-content") }, /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("confirm-payment-text") }, getText("will.be.paid.in.full") || "Will be paid in full", " ", /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("amount-text") }, finalBalanceAmount), " ", getText("by.wallet") || "by Wallet"), /* @__PURE__ */ import_react2.default.createElement(
      import_antd.Button,
      {
        className: (0, import_classnames.default)("confirm-button"),
        onClick: handleConfirmClick,
        type: "primary"
      },
      getText("confirm") || "Confirm"
    )));
  };
  const getMiddleContent = () => {
    if (paymentType === "deposit") {
      return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("payment-details") }, shouldShowPartialPaidCard() && /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("partial-paid-card") }, /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("partial-paid-label") }, paymentType === "deposit" ? getText("deposit.partial.paid") || "Deposit Paid" : getText("partial.paid") || "Partial Paid"), /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("partial-paid-amount") }, (0, import_utils.formatAmountWithOptions)(partialPaidAmount, amountSymbol, {
        precision: 2,
        hideDecimalForWholeNumbers: false,
        useThousandsSeparator: true,
        showCurrencySymbol: true
      }))), renderSummaryItems(), hasMoreItems() && /* @__PURE__ */ import_react2.default.createElement(
        "div",
        {
          className: (0, import_classnames.default)("more-section"),
          onClick: handleMoreClick,
          style: { cursor: "pointer" },
          role: "button"
        },
        /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("more-text") }, getText("more") || "更多"),
        /* @__PURE__ */ import_react2.default.createElement(
          import_materials2.Iconfont,
          {
            type: "pisell2-TriangleFill",
            style: { fontSize: "12px" }
          }
        )
      )));
    } else {
      return /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("payment-details") }, shouldShowPartialPaidCard() && /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("partial-paid-card") }, /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("partial-paid-label") }, getText("partial.paid") || "Partial Paid"), /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("partial-paid-amount") }, (0, import_utils.formatAmountWithOptions)(partialPaidAmount, amountSymbol, {
        precision: 2,
        hideDecimalForWholeNumbers: false,
        useThousandsSeparator: true,
        showCurrencySymbol: true
      }))), renderSummaryItems(), hasMoreItems() && /* @__PURE__ */ import_react2.default.createElement(
        "div",
        {
          className: (0, import_classnames.default)("more-section"),
          onClick: handleMoreClick,
          style: { cursor: "pointer" },
          role: "button"
        },
        /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("more-text") }, getText("more") || "更多"),
        /* @__PURE__ */ import_react2.default.createElement(
          import_materials2.Iconfont,
          {
            type: "pisell2-TriangleFill",
            style: { fontSize: "24px", color: "#C3B2E7" }
          }
        )
      ));
    }
  };
  const canSwitch = (0, import_react.useMemo)(() => {
    if (Number(orderInfo == null ? void 0 : orderInfo.totalAmount) === 0) {
      return false;
    }
    if (paymentType === "regular") {
      const depositPaidAmount = paymentItems == null ? void 0 : paymentItems.reduce((acc, item) => {
        if (item.order_payment_type === "deposit") {
          return acc.plus(item.amount).plus(Number(item.rounding_amount) > 0 ? 0 : item.rounding_amount || 0);
        }
        return acc;
      }, new import_decimal.default(0)).toNumber();
      const depositFlag = depositPaidAmount >= new import_decimal.default((orderInfo == null ? void 0 : orderInfo.depositAmount) || "0").toNumber() && Number(orderInfo == null ? void 0 : orderInfo.depositAmount) > 0;
      return !(paymentItems == null ? void 0 : paymentItems.some((item) => item.order_payment_type === "normal")) && !depositFlag;
    } else {
      const depositPaidAmount = paymentItems == null ? void 0 : paymentItems.reduce((acc, item) => {
        if (item.order_payment_type === "deposit") {
          return acc.plus(item.amount).plus(Number(item.rounding_amount) > 0 ? 0 : item.rounding_amount || 0);
        }
        return acc;
      }, new import_decimal.default(0)).toNumber();
      return depositPaidAmount < new import_decimal.default(totalAmount).toNumber();
    }
  }, [paymentItems, paymentType, totalAmount]);
  const showCancelSplitPayment = (0, import_react.useMemo)(() => {
    return balanceDueAmount !== customAmount && Number(balanceDueAmount) > 0 && Number(customAmount) > 0;
  }, [customAmount, balanceDueAmount]);
  const handleChangeDepositAmount = async (value) => {
    var _a2, _b;
    const valueStr = String(value);
    console.log("handleChangeDepositAmount", valueStr);
    const tempOrder = (_a2 = baseSales == null ? void 0 : baseSales.getTempOrder) == null ? void 0 : _a2.call(baseSales);
    if (tempOrder) tempOrder.deposit_amount = valueStr;
    await ((_b = baseSales == null ? void 0 : baseSales.saveDraft) == null ? void 0 : _b.call(baseSales));
  };
  const hasDepositPayment = (0, import_react.useMemo)(() => {
    return paymentItems == null ? void 0 : paymentItems.some((item) => item.order_payment_type === "deposit" && item.status !== "voided");
  }, [paymentItems]);
  const showCanNotChangeDepositAmount = () => {
    Toast == null ? void 0 : Toast.fail(
      import_utils.locales.getText(
        "pisell2.checkout.can-not-change-deposit-amount"
      )
    );
  };
  return /* @__PURE__ */ import_react2.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)(
        "amount-summary-module",
        "amount-summary-container"
      )
    },
    /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("left-section") }, open_deposit && canSwitch ? /* @__PURE__ */ import_react2.default.createElement(
      import_antd.Dropdown,
      {
        menu: {
          items: paymentOptions,
          onClick: ({ key, domEvent }) => {
            domEvent.preventDefault();
            domEvent.stopPropagation();
            handlePaymentTypeChange(String(key));
          },
          style: {
            backgroundColor: "#7F56DA",
            border: "1px solid #C3B2E7",
            borderRadius: "8px",
            padding: "8px 16px"
          }
        },
        trigger: ["click"],
        placement: "bottomLeft",
        overlayClassName: "amount-summary-dropdown",
        getPopupContainer: resolveDropdownContainer
      },
      /* @__PURE__ */ import_react2.default.createElement(import_antd.Button, { className: getPaymentButtonClassName() }, /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("button-content") }, /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("button-text") }, paymentType === "deposit" ? getText("deposit.payment.short") || "定金\n支付" : getText("regular.payment.short") || "普通\n支付"), /* @__PURE__ */ import_react2.default.createElement(
        ChevronSelectorVertical,
        {
          style: { width: "36px", height: "36px" }
        }
      )))
    ) : /* @__PURE__ */ import_react2.default.createElement(import_antd.Button, { className: getPaymentButtonClassName() }, /* @__PURE__ */ import_react2.default.createElement("div", null, paymentType === "deposit" ? getText("deposit.text") || "定金" : getText("regular.text") || "普通"), /* @__PURE__ */ import_react2.default.createElement("div", null, getText("payment.text") || "支付")), /* @__PURE__ */ import_react2.default.createElement(import_materials2.Iconfont, { type: "pisell2-arrow-right", style: { fontSize: "20px" } })),
    /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("middle-section") }, getMiddleContent()),
    /* @__PURE__ */ import_react2.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)("balance-due-card", {
          "confirm-mode": shouldShowConfirmMode()
        })
      },
      // 如果应该显示确认模式，直接返回确认界面
      shouldShowConfirmMode() ? renderConfirmMode() : /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("balance-due-info") }, paymentType === "deposit" ? hasDepositPayment ? /* @__PURE__ */ import_react2.default.createElement("div", { onClick: () => showCanNotChangeDepositAmount() }, /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("balance-due-label") }, getText("deposit.due") || "Deposit Due"), /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("balance-due-amount") }, (0, import_utils.formatAmountWithOptions)(balanceDueAmount, amountSymbol, {
        precision: 2,
        hideDecimalForWholeNumbers: false,
        useThousandsSeparator: true,
        showCurrencySymbol: true
      }), /* @__PURE__ */ import_react2.default.createElement(
        import_icon.Edit05,
        {
          className: (0, import_classnames.default)("edit-icon"),
          style: { color: "#7F56DA" }
        }
      ))) : /* @__PURE__ */ import_react2.default.createElement(
        import_pisellSimplePriceKeyboardPopover.default,
        {
          value: balanceDueAmount || "0",
          onConfirm: handleChangeDepositAmount,
          showCurrencySymbol: true,
          useThousandsSeparator: true,
          selectType: "dark",
          overlayClassName: "cash-payment-keyboard-popover"
        },
        /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("balance-due-label") }, getText("deposit.due") || "Deposit Due"), /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("balance-due-amount") }, (0, import_utils.formatAmountWithOptions)(balanceDueAmount, amountSymbol, {
          precision: 2,
          hideDecimalForWholeNumbers: false,
          useThousandsSeparator: true,
          showCurrencySymbol: true
        }), /* @__PURE__ */ import_react2.default.createElement(
          import_icon.Edit05,
          {
            className: (0, import_classnames.default)("edit-icon"),
            style: { color: "#7F56DA" }
          }
        )))
      ) : /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("balance-due-label") }, getText("balance.due") || "Balance Due"), /* @__PURE__ */ import_react2.default.createElement("div", { className: (0, import_classnames.default)("balance-due-amount"), onClick: () => {
        onBalanceDueAmountClick == null ? void 0 : onBalanceDueAmountClick("manual-discount");
      } }, (0, import_utils.formatAmountWithOptions)(balanceDueAmount, amountSymbol, {
        precision: 2,
        hideDecimalForWholeNumbers: false,
        useThousandsSeparator: true,
        showCurrencySymbol: true
      }), /* @__PURE__ */ import_react2.default.createElement(
        import_icon.Edit05,
        {
          className: (0, import_classnames.default)("edit-icon"),
          style: { color: "#7F56DA" }
        }
      )))),
      Number(currentAmount) > 0 && /* @__PURE__ */ import_react2.default.createElement(
        "div",
        {
          className: (0, import_classnames.default)("pay-section"),
          style: { cursor: "pointer" },
          role: "button"
        },
        /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("pay-text") }, getText("pay") || "支付"),
        /* @__PURE__ */ import_react2.default.createElement("span", { className: (0, import_classnames.default)("pay-amount") }, (0, import_utils.formatAmountWithOptions)(
          (() => {
            try {
              return new import_decimal.default(currentAmount || "0").toNumber();
            } catch {
              return 0;
            }
          })(),
          amountSymbol,
          {
            precision: 2,
            hideDecimalForWholeNumbers: false,
            useThousandsSeparator: true,
            showCurrencySymbol: true
          }
        ))
      )
    ),
    /* @__PURE__ */ import_react2.default.createElement(
      import_materials.PisellModal,
      {
        open: isPaymentDetailOpen,
        onCancel: handlePaymentDetailClose,
        footer: null,
        closable: true,
        mask: true,
        maskClosable: true,
        centered: true,
        width: 600,
        wrapClassName: "payment-detail-modal-wrapper",
        title: getText("order.and.payment.summary") || "Order and Payment Summary"
      },
      isPaymentDetailOpen && /* @__PURE__ */ import_react2.default.createElement(
        import_PaymentDetailModal.default,
        {
          amountSymbol,
          orderInfo,
          cartData,
          onClose: handlePaymentDetailClose,
          summaryData,
          labelMaps,
          paymentItems,
          customAmount,
          voidPayment: handleVoidPayment,
          walletPassData,
          clientInfo
        }
      )
    )
  );
}
var AmountSummary_default = AmountSummary;
