/*
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 { Base, markType, runOn, EnumUtil, typeCast, fromEnum, markDep } from "igniteui-angular-core";
import { IBucketizer_$type } from "./IBucketizer";
import { NotImplementedException } from "igniteui-angular-core";
import { CategoryAngleAxis } from "./CategoryAngleAxis";
import { NumericRadiusAxis } from "./NumericRadiusAxis";
import { truncate, intDivide, isNaN_ } from "igniteui-angular-core";
import { MarkerSeries } from "./MarkerSeries";
import { IHasCategoryModePreference_$type } from "./IHasCategoryModePreference";
import { SeriesRenderer$2 } from "./SeriesRenderer$2";
import { RadialFrame } from "./RadialFrame";
import { DependencyProperty } from "igniteui-angular-core";
import { HighlightingInfo } from "./HighlightingInfo";
import { RadialSeriesRenderManager } from "./RadialSeriesRenderManager";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { ScalerParams } from "./ScalerParams";
import { Marker } from "./Marker";
import { MarkerSeriesView } from "./MarkerSeriesView";
import { RadialAxes } from "./RadialAxes";
import { Visibility_$type } from "igniteui-angular-core";
import { SeriesRenderingArguments } from "./SeriesRenderingArguments";
import { PropertyMetadata } from "igniteui-angular-core";
import { round10N } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
/**
 * @hidden
 */
var RadialBucketCalculator = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(RadialBucketCalculator, _super);
    function RadialBucketCalculator(a) {
        var _this = _super.call(this) || this;
        _this.a = null;
        _this.c = 0;
        _this.d = 0;
        _this.b = 0;
        _this.a = a;
        return _this;
    }
    RadialBucketCalculator.prototype.getBucket = function (a) {
        throw new NotImplementedException(0);
    };
    RadialBucketCalculator.prototype.getBucketWithoutUnknowns = function (a) {
        return this.getBucket(a);
    };
    RadialBucketCalculator.prototype.getErrorBucket = function (a, b) {
        return NaN;
    };
    RadialBucketCalculator.prototype.getBucketInfo = function (a, b, c, d) {
        a = this.c;
        b = this.d;
        c = this.b;
        d = this.a.cr.ft;
        return {
            p0: a,
            p1: b,
            p2: c,
            p3: d
        };
    };
    RadialBucketCalculator.prototype.e = function (a) {
        var b = this.a.bv;
        var c = this.a.bu;
        var d = this.a.cr.rk;
        if (b.isEmpty || c.isEmpty || d == null || this.a.cr.ck == null || this.a.cr.ck.count == 0) {
            this.b = 0;
            return;
        }
        var e = Math.floor(d.mw(c, b));
        var f = Math.ceil(d.mv(c, b));
        if (d.cg) {
            f = Math.ceil(d.mw(c, b));
            e = Math.floor(d.mv(c, b));
        }
        if (f < e) {
            f = d.le + f;
        }
        var g = this.a.cr.rr;
        var h = g != null ? g.nm : 0.75;
        var i = Math.min(c.width, c.height) * 0.5 * (h) * 2 * Math.PI;
        var j = Math.floor((f - e + 1) * a / i);
        this.b = truncate(Math.max(1, j));
        this.c = truncate(Math.max(0, Math.floor(e / this.b) - 1));
        this.d = truncate(Math.ceil(f / this.b));
    };
    RadialBucketCalculator.prototype.cacheValues = function () {
    };
    RadialBucketCalculator.prototype.unCacheValues = function () {
    };
    RadialBucketCalculator.$t = markType(RadialBucketCalculator, 'RadialBucketCalculator', Base.$, [IBucketizer_$type]);
    return RadialBucketCalculator;
}(Base));
export { RadialBucketCalculator };
/**
 * @hidden
 */
