/*
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.abv = null;
        }
        ci() {
            if (this.xAxis != null && this.xAxis.ch) {
                return 4;
            }
            return 3;
        }
        cj() {
            return 1;
        }
        o0() {
            super.o0();
            this.xAxis = null;
            this.yAxis = null;
        }
        get abw() {
            if (this.abv == null) {
                this.abv = DVContainer.instance.createInstance(IVerticalAnchoredCategorySeriesInteractionManager_$type, () => this.dp.n);
            }
            return this.abv;
        }
        get_isVertical() {
            return true;
        }
        yk() {
            return this.yAxis;
        }
        y0() {
            return this.xAxis;
        }
        getOffsetValue() {
            return this.yq.r(this.yk(), this.ct.by, this.ct.bx, this.getEffectiveViewport1(this.ct));
        }
        getCategoryWidth() {
            return this.yAxis.getCategorySize(this.ct.by, this.ct.bx, this.getEffectiveViewport1(this.ct));
        }
        j6(a, b) {
            return this.j7(a, b, this.yk(), runOn(this, this.zk), this.valueColumn);
        }
        j8(a, b) {
            return this.j9(a, b, this.yk(), runOn(this, this.zk), this.valueColumn);
        }
        im(a, b, c, d, e) {
            if (this.valueColumn == null) {
                return Number.POSITIVE_INFINITY;
            }
            return this.io(a, b, this.yAxis, d, e, this.valueColumn.count, runOn(this, this.zk));
        }
        ay(a) {
            if (a.isEmpty && this.c9 != null) {
                a = this.c9.vl;
            }
            if (this.valueColumn == null) {
                return null;
            }
            let b = this.wd(this.ct);
            let c = this.yk();
            let d = new ScalerParams(0, a, this.c9.v0, c.ch, this.getEffectiveViewport());
            let e = (c.en(b.top, d));
            let f = (c.en(b.bottom, d));
            if (!c.ch) {
                let g = e;
                e = f;
                f = g;
            }
            e -= this.aas;
            f += this.aas;
            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.aw(n, this.y0(), a);
            return n;
        }
        b0() {
            if (this.b1 == 0) {
                return 1;
            }
            else {
                return super.b0();
            }
        }
        wj(a) {
            if (!this.hasMarkers || !this.w8()) {
                return Rect.empty;
            }
            return this.abw.e$b(this, this.yl.n, a, runOn(this, this.ab4));
        }
        ab4(a) {
            return this.aae.de(a);
        }
        gu(a, b) {
            if (this.gt(a, b)) {
                return true;
            }
            if (this.w9(a, b)) {
                return true;
            }
            return false;
        }
        i3(a, b, c) {
            if (this.c9 == null) {
                return NaN;
            }
            let d = this.getEffectiveViewport1(this.ct);
            let e = this.yk();
            let f = new ScalerParams(0, this.c9.vl, this.ct.bx, e.ch, d);
            let g = this.yq.r(e, this.c9.vl, this.ct.bx, d);
            return this.i5(this.valueColumn, a, e, f, g, runOn(this, this.zk), b, c);
        }
        v6(a, b, c) {
            let d = this.yk();
            return this.v8(a, b, c, this.yq.r(d, this.ct.by, this.ct.bx, this.getEffectiveViewport1(this.ct)), this.y0(), d, null, null, null);
        }
        fetchXAxis() {
            return this.xAxis;
        }
        fetchYAxis() {
            return this.yAxis;
        }
        aa8(a) {
            this.xAxis = typeCast(NumericXAxis.$, a);
        }
        aa9(a) {
            this.yAxis = typeCast(CategoryYAxis.$, a);
        }
        zg() {
            return this.xAxis != null && this.xAxis.c1();
        }
        ye(a, b) {
            return this.aab(a, b, this.yAxis);
        }
        ip(a) {
            return this.abw.e$a(this, a);
        }
        zk(a) {
            return this.ir(a, this.yk());
        }
        j1(a) {
            return truncate(Math.round(this.ip(a)));
        }
        kl(a) {
            let b = this.j1(a);
            return b >= 0 && this.dl != null && b < this.dl.count ? this.dl.item(b) : null;
        }
        q5(a, b, c, d) {
            super.q5(a, b, c, d);
            switch (b) {
                case VerticalAnchoredCategorySeries.$$p[0]:
                    if (c != d) {
                        this.pa(typeCast(Axis.$, c));
                        this.rd(typeCast(Axis.$, d));
                        this.yu.cw.g(this.ib);
                        if (this.c9 != null) {
                            this.c9.nq();
                        }
                        this.rn(false);
                        this.qh();
                    }
                    break;
                case VerticalAnchoredCategorySeries.$$p[1]:
                    if (c != d) {
                        this.pa(typeCast(Axis.$, c));
                        this.rd(typeCast(Axis.$, d));
                        this.yu.cw.g(this.ib);
                        this.zg();
                        this.rn(false);
                        this.qh();
                    }
                    break;
                case "TrendLineType":
                    let e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                    if (e != 0) {
                        this.aae.c7 = CategoryTrendLineManagerFactory.a(this.aae.c7, this.yAxis, this.sp, this, this.dp);
                    }
                    break;
            }
        }
        abz(a) {
            if (typeCast(CategoryYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        aby(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        get useHighMarkerFidelity() {
            return this.zh;
        }
    }
    VerticalAnchoredCategorySeries.$t = /*@__PURE__*/ markType(VerticalAnchoredCategorySeries, 'VerticalAnchoredCategorySeries', AnchoredCategorySeries.$);
    VerticalAnchoredCategorySeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, VerticalAnchoredCategorySeries, 'raisePropertyChanged', ['XAxis::ab2', [NumericXAxis.$, null], 'YAxis::ab3', [CategoryYAxis.$, null]]);
    return VerticalAnchoredCategorySeries;
})();
