/*
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 { AnchoredCategorySeries } from "./AnchoredCategorySeries";
import { NumericXAxis } from "./NumericXAxis";
import { DependencyProperty } from "igniteui-angular-core";
import { CategoryYAxis } from "./CategoryYAxis";
import { IVerticalAnchoredCategorySeriesInteractionManager_$type } from "./IVerticalAnchoredCategorySeriesInteractionManager";
import { DVContainer } from "igniteui-angular-core";
import { runOn, typeCast, EnumUtil, markType, markDep } from "igniteui-angular-core";
import { Axis } from "./Axis";
import { ScalerParams } from "./ScalerParams";
import { AxisRange } from "./AxisRange";
import { Rect } from "igniteui-angular-core";
import { TrendLineType_$type } from "igniteui-angular-core";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
import { PropertyMetadata } from "igniteui-angular-core";
import { truncate, isNaN_, isInfinity } from "igniteui-angular-core";
/**
 * @hidden
 */
var VerticalAnchoredCategorySeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(VerticalAnchoredCategorySeries, _super);
    function VerticalAnchoredCategorySeries() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.uo = null;
        return _this;
    }
    VerticalAnchoredCategorySeries.prototype.bv = function () {
        if (this.xAxis != null && this.xAxis.cg) {
            return 4;
        }
        return 3;
    };
    VerticalAnchoredCategorySeries.prototype.bw = function () {
        return 1;
    };
    VerticalAnchoredCategorySeries.prototype.ku = function () {
        _super.prototype.ku.call(this);
        this.xAxis = null;
        this.yAxis = null;
    };
    Object.defineProperty(VerticalAnchoredCategorySeries.prototype, "up", {
        get: function () {
            var _this = this;
            if (this.uo == null) {
                this.uo = DVContainer.instance.createInstance(IVerticalAnchoredCategorySeriesInteractionManager_$type, function () { return _this.cn.n; });
            }
            return this.uo;
        },
        enumerable: false,
        configurable: true
    });
    VerticalAnchoredCategorySeries.prototype.get_isVertical = function () {
        return true;
    };
    VerticalAnchoredCategorySeries.prototype.rn = function () {
        return this.yAxis;
    };
    VerticalAnchoredCategorySeries.prototype.r8 = function () {
        return this.xAxis;
    };
    VerticalAnchoredCategorySeries.prototype.getOffsetValue = function () {
        return this.rt.r(this.rn(), this.b0.bv, this.b0.bu, this.getEffectiveViewport1(this.b0));
    };
    VerticalAnchoredCategorySeries.prototype.getCategoryWidth = function () {
        return this.yAxis.getCategorySize(this.b0.bv, this.b0.bu, this.getEffectiveViewport1(this.b0));
    };
    VerticalAnchoredCategorySeries.prototype.hh = function (a, b) {
        return this.hi(a, b, this.rn(), runOn(this, this.sm), this.valueColumn);
    };
    VerticalAnchoredCategorySeries.prototype.hj = function (a, b) {
        return this.hk(a, b, this.rn(), runOn(this, this.sm), this.valueColumn);
    };
    VerticalAnchoredCategorySeries.prototype.f3 = function (a, b, c, d, e) {
        if (this.valueColumn == null) {
            return Number.POSITIVE_INFINITY;
        }
        return this.f4(a, b, this.yAxis, d, e, this.valueColumn.count, runOn(this, this.sm));
    };
    VerticalAnchoredCategorySeries.prototype.aq = function (a) {
        if (a.isEmpty && this.cd != null) {
            a = this.cd.sf;
        }
        if (this.valueColumn == null) {
            return null;
        }
        var b = this.pq(this.b0);
        var c = this.rn();
        var d = new ScalerParams(0, a, this.cd.su, c.cg, this.getEffectiveViewport());
        var e = (c.el(b.top, d));
        var f = (c.el(b.bottom, d));
        if (!c.cg) {
            var g = e;
            e = f;
            f = g;
        }
        e -= this.tr;
        f += this.tr;
        var h = null;
        if (c.cm) {
            h = c;
            e = h.i$f(e);
            f = h.i$f(f);
        }
        else {
            e = Math.floor(e);
            f = Math.ceil(f);
        }
        if (isNaN_(e) || isNaN_(f)) {
            return null;
        }
        e = Math.max(0, Math.min(this.valueColumn.count - 1, e));
        f = Math.max(0, Math.min(this.valueColumn.count - 1, f));
        var i = 1.7976931348623157E+308;
        var j = -1.7976931348623157E+308;
        if (truncate(e) <= truncate(f)) {
            for (var k = truncate(e); k <= truncate(f); k++) {
                var l = k;
                if (h != null) {
                    l = h.i$b._inner[k];
                }
                var m = this.valueColumn.item(l);
                if (this.valueColumn.mayContainUnknowns) {
                    if (isInfinity(m) || isNaN_(m)) {
                        continue;
                    }
                }
                i = Math.min(i, m);
                j = Math.max(j, m);
            }
        }
        var n = new AxisRange(i, j);
        n = this.ao(n, this.r8(), a);
        return n;
    };
    VerticalAnchoredCategorySeries.prototype.bp = function () {
        if (this.bq == 0) {
            return 1;
        }
        else {
            return _super.prototype.bp.call(this);
        }
    };
    VerticalAnchoredCategorySeries.prototype.pw = function (a) {
        if (!this.hasMarkers || !this.qe()) {
            return Rect.empty;
        }
        return this.up.e$b(this, this.ro.m, a, runOn(this, this.ux));
    };
    VerticalAnchoredCategorySeries.prototype.ux = function (a) {
        return this.tg.c9(a);
    };
    VerticalAnchoredCategorySeries.prototype.ev = function (a, b) {
        if (this.eu(a, b)) {
            return true;
        }
        if (this.qf(a, b)) {
            return true;
        }
        return false;
    };
    VerticalAnchoredCategorySeries.prototype.gj = function (a, b, c) {
        if (this.cd == null) {
            return NaN;
        }
        var d = this.getEffectiveViewport1(this.b0);
        var e = this.rn();
        var f = new ScalerParams(0, this.cd.sf, this.b0.bu, e.cg, d);
        var g = this.rt.r(e, this.cd.sf, this.b0.bu, d);
        return this.gl(this.valueColumn, a, e, f, g, runOn(this, this.sm), b, c);
    };
    VerticalAnchoredCategorySeries.prototype.pl = function (a, b, c) {
        var d = this.rn();
        return this.pn(a, b, c, this.rt.r(d, this.b0.bv, this.b0.bu, this.getEffectiveViewport1(this.b0)), this.r8(), d, null, null, null);
    };
    VerticalAnchoredCategorySeries.prototype.fetchXAxis = function () {
        return this.xAxis;
    };
    VerticalAnchoredCategorySeries.prototype.fetchYAxis = function () {
        return this.yAxis;
    };
    VerticalAnchoredCategorySeries.prototype.t3 = function (a) {
        this.xAxis = typeCast(NumericXAxis.$, a);
    };
    VerticalAnchoredCategorySeries.prototype.t4 = function (a) {
        this.yAxis = typeCast(CategoryYAxis.$, a);
    };
    VerticalAnchoredCategorySeries.prototype.si = function () {
        return this.xAxis != null && this.xAxis.c0();
    };
    VerticalAnchoredCategorySeries.prototype.rh = function (a, b) {
        return this.td(a, b, this.yAxis);
    };
    VerticalAnchoredCategorySeries.prototype.f5 = function (a) {
        return this.up.e$a(this, a);
    };
    VerticalAnchoredCategorySeries.prototype.sm = function (a) {
        return this.f7(a, this.rn());
    };
    VerticalAnchoredCategorySeries.prototype.hd = function (a) {
        return truncate(Math.round(this.f5(a)));
    };
    VerticalAnchoredCategorySeries.prototype.ht = function (a) {
        var b = this.hd(a);
        return b >= 0 && this.ck != null && b < this.ck.count ? this.ck.item(b) : null;
    };
    VerticalAnchoredCategorySeries.prototype.l3 = function (a, b, c, d) {
        _super.prototype.l3.call(this, a, b, c, d);
        switch (b) {
            case VerticalAnchoredCategorySeries.$$p[0]:
                if (c != d) {
                    this.k1(typeCast(Axis.$, c));
                    this.l8(typeCast(Axis.$, d));
                    this.rx.cr.g(this.ft);
                    if (this.cd != null) {
                        this.cd.li();
                    }
                    this.mh(false);
                    this.lo();
                }
                break;
            case VerticalAnchoredCategorySeries.$$p[1]:
                if (c != d) {
                    this.k1(typeCast(Axis.$, c));
                    this.l8(typeCast(Axis.$, d));
                    this.rx.cr.g(this.ft);
                    this.si();
                    this.mh(false);
                    this.lo();
                }
                break;
            case "TrendLineType":
                var e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                if (e != 0) {
                    this.tg.c2 = CategoryTrendLineManagerFactory.a(this.tg.c2, this.yAxis, this.m9, this, this.cn);
                }
                break;
        }
    };
    VerticalAnchoredCategorySeries.prototype.us = function (a) {
        if (typeCast(CategoryYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    VerticalAnchoredCategorySeries.prototype.ur = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    Object.defineProperty(VerticalAnchoredCategorySeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.sj;
        },
        enumerable: false,
        configurable: true
    });
    VerticalAnchoredCategorySeries.$t = markType(VerticalAnchoredCategorySeries, 'VerticalAnchoredCategorySeries', AnchoredCategorySeries.$);
    VerticalAnchoredCategorySeries.$$p = markDep(DependencyProperty, PropertyMetadata, VerticalAnchoredCategorySeries, 'raisePropertyChanged', ['XAxis::uv', [NumericXAxis.$, null], 'YAxis::uw', [CategoryYAxis.$, null]]);
    return VerticalAnchoredCategorySeries;
}(AnchoredCategorySeries));
export { VerticalAnchoredCategorySeries };
