/*
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.w1 = null;
        _this.uh = null;
        _this.ug = null;
        _this.ui = null;
        _this.wz = { $type: Point_$type, x: NaN, y: NaN };
        _this.uj = false;
        _this.w1 = { $type: Point_$type, x: NaN, y: NaN };
        _this.v4();
        return _this;
    }
    AnnotationLayer.prototype.cd = function () {
        return new AnnotationLayerView(this);
    };
    AnnotationLayer.prototype.o2 = function (a) {
        _super.prototype.o2.call(this, a);
        this.uf = a;
    };
    AnnotationLayer.prototype.un = function (a) {
        if (a == null) {
            return false;
        }
        if (a.d7) {
            return false;
        }
        if (a.isValueOverlay) {
            return false;
        }
        if (a == this) {
            return false;
        }
        return a.gm(a.cg.bx, a.cg.by, a.cg);
    };
    AnnotationLayer.prototype.get_eg = function () {
        return this.uk;
    };
    AnnotationLayer.prototype.bu = function () {
        if (this.bv == 0) {
            return 1;
        }
        else {
            return _super.prototype.bu.call(this);
        }
    };
    AnnotationLayer.prototype.get_eu = function () {
        return this.up || this.uq;
    };
    AnnotationLayer.prototype.get_isUsableInLegend = function () {
        return this.uq;
    };
    AnnotationLayer.prototype.pa = function (a, b, c, d) {
        _super.prototype.pa.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                var e = c;
                var f = d;
                if (e != null) {
                    this.v3(e.series);
                    var g = e.series;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.v0));
                    if (typeCast(XamDataChart.$, e) !== null) {
                        var h = e;
                        this.v2(h.axes);
                        var i = h.axes;
                        i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.vq));
                    }
                }
                if (f != null) {
                    this.vy(f.series);
                    var j = f.series;
                    j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.v0));
                    if (typeCast(XamDataChart.$, f) !== null) {
                        var k = f;
                        this.vx(k.axes);
                        var l = k.axes;
                        l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.vq));
                    }
                }
                break;
            case AnnotationLayer.$$p[16]:
            case AnnotationLayer.$$p[15]:
                if (this.eu) {
                    if (this.index == -1) {
                        this.index = XamDataChart.wd(this);
                    }
                }
                else {
                    this.index = -1;
                    this.su = null;
                    this.sx = null;
                }
                if (this.cv != null) {
                    this.cv.nk();
                }
                this.pr(true);
                break;
            case "TransitionProgress":
                this.ui.c(this.iw, this.uh, this.ug);
                if (this.dm(this.cg)) {
                    return;
                }
                if (this.iw == 1) {
                    this.vz(this.ug, this.cg);
                    this.op();
                }
                else {
                    this.vz(this.ui, this.cg);
                }
                if (this.cv != null) {
                    this.cv.or(this);
                }
                break;
            case AnnotationLayer.$$p[13]:
                if (this.cv != null) {
                    this.cv.ni();
                }
                break;
            case AnnotationLayer.$$p[9]:
                this.w1 = this.w0;
                this.os(this.w0);
                break;
            case "ShouldRenderAsOverlay":
                if (this.cv != null) {
                    this.cg.al(this.cv);
                    this.cg.ag(this.cv);
                }
                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.v4();
                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.pr(true);
                break;
        }
    };
    AnnotationLayer.prototype.v3 = 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.v1));
                }
            }
        }
        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.pr(true);
    };
    AnnotationLayer.prototype.v2 = 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.vr));
            }
        }
        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.pr(true);
    };
    AnnotationLayer.prototype.vy = 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.v1));
                }
            }
        }
        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.pr(true);
    };
    AnnotationLayer.prototype.vx = 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.vr));
            }
        }
        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.pr(true);
    };
    AnnotationLayer.prototype.ul = function (a) {
        if (a == null) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.vr = function (a, b) {
        if (this.ul(a)) {
            this.vt(a, b.animate);
        }
    };
    AnnotationLayer.prototype.um = function (a) {
        if (a == null) {
            return false;
        }
        if (a.d7) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.v1 = function (a, b) {
        if (this.um(a)) {
            this.vu(a, b.animate);
        }
    };
    AnnotationLayer.prototype.vt = function (a, b) {
    };
    AnnotationLayer.prototype.vu = function (a, b) {
    };
    AnnotationLayer.prototype.v0 = function (a, b) {
        this.vv(b);
    };
    AnnotationLayer.prototype.vq = function (a, b) {
        this.vs(b);
    };
    AnnotationLayer.prototype.wp = function () {
        if (this.su != null) {
            return this.su;
        }
        return this.sy;
    };
    AnnotationLayer.prototype.wq = function () {
        if (this.sx != null) {
            return this.sx;
        }
        return this.s4;
    };
    AnnotationLayer.prototype.vs = 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.vr));
                }
            }
            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.vr));
                }
            }
            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.pr(true);
    };
    AnnotationLayer.prototype.vv = 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.v1));
                }
            }
            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.v1));
                }
            }
            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.pr(true);
    };
    AnnotationLayer.prototype.qp = function (a, b) {
        this.pr(false);
    };
    AnnotationLayer.prototype.qo = function (a, b) {
        this.pr(true);
    };
    AnnotationLayer.prototype.ps = function (a) {
        _super.prototype.ps.call(this, a);
        if (this.dm(this.cg)) {
            return;
        }
        if (this.fq(a) && !this.f1) {
            var b = this.uh;
            if (this.dk()) {
                if (this.cw.g) {
                    this.cw.t();
                }
                this.uh = this.ui;
                this.ui = b;
            }
            else {
                this.uh = this.ug;
                this.ug = b;
            }
            this.vw(this.ug, this.cg);
            this.p5();
        }
        else {
            if (!this.f1) {
                this.vw(this.ug, this.cg);
            }
            this.vz(this.ug, this.cg);
        }
    };
    AnnotationLayer.prototype.get_d7 = function () {
        return true;
    };
    AnnotationLayer.prototype.vw = function (a, b) {
    };
    AnnotationLayer.prototype.vz = function (a, b) {
        this.oy();
        this.uf.b4();
    };
    AnnotationLayer.prototype.vp = function (a) {
        var b = { $type: Point_$type, x: this.wz.x, y: this.wz.y };
        if (a.isVertical) {
            if (isNaN_(this.wz.y)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.wz.x)) {
                b.x = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        else {
            if (isNaN_(this.wz.x)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.wz.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.os = function (a) {
        _super.prototype.os.call(this, a);
        if (isNaN_(this.w1.x) && isNaN_(this.w1.y)) {
            if (isNaN_(a.x) && isNaN_(a.y)) {
                this.uf.b3();
                return;
            }
            else {
                this.uf.b5();
                this.wz = a;
            }
        }
        else {
            this.uf.b5();
            this.wz = this.w1;
        }
        this.pr(true);
    };
    AnnotationLayer.prototype.gm = function (a, b, c) {
        var d = _super.prototype.gm.call(this, a, b, c);
        if (this.cv == null) {
            return false;
        }
        if (!this.cg.t()) {
            d = false;
            return d;
        }
        return d;
    };
    AnnotationLayer.prototype.u0 = function () {
        if (isNaN_(this.u3)) {
            switch (this.t3) {
                case 1: return this.uu();
                case 2: return this.ux();
                case 4: return this.uw();
            }
        }
        return this.u3;
    };
    AnnotationLayer.prototype.uz = function () {
        if (isNaN_(this.u2)) {
            return this.us;
        }
        return this.u2;
    };
    AnnotationLayer.prototype.u1 = function () {
        if (isNaN_(this.u4)) {
            return this.us;
        }
        return this.u4;
    };
    AnnotationLayer.prototype.ua = function () {
        switch (this.t6) {
            case 0: return this.t7();
        }
        return this.t6;
    };
    AnnotationLayer.prototype.ub = function () {
        switch (this.ud) {
            case 0: return this.t3;
        }
        return this.ud;
    };
    AnnotationLayer.prototype.uc = function () {
        switch (this.ue) {
            case 0: return this.t3;
        }
        return this.ue;
    };
    AnnotationLayer.prototype.wv = function () {
        if (this.wx == null) {
            if (this.s9 == null) {
                return this.wt();
            }
            return this.s9;
        }
        return this.wx;
    };
    AnnotationLayer.prototype.ww = function () {
        if (this.wy == null) {
            if (this.s9 == null) {
                return this.wu();
            }
            return this.s9;
        }
        return this.wy;
    };
    AnnotationLayer.prototype.t7 = function () {
        return 0;
    };
    AnnotationLayer.prototype.t8 = function () {
        return this.t7();
    };
    AnnotationLayer.prototype.t9 = function () {
        return this.t7();
    };
    AnnotationLayer.prototype.uu = function () {
        return NaN;
    };
    AnnotationLayer.prototype.ux = function () {
        return NaN;
    };
    AnnotationLayer.prototype.uw = function () {
        return NaN;
    };
    AnnotationLayer.prototype.uv = function () {
        return NaN;
    };
    AnnotationLayer.prototype.uy = function () {
        return NaN;
    };
    AnnotationLayer.prototype.wt = function () {
        return null;
    };
    AnnotationLayer.prototype.wu = function () {
        return null;
    };
    AnnotationLayer.prototype.v4 = function () {
        this.t3 = this.ua();
        this.us = this.u0();
        this.t4 = this.ub();
        this.ur = this.uz();
        this.t5 = this.uc();
        this.ut = this.u1();
        this.wr = this.wv();
        this.ws = this.ww();
    };
    AnnotationLayer.prototype.get_gi = function () {
        return this.uo;
    };
    Object.defineProperty(AnnotationLayer.prototype, "uo", {
        get: function () {
            return this.uj;
        },
        set: function (a) {
            var b = this.uj;
            this.uj = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.uj);
        },
        enumerable: false,
        configurable: true
    });
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    AnnotationLayer.$$p = markDep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['ActualAppearanceMode:t3:v5', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalAppearanceMode:t4:v6', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalDashArray:wr:v7', [DoubleCollection.$], 'ActualHorizontalShiftAmount:ur:v8', [1, NaN], 'ActualShiftAmount:us:v9', [1, NaN], 'ActualVerticalAppearanceMode:t5:wa', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualVerticalDashArray:ws:wb', [DoubleCollection.$], 'ActualVerticalShiftAmount:ut:wc', [1, NaN], 'AppearanceMode:t6:wd', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'CursorPosition:w0:we', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'HorizontalAppearanceMode:ud:wf', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'HorizontalDashArray:wx:wg', [DoubleCollection.$], 'HorizontalShiftAmount:u2:wh', [1, NaN], 'IsDefaultCrosshairDisabled:uk:wi', [0, true], 'ShiftAmount:u3:wj', [1, NaN], 'UseIndex:up:wk', [0, false], 'UseLegend:uq:wl', [0, false], 'VerticalAppearanceMode:ue:wm', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'VerticalDashArray:wy:wn', [DoubleCollection.$], 'VerticalShiftAmount:u4:wo', [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.wz = { $type: Point_$type, x: NaN, y: NaN };
            this.b0.pr(true);
        }
    };
    AnnotationLayerView.prototype.b3 = function () {
        this.b1 = true;
        if (this.e.i5 != null) {
            this.e.i5.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 };
