/*
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 { 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
 */
export class WaterfallSeries extends HorizontalAnchoredCategorySeries {
    constructor() {
        super();
        this.ab = WaterfallSeries.$;
    }
    bf() {
        return new WaterfallSeriesView(this);
    }
    iu(a) {
        super.iu(a);
        this.qh = a;
    }
    preferredCategoryMode(a) {
        return 2;
    }
    get_cz() {
        return true;
    }
    ji(a, b) {
        super.ji(a, b);
        this.qs = a;
        this.qt = b;
    }
    k9() {
        return this.qs;
    }
    get_nv() {
        return true;
    }
    iz(a, b, c, d) {
        super.iz(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;
        }
    }
    dh(a, b) {
        if (this.dk(a, b)) {
            return true;
        }
        if (this.l4(a, b)) {
            return true;
        }
        return false;
    }
    lu(a) {
        if (this.qh == null || this.qh.c7 == null || this.qh.c7.count == 0 || this.xAxis == null) {
            return Rect.empty;
        }
        let b = this.qh.c7;
        let c = this.lg(a);
        let d = -1;
        let e = this.xAxis.b8;
        let f = this.ly.right * 2;
        if (e) {
            d = ArrayExtension.binarySearch$1(Rectangle.$, b, (g) => {
                let 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, (g) => {
                let 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;
        }
        let g = d;
        let h = d;
        if (g < 0) {
            g--;
        }
        if (h < b.count - 1) {
            h++;
        }
        let i = this.qu(g);
        let j = this.qu(d);
        let k = this.qu(h);
        let l = i.left + i.width / 2;
        let m = j.left + j.width / 2;
        let n = k.left + k.width / 2;
        let o = Math.abs(l - c.x);
        let p = Math.abs(m - c.x);
        let q = Math.abs(n - c.x);
        let r = i.containsPoint(c);
        let s = j.containsPoint(c);
        let 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;
    }
    qu(a) {
        return this.qh.dd(a);
    }
    ng() {
        return 1;
    }
    hv(a, b) {
        super.hv(a, b);
        this.qh.c7.count = 0;
    }
    eg() {
        return this.py.jr(this.bi.bs, this.bi.br, this.getEffectiveViewport1(this.bi));
    }
    oo(a, b) {
        let c = b;
        super.oo(a, b);
        let d = b.bs;
        let e = b.br;
        let f = this.getEffectiveViewport1(b);
        let g = this.py.jr(d, e, f);
        let h = this.qi;
        let i = this.qj;
        let j;
        let k = this.o7(b);
        let l = NaN;
        let m = c.c7;
        let n;
        let 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;
        let p = false;
        let q = this.ne.c;
        if (q != null) {
            p = true;
        }
        let r = this.py.cd;
        let s = this.valueColumn.count;
        let t = a.f;
        let u = this.py;
        let v = new ScalerParams(0, d, e, this.py.b8, f);
        let w = this.k3;
        let x = this.qs;
        let y = this.k4;
        let z = this.qt || y;
        if (a.f.count > 0) {
            j = a.f._inner[0][0] - 0.5 * g;
            let 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 (let ab = 1; ab < a.f.count; ++ab) {
            let ac = a.f._inner[ab];
            j = a.f._inner[ab][0] - 0.5 * g;
            let 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);
    }
    get useHighMarkerFidelity() {
        return this.n2;
    }
}
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]]);
/**
 * @hidden
 */
export class WaterfallSeriesView extends AnchoredCategorySeriesView {
    constructor(a) {
        super(a);
        this.c6 = null;
        this.c8 = null;
        this.df = new Rectangle();
        this.c7 = null;
        this.c6 = a;
        this.c7 = ((() => {
            let $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;
        })());
    }
    ap() {
        super.ap();
        this.c8 = new List$1(Rectangle.$, 0);
        if (!this.n) {
            this.e.eu = 4;
            this.c6.qs = ((() => {
                let $ret = new Brush();
                $ret.fill = "#C62828";
                return $ret;
            })());
            this.c6.qt = ((() => {
                let $ret = new Brush();
                $ret.fill = "#C62828";
                return $ret;
            })());
            this.e.bj = 5;
        }
    }
    dg() {
        let a = new Rectangle();
        this.c8.add(a);
        a._visibility = 1;
        return a;
    }
    c9(a) {
        a._visibility = 0;
    }
    db(a) {
        a._visibility = 1;
    }
    da(a) {
        this.c8.remove(a);
    }
    dc(a, b, c) {
        let d = false;
        if (a.o != c) {
            d = true;
            a.o = c;
        }
        if (a.n != b) {
            d = true;
            a.n = b;
        }
        if (d) {
            this.an();
        }
    }
    z(a) {
        return this.c8._inner[a];
    }
    y(a) {
        let 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;
        let c = this.bm(a);
        this.df._fill = c;
        this.df._stroke = c;
        this.df.ac = this.e.ey + 3;
        return this.df;
    }
    a3(a, b) {
        super.a3(a, b);
        if (a.d) {
            for (let c = 0; c < this.c8.count; c++) {
                let d = this.x(c, b);
                this.ba(d, c, b);
                a.v(d);
            }
        }
    }
    ai(a) {
        super.ai(a);
        let b = 0;
        let c = new List$1(Rectangle.$, 0);
        for (let d of fromEnum(this.c7.a)) {
            c.add(d);
        }
        c.aa((e, f) => {
            if (e.n < f.n) {
                return -1;
            }
            else if (e.n > f.n) {
                return 1;
            }
            else {
                return 0;
            }
        });
        for (let e of fromEnum(c)) {
            let f = "Negative";
            if (e._fill == this.e.k3) {
                f = "Positive";
            }
            this.e.a2.exportRectangleData(a, e, "column" + b, ["Main", f]);
        }
        b++;
    }
    dd(a) {
        let b = this.c7.item(a);
        return new Rect(0, b.n, b.o, b.width, b.height);
    }
    de(a) {
        return new Rect(0, a.n, a.o, a.width, a.height);
    }
}
WaterfallSeriesView.$t = markType(WaterfallSeriesView, 'WaterfallSeriesView', AnchoredCategorySeriesView.$);
//# sourceMappingURL=WaterfallSeries_combined.js.map