/*
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 { intDivide, isNaN_ } from "igniteui-angular-core";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
import { Defaults } from "./Defaults";
import { Color } from "igniteui-angular-core";
/**
 * @hidden
 */
export let StepLineSeries = /*@__PURE__*/ (() => {
    class StepLineSeries extends HorizontalAnchoredCategorySeries {
        constructor() {
            super();
            this.u6 = null;
            this.u6 = new CategoryLineRasterizer();
            this.ab = StepLineSeries.$;
        }
        get_d1() {
            return true;
        }
        get_eh() {
            return true;
        }
        get_d2() {
            return true;
        }
        bx() {
            return new StepLineSeriesView(this);
        }
        ly(a) {
            super.ly(a);
            this.u7 = a;
        }
        ac() {
            super.ac();
        }
        preferredCategoryMode(a) {
            return typeCast(ISortingAxis_$type, a) !== null ? 0 : 1;
        }
        get_de() {
            return true;
        }
        kx(a, b) {
            super.kx(a, b);
            let c = b;
            c.db();
        }
        bp() {
            if (this.bq == 0) {
                return 2;
            }
            else {
                return super.bp();
            }
        }
        f9(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;
        }
        u8(a, b, c, d, e, f) {
            let g;
            if (b) {
                if (f) {
                    g = (a & 1) == 0;
                    if (g || (intDivide(a, 2)) + 1 < 0) {
                        return c.f._inner[(intDivide(a, 2))][0];
                    }
                    if (c.f.count == (intDivide(a, 2)) + 1) {
                        return c.f._inner[(intDivide(a, 2))][0];
                    }
                    return c.f._inner[(intDivide(a, 2)) + 1][0];
                }
                g = (a & 1) == 0;
                return c.f._inner[(intDivide(a, 2))][0] + (g ? d : -d);
            }
            if (f) {
                g = (a & 1) == 0;
                if (g || ((intDivide(a, 2)) + 1) >= c.f.count) {
                    return c.f._inner[(intDivide(a, 2))][0];
                }
                if (c.f.count == (intDivide(a, 2)) + 1) {
                    return c.f._inner[(intDivide(a, 2))][0];
                }
                return c.f._inner[(intDivide(a, 2)) + 1][0];
            }
            g = (a & 1) == 0;
            return c.f._inner[(intDivide(a, 2))][0] + (g ? -d : d);
        }
        s6(a, b) {
            super.s6(a, b);
            let c = b.bv;
            let d = b.bu;
            let e = this.getEffectiveViewport1(b);
            let f = typeCast(ISortingAxis_$type, this.un) != null;
            let g = this.un.cg;
            let h = 0;
            if (this.un != null) {
                h = 0.5 * this.un.getCategorySize(c, d, e);
            }
            let i = a.f;
            let j = 2 * i.count;
            let k = new List$1(Array_$type, 2, j);
            if (!this.un.cg) {
                for (let l = 0; l < j; l++) {
                    let m = new Array(4);
                    m[0] = this.u8(l, false, a, h, g, f);
                    m[1] = a.f._inner[(intDivide(l, 2))][1];
                    m[2] = this.u8(l, true, a, h, g, f);
                    m[3] = a.f._inner[(intDivide(l, 2))][2];
                    k.add(m);
                }
            }
            else {
                for (let n = 0; n < j; n++) {
                    let o = new Array(4);
                    o[0] = this.u8(n, true, a, h, g, f);
                    o[1] = a.f._inner[(intDivide(n, 2))][1];
                    o[2] = this.u8(n, true, a, h, g, f);
                    o[3] = a.f._inner[(intDivide(n, 2))][2];
                    k.add(o);
                }
            }
            let p = typeCast(StepLineSeriesView.$, b);
            let q = p.cr.d;
            this.rw.a0(this, this.sg(), runOn(this, this.rh), this.so(b), this.sp(b));
            let r = false;
            let s = this.rw.b;
            if (s != null) {
                r = true;
            }
            if (r) {
                let t = new ScalerParams(0, b.bv, b.bu, this.un.cg, e);
                this.s2(i, -1, this.valueColumn.count, this.un, t, b.q);
            }
            let u = p.dh;
            let v = p.di;
            let w = p.dg;
            this.rw.ad(u, true, false, true, false);
            this.rw.ad(v, true, false, true, false);
            this.rw.ad(w, false, true, false, false);
            w._opacity = 0.75 * this.rw.j;
            if (b.cv(a)) {
                p.dc(j, k, false, 1, this.te(k, j - 1, b.bu, b.bv), q, this.ft);
                b.cy(a);
            }
        }
        get useHighMarkerFidelity() {
            return this.sj;
        }
    }
    StepLineSeries.$t = markType(StepLineSeries, 'StepLineSeries', HorizontalAnchoredCategorySeries.$);
    return StepLineSeries;
})();
/**
 * @hidden
 */
export let StepLineSeriesView = /*@__PURE__*/ (() => {
    class StepLineSeriesView extends AnchoredCategorySeriesView {
        constructor(a) {
            super(a);
            this.da = null;
            this.dk = new Path();
            this.dj = new Path();
            this.dl = new Path();
            this.df = new Path();
            this.de = new Path();
            this.dd = new Path();
            this.da = a;
        }
        as() {
            super.as();
            if (!this.q) {
                this.da.qc = Defaults.c;
            }
        }
        get dh() {
            return this.dk;
        }
        get di() {
            return this.dl;
        }
        get dg() {
            return this.dj;
        }
        db() {
            this.dj.ak = null;
            this.dk.ak = null;
            this.dl.ak = null;
            this.aq();
        }
        dc(a, b, c, d, e, f, g) {
            this.da.u6.a = typeCast(ISortingAxis_$type, this.ct.fetchXAxis()) !== null ? true : false;
            this.da.u6.m(this.dk, this.dj, this.dl, a, b, c, d, e, f, g);
            this.aq();
        }
        bc() {
            super.bc();
            this.de.ak = this.dk.ak;
            this.df.ak = this.dl.ak;
            this.dd.ak = this.dj.ak;
            let a = this.bo();
            this.de._stroke = a;
            this.de.ac = this.e.fu + 3;
            this.df._stroke = a;
            this.df.ac = this.e.fu + 3;
            this.dd._fill = a;
            this.dd._opacity = 1;
        }
        a6(a, b) {
            super.a6(a, b);
            if (a.d) {
                if (b) {
                    a.s(this.dd);
                    a.s(this.de);
                    a.s(this.df);
                }
                else {
                    a.s(this.dj);
                    a.s(this.dk);
                    a.s(this.dl);
                }
            }
        }
        al(a) {
            super.al(a);
            this.e.a8.exportPathData(a, this.dk, "lowerShape", ["Lower", "Main"]);
            this.e.a8.exportPathData(a, this.dl, "upperShape", ["Upper"]);
            this.e.a8.exportPathData(a, this.dj, "translucentShape", ["Translucent"]);
        }
        af() {
            let a = new Color();
            a.colorString = "rgba(95,95,95,0.5)";
            this.e.pa = a;
            this.e.gw = 3;
            this.e.gx = 1;
            this.e.gy = 4;
            this.e.e7 = false;
        }
    }
    StepLineSeriesView.$t = markType(StepLineSeriesView, 'StepLineSeriesView', AnchoredCategorySeriesView.$);
    return StepLineSeriesView;
})();
