/*
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 { Base, markType } from "igniteui-webcomponents-core";
import { isNaN_ } from "igniteui-webcomponents-core";
import { isDigit } from "igniteui-webcomponents-core";
import { stringIsNullOrEmpty } from "igniteui-webcomponents-core";
/**
 * @hidden
 */
export let NumericCellFormatter = /*@__PURE__*/ (() => {
    class NumericCellFormatter extends Base {
        static c() {
            if (NumericCellFormatter.a != null) {
                return NumericCellFormatter.a;
            }
            let a = "";
            let b = 1.1;
            let c = b.toLocaleString();
            let d = false;
            for (let e = 0; e < c.length; e++) {
                if (c.charAt(e) == '1') {
                    d = !d;
                }
                if (c.charAt(e) != '1' && d) {
                    a += c.charAt(e);
                }
            }
            NumericCellFormatter.a = a;
            return NumericCellFormatter.a;
        }
        static b(a) {
            if (a.ky != null) {
                return a.ky.i(a.k5);
            }
            let b = a.k5;
            let c = a.k5;
            let d = 10;
            let e = 0;
            let f = "0";
            if (isNaN_(a.k5)) {
                return "";
            }
            let g = 0;
            if (a.k5 >= 0) {
                g = a.k5 - Math.floor(a.k5);
            }
            else {
                g = Math.abs(a.k5 - Math.ceil(a.k5));
            }
            let h = 0;
            if (a.k5 >= 0) {
                h = a.k5 - g;
            }
            else {
                h = a.k5 + g;
            }
            let i = Math.abs(h);
            let j = g.toString();
            if (g == 0) {
                j = "";
            }
            else {
                j = j.substr(2);
            }
            let k = Math.round(i).toString();
            d = a.ld;
            e = a.lf;
            if (e < 0) {
                e = 0;
            }
            if (d < 0) {
                d = 10;
            }
            if (e > d) {
                d = e;
            }
            if (j.length > d) {
                let l = Math.round(g * (Math.pow(10, d))) / (Math.pow(10, d));
                j = (l).toString();
                if (l == 1) {
                    if (a.k5 >= 0) {
                        h += 1;
                        i += 1;
                    }
                    else {
                        h -= 1;
                        i += 1;
                    }
                    j = "";
                    k = Math.round(i).toString();
                }
                else if (l == 0) {
                    j = "";
                }
                else {
                    j = j.substr(2);
                }
            }
            let m = k.length;
            let n = Math.max(0, a.lh - k.length);
            let o = Math.max(0, a.lf - j.length);
            let p = false;
            if (k.charAt(0) == '1') {
                p = true;
            }
            for (let q = 0; q < n; q++) {
                let r = "0";
                if (a.k3) {
                    if (p) {
                        r = "9";
                    }
                    else {
                        r = "1";
                    }
                }
                k = r + k;
            }
            for (let s = 0; s < o; s++) {
                j = j + "0";
            }
            if (d == 0) {
                j = "";
            }
            if (a.k3 && k.length > 0) {
                let t = parseInt(k);
                let u = t.toLocaleString();
                let v = '1';
                if (p) {
                    v = '9';
                }
                let w = true;
                let x = "";
                for (let y = 0; y < u.length; y++) {
                    if (u.charAt(y) == v && w) {
                        x += "0";
                    }
                    else {
                        x += u.charAt(y);
                        if (isDigit(u.charAt(y)) && u.charAt(y) != v) {
                            w = false;
                        }
                    }
                }
                k = x;
            }
            if (h < 0) {
                k = "-" + k;
            }
            let z = k;
            if (j.length > 0) {
                z += NumericCellFormatter.c() + j;
            }
            if (b >= 0) {
                if (!stringIsNullOrEmpty(a.ma)) {
                    z = a.ma + z;
                }
                if (!stringIsNullOrEmpty(a.mc)) {
                    z += a.mc;
                }
            }
            else {
                if (!stringIsNullOrEmpty(a.l5)) {
                    z = a.l5 + z;
                }
                if (!stringIsNullOrEmpty(a.l7)) {
                    z += a.l7;
                }
            }
            return z;
        }
    }
    NumericCellFormatter.$t = /*@__PURE__*/ markType(NumericCellFormatter, 'NumericCellFormatter');
    NumericCellFormatter.a = null;
    return NumericCellFormatter;
})();
//# sourceMappingURL=NumericCellFormatter.js.map
