/*
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 { PointTrendLineManagerBase } from "./PointTrendLineManagerBase";
import { Point_$type, fromEnum, markType } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { TrendFitCalculator } from "./TrendFitCalculator";
import { TrendAverageCalculator } from "./TrendAverageCalculator";
import { PolarLinePlanner } from "./PolarLinePlanner";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
export let PolarTrendLineManager = /*@__PURE__*/ (() => {
    class PolarTrendLineManager extends PointTrendLineManagerBase {
        constructor() {
            super(...arguments);
            this.k = false;
            this.j = 0;
            this.m = 0;
            this.l = 0;
            this.n = null;
            this.o = null;
        }
        get_g$a() {
            return 2;
        }
        get g$a() {
            return this.get_g$a();
        }
        p(a, b, c, d, e, f, g, h, i, j, k) {
            let l = j;
            let m = k;
            let n = new List$1(Point_$type, 0);
            if (!h.j.isEmpty && !h.i.isEmpty) {
                let o = c;
                let p = d;
                let q = 0;
                if (o != null) {
                    q = o.count;
                }
                if (p != null) {
                    q = Math.min(q, p.count);
                }
                if (b == 0) {
                    this.a = null;
                    this.i.clear();
                    return;
                }
                if (this.d(b)) {
                    this.i.clear();
                    this.a = TrendFitCalculator.a(n, b, h, this.a, q, (r) => o.item(r), (r) => p.item(r), f, g, l, m);
                }
                if (this.c(b)) {
                    this.a = null;
                    TrendAverageCalculator.c(b, this.i, c, d, e);
                    for (let r of fromEnum(this.i)) {
                        let s = f(r.x);
                        let t = g(r.y);
                        if (!isNaN_(s) && !isNaN_(t)) {
                            n.add({ $type: Point_$type, x: s, y: t });
                        }
                    }
                }
                if (n.count > 0) {
                    this.g(n, h, a, i);
                }
            }
        }
        g(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.d;
                $ret.o = (f) => this.n(a.item(f).x, a.item(f).y);
                $ret.p = (f) => this.o(a.item(f).x, a.item(f).y);
                $ret.f = this.k;
                $ret.b = this.j;
                $ret.ad = b.i;
                $ret.ac = b.h;
                $ret.ae = b.j;
                return $ret;
            })());
            e.x(null, null);
        }
    }
    PolarTrendLineManager.$t = markType(PolarTrendLineManager, 'PolarTrendLineManager', PointTrendLineManagerBase.$);
    return PolarTrendLineManager;
})();
