/*
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.acc = null;
        }
        ck() {
            if (this.xAxis != null && this.xAxis.ch) {
                return 4;
            }
            return 3;
        }
        cl() {
            return 1;
        }
        o2() {
            super.o2();
            this.xAxis = null;
            this.yAxis = null;
        }
        get acd() {
            if (this.acc == null) {
                this.acc = DVContainer.instance.createInstance(IVerticalAnchoredCategorySeriesInteractionManager_$type, () => this.dr.n);
            }
            return this.acc;
        }
        get_isVertical() {
            return true;
        }
        yq() {
            return this.yAxis;
        }
        y7() {
            return this.xAxis;
        }
        getOffsetValue() {
            return this.yx.r(this.yq(), this.cv.by, this.cv.bx, this.getEffectiveViewport1(this.cv));
        }
        getCategoryWidth() {
            return this.yAxis.getCategorySize(this.cv.by, this.cv.bx, this.getEffectiveViewport1(this.cv));
        }
        j8(a, b) {
            return this.j9(a, b, this.yq(), runOn(this, this.zr), this.valueColumn);
        }
        ka(a, b) {
            return this.kb(a, b, this.yq(), runOn(this, this.zr), this.valueColumn);
        }
        ip(a, b, c, d, e) {
            if (this.valueColumn == null) {
                return Number.POSITIVE_INFINITY;
            }
            return this.iq(a, b, this.yAxis, d, e, this.valueColumn.count, runOn(this, this.zr));
        }
        az(a) {
            if (a.isEmpty && this.db != null) {
                a = this.db.v4;
            }
            if (this.valueColumn == null) {
                return null;
            }
            let b = this.wh(this.cv);
            let c = this.yq();
            let d = new ScalerParams(0, a, this.db.wj, c.ch, this.getEffectiveViewport());
            let e = (c.eo(b.top, d));
            let f = (c.eo(b.bottom, d));
            if (!c.ch) {
                let g = e;
                e = f;
                f = g;
            }
            e -= this.aa9;
            f += this.aa9;
            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.ax(n, this.y7(), a);
            return n;
        }
        b2() {
            if (this.b3 == 0) {
                return 1;
            }
            else {
                return super.b2();
            }
        }
        wn(a) {
            if (!this.hasMarkers || !this.xe()) {
                return Rect.empty;
            }
            return this.acd.e$b(this, this.ys.n, a, runOn(this, this.acl));
        }
        acl(a) {
            return this.aat.de(a);
        }
        gw(a, b) {
            if (this.gv(a, b)) {
                return true;
            }
            if (this.xf(a, b)) {
                return true;
            }
            return false;
        }
        i5(a, b, c) {
            if (this.db == null) {
                return NaN;
            }
            let d = this.getEffectiveViewport1(this.cv);
            let e = this.yq();
            let f = new ScalerParams(0, this.db.v4, this.cv.bx, e.ch, d);
            let g = this.yx.r(e, this.db.v4, this.cv.bx, d);
            return this.i7(this.valueColumn, a, e, f, g, runOn(this, this.zr), b, c);
        }
        wa(a, b, c) {
            let d = this.yq();
            return this.wc(a, b, c, this.yx.r(d, this.cv.by, this.cv.bx, this.getEffectiveViewport1(this.cv)), this.y7(), d, null, null, null);
        }
        fetchXAxis() {
            return this.xAxis;
        }
        fetchYAxis() {
            return this.yAxis;
        }
        abp(a) {
            this.xAxis = typeCast(NumericXAxis.$, a);
        }
        abq(a) {
            this.yAxis = typeCast(CategoryYAxis.$, a);
        }
        zn() {
            return this.xAxis != null && this.xAxis.c1();
        }
        yk(a, b) {
            return this.aaq(a, b, this.yAxis);
        }
        ir(a) {
            return this.acd.e$a(this, a);
        }
        zr(a) {
            return this.it(a, this.yq());
        }
        j3(a) {
            return truncate(Math.round(this.ir(a)));
        }
        kn(a) {
            let b = this.j3(a);
            return b >= 0 && this.dn != null && b < this.dn.count ? this.dn.item(b) : null;
        }
        q7(a, b, c, d) {
            super.q7(a, b, c, d);
            switch (b) {
                case VerticalAnchoredCategorySeries.$$p[0]:
                    if (c != d) {
                        this.pc(typeCast(Axis.$, c));
                        this.rf(typeCast(Axis.$, d));
                        this.y1.cw.g(this.id);
                        if (this.db != null) {
                            this.db.n2();
                        }
                        this.rp(false);
                        this.qj();
                    }
                    break;
                case VerticalAnchoredCategorySeries.$$p[1]:
                    if (c != d) {
                        this.pc(typeCast(Axis.$, c));
                        this.rf(typeCast(Axis.$, d));
                        this.y1.cw.g(this.id);
                        this.zn();
                        this.rp(false);
                        this.qj();
                    }
                    break;
                case "TrendLineType":
                    let e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                    if (e != 0) {
                        this.aat.c7 = CategoryTrendLineManagerFactory.a(this.aat.c7, this.yAxis, this.st, this, this.dr);
                    }
                    break;
            }
        }
        acg(a) {
            if (typeCast(CategoryYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        acf(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        get useHighMarkerFidelity() {
            return this.zo;
        }
    }
    VerticalAnchoredCategorySeries.$t = /*@__PURE__*/ markType(VerticalAnchoredCategorySeries, 'VerticalAnchoredCategorySeries', AnchoredCategorySeries.$);
    VerticalAnchoredCategorySeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, VerticalAnchoredCategorySeries, 'raisePropertyChanged', ['XAxis::acj', [NumericXAxis.$, null], 'YAxis::ack', [CategoryYAxis.$, null]]);
    return VerticalAnchoredCategorySeries;
})();
