/*
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 { 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
 */
export let TrendLineManagerBase = /*@__PURE__*/ (() => {
    class TrendLineManagerBase extends Base {
        constructor() {
            super();
            this.a = null;
            this.h = ((() => {
                let $ret = new Polyline();
                $ret.ab = false;
                return $ret;
            })());
            this.b = false;
            this.g$b = 0;
            this.g$f = 0;
            this.g$d = false;
        }
        get g$n() {
            return this.h;
        }
        get g$c() {
            return this.b;
        }
        g$k(a) {
            this.g$l(a, null);
        }
        d(a) {
            return a == 1 || a == 2 || a == 3 || a == 4 || a == 5 || a == 6 || a == 7 || a == 8;
        }
        c(a) {
            return a == 9 || a == 10 || a == 11 || a == 12 || a == 13;
        }
        g$l(a, b) {
            this.g$n.an.clear();
            if (b != null) {
                b.i = this.g$n.an;
            }
            if (a != null) {
                for (let c of fromEnum(a)) {
                    if (!isNaN_(c.x) && !isNaN_(c.y)) {
                        if (b != null) {
                            b.j(c);
                        }
                        else {
                            this.g$n.an.add(c);
                        }
                    }
                }
            }
            this.g$n.ab = this.g$n.an.count > 0;
        }
        f(a, b, c) {
            this.g(a, b, c, null);
        }
        g(a, b, c, d) {
            if (d != null) {
                d.i = c;
            }
            for (let e of fromEnum(Flattener.d(a.count, (f) => a.item(f).x, (f) => a.item(f).y, b.d))) {
                if (d != null) {
                    d.j(a.item(e));
                }
                else {
                    c.add(a.item(e));
                }
            }
        }
        g$g(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;
        }
        g$j() {
            if (this.g$n == null) {
                return;
            }
            let a = typeCast(Panel.$, this.g$n.x);
            if (a != null) {
                a.ab.remove(this.g$n);
                this.b = false;
            }
        }
        g$h() {
            this.g$n.an.clear();
        }
        g$m() {
            this.a = null;
            this.e();
        }
        g$i(a, b, c, d) {
            switch (a) {
                case 3:
                case 2:
                case 1:
                case 0:
                case 4:
                    this.g$m();
                    break;
            }
        }
        g$e(a, b, c, d) {
            let 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;
})();
