/*
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 { CategoryTrendLineManager } from "./CategoryTrendLineManager";
import { Point_$type, markType } from "igniteui-angular-core";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { ScalerParams } from "./ScalerParams";
import { SafeSortedReadOnlyDoubleCollection } from "./SafeSortedReadOnlyDoubleCollection";
import { List$1 } from "igniteui-angular-core";
import { BarTrendFitCalculator } from "./BarTrendFitCalculator";
import { TrendAverageCalculator } from "./TrendAverageCalculator";
/**
 * @hidden
 */
var BarTrendLineManager = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(BarTrendLineManager, _super);
    function BarTrendLineManager() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    BarTrendLineManager.prototype.prepareLine = function (a, b, c, d) {
        var e = b.n;
        var f = new ScalerParams(0, b.p, b.o, b.b.j$b, e);
        var g = new ScalerParams(0, b.p, b.o, b.c.j$b, e);
        var h = c.f;
        if (b.d != null && b.d.i$b != null) {
            h = new SafeSortedReadOnlyDoubleCollection(0, h, b.d.i$b);
        }
        var i = ((function () {
            var $ret = new TrendResolutionParams();
            $ret.e = b.j;
            $ret.f = b.k;
            $ret.g = b.l;
            $ret.a = d;
            $ret.d = b.i;
            $ret.i = b.o;
            $ret.h = b.n;
            return $ret;
        })());
        if (a.trendLineType != 0) {
            this.prepareLineCore(b.a.s, a.trendLineType, h, a.trendLinePeriod, function (j) { return b.c.j$c(j, g); }, function (j) { return b.b.j$c(j, f); }, i);
        }
    };
    BarTrendLineManager.prototype.prepareLineCore = function (a, b, c, d, e, f, g) {
        var h = g.f * g.e;
        var i = g.g * g.e;
        var j = new List$1(Point_$type, 0);
        if (b == 0) {
            this.a = null;
            this.i.clear();
            return;
        }
        if (this.d(b)) {
            this.i.clear();
            this.a = BarTrendFitCalculator.a(j, b, g, this.a, c.count, function (k) { return c.item(k); }, function (k) { return k + 1; }, e, function (k) { return f(k - 1); }, h + 1, i + 1);
        }
        if (this.c(b)) {
            this.a = null;
            TrendAverageCalculator.b(b, this.i, c, d);
            for (var k = g.f; k <= g.g; k += 1) {
                var l = k * g.e;
                if (l >= 0 && l < this.i.count) {
                    var m = e(this.i._inner[l]);
                    var n = f(l);
                    j.add({ $type: Point_$type, x: m, y: n + g.a });
                }
            }
        }
        this.f(j, g, a);
    };
    BarTrendLineManager.$t = markType(BarTrendLineManager, 'BarTrendLineManager', CategoryTrendLineManager.$);
    return BarTrendLineManager;
}(CategoryTrendLineManager));
export { BarTrendLineManager };
