/*
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 { __extends, __values } from "tslib";
import { Series } from "./Series";
import { DependencyProperty } from "igniteui-react-core";
import { Point_$type, Boolean_$type, enumGetBox, runOn, delegateRemove, typeCast, delegateCombine, fromEnum, fromEn, markType, markDep } from "igniteui-react-core";
import { AnnotationAppearanceMode_$type } from "./AnnotationAppearanceMode";
import { DoubleCollection } from "igniteui-react-core";
import { SeriesView } from "./SeriesView";
import { XamDataChart } from "./XamDataChart";
import { Tuple$2 } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
/**
 * @hidden
 */
var AnnotationLayer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(AnnotationLayer, _super);
    function AnnotationLayer() {
        var _this = _super.call(this) || this;
        _this.wz = null;
        _this.uf = null;
        _this.ue = null;
        _this.ug = null;
        _this.wx = { $type: Point_$type, x: NaN, y: NaN };
        _this.uh = false;
        _this.wz = { $type: Point_$type, x: NaN, y: NaN };
        _this.v2();
        return _this;
    }
    AnnotationLayer.prototype.cg = function () {
        return new AnnotationLayerView(this);
    };
    AnnotationLayer.prototype.o0 = function (a) {
        _super.prototype.o0.call(this, a);
        this.ud = a;
    };
    AnnotationLayer.prototype.ul = function (a) {
        if (a == null) {
            return false;
        }
        if (a.d6) {
            return false;
        }
        if (a.isValueOverlay) {
            return false;
        }
        if (a == this) {
            return false;
        }
        return a.gl(a.cj.bx, a.cj.by, a.cj);
    };
    AnnotationLayer.prototype.get_ef = function () {
        return this.ui;
    };
    AnnotationLayer.prototype.bx = function () {
        if (this.by == 0) {
            return 1;
        }
        else {
            return _super.prototype.bx.call(this);
        }
    };
    AnnotationLayer.prototype.get_et = function () {
        return this.un || this.uo;
    };
    AnnotationLayer.prototype.get_isUsableInLegend = function () {
        return this.uo;
    };
    AnnotationLayer.prototype.o8 = function (a, b, c, d) {
        _super.prototype.o8.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                var e = c;
                var f = d;
                if (e != null) {
                    this.v1(e.series);
                    var g = e.series;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.vy));
                    if (typeCast(XamDataChart.$, e) !== null) {
                        var h = e;
                        this.v0(h.axes);
                        var i = h.axes;
                        i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.vo));
                    }
                }
                if (f != null) {
                    this.vw(f.series);
                    var j = f.series;
                    j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.vy));
                    if (typeCast(XamDataChart.$, f) !== null) {
                        var k = f;
                        this.vv(k.axes);
                        var l = k.axes;
                        l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.vo));
                    }
                }
                break;
            case AnnotationLayer.$$p[16]:
            case AnnotationLayer.$$p[15]:
                if (this.et) {
                    if (this.index == -1) {
                        this.index = XamDataChart.v9(this);
                    }
                }
                else {
                    this.index = -1;
                    this.ss = null;
                    this.sv = null;
                }
                if (this.cy != null) {
                    this.cy.ni();
                }
                this.pp(true);
                break;
            case "TransitionProgress":
                this.ug.c(this.iv, this.uf, this.ue);
                if (this.dl(this.cj)) {
                    return;
                }
                if (this.iv == 1) {
                    this.vx(this.ue, this.cj);
                }
                else {
                    this.vx(this.ug, this.cj);
                }
                if (this.cy != null) {
                    this.cy.on(this);
                }
                break;
            case AnnotationLayer.$$p[13]:
                if (this.cy != null) {
                    this.cy.ng();
                }
                break;
            case AnnotationLayer.$$p[9]:
                this.wz = this.wy;
                this.oq(this.wy);
                break;
            case "ShouldRenderAsOverlay":
                if (this.cy != null) {
                    this.cj.al(this.cy);
                    this.cj.ag(this.cy);
                }
                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.v2();
                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.pp(true);
                break;
        }
    };
    AnnotationLayer.prototype.v1 = function (a) {
        var e_1, _a;
        try {
            for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (!(b == this)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.vz));
                }
            }
        }
        catch (e_1_1) {
            e_1 = { error: e_1_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_1)
                    throw e_1.error;
            }
        }
        this.pp(true);
    };
    AnnotationLayer.prototype.v0 = function (a) {
        var e_2, _a;
        try {
            for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.vp));
            }
        }
        catch (e_2_1) {
            e_2 = { error: e_2_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_2)
                    throw e_2.error;
            }
        }
        this.pp(true);
    };
    AnnotationLayer.prototype.vw = function (a) {
        var e_3, _a;
        try {
            for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (!(b == this)) {
                    b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.vz));
                }
            }
        }
        catch (e_3_1) {
            e_3 = { error: e_3_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_3)
                    throw e_3.error;
            }
        }
        this.pp(true);
    };
    AnnotationLayer.prototype.vv = function (a) {
        var e_4, _a;
        try {
            for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.vp));
            }
        }
        catch (e_4_1) {
            e_4 = { error: e_4_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_4)
                    throw e_4.error;
            }
        }
        this.pp(true);
    };
    AnnotationLayer.prototype.uj = function (a) {
        if (a == null) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.vp = function (a, b) {
        if (this.uj(a)) {
            this.vr(a, b.animate);
        }
    };
    AnnotationLayer.prototype.uk = function (a) {
        if (a == null) {
            return false;
        }
        if (a.d6) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.vz = function (a, b) {
        if (this.uk(a)) {
            this.vs(a, b.animate);
        }
    };
    AnnotationLayer.prototype.vr = function (a, b) {
    };
    AnnotationLayer.prototype.vs = function (a, b) {
    };
    AnnotationLayer.prototype.vy = function (a, b) {
        this.vt(b);
    };
    AnnotationLayer.prototype.vo = function (a, b) {
        this.vq(b);
    };
    AnnotationLayer.prototype.wn = function () {
        if (this.ss != null) {
            return this.ss;
        }
        return this.sw;
    };
    AnnotationLayer.prototype.wo = function () {
        if (this.sv != null) {
            return this.sv;
        }
        return this.s2;
    };
    AnnotationLayer.prototype.vq = function (a) {
        var e_5, _a, e_6, _b;
        if (a.oldItems != null) {
            try {
                for (var _c = __values(fromEn(a.oldItems)), _d = _c.next(); !_d.done; _d = _c.next()) {
                    var b = _d.value;
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.vp));
                }
            }
            catch (e_5_1) {
                e_5 = { error: e_5_1 };
            }
            finally {
                try {
                    if (_d && !_d.done && (_a = _c.return))
                        _a.call(_c);
                }
                finally {
                    if (e_5)
                        throw e_5.error;
                }
            }
        }
        if (a.newItems != null) {
            try {
                for (var _e = __values(fromEn(a.newItems)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var c = _f.value;
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.vp));
                }
            }
            catch (e_6_1) {
                e_6 = { error: e_6_1 };
            }
            finally {
                try {
                    if (_f && !_f.done && (_b = _e.return))
                        _b.call(_e);
                }
                finally {
                    if (e_6)
                        throw e_6.error;
                }
            }
        }
        this.pp(true);
    };
    AnnotationLayer.prototype.vt = function (a) {
        var e_7, _a, e_8, _b;
        if (a.oldItems != null) {
            try {
                for (var _c = __values(fromEn(a.oldItems)), _d = _c.next(); !_d.done; _d = _c.next()) {
                    var b = _d.value;
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.vz));
                }
            }
            catch (e_7_1) {
                e_7 = { error: e_7_1 };
            }
            finally {
                try {
                    if (_d && !_d.done && (_a = _c.return))
                        _a.call(_c);
                }
                finally {
                    if (e_7)
                        throw e_7.error;
                }
            }
        }
        if (a.newItems != null) {
            try {
                for (var _e = __values(fromEn(a.newItems)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var c = _f.value;
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.vz));
                }
            }
            catch (e_8_1) {
                e_8 = { error: e_8_1 };
            }
            finally {
                try {
                    if (_f && !_f.done && (_b = _e.return))
                        _b.call(_e);
                }
                finally {
                    if (e_8)
                        throw e_8.error;
                }
            }
        }
        this.pp(true);
    };
    AnnotationLayer.prototype.qn = function (a, b) {
        this.pp(false);
    };
    AnnotationLayer.prototype.qm = function (a, b) {
        this.pp(true);
    };
    AnnotationLayer.prototype.pq = function (a) {
        _super.prototype.pq.call(this, a);
        if (this.dl(this.cj)) {
            return;
        }
        if (this.fp(a) && !this.f0) {
            var b = this.uf;
            if (this.dj()) {
                if (this.cz.g) {
                    this.cz.t();
                }
                this.uf = this.ug;
                this.ug = b;
            }
            else {
                this.uf = this.ue;
                this.ue = b;
            }
            this.vu(this.ue, this.cj);
            this.p3();
        }
        else {
            if (!this.f0) {
                this.vu(this.ue, this.cj);
            }
            this.vx(this.ue, this.cj);
        }
    };
    AnnotationLayer.prototype.get_d6 = function () {
        return true;
    };
    AnnotationLayer.prototype.vu = function (a, b) {
    };
    AnnotationLayer.prototype.vx = function (a, b) {
        this.ow();
        this.ud.b4();
    };
    AnnotationLayer.prototype.vn = function (a) {
        var b = { $type: Point_$type, x: this.wx.x, y: this.wx.y };
        if (a.isVertical) {
            if (isNaN_(this.wx.y)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.wx.x)) {
                b.x = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        else {
            if (isNaN_(this.wx.x)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.wx.y)) {
                b.y = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        return new Tuple$2(Boolean_$type, Point_$type, true, b);
    };
    AnnotationLayer.prototype.oq = function (a) {
        _super.prototype.oq.call(this, a);
        if (isNaN_(this.wz.x) && isNaN_(this.wz.y)) {
            if (isNaN_(a.x) && isNaN_(a.y)) {
                this.ud.b3();
                return;
            }
            else {
                this.ud.b5();
                this.wx = a;
            }
        }
        else {
            this.ud.b5();
            this.wx = this.wz;
        }
        this.pp(true);
    };
    AnnotationLayer.prototype.gl = function (a, b, c) {
        var d = _super.prototype.gl.call(this, a, b, c);
        if (this.cy == null) {
            return false;
        }
        if (!this.cj.t()) {
            d = false;
            return d;
        }
        return d;
    };
    AnnotationLayer.prototype.uy = function () {
        if (isNaN_(this.u1)) {
            switch (this.t1) {
                case 1: return this.us();
                case 2: return this.uv();
                case 4: return this.uu();
            }
        }
        return this.u1;
    };
    AnnotationLayer.prototype.ux = function () {
        if (isNaN_(this.u0)) {
            return this.uq;
        }
        return this.u0;
    };
    AnnotationLayer.prototype.uz = function () {
        if (isNaN_(this.u2)) {
            return this.uq;
        }
        return this.u2;
    };
    AnnotationLayer.prototype.t8 = function () {
        switch (this.t4) {
            case 0: return this.t5();
        }
        return this.t4;
    };
    AnnotationLayer.prototype.t9 = function () {
        switch (this.ub) {
            case 0: return this.t1;
        }
        return this.ub;
    };
    AnnotationLayer.prototype.ua = function () {
        switch (this.uc) {
            case 0: return this.t1;
        }
        return this.uc;
    };
    AnnotationLayer.prototype.wt = function () {
        if (this.wv == null) {
            if (this.s7 == null) {
                return this.wr();
            }
            return this.s7;
        }
        return this.wv;
    };
    AnnotationLayer.prototype.wu = function () {
        if (this.ww == null) {
            if (this.s7 == null) {
                return this.ws();
            }
            return this.s7;
        }
        return this.ww;
    };
    AnnotationLayer.prototype.t5 = function () {
        return 0;
    };
    AnnotationLayer.prototype.t6 = function () {
        return this.t5();
    };
    AnnotationLayer.prototype.t7 = function () {
        return this.t5();
    };
    AnnotationLayer.prototype.us = function () {
        return NaN;
    };
    AnnotationLayer.prototype.uv = function () {
        return NaN;
    };
    AnnotationLayer.prototype.uu = function () {
        return NaN;
    };
    AnnotationLayer.prototype.ut = function () {
        return NaN;
    };
    AnnotationLayer.prototype.uw = function () {
        return NaN;
    };
    AnnotationLayer.prototype.wr = function () {
        return null;
    };
    AnnotationLayer.prototype.ws = function () {
        return null;
    };
    AnnotationLayer.prototype.v2 = function () {
        this.t1 = this.t8();
        this.uq = this.uy();
        this.t2 = this.t9();
        this.up = this.ux();
        this.t3 = this.ua();
        this.ur = this.uz();
        this.wp = this.wt();
        this.wq = this.wu();
    };
    AnnotationLayer.prototype.get_gh = function () {
        return this.um;
    };
    Object.defineProperty(AnnotationLayer.prototype, "um", {
        get: function () {
            return this.uh;
        },
        set: function (a) {
            var b = this.uh;
            this.uh = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.uh);
        },
        enumerable: false,
        configurable: true
    });
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    AnnotationLayer.$$p = markDep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['ActualAppearanceMode:t1:v3', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalAppearanceMode:t2:v4', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalDashArray:wp:v5', [DoubleCollection.$], 'ActualHorizontalShiftAmount:up:v6', [1, NaN], 'ActualShiftAmount:uq:v7', [1, NaN], 'ActualVerticalAppearanceMode:t3:v8', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualVerticalDashArray:wq:v9', [DoubleCollection.$], 'ActualVerticalShiftAmount:ur:wa', [1, NaN], 'AppearanceMode:t4:wb', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'CursorPosition:wy:wc', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'HorizontalAppearanceMode:ub:wd', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'HorizontalDashArray:wv:we', [DoubleCollection.$], 'HorizontalShiftAmount:u0:wf', [1, NaN], 'IsDefaultCrosshairDisabled:ui:wg', [0, true], 'ShiftAmount:u1:wh', [1, NaN], 'UseIndex:un:wi', [0, false], 'UseLegend:uo:wj', [0, false], 'VerticalAppearanceMode:uc:wk', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'VerticalDashArray:ww:wl', [DoubleCollection.$], 'VerticalShiftAmount:u2:wm', [1, NaN]]);
    return AnnotationLayer;
}(Series));
export { AnnotationLayer };
/**
 * @hidden
 */
