/*
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-react-core/ES2015/DependencyProperty";
import { Type, fromEnum, Number_$type, fromEn, markType } from "igniteui-react-core/ES2015/type";
import { Ring } from "./Ring";
import { ArcItem } from "./ArcItem";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { IgQueue$1 } from "./IgQueue$1";
import { BrushCollection } from "igniteui-react-core/ES2015/BrushCollection";
import { PropertyMetadata } from "igniteui-react-core/ES2015/PropertyMetadata";
/**
 * @hidden
 */
export class HierarchicalRingSeries extends RingSeriesBase {
    constructor() {
        super();
        this.ds = null;
        this.ab = HierarchicalRingSeries.$;
    }
    aq() {
        if (this.itemsSource == null) {
            return new RingCollection();
        }
        this.ds = this.dt(this.itemsSource);
        return this.ds;
    }
    cj(a, b, c, d) {
        super.cj(a, b, c, d);
        switch (b) {
            case RingSeriesBase.$$p[23]:
                let e = c;
                let f = d;
                let g = f - e;
                if (this.ds != null && this.ds.count > 0) {
                    for (let h = 0; h < this.ds.count; h++) {
                        let i = this.ds._inner[h];
                        for (let j of fromEnum(i.g)) {
                            j.k = j.k + g;
                        }
                    }
                }
                break;
            case RingSeriesBase.$$p[0]:
                this.ch();
                break;
            case HierarchicalRingSeries.$$p[0]:
                this.ci();
                break;
        }
        if (this.ds != null && this.as.e()) {
            let k = false;
            for (let l of fromEnum(this.ds)) {
                l.o();
                if (l.f()) {
                    k = true;
                }
            }
            if (k) {
                for (let m of fromEnum(this.ds)) {
                    m.c.as.l();
                }
            }
        }
    }
    ci() {
        if (this.at != null) {
            this.at.bv();
            this.at.b0();
        }
    }
    ch() {
        if (this.ds != null) {
            for (let a of fromEnum(this.ds)) {
                for (let b of fromEnum(a.g)) {
                    this.dy(b);
                }
            }
        }
    }
    cn() {
        if (this.ds != null && this.ds.count > 0) {
            let a = this.ds._inner[this.ds.count - 1];
            this.width = a.q.width;
            this.height = a.q.height;
            this.as.m(a.p.x, a.p.y);
        }
    }
    cm() {
        for (let a = 0; a < this.ds.count; a++) {
            for (let b of fromEnum(this.ds._inner[a].ringControl.arcs.a)) {
                b.fe();
            }
        }
    }
    dv(obj_) {
        let memberPath_ = this.dw;
        if ((obj_[memberPath_] !== undefined)) {
            return (obj_[memberPath_]);
        }
        return null;
    }
    dt(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.b7;
            $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.dv(n.g);
                if ((o != null && this.du(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.b7;
                        $ret.e = n;
                        return $ret;
                    })());
                    p.p(this.a4);
                    c.h(p);
                    b.h(i);
                }
                m++;
            }
            let q = this.dr(i, k, h, g);
            if (q != g) {
                f.add(q);
                g = q;
            }
            h = i.m;
        }
        return f;
    }
    dr(a, b, c, d) {
        a.k = a.e == null ? this.a4 : a.e.e;
        a.i = a.e == null ? 360 : a.e.d;
        this.dy(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;
    }
    du(a) {
        for (let b of fromEn(a)) {
            return false;
        }
        return true;
    }
    dy(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.$);
Type.dep(DependencyProperty, PropertyMetadata, HierarchicalRingSeries, 'cl', ['ChildrenMemberPath:dw:dz', [2]]);
