"use strict";

function numberAddSeparators(str, thousandsSep, decimalSep) {
    const strArr = (str += "").split(".");
    let str1 = strArr[0];
    const str2 = strArr.length > 1 ? decimalSep + strArr[1] : "";
    return str1 = numFormat(str1, thousandsSep), str1 + str2;
}

function numFormat(num, thousandsSep) {
    return num.replace(/\d+/, (function(n) {
        return n.replace(/(\d)(?=(\d{3})+$)/g, (function($1) {
            return `${$1}${thousandsSep}`;
        }));
    }));
}

function numberFormat(option) {
    return option = Object.assign({}, {
        digitsAfterDecimal: 2,
        scaler: 1,
        thousandsSep: ",",
        decimalSep: ".",
        prefix: "",
        suffix: ""
    }, option), function(num) {
        if (isNaN(num) || !isFinite(num)) return "";
        const result = numberAddSeparators((option.scaler * num).toFixed(option.digitsAfterDecimal), option.thousandsSep, option.decimalSep);
        return `${option.prefix}${result}${option.suffix}`;
    };
}

function dateFormat(baseField, formatString, utcOutput, mthNames, dayNames) {
    null == utcOutput && (utcOutput = !1), null == mthNames && (mthNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]), 
    null == dayNames && (dayNames = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]);
    const utc = utcOutput ? "UTC" : "", zeroPad = function(number) {
        return `0${number}`.substring(0, 2);
    };
    return function(record) {
        const date = new Date(Date.parse(record[baseField]));
        return formatString.replace(/%(.)/g, (function(m, p) {
            switch (p) {
              case "y":
                return date[`get${utc}FullYear`]();

              case "m":
                return zeroPad(date[`get${utc}Month`]() + 1);

              case "n":
                return mthNames[date[`get${utc}Month`]()];

              case "d":
                return zeroPad(date[`get${utc}Date`]());

              case "w":
                return dayNames[date[`get${utc}Day`]()];

              case "x":
                return date[`get${utc}Day`]();

              case "H":
                return zeroPad(date[`get${utc}Hours`]());

              case "M":
                return zeroPad(date[`get${utc}Minutes`]());

              case "S":
                return zeroPad(date[`get${utc}Seconds`]());

              default:
                return `%${p}`;
            }
        }));
    };
}

Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.dateFormat = exports.numberFormat = void 0, exports.numberFormat = numberFormat, 
exports.dateFormat = dateFormat;