/*
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 * as tslib_1 from "tslib";
import { Series } from "./Series";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { Type, Point_$type, Boolean_$type, runOn, delegateRemove, typeCast, delegateCombine, fromEnum, fromEn, markType } from "igniteui-react-core/ES5/type";
import { SeriesView } from "./SeriesView";
import { XamDataChart } from "./XamDataChart";
import { Tuple$2 } from "igniteui-react-core/ES5/Tuple$2";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
import { isNaN_ } from "igniteui-react-core/ES5/number";
var AnnotationLayer = /** @class */ (function (_super) {
    tslib_1.__extends(AnnotationLayer, _super);
    function AnnotationLayer() {
        var _this = _super.call(this) || this;
        _this.mp = null;
        _this.lq = null;
        _this.lp = null;
        _this.lr = null;
        _this.mn = { $type: Point_$type, x: NaN, y: NaN };
        _this.ls = false;
        _this.mp = { $type: Point_$type, x: NaN, y: NaN };
        return _this;
    }
    AnnotationLayer.prototype.bf = function () {
        return new AnnotationLayerView(this);
    };
    AnnotationLayer.prototype.ii = function (a) {
        _super.prototype.ii.call(this, a);
        this.lo = a;
    };
    AnnotationLayer.prototype.lu = function (a) {
        if (a == null) {
            return false;
        }
        if (a.ci) {
            return false;
        }
        if (a == this) {
            return false;
        }
        return a.dt(a.bi.bp, a.bi.bq, a.bi);
    };
    AnnotationLayer.prototype.get_cl = function () {
        return this.lt;
    };
    Object.defineProperty(AnnotationLayer.prototype, "cl", {
        get: function () {
            return this.get_cl();
        },
        enumerable: true,
        configurable: true
    });
    AnnotationLayer.prototype.bd = function () {
        if (this.be == 0) {
            return 1;
        }
        else {
            return _super.prototype.bd.call(this);
        }
    };
    AnnotationLayer.prototype.get_cv = function () {
        return this.lw || this.lx;
    };
    Object.defineProperty(AnnotationLayer.prototype, "cv", {
        get: function () {
            return this.get_cv();
        },
        enumerable: true,
        configurable: true
    });
    AnnotationLayer.prototype.get_isUsableInLegend = function () {
        return this.lx;
    };
    Object.defineProperty(AnnotationLayer.prototype, "isUsableInLegend", {
        get: function () {
            return this.get_isUsableInLegend();
        },
        enumerable: true,
        configurable: true
    });
    AnnotationLayer.prototype.io = function (a, b, c, d) {
        _super.prototype.io.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                var e = c;
                var f = d;
                if (e != null) {
                    this.mg(e.series);
                    var g = e.series;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.md));
                    if (typeCast(XamDataChart.$, e) !== null) {
                        var h = e;
                        this.mf(h.axes);
                        var i = h.axes;
                        i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.l3));
                    }
                }
                if (f != null) {
                    this.mb(f.series);
                    var j = f.series;
                    j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.md));
                    if (typeCast(XamDataChart.$, f) !== null) {
                        var k = f;
                        this.ma(k.axes);
                        var l = k.axes;
                        l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.l3));
                    }
                }
                break;
            case AnnotationLayer.$$p[3]:
            case AnnotationLayer.$$p[2]:
                if (this.cv) {
                    if (this.fb == -1) {
                        this.fb = XamDataChart.n7(this);
                    }
                }
                else {
                    this.fb = -1;
                    this.kr = null;
                    this.ks = null;
                }
                if (this.bs != null) {
                    this.bs.id();
                }
                this.i1(true);
                break;
            case "TransitionProgress":
                this.lr.c(this.et, this.lq, this.lp);
                if (this.cc(this.bi)) {
                    return;
                }
                if (this.et == 1) {
                    this.mc(this.lp, this.bi);
                }
                else {
                    this.mc(this.lr, this.bi);
                }
                break;
            case AnnotationLayer.$$p[1]:
                if (this.bs != null) {
                    this.bs.ib();
                }
                break;
            case AnnotationLayer.$$p[0]:
                this.mp = this.mo;
                this.ic(this.mo);
                break;
            case "ShouldRenderAsOverlay":
                if (this.bs != null) {
                    this.bi.ah(this.bs);
                    this.bi.ad(this.bs);
                }
                break;
        }
    };
    AnnotationLayer.prototype.mg = function (a) {
        try {
            for (var _a = tslib_1.__values(fromEnum(a)), _b = _a.next(); !_b.done; _b = _a.next()) {
                var b = _b.value;
                if (!(b == this)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.me));
                }
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
            }
            finally { if (e_1) throw e_1.error; }
        }
        this.i1(true);
        var e_1, _c;
    };
    AnnotationLayer.prototype.mf = function (a) {
        try {
            for (var _a = tslib_1.__values(fromEnum(a)), _b = _a.next(); !_b.done; _b = _a.next()) {
                var b = _b.value;
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.l4));
            }
        }
        catch (e_2_1) { e_2 = { error: e_2_1 }; }
        finally {
            try {
                if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
            }
            finally { if (e_2) throw e_2.error; }
        }
        this.i1(true);
        var e_2, _c;
    };
    AnnotationLayer.prototype.mb = function (a) {
        try {
            for (var _a = tslib_1.__values(fromEnum(a)), _b = _a.next(); !_b.done; _b = _a.next()) {
                var b = _b.value;
                if (!(b == this)) {
                    b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.me));
                }
            }
        }
        catch (e_3_1) { e_3 = { error: e_3_1 }; }
        finally {
            try {
                if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
            }
            finally { if (e_3) throw e_3.error; }
        }
        this.i1(true);
        var e_3, _c;
    };
    AnnotationLayer.prototype.ma = function (a) {
        try {
            for (var _a = tslib_1.__values(fromEnum(a)), _b = _a.next(); !_b.done; _b = _a.next()) {
                var b = _b.value;
                b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.l4));
            }
        }
        catch (e_4_1) { e_4 = { error: e_4_1 }; }
        finally {
            try {
                if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
            }
            finally { if (e_4) throw e_4.error; }
        }
        this.i1(true);
        var e_4, _c;
    };
    AnnotationLayer.prototype.l4 = function (a, b) {
        this.l6(a, b.animate);
    };
    AnnotationLayer.prototype.me = function (a, b) {
        this.l7(a, b.animate);
    };
    AnnotationLayer.prototype.l6 = function (a, b) {
    };
    AnnotationLayer.prototype.l7 = function (a, b) {
    };
    AnnotationLayer.prototype.md = function (a, b) {
        this.l8(b);
    };
    AnnotationLayer.prototype.l3 = function (a, b) {
        this.l5(b);
    };
    AnnotationLayer.prototype.ml = function () {
        if (this.kr != null) {
            return this.kr;
        }
        return this.kt;
    };
    AnnotationLayer.prototype.mm = function () {
        if (this.ks != null) {
            return this.ks;
        }
        return this.kw;
    };
    AnnotationLayer.prototype.l5 = function (a) {
        if (a.oldItems != null) {
            try {
                for (var _a = tslib_1.__values(fromEn(a.oldItems)), _b = _a.next(); !_b.done; _b = _a.next()) {
                    var b = _b.value;
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.l4));
                }
            }
            catch (e_5_1) { e_5 = { error: e_5_1 }; }
            finally {
                try {
                    if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
                }
                finally { if (e_5) throw e_5.error; }
            }
        }
        if (a.newItems != null) {
            try {
                for (var _d = tslib_1.__values(fromEn(a.newItems)), _e = _d.next(); !_e.done; _e = _d.next()) {
                    var c = _e.value;
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.l4));
                }
            }
            catch (e_6_1) { e_6 = { error: e_6_1 }; }
            finally {
                try {
                    if (_e && !_e.done && (_f = _d.return)) _f.call(_d);
                }
                finally { if (e_6) throw e_6.error; }
            }
        }
        this.i1(true);
        var e_5, _c, e_6, _f;
    };
    AnnotationLayer.prototype.l8 = function (a) {
        if (a.oldItems != null) {
            try {
                for (var _a = tslib_1.__values(fromEn(a.oldItems)), _b = _a.next(); !_b.done; _b = _a.next()) {
                    var b = _b.value;
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.me));
                }
            }
            catch (e_7_1) { e_7 = { error: e_7_1 }; }
            finally {
                try {
                    if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
                }
                finally { if (e_7) throw e_7.error; }
            }
        }
        if (a.newItems != null) {
            try {
                for (var _d = tslib_1.__values(fromEn(a.newItems)), _e = _d.next(); !_e.done; _e = _d.next()) {
                    var c = _e.value;
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.me));
                }
            }
            catch (e_8_1) { e_8 = { error: e_8_1 }; }
            finally {
                try {
                    if (_e && !_e.done && (_f = _d.return)) _f.call(_d);
                }
                finally { if (e_8) throw e_8.error; }
            }
        }
        this.i1(true);
        var e_7, _c, e_8, _f;
    };
    AnnotationLayer.prototype.jh = function (a, b) {
        this.i1(false);
    };
    AnnotationLayer.prototype.jg = function (a, b) {
        this.i1(true);
    };
    AnnotationLayer.prototype.i2 = function (a) {
        _super.prototype.i2.call(this, a);
        if (this.cc(this.bi)) {
            return;
        }
        if (this.c7(a) && !this.db) {
            var b = this.lq;
            if (this.ca()) {
                if (this.bt.g) {
                    this.bt.t();
                }
                this.lq = this.lr;
                this.lr = b;
            }
            else {
                this.lq = this.lp;
                this.lp = b;
            }
            this.l9(this.lp, this.bi);
            this.i9();
        }
        else {
            if (!this.db) {
                this.l9(this.lp, this.bi);
            }
            this.mc(this.lp, this.bi);
        }
    };
    AnnotationLayer.prototype.get_ci = function () {
        return true;
    };
    Object.defineProperty(AnnotationLayer.prototype, "ci", {
        get: function () {
            return this.get_ci();
        },
        enumerable: true,
        configurable: true
    });
    AnnotationLayer.prototype.l9 = function (a, b) {
    };
    AnnotationLayer.prototype.mc = function (a, b) {
        this.lo.bw();
    };
    AnnotationLayer.prototype.l2 = function (a) {
        var b = { $type: Point_$type, x: this.mn.x, y: this.mn.y };
        if (a.isVertical) {
            if (isNaN_(this.mn.y)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.mn.x)) {
                b.x = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        else {
            if (isNaN_(this.mn.x)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.mn.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.ic = function (a) {
        _super.prototype.ic.call(this, a);
        if (isNaN_(this.mp.x) && isNaN_(this.mp.y)) {
            if (isNaN_(a.x) && isNaN_(a.y)) {
                this.lo.bv();
                return;
            }
            else {
                this.lo.bx();
                this.mn = a;
            }
        }
        else {
            this.lo.bx();
            this.mn = this.mp;
        }
        this.i1(true);
    };
    AnnotationLayer.prototype.dt = function (a, b, c) {
        var d = _super.prototype.dt.call(this, a, b, c);
        if (!this.bi.q()) {
            return d = false;
        }
        return d;
    };
    AnnotationLayer.prototype.get_dp = function () {
        return this.lv;
    };
    Object.defineProperty(AnnotationLayer.prototype, "dp", {
        get: function () {
            return this.get_dp();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(AnnotationLayer.prototype, "lv", {
        get: function () {
            return this.ls;
        },
        set: function (a) {
            var b = this.ls;
            this.ls = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.ls);
        },
        enumerable: true,
        configurable: true
    });
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    return AnnotationLayer;
}(Series));
export { AnnotationLayer };
Type.dep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['CursorPosition:mo:mh', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'IsDefaultCrosshairDisabled:lt:mi', [0, true], 'UseIndex:lw:mj', [0, false], 'UseLegend:lx:mk', [0, false]]);
var AnnotationLayerView = /** @class */ (function (_super) {
    tslib_1.__extends(AnnotationLayerView, _super);
    function AnnotationLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.bs = null;
        _this.bt = false;
        _this.bu = -1;
        _this.bs = a;
        return _this;
    }
    AnnotationLayerView.prototype.by = function () {
        if (this.bt) {
            this.bt = false;
            this.bu = -1;
            this.bs.mn = { $type: Point_$type, x: NaN, y: NaN };
            this.bs.i1(true);
        }
    };
    AnnotationLayerView.prototype.bv = function () {
        this.bt = true;
        if (this.e.ey != null) {
            this.e.ey.setTimeout(runOn(this, this.by), 300);
        }
        else {
            this.bu = window.setTimeout(runOn(this, this.by), 300);
        }
    };
    AnnotationLayerView.prototype.bx = function () {
        if (this.bt == true) {
            this.bt = false;
            if (this.bu != -1) {
                window.clearTimeout(this.bu);
                this.bu = -1;
            }
        }
    };
    AnnotationLayerView.prototype.bw = function () {
        this.an();
    };
    AnnotationLayerView.$t = markType(AnnotationLayerView, 'AnnotationLayerView', SeriesView.$);
    return AnnotationLayerView;
}(SeriesView));
export { AnnotationLayerView };
/*<BeginStatics Name="Infragistics.Controls.Charts.AnnotationLayer" />*/
/*<EndStatics Name="Infragistics.Controls.Charts.AnnotationLayer" />*/
