/*
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 * as tslib_1 from "tslib";
import { CategoryTrendLineManagerBase } from "./CategoryTrendLineManagerBase";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { Point_$type, markType } from "igniteui-react-core/ES5/type";
import { TrendFitCalculator } from "./TrendFitCalculator";
import { TrendAverageCalculator } from "./TrendAverageCalculator";
import { truncate } from "igniteui-react-core/ES5/number";
var SortingTrendLineManager = /** @class */ (function (_super) {
    tslib_1.__extends(SortingTrendLineManager, _super);
    function SortingTrendLineManager(a, b) {
        var _this = _super.call(this) || this;
        _this.p = null;
        _this.q = null;
        _this.p = a;
        _this.q = b;
        return _this;
    }
    SortingTrendLineManager.prototype.get_g$a = function () {
        return 1;
    };
    Object.defineProperty(SortingTrendLineManager.prototype, "g$a", {
        get: function () {
            return this.get_g$a();
        },
        enumerable: true,
        configurable: true
    });
    SortingTrendLineManager.prototype.prepareLineCore = function (a, b, c, d, e, f, g) {
        var _this = this;
        var h = g.d * g.c;
        var i = g.e * g.c;
        var j = new List$1(Point_$type, 0);
        if (b == 0) {
            this.a = null;
            this.d.clear();
            return;
        }
        if (this.c(b)) {
            this.d.clear();
            this.a = TrendFitCalculator.a(j, b, g, this.a, c.count, function (k) { return (k + 1); }, function (k) { return c.item(k); }, function (k) {
                var l = truncate(Math.floor(k));
                var m = truncate(Math.ceil(k));
                var n = k - l;
                var o;
                if (m <= i) {
                    o = _this.p(l) + n * (_this.p(m) - _this.p(l));
                }
                else {
                    o = _this.p(l) + n * (_this.p(truncate(i)) - _this.p(l));
                }
                return e(o);
            }, f, h, i);
        }
        if (this.b(b)) {
            this.a = null;
            TrendAverageCalculator.b(b, this.d, c, d);
            for (var k = g.d; k <= g.e; k += 1) {
                var l = k * g.c;
                var m = this.p(l);
                if (l >= 0 && l < this.d.count) {
                    var n = e(m);
                    var o = f(this.d._inner[l]);
                    j.add({ $type: Point_$type, x: n + g.a, y: o });
                }
            }
        }
        this.m(j, g, a);
    };
    SortingTrendLineManager.$t = markType(SortingTrendLineManager, 'SortingTrendLineManager', CategoryTrendLineManagerBase.$);
    return SortingTrendLineManager;
}(CategoryTrendLineManagerBase));
export { SortingTrendLineManager };
