/*
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.zu = null;
        _this.xa = null;
        _this.w9 = null;
        _this.xb = null;
        _this.zs = { $type: Point_$type, x: NaN, y: NaN };
        _this.xc = false;
        _this.zu = { $type: Point_$type, x: NaN, y: NaN };
        _this.yx();
        return _this;
    }
    AnnotationLayer.prototype.cs = function () {
        return new AnnotationLayerView(this);
    };
    AnnotationLayer.prototype.qz = function (a) {
        _super.prototype.qz.call(this, a);
        this.w8 = a;
    };
    AnnotationLayer.prototype.xg = function (a) {
        if (a == null) {
            return false;
        }
        if (a.es) {
            return false;
        }
        if (a.isValueOverlay) {
            return false;
        }
        if (a == this) {
            return false;
        }
        return a.he(a.cv.bx, a.cv.by, a.cv);
    };
    AnnotationLayer.prototype.get_e1 = function () {
        return this.xd;
    };
    AnnotationLayer.prototype.b2 = function () {
        if (this.b3 == 0) {
            return 1;
        }
        else {
            return _super.prototype.b2.call(this);
        }
    };
    AnnotationLayer.prototype.get_fg = function () {
        return this.xi || this.xj;
    };
    AnnotationLayer.prototype.get_isUsableInLegend = function () {
        return this.xj;
    };
    AnnotationLayer.prototype.q7 = function (a, b, c, d) {
        _super.prototype.q7.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                var e = c;
                var f = d;
                if (e != null) {
                    this.yw(e.series);
                    var g = e.series;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.yt));
                    if (typeCast(XamDataChart.$, e) !== null) {
                        var h = e;
                        this.yv(h.axes);
                        var i = h.axes;
                        i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.yj));
                    }
                }
                if (f != null) {
                    this.yr(f.series);
                    var j = f.series;
                    j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.yt));
                    if (typeCast(XamDataChart.$, f) !== null) {
                        var k = f;
                        this.yq(k.axes);
                        var l = k.axes;
                        l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.yj));
                    }
                }
                break;
            case AnnotationLayer.$$p[16]:
            case AnnotationLayer.$$p[15]:
                if (this.fg) {
                    if (this.index == -1) {
                        this.index = XamDataChart.yq(this);
                    }
                }
                else {
                    this.index = -1;
                    this.u7 = null;
                    this.vb = null;
                }
                if (this.db != null) {
                    this.db.pe();
                }
                this.rp(true);
                break;
            case "TransitionProgress":
                this.xb.c(this.jq, this.xa, this.w9);
                if (this.d5(this.cv)) {
                    return;
                }
                if (this.jq == 1) {
                    this.ys(this.w9, this.cv);
                    this.qm();
                }
                else {
                    this.ys(this.xb, this.cv);
                }
                if (this.db != null) {
                    this.db.qo(this);
                }
                break;
            case AnnotationLayer.$$p[13]:
                if (this.db != null) {
                    this.db.o8();
                }
                break;
            case AnnotationLayer.$$p[9]:
                this.zu = this.zt;
                this.qp(this.zt);
                break;
            case "ShouldRenderAsOverlay":
                if (this.db != null) {
                    this.cv.al(this.db);
                    this.cv.ag(this.db);
                }
                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.yx();
                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.rp(true);
                break;
        }
    };
    AnnotationLayer.prototype.yw = 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.yu));
                }
            }
        }
        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.rp(true);
    };
    AnnotationLayer.prototype.yv = 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.yk));
            }
        }
        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.rp(true);
    };
    AnnotationLayer.prototype.yr = 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.yu));
                }
            }
        }
        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.rp(true);
    };
    AnnotationLayer.prototype.yq = 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.yk));
            }
        }
        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.rp(true);
    };
    AnnotationLayer.prototype.xe = function (a) {
        if (a == null) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.yk = function (a, b) {
        if (this.xe(a)) {
            this.ym(a, b.animate);
        }
    };
    AnnotationLayer.prototype.xf = function (a) {
        if (a == null) {
            return false;
        }
        if (a.es) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.yu = function (a, b) {
        if (this.xf(a)) {
            this.yn(a, b.animate);
        }
    };
    AnnotationLayer.prototype.ym = function (a, b) {
    };
    AnnotationLayer.prototype.yn = function (a, b) {
    };
    AnnotationLayer.prototype.yt = function (a, b) {
        this.yo(b);
    };
    AnnotationLayer.prototype.yj = function (a, b) {
        this.yl(b);
    };
    AnnotationLayer.prototype.zi = function () {
        if (this.u7 != null) {
            return this.u7;
        }
        return this.vd;
    };
    AnnotationLayer.prototype.zj = function () {
        if (this.vb != null) {
            return this.vb;
        }
        return this.vt;
    };
    AnnotationLayer.prototype.yl = 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.yk));
                }
            }
            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.yk));
                }
            }
            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.rp(true);
    };
    AnnotationLayer.prototype.yo = 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.yu));
                }
            }
            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.yu));
                }
            }
            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.rp(true);
    };
    AnnotationLayer.prototype.sp = function (a, b) {
        this.rp(false);
    };
    AnnotationLayer.prototype.so = function (a, b) {
        this.rp(true);
    };
    AnnotationLayer.prototype.rq = function (a) {
        _super.prototype.rq.call(this, a);
        if (this.d5(this.cv)) {
            return;
        }
        if (this.gf(a) && !this.gr) {
            var b = this.xa;
            if (this.d3()) {
                if (this.dc.g) {
                    this.dc.t();
                }
                this.xa = this.xb;
                this.xb = b;
            }
            else {
                this.xa = this.w9;
                this.w9 = b;
            }
            this.yp(this.w9, this.cv);
            this.r5();
        }
        else {
            if (!this.gr) {
                this.yp(this.w9, this.cv);
            }
            this.ys(this.w9, this.cv);
        }
    };
    AnnotationLayer.prototype.get_es = function () {
        return true;
    };
    AnnotationLayer.prototype.yp = function (a, b) {
    };
    AnnotationLayer.prototype.ys = function (a, b) {
        this.qv();
        this.w8.b4();
    };
    AnnotationLayer.prototype.yi = function (a) {
        var b = { $type: Point_$type, x: this.zs.x, y: this.zs.y };
        if (a.isVertical) {
            if (isNaN_(this.zs.y)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.zs.x)) {
                b.x = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        else {
            if (isNaN_(this.zs.x)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.zs.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.qp = function (a) {
        _super.prototype.qp.call(this, a);
        if (isNaN_(this.zu.x) && isNaN_(this.zu.y)) {
            if (isNaN_(a.x) && isNaN_(a.y)) {
                this.w8.b3();
                return;
            }
            else {
                this.w8.b5();
                this.zs = a;
            }
        }
        else {
            this.w8.b5();
            this.zs = this.zu;
        }
        this.rp(true);
    };
    AnnotationLayer.prototype.he = function (a, b, c) {
        var d = _super.prototype.he.call(this, a, b, c);
        if (this.db == null) {
            return false;
        }
        if (!this.cv.t()) {
            d = false;
            return d;
        }
        return d;
    };
    AnnotationLayer.prototype.xt = function () {
        if (isNaN_(this.xw)) {
            switch (this.ww) {
                case 1: return this.xn();
                case 2: return this.xq();
                case 4: return this.xp();
            }
        }
        return this.xw;
    };
    AnnotationLayer.prototype.xs = function () {
        if (isNaN_(this.xv)) {
            return this.xl;
        }
        return this.xv;
    };
    AnnotationLayer.prototype.xu = function () {
        if (isNaN_(this.xx)) {
            return this.xl;
        }
        return this.xx;
    };
    AnnotationLayer.prototype.w3 = function () {
        switch (this.wz) {
            case 0: return this.w0();
        }
        return this.wz;
    };
    AnnotationLayer.prototype.w4 = function () {
        switch (this.w6) {
            case 0: return this.ww;
        }
        return this.w6;
    };
    AnnotationLayer.prototype.w5 = function () {
        switch (this.w7) {
            case 0: return this.ww;
        }
        return this.w7;
    };
    AnnotationLayer.prototype.zo = function () {
        if (this.zq == null) {
            if (this.v0 == null) {
                return this.zm();
            }
            return this.v0;
        }
        return this.zq;
    };
    AnnotationLayer.prototype.zp = function () {
        if (this.zr == null) {
            if (this.v0 == null) {
                return this.zn();
            }
            return this.v0;
        }
        return this.zr;
    };
    AnnotationLayer.prototype.w0 = function () {
        return 0;
    };
    AnnotationLayer.prototype.w1 = function () {
        return this.w0();
    };
    AnnotationLayer.prototype.w2 = function () {
        return this.w0();
    };
    AnnotationLayer.prototype.xn = function () {
        return NaN;
    };
    AnnotationLayer.prototype.xq = function () {
        return NaN;
    };
    AnnotationLayer.prototype.xp = function () {
        return NaN;
    };
    AnnotationLayer.prototype.xo = function () {
        return NaN;
    };
    AnnotationLayer.prototype.xr = function () {
        return NaN;
    };
    AnnotationLayer.prototype.zm = function () {
        return null;
    };
    AnnotationLayer.prototype.zn = function () {
        return null;
    };
    AnnotationLayer.prototype.yx = function () {
        this.ww = this.w3();
        this.xl = this.xt();
        this.wx = this.w4();
        this.xk = this.xs();
        this.wy = this.w5();
        this.xm = this.xu();
        this.zk = this.zo();
        this.zl = this.zp();
    };
    AnnotationLayer.prototype.get_ha = function () {
        return this.xh;
    };
    Object.defineProperty(AnnotationLayer.prototype, "xh", {
        get: function () {
            return this.xc;
        },
        set: function (a) {
            var b = this.xc;
            this.xc = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.xc);
        },
        enumerable: false,
        configurable: true
    });
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    AnnotationLayer.$$p = markDep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['ActualAppearanceMode:ww:yy', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalAppearanceMode:wx:yz', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalDashArray:zk:y0', [DoubleCollection.$], 'ActualHorizontalShiftAmount:xk:y1', [1, NaN], 'ActualShiftAmount:xl:y2', [1, NaN], 'ActualVerticalAppearanceMode:wy:y3', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualVerticalDashArray:zl:y4', [DoubleCollection.$], 'ActualVerticalShiftAmount:xm:y5', [1, NaN], 'AppearanceMode:wz:y6', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'CursorPosition:zt:y7', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'HorizontalAppearanceMode:w6:y8', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'HorizontalDashArray:zq:y9', [DoubleCollection.$], 'HorizontalShiftAmount:xv:za', [1, NaN], 'IsDefaultCrosshairDisabled:xd:zb', [0, true], 'ShiftAmount:xw:zc', [1, NaN], 'UseIndex:xi:zd', [0, false], 'UseLegend:xj:ze', [0, false], 'VerticalAppearanceMode:w7:zf', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'VerticalDashArray:zr:zg', [DoubleCollection.$], 'VerticalShiftAmount:xx:zh', [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.zs = { $type: Point_$type, x: NaN, y: NaN };
            this.b0.rp(true);
        }
    };
    AnnotationLayerView.prototype.b3 = function () {
        this.b1 = true;
        if (this.e.jz != null) {
            this.e.jz.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 };