var RadialBase = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(RadialBase, _super);
    function RadialBase() {
        var _this = _super.call(this) || this;
        _this.ry = null;
        _this.rz = null;
        _this.r1 = false;
        _this.r0 = false;
        _this.rp = null;
        _this.rq = null;
        _this.assigningRadialStyle = null;
        _this.assigningRadialMarkerStyle = null;
        _this.rw = new RadialFrame(3);
        _this.rx = new RadialFrame(3);
        _this.ru = new RadialFrame(3);
        _this.rs = null;
        _this.ry = new RadialSeriesRenderManager();
        _this.rz = new SeriesRenderer$2(RadialFrame.$, RadialBaseView.$, 1, runOn(_this, _this.sm), runOn(_this, _this.sp), runOn(_this, _this.cv), runOn(_this, _this.mq), runOn(_this, _this.sl), function (a) { return _this.rt.cs.e(_this.ft); });
        return _this;
    }
    RadialBase.prototype.ly = function (a) {
        _super.prototype.ly.call(this, a);
        this.rt = a;
    };
    RadialBase.prototype.sl = function () {
        if (this.ce.g) {
            this.ce.t();
        }
    };
    Object.defineProperty(RadialBase.prototype, "categoryAxis", {
        get: function () {
            return this.rk;
        },
        enumerable: false,
        configurable: true
    });
    RadialBase.prototype.ar = function () {
        return this.rk;
    };
    RadialBase.prototype.rh = function (a, b) {
        return null;
    };
    RadialBase.prototype.c1 = function (a, b, c, d) {
        var _this = this;
        if (!this.hasMarkers) {
            return false;
        }
        var e = this.rk;
        var f = new ScalerParams(1, this.cd.sf, this.py, e.cg);
        f.c = this.getEffectiveViewport1(this.b0);
        var g = this.rr;
        var h = new ScalerParams(1, this.cd.sf, this.py, g.cg);
        h.c = this.getEffectiveViewport1(this.b0);
        a.clear();
        this.qb.cf(function (i) {
            if (i._visibility == 0) {
                var j = new SeriesPointOfInterest();
                var k = i.n;
                var l = i.o;
                if (k < _this.py.left || k > _this.py.right || l < _this.py.top || l > _this.py.bottom) {
                    return;
                }
                var m = void 0;
                var n = void 0;
                var o = _this.rs.g(k, l, _this.b0.bv, _this.b0.bu, m, n);
                m = o.p4;
                n = o.p5;
                j.b = m;
                j.c = n;
                if (b) {
                    if (c) {
                        j.d = _this.sg(j.c, d);
                    }
                    else {
                        var p = _this.go(i);
                        if (!isNaN_(p)) {
                            j.d = _this.sg(p, d);
                        }
                        else {
                            j.d = _this.sg(j.c, d);
                        }
                    }
                }
                else {
                    j.d = e.gc(i.ak);
                }
                j.a = i.content;
                a.add(j);
            }
        });
        return true;
    };
    RadialBase.prototype.sg = function (a, b) {
        if (b >= 0) {
            return round10N(a, b).toString();
        }
        else {
            return a.toString();
        }
    };
    RadialBase.prototype.get_ea = function () {
        return true;
    };
    RadialBase.prototype.get_dx = function () {
        return true;
    };
    RadialBase.prototype.rm = function (a, b, c) {
        var d = new HighlightingInfo();
        d.b = this;
        d.h = 0;
        d.g = this.ck.count - 1;
        d.d = true;
        if (c != null && c.h == d.h && c.g == d.g) {
            return c;
        }
        return d;
    };
    RadialBase.prototype.rn = function (a, b, c) {
        var d = this.rt.cs.c;
        var e = this.rt.cs.d;
        var f = this.rt.cs.b;
        var g = this.rv();
        var h = this.ck.count;
        var i = this.rk;
        var j = -1;
        var k = -1;
        var l = this.hd(b);
        j = truncate(Math.floor((intDivide(l, f)))) * f;
        k = j + (f - 1);
        if (c != null && c.h == j && c.g == k) {
            return c;
        }
        var m = new HighlightingInfo();
        m.b = this;
        m.h = j;
        m.g = k;
        return m;
    };
    RadialBase.prototype.ro = function (a, b, c) {
        var d = this.rt.cs.c;
        var e = this.rt.cs.d;
        var f = this.rt.cs.b;
        var g = this.rv();
        var h = this.ck.count;
        var i = this.rk;
        var j = -1;
        var k = -1;
        var l = this.hd(b);
        j = truncate(Math.floor((intDivide(l, f)))) * f;
        k = j + (f - 1);
        if (c != null && c.h == j && c.g == k) {
            return c;
        }
        var m = new HighlightingInfo();
        m.e = true;
        m.b = this;
        m.h = j;
        m.g = k;
        return m;
    };
    RadialBase.prototype.aw = function (a, b, c) {
        if (this.c2 && this.ef(this.bk) && !c) {
            var d = this.rn(a, b, this.rp);
            this.rp = d;
            return d;
        }
        else {
            var e = this.rm(a, b, this.rp);
            this.rp = e;
            return e;
        }
    };
    RadialBase.prototype.ax = function (a, b, c) {
        if (this.ef(this.bk) && !c) {
            var d = this.ro(a, b, this.rq);
            this.rq = d;
            return d;
        }
        else {
            var e = this.rm(a, b, this.rq);
            e.e = true;
            this.rq = e;
            return e;
        }
    };
    RadialBase.prototype.sa = function () {
        return (this.assigningRadialStyle != null && this.r1) || (this.bk != 1);
    };
    RadialBase.prototype.r9 = function () {
        return (this.assigningRadialMarkerStyle != null && this.r0) || (this.bk != 1);
    };
    RadialBase.prototype.so = function (a) {
        if (this.assigningRadialStyle != null && this.r1) {
            this.assigningRadialStyle(this, a);
        }
    };
    RadialBase.prototype.sn = function (a) {
        if (this.assigningRadialMarkerStyle != null && this.r0) {
            this.assigningRadialMarkerStyle(this, a);
        }
    };
    RadialBase.prototype.sc = function (a) {
        return a.cs.b;
    };
    RadialBase.prototype.sd = function (a) {
        return a.cs.c;
    };
    RadialBase.prototype.ag = function () {
        return [this.rk, this.rr];
    };
    RadialBase.prototype.m5 = function (a, b) {
        this.rt.cs.e(this.ft);
        this.mh(false);
    };
    RadialBase.prototype.m4 = function (a, b) {
        this.rt.cs.e(this.ft);
        this.mh(false);
    };
    RadialBase.prototype.l3 = function (a, b, c, d) {
        _super.prototype.l3.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                if (c != null && d == null) {
                    if (this.rk != null) {
                        this.rk.bz(this);
                    }
                    if (this.rr != null) {
                        this.rr.bz(this);
                    }
                }
                if (c == null && d != null) {
                    if (this.rk != null) {
                        this.rk.cs(this);
                    }
                    if (this.rr != null) {
                        this.rr.cs(this);
                    }
                }
                this.rt.cs.e(this.ft);
                this.mh(false);
                break;
            case RadialBase.$$p[0]:
                if (this.rk != null && this.rr != null) {
                    this.rs = new RadialAxes(this.rr, this.rk);
                }
                if (c != null) {
                    c.bz(this);
                }
                if (d != null) {
                    d.cs(this);
                }
                this.rt.cs.e(this.ft);
                this.mh(false);
                break;
            case RadialBase.$$p[4]:
                if (this.rk != null && this.rr != null) {
                    this.rs = new RadialAxes(this.rr, this.rk);
                }
                if (c != null) {
                    c.bz(this);
                }
                if (d != null) {
                    d.cs(this);
                }
                this.rt.cs.e(this.ft);
                if (this.rr == null || !this.rr.c0()) {
                    this.mh(false);
                }
                break;
            case "SyncLink":
                if (this.b8 != null && this.cd != null) {
                    this.rt.cs.e(this.ft);
                    this.mh(false);
                }
                break;
            case "TransitionProgress":
                this.rx.c(this.g0, this.rw, this.ru);
                if (this.cx(this.b0)) {
                    return;
                }
                if (this.g0 == 1) {
                    this.sp(this.ru, this.rt);
                }
                else {
                    this.sp(this.rx, this.rt);
                }
                if (this.cd != null) {
                    this.cd.nn(this);
                }
                break;
            case RadialBase.$$p[1]:
                this.mh(false);
                this.lo();
                break;
            case "VisibilityProxy":
                if (EnumUtil.getEnumValue(Visibility_$type, c) != 0 && EnumUtil.getEnumValue(Visibility_$type, d) == 0) {
                    this.rt.cs.e(this.ft);
                }
                break;
            case RadialBase.$$p[3]:
                this.r1 = this.r8();
                this.mh(false);
                break;
            case RadialBase.$$p[2]:
                this.r0 = this.r7();
                this.mh(false);
                break;
        }
    };
    RadialBase.prototype.r8 = function () {
        return this.r6;
    };
    RadialBase.prototype.r7 = function () {
        return this.r5;
    };
    RadialBase.prototype.r3 = function (a) {
        if (typeCast(NumericRadiusAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    RadialBase.prototype.r2 = function (a) {
        if (typeCast(CategoryAngleAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    RadialBase.prototype.ht = function (a) {
        var b = this.hd(a);
        return b >= 0 && this.ck != null && b < this.ck.count ? this.ck.item(b) : null;
    };
    RadialBase.prototype.sb = function (a) {
        var b = this.b0.bv;
        var c = this.b0.bu;
        if (this.rk != null && !b.isEmpty && !c.isEmpty && this.rs != null) {
            var d = this.rs.c(a);
            if (d < 0) {
                d += Math.PI * 2;
            }
            if (d > Math.PI * 2) {
                d -= Math.PI * 2;
            }
            return d;
        }
        return NaN;
    };
    RadialBase.prototype.f5 = function (a) {
        var b = this.b0.bv;
        var c = this.b0.bu;
        var d = -1;
        if (this.rk != null && !b.isEmpty && !c.isEmpty && this.rs != null) {
            var e = this.rs.c(a);
            if (e < 0) {
                e += Math.PI * 2;
            }
            if (e > Math.PI * 2) {
                e -= Math.PI * 2;
            }
            var f = this.rk.getUnscaledAngle(e);
            if (this.rk.categoryMode != 0) {
                f -= 0.5;
            }
            d = f;
        }
        return d;
    };
    RadialBase.prototype.hd = function (a) {
        var b = truncate(Math.round(this.f5(a)));
        if (this.ck != null && b == this.ck.count) {
            b = 0;
        }
        return b;
    };
    RadialBase.prototype.en = function (a) {
        return false;
    };
    RadialBase.prototype.rv = function () {
        var a = this.ru;
        if (this.cv()) {
            if (this.ce.g) {
                this.ce.t();
            }
            a = this.rx;
        }
        return a;
    };
    RadialBase.prototype.le = function () {
        _super.prototype.le.call(this);
        if (this.rk != null) {
            this.rk.h7(false);
        }
        if (this.rr != null) {
            this.rr.h7(false);
        }
    };
    RadialBase.prototype.e9 = function (a, b, c) {
        var d = true;
        var e = c;
        if (!_super.prototype.e9.call(this, a, b, c) || !c.o() || b.isEmpty || a.isEmpty || this.rk == null || this.rk.itemsSource == null || this.rr == null || this.rs == null || this.ck == null || this.rk.bh == null || this.rr.bh == null || this.rr.lv == this.rr.lu) {
            e.cs.b = 0;
            d = false;
        }
        return d;
    };
    RadialBase.prototype.mi = function (a) {
        var b;
        var c;
        var d = this.getViewInfo(c, b);
        c = d.p0;
        b = d.p1;
        if (!this.e9(c, b, this.b0)) {
            this.kx(true, this.b0);
            return;
        }
        var e = new SeriesRenderingArguments(this, c, b, a, this.es);
        var f = this.rz.g(e, this.rw, this.ru, this.rx, this.rt);
        this.rw = f.p1;
        this.ru = f.p2;
        this.rx = f.p3;
    };
    RadialBase.prototype.se = function () {
        var e_1, _a;
        var a = 0;
        try {
            for (var _b = __values(fromEnum(this.cd.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (b == this) {
                    return a;
                }
                var c = typeCast(RadialBase.$, b);
                if (c != null && c.rk == this.rk && c.preferredCategoryMode(c.rk) == 2) {
                    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 -1;
    };
    RadialBase.$t = markType(RadialBase, 'RadialBase', MarkerSeries.$, [IHasCategoryModePreference_$type]);
    RadialBase.$$p = markDep(DependencyProperty, PropertyMetadata, RadialBase, 'raisePropertyChanged', ['AngleAxis:rk:sq', [CategoryAngleAxis.$, null], 'ClipSeriesToBounds:r4:sr', [0, false], 'IsCustomRadialMarkerStyleAllowed:r5:ss', [0, false], 'IsCustomRadialStyleAllowed:r6:st', [0, false], 'ValueAxis:rr:su', [NumericRadiusAxis.$, null]]);
    return RadialBase;
}(MarkerSeries));
export { RadialBase };
/**
 * @hidden
 */
var RadialBaseView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(RadialBaseView, _super);
    function RadialBaseView(a) {
        var _this = _super.call(this, a) || this;
        _this.cs = null;
        _this.cr = null;
        _this.ct = null;
        _this.cu = 0;
        _this.cv = null;
        _this.cr = a;
        _this.ct = new Pool$1(Marker.$);
        _this.ci(_this.ct);
        return _this;
    }
    RadialBaseView.prototype.cf = function (a) {
        this.ct.c(a);
    };
    RadialBaseView.$t = markType(RadialBaseView, 'RadialBaseView', MarkerSeriesView.$);
    return RadialBaseView;
}(MarkerSeriesView));
export { RadialBaseView };
