/*
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 "./HighlightingInfo";
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.hj;
        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.vi;
        if (b.isEmpty || c.isEmpty || d == null || this.a.cu.c6 == null || this.a.cu.c6.count == 0) {
            this.b = 0;
            return;
        }
        var e = Math.floor(d.mx(c, b));
        var f = Math.ceil(d.mw(c, b));
        if (d.ch) {
            f = Math.ceil(d.mx(c, b));
            e = Math.floor(d.mw(c, b));
        }
        if (f < e) {
            f = d.lf + f;
        }
        var g = this.a.cu.vp;
        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.vw = null;
        _this.vx = null;
        _this.vz = false;
        _this.vy = false;
        _this.vn = null;
        _this.vo = null;
        _this.assigningRadialStyle = null;
        _this.assigningRadialMarkerStyle = null;
        _this.vu = new RadialFrame(3);
        _this.vv = new RadialFrame(3);
        _this.vs = new RadialFrame(3);
        _this.vq = null;
        _this.vw = new RadialSeriesRenderManager();
        _this.vx = new SeriesRenderer$2(RadialFrame.$, RadialBaseView.$, 1, runOn(_this, _this.wl), runOn(_this, _this.wo), runOn(_this, _this.dj), runOn(_this, _this.p3), runOn(_this, _this.wk), function (a) { return _this.vr.cv.e(_this.hj); });
        return _this;
    }
    RadialBase.prototype.o0 = function (a) {
        _super.prototype.o0.call(this, a);
        this.vr = a;
    };
    RadialBase.prototype.wk = function () {
        if (this.cz.g) {
            this.cz.t();
        }
    };
    Object.defineProperty(RadialBase.prototype, "categoryAxis", {
        get: function () {
            return this.vi;
        },
        enumerable: false,
        configurable: true
    });
    RadialBase.prototype.as = function () {
        return this.vi;
    };
    RadialBase.prototype.vf = function (a, b) {
        return null;
    };
    RadialBase.prototype.ds = function (a, b, c, d) {
        var _this = this;
        if (!this.hasMarkers) {
            return false;
        }
        var e = this.vi;
        var f = new ScalerParams(1, this.cy.tn, this.tw, e.ch);
        f.c = this.getEffectiveViewport1(this.cj);
        var g = this.vp;
        var h = new ScalerParams(1, this.cy.tn, this.tw, g.ch);
        h.c = this.getEffectiveViewport1(this.cj);
        a.clear();
        this.t9.ci(function (i) {
            if (i._visibility == 0) {
                var j = new SeriesPointOfInterest();
                var k = i.n;
                var l = i.o;
                if (k < _this.tw.left || k > _this.tw.right || l < _this.tw.top || l > _this.tw.bottom) {
                    return;
                }
                var m = void 0;
                var n = void 0;
                var o = _this.vq.g(k, l, _this.cj.by, _this.cj.bx, m, n);
                m = o.p4;
                n = o.p5;
                j.b = m;
                j.c = n;
                if (b) {
                    if (c) {
                        j.d = _this.wf(j.c, d);
                    }
                    else {
                        var p = _this.ih(i);
                        if (!isNaN_(p)) {
                            j.d = _this.wf(p, d);
                        }
                        else {
                            j.d = _this.wf(j.c, d);
                        }
                    }
                }
                else {
                    j.d = e.gd(i.ak);
                }
                j.a = i.content;
                a.add(j);
            }
        });
        return true;
    };
    RadialBase.prototype.wf = function (a, b) {
        if (b >= 0) {
            return round10N(a, b).toString();
        }
        else {
            return a.toString();
        }
    };
    RadialBase.prototype.get_e6 = function () {
        return true;
    };
    RadialBase.prototype.get_es = function () {
        return true;
    };
    RadialBase.prototype.vk = function (a, b, c) {
        var d = new HighlightingInfo();
        d.b = this;
        d.h = 0;
        d.g = this.c6.count - 1;
        d.d = true;
        if (c != null && c.h == d.h && c.g == d.g) {
            return c;
        }
        return d;
    };
    RadialBase.prototype.v9 = function () {
        return false;
    };
    RadialBase.prototype.g0 = function () {
        var a = _super.prototype.g0.call(this);
        if (this.v9()) {
            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.v9()) {
            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.px));
            a.add(c);
        }
        if (!this.v9()) {
            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.px));
            a.add(d);
        }
        return a;
    };
    RadialBase.prototype.vl = function (a, b, c) {
        var d = this.vr.cv.c;
        var e = this.vr.cv.d;
        var f = this.vr.cv.b;
        var g = this.vt();
        var h = this.c6.count;
        var i = this.vi;
        var j = -1;
        var k = -1;
        var l = this.i8(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.vm = function (a, b, c) {
        var d = this.vr.cv.c;
        var e = this.vr.cv.d;
        var f = this.vr.cv.b;
        var g = this.vt();
        var h = this.c6.count;
        var i = this.vi;
        var j = -1;
        var k = -1;
        var l = this.i8(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.ax = function (a, b, c) {
        if (this.du && this.fc(this.bs) && !c) {
            var d = this.vl(a, b, this.vn);
            this.vn = d;
            return d;
        }
        else {
            var e = this.vk(a, b, this.vn);
            this.vn = e;
            return e;
        }
    };
    RadialBase.prototype.ay = function (a, b, c) {
        if (this.fc(this.bs) && !c) {
            var d = this.vm(a, b, this.vo);
            this.vo = d;
            return d;
        }
        else {
            var e = this.vk(a, b, this.vo);
            e.e = true;
            this.vo = e;
            return e;
        }
    };
    RadialBase.prototype.v8 = function () {
        return (this.assigningRadialStyle != null && this.vz) || (this.bs != 1);
    };
    RadialBase.prototype.v7 = function () {
        return (this.assigningRadialMarkerStyle != null && this.vy) || (this.bs != 1);
    };
    RadialBase.prototype.wn = function (a) {
        if (this.assigningRadialStyle != null && this.vz) {
            this.assigningRadialStyle(this, a);
        }
    };
    RadialBase.prototype.wm = function (a) {
        if (this.assigningRadialMarkerStyle != null && this.vy) {
            this.assigningRadialMarkerStyle(this, a);
        }
    };
    RadialBase.prototype.wb = function (a) {
        return a.cv.b;
    };
    RadialBase.prototype.wc = function (a) {
        return a.cv.c;
    };
    RadialBase.prototype.ag = function () {
        return [this.vi, this.vp];
    };
    RadialBase.prototype.qn = function (a, b) {
        this.vr.cv.e(this.hj);
        this.pp(false);
    };
    RadialBase.prototype.qm = function (a, b) {
        this.vr.cv.e(this.hj);
        this.pp(false);
    };
    RadialBase.prototype.o8 = function (a, b, c, d) {
        _super.prototype.o8.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                if (c != null && d == null) {
                    if (this.vi != null) {
                        this.vi.b0(this);
                    }
                    if (this.vp != null) {
                        this.vp.b0(this);
                    }
                }
                if (c == null && d != null) {
                    if (this.vi != null) {
                        this.vi.ct(this);
                    }
                    if (this.vp != null) {
                        this.vp.ct(this);
                    }
                }
                this.vr.cv.e(this.hj);
                this.pp(false);
                break;
            case RadialBase.$$p[0]:
                if (this.vi != null && this.vp != null) {
                    this.vq = new RadialAxes(this.vp, this.vi);
                }
                if (c != null) {
                    c.b0(this);
                }
                if (d != null) {
                    d.ct(this);
                }
                this.vr.cv.e(this.hj);
                this.pp(false);
                break;
            case RadialBase.$$p[4]:
                if (this.vi != null && this.vp != null) {
                    this.vq = new RadialAxes(this.vp, this.vi);
                }
                if (c != null) {
                    c.b0(this);
                }
                if (d != null) {
                    d.ct(this);
                }
                this.vr.cv.e(this.hj);
                if (this.vp == null || !this.vp.c1()) {
                    this.pp(false);
                }
                break;
            case "SyncLink":
                if (this.cr != null && this.cy != null) {
                    this.vr.cv.e(this.hj);
                    this.pp(false);
                }
                break;
            case "TransitionProgress":
                this.vv.c(this.iv, this.vu, this.vs);
                if (this.dl(this.cj)) {
                    return;
                }
                if (this.iv == 1) {
                    this.wo(this.vs, this.vr);
                }
                else {
                    this.wo(this.vv, this.vr);
                }
                if (this.cy != null) {
                    this.cy.on(this);
                }
                break;
            case RadialBase.$$p[1]:
                this.pp(false);
                this.ol();
                break;
            case "VisibilityProxy":
                if (EnumUtil.getEnumValue(Visibility_$type, c) != 0 && EnumUtil.getEnumValue(Visibility_$type, d) == 0) {
                    this.vr.cv.e(this.hj);
                }
                break;
            case RadialBase.$$p[3]:
                this.vz = this.v6();
                this.pp(false);
                break;
            case RadialBase.$$p[2]:
                this.vy = this.v5();
                this.pp(false);
                break;
        }
    };
    RadialBase.prototype.v6 = function () {
        return this.v4;
    };
    RadialBase.prototype.v5 = function () {
        return this.v3;
    };
    RadialBase.prototype.v1 = function (a) {
        if (typeCast(NumericRadiusAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    RadialBase.prototype.v0 = function (a) {
        if (typeCast(CategoryAngleAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    RadialBase.prototype.jr = function (a) {
        var b = this.i8(a);
        return b >= 0 && this.c6 != null && b < this.c6.count ? this.c6.item(b) : null;
    };
    RadialBase.prototype.wa = function (a) {
        var b = this.cj.by;
        var c = this.cj.bx;
        if (this.vi != null && !b.isEmpty && !c.isEmpty && this.vq != null) {
            var d = this.vq.c(a);
            if (d < 0) {
                d += Math.PI * 2;
            }
            if (d > Math.PI * 2) {
                d -= Math.PI * 2;
            }
            return d;
        }
        return NaN;
    };
    RadialBase.prototype.hv = function (a) {
        var b = this.cj.by;
        var c = this.cj.bx;
        var d = -1;
        if (this.vi != null && !b.isEmpty && !c.isEmpty && this.vq != null) {
            var e = this.vq.c(a);
            if (e < 0) {
                e += Math.PI * 2;
            }
            if (e > Math.PI * 2) {
                e -= Math.PI * 2;
            }
            var f = this.vi.getUnscaledAngle(e);
            if (this.vi.categoryMode != 0) {
                f -= 0.5;
            }
            d = f;
        }
        return d;
    };
    RadialBase.prototype.i8 = function (a) {
        var b = truncate(Math.round(this.hv(a)));
        if (this.c6 != null && b == this.c6.count) {
            b = 0;
        }
        return b;
    };
    RadialBase.prototype.fo = function (a) {
        return false;
    };
    RadialBase.prototype.vt = function () {
        var a = this.vs;
        if (this.dj()) {
            if (this.cz.g) {
                this.cz.t();
            }
            a = this.vv;
        }
        return a;
    };
    RadialBase.prototype.ob = function () {
        _super.prototype.ob.call(this);
        if (this.vi != null) {
            this.vi.h8(false);
        }
        if (this.vp != null) {
            this.vp.h8(false);
        }
    };
    RadialBase.prototype.gl = function (a, b, c) {
        var d = true;
        var e = c;
        if (!_super.prototype.gl.call(this, a, b, c) || !c.o() || b.isEmpty || a.isEmpty || this.vi == null || this.vi.itemsSource == null || this.vp == null || this.vq == null || this.c6 == null || this.vi.bi == null || this.vp.bi == null || this.vp.lx == this.vp.lw) {
            e.cv.b = 0;
            d = false;
        }
        return d;
    };
    RadialBase.prototype.pq = function (a) {
        _super.prototype.pq.call(this, a);
        var b;
        var c;
        var d = this.getViewInfo(c, b);
        c = d.p0;
        b = d.p1;
        if (!this.gl(c, b, this.cj)) {
            this.nj(true, this.cj);
            return;
        }
        var e = new SeriesRenderingArguments(this, c, b, a, this.f0);
        var f = this.vx.g(e, this.vu, this.vs, this.vv, this.vr);
        this.vu = f.p1;
        this.vs = f.p2;
        this.vv = f.p3;
    };
    RadialBase.prototype.wd = function () {
        var e_1, _a;
        var a = 0;
        try {
            for (var _b = __values(fromEnum(this.cy.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (b == this || this.bi == b) {
                    return a;
                }
                var c = typeCast(RadialBase.$, b);
                if (c != null && c.vi == this.vi && c.preferredCategoryMode(c.vi) == 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:vi:wp', [CategoryAngleAxis.$, null], 'ClipSeriesToBounds:v2:wq', [0, false], 'IsCustomRadialMarkerStyleAllowed:v3:wr', [0, false], 'IsCustomRadialStyleAllowed:v4:ws', [0, false], 'ValueAxis:vp:wt', [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 };
