/*
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 { __extends, __values } from "tslib";
import { HorizontalAxisLabelPanelBase } from "./HorizontalAxisLabelPanelBase";
import { Number_$type, fromEnum, Boolean_$type, markType } from "igniteui-angular-core";
import { Size } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { HorizontalAxisLabelPanelBaseView } from "./HorizontalAxisLabelPanelBaseView";
import { TransformGroup } from "igniteui-angular-core";
import { RotateTransform } from "igniteui-angular-core";
import { TranslateTransform } from "igniteui-angular-core";
import { ViewportUtils } from "./ViewportUtils";
/**
 * @hidden
 */
var RadialAxisLabelPanel = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(RadialAxisLabelPanel, _super);
    function RadialAxisLabelPanel() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.dy = null;
        _this.dv = 0;
        _this.du = new List$1(Number_$type, 0);
        return _this;
    }
    RadialAxisLabelPanel.prototype.ae = function () {
        return new RadialAxisLabelPanelView(this);
    };
    RadialAxisLabelPanel.prototype.ch = function (a) {
        _super.prototype.ch.call(this, a);
        this.ds = a;
    };
    Object.defineProperty(RadialAxisLabelPanel.prototype, "dt", {
        get: function () {
            return !this.am;
        },
        enumerable: false,
        configurable: true
    });
    RadialAxisLabelPanel.prototype.dc = function () {
        return this.ao && (!this.av || this.bl() == -180);
    };
    RadialAxisLabelPanel.prototype.dd = function () {
        return !this.aw;
    };
    RadialAxisLabelPanel.prototype.b2 = function (a) {
        _super.prototype.b2.call(this, a);
        if (this.dv % 360 == 0 || this.am) {
            this.ds.a5();
        }
        else {
            this.ds.a4(a);
        }
    };
    RadialAxisLabelPanel.prototype.bl = function () {
        var a = _super.prototype.bl.call(this);
        if (this.dt) {
            a -= (this.dv * 180) / Math.PI;
        }
        return a;
    };
    RadialAxisLabelPanel.prototype.db = function () {
        return this.bl() % 360 != 0;
    };
    RadialAxisLabelPanel.prototype.da = function () {
        if (this.ad != null && this.ad.bi != null && this.ad.bi.ft) {
            return false;
        }
        if (this.am) {
            return true;
        }
        var a = this.dv * 180 / Math.PI;
        if (a < 30 || a > 330 || (a > 150 && a < 210)) {
            return true;
        }
        return false;
    };
    RadialAxisLabelPanel.prototype.cm = function (a, b) {
        var c = b * Math.PI / 180;
        var d = Math.abs(Math.sin(c));
        if (this.ad.az != null && this.ad.az.c == 4) {
            d = d * -1;
        }
        this.ds.a6(a, b, d);
    };
    RadialAxisLabelPanel.prototype.dx = function () {
        var e_1, _a;
        var a = 1.7976931348623157E+308;
        try {
            for (var _b = __values(fromEnum(this.ba)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                a = Math.min(b.c, a);
            }
        }
        catch (e_1_1) {
            e_1 = { error: e_1_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_1)
                    throw e_1.error;
            }
        }
        return a;
    };
    RadialAxisLabelPanel.prototype.dw = function () {
        var e_2, _a;
        var a = -1.7976931348623157E+308;
        try {
            for (var _b = __values(fromEnum(this.ba)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                a = Math.max(b.c, a);
            }
        }
        catch (e_2_1) {
            e_2 = { error: e_2_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_2)
                    throw e_2.error;
            }
        }
        return a;
    };
    RadialAxisLabelPanel.prototype.dq = function (a, b) {
        var c;
        if (this.ad.ch) {
            c = this.dx();
        }
        else {
            c = this.dw();
        }
        var d = new List$1(Number_$type, 0);
        var e = new List$1(Boolean_$type, 0);
        for (var f = 0; f < this.ba.count; f++) {
            var g = this.ba._inner[f];
            if (g.c == c && !g.a) {
                d.add(this.ba.indexOf(g));
            }
        }
        this.du = d;
        var h = new List$1(Rect.$, 0);
        for (var i = 0; i < a.count; i++) {
            var j = a._inner[i];
            var k = this.ba._inner[i].a;
            if (!this.du.contains(i)) {
                h.add(j);
                e.add(k);
            }
        }
        this.ao = this.an(h, e);
    };
    RadialAxisLabelPanel.prototype.at = function (a, b) {
        if (this.du.contains(a)) {
            return false;
        }
        else {
            return _super.prototype.at.call(this, a, b);
        }
    };
    RadialAxisLabelPanel.prototype.dr = function () {
        this.du = new List$1(Number_$type, 0);
        _super.prototype.dr.call(this);
    };
    RadialAxisLabelPanel.prototype.ai = function () {
        return 5;
    };
    RadialAxisLabelPanel.prototype.ay = function (a) {
        return a == 5 || a == 4 || a == 1 || a == 0;
    };
    RadialAxisLabelPanel.prototype.b9 = function () {
    };
    RadialAxisLabelPanel.$t = markType(RadialAxisLabelPanel, 'RadialAxisLabelPanel', HorizontalAxisLabelPanelBase.$);
    return RadialAxisLabelPanel;
}(HorizontalAxisLabelPanelBase));
export { RadialAxisLabelPanel };
/**
 * @hidden
 */
var RadialAxisLabelPanelView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(RadialAxisLabelPanelView, _super);
    function RadialAxisLabelPanelView(a) {
        var _this = _super.call(this, a) || this;
        _this.a3 = null;
        _this.a3 = a;
        return _this;
    }
    RadialAxisLabelPanelView.prototype.a6 = function (a, b, c) {
        var d = this.m(a);
        var e = this.l(a);
        var f = new TransformGroup();
        f.j.add(((function () {
            var $ret = new RotateTransform();
            $ret.j = b;
            $ret.k = d / 2;
            $ret.l = e / 2;
            return $ret;
        })()));
        f.j.add(((function () {
            var $ret = new TranslateTransform();
            $ret.j = d / -2;
            $ret.k = d / 2 * c;
            return $ret;
        })()));
        a.j = f;
    };
    RadialAxisLabelPanelView.prototype.a5 = function () {
        this.a.j = null;
    };
    RadialAxisLabelPanelView.prototype.a4 = function (a) {
        var _this = this;
        var b = ViewportUtils.i(0.5, this.a.c5, this.a.c4, this.a.ad != null ? this.a.ad.kc() : Rect.empty);
        this.a.j = ((function () {
            var $ret = new RotateTransform();
            $ret.j = (_this.a3.dv * 180) / Math.PI;
            $ret.k = _this.a3.dy.x;
            $ret.l = (_this.a3.dy.y * a.height) + b;
            return $ret;
        })());
    };
    RadialAxisLabelPanelView.prototype.am = function () {
        _super.prototype.am.call(this);
        this.a.c6(new Size(1, this.a.c1.width, this.a.c1.height));
    };
    RadialAxisLabelPanelView.$t = markType(RadialAxisLabelPanelView, 'RadialAxisLabelPanelView', HorizontalAxisLabelPanelBaseView.$);
    return RadialAxisLabelPanelView;
}(HorizontalAxisLabelPanelBaseView));
export { RadialAxisLabelPanelView };
