/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { __extends } from "tslib";
import { Base, markType } from "igniteui-angular-core";
import { INumberAbbreviator_$type } from "./INumberAbbreviator";
import { MathUtil } from "igniteui-angular-core";
import { round10N } from "igniteui-angular-core";
/**
 * @hidden
 */
var NumberAbbreviator = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(NumberAbbreviator, _super);
    function NumberAbbreviator() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    NumberAbbreviator.prototype.abbreviate = function (a, b) {
        var c = Math.abs(a);
        var d = ['Q', 'T', 'B', 'M', 'K'];
        var e = [1E+15, 1000000000000, 1000000000, 1000000, 1000];
        for (var f = 0; f < d.length; f++) {
            if (c >= e[f]) {
                if (b != null) {
                    var g = b(round10N(a / e[f], 1), true);
                    if (g != null) {
                        return g.toString() + d[f];
                    }
                }
                return round10N(a / e[f], 1).toString() + d[f];
            }
        }
        if (b != null) {
            var h = b(a, false);
            if (h != null) {
                return h.toString();
            }
        }
        return MathUtil.r(a);
    };
    NumberAbbreviator.$t = markType(NumberAbbreviator, 'NumberAbbreviator', Base.$, [INumberAbbreviator_$type]);
    return NumberAbbreviator;
}(Base));
export { NumberAbbreviator };
