/*
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 { Base, String_$type, markType } from "./type";
import { ISummaryResult_$type } from "./ISummaryResult";
import { List$1 } from "./List$1";
import { Dictionary$2 } from "./Dictionary$2";
/**
 * @hidden
 */
export let SectionData = /*@__PURE__*/ (() => {
    class SectionData extends Base {
        constructor() {
            super(...arguments);
            this.o = false;
            this.ae = 0;
            this.af = 0;
            this.ad = 0;
            this.e = null;
            this.f = null;
            this.i = null;
            this.h = null;
            this.g = null;
            this.aa = 0;
            this.ah = 0;
            this.ag = 0;
            this.t = 0;
            this.d = null;
            this.u = 0;
            this.b = null;
            this.s = -1;
            this.c = null;
            this.a = null;
            this.y = 0;
            this.l = true;
            this.k = null;
        }
        get z() {
            return this.s;
        }
        set z(a) {
            this.s = a;
        }
        get ac() {
            return this.af + this.y + this.ah - this.t;
        }
        get ab() {
            return this.ac + this.d[this.d.length - 1] - 1;
        }
        get p() {
            if (!this.q) {
                return false;
            }
            let a = this.w();
            for (let b = a; b < this.c.length; b++) {
                if (!this.c[b]) {
                    return false;
                }
            }
            return true;
        }
        get q() {
            return this.l;
        }
        set q(a) {
            this.l = a;
        }
        ai(a, b) {
            this.aj(a, b, this.e.length);
        }
        aj(a, b, c) {
            switch (a) {
                case 0:
                    this.c = new Array(1);
                    this.a = new Array(1);
                    break;
                case 1:
                    this.c = new Array(c);
                    this.a = new Array(c);
                    break;
            }
            for (let d = 0; d < this.c.length; d++) {
                this.c[d] = b;
            }
        }
        static r(a) {
            let b = new List$1(Dictionary$2.$.specialize(String_$type, ISummaryResult_$type), 0);
            if (a != null) {
                for (let c = 0; c < a.length; c++) {
                    if (a[c] == null) {
                        continue;
                    }
                    if (!a[c].shouldDisplay) {
                        continue;
                    }
                    if (b.count == 0) {
                        b.add(new Dictionary$2(String_$type, ISummaryResult_$type, 0));
                    }
                    for (let d = 0; d < b.count; d++) {
                        if (!b._inner[d].containsKey(a[c].propertyName)) {
                            b._inner[d].addItem(a[c].propertyName, a[c]);
                            break;
                        }
                        else if (d == b.count - 1) {
                            b.add(new Dictionary$2(String_$type, ISummaryResult_$type, 0));
                        }
                    }
                }
            }
            return b;
        }
        j(a) {
            let b = this.v();
            if (a >= this.af && a < this.af + b) {
                return 1;
            }
            if (a >= this.af + b && a < this.af + b + this.ah) {
                return 5;
            }
            if (a > this.ad - this.u - this.ag && a <= this.ad - this.u) {
                return 5;
            }
            if (a > this.ad - this.u && a <= this.ad) {
                return 2;
            }
            return 0;
        }
        x(a) {
            let b = this.v();
            let c = -1;
            if (a >= this.af + b && a < this.af + b + this.ah) {
                c = a - (this.af + b);
            }
            if (a > this.ad - this.u - this.ag && a <= this.ad - this.u) {
                c = a - (this.ad - this.u - this.ag + 1);
            }
            return c;
        }
        v() {
            let a = 0;
            if (this.a != null) {
                for (let b = 0; b < this.a.length; b++) {
                    if (this.a[b] != null) {
                        a++;
                    }
                }
            }
            return a;
        }
        w() {
            if (this.a != null) {
                for (let a = 0; a < this.a.length; a++) {
                    if (this.a[a] != null) {
                        return a;
                    }
                }
            }
            return 0;
        }
        m() {
            return this.d[this.d.length - 1] > 0;
        }
        am(a) {
            for (let b = 0; b < this.g.length; b++) {
                if (this.g[b] == null) {
                    continue;
                }
                let c = this.i[b];
                let d = SectionData.r(c);
                for (let e = 0; e < d.count; e++) {
                    let f = new Array(d._inner[e].count);
                    d._inner[e].values.copyTo(f, 0);
                    this.g[b].a[e].summaryResults = f;
                    if (a != null) {
                        a(this.g[b].a[e]);
                    }
                }
            }
        }
        ak(a, b) {
            if (a == null || a.rowType != 5) {
                return;
            }
            if (b < 0 && b >= this.g[a.level - 1].a.length) {
                return;
            }
            this.g[a.level - 1].a[b] = a;
        }
        n() {
            for (let a = 0; a < this.g.length; a++) {
                if (this.g[a] != null) {
                    for (let b = 0; b < this.g[a].a.length; b++) {
                        if (this.g[a].a[b] != null) {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
        an(a, b, c) {
            c.summaryIndex = b;
            this.i[a][b] = c;
            if (this.o && this.k != null) {
                this.k.i[a][b] = c;
            }
        }
        al(a, b) {
            for (let c = a - 1; c >= 0; c--) {
                if (this.h[c] != -1) {
                    this.h[c] += b;
                }
            }
        }
    }
    SectionData.$t = markType(SectionData, 'SectionData');
    return SectionData;
})();
