/*
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 * as tslib_1 from "tslib";
import { Snapper } from "./Snapper";
import { markType } from "igniteui-react-core";
import { truncate, log10 } from "igniteui-react-core";
/**
 * @hidden
 */
var LinearNumericSnapper = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(LinearNumericSnapper, _super);
    function LinearNumericSnapper(a) {
        var _rest = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            _rest[_i - 1] = arguments[_i];
        }
        var _this = _super.call(this) || this;
        _this.g = 0;
        _this.j = 0;
        _this.i = 0;
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0:
                {
                    var c = _rest[0];
                    var d = _rest[1];
                    var e = _rest[2];
                    var f = _rest[3];
                    if (f > 0) {
                        _this.f = f;
                        _this.b = true;
                    }
                    _this.k(c, d, e, 10);
                }
                break;
            case 1:
                {
                    var c = _rest[0];
                    var d = _rest[1];
                    var e = _rest[2];
                    var f = _rest[3];
                    var g = _rest[4];
                    if (g > 0) {
                        _this.f = g;
                        _this.b = true;
                    }
                    _this.k(c, d, e, f);
                }
                break;
        }
        return _this;
    }
    LinearNumericSnapper.prototype.k = function (a, b, c, d) {
        this.g = NaN;
        this.j = 0;
        this.i = 0;
        var e = 0;
        if (c < 100) {
            e = 4;
        }
        else {
            e = Math.min(d, truncate((c / this.f)));
        }
        if (e > 0) {
            var f = this.h(a, b, e);
            if (this.b && f > e) {
                this.g = NaN;
                f = this.h(a, b, e - 1);
            }
            e = f;
            if (c / e > this.f * 10) {
                this.i = 10;
            }
            else {
                if (c / e > this.f * 5) {
                    this.i = 5;
                }
                else {
                    if (c / e > this.f * 2) {
                        this.i = 2;
                    }
                }
            }
            this.j = Math.max(-truncate(Math.floor(log10(this.g))), 0);
        }
    };
    LinearNumericSnapper.prototype.h = function (a, b, c) {
        var d = Snapper.e(b - a, false);
        var e = Math.max(1, c - 1);
        this.g = Snapper.e(d / e, true);
        var f = Math.floor(a / this.g) * this.g;
        var g = Math.ceil(b / this.g) * this.g;
        var h = truncate(Math.round((g - f) / this.g));
        return h;
    };
    LinearNumericSnapper.$t = markType(LinearNumericSnapper, 'LinearNumericSnapper', Snapper.$);
    return LinearNumericSnapper;
}(Snapper));
export { LinearNumericSnapper };
//# sourceMappingURL=LinearNumericSnapper.js.map
