/*
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, markType } from "igniteui-react-core";
import { IVerticalAnchoredCategorySeriesInteractionManager_$type } from "./IVerticalAnchoredCategorySeriesInteractionManager";
import { Rect } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { ArrayExtension } from "igniteui-react-core";
/**
 * @hidden
 */
var VerticalAnchoredCategorySeriesInteractionManager = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(VerticalAnchoredCategorySeriesInteractionManager, _super);
    function VerticalAnchoredCategorySeriesInteractionManager() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    VerticalAnchoredCategorySeriesInteractionManager.prototype.e$a = function (a, b) {
        var c = a.b6 != null ? a.b6.os : Rect.empty;
        var d = a.bs.bu;
        var e = a.ny(a.bs);
        var f = a.getEffectiveViewport1(a.bs);
        var g = a.aq();
        var h = -1;
        if (g != null && !c.isEmpty && !d.isEmpty) {
            var i = new ScalerParams(0, c, d, g.ca, f);
            var j = g.d2(e.top, i);
            var k = g.d2(e.bottom, i);
            var l = (b.y - c.top) / c.height;
            var m = j + (l * (k - j));
            if (g.categoryMode != 0) {
                m -= 0.5;
            }
            h = m;
        }
        return h;
    };
    VerticalAnchoredCategorySeriesInteractionManager.prototype.e$b = function (a, b, c, d) {
        if (b == null || b.count == 0) {
            return Rect.empty;
        }
        var e = a.no(c);
        var f = -1;
        var g = a.aq().ca;
        var h = a.bs.bu.bottom * 2;
        if (g) {
            f = ArrayExtension.binarySearch$11(Point_$type, b, function (i) { return (h - e.y) < (h - i.y) ? -1 : ((h - e.y) > (h - i.y) ? 1 : 0); });
        }
        else {
            f = ArrayExtension.binarySearch$11(Point_$type, b, function (i) { return e.y < i.y ? -1 : (e.y > i.y ? 1 : 0); });
        }
        if (f < 0) {
            f = ~f;
        }
        if (f < 0) {
            f = 0;
        }
        if (f > b.count - 1) {
            f = b.count - 1;
        }
        var i = f;
        var j = f;
        if (i > 0) {
            i--;
        }
        if (j < b.count - 1) {
            j++;
        }
        var k = b._inner[i].y;
        var l = b._inner[f].y;
        var m = b._inner[j].y;
        var n = Math.abs(k - e.y);
        var o = Math.abs(l - e.y);
        var p = Math.abs(m - e.y);
        var q = d(i);
        var r = d(f);
        var s = d(j);
        var t = q.containsPoint(e);
        var u = r.containsPoint(e);
        var v = s.containsPoint(e);
        if (o <= n && o <= p) {
            if (!g && v) {
                return s;
            }
            if (g && t) {
                return q;
            }
            return r;
        }
        if (n <= o && n <= p) {
            if (!g && u) {
                return r;
            }
            return d(i);
        }
        if (p <= o && p <= n) {
            if (g && u) {
                return r;
            }
            return d(j);
        }
        return Rect.empty;
    };
    VerticalAnchoredCategorySeriesInteractionManager.$t = markType(VerticalAnchoredCategorySeriesInteractionManager, 'VerticalAnchoredCategorySeriesInteractionManager', Base.$, [IVerticalAnchoredCategorySeriesInteractionManager_$type]);
    return VerticalAnchoredCategorySeriesInteractionManager;
}(Base));
export { VerticalAnchoredCategorySeriesInteractionManager };
//# sourceMappingURL=VerticalAnchoredCategorySeriesInteractionManager.js.map
