/*
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.ms = null;
        this.lt = null;
        this.ls = null;
        this.lu = null;
        this.mq = { $type: Point_$type, x: NaN, y: NaN };
        this.lv = false;
        this.ms = { $type: Point_$type, x: NaN, y: NaN };
    }
    bf() {
        return new AnnotationLayerView(this);
    }
    il(a) {
        super.il(a);
        this.lr = a;
    }
    lx(a) {
        if (a == null) {
            return false;
        }
        if (a.cj) {
            return false;
        }
        if (a == this) {
            return false;
        }
        return a.du(a.bi.br, a.bi.bs, a.bi);
    }
    get_cm() {
        return this.lw;
    }
    bd() {
        if (this.be == 0) {
            return 1;
        }
        else {
            return super.bd();
        }
    }
    get_cw() {
        return this.lz || this.l0;
    }
    get_isUsableInLegend() {
        return this.l0;
    }
    ir(a, b, c, d) {
        super.ir(a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                let e = c;
                let f = d;
                if (e != null) {
                    this.mj(e.series);
                    let g = e.series;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.mg));
                    if (typeCast(XamDataChart.$, e) !== null) {
                        let h = e;
                        this.mi(h.axes);
                        let i = h.axes;
                        i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.l6));
                    }
                }
                if (f != null) {
                    this.me(f.series);
                    let j = f.series;
                    j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.mg));
                    if (typeCast(XamDataChart.$, f) !== null) {
                        let k = f;
                        this.md(k.axes);
                        let l = k.axes;
                        l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.l6));
                    }
                }
                break;
            case AnnotationLayer.$$p[3]:
            case AnnotationLayer.$$p[2]:
                if (this.cw) {
                    if (this.fd == -1) {
                        this.fd = XamDataChart.oa(this);
                    }
                }
                else {
                    this.fd = -1;
                    this.ku = null;
                    this.kv = null;
                }
                if (this.bs != null) {
                    this.bs.ig();
                }
                this.i4(true);
                break;
            case "TransitionProgress":
                this.lu.c(this.ev, this.lt, this.ls);
                if (this.cc(this.bi)) {
                    return;
                }
                if (this.ev == 1) {
                    this.mf(this.ls, this.bi);
                }
                else {
                    this.mf(this.lu, this.bi);
                }
                if (this.bs != null) {
                    this.bs.jh(this);
                }
                break;
            case AnnotationLayer.$$p[1]:
                if (this.bs != null) {
                    this.bs.id();
                }
                break;
            case AnnotationLayer.$$p[0]:
                this.ms = this.mr;
                this.ig(this.mr);
                break;
            case "ShouldRenderAsOverlay":
                if (this.bs != null) {
                    this.bi.ah(this.bs);
                    this.bi.ad(this.bs);
                }
                break;
        }
    }
    mj(a) {
        for (let b of fromEnum(a)) {
            if (!(b == this)) {
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.mh));
            }
        }
        this.i4(true);
    }
    mi(a) {
        for (let b of fromEnum(a)) {
            b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.l7));
        }
        this.i4(true);
    }
    me(a) {
        for (let b of fromEnum(a)) {
            if (!(b == this)) {
                b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.mh));
            }
        }
        this.i4(true);
    }
    md(a) {
        for (let b of fromEnum(a)) {
            b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.l7));
        }
        this.i4(true);
    }
    l7(a, b) {
        this.l9(a, b.animate);
    }
    mh(a, b) {
        this.ma(a, b.animate);
    }
    l9(a, b) {
    }
    ma(a, b) {
    }
    mg(a, b) {
        this.mb(b);
    }
    l6(a, b) {
        this.l8(b);
    }
    mo() {
        if (this.ku != null) {
            return this.ku;
        }
        return this.kw;
    }
    mp() {
        if (this.kv != null) {
            return this.kv;
        }
        return this.kz;
    }
    l8(a) {
        if (a.oldItems != null) {
            for (let b of fromEn(a.oldItems)) {
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.l7));
            }
        }
        if (a.newItems != null) {
            for (let c of fromEn(a.newItems)) {
                c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.l7));
            }
        }
        this.i4(true);
    }
    mb(a) {
        if (a.oldItems != null) {
            for (let b of fromEn(a.oldItems)) {
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.mh));
            }
        }
        if (a.newItems != null) {
            for (let c of fromEn(a.newItems)) {
                c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.mh));
            }
        }
        this.i4(true);
    }
    jk(a, b) {
        this.i4(false);
    }
    jj(a, b) {
        this.i4(true);
    }
    i5(a) {
        super.i5(a);
        if (this.cc(this.bi)) {
            return;
        }
        if (this.c8(a) && !this.dc) {
            let b = this.lt;
            if (this.ca()) {
                if (this.bt.g) {
                    this.bt.t();
                }
                this.lt = this.lu;
                this.lu = b;
            }
            else {
                this.lt = this.ls;
                this.ls = b;
            }
            this.mc(this.ls, this.bi);
            this.jc();
        }
        else {
            if (!this.dc) {
                this.mc(this.ls, this.bi);
            }
            this.mf(this.ls, this.bi);
        }
    }
    get_cj() {
        return true;
    }
    mc(a, b) {
    }
    mf(a, b) {
        this.lr.by();
    }
    l5(a) {
        let b = { $type: Point_$type, x: this.mq.x, y: this.mq.y };
        if (a.isVertical) {
            if (isNaN_(this.mq.y)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.mq.x)) {
                b.x = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        else {
            if (isNaN_(this.mq.x)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.mq.y)) {
                b.y = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        return new Tuple$2(Boolean_$type, Point_$type, true, b);
    }
    ig(a) {
        super.ig(a);
        if (isNaN_(this.ms.x) && isNaN_(this.ms.y)) {
            if (isNaN_(a.x) && isNaN_(a.y)) {
                this.lr.bx();
                return;
            }
            else {
                this.lr.bz();
                this.mq = a;
            }
        }
        else {
            this.lr.bz();
            this.mq = this.ms;
        }
        this.i4(true);
    }
    du(a, b, c) {
        let d = super.du(a, b, c);
        if (!this.bi.q()) {
            return d = false;
        }
        return d;
    }
    get_dq() {
        return this.ly;
    }
    get ly() {
        return this.lv;
    }
    set ly(a) {
        let b = this.lv;
        this.lv = a;
        this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.lv);
    }
}
AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
Type.dep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['CursorPosition:mr:mk', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'IsDefaultCrosshairDisabled:lw:ml', [0, true], 'UseIndex:lz:mm', [0, false], 'UseLegend:l0:mn', [0, false]]);
export class AnnotationLayerView extends SeriesView {
    constructor(a) {
        super(a);
        this.bu = null;
        this.bv = false;
        this.bw = -1;
        this.bu = a;
    }
    b0() {
        if (this.bv) {
            this.bv = false;
            this.bw = -1;
            this.bu.mq = { $type: Point_$type, x: NaN, y: NaN };
            this.bu.i4(true);
        }
    }
    bx() {
        this.bv = true;
        if (this.e.e0 != null) {
            this.e.e0.setTimeout(runOn(this, this.b0), 300);
        }
        else {
            this.bw = window.setTimeout(runOn(this, this.b0), 300);
        }
    }
    bz() {
        if (this.bv == true) {
            this.bv = false;
            if (this.bw != -1) {
                window.clearTimeout(this.bw);
                this.bw = -1;
            }
        }
    }
    by() {
        this.an();
    }
}
AnnotationLayerView.$t = markType(AnnotationLayerView, 'AnnotationLayerView', SeriesView.$);
