/*
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 { 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
 */
export let RadialBucketCalculator = /*@__PURE__*/ (() => {
    class RadialBucketCalculator extends Base {
        constructor(a) {
            super();
            this.a = null;
            this.c = 0;
            this.d = 0;
            this.b = 0;
            this.a = a;
        }
        getBucket(a) {
            throw new NotImplementedException(0);
        }
        getBucketWithoutUnknowns(a) {
            return this.getBucket(a);
        }
        getErrorBucket(a, b) {
            return NaN;
        }
        getBucketInfo(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
            };
        }
        e(a) {
            let b = this.a.by;
            let c = this.a.bx;
            let 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;
            }
            let e = Math.floor(d.mz(c, b));
            let 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;
            }
            let g = this.a.cu.vm;
            let h = g != null ? g.no : 0.75;
            let i = Math.min(c.width, c.height) * 0.5 * (h) * 2 * Math.PI;
            let 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));
        }
        cacheValues() {
        }
        unCacheValues() {
        }
    }
    RadialBucketCalculator.$t = /*@__PURE__*/ markType(RadialBucketCalculator, 'RadialBucketCalculator', Base.$, [IBucketizer_$type]);
    return RadialBucketCalculator;
})();
/**
 * @hidden
 */
export let RadialBase = /*@__PURE__*/ (() => {
    class RadialBase extends MarkerSeries {
        o2(a) {
            super.o2(a);
            this.vo = a;
        }
        constructor() {
            super();
            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), (a) => this.vo.cv.e(this.hk));
        }
        wm() {
            if (this.cw.g) {
                this.cw.t();
            }
        }
        get categoryAxis() {
            return this.vk;
        }
        as() {
            return this.vk;
        }
        vh(a, b) {
            return null;
        }
        dt(a, b, c, d) {
            if (!this.hasMarkers) {
                return false;
            }
            let e = this.vk;
            let f = new ScalerParams(1, this.cv.tr, this.ty, e.ch);
            f.c = this.getEffectiveViewport1(this.cg);
            let g = this.vm;
            let h = new ScalerParams(1, this.cv.tr, this.ty, g.ch);
            h.c = this.getEffectiveViewport1(this.cg);
            a.clear();
            this.ub.ci((i) => {
                if (i._visibility == 0) {
                    let j = new SeriesPointOfInterest();
                    let k = i.n;
                    let l = i.o;
                    if (k < this.ty.left || k > this.ty.right || l < this.ty.top || l > this.ty.bottom) {
                        return;
                    }
                    let m;
                    let n;
                    let 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 {
                            let 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;
        }
        wh(a, b) {
            if (b >= 0) {
                return round10N(a, b).toString();
            }
            else {
                return a.toString();
            }
        }
        get_e7() {
            return true;
        }
        get_et() {
            return true;
        }
        vv(a, b, c) {
            let 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;
        }
        wb() {
            return false;
        }
        g1() {
            let a = super.g1();
            if (this.wb()) {
                let b = ((() => {
                    let $ret = new SeriesLayerPropertyOverlay();
                    $ret.r = true;
                    $ret.ad = "DashArray";
                    $ret.p = true;
                    $ret.x = ((() => {
                        let $ret = new DoubleCollection();
                        $ret.add(5);
                        $ret.add(5);
                        return $ret;
                    })());
                    $ret.q = true;
                    return $ret;
                })());
                a.add(b);
            }
            if (!this.wb()) {
                let c = ((() => {
                    let $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()) {
                let d = ((() => {
                    let $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;
        }
        vw(a, b, c) {
            let d = this.vo.cv.c;
            let e = this.vo.cv.d;
            let f = this.vo.cv.b;
            let g = this.vq();
            let h = this.c7.count;
            let i = this.vk;
            let j = -1;
            let k = -1;
            let 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;
            }
            let m = new HighlightingInfo();
            m.i = this;
            m.g = j;
            m.f = k;
            return m;
        }
        vx(a, b, c) {
            let d = this.vo.cv.c;
            let e = this.vo.cv.d;
            let f = this.vo.cv.b;
            let g = this.vq();
            let h = this.c7.count;
            let i = this.vk;
            let j = -1;
            let k = -1;
            let 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;
            }
            let m = new HighlightingInfo();
            m.d = true;
            m.i = this;
            m.g = j;
            m.f = k;
            return m;
        }
        c0(a, b, c) {
            if (this.dv && this.fd(this.bp) && !c) {
                let d = this.vw(a, b, this.vy);
                this.vy = d;
                return d;
            }
            else {
                let e = this.vv(a, b, this.vy);
                this.vy = e;
                return e;
            }
        }
        c1(a, b, c) {
            if (this.fd(this.bp) && !c) {
                let d = this.vx(a, b, this.vz);
                this.vz = d;
                return d;
            }
            else {
                let e = this.vv(a, b, this.vz);
                e.d = true;
                this.vz = e;
                return e;
            }
        }
        wa() {
            return (this.assigningRadialStyle != null && this.v1) || (this.bp != 1);
        }
        v9() {
            return (this.assigningRadialMarkerStyle != null && this.v0) || (this.bp != 1);
        }
        wp(a) {
            if (this.assigningRadialStyle != null && this.v1) {
                this.assigningRadialStyle(this, a);
            }
        }
        wo(a) {
            if (this.assigningRadialMarkerStyle != null && this.v0) {
                this.assigningRadialMarkerStyle(this, a);
            }
        }
        wd(a) {
            return a.cv.b;
        }
        we(a) {
            return a.cv.c;
        }
        ag() {
            return [this.vk, this.vm];
        }
        qp(a, b) {
            this.vo.cv.e(this.hk);
            this.pr(false);
        }
        qo(a, b) {
            this.vo.cv.e(this.hk);
            this.pr(false);
        }
        pa(a, b, c, d) {
            super.pa(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;
            }
        }
        v8() {
            return this.v6;
        }
        v7() {
            return this.v5;
        }
        v3(a) {
            if (typeCast(NumericRadiusAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        v2(a) {
            if (typeCast(CategoryAngleAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        js(a) {
            let b = this.i9(a);
            return b >= 0 && this.c7 != null && b < this.c7.count ? this.c7.item(b) : null;
        }
        wc(a) {
            let b = this.cg.by;
            let c = this.cg.bx;
            if (this.vk != null && !b.isEmpty && !c.isEmpty && this.vn != null) {
                let 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;
        }
        hw(a) {
            let b = this.cg.by;
            let c = this.cg.bx;
            let d = -1;
            if (this.vk != null && !b.isEmpty && !c.isEmpty && this.vn != null) {
                let e = this.vn.c(a);
                if (e < 0) {
                    e += Math.PI * 2;
                }
                if (e > Math.PI * 2) {
                    e -= Math.PI * 2;
                }
                let f = this.vk.getUnscaledAngle(e);
                if (this.vk.categoryMode != 0) {
                    f -= 0.5;
                }
                d = f;
            }
            return d;
        }
        i9(a) {
            let b = truncate(Math.round(this.hw(a)));
            if (this.c7 != null && b == this.c7.count) {
                b = 0;
            }
            return b;
        }
        fp(a) {
            return false;
        }
        vq() {
            let a = this.vp;
            if (this.dk()) {
                if (this.cw.g) {
                    this.cw.t();
                }
                a = this.vs;
            }
            return a;
        }
        oc() {
            super.oc();
            if (this.vk != null) {
                this.vk.h8(false);
            }
            if (this.vm != null) {
                this.vm.h8(false);
            }
        }
        gm(a, b, c) {
            let d = true;
            let e = c;
            if (!super.gm(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;
        }
        ps(a) {
            super.ps(a);
            let b;
            let c;
            let d = this.getViewInfo(c, b);
            c = d.p0;
            b = d.p1;
            if (!this.gm(c, b, this.cg)) {
                this.nk(true, this.cg);
                return;
            }
            let e = new SeriesRenderingArguments(this, c, b, a, this.f1);
            let 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;
        }
        wf() {
            let a = 0;
            for (let b of fromEnum(this.cv.series)) {
                if (b == this || this.bf == b) {
                    return a;
                }
                let c = typeCast(RadialBase.$, b);
                if (c != null && c.vk == this.vk && c.preferredCategoryMode(c.vk) == 2) {
                    a++;
                }
            }
            return -1;
        }
    }
    RadialBase.$t = /*@__PURE__*/ markType(RadialBase, 'RadialBase', MarkerSeries.$, [IHasCategoryModePreference_$type]);
    RadialBase.$$p = /*@__PURE__*/ 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;
})();
/**
 * @hidden
 */
export let RadialBaseView = /*@__PURE__*/ (() => {
    class RadialBaseView extends MarkerSeriesView {
        constructor(a) {
            super(a);
            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);
        }
        ci(a) {
            this.cw.c(a);
        }
    }
    RadialBaseView.$t = /*@__PURE__*/ markType(RadialBaseView, 'RadialBaseView', MarkerSeriesView.$);
    return RadialBaseView;
})();
