/*
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 { IFlattener_$type } from "./IFlattener";
import { Base, Number_$type, Point_$type, markType } from "igniteui-react-core/ES2015/type";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { Flattener } from "igniteui-react-core/ES2015/Flattener";
import { FastFlattener } from "igniteui-react-core/ES2015/FastFlattener";
import { RearrangedList$1 } from "igniteui-react-core/ES2015/RearrangedList$1";
export class DefaultFlattener extends Base {
    a(a, b, c, d, e, f) {
        let g = new List$1(Number_$type, 0);
        let h = d;
        let i = e;
        let j = i - h + 1;
        while (j > 0) {
            if (j <= 512) {
                Flattener.c(g, b, c, h, i, f);
                h = i + 1;
            }
            else {
                let k = h + 512 - 1;
                Flattener.c(g, b, c, h, k, f);
                h = k + 1;
            }
            j = i - h + 1;
        }
        return g;
    }
    d(a, b, c, d, e) {
        let f = new List$1(Number_$type, 0);
        let g = c;
        let h = d;
        let i = h - g + 1;
        while (i > 0) {
            if (i <= 512) {
                FastFlattener.e(f, a, b, g, h, e);
                g = h + 1;
            }
            else {
                let j = g + 512 - 1;
                FastFlattener.e(f, a, b, g, j, e);
                g = j + 1;
            }
            i = h - g + 1;
        }
        return f;
    }
    flatten(a, b) {
        let c = (d) => this.f(a, d);
        let d = (e) => this.g(a, e);
        return this.b(a, b, c, d);
    }
    c(a, b, c, d) {
        return this.e(a, b, c, d);
    }
    b(a, b, c, d) {
        let e = this.a(new List$1(Number_$type, 0), c, d, 0, a.count - 1, b);
        let f = new RearrangedList$1(Point_$type, a, e);
        return f;
    }
    e(a, b, c, d) {
        let e = this.d(a, b, 0, c - 1, d);
        let f = new List$1(Point_$type, 0);
        for (let g = 0; g < e.count; g++) {
            f.add({ $type: Point_$type, x: a[e._inner[g]], y: b[e._inner[g]] });
        }
        return f;
    }
    f(a, b) {
        return a.item(b).x;
    }
    g(a, b) {
        return a.item(b).y;
    }
}
DefaultFlattener.$t = markType(DefaultFlattener, 'DefaultFlattener', Base.$, [IFlattener_$type]);
