/*
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 { Base, Point_$type, markType } from "igniteui-angular-core/ES2015/type";
import { IVerticalAnchoredCategorySeriesInteractionManager_$type } from "./IVerticalAnchoredCategorySeriesInteractionManager";
import { Rect } from "igniteui-angular-core/ES2015/Rect";
import { ScalerParams } from "./ScalerParams";
import { ArrayExtension } from "igniteui-angular-core/ES2015/ArrayExtension";
/**
 * @hidden
 */
export class VerticalAnchoredCategorySeriesInteractionManager extends Base {
    e$a(a, b) {
        let c = a.bs != null ? a.bs.mq : Rect.empty;
        let d = a.bi.br;
        let e = a.lp(a.bi);
        let f = a.getEffectiveViewport1(a.bi);
        let g = a.ap();
        let h = -1;
        if (g != null && !c.isEmpty && !d.isEmpty) {
            let i = new ScalerParams(0, c, d, g.b8, f);
            let j = g.dy(e.top, i);
            let k = g.dy(e.bottom, i);
            let l = (b.y - c.top) / c.height;
            let m = j + (l * (k - j));
            if (g.categoryMode != 0) {
                m -= 0.5;
            }
            h = m;
        }
        return h;
    }
    e$b(a, b, c, d) {
        let e = a.lf(c);
        let f = -1;
        let g = a.ap().b8;
        let h = a.bi.br.bottom * 2;
        if (g) {
            f = ArrayExtension.binarySearch$11(Point_$type, b, (i) => (h - e.y) < (h - i.y) ? -1 : ((h - e.y) > (h - i.y) ? 1 : 0));
        }
        else {
            f = ArrayExtension.binarySearch$11(Point_$type, b, (i) => 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;
        }
        let i = f;
        let j = f;
        if (i > 0) {
            i--;
        }
        if (j < b.count - 1) {
            j++;
        }
        let k = b._inner[i].y;
        let l = b._inner[f].y;
        let m = b._inner[j].y;
        let n = Math.abs(k - e.y);
        let o = Math.abs(l - e.y);
        let p = Math.abs(m - e.y);
        let q = d(i);
        let r = d(f);
        let s = d(j);
        let t = q.containsPoint(e);
        let u = r.containsPoint(e);
        let 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]);
//# sourceMappingURL=VerticalAnchoredCategorySeriesInteractionManager.js.map