/*
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.z = null;
        _this.f = new List$1(Array_$type, 0);
        _this.k = new List$1(Number_$type, 0);
        _this.l = new List$1(Number_$type, 0);
        _this.m = new List$1(Point_$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.i = new List$1(Point_$type, 0);
        _this.j = new List$1(Number_$type, 0);
        _this.h = new List$1(Number_$type, 0);
        _this.g = new List$1(Number_$type, 0);
        _this.o = new List$1(Number_$type, 0);
        _this.t = 0;
        _this.s = 0;
        _this.aa = null;
        _this.z = new Rect(0, 0, 0, 1, 1);
        _this.s = a;
        _this.w();
        return _this;
    }
    CategoryFrame.prototype.c = function (a, b, c) {
        this.w();
        var d = typeCast(CategoryFrame.$, b);
        var e = typeCast(CategoryFrame.$, c);
        var f = d.f.count;
        var g = e.f.count;
        var h = Math.max(f, g);
        var i = Math.max(d.m.count, e.m.count);
        var j = Math.max(d.p.count, e.p.count);
        var k = Math.max(d.k.count, e.k.count);
        var l = Math.max(d.i.count, e.i.count);
        var m = d.o.count > 0;
        if (m) {
            this.x(this.o, a, d.o, e.o, h);
        }
        var n = d.n.count > 0;
        if (n) {
            this.x(this.n, a, d.n, e.n, i);
        }
        var o = d.q.count > 0;
        if (o) {
            this.x(this.q, a, d.q, e.q, j);
        }
        var p = d.l.count > 0;
        if (p) {
            this.x(this.l, a, d.l, e.l, k);
        }
        var q = d.j.count > 0;
        if (q) {
            this.x(this.j, a, d.j, e.j, l);
        }
        if (this.f.count < h) {
            while (this.f.count < h) {
                this.f.add(new Array(this.s));
            }
        }
        if (this.f.count > h) {
            this.f.v(h, this.f.count - h);
        }
        if (m) {
            var r = 0;
            for (var s = 0; s < Math.min(f, g); ++s) {
                var t = this.f._inner[s];
                r = a * this.o._inner[s];
                r = r > 1 ? 1 : r;
                for (var u = 0; u < this.s; ++u) {
                    t[u] = d.f._inner[s][u] + r * (e.f._inner[s][u] - d.f._inner[s][u]);
                }
            }
        }
        else {
            for (var v = 0; v < Math.min(f, g); ++v) {
                var w = this.f._inner[v];
                for (var x = 0; x < this.s; ++x) {
                    w[x] = d.f._inner[v][x] + a * (e.f._inner[v][x] - d.f._inner[v][x]);
                }
            }
        }
        if (f < g) {
            var y = new Array(this.s);
            for (var z = this.s - 1; z >= 0; --z) {
                y[z] = d.f.count > 0 ? d.f._inner[d.f.count - 1][z] : 0;
            }
            if (m) {
                var aa = 0;
                for (var ab = f; ab < g; ++ab) {
                    var ac = this.f._inner[ab];
                    aa = a * this.o._inner[ab];
                    aa = aa > 1 ? 1 : aa;
                    for (var ad = this.s - 1; ad >= 0; --ad) {
                        ac[ad] = y[ad] + aa * (e.f._inner[ab][ad] - y[ad]);
                    }
                }
            }
            else {
                for (var ae = f; ae < g; ++ae) {
                    var af = this.f._inner[ae];
                    for (var ag = this.s - 1; ag >= 0; --ag) {
                        af[ag] = y[ag] + a * (e.f._inner[ae][ag] - y[ag]);
                    }
                }
            }
        }
        if (f > g) {
            var ah = new Array(this.s);
            for (var ai = this.s - 1; ai >= 0; --ai) {
                ah[ai] = e.f.count > 0 ? e.f._inner[e.f.count - 1][ai] : 0;
            }
            if (m) {
                var aj = 0;
                for (var ak = g; ak < f; ++ak) {
                    var al = this.f._inner[ak];
                    aj = a * this.o._inner[ak];
                    aj = aj > 1 ? 1 : aj;
                    for (var am = this.s - 1; am >= 0; --am) {
                        al[am] = d.f._inner[ak][am] + aj * (ah[am] - d.f._inner[ak][am]);
                    }
                }
            }
            else {
                for (var an = g; an < f; ++an) {
                    var ao = this.f._inner[an];
                    for (var ap = this.s - 1; ap >= 0; --ap) {
                        ao[ap] = d.f._inner[an][ap] + a * (ah[ap] - d.f._inner[an][ap]);
                    }
                }
            }
        }
        if (n) {
            Frame.d(this.m, a, d.m, e.m, this.n);
        }
        else {
            Frame.a(this.m, a, d.m, e.m);
        }
        if (o) {
            Frame.d(this.p, a, d.p, e.p, this.q);
        }
        else {
            Frame.a(this.p, a, d.p, e.p);
        }
        if (p) {
            Frame.d(this.i, a, d.i, e.i, this.l);
        }
        else {
            Frame.a(this.i, a, d.i, e.i);
        }
        if (q) {
            Frame.e(this.h, a, d.h, e.h, this.j);
            Frame.e(this.g, a, d.g, e.g, this.j);
        }
        else {
            Frame.b(this.h, a, d.h, e.h);
            Frame.b(this.g, a, d.g, e.g);
        }
        var aq = d.aa;
        var ar = e.aa;
        if (Rect.l_op_Equality(aq, null)) {
            aq = this.z;
        }
        if (Rect.l_op_Equality(ar, null)) {
            ar = this.z;
        }
        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.aa = new Rect(0, as, at, au, av);
    };
    CategoryFrame.prototype.x = 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.v = function () {
        this.o.clear();
        this.q.clear();
        this.n.clear();
        this.l.clear();
        this.j.clear();
    };
    CategoryFrame.prototype.u = function () {
        this.w();
        this.v();
        this.aa = this.z;
    };
    CategoryFrame.prototype.y = function () {
        this.u();
        this.f.clear();
        this.i.clear();
        this.k.clear();
        this.m.clear();
        this.p.clear();
    };
    CategoryFrame.prototype.w = function () {
        CategoryFrame.r++;
        if (CategoryFrame.r >= (0x7FFFFFFF - 1)) {
            CategoryFrame.r = 0;
        }
        this.t = CategoryFrame.r;
    };
    CategoryFrame.$t = markType(CategoryFrame, 'CategoryFrame', Frame.$);
    CategoryFrame.r = 0;
    return CategoryFrame;
}(Frame));
export { CategoryFrame };
