/*
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 { IHorizontalAnchoredCategorySeriesInteractionManager_$type } from "./IHorizontalAnchoredCategorySeriesInteractionManager";
import { Base, Point_$type, markType } from "igniteui-react-core/ES5/type";
import { Rect } from "igniteui-react-core/ES5/Rect";
import { ArrayExtension } from "igniteui-react-core/ES5/ArrayExtension";
import { isNaN_ } from "igniteui-react-core/ES5/number";
var HorizontalAnchoredCategorySeriesInteractionManager = /** @class */ (function (_super) {
    tslib_1.__extends(HorizontalAnchoredCategorySeriesInteractionManager, _super);
    function HorizontalAnchoredCategorySeriesInteractionManager() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    HorizontalAnchoredCategorySeriesInteractionManager.prototype.d$a = function (a, b, c, d, e) {
        var f = a.aj(a.ap(), b, c, d, a.lc(e), true);
        if (f == null) {
            return null;
        }
        var g = f[0];
        var h = f[1];
        var i = new Array(1);
        var j = new Array(2);
        j[0] = { $type: Point_$type, x: g[0], y: g[2] };
        j[1] = { $type: Point_$type, x: h[0], y: h[2] };
        i[0] = j;
        return i;
    };
    HorizontalAnchoredCategorySeriesInteractionManager.prototype.d$b = function (a, b, c, d, e) {
        var f = a.aj(a.ap(), b, c, d, a.lc(e), true);
        if (f == null) {
            return null;
        }
        var g = f[0];
        var h = f[1];
        var i = new Array(1);
        var j = new Array(2);
        j[0] = { $type: Point_$type, x: g[0], y: g[1] };
        j[1] = { $type: Point_$type, x: h[0], y: h[1] };
        i[0] = j;
        return i;
    };
    HorizontalAnchoredCategorySeriesInteractionManager.prototype.d$d = function (a, b, c, d) {
        var e = a.k4(c);
        var f = -1;
        var g = a.ap();
        var h = g.b8;
        var i = a.bi.bp.right * 2;
        if (h) {
            f = ArrayExtension.binarySearch$11(Point_$type, b, function (j) { return (i - e.x) < (i - j.x) ? -1 : ((i - e.x) > (i - j.x) ? 1 : 0); });
        }
        else {
            f = ArrayExtension.binarySearch$11(Point_$type, b, function (j) { return e.x < j.x ? -1 : (e.x > j.x ? 1 : 0); });
        }
        if (f < 0) {
            f = ~f;
        }
        if (f < 0) {
            f = 0;
        }
        if (f > b.count - 1) {
            f = b.count - 1;
        }
        var j = f;
        var k = f;
        if (j > 0) {
            j--;
        }
        if (k < b.count - 1) {
            k++;
        }
        var l = b._inner[j].x;
        var m = b._inner[f].x;
        var n = b._inner[k].x;
        var o = Math.abs(l - e.x);
        var p = Math.abs(m - e.x);
        var q = Math.abs(n - e.x);
        var r = d(j);
        var s = d(f);
        var t = d(k);
        var u = r.containsPoint(e);
        var v = s.containsPoint(e);
        var w = t.containsPoint(e);
        if (p <= o && p <= q) {
            if (!h && w) {
                return t;
            }
            if (h && u) {
                return r;
            }
            return s;
        }
        if (o <= p && o <= q) {
            if (!h && v) {
                return s;
            }
            return d(j);
        }
        if (q <= p && q <= o) {
            if (h && v) {
                return s;
            }
            return d(k);
        }
        return Rect.empty;
    };
    HorizontalAnchoredCategorySeriesInteractionManager.prototype.d$c = function (a, b, c, d, e) {
        if (isNaN_(d.x) || isNaN_(d.y)) {
            return false;
        }
        var f = 0;
        if (b != null) {
            f = b.d8(b.j6);
        }
        if ((c.y >= f && c.y <= d.y) || (c.y <= f && c.y >= d.y)) {
            return true;
        }
        return false;
    };
    HorizontalAnchoredCategorySeriesInteractionManager.$t = markType(HorizontalAnchoredCategorySeriesInteractionManager, 'HorizontalAnchoredCategorySeriesInteractionManager', Base.$, [IHorizontalAnchoredCategorySeriesInteractionManager_$type]);
    return HorizontalAnchoredCategorySeriesInteractionManager;
}(Base));
export { HorizontalAnchoredCategorySeriesInteractionManager };
