/*
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 { __extends } from "tslib";
import { DoubleTrendLineManagerBase } from "./DoubleTrendLineManagerBase";
import { Point_$type, 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
 */
var RadialTrendLineManager = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(RadialTrendLineManager, _super);
    function RadialTrendLineManager() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.k = 0;
        _this.j = 0;
        _this.l = null;
        _this.m = null;
        return _this;
    }
    RadialTrendLineManager.prototype.get_g$a = function () {
        return 3;
    };
    Object.defineProperty(RadialTrendLineManager.prototype, "g$a", {
        get: function () {
            return this.get_g$a();
        },
        enumerable: false,
        configurable: true
    });
    RadialTrendLineManager.prototype.n = function (a, b, c, d, e, f, g, h) {
        var i = g.f * g.e;
        var j = g.g * g.e;
        var k = new List$1(Point_$type, 0);
        if (!g.j.isEmpty && !g.i.isEmpty) {
            if (b == 0) {
                this.a = null;
                this.i.clear();
                return;
            }
            if (this.d(b)) {
                this.i.clear();
                this.a = TrendFitCalculator.a(k, b, g, this.a, c.count, function (l) { return (l + 1); }, function (l) { return c.item(l); }, function (l) { return e(l - 1); }, f, i + 1, j + 1);
            }
            if (this.c(b)) {
                this.a = null;
                TrendAverageCalculator.b(b, this.i, c, d);
                for (var l = g.f; l <= g.g; l += 1) {
                    var m = (l % c.count) * g.e;
                    if (m >= 0 && m < this.i.count) {
                        var n = e(m);
                        var o = f(this.i._inner[m]);
                        if (!isNaN_(n) && !isNaN_(o)) {
                            k.add({ $type: Point_$type, x: n + g.a, y: o });
                        }
                    }
                }
            }
            if (k.count > 0) {
                this.g(k, g, a, h);
            }
        }
    };
    RadialTrendLineManager.prototype.f = function (a, b, c) {
        this.g(a, b, c, null);
    };
    RadialTrendLineManager.prototype.g = function (a, b, c, d) {
        var _this = this;
        if (d != null) {
            d.i = c;
        }
        var e = ((function () {
            var $ret = new PolarLinePlanner();
            $ret.m = function (f) { return a.item(f).x; };
            $ret.n = function (f) { return a.item(f).y; };
            $ret.a = d;
            $ret.q = a.count;
            $ret.l = b.d;
            $ret.o = function (f) { return _this.l(a.item(f).x, a.item(f).y); };
            $ret.p = function (f) { return _this.m(a.item(f).x, a.item(f).y); };
            $ret.f = true;
            $ret.ad = b.i;
            $ret.ac = b.h;
            $ret.ae = b.j;
            return $ret;
        })());
        e.x(null, null);
    };
    RadialTrendLineManager.$t = markType(RadialTrendLineManager, 'RadialTrendLineManager', DoubleTrendLineManagerBase.$);
    return RadialTrendLineManager;
}(DoubleTrendLineManagerBase));
export { RadialTrendLineManager };
