/*
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 { 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
 */
export let TrendLineLayer = /*@__PURE__*/ (() => {
    class TrendLineLayer extends AnnotationLayer {
        constructor() {
            super();
            this.aav = null;
            this.aaw = null;
            this.ab = TrendLineLayer.$;
        }
        bk() {
            return new ValueOverlay();
        }
        ac() {
            super.ac();
        }
        ct() {
            return new TrendLineLayerView(this);
        }
        q7(a) {
            super.q7(a);
            this.aah = a;
        }
        get_eu() {
            return true;
        }
        get_fl() {
            return true;
        }
        get_isUsableInLegend() {
            return this.xv && this.aaf != null;
        }
        y1(a, b) {
            if (this.aaf == null || this.aaf == a) {
                if (!this.a1.c) {
                    this.ry(b);
                }
            }
        }
        xs(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;
        }
        r0(a, b) {
            super.r0(a, b);
            if (this.aaf != null && this.aaf.cv == null) {
                this.aaf.r1();
            }
            this.cw.be(b);
            let c = typeCast(TrendLineLayerView.$, this.cv);
            if (this.aaf != null && c.cp) {
                this.aaf.r1();
                c.cp = false;
            }
        }
        rx(a, b, c, d, e) {
            super.rx(a, b, c, d, e);
            let f = typeCast(TrendLineLayerView.$, this.cv);
            if (this.aaf != null) {
                this.aaf.rx(a, b, c, d, e);
            }
            this.cw.bd(c);
        }
        y2(a) {
            super.y2(a);
            if (this.aaf == null) {
                this.aaq();
            }
            else {
                if (a.oldItems != null && a.oldItems.contains(this.aaf)) {
                    this.aaf = null;
                }
            }
        }
        aal() {
            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;
        }
        aaq() {
            if (this.aag != null && this.xs(this.aag)) {
                this.aaf = this.aag;
                return;
            }
        }
        aan(a, b) {
            this.aah.ct(a, b);
            if (b != null) {
                b.ry(true);
            }
            this.o2(this.a5, this.a5);
        }
        aap() {
            if (this.aaf != null && this.aah.cn != null) {
                this.aah.cn.g$b = this.aai;
                this.aaf.ry(true);
            }
        }
        aao() {
            if (this.aaf != null && this.aah.cn != null) {
                this.aah.cn.g$f = this.aaj;
                this.aaf.ry(true);
            }
        }
        sp() {
            super.sp();
            this.qr();
            this.zb();
        }
        zb() {
            super.zb();
            let 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;
        }
        xc() {
            return 3;
        }
        xz() {
            return 0.3;
        }
        x2() {
            return -0.4;
        }
        x1() {
            return 0.5;
        }
        z3() {
            return this.w8 == 3 ? this.aax() : null;
        }
        aax() {
            if (this.aaw == null) {
                this.aaw = new DoubleCollection();
                this.aaw.add(DeviceUtils.g(5));
                this.aaw.add(DeviceUtils.g(5));
            }
            return this.aaw;
        }
        rg(a, b, c, d) {
            super.rg(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;
            }
        }
        p5(a) {
            super.p5(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;
})();
/**
 * @hidden
 */
export let TrendLineLayerView = /*@__PURE__*/ (() => {
    class TrendLineLayerView extends AnnotationLayerView {
        constructor(a) {
            super(a);
            this.cq = 0;
            this.co = null;
            this.cn = null;
            this.cp = false;
            this.co = a;
            this.cq = TrendLineLayerView.cr++;
        }
        cu() {
            if (this.cn == null && this.co.aaf != null) {
                if (this.t) {
                    let a = this.co.aaf.cv;
                    this.cn = a.e();
                    this.cp = true;
                }
                else if (this.s) {
                    let b = this.co.aaf.ba.a$j.item(this.al);
                    this.cn = b.e();
                }
                else {
                    let 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();
                }
            }
        }
        bj(a, b) {
            super.bj(a, b);
            if (this.cn != null && a.d) {
                if (this.co.aai != 0 && !b) {
                    let 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);
                }
            }
        }
        ct(a, b) {
            if (a != null) {
                let 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();
        }
        cs() {
            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;
            }
        }
        ax(a) {
            super.ax(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;
})();
