/*
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.rb = null;
        _this.qa = null;
        _this.p9 = null;
        _this.qb = null;
        _this.q9 = { $type: Point_$type, x: NaN, y: NaN };
        _this.qc = false;
        _this.rb = { $type: Point_$type, x: NaN, y: NaN };
        return _this;
    }
    AnnotationLayer.prototype.bx = function () {
        return new AnnotationLayerView(this);
    };
    AnnotationLayer.prototype.l2 = function (a) {
        _super.prototype.l2.call(this, a);
        this.p8 = a;
    };
    AnnotationLayer.prototype.qg = function (a) {
        if (a == null) {
            return false;
        }
        if (a.dc) {
            return false;
        }
        if (a.isValueOverlay) {
            return false;
        }
        if (a == this) {
            return false;
        }
        return a.fb(a.b0.bu, a.b0.bv, a.b0);
    };
    AnnotationLayer.prototype.get_dk = function () {
        return this.qd;
    };
    AnnotationLayer.prototype.bp = function () {
        if (this.bq == 0) {
            return 1;
        }
        else {
            return _super.prototype.bp.call(this);
        }
    };
    AnnotationLayer.prototype.get_dz = function () {
        return this.qi || this.qj;
    };
    AnnotationLayer.prototype.get_isUsableInLegend = function () {
        return this.qj;
    };
    AnnotationLayer.prototype.l7 = function (a, b, c, d) {
        _super.prototype.l7.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                var e = c;
                var f = d;
                if (e != null) {
                    this.q2(e.series);
                    var g = e.series;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.qz));
                    if (typeCast(XamDataChart.$, e) !== null) {
                        var h = e;
                        this.q1(h.axes);
                        var i = h.axes;
                        i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.qp));
                    }
                }
                if (f != null) {
                    this.qx(f.series);
                    var j = f.series;
                    j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.qz));
                    if (typeCast(XamDataChart.$, f) !== null) {
                        var k = f;
                        this.qw(k.axes);
                        var l = k.axes;
                        l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.qp));
                    }
                }
                break;
            case AnnotationLayer.$$p[3]:
            case AnnotationLayer.$$p[2]:
                if (this.dz) {
                    if (this.index == -1) {
                        this.index = XamDataChart.vv(this);
                    }
                }
                else {
                    this.index = -1;
                    this.o3 = null;
                    this.o6 = null;
                }
                if (this.cd != null) {
                    this.cd.m7();
                }
                this.ml(true);
                break;
            case "TransitionProgress":
                this.qb.c(this.g2, this.qa, this.p9);
                if (this.cx(this.b0)) {
                    return;
                }
                if (this.g2 == 1) {
                    this.qy(this.p9, this.b0);
                }
                else {
                    this.qy(this.qb, this.b0);
                }
                if (this.cd != null) {
                    this.cd.oa(this);
                }
                break;
            case AnnotationLayer.$$p[1]:
                if (this.cd != null) {
                    this.cd.m5();
                }
                break;
            case AnnotationLayer.$$p[0]:
                this.rb = this.ra;
                this.lw(this.ra);
                break;
            case "ShouldRenderAsOverlay":
                if (this.cd != null) {
                    this.b0.ak(this.cd);
                    this.b0.ag(this.cd);
                }
                break;
        }
    };
    AnnotationLayer.prototype.q2 = 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.q0));
                }
            }
        }
        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.ml(true);
    };
    AnnotationLayer.prototype.q1 = 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.qq));
            }
        }
        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.ml(true);
    };
    AnnotationLayer.prototype.qx = 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.q0));
                }
            }
        }
        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.ml(true);
    };
    AnnotationLayer.prototype.qw = 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.qq));
            }
        }
        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.ml(true);
    };
    AnnotationLayer.prototype.qe = function (a) {
        if (a == null) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.qq = function (a, b) {
        if (this.qe(a)) {
            this.qs(a, b.animate);
        }
    };
    AnnotationLayer.prototype.qf = function (a) {
        if (a == null) {
            return false;
        }
        if (a.dc) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.q0 = function (a, b) {
        if (this.qf(a)) {
            this.qt(a, b.animate);
        }
    };
    AnnotationLayer.prototype.qs = function (a, b) {
    };
    AnnotationLayer.prototype.qt = function (a, b) {
    };
    AnnotationLayer.prototype.qz = function (a, b) {
        this.qu(b);
    };
    AnnotationLayer.prototype.qp = function (a, b) {
        this.qr(b);
    };
    AnnotationLayer.prototype.q7 = function () {
        if (this.o3 != null) {
            return this.o3;
        }
        return this.o7;
    };
    AnnotationLayer.prototype.q8 = function () {
        if (this.o6 != null) {
            return this.o6;
        }
        return this.pc;
    };
    AnnotationLayer.prototype.qr = 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.qq));
                }
            }
            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.qq));
                }
            }
            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.ml(true);
    };
    AnnotationLayer.prototype.qu = 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.q0));
                }
            }
            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.q0));
                }
            }
            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.ml(true);
    };
    AnnotationLayer.prototype.m9 = function (a, b) {
        this.ml(false);
    };
    AnnotationLayer.prototype.m8 = function (a, b) {
        this.ml(true);
    };
    AnnotationLayer.prototype.mm = function (a) {
        _super.prototype.mm.call(this, a);
        if (this.cx(this.b0)) {
            return;
        }
        if (this.ep(a) && !this.eu) {
            var b = this.qa;
            if (this.cv()) {
                if (this.ce.g) {
                    this.ce.t();
                }
                this.qa = this.qb;
                this.qb = b;
            }
            else {
                this.qa = this.p9;
                this.p9 = b;
            }
            this.qv(this.p9, this.b0);
            this.mu();
        }
        else {
            if (!this.eu) {
                this.qv(this.p9, this.b0);
            }
            this.qy(this.p9, this.b0);
        }
    };
    AnnotationLayer.prototype.get_dc = function () {
        return true;
    };
    AnnotationLayer.prototype.qv = function (a, b) {
    };
    AnnotationLayer.prototype.qy = function (a, b) {
        this.p8.b1();
    };
    AnnotationLayer.prototype.qo = function (a) {
        var b = { $type: Point_$type, x: this.q9.x, y: this.q9.y };
        if (a.isVertical) {
            if (isNaN_(this.q9.y)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.q9.x)) {
                b.x = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        else {
            if (isNaN_(this.q9.x)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.q9.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.lw = function (a) {
        _super.prototype.lw.call(this, a);
        if (isNaN_(this.rb.x) && isNaN_(this.rb.y)) {
            if (isNaN_(a.x) && isNaN_(a.y)) {
                this.p8.b0();
                return;
            }
            else {
                this.p8.b2();
                this.q9 = a;
            }
        }
        else {
            this.p8.b2();
            this.q9 = this.rb;
        }
        this.ml(true);
    };
    AnnotationLayer.prototype.fb = function (a, b, c) {
        var d = _super.prototype.fb.call(this, a, b, c);
        if (!this.b0.t()) {
            d = false;
            return d;
        }
        return d;
    };
    AnnotationLayer.prototype.get_e7 = function () {
        return this.qh;
    };
    Object.defineProperty(AnnotationLayer.prototype, "qh", {
        get: function () {
            return this.qc;
        },
        set: function (a) {
            var b = this.qc;
            this.qc = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.qc);
        },
        enumerable: false,
        configurable: true
    });
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    AnnotationLayer.$$p = markDep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['CursorPosition:ra:q3', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'IsDefaultCrosshairDisabled:qd:q4', [0, true], 'UseIndex:qi:q5', [0, false], 'UseLegend:qj:q6', [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.q9 = { $type: Point_$type, x: NaN, y: NaN };
            this.bx.ml(true);
        }
    };
    AnnotationLayerView.prototype.b0 = function () {
        this.by = true;
        if (this.e.hb != null) {
            this.e.hb.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 };
