/*
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 * as tslib_1 from "tslib";
import { RingSeriesBase } from "./RingSeriesBase";
import { RingCollection } from "./RingCollection";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { Type, fromEnum, Number_$type, fromEn, markType } from "igniteui-react-core/ES5/type";
import { Ring } from "./Ring";
import { ArcItem } from "./ArcItem";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { IgQueue$1 } from "./IgQueue$1";
import { BrushCollection } from "igniteui-react-core/ES5/BrushCollection";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
/**
 * @hidden
 */
var HierarchicalRingSeries = /** @class */ (function (_super) {
    tslib_1.__extends(HierarchicalRingSeries, _super);
    function HierarchicalRingSeries() {
        var _this = _super.call(this) || this;
        _this.ds = null;
        _this.ab = HierarchicalRingSeries.$;
        return _this;
    }
    HierarchicalRingSeries.prototype.aq = function () {
        if (this.itemsSource == null) {
            return new RingCollection();
        }
        this.ds = this.dt(this.itemsSource);
        return this.ds;
    };
    HierarchicalRingSeries.prototype.cj = function (a, b, c, d) {
        var e_1, _a, e_2, _b, e_3, _c;
        _super.prototype.cj.call(this, a, b, c, d);
        switch (b) {
            case RingSeriesBase.$$p[23]:
                var e = c;
                var f = d;
                var g = f - e;
                if (this.ds != null && this.ds.count > 0) {
                    for (var h = 0; h < this.ds.count; h++) {
                        var i = this.ds._inner[h];
                        try {
                            for (var _d = tslib_1.__values(fromEnum(i.g)), _e = _d.next(); !_e.done; _e = _d.next()) {
                                var j = _e.value;
                                j.k = j.k + g;
                            }
                        }
                        catch (e_1_1) { e_1 = { error: e_1_1 }; }
                        finally {
                            try {
                                if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
                            }
                            finally { if (e_1) throw e_1.error; }
                        }
                    }
                }
                break;
            case RingSeriesBase.$$p[0]:
                this.ch();
                break;
            case HierarchicalRingSeries.$$p[0]:
                this.ci();
                break;
        }
        if (this.ds != null && this.as.e()) {
            var k = false;
            try {
                for (var _f = tslib_1.__values(fromEnum(this.ds)), _g = _f.next(); !_g.done; _g = _f.next()) {
                    var l = _g.value;
                    l.o();
                    if (l.f()) {
                        k = true;
                    }
                }
            }
            catch (e_2_1) { e_2 = { error: e_2_1 }; }
            finally {
                try {
                    if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
                }
                finally { if (e_2) throw e_2.error; }
            }
            if (k) {
                try {
                    for (var _h = tslib_1.__values(fromEnum(this.ds)), _j = _h.next(); !_j.done; _j = _h.next()) {
                        var m = _j.value;
                        m.c.as.l();
                    }
                }
                catch (e_3_1) { e_3 = { error: e_3_1 }; }
                finally {
                    try {
                        if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
                    }
                    finally { if (e_3) throw e_3.error; }
                }
            }
        }
    };
    HierarchicalRingSeries.prototype.ci = function () {
        if (this.at != null) {
            this.at.bv();
            this.at.b0();
        }
    };
    HierarchicalRingSeries.prototype.ch = function () {
        var e_4, _a, e_5, _b;
        if (this.ds != null) {
            try {
                for (var _c = tslib_1.__values(fromEnum(this.ds)), _d = _c.next(); !_d.done; _d = _c.next()) {
                    var a = _d.value;
                    try {
                        for (var _e = tslib_1.__values(fromEnum(a.g)), _f = _e.next(); !_f.done; _f = _e.next()) {
                            var b = _f.value;
                            this.dy(b);
                        }
                    }
                    catch (e_5_1) { e_5 = { error: e_5_1 }; }
                    finally {
                        try {
                            if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
                        }
                        finally { if (e_5) throw e_5.error; }
                    }
                }
            }
            catch (e_4_1) { e_4 = { error: e_4_1 }; }
            finally {
                try {
                    if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
                }
                finally { if (e_4) throw e_4.error; }
            }
        }
    };
    HierarchicalRingSeries.prototype.cn = function () {
        if (this.ds != null && this.ds.count > 0) {
            var 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);
        }
    };
    HierarchicalRingSeries.prototype.cm = function () {
        var e_6, _a;
        for (var a = 0; a < this.ds.count; a++) {
            try {
                for (var _b = tslib_1.__values(fromEnum(this.ds._inner[a].ringControl.arcs.a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var b = _c.value;
                    b.fe();
                }
            }
            catch (e_6_1) { e_6 = { error: e_6_1 }; }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
                }
                finally { if (e_6) throw e_6.error; }
            }
        }
    };
    HierarchicalRingSeries.prototype.dv = function (obj_) {
        var memberPath_ = this.dw;
        if ((obj_[memberPath_] !== undefined)) {
            return (obj_[memberPath_]);
        }
        return null;
    };
    HierarchicalRingSeries.prototype.dt = function (a) {
        var _this = this;
        var b = new IgQueue$1(ArcItem.$);
        var c = new IgQueue$1(ArcItem.$);
        var d = ((function () {
            var $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);
        var e = ((function () {
            var $ret = new ArcItem();
            $ret.m = -1;
            $ret.h = null;
            return $ret;
        })());
        c.h(d);
        b.h(e);
        var f = new RingCollection();
        var g = null;
        var h = -1;
        var _loop_1 = function () {
            var e_7, _a;
            var i;
            var j = c.g(i);
            i = j.p0;
            var k = void 0;
            var l = b.g(k);
            k = l.p0;
            if (i == null) {
                return "continue";
            }
            var m = 0;
            var _loop_2 = function (n) {
                var o = this_1.dv(n.g);
                if ((o != null && this_1.du(o) == false) || n.c) {
                    var p = ((function () {
                        var $ret = new ArcItem();
                        $ret.m = i.m + 1;
                        $ret.h = n.c ? ((function () {
                            var $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_1.a4);
                    c.h(p);
                    b.h(i);
                }
                m++;
            };
            try {
                for (var _b = tslib_1.__values(fromEnum(i.g)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var n = _c.value;
                    _loop_2(n);
                }
            }
            catch (e_7_1) { e_7 = { error: e_7_1 }; }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
                }
                finally { if (e_7) throw e_7.error; }
            }
            var q = this_1.dr(i, k, h, g);
            if (q != g) {
                f.add(q);
                g = q;
            }
            h = i.m;
        };
        var this_1 = this;
        while (c.f > 0) {
            _loop_1();
        }
        return f;
    };
    HierarchicalRingSeries.prototype.dr = function (a, b, c, d) {
        var _this = this;
        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) {
            var e = ((function () {
                var $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;
    };
    HierarchicalRingSeries.prototype.du = function (a) {
        var e_8, _a;
        try {
            for (var _b = tslib_1.__values(fromEn(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                return false;
            }
        }
        catch (e_8_1) { e_8 = { error: e_8_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_8) throw e_8.error; }
        }
        return true;
    };
    HierarchicalRingSeries.prototype.dy = function (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.$);
    return HierarchicalRingSeries;
}(RingSeriesBase));
export { HierarchicalRingSeries };
Type.dep(DependencyProperty, PropertyMetadata, HierarchicalRingSeries, 'cl', ['ChildrenMemberPath:dw:dz', [2]]);
