/*
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-react-core";
import { CategoryYAxis } from "./CategoryYAxis";
import { IVerticalAnchoredCategorySeriesInteractionManager_$type } from "./IVerticalAnchoredCategorySeriesInteractionManager";
import { DVContainer } from "igniteui-react-core";
import { runOn, typeCast, EnumUtil, markType, markDep } from "igniteui-react-core";
import { Axis } from "./Axis";
import { ScalerParams } from "./ScalerParams";
import { AxisRange } from "./AxisRange";
import { Rect } from "igniteui-react-core";
import { TrendLineType_$type } from "igniteui-react-core";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_, isInfinity } from "igniteui-react-core";
/**
 * @hidden
 */
var VerticalAnchoredCategorySeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(VerticalAnchoredCategorySeries, _super);
    function VerticalAnchoredCategorySeries() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.yw = null;
        return _this;
    }
    VerticalAnchoredCategorySeries.prototype.ce = function () {
        if (this.xAxis != null && this.xAxis.ch) {
            return 4;
        }
        return 3;
    };
    VerticalAnchoredCategorySeries.prototype.cf = function () {
        return 1;
    };
    VerticalAnchoredCategorySeries.prototype.ng = function () {
        _super.prototype.ng.call(this);
        this.xAxis = null;
        this.yAxis = null;
    };
    Object.defineProperty(VerticalAnchoredCategorySeries.prototype, "yx", {
        get: function () {
            var _this = this;
            if (this.yw == null) {
                this.yw = DVContainer.instance.createInstance(IVerticalAnchoredCategorySeriesInteractionManager_$type, function () { return _this.c9.n; });
            }
            return this.yw;
        },
        enumerable: false,
        configurable: true
    });
    VerticalAnchoredCategorySeries.prototype.get_isVertical = function () {
        return true;
    };
    VerticalAnchoredCategorySeries.prototype.vl = function () {
        return this.yAxis;
    };
    VerticalAnchoredCategorySeries.prototype.v6 = function () {
        return this.xAxis;
    };
    VerticalAnchoredCategorySeries.prototype.getOffsetValue = function () {
        return this.vr.r(this.vl(), this.cj.by, this.cj.bx, this.getEffectiveViewport1(this.cj));
    };
    VerticalAnchoredCategorySeries.prototype.getCategoryWidth = function () {
        return this.yAxis.getCategorySize(this.cj.by, this.cj.bx, this.getEffectiveViewport1(this.cj));
    };
    VerticalAnchoredCategorySeries.prototype.jd = function (a, b) {
        return this.je(a, b, this.vl(), runOn(this, this.wl), this.valueColumn);
    };
    VerticalAnchoredCategorySeries.prototype.jf = function (a, b) {
        return this.jg(a, b, this.vl(), runOn(this, this.wl), this.valueColumn);
    };
    VerticalAnchoredCategorySeries.prototype.ht = function (a, b, c, d, e) {
        if (this.valueColumn == null) {
            return Number.POSITIVE_INFINITY;
        }
        return this.hu(a, b, this.yAxis, d, e, this.valueColumn.count, runOn(this, this.wl));
    };
    VerticalAnchoredCategorySeries.prototype.ar = function (a) {
        if (a.isEmpty && this.cy != null) {
            a = this.cy.tn;
        }
        if (this.valueColumn == null) {
            return null;
        }
        var b = this.to(this.cj);
        var c = this.vl();
        var d = new ScalerParams(0, a, this.cy.t2, c.ch, this.getEffectiveViewport());
        var e = (c.em(b.top, d));
        var f = (c.em(b.bottom, d));
        if (!c.ch) {
            var g = e;
            e = f;
            f = g;
        }
        e -= this.xt;
        f += this.xt;
        var h = null;
        if (c.cn) {
            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.ap(n, this.v6(), a);
        return n;
    };
    VerticalAnchoredCategorySeries.prototype.bx = function () {
        if (this.by == 0) {
            return 1;
        }
        else {
            return _super.prototype.bx.call(this);
        }
    };
    VerticalAnchoredCategorySeries.prototype.tu = function (a) {
        if (!this.hasMarkers || !this.uc()) {
            return Rect.empty;
        }
        return this.yx.e$b(this, this.vm.m, a, runOn(this, this.y5));
    };
    VerticalAnchoredCategorySeries.prototype.y5 = function (a) {
        return this.xf.dc(a);
    };
    VerticalAnchoredCategorySeries.prototype.f4 = function (a, b) {
        if (this.f3(a, b)) {
            return true;
        }
        if (this.ud(a, b)) {
            return true;
        }
        return false;
    };
    VerticalAnchoredCategorySeries.prototype.h9 = function (a, b, c) {
        if (this.cy == null) {
            return NaN;
        }
        var d = this.getEffectiveViewport1(this.cj);
        var e = this.vl();
        var f = new ScalerParams(0, this.cy.tn, this.cj.bx, e.ch, d);
        var g = this.vr.r(e, this.cy.tn, this.cj.bx, d);
        return this.ib(this.valueColumn, a, e, f, g, runOn(this, this.wl), b, c);
    };
    VerticalAnchoredCategorySeries.prototype.th = function (a, b, c) {
        var d = this.vl();
        return this.tj(a, b, c, this.vr.r(d, this.cj.by, this.cj.bx, this.getEffectiveViewport1(this.cj)), this.v6(), d, null, null, null);
    };
    VerticalAnchoredCategorySeries.prototype.fetchXAxis = function () {
        return this.xAxis;
    };
    VerticalAnchoredCategorySeries.prototype.fetchYAxis = function () {
        return this.yAxis;
    };
    VerticalAnchoredCategorySeries.prototype.x9 = function (a) {
        this.xAxis = typeCast(NumericXAxis.$, a);
    };
    VerticalAnchoredCategorySeries.prototype.ya = function (a) {
        this.yAxis = typeCast(CategoryYAxis.$, a);
    };
    VerticalAnchoredCategorySeries.prototype.wh = function () {
        return this.xAxis != null && this.xAxis.c1();
    };
    VerticalAnchoredCategorySeries.prototype.vf = function (a, b) {
        return this.xc(a, b, this.yAxis);
    };
    VerticalAnchoredCategorySeries.prototype.hv = function (a) {
        return this.yx.e$a(this, a);
    };
    VerticalAnchoredCategorySeries.prototype.wl = function (a) {
        return this.hx(a, this.vl());
    };
    VerticalAnchoredCategorySeries.prototype.i8 = function (a) {
        return truncate(Math.round(this.hv(a)));
    };
    VerticalAnchoredCategorySeries.prototype.jr = function (a) {
        var b = this.i8(a);
        return b >= 0 && this.c6 != null && b < this.c6.count ? this.c6.item(b) : null;
    };
    VerticalAnchoredCategorySeries.prototype.o8 = function (a, b, c, d) {
        _super.prototype.o8.call(this, a, b, c, d);
        switch (b) {
            case VerticalAnchoredCategorySeries.$$p[0]:
                if (c != d) {
                    this.np(typeCast(Axis.$, c));
                    this.pf(typeCast(Axis.$, d));
                    this.vv.cu.g(this.hj);
                    if (this.cy != null) {
                        this.cy.mf();
                    }
                    this.pp(false);
                    this.ol();
                }
                break;
            case VerticalAnchoredCategorySeries.$$p[1]:
                if (c != d) {
                    this.np(typeCast(Axis.$, c));
                    this.pf(typeCast(Axis.$, d));
                    this.vv.cu.g(this.hj);
                    this.wh();
                    this.pp(false);
                    this.ol();
                }
                break;
            case "TrendLineType":
                var e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                if (e != 0) {
                    this.xf.c5 = CategoryTrendLineManagerFactory.a(this.xf.c5, this.yAxis, this.qr, this, this.c9);
                }
                break;
        }
    };
    VerticalAnchoredCategorySeries.prototype.y0 = function (a) {
        if (typeCast(CategoryYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    VerticalAnchoredCategorySeries.prototype.yz = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    Object.defineProperty(VerticalAnchoredCategorySeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.wi;
        },
        enumerable: false,
        configurable: true
    });
    VerticalAnchoredCategorySeries.$t = markType(VerticalAnchoredCategorySeries, 'VerticalAnchoredCategorySeries', AnchoredCategorySeries.$);
    VerticalAnchoredCategorySeries.$$p = markDep(DependencyProperty, PropertyMetadata, VerticalAnchoredCategorySeries, 'raisePropertyChanged', ['XAxis::y3', [NumericXAxis.$, null], 'YAxis::y4', [CategoryYAxis.$, null]]);
    return VerticalAnchoredCategorySeries;
}(AnchoredCategorySeries));
export { VerticalAnchoredCategorySeries };
