/*
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 { Rectangle } from "igniteui-react-core/ES5/Rectangle";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { ScalerParams } from "./ScalerParams";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
import { isNaN_, isInfinity } from "igniteui-react-core/ES5/number";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
/**
 * @hidden
 */
var ColumnSeries = /** @class */ (function (_super) {
    tslib_1.__extends(ColumnSeries, _super);
    function ColumnSeries() {
        var _this = _super.call(this) || this;
        _this.qg = null;
        _this.qb = 0;
        _this.ab = ColumnSeries.$;
        _this.pu = 2;
        return _this;
    }
    ColumnSeries.prototype.bf = function () {
        return new ColumnSeriesView(this);
    };
    ColumnSeries.prototype.im = function (a) {
        _super.prototype.im.call(this, a);
        this.qa = a;
    };
    ColumnSeries.prototype.m9 = function () {
        return 1;
    };
    ColumnSeries.prototype.get_no = function () {
        return true;
    };
    ColumnSeries.prototype.preferredCategoryMode = function (a) {
        return this.pu;
    };
    ColumnSeries.prototype.ln = function (a) {
        if (this.qg == null) {
            this.qg = runOn(this, this.qd);
        }
        var b = this.px != null ? this.px : this.yAxis;
        var c = this.pr;
        return this.ow.c$d(this, a, c, b, this.m0, this.n0(this.bi), this.n1(this.bi), this.qg);
    };
    ColumnSeries.prototype.dg = function (a, b) {
        if (this.dj(a, b)) {
            return true;
        }
        if (this.lx(a, b)) {
            return true;
        }
        return false;
    };
    ColumnSeries.prototype.hp = function (a, b) {
        _super.prototype.hp.call(this, a, b);
        var c = b;
        if (a && c.c7 != null) {
            c.c7.count = 0;
        }
    };
    ColumnSeries.prototype.ed = function () {
        return this.pr.jk(this.bi.bs, this.bi.br, this.getEffectiveViewport1(this.bi));
    };
    ColumnSeries.prototype.oh = function (a, b) {
        _super.prototype.oh.call(this, a, b);
        var c = a.f;
        if (!b.q()) {
            return;
        }
        var d = b.bs;
        var e = b.br;
        var f = this.getEffectiveViewport1(b);
        var g = new ScalerParams(0, d, e, this.px.b8, f);
        g.b = this.ee();
        var h = new ScalerParams(0, d, e, this.pr.b8, f);
        var i = this.px;
        var j = i.dt(i.j7, g);
        var k = this.pr.jk(d, e, f);
        var l = this.pr;
        var m = b;
        if (isNaN_(k) || isInfinity(k)) {
            m.c7.count = 0;
            return;
        }
        this.m7.x(this, this.ns(), this.pr, runOn(this, this.mt), this.n0(b), this.n1(b));
        this.m7.p = this.qe;
        this.m7.q = this.qf;
        this.m7.j = this.qe;
        this.m7.k = this.qf;
        var n = false;
        var o = this.m7.c;
        if (o != null) {
            n = true;
        }
        var p = this.pr.cc;
        var q = p ? this.pr : null;
        var r = this.valueColumn.count;
        var s = this.n0(b);
        var t = 0;
        for (var u = 0; u < c.count; ++u) {
            var v = c._inner[u][0] - 0.5 * k;
            var w = this.qd(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.c7.item(t);
            t++;
            z.width = k;
            z.height = y;
            if (n) {
                this.od(c, u, r, l, h, b.n);
            }
            if (z.dataContext != null) {
                var aa = z.dataContext;
                if (s == 1) {
                    var ab = this.m7.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.m7.ae(z, false, false, false, false);
            z.al = this.m7.j;
            z.am = this.m7.k;
            m.dc(z, v, Math.min(x, w));
        }
        m.c7.count = t;
        b.cu(a);
    };
    Object.defineProperty(ColumnSeries.prototype, "qc", {
        get: function () {
            return this.qb;
        },
        set: function (a) {
            if (this.qc != a) {
                var b = this.qc;
                this.qb = a;
                this.raisePropertyChanged("ConsolidatedColumnVerticalPosition", enumGetBox(ConsolidatedItemsPosition_$type, b), enumGetBox(ConsolidatedItemsPosition_$type, this.qc));
            }
        },
        enumerable: true,
        configurable: true
    });
    ColumnSeries.prototype.qd = function (a) {
        if (a == null || a.length < 3) {
            return NaN;
        }
        switch (this.qc) {
            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.m4, this.bs.m3, this.yAxis.b8));
                if (c < this.yAxis.j7) {
                    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.m4, this.bs.m3, this.yAxis.b8));
                if (this.yAxis == null) {
                    return d;
                }
                if (e < this.yAxis.j7) {
                    return a[1];
                }
                else {
                    return a[2];
                }
            default: return (a[1] + a[2]) / 2;
        }
    };
    Object.defineProperty(ColumnSeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.nv;
        },
        enumerable: true,
        configurable: true
    });
    ColumnSeries.$t = markType(ColumnSeries, 'ColumnSeries', HorizontalAnchoredCategorySeries.$);
    return ColumnSeries;
}(HorizontalAnchoredCategorySeries));
export { ColumnSeries };
Type.dep(DependencyProperty, PropertyMetadata, ColumnSeries, 'raisePropertyChanged', ['RadiusX:qe:qk', [1, 2], 'RadiusY:qf:ql', [1, 2]]);
/**
 * @hidden
 */
