/*
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 { DependencyProperty } from "igniteui-angular-core";
import { ConsolidatedItemsPosition_$type } from "./ConsolidatedItemsPosition";
import { Defaults } from "./Defaults";
import { runOn, enumGetBox, markType, markDep, fromEnum } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { Rectangle } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_, isInfinity } from "igniteui-angular-core";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
/**
 * @hidden
 */
export let ColumnSeries = /*@__PURE__*/ (() => {
    class ColumnSeries extends HorizontalAnchoredCategorySeries {
        constructor() {
            super();
            this.vp = null;
            this.vk = 0;
            this.ab = ColumnSeries.$;
            this.u3 = 2;
        }
        get_dk() {
            return true;
        }
        get_d5() {
            return true;
        }
        gz() {
            if (!isNaN_(this.gy)) {
                return super.gz();
            }
            return Defaults.h;
        }
        by() {
            return new ColumnSeriesView(this);
        }
        l4(a) {
            super.l4(a);
            this.vj = a;
        }
        b4() {
            if (this.b5 == 0) {
                return 2;
            }
            return super.b4();
        }
        r7() {
            return 1;
        }
        get_c3() {
            return true;
        }
        preferredCategoryMode(a) {
            return this.u3;
        }
        p3(a) {
            if (this.vp == null) {
                this.vp = runOn(this, this.vm);
            }
            let b = this.u6 != null ? this.u6 : this.yAxis;
            let c = this.u0;
            return this.tu.c$d(this, a, c, b, this.rx, this.sx(this.b1), this.sy(this.b1), this.vp);
        }
        ez(a, b) {
            if (this.e2(a, b)) {
                return true;
            }
            if (this.qo(a, b)) {
                return true;
            }
            return false;
        }
        k2(a, b) {
            super.k2(a, b);
            let c = b;
            if (a && c.db != null) {
                c.db.count = 0;
            }
        }
        ge() {
            return this.u0.k3(this.b1.bv, this.b1.bu, this.getEffectiveViewport1(this.b1));
        }
        tf(a, b) {
            super.tf(a, b);
            let c = a.f;
            if (!b.t()) {
                return;
            }
            let d = b.bv;
            let e = b.bu;
            let f = this.getEffectiveViewport1(b);
            let g = new ScalerParams(0, d, e, this.u6.cg, f);
            g.b = this.gg();
            let h = new ScalerParams(0, d, e, this.u0.cg, f);
            let i = this.u6;
            let j = i.ei(i.l6, g);
            let k = this.u0.k3(d, e, f);
            let l = this.u0;
            let m = b;
            if (isNaN_(k) || isInfinity(k)) {
                m.db.count = 0;
                return;
            }
            this.r5.a2(this, this.sp(), runOn(this, this.rq), this.sx(b), this.sy(b));
            this.r5.r = this.vn;
            this.r5.s = this.vo;
            this.r5.k = this.vn;
            this.r5.l = this.vo;
            let n = false;
            let o = this.r5.b;
            if (o != null) {
                n = true;
            }
            let p = this.u0.cm;
            let q = p ? this.u0 : null;
            let r = this.valueColumn.count;
            let s = this.sx(b);
            let t = 0;
            for (let u = 0; u < c.count; ++u) {
                let v = c._inner[u][0] - 0.5 * k;
                let w = this.vm(c._inner[u]);
                let x = j;
                w = Math.max(w, -100);
                x = Math.min(x, e.bottom + 100);
                let y = Math.abs(x - w);
                if (isInfinity(y) || isNaN_(y)) {
                    continue;
                }
                let z = m.db.item(t);
                t++;
                z.width = k;
                z.height = y;
                if (n) {
                    this.tb(c, u, r, l, h, b.q);
                }
                if (z.dataContext != null) {
                    let aa = z.dataContext;
                    if (s == 1) {
                        let ab = this.r5.aw(r, u)[0];
                        if (ab >= 0 && ab < this.cl.count) {
                            if (q != null && q.i$b != null && q.i$b.count > ab) {
                                ab = q.i$b._inner[ab];
                            }
                            aa.item = this.cl.item(ab);
                        }
                    }
                    else {
                        aa.item = null;
                    }
                }
                this.r5.ad(z, false, false, false, false);
                z.ap = this.r5.k;
                z.aq = this.r5.l;
                m.dg(z, v, Math.min(x, w));
            }
            m.db.count = t;
            b.cy(a);
        }
        get vl() {
            return this.vk;
        }
        set vl(a) {
            if (this.vl != a) {
                let b = this.vl;
                this.vk = a;
                this.raisePropertyChanged("ConsolidatedColumnVerticalPosition", enumGetBox(ConsolidatedItemsPosition_$type, b), enumGetBox(ConsolidatedItemsPosition_$type, this.vl));
            }
        }
        vm(a) {
            if (a == null || a.length < 3) {
                return NaN;
            }
            switch (this.vl) {
                case 0: return a[1];
                case 1: return a[2];
                case 2: return (a[1] + a[2]) / 2;
                case 3:
                    let b = (a[1] + a[2]) / 2;
                    if (this.yAxis == null) {
                        return b;
                    }
                    let c = this.yAxis.el(b, new ScalerParams(1, this.ce.tq, this.ce.tp, this.yAxis.cg));
                    if (c < this.yAxis.l6) {
                        return a[2];
                    }
                    else {
                        return a[1];
                    }
                case 4:
                    let d = (a[1] + a[2]) / 2;
                    let e = this.yAxis.el(d, new ScalerParams(1, this.ce.tq, this.ce.tp, this.yAxis.cg));
                    if (this.yAxis == null) {
                        return d;
                    }
                    if (e < this.yAxis.l6) {
                        return a[1];
                    }
                    else {
                        return a[2];
                    }
                default: return (a[1] + a[2]) / 2;
            }
        }
        get useHighMarkerFidelity() {
            return this.ss;
        }
    }
    ColumnSeries.$t = markType(ColumnSeries, 'ColumnSeries', HorizontalAnchoredCategorySeries.$);
    ColumnSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ColumnSeries, 'raisePropertyChanged', ['RadiusX:vn:vt', [1, 0], 'RadiusY:vo:vu', [1, 0]]);
    return ColumnSeries;
})();
/**
 * @hidden
 */
