/*
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 { CategoryFramePreparerBase } from "./CategoryFramePreparerBase";
import { IHasCategoryTrendline_$type } from "./IHasCategoryTrendline";
import { IHasHighLowValueCategory_$type } from "./IHasHighLowValueCategory";
import { ISupportsMarkers_$type } from "./ISupportsMarkers";
import { IProvidesViewport_$type } from "./IProvidesViewport";
import { ISupportsErrorBars_$type } from "./ISupportsErrorBars";
import { IBucketizer_$type } from "./IBucketizer";
import { DefaultCategoryTrendlineHost } from "./DefaultCategoryTrendlineHost";
import { DefaultHighLowValueProvider } from "./DefaultHighLowValueProvider";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { typeCast, Point_$type, Number_$type, markType } from "igniteui-react-core/ES2015/type";
import { HighLowValuesHolder } from "./HighLowValuesHolder";
import { isNaN_ } from "igniteui-react-core/ES2015/number";
/**
 * @hidden
 */
export class RangeCategoryFramePreparer extends CategoryFramePreparerBase {
    constructor(a, ..._rest) {
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0:
                {
                    let c = _rest[0];
                    let d = [c, typeCast(ISupportsMarkers_$type, c), typeCast(IProvidesViewport_$type, c), typeCast(ISupportsErrorBars_$type, c), typeCast(IBucketizer_$type, c)];
                    {
                        let f = d[0];
                        let g = d[1];
                        let h = d[2];
                        let i = d[3];
                        let j = d[4];
                        super(1, f, g, h, i, j);
                        this.aa = null;
                        this.ab = null;
                        this.aa = new DefaultCategoryTrendlineHost();
                        if (typeCast(IHasCategoryTrendline_$type, f) !== null) {
                            this.aa = typeCast(IHasCategoryTrendline_$type, f);
                        }
                        this.ab = new DefaultHighLowValueProvider();
                        if (typeCast(IHasHighLowValueCategory_$type, f) !== null) {
                            this.ab = typeCast(IHasHighLowValueCategory_$type, f);
                        }
                    }
                }
                break;
            case 1:
                {
                    let c = _rest[0];
                    let d = _rest[1];
                    let e = _rest[2];
                    let f = _rest[3];
                    let g = _rest[4];
                    super(1, c, d, e, f, g);
                    this.aa = null;
                    this.ab = null;
                    this.aa = new DefaultCategoryTrendlineHost();
                    if (typeCast(IHasCategoryTrendline_$type, c) !== null) {
                        this.aa = typeCast(IHasCategoryTrendline_$type, c);
                    }
                    this.ab = new DefaultHighLowValueProvider();
                    if (typeCast(IHasHighLowValueCategory_$type, c) !== null) {
                        this.ab = typeCast(IHasHighLowValueCategory_$type, c);
                    }
                }
                break;
        }
    }
    l(a, b, c, d, e, f) {
        let g = b[0];
        let h = b[1];
        let i = b[2];
        if (!isNaN_(g) && !isNaN_(h) && !isNaN_(i)) {
            a.m.add({ $type: Point_$type, x: g, y: (h + i) / 2 });
            this.c.updateMarkerTemplate(e, d, f);
            return true;
        }
        return false;
    }
    z(a, b, c, d) {
        let e = a;
        let f = e.f;
        let g = e.g;
        let h = f.item(b);
        let i = g.item(b);
        let j = Math.max(h, i);
        let k = Math.min(h, i);
        if (c) {
            e.c = k;
            e.d = j;
        }
        else {
            e.b = j;
            e.a = k;
        }
    }
    u(a, b, c) {
        let d = a;
        let e = d.f;
        let f = d.g;
        let g = e.item(b);
        let h = f.item(b);
        if (!isNaN_(g)) {
            d.b = Math.max(d.b, g);
            d.a = Math.min(d.a, g);
        }
        if (!isNaN_(h)) {
            d.b = Math.max(d.b, h);
            d.a = Math.min(d.a, h);
        }
    }
    e(a, b) {
        let c = b;
        return [a, c.a, c.b];
    }
    x(a, b, c, d, e, f) {
        if (d) {
            b[0] = b[0] + c;
        }
        else {
            b[0] = a.b.j$b(b[0], e) + c;
        }
        b[1] = a.c.j$b(b[1], f);
        b[2] = a.c.j$b(b[2], f);
    }
    y(a, b, c, d, e, f, g) {
        super.y(a, b, c, d, e, f, g);
        let h = a.h;
        let i = a.a.f.count;
        let j = a.a.f;
        let k = this.q;
        let l = k.count;
        let m = new List$1(Number_$type, 0);
        if (!c) {
            m.add(0);
        }
        let n = new List$1(Number_$type, 0);
        n.add(1);
        n.add(2);
        a.b.j$d(j, m, 0, i, d);
        a.c.j$d(j, n, 0, i, e);
        for (let o = 0; o < i; o++) {
            j._inner[o][0] = j._inner[o][0] + b;
        }
        if (g) {
            a.b.j$d(k, m, 0, l, d);
            a.c.j$d(k, n, 0, l, e);
            for (let p = 0; p < l; p++) {
                k._inner[p][0] = k._inner[p][0] + b;
            }
        }
    }
    j(a) {
        let b = new HighLowValuesHolder();
        b.f = this.ab.highColumn;
        b.g = this.ab.lowColumn;
        return b;
    }
}
RangeCategoryFramePreparer.$t = markType(RangeCategoryFramePreparer, 'RangeCategoryFramePreparer', CategoryFramePreparerBase.$);
