/*
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 { Brush } from "igniteui-angular-core";
import { DependencyProperty } from "igniteui-angular-core";
import { runOn, markType, markDep, fromEnum } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { Rectangle } from "igniteui-angular-core";
import { ArrayExtension } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
/**
 * @hidden
 */
var WaterfallSeries = /** @class */ (function (_super) {
    tslib_1.__extends(WaterfallSeries, _super);
    function WaterfallSeries() {
        var _this = _super.call(this) || this;
        _this.ab = WaterfallSeries.$;
        return _this;
    }
    WaterfallSeries.prototype.bf = function () {
        return new WaterfallSeriesView(this);
    };
    WaterfallSeries.prototype.iu = function (a) {
        _super.prototype.iu.call(this, a);
        this.qh = a;
    };
    WaterfallSeries.prototype.preferredCategoryMode = function (a) {
        return 2;
    };
    WaterfallSeries.prototype.get_cz = function () {
        return true;
    };
    WaterfallSeries.prototype.ji = function (a, b) {
        _super.prototype.ji.call(this, a, b);
        this.qs = a;
        this.qt = b;
    };
    WaterfallSeries.prototype.k9 = function () {
        return this.qs;
    };
    WaterfallSeries.prototype.get_nv = function () {
        return true;
    };
    WaterfallSeries.prototype.iz = function (a, b, c, d) {
        _super.prototype.iz.call(this, a, b, c, d);
        switch (b) {
            case WaterfallSeries.$$p[3]:
            case WaterfallSeries.$$p[2]:
            case WaterfallSeries.$$p[0]:
            case WaterfallSeries.$$p[1]:
                this.jd(false);
                break;
        }
    };
    WaterfallSeries.prototype.dh = function (a, b) {
        if (this.dk(a, b)) {
            return true;
        }
        if (this.l4(a, b)) {
            return true;
        }
        return false;
    };
    WaterfallSeries.prototype.lu = function (a) {
        var _this = this;
        if (this.qh == null || this.qh.c7 == null || this.qh.c7.count == 0 || this.xAxis == null) {
            return Rect.empty;
        }
        var b = this.qh.c7;
        var c = this.lg(a);
        var d = -1;
        var e = this.xAxis.b8;
        var f = this.ly.right * 2;
        if (e) {
            d = ArrayExtension.binarySearch$1(Rectangle.$, b, function (g) {
                var h = _this.qh.de(g);
                return (f - c.x) < (f - (h.left + h.width / 2)) ? -1 : ((f - c.x) > (f - (h.left + h.width / 2)) ? 1 : 0);
            });
        }
        else {
            d = ArrayExtension.binarySearch$1(Rectangle.$, b, function (g) {
                var h = _this.qh.de(g);
                return c.x < (h.left + h.width / 2) ? -1 : (c.x > (h.left + h.width / 2) ? 1 : 0);
            });
        }
        if (d < 0) {
            d = ~d;
            d--;
        }
        if (d < 0) {
            d = 0;
        }
        if (d > b.count - 1) {
            d = b.count - 1;
        }
        var g = d;
        var h = d;
        if (g < 0) {
            g--;
        }
        if (h < b.count - 1) {
            h++;
        }
        var i = this.qu(g);
        var j = this.qu(d);
        var k = this.qu(h);
        var l = i.left + i.width / 2;
        var m = j.left + j.width / 2;
        var n = k.left + k.width / 2;
        var o = Math.abs(l - c.x);
        var p = Math.abs(m - c.x);
        var q = Math.abs(n - c.x);
        var r = i.containsPoint(c);
        var s = j.containsPoint(c);
        var t = k.containsPoint(c);
        if (p <= o && p <= q) {
            if (!e && t) {
                return k;
            }
            if (e && r) {
                return i;
            }
            return j;
        }
        if (o <= p && o <= q) {
            if (!e && s) {
                return j;
            }
            return i;
        }
        if (q <= p && q <= o) {
            if (e && s) {
                return j;
            }
            return k;
        }
        return Rect.empty;
    };
    WaterfallSeries.prototype.qu = function (a) {
        return this.qh.dd(a);
    };
    WaterfallSeries.prototype.ng = function () {
        return 1;
    };
    WaterfallSeries.prototype.hv = function (a, b) {
        _super.prototype.hv.call(this, a, b);
        this.qh.c7.count = 0;
    };
    WaterfallSeries.prototype.eg = function () {
        return this.py.jr(this.bi.bs, this.bi.br, this.getEffectiveViewport1(this.bi));
    };
    WaterfallSeries.prototype.oo = function (a, b) {
        var c = b;
        _super.prototype.oo.call(this, a, b);
        var d = b.bs;
        var e = b.br;
        var f = this.getEffectiveViewport1(b);
        var g = this.py.jr(d, e, f);
        var h = this.qi;
        var i = this.qj;
        var j;
        var k = this.o7(b);
        var l = NaN;
        var m = c.c7;
        var n;
        var o = 0;
        this.ne.x(this, this.nz(), this.py, runOn(this, this.m0), this.n7(b), this.n8(b));
        this.ne.p = this.qi;
        this.ne.q = this.qj;
        this.ne.j = this.qi;
        this.ne.k = this.qj;
        var p = false;
        var q = this.ne.c;
        if (q != null) {
            p = true;
        }
        var r = this.py.cd;
        var s = this.valueColumn.count;
        var t = a.f;
        var u = this.py;
        var v = new ScalerParams(0, d, e, this.py.b8, f);
        var w = this.k3;
        var x = this.qs;
        var y = this.k4;
        var z = this.qt || y;
        if (a.f.count > 0) {
            j = a.f._inner[0][0] - 0.5 * g;
            var aa = a.f._inner[0][1];
            if (!isNaN_(aa)) {
                if (aa > k) {
                    n = m.item(o);
                    o++;
                    c.dc(n, j, k);
                    n.width = g;
                    n.height = Math.abs(k - aa);
                    this.ne.al = x;
                    this.ne.ah = x;
                    this.ne.am = z;
                    this.ne.ai = z;
                    this.ne.f = true;
                    if (p) {
                        this.ok(t, 0, s, u, v, b.n);
                    }
                    this.ne.ae(n, false, false, false, false);
                    n.am = this.ne.j;
                    n.an = this.ne.k;
                }
                else {
                    n = m.item(o);
                    o++;
                    c.dc(n, j, aa);
                    n.width = g;
                    n.height = Math.abs(aa - k);
                    this.ne.al = w;
                    this.ne.ah = w;
                    this.ne.am = y;
                    this.ne.ai = y;
                    this.ne.f = false;
                    if (p) {
                        this.ok(t, 0, s, u, v, b.n);
                    }
                    this.ne.ae(n, false, false, false, false);
                    n.am = this.ne.j;
                    n.an = this.ne.k;
                }
                l = aa;
            }
            else {
                l = k;
            }
        }
        for (var ab = 1; ab < a.f.count; ++ab) {
            var ac = a.f._inner[ab];
            j = a.f._inner[ab][0] - 0.5 * g;
            var ad = ac[1];
            if (!isNaN_(ad)) {
                n = m.item(o);
                o++;
                c.dc(n, j, Math.min(l, ad));
                n.width = g;
                n.height = Math.abs(l - ad);
                this.ne.al = w;
                this.ne.ah = w;
                this.ne.am = y;
                this.ne.ai = y;
                this.ne.f = false;
                if (l > ad) {
                    if (p) {
                        this.ok(t, ab, s, u, v, b.n);
                    }
                }
                else {
                    this.ne.al = x;
                    this.ne.ah = x;
                    this.ne.am = z;
                    this.ne.ai = z;
                    this.ne.f = true;
                    if (p) {
                        this.ok(t, ab, s, u, v, b.n);
                    }
                }
                this.ne.ae(n, false, false, false, false);
                n.am = this.ne.j;
                n.an = this.ne.k;
                l = ad;
            }
        }
        m.count = o;
        b.cu(a);
    };
    Object.defineProperty(WaterfallSeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.n2;
        },
        enumerable: true,
        configurable: true
    });
    WaterfallSeries.$t = markType(WaterfallSeries, 'WaterfallSeries', HorizontalAnchoredCategorySeries.$);
    WaterfallSeries.$$p = markDep(DependencyProperty, PropertyMetadata, WaterfallSeries, 'raisePropertyChanged', ['NegativeBrush:qs:qo', [Brush.$, null], 'NegativeOutline:qt:qp', [Brush.$, null], 'RadiusX:qi:qq', [1, 2], 'RadiusY:qj:qr', [1, 2]]);
    return WaterfallSeries;
}(HorizontalAnchoredCategorySeries));
export { WaterfallSeries };
/**
 * @hidden
 */
