/*
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-angular-core";
import { ISortingAxis_$type } from "./ISortingAxis";
import { List$1 } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { ChartSelection } from "./ChartSelection";
import { intDivide, isNaN_ } from "igniteui-angular-core";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
import { Defaults } from "./Defaults";
/**
 * @hidden
 */
export let StepAreaSeries = /*@__PURE__*/ (() => {
    class StepAreaSeries extends HorizontalAnchoredCategorySeries {
        constructor() {
            super();
            this.ac8 = null;
            this.ac8 = new CategoryLineRasterizer();
            this.ab = StepAreaSeries.$;
        }
        bk() {
            return new StepAreaSeries();
        }
        ct() {
            return new StepAreaSeriesView(this);
        }
        q7(a) {
            super.q7(a);
            this.ac9 = a;
        }
        get_ex() {
            return true;
        }
        get_ew() {
            return true;
        }
        get_f2() {
            return true;
        }
        get_fm() {
            return true;
        }
        cz() {
            if (this.c0 == 0) {
                return 2;
            }
            return super.cz();
        }
        preferredCategoryMode(a) {
            return typeCast(ISortingAxis_$type, a) !== null ? 0 : 1;
        }
        pb(a, b) {
            super.pb(a, b);
            let c = b;
            c.du();
        }
        ada(a, b, c, d, e) {
            if (b) {
                if (e) {
                    if ((a & 1) == 0 || ((intDivide(a, 2)) + 1) >= c.h.count) {
                        return c.h._inner[(intDivide(a, 2))][0];
                    }
                    return c.h._inner[(intDivide(a, 2)) + 1][0];
                }
                return c.h._inner[(intDivide(a, 2))][0] + ((a & 1) == 1 ? -d : d);
            }
            if (e) {
                if ((a & 1) == 0 || ((intDivide(a, 2)) + 1) >= c.h.count) {
                    return c.h._inner[(intDivide(a, 2))][0];
                }
                return c.h._inner[(intDivide(a, 2)) + 1][0];
            }
            return c.h._inner[(intDivide(a, 2))][0] + ((a & 1) == 0 ? -d : d);
        }
        ze() {
            return 1;
        }
        ix(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;
        }
        b3() {
            if (this.b4 == 0) {
                return 2;
            }
            else {
                return super.b3();
            }
        }
        aax(a, b) {
            super.aax(a, b);
            let c = b.ca;
            let d = b.b9;
            let e = this.getEffectiveViewport1(b);
            let f = typeCast(ISortingAxis_$type, this.acp) != null;
            let g = this.acp != null ? 0.5 * this.acp.getCategorySize(c, d, e) : 0;
            if (this.acp != null && this.acp.df) {
                g = -g;
            }
            let h = a.h.count * 2;
            let i = new List$1(Array_$type, 2, h);
            this.zc.a2(this, this.zw(), runOn(this, this.yw), this.z5(b), this.z6(b));
            let j = false;
            let k = this.zc.b;
            if (k != null) {
                j = true;
            }
            for (let l = 0; l < h; l++) {
                let m = new Array(4);
                m[0] = this.ada(l, false, a, g, f);
                m[1] = a.h._inner[(intDivide(l, 2))][1];
                m[2] = this.ada(l, true, a, g, f);
                m[3] = a.h._inner[(intDivide(l, 2))][2];
                i.add(m);
            }
            let n = this.zd.c9.d;
            if (j) {
                let o = new ScalerParams(0, b.ca, b.b9, this.acp.df, e);
                this.aat(i, -1, this.valueColumn.count, this.acp, o, b.t, -1);
            }
            let p = typeCast(StepAreaSeriesView.$, b);
            let q = p.d7;
            let r = p.d8;
            let s = p.d5;
            let t = p.d6;
            this.zc.ad(q, true, false, true, true);
            this.zc.ad(r, true, false, true, true);
            this.zc.ad(s, false, true, false, false);
            this.zc.ad(t, false, true, false, false);
            if (b.dd(a)) {
                p.dw(h, i, false, n, this.ie, (u, v, w, x, y) => this.ab5(u, 2 * a.h.count, b), 1, this.aa6(i, i.count - 1, b.b9, b.ca, true));
                b.dg(a);
            }
            let u = this.fetchYAxis();
            p.d5._opacity = this.zc.j * this.ia;
            p.d6._opacity = 0.5 * this.zc.j * this.ia;
        }
        qa(a, b, c) {
            this.aap(a, b, c, this.y3, 1);
        }
        ak(a, b) {
            let c = new List$1(ChartSelection.$, 0);
            this.qa(a, c, b);
            return c.toArray();
        }
        get useHighMarkerFidelity() {
            return this.z0;
        }
    }
    StepAreaSeries.$t = markType(StepAreaSeries, 'StepAreaSeries', HorizontalAnchoredCategorySeries.$);
    return StepAreaSeries;
})();
/**
 * @hidden
 */
