/*
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 { ITrendLineManager_$type } from "./ITrendLineManager";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { Polyline } from "igniteui-react-core/ES5/Polyline";
import { Base, fromEnum, typeCast, markType } from "igniteui-react-core/ES5/type";
import { Flattener } from "igniteui-react-core/ES5/Flattener";
import { Series } from "./Series";
import { Panel } from "igniteui-react-core/ES5/Panel";
import { isNaN_ } from "igniteui-react-core/ES5/number";
var TrendLineManagerBase$1 = /** @class */ (function (_super) {
    tslib_1.__extends(TrendLineManagerBase$1, _super);
    function TrendLineManagerBase$1($tTrendColumn) {
        var _this = _super.call(this) || this;
        _this.$tTrendColumn = null;
        _this.d = null;
        _this.a = null;
        _this.o = ((function () {
            var $ret = new Polyline();
            $ret.ab = false;
            return $ret;
        })());
        _this.$tTrendColumn = $tTrendColumn;
        _this.$type = _this.$type.specialize(_this.$tTrendColumn);
        _this.d = new List$1(_this.$tTrendColumn, 0);
        return _this;
    }
    Object.defineProperty(TrendLineManagerBase$1.prototype, "g$j", {
        get: function () {
            return this.o;
        },
        enumerable: true,
        configurable: true
    });
    TrendLineManagerBase$1.prototype.g$g = function (a) {
        this.g$h(a, null);
    };
    TrendLineManagerBase$1.prototype.c = function (a) {
        return a == 1 || a == 2 || a == 3 || a == 4 || a == 5 || a == 6 || a == 7 || a == 8;
    };
    TrendLineManagerBase$1.prototype.b = function (a) {
        return a == 9 || a == 10 || a == 11 || a == 12 || a == 13;
    };
    TrendLineManagerBase$1.prototype.g$h = function (a, b) {
        this.g$j.aj.clear();
        if (b != null) {
            b.i = this.g$j.aj;
        }
        if (a != null) {
            try {
                for (var _a = tslib_1.__values(fromEnum(a)), _b = _a.next(); !_b.done; _b = _a.next()) {
                    var c = _b.value;
                    if (!isNaN_(c.x) && !isNaN_(c.y)) {
                        if (b != null) {
                            b.j(c);
                        }
                        else {
                            this.g$j.aj.add(c);
                        }
                    }
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
                }
                finally { if (e_1) throw e_1.error; }
            }
        }
        this.g$j.ab = this.g$j.aj.count > 0;
        var e_1, _c;
    };
    TrendLineManagerBase$1.prototype.m = function (a, b, c) {
        this.n(a, b, c, null);
    };
    TrendLineManagerBase$1.prototype.n = function (a, b, c, d) {
        if (d != null) {
            d.i = c;
        }
        try {
            for (var _a = tslib_1.__values(fromEnum(Flattener.d(a.count, function (f) { return a.item(f).x; }, function (f) { return a.item(f).y; }, b.b))), _b = _a.next(); !_b.done; _b = _a.next()) {
                var e = _b.value;
                if (d != null) {
                    d.j(a.item(e));
                }
                else {
                    c.add(a.item(e));
                }
            }
        }
        catch (e_2_1) { e_2 = { error: e_2_1 }; }
        finally {
            try {
                if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
            }
            finally { if (e_2) throw e_2.error; }
        }
        var e_2, _c;
    };
    TrendLineManagerBase$1.prototype.g$c = function (a, b) {
        if (a == null || b == null) {
            return;
        }
        if (this.g$j.x != null) {
            this.g$f();
        }
        a.ab.add(this.g$j);
    };
    TrendLineManagerBase$1.prototype.g$f = function () {
        if (this.g$j == null) {
            return;
        }
        var a = typeCast(Panel.$, this.g$j.x);
        if (a != null) {
            a.ab.remove(this.g$j);
        }
    };
    TrendLineManagerBase$1.prototype.g$d = function () {
        this.g$j.aj.clear();
    };
    TrendLineManagerBase$1.prototype.g$i = function () {
        this.a = null;
        this.d.clear();
    };
    TrendLineManagerBase$1.prototype.g$e = function (a, b, c, d) {
        switch (a) {
            case 3:
            case 2:
            case 1:
            case 0:
            case 4:
                this.g$i();
                break;
        }
    };
    TrendLineManagerBase$1.prototype.g$b = function (a, b, c, d) {
        var e = false;
        switch (b) {
            case "TrendLineType":
            case "TrendLinePeriod":
                this.g$i();
                e = true;
                break;
            case "TrendLineThickness":
                e = true;
                break;
            case Series.$$p[8]:
                e = true;
                this.g$i();
                break;
        }
        return e;
    };
    TrendLineManagerBase$1.$t = markType(TrendLineManagerBase$1, 'TrendLineManagerBase$1', Base.$, [ITrendLineManager_$type]);
    return TrendLineManagerBase$1;
}(Base));
export { TrendLineManagerBase$1 };
