"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sumTotalsDollarColoredFormatter = void 0;
const utils_1 = require("@slickgrid-universal/utils");
const formatterUtilities_js_1 = require("../formatters/formatterUtilities.js");
const index_js_1 = require("../services/index.js");
const sumTotalsDollarColoredFormatter = (totals, columnDef, grid) => {
    const field = columnDef.field ?? '';
    const val = totals.sum?.[field];
    const params = columnDef?.params;
    const prefix = params?.groupFormatterPrefix || '';
    const suffix = params?.groupFormatterSuffix || '';
    const { minDecimal, maxDecimal, decimalSeparator, thousandSeparator, wrapNegativeNumber } = (0, formatterUtilities_js_1.retrieveFormatterOptions)(columnDef, grid, 'currency', 'group');
    if ((0, utils_1.isNumber)(val)) {
        const colorStyle = val >= 0 ? 'green' : 'red';
        const formattedNumber = (0, index_js_1.formatNumber)(val, minDecimal, maxDecimal, wrapNegativeNumber, '$', '', decimalSeparator, thousandSeparator);
        return (0, utils_1.createDomElement)('span', { style: { color: colorStyle }, textContent: `${prefix}${formattedNumber}${suffix}` });
    }
    return '';
};
exports.sumTotalsDollarColoredFormatter = sumTotalsDollarColoredFormatter;
//# sourceMappingURL=sumTotalsDollarColoredFormatter.js.map