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/WalletPassModule/components/ConflictModal/index.tsx
var ConflictModal_exports = {};
__export(ConflictModal_exports, {
  TestModule: () => TestModule,
  default: () => ConflictModal_default
});
module.exports = __toCommonJS(ConflictModal_exports);
var import_react = __toESM(require("react"));
var import_materials = require("@pisell/materials");
var import_antd = require("antd");
var import_utils = require("../../utils");
var item1 = {
  id: 70652,
  shop_id: 9,
  customer_id: 9752,
  code: "785af187c3b74493",
  encoded: "VC5742851573",
  status: "partial_used",
  cover: "",
  tag: "product_voucher",
  relation_type: "product",
  product_id: 0,
  limit_status: "enable",
  sales_status: 1,
  par_value: "10.00",
  used_par_value: "9.00",
  start_date: "2025-08-26",
  expire_date: "2026-02-26",
  end_time: "16:05",
  start_time: "16:05",
  created_at: "2025-08-26 16:05:14",
  product_name: "$$10-代金券",
  expire_time: "2026-02-26 16:05:14",
  total_order_behavior_count: 1,
  today_order_behavior_count: 1,
  week_order_behavior_count: 1,
  month_order_behavior_count: 1,
  balance_par_value: "1.00",
  available_max_amount: "1.00",
  available_max_par_value: "1.00",
  custom_expire_status: 0,
  wallet_pass_usage_unit: {
    price: 1,
    points: 1
  },
  custom_order_deduct_exhausted: 0,
  available_product_status: 1,
  custom_invalid_product: 0,
  custom_order_wallet_pass_behavior_info: {
    is_success: true
  },
  available_product_ids: [61031],
  available_product_type: "product_all",
  available_num: 1,
  available_product_title: "",
  recommended_usage_par_value: "1.00",
  recommended_usage_amount: "1.00",
  unified_error_code: null,
  unified_available_status: 1,
  unified_messages: [],
  external_card: [],
  product: null,
  shop: {
    id: 9,
    name: "测试环境店铺09",
    default_url: "https://"
  },
  extension_data: []
};
var item2 = {
  id: 70648,
  shop_id: 9,
  customer_id: 9752,
  code: "64abd351b42cf85c",
  encoded: "VC6893431720",
  status: "used",
  cover: "",
  tag: "product_voucher",
  relation_type: "product",
  product_id: 0,
  limit_status: "enable",
  sales_status: 1,
  par_value: "10.00",
  used_par_value: "10.00",
  start_date: "2025-08-26",
  expire_date: "2026-02-26",
  end_time: "15:58",
  start_time: "15:58",
  created_at: "2025-08-26 15:58:54",
  product_name: "$$10-代金券",
  expire_time: "2026-02-26 15:58:54",
  total_order_behavior_count: 2,
  today_order_behavior_count: 2,
  week_order_behavior_count: 2,
  month_order_behavior_count: 2,
  balance_par_value: "0.00",
  available_max_amount: 0,
  available_max_par_value: "0.00",
  custom_expire_status: 0,
  wallet_pass_usage_unit: {
    price: 1,
    points: 1
  },
  custom_order_deduct_exhausted: 0,
  available_product_status: 1,
  custom_invalid_product: 0,
  custom_order_wallet_pass_behavior_info: {
    is_success: true
  },
  available_product_ids: [61031],
  available_product_type: "product_all",
  available_num: 1,
  available_product_title: "",
  recommended_usage_par_value: "0.00",
  recommended_usage_amount: 0,
  unified_error_code: "500100",
  unified_available_status: 0,
  unified_messages: {
    title: "代金券已使用！",
    desc: "带有此编号的代金券已被使用。",
    alert: "已使用"
  },
  external_card: [],
  product: null,
  shop: {
    id: 9,
    name: "测试环境店铺09",
    default_url: "https://"
  },
  extension_data: []
};
var TestModule = () => {
  const [show, setShow] = (0, import_react.useState)(false);
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { type: "primary", onClick: () => setShow(true) }, "show"), show && /* @__PURE__ */ import_react.default.createElement(
    ConflictModal,
    {
      currentItem: item1,
      newItem: item2,
      onCancel: () => setShow(false)
    }
  ));
};
var ConflictModal = (props) => {
  const { currentItem, newItem, onSwitch, onCancel, onSave } = props;
  const handleSwitch = () => {
    onSwitch(newItem);
  };
  const handleSave = () => {
    onSave == null ? void 0 : onSave(newItem);
  };
  const formatData = (item) => {
    var _a, _b;
    return {
      id: item.id,
      name: item.product_name,
      // storeName: item.shop?.name,
      balance: item.balance_par_value,
      redeem: (0, import_utils.getAvailableMaxAmount)(item),
      showRedeem: true,
      showStoreName: false,
      showBalanceSymbol: item.tag !== "point_card",
      // balanceTitle: item.tag !== 'point_card' ? "" : "",
      // redeemTitle: item.tag !== 'point_card' ? "" : "",
      showDetail: false,
      showQrCode: false,
      code: item.code,
      disabled: !item.unified_available_status,
      disabledReason: (_a = item.unified_messages) == null ? void 0 : _a.title,
      cover: (_b = item.product) == null ? void 0 : _b.cover,
      qrCode: item.code,
      validDate: (0, import_utils.voucherTime)(item),
      originData: item
    };
  };
  const oldVoucher = /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", null, "Previously Applied"), /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellWalletPassCard,
    {
      ...formatData(currentItem),
      type: "mini",
      style: {
        borderColor: "#7F56DA"
      }
    }
  ));
  const newVoucher = /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement("div", null, "New Voucher"), /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellWalletPassCard,
    {
      ...formatData(newItem),
      type: "mini",
      style: {
        borderColor: "#7F56DA"
      }
    }
  ));
  return /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellModal,
    {
      width: 680,
      open: true,
      platform: "pc",
      title: "Switch Voucher",
      onCancel,
      headerDivider: false,
      footerDivider: false,
      footer: /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          style: {
            display: "flex",
            alignItems: "center",
            justifyContent: "space-between",
            width: "100%"
          }
        },
        /* @__PURE__ */ import_react.default.createElement(
          "div",
          {
            style: {
              display: "flex",
              alignItems: "center",
              gap: 16
            }
          },
          /* @__PURE__ */ import_react.default.createElement(
            import_antd.Button,
            {
              style: {
                width: 150,
                height: 48,
                fontWeight: 600,
                color: "#7F56DA",
                border: "2px solid #7F56DA"
              },
              onClick: onCancel
            },
            "Cancel"
          ),
          /* @__PURE__ */ import_react.default.createElement(
            import_antd.Button,
            {
              style: {
                width: 150,
                height: 48,
                fontWeight: 600,
                color: "#7F56DA",
                border: "2px solid #7F56DA"
              },
              onClick: handleSave
            },
            "Cancel & Save to Wallet"
          )
        ),
        /* @__PURE__ */ import_react.default.createElement(
          import_antd.Button,
          {
            type: "primary",
            style: { width: 240, height: 48 },
            onClick: handleSwitch
          },
          "Switch Voucher"
        )
      )
    },
    /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        style: {
          display: "flex",
          flexWrap: "nowrap",
          alignItems: "center",
          justifyContent: "space-between"
        }
      },
      oldVoucher,
      /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          style: {
            border: "2px solid #7F56DA",
            width: 24,
            height: 24,
            borderRadius: 12,
            display: "flex",
            alignItems: "center",
            justifyContent: "center"
          }
        },
        /* @__PURE__ */ import_react.default.createElement(
          import_materials.Iconfont,
          {
            type: "pisell2-arrow-right",
            style: { transform: "scale(1.3)", color: "#7F56DA" }
          }
        )
      ),
      newVoucher
    )
  );
};
var ConflictModal_default = ConflictModal;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  TestModule
});
