var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/eftposPay/tyro/const.tsx
var const_exports = {};
__export(const_exports, {
  default: () => const_default,
  getAmonunt: () => getAmonunt
});
module.exports = __toCommonJS(const_exports);
var import_utils = require("@pisell/utils");
var import_const = require("../const");
var const_default = (params) => {
  const {
    order_id,
    name,
    symbol,
    amount,
    mode,
    number,
    pay,
    device,
    net,
    client,
    ...other
  } = params || {
    mode: import_const.ModeEnum.Pay
  };
  return {
    name,
    symbol,
    amount,
    order_id,
    mode,
    eftpos: import_const.EftposEnum.Tyro,
    key: Date.now(),
    warn: "",
    step: 0,
    type: import_const.PayRouteEnum.Step,
    title: import_utils.locales.getText("page.eftpos-pay.text.loading")(mode),
    component: "",
    status: import_const.StatusEnum.Loading,
    steps: [],
    render: true,
    client: client !== "undefined" ? client : import_const.ClientEnum.Merchant,
    custom: other || {},
    ...typeof net !== "undefined" ? { net } : {},
    ...typeof number !== "undefined" ? { number } : {},
    ...typeof pay !== "undefined" ? { pay } : {},
    ...typeof device !== "undefined" ? { device } : {}
  };
};
function getAmonunt(store) {
  const { device, pay, custom, name, symbol, amount } = store;
  if (!device || !custom) {
    throw Error("device or custom is not defined");
  }
  const setting = device.setting;
  if (pay) {
    return {
      name,
      symbol,
      money: Number(amount),
      amount: Number(pay.amount),
      surRate: Number(pay.surRate),
      surMoney: Number(pay.surMoney),
      surcharge: (setting == null ? void 0 : setting.surcharge) || false,
      useOriginSurcharge: (pay == null ? void 0 : pay.useOriginSurcharge) || false
    };
  }
  if (!setting) {
    return {
      name,
      symbol,
      money: Number(amount),
      amount: Number(amount),
      surRate: 0,
      surMoney: 0,
      surcharge: false,
      useOriginSurcharge: false
    };
  }
  const useOriginSurcharge = setting.useOriginSurcharge || false;
  const surRate = setting.constant_rate || 0;
  const surMoney = setting.constant_money || 0;
  const surcharge = setting.surcharge;
  return {
    name,
    symbol,
    money: Number(amount),
    amount: Number(amount),
    surRate: useOriginSurcharge ? 0 : surcharge ? surRate : 0,
    surMoney: useOriginSurcharge ? 0 : surcharge ? surMoney : 0,
    surcharge,
    useOriginSurcharge
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  getAmonunt
});
