/*
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 * as tslib_1 from "tslib";
import { HorizontalAnchoredCategorySeries } from "./HorizontalAnchoredCategorySeries";
import { IIsCategoryBased_$type } from "./IIsCategoryBased";
import { CategoryLineRasterizer } from "./CategoryLineRasterizer";
import { typeCast, Array_$type, runOn, markType } from "igniteui-react-core/ES5/type";
import { ISortingAxis_$type } from "./ISortingAxis";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { Path } from "igniteui-react-core/ES5/Path";
import { ScalerParams } from "./ScalerParams";
import { intDivide, isNaN_ } from "igniteui-react-core/ES5/number";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
/**
 * @hidden
 */
var StepAreaSeries = /** @class */ (function (_super) {
    tslib_1.__extends(StepAreaSeries, _super);
    function StepAreaSeries() {
        var _this = _super.call(this) || this;
        _this.qa = null;
        _this.qa = new CategoryLineRasterizer();
        _this.ab = StepAreaSeries.$;
        return _this;
    }
    StepAreaSeries.prototype.bf = function () {
        return new StepAreaSeriesView(this);
    };
    StepAreaSeries.prototype.getHostReferenceValue = function () {
        return this.ee();
    };
    StepAreaSeries.prototype.im = function (a) {
        _super.prototype.im.call(this, a);
        this.qb = a;
    };
    StepAreaSeries.prototype.get_ck = function () {
        return true;
    };
    StepAreaSeries.prototype.preferredCategoryMode = function (a) {
        return typeCast(ISortingAxis_$type, a) !== null ? 0 : 1;
    };
    StepAreaSeries.prototype.hp = function (a, b) {
        _super.prototype.hp.call(this, a, b);
        var c = b;
        c.c7();
    };
    StepAreaSeries.prototype.qc = function (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);
    };
    StepAreaSeries.prototype.m9 = function () {
        return 1;
    };
    StepAreaSeries.prototype.ec = 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;
    };
    StepAreaSeries.prototype.bd = function () {
        if (this.be == 0) {
            return 2;
        }
        else {
            return _super.prototype.bd.call(this);
        }
    };
    StepAreaSeries.prototype.oh = function (a, b) {
        var _this = this;
        _super.prototype.oh.call(this, a, b);
        var c = b.bs;
        var d = b.br;
        var e = this.getEffectiveViewport1(b);
        var f = typeCast(ISortingAxis_$type, this.pr) != null;
        var g = this.pr != null ? 0.5 * this.pr.getCategorySize(c, d, e) : 0;
        if (this.pr != null && this.pr.b8) {
            g = -g;
        }
        var h = a.f.count * 2;
        var i = new List$1(Array_$type, 2, h);
        this.m7.x(this, this.ns(), this.pr, runOn(this, this.mt), this.n0(b), this.n1(b));
        var j = false;
        var k = this.m7.c;
        if (k != null) {
            j = true;
        }
        for (var l = 0; l < h; l++) {
            var m = new Array(4);
            m[0] = this.qc(l, false, a, g, f);
            m[1] = a.f._inner[(intDivide(l, 2))][1];
            m[2] = this.qc(l, true, a, g, f);
            m[3] = a.f._inner[(intDivide(l, 2))][2];
            i.add(m);
        }
        var n = this.m8.cn.d;
        if (j) {
            var o = new ScalerParams(0, b.bs, b.br, this.pr.b8, e);
            this.od(i, -1, this.valueColumn.count, this.pr, o, b.n);
        }
        var p = typeCast(StepAreaSeriesView.$, b);
        var q = p.dj;
        var r = p.dl;
        var s = p.df;
        var t = p.dh;
        this.m7.ae(q, true, false, true, true);
        this.m7.ae(r, true, false, true, true);
        this.m7.ae(s, false, true, false, false);
        this.m7.ae(t, false, true, false, false);
        if (b.cr(a)) {
            p.c9(h, i, false, n, this.er, function (u, v, w, x, y) { return _this.pb(u, 2 * a.f.count, b); }, 1, this.oq(i, i.count - 1, b.br, b.bs, true));
            b.cu(a);
        }
        var u = this.fetchYAxis();
        p.df._opacity = this.d3;
        p.dh._opacity = 0.5 * this.d3;
    };
    Object.defineProperty(StepAreaSeries.prototype, "currentCategoryMode", {
        get: function () {
            return this.preferredCategoryMode(this.pr);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(StepAreaSeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.nv;
        },
        enumerable: true,
        configurable: true
    });
    StepAreaSeries.$t = markType(StepAreaSeries, 'StepAreaSeries', HorizontalAnchoredCategorySeries.$, [IIsCategoryBased_$type]);
    return StepAreaSeries;
}(HorizontalAnchoredCategorySeries));
export { StepAreaSeries };
/**
 * @hidden
 */
