/*
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-react-core/ES2015/DependencyProperty";
import { FinalValueSelectionMode_$type } from "./FinalValueSelectionMode";
import { Brush } from "igniteui-react-core/ES2015/Brush";
import { Thickness } from "igniteui-react-core/ES2015/Thickness";
import { FinalValueLayerFrame } from "./FinalValueLayerFrame";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { Axis } from "./Axis";
import { Dictionary$2 } from "igniteui-react-core/ES2015/Dictionary$2";
import { Pool$1 } from "igniteui-react-core/ES2015/Pool$1";
import { AxisAnnotation } from "./AxisAnnotation";
import { Type, enumGetBox, fromEnum, Point_$type, markType } from "igniteui-react-core/ES2015/type";
import { AxisAnnotationFrameManager } from "./AxisAnnotationFrameManager";
import { PropertyMetadata } from "igniteui-react-core/ES2015/PropertyMetadata";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { BrushUtil } from "igniteui-react-core/ES2015/BrushUtil";
export class FinalValueLayer extends AnnotationLayer {
    constructor() {
        super();
        this.axisAnnotationFormatLabel = null;
        this.mz = null;
        this.my = null;
        let a = new FinalValueLayerFrame();
        let b = new FinalValueLayerFrame();
        let c = new FinalValueLayerFrame();
        let d = this.fe / 1000;
        this.lt = a;
        this.ls = b;
        this.lu = c;
        this.ab = FinalValueLayer.$;
    }
    bf() {
        return new FinalValueLayerView(this);
    }
    il(a) {
        super.il(a);
        this.mu = a;
    }
    get ny() {
        return new Thickness(1, this.m1, this.m3, this.m2, this.m0);
    }
    mx() {
        return this.axisAnnotationFormatLabel != null;
    }
    ma(a, b) {
        if (this.mw == null || this.mw == a) {
            if (!this.aq.c) {
                this.i4(b);
            }
        }
    }
    mc(a, b) {
        super.mc(a, b);
        let c = a;
        c.f.clear();
        c.q.clear();
        c.p.clear();
        c.aa.clear();
        c.o.clear();
        c.z.clear();
        c.g.clear();
        c.h.clear();
        c.j.clear();
        c.l.clear();
        c.k.clear();
        c.i.clear();
        c.m.clear();
        c.n.clear();
        c.r.clear();
        c.s.clear();
        c.u.clear();
        c.w.clear();
        c.v.clear();
        c.t.clear();
        c.x.clear();
        c.y.clear();
        if (this.lx(this.mw)) {
            this.nh(this.mw, c);
        }
        else {
            for (let d of fromEnum(this.bs.series)) {
                if (this.lx(d)) {
                    this.nh(d, c);
                }
            }
        }
    }
    lx(a) {
        if (!super.lx(a)) {
            return false;
        }
        return true;
    }
    ie() {
        super.ie();
        if (!this.aq.c && !this.ca()) {
            return;
        }
        if (this.ca()) {
            this.ni(this.lu, false);
        }
        else {
            this.ni(this.ls, false);
        }
    }
    nx(a) {
        let b = NaN;
        let c = NaN;
        let d = this.mv;
        if (d == 0) {
            d = 1;
        }
        let e = false;
        if (d == 2) {
            e = true;
        }
        if (a.isVertical) {
            let f = a.ap();
            if (f != null) {
                if (d == 1 || d == 2) {
                    if (f.b8) {
                        c = a.lf({ $type: Point_$type, x: this.lp.right, y: this.lp.bottom }).y;
                    }
                    else {
                        c = a.lf({ $type: Point_$type, x: this.lp.right, y: this.lp.top }).y;
                    }
                }
                else {
                    if (f.b8) {
                        c = 1;
                    }
                    else {
                        c = 0;
                    }
                }
            }
            return a.lc({ $type: Point_$type, x: 0, y: c }, e, true);
        }
        else {
            let g = a.ap();
            if (g != null) {
                if (d == 1 || d == 2) {
                    if (g.b8) {
                        b = a.lf({ $type: Point_$type, x: this.lp.left, y: this.lp.top }).x;
                    }
                    else {
                        b = a.lf({ $type: Point_$type, x: this.lp.right, y: this.lp.top }).x;
                    }
                }
                else {
                    if (g.b8) {
                        b = 0;
                    }
                    else {
                        b = 1;
                    }
                }
            }
            if (a.cr) {
                return a.lc({ $type: Point_$type, x: b, y: 0 }, e, true);
            }
            else {
                return a.lc({ $type: Point_$type, x: b, y: 0 }, e, true);
            }
        }
    }
    nh(a, b) {
        let c = this.nx(a);
        let d = this.lf(c);
        let e = this.ku;
        if (e == null) {
            e = this.kw;
        }
        if (e == null) {
            e = a.ku;
            if (e != null) {
                e = this.mu.b2(e);
            }
        }
        AxisAnnotationFrameManager.c(b, c, a, this.bs, this.getEffectiveViewport(), e, this.nu, this.nw, this.nv, this.ny, this.m4, this.nu, this.nw, this.nv, this.ny, this.m4, a.isVertical, !a.isVertical);
    }
    ni(a, b) {
        let c = false;
        if (this.my == null) {
            c = true;
            this.mz = new List$1(Axis.$, 0);
            this.my = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        AxisAnnotationFrameManager.d(this, a, c, this.my, this.mz, b, this.m5, this.m5, this.axisAnnotationFormatLabel, this.axisAnnotationFormatLabel);
    }
    mf(a, b) {
        super.mf(a, b);
        if (this.ca()) {
            this.ni(this.lu, true);
        }
        else {
            this.ni(this.ls, false);
        }
    }
    c6() {
        return true;
    }
    ir(a, b, c, d) {
        super.ir(a, b, c, d);
        switch (b) {
            case FinalValueLayer.$$p[10]:
                this.i4(true);
                break;
            case FinalValueLayer.$$p[0]:
            case FinalValueLayer.$$p[2]:
            case FinalValueLayer.$$p[4]:
            case FinalValueLayer.$$p[6]:
            case FinalValueLayer.$$p[5]:
            case FinalValueLayer.$$p[3]:
            case FinalValueLayer.$$p[7]:
            case FinalValueLayer.$$p[8]:
            case FinalValueLayer.$$p[9]:
                this.i4(true);
                break;
            case "SeriesViewer":
                let e = this.mz;
                let f = this.my;
                if (f != null) {
                    for (let g of fromEnum(f)) {
                        let h = g.value;
                        h.c((i) => g.key.ak.remove(i));
                        h.clear();
                    }
                    e.clear();
                    f.clear();
                }
                break;
        }
    }
}
FinalValueLayer.$t = markType(FinalValueLayer, 'FinalValueLayer', AnnotationLayer.$);
Type.dep(DependencyProperty, PropertyMetadata, FinalValueLayer, 'raisePropertyChanged', ['AxisAnnotationBackground:nu:nj', [Brush.$, null], 'AxisAnnotationInterpolatedValuePrecision:m5:nk', [1, -1], 'AxisAnnotationOutline:nv:nl', [Brush.$, null], 'AxisAnnotationPaddingBottom:m0:nm', [1, NaN], 'AxisAnnotationPaddingLeft:m1:nn', [1, NaN], 'AxisAnnotationPaddingRight:m2:no', [1, NaN], 'AxisAnnotationPaddingTop:m3:np', [1, NaN], 'AxisAnnotationStrokeThickness:m4:nq', [1, NaN], 'AxisAnnotationTextColor:nw:nr', [Brush.$, null], 'FinalValueSelectionMode:mv:ns', [FinalValueSelectionMode_$type, enumGetBox(FinalValueSelectionMode_$type, 0)], 'TargetSeries:mw:nt', [Series.$, null]]);
export class FinalValueLayerView extends AnnotationLayerView {
    constructor(a) {
        super(a);
        this.b1 = null;
        this.b1 = a;
    }
    ap() {
        super.ap();
    }
    b2(a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.h(a, 0.1);
    }
    ai(a) {
        super.ai(a);
    }
}
FinalValueLayerView.$t = markType(FinalValueLayerView, 'FinalValueLayerView', AnnotationLayerView.$);
