"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get intlFormatter () {
        return intlFormatter;
    },
    get isNumbroScheme () {
        return isNumbroScheme;
    },
    get numbroFormatter () {
        return numbroFormatter;
    }
});
const _numbro = /*#__PURE__*/ _interop_require_default(require("numbro"));
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
const DEFAULT_INTL_FORMAT = {
    useGrouping: false,
    maximumFractionDigits: 20
};
function numbroFormatter(value, cellProperties) {
    const { numericFormat } = cellProperties;
    const cellCulture = numericFormat && numericFormat.culture || '-';
    const cellFormatPattern = numericFormat && numericFormat.pattern;
    if (typeof cellCulture !== 'undefined' && !_numbro.default.languages()[cellCulture]) {
        const shortTag = cellCulture.replace('-', '');
        const langData = _numbro.default.allLanguages ? _numbro.default.allLanguages[cellCulture] : _numbro.default[shortTag];
        if (langData) {
            _numbro.default.registerLanguage(langData);
        }
    }
    _numbro.default.setLanguage(cellCulture);
    return (0, _numbro.default)(value).format(cellFormatPattern || '0');
}
function intlFormatter(value, cellProperties) {
    const { numericFormat, locale } = cellProperties;
    return new Intl.NumberFormat(locale, numericFormat ?? DEFAULT_INTL_FORMAT).format(value);
}
function isNumbroScheme(cellProperties) {
    const { numericFormat } = cellProperties;
    return numericFormat?.pattern !== undefined || numericFormat?.culture !== undefined;
}
