/*
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, enumGetBox, runOn, delegateRemove, typeCast, delegateCombine, fromEnum, fromEn, markType, markDep } from "igniteui-angular-core";
import { AnnotationAppearanceMode_$type } from "./AnnotationAppearanceMode";
import { DoubleCollection } 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.ta = null;
            this.qq = null;
            this.qp = null;
            this.qr = null;
            this.s8 = { $type: Point_$type, x: NaN, y: NaN };
            this.qs = false;
            this.ta = { $type: Point_$type, x: NaN, y: NaN };
            this.sd();
        }
        by() {
            return new AnnotationLayerView(this);
        }
        l4(a) {
            super.l4(a);
            this.qo = a;
        }
        qw(a) {
            if (a == null) {
                return false;
            }
            if (a.dd) {
                return false;
            }
            if (a.isValueOverlay) {
                return false;
            }
            if (a == this) {
                return false;
            }
            return a.fd(a.b1.bu, a.b1.bv, a.b1);
        }
        get_dm() {
            return this.qt;
        }
        bq() {
            if (this.br == 0) {
                return 1;
            }
            else {
                return super.bq();
            }
        }
        get_d1() {
            return this.qy || this.qz;
        }
        get_isUsableInLegend() {
            return this.qz;
        }
        l9(a, b, c, d) {
            super.l9(a, b, c, d);
            switch (b) {
                case "SeriesViewer":
                    let e = c;
                    let f = d;
                    if (e != null) {
                        this.sc(e.series);
                        let g = e.series;
                        g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.r9));
                        if (typeCast(XamDataChart.$, e) !== null) {
                            let h = e;
                            this.sb(h.axes);
                            let i = h.axes;
                            i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.rz));
                        }
                    }
                    if (f != null) {
                        this.r7(f.series);
                        let j = f.series;
                        j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.r9));
                        if (typeCast(XamDataChart.$, f) !== null) {
                            let k = f;
                            this.r6(k.axes);
                            let l = k.axes;
                            l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.rz));
                        }
                    }
                    break;
                case AnnotationLayer.$$p[16]:
                case AnnotationLayer.$$p[15]:
                    if (this.d1) {
                        if (this.index == -1) {
                            this.index = XamDataChart.vw(this);
                        }
                    }
                    else {
                        this.index = -1;
                        this.o5 = null;
                        this.o8 = null;
                    }
                    if (this.ce != null) {
                        this.ce.m8();
                    }
                    this.mn(true);
                    break;
                case "TransitionProgress":
                    this.qr.c(this.g5, this.qq, this.qp);
                    if (this.cy(this.b1)) {
                        return;
                    }
                    if (this.g5 == 1) {
                        this.r8(this.qp, this.b1);
                    }
                    else {
                        this.r8(this.qr, this.b1);
                    }
                    if (this.ce != null) {
                        this.ce.ob(this);
                    }
                    break;
                case AnnotationLayer.$$p[13]:
                    if (this.ce != null) {
                        this.ce.m6();
                    }
                    break;
                case AnnotationLayer.$$p[9]:
                    this.ta = this.s9;
                    this.ly(this.s9);
                    break;
                case "ShouldRenderAsOverlay":
                    if (this.ce != null) {
                        this.b1.ak(this.ce);
                        this.b1.ag(this.ce);
                    }
                    break;
                case AnnotationLayer.$$p[8]:
                case AnnotationLayer.$$p[14]:
                case "DashArray":
                case AnnotationLayer.$$p[10]:
                case AnnotationLayer.$$p[17]:
                case AnnotationLayer.$$p[12]:
                case AnnotationLayer.$$p[19]:
                case AnnotationLayer.$$p[11]:
                case AnnotationLayer.$$p[18]:
                    this.sd();
                    break;
                case AnnotationLayer.$$p[0]:
                case AnnotationLayer.$$p[4]:
                case AnnotationLayer.$$p[1]:
                case AnnotationLayer.$$p[5]:
                case AnnotationLayer.$$p[3]:
                case AnnotationLayer.$$p[7]:
                case AnnotationLayer.$$p[2]:
                case AnnotationLayer.$$p[6]:
                    this.mn(true);
                    break;
            }
        }
        sc(a) {
            for (let b of fromEnum(a)) {
                if (!(b == this)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.sa));
                }
            }
            this.mn(true);
        }
        sb(a) {
            for (let b of fromEnum(a)) {
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.r0));
            }
            this.mn(true);
        }
        r7(a) {
            for (let b of fromEnum(a)) {
                if (!(b == this)) {
                    b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.sa));
                }
            }
            this.mn(true);
        }
        r6(a) {
            for (let b of fromEnum(a)) {
                b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.r0));
            }
            this.mn(true);
        }
        qu(a) {
            if (a == null) {
                return false;
            }
            return true;
        }
        r0(a, b) {
            if (this.qu(a)) {
                this.r2(a, b.animate);
            }
        }
        qv(a) {
            if (a == null) {
                return false;
            }
            if (a.dd) {
                return false;
            }
            return true;
        }
        sa(a, b) {
            if (this.qv(a)) {
                this.r3(a, b.animate);
            }
        }
        r2(a, b) {
        }
        r3(a, b) {
        }
        r9(a, b) {
            this.r4(b);
        }
        rz(a, b) {
            this.r1(b);
        }
        sy() {
            if (this.o5 != null) {
                return this.o5;
            }
            return this.o9;
        }
        sz() {
            if (this.o8 != null) {
                return this.o8;
            }
            return this.pe;
        }
        r1(a) {
            if (a.oldItems != null) {
                for (let b of fromEn(a.oldItems)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.r0));
                }
            }
            if (a.newItems != null) {
                for (let c of fromEn(a.newItems)) {
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.r0));
                }
            }
            this.mn(true);
        }
        r4(a) {
            if (a.oldItems != null) {
                for (let b of fromEn(a.oldItems)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.sa));
                }
            }
            if (a.newItems != null) {
                for (let c of fromEn(a.newItems)) {
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.sa));
                }
            }
            this.mn(true);
        }
        nb(a, b) {
            this.mn(false);
        }
        na(a, b) {
            this.mn(true);
        }
        mo(a) {
            super.mo(a);
            if (this.cy(this.b1)) {
                return;
            }
            if (this.er(a) && !this.ew) {
                let b = this.qq;
                if (this.cw()) {
                    if (this.cf.g) {
                        this.cf.t();
                    }
                    this.qq = this.qr;
                    this.qr = b;
                }
                else {
                    this.qq = this.qp;
                    this.qp = b;
                }
                this.r5(this.qp, this.b1);
                this.mw();
            }
            else {
                if (!this.ew) {
                    this.r5(this.qp, this.b1);
                }
                this.r8(this.qp, this.b1);
            }
        }
        get_dd() {
            return true;
        }
        r5(a, b) {
        }
        r8(a, b) {
            this.qo.b1();
        }
        ry(a) {
            let b = { $type: Point_$type, x: this.s8.x, y: this.s8.y };
            if (a.isVertical) {
                if (isNaN_(this.s8.y)) {
                    return new Tuple$2(Boolean_$type, Point_$type, false, b);
                }
                if (isNaN_(this.s8.x)) {
                    b.x = 0;
                    return new Tuple$2(Boolean_$type, Point_$type, true, b);
                }
            }
            else {
                if (isNaN_(this.s8.x)) {
                    return new Tuple$2(Boolean_$type, Point_$type, false, b);
                }
                if (isNaN_(this.s8.y)) {
                    b.y = 0;
                    return new Tuple$2(Boolean_$type, Point_$type, true, b);
                }
            }
            return new Tuple$2(Boolean_$type, Point_$type, true, b);
        }
        ly(a) {
            super.ly(a);
            if (isNaN_(this.ta.x) && isNaN_(this.ta.y)) {
                if (isNaN_(a.x) && isNaN_(a.y)) {
                    this.qo.b0();
                    return;
                }
                else {
                    this.qo.b2();
                    this.s8 = a;
                }
            }
            else {
                this.qo.b2();
                this.s8 = this.ta;
            }
            this.mn(true);
        }
        fd(a, b, c) {
            let d = super.fd(a, b, c);
            if (!this.b1.t()) {
                d = false;
                return d;
            }
            return d;
        }
        q9() {
            if (isNaN_(this.rc)) {
                switch (this.qc) {
                    case 1: return this.q3();
                    case 2: return this.q6();
                    case 4: return this.q5();
                }
            }
            return this.rc;
        }
        q8() {
            if (isNaN_(this.rb)) {
                return this.q1;
            }
            return this.rb;
        }
        ra() {
            if (isNaN_(this.rd)) {
                return this.q1;
            }
            return this.rd;
        }
        qj() {
            switch (this.qf) {
                case 0: return this.qg();
            }
            return this.qf;
        }
        qk() {
            switch (this.qm) {
                case 0: return this.qc;
            }
            return this.qm;
        }
        ql() {
            switch (this.qn) {
                case 0: return this.qc;
            }
            return this.qn;
        }
        s4() {
            if (this.s6 == null) {
                if (this.pi == null) {
                    return this.s2();
                }
                return this.pi;
            }
            return this.s6;
        }
        s5() {
            if (this.s7 == null) {
                if (this.pi == null) {
                    return this.s3();
                }
                return this.pi;
            }
            return this.s7;
        }
        qg() {
            return 0;
        }
        qh() {
            return this.qg();
        }
        qi() {
            return this.qg();
        }
        q3() {
            return NaN;
        }
        q6() {
            return NaN;
        }
        q5() {
            return NaN;
        }
        q4() {
            return NaN;
        }
        q7() {
            return NaN;
        }
        s2() {
            return null;
        }
        s3() {
            return null;
        }
        sd() {
            this.qc = this.qj();
            this.q1 = this.q9();
            this.qd = this.qk();
            this.q0 = this.q8();
            this.qe = this.ql();
            this.q2 = this.ra();
            this.s0 = this.s4();
            this.s1 = this.s5();
        }
        get_e9() {
            return this.qx;
        }
        get qx() {
            return this.qs;
        }
        set qx(a) {
            let b = this.qs;
            this.qs = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.qs);
        }
    }
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    AnnotationLayer.$$p = markDep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['ActualAppearanceMode:qc:se', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalAppearanceMode:qd:sf', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalDashArray:s0:sg', [DoubleCollection.$], 'ActualHorizontalShiftAmount:q0:sh', [1, NaN], 'ActualShiftAmount:q1:si', [1, NaN], 'ActualVerticalAppearanceMode:qe:sj', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualVerticalDashArray:s1:sk', [DoubleCollection.$], 'ActualVerticalShiftAmount:q2:sl', [1, NaN], 'AppearanceMode:qf:sm', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'CursorPosition:s9:sn', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'HorizontalAppearanceMode:qm:so', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'HorizontalDashArray:s6:sp', [DoubleCollection.$], 'HorizontalShiftAmount:rb:sq', [1, NaN], 'IsDefaultCrosshairDisabled:qt:sr', [0, true], 'ShiftAmount:rc:ss', [1, NaN], 'UseIndex:qy:st', [0, false], 'UseLegend:qz:su', [0, false], 'VerticalAppearanceMode:qn:sv', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'VerticalDashArray:s7:sw', [DoubleCollection.$], 'VerticalShiftAmount:rd:sx', [1, NaN]]);
    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.s8 = { $type: Point_$type, x: NaN, y: NaN };
                this.bx.mn(true);
            }
        }
        b0() {
            this.by = true;
            if (this.e.he != null) {
                this.e.he.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;
})();
