/*
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 { 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
 */
export let VerticalAnchoredCategorySeries = /*@__PURE__*/ (() => {
    class VerticalAnchoredCategorySeries extends AnchoredCategorySeries {
        constructor() {
            super(...arguments);
            this.yy = null;
        }
        cb() {
            if (this.xAxis != null && this.xAxis.ch) {
                return 4;
            }
            return 3;
        }
        cc() {
            return 1;
        }
        nh() {
            super.nh();
            this.xAxis = null;
            this.yAxis = null;
        }
        get yz() {
            if (this.yy == null) {
                this.yy = DVContainer.instance.createInstance(IVerticalAnchoredCategorySeriesInteractionManager_$type, () => this.da.n);
            }
            return this.yy;
        }
        get_isVertical() {
            return true;
        }
        vn() {
            return this.yAxis;
        }
        v3() {
            return this.xAxis;
        }
        getOffsetValue() {
            return this.vt.r(this.vn(), this.cg.by, this.cg.bx, this.getEffectiveViewport1(this.cg));
        }
        getCategoryWidth() {
            return this.yAxis.getCategorySize(this.cg.by, this.cg.bx, this.getEffectiveViewport1(this.cg));
        }
        je(a, b) {
            return this.jf(a, b, this.vn(), runOn(this, this.wn), this.valueColumn);
        }
        jg(a, b) {
            return this.jh(a, b, this.vn(), runOn(this, this.wn), this.valueColumn);
        }
        hu(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));
        }
        ar(a) {
            if (a.isEmpty && this.cv != null) {
                a = this.cv.tr;
            }
            if (this.valueColumn == null) {
                return null;
            }
            let b = this.tq(this.cg);
            let c = this.vn();
            let d = new ScalerParams(0, a, this.cv.t6, c.ch, this.getEffectiveViewport());
            let e = (c.em(b.top, d));
            let f = (c.em(b.bottom, d));
            if (!c.ch) {
                let g = e;
                e = f;
                f = g;
            }
            e -= this.xv;
            f += this.xv;
            let 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));
            let i = 1.7976931348623157E+308;
            let j = -1.7976931348623157E+308;
            if (truncate(e) <= truncate(f)) {
                for (let k = truncate(e); k <= truncate(f); k++) {
                    let l = k;
                    if (h != null) {
                        l = h.i$b._inner[k];
                    }
                    let 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);
                }
            }
            let n = new AxisRange(i, j);
            n = this.ap(n, this.v3(), a);
            return n;
        }
        bu() {
            if (this.bv == 0) {
                return 1;
            }
            else {
                return super.bu();
            }
        }
        tw(a) {
            if (!this.hasMarkers || !this.ue()) {
                return Rect.empty;
            }
            return this.yz.e$b(this, this.vo.m, a, runOn(this, this.y7));
        }
        y7(a) {
            return this.xh.dc(a);
        }
        f5(a, b) {
            if (this.f4(a, b)) {
                return true;
            }
            if (this.uf(a, b)) {
                return true;
            }
            return false;
        }
        ia(a, b, c) {
            if (this.cv == null) {
                return NaN;
            }
            let d = this.getEffectiveViewport1(this.cg);
            let e = this.vn();
            let f = new ScalerParams(0, this.cv.tr, this.cg.bx, e.ch, d);
            let 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);
        }
        tj(a, b, c) {
            let 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);
        }
        fetchXAxis() {
            return this.xAxis;
        }
        fetchYAxis() {
            return this.yAxis;
        }
        yb(a) {
            this.xAxis = typeCast(NumericXAxis.$, a);
        }
        yc(a) {
            this.yAxis = typeCast(CategoryYAxis.$, a);
        }
        wj() {
            return this.xAxis != null && this.xAxis.c1();
        }
        vh(a, b) {
            return this.xe(a, b, this.yAxis);
        }
        hw(a) {
            return this.yz.e$a(this, a);
        }
        wn(a) {
            return this.hy(a, this.vn());
        }
        i9(a) {
            return truncate(Math.round(this.hw(a)));
        }
        js(a) {
            let b = this.i9(a);
            return b >= 0 && this.c7 != null && b < this.c7.count ? this.c7.item(b) : null;
        }
        pa(a, b, c, d) {
            super.pa(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":
                    let 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;
            }
        }
        y2(a) {
            if (typeCast(CategoryYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        y1(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        get useHighMarkerFidelity() {
            return this.wk;
        }
    }
    VerticalAnchoredCategorySeries.$t = /*@__PURE__*/ markType(VerticalAnchoredCategorySeries, 'VerticalAnchoredCategorySeries', AnchoredCategorySeries.$);
    VerticalAnchoredCategorySeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, VerticalAnchoredCategorySeries, 'raisePropertyChanged', ['XAxis::y5', [NumericXAxis.$, null], 'YAxis::y6', [CategoryYAxis.$, null]]);
    return VerticalAnchoredCategorySeries;
})();
