"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.formatValues = void 0;
var _getCardConfig = require("./getCardConfig");
var _getCardType = require("./getCardType");
var _formatExpire = require("../../../helpers/formatExpire");
const PARSER = [/[^\d]/g, ''];
const formatValues = function () {
  let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  let cards = arguments.length > 1 ? arguments[1] : undefined;
  let {
    card = '',
    CVV = '',
    expire = '',
    name = ''
  } = values;
  card = card.replace(...PARSER);
  CVV = CVV.replace(...PARSER);
  expire = (0, _formatExpire.formatExpire)(expire);
  name = name.toUpperCase();
  const {
    placeholder = {}
  } = (0, _getCardConfig.getCardConfig)(card);
  const cardArray = card ? [...card] : [];
  card = [...placeholder.card].map(function () {
    let char = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
    return char === ' ' ? char : cardArray.length >= 0 ? cardArray.shift() : '';
  }).join('').trimEnd();
  return {
    card,
    CVV,
    expire,
    name,
    type: (0, _getCardType.getCardType)(card, cards)
  };
};
exports.formatValues = formatValues;
//# sourceMappingURL=formatValues.js.map