var WaterfallSeriesView = /** @class */ (function (_super) {
    tslib_1.__extends(WaterfallSeriesView, _super);
    function WaterfallSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.c6 = null;
        _this.c8 = null;
        _this.df = new Rectangle();
        _this.c7 = null;
        _this.c6 = a;
        _this.c7 = ((function () {
            var $ret = new Pool$1(Rectangle.$);
            $ret.create = runOn(_this, _this.dg);
            $ret.activate = runOn(_this, _this.c9);
            $ret.disactivate = runOn(_this, _this.db);
            $ret.destroy = runOn(_this, _this.da);
            return $ret;
        })());
        return _this;
    }
    WaterfallSeriesView.prototype.ap = function () {
        _super.prototype.ap.call(this);
        this.c8 = new List$1(Rectangle.$, 0);
        if (!this.n) {
            this.e.eu = 4;
            this.c6.qs = ((function () {
                var $ret = new Brush();
                $ret.fill = "#C62828";
                return $ret;
            })());
            this.c6.qt = ((function () {
                var $ret = new Brush();
                $ret.fill = "#C62828";
                return $ret;
            })());
            this.e.bj = 5;
        }
    };
    WaterfallSeriesView.prototype.dg = function () {
        var a = new Rectangle();
        this.c8.add(a);
        a._visibility = 1;
        return a;
    };
    WaterfallSeriesView.prototype.c9 = function (a) {
        a._visibility = 0;
    };
    WaterfallSeriesView.prototype.db = function (a) {
        a._visibility = 1;
    };
    WaterfallSeriesView.prototype.da = function (a) {
        this.c8.remove(a);
    };
    WaterfallSeriesView.prototype.dc = function (a, b, c) {
        var d = false;
        if (a.o != c) {
            d = true;
            a.o = c;
        }
        if (a.n != b) {
            d = true;
            a.n = b;
        }
        if (d) {
            this.an();
        }
    };
    WaterfallSeriesView.prototype.z = function (a) {
        return this.c8._inner[a];
    };
    WaterfallSeriesView.prototype.y = function (a) {
        var b = this.c8._inner[a];
        this.df._visibility = b._visibility;
        this.df.n = b.n;
        this.df.o = b.o;
        this.df.width = b.width;
        this.df.height = b.height;
        var c = this.bm(a);
        this.df._fill = c;
        this.df._stroke = c;
        this.df.ac = this.e.ey + 3;
        return this.df;
    };
    WaterfallSeriesView.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);
            }
        }
    };
    WaterfallSeriesView.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;
                var f = "Negative";
                if (e._fill == this.e.k3) {
                    f = "Positive";
                }
                this.e.a2.exportRectangleData(a, e, "column" + b, ["Main", f]);
            }
        }
        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++;
    };
    WaterfallSeriesView.prototype.dd = function (a) {
        var b = this.c7.item(a);
        return new Rect(0, b.n, b.o, b.width, b.height);
    };
    WaterfallSeriesView.prototype.de = function (a) {
        return new Rect(0, a.n, a.o, a.width, a.height);
    };
    WaterfallSeriesView.$t = markType(WaterfallSeriesView, 'WaterfallSeriesView', AnchoredCategorySeriesView.$);
    return WaterfallSeriesView;
}(AnchoredCategorySeriesView));
export { WaterfallSeriesView };
//# sourceMappingURL=WaterfallSeries_combined.js.map