/*
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 { HorizontalRangeCategorySeries } from "./HorizontalRangeCategorySeries";
import { DependencyProperty } from "igniteui-angular-core";
import { Defaults } from "./Defaults";
import { typeCast, runOn, markType, markDep, fromEnum } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { List$1 } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { Rectangle } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_, isInfinity } from "igniteui-angular-core";
import { RangeCategorySeriesView } from "./RangeCategorySeriesView";
/**
 * @hidden
 */
export let RangeColumnSeries = /*@__PURE__*/ (() => {
    class RangeColumnSeries extends HorizontalRangeCategorySeries {
        constructor() {
            super();
            this.ab = RangeColumnSeries.$;
        }
        get_dh() {
            return true;
        }
        get_d2() {
            return true;
        }
        gu() {
            if (!isNaN_(this.gt)) {
                return super.gu();
            }
            return Defaults.h;
        }
        bx() {
            return new RangeColumnSeriesView(this);
        }
        ly(a) {
            super.ly(a);
            this.ud = a;
        }
        get_c2() {
            return true;
        }
        preferredCategoryMode(a) {
            return 2;
        }
        pu(a) {
            if (this.xAxis == null || this.yAxis == null) {
                return Rect.empty;
            }
            let b = this.pg(a);
            let c = this.b0.bv;
            let d = this.b0.bu;
            let e = this.getEffectiveViewport1(this.b0);
            let f = new ScalerParams(0, c, d, this.yAxis.cg, e);
            f.b = this.gc();
            let g = this.aj(this.rn(), this.ro.f, this.so(this.b0), this.sp(this.b0), a, true);
            if (g == null) {
                return Rect.empty;
            }
            let h = g[0];
            let i = g[1];
            let j = Math.abs(b.x - h[0]);
            let k = Math.abs(b.x - i[0]);
            let l = this.xAxis.k3(c, d, e);
            if (j < k) {
                let m = h[0] - 0.5 * l;
                let n = h[1];
                let o = h[2];
                return new Rect(0, m, Math.min(n, o), l, Math.max(n, o) - Math.min(n, o));
            }
            else {
                let p = i[0] - 0.5 * l;
                let q = i[1];
                let r = i[2];
                return new Rect(0, p, Math.min(q, r), l, Math.max(q, r) - Math.min(q, r));
            }
        }
        ev(a, b) {
            if (this.ey(a, b)) {
                return true;
            }
            if (this.qf(a, b)) {
                return true;
            }
            return false;
        }
        kx(a, b) {
            super.kx(a, b);
            let c = b;
            if (a && c.c3 != null) {
                c.c3.count = 0;
            }
        }
        ga() {
            return this.xAxis.k3(this.b0.bv, this.b0.bu, this.getEffectiveViewport1(this.b0));
        }
        s6(a, b) {
            super.s6(a, b);
            let c = typeCast(RangeColumnSeriesView.$, b);
            let d = a.f;
            let e = b.bv;
            let f = b.bu;
            let g = this.getEffectiveViewport1(b);
            let h = this.xAxis.k3(e, f, g);
            if (isNaN_(h) || isInfinity(h)) {
                c.c3.count = 0;
                return;
            }
            this.rw.a0(this, this.sg(), runOn(this, this.rh), this.so(b), this.sp(b));
            this.rw.r = this.ue;
            this.rw.s = this.uf;
            this.rw.k = this.ue;
            this.rw.l = this.uf;
            let i = false;
            let j = this.rw.b;
            if (j != null) {
                i = true;
            }
            let k = this.xAxis.cm;
            let l = this.lowColumn.count;
            let m = this.xAxis;
            let n = new ScalerParams(0, e, f, this.xAxis.cg, g);
            let o = 0;
            for (let p = 0; p < d.count; ++p) {
                let q = d._inner[p][0] - 0.5 * h;
                let r = Math.min(d._inner[p][1], d._inner[p][2]);
                let s = Math.max(d._inner[p][1], d._inner[p][2]);
                let t = Math.abs(s - r);
                if (isInfinity(t) || isNaN_(t)) {
                    continue;
                }
                let u = c.c3.item(o);
                o++;
                u.width = h;
                u.height = t;
                if (i) {
                    this.s2(d, p, l, m, n, b.q);
                }
                this.rw.ad(u, false, false, false, false);
                u.am = this.rw.k;
                u.an = this.rw.l;
                c.c8(u, q, r);
            }
            c.c3.count = o;
            b.cy(a);
        }
        get useHighMarkerFidelity() {
            return this.sj;
        }
    }
    RangeColumnSeries.$t = markType(RangeColumnSeries, 'RangeColumnSeries', HorizontalRangeCategorySeries.$);
    RangeColumnSeries.$$p = markDep(DependencyProperty, PropertyMetadata, RangeColumnSeries, 'raisePropertyChanged', ['RadiusX:ue:ui', [1, 0], 'RadiusY:uf:uj', [1, 0]]);
    return RangeColumnSeries;
})();
/**
 * @hidden
 */
export let RangeColumnSeriesView = /*@__PURE__*/ (() => {
    class RangeColumnSeriesView extends RangeCategorySeriesView {
        constructor(a) {
            super(a);
            this.c2 = null;
            this.c3 = null;
            this.c4 = null;
            this.c9 = new Rectangle();
            this.c2 = a;
            this.c3 = ((() => {
                let $ret = new Pool$1(Rectangle.$);
                $ret.create = runOn(this, this.da);
                $ret.activate = runOn(this, this.c5);
                $ret.disactivate = runOn(this, this.c7);
                $ret.destroy = runOn(this, this.c6);
                return $ret;
            })());
        }
        as() {
            super.as();
            this.c4 = new List$1(Rectangle.$, 0);
            if (!this.q) {
                this.c2.qc = Defaults.c;
                this.c2.gz = Defaults.i;
            }
        }
        da() {
            let a = new Rectangle();
            this.c4.add(a);
            a._visibility = 1;
            return a;
        }
        c5(a) {
            a._visibility = 0;
        }
        c7(a) {
            a._visibility = 1;
        }
        c6(a) {
            this.c4.remove(a);
        }
        c8(a, b, c) {
            if (!this.isDirty) {
                this.aq();
            }
            a.o = c;
            a.n = b;
        }
        ac(a) {
            return this.c4._inner[a];
        }
        ab(a) {
            let b = this.c4._inner[a];
            this.c9._visibility = b._visibility;
            this.c9.n = b.n;
            this.c9.o = b.o;
            this.c9.width = b.width;
            this.c9.height = b.height;
            let c = this.bp(a);
            this.c9._fill = c;
            this.c9._stroke = c;
            this.c9.ac = this.e.fu + 3;
            return this.c9;
        }
        a6(a, b) {
            super.a6(a, b);
            if (a.d) {
                for (let c = 0; c < this.c4.count; c++) {
                    let d = this.aa(c, b);
                    this.bd(d, c, b);
                    a.v(d);
                }
            }
        }
        al(a) {
            super.al(a);
            let b = 0;
            let c = new List$1(Rectangle.$, 0);
            for (let d of fromEnum(this.c3.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.a8.exportRectangleData(a, e, "column" + b, ["Main", "Fill"]);
            }
            b++;
        }
    }
    RangeColumnSeriesView.$t = markType(RangeColumnSeriesView, 'RangeColumnSeriesView', RangeCategorySeriesView.$);
    return RangeColumnSeriesView;
})();
