/*
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, markType } from "igniteui-angular-core";
import { Thickness } from "igniteui-angular-core";
import { isInfinity } from "igniteui-angular-core";
/**
 * @hidden
 */
export let CalloutViewHelper = /*@__PURE__*/ (() => {
    class CalloutViewHelper extends Base {
        static a(a, b, c, d, e, f, g, h) {
            let i = Math.sqrt((c - a) * (c - a) + (d - b) * (d - b));
            let j = (c - a) / i;
            let k = (d - b) / i;
            let l = a - e;
            let m = b - f;
            let n = g - e;
            let o = h - f;
            let p = -k;
            let q = j;
            let r = n * p + o * q;
            let s = n * m - o * l;
            let t = l * p + m * q;
            let u = s / r;
            let v = t / r;
            if (u >= 0 && v >= 0 && v <= 1) {
                return u;
            }
            return Number.POSITIVE_INFINITY;
        }
        static b(a, b, c, d) {
            let e = a.x;
            let f = a.y;
            let g = 0;
            let h = 0;
            let i = 0;
            let j = 0;
            let k = 0;
            let l = 0;
            if (e < 0) {
                g = -e;
                k = g;
                e = 0;
            }
            if (f < 0) {
                h = -f;
                l = h;
                f = 0;
            }
            if (e > b) {
                i = e - b;
            }
            if (f > c) {
                j = f - c;
            }
            let m = new Thickness(1, g, h, i, j);
            let n = CalloutViewHelper.a(e, f, k + b / 2, l + c / 2, k, l, k, l + c);
            let o = CalloutViewHelper.a(e, f, k + b / 2, l + c / 2, k, l, k + b, l);
            let p = CalloutViewHelper.a(e, f, k + b / 2, l + c / 2, k, l + c, k + b, l + c);
            let q = CalloutViewHelper.a(e, f, k + b / 2, l + c / 2, k + b, l, k + b, l + c);
            let r = Math.min(n, Math.min(o, Math.min(p, q)));
            let s = 0;
            let t = 0;
            if (isInfinity(r)) {
                s = e;
                t = f;
            }
            else {
                let u = k + b / 2;
                let v = l + c / 2;
                let w = e;
                let x = f;
                let y = Math.sqrt((u - w) * (u - w) + (v - x) * (v - x));
                let z = (u - w) / y;
                let aa = (v - x) / y;
                s = w + z * r;
                t = x + aa * r;
            }
            d.ak = e;
            d.am = f;
            d.al = s;
            d.an = t;
            return m;
        }
    }
    CalloutViewHelper.$t = markType(CalloutViewHelper, 'CalloutViewHelper');
    return CalloutViewHelper;
})();
