/*
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 { AnnotationLayer } from "./AnnotationLayer";
import { Series } from "./Series";
import { DependencyProperty } from "igniteui-angular-core";
import { TrendLineType_$type } from "igniteui-angular-core";
import { ValueOverlay } from "./ValueOverlay";
import { enumGetBox, typeCast, markType, markDep } from "igniteui-angular-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { DoubleCollection } from "igniteui-angular-core";
import { DeviceUtils } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
/**
 * @hidden
 */
var TrendLineLayer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(TrendLineLayer, _super);
    function TrendLineLayer() {
        var _this = _super.call(this) || this;
        _this.aav = null;
        _this.aaw = null;
        _this.ab = TrendLineLayer.$;
        return _this;
    }
    TrendLineLayer.prototype.bk = function () {
        return new ValueOverlay();
    };
    TrendLineLayer.prototype.ac = function () {
        _super.prototype.ac.call(this);
    };
    TrendLineLayer.prototype.ct = function () {
        return new TrendLineLayerView(this);
    };
    TrendLineLayer.prototype.q7 = function (a) {
        _super.prototype.q7.call(this, a);
        this.aah = a;
    };
    TrendLineLayer.prototype.get_eu = function () {
        return true;
    };
    TrendLineLayer.prototype.get_fl = function () {
        return true;
    };
    TrendLineLayer.prototype.get_isUsableInLegend = function () {
        return this.xv && this.aaf != null;
    };
    TrendLineLayer.prototype.y1 = function (a, b) {
        if (this.aaf == null || this.aaf == a) {
            if (!this.a1.c) {
                this.ry(b);
            }
        }
    };
    TrendLineLayer.prototype.xs = function (a) {
        if (a == null) {
            return false;
        }
        if (a == this) {
            return false;
        }
        if (a.dc != this.dc) {
            return false;
        }
        if (a.eu || a.isStacked) {
            return false;
        }
        return true;
    };
    TrendLineLayer.prototype.r0 = function (a, b) {
        _super.prototype.r0.call(this, a, b);
        if (this.aaf != null && this.aaf.cv == null) {
            this.aaf.r1();
        }
        this.cw.be(b);
        var c = typeCast(TrendLineLayerView.$, this.cv);
        if (this.aaf != null && c.cp) {
            this.aaf.r1();
            c.cp = false;
        }
    };
    TrendLineLayer.prototype.rx = function (a, b, c, d, e) {
        _super.prototype.rx.call(this, a, b, c, d, e);
        var f = typeCast(TrendLineLayerView.$, this.cv);
        if (this.aaf != null) {
            this.aaf.rx(a, b, c, d, e);
        }
        this.cw.bd(c);
    };
    TrendLineLayer.prototype.y2 = function (a) {
        _super.prototype.y2.call(this, a);
        if (this.aaf == null) {
            this.aaq();
        }
        else {
            if (a.oldItems != null && a.oldItems.contains(this.aaf)) {
                this.aaf = null;
            }
        }
    };
    TrendLineLayer.prototype.aal = function () {
        switch (this.aai) {
            case 3: return "TrendLineLayer_CubicFit";
            case 12: return "TrendLineLayer_CumulativeAverage";
            case 10: return "TrendLineLayer_ExponentialAverage";
            case 7: return "TrendLineLayer_ExponentialAverage";
            case 1: return "TrendLineLayer_LinearFit";
            case 6: return "TrendLineLayer_LogarithmicFit";
            case 11: return "TrendLineLayer_ModifiedAverage";
            case 8: return "TrendLineLayer_PowerLawFit";
            case 2: return "TrendLineLayer_QuadraticFit";
            case 4: return "TrendLineLayer_QuarticFit";
            case 5: return "TrendLineLayer_QuinticFit";
            case 9: return "TrendLineLayer_SimpleAverage";
            case 13: return "TrendLineLayer_WeightedAverage";
        }
        return null;
    };
    TrendLineLayer.prototype.aaq = function () {
        if (this.aag != null && this.xs(this.aag)) {
            this.aaf = this.aag;
            return;
        }
    };
    TrendLineLayer.prototype.aan = function (a, b) {
        this.aah.ct(a, b);
        if (b != null) {
            b.ry(true);
        }
        this.o2(this.a5, this.a5);
    };
    TrendLineLayer.prototype.aap = function () {
        if (this.aaf != null && this.aah.cn != null) {
            this.aah.cn.g$b = this.aai;
            this.aaf.ry(true);
        }
    };
    TrendLineLayer.prototype.aao = function () {
        if (this.aaf != null && this.aah.cn != null) {
            this.aah.cn.g$f = this.aaj;
            this.aaf.ry(true);
        }
    };
    TrendLineLayer.prototype.sp = function () {
        _super.prototype.sp.call(this);
        this.qr();
        this.zb();
    };
    TrendLineLayer.prototype.zb = function () {
        _super.prototype.zb.call(this);
        var a = this.vj;
        if (!this.xu) {
            if (this.aaf != null) {
                a = this.vp != null ? this.vp : this.aaf.vj;
                if (this.aav == null) {
                    this.aav = this.vj;
                }
            }
            else {
                if (this.aav != null) {
                    a = this.aav;
                }
            }
        }
        switch (this.w8) {
            case 0:
            case 1:
                a = this.aah.ck(a, this.xx);
                break;
            case 2:
                a = this.aah.cm(a, this.xx);
                break;
            case 4:
                a = this.aah.cl(a, this.xx);
                break;
        }
        this.vj = a;
    };
    TrendLineLayer.prototype.xc = function () {
        return 3;
    };
    TrendLineLayer.prototype.xz = function () {
        return 0.3;
    };
    TrendLineLayer.prototype.x2 = function () {
        return -0.4;
    };
    TrendLineLayer.prototype.x1 = function () {
        return 0.5;
    };
    TrendLineLayer.prototype.z3 = function () {
        return this.w8 == 3 ? this.aax() : null;
    };
    TrendLineLayer.prototype.aax = function () {
        if (this.aaw == null) {
            this.aaw = new DoubleCollection();
            this.aaw.add(DeviceUtils.g(5));
            this.aaw.add(DeviceUtils.g(5));
        }
        return this.aaw;
    };
    TrendLineLayer.prototype.rg = function (a, b, c, d) {
        _super.prototype.rg.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                this.aaq();
                break;
            case "TrendLineType":
                this.aap();
                break;
            case "TrendLinePeriod":
                this.aao();
                break;
            case TrendLineLayer.$$p[0]:
                this.aan(c, d);
                this.zb();
                this.aah.cs();
                break;
            case TrendLineLayer.$$p[1]:
                this.aaq();
                break;
            case "ActualBrush":
            case "ActualThickness":
            case AnnotationLayer.$$p[1]:
            case "DashCap":
                this.aah.cs();
                break;
            case "UseItemWiseColors":
                this.zb();
                break;
        }
    };
    TrendLineLayer.prototype.p5 = function (a) {
        _super.prototype.p5.call(this, a);
        this.aah.ax(a);
    };
    TrendLineLayer.$t = markType(TrendLineLayer, 'TrendLineLayer', AnnotationLayer.$);
    TrendLineLayer.$$p = markDep(DependencyProperty, PropertyMetadata, TrendLineLayer, 'raisePropertyChanged', ['ActualTargetSeries:aaf:aar', [Series.$, null], 'TargetSeries:aag:aas', [Series.$, null], 'TrendLineType:aai:aau', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLinePeriod:aaj:aat', [1, 7]]);
    return TrendLineLayer;
}(AnnotationLayer));
export { TrendLineLayer };
/**
 * @hidden
 */
