"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 RENDERER_TYPE () {
        return RENDERER_TYPE;
    },
    get numericRenderer () {
        return numericRenderer;
    },
    get valueFormatter () {
        return valueFormatter;
    }
});
const _textRenderer = require("../textRenderer");
const _number = require("../../helpers/number");
const _console = require("../../helpers/console");
const _utils = require("./utils");
const RENDERER_TYPE = 'numeric';
const deprecatedMessageShown = new WeakSet();
function valueFormatter(value, cellProperties) {
    if ((0, _number.isNumeric)(value)) {
        if ((0, _utils.isNumbroScheme)(cellProperties)) {
            value = (0, _utils.numbroFormatter)(value, cellProperties);
        } else {
            value = (0, _utils.intlFormatter)(value, cellProperties);
        }
    }
    return value;
}
function numericRenderer(hotInstance, TD, row, col, prop, value, cellProperties) {
    const isNumbroFormat = (0, _utils.isNumbroScheme)(cellProperties);
    if (isNumbroFormat && !deprecatedMessageShown.has(cellProperties.instance)) {
        deprecatedMessageShown.add(cellProperties.instance);
        (0, _console.deprecatedWarn)('The `numericFormat.pattern` and `numericFormat.culture` options are deprecated ' + 'and will be removed in the next major release. Pass `Intl.NumberFormat` options ' + 'directly to `numericFormat` and use the `locale` cell property instead of `culture`.\n\n' + 'Migration guide: https://handsontable.com/docs/migration-from-16.2-to-17.0/\n' + '`numericFormat` documentation: https://handsontable.com/docs/api/options/#numericformat\n' + '`locale` documentation: https://handsontable.com/docs/api/options/#locale');
    }
    if ((0, _number.isNumeric)(hotInstance.getDataAtCell(row, col))) {
        let classArr = [];
        if (Array.isArray(cellProperties.className)) {
            classArr = cellProperties.className;
        } else {
            const className = cellProperties.className ?? '';
            if (className.length) {
                classArr = className.split(' ');
            }
        }
        if (classArr.indexOf('htLeft') < 0 && classArr.indexOf('htCenter') < 0 && classArr.indexOf('htRight') < 0 && classArr.indexOf('htJustify') < 0) {
            classArr.push('htRight');
        }
        if (classArr.indexOf('htNumeric') < 0) {
            classArr.push('htNumeric');
        }
        cellProperties.className = classArr.join(' ');
        TD.dir = 'ltr';
    }
    _textRenderer.textRenderer.apply(this, [
        hotInstance,
        TD,
        row,
        col,
        prop,
        value,
        cellProperties
    ]);
}
numericRenderer.valueFormatter = valueFormatter;
numericRenderer.RENDERER_TYPE = RENDERER_TYPE;
