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