/*
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 { RingSeriesBase } from "./RingSeriesBase";
import { RingCollection } from "./RingCollection";
import { DependencyProperty } from "igniteui-angular-core";
import { fromEnum, Number_$type, fromEn, markType, markDep } from "igniteui-angular-core";
import { Ring } from "./Ring";
import { ArcItem } from "./ArcItem";
import { List$1 } from "igniteui-angular-core";
import { IgQueue$1 } from "./IgQueue$1";
import { BrushCollection } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
/**
 * @hidden
 */
export class HierarchicalRingSeries extends RingSeriesBase {
    constructor() {
        super();
        this.dy = null;
        this.ab = HierarchicalRingSeries.$;
    }
    aq() {
        if (this.itemsSource == null) {
            return new RingCollection();
        }
        this.dy = this.dz(this.itemsSource);
        return this.dy;
    }
    cl(a, b, c, d) {
        super.cl(a, b, c, d);
        switch (b) {
            case RingSeriesBase.$$p[25]:
                let e = c;
                let f = d;
                let g = f - e;
                if (this.dy != null && this.dy.count > 0) {
                    for (let h = 0; h < this.dy.count; h++) {
                        let i = this.dy._inner[h];
                        for (let j of fromEnum(i.g)) {
                            j.k = j.k + g;
                        }
                    }
                }
                break;
            case RingSeriesBase.$$p[0]:
                this.cj();
                break;
            case HierarchicalRingSeries.$$p[0]:
                this.ck();
                break;
        }
        if (this.dy != null && this.as.e()) {
            let k = false;
            for (let l of fromEnum(this.dy)) {
                l.o();
                if (l.f()) {
                    k = true;
                }
            }
            if (k) {
                for (let m of fromEnum(this.dy)) {
                    m.c.as.l();
                }
            }
        }
    }
    ck() {
        if (this.at != null) {
            this.at.bx();
            this.at.b2();
        }
    }
    cj() {
        if (this.dy != null) {
            for (let a of fromEnum(this.dy)) {
                for (let b of fromEnum(a.g)) {
                    this.d4(b);
                }
            }
        }
    }
    cp() {
        if (this.dy != null && this.dy.count > 0) {
            let a = this.dy._inner[this.dy.count - 1];
            this.width = a.q.width;
            this.height = a.q.height;
            this.as.m(a.p.x, a.p.y);
        }
    }
    co() {
        for (let a = 0; a < this.dy.count; a++) {
            for (let b of fromEnum(this.dy._inner[a].ringControl.arcs.a)) {
                b.fg();
            }
        }
    }
    d1(obj_) {
        let memberPath_ = this.d2;
        if ((obj_[memberPath_] !== undefined)) {
            return (obj_[memberPath_]);
        }
        return null;
    }
    dz(a) {
        let b = new IgQueue$1(ArcItem.$);
        let c = new IgQueue$1(ArcItem.$);
        let d = ((() => {
            let $ret = new ArcItem();
            $ret.m = 0;
            $ret.h = a;
            $ret.n = this.b9;
            $ret.c = this.al;
            $ret.j = this.a2;
            return $ret;
        })());
        d.p(this.a4);
        let e = ((() => {
            let $ret = new ArcItem();
            $ret.m = -1;
            $ret.h = null;
            return $ret;
        })());
        c.h(d);
        b.h(e);
        let f = new RingCollection();
        let g = null;
        let h = -1;
        while (c.f > 0) {
            let i;
            let j = c.g(i);
            i = j.p0;
            let k;
            let l = b.g(k);
            k = l.p0;
            if (i == null) {
                continue;
            }
            let m = 0;
            for (let n of fromEnum(i.g)) {
                let o = this.d1(n.g);
                if ((o != null && this.d0(o) == false) || n.c) {
                    let p = ((() => {
                        let $ret = new ArcItem();
                        $ret.m = i.m + 1;
                        $ret.h = n.c ? ((() => {
                            let $ret = new List$1(Number_$type, 0);
                            $ret.add(0);
                            return $ret;
                        })()) : o;
                        $ret.l = m;
                        $ret.b = i;
                        $ret.n = this.b9;
                        $ret.e = n;
                        return $ret;
                    })());
                    p.p(this.a4);
                    c.h(p);
                    b.h(i);
                }
                m++;
            }
            let q = this.dx(i, k, h, g);
            if (q != g) {
                f.add(q);
                g = q;
            }
            h = i.m;
        }
        return f;
    }
    dx(a, b, c, d) {
        a.k = a.e == null ? this.a4 : a.e.e;
        a.i = a.e == null ? 360 : a.e.d;
        this.d4(a);
        if (a.m != c) {
            let e = ((() => {
                let $ret = new Ring();
                $ret.c = this;
                return $ret;
            })());
            e.g.add(a);
            a.d = e;
            return e;
        }
        a.d = d;
        d.g.add(a);
        return d;
    }
    d0(a) {
        for (let b of fromEn(a)) {
            return false;
        }
        return true;
    }
    d4(a) {
        if (a.b == null) {
            a.a = this.ag;
        }
        else if (a.b.m == 0) {
            a.a = new BrushCollection();
            if (a.b.a != null) {
                a.a.add(a.b.a.item(a.l % a.b.a.count));
            }
        }
        else {
            a.a = a.b.a;
        }
    }
}
HierarchicalRingSeries.$t = markType(HierarchicalRingSeries, 'HierarchicalRingSeries', RingSeriesBase.$);
HierarchicalRingSeries.$$p = markDep(DependencyProperty, PropertyMetadata, HierarchicalRingSeries, 'cn', ['ChildrenMemberPath:d2:d5', [2]]);
//# sourceMappingURL=HierarchicalRingSeries.js.map