var StepAreaSeriesView = /** @class */ (function (_super) {
    tslib_1.__extends(StepAreaSeriesView, _super);
    function StepAreaSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.c6 = null;
        _this.de = new Path();
        _this.di = new Path();
        _this.dg = new Path();
        _this.dk = new Path();
        _this.da = new Path();
        _this.dc = new Path();
        _this.db = new Path();
        _this.dd = new Path();
        _this.c6 = a;
        return _this;
    }
    StepAreaSeriesView.prototype.ap = function () {
        _super.prototype.ap.call(this);
        if (!this.n) {
            this.e.bj = 1;
        }
    };
    Object.defineProperty(StepAreaSeriesView.prototype, "df", {
        get: function () {
            return this.de;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(StepAreaSeriesView.prototype, "dj", {
        get: function () {
            return this.di;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(StepAreaSeriesView.prototype, "dh", {
        get: function () {
            return this.dg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(StepAreaSeriesView.prototype, "dl", {
        get: function () {
            return this.dk;
        },
        enumerable: true,
        configurable: true
    });
    StepAreaSeriesView.prototype.c7 = function () {
        this.de.aj = null;
        this.dg.aj = null;
        this.di.aj = null;
        this.dk.aj = null;
        this.an();
    };
    StepAreaSeriesView.prototype.c8 = function (a, b, c, d, e, f, g) {
        this.c8(a, b, c, d, e, f, g);
    };
    StepAreaSeriesView.prototype.c9 = function (a, b, c, d, e, f, g, h) {
        this.c6.qa.a = typeCast(ISortingAxis_$type, this.cp.fetchXAxis()) !== null ? true : false;
        this.c6.qa.j(this.de, this.di, this.dg, this.dk, a, b, c, d, e, f, g, h);
        this.an();
    };
    StepAreaSeriesView.prototype.a9 = function () {
        _super.prototype.a9.call(this);
        this.da.aj = this.de.aj;
        this.dc.aj = this.di.aj;
        this.db.aj = this.dg.aj;
        this.dd.aj = this.dk.aj;
        var a = this.bl();
        this.da._fill = a;
        this.da._opacity = 1;
        this.db._fill = a;
        this.db._opacity = 1;
        this.dc._stroke = a;
        this.dc.ac = this.e.ev + 3;
        this.dd._stroke = a;
        this.dd.ac = this.e.ev + 3;
    };
    StepAreaSeriesView.prototype.a3 = function (a, b) {
        _super.prototype.a3.call(this, a, b);
        if (b) {
            a.s(this.da);
            a.s(this.db);
            a.s(this.dc);
            a.s(this.dd);
        }
        else {
            a.s(this.de);
            a.s(this.dg);
            a.s(this.di);
            a.s(this.dk);
        }
    };
    StepAreaSeriesView.prototype.ai = function (a) {
        _super.prototype.ai.call(this, a);
        this.e.a2.exportPathData(a, this.di, "lowerShape", ["Lower"]);
        this.e.a2.exportPathData(a, this.dk, "upperShape", ["Upper", "Main"]);
        this.e.a2.exportPathData(a, this.dg, "translucentShape", ["Translucent"]);
        this.e.a2.exportPathData(a, this.de, "fillShape", ["Fill"]);
    };
    StepAreaSeriesView.$t = markType(StepAreaSeriesView, 'StepAreaSeriesView', AnchoredCategorySeriesView.$);
    return StepAreaSeriesView;
}(AnchoredCategorySeriesView));
export { StepAreaSeriesView };
