/*
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.zn = null;
        _this.w3 = null;
        _this.w2 = null;
        _this.w4 = null;
        _this.zl = { $type: Point_$type, x: NaN, y: NaN };
        _this.w5 = false;
        _this.zn = { $type: Point_$type, x: NaN, y: NaN };
        _this.yq();
        return _this;
    }
    AnnotationLayer.prototype.cq = function () {
        return new AnnotationLayerView(this);
    };
    AnnotationLayer.prototype.qw = function (a) {
        _super.prototype.qw.call(this, a);
        this.w1 = a;
    };
    AnnotationLayer.prototype.w9 = function (a) {
        if (a == null) {
            return false;
        }
        if (a.eq) {
            return false;
        }
        if (a.isValueOverlay) {
            return false;
        }
        if (a == this) {
            return false;
        }
        return a.hc(a.ct.bx, a.ct.by, a.ct);
    };
    AnnotationLayer.prototype.get_ez = function () {
        return this.w6;
    };
    AnnotationLayer.prototype.b0 = function () {
        if (this.b1 == 0) {
            return 1;
        }
        else {
            return _super.prototype.b0.call(this);
        }
    };
    AnnotationLayer.prototype.get_fe = function () {
        return this.xb || this.xc;
    };
    AnnotationLayer.prototype.get_isUsableInLegend = function () {
        return this.xc;
    };
    AnnotationLayer.prototype.q4 = function (a, b, c, d) {
        _super.prototype.q4.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                var e = c;
                var f = d;
                if (e != null) {
                    this.yp(e.series);
                    var g = e.series;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.ym));
                    if (typeCast(XamDataChart.$, e) !== null) {
                        var h = e;
                        this.yo(h.axes);
                        var i = h.axes;
                        i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.yc));
                    }
                }
                if (f != null) {
                    this.yk(f.series);
                    var j = f.series;
                    j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.ym));
                    if (typeCast(XamDataChart.$, f) !== null) {
                        var k = f;
                        this.yj(k.axes);
                        var l = k.axes;
                        l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.yc));
                    }
                }
                break;
            case AnnotationLayer.$$p[16]:
            case AnnotationLayer.$$p[15]:
                if (this.fe) {
                    if (this.index == -1) {
                        this.index = XamDataChart.x7(this);
                    }
                }
                else {
                    this.index = -1;
                    this.u2 = null;
                    this.u6 = null;
                }
                if (this.c9 != null) {
                    this.c9.o0();
                }
                this.rm(true);
                break;
            case "TransitionProgress":
                this.w4.c(this.jo, this.w3, this.w2);
                if (this.d3(this.ct)) {
                    return;
                }
                if (this.jo == 1) {
                    this.yl(this.w2, this.ct);
                    this.qj();
                }
                else {
                    this.yl(this.w4, this.ct);
                }
                if (this.c9 != null) {
                    this.c9.qa(this);
                }
                break;
            case AnnotationLayer.$$p[13]:
                if (this.c9 != null) {
                    this.c9.ou();
                }
                break;
            case AnnotationLayer.$$p[9]:
                this.zn = this.zm;
                this.qm(this.zm);
                break;
            case "ShouldRenderAsOverlay":
                if (this.c9 != null) {
                    this.ct.al(this.c9);
                    this.ct.ag(this.c9);
                }
                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.yq();
                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.rm(true);
                break;
        }
    };
    AnnotationLayer.prototype.yp = 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.yn));
                }
            }
        }
        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.rm(true);
    };
    AnnotationLayer.prototype.yo = 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.yd));
            }
        }
        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.rm(true);
    };
    AnnotationLayer.prototype.yk = 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.yn));
                }
            }
        }
        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.rm(true);
    };
    AnnotationLayer.prototype.yj = 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.yd));
            }
        }
        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.rm(true);
    };
    AnnotationLayer.prototype.w7 = function (a) {
        if (a == null) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.yd = function (a, b) {
        if (this.w7(a)) {
            this.yf(a, b.animate);
        }
    };
    AnnotationLayer.prototype.w8 = function (a) {
        if (a == null) {
            return false;
        }
        if (a.eq) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.yn = function (a, b) {
        if (this.w8(a)) {
            this.yg(a, b.animate);
        }
    };
    AnnotationLayer.prototype.yf = function (a, b) {
    };
    AnnotationLayer.prototype.yg = function (a, b) {
    };
    AnnotationLayer.prototype.ym = function (a, b) {
        this.yh(b);
    };
    AnnotationLayer.prototype.yc = function (a, b) {
        this.ye(b);
    };
    AnnotationLayer.prototype.zb = function () {
        if (this.u2 != null) {
            return this.u2;
        }
        return this.u8;
    };
    AnnotationLayer.prototype.zc = function () {
        if (this.u6 != null) {
            return this.u6;
        }
        return this.vo;
    };
    AnnotationLayer.prototype.ye = 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.yd));
                }
            }
            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.yd));
                }
            }
            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.rm(true);
    };
    AnnotationLayer.prototype.yh = 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.yn));
                }
            }
            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.yn));
                }
            }
            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.rm(true);
    };
    AnnotationLayer.prototype.sk = function (a, b) {
        this.rm(false);
    };
    AnnotationLayer.prototype.sj = function (a, b) {
        this.rm(true);
    };
    AnnotationLayer.prototype.rn = function (a) {
        _super.prototype.rn.call(this, a);
        if (this.d3(this.ct)) {
            return;
        }
        if (this.gd(a) && !this.gp) {
            var b = this.w3;
            if (this.d1()) {
                if (this.da.g) {
                    this.da.t();
                }
                this.w3 = this.w4;
                this.w4 = b;
            }
            else {
                this.w3 = this.w2;
                this.w2 = b;
            }
            this.yi(this.w2, this.ct);
            this.r0();
        }
        else {
            if (!this.gp) {
                this.yi(this.w2, this.ct);
            }
            this.yl(this.w2, this.ct);
        }
    };
    AnnotationLayer.prototype.get_eq = function () {
        return true;
    };
    AnnotationLayer.prototype.yi = function (a, b) {
    };
    AnnotationLayer.prototype.yl = function (a, b) {
        this.qs();
        this.w1.b4();
    };
    AnnotationLayer.prototype.yb = function (a) {
        var b = { $type: Point_$type, x: this.zl.x, y: this.zl.y };
        if (a.isVertical) {
            if (isNaN_(this.zl.y)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.zl.x)) {
                b.x = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        else {
            if (isNaN_(this.zl.x)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.zl.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.qm = function (a) {
        _super.prototype.qm.call(this, a);
        if (isNaN_(this.zn.x) && isNaN_(this.zn.y)) {
            if (isNaN_(a.x) && isNaN_(a.y)) {
                this.w1.b3();
                return;
            }
            else {
                this.w1.b5();
                this.zl = a;
            }
        }
        else {
            this.w1.b5();
            this.zl = this.zn;
        }
        this.rm(true);
    };
    AnnotationLayer.prototype.hc = function (a, b, c) {
        var d = _super.prototype.hc.call(this, a, b, c);
        if (this.c9 == null) {
            return false;
        }
        if (!this.ct.t()) {
            d = false;
            return d;
        }
        return d;
    };
    AnnotationLayer.prototype.xm = function () {
        if (isNaN_(this.xp)) {
            switch (this.wp) {
                case 1: return this.xg();
                case 2: return this.xj();
                case 4: return this.xi();
            }
        }
        return this.xp;
    };
    AnnotationLayer.prototype.xl = function () {
        if (isNaN_(this.xo)) {
            return this.xe;
        }
        return this.xo;
    };
    AnnotationLayer.prototype.xn = function () {
        if (isNaN_(this.xq)) {
            return this.xe;
        }
        return this.xq;
    };
    AnnotationLayer.prototype.ww = function () {
        switch (this.ws) {
            case 0: return this.wt();
        }
        return this.ws;
    };
    AnnotationLayer.prototype.wx = function () {
        switch (this.wz) {
            case 0: return this.wp;
        }
        return this.wz;
    };
    AnnotationLayer.prototype.wy = function () {
        switch (this.w0) {
            case 0: return this.wp;
        }
        return this.w0;
    };
    AnnotationLayer.prototype.zh = function () {
        if (this.zj == null) {
            if (this.vv == null) {
                return this.zf();
            }
            return this.vv;
        }
        return this.zj;
    };
    AnnotationLayer.prototype.zi = function () {
        if (this.zk == null) {
            if (this.vv == null) {
                return this.zg();
            }
            return this.vv;
        }
        return this.zk;
    };
    AnnotationLayer.prototype.wt = function () {
        return 0;
    };
    AnnotationLayer.prototype.wu = function () {
        return this.wt();
    };
    AnnotationLayer.prototype.wv = function () {
        return this.wt();
    };
    AnnotationLayer.prototype.xg = function () {
        return NaN;
    };
    AnnotationLayer.prototype.xj = function () {
        return NaN;
    };
    AnnotationLayer.prototype.xi = function () {
        return NaN;
    };
    AnnotationLayer.prototype.xh = function () {
        return NaN;
    };
    AnnotationLayer.prototype.xk = function () {
        return NaN;
    };
    AnnotationLayer.prototype.zf = function () {
        return null;
    };
    AnnotationLayer.prototype.zg = function () {
        return null;
    };
    AnnotationLayer.prototype.yq = function () {
        this.wp = this.ww();
        this.xe = this.xm();
        this.wq = this.wx();
        this.xd = this.xl();
        this.wr = this.wy();
        this.xf = this.xn();
        this.zd = this.zh();
        this.ze = this.zi();
    };
    AnnotationLayer.prototype.get_g8 = function () {
        return this.xa;
    };
    Object.defineProperty(AnnotationLayer.prototype, "xa", {
        get: function () {
            return this.w5;
        },
        set: function (a) {
            var b = this.w5;
            this.w5 = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.w5);
        },
        enumerable: false,
        configurable: true
    });
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    AnnotationLayer.$$p = markDep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['ActualAppearanceMode:wp:yr', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalAppearanceMode:wq:ys', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalDashArray:zd:yt', [DoubleCollection.$], 'ActualHorizontalShiftAmount:xd:yu', [1, NaN], 'ActualShiftAmount:xe:yv', [1, NaN], 'ActualVerticalAppearanceMode:wr:yw', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualVerticalDashArray:ze:yx', [DoubleCollection.$], 'ActualVerticalShiftAmount:xf:yy', [1, NaN], 'AppearanceMode:ws:yz', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'CursorPosition:zm:y0', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'HorizontalAppearanceMode:wz:y1', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'HorizontalDashArray:zj:y2', [DoubleCollection.$], 'HorizontalShiftAmount:xo:y3', [1, NaN], 'IsDefaultCrosshairDisabled:w6:y4', [0, true], 'ShiftAmount:xp:y5', [1, NaN], 'UseIndex:xb:y6', [0, false], 'UseLegend:xc:y7', [0, false], 'VerticalAppearanceMode:w0:y8', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'VerticalDashArray:zk:y9', [DoubleCollection.$], 'VerticalShiftAmount:xq:za', [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.zl = { $type: Point_$type, x: NaN, y: NaN };
            this.b0.rm(true);
        }
    };
    AnnotationLayerView.prototype.b3 = function () {
        this.b1 = true;
        if (this.e.jx != null) {
            this.e.jx.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 };
