/*
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-angular-core";
import { Point_$type, Boolean_$type, runOn, delegateRemove, typeCast, delegateCombine, fromEnum, fromEn, markType, markDep } from "igniteui-angular-core";
import { SeriesView } from "./SeriesView";
import { XamDataChart } from "./XamDataChart";
import { Tuple$2 } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
export let AnnotationLayer = /*@__PURE__*/ (() => {
    class AnnotationLayer extends Series {
        constructor() {
            super();
            this.rb = null;
            this.qa = null;
            this.p9 = null;
            this.qb = null;
            this.q9 = { $type: Point_$type, x: NaN, y: NaN };
            this.qc = false;
            this.rb = { $type: Point_$type, x: NaN, y: NaN };
        }
        bx() {
            return new AnnotationLayerView(this);
        }
        l2(a) {
            super.l2(a);
            this.p8 = a;
        }
        qg(a) {
            if (a == null) {
                return false;
            }
            if (a.dc) {
                return false;
            }
            if (a.isValueOverlay) {
                return false;
            }
            if (a == this) {
                return false;
            }
            return a.fb(a.b0.bu, a.b0.bv, a.b0);
        }
        get_dk() {
            return this.qd;
        }
        bp() {
            if (this.bq == 0) {
                return 1;
            }
            else {
                return super.bp();
            }
        }
        get_dz() {
            return this.qi || this.qj;
        }
        get_isUsableInLegend() {
            return this.qj;
        }
        l7(a, b, c, d) {
            super.l7(a, b, c, d);
            switch (b) {
                case "SeriesViewer":
                    let e = c;
                    let f = d;
                    if (e != null) {
                        this.q2(e.series);
                        let g = e.series;
                        g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.qz));
                        if (typeCast(XamDataChart.$, e) !== null) {
                            let h = e;
                            this.q1(h.axes);
                            let i = h.axes;
                            i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.qp));
                        }
                    }
                    if (f != null) {
                        this.qx(f.series);
                        let j = f.series;
                        j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.qz));
                        if (typeCast(XamDataChart.$, f) !== null) {
                            let k = f;
                            this.qw(k.axes);
                            let l = k.axes;
                            l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.qp));
                        }
                    }
                    break;
                case AnnotationLayer.$$p[3]:
                case AnnotationLayer.$$p[2]:
                    if (this.dz) {
                        if (this.index == -1) {
                            this.index = XamDataChart.vv(this);
                        }
                    }
                    else {
                        this.index = -1;
                        this.o3 = null;
                        this.o6 = null;
                    }
                    if (this.cd != null) {
                        this.cd.m7();
                    }
                    this.ml(true);
                    break;
                case "TransitionProgress":
                    this.qb.c(this.g2, this.qa, this.p9);
                    if (this.cx(this.b0)) {
                        return;
                    }
                    if (this.g2 == 1) {
                        this.qy(this.p9, this.b0);
                    }
                    else {
                        this.qy(this.qb, this.b0);
                    }
                    if (this.cd != null) {
                        this.cd.oa(this);
                    }
                    break;
                case AnnotationLayer.$$p[1]:
                    if (this.cd != null) {
                        this.cd.m5();
                    }
                    break;
                case AnnotationLayer.$$p[0]:
                    this.rb = this.ra;
                    this.lw(this.ra);
                    break;
                case "ShouldRenderAsOverlay":
                    if (this.cd != null) {
                        this.b0.ak(this.cd);
                        this.b0.ag(this.cd);
                    }
                    break;
            }
        }
        q2(a) {
            for (let b of fromEnum(a)) {
                if (!(b == this)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.q0));
                }
            }
            this.ml(true);
        }
        q1(a) {
            for (let b of fromEnum(a)) {
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.qq));
            }
            this.ml(true);
        }
        qx(a) {
            for (let b of fromEnum(a)) {
                if (!(b == this)) {
                    b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.q0));
                }
            }
            this.ml(true);
        }
        qw(a) {
            for (let b of fromEnum(a)) {
                b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.qq));
            }
            this.ml(true);
        }
        qe(a) {
            if (a == null) {
                return false;
            }
            return true;
        }
        qq(a, b) {
            if (this.qe(a)) {
                this.qs(a, b.animate);
            }
        }
        qf(a) {
            if (a == null) {
                return false;
            }
            if (a.dc) {
                return false;
            }
            return true;
        }
        q0(a, b) {
            if (this.qf(a)) {
                this.qt(a, b.animate);
            }
        }
        qs(a, b) {
        }
        qt(a, b) {
        }
        qz(a, b) {
            this.qu(b);
        }
        qp(a, b) {
            this.qr(b);
        }
        q7() {
            if (this.o3 != null) {
                return this.o3;
            }
            return this.o7;
        }
        q8() {
            if (this.o6 != null) {
                return this.o6;
            }
            return this.pc;
        }
        qr(a) {
            if (a.oldItems != null) {
                for (let b of fromEn(a.oldItems)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.qq));
                }
            }
            if (a.newItems != null) {
                for (let c of fromEn(a.newItems)) {
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.qq));
                }
            }
            this.ml(true);
        }
        qu(a) {
            if (a.oldItems != null) {
                for (let b of fromEn(a.oldItems)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.q0));
                }
            }
            if (a.newItems != null) {
                for (let c of fromEn(a.newItems)) {
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.q0));
                }
            }
            this.ml(true);
        }
        m9(a, b) {
            this.ml(false);
        }
        m8(a, b) {
            this.ml(true);
        }
        mm(a) {
            super.mm(a);
            if (this.cx(this.b0)) {
                return;
            }
            if (this.ep(a) && !this.eu) {
                let b = this.qa;
                if (this.cv()) {
                    if (this.ce.g) {
                        this.ce.t();
                    }
                    this.qa = this.qb;
                    this.qb = b;
                }
                else {
                    this.qa = this.p9;
                    this.p9 = b;
                }
                this.qv(this.p9, this.b0);
                this.mu();
            }
            else {
                if (!this.eu) {
                    this.qv(this.p9, this.b0);
                }
                this.qy(this.p9, this.b0);
            }
        }
        get_dc() {
            return true;
        }
        qv(a, b) {
        }
        qy(a, b) {
            this.p8.b1();
        }
        qo(a) {
            let b = { $type: Point_$type, x: this.q9.x, y: this.q9.y };
            if (a.isVertical) {
                if (isNaN_(this.q9.y)) {
                    return new Tuple$2(Boolean_$type, Point_$type, false, b);
                }
                if (isNaN_(this.q9.x)) {
                    b.x = 0;
                    return new Tuple$2(Boolean_$type, Point_$type, true, b);
                }
            }
            else {
                if (isNaN_(this.q9.x)) {
                    return new Tuple$2(Boolean_$type, Point_$type, false, b);
                }
                if (isNaN_(this.q9.y)) {
                    b.y = 0;
                    return new Tuple$2(Boolean_$type, Point_$type, true, b);
                }
            }
            return new Tuple$2(Boolean_$type, Point_$type, true, b);
        }
        lw(a) {
            super.lw(a);
            if (isNaN_(this.rb.x) && isNaN_(this.rb.y)) {
                if (isNaN_(a.x) && isNaN_(a.y)) {
                    this.p8.b0();
                    return;
                }
                else {
                    this.p8.b2();
                    this.q9 = a;
                }
            }
            else {
                this.p8.b2();
                this.q9 = this.rb;
            }
            this.ml(true);
        }
        fb(a, b, c) {
            let d = super.fb(a, b, c);
            if (!this.b0.t()) {
                d = false;
                return d;
            }
            return d;
        }
        get_e7() {
            return this.qh;
        }
        get qh() {
            return this.qc;
        }
        set qh(a) {
            let b = this.qc;
            this.qc = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.qc);
        }
    }
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    AnnotationLayer.$$p = markDep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['CursorPosition:ra:q3', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'IsDefaultCrosshairDisabled:qd:q4', [0, true], 'UseIndex:qi:q5', [0, false], 'UseLegend:qj:q6', [0, false]]);
    return AnnotationLayer;
})();
/**
 * @hidden
 */
export let AnnotationLayerView = /*@__PURE__*/ (() => {
    class AnnotationLayerView extends SeriesView {
        constructor(a) {
            super(a);
            this.bx = null;
            this.by = false;
            this.bz = -1;
            this.bx = a;
        }
        b3() {
            if (this.by) {
                this.by = false;
                this.bz = -1;
                this.bx.q9 = { $type: Point_$type, x: NaN, y: NaN };
                this.bx.ml(true);
            }
        }
        b0() {
            this.by = true;
            if (this.e.hb != null) {
                this.e.hb.setTimeout(runOn(this, this.b3), 300);
            }
            else {
                this.bz = window.setTimeout(runOn(this, this.b3), 300);
            }
        }
        b2() {
            if (this.by == true) {
                this.by = false;
                if (this.bz != -1) {
                    window.clearTimeout(this.bz);
                    this.bz = -1;
                }
            }
        }
        b1() {
            this.aq();
        }
    }
    AnnotationLayerView.$t = markType(AnnotationLayerView, 'AnnotationLayerView', SeriesView.$);
    return AnnotationLayerView;
})();
