/*
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.yy = null;
        return _this;
    }
    VerticalAnchoredCategorySeries.prototype.cb = function () {
        if (this.xAxis != null && this.xAxis.ch) {
            return 4;
        }
        return 3;
    };
    VerticalAnchoredCategorySeries.prototype.cc = function () {
        return 1;
    };
    VerticalAnchoredCategorySeries.prototype.nh = function () {
        _super.prototype.nh.call(this);
        this.xAxis = null;
        this.yAxis = null;
    };
    Object.defineProperty(VerticalAnchoredCategorySeries.prototype, "yz", {
        get: function () {
            var _this = this;
            if (this.yy == null) {
                this.yy = DVContainer.instance.createInstance(IVerticalAnchoredCategorySeriesInteractionManager_$type, function () { return _this.da.n; });
            }
            return this.yy;
        },
        enumerable: false,
        configurable: true
    });
    VerticalAnchoredCategorySeries.prototype.get_isVertical = function () {
        return true;
    };
    VerticalAnchoredCategorySeries.prototype.vn = function () {
        return this.yAxis;
    };
    VerticalAnchoredCategorySeries.prototype.v3 = function () {
        return this.xAxis;
    };
    VerticalAnchoredCategorySeries.prototype.getOffsetValue = function () {
        return this.vt.r(this.vn(), this.cg.by, this.cg.bx, this.getEffectiveViewport1(this.cg));
    };
    VerticalAnchoredCategorySeries.prototype.getCategoryWidth = function () {
        return this.yAxis.getCategorySize(this.cg.by, this.cg.bx, this.getEffectiveViewport1(this.cg));
    };
    VerticalAnchoredCategorySeries.prototype.je = function (a, b) {
        return this.jf(a, b, this.vn(), runOn(this, this.wn), this.valueColumn);
    };
    VerticalAnchoredCategorySeries.prototype.jg = function (a, b) {
        return this.jh(a, b, this.vn(), runOn(this, this.wn), this.valueColumn);
    };
    VerticalAnchoredCategorySeries.prototype.hu = function (a, b, c, d, e) {
        if (this.valueColumn == null) {
            return Number.POSITIVE_INFINITY;
        }
        return this.hv(a, b, this.yAxis, d, e, this.valueColumn.count, runOn(this, this.wn));
    };
    VerticalAnchoredCategorySeries.prototype.ar = function (a) {
        if (a.isEmpty && this.cv != null) {
            a = this.cv.tr;
        }
        if (this.valueColumn == null) {
            return null;
        }
        var b = this.tq(this.cg);
        var c = this.vn();
        var d = new ScalerParams(0, a, this.cv.t6, 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.xv;
        f += this.xv;
        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.v3(), a);
        return n;
    };
    VerticalAnchoredCategorySeries.prototype.bu = function () {
        if (this.bv == 0) {
            return 1;
        }
        else {
            return _super.prototype.bu.call(this);
        }
    };
    VerticalAnchoredCategorySeries.prototype.tw = function (a) {
        if (!this.hasMarkers || !this.ue()) {
            return Rect.empty;
        }
        return this.yz.e$b(this, this.vo.m, a, runOn(this, this.y7));
    };
    VerticalAnchoredCategorySeries.prototype.y7 = function (a) {
        return this.xh.dc(a);
    };
    VerticalAnchoredCategorySeries.prototype.f5 = function (a, b) {
        if (this.f4(a, b)) {
            return true;
        }
        if (this.uf(a, b)) {
            return true;
        }
        return false;
    };
    VerticalAnchoredCategorySeries.prototype.ia = function (a, b, c) {
        if (this.cv == null) {
            return NaN;
        }
        var d = this.getEffectiveViewport1(this.cg);
        var e = this.vn();
        var f = new ScalerParams(0, this.cv.tr, this.cg.bx, e.ch, d);
        var g = this.vt.r(e, this.cv.tr, this.cg.bx, d);
        return this.ic(this.valueColumn, a, e, f, g, runOn(this, this.wn), b, c);
    };
    VerticalAnchoredCategorySeries.prototype.tj = function (a, b, c) {
        var d = this.vn();
        return this.tl(a, b, c, this.vt.r(d, this.cg.by, this.cg.bx, this.getEffectiveViewport1(this.cg)), this.v3(), d, null, null, null);
    };
    VerticalAnchoredCategorySeries.prototype.fetchXAxis = function () {
        return this.xAxis;
    };
    VerticalAnchoredCategorySeries.prototype.fetchYAxis = function () {
        return this.yAxis;
    };
    VerticalAnchoredCategorySeries.prototype.yb = function (a) {
        this.xAxis = typeCast(NumericXAxis.$, a);
    };
    VerticalAnchoredCategorySeries.prototype.yc = function (a) {
        this.yAxis = typeCast(CategoryYAxis.$, a);
    };
    VerticalAnchoredCategorySeries.prototype.wj = function () {
        return this.xAxis != null && this.xAxis.c1();
    };
    VerticalAnchoredCategorySeries.prototype.vh = function (a, b) {
        return this.xe(a, b, this.yAxis);
    };
    VerticalAnchoredCategorySeries.prototype.hw = function (a) {
        return this.yz.e$a(this, a);
    };
    VerticalAnchoredCategorySeries.prototype.wn = function (a) {
        return this.hy(a, this.vn());
    };
    VerticalAnchoredCategorySeries.prototype.i9 = function (a) {
        return truncate(Math.round(this.hw(a)));
    };
    VerticalAnchoredCategorySeries.prototype.js = function (a) {
        var b = this.i9(a);
        return b >= 0 && this.c7 != null && b < this.c7.count ? this.c7.item(b) : null;
    };
    VerticalAnchoredCategorySeries.prototype.pa = function (a, b, c, d) {
        _super.prototype.pa.call(this, a, b, c, d);
        switch (b) {
            case VerticalAnchoredCategorySeries.$$p[0]:
                if (c != d) {
                    this.nq(typeCast(Axis.$, c));
                    this.ph(typeCast(Axis.$, d));
                    this.vx.cu.g(this.hk);
                    if (this.cv != null) {
                        this.cv.mg();
                    }
                    this.pr(false);
                    this.om();
                }
                break;
            case VerticalAnchoredCategorySeries.$$p[1]:
                if (c != d) {
                    this.nq(typeCast(Axis.$, c));
                    this.ph(typeCast(Axis.$, d));
                    this.vx.cu.g(this.hk);
                    this.wj();
                    this.pr(false);
                    this.om();
                }
                break;
            case "TrendLineType":
                var e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                if (e != 0) {
                    this.xh.c5 = CategoryTrendLineManagerFactory.a(this.xh.c5, this.yAxis, this.qt, this, this.da);
                }
                break;
        }
    };
    VerticalAnchoredCategorySeries.prototype.y2 = function (a) {
        if (typeCast(CategoryYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    VerticalAnchoredCategorySeries.prototype.y1 = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    Object.defineProperty(VerticalAnchoredCategorySeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.wk;
        },
        enumerable: false,
        configurable: true
    });
    VerticalAnchoredCategorySeries.$t = markType(VerticalAnchoredCategorySeries, 'VerticalAnchoredCategorySeries', AnchoredCategorySeries.$);
    VerticalAnchoredCategorySeries.$$p = markDep(DependencyProperty, PropertyMetadata, VerticalAnchoredCategorySeries, 'raisePropertyChanged', ['XAxis::y5', [NumericXAxis.$, null], 'YAxis::y6', [CategoryYAxis.$, null]]);
    return VerticalAnchoredCategorySeries;
}(AnchoredCategorySeries));
export { VerticalAnchoredCategorySeries };
