/*
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 { CategoryFramePreparer } from "./CategoryFramePreparer";
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 { IHasCategoryTrendline_$type } from "./IHasCategoryTrendline";
import { DefaultSingleValueProvider } from "./DefaultSingleValueProvider";
import { IHasSingleValueCategory_$type } from "./IHasSingleValueCategory";
import { Rect } from "igniteui-react-core/ES2015/Rect";
import { typeCast, Point_$type, markType } from "igniteui-react-core/ES2015/type";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { ScalerParams } from "./ScalerParams";
import { SafeSortedReadOnlyDoubleCollection } from "./SafeSortedReadOnlyDoubleCollection";
import { isNaN_, isInfinity } from "igniteui-react-core/ES2015/number";
/**
 * @hidden
 */
export class BarFramePreparer extends CategoryFramePreparer {
    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 = new DefaultCategoryTrendlineHost();
                        if (typeCast(IHasCategoryTrendline_$type, f) !== null) {
                            this.aa = typeCast(IHasCategoryTrendline_$type, f);
                        }
                        this.ab = new DefaultSingleValueProvider();
                        if (typeCast(IHasSingleValueCategory_$type, f) !== null) {
                            this.ab = typeCast(IHasSingleValueCategory_$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 = new DefaultCategoryTrendlineHost();
                    if (typeCast(IHasCategoryTrendline_$type, c) !== null) {
                        this.aa = typeCast(IHasCategoryTrendline_$type, c);
                    }
                    this.ab = new DefaultSingleValueProvider();
                    if (typeCast(IHasSingleValueCategory_$type, c) !== null) {
                        this.ab = typeCast(IHasSingleValueCategory_$type, c);
                    }
                }
                break;
        }
    }
    l(a, b, c, d, e, f) {
        let g = b[1];
        let h = b[0];
        let i = new Rect(0, g - 5, h - 5, 11, 11);
        if (!isNaN_(g) && !isNaN_(h) && !isInfinity(g) && !isInfinity(h) && c.tryAdd(i)) {
            a.m.add({ $type: Point_$type, x: g, y: h });
            this.c.updateMarkerTemplate(e, d, f);
            return true;
        }
        return false;
    }
    w(a, b, c) {
        if (this.aa.trendLineType == 0 || this.aa.trendlinePreparer == null || this.aa.trendLinePeriod < 1) {
            return;
        }
        let d = a.k;
        let e = new ScalerParams(0, a.m, a.l, a.b.j$a, d);
        let f = new ScalerParams(0, a.m, a.l, a.c.j$a, d);
        let g = b.f;
        if (a.d != null && a.d.i$b != null) {
            g = new SafeSortedReadOnlyDoubleCollection(0, g, a.d.i$b);
        }
        let h = ((() => {
            let $ret = new TrendResolutionParams();
            $ret.c = a.h;
            $ret.d = a.i;
            $ret.e = a.j;
            $ret.a = c;
            $ret.b = a.g;
            $ret.f = a.l;
            return $ret;
        })());
        if (this.aa.trendLineType != 0) {
            this.aa.trendlinePreparer.prepareLineCore(a.a.p, this.aa.trendLineType, g, this.aa.trendLinePeriod, (i) => a.c.j$b(i, f), (i) => a.b.j$b(i, e), h);
        }
    }
}
BarFramePreparer.$t = markType(BarFramePreparer, 'BarFramePreparer', CategoryFramePreparer.$);
