/*
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 } from "tslib";
import { Frame } from "./Frame";
import { Rect } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { Array_$type, Number_$type, Point_$type, typeCast, markType } from "igniteui-angular-core";
/**
 * @hidden
 */
var CategoryFrame = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CategoryFrame, _super);
    function CategoryFrame(a) {
        var _this = _super.call(this) || this;
        _this.ac = null;
        _this.h = new List$1(Array_$type, 0);
        _this.o = null;
        _this.m = new List$1(Number_$type, 0);
        _this.n = new List$1(Number_$type, 0);
        _this.p = new List$1(Point_$type, 0);
        _this.q = new List$1(Number_$type, 0);
        _this.s = new List$1(Point_$type, 0);
        _this.t = new List$1(Number_$type, 0);
        _this.k = new List$1(Point_$type, 0);
        _this.l = new List$1(Number_$type, 0);
        _this.j = new List$1(Number_$type, 0);
        _this.i = new List$1(Number_$type, 0);
        _this.r = new List$1(Number_$type, 0);
        _this.f = new List$1(List$1.$.specialize(Point_$type), 0);
        _this.g = new List$1(List$1.$.specialize(Number_$type), 0);
        _this.w = 0;
        _this.v = 0;
        _this.ad = null;
        _this.ac = new Rect(0, 0, 0, 1, 1);
        _this.v = a;
        _this.z();
        return _this;
    }
    CategoryFrame.prototype.c = function (a, b, c) {
        this.z();
        var d = typeCast(CategoryFrame.$, b);
        var e = typeCast(CategoryFrame.$, c);
        var f = d.h.count;
        var g = e.h.count;
        var h = Math.max(f, g);
        var i = Math.max(d.p.count, e.p.count);
        var j = Math.max(d.s.count, e.s.count);
        var k = Math.max(d.m.count, e.m.count);
        var l = Math.max(d.k.count, e.k.count);
        var m = d.r.count > 0;
        if (m) {
            this.aa(this.r, a, d.r, e.r, h);
        }
        var n = d.q.count > 0;
        if (n) {
            this.aa(this.q, a, d.q, e.q, i);
        }
        var o = d.t.count > 0;
        if (o) {
            this.aa(this.t, a, d.t, e.t, j);
        }
        var p = d.n.count > 0;
        if (p) {
            this.aa(this.n, a, d.n, e.n, k);
        }
        var q = d.l.count > 0;
        if (q) {
            this.aa(this.l, a, d.l, e.l, l);
        }
        if (this.h.count < h) {
            while (this.h.count < h) {
                this.h.add(new Array(this.v));
            }
        }
        if (this.h.count > h) {
            this.h.v(h, this.h.count - h);
        }
        if (m) {
            var r = 0;
            for (var s = 0; s < Math.min(f, g); ++s) {
                var t = this.h._inner[s];
                r = a * this.r._inner[s];
                r = r > 1 ? 1 : r;
                for (var u = 0; u < this.v; ++u) {
                    t[u] = d.h._inner[s][u] + r * (e.h._inner[s][u] - d.h._inner[s][u]);
                }
            }
        }
        else {
            for (var v = 0; v < Math.min(f, g); ++v) {
                var w = this.h._inner[v];
                for (var x = 0; x < this.v; ++x) {
                    w[x] = d.h._inner[v][x] + a * (e.h._inner[v][x] - d.h._inner[v][x]);
                }
            }
        }
        if (f < g) {
            var y = new Array(this.v);
            for (var z = this.v - 1; z >= 0; --z) {
                y[z] = d.h.count > 0 ? d.h._inner[d.h.count - 1][z] : 0;
            }
            if (m) {
                var aa = 0;
                for (var ab = f; ab < g; ++ab) {
                    var ac = this.h._inner[ab];
                    aa = a * this.r._inner[ab];
                    aa = aa > 1 ? 1 : aa;
                    for (var ad = this.v - 1; ad >= 0; --ad) {
                        ac[ad] = y[ad] + aa * (e.h._inner[ab][ad] - y[ad]);
                    }
                }
            }
            else {
                for (var ae = f; ae < g; ++ae) {
                    var af = this.h._inner[ae];
                    for (var ag = this.v - 1; ag >= 0; --ag) {
                        af[ag] = y[ag] + a * (e.h._inner[ae][ag] - y[ag]);
                    }
                }
            }
        }
        if (f > g) {
            var ah = new Array(this.v);
            for (var ai = this.v - 1; ai >= 0; --ai) {
                ah[ai] = e.h.count > 0 ? e.h._inner[e.h.count - 1][ai] : 0;
            }
            if (m) {
                var aj = 0;
                for (var ak = g; ak < f; ++ak) {
                    var al = this.h._inner[ak];
                    aj = a * this.r._inner[ak];
                    aj = aj > 1 ? 1 : aj;
                    for (var am = this.v - 1; am >= 0; --am) {
                        al[am] = d.h._inner[ak][am] + aj * (ah[am] - d.h._inner[ak][am]);
                    }
                }
            }
            else {
                for (var an = g; an < f; ++an) {
                    var ao = this.h._inner[an];
                    for (var ap = this.v - 1; ap >= 0; --ap) {
                        ao[ap] = d.h._inner[an][ap] + a * (ah[ap] - d.h._inner[an][ap]);
                    }
                }
            }
        }
        if (n) {
            Frame.d(this.p, a, d.p, e.p, this.q);
        }
        else {
            Frame.a(this.p, a, d.p, e.p);
        }
        if (o) {
            Frame.d(this.s, a, d.s, e.s, this.t);
        }
        else {
            Frame.a(this.s, a, d.s, e.s);
        }
        if (p) {
            Frame.d(this.k, a, d.k, e.k, this.n);
        }
        else {
            Frame.a(this.k, a, d.k, e.k);
        }
        if (q) {
            Frame.e(this.j, a, d.j, e.j, this.l);
            Frame.e(this.i, a, d.i, e.i, this.l);
        }
        else {
            Frame.b(this.j, a, d.j, e.j);
            Frame.b(this.i, a, d.i, e.i);
        }
        if (d.o != null || e.o != null) {
            if (this.o == null) {
                this.o = new List$1(Number_$type, 0);
            }
            if (d.o == null) {
                d.o = new List$1(Number_$type, 0);
            }
            if (e.o == null) {
                e.o = new List$1(Number_$type, 0);
            }
            if (m) {
                Frame.e(this.o, a, d.o, e.o, this.r);
                Frame.e(this.o, a, d.o, e.o, this.r);
            }
            else {
                Frame.b(this.o, a, d.o, e.o);
                Frame.b(this.o, a, d.o, e.o);
            }
        }
        var aq = d.ad;
        var ar = e.ad;
        if (Rect.l_op_Equality(aq, null)) {
            aq = this.ac;
        }
        if (Rect.l_op_Equality(ar, null)) {
            ar = this.ac;
        }
        var as = aq.left + (ar.left - aq.left) * a;
        var at = aq.top + (ar.top - aq.top) * a;
        var au = Math.max(0, aq.width + (ar.width - aq.width) * a);
        var av = Math.max(0, aq.height + (ar.height - aq.height) * a);
        this.ad = new Rect(0, as, at, au, av);
        var aw = Math.max(Math.max(d.f.count, e.f.count), this.f.count);
        for (var ax = 0; ax < aw; ax++) {
            var ay = null;
            if (this.f.count <= ax) {
                ay = new List$1(Point_$type, 0);
                this.f.add(ay);
            }
            else {
                ay = this.f._inner[ax];
            }
            var az = null;
            if (d.f.count <= ax) {
                az = new List$1(Point_$type, 0);
                d.f.add(az);
            }
            else {
                az = d.f._inner[ax];
            }
            var a0 = null;
            if (e.f.count <= ax) {
                a0 = new List$1(Point_$type, 0);
                e.f.add(a0);
            }
            else {
                a0 = e.f._inner[ax];
            }
            var a1 = null;
            if (this.g.count <= ax) {
                a1 = new List$1(Number_$type, 0);
                this.g.add(a1);
            }
            else {
                a1 = this.g._inner[ax];
            }
            var a2 = null;
            if (d.g.count <= ax) {
                a2 = new List$1(Number_$type, 0);
                d.g.add(a2);
            }
            else {
                a2 = d.g._inner[ax];
            }
            var a3 = null;
            if (e.g.count <= ax) {
                a3 = new List$1(Number_$type, 0);
                e.g.add(a3);
            }
            else {
                a3 = e.g._inner[ax];
            }
            var a4 = Math.max(az.count, a0.count);
            var a5 = a2.count > 0;
            if (a5) {
                this.aa(a1, a, a2, a3, a4);
            }
            if (a5) {
                Frame.d(ay, a, az, a0, a1);
            }
            else {
                Frame.a(ay, a, az, a0);
            }
        }
    };
    CategoryFrame.prototype.aa = function (a, b, c, d, e) {
        if (d.count == 0) {
            for (var f = 0; f < c.count; f++) {
                d.add(c._inner[f]);
            }
        }
        else {
            Frame.b(a, b, c, d);
        }
        if (a.count < e) {
            var g = a.count;
            for (var h = 0; h < e - g; h++) {
                a.add(1);
            }
        }
    };
    CategoryFrame.prototype.y = function () {
        this.r.clear();
        this.t.clear();
        this.q.clear();
        this.n.clear();
        this.l.clear();
        this.g.clear();
    };
    CategoryFrame.prototype.x = function () {
        this.z();
        this.y();
        this.ad = this.ac;
    };
    CategoryFrame.prototype.ab = function () {
        this.x();
        this.h.clear();
        this.k.clear();
        this.m.clear();
        this.p.clear();
        this.s.clear();
        if (this.o != null) {
            this.o.clear();
        }
        this.f.clear();
    };
    CategoryFrame.prototype.z = function () {
        CategoryFrame.u++;
        if (CategoryFrame.u >= (0x7FFFFFFF - 1)) {
            CategoryFrame.u = 0;
        }
        this.w = CategoryFrame.u;
    };
    CategoryFrame.$t = markType(CategoryFrame, 'CategoryFrame', Frame.$);
    CategoryFrame.u = 0;
    return CategoryFrame;
}(Frame));
export { CategoryFrame };