var TrendLineLayerView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(TrendLineLayerView, _super);
    function TrendLineLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.cq = 0;
        _this.co = null;
        _this.cn = null;
        _this.cp = false;
        _this.co = a;
        _this.cq = TrendLineLayerView.cr++;
        return _this;
    }
    TrendLineLayerView.prototype.cu = function () {
        if (this.cn == null && this.co.aaf != null) {
            if (this.t) {
                var a = this.co.aaf.cv;
                this.cn = a.e();
                this.cp = true;
            }
            else if (this.s) {
                var b = this.co.aaf.ba.a$j.item(this.al);
                this.cn = b.e();
            }
            else {
                var c = this.co.aaf.cw;
                this.cn = c.e();
            }
            if (this.cn != null) {
                this.cn.g$b = this.co.aai;
                this.cn.g$f = this.co.aaj;
                this.cs();
            }
        }
    };
    TrendLineLayerView.prototype.bj = function (a, b) {
        _super.prototype.bj.call(this, a, b);
        if (this.cn != null && a.d) {
            if (this.co.aai != 0 && !b) {
                var c = this.cn.g$n;
                c.ad = this.co.ig;
                c._stroke = this.co.vj;
                c.ai = this.co.z0;
                c.aj = this.co.wd;
                a.v(c);
            }
        }
    };
    TrendLineLayerView.prototype.ct = function (a, b) {
        if (a != null) {
            var c = null;
            if (this.t) {
                c = a.cv;
            }
            else if (this.s) {
                c = a.ba.a$j.item(this.al);
            }
            else {
                c = a.cw;
            }
            if (this.cn != null) {
                c.bf(this.cn);
                this.cn = null;
            }
        }
        this.cu();
    };
    TrendLineLayerView.prototype.cs = function () {
        if (this.cn != null) {
            this.cn.g$n.ad = this.co.ig;
            this.cn.g$n._stroke = this.co.vj;
            this.cn.g$n.ai = this.co.z0;
            this.cn.g$n.aj = this.co.wd;
        }
    };
    TrendLineLayerView.prototype.ax = function (a) {
        _super.prototype.ax.call(this, a);
        if (this.cn != null) {
            this.co.bc.exportTrendlineData(this.co, a, this.cn.g$n);
        }
    };
    TrendLineLayerView.$t = markType(TrendLineLayerView, 'TrendLineLayerView', AnnotationLayerView.$);
    TrendLineLayerView.cr = 0;
    return TrendLineLayerView;
}(AnnotationLayerView));
export { TrendLineLayerView };
