/*
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 { __extends, __values } from "tslib";
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
 */
var HierarchicalRingSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(HierarchicalRingSeries, _super);
    function HierarchicalRingSeries() {
        var _this = _super.call(this) || this;
        _this.ep = null;
        _this.ab = HierarchicalRingSeries.$;
        return _this;
    }
    HierarchicalRingSeries.prototype.au = function () {
        if (this.itemsSource == null) {
            return new RingCollection();
        }
        this.ep = this.eq(this.itemsSource);
        return this.ep;
    };
    HierarchicalRingSeries.prototype.c4 = function (a, b, c, d) {
        var e_1, _a, e_2, _b, e_3, _c;
        _super.prototype.c4.call(this, a, b, c, d);
        switch (b) {
            case RingSeriesBase.$$p[33]:
                var e = c;
                var f = d;
                var g = f - e;
                if (this.ep != null && this.ep.count > 0) {
                    for (var h = 0; h < this.ep.count; h++) {
                        var i = this.ep._inner[h];
                        try {
                            for (var _d = (e_1 = void 0, __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.c2();
                break;
            case HierarchicalRingSeries.$$p[0]:
                this.c3();
                break;
        }
        if (this.ep != null && this.aw.e()) {
            var k = false;
            try {
                for (var _f = __values(fromEnum(this.ep)), _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 = __values(fromEnum(this.ep)), _j = _h.next(); !_j.done; _j = _h.next()) {
                        var m = _j.value;
                        m.c.aw.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.c3 = function () {
        if (this.ax != null) {
            this.ax.bx();
            this.ax.b2();
        }
    };
    HierarchicalRingSeries.prototype.c2 = function () {
        var e_4, _a, e_5, _b;
        if (this.ep != null) {
            try {
                for (var _c = __values(fromEnum(this.ep)), _d = _c.next(); !_d.done; _d = _c.next()) {
                    var a = _d.value;
                    try {
                        for (var _e = (e_5 = void 0, __values(fromEnum(a.g))), _f = _e.next(); !_f.done; _f = _e.next()) {
                            var b = _f.value;
                            this.ev(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.c8 = function () {
        if (this.ep != null && this.ep.count > 0) {
            var a = this.ep._inner[this.ep.count - 1];
            this.width = a.q.width;
            this.height = a.q.height;
            this.aw.m(a.p.x, a.p.y);
        }
    };
    HierarchicalRingSeries.prototype.c7 = function () {
        var e_6, _a;
        for (var a = 0; a < this.ep.count; a++) {
            try {
                for (var _b = (e_6 = void 0, __values(fromEnum(this.ep._inner[a].ringControl.arcs.a))), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var b = _c.value;
                    b.gv();
                }
            }
            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.es = function (obj_) {
        var memberPath_ = this.et;
        if ((obj_[memberPath_] !== undefined)) {
            return (obj_[memberPath_]);
        }
        return null;
    };
    HierarchicalRingSeries.prototype.eq = 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.cs;
            $ret.c = _this.ap;
            $ret.j = _this.a8;
            return $ret;
        })());
        d.p(this.ba);
        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.es(n.g);
                if ((o != null && this_1.er(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.cs;
                        $ret.e = n;
                        return $ret;
                    })());
                    p.p(this_1.ba);
                    c.h(p);
                    b.h(i);
                }
                m++;
            };
            try {
                for (var _b = (e_7 = void 0, __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.eo(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.eo = function (a, b, c, d) {
        var _this = this;
        a.k = a.e == null ? this.ba : a.e.e;
        a.i = a.e == null ? 360 : a.e.d;
        this.ev(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.er = function (a) {
        var e_8, _a;
        try {
            for (var _b = __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.ev = function (a) {
        if (a.b == null) {
            a.a = this.ak;
        }
        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, 'c6', ['ChildrenMemberPath:et:ew', [2]]);
    return HierarchicalRingSeries;
}(RingSeriesBase));
export { HierarchicalRingSeries };
