/*
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";
import { ViewportUtils } from "./ViewportUtils";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
export let PolarAxes = /*@__PURE__*/ (() => {
    class PolarAxes extends Base {
        constructor(a, b) {
            super();
            this.b = null;
            this.a = null;
            this.g = { $type: Point_$type, x: 0.5, y: 0.5 };
            this.b = a;
            this.a = b;
        }
        c(a, b, c, d, e) {
            let f = this.g.x + (b * e(a));
            return ViewportUtils.c(f, c, d);
        }
        h(a, b, c, d, e, f, g, h, i, j) {
            let k = this.a.getScaledAngle1(a, e, f);
            let l = this.b.nt(b, g, h, i, j);
            let m = this.g.x;
            let n = this.g.y;
            let o = m + (l * Math.cos(k));
            let p = n + (l * Math.sin(k));
            o = d.left + d.width * (o - c.left) / c.width;
            p = d.top + d.height * (p - c.top) / c.height;
            return { $type: Point_$type, x: o, y: p };
        }
        e(a, b, c, d, e, f, g, h) {
            let i = Math.min(b != null ? b.count : 0, c != null ? c.count : 0);
            a.clear();
            let j;
            let k;
            let l = this.g.x;
            let m = this.g.y;
            let n;
            let o;
            let p = Math.min(this.a.lv, this.a.lu);
            let q = Math.max(this.a.lv, this.a.lu);
            let r = Math.min(this.b.lu, this.b.lv);
            let s = Math.max(this.b.lu, this.b.lv);
            let t = this.a.lh;
            let u = this.a.cg;
            let v = this.b.lh;
            let w = this.b.cg;
            let x = this.b.nm;
            let y = this.b.nl;
            for (let z = 0; z < i; z++) {
                if ((b.item(z) <= q && b.item(z) >= p && c.item(z) <= s && c.item(z) >= r) || (isNaN_(b.item(z)) || isNaN_(c.item(z)))) {
                    j = this.a.getScaledAngle1(b.item(z), t, u);
                    k = this.b.nt(c.item(z), v, w, x, y);
                    n = l + (k * f(z, j));
                    o = m + (k * g(z, j));
                    n = e.left + e.width * (n - d.left) / d.width;
                    o = e.top + e.height * (o - d.top) / d.height;
                    a.add({ $type: Point_$type, x: n, y: o });
                }
                else {
                    a.add({ $type: Point_$type, x: NaN, y: NaN });
                }
            }
        }
        f(a, b, c, d, e, f) {
            let g = ViewportUtils.a(a, c, d);
            let h = ViewportUtils.e(b, c, d);
            let i = Math.sqrt(Math.pow(g - this.g.x, 2) + Math.pow(h - this.g.y, 2));
            let j = Math.acos((g - this.g.x) / i);
            if ((h - this.g.y) < 0) {
                j = (2 * Math.PI) - j;
            }
            e = this.a.getUnscaledAngle(j);
            f = this.b.nu(i);
            return {
                p4: e,
                p5: f
            };
        }
        d(a, b, c, d, e) {
            let f = this.g.y + (b * e(a));
            return ViewportUtils.f(f, c, d);
        }
    }
    PolarAxes.$t = markType(PolarAxes, 'PolarAxes');
    return PolarAxes;
})();
