/*
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, delegateCombine, EnumUtil, typeCast, fromEnum, markDep } from "igniteui-react-core";
import { IBucketizer_$type } from "./IBucketizer";
import { NotImplementedException } from "igniteui-react-core";
import { CategoryAngleAxis } from "./CategoryAngleAxis";
import { NumericRadiusAxis } from "./NumericRadiusAxis";
import { truncate, intDivide, isNaN_ } from "igniteui-react-core";
import { MarkerSeries } from "./MarkerSeries";
import { IHasCategoryModePreference_$type } from "./IHasCategoryModePreference";
import { SeriesRenderer$2 } from "./SeriesRenderer$2";
import { RadialFrame } from "./RadialFrame";
import { DependencyProperty } from "igniteui-react-core";
import { HighlightingInfo } from "igniteui-react-core";
import { RadialSeriesRenderManager } from "./RadialSeriesRenderManager";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { ScalerParams } from "./ScalerParams";
import { Marker } from "./Marker";
import { MarkerSeriesView } from "./MarkerSeriesView";
import { SeriesLayerPropertyOverlay } from "./SeriesLayerPropertyOverlay";
import { DoubleCollection } from "igniteui-react-core";
import { RadialAxes } from "./RadialAxes";
import { Visibility_$type } from "igniteui-react-core";
import { SeriesRenderingArguments } from "./SeriesRenderingArguments";
import { PropertyMetadata } from "igniteui-react-core";
import { round10N } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-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.cu.hk;
        return {
            p0: a,
            p1: b,
            p2: c,
            p3: d
        };
    };
    RadialBucketCalculator.prototype.e = function (a) {
        var b = this.a.by;
        var c = this.a.bx;
        var d = this.a.cu.vk;
        if (b.isEmpty || c.isEmpty || d == null || this.a.cu.c7 == null || this.a.cu.c7.count == 0) {
            this.b = 0;
            return;
        }
        var e = Math.floor(d.mz(c, b));
        var f = Math.ceil(d.my(c, b));
        if (d.ch) {
            f = Math.ceil(d.mz(c, b));
            e = Math.floor(d.my(c, b));
        }
        if (f < e) {
            f = d.lf + f;
        }
        var g = this.a.cu.vm;
        var h = g != null ? g.no : 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.vt = null;
        _this.vu = null;
        _this.v1 = false;
        _this.v0 = false;
        _this.vy = null;
        _this.vz = null;
        _this.assigningRadialStyle = null;
        _this.assigningRadialMarkerStyle = null;
        _this.vr = new RadialFrame(3);
        _this.vs = new RadialFrame(3);
        _this.vp = new RadialFrame(3);
        _this.vn = null;
        _this.vt = new RadialSeriesRenderManager();
        _this.vu = new SeriesRenderer$2(RadialFrame.$, RadialBaseView.$, 1, runOn(_this, _this.wn), runOn(_this, _this.wq), runOn(_this, _this.dk), runOn(_this, _this.p5), runOn(_this, _this.wm), function (a) { return _this.vo.cv.e(_this.hk); });
        return _this;
    }
    RadialBase.prototype.o2 = function (a) {
        _super.prototype.o2.call(this, a);
        this.vo = a;
    };
    RadialBase.prototype.wm = function () {
        if (this.cw.g) {
            this.cw.t();
        }
    };
    Object.defineProperty(RadialBase.prototype, "categoryAxis", {
        get: function () {
            return this.vk;
        },
        enumerable: false,
        configurable: true
    });
    RadialBase.prototype.as = function () {
        return this.vk;
    };
    RadialBase.prototype.vh = function (a, b) {
        return null;
    };
    RadialBase.prototype.dt = function (a, b, c, d) {
        var _this = this;
        if (!this.hasMarkers) {
            return false;
        }
        var e = this.vk;
        var f = new ScalerParams(1, this.cv.tr, this.ty, e.ch);
        f.c = this.getEffectiveViewport1(this.cg);
        var g = this.vm;
        var h = new ScalerParams(1, this.cv.tr, this.ty, g.ch);
        h.c = this.getEffectiveViewport1(this.cg);
        a.clear();
        this.ub.ci(function (i) {
            if (i._visibility == 0) {
                var j = new SeriesPointOfInterest();
                var k = i.n;
                var l = i.o;
                if (k < _this.ty.left || k > _this.ty.right || l < _this.ty.top || l > _this.ty.bottom) {
                    return;
                }
                var m = void 0;
                var n = void 0;
                var o = _this.vn.g(k, l, _this.cg.by, _this.cg.bx, m, n);
                m = o.p4;
                n = o.p5;
                j.b = m;
                j.c = n;
                if (b) {
                    if (c) {
                        j.d = _this.wh(j.c, d);
                    }
                    else {
                        var p = _this.ii(i);
                        if (!isNaN_(p)) {
                            j.d = _this.wh(p, d);
                        }
                        else {
                            j.d = _this.wh(j.c, d);
                        }
                    }
                }
                else {
                    j.d = e.gd(i.ak);
                }
                j.a = i.content;
                a.add(j);
            }
        });
        return true;
    };
    RadialBase.prototype.wh = function (a, b) {
        if (b >= 0) {
            return round10N(a, b).toString();
        }
        else {
            return a.toString();
        }
    };
    RadialBase.prototype.get_e7 = function () {
        return true;
    };
    RadialBase.prototype.get_et = function () {
        return true;
    };
    RadialBase.prototype.vv = function (a, b, c) {
        var d = new HighlightingInfo();
        d.i = this;
        d.g = 0;
        d.f = this.c7.count - 1;
        d.c = true;
        if (c != null && c.g == d.g && c.f == d.f) {
            return c;
        }
        return d;
    };
    RadialBase.prototype.wb = function () {
        return false;
    };
    RadialBase.prototype.g1 = function () {
        var a = _super.prototype.g1.call(this);
        if (this.wb()) {
            var b = ((function () {
                var $ret = new SeriesLayerPropertyOverlay();
                $ret.r = true;
                $ret.ad = "DashArray";
                $ret.p = true;
                $ret.x = ((function () {
                    var $ret = new DoubleCollection();
                    $ret.add(5);
                    $ret.add(5);
                    return $ret;
                })());
                $ret.q = true;
                return $ret;
            })());
            a.add(b);
        }
        if (!this.wb()) {
            var c = ((function () {
                var $ret = new SeriesLayerPropertyOverlay();
                $ret.r = true;
                $ret.ad = "Brush";
                $ret.p = true;
                $ret.y = "ActualBrush";
                $ret.q = true;
                return $ret;
            })());
            c.valueResolving = delegateCombine(c.valueResolving, runOn(this, this.pz));
            a.add(c);
        }
        if (!this.wb()) {
            var d = ((function () {
                var $ret = new SeriesLayerPropertyOverlay();
                $ret.r = true;
                $ret.ad = "Outline";
                $ret.p = true;
                $ret.y = "ActualOutline";
                $ret.q = true;
                return $ret;
            })());
            d.valueResolving = delegateCombine(d.valueResolving, runOn(this, this.pz));
            a.add(d);
        }
        return a;
    };
    RadialBase.prototype.vw = function (a, b, c) {
        var d = this.vo.cv.c;
        var e = this.vo.cv.d;
        var f = this.vo.cv.b;
        var g = this.vq();
        var h = this.c7.count;
        var i = this.vk;
        var j = -1;
        var k = -1;
        var l = this.i9(b);
        j = truncate(Math.floor((intDivide(l, f)))) * f;
        k = j + (f - 1);
        if (c != null && c.g == j && c.f == k) {
            return c;
        }
        var m = new HighlightingInfo();
        m.i = this;
        m.g = j;
        m.f = k;
        return m;
    };
    RadialBase.prototype.vx = function (a, b, c) {
        var d = this.vo.cv.c;
        var e = this.vo.cv.d;
        var f = this.vo.cv.b;
        var g = this.vq();
        var h = this.c7.count;
        var i = this.vk;
        var j = -1;
        var k = -1;
        var l = this.i9(b);
        j = truncate(Math.floor((intDivide(l, f)))) * f;
        k = j + (f - 1);
        if (c != null && c.g == j && c.f == k) {
            return c;
        }
        var m = new HighlightingInfo();
        m.d = true;
        m.i = this;
        m.g = j;
        m.f = k;
        return m;
    };
    RadialBase.prototype.c0 = function (a, b, c) {
        if (this.dv && this.fd(this.bp) && !c) {
            var d = this.vw(a, b, this.vy);
            this.vy = d;
            return d;
        }
        else {
            var e = this.vv(a, b, this.vy);
            this.vy = e;
            return e;
        }
    };
    RadialBase.prototype.c1 = function (a, b, c) {
        if (this.fd(this.bp) && !c) {
            var d = this.vx(a, b, this.vz);
            this.vz = d;
            return d;
        }
        else {
            var e = this.vv(a, b, this.vz);
            e.d = true;
            this.vz = e;
            return e;
        }
    };
    RadialBase.prototype.wa = function () {
        return (this.assigningRadialStyle != null && this.v1) || (this.bp != 1);
    };
    RadialBase.prototype.v9 = function () {
        return (this.assigningRadialMarkerStyle != null && this.v0) || (this.bp != 1);
    };
    RadialBase.prototype.wp = function (a) {
        if (this.assigningRadialStyle != null && this.v1) {
            this.assigningRadialStyle(this, a);
        }
    };
    RadialBase.prototype.wo = function (a) {
        if (this.assigningRadialMarkerStyle != null && this.v0) {
            this.assigningRadialMarkerStyle(this, a);
        }
    };
    RadialBase.prototype.wd = function (a) {
        return a.cv.b;
    };
    RadialBase.prototype.we = function (a) {
        return a.cv.c;
    };
    RadialBase.prototype.ag = function () {
        return [this.vk, this.vm];
    };
    RadialBase.prototype.qp = function (a, b) {
        this.vo.cv.e(this.hk);
        this.pr(false);
    };
    RadialBase.prototype.qo = function (a, b) {
        this.vo.cv.e(this.hk);
        this.pr(false);
    };
    RadialBase.prototype.pa = function (a, b, c, d) {
        _super.prototype.pa.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                if (c != null && d == null) {
                    if (this.vk != null) {
                        this.vk.b0(this);
                    }
                    if (this.vm != null) {
                        this.vm.b0(this);
                    }
                }
                if (c == null && d != null) {
                    if (this.vk != null) {
                        this.vk.ct(this);
                    }
                    if (this.vm != null) {
                        this.vm.ct(this);
                    }
                }
                this.vo.cv.e(this.hk);
                this.pr(false);
                break;
            case RadialBase.$$p[0]:
                if (this.vk != null && this.vm != null) {
                    this.vn = new RadialAxes(this.vm, this.vk);
                }
                if (c != null) {
                    c.b0(this);
                }
                if (d != null) {
                    d.ct(this);
                }
                this.vo.cv.e(this.hk);
                this.pr(false);
                break;
            case RadialBase.$$p[4]:
                if (this.vk != null && this.vm != null) {
                    this.vn = new RadialAxes(this.vm, this.vk);
                }
                if (c != null) {
                    c.b0(this);
                }
                if (d != null) {
                    d.ct(this);
                }
                this.vo.cv.e(this.hk);
                if (this.vm == null || !this.vm.c1()) {
                    this.pr(false);
                }
                break;
            case "SyncLink":
                if (this.co != null && this.cv != null) {
                    this.vo.cv.e(this.hk);
                    this.pr(false);
                }
                break;
            case "TransitionProgress":
                this.vs.c(this.iw, this.vr, this.vp);
                if (this.dm(this.cg)) {
                    return;
                }
                if (this.iw == 1) {
                    this.wq(this.vp, this.vo);
                    this.op();
                }
                else {
                    this.wq(this.vs, this.vo);
                }
                if (this.cv != null) {
                    this.cv.or(this);
                }
                break;
            case RadialBase.$$p[1]:
                this.pr(false);
                this.om();
                break;
            case "VisibilityProxy":
                if (EnumUtil.getEnumValue(Visibility_$type, c) != 0 && EnumUtil.getEnumValue(Visibility_$type, d) == 0) {
                    this.vo.cv.e(this.hk);
                }
                break;
            case RadialBase.$$p[3]:
                this.v1 = this.v8();
                this.pr(false);
                break;
            case RadialBase.$$p[2]:
                this.v0 = this.v7();
                this.pr(false);
                break;
        }
    };
    RadialBase.prototype.v8 = function () {
        return this.v6;
    };
    RadialBase.prototype.v7 = function () {
        return this.v5;
    };
    RadialBase.prototype.v3 = function (a) {
        if (typeCast(NumericRadiusAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    RadialBase.prototype.v2 = function (a) {
        if (typeCast(CategoryAngleAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    RadialBase.prototype.js = function (a) {
        var b = this.i9(a);
        return b >= 0 && this.c7 != null && b < this.c7.count ? this.c7.item(b) : null;
    };
    RadialBase.prototype.wc = function (a) {
        var b = this.cg.by;
        var c = this.cg.bx;
        if (this.vk != null && !b.isEmpty && !c.isEmpty && this.vn != null) {
            var d = this.vn.c(a);
            if (d < 0) {
                d += Math.PI * 2;
            }
            if (d > Math.PI * 2) {
                d -= Math.PI * 2;
            }
            return d;
        }
        return NaN;
    };
    RadialBase.prototype.hw = function (a) {
        var b = this.cg.by;
        var c = this.cg.bx;
        var d = -1;
        if (this.vk != null && !b.isEmpty && !c.isEmpty && this.vn != null) {
            var e = this.vn.c(a);
            if (e < 0) {
                e += Math.PI * 2;
            }
            if (e > Math.PI * 2) {
                e -= Math.PI * 2;
            }
            var f = this.vk.getUnscaledAngle(e);
            if (this.vk.categoryMode != 0) {
                f -= 0.5;
            }
            d = f;
        }
        return d;
    };
    RadialBase.prototype.i9 = function (a) {
        var b = truncate(Math.round(this.hw(a)));
        if (this.c7 != null && b == this.c7.count) {
            b = 0;
        }
        return b;
    };
    RadialBase.prototype.fp = function (a) {
        return false;
    };
    RadialBase.prototype.vq = function () {
        var a = this.vp;
        if (this.dk()) {
            if (this.cw.g) {
                this.cw.t();
            }
            a = this.vs;
        }
        return a;
    };
    RadialBase.prototype.oc = function () {
        _super.prototype.oc.call(this);
        if (this.vk != null) {
            this.vk.h8(false);
        }
        if (this.vm != null) {
            this.vm.h8(false);
        }
    };
    RadialBase.prototype.gm = function (a, b, c) {
        var d = true;
        var e = c;
        if (!_super.prototype.gm.call(this, a, b, c) || !c.o() || b.isEmpty || a.isEmpty || this.vk == null || this.vk.itemsSource == null || this.vm == null || this.vn == null || this.c7 == null || this.vk.bi == null || this.vm.bi == null || this.vm.lx == this.vm.lw) {
            e.cv.b = 0;
            d = false;
        }
        return d;
    };
    RadialBase.prototype.ps = function (a) {
        _super.prototype.ps.call(this, a);
        var b;
        var c;
        var d = this.getViewInfo(c, b);
        c = d.p0;
        b = d.p1;
        if (!this.gm(c, b, this.cg)) {
            this.nk(true, this.cg);
            return;
        }
        var e = new SeriesRenderingArguments(this, c, b, a, this.f1);
        var f = this.vu.g(e, this.vr, this.vp, this.vs, this.vo);
        this.vr = f.p1;
        this.vp = f.p2;
        this.vs = f.p3;
    };
    RadialBase.prototype.wf = function () {
        var e_1, _a;
        var a = 0;
        try {
            for (var _b = __values(fromEnum(this.cv.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (b == this || this.bf == b) {
                    return a;
                }
                var c = typeCast(RadialBase.$, b);
                if (c != null && c.vk == this.vk && c.preferredCategoryMode(c.vk) == 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:vk:wr', [CategoryAngleAxis.$, null], 'ClipSeriesToBounds:v4:ws', [0, false], 'IsCustomRadialMarkerStyleAllowed:v5:wt', [0, false], 'IsCustomRadialStyleAllowed:v6:wu', [0, false], 'ValueAxis:vm:wv', [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.cv = null;
        _this.cu = null;
        _this.cw = null;
        _this.cx = 0;
        _this.cy = null;
        _this.cu = a;
        _this.cw = new Pool$1(Marker.$);
        _this.cl(_this.cw);
        return _this;
    }
    RadialBaseView.prototype.ci = function (a) {
        this.cw.c(a);
    };
    RadialBaseView.$t = markType(RadialBaseView, 'RadialBaseView', MarkerSeriesView.$);
    return RadialBaseView;
}(MarkerSeriesView));
export { RadialBaseView };