var AnnotationLayerView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(AnnotationLayerView, _super);
    function AnnotationLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.b0 = null;
        _this.b1 = false;
        _this.b2 = -1;
        _this.b0 = a;
        return _this;
    }
    AnnotationLayerView.prototype.b6 = function () {
        if (this.b1) {
            this.b1 = false;
            this.b2 = -1;
            this.b0.wx = { $type: Point_$type, x: NaN, y: NaN };
            this.b0.pp(true);
        }
    };
    AnnotationLayerView.prototype.b3 = function () {
        this.b1 = true;
        if (this.e.i4 != null) {
            this.e.i4.setTimeout(runOn(this, this.b6), 300);
        }
        else {
            this.b2 = window.setTimeout(runOn(this, this.b6), 300);
        }
    };
    AnnotationLayerView.prototype.b5 = function () {
        if (this.b1 == true) {
            this.b1 = false;
            if (this.b2 != -1) {
                window.clearTimeout(this.b2);
                this.b2 = -1;
            }
        }
    };
    AnnotationLayerView.prototype.b4 = function () {
        this.as();
    };
    AnnotationLayerView.$t = markType(AnnotationLayerView, 'AnnotationLayerView', SeriesView.$);
    return AnnotationLayerView;
}(SeriesView));
export { AnnotationLayerView };
