/*
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/ES5/type";
import { ViewportUtils } from "./ViewportUtils";
import { isNaN_ } from "igniteui-react-core/ES5/number";
var PolarAxes = /** @class */ (function (_super) {
    tslib_1.__extends(PolarAxes, _super);
    function PolarAxes(a, b) {
        var _this = _super.call(this) || this;
        _this.b = null;
        _this.a = null;
        _this.g = { $type: Point_$type, x: 0.5, y: 0.5 };
        _this.b = a;
        _this.a = b;
        return _this;
    }
    PolarAxes.prototype.c = function (a, b, c, d, e) {
        var f = this.g.x + (b * e(a));
        return ViewportUtils.c(f, c, d);
    };
    PolarAxes.prototype.h = function (a, b, c, d, e, f, g, h, i, j) {
        var k = this.a.getScaledAngle1(a, e, f);
        var l = this.b.li(b, g, h, i, j);
        var m = this.g.x;
        var n = this.g.y;
        var o = m + (l * Math.cos(k));
        var 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 };
    };
    PolarAxes.prototype.e = function (a, b, c, d, e, f, g, h) {
        var i = Math.min(b != null ? b.count : 0, c != null ? c.count : 0);
        a.clear();
        var j;
        var k;
        var l = this.g.x;
        var m = this.g.y;
        var n;
        var o;
        var p = Math.min(this.a.jw, this.a.jv);
        var q = Math.max(this.a.jw, this.a.jv);
        var r = Math.min(this.b.jv, this.b.jw);
        var s = Math.max(this.b.jv, this.b.jw);
        var t = this.a.jm;
        var u = this.a.b8;
        var v = this.b.jm;
        var w = this.b.b8;
        var x = this.b.lb;
        var y = this.b.la;
        for (var 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.li(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 });
            }
        }
    };
    PolarAxes.prototype.f = function (a, b, c, d, e, f) {
        var g = ViewportUtils.a(a, c, d);
        var h = ViewportUtils.e(b, c, d);
        var i = Math.sqrt(Math.pow(g - this.g.x, 2) + Math.pow(h - this.g.y, 2));
        var 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.lj(i);
        return {
            p4: e,
            p5: f
        };
    };
    PolarAxes.prototype.d = function (a, b, c, d, e) {
        var f = this.g.y + (b * e(a));
        return ViewportUtils.f(f, c, d);
    };
    PolarAxes.$t = markType(PolarAxes, 'PolarAxes');
    return PolarAxes;
}(Base));
export { PolarAxes };
