/*
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, 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
 */
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.cr.fx;
            return {
                p0: a,
                p1: b,
                p2: c,
                p3: d
            };
        }
        e(a) {
            let b = this.a.bv;
            let c = this.a.bu;
            let d = this.a.cr.rt;
            if (b.isEmpty || c.isEmpty || d == null || this.a.cr.cl == null || this.a.cr.cl.count == 0) {
                this.b = 0;
                return;
            }
            let e = Math.floor(d.mw(c, b));
            let 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;
            }
            let g = this.a.cr.r0;
            let h = g != null ? g.nn : 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 = markType(RadialBucketCalculator, 'RadialBucketCalculator', Base.$, [IBucketizer_$type]);
    return RadialBucketCalculator;
})();
/**
 * @hidden
 */
export let RadialBase = /*@__PURE__*/ (() => {
    class RadialBase extends MarkerSeries {
        constructor() {
            super();
            this.r7 = null;
            this.r8 = null;
            this.sa = false;
            this.r9 = false;
            this.ry = null;
            this.rz = null;
            this.assigningRadialStyle = null;
            this.assigningRadialMarkerStyle = null;
            this.r5 = new RadialFrame(3);
            this.r6 = new RadialFrame(3);
            this.r3 = new RadialFrame(3);
            this.r1 = null;
            this.r7 = new RadialSeriesRenderManager();
            this.r8 = new SeriesRenderer$2(RadialFrame.$, RadialBaseView.$, 1, runOn(this, this.sv), runOn(this, this.sy), runOn(this, this.cw), runOn(this, this.mw), runOn(this, this.su), (a) => this.r2.cs.e(this.fx));
        }
        l4(a) {
            super.l4(a);
            this.r2 = a;
        }
        su() {
            if (this.cf.g) {
                this.cf.t();
            }
        }
        get categoryAxis() {
            return this.rt;
        }
        as() {
            return this.rt;
        }
        rq(a, b) {
            return null;
        }
        c2(a, b, c, d) {
            if (!this.hasMarkers) {
                return false;
            }
            let e = this.rt;
            let f = new ScalerParams(1, this.ce.ta, this.p7, e.cg);
            f.c = this.getEffectiveViewport1(this.b1);
            let g = this.r0;
            let h = new ScalerParams(1, this.ce.ta, this.p7, g.cg);
            h.c = this.getEffectiveViewport1(this.b1);
            a.clear();
            this.qk.cf((i) => {
                if (i._visibility == 0) {
                    let j = new SeriesPointOfInterest();
                    let k = i.n;
                    let l = i.o;
                    if (k < this.p7.left || k > this.p7.right || l < this.p7.top || l > this.p7.bottom) {
                        return;
                    }
                    let m;
                    let n;
                    let o = this.r1.g(k, l, this.b1.bv, this.b1.bu, m, n);
                    m = o.p4;
                    n = o.p5;
                    j.b = m;
                    j.c = n;
                    if (b) {
                        if (c) {
                            j.d = this.sp(j.c, d);
                        }
                        else {
                            let p = this.gt(i);
                            if (!isNaN_(p)) {
                                j.d = this.sp(p, d);
                            }
                            else {
                                j.d = this.sp(j.c, d);
                            }
                        }
                    }
                    else {
                        j.d = e.gc(i.ak);
                    }
                    j.a = i.content;
                    a.add(j);
                }
            });
            return true;
        }
        sp(a, b) {
            if (b >= 0) {
                return round10N(a, b).toString();
            }
            else {
                return a.toString();
            }
        }
        get_ed() {
            return true;
        }
        get_d0() {
            return true;
        }
        rv(a, b, c) {
            let d = new HighlightingInfo();
            d.b = this;
            d.h = 0;
            d.g = this.cl.count - 1;
            d.d = true;
            if (c != null && c.h == d.h && c.g == d.g) {
                return c;
            }
            return d;
        }
        rw(a, b, c) {
            let d = this.r2.cs.c;
            let e = this.r2.cs.d;
            let f = this.r2.cs.b;
            let g = this.r4();
            let h = this.cl.count;
            let i = this.rt;
            let j = -1;
            let k = -1;
            let l = this.hi(b);
            j = truncate(Math.floor((intDivide(l, f)))) * f;
            k = j + (f - 1);
            if (c != null && c.h == j && c.g == k) {
                return c;
            }
            let m = new HighlightingInfo();
            m.b = this;
            m.h = j;
            m.g = k;
            return m;
        }
        rx(a, b, c) {
            let d = this.r2.cs.c;
            let e = this.r2.cs.d;
            let f = this.r2.cs.b;
            let g = this.r4();
            let h = this.cl.count;
            let i = this.rt;
            let j = -1;
            let k = -1;
            let l = this.hi(b);
            j = truncate(Math.floor((intDivide(l, f)))) * f;
            k = j + (f - 1);
            if (c != null && c.h == j && c.g == k) {
                return c;
            }
            let m = new HighlightingInfo();
            m.e = true;
            m.b = this;
            m.h = j;
            m.g = k;
            return m;
        }
        ax(a, b, c) {
            if (this.c3 && this.ei(this.bl) && !c) {
                let d = this.rw(a, b, this.ry);
                this.ry = d;
                return d;
            }
            else {
                let e = this.rv(a, b, this.ry);
                this.ry = e;
                return e;
            }
        }
        ay(a, b, c) {
            if (this.ei(this.bl) && !c) {
                let d = this.rx(a, b, this.rz);
                this.rz = d;
                return d;
            }
            else {
                let e = this.rv(a, b, this.rz);
                e.e = true;
                this.rz = e;
                return e;
            }
        }
        sj() {
            return (this.assigningRadialStyle != null && this.sa) || (this.bl != 1);
        }
        si() {
            return (this.assigningRadialMarkerStyle != null && this.r9) || (this.bl != 1);
        }
        sx(a) {
            if (this.assigningRadialStyle != null && this.sa) {
                this.assigningRadialStyle(this, a);
            }
        }
        sw(a) {
            if (this.assigningRadialMarkerStyle != null && this.r9) {
                this.assigningRadialMarkerStyle(this, a);
            }
        }
        sl(a) {
            return a.cs.b;
        }
        sm(a) {
            return a.cs.c;
        }
        ag() {
            return [this.rt, this.r0];
        }
        nb(a, b) {
            this.r2.cs.e(this.fx);
            this.mn(false);
        }
        na(a, b) {
            this.r2.cs.e(this.fx);
            this.mn(false);
        }
        l9(a, b, c, d) {
            super.l9(a, b, c, d);
            switch (b) {
                case "SeriesViewer":
                    if (c != null && d == null) {
                        if (this.rt != null) {
                            this.rt.bz(this);
                        }
                        if (this.r0 != null) {
                            this.r0.bz(this);
                        }
                    }
                    if (c == null && d != null) {
                        if (this.rt != null) {
                            this.rt.cs(this);
                        }
                        if (this.r0 != null) {
                            this.r0.cs(this);
                        }
                    }
                    this.r2.cs.e(this.fx);
                    this.mn(false);
                    break;
                case RadialBase.$$p[0]:
                    if (this.rt != null && this.r0 != null) {
                        this.r1 = new RadialAxes(this.r0, this.rt);
                    }
                    if (c != null) {
                        c.bz(this);
                    }
                    if (d != null) {
                        d.cs(this);
                    }
                    this.r2.cs.e(this.fx);
                    this.mn(false);
                    break;
                case RadialBase.$$p[4]:
                    if (this.rt != null && this.r0 != null) {
                        this.r1 = new RadialAxes(this.r0, this.rt);
                    }
                    if (c != null) {
                        c.bz(this);
                    }
                    if (d != null) {
                        d.cs(this);
                    }
                    this.r2.cs.e(this.fx);
                    if (this.r0 == null || !this.r0.c0()) {
                        this.mn(false);
                    }
                    break;
                case "SyncLink":
                    if (this.b9 != null && this.ce != null) {
                        this.r2.cs.e(this.fx);
                        this.mn(false);
                    }
                    break;
                case "TransitionProgress":
                    this.r6.c(this.g5, this.r5, this.r3);
                    if (this.cy(this.b1)) {
                        return;
                    }
                    if (this.g5 == 1) {
                        this.sy(this.r3, this.r2);
                    }
                    else {
                        this.sy(this.r6, this.r2);
                    }
                    if (this.ce != null) {
                        this.ce.ob(this);
                    }
                    break;
                case RadialBase.$$p[1]:
                    this.mn(false);
                    this.lu();
                    break;
                case "VisibilityProxy":
                    if (EnumUtil.getEnumValue(Visibility_$type, c) != 0 && EnumUtil.getEnumValue(Visibility_$type, d) == 0) {
                        this.r2.cs.e(this.fx);
                    }
                    break;
                case RadialBase.$$p[3]:
                    this.sa = this.sh();
                    this.mn(false);
                    break;
                case RadialBase.$$p[2]:
                    this.r9 = this.sg();
                    this.mn(false);
                    break;
            }
        }
        sh() {
            return this.sf;
        }
        sg() {
            return this.se;
        }
        sc(a) {
            if (typeCast(NumericRadiusAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        sb(a) {
            if (typeCast(CategoryAngleAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        hy(a) {
            let b = this.hi(a);
            return b >= 0 && this.cl != null && b < this.cl.count ? this.cl.item(b) : null;
        }
        sk(a) {
            let b = this.b1.bv;
            let c = this.b1.bu;
            if (this.rt != null && !b.isEmpty && !c.isEmpty && this.r1 != null) {
                let d = this.r1.c(a);
                if (d < 0) {
                    d += Math.PI * 2;
                }
                if (d > Math.PI * 2) {
                    d -= Math.PI * 2;
                }
                return d;
            }
            return NaN;
        }
        f9(a) {
            let b = this.b1.bv;
            let c = this.b1.bu;
            let d = -1;
            if (this.rt != null && !b.isEmpty && !c.isEmpty && this.r1 != null) {
                let e = this.r1.c(a);
                if (e < 0) {
                    e += Math.PI * 2;
                }
                if (e > Math.PI * 2) {
                    e -= Math.PI * 2;
                }
                let f = this.rt.getUnscaledAngle(e);
                if (this.rt.categoryMode != 0) {
                    f -= 0.5;
                }
                d = f;
            }
            return d;
        }
        hi(a) {
            let b = truncate(Math.round(this.f9(a)));
            if (this.cl != null && b == this.cl.count) {
                b = 0;
            }
            return b;
        }
        eq(a) {
            return false;
        }
        r4() {
            let a = this.r3;
            if (this.cw()) {
                if (this.cf.g) {
                    this.cf.t();
                }
                a = this.r6;
            }
            return a;
        }
        lk() {
            super.lk();
            if (this.rt != null) {
                this.rt.h7(false);
            }
            if (this.r0 != null) {
                this.r0.h7(false);
            }
        }
        fd(a, b, c) {
            let d = true;
            let e = c;
            if (!super.fd(a, b, c) || !c.o() || b.isEmpty || a.isEmpty || this.rt == null || this.rt.itemsSource == null || this.r0 == null || this.r1 == null || this.cl == null || this.rt.bh == null || this.r0.bh == null || this.r0.lw == this.r0.lv) {
                e.cs.b = 0;
                d = false;
            }
            return d;
        }
        mo(a) {
            let b;
            let c;
            let d = this.getViewInfo(c, b);
            c = d.p0;
            b = d.p1;
            if (!this.fd(c, b, this.b1)) {
                this.k2(true, this.b1);
                return;
            }
            let e = new SeriesRenderingArguments(this, c, b, a, this.ew);
            let f = this.r8.g(e, this.r5, this.r3, this.r6, this.r2);
            this.r5 = f.p1;
            this.r3 = f.p2;
            this.r6 = f.p3;
        }
        sn() {
            let a = 0;
            for (let b of fromEnum(this.ce.series)) {
                if (b == this) {
                    return a;
                }
                let c = typeCast(RadialBase.$, b);
                if (c != null && c.rt == this.rt && c.preferredCategoryMode(c.rt) == 2) {
                    a++;
                }
            }
            return -1;
        }
    }
    RadialBase.$t = markType(RadialBase, 'RadialBase', MarkerSeries.$, [IHasCategoryModePreference_$type]);
    RadialBase.$$p = markDep(DependencyProperty, PropertyMetadata, RadialBase, 'raisePropertyChanged', ['AngleAxis:rt:sz', [CategoryAngleAxis.$, null], 'ClipSeriesToBounds:sd:s0', [0, false], 'IsCustomRadialMarkerStyleAllowed:se:s1', [0, false], 'IsCustomRadialStyleAllowed:sf:s2', [0, false], 'ValueAxis:r0:s3', [NumericRadiusAxis.$, null]]);
    return RadialBase;
})();
/**
 * @hidden
 */
export let RadialBaseView = /*@__PURE__*/ (() => {
    class RadialBaseView extends MarkerSeriesView {
        constructor(a) {
            super(a);
            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);
        }
        cf(a) {
            this.ct.c(a);
        }
    }
    RadialBaseView.$t = markType(RadialBaseView, 'RadialBaseView', MarkerSeriesView.$);
    return RadialBaseView;
})();
