/*
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 { 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
 */
export let CategoryFrame = /*@__PURE__*/ (() => {
    class CategoryFrame extends Frame {
        constructor(a) {
            super();
            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();
        }
        c(a, b, c) {
            this.z();
            let d = typeCast(CategoryFrame.$, b);
            let e = typeCast(CategoryFrame.$, c);
            let f = d.h.count;
            let g = e.h.count;
            let h = Math.max(f, g);
            let i = Math.max(d.p.count, e.p.count);
            let j = Math.max(d.s.count, e.s.count);
            let k = Math.max(d.m.count, e.m.count);
            let l = Math.max(d.k.count, e.k.count);
            let m = d.r.count > 0;
            if (m) {
                this.aa(this.r, a, d.r, e.r, h);
            }
            let n = d.q.count > 0;
            if (n) {
                this.aa(this.q, a, d.q, e.q, i);
            }
            let o = d.t.count > 0;
            if (o) {
                this.aa(this.t, a, d.t, e.t, j);
            }
            let p = d.n.count > 0;
            if (p) {
                this.aa(this.n, a, d.n, e.n, k);
            }
            let 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) {
                let r = 0;
                for (let s = 0; s < Math.min(f, g); ++s) {
                    let t = this.h._inner[s];
                    r = a * this.r._inner[s];
                    r = r > 1 ? 1 : r;
                    for (let 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 (let v = 0; v < Math.min(f, g); ++v) {
                    let w = this.h._inner[v];
                    for (let 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) {
                let y = new Array(this.v);
                for (let z = this.v - 1; z >= 0; --z) {
                    y[z] = d.h.count > 0 ? d.h._inner[d.h.count - 1][z] : 0;
                }
                if (m) {
                    let aa = 0;
                    for (let ab = f; ab < g; ++ab) {
                        let ac = this.h._inner[ab];
                        aa = a * this.r._inner[ab];
                        aa = aa > 1 ? 1 : aa;
                        for (let ad = this.v - 1; ad >= 0; --ad) {
                            ac[ad] = y[ad] + aa * (e.h._inner[ab][ad] - y[ad]);
                        }
                    }
                }
                else {
                    for (let ae = f; ae < g; ++ae) {
                        let af = this.h._inner[ae];
                        for (let ag = this.v - 1; ag >= 0; --ag) {
                            af[ag] = y[ag] + a * (e.h._inner[ae][ag] - y[ag]);
                        }
                    }
                }
            }
            if (f > g) {
                let ah = new Array(this.v);
                for (let ai = this.v - 1; ai >= 0; --ai) {
                    ah[ai] = e.h.count > 0 ? e.h._inner[e.h.count - 1][ai] : 0;
                }
                if (m) {
                    let aj = 0;
                    for (let ak = g; ak < f; ++ak) {
                        let al = this.h._inner[ak];
                        aj = a * this.r._inner[ak];
                        aj = aj > 1 ? 1 : aj;
                        for (let am = this.v - 1; am >= 0; --am) {
                            al[am] = d.h._inner[ak][am] + aj * (ah[am] - d.h._inner[ak][am]);
                        }
                    }
                }
                else {
                    for (let an = g; an < f; ++an) {
                        let ao = this.h._inner[an];
                        for (let 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);
                }
            }
            let aq = d.ad;
            let ar = e.ad;
            if (Rect.l_op_Equality(aq, null)) {
                aq = this.ac;
            }
            if (Rect.l_op_Equality(ar, null)) {
                ar = this.ac;
            }
            let as = aq.left + (ar.left - aq.left) * a;
            let at = aq.top + (ar.top - aq.top) * a;
            let au = Math.max(0, aq.width + (ar.width - aq.width) * a);
            let av = Math.max(0, aq.height + (ar.height - aq.height) * a);
            this.ad = new Rect(0, as, at, au, av);
            let aw = Math.max(Math.max(d.f.count, e.f.count), this.f.count);
            for (let ax = 0; ax < aw; ax++) {
                let ay = null;
                if (this.f.count <= ax) {
                    ay = new List$1(Point_$type, 0);
                    this.f.add(ay);
                }
                else {
                    ay = this.f._inner[ax];
                }
                let az = null;
                if (d.f.count <= ax) {
                    az = new List$1(Point_$type, 0);
                    d.f.add(az);
                }
                else {
                    az = d.f._inner[ax];
                }
                let a0 = null;
                if (e.f.count <= ax) {
                    a0 = new List$1(Point_$type, 0);
                    e.f.add(a0);
                }
                else {
                    a0 = e.f._inner[ax];
                }
                let a1 = null;
                if (this.g.count <= ax) {
                    a1 = new List$1(Number_$type, 0);
                    this.g.add(a1);
                }
                else {
                    a1 = this.g._inner[ax];
                }
                let a2 = null;
                if (d.g.count <= ax) {
                    a2 = new List$1(Number_$type, 0);
                    d.g.add(a2);
                }
                else {
                    a2 = d.g._inner[ax];
                }
                let a3 = null;
                if (e.g.count <= ax) {
                    a3 = new List$1(Number_$type, 0);
                    e.g.add(a3);
                }
                else {
                    a3 = e.g._inner[ax];
                }
                let a4 = Math.max(az.count, a0.count);
                let 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);
                }
            }
        }
        aa(a, b, c, d, e) {
            if (d.count == 0) {
                for (let f = 0; f < c.count; f++) {
                    d.add(c._inner[f]);
                }
            }
            else {
                Frame.b(a, b, c, d);
            }
            if (a.count < e) {
                let g = a.count;
                for (let h = 0; h < e - g; h++) {
                    a.add(1);
                }
            }
        }
        y() {
            this.r.clear();
            this.t.clear();
            this.q.clear();
            this.n.clear();
            this.l.clear();
            this.g.clear();
        }
        x() {
            this.z();
            this.y();
            this.ad = this.ac;
        }
        ab() {
            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();
        }
        z() {
            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;
})();
