/*
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 { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { ConsolidatedItemsPosition_$type } from "./ConsolidatedItemsPosition";
import { Type, runOn, enumGetBox, markType, fromEnum } from "igniteui-react-core/ES5/type";
import { Pool$1 } from "igniteui-react-core/ES5/Pool$1";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { ScalerParams } from "./ScalerParams";
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 { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
var ColumnSeries = /** @class */ (function (_super) {
    tslib_1.__extends(ColumnSeries, _super);
    function ColumnSeries() {
        var _this = _super.call(this) || this;
        _this.qc = null;
        _this.p7 = 0;
        _this.ab = ColumnSeries.$;
        _this.pq = 2;
        return _this;
    }
    ColumnSeries.prototype.bf = function () {
        return new ColumnSeriesView(this);
    };
    ColumnSeries.prototype.ii = function (a) {
        _super.prototype.ii.call(this, a);
        this.p6 = a;
    };
    ColumnSeries.prototype.m4 = function () {
        return 1;
    };
    ColumnSeries.prototype.get_nj = function () {
        return true;
    };
    Object.defineProperty(ColumnSeries.prototype, "nj", {
        get: function () {
            return this.get_nj();
        },
        enumerable: true,
        configurable: true
    });
    ColumnSeries.prototype.preferredCategoryMode = function (a) {
        return this.pq;
    };
    ColumnSeries.prototype.li = function (a) {
        if (this.qc == null) {
            this.qc = runOn(this, this.p9);
        }
        var b = this.pt != null ? this.pt : this.yAxis;
        var c = this.pn;
        return this.os.c$d(this, a, c, b, this.mv, this.nv(this.bi), this.nw(this.bi), this.qc);
    };
    ColumnSeries.prototype.de = function (a, b) {
        if (this.dh(a, b)) {
            return true;
        }
        if (this.ls(a, b)) {
            return true;
        }
        return false;
    };
    ColumnSeries.prototype.hl = function (a, b) {
        _super.prototype.hl.call(this, a, b);
        var c = b;
        if (a && c.c5 != null) {
            c.c5.count = 0;
        }
    };
    ColumnSeries.prototype.eb = function () {
        return this.pn.jj(this.bi.bq, this.bi.bp, this.getEffectiveViewport1(this.bi));
    };
    ColumnSeries.prototype.ob = function (a, b) {
        _super.prototype.ob.call(this, a, b);
        var c = a.f;
        if (!b.q()) {
            return;
        }
        var d = b.bq;
        var e = b.bp;
        var f = this.getEffectiveViewport1(b);
        var g = new ScalerParams(0, d, e, this.pt.b8, f);
        var h = new ScalerParams(0, d, e, this.pn.b8, f);
        var i = this.pt;
        var j = i.dt(i.j6, g);
        var k = this.pn.jj(d, e, f);
        var l = this.pn;
        var m = b;
        if (isNaN_(k) || isInfinity(k)) {
            m.c5.count = 0;
            return;
        }
        this.m2.x(this, this.nn(), this.pn, runOn(this, this.mo), this.nv(b), this.nw(b));
        this.m2.p = this.qa;
        this.m2.q = this.qb;
        this.m2.j = this.qa;
        this.m2.k = this.qb;
        var n = false;
        var o = this.m2.c;
        if (o != null) {
            n = true;
        }
        var p = this.pn.cc;
        var q = p ? this.pn : null;
        var r = this.valueColumn.count;
        var s = this.nv(b);
        var t = 0;
        for (var u = 0; u < c.count; ++u) {
            var v = c._inner[u][0] - 0.5 * k;
            var w = this.p9(c._inner[u]);
            var x = j;
            w = Math.max(w, -100);
            x = Math.min(x, e.bottom + 100);
            var y = Math.abs(x - w);
            if (isInfinity(y)) {
                continue;
            }
            var z = m.c5.item(t);
            t++;
            z.width = k;
            z.height = y;
            if (n) {
                this.n7(c, u, r, l, h, b.n);
            }
            if (z.dataContext != null) {
                var aa = z.dataContext;
                if (s == 1) {
                    var ab = this.m2.a(r, u)[0];
                    if (ab >= 0 && ab < this.bz.count) {
                        if (q != null && q.i$b != null && q.i$b.count > ab) {
                            ab = q.i$b._inner[ab];
                        }
                        aa.item = this.bz.item(ab);
                    }
                }
                else {
                    aa.item = null;
                }
            }
            this.m2.ae(z, false, false, false, false);
            z.al = this.m2.j;
            z.am = this.m2.k;
            m.da(z, v, Math.min(x, w));
        }
        m.c5.count = t;
        b.cs(a);
    };
    Object.defineProperty(ColumnSeries.prototype, "p8", {
        get: function () {
            return this.p7;
        },
        set: function (a) {
            if (this.p8 != a) {
                var b = this.p8;
                this.p7 = a;
                this.raisePropertyChanged("ConsolidatedColumnVerticalPosition", enumGetBox(ConsolidatedItemsPosition_$type, b), enumGetBox(ConsolidatedItemsPosition_$type, this.p8));
            }
        },
        enumerable: true,
        configurable: true
    });
    ColumnSeries.prototype.p9 = function (a) {
        if (a == null || a.length < 3) {
            return NaN;
        }
        switch (this.p8) {
            case 0: return a[1];
            case 1: return a[2];
            case 2: return (a[1] + a[2]) / 2;
            case 3:
                var b = (a[1] + a[2]) / 2;
                if (this.yAxis == null) {
                    return b;
                }
                var c = this.yAxis.dw(b, new ScalerParams(1, this.bs.my, this.bs.mx, this.yAxis.b8));
                if (c < this.yAxis.j6) {
                    return a[2];
                }
                else {
                    return a[1];
                }
            case 4:
                var d = (a[1] + a[2]) / 2;
                var e = this.yAxis.dw(d, new ScalerParams(1, this.bs.my, this.bs.mx, this.yAxis.b8));
                if (this.yAxis == null) {
                    return d;
                }
                if (e < this.yAxis.j6) {
                    return a[1];
                }
                else {
                    return a[2];
                }
            default: return (a[1] + a[2]) / 2;
        }
    };
    Object.defineProperty(ColumnSeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.nq;
        },
        enumerable: true,
        configurable: true
    });
    ColumnSeries.$t = markType(ColumnSeries, 'ColumnSeries', HorizontalAnchoredCategorySeries.$);
    return ColumnSeries;
}(HorizontalAnchoredCategorySeries));
export { ColumnSeries };
Type.dep(DependencyProperty, PropertyMetadata, ColumnSeries, 'raisePropertyChanged', ['RadiusX:qa:qg', [1, 2], 'RadiusY:qb:qh', [1, 2]]);
var ColumnSeriesView = /** @class */ (function (_super) {
    tslib_1.__extends(ColumnSeriesView, _super);
    function ColumnSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.c4 = null;
        _this.c6 = null;
        _this.db = new Rectangle();
        _this.c5 = null;
        _this.c4 = a;
        _this.c5 = ((function () {
            var $ret = new Pool$1(Rectangle.$);
            $ret.create = runOn(_this, _this.dc);
            $ret.activate = runOn(_this, _this.c7);
            $ret.disactivate = runOn(_this, _this.c9);
            $ret.destroy = runOn(_this, _this.c8);
            return $ret;
        })());
        return _this;
    }
    ColumnSeriesView.prototype.ap = function () {
        _super.prototype.ap.call(this);
        this.c6 = new List$1(Rectangle.$, 0);
        if (!this.n) {
            this.e.eo = 4;
            this.e.bj = 1;
        }
    };
    ColumnSeriesView.prototype.dc = function () {
        var a = new Rectangle();
        this.c6.add(a);
        a._visibility = 1;
        return a;
    };
    ColumnSeriesView.prototype.c7 = function (a) {
        a._visibility = 0;
    };
    ColumnSeriesView.prototype.c9 = function (a) {
        a._visibility = 1;
    };
    ColumnSeriesView.prototype.c8 = function (a) {
        this.c6.remove(a);
    };
    ColumnSeriesView.prototype.da = function (a, b, c) {
        if (!this.isDirty) {
            this.an();
        }
        a.o = c;
        a.n = b;
    };
    ColumnSeriesView.prototype.z = function (a) {
        return this.c6._inner[a];
    };
    ColumnSeriesView.prototype.y = function (a) {
        var b = this.c6._inner[a];
        this.db._visibility = b._visibility;
        this.db.n = b.n;
        this.db.o = b.o;
        this.db.width = b.width;
        this.db.height = b.height;
        var c = this.bl(a);
        this.db._fill = c;
        this.db._stroke = c;
        this.db.ac = this.e.es + 3;
        return this.db;
    };
    ColumnSeriesView.prototype.a3 = function (a, b) {
        _super.prototype.a3.call(this, a, b);
        if (a.d) {
            for (var c = 0; c < this.c6.count; c++) {
                var d = this.x(c, b);
                this.ba(d, c, b);
                a.v(d);
            }
        }
    };
    ColumnSeriesView.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.c5.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;
    };
    ColumnSeriesView.$t = markType(ColumnSeriesView, 'ColumnSeriesView', AnchoredCategorySeriesView.$);
    return ColumnSeriesView;
}(AnchoredCategorySeriesView));
export { ColumnSeriesView };
/*<BeginStatics Name="Infragistics.Controls.Charts.ColumnSeries" />*/
/*<EndStatics Name="Infragistics.Controls.Charts.ColumnSeries" />*/
