/*
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 { HorizontalAnchoredCategorySeries } from "./HorizontalAnchoredCategorySeries";
import { IIsCategoryBased_$type } from "./IIsCategoryBased";
import { CategoryLineRasterizer } from "./CategoryLineRasterizer";
import { typeCast, Array_$type, runOn, markType } from "igniteui-react-core/ES2015/type";
import { ISortingAxis_$type } from "./ISortingAxis";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { Path } from "igniteui-react-core/ES2015/Path";
import { ScalerParams } from "./ScalerParams";
import { intDivide, isNaN_ } from "igniteui-react-core/ES2015/number";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
export class StepAreaSeries extends HorizontalAnchoredCategorySeries {
    constructor() {
        super();
        this.p6 = null;
        this.p6 = new CategoryLineRasterizer();
        this.ab = StepAreaSeries.$;
    }
    bf() {
        return new StepAreaSeriesView(this);
    }
    ii(a) {
        super.ii(a);
        this.p7 = a;
    }
    get_cj() {
        return true;
    }
    get cj() {
        return this.get_cj();
    }
    preferredCategoryMode(a) {
        return typeCast(ISortingAxis_$type, a) !== null ? 0 : 1;
    }
    hl(a, b) {
        super.hl(a, b);
        let c = b;
        c.c5();
    }
    p8(a, b, c, d, e) {
        if (b) {
            if (e) {
                if ((a & 1) == 0 || ((intDivide(a, 2)) + 1) >= c.f.count) {
                    return c.f._inner[(intDivide(a, 2))][0];
                }
                return c.f._inner[(intDivide(a, 2)) + 1][0];
            }
            return c.f._inner[(intDivide(a, 2))][0] + ((a & 1) == 1 ? -d : d);
        }
        if (e) {
            if ((a & 1) == 0 || ((intDivide(a, 2)) + 1) >= c.f.count) {
                return c.f._inner[(intDivide(a, 2))][0];
            }
            return c.f._inner[(intDivide(a, 2)) + 1][0];
        }
        return c.f._inner[(intDivide(a, 2))][0] + ((a & 1) == 0 ? -d : d);
    }
    m4() {
        return 1;
    }
    ea(a, b, c, d, e, f, g, h) {
        let i = NaN;
        if (c >= 0 && c < b.count) {
            i = b.item(c);
        }
        let j = NaN;
        if (d >= 0 && d < b.count) {
            j = b.item(d);
        }
        if (f == 0) {
            return j;
        }
        if (e == b.count - 1) {
            return i;
        }
        if (isNaN_(j) && g != 0 && a <= 0.5 && !h) {
            return i;
        }
        if (isNaN_(i) && g != 0 && a >= 0.5 && !h) {
            return j;
        }
        if (a > 0.5) {
            return j;
        }
        return i;
    }
    bd() {
        if (this.be == 0) {
            return 2;
        }
        else {
            return super.bd();
        }
    }
    ob(a, b) {
        super.ob(a, b);
        let c = b.bq;
        let d = b.bp;
        let e = this.getEffectiveViewport1(b);
        let f = typeCast(ISortingAxis_$type, this.pn) != null;
        let g = this.pn != null ? 0.5 * this.pn.getCategorySize(c, d, e) : 0;
        if (this.pn != null && this.pn.b8) {
            g = -g;
        }
        let h = a.f.count * 2;
        let i = new List$1(Array_$type, 2, h);
        this.m2.x(this, this.nn(), this.pn, runOn(this, this.mo), this.nv(b), this.nw(b));
        let j = false;
        let k = this.m2.c;
        if (k != null) {
            j = true;
        }
        for (let l = 0; l < h; l++) {
            let m = new Array(4);
            m[0] = this.p8(l, false, a, g, f);
            m[1] = a.f._inner[(intDivide(l, 2))][1];
            m[2] = this.p8(l, true, a, g, f);
            m[3] = a.f._inner[(intDivide(l, 2))][2];
            i.add(m);
        }
        let n = this.m3.cl.d;
        if (j) {
            let o = new ScalerParams(0, b.bq, b.bp, this.pn.b8, e);
            this.n7(i, -1, this.valueColumn.count, this.pn, o, b.n);
        }
        let p = typeCast(StepAreaSeriesView.$, b);
        let q = p.dh;
        let r = p.dj;
        let s = p.dd;
        let t = p.df;
        this.m2.ae(q, true, false, true, true);
        this.m2.ae(r, true, false, true, true);
        this.m2.ae(s, false, true, false, false);
        this.m2.ae(t, false, true, false, false);
        if (b.cp(a)) {
            p.c7(h, i, false, n, this.eo, (u, v, w, x, y) => this.o7(u, 2 * a.f.count, b), 1, this.om(i, i.count - 1, b.bp, b.bq, true));
            b.cs(a);
        }
        let u = this.fetchYAxis();
        p.dd._opacity = this.d1;
        p.df._opacity = 0.5 * this.d1;
    }
    get currentCategoryMode() {
        return this.preferredCategoryMode(this.pn);
    }
    get useHighMarkerFidelity() {
        return this.nq;
    }
}
StepAreaSeries.$t = markType(StepAreaSeries, 'StepAreaSeries', HorizontalAnchoredCategorySeries.$, [IIsCategoryBased_$type]);
export class StepAreaSeriesView extends AnchoredCategorySeriesView {
    constructor(a) {
        super(a);
        this.c4 = null;
        this.dc = new Path();
        this.dg = new Path();
        this.de = new Path();
        this.di = new Path();
        this.c8 = new Path();
        this.da = new Path();
        this.c9 = new Path();
        this.db = new Path();
        this.c4 = a;
    }
    ap() {
        super.ap();
        if (!this.n) {
            this.e.bj = 1;
        }
    }
    get dd() {
        return this.dc;
    }
    get dh() {
        return this.dg;
    }
    get df() {
        return this.de;
    }
    get dj() {
        return this.di;
    }
    c5() {
        this.dc.aj = null;
        this.de.aj = null;
        this.dg.aj = null;
        this.di.aj = null;
        this.an();
    }
    c6(a, b, c, d, e, f, g) {
        this.c6(a, b, c, d, e, f, g);
    }
    c7(a, b, c, d, e, f, g, h) {
        this.c4.p6.a = typeCast(ISortingAxis_$type, this.cn.fetchXAxis()) !== null ? true : false;
        this.c4.p6.j(this.dc, this.dg, this.de, this.di, a, b, c, d, e, f, g, h);
        this.an();
    }
    a9() {
        super.a9();
        this.c8.aj = this.dc.aj;
        this.da.aj = this.dg.aj;
        this.c9.aj = this.de.aj;
        this.db.aj = this.di.aj;
        let a = this.bk();
        this.c8._fill = a;
        this.c8._opacity = 1;
        this.c9._fill = a;
        this.c9._opacity = 1;
        this.da._stroke = a;
        this.da.ac = this.e.es + 3;
        this.db._stroke = a;
        this.db.ac = this.e.es + 3;
    }
    a3(a, b) {
        super.a3(a, b);
        if (b) {
            a.s(this.c8);
            a.s(this.c9);
            a.s(this.da);
            a.s(this.db);
        }
        else {
            a.s(this.dc);
            a.s(this.de);
            a.s(this.dg);
            a.s(this.di);
        }
    }
    ai(a) {
        super.ai(a);
        this.e.a2.exportPathData(a, this.dg, "lowerShape", ["Lower"]);
        this.e.a2.exportPathData(a, this.di, "upperShape", ["Upper", "Main"]);
        this.e.a2.exportPathData(a, this.de, "translucentShape", ["Translucent"]);
        this.e.a2.exportPathData(a, this.dc, "fillShape", ["Fill"]);
    }
}
StepAreaSeriesView.$t = markType(StepAreaSeriesView, 'StepAreaSeriesView', AnchoredCategorySeriesView.$);
