/*
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 { Base, Point_$type, Nullable$1, String_$type, fromEnum, markType } from "igniteui-react-core/ES5/type";
import { ISeriesInteractionManager_$type } from "./ISeriesInteractionManager";
import { Dictionary$2 } from "igniteui-react-core/ES5/Dictionary$2";
import { SeriesView } from "./SeriesView";
import { ScalerParams } from "./ScalerParams";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { Rect } from "igniteui-react-core/ES5/Rect";
import { GeometryUtil } from "igniteui-react-core/ES5/GeometryUtil";
import { PolygonUtil } from "igniteui-react-core/ES5/PolygonUtil";
import { RectUtil } from "igniteui-react-core/ES5/RectUtil";
import { BrushUtil } from "igniteui-react-core/ES5/BrushUtil";
import { Color } from "igniteui-react-core/ES5/Color";
import { truncate, isNaN_ } from "igniteui-react-core/ES5/number";
import { boxArray$1 } from "igniteui-react-core/ES5/array";
import { stringIsNullOrEmpty } from "igniteui-react-core/ES5/string";
/**
 * @hidden
 */
var SeriesInteractionManager = /** @class */ (function (_super) {
    tslib_1.__extends(SeriesInteractionManager, _super);
    function SeriesInteractionManager() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.a = null;
        _this.b = null;
        _this.a$o = null;
        _this.a$c = false;
        _this.i = false;
        _this.c = false;
        _this.d = false;
        _this.e = true;
        _this.f = false;
        _this._toolTipObject = null;
        _this.p = null;
        _this.s = null;
        _this.o = null;
        _this.j = false;
        _this.k = new Dictionary$2(String_$type, SeriesView.$, 0);
        return _this;
    }
    SeriesInteractionManager.prototype.a$i = function (a, b, c, d, e, f, g, h) {
        if (d == null) {
            return Number.POSITIVE_INFINITY;
        }
        if (c < 0 || c > g - 1) {
            return Number.POSITIVE_INFINITY;
        }
        var i;
        var j = NaN;
        var k = NaN;
        var l = NaN;
        var m = NaN;
        if (d.cc) {
            var n = d;
            i = h(b);
            var o = truncate(Math.floor(i));
            var p = truncate(Math.ceil(i));
            m = i - o;
            if (o >= 0 && o < g) {
                var q = n.i$d(n.i$b._inner[o]);
                j = d.dt(q, e) + f;
            }
            else {
                j = NaN;
            }
            if (p >= 0 && p < g) {
                var r = n.i$d(n.i$b._inner[p]);
                k = d.dt(r, e) + f;
            }
            else {
                k = NaN;
            }
            if (isNaN_(j) && !isNaN_(k)) {
                j = k;
            }
            if (isNaN_(k) && !isNaN_(j)) {
                k = j;
            }
            if (c >= 0 && c < g) {
                var s = n.i$d(n.i$b._inner[c]);
                l = d.dt(s, e) + f;
            }
        }
        else {
            i = a.d8(b);
            var t = truncate(Math.floor(i));
            var u = truncate(Math.ceil(i));
            m = i - t;
            if (t >= 0 && t < g) {
                j = d.dt(t, e) + f;
            }
            else {
                j = NaN;
            }
            if (u >= 0 && u < g) {
                k = d.dt(u, e) + f;
            }
            else {
                k = NaN;
            }
            if (isNaN_(j) && !isNaN_(k)) {
                j = k;
            }
            if (isNaN_(k) && !isNaN_(j)) {
                k = j;
            }
            if (c >= 0 && c < g) {
                l = d.dt(c, e) + f;
            }
        }
        var v = j + m * (k - j);
        return Math.abs(l - v);
    };
    SeriesInteractionManager.prototype.a$k = function (a, b, c, d, e, f, g, h, i) {
        var j = NaN;
        if (d >= 0 && d < c.count) {
            j = c.item(d);
        }
        var k = NaN;
        if (e >= 0 && e < c.count) {
            k = c.item(e);
        }
        if (g == 0) {
            return k;
        }
        if (f == c.count - 1) {
            return j;
        }
        if (isNaN_(k) && h != 0 && b <= 0.5 && !i) {
            return j;
        }
        if (isNaN_(j) && h != 0 && b >= 0.5 && !i) {
            return k;
        }
        return j * (1 - b) + k * b;
    };
    SeriesInteractionManager.prototype.a$a = function (a, b, c, d, e, f, g) {
        if (b == null) {
            return null;
        }
        var h = -1;
        var i = -1;
        if (b.cc) {
            var j = a.k9(f);
            var k = -1;
            var l = b.b8;
            var m = a.bi.br.right * 2;
            k = SeriesInteractionManager.n(c, j, l, m);
            if (k < 0) {
                k = ~k;
                k--;
            }
            if (k < 0) {
                k = 0;
            }
            if (k > c.count - 1) {
                k = c.count - 1;
            }
            var n = k;
            var o = k + 1;
            if (o > c.count - 1) {
                o = c.count - 1;
            }
            h = n;
            i = o;
        }
        else {
            var p = a.fb(f, g);
            var q = a.e9(f, g);
            var r = truncate(Math.floor(p / d));
            var s = truncate(Math.floor(q / d));
            h = r - e;
            i = s - e;
            if (i == h) {
                i++;
            }
        }
        if (h < 0) {
            h = 0;
        }
        if (h > c.count - 1) {
            h = c.count - 1;
        }
        if (i < 0) {
            i = 0;
        }
        if (i > c.count - 1) {
            i = c.count - 1;
        }
        if (h < 0 || i < 0) {
            return null;
        }
        var t = c._inner[h];
        var u = c._inner[i];
        var v = new Array(2);
        v[0] = t;
        v[1] = u;
        return v;
    };
    SeriesInteractionManager.n = function (a, b, c, d) {
        var e = 0;
        var f = a.count - 1;
        while (e <= f) {
            var g = (e + ((f - e) >> 1));
            var h = void 0;
            var i = a.item(g);
            if (c) {
                h = (d - b.x) < (d - i[0]) ? -1 : ((d - b.x) > (d - i[0]) ? 1 : 0);
            }
            else {
                h = b.x < i[0] ? -1 : (b.x > i[0] ? 1 : 0);
            }
            if (h < 0) {
                f = g - 1;
            }
            else if (h > 0) {
                e = g + 1;
            }
            else {
                return g;
            }
        }
        return ~e;
    };
    SeriesInteractionManager.prototype.a$n = function (a, b, c, d, e, f) {
        if (d == null) {
            return -1;
        }
        var g = d.cc;
        var h = a.du;
        var i = null;
        if (g) {
            i = d;
        }
        var j = -1;
        var k = -1;
        var l = -1;
        if (g) {
            j = e(b);
            if (isNaN_(j)) {
                return -1;
            }
            k = truncate(Math.floor(j));
            l = truncate(Math.ceil(j));
        }
        else {
            j = a.d8(b);
            if (isNaN_(j)) {
                return -1;
            }
            k = truncate(Math.floor(j));
            l = truncate(Math.ceil(j));
        }
        if (f == null) {
            return -1;
        }
        if (k < 0 || k > f.count - 1) {
            return -1;
        }
        if (!c) {
            return k;
        }
        var m = NaN;
        if (g && !h) {
            if (k < i.i$b.count && i.i$b._inner[k] < f.count) {
                m = f.item(i.i$b._inner[k]);
            }
        }
        else {
            m = f.item(k);
        }
        while (isNaN_(m)) {
            k--;
            if (k < 0 || k > f.count - 1) {
                return -1;
            }
            if (g && !h) {
                m = f.item(i.i$b._inner[k]);
            }
            else {
                m = f.item(k);
            }
        }
        return k;
    };
    SeriesInteractionManager.prototype.a$l = function (a, b, c, d, e, f, g, h, i) {
        if (b == null) {
            return NaN;
        }
        var j = a.du;
        var k = a.fc(c, i, d, g, b);
        var l = a.fa(c, i, d, g, b);
        var m = a.d6(c, k, d, e, f);
        var n = a.d6(c, l, d, e, f);
        var o = k;
        var p = l;
        var q = d.cc;
        if (q && !j) {
            var r = d;
            if (k >= 0 && k < r.i$b.count) {
                k = r.i$b._inner[k];
            }
            if (l >= 0 && k < r.i$b.count) {
                l = r.i$b._inner[l];
            }
        }
        var s = m / (n + m);
        if (m == 0) {
            s = 0;
        }
        if (n == 0) {
            s = 1;
        }
        if (!h) {
            if (n <= m) {
                if (l >= 0 && l < b.count) {
                    return b.item(l);
                }
            }
            else {
                if (k >= 0 && k < b.count) {
                    return b.item(k);
                }
            }
            return NaN;
        }
        return a.ec(s, b, k, l, o, p, f, q);
    };
    SeriesInteractionManager.prototype.a$d = function (a, b, c) {
        var d = a.ai(b);
        var e = a.ah(b);
        if (d == null) {
            return false;
        }
        for (var f = 0; f < d.length; f++) {
            var g = d[f];
            if (g == null || g.length != 2) {
                continue;
            }
            if (GeometryUtil.a(b, g[0], g[1], a.ev / 2 + a.eb(c))) {
                return true;
            }
            if (e != null && f < e.length) {
                var h = e[f];
                if (h == null || h.length != 2) {
                    continue;
                }
                if (GeometryUtil.a(b, h[0], h[1], a.ev / 2 + a.eb(c))) {
                    return true;
                }
                if (GeometryUtil.a(b, g[0], h[0], a.ev / 2 + a.eb(c))) {
                    return true;
                }
                if (GeometryUtil.a(b, g[1], h[1], a.ev / 2 + a.eb(c))) {
                    return true;
                }
                var i = new Array(5);
                i[0] = h[0];
                i[1] = h[1];
                i[2] = g[1];
                i[3] = g[0];
                i[4] = h[0];
                if (PolygonUtil.a(boxArray$1(i), b)) {
                    return true;
                }
            }
        }
        return false;
    };
    SeriesInteractionManager.prototype.a$e = function (a, b, c, d) {
        if (d == null) {
            return false;
        }
        for (var e = 0; e < d.b.count; e++) {
            var f = d.b._inner[e];
            for (var g = 0; g < f._segments.count; g++) {
                var h = f._segments._inner[g];
                if (GeometryUtil.b(b, f._startPoint, h._points, a.eb(c))) {
                    return true;
                }
            }
        }
        return false;
    };
    SeriesInteractionManager.prototype.a$f = function (a, b, c) {
        if (c.b.count > 0) {
            var d = c.b._inner[0];
            if (d._segments.count > 0) {
                var e = d._segments._inner[0];
                if (PolygonUtil.a(e._points, b)) {
                    return true;
                }
            }
        }
        return false;
    };
    SeriesInteractionManager.prototype.a$m = function (a, b, c, d, e, f) {
        var g = a.du;
        var h = d.cc;
        var i = null;
        if (h) {
            i = d;
        }
        var j = -1;
        var k = -1;
        var l = -1;
        if (h) {
            j = e(b);
            if (isNaN_(j)) {
                return -1;
            }
            k = truncate(Math.floor(j));
            l = truncate(Math.ceil(j));
        }
        else {
            j = a.d8(b);
            if (isNaN_(j)) {
                return -1;
            }
            k = truncate(Math.floor(j));
            l = truncate(Math.ceil(j));
        }
        if (f == null) {
            return -1;
        }
        if (l < 0 || l > f.count - 1) {
            return -1;
        }
        if (!c) {
            return l;
        }
        var m = NaN;
        if (h && !g) {
            if (l < i.i$b.count && i.i$b._inner[l] < f.count) {
                m = f.item(i.i$b._inner[l]);
            }
        }
        else {
            m = f.item(l);
        }
        while (isNaN_(m)) {
            l++;
            if (l < 0 || l > f.count - 1) {
                return -1;
            }
            if (h && !g) {
                m = f.item(i.i$b._inner[l]);
            }
            else {
                m = f.item(l);
            }
        }
        return l;
    };
    SeriesInteractionManager.prototype.a$j = function (a, b, c) {
        var d = a.bi.bs;
        var e = a.bi.br;
        if (d.isEmpty || e.isEmpty || c == null) {
            return -1;
        }
        var f = a.getEffectiveViewport1(a.bi);
        var g = null;
        if (c.cc) {
            g = c;
        }
        var h = new ScalerParams(0, d, e, c.b8, f);
        if (a.bs == null) {
            return -1;
        }
        h.c = a.getEffectiveViewport1(a.bi);
        var i = a.lj(a.bi);
        var j = 0;
        if (c.ce) {
            var k = c.dw(i.top, h);
            var l = c.dw(i.bottom, h);
            var m = (b.y - d.top) / d.height;
            j = k + ((l - k) * m);
        }
        else {
            if (c.b3) {
                var n = c.dw(i.left, h);
                var o = c.dw(i.right, h);
                var p = (b.x - d.left) / d.width;
                j = n + ((o - n) * p);
            }
            else {
                var q = new Rect(0, 0, 0, 1, 1);
                j = c.dw(b.x, new ScalerParams(1, q, q, c.b8));
            }
        }
        if (c.b5) {
        }
        var r = g.i$c(j);
        return r;
    };
    SeriesInteractionManager.prototype.a$g = function (a, b, c) {
        var d = a.lo(b);
        if (d.isEmpty) {
            return false;
        }
        var e = RectUtil.r(d, a.eb(c));
        return e.containsPoint(b);
    };
    SeriesInteractionManager.prototype.a$aj = function (a, b, c, d, e, f, g, h, i, j) {
        if (f == null || g == null || a.bi == null || a.bi.bs.isEmpty || a.bi.br.isEmpty) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var k = a.getEffectiveViewport1(a.bi);
        var l = new ScalerParams(0, a.bi.bs, a.bi.br, f.b8, k);
        if (f.ce) {
            l.b = a.ee();
        }
        l.c = a.getEffectiveViewport1(a.bi);
        var m = a.bi;
        var n;
        if (g.ce) {
            n = b.y;
            n = m.br.top + m.br.height * (n - m.bs.top) / m.bs.height;
        }
        else {
            n = b.x;
            n = m.br.left + m.br.width * (n - m.bs.left) / m.bs.width;
        }
        if (!c && g != null) {
            var o = void 0;
            var p = void 0;
            if (i != null) {
                o = i(b, d);
            }
            else {
                o = a.fb(b, d);
            }
            if (j != null) {
                p = j(b, d);
            }
            else {
                p = a.e9(b, d);
            }
            if (o == -1 && p == -1) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            var q = new ScalerParams(0, m.bs, m.br, g.b8, k);
            q.c = a.bs.m3;
            var r = a.d6(b, o, g, q, e);
            var s = a.d6(b, p, g, q, e);
            var t = p;
            var u = o;
            if (g.cc) {
                var v = g;
                if (t >= 0 && t < v.i$b.count) {
                    t = v.i$d(v.i$b._inner[truncate(t)]);
                }
                if (u >= 0 && u < v.i$b.count) {
                    u = v.i$d(v.i$b._inner[truncate(u)]);
                }
            }
            if ((s + r) != 0) {
                var w = s / (r + s);
                if (Math.abs(w - 0.5) < 1E-07) {
                    s = r;
                }
            }
            if (s <= r) {
                n = g.dt(t, q) + e;
            }
            else {
                n = g.dt(u, q) + e;
            }
        }
        else {
            if (g.b2 && !g.b5 && g.categoryMode != 0) {
                var x = 0.5 * g.getCategorySize(m.bs, m.br, a.getEffectiveViewport1(m));
                if (a.isVertical) {
                    x = x * -1;
                }
                if (g.b8) {
                    x = x * -1;
                }
                n -= x;
                n += e;
            }
        }
        var y;
        if (h != null) {
            y = h(b, c, d);
        }
        else {
            y = a.ek(b, c, d);
        }
        var z = f.dt(y, l);
        if (g.ce) {
            return { $type: Point_$type, x: z, y: n };
        }
        else {
            return { $type: Point_$type, x: n, y: z };
        }
    };
    SeriesInteractionManager.prototype.a$t = function (a, b, c, d, e) {
        if (a.bs.c5() && !e) {
            return;
        }
        if (!a.b9) {
            return;
        }
        if (a.bs == null) {
            return;
        }
        var f = null;
        var g = null;
        var h = a.bs.az;
        var i = a.bs.bo;
        if (e && this.a != null) {
            f = this.a;
        }
        else {
            f = a.at(b, c);
            if (this.a != null && this.a != f) {
                if (a.bs != null) {
                    h.endHighlight(this.a);
                }
            }
            this.a = f;
        }
        if (a.hasMarkers) {
            if (e && this.b != null) {
                g = this.b;
            }
            else {
                g = a.au(b, c);
                if (this.b != null && this.b != g) {
                    h.endHighlight(this.b);
                }
                this.b = g;
            }
        }
        var j = true;
        if (e) {
            h.endHighlight(f);
            if (g != null) {
                h.endHighlight(g);
            }
        }
        else {
            if (d || !j) {
                h.startHighlight(f);
                if (g != null) {
                    h.startHighlight(g);
                }
            }
        }
        if (!i.f() && i.r > 0) {
            i.v();
        }
        if (i.r == 0) {
            a.bs.ke(1);
        }
    };
    SeriesInteractionManager.prototype.a$ai = function (a, b, c) {
        var d = b.d;
        d = d * 0.5;
        return this.r(c, d);
    };
    SeriesInteractionManager.prototype.r = function (a, b) {
        if (a == null) {
            return a;
        }
        return BrushUtil.h(a, b);
    };
    SeriesInteractionManager.prototype.a$w = function (a, b, c, d) {
        var e = a.bi;
        e.aj();
        this.a$c = true;
        var f = a.fq(c, b);
        this.a$o = f;
        if (a.bs != null && !a.aq.c) {
            this.q(a, b, f, d);
        }
        this.c = false;
        if (a.da && f == null) {
            this.c = true;
        }
        if (a.bs != null && !this.c) {
            if (a.da) {
                this.d = true;
            }
            this.a$t(a, f, a.lh(b), true, false);
            a.bs.it(a, f, d);
        }
    };
    SeriesInteractionManager.prototype.a$ag = function (a, b) {
        var c = null;
        var d = null;
        var e;
        var f = ((function () { var g = a.bs.bn.e(b, false, e, false); e = g.p2; return g.ret; })());
        if (f != a) {
            if (this.a$c) {
                this.a$x(a, b, null, null);
            }
            return;
        }
        c = e;
        if (!this.a$c) {
            this.a$w(a, b, c, d);
        }
        this.a$z(a, b, c, d);
    };
    SeriesInteractionManager.prototype.a$z = function (a, b, c, d) {
        this.a$c = true;
        var e = a.fq(c, b);
        this.q(a, b, e, d);
        if (e != null) {
            this.a$o = e;
        }
        if (a.bs != null && e != null && this.c) {
            this.c = false;
            this.d = true;
            this.a$t(a, e, a.lh(b), true, false);
            a.bs.it(a, e, d);
        }
        if (a.bs != null && (!a.da || e != null) && !this.c) {
            this.a$t(a, e, a.lh(b), true, false);
            a.bs.ix(a, e, d);
        }
        if (e == null && !this.c && a.da) {
            this.a$t(a, e, a.lh(b), false, true);
            a.bs.iu(a, this.a$o, d);
            this.d = false;
            this.c = true;
        }
    };
    SeriesInteractionManager.prototype.a$x = function (a, b, c, d) {
        a.bi.ak();
        this.a$c = false;
        var e = this.a$o;
        a.bi.am();
        if (a.bs != null && (this.d || !a.da)) {
            this.d = false;
            this.c = false;
            this.a$t(a, e, a.lh(b), false, true);
            a.bs.iu(a, e, d);
        }
    };
    SeriesInteractionManager.prototype.a$u = function (a, b, c, d) {
        this.i = true;
        if (a.bs != null) {
            a.bs.iv(a, a.fq(c, b), d);
        }
    };
    SeriesInteractionManager.prototype.a$y = function (a, b, c, d) {
        this.i = false;
        if (a.bs != null) {
            a.bs.iw(a, a.fq(c, b), d);
        }
    };
    SeriesInteractionManager.prototype.a$v = function (a, b, c, d) {
        if (a.bi.p) {
            return;
        }
        if (this.i) {
            this.a$y(a, b, c, d);
        }
        if (this.a$c) {
            this.a$x(a, b, c, d);
        }
    };
    SeriesInteractionManager.prototype.a$aa = function (a, b, c, d) {
        if (a.bs != null) {
            a.bs.iy(a, a.fq(c, b), d);
        }
    };
    SeriesInteractionManager.prototype.a$ab = function (a, b, c, d) {
        if (a.bs != null) {
            a.bs.iz(a, a.fq(c, b), d);
        }
    };
    Object.defineProperty(SeriesInteractionManager.prototype, "g", {
        get: function () {
            return this.c;
        },
        set: function (a) {
            this.c = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SeriesInteractionManager.prototype, "a$b", {
        get: function () {
            return this.d;
        },
        set: function (a) {
            this.d = a;
        },
        enumerable: true,
        configurable: true
    });
    SeriesInteractionManager.prototype.q = function (a, b, c, d) {
        var e = false;
        if (a.bs != null) {
            e = a.bs.cr;
        }
        if (e) {
            return;
        }
        if (a.bs == null || a.bs.ck) {
            return;
        }
        this.j = true;
        this.s = b;
        this.o = c;
        a.bi.d.item = c;
        a.bi.d.itemLabel = a.fo(c);
        var f = a.bs.mj();
        var pos_ = { $type: Point_$type, x: b.x + 15 + f.x, y: b.y + 15 + f.y };
        var context_ = a.bi.d;
        var g = false;
        if (this._toolTipObject != null) {
            g = (this._toolTipObject._inPointer);
            this._toolTipObject._inPointer = false;
        }
        if (this._toolTipObject != null) {
            if (this.f || g) {
                this.f = false;
                this._toolTipObject.remove();
                this._toolTipObject.setStyleProperty("position", "absolute");
                this._toolTipObject.addClass(a.bs.g0);
                a.bs.ha(this._toolTipObject);
                this._toolTipObject.hide();
            }
            if (this.e) {
                a.bs.ha(this._toolTipObject);
                this.e = false;
            }
            context_.hideOthers = true;
            if ((this._toolTipObject.updateToolTip && !this._toolTipObject.updateToolTip(context_))) {
                this.a$s(a);
            }
            var h = window.pageXOffset;
            var i = window.pageYOffset;
            var j = document.documentElement.clientWidth;
            var k = document.documentElement.clientHeight;
            var l = this._toolTipObject.outerWidthWithMargin();
            var m = this._toolTipObject.outerHeightWithMargin();
            var n = pos_.x;
            var o = pos_.y;
            var p = 5;
            var q = 30;
            if (l + n - h + p > j) {
                pos_.x -= q;
                pos_.x -= l;
            }
            if (m + o - i + p > k) {
                pos_.y -= q;
                pos_.y -= m;
            }
            this._toolTipObject.setOffset(pos_.x, pos_.y);
        }
    };
    SeriesInteractionManager.prototype.a$af = function (a, b, c) {
        this.j = true;
        var d = { $type: Point_$type, x: b.x + a.bi.br.left, y: b.y + a.bi.br.top };
        var e = a.fq(null, d);
        if (a.bi.d != null) {
            a.bi.d.series = a;
            a.bi.d.item = e;
        }
        var tooltip_ = this._toolTipObject;
        var context_ = a.bi.d;
        var f = false;
        if (this._toolTipObject != null) {
            f = (this._toolTipObject._inPointer);
            this._toolTipObject._inPointer = false;
        }
        if (context_ != null) {
            context_.hideOthers = false;
        }
        if ((!this.f || f) && tooltip_ != null) {
            this.f = true;
            tooltip_.remove();
            tooltip_.setStyleProperty("position", "relative");
            tooltip_.setStyleProperty("top", "");
            tooltip_.setStyleProperty("left", "");
            tooltip_.removeClass(a.bs.g0);
        }
        if (this._toolTipObject != null) {
            if (tooltip_.updateToolTip) {
                tooltip_.updateToolTip(context_);
            }
            ;
        }
        if (tooltip_ != null) {
            c(tooltip_);
        }
    };
    SeriesInteractionManager.prototype.a$p = function (a) {
        var b = "<div class='ui-chart-default-tooltip-content'><span";
        var c = this.a$q(a);
        if (!stringIsNullOrEmpty(c)) {
            b += " style='color:" + c + "'";
        }
        b += ">" + a.fs + "</span></div>";
        return b;
    };
    SeriesInteractionManager.prototype.h = function (a, b) {
        var c = a != null && Color.e(Nullable$1.toNullable(Color.$, a.color), Nullable$1.toNullable(Color.$, null));
        c = c && a.color.l > 0;
        c = c && Color.d(a.color, b);
        return !c;
    };
    SeriesInteractionManager.prototype.a$q = function (a) {
        var b = new Color();
        var c = a != null && a.bs != null && a.bs.bn != null && a.bs.bn.i != null ? a.bs.bn.i.af : null;
        c.startCSSQuery();
        b.colorString = c.getCssDefaultPropertyValue("ui-chart-pointer-tooltip", "background-color");
        c.endCSSQuery();
        if (!this.h(a.kx, b)) {
            return a.kx._fill;
        }
        if (!this.h(a.kw, b)) {
            return a.kw._fill;
        }
        return null;
    };
    SeriesInteractionManager.prototype.a$s = function (a) {
        if (this._toolTipObject != null && this.j) {
            this.j = false;
            var context_ = a.bi.d;
            if (this._toolTipObject.hideToolTip) {
                this._toolTipObject.hideToolTip(context_);
            }
            ;
        }
    };
    SeriesInteractionManager.prototype.a$ah = function (a, b) {
        var c = this._toolTipObject;
        this.p = null;
        this._toolTipObject = null;
        if (typeof b === 'string') {
            this.p = b;
        }
        else {
            this._toolTipObject = b;
            if (this._toolTipObject != null) {
                this._toolTipObject.setStyleProperty("position", "absolute");
                this._toolTipObject.setStyleProperty("top", "0px");
                this._toolTipObject.setStyleProperty("left", "0px");
                this._toolTipObject.setStyleProperty("z-index", "10000");
                this._toolTipObject.setStyleProperty("pointer-events", "none");
                var d = a.kx != null && Color.e(Nullable$1.toNullable(Color.$, a.kx.color), Nullable$1.toNullable(Color.$, null)) && a.kx.color.l > 0;
                if (d) {
                    this._toolTipObject.setStyleProperty("border-color", a.kx._fill);
                }
            }
            else {
                if (!this.e && c != null) {
                    a.bs.jz(c);
                    this.e = true;
                }
            }
        }
    };
    SeriesInteractionManager.prototype.a$ae = function (a) {
    };
    Object.defineProperty(SeriesInteractionManager.prototype, "a$h", {
        get: function () {
            return this.k;
        },
        enumerable: true,
        configurable: true
    });
    SeriesInteractionManager.prototype.a$r = function (a, b, c, d, e) {
        var _this = this;
        var f;
        if (!((function () { var g = _this.k.tryGetValue(d, f); f = g.p1; return g.ret; })())) {
            f = a.bg();
            f.n = true;
            f.m = true;
            if (a.bs != null) {
                f.a = a.bs.ag;
                a.bs.ag.l(f);
            }
            f.ap();
            f.aa = d;
            this.k.item(d, f);
        }
        f.s = e;
        f.br = b;
        f.bq = c;
    };
    SeriesInteractionManager.prototype.a$ad = function (a, b, c) {
        var _this = this;
        var d;
        var e = c;
        if (e == null) {
            e = a.bs;
        }
        if (((function () { var f = _this.k.tryGetValue(b, d); d = f.p1; return f.ret; })())) {
            if (e != null) {
                d.a = null;
                e.ag.r(d);
            }
            this.k.removeItem(b);
        }
    };
    SeriesInteractionManager.prototype.a$ac = function (a, b) {
        var e_1, _a;
        var c = new List$1(String_$type, 0);
        try {
            for (var _b = tslib_1.__values(fromEnum(this.k.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var d = _c.value;
                c.add(d);
            }
        }
        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; }
        }
        for (var e = 0; e < c.count; e++) {
            this.a$ad(a, c._inner[e], b);
        }
    };
    SeriesInteractionManager.$t = markType(SeriesInteractionManager, 'SeriesInteractionManager', Base.$, [ISeriesInteractionManager_$type]);
    return SeriesInteractionManager;
}(Base));
export { SeriesInteractionManager };
