export var paymentResultPresets = {
  paid: {
    titleKey: 'payment.result.success',
    fallbackTitle: 'Payment Successful',
    subtitleMode: 'paid',
    colorClass: 'paid',
    statusClassName: 'success',
    autoClose: true,
    maskClosable: false
  },
  partially_paid: {
    titleKey: 'payment.result.success',
    fallbackTitle: 'Payment Successful',
    subtitleMode: 'partial',
    colorClass: 'partially-paid',
    statusClassName: 'success',
    autoClose: true,
    maskClosable: false
  },
  deposit_paid: {
    titleKey: 'payment.result.success',
    fallbackTitle: 'Payment Successful',
    subtitleMode: 'deposit',
    colorClass: 'paid',
    statusClassName: 'success',
    autoClose: true,
    maskClosable: false
  },
  failed: {
    titleKey: 'payment.result.failed',
    fallbackTitle: 'Payment Failed',
    subtitleMode: 'amount_due',
    colorClass: 'amount-due',
    statusClassName: 'failed',
    autoClose: false,
    maskClosable: false
  },
  'wallet-pass-redemption-failed': {
    titleKey: 'pisell2.checkout.wallet-pass.redemption-failed',
    fallbackTitle: 'Wallet pass redeem failed',
    subtitleMode: 'wallet_pass_partial',
    colorClass: 'partially-paid',
    statusClassName: 'wallet-pass-failed',
    autoClose: false,
    maskClosable: false
  }
};
export function getPaymentResultKind(paymentStatus, resultKind) {
  if (resultKind) return resultKind;
  if (!paymentStatus) return null;
  if (paymentStatus === 'error') return 'failed';
  if (paymentStatus in paymentResultPresets) {
    return paymentStatus;
  }
  return 'paid';
}
export function getPaymentResultPreset(paymentStatus, resultKind) {
  var kind = getPaymentResultKind(paymentStatus, resultKind) || 'paid';
  return paymentResultPresets[kind];
}
export function buildPaymentResultToastParams(_ref) {
  var paymentStatus = _ref.paymentStatus,
    resultKind = _ref.resultKind,
    orderTotalAmount = _ref.orderTotalAmount,
    gapAmount = _ref.gapAmount,
    depositAmount = _ref.depositAmount,
    changeGivenAmount = _ref.changeGivenAmount,
    failureReason = _ref.failureReason,
    isModalMode = _ref.isModalMode;
  var resolvedKind = getPaymentResultKind(paymentStatus, resultKind);
  if (!resolvedKind) return null;
  var preset = paymentResultPresets[resolvedKind];
  var autoCloseConfig = {
    autoClose: preset.autoClose,
    autoCloseDelay: 30,
    maskClosable: preset.maskClosable
  };
  if (isModalMode) {
    autoCloseConfig.autoClose = false;
    autoCloseConfig.autoCloseDelay = 0;
    autoCloseConfig.maskClosable = false;
  }
  return {
    resultKind: resolvedKind,
    statusClassName: preset.statusClassName,
    paymentStatus: paymentStatus || resolvedKind,
    orderTotalAmount: Number(orderTotalAmount || 0),
    depositAmount: Number(depositAmount || 0),
    changeGivenAmount: Number(changeGivenAmount || 0),
    gapAmount: resolvedKind === 'partially_paid' ? Number(gapAmount || 0) : Number(changeGivenAmount || 0),
    failureReason: failureReason,
    autoCloseConfig: autoCloseConfig
  };
}