/*
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 { IHorizontalAnchoredCategorySeriesInteractionManager_$type } from "./IHorizontalAnchoredCategorySeriesInteractionManager";
import { DVContainer } from "igniteui-react-core/ES2015/DVContainer";
import { Type, runOn, Point_$type, typeCast, EnumUtil, enumGetBox, markType } from "igniteui-react-core/ES2015/type";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { DependencyProperty } from "igniteui-react-core/ES2015/DependencyProperty";
import { NumericYAxis } from "./NumericYAxis";
import { CategoryMode_$type } from "./CategoryMode";
import { Rect } from "igniteui-react-core/ES2015/Rect";
import { ScalerParams } from "./ScalerParams";
import { Axis } from "./Axis";
import { TrendLineType_$type } from "igniteui-react-core/ES2015/TrendLineType";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
import { ISortingAxis_$type } from "./ISortingAxis";
import { CategoryXAxis } from "./CategoryXAxis";
import { PropertyMetadata } from "igniteui-react-core/ES2015/PropertyMetadata";
/**
 * @hidden
 */
export class HorizontalAnchoredCategorySeries extends AnchoredCategorySeries {
    constructor() {
        super(...arguments);
        this.pv = null;
        this.pr = null;
        this.px = null;
        this.pt = 0;
    }
    get pw() {
        if (this.pv == null) {
            this.pv = DVContainer.instance.createInstance(IHorizontalAnchoredCategorySeriesInteractionManager_$type, () => this.b2.n);
        }
        return this.pv;
    }
    hn() {
        super.hn();
        this.xAxis = null;
        this.yAxis = null;
    }
    bd() {
        if (this.be == 0) {
            return 1;
        }
        else {
            return super.bd();
        }
    }
    mz() {
        return this.pr;
    }
    nj() {
        return this.px;
    }
    lp(a) {
        if (this.m0 == null || this.m0.m.count == 0 || !this.hasMarkers || !this.lw()) {
            return Rect.empty;
        }
        return this.pw.d$d(this, this.m0.m, a, runOn(this, this.p9));
    }
    p9(a) {
        return this.or.c5(a);
    }
    p1(a, b, c) {
        return this.pw.d$c(this, this.nj(), a, b, c);
    }
    ah(a) {
        return this.pw.d$a(this, this.m0.f, this.n0(this.bi), this.n1(this.bi), a);
    }
    ai(a) {
        return this.pw.d$b(this, this.m0.f, this.n0(this.bi), this.n1(this.bi), a);
    }
    dg(a, b) {
        if (this.df(a, b)) {
            return true;
        }
        if (this.lx(a, b)) {
            return true;
        }
        return false;
    }
    getOffsetValue() {
        return this.m4.r(this.mz(), this.bi.bs, this.bi.br, this.getEffectiveViewport1(this.bi));
    }
    getCategoryWidth() {
        let a = this.getEffectiveViewport1(this.bi);
        return this.mz().getCategorySize(this.bi.bs, this.bi.br, a);
    }
    ek(a, b, c) {
        if (this.bs == null) {
            return NaN;
        }
        let d = this.getEffectiveViewport1(this.bi);
        let e = this.mz();
        let f = new ScalerParams(0, this.bs.mq, this.bi.br, e.b8, d);
        let g = this.m4.r(e, this.bs.mq, this.bi.br, d);
        return this.em(this.valueColumn, a, e, f, g, runOn(this, this.ny), b, c);
    }
    fb(a, b) {
        return this.fc(a, b, this.mz(), runOn(this, this.ny), this.valueColumn);
    }
    e9(a, b) {
        return this.fa(a, b, this.mz(), runOn(this, this.ny), this.valueColumn);
    }
    d6(a, b, c, d, e) {
        if (this.valueColumn == null) {
            return Number.POSITIVE_INFINITY;
        }
        return this.d7(a, b, this.mz(), d, e, this.valueColumn.count, runOn(this, this.ny));
    }
    le(a, b, c) {
        if (this.mz() == null || this.nj() == null) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        return this.lg(a, b, c, this.m4.r(this.mz(), this.bi.bs, this.bi.br, this.getEffectiveViewport1(this.bi)), this.nj(), this.mz(), null, null, null);
    }
    fetchXAxis() {
        return this.pr;
    }
    fetchYAxis() {
        return this.px;
    }
    o9(a) {
        this.xAxis = typeCast(CategoryAxisBase.$, a);
    }
    pa(a) {
        this.yAxis = typeCast(NumericYAxis.$, a);
    }
    nu() {
        return this.px != null && this.px.ck();
    }
    p5(a) {
        this.pr = a;
    }
    p6(a) {
        this.px = a;
    }
    mt(a, b) {
        return this.oo(a, b, this.pr);
    }
    is(a, b, c, d) {
        switch (b) {
            case HorizontalAnchoredCategorySeries.$$p[0]:
                this.p5(this.xAxis);
                if (this.or.cz) {
                    this.or.cy = CategoryTrendLineManagerFactory.a(this.or.cy, this.pr, this.jq, this, this.b2);
                }
                break;
            case "TrendLineType":
                let e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                if (e != 0) {
                    this.or.cy = CategoryTrendLineManagerFactory.a(this.or.cy, this.pr, this.jq, this, this.b2);
                }
                break;
        }
        super.is(a, b, c, d);
        switch (b) {
            case HorizontalAnchoredCategorySeries.$$p[0]:
                if (c != d) {
                    this.ht(typeCast(Axis.$, c));
                    this.ix(typeCast(Axis.$, d));
                    this.p5(this.xAxis);
                    this.m8.cn.g(this.er);
                    this.i6(false);
                    this.ic();
                }
                break;
            case HorizontalAnchoredCategorySeries.$$p[1]:
                if (c != d) {
                    this.ht(typeCast(Axis.$, c));
                    this.ix(typeCast(Axis.$, d));
                    this.p6(this.yAxis);
                    this.m8.cn.g(this.er);
                    this.nu();
                    this.i6(false);
                    this.ic();
                }
                break;
            case "CategoryMode":
                if (this.xAxis != null) {
                    this.xAxis.kg(true);
                }
                break;
        }
    }
    hs(a, b, c, d) {
        super.hs(a, b, c, d);
        if (this.pr != null && typeCast(ISortingAxis_$type, this.pr) !== null) {
            this.pr.i$i();
        }
        switch (a) {
            case 4:
                if (this.pr != null) {
                    this.pr.ck();
                }
                if (this.px != null && !this.px.ck()) {
                    this.i6(true);
                }
                break;
            case 1:
                if (this.pr != null) {
                    this.pr.ck();
                }
                if (this.px != null && !this.px.ck()) {
                    this.i6(true);
                }
                break;
            case 0:
                if (this.pr != null) {
                    this.pr.ck();
                }
                if (this.px != null && !this.px.ck()) {
                    this.i6(true);
                }
                break;
            case 2:
                if (this.o2 != null && this.or.cn.d > 0 && this.px != null && !this.px.ck()) {
                    this.i6(true);
                }
                break;
            case 3:
                if (d == this.o2) {
                    if (this.pr != null) {
                        this.pr.ck();
                    }
                    if (this.px != null && !this.px.ck()) {
                        this.i6(true);
                    }
                }
                break;
        }
    }
    pz(a) {
        if (typeCast(CategoryXAxis.$, a) !== null || a.b5) {
            return true;
        }
        return false;
    }
    p0(a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    get pu() {
        return this.pt;
    }
    set pu(a) {
        let b = this.pu;
        if (a != b) {
            this.pt = a;
            this.raisePropertyChanged("CategoryMode", enumGetBox(CategoryMode_$type, b), enumGetBox(CategoryMode_$type, this.pu));
        }
    }
    get useHighMarkerFidelity() {
        return this.nv;
    }
}
HorizontalAnchoredCategorySeries.$t = markType(HorizontalAnchoredCategorySeries, 'HorizontalAnchoredCategorySeries', AnchoredCategorySeries.$);
Type.dep(DependencyProperty, PropertyMetadata, HorizontalAnchoredCategorySeries, 'raisePropertyChanged', ['XAxis::p7', [CategoryAxisBase.$, null], 'YAxis::p8', [NumericYAxis.$, null]]);
