/*
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 { Series } from "./Series";
import { DependencyProperty } from "igniteui-react-core/ES2015/DependencyProperty";
import { Type, Point_$type, Boolean_$type, runOn, delegateRemove, typeCast, delegateCombine, fromEnum, fromEn, markType } from "igniteui-react-core/ES2015/type";
import { SeriesView } from "./SeriesView";
import { XamDataChart } from "./XamDataChart";
import { Tuple$2 } from "igniteui-react-core/ES2015/Tuple$2";
import { PropertyMetadata } from "igniteui-react-core/ES2015/PropertyMetadata";
import { isNaN_ } from "igniteui-react-core/ES2015/number";
export class AnnotationLayer extends Series {
    constructor() {
        super();
        this.mp = null;
        this.lq = null;
        this.lp = null;
        this.lr = null;
        this.mn = { $type: Point_$type, x: NaN, y: NaN };
        this.ls = false;
        this.mp = { $type: Point_$type, x: NaN, y: NaN };
    }
    bf() {
        return new AnnotationLayerView(this);
    }
    ii(a) {
        super.ii(a);
        this.lo = a;
    }
    lu(a) {
        if (a == null) {
            return false;
        }
        if (a.ci) {
            return false;
        }
        if (a == this) {
            return false;
        }
        return a.dt(a.bi.bp, a.bi.bq, a.bi);
    }
    get_cl() {
        return this.lt;
    }
    get cl() {
        return this.get_cl();
    }
    bd() {
        if (this.be == 0) {
            return 1;
        }
        else {
            return super.bd();
        }
    }
    get_cv() {
        return this.lw || this.lx;
    }
    get cv() {
        return this.get_cv();
    }
    get_isUsableInLegend() {
        return this.lx;
    }
    get isUsableInLegend() {
        return this.get_isUsableInLegend();
    }
    io(a, b, c, d) {
        super.io(a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                let e = c;
                let f = d;
                if (e != null) {
                    this.mg(e.series);
                    let g = e.series;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.md));
                    if (typeCast(XamDataChart.$, e) !== null) {
                        let h = e;
                        this.mf(h.axes);
                        let i = h.axes;
                        i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.l3));
                    }
                }
                if (f != null) {
                    this.mb(f.series);
                    let j = f.series;
                    j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.md));
                    if (typeCast(XamDataChart.$, f) !== null) {
                        let k = f;
                        this.ma(k.axes);
                        let l = k.axes;
                        l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.l3));
                    }
                }
                break;
            case AnnotationLayer.$$p[3]:
            case AnnotationLayer.$$p[2]:
                if (this.cv) {
                    if (this.fb == -1) {
                        this.fb = XamDataChart.n7(this);
                    }
                }
                else {
                    this.fb = -1;
                    this.kr = null;
                    this.ks = null;
                }
                if (this.bs != null) {
                    this.bs.id();
                }
                this.i1(true);
                break;
            case "TransitionProgress":
                this.lr.c(this.et, this.lq, this.lp);
                if (this.cc(this.bi)) {
                    return;
                }
                if (this.et == 1) {
                    this.mc(this.lp, this.bi);
                }
                else {
                    this.mc(this.lr, this.bi);
                }
                break;
            case AnnotationLayer.$$p[1]:
                if (this.bs != null) {
                    this.bs.ib();
                }
                break;
            case AnnotationLayer.$$p[0]:
                this.mp = this.mo;
                this.ic(this.mo);
                break;
            case "ShouldRenderAsOverlay":
                if (this.bs != null) {
                    this.bi.ah(this.bs);
                    this.bi.ad(this.bs);
                }
                break;
        }
    }
    mg(a) {
        for (let b of fromEnum(a)) {
            if (!(b == this)) {
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.me));
            }
        }
        this.i1(true);
    }
    mf(a) {
        for (let b of fromEnum(a)) {
            b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.l4));
        }
        this.i1(true);
    }
    mb(a) {
        for (let b of fromEnum(a)) {
            if (!(b == this)) {
                b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.me));
            }
        }
        this.i1(true);
    }
    ma(a) {
        for (let b of fromEnum(a)) {
            b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.l4));
        }
        this.i1(true);
    }
    l4(a, b) {
        this.l6(a, b.animate);
    }
    me(a, b) {
        this.l7(a, b.animate);
    }
    l6(a, b) {
    }
    l7(a, b) {
    }
    md(a, b) {
        this.l8(b);
    }
    l3(a, b) {
        this.l5(b);
    }
    ml() {
        if (this.kr != null) {
            return this.kr;
        }
        return this.kt;
    }
    mm() {
        if (this.ks != null) {
            return this.ks;
        }
        return this.kw;
    }
    l5(a) {
        if (a.oldItems != null) {
            for (let b of fromEn(a.oldItems)) {
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.l4));
            }
        }
        if (a.newItems != null) {
            for (let c of fromEn(a.newItems)) {
                c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.l4));
            }
        }
        this.i1(true);
    }
    l8(a) {
        if (a.oldItems != null) {
            for (let b of fromEn(a.oldItems)) {
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.me));
            }
        }
        if (a.newItems != null) {
            for (let c of fromEn(a.newItems)) {
                c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.me));
            }
        }
        this.i1(true);
    }
    jh(a, b) {
        this.i1(false);
    }
    jg(a, b) {
        this.i1(true);
    }
    i2(a) {
        super.i2(a);
        if (this.cc(this.bi)) {
            return;
        }
        if (this.c7(a) && !this.db) {
            let b = this.lq;
            if (this.ca()) {
                if (this.bt.g) {
                    this.bt.t();
                }
                this.lq = this.lr;
                this.lr = b;
            }
            else {
                this.lq = this.lp;
                this.lp = b;
            }
            this.l9(this.lp, this.bi);
            this.i9();
        }
        else {
            if (!this.db) {
                this.l9(this.lp, this.bi);
            }
            this.mc(this.lp, this.bi);
        }
    }
    get_ci() {
        return true;
    }
    get ci() {
        return this.get_ci();
    }
    l9(a, b) {
    }
    mc(a, b) {
        this.lo.bw();
    }
    l2(a) {
        let b = { $type: Point_$type, x: this.mn.x, y: this.mn.y };
        if (a.isVertical) {
            if (isNaN_(this.mn.y)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.mn.x)) {
                b.x = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        else {
            if (isNaN_(this.mn.x)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.mn.y)) {
                b.y = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        return new Tuple$2(Boolean_$type, Point_$type, true, b);
    }
    ic(a) {
        super.ic(a);
        if (isNaN_(this.mp.x) && isNaN_(this.mp.y)) {
            if (isNaN_(a.x) && isNaN_(a.y)) {
                this.lo.bv();
                return;
            }
            else {
                this.lo.bx();
                this.mn = a;
            }
        }
        else {
            this.lo.bx();
            this.mn = this.mp;
        }
        this.i1(true);
    }
    dt(a, b, c) {
        let d = super.dt(a, b, c);
        if (!this.bi.q()) {
            return d = false;
        }
        return d;
    }
    get_dp() {
        return this.lv;
    }
    get dp() {
        return this.get_dp();
    }
    get lv() {
        return this.ls;
    }
    set lv(a) {
        let b = this.ls;
        this.ls = a;
        this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.ls);
    }
}
AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
Type.dep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['CursorPosition:mo:mh', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'IsDefaultCrosshairDisabled:lt:mi', [0, true], 'UseIndex:lw:mj', [0, false], 'UseLegend:lx:mk', [0, false]]);
export class AnnotationLayerView extends SeriesView {
    constructor(a) {
        super(a);
        this.bs = null;
        this.bt = false;
        this.bu = -1;
        this.bs = a;
    }
    by() {
        if (this.bt) {
            this.bt = false;
            this.bu = -1;
            this.bs.mn = { $type: Point_$type, x: NaN, y: NaN };
            this.bs.i1(true);
        }
    }
    bv() {
        this.bt = true;
        if (this.e.ey != null) {
            this.e.ey.setTimeout(runOn(this, this.by), 300);
        }
        else {
            this.bu = window.setTimeout(runOn(this, this.by), 300);
        }
    }
    bx() {
        if (this.bt == true) {
            this.bt = false;
            if (this.bu != -1) {
                window.clearTimeout(this.bu);
                this.bu = -1;
            }
        }
    }
    bw() {
        this.an();
    }
}
AnnotationLayerView.$t = markType(AnnotationLayerView, 'AnnotationLayerView', SeriesView.$);
/*<BeginStatics Name="Infragistics.Controls.Charts.AnnotationLayer" />*/
/*<EndStatics Name="Infragistics.Controls.Charts.AnnotationLayer" />*/
