/*
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 { intDivide, isNaN_ } from "igniteui-react-core";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
import { Defaults } from "./Defaults";
/**
 * @hidden
 */
export let StepAreaSeries = /*@__PURE__*/ (() => {
    class StepAreaSeries extends HorizontalAnchoredCategorySeries {
        bc() {
            return new StepAreaSeries();
        }
        cd() {
            return new StepAreaSeriesView(this);
        }
        o2(a) {
            super.o2(a);
            this.zh = a;
        }
        get_ea() {
            return true;
        }
        get_d9() {
            return true;
        }
        get_ff() {
            return true;
        }
        get_ez() {
            return true;
        }
        cj() {
            if (this.ck == 0) {
                return 2;
            }
            return super.cj();
        }
        constructor() {
            super();
            this.zg = null;
            this.zg = new CategoryLineRasterizer();
            this.ab = StepAreaSeries.$;
        }
        preferredCategoryMode(a) {
            return typeCast(ISortingAxis_$type, a) !== null ? 0 : 1;
        }
        nk(a, b) {
            super.nk(a, b);
            let c = b;
            c.de();
        }
        zi(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);
        }
        vy() {
            return 1;
        }
        h0(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;
        }
        bu() {
            if (this.bv == 0) {
                return 2;
            }
            else {
                return super.bu();
            }
        }
        w7(a, b) {
            super.w7(a, b);
            let c = b.by;
            let d = b.bx;
            let e = this.getEffectiveViewport1(b);
            let f = typeCast(ISortingAxis_$type, this.yx) != null;
            let g = this.yx != null ? 0.5 * this.yx.getCategorySize(c, d, e) : 0;
            if (this.yx != null && this.yx.ch) {
                g = -g;
            }
            let h = a.f.count * 2;
            let i = new List$1(Array_$type, 2, h);
            this.vw.a2(this, this.wg(), runOn(this, this.vh), this.wp(b), this.wq(b));
            let j = false;
            let k = this.vw.b;
            if (k != null) {
                j = true;
            }
            for (let l = 0; l < h; l++) {
                let m = new Array(4);
                m[0] = this.zi(l, false, a, g, f);
                m[1] = a.f._inner[(intDivide(l, 2))][1];
                m[2] = this.zi(l, true, a, g, f);
                m[3] = a.f._inner[(intDivide(l, 2))][2];
                i.add(m);
            }
            let n = this.vx.cu.d;
            if (j) {
                let o = new ScalerParams(0, b.by, b.bx, this.yx.ch, e);
                this.w3(i, -1, this.valueColumn.count, this.yx, o, b.q);
            }
            let p = typeCast(StepAreaSeriesView.$, b);
            let q = p.ds;
            let r = p.dt;
            let s = p.dq;
            let t = p.dr;
            this.vw.ad(q, true, false, true, true);
            this.vw.ad(r, true, false, true, true);
            this.vw.ad(s, false, true, false, false);
            this.vw.ad(t, false, true, false, false);
            if (b.cy(a)) {
                p.dg(h, i, false, n, this.hk, (u, v, w, x, y) => this.yd(u, 2 * a.f.count, b), 1, this.xg(i, i.count - 1, b.bx, b.by, true));
                b.c1(a);
            }
            let u = this.fetchYAxis();
            p.dq._opacity = this.vw.j * this.hg;
            p.dr._opacity = 0.5 * this.vw.j * this.hg;
        }
        get useHighMarkerFidelity() {
            return this.wk;
        }
    }
    StepAreaSeries.$t = /*@__PURE__*/ markType(StepAreaSeries, 'StepAreaSeries', HorizontalAnchoredCategorySeries.$);
    return StepAreaSeries;
})();
/**
 * @hidden
 */
export let StepAreaSeriesView = /*@__PURE__*/ (() => {
    class StepAreaSeriesView extends AnchoredCategorySeriesView {
        constructor(a) {
            super(a);
            this.dd = null;
            this.dl = new Path();
            this.dn = new Path();
            this.dm = new Path();
            this.dp = new Path();
            this.dh = new Path();
            this.dj = new Path();
            this.di = new Path();
            this.dk = new Path();
            this.dd = a;
        }
        au() {
            super.au();
            if (!this.q) {
                this.dd.uc = Defaults.c;
            }
        }
        get dq() {
            return this.dl;
        }
        get ds() {
            return this.dn;
        }
        get dr() {
            return this.dm;
        }
        get dt() {
            return this.dp;
        }
        de() {
            this.dl.an = null;
            this.dm.an = null;
            this.dn.an = null;
            this.dp.an = null;
            this.as();
        }
        df(a, b, c, d, e, f, g) {
            this.df(a, b, c, d, e, f, g);
        }
        dg(a, b, c, d, e, f, g, h) {
            this.dd.zg.a = typeCast(ISortingAxis_$type, this.cw.fetchXAxis()) !== null ? true : false;
            this.dd.zg.j(this.dl, this.dn, this.dm, this.dp, a, b, c, d, e, f, g, h);
            this.as();
        }
        be() {
            super.be();
            this.dh.an = this.dl.an;
            this.dj.an = this.dn.an;
            this.di.an = this.dm.an;
            this.dk.an = this.dp.an;
            let a = this.br();
            this.dh._fill = a;
            this.dh._opacity = 1;
            this.di._fill = a;
            this.di._opacity = 1;
            this.dj._stroke = a;
            this.dj.ad = this.e.hl + 3;
            this.dk._stroke = a;
            this.dk.ad = this.e.hl + 3;
        }
        a8(a, b) {
            super.a8(a, b);
            if (b) {
                a.t(this.dh);
                a.t(this.di);
                a.t(this.dj);
                a.t(this.dk);
            }
            else {
                a.t(this.dl);
                a.t(this.dm);
                a.t(this.dn);
                a.t(this.dp);
            }
        }
        an(a) {
            super.an(a);
            this.e.a5.exportPathData(a, this.dn, "lowerShape", ["Lower"]);
            this.e.a5.exportPathData(a, this.dp, "upperShape", ["Upper", "Main"]);
            this.e.a5.exportPathData(a, this.dm, "translucentShape", ["Translucent"]);
            this.e.a5.exportPathData(a, this.dl, "fillShape", ["Fill"]);
        }
    }
    StepAreaSeriesView.$t = /*@__PURE__*/ markType(StepAreaSeriesView, 'StepAreaSeriesView', AnchoredCategorySeriesView.$);
    return StepAreaSeriesView;
})();
