/*
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, enumGetBox, runOn, delegateRemove, typeCast, delegateCombine, fromEnum, fromEn, markType, markDep } from "igniteui-angular-core";
import { AnnotationAppearanceMode_$type } from "./AnnotationAppearanceMode";
import { DoubleCollection } from "igniteui-angular-core";
import { PenLineCap_$type } from "igniteui-angular-core";
import { SeriesView } from "./SeriesView";
import { XamDataChart } from "./XamDataChart";
import { Brush } from "igniteui-angular-core";
import { Tuple$2 } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_, truncate } from "igniteui-angular-core";
import { BrushUtil } from "igniteui-angular-core";
import { Color } from "igniteui-angular-core";
/**
 * @hidden
 */
var AnnotationLayer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(AnnotationLayer, _super);
    function AnnotationLayer() {
        var _this = _super.call(this) || this;
        _this.aae = null;
        _this.xm = null;
        _this.xl = null;
        _this.xn = null;
        _this.aac = { $type: Point_$type, x: NaN, y: NaN };
        _this.xo = false;
        _this.aae = { $type: Point_$type, x: NaN, y: NaN };
        _this.zb();
        return _this;
    }
    AnnotationLayer.prototype.ct = function () {
        return new AnnotationLayerView(this);
    };
    AnnotationLayer.prototype.q7 = function (a) {
        _super.prototype.q7.call(this, a);
        this.xk = a;
    };
    AnnotationLayer.prototype.xs = function (a) {
        if (a == null) {
            return false;
        }
        if (a.eu) {
            return false;
        }
        if (a.isValueOverlay) {
            return false;
        }
        if (a == this) {
            return false;
        }
        return a.hf(a.cw.b9, a.cw.ca, a.cw);
    };
    AnnotationLayer.prototype.get_e3 = function () {
        return this.xp;
    };
    AnnotationLayer.prototype.b3 = function () {
        if (this.b4 == 0) {
            return 1;
        }
        else {
            return _super.prototype.b3.call(this);
        }
    };
    AnnotationLayer.prototype.get_fh = function () {
        return this.xu || this.xv;
    };
    AnnotationLayer.prototype.get_isUsableInLegend = function () {
        return this.xv;
    };
    AnnotationLayer.prototype.rg = function (a, b, c, d) {
        _super.prototype.rg.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                var e = c;
                var f = d;
                if (e != null) {
                    this.za(e.series);
                    var g = e.series;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.y7));
                    if (typeCast(XamDataChart.$, e) !== null) {
                        var h = e;
                        this.y9(h.axes);
                        var i = h.axes;
                        i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.yx));
                    }
                }
                if (f != null) {
                    this.y5(f.series);
                    var j = f.series;
                    j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.y7));
                    if (typeCast(XamDataChart.$, f) !== null) {
                        var k = f;
                        this.y4(k.axes);
                        var l = k.axes;
                        l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.yx));
                    }
                }
                break;
            case AnnotationLayer.$$p[18]:
            case AnnotationLayer.$$p[17]:
                if (this.fh) {
                    if (this.index == -1) {
                        this.index = XamDataChart.aad(this);
                    }
                }
                else {
                    this.index = -1;
                    this.vj = null;
                    this.vn = null;
                }
                if (this.dc != null) {
                    this.dc.qd();
                }
                this.ry(true);
                break;
            case "TransitionProgress":
                this.xn.c(this.ju, this.xm, this.xl);
                if (this.d7(this.cw)) {
                    return;
                }
                if (this.ju == 1) {
                    this.y6(this.xl, this.cw);
                    this.qu();
                }
                else {
                    this.y6(this.xn, this.cw);
                }
                if (this.dc != null) {
                    this.dc.rz(this);
                }
                break;
            case AnnotationLayer.$$p[15]:
                if (this.dc != null) {
                    this.dc.p7();
                }
                break;
            case AnnotationLayer.$$p[11]:
                this.aae = this.aad;
                this.qx(this.aad);
                break;
            case "ShouldRenderAsOverlay":
                if (this.dc != null) {
                    this.cw.at(this.dc);
                    this.cw.ao(this.dc);
                }
                break;
            case AnnotationLayer.$$p[10]:
            case AnnotationLayer.$$p[16]:
            case "DashArray":
            case AnnotationLayer.$$p[12]:
            case AnnotationLayer.$$p[19]:
            case AnnotationLayer.$$p[14]:
            case AnnotationLayer.$$p[21]:
            case AnnotationLayer.$$p[13]:
            case AnnotationLayer.$$p[20]:
                this.zb();
                break;
            case AnnotationLayer.$$p[0]:
            case AnnotationLayer.$$p[6]:
            case AnnotationLayer.$$p[3]:
            case AnnotationLayer.$$p[7]:
            case AnnotationLayer.$$p[5]:
            case AnnotationLayer.$$p[9]:
            case AnnotationLayer.$$p[4]:
            case AnnotationLayer.$$p[8]:
                this.ry(true);
                break;
        }
    };
    AnnotationLayer.prototype.za = 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.y8));
                }
            }
        }
        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.ry(true);
    };
    AnnotationLayer.prototype.y9 = 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.yy));
            }
        }
        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.ry(true);
    };
    AnnotationLayer.prototype.y5 = 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.y8));
                }
            }
        }
        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.ry(true);
    };
    AnnotationLayer.prototype.y4 = 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.yy));
            }
        }
        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.ry(true);
    };
    AnnotationLayer.prototype.xq = function (a) {
        if (a == null) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.yy = function (a, b) {
        if (this.xq(a)) {
            this.y0(a, b.animate);
        }
    };
    AnnotationLayer.prototype.xr = function (a) {
        if (a == null) {
            return false;
        }
        if (a.eu) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.y8 = function (a, b) {
        if (this.xr(a)) {
            this.y1(a, b.animate);
        }
    };
    AnnotationLayer.prototype.y0 = function (a, b) {
    };
    AnnotationLayer.prototype.y1 = function (a, b) {
    };
    AnnotationLayer.prototype.y7 = function (a, b) {
        this.y2(b);
    };
    AnnotationLayer.prototype.yx = function (a, b) {
        this.yz(b);
    };
    AnnotationLayer.prototype.zy = function () {
        if (this.vj != null) {
            return this.vj;
        }
        return this.vp;
    };
    AnnotationLayer.prototype.zz = function () {
        if (this.vn != null) {
            return this.vn;
        }
        return this.v5;
    };
    AnnotationLayer.prototype.yz = 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.yy));
                }
            }
            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.yy));
                }
            }
            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.ry(true);
    };
    AnnotationLayer.prototype.y2 = 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.y8));
                }
            }
            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.y8));
                }
            }
            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.ry(true);
    };
    AnnotationLayer.prototype.sz = function (a, b) {
        this.ry(false);
    };
    AnnotationLayer.prototype.sy = function (a, b) {
        this.ry(true);
    };
    AnnotationLayer.prototype.rz = function (a) {
        _super.prototype.rz.call(this, a);
        if (this.d7(this.cw)) {
            return;
        }
        if (this.gg(a) && !this.gs) {
            var b = this.xm;
            if (this.d4()) {
                if (this.dd.g) {
                    this.dd.t();
                }
                this.xm = this.xn;
                this.xn = b;
            }
            else {
                this.xm = this.xl;
                this.xl = b;
            }
            this.y3(this.xl, this.cw);
            this.sf();
        }
        else {
            if (!this.gs) {
                this.y3(this.xl, this.cw);
            }
            this.y6(this.xl, this.cw);
        }
    };
    AnnotationLayer.prototype.get_eu = function () {
        return true;
    };
    AnnotationLayer.prototype.y3 = function (a, b) {
    };
    AnnotationLayer.prototype.y6 = function (a, b) {
        this.q3();
        this.xk.ch();
    };
    AnnotationLayer.prototype.yw = function (a) {
        var b = { $type: Point_$type, x: this.aac.x, y: this.aac.y };
        if (a.isVertical) {
            if (isNaN_(this.aac.y)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.aac.x)) {
                b.x = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        else {
            if (isNaN_(this.aac.x)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.aac.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.qx = function (a) {
        _super.prototype.qx.call(this, a);
        if (isNaN_(this.aae.x) && isNaN_(this.aae.y)) {
            if (isNaN_(a.x) && isNaN_(a.y)) {
                this.xk.cg();
                return;
            }
            else {
                this.xk.ci();
                this.aac = a;
            }
        }
        else {
            this.xk.ci();
            this.aac = this.aae;
        }
        this.ry(true);
    };
    AnnotationLayer.prototype.hf = function (a, b, c) {
        var d = _super.prototype.hf.call(this, a, b, c);
        if (this.dc == null) {
            return false;
        }
        if (!this.cw.w()) {
            d = false;
            return d;
        }
        return d;
    };
    AnnotationLayer.prototype.x5 = function () {
        if (isNaN_(this.x8)) {
            switch (this.w8) {
                case 1: return this.xz();
                case 2: return this.x2();
                case 4: return this.x1();
            }
        }
        return this.x8;
    };
    AnnotationLayer.prototype.x4 = function () {
        if (isNaN_(this.x7)) {
            return this.xx;
        }
        return this.x7;
    };
    AnnotationLayer.prototype.x6 = function () {
        if (isNaN_(this.x9)) {
            return this.xx;
        }
        return this.x9;
    };
    AnnotationLayer.prototype.xf = function () {
        switch (this.xb) {
            case 0: return this.xc();
        }
        return this.xb;
    };
    AnnotationLayer.prototype.xg = function () {
        switch (this.xi) {
            case 0: return this.w8;
        }
        return this.xi;
    };
    AnnotationLayer.prototype.xh = function () {
        switch (this.xj) {
            case 0: return this.w8;
        }
        return this.xj;
    };
    AnnotationLayer.prototype.z7 = function () {
        if (this.z9 == null) {
            if (this.wc == null) {
                return this.z4();
            }
            return this.wc;
        }
        return this.z9;
    };
    AnnotationLayer.prototype.z8 = function () {
        if (this.aaa == null) {
            if (this.wc == null) {
                return this.z5();
            }
            return this.wc;
        }
        return this.aaa;
    };
    AnnotationLayer.prototype.z6 = function () {
        if (this.wc == null) {
            return this.z3();
        }
        return this.wc;
    };
    AnnotationLayer.prototype.xc = function () {
        return 0;
    };
    AnnotationLayer.prototype.xd = function () {
        return this.xc();
    };
    AnnotationLayer.prototype.xe = function () {
        return this.xc();
    };
    AnnotationLayer.prototype.xz = function () {
        return NaN;
    };
    AnnotationLayer.prototype.x2 = function () {
        return NaN;
    };
    AnnotationLayer.prototype.x1 = function () {
        return NaN;
    };
    AnnotationLayer.prototype.x0 = function () {
        return NaN;
    };
    AnnotationLayer.prototype.x3 = function () {
        return NaN;
    };
    AnnotationLayer.prototype.z4 = function () {
        return null;
    };
    AnnotationLayer.prototype.z5 = function () {
        return null;
    };
    AnnotationLayer.prototype.z3 = function () {
        return null;
    };
    AnnotationLayer.prototype.zb = function () {
        this.w8 = this.xf();
        this.xx = this.x5();
        this.w9 = this.xg();
        this.xw = this.x4();
        this.xa = this.xh();
        this.xy = this.x6();
        this.z1 = this.z7();
        this.z2 = this.z8();
        this.z0 = this.z6();
    };
    AnnotationLayer.prototype.get_hb = function () {
        return this.xt;
    };
    Object.defineProperty(AnnotationLayer.prototype, "xt", {
        get: function () {
            return this.xo;
        },
        set: function (a) {
            var b = this.xo;
            this.xo = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.xo);
        },
        enumerable: false,
        configurable: true
    });
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    AnnotationLayer.$$p = markDep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['ActualAppearanceMode:w8:zc', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualDashArray:z0:zd', [DoubleCollection.$], 'ActualDashCap:aab:ze', [PenLineCap_$type], 'ActualHorizontalAppearanceMode:w9:zf', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalDashArray:z1:zg', [DoubleCollection.$], 'ActualHorizontalShiftAmount:xw:zh', [1, NaN], 'ActualShiftAmount:xx:zi', [1, NaN], 'ActualVerticalAppearanceMode:xa:zj', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualVerticalDashArray:z2:zk', [DoubleCollection.$], 'ActualVerticalShiftAmount:xy:zl', [1, NaN], 'AppearanceMode:xb:zm', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'CursorPosition:aad:zn', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'HorizontalAppearanceMode:xi:zo', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'HorizontalDashArray:z9:zp', [DoubleCollection.$], 'HorizontalShiftAmount:x7:zq', [1, NaN], 'IsDefaultCrosshairDisabled:xp:zr', [0, true], 'ShiftAmount:x8:zs', [1, NaN], 'UseIndex:xu:zt', [0, false], 'UseLegend:xv:zu', [0, false], 'VerticalAppearanceMode:xj:zv', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'VerticalDashArray:aaa:zw', [DoubleCollection.$], 'VerticalShiftAmount:x9:zx', [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.cd = null;
        _this.ce = false;
        _this.cf = -1;
        _this.cd = a;
        return _this;
    }
    AnnotationLayerView.prototype.cj = function () {
        if (this.ce) {
            this.ce = false;
            this.cf = -1;
            this.cd.aac = { $type: Point_$type, x: NaN, y: NaN };
            this.cd.ry(true);
        }
    };
    AnnotationLayerView.prototype.cg = function () {
        this.ce = true;
        if (this.f.j3 != null) {
            this.f.j3.setTimeout(runOn(this, this.cj), 300);
        }
        else {
            this.cf = window.setTimeout(runOn(this, this.cj), 300);
        }
    };
    AnnotationLayerView.prototype.ci = function () {
        if (this.ce == true) {
            this.ce = false;
            if (this.cf != -1) {
                window.clearTimeout(this.cf);
                this.cf = -1;
            }
        }
    };
    AnnotationLayerView.prototype.ch = function () {
        this.a2();
    };
    AnnotationLayerView.prototype.ck = function (a, b) {
        if (a == null) {
            return a;
        }
        return BrushUtil.o(a, b);
    };
    AnnotationLayerView.prototype.cm = function (a, b) {
        if (a == null) {
            return a;
        }
        return BrushUtil.q(a, b);
    };
    AnnotationLayerView.prototype.cl = function (a, b) {
        if (a == null) {
            return a;
        }
        var c = new Brush();
        c.color = Color.u(truncate((a.color.l * b)), a.color.o, a.color.n, a.color.m);
        return c;
    };
    AnnotationLayerView.$t = markType(AnnotationLayerView, 'AnnotationLayerView', SeriesView.$);
    return AnnotationLayerView;
}(SeriesView));
export { AnnotationLayerView };