export let ColumnSeriesView = /*@__PURE__*/ (() => {
    class ColumnSeriesView extends AnchoredCategorySeriesView {
        constructor(a) {
            super(a);
            this.da = null;
            this.dc = null;
            this.dh = new Rectangle();
            this.db = null;
            this.da = a;
            this.db = ((() => {
                let $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;
            })());
        }
        as() {
            super.as();
            this.dc = new List$1(Rectangle.$, 0);
            if (!this.q) {
                this.da.g4 = Defaults.i;
                this.da.ql = Defaults.c;
            }
        }
        di() {
            let a = new Rectangle();
            this.dc.add(a);
            a._visibility = 1;
            return a;
        }
        dd(a) {
            a._visibility = 0;
        }
        df(a) {
            a._visibility = 1;
        }
        de(a) {
            this.dc.remove(a);
        }
        dg(a, b, c) {
            if (!this.isDirty) {
                this.aq();
            }
            a.o = c;
            a.n = b;
        }
        ac(a) {
            return this.dc._inner[a];
        }
        ab(a) {
            let 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;
            let c = this.bp(a);
            this.dh._fill = c;
            this.dh._stroke = c;
            this.dh.ad = this.e.fy + 3;
            return this.dh;
        }
        a6(a, b) {
            super.a6(a, b);
            if (a.d) {
                for (let c = 0; c < this.dc.count; c++) {
                    let d = this.aa(c, b);
                    this.bd(d, c, b);
                    a.w(d);
                }
            }
        }
        al(a) {
            super.al(a);
            let b = 0;
            let c = new List$1(Rectangle.$, 0);
            for (let d of fromEnum(this.db.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)) {
                this.e.a9.exportRectangleData(a, e, "column" + b, ["Main", "Fill"]);
            }
            b++;
        }
    }
    ColumnSeriesView.$t = markType(ColumnSeriesView, 'ColumnSeriesView', AnchoredCategorySeriesView.$);
    return ColumnSeriesView;
})();
