/*
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 { BrushScale } from "./BrushScale";
import { DependencyProperty } from "igniteui-angular-core";
import { typeGetValue, markType, markDep } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_, isInfinity, logBase } from "igniteui-angular-core";
/**
 * @hidden
 */
var ValueBrushScale = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ValueBrushScale, _super);
    function ValueBrushScale() {
        var _this = _super.call(this) || this;
        _this.ab = false;
        _this.af = 10;
        return _this;
    }
    ValueBrushScale.prototype.getBrushByIndex = function (a, b) {
        if (b == null || this.brushes == null || this.brushes.count == 0 || a < 0 || a >= b.count) {
            return null;
        }
        if (b.count == 0) {
            return this.brushes.item(0);
        }
        var c = isNaN_(this.minimumValue) || isInfinity(this.minimumValue) ? b.minimum : this.minimumValue;
        var d = isNaN_(this.maximumValue) || isInfinity(this.maximumValue) ? b.maximum : this.maximumValue;
        var e = b.item(a);
        if (c == d) {
            return e == c ? this.brushes.item(0) : null;
        }
        return this.at(c, d, e);
    };
    ValueBrushScale.prototype.getBrushByValue = function (a, b) {
        if (b == null || this.brushes == null || this.brushes.count == 0) {
            return null;
        }
        if (b.count <= 1) {
            return this.brushes.item(0);
        }
        var c = isNaN_(this.minimumValue) || isInfinity(this.minimumValue) ? b.minimum : this.minimumValue;
        var d = isNaN_(this.maximumValue) || isInfinity(this.maximumValue) ? b.maximum : this.maximumValue;
        if (a < c) {
            return null;
        }
        if (a > d) {
            return null;
        }
        return this.at(c, d, a);
    };
    ValueBrushScale.prototype.getBrushByRange = function (a, b, c) {
        if (this.brushes == null || this.brushes.count == 0 || isNaN_(a)) {
            return null;
        }
        if (this.brushes.count == 1) {
            return this.brushes.item(0);
        }
        var d = isNaN_(this.minimumValue) || isInfinity(this.minimumValue) ? b : this.minimumValue;
        var e = isNaN_(this.maximumValue) || isInfinity(this.maximumValue) ? c : this.maximumValue;
        if (isNaN_(d) || a < d) {
            return null;
        }
        if (isNaN_(e) || a > e) {
            return null;
        }
        return this.at(d, e, a);
    };
    ValueBrushScale.prototype.at = function (a, b, c) {
        if (this.ab && this.af > 0) {
            var d = logBase(a, this.af);
            var e = logBase(b, this.af);
            var f = logBase(c, this.af);
            return this.as(d, e, f);
        }
        return this.as(a, b, c);
    };
    ValueBrushScale.prototype.as = function (a, b, c) {
        if (c < a || c > b) {
            return null;
        }
        var d = (c - a) / (b - a);
        var e = d * (this.brushes.count - 1);
        return this.aa(e);
    };
    ValueBrushScale.prototype.get_isReady = function () {
        return this.brushes != null && this.brushes.count > 0;
    };
    ValueBrushScale.prototype.t = function (a, b, c, d) {
        switch (b) {
            case ValueBrushScale.$$p[1]:
                this.af = typeGetValue(d);
                break;
            case ValueBrushScale.$$p[0]:
                this.ab = d;
                break;
        }
        _super.prototype.t.call(this, a, b, c, d);
    };
    ValueBrushScale.$t = markType(ValueBrushScale, 'ValueBrushScale', BrushScale.$);
    ValueBrushScale.$$p = markDep(DependencyProperty, PropertyMetadata, ValueBrushScale, 'u', ['IsLogarithmic', [0, false], 'LogarithmBase', [1, 10], 'MaximumValue', [1, NaN], 'MinimumValue', [1, NaN]]);
    return ValueBrushScale;
}(BrushScale));
export { ValueBrushScale };
//# sourceMappingURL=ValueBrushScale.js.map