export let StepAreaSeriesView = /*@__PURE__*/ (() => {
    class StepAreaSeriesView extends AnchoredCategorySeriesView {
        constructor(a) {
            super(a);
            this.dt = null;
            this.d1 = new Path();
            this.d3 = new Path();
            this.d2 = new Path();
            this.d4 = new Path();
            this.dx = new Path();
            this.dz = new Path();
            this.dy = new Path();
            this.d0 = new Path();
            this.dt = a;
        }
        a4() {
            super.a4();
            if (!this.t) {
                this.dt.xk = Defaults.c;
            }
        }
        get d5() {
            return this.d1;
        }
        get d7() {
            return this.d3;
        }
        get d6() {
            return this.d2;
        }
        get d8() {
            return this.d4;
        }
        du() {
            this.d1.an = null;
            this.d2.an = null;
            this.d3.an = null;
            this.d4.an = null;
            this.a2();
        }
        dv(a, b, c, d, e, f, g) {
            this.dv(a, b, c, d, e, f, g);
        }
        dw(a, b, c, d, e, f, g, h) {
            this.dt.ac8.a = typeCast(ISortingAxis_$type, this.db.fetchXAxis()) !== null ? true : false;
            this.dt.ac8.j(this.d1, this.d3, this.d2, this.d4, a, b, c, d, e, f, g, h);
            this.a2();
        }
        bq() {
            super.bq();
            this.dx.an = this.d1.an;
            this.dz.an = this.d3.an;
            this.dy.an = this.d2.an;
            this.d0.an = this.d4.an;
            let a = this.b3();
            this.dx._fill = a;
            this.dx._opacity = 1;
            this.dy._fill = a;
            this.dy._opacity = 1;
            this.dz._stroke = a;
            this.dz.ad = this.f.ig + 3;
            this.d0._stroke = a;
            this.d0.ad = this.f.ig + 3;
        }
        bj(a, b) {
            super.bj(a, b);
            if (b) {
                a.t(this.dx);
                a.t(this.dy);
                a.t(this.dz);
                a.t(this.d0);
            }
            else {
                a.t(this.d1);
                a.t(this.d2);
                a.t(this.d3);
                a.t(this.d4);
            }
        }
        ax(a) {
            super.ax(a);
            this.f.bc.exportPathData(a, this.d3, "lowerShape", ["Lower"]);
            this.f.bc.exportPathData(a, this.d4, "upperShape", ["Upper", "Main"]);
            this.f.bc.exportPathData(a, this.d2, "translucentShape", ["Translucent"]);
            this.f.bc.exportPathData(a, this.d1, "fillShape", ["Fill"]);
        }
    }
    StepAreaSeriesView.$t = markType(StepAreaSeriesView, 'StepAreaSeriesView', AnchoredCategorySeriesView.$);
    return StepAreaSeriesView;
})();
