/*
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";
import { ConsolidatedItemsPosition_$type } from "./ConsolidatedItemsPosition";
import { runOn, enumGetBox, markType, markDep, fromEnum } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { Rectangle } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_, isInfinity } from "igniteui-react-core";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
import { DeviceUtils } from "igniteui-react-core";
/**
 * @hidden
 */
var ColumnSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(ColumnSeries, _super);
    function ColumnSeries() {
        var _this = _super.call(this) || this;
        _this.tc = null;
        _this.s7 = 0;
        _this.ab = ColumnSeries.$;
        _this.sq = 2;
        return _this;
    }
    ColumnSeries.prototype.bp = function () {
        return new ColumnSeriesView(this);
    };
    ColumnSeries.prototype.kk = function (a) {
        _super.prototype.kk.call(this, a);
        this.s6 = a;
    };
    ColumnSeries.prototype.bv = function () {
        if (this.bw == 0) {
            return 2;
        }
        return _super.prototype.bv.call(this);
    };
    ColumnSeries.prototype.p4 = function () {
        return 1;
    };
    ColumnSeries.prototype.get_cu = function () {
        return true;
    };
    ColumnSeries.prototype.preferredCategoryMode = function (a) {
        return this.sq;
    };
    ColumnSeries.prototype.n2 = function (a) {
        if (this.tc == null) {
            this.tc = runOn(this, this.s9);
        }
        var b = this.st != null ? this.st : this.yAxis;
        var c = this.sn;
        return this.rr.c$d(this, a, c, b, this.pv, this.qu(this.bs), this.qv(this.bs), this.tc);
    };
    ColumnSeries.prototype.dy = function (a, b) {
        if (this.d1(a, b)) {
            return true;
        }
        if (this.ol(a, b)) {
            return true;
        }
        return false;
    };
    ColumnSeries.prototype.jl = function (a, b) {
        _super.prototype.jl.call(this, a, b);
        var c = b;
        if (a && c.db != null) {
            c.db.count = 0;
        }
    };
    ColumnSeries.prototype.e9 = function () {
        return this.sn.j0(this.bs.bv, this.bs.bu, this.getEffectiveViewport1(this.bs));
    };
    ColumnSeries.prototype.rc = function (a, b) {
        _super.prototype.rc.call(this, a, b);
        var c = a.f;
        if (!b.t()) {
            return;
        }
        var d = b.bv;
        var e = b.bu;
        var f = this.getEffectiveViewport1(b);
        var g = new ScalerParams(0, d, e, this.st.ca, f);
        g.b = this.fa();
        var h = new ScalerParams(0, d, e, this.sn.ca, f);
        var i = this.st;
        var j = i.dz(i.kn, g);
        var k = this.sn.j0(d, e, f);
        var l = this.sn;
        var m = b;
        if (isNaN_(k) || isInfinity(k)) {
            m.db.count = 0;
            return;
        }
        this.p2.a0(this, this.qm(), runOn(this, this.po), this.qu(b), this.qv(b));
        this.p2.r = this.ta;
        this.p2.s = this.tb;
        this.p2.k = this.ta;
        this.p2.l = this.tb;
        var n = false;
        var o = this.p2.b;
        if (o != null) {
            n = true;
        }
        var p = this.sn.cf;
        var q = p ? this.sn : null;
        var r = this.valueColumn.count;
        var s = this.qu(b);
        var t = 0;
        for (var u = 0; u < c.count; ++u) {
            var v = c._inner[u][0] - 0.5 * k;
            var w = this.s9(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.db.item(t);
            t++;
            z.width = k;
            z.height = y;
            if (n) {
                this.q8(c, u, r, l, h, b.q);
            }
            if (z.dataContext != null) {
                var aa = z.dataContext;
                if (s == 1) {
                    var ab = this.p2.au(r, u)[0];
                    if (ab >= 0 && ab < this.cd.count) {
                        if (q != null && q.i$b != null && q.i$b.count > ab) {
                            ab = q.i$b._inner[ab];
                        }
                        aa.item = this.cd.item(ab);
                    }
                }
                else {
                    aa.item = null;
                }
            }
            this.p2.ad(z, false, false, false, false);
            z.am = this.p2.k;
            z.an = this.p2.l;
            m.dg(z, v, Math.min(x, w));
        }
        m.db.count = t;
        b.cy(a);
    };
    Object.defineProperty(ColumnSeries.prototype, "s8", {
        get: function () {
            return this.s7;
        },
        set: function (a) {
            if (this.s8 != a) {
                var b = this.s8;
                this.s7 = a;
                this.raisePropertyChanged("ConsolidatedColumnVerticalPosition", enumGetBox(ConsolidatedItemsPosition_$type, b), enumGetBox(ConsolidatedItemsPosition_$type, this.s8));
            }
        },
        enumerable: true,
        configurable: true
    });
    ColumnSeries.prototype.s9 = function (a) {
        if (a == null || a.length < 3) {
            return NaN;
        }
        switch (this.s8) {
            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.d2(b, new ScalerParams(1, this.b6.o8, this.b6.o7, this.yAxis.ca));
                if (c < this.yAxis.kn) {
                    return a[2];
                }
                else {
                    return a[1];
                }
            case 4:
                var d = (a[1] + a[2]) / 2;
                var e = this.yAxis.d2(d, new ScalerParams(1, this.b6.o8, this.b6.o7, this.yAxis.ca));
                if (this.yAxis == null) {
                    return d;
                }
                if (e < this.yAxis.kn) {
                    return a[1];
                }
                else {
                    return a[2];
                }
            default: return (a[1] + a[2]) / 2;
        }
    };
    Object.defineProperty(ColumnSeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.qp;
        },
        enumerable: true,
        configurable: true
    });
    ColumnSeries.$t = markType(ColumnSeries, 'ColumnSeries', HorizontalAnchoredCategorySeries.$);
    ColumnSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ColumnSeries, 'raisePropertyChanged', ['RadiusX:ta:tg', [1, 0], 'RadiusY:tb:th', [1, 0]]);
    return ColumnSeries;
}(HorizontalAnchoredCategorySeries));
export { ColumnSeries };
/**
 * @hidden
 */
var ColumnSeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(ColumnSeriesView, _super);
    function ColumnSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.da = null;
        _this.dc = null;
        _this.dh = new Rectangle();
        _this.db = null;
        _this.da = a;
        _this.db = ((function () {
            var $ret = new Pool$1(Rectangle.$);
            $ret.create = runOn(_this, _this.di);
            $ret.activate = runOn(_this, _this.dd);
            $ret.disactivate = runOn(_this, _this.df);
            $ret.destroy = runOn(_this, _this.de);
            return $ret;
        })());
        return _this;
    }
    ColumnSeriesView.prototype.as = function () {
        _super.prototype.as.call(this);
        this.dc = new List$1(Rectangle.$, 0);
        if (!this.q) {
            this.e.fq = 4;
            this.e.bx = 1;
            this.e.fv = DeviceUtils.g(1);
        }
    };
    ColumnSeriesView.prototype.di = function () {
        var a = new Rectangle();
        this.dc.add(a);
        a._visibility = 1;
        return a;
    };
    ColumnSeriesView.prototype.dd = function (a) {
        a._visibility = 0;
    };
    ColumnSeriesView.prototype.df = function (a) {
        a._visibility = 1;
    };
    ColumnSeriesView.prototype.de = function (a) {
        this.dc.remove(a);
    };
    ColumnSeriesView.prototype.dg = function (a, b, c) {
        if (!this.isDirty) {
            this.aq();
        }
        a.o = c;
        a.n = b;
    };
    ColumnSeriesView.prototype.ac = function (a) {
        return this.dc._inner[a];
    };
    ColumnSeriesView.prototype.ab = function (a) {
        var b = this.dc._inner[a];
        this.dh._visibility = b._visibility;
        this.dh.n = b.n;
        this.dh.o = b.o;
        this.dh.width = b.width;
        this.dh.height = b.height;
        var c = this.bp(a);
        this.dh._fill = c;
        this.dh._stroke = c;
        this.dh.ac = this.e.eu + 3;
        return this.dh;
    };
    ColumnSeriesView.prototype.a6 = function (a, b) {
        _super.prototype.a6.call(this, a, b);
        if (a.d) {
            for (var c = 0; c < this.dc.count; c++) {
                var d = this.aa(c, b);
                this.bd(d, c, b);
                a.v(d);
            }
        }
    };
    ColumnSeriesView.prototype.al = function (a) {
        var e_1, _a, e_2, _b;
        _super.prototype.al.call(this, a);
        var b = 0;
        var c = new List$1(Rectangle.$, 0);
        try {
            for (var _c = tslib_1.__values(fromEnum(this.db.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.a5.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 };
//# sourceMappingURL=ColumnSeries_combined.js.map
