/*
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 { HorizontalRangeCategorySeries } from "./HorizontalRangeCategorySeries";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { Type, typeCast, runOn, markType, fromEnum } from "igniteui-react-core/ES5/type";
import { Rect } from "igniteui-react-core/ES5/Rect";
import { ScalerParams } from "./ScalerParams";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { Pool$1 } from "igniteui-react-core/ES5/Pool$1";
import { Rectangle } from "igniteui-react-core/ES5/Rectangle";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
import { isNaN_, isInfinity } from "igniteui-react-core/ES5/number";
import { RangeCategorySeriesView } from "./RangeCategorySeriesView";
var RangeColumnSeries = /** @class */ (function (_super) {
    tslib_1.__extends(RangeColumnSeries, _super);
    function RangeColumnSeries() {
        var _this = _super.call(this) || this;
        _this.ab = RangeColumnSeries.$;
        return _this;
    }
    RangeColumnSeries.prototype.bf = function () {
        return new RangeColumnSeriesView(this);
    };
    RangeColumnSeries.prototype.ii = function (a) {
        _super.prototype.ii.call(this, a);
        this.o8 = a;
    };
    RangeColumnSeries.prototype.get_nj = function () {
        return true;
    };
    Object.defineProperty(RangeColumnSeries.prototype, "nj", {
        get: function () {
            return this.get_nj();
        },
        enumerable: true,
        configurable: true
    });
    RangeColumnSeries.prototype.preferredCategoryMode = function (a) {
        return 2;
    };
    RangeColumnSeries.prototype.li = function (a) {
        if (this.xAxis == null || this.yAxis == null) {
            return Rect.empty;
        }
        var b = this.k4(a);
        var c = this.bi.bq;
        var d = this.bi.bp;
        var e = this.getEffectiveViewport1(this.bi);
        var f = new ScalerParams(0, c, d, this.yAxis.b8, e);
        var g = this.aj(this.mu(), this.mv.f, this.nv(this.bi), this.nw(this.bi), a, true);
        if (g == null) {
            return Rect.empty;
        }
        var h = g[0];
        var i = g[1];
        var j = Math.abs(b.x - h[0]);
        var k = Math.abs(b.x - i[0]);
        var l = this.xAxis.jj(c, d, e);
        if (j < k) {
            var m = h[0] - 0.5 * l;
            var n = h[1];
            var o = h[2];
            return new Rect(0, m, Math.min(n, o), l, Math.max(n, o) - Math.min(n, o));
        }
        else {
            var p = i[0] - 0.5 * l;
            var q = i[1];
            var r = i[2];
            return new Rect(0, p, Math.min(q, r), l, Math.max(q, r) - Math.min(q, r));
        }
    };
    RangeColumnSeries.prototype.de = function (a, b) {
        if (this.dh(a, b)) {
            return true;
        }
        if (this.ls(a, b)) {
            return true;
        }
        return false;
    };
    RangeColumnSeries.prototype.hl = function (a, b) {
        _super.prototype.hl.call(this, a, b);
        var c = b;
        if (a && c.cx != null) {
            c.cx.count = 0;
        }
    };
    RangeColumnSeries.prototype.eb = function () {
        return this.xAxis.jj(this.bi.bq, this.bi.bp, this.getEffectiveViewport1(this.bi));
    };
    RangeColumnSeries.prototype.ob = function (a, b) {
        _super.prototype.ob.call(this, a, b);
        var c = typeCast(RangeColumnSeriesView.$, b);
        var d = a.f;
        var e = b.bq;
        var f = b.bp;
        var g = this.getEffectiveViewport1(b);
        var h = this.xAxis.jj(e, f, g);
        if (isNaN_(h) || isInfinity(h)) {
            c.cx.count = 0;
            return;
        }
        this.m2.x(this, this.nn(), this.xAxis, runOn(this, this.mo), this.nv(b), this.nw(b));
        this.m2.p = this.o9;
        this.m2.q = this.pa;
        this.m2.j = this.o9;
        this.m2.k = this.pa;
        var i = false;
        var j = this.m2.c;
        if (j != null) {
            i = true;
        }
        var k = this.xAxis.cc;
        var l = this.lowColumn.count;
        var m = this.xAxis;
        var n = new ScalerParams(0, e, f, this.xAxis.b8, g);
        var o = 0;
        for (var p = 0; p < d.count; ++p) {
            var q = d._inner[p][0] - 0.5 * h;
            var r = Math.min(d._inner[p][1], d._inner[p][2]);
            var s = Math.max(d._inner[p][1], d._inner[p][2]);
            var t = Math.abs(s - r);
            if (isInfinity(t)) {
                continue;
            }
            var u = c.cx.item(o);
            o++;
            u.width = h;
            u.height = t;
            if (i) {
                this.n7(d, p, l, m, n, b.n);
            }
            this.m2.ae(u, false, false, false, false);
            u.al = this.m2.j;
            u.am = this.m2.k;
            c.c2(u, q, r);
        }
        c.cx.count = o;
        b.cs(a);
    };
    Object.defineProperty(RangeColumnSeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.nq;
        },
        enumerable: true,
        configurable: true
    });
    RangeColumnSeries.$t = markType(RangeColumnSeries, 'RangeColumnSeries', HorizontalRangeCategorySeries.$);
    return RangeColumnSeries;
}(HorizontalRangeCategorySeries));
export { RangeColumnSeries };
Type.dep(DependencyProperty, PropertyMetadata, RangeColumnSeries, 'raisePropertyChanged', ['RadiusX:o9:pd', [1, 2], 'RadiusY:pa:pe', [1, 2]]);
var RangeColumnSeriesView = /** @class */ (function (_super) {
    tslib_1.__extends(RangeColumnSeriesView, _super);
    function RangeColumnSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.cw = null;
        _this.cx = null;
        _this.cy = null;
        _this.c3 = new Rectangle();
        _this.cw = a;
        _this.cx = ((function () {
            var $ret = new Pool$1(Rectangle.$);
            $ret.create = runOn(_this, _this.c4);
            $ret.activate = runOn(_this, _this.cz);
            $ret.disactivate = runOn(_this, _this.c1);
            $ret.destroy = runOn(_this, _this.c0);
            return $ret;
        })());
        return _this;
    }
    RangeColumnSeriesView.prototype.ap = function () {
        _super.prototype.ap.call(this);
        this.cy = new List$1(Rectangle.$, 0);
        if (!this.n) {
            this.e.eo = 4;
            this.e.bj = 1;
        }
    };
    RangeColumnSeriesView.prototype.c4 = function () {
        var a = new Rectangle();
        this.cy.add(a);
        a._visibility = 1;
        return a;
    };
    RangeColumnSeriesView.prototype.cz = function (a) {
        a._visibility = 0;
    };
    RangeColumnSeriesView.prototype.c1 = function (a) {
        a._visibility = 1;
    };
    RangeColumnSeriesView.prototype.c0 = function (a) {
        this.cy.remove(a);
    };
    RangeColumnSeriesView.prototype.c2 = function (a, b, c) {
        if (!this.isDirty) {
            this.an();
        }
        a.o = c;
        a.n = b;
    };
    RangeColumnSeriesView.prototype.z = function (a) {
        return this.cy._inner[a];
    };
    RangeColumnSeriesView.prototype.y = function (a) {
        var b = this.cy._inner[a];
        this.c3._visibility = b._visibility;
        this.c3.n = b.n;
        this.c3.o = b.o;
        this.c3.width = b.width;
        this.c3.height = b.height;
        var c = this.bl(a);
        this.c3._fill = c;
        this.c3._stroke = c;
        this.c3.ac = this.e.es + 3;
        return this.c3;
    };
    RangeColumnSeriesView.prototype.a3 = function (a, b) {
        _super.prototype.a3.call(this, a, b);
        if (a.d) {
            for (var c = 0; c < this.cy.count; c++) {
                var d = this.x(c, b);
                this.ba(d, c, b);
                a.v(d);
            }
        }
    };
    RangeColumnSeriesView.prototype.ai = function (a) {
        _super.prototype.ai.call(this, a);
        var b = 0;
        var c = new List$1(Rectangle.$, 0);
        try {
            for (var _a = tslib_1.__values(fromEnum(this.cx.a)), _b = _a.next(); !_b.done; _b = _a.next()) {
                var d = _b.value;
                c.add(d);
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
            }
            finally { if (e_1) throw e_1.error; }
        }
        c.aa(function (e, f) {
            if (e.n < f.n) {
                return -1;
            }
            else if (e.n > f.n) {
                return 1;
            }
            else {
                return 0;
            }
        });
        try {
            for (var _d = tslib_1.__values(fromEnum(c)), _e = _d.next(); !_e.done; _e = _d.next()) {
                var e = _e.value;
                this.e.a2.exportRectangleData(a, e, "column" + b, ["Main", "Fill"]);
            }
        }
        catch (e_2_1) { e_2 = { error: e_2_1 }; }
        finally {
            try {
                if (_e && !_e.done && (_f = _d.return)) _f.call(_d);
            }
            finally { if (e_2) throw e_2.error; }
        }
        b++;
        var e_1, _c, e_2, _f;
    };
    RangeColumnSeriesView.$t = markType(RangeColumnSeriesView, 'RangeColumnSeriesView', RangeCategorySeriesView.$);
    return RangeColumnSeriesView;
}(RangeCategorySeriesView));
export { RangeColumnSeriesView };
/*<BeginStatics Name="Infragistics.Controls.Charts.RangeColumnSeries" />*/
/*<EndStatics Name="Infragistics.Controls.Charts.RangeColumnSeries" />*/
