/*
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 { CategoryLineRasterizer } from "./CategoryLineRasterizer";
import { typeCast, Array_$type, runOn, markType } from "igniteui-react-core";
import { ISortingAxis_$type } from "./ISortingAxis";
import { List$1 } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { ChartSelection } from "./ChartSelection";
import { intDivide, isNaN_ } from "igniteui-react-core";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
import { Defaults } from "./Defaults";
/**
 * @hidden
 */
export let StepAreaSeries = /*@__PURE__*/ (() => {
    class StepAreaSeries extends HorizontalAnchoredCategorySeries {
        bj() {
            return new StepAreaSeries();
        }
        cs() {
            return new StepAreaSeriesView(this);
        }
        qz(a) {
            super.qz(a);
            this.acv = a;
        }
        get_ev() {
            return true;
        }
        get_eu() {
            return true;
        }
        get_f1() {
            return true;
        }
        get_fl() {
            return true;
        }
        cy() {
            if (this.cz == 0) {
                return 2;
            }
            return super.cy();
        }
        constructor() {
            super();
            this.acu = null;
            this.acu = new CategoryLineRasterizer();
            this.ab = StepAreaSeries.$;
        }
        preferredCategoryMode(a) {
            return typeCast(ISortingAxis_$type, a) !== null ? 0 : 1;
        }
        o5(a, b) {
            super.o5(a, b);
            let c = b;
            c.dg();
        }
        acw(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);
        }
        y2() {
            return 1;
        }
        iv(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;
        }
        b2() {
            if (this.b3 == 0) {
                return 2;
            }
            else {
                return super.b2();
            }
        }
        aai(a, b) {
            super.aai(a, b);
            let c = b.by;
            let d = b.bx;
            let e = this.getEffectiveViewport1(b);
            let f = typeCast(ISortingAxis_$type, this.acb) != null;
            let g = this.acb != null ? 0.5 * this.acb.getCategorySize(c, d, e) : 0;
            if (this.acb != null && this.acb.ch) {
                g = -g;
            }
            let h = a.f.count * 2;
            let i = new List$1(Array_$type, 2, h);
            this.y0.a2(this, this.zk(), runOn(this, this.yk), this.zt(b), this.zu(b));
            let j = false;
            let k = this.y0.b;
            if (k != null) {
                j = true;
            }
            for (let l = 0; l < h; l++) {
                let m = new Array(4);
                m[0] = this.acw(l, false, a, g, f);
                m[1] = a.f._inner[(intDivide(l, 2))][1];
                m[2] = this.acw(l, true, a, g, f);
                m[3] = a.f._inner[(intDivide(l, 2))][2];
                i.add(m);
            }
            let n = this.y1.cw.d;
            if (j) {
                let o = new ScalerParams(0, b.by, b.bx, this.acb.ch, e);
                this.aae(i, -1, this.valueColumn.count, this.acb, o, b.q, -1);
            }
            let p = typeCast(StepAreaSeriesView.$, b);
            let q = p.du;
            let r = p.dv;
            let s = p.ds;
            let t = p.dt;
            this.y0.ad(q, true, false, true, true);
            this.y0.ad(r, true, false, true, true);
            this.y0.ad(s, false, true, false, false);
            this.y0.ad(t, false, true, false, false);
            if (b.c0(a)) {
                p.di(h, i, false, n, this.id, (u, v, w, x, y) => this.abr(u, 2 * a.f.count, b), 1, this.aas(i, i.count - 1, b.bx, b.by, true));
                b.c3(a);
            }
            let u = this.fetchYAxis();
            p.ds._opacity = this.y0.j * this.h9;
            p.dt._opacity = 0.5 * this.y0.j * this.h9;
        }
        p2(a, b, c) {
            this.aaa(a, b, c, this.yr, 1);
        }
        ak(a, b) {
            let c = new List$1(ChartSelection.$, 0);
            this.p2(a, c, b);
            return c.toArray();
        }
        get useHighMarkerFidelity() {
            return this.zo;
        }
    }
    StepAreaSeries.$t = /*@__PURE__*/ markType(StepAreaSeries, 'StepAreaSeries', HorizontalAnchoredCategorySeries.$);
    return StepAreaSeries;
})();
/**
 * @hidden
 */
export let StepAreaSeriesView = /*@__PURE__*/ (() => {
    class StepAreaSeriesView extends AnchoredCategorySeriesView {
        constructor(a) {
            super(a);
            this.df = null;
            this.dn = new Path();
            this.dq = new Path();
            this.dp = new Path();
            this.dr = new Path();
            this.dj = new Path();
            this.dl = new Path();
            this.dk = new Path();
            this.dm = new Path();
            this.df = a;
        }
        au() {
            super.au();
            if (!this.q) {
                this.df.w8 = Defaults.c;
            }
        }
        get ds() {
            return this.dn;
        }
        get du() {
            return this.dq;
        }
        get dt() {
            return this.dp;
        }
        get dv() {
            return this.dr;
        }
        dg() {
            this.dn.an = null;
            this.dp.an = null;
            this.dq.an = null;
            this.dr.an = null;
            this.as();
        }
        dh(a, b, c, d, e, f, g) {
            this.dh(a, b, c, d, e, f, g);
        }
        di(a, b, c, d, e, f, g, h) {
            this.df.acu.a = typeCast(ISortingAxis_$type, this.cy.fetchXAxis()) !== null ? true : false;
            this.df.acu.j(this.dn, this.dq, this.dp, this.dr, a, b, c, d, e, f, g, h);
            this.as();
        }
        be() {
            super.be();
            this.dj.an = this.dn.an;
            this.dl.an = this.dq.an;
            this.dk.an = this.dp.an;
            this.dm.an = this.dr.an;
            let a = this.br();
            this.dj._fill = a;
            this.dj._opacity = 1;
            this.dk._fill = a;
            this.dk._opacity = 1;
            this.dl._stroke = a;
            this.dl.ad = this.e.ie + 3;
            this.dm._stroke = a;
            this.dm.ad = this.e.ie + 3;
        }
        a8(a, b) {
            super.a8(a, b);
            if (b) {
                a.t(this.dj);
                a.t(this.dk);
                a.t(this.dl);
                a.t(this.dm);
            }
            else {
                a.t(this.dn);
                a.t(this.dp);
                a.t(this.dq);
                a.t(this.dr);
            }
        }
        an(a) {
            super.an(a);
            this.e.bc.exportPathData(a, this.dq, "lowerShape", ["Lower"]);
            this.e.bc.exportPathData(a, this.dr, "upperShape", ["Upper", "Main"]);
            this.e.bc.exportPathData(a, this.dp, "translucentShape", ["Translucent"]);
            this.e.bc.exportPathData(a, this.dn, "fillShape", ["Fill"]);
        }
    }
    StepAreaSeriesView.$t = /*@__PURE__*/ markType(StepAreaSeriesView, 'StepAreaSeriesView', AnchoredCategorySeriesView.$);
    return StepAreaSeriesView;
})();
