/*
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 { __extends } from "tslib";
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
 */
var StepLineSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(StepLineSeries, _super);
    function StepLineSeries() {
        var _this = _super.call(this) || this;
        _this.vj = null;
        _this.vj = new CategoryLineRasterizer();
        _this.ab = StepLineSeries.$;
        return _this;
    }
    StepLineSeries.prototype.get_d4 = function () {
        return true;
    };
    StepLineSeries.prototype.get_ek = function () {
        return true;
    };
    StepLineSeries.prototype.get_d5 = function () {
        return true;
    };
    StepLineSeries.prototype.by = function () {
        return new StepLineSeriesView(this);
    };
    StepLineSeries.prototype.l4 = function (a) {
        _super.prototype.l4.call(this, a);
        this.vk = a;
    };
    StepLineSeries.prototype.ac = function () {
        _super.prototype.ac.call(this);
    };
    StepLineSeries.prototype.preferredCategoryMode = function (a) {
        return typeCast(ISortingAxis_$type, a) !== null ? 0 : 1;
    };
    StepLineSeries.prototype.get_dg = function () {
        return true;
    };
    StepLineSeries.prototype.k2 = function (a, b) {
        _super.prototype.k2.call(this, a, b);
        var c = b;
        c.db();
    };
    StepLineSeries.prototype.bq = function () {
        if (this.br == 0) {
            return 2;
        }
        else {
            return _super.prototype.bq.call(this);
        }
    };
    StepLineSeries.prototype.gd = function (a, b, c, d, e, f, g, h) {
        var i = NaN;
        if (c >= 0 && c < b.count) {
            i = b.item(c);
        }
        var 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;
    };
    StepLineSeries.prototype.vl = function (a, b, c, d, e, f) {
        var 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);
    };
    StepLineSeries.prototype.tf = function (a, b) {
        _super.prototype.tf.call(this, a, b);
        var c = b.bv;
        var d = b.bu;
        var e = this.getEffectiveViewport1(b);
        var f = typeCast(ISortingAxis_$type, this.u0) != null;
        var g = this.u0.cg;
        var h = 0;
        if (this.u0 != null) {
            h = 0.5 * this.u0.getCategorySize(c, d, e);
        }
        var i = a.f;
        var j = 2 * i.count;
        var k = new List$1(Array_$type, 2, j);
        if (!this.u0.cg) {
            for (var l = 0; l < j; l++) {
                var m = new Array(4);
                m[0] = this.vl(l, false, a, h, g, f);
                m[1] = a.f._inner[(intDivide(l, 2))][1];
                m[2] = this.vl(l, true, a, h, g, f);
                m[3] = a.f._inner[(intDivide(l, 2))][2];
                k.add(m);
            }
        }
        else {
            for (var n = 0; n < j; n++) {
                var o = new Array(4);
                o[0] = this.vl(n, true, a, h, g, f);
                o[1] = a.f._inner[(intDivide(n, 2))][1];
                o[2] = this.vl(n, true, a, h, g, f);
                o[3] = a.f._inner[(intDivide(n, 2))][2];
                k.add(o);
            }
        }
        var p = typeCast(StepLineSeriesView.$, b);
        var q = p.cr.d;
        this.r5.a2(this, this.sp(), runOn(this, this.rq), this.sx(b), this.sy(b));
        var r = false;
        var s = this.r5.b;
        if (s != null) {
            r = true;
        }
        if (r) {
            var t = new ScalerParams(0, b.bv, b.bu, this.u0.cg, e);
            this.tb(i, -1, this.valueColumn.count, this.u0, t, b.q);
        }
        var u = p.dh;
        var v = p.di;
        var w = p.dg;
        this.r5.ad(u, true, false, true, false);
        this.r5.ad(v, true, false, true, false);
        this.r5.ad(w, false, true, false, false);
        w._opacity = 0.75 * this.r5.j;
        if (b.cv(a)) {
            p.dc(j, k, false, 1, this.tn(k, j - 1, b.bu, b.bv), q, this.fx);
            b.cy(a);
        }
    };
    Object.defineProperty(StepLineSeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.ss;
        },
        enumerable: false,
        configurable: true
    });
    StepLineSeries.$t = markType(StepLineSeries, 'StepLineSeries', HorizontalAnchoredCategorySeries.$);
    return StepLineSeries;
}(HorizontalAnchoredCategorySeries));
export { StepLineSeries };
/**
 * @hidden
 */
var StepLineSeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(StepLineSeriesView, _super);
    function StepLineSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _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;
        return _this;
    }
    StepLineSeriesView.prototype.as = function () {
        _super.prototype.as.call(this);
        if (!this.q) {
            this.da.ql = Defaults.c;
        }
    };
    Object.defineProperty(StepLineSeriesView.prototype, "dh", {
        get: function () {
            return this.dk;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(StepLineSeriesView.prototype, "di", {
        get: function () {
            return this.dl;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(StepLineSeriesView.prototype, "dg", {
        get: function () {
            return this.dj;
        },
        enumerable: false,
        configurable: true
    });
    StepLineSeriesView.prototype.db = function () {
        this.dj.an = null;
        this.dk.an = null;
        this.dl.an = null;
        this.aq();
    };
    StepLineSeriesView.prototype.dc = function (a, b, c, d, e, f, g) {
        this.da.vj.a = typeCast(ISortingAxis_$type, this.ct.fetchXAxis()) !== null ? true : false;
        this.da.vj.m(this.dk, this.dj, this.dl, a, b, c, d, e, f, g);
        this.aq();
    };
    StepLineSeriesView.prototype.bc = function () {
        _super.prototype.bc.call(this);
        this.de.an = this.dk.an;
        this.df.an = this.dl.an;
        this.dd.an = this.dj.an;
        var a = this.bo();
        this.de._stroke = a;
        this.de.ad = this.e.fy + 3;
        this.df._stroke = a;
        this.df.ad = this.e.fy + 3;
        this.dd._fill = a;
        this.dd._opacity = 1;
    };
    StepLineSeriesView.prototype.a6 = function (a, b) {
        _super.prototype.a6.call(this, a, b);
        if (a.d) {
            if (b) {
                a.t(this.dd);
                a.t(this.de);
                a.t(this.df);
            }
            else {
                a.t(this.dj);
                a.t(this.dk);
                a.t(this.dl);
            }
        }
    };
    StepLineSeriesView.prototype.al = function (a) {
        _super.prototype.al.call(this, a);
        this.e.a9.exportPathData(a, this.dk, "lowerShape", ["Lower", "Main"]);
        this.e.a9.exportPathData(a, this.dl, "upperShape", ["Upper"]);
        this.e.a9.exportPathData(a, this.dj, "translucentShape", ["Translucent"]);
    };
    StepLineSeriesView.prototype.af = function () {
        var a = new Color();
        a.colorString = "rgba(95,95,95,0.5)";
        this.e.ph = a;
        this.e.g1 = 3;
        this.e.g2 = 1;
        this.e.g3 = 4;
        this.e.fb = false;
    };
    StepLineSeriesView.$t = markType(StepLineSeriesView, 'StepLineSeriesView', AnchoredCategorySeriesView.$);
    return StepLineSeriesView;
}(AnchoredCategorySeriesView));
export { StepLineSeriesView };
