/*
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-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
 */
export let VerticalAnchoredCategorySeries = /*@__PURE__*/ (() => {
    class VerticalAnchoredCategorySeries extends AnchoredCategorySeries {
        constructor() {
            super(...arguments);
            this.uo = null;
        }
        bv() {
            if (this.xAxis != null && this.xAxis.cg) {
                return 4;
            }
            return 3;
        }
        bw() {
            return 1;
        }
        ku() {
            super.ku();
            this.xAxis = null;
            this.yAxis = null;
        }
        get up() {
            if (this.uo == null) {
                this.uo = DVContainer.instance.createInstance(IVerticalAnchoredCategorySeriesInteractionManager_$type, () => this.cn.n);
            }
            return this.uo;
        }
        get_isVertical() {
            return true;
        }
        rn() {
            return this.yAxis;
        }
        r8() {
            return this.xAxis;
        }
        getOffsetValue() {
            return this.rt.r(this.rn(), this.b0.bv, this.b0.bu, this.getEffectiveViewport1(this.b0));
        }
        getCategoryWidth() {
            return this.yAxis.getCategorySize(this.b0.bv, this.b0.bu, this.getEffectiveViewport1(this.b0));
        }
        hh(a, b) {
            return this.hi(a, b, this.rn(), runOn(this, this.sm), this.valueColumn);
        }
        hj(a, b) {
            return this.hk(a, b, this.rn(), runOn(this, this.sm), this.valueColumn);
        }
        f3(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));
        }
        aq(a) {
            if (a.isEmpty && this.cd != null) {
                a = this.cd.sf;
            }
            if (this.valueColumn == null) {
                return null;
            }
            let b = this.pq(this.b0);
            let c = this.rn();
            let d = new ScalerParams(0, a, this.cd.su, c.cg, this.getEffectiveViewport());
            let e = (c.el(b.top, d));
            let f = (c.el(b.bottom, d));
            if (!c.cg) {
                let g = e;
                e = f;
                f = g;
            }
            e -= this.tr;
            f += this.tr;
            let 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));
            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.ao(n, this.r8(), a);
            return n;
        }
        bp() {
            if (this.bq == 0) {
                return 1;
            }
            else {
                return super.bp();
            }
        }
        pw(a) {
            if (!this.hasMarkers || !this.qe()) {
                return Rect.empty;
            }
            return this.up.e$b(this, this.ro.m, a, runOn(this, this.ux));
        }
        ux(a) {
            return this.tg.c9(a);
        }
        ev(a, b) {
            if (this.eu(a, b)) {
                return true;
            }
            if (this.qf(a, b)) {
                return true;
            }
            return false;
        }
        gj(a, b, c) {
            if (this.cd == null) {
                return NaN;
            }
            let d = this.getEffectiveViewport1(this.b0);
            let e = this.rn();
            let f = new ScalerParams(0, this.cd.sf, this.b0.bu, e.cg, d);
            let 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);
        }
        pl(a, b, c) {
            let 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);
        }
        fetchXAxis() {
            return this.xAxis;
        }
        fetchYAxis() {
            return this.yAxis;
        }
        t3(a) {
            this.xAxis = typeCast(NumericXAxis.$, a);
        }
        t4(a) {
            this.yAxis = typeCast(CategoryYAxis.$, a);
        }
        si() {
            return this.xAxis != null && this.xAxis.c0();
        }
        rh(a, b) {
            return this.td(a, b, this.yAxis);
        }
        f5(a) {
            return this.up.e$a(this, a);
        }
        sm(a) {
            return this.f7(a, this.rn());
        }
        hd(a) {
            return truncate(Math.round(this.f5(a)));
        }
        ht(a) {
            let b = this.hd(a);
            return b >= 0 && this.ck != null && b < this.ck.count ? this.ck.item(b) : null;
        }
        l3(a, b, c, d) {
            super.l3(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":
                    let 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;
            }
        }
        us(a) {
            if (typeCast(CategoryYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        ur(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        get useHighMarkerFidelity() {
            return this.sj;
        }
    }
    VerticalAnchoredCategorySeries.$t = markType(VerticalAnchoredCategorySeries, 'VerticalAnchoredCategorySeries', AnchoredCategorySeries.$);
    VerticalAnchoredCategorySeries.$$p = markDep(DependencyProperty, PropertyMetadata, VerticalAnchoredCategorySeries, 'raisePropertyChanged', ['XAxis::uv', [NumericXAxis.$, null], 'YAxis::uw', [CategoryYAxis.$, null]]);
    return VerticalAnchoredCategorySeries;
})();
