/*
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 { TrendLineManagerBase$1 } from "./TrendLineManagerBase$1";
import { Number_$type, Point_$type, markType } from "igniteui-react-core/ES2015/type";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { TrendFitCalculator } from "./TrendFitCalculator";
import { TrendAverageCalculator } from "./TrendAverageCalculator";
import { PolarLinePlanner } from "./PolarLinePlanner";
import { isNaN_ } from "igniteui-react-core/ES2015/number";
/**
 * @hidden
 */
export class RadialTrendLineManager extends TrendLineManagerBase$1 {
    constructor() {
        super(Number_$type);
        this.q = 0;
        this.p = 0;
        this.r = null;
        this.s = null;
    }
    get_g$a() {
        return 3;
    }
    get g$a() {
        return this.get_g$a();
    }
    t(a, b, c, d, e, f, g, h) {
        let i = g.d * g.c;
        let j = g.e * g.c;
        let k = new List$1(Point_$type, 0);
        if (!g.g.isEmpty && !g.f.isEmpty) {
            if (b == 0) {
                this.a = null;
                this.d.clear();
                return;
            }
            if (this.c(b)) {
                this.d.clear();
                this.a = TrendFitCalculator.a(k, b, g, this.a, c.count, (l) => (l + 1), (l) => c.item(l), (l) => e(l - 1), f, i + 1, j + 1);
            }
            if (this.b(b)) {
                this.a = null;
                TrendAverageCalculator.b(b, this.d, c, d);
                for (let l = g.d; l <= g.e; l += 1) {
                    let m = (l % c.count) * g.c;
                    if (m >= 0 && m < this.d.count) {
                        let n = e(m);
                        let o = f(this.d._inner[m]);
                        if (!isNaN_(n) && !isNaN_(o)) {
                            k.add({ $type: Point_$type, x: n + g.a, y: o });
                        }
                    }
                }
            }
            if (k.count > 0) {
                this.n(k, g, a, h);
            }
        }
    }
    m(a, b, c) {
        this.n(a, b, c, null);
    }
    n(a, b, c, d) {
        if (d != null) {
            d.i = c;
        }
        let e = ((() => {
            let $ret = new PolarLinePlanner();
            $ret.m = (f) => a.item(f).x;
            $ret.n = (f) => a.item(f).y;
            $ret.a = d;
            $ret.q = a.count;
            $ret.l = b.b;
            $ret.o = (f) => this.r(a.item(f).x, a.item(f).y);
            $ret.p = (f) => this.s(a.item(f).x, a.item(f).y);
            $ret.f = true;
            $ret.ab = b.f;
            $ret.ac = b.g;
            return $ret;
        })());
        e.x(null, null);
    }
}
RadialTrendLineManager.$t = markType(RadialTrendLineManager, 'RadialTrendLineManager', TrendLineManagerBase$1.$.specialize(Number_$type));