var ColumnSeriesView = /** @class */ (function (_super) {
    tslib_1.__extends(ColumnSeriesView, _super);
    function ColumnSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.c6 = null;
        _this.c8 = null;
        _this.dd = new Rectangle();
        _this.c7 = null;
        _this.c6 = a;
        _this.c7 = ((function () {
            var $ret = new Pool$1(Rectangle.$);
            $ret.create = runOn(_this, _this.de);
            $ret.activate = runOn(_this, _this.c9);
            $ret.disactivate = runOn(_this, _this.db);
            $ret.destroy = runOn(_this, _this.da);
            return $ret;
        })());
        return _this;
    }
    ColumnSeriesView.prototype.ap = function () {
        _super.prototype.ap.call(this);
        this.c8 = new List$1(Rectangle.$, 0);
        if (!this.n) {
            this.e.er = 4;
            this.e.bj = 1;
        }
    };
    ColumnSeriesView.prototype.de = function () {
        var a = new Rectangle();
        this.c8.add(a);
        a._visibility = 1;
        return a;
    };
    ColumnSeriesView.prototype.c9 = function (a) {
        a._visibility = 0;
    };
    ColumnSeriesView.prototype.db = function (a) {
        a._visibility = 1;
    };
    ColumnSeriesView.prototype.da = function (a) {
        this.c8.remove(a);
    };
    ColumnSeriesView.prototype.dc = function (a, b, c) {
        if (!this.isDirty) {
            this.an();
        }
        a.o = c;
        a.n = b;
    };
    ColumnSeriesView.prototype.z = function (a) {
        return this.c8._inner[a];
    };
    ColumnSeriesView.prototype.y = function (a) {
        var b = this.c8._inner[a];
        this.dd._visibility = b._visibility;
        this.dd.n = b.n;
        this.dd.o = b.o;
        this.dd.width = b.width;
        this.dd.height = b.height;
        var c = this.bm(a);
        this.dd._fill = c;
        this.dd._stroke = c;
        this.dd.ac = this.e.ev + 3;
        return this.dd;
    };
    ColumnSeriesView.prototype.a3 = function (a, b) {
        _super.prototype.a3.call(this, a, b);
        if (a.d) {
            for (var c = 0; c < this.c8.count; c++) {
                var d = this.x(c, b);
                this.ba(d, c, b);
                a.v(d);
            }
        }
    };
    ColumnSeriesView.prototype.ai = function (a) {
        var e_1, _a, e_2, _b;
        _super.prototype.ai.call(this, a);
        var b = 0;
        var c = new List$1(Rectangle.$, 0);
        try {
            for (var _c = tslib_1.__values(fromEnum(this.c7.a)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var d = _d.value;
                c.add(d);
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
            }
            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 _e = tslib_1.__values(fromEnum(c)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var e = _f.value;
                this.e.a2.exportRectangleData(a, e, "column" + b, ["Main", "Fill"]);
            }
        }
        catch (e_2_1) { e_2 = { error: e_2_1 }; }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
            }
            finally { if (e_2) throw e_2.error; }
        }
        b++;
    };
    ColumnSeriesView.$t = markType(ColumnSeriesView, 'ColumnSeriesView', AnchoredCategorySeriesView.$);
    return ColumnSeriesView;
}(AnchoredCategorySeriesView));
export { ColumnSeriesView };
