/*
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-angular-core";
import { Point_$type, Boolean_$type, runOn, delegateRemove, typeCast, delegateCombine, fromEnum, fromEn, markType, markDep } from "igniteui-angular-core";
import { SeriesView } from "./SeriesView";
import { XamDataChart } from "./XamDataChart";
import { Tuple$2 } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
var AnnotationLayer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(AnnotationLayer, _super);
    function AnnotationLayer() {
        var _this = _super.call(this) || this;
        _this.q6 = null;
        _this.p5 = null;
        _this.p4 = null;
        _this.p6 = null;
        _this.q4 = { $type: Point_$type, x: NaN, y: NaN };
        _this.p7 = false;
        _this.q6 = { $type: Point_$type, x: NaN, y: NaN };
        return _this;
    }
    AnnotationLayer.prototype.bx = function () {
        return new AnnotationLayerView(this);
    };
    AnnotationLayer.prototype.ly = function (a) {
        _super.prototype.ly.call(this, a);
        this.p3 = a;
    };
    AnnotationLayer.prototype.qb = function (a) {
        if (a == null) {
            return false;
        }
        if (a.dc) {
            return false;
        }
        if (a.isValueOverlay) {
            return false;
        }
        if (a == this) {
            return false;
        }
        return a.e9(a.b0.bu, a.b0.bv, a.b0);
    };
    AnnotationLayer.prototype.get_dj = function () {
        return this.p8;
    };
    AnnotationLayer.prototype.bp = function () {
        if (this.bq == 0) {
            return 1;
        }
        else {
            return _super.prototype.bp.call(this);
        }
    };
    AnnotationLayer.prototype.get_dy = function () {
        return this.qd || this.qe;
    };
    AnnotationLayer.prototype.get_isUsableInLegend = function () {
        return this.qe;
    };
    AnnotationLayer.prototype.l3 = function (a, b, c, d) {
        _super.prototype.l3.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                var e = c;
                var f = d;
                if (e != null) {
                    this.qx(e.series);
                    var g = e.series;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.qu));
                    if (typeCast(XamDataChart.$, e) !== null) {
                        var h = e;
                        this.qw(h.axes);
                        var i = h.axes;
                        i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.qk));
                    }
                }
                if (f != null) {
                    this.qs(f.series);
                    var j = f.series;
                    j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.qu));
                    if (typeCast(XamDataChart.$, f) !== null) {
                        var k = f;
                        this.qr(k.axes);
                        var l = k.axes;
                        l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.qk));
                    }
                }
                break;
            case AnnotationLayer.$$p[3]:
            case AnnotationLayer.$$p[2]:
                if (this.dy) {
                    if (this.index == -1) {
                        this.index = XamDataChart.u1(this);
                    }
                }
                else {
                    this.index = -1;
                    this.oy = null;
                    this.o1 = null;
                }
                if (this.cd != null) {
                    this.cd.mk();
                }
                this.mh(true);
                break;
            case "TransitionProgress":
                this.p6.c(this.g0, this.p5, this.p4);
                if (this.cx(this.b0)) {
                    return;
                }
                if (this.g0 == 1) {
                    this.qt(this.p4, this.b0);
                }
                else {
                    this.qt(this.p6, this.b0);
                }
                if (this.cd != null) {
                    this.cd.nn(this);
                }
                break;
            case AnnotationLayer.$$p[1]:
                if (this.cd != null) {
                    this.cd.mi();
                }
                break;
            case AnnotationLayer.$$p[0]:
                this.q6 = this.q5;
                this.ls(this.q5);
                break;
            case "ShouldRenderAsOverlay":
                if (this.cd != null) {
                    this.b0.ak(this.cd);
                    this.b0.ag(this.cd);
                }
                break;
        }
    };
    AnnotationLayer.prototype.qx = 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.qv));
                }
            }
        }
        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.mh(true);
    };
    AnnotationLayer.prototype.qw = 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.ql));
            }
        }
        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.mh(true);
    };
    AnnotationLayer.prototype.qs = 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.qv));
                }
            }
        }
        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.mh(true);
    };
    AnnotationLayer.prototype.qr = 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.ql));
            }
        }
        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.mh(true);
    };
    AnnotationLayer.prototype.p9 = function (a) {
        if (a == null) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.ql = function (a, b) {
        if (this.p9(a)) {
            this.qn(a, b.animate);
        }
    };
    AnnotationLayer.prototype.qa = function (a) {
        if (a == null) {
            return false;
        }
        if (a.dc) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.qv = function (a, b) {
        if (this.qa(a)) {
            this.qo(a, b.animate);
        }
    };
    AnnotationLayer.prototype.qn = function (a, b) {
    };
    AnnotationLayer.prototype.qo = function (a, b) {
    };
    AnnotationLayer.prototype.qu = function (a, b) {
        this.qp(b);
    };
    AnnotationLayer.prototype.qk = function (a, b) {
        this.qm(b);
    };
    AnnotationLayer.prototype.q2 = function () {
        if (this.oy != null) {
            return this.oy;
        }
        return this.o2;
    };
    AnnotationLayer.prototype.q3 = function () {
        if (this.o1 != null) {
            return this.o1;
        }
        return this.o7;
    };
    AnnotationLayer.prototype.qm = 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.ql));
                }
            }
            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.ql));
                }
            }
            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.mh(true);
    };
    AnnotationLayer.prototype.qp = 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.qv));
                }
            }
            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.qv));
                }
            }
            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.mh(true);
    };
    AnnotationLayer.prototype.m5 = function (a, b) {
        this.mh(false);
    };
    AnnotationLayer.prototype.m4 = function (a, b) {
        this.mh(true);
    };
    AnnotationLayer.prototype.mi = function (a) {
        _super.prototype.mi.call(this, a);
        if (this.cx(this.b0)) {
            return;
        }
        if (this.eo(a) && !this.es) {
            var b = this.p5;
            if (this.cv()) {
                if (this.ce.g) {
                    this.ce.t();
                }
                this.p5 = this.p6;
                this.p6 = b;
            }
            else {
                this.p5 = this.p4;
                this.p4 = b;
            }
            this.qq(this.p4, this.b0);
            this.mq();
        }
        else {
            if (!this.es) {
                this.qq(this.p4, this.b0);
            }
            this.qt(this.p4, this.b0);
        }
    };
    AnnotationLayer.prototype.get_dc = function () {
        return true;
    };
    AnnotationLayer.prototype.qq = function (a, b) {
    };
    AnnotationLayer.prototype.qt = function (a, b) {
        this.p3.b1();
    };
    AnnotationLayer.prototype.qj = function (a) {
        var b = { $type: Point_$type, x: this.q4.x, y: this.q4.y };
        if (a.isVertical) {
            if (isNaN_(this.q4.y)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.q4.x)) {
                b.x = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        else {
            if (isNaN_(this.q4.x)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.q4.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.ls = function (a) {
        _super.prototype.ls.call(this, a);
        if (isNaN_(this.q6.x) && isNaN_(this.q6.y)) {
            if (isNaN_(a.x) && isNaN_(a.y)) {
                this.p3.b0();
                return;
            }
            else {
                this.p3.b2();
                this.q4 = a;
            }
        }
        else {
            this.p3.b2();
            this.q4 = this.q6;
        }
        this.mh(true);
    };
    AnnotationLayer.prototype.e9 = function (a, b, c) {
        var d = _super.prototype.e9.call(this, a, b, c);
        if (!this.b0.t()) {
            d = false;
            return d;
        }
        return d;
    };
    AnnotationLayer.prototype.get_e5 = function () {
        return this.qc;
    };
    Object.defineProperty(AnnotationLayer.prototype, "qc", {
        get: function () {
            return this.p7;
        },
        set: function (a) {
            var b = this.p7;
            this.p7 = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.p7);
        },
        enumerable: false,
        configurable: true
    });
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    AnnotationLayer.$$p = markDep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['CursorPosition:q5:qy', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'IsDefaultCrosshairDisabled:p8:qz', [0, true], 'UseIndex:qd:q0', [0, false], 'UseLegend:qe:q1', [0, false]]);
    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.bx = null;
        _this.by = false;
        _this.bz = -1;
        _this.bx = a;
        return _this;
    }
    AnnotationLayerView.prototype.b3 = function () {
        if (this.by) {
            this.by = false;
            this.bz = -1;
            this.bx.q4 = { $type: Point_$type, x: NaN, y: NaN };
            this.bx.mh(true);
        }
    };
    AnnotationLayerView.prototype.b0 = function () {
        this.by = true;
        if (this.e.g9 != null) {
            this.e.g9.setTimeout(runOn(this, this.b3), 300);
        }
        else {
            this.bz = window.setTimeout(runOn(this, this.b3), 300);
        }
    };
    AnnotationLayerView.prototype.b2 = function () {
        if (this.by == true) {
            this.by = false;
            if (this.bz != -1) {
                window.clearTimeout(this.bz);
                this.bz = -1;
            }
        }
    };
    AnnotationLayerView.prototype.b1 = function () {
        this.aq();
    };
    AnnotationLayerView.$t = markType(AnnotationLayerView, 'AnnotationLayerView', SeriesView.$);
    return AnnotationLayerView;
}(SeriesView));
export { AnnotationLayerView